diff --git a/reactos/win32ss/gdi/ntgdi/device.c b/reactos/win32ss/gdi/ntgdi/device.c index a54acdeda34..3740bea2108 100644 --- a/reactos/win32ss/gdi/ntgdi/device.c +++ b/reactos/win32ss/gdi/ntgdi/device.c @@ -57,7 +57,7 @@ IntCreatePrimarySurface(VOID) DPRINT1("No DESKTOP Window!!!!!\n"); } } - co_IntShowDesktop(rpDesk, SurfSize.cx, SurfSize.cy); + co_IntShowDesktop(rpDesk, SurfSize.cx, SurfSize.cy, TRUE); // Init Primary Displays Device Capabilities. PDEVOBJ_vGetDeviceCaps(gppdevPrimary, &GdiHandleTable->DevCaps); diff --git a/reactos/win32ss/user/ntuser/desktop.c b/reactos/win32ss/user/ntuser/desktop.c index c67f9933ea4..dfa993ea9f8 100644 --- a/reactos/win32ss/user/ntuser/desktop.c +++ b/reactos/win32ss/user/ntuser/desktop.c @@ -647,7 +647,19 @@ DesktopWindowProc(PWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam, LRESULT *lRe { UserDereferenceObject(pcurOld); } + return TRUE; } + + case WM_WINDOWPOSCHANGING: + { + PWINDOWPOS pWindowPos = (PWINDOWPOS)lParam; + if((pWindowPos->flags & SWP_SHOWWINDOW) != 0) + { + HDESK hdesk = IntGetDesktopObjectHandle(gpdeskInputDesktop); + IntSetThreadDesktop(hdesk, FALSE); + } + } + } return TRUE; /* We are done. Do not do any callbacks to user mode */ } @@ -737,20 +749,20 @@ UserRedrawDesktop() NTSTATUS FASTCALL -co_IntShowDesktop(PDESKTOP Desktop, ULONG Width, ULONG Height) +co_IntShowDesktop(PDESKTOP Desktop, ULONG Width, ULONG Height, BOOL bRedraw) { - PWND Window; + PWND pwnd = Desktop->pDeskInfo->spwnd; + UINT flags = SWP_NOACTIVATE|SWP_NOZORDER|SWP_SHOWWINDOW; + ASSERT(pwnd); - Window = IntGetWindowObject(Desktop->DesktopWindow); + if(!bRedraw) + flags |= SWP_NOREDRAW; - if (!Window) - { - ERR("No Desktop window.\n"); - return STATUS_UNSUCCESSFUL; - } - co_WinPosSetWindowPos(Window, NULL, 0, 0, Width, Height, SWP_NOACTIVATE|SWP_NOZORDER|SWP_SHOWWINDOW); + co_WinPosSetWindowPos(pwnd, NULL, 0, 0, Width, Height, flags); + + if(bRedraw) + co_UserRedrawWindow( pwnd, NULL, 0, RDW_UPDATENOW | RDW_ALLCHILDREN | RDW_INVALIDATE ); - co_UserRedrawWindow( Window, NULL, 0, RDW_UPDATENOW | RDW_ALLCHILDREN); return STATUS_SUCCESS; } @@ -1607,6 +1619,7 @@ NtUserSwitchDesktop(HDESK hdesk) { PDESKTOP pdesk; NTSTATUS Status; + BOOL bRedrawDesktop; DECLARE_RETURN(BOOL); UserEnterExclusive(); @@ -1619,6 +1632,12 @@ NtUserSwitchDesktop(HDESK hdesk) RETURN(FALSE); } + if(pdesk == gpdeskInputDesktop) + { + WARN("NtUserSwitchDesktop called for active desktop\n"); + RETURN(TRUE); + } + /* * Don't allow applications switch the desktop if it's locked, unless the caller * is the logon application itself @@ -1642,11 +1661,29 @@ NtUserSwitchDesktop(HDESK hdesk) desktop such as Winlogon or Screen-Saver */ /* FIXME: Connect to input device */ + TRACE("Switching from desktop 0x%p to 0x%p\n", gpdeskInputDesktop, pdesk); + + bRedrawDesktop = FALSE; + + /* The first time SwitchDesktop is called, gpdeskInputDesktop is NULL */ + if(gpdeskInputDesktop != NULL) + { + if((gpdeskInputDesktop->pDeskInfo->spwnd->style & WS_VISIBLE) == WS_VISIBLE) + bRedrawDesktop = TRUE; + + /* Hide the previous desktop window */ + IntHideDesktop(gpdeskInputDesktop); + } + /* Set the active desktop in the desktop's window station. */ InputWindowStation->ActiveDesktop = pdesk; /* Set the global state. */ gpdeskInputDesktop = pdesk; + + /* Show the new desktop window */ + co_IntShowDesktop(pdesk, UserGetSystemMetrics(SM_CXSCREEN), UserGetSystemMetrics(SM_CYSCREEN), bRedrawDesktop); + TRACE("SwitchDesktop gpdeskInputDesktop 0x%p\n",gpdeskInputDesktop); ObDereferenceObject(pdesk); diff --git a/reactos/win32ss/user/ntuser/desktop.h b/reactos/win32ss/user/ntuser/desktop.h index 6f492117dc0..672303eee05 100644 --- a/reactos/win32ss/user/ntuser/desktop.h +++ b/reactos/win32ss/user/ntuser/desktop.h @@ -132,7 +132,7 @@ PDESKTOP FASTCALL IntGetActiveDesktop(VOID); NTSTATUS FASTCALL -co_IntShowDesktop(PDESKTOP Desktop, ULONG Width, ULONG Height); +co_IntShowDesktop(PDESKTOP Desktop, ULONG Width, ULONG Height, BOOL Redraw); NTSTATUS FASTCALL IntHideDesktop(PDESKTOP Desktop);