diff --git a/reactos/dll/win32/user32/windows/window.c b/reactos/dll/win32/user32/windows/window.c index 40d55c92849..604eb6a3163 100644 --- a/reactos/dll/win32/user32/windows/window.c +++ b/reactos/dll/win32/user32/windows/window.c @@ -1,5 +1,4 @@ -/* $Id$ - * +/* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS user32.dll * FILE: lib/user32/windows/window.c @@ -916,21 +915,21 @@ GetGUIThreadInfo(DWORD idThread, /* - * @unimplemented + * @implemented */ HWND STDCALL GetLastActivePopup(HWND hWnd) { - PWINDOW Wnd, WndParent; - HWND Ret = NULL; - WARN("Not fully implemented!"); + PWINDOW Wnd; + HWND Ret = hWnd; + Wnd = ValidateHwnd(hWnd); if (Wnd != NULL) { _SEH_TRY { - WndParent = NULL; - Ret = hWnd; + if (Wnd->hWndLastActive) + Ret = Wnd->hWndLastActive; } _SEH_HANDLE { diff --git a/reactos/include/reactos/win32k/ntuser.h b/reactos/include/reactos/win32k/ntuser.h index 3a5840fbceb..660aca6dae4 100644 --- a/reactos/include/reactos/win32k/ntuser.h +++ b/reactos/include/reactos/win32k/ntuser.h @@ -154,6 +154,8 @@ typedef struct _WINDOW /* Context help id */ DWORD ContextHelpId; + HWND hWndLastActive; + struct { RECT NormalRect; diff --git a/reactos/subsystems/win32/win32k/ntuser/focus.c b/reactos/subsystems/win32/win32k/ntuser/focus.c index 655bc2a4ea8..4bb9c655db3 100644 --- a/reactos/subsystems/win32/win32k/ntuser/focus.c +++ b/reactos/subsystems/win32/win32k/ntuser/focus.c @@ -16,7 +16,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id$ */ #include @@ -85,17 +84,12 @@ co_IntSendActivateMessages(HWND hWndPrev, HWND hWnd, BOOL MouseActivate) co_IntShellHookNotify(HSHELL_WINDOWACTIVATED, (LPARAM) hWnd); } - UserDerefObjectCo(Window); - - /* FIXME: IntIsWindow */ - - CHECKPOINT; - co_IntPostOrSendMessage(hWnd, WM_NCACTIVATE, (WPARAM)(hWnd == UserGetForegroundWindow()), 0); - /* FIXME: WA_CLICKACTIVE */ - co_IntPostOrSendMessage(hWnd, WM_ACTIVATE, - MAKEWPARAM(MouseActivate ? WA_CLICKACTIVE : WA_ACTIVE, - UserGetWindowLong(hWnd, GWL_STYLE, FALSE) & WS_MINIMIZE), - (LPARAM)hWndPrev); + if (Window->Wnd) + { // Set last active for window and it's owner. + Window->Wnd->hWndLastActive = hWnd; + if (Window->Wnd->Owner) + Window->Wnd->Owner->hWndLastActive = hWnd; + } if (Window && hWndPrev) { @@ -133,6 +127,18 @@ co_IntSendActivateMessages(HWND hWndPrev, HWND hWnd, BOOL MouseActivate) } } } + + UserDerefObjectCo(Window); + + /* FIXME: IntIsWindow */ + + CHECKPOINT; + co_IntPostOrSendMessage(hWnd, WM_NCACTIVATE, (WPARAM)(hWnd == UserGetForegroundWindow()), 0); + /* FIXME: WA_CLICKACTIVE */ + co_IntPostOrSendMessage(hWnd, WM_ACTIVATE, + MAKEWPARAM(MouseActivate ? WA_CLICKACTIVE : WA_ACTIVE, + UserGetWindowLong(hWnd, GWL_STYLE, FALSE) & WS_MINIMIZE), + (LPARAM)hWndPrev); } } diff --git a/reactos/subsystems/win32/win32k/ntuser/windc.c b/reactos/subsystems/win32/win32k/ntuser/windc.c index 69094388d83..24f4955d26b 100644 --- a/reactos/subsystems/win32/win32k/ntuser/windc.c +++ b/reactos/subsystems/win32/win32k/ntuser/windc.c @@ -220,16 +220,6 @@ DceReleaseDC(DCE* dce, BOOL EndPaint) dce->DCXFlags |= DCX_DCEEMPTY; } } - else - { // Save Users Dc_Attr. - PDC dc = DC_LockDc(dce->hDC); - if(dc) - { - PDC_ATTR Dc_Attr = dc->pDc_Attr; - if(Dc_Attr) MmCopyFromCaller(&dc->Dc_Attr, Dc_Attr, sizeof(DC_ATTR)); - DC_UnlockDc(dc); - } - } dce->DCXFlags &= ~DCX_DCEBUSY; DPRINT("Exit!!!!! DCX_CACHE!!!!!! hDC-> %x \n", dce->hDC); if (!IntGdiSetDCOwnerEx( dce->hDC, GDI_OBJ_HMGR_NONE, FALSE)) @@ -427,17 +417,8 @@ UserGetDCEx(PWINDOW_OBJECT Window OPTIONAL, HANDLE ClipRegion, ULONG Flags) // Window nz, check to see if we still own this or it is just cheap wine tonight. if (!(Flags & DCX_CACHE)) { - if ( Wnd->ti != GetW32ThreadInfo()) Flags |= DCX_CACHE; // Ah~ Not Powned! Forced to be cheap~ - // Can only have one POWNED or CLASS. - if ( !Window->Dce && (Wnd->Class->Style & CS_OWNDC)) - Window->Dce = DceAllocDCE(NULL, DCE_WINDOW_DC); - else - Flags |= DCX_CACHE; - - if ( !Wnd->Class->Dce && (Wnd->Class->Style & CS_CLASSDC)) - Wnd->Class->Dce = DceAllocDCE(NULL, DCE_CLASS_DC); - else - Flags |= DCX_CACHE; + if ( Wnd->ti != GetW32ThreadInfo()) + Flags |= DCX_CACHE; // Ah~ Not Powned! Forced to be cheap~ } DcxFlags = Flags & DCX_CACHECOMPAREMASK; @@ -455,7 +436,10 @@ UserGetDCEx(PWINDOW_OBJECT Window OPTIONAL, HANDLE ClipRegion, ULONG Flags) // Need to test for null here. Not sure if this is a bug or a feature. // First time use hax, need to use DceAllocDCE during window display init. if (!Dce) break; - +// +// The way I understand this, you can have more than one DC per window. +// Only one Owned if one was requested and saved and one Cached. +// if ((Dce->DCXFlags & (DCX_CACHE | DCX_DCEBUSY)) == DCX_CACHE) { DceUnused = Dce; @@ -469,7 +453,6 @@ UserGetDCEx(PWINDOW_OBJECT Window OPTIONAL, HANDLE ClipRegion, ULONG Flags) #if 0 /* FIXME */ UpdateVisRgn = FALSE; #endif - UpdateClipOrigin = TRUE; break; } @@ -531,8 +514,6 @@ UserGetDCEx(PWINDOW_OBJECT Window OPTIONAL, HANDLE ClipRegion, ULONG Flags) /* FIXME: Handle error */ } - Dce->DCXFlags = Flags | DCX_DCEBUSY; - if (!(Flags & (DCX_EXCLUDERGN | DCX_INTERSECTRGN)) && ClipRegion) { if (!(Flags & DCX_KEEPCLIPRGN)) @@ -547,6 +528,8 @@ UserGetDCEx(PWINDOW_OBJECT Window OPTIONAL, HANDLE ClipRegion, ULONG Flags) } #endif + Dce->DCXFlags = Flags | DCX_DCEBUSY; + if (0 != (Flags & DCX_INTERSECTUPDATE) && NULL == ClipRegion) { Flags |= DCX_INTERSECTRGN | DCX_KEEPCLIPRGN; diff --git a/reactos/subsystems/win32/win32k/ntuser/window.c b/reactos/subsystems/win32/win32k/ntuser/window.c index abad9a28c40..7c682821f80 100644 --- a/reactos/subsystems/win32/win32k/ntuser/window.c +++ b/reactos/subsystems/win32/win32k/ntuser/window.c @@ -1627,6 +1627,7 @@ co_IntCreateWindowEx(DWORD dwExStyle, Wnd->ti = ti; Wnd->pi = ti->kpi; + Wnd->hWndLastActive = hWnd; } DPRINT("Created object with handle %X\n", hWnd);