Author: weiden Date: Fri May 9 20:45:08 2008 New Revision: 33401
URL: http://svn.reactos.org/svn/reactos?rev=33401&view=rev Log: Fix some task switch window bugs
Modified: trunk/reactos/base/shell/explorer-new/dragdrop.c trunk/reactos/base/shell/explorer-new/taskswnd.c trunk/reactos/base/shell/explorer-new/tbsite.c trunk/reactos/base/shell/explorer-new/todo.h trunk/reactos/base/shell/explorer-new/trayntfy.c trunk/reactos/base/shell/explorer-new/traywnd.c
Modified: trunk/reactos/base/shell/explorer-new/dragdrop.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/explorer-new/dra... ============================================================================== --- trunk/reactos/base/shell/explorer-new/dragdrop.c [iso-8859-1] (original) +++ trunk/reactos/base/shell/explorer-new/dragdrop.c [iso-8859-1] Fri May 9 20:45:08 2008 @@ -217,7 +217,7 @@ hr = IDropTargetHelper_DragEnter(This->DropTargetHelper, This->hwndTarget, pDataObject, - &pt, + (POINT *)&pt, *pdwEffect);
if (SUCCEEDED(hr)) @@ -274,7 +274,7 @@ HRESULT hr;
hr = IDropTargetHelper_DragOver(This->DropTargetHelper, - &pt, + (POINT *)&pt, *pdwEffect);
if (SUCCEEDED(hr)) @@ -350,7 +350,7 @@
hr = IDropTargetHelper_Drop(This->DropTargetHelper, pDataObject, - &pt, + (POINT *)&pt, *pdwEffect);
if (SUCCEEDED(hr) && This->CanDrop)
Modified: trunk/reactos/base/shell/explorer-new/taskswnd.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/explorer-new/tas... ============================================================================== --- trunk/reactos/base/shell/explorer-new/taskswnd.c [iso-8859-1] (original) +++ trunk/reactos/base/shell/explorer-new/taskswnd.c [iso-8859-1] Fri May 9 20:45:08 2008 @@ -26,7 +26,7 @@
/* Set DUMP_TASKS to 1 to enable a dump of the tasks and task groups every 5 seconds */ -#define DUMP_TASKS 0 +#define DUMP_TASKS 1
static const TCHAR szTaskSwitchWndClass[] = TEXT("MSTaskSwWClass"); static const TCHAR szRunningApps[] = TEXT("Running Applications"); @@ -135,17 +135,6 @@ #define TSW_TOOLBAR_SUBCLASS_ID 1
#define MAX_TASKS_COUNT (0x7FFF) - -#define MAKE_TASKITEM_PTR(ti) ((DWORD_PTR)ti) -#define MAKE_TASKGROUP_PTR(tg) (((DWORD_PTR)tg) | 1) -#define IS_TASKGROUP_PTR(p) ((((DWORD_PTR)p) & 1) != 0) -#define GET_TASKITEM_PTR(lp) ((PTASK_ITEM)(((DWORD_PTR)lp) & ~1)) -#define GET_TASKGROUP_PTR(lp) ((PTASK_GROUP)(((DWORD_PTR)lp) & ~1)) - -#define MAKE_TASKITEM_CMD_ID(id) ((INT)(id)) -#define MAKE_TASKGROUP_CMD_ID(id) ((INT)(id) | (1 << 15)) -#define IS_TASKGROUP_CMD_ID(id) ((((INT)(id)) & (1 << 15)) != 0) -#define GET_INDEX_FROM_CMD_ID(id) ((INT)(id) & MAX_TASKS_COUNT)
static VOID TaskSwitchWnd_UpdateButtonsSize(IN OUT PTASK_SWITCH_WND This, IN BOOL bRedrawDisabled); @@ -286,7 +275,7 @@ NewIndex = CurrentGroup->Index + 1; if (TaskSwitchWnd_SetToolbarButtonCommandId(This, CurrentGroup->Index + 1, - MAKE_TASKGROUP_CMD_ID(NewIndex))) + NewIndex)) { CurrentGroup->Index = NewIndex; } @@ -319,7 +308,7 @@ NewIndex = CurrentTaskItem->Index + 1; if (TaskSwitchWnd_SetToolbarButtonCommandId(This, CurrentTaskItem->Index + 1, - MAKE_TASKITEM_CMD_ID(NewIndex))) + NewIndex)) { CurrentTaskItem->Index = NewIndex; } @@ -352,7 +341,7 @@ NewIndex = CurrentGroup->Index - 1; if (TaskSwitchWnd_SetToolbarButtonCommandId(This, CurrentGroup->Index - 1, - MAKE_TASKGROUP_CMD_ID(NewIndex))) + NewIndex)) { CurrentGroup->Index = NewIndex; } @@ -385,7 +374,7 @@ NewIndex = CurrentTaskItem->Index - 1; if (TaskSwitchWnd_SetToolbarButtonCommandId(This, CurrentTaskItem->Index - 1, - MAKE_TASKITEM_CMD_ID(NewIndex))) + NewIndex)) { CurrentTaskItem->Index = NewIndex; } @@ -570,7 +559,7 @@ tbBtn.iBitmap = 0; tbBtn.fsState = TBSTATE_ENABLED | TBSTATE_ELLIPSES; tbBtn.fsStyle = BTNS_CHECK | BTNS_NOPREFIX | BTNS_SHOWTEXT; - tbBtn.dwData = MAKE_TASKITEM_PTR(TaskItem); + tbBtn.dwData = TaskItem->Index;
tbBtn.iString = (DWORD_PTR)TaskSwitchWnd_GetWndTextFromTaskItem(This, TaskItem); @@ -579,7 +568,7 @@ iIndex = TaskSwitchWnd_CalculateTaskItemNewButtonIndex(This, TaskItem); ASSERT(iIndex >= 0); - tbBtn.idCommand = MAKE_TASKITEM_CMD_ID(iIndex); + tbBtn.idCommand = iIndex;
TaskSwitchWnd_BeginUpdate(This);
@@ -719,6 +708,7 @@ }
/* Remove the group from the list */ + ASSERT(TaskGroup == CurrentGroup); *PrevLink = TaskGroup->Next;
/* Free the task group */ @@ -819,39 +809,44 @@ return NULL; }
- if (This->AllocatedTaskItems <= This->TaskItemCount) - { - if (This->TaskItemCount != 0) - { - PTASK_ITEM NewArray; - WORD NewArrayLength; - - NewArrayLength = This->AllocatedTaskItems + TASK_ITEM_ARRAY_ALLOC; - - NewArray = HeapReAlloc(hProcessHeap, - 0, - This->TaskItems, - NewArrayLength * sizeof(*This->TaskItems)); - if (NewArray != NULL) - { - This->AllocatedTaskItems = NewArrayLength; - This->TaskItems = NewArray; - } - else - return NULL; + ASSERT(This->AllocatedTaskItems >= This->TaskItemCount); + + if (This->TaskItemCount != 0) + { + PTASK_ITEM NewArray; + SIZE_T NewArrayLength, ActiveTaskItemIndex; + + NewArrayLength = This->AllocatedTaskItems + TASK_ITEM_ARRAY_ALLOC; + + NewArray = HeapReAlloc(hProcessHeap, + 0, + This->TaskItems, + NewArrayLength * sizeof(*This->TaskItems)); + if (NewArray != NULL) + { + if (This->ActiveTaskItem != NULL) + { + /* Fixup the ActiveTaskItem pointer */ + ActiveTaskItemIndex = This->ActiveTaskItem - This->TaskItems; + This->ActiveTaskItem = NewArray + ActiveTaskItemIndex; + } + This->AllocatedTaskItems = (WORD)NewArrayLength; + This->TaskItems = NewArray; } else - { - This->TaskItems = HeapAlloc(hProcessHeap, - 0, - TASK_ITEM_ARRAY_ALLOC * sizeof(*This->TaskItems)); - if (This->TaskItems != NULL) - { - This->AllocatedTaskItems = TASK_ITEM_ARRAY_ALLOC; - } - else - return NULL; - } + return NULL; + } + else + { + This->TaskItems = HeapAlloc(hProcessHeap, + 0, + TASK_ITEM_ARRAY_ALLOC * sizeof(*This->TaskItems)); + if (This->TaskItems != NULL) + { + This->AllocatedTaskItems = TASK_ITEM_ARRAY_ALLOC; + } + else + return NULL; }
return This->TaskItems + This->TaskItemCount++; @@ -964,6 +959,43 @@ } }
+static PTASK_ITEM +FindTaskItemByIndex(IN OUT PTASK_SWITCH_WND This, + IN INT Index) +{ + PTASK_ITEM TaskItem, LastItem; + + TaskItem = This->TaskItems; + LastItem = TaskItem + This->TaskItemCount; + while (TaskItem != LastItem) + { + if (TaskItem->Index == Index) + return TaskItem; + + TaskItem++; + } + + return NULL; +} + +static PTASK_GROUP +FindTaskGroupByIndex(IN OUT PTASK_SWITCH_WND This, + IN INT Index) +{ + PTASK_GROUP CurrentGroup; + + CurrentGroup = This->TaskGroups; + while (CurrentGroup != NULL) + { + if (CurrentGroup->Index == Index) + break; + + CurrentGroup = CurrentGroup->Next; + } + + return CurrentGroup; +} + static BOOL TaskSwitchWnd_AddTask(IN OUT PTASK_SWITCH_WND This, IN HWND hWnd) @@ -1211,9 +1243,9 @@
uiMin = GetSystemMetrics(SM_CXSIZE) + (2 * GetSystemMetrics(SM_CXEDGE));
- if (NewBtnSize < uiMin) + if (NewBtnSize < (LONG)uiMin) NewBtnSize = uiMin; - if (NewBtnSize > uiMax) + if (NewBtnSize > (LONG)uiMax) NewBtnSize = uiMax;
This->ButtonSize.cx = NewBtnSize; @@ -1392,7 +1424,7 @@
/* Register the shell hook */ This->ShellHookMsg = RegisterWindowMessage(TEXT("SHELLHOOK")); - hShell32 = LoadLibrary(TEXT("SHELL32.DLL")); + hShell32 = GetModuleHandle(TEXT("SHELL32.DLL")); if (hShell32 != NULL) { REGSHELLHOOK RegShellHook; @@ -1405,8 +1437,6 @@ RegShellHook(This->hWnd, 3); /* 1 if no NT! We're targeting NT so we don't care! */ } - - FreeLibrary(hShell32); }
/* Add all windows to the toolbar */ @@ -1434,7 +1464,7 @@ This->IsDestroying = TRUE;
/* Unregister the shell hook */ - hShell32 = LoadLibrary(TEXT("SHELL32.DLL")); + hShell32 = GetModuleHandle(TEXT("SHELL32.DLL")); if (hShell32 != NULL) { REGSHELLHOOK RegShellHook; @@ -1447,8 +1477,6 @@ RegShellHook(This->hWnd, FALSE); } - - FreeLibrary(hShell32); }
TaskSwitchWnd_DeleteAllTasks(This); @@ -1604,16 +1632,21 @@ HFONT hCaptionFont, hBoldCaptionFont; LRESULT Ret = CDRF_DODEFAULT; HMODULE hUser32; + PTASK_GROUP TaskGroup; + PTASK_ITEM TaskItem;
#if TASK_USE_DRAWCAPTIONTEMP != 0
UINT uidctFlags = DC_TEXT | DC_ICON | DC_NOSENDMSG;
#endif - - if (!IS_TASKGROUP_PTR(nmtbcd->nmcd.lItemlParam)) - { - PTASK_ITEM TaskItem = GET_TASKITEM_PTR(nmtbcd->nmcd.lItemlParam); + TaskItem = FindTaskItemByIndex(This, + (INT)nmtbcd->nmcd.dwItemSpec); + TaskGroup = FindTaskGroupByIndex(This, + (INT)nmtbcd->nmcd.dwItemSpec); + if (TaskGroup == NULL && TaskItem != NULL) + { + ASSERT(TaskItem != NULL);
if (TaskItem != NULL && IsWindow(TaskItem->hWnd)) { @@ -1717,14 +1750,9 @@
} } - else - { - PTASK_GROUP TaskGroup = GET_TASKGROUP_PTR(nmtbcd->nmcd.lItemlParam); - - if (TaskGroup != NULL) - { - /* FIXME: Implement painting for task groups */ - } + else if (TaskGroup != NULL) + { + /* FIXME: Implement painting for task groups */ }
return Ret;
Modified: trunk/reactos/base/shell/explorer-new/tbsite.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/explorer-new/tbs... ============================================================================== --- trunk/reactos/base/shell/explorer-new/tbsite.c [iso-8859-1] (original) +++ trunk/reactos/base/shell/explorer-new/tbsite.c [iso-8859-1] Fri May 9 20:45:08 2008 @@ -202,10 +202,17 @@ if (SUCCEEDED(hRet)) { /* Now let's read the CLSID from the stream and see if it's our task band */ +#if defined(IStream_Read) hRet = IStream_Read(pStm, &clsid, sizeof(clsid), &ulRead); +#else + ulRead = sizeof(clsid); + hRet = IStream_Read(pStm, + &clsid, + sizeof(clsid)); +#endif if (SUCCEEDED(hRet) && ulRead == sizeof(clsid)) { if (IsEqualGUID(&clsid, @@ -350,7 +357,7 @@ shell behavior! */ if (This->WindowEventHandler != NULL) { - DbgPrint("Calling IWindowEventHandler::ProcessMessage(0x%p, 0x%x, 0x%p, 0x%p, 0x%p) This->hWndRebar=0x%p\n", hWnd, uMsg, wParam, lParam, plResult, This->hWndRebar); + /*DbgPrint("Calling IWindowEventHandler::ProcessMessage(0x%p, 0x%x, 0x%p, 0x%p, 0x%p) This->hWndRebar=0x%p\n", hWnd, uMsg, wParam, lParam, plResult, This->hWndRebar);*/ hRet = IWindowEventHandler_ProcessMessage(This->WindowEventHandler, hWnd, uMsg,
Modified: trunk/reactos/base/shell/explorer-new/todo.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/explorer-new/tod... ============================================================================== --- trunk/reactos/base/shell/explorer-new/todo.h [iso-8859-1] (original) +++ trunk/reactos/base/shell/explorer-new/todo.h [iso-8859-1] Fri May 9 20:45:08 2008 @@ -1,5 +1,9 @@ #ifndef __TODO_H #define __TODO_H + +#ifdef INTERFACE +#undef INTERFACE +#endif
/* FIXME: Ugly hack!!! FIX ASAP! Move to uuid! */ static const GUID IID_HACK_IShellView2 = {0x88E39E80,0x3578,0x11CF,{0xAE,0x69,0x08,0x00,0x2B,0x2E,0x12,0x62}};
Modified: trunk/reactos/base/shell/explorer-new/trayntfy.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/explorer-new/tra... ============================================================================== --- trunk/reactos/base/shell/explorer-new/trayntfy.c [iso-8859-1] (original) +++ trunk/reactos/base/shell/explorer-new/trayntfy.c [iso-8859-1] Fri May 9 20:45:08 2008 @@ -159,7 +159,7 @@ { if (Horizontal) { - if (szMax.cy + This->LineSizes[i].cy + This->LineSpacing > + if (szMax.cy + This->LineSizes[i].cy + (LONG)This->LineSpacing > pSize->cy - (2 * TRAY_CLOCK_WND_SPACING_Y)) { break;
Modified: trunk/reactos/base/shell/explorer-new/traywnd.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/explorer-new/tra... ============================================================================== --- trunk/reactos/base/shell/explorer-new/traywnd.c [iso-8859-1] (original) +++ trunk/reactos/base/shell/explorer-new/traywnd.c [iso-8859-1] Fri May 9 20:45:08 2008 @@ -1010,8 +1010,7 @@ sizeof(bmp), &bmp) != 0) { - Size.cx += max(bmp.bmWidth, - GetSystemMetrics(SM_CXMINIMIZED)); + Size.cx += bmp.bmWidth; Size.cy += max(bmp.bmHeight, GetSystemMetrics(SM_CYCAPTION)); }