* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* PURPOSE: Windows
- * FILE: subsystems/win32/win32k/ntuser/window.c
+ * FILE: win32ss/user/ntuser/winpos.c
* PROGRAMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
*/
#define SWP_EX_PAINTSELF 0x0002
#define SWP_AGG_NOGEOMETRYCHANGE \
- (SWP_NOSIZE | SWP_NOMOVE | SWP_NOCLIENTSIZE | SWP_NOCLIENTMOVE)
+ (SWP_NOSIZE | SWP_NOCLIENTSIZE | SWP_NOZORDER)
#define SWP_AGG_NOPOSCHANGE \
- (SWP_AGG_NOGEOMETRYCHANGE | SWP_NOZORDER)
+ (SWP_NOSIZE | SWP_NOMOVE | SWP_NOCLIENTSIZE | SWP_NOCLIENTMOVE | SWP_NOZORDER)
#define SWP_AGG_STATUSFLAGS \
(SWP_AGG_NOPOSCHANGE | SWP_FRAMECHANGED | SWP_HIDEWINDOW | SWP_SHOWWINDOW)
/* FUNCTIONS *****************************************************************/
+#if DBG
+/***********************************************************************
+ * dump_winpos_flags
+ */
+static void dump_winpos_flags(UINT flags)
+{
+ static const DWORD dumped_flags = (SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOREDRAW |
+ SWP_NOACTIVATE | SWP_FRAMECHANGED | SWP_SHOWWINDOW |
+ SWP_HIDEWINDOW | SWP_NOCOPYBITS | SWP_NOOWNERZORDER |
+ SWP_NOSENDCHANGING | SWP_DEFERERASE | SWP_ASYNCWINDOWPOS |
+ SWP_NOCLIENTSIZE | SWP_NOCLIENTMOVE | SWP_STATECHANGED);
+ TRACE("flags:");
+ if(flags & SWP_NOSIZE) TRACE(" SWP_NOSIZE");
+ if(flags & SWP_NOMOVE) TRACE(" SWP_NOMOVE");
+ if(flags & SWP_NOZORDER) TRACE(" SWP_NOZORDER");
+ if(flags & SWP_NOREDRAW) TRACE(" SWP_NOREDRAW");
+ if(flags & SWP_NOACTIVATE) TRACE(" SWP_NOACTIVATE");
+ if(flags & SWP_FRAMECHANGED) TRACE(" SWP_FRAMECHANGED");
+ if(flags & SWP_SHOWWINDOW) TRACE(" SWP_SHOWWINDOW");
+ if(flags & SWP_HIDEWINDOW) TRACE(" SWP_HIDEWINDOW");
+ if(flags & SWP_NOCOPYBITS) TRACE(" SWP_NOCOPYBITS");
+ if(flags & SWP_NOOWNERZORDER) TRACE(" SWP_NOOWNERZORDER");
+ if(flags & SWP_NOSENDCHANGING) TRACE(" SWP_NOSENDCHANGING");
+ if(flags & SWP_DEFERERASE) TRACE(" SWP_DEFERERASE");
+ if(flags & SWP_ASYNCWINDOWPOS) TRACE(" SWP_ASYNCWINDOWPOS");
+ if(flags & SWP_NOCLIENTSIZE) TRACE(" SWP_NOCLIENTSIZE");
+ if(flags & SWP_NOCLIENTMOVE) TRACE(" SWP_NOCLIENTMOVE");
+ if(flags & SWP_STATECHANGED) TRACE(" SWP_STATECHANGED");
+
+ if(flags & ~dumped_flags) TRACE(" %08x", flags & ~dumped_flags);
+ TRACE("\n");
+}
+#endif
+
BOOL FASTCALL
IntGetClientOrigin(PWND Window OPTIONAL, LPPOINT Point)
{
}
}
+BOOL FASTCALL
+IntGetWindowRect(PWND Wnd, RECTL *Rect)
+{
+ ASSERT( Wnd );
+ ASSERT( Rect );
+ if (!Wnd) return FALSE;
+ if ( Wnd != UserGetDesktopWindow()) // Wnd->fnid != FNID_DESKTOP )
+ {
+ *Rect = Wnd->rcWindow;
+ }
+ else
+ {
+ Rect->left = Rect->top = 0;
+ Rect->right = Wnd->rcWindow.right;
+ Rect->bottom = Wnd->rcWindow.bottom;
+/* Do this until Init bug is fixed. This sets 640x480, see InitMetrics.
+ Rect->right = GetSystemMetrics(SM_CXSCREEN);
+ Rect->bottom = GetSystemMetrics(SM_CYSCREEN);
+*/ }
+ return TRUE;
+}
+
+
INT FASTCALL
IntMapWindowPoints(PWND FromWnd, PWND ToWnd, LPPOINT lpPoints, UINT cPoints)
{
return NULL;
}
+VOID
+SelectWindowRgn( PWND Window, HRGN hRgnClip)
+{
+ if (Window->hrgnClip)
+ {
+ /* Delete no longer needed region handle */
+ IntGdiSetRegionOwner(Window->hrgnClip, GDI_OBJ_HMGR_POWNED);
+ GreDeleteObject(Window->hrgnClip);
+ Window->hrgnClip = NULL;
+ }
+
+ if (hRgnClip > HRGN_WINDOW)
+ {
+ /*if (Window != UserGetDesktopWindow()) // Window->fnid != FNID_DESKTOP)
+ {
+ NtGdiOffsetRgn(hRgnClip, Window->rcWindow.left, Window->rcWindow.top);
+ }*/
+ /* Set public ownership */
+ IntGdiSetRegionOwner(hRgnClip, GDI_OBJ_HMGR_PUBLIC);
+
+ Window->hrgnClip = hRgnClip;
+ }
+}
+
//
// This helps with CORE-6129 forcing modal dialog active when another app is minimized or closed.
//
USER_REFERENCE_ENTRY Ref;
PTHREADINFO pti = gptiCurrent;
- //ERR("AOWM 1\n");
+ //ERR("AOWM 1 %p\n",Wnd->head.h);
ActivePrev = (pti->MessageQueue->spwndActivePrev != NULL);
FindTopWnd = TRUE;
//ERR("ActivateOtherWindowMin Set FG 1\n");
co_IntSetForegroundWindow(pWndSetActive);
UserDerefObjectCo(pWndSetActive);
- //ERR("AOWM 2 Exit Good\n");
+ //ERR("AOWM 2 Exit Good %p\n",pWndSetActive->head.h);
return TRUE;
}
if (!pWndTemp ) pWndTemp = pWndSetActive;
//ERR("ActivateOtherWindowMin Set FG 2\n");
co_IntSetForegroundWindow(pWndSetActive);
UserDerefObjectCo(pWndSetActive);
- //ERR("AOWM 3 Exit Good\n");
+ //ERR("AOWM 3 Exit Good %p\n",pWndSetActive->head.h);
return TRUE;
}
//ERR("AOWM 4 Bad\n");
/* If this is popup window, try to activate the owner first. */
if ((Wnd->style & WS_POPUP) && (WndTo = Wnd->spwndOwner))
{
+ TRACE("WPAOW Popup with Owner\n");
WndTo = UserGetAncestor( WndTo, GA_ROOT );
if (can_activate_window(WndTo)) goto done;
}
WndTo = Wnd;
for (;;)
{
- if (!(WndTo = WndTo->spwndNext)) break;
- if (can_activate_window( WndTo )) break;
+ if (!(WndTo = WndTo->spwndNext)) break;
+ if (can_activate_window( WndTo )) goto done;
}
-done:
+ /*
+ Fixes wine win.c:test_SetParent last ShowWindow test after popup dies.
+ Check for previous active window to bring to top.
+ */
+ if (Wnd)
+ {
+ WndTo = Wnd->head.pti->MessageQueue->spwndActivePrev;
+ if (can_activate_window( WndTo )) goto done;
+ }
+
+ // Find any window to bring to top. Works Okay for wine since it does not see X11 windows.
+ WndTo = UserGetDesktopWindow();
+ WndTo = WndTo->spwndChild;
+ if ( WndTo == NULL )
+ {
+ return;
+ }
+ for (;;)
+ {
+ if (WndTo == Wnd)
+ {
+ WndTo = NULL;
+ break;
+ }
+ if (can_activate_window( WndTo )) goto done;
+ if (!(WndTo = WndTo->spwndNext)) break;
+ }
+done:
if (WndTo) UserRefObjectCo(WndTo, &Ref);
- if (!gpqForeground || Wnd == gpqForeground->spwndActive)
+ if (gpqForeground && (!gpqForeground->spwndActive || Wnd == gpqForeground->spwndActive))
{
/* ReactOS can pass WndTo = NULL to co_IntSetForegroundWindow and returns FALSE. */
- //ERR("WinPosActivateOtherWindow Set FG 0x%p\n",WndTo);
+ //ERR("WinPosActivateOtherWindow Set FG 0x%p hWnd %p\n",WndTo, WndTo ? WndTo->head.h : 0);
if (co_IntSetForegroundWindow(WndTo))
{
if (WndTo) UserDerefObjectCo(WndTo);
//ERR("WinPosActivateOtherWindow Set Active 0x%p\n",WndTo);
if (!co_IntSetActiveWindow(WndTo,FALSE,TRUE,FALSE)) /* Ok for WndTo to be NULL here */
{
+ //ERR("WPAOW SA 1\n");
co_IntSetActiveWindow(NULL,FALSE,TRUE,FALSE);
}
if (WndTo) UserDerefObjectCo(WndTo);
POINT Size;
RECTL Rect = *RestoreRect;
- if (Wnd->spwndParent != UserGetDesktopWindow())
+ if (Wnd->spwndParent && Wnd->spwndParent != UserGetDesktopWindow())
{
RECTL_vOffsetRect(&Rect,
-Wnd->spwndParent->rcClient.left,
pwndParent = Window->spwndParent;
if (pwndParent == UserGetDesktopWindow())
{
- //ERR("Parent is Desktop, Min off screen!\n");
- /* ReactOS doesn't support iconic minimize to desktop */
+ ERR("FIXME: Parent is Desktop, Min off screen!\n");
+ /* FIXME: ReactOS doesn't support iconic minimize to desktop */
Pos->x = Pos->y = -32000;
Window->InternalPos.flags |= WPF_MININIT;
Window->InternalPos.IconPos.x = Pos->x;
{
switch (ShowFlag)
{
+ case SW_MINIMIZE:
case SW_SHOWMINNOACTIVE:
case SW_SHOWMINIMIZED:
case SW_FORCEMINIMIZE:
- case SW_MINIMIZE:
return SWP_NOSIZE | SWP_NOMOVE;
}
if (!co_IntSendMessageNoWait(Wnd->head.h, WM_QUERYOPEN, 0, 0))
}
switch (ShowFlag)
{
+ case SW_MINIMIZE:
case SW_SHOWMINNOACTIVE:
case SW_SHOWMINIMIZED:
case SW_FORCEMINIMIZE:
- case SW_MINIMIZE:
{
//ERR("MinMaximize Minimize\n");
if (Wnd->style & WS_MAXIMIZE)
WinPosFindIconPos(Wnd, &wpl.ptMinPosition);
- if (!(old_style & WS_MINIMIZE)) SwpFlags |= SWP_STATECHANGED;
+ /*if (!(old_style & WS_MINIMIZE))
+ {
+ SwpFlags |= SWP_STATECHANGED;
+ IntShowOwnedPopups(Wnd, FALSE);
+ }*/
RECTL_vSetRect(NewPos, wpl.ptMinPosition.x, wpl.ptMinPosition.y,
wpl.ptMinPosition.x + UserGetSystemMetrics(SM_CXMINIMIZED),
wpl.ptMaxPosition.x, wpl.ptMaxPosition.y, Size.x, Size.y);
*/
old_style = IntSetStyle( Wnd, WS_MAXIMIZE, WS_MINIMIZE );
+ /*if (old_style & WS_MINIMIZE)
+ {
+ IntShowOwnedPopups(Wnd, TRUE);
+ }*/
if (!(old_style & WS_MAXIMIZE)) SwpFlags |= SWP_STATECHANGED;
RECTL_vSetRect(NewPos, wpl.ptMaxPosition.x, wpl.ptMaxPosition.y,
old_style = IntSetStyle( Wnd, 0, WS_MINIMIZE | WS_MAXIMIZE );
if (old_style & WS_MINIMIZE)
{
+ //IntShowOwnedPopups(Wnd, TRUE);
+
if (Wnd->InternalPos.flags & WPF_RESTORETOMAXIMIZED)
{
co_WinPosGetMinMaxInfo(Wnd, &Size, &wpl.ptMaxPosition, NULL, NULL);
return 0; // FIXME: What does it return?
}
+static
+BOOL
+IntValidateParent(PWND Child, PREGION ValidateRgn)
+{
+ PWND ParentWnd = Child;
+
+ if (ParentWnd->style & WS_CHILD)
+ {
+ do
+ ParentWnd = ParentWnd->spwndParent;
+ while (ParentWnd->style & WS_CHILD);
+ }
+
+ ParentWnd = Child->spwndParent;
+ while (ParentWnd)
+ {
+ if (ParentWnd->style & WS_CLIPCHILDREN)
+ break;
+
+ if (ParentWnd->hrgnUpdate != 0)
+ {
+ IntInvalidateWindows( ParentWnd,
+ ValidateRgn,
+ RDW_VALIDATE | RDW_NOCHILDREN);
+ }
+
+ ParentWnd = ParentWnd->spwndParent;
+ }
+
+ return TRUE;
+}
+
static
VOID FASTCALL
FixClientRect(PRECTL ClientRect, PRECTL WindowRect)
if (!(WinPos->flags & SWP_NOSENDCHANGING))
{
- TRACE("Sending WM_WINDOWPOSCHANGING to hwnd %p.\n", Window->head.h);
- co_IntSendMessageNoWait(Window->head.h, WM_WINDOWPOSCHANGING, 0, (LPARAM) WinPos);
+ TRACE("Sending WM_WINDOWPOSCHANGING to hwnd %p flags %04x.\n", Window->head.h,WinPos->flags);
+ co_IntSendMessage(Window->head.h, WM_WINDOWPOSCHANGING, 0, (LPARAM) WinPos);
}
/* Calculate new position and size */
Parent = Window->spwndParent;
- if (((Window->style & WS_CHILD) != 0) &&
+ // Parent child position issue is in here. SetParent_W7 test CORE-6651.
+ if (//((Window->style & WS_CHILD) != 0) && <- Fixes wine msg test_SetParent: "rects do not match", the last test.
Parent &&
Parent != Window->head.rpdesk->pDeskInfo->spwnd)
{
TRACE("(%p) hInsertAfter = %p\n", Window, hWndInsertAfter );
- Owner = Window->spwndOwner ? Window->spwndOwner->head.h : NULL;
Style = Window->style;
if (Style & WS_CHILD)
return hWndInsertAfter;
}
+ Owner = Window->spwndOwner ? Window->spwndOwner->head.h : NULL;
+
if (Owner)
{
/* Make sure this popup stays above the owner */
if (hWndInsertAfter == HWND_BOTTOM)
{
- ERR("Window is HWND_BOTTOM\n");
+ ERR("Window is HWND_BOTTOM hwnd %p\n",hWndInsertAfter);
if (List) ExFreePoolWithTag(List, USERTAG_WINDOWLIST);
goto done;
}
TRACE("skip all the topmost windows\n");
/* skip all the topmost windows */
while (List[i] &&
- (ChildObject = ValidateHwndNoErr(List[i])) &&
+ (ChildObject = ValidateHwndNoErr(List[i])) &&
(ChildObject->ExStyle & WS_EX_TOPMOST)) i++;
}
}
POINT pt;
/* Finally make sure that all coordinates are valid */
- if (WinPos->x < -32768) WinPos->x = -32768;
+ if (WinPos->x < -32768) WinPos->x = -32768;
else if (WinPos->x > 32767) WinPos->x = 32767;
- if (WinPos->y < -32768) WinPos->y = -32768;
+ if (WinPos->y < -32768) WinPos->y = -32768;
else if (WinPos->y > 32767) WinPos->y = 32767;
WinPos->cx = max(WinPos->cx, 0);
WinPos->cy = max(WinPos->cy, 0);
Parent = UserGetAncestor( Wnd, GA_PARENT );
- if (!IntIsWindowVisible( Parent )) WinPos->flags |= SWP_NOREDRAW;
+ if (!IntIsWindowVisible( Parent ) &&
+ /* Fix B : wine msg test_SetParent:WmSetParentSeq_2:25 wParam bits! */
+ (WinPos->flags & SWP_AGG_STATUSFLAGS) == SWP_AGG_NOPOSCHANGE) WinPos->flags |= SWP_NOREDRAW;
if (Wnd->style & WS_VISIBLE) WinPos->flags &= ~SWP_SHOWWINDOW;
else
WinPos->flags |= SWP_NOMOVE;
}
- if (WinPos->hwnd == UserGetForegroundWindow())
+ if ( WinPos->hwnd != UserGetForegroundWindow() && (Wnd->style & (WS_POPUP | WS_CHILD)) != WS_CHILD)
{
- WinPos->flags |= SWP_NOACTIVATE; /* Already active */
- }
- else
- if ((Wnd->style & (WS_POPUP | WS_CHILD)) != WS_CHILD)
+ /* Bring to the top when activating */
+ if (!(WinPos->flags & (SWP_NOACTIVATE|SWP_HIDEWINDOW)) &&
+ (WinPos->flags & SWP_NOZORDER ||
+ (WinPos->hwndInsertAfter != HWND_TOPMOST && WinPos->hwndInsertAfter != HWND_NOTOPMOST)))
{
- /* Bring to the top when activating */
- if (!(WinPos->flags & (SWP_NOACTIVATE|SWP_HIDEWINDOW)) &&
- (WinPos->flags & SWP_NOZORDER ||
- (WinPos->hwndInsertAfter != HWND_TOPMOST && WinPos->hwndInsertAfter != HWND_NOTOPMOST)))
- {
- WinPos->flags &= ~SWP_NOZORDER;
- WinPos->hwndInsertAfter = (0 != (Wnd->ExStyle & WS_EX_TOPMOST) ? HWND_TOPMOST : HWND_TOP);
- }
+ WinPos->flags &= ~SWP_NOZORDER;
+ WinPos->hwndInsertAfter = (0 != (Wnd->ExStyle & WS_EX_TOPMOST) ? HWND_TOPMOST : HWND_TOP);
}
+ }
/* Check hwndInsertAfter */
if (!(WinPos->flags & SWP_NOZORDER))
WinPos->hwndInsertAfter = HWND_TOPMOST;
if (IntGetWindow(WinPos->hwnd, GW_HWNDFIRST) == WinPos->hwnd)
+ {
WinPos->flags |= SWP_NOZORDER;
+ }
}
else if (WinPos->hwndInsertAfter == HWND_BOTTOM)
{
HDC Dc;
RECTL CopyRect;
PWND Ancestor;
- BOOL bPointerInWindow;
+ BOOL bPointerInWindow, PosChanged = FALSE;
+ //PTHREADINFO pti = PsGetCurrentThreadWin32Thread();
ASSERT_REFS_CO(Window);
+ TRACE("pwnd %p, after %p, %d,%d (%dx%d), flags %s",
+ Window, WndInsertAfter, x, y, cx, cy, flags);
+#if DBG
+ dump_winpos_flags(flags);
+#endif
+
/* FIXME: Get current active window from active queue. Why? since r2915. */
bPointerInWindow = IntPtInWindow(Window, gpsi->ptCursor.x, gpsi->ptCursor.y);
}
else if(VisBefore)
{
- IntGdiOffsetRgn(VisBefore, -Window->rcWindow.left, -Window->rcWindow.top);
+ REGION_bOffsetRgn(VisBefore, -Window->rcWindow.left, -Window->rcWindow.top);
}
- /* Calculate the non client area for resizes, as this is used in the copy region */
+ /* Calculate the non client area for resizes, as this is used in the copy region */
if (!(WinPos.flags & SWP_NOSIZE))
{
VisBeforeJustClient = VIS_ComputeVisibleRegion(Window, TRUE, FALSE,
}
else if(VisBeforeJustClient)
{
- IntGdiOffsetRgn(VisBeforeJustClient, -Window->rcWindow.left, -Window->rcWindow.top);
+ REGION_bOffsetRgn(VisBeforeJustClient, -Window->rcWindow.left, -Window->rcWindow.top);
}
}
}
}
+ //// HACK 3
+ if (Window->hrgnNewFrame)
+ {
+ SelectWindowRgn( Window, Window->hrgnNewFrame ); // Should be PSMWP->acvr->hrgnClip
+ Window->hrgnNewFrame = NULL;
+ }
+
WvrFlags = co_WinPosDoNCCALCSize(Window, &WinPos, &NewWindowRect, &NewClientRect, valid_rects);
// ERR("co_WinPosDoNCCALCSize returned 0x%x\n valid dest: %d %d %d %d\n valid src : %d %d %d %d\n", WvrFlags,
WinPosInternalMoveWindow(Window,
NewClientRect.left - OldClientRect.left,
NewClientRect.top - OldClientRect.top);
+ PosChanged = TRUE;
}
Window->rcWindow = NewWindowRect;
}
else if (WinPos.flags & SWP_SHOWWINDOW)
{
- if (Window->spwndParent == UserGetDesktopWindow())
+ if (Window->spwndParent == UserGetDesktopWindow() &&
+ Window->spwndOwner == NULL &&
+ (!(Window->ExStyle & WS_EX_TOOLWINDOW) ||
+ (Window->ExStyle & WS_EX_APPWINDOW)))
co_IntShellHookNotify(HSHELL_WINDOWCREATED, (WPARAM)Window->head.h, 0);
Window->style |= WS_VISIBLE; //IntSetStyle( Window, WS_VISIBLE, 0 );
}
else if(VisAfter)
{
- IntGdiOffsetRgn(VisAfter, -Window->rcWindow.left, -Window->rcWindow.top);
+ REGION_bOffsetRgn(VisAfter, -Window->rcWindow.left, -Window->rcWindow.top);
}
/*
* class need to be completely repainted on (horizontal/vertical) size
* change.
*/
- if ( VisBefore != NULL &&
- VisAfter != NULL &&
- !(WinPos.flags & SWP_NOCOPYBITS) &&
- ((WinPos.flags & SWP_NOSIZE) || !(WvrFlags & WVR_REDRAW)) &&
- !(Window->ExStyle & WS_EX_TRANSPARENT) )
+ if ( ( VisBefore != NULL &&
+ VisAfter != NULL &&
+ !(WinPos.flags & SWP_NOCOPYBITS) &&
+ ((WinPos.flags & SWP_NOSIZE) || !(WvrFlags & WVR_REDRAW)) &&
+ !(Window->ExStyle & WS_EX_TRANSPARENT) ) ||
+ ( !PosChanged && (WinPos.flags & SWP_FRAMECHANGED) && VisBefore) )
{
/*
/* No use in copying bits which are in the update region. */
if (Window->hrgnUpdate != NULL)
{
- PREGION RgnUpdate = RGNOBJAPI_Lock(Window->hrgnUpdate, NULL);
+ PREGION RgnUpdate = REGION_LockRgn(Window->hrgnUpdate);
if (RgnUpdate)
{
- IntGdiOffsetRgn(CopyRgn, NewWindowRect.left, NewWindowRect.top);
+ REGION_bOffsetRgn(CopyRgn, NewWindowRect.left, NewWindowRect.top);
IntGdiCombineRgn(CopyRgn, CopyRgn, RgnUpdate, RGN_DIFF);
- IntGdiOffsetRgn(CopyRgn, -NewWindowRect.left, -NewWindowRect.top);
- RGNOBJAPI_Unlock(RgnUpdate);
+ REGION_bOffsetRgn(CopyRgn, -NewWindowRect.left, -NewWindowRect.top);
+ REGION_UnlockRgn(RgnUpdate);
}
}
REGION_Delete(CopyRgn);
CopyRgn = NULL;
}
- else if (OldWindowRect.left != NewWindowRect.left ||
- OldWindowRect.top != NewWindowRect.top)
+ else if ( OldWindowRect.left != NewWindowRect.left ||
+ OldWindowRect.top != NewWindowRect.top ||
+ (WinPos.flags & SWP_FRAMECHANGED) )
{
HRGN DcRgn = NtGdiCreateRectRgn(0, 0, 0, 0);
- PREGION DcRgnObj = RGNOBJAPI_Lock(DcRgn, NULL);
+ PREGION DcRgnObj = REGION_LockRgn(DcRgn);
/*
* Small trick here: there is no function to bitblt a region. So
* to create a copy of CopyRgn and pass that. We need CopyRgn later
*/
IntGdiCombineRgn(DcRgnObj, CopyRgn, NULL, RGN_COPY);
- IntGdiOffsetRgn(DcRgnObj, NewWindowRect.left, NewWindowRect.top);
- RGNOBJAPI_Unlock(DcRgnObj);
+ REGION_bOffsetRgn(DcRgnObj, NewWindowRect.left, NewWindowRect.top);
+ REGION_UnlockRgn(DcRgnObj);
Dc = UserGetDCEx( Window,
DcRgn,
DCX_WINDOW|DCX_CACHE|DCX_INTERSECTRGN|DCX_CLIPSIBLINGS|DCX_KEEPCLIPRGN);
0);
UserReleaseDC(Window, Dc, FALSE);
- IntValidateParent(Window, CopyRgn, FALSE);
+ IntValidateParent(Window, CopyRgn);
GreDeleteObject(DcRgn);
}
}
{
CopyRgn = NULL;
}
-
+#if 0
+ /////// Fixes NoPopup tests but breaks msg_paint tests.
+ if ( !PosChanged && (WinPos.flags & SWP_FRAMECHANGED) && VisBefore)
+ {
+ PWND Parent = Window->spwndParent;
+ ERR("SWP_FRAMECHANGED no chg\n");
+ if ( !(Window->style & WS_CHILD) && (Parent) && (Parent->style & WS_CLIPCHILDREN))
+ {
+ ERR("SWP_FRAMECHANGED Parent WS_CLIPCHILDREN\n");
+ //IntInvalidateWindows( Window, VisBefore, /*RDW_ERASE |*/ RDW_FRAME | RDW_INVALIDATE | RDW_ALLCHILDREN);
+ }
+ }
+#endif
/* We need to redraw what wasn't visible before */
if (VisAfter != NULL)
{
{
RgnType = IntGdiCombineRgn(DirtyRgn, VisAfter, 0, RGN_COPY);
}
+
if (RgnType != ERROR && RgnType != NULLREGION)
{
/* old code
PWND Parent = Window->spwndParent;
- IntGdiOffsetRgn( DirtyRgn,
- Window->rcWindow.left,
- Window->rcWindow.top);
- if ( (Window->style & WS_CHILD) &&
- (Parent) &&
- !(Parent->style & WS_CLIPCHILDREN))
+ REGION_bOffsetRgn( DirtyRgn, Window->rcWindow.left, Window->rcWindow.top);
+
+ if ( (Window->style & WS_CHILD) && (Parent) && !(Parent->style & WS_CLIPCHILDREN))
{
- IntInvalidateWindows( Parent,
- DirtyRgn,
- RDW_ERASE | RDW_INVALIDATE);
- co_IntPaintWindows(Parent, RDW_ERASENOW, FALSE);
+ IntInvalidateWindows( Parent, DirtyRgn, RDW_ERASE | RDW_INVALIDATE);
+ co_IntPaintWindows(Parent, RDW_NOCHILDREN, FALSE);
}
else
{
- IntInvalidateWindows( Window,
- DirtyRgn,
- RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_ALLCHILDREN);
+ IntInvalidateWindows( Window, DirtyRgn, RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_ALLCHILDREN);
}
}
REGION_Delete(DirtyRgn);
if (ExposedRgn)
{
RgnType = IntGdiCombineRgn(ExposedRgn, VisBefore, NULL, RGN_COPY);
- IntGdiOffsetRgn( ExposedRgn,
- OldWindowRect.left - NewWindowRect.left,
- OldWindowRect.top - NewWindowRect.top);
+ REGION_bOffsetRgn(ExposedRgn,
+ OldWindowRect.left - NewWindowRect.left,
+ OldWindowRect.top - NewWindowRect.top);
if (VisAfter != NULL)
RgnType = IntGdiCombineRgn(ExposedRgn, ExposedRgn, VisAfter, RGN_DIFF);
}
}
+ if ( !PosChanged &&
+ (WinPos.flags & SWP_FRAMECHANGED) &&
+ !(WinPos.flags & SWP_DEFERERASE) && // Prevent sending WM_SYNCPAINT message.
+ VisAfter )
+ {
+ PWND Parent = Window->spwndParent;
+ if ( !(Window->style & WS_CHILD) && (Parent) && (Parent->style & WS_CLIPCHILDREN))
+ {
+ TRACE("SWP_FRAMECHANGED Parent WS_CLIPCHILDREN\n");
+ UserSyncAndPaintWindows( Parent, RDW_CLIPCHILDREN);
+ }
+ }
+
+ // Fix wine msg test_SetFocus, prevents sending WM_WINDOWPOSCHANGED.
+ if ( VisBefore == NULL &&
+ VisBeforeJustClient == NULL &&
+ !(Window->ExStyle & WS_EX_TOPMOST) &&
+ (WinPos.flags & SWP_AGG_STATUSFLAGS) == (SWP_AGG_NOPOSCHANGE & ~SWP_NOZORDER))
+ {
+ TRACE("No drawing, set no Z order and no redraw!\n");
+ WinPos.flags |= SWP_NOZORDER|SWP_NOREDRAW;
+ }
+
/* And last, send the WM_WINDOWPOSCHANGED message */
- TRACE("\tstatus flags = %04x\n", WinPos.flags & SWP_AGG_STATUSFLAGS);
+ TRACE("\tstatus hwnd %p flags = %04x\n",Window?Window->head.h:NULL,WinPos.flags & SWP_AGG_STATUSFLAGS);
if ((WinPos.flags & SWP_AGG_STATUSFLAGS) != SWP_AGG_NOPOSCHANGE)
{
WinPos.y = NewWindowRect.top;
WinPos.cx = NewWindowRect.right - NewWindowRect.left;
WinPos.cy = NewWindowRect.bottom - NewWindowRect.top;
+ TRACE("WM_WINDOWPOSCHANGED hwnd %p Flags %04x\n",WinPos.hwnd,WinPos.flags);
co_IntSendMessageNoWait(WinPos.hwnd, WM_WINDOWPOSCHANGED, 0, (LPARAM) &WinPos);
}
IntEngWindowChanged(Wnd, WOC_RGN_CLIENT);
}
+/*
+ ShowWindow does not set SWP_FRAMECHANGED!!! Fix wine msg test_SetParent:WmSetParentSeq_2:23 wParam bits!
+ */
BOOLEAN FASTCALL
co_WinPosShowWindow(PWND Wnd, INT Cmd)
{
PTHREADINFO pti;
//HRGN VisibleRgn;
BOOL ShowOwned = FALSE;
+ BOOL FirstTime = FALSE;
ASSERT_REFS_CO(Wnd);
- //ERR("co_WinPosShowWindow START\n");
-
+ //KeRosDumpStackFrames(NULL, 20);
pti = PsGetCurrentThreadWin32Thread();
WasVisible = (Wnd->style & WS_VISIBLE) != 0;
style = Wnd->style;
+ TRACE("co_WinPosShowWindow START hwnd %p Cmd %d usicmd %u\n",
+ Wnd->head.h, Cmd, pti->ppi->usi.wShowWindow);
+
+ if ( pti->ppi->usi.dwFlags & STARTF_USESHOWWINDOW )
+ {
+ if ((Wnd->style & (WS_POPUP|WS_CHILD)) != WS_CHILD)
+ {
+ if ((Wnd->style & WS_CAPTION) == WS_CAPTION)
+ {
+ if (Wnd->spwndOwner == NULL)
+ {
+ if ( Cmd == SW_SHOWNORMAL || Cmd == SW_SHOW)
+ {
+ Cmd = SW_SHOWDEFAULT;
+ }
+ FirstTime = TRUE;
+ TRACE("co_WPSW FT 1\n");
+ }
+ }
+ }
+ }
+
+ if ( Cmd == SW_SHOWDEFAULT )
+ {
+ if ( pti->ppi->usi.dwFlags & STARTF_USESHOWWINDOW )
+ {
+ Cmd = pti->ppi->usi.wShowWindow;
+ FirstTime = TRUE;
+ TRACE("co_WPSW FT 2\n");
+ }
+ }
+
+ if (FirstTime)
+ {
+ pti->ppi->usi.dwFlags &= ~(STARTF_USEPOSITION|STARTF_USESIZE|STARTF_USESHOWWINDOW);
+ }
+
switch (Cmd)
{
case SW_HIDE:
if (!WasVisible)
{
//ERR("co_WinPosShowWindow Exit Bad\n");
- return(FALSE);
+ return FALSE;
}
Swp |= SWP_HIDEWINDOW | SWP_NOSIZE | SWP_NOMOVE;
if (Wnd != pti->MessageQueue->spwndActive)
if (!(style & WS_MINIMIZE))
{
IntShowOwnedPopups(Wnd, FALSE );
-
// Fix wine Win test_SetFocus todo #1 & #2,
if (Cmd == SW_SHOWMINIMIZED)
{
co_UserSetFocus(0);
}
- Swp |= co_WinPosMinMaximize(Wnd, Cmd, &NewPos) |
- SWP_FRAMECHANGED;
+ Swp |= co_WinPosMinMaximize(Wnd, Cmd, &NewPos);
EventMsg = EVENT_SYSTEM_MINIMIZESTART;
}
else
{
- if (!WasVisible)
- {
- Swp |= SWP_FRAMECHANGED;
- }
- else ////
+ if (WasVisible)
{
//ERR("co_WinPosShowWindow Exit Good\n");
return TRUE;
{
ShowOwned = TRUE;
- Swp |= co_WinPosMinMaximize(Wnd, SW_MAXIMIZE, &NewPos) |
- SWP_FRAMECHANGED;
+ Swp |= co_WinPosMinMaximize(Wnd, SW_MAXIMIZE, &NewPos);
EventMsg = EVENT_SYSTEM_MINIMIZEEND;
}
else
{
- if (!WasVisible)
- {
- Swp |= SWP_FRAMECHANGED;
- }
- else ////
+ if (WasVisible)
{
//ERR("co_WinPosShowWindow Exit Good 1\n");
return TRUE;
if (!WasVisible) Swp |= SWP_SHOWWINDOW;
if (style & (WS_MINIMIZE | WS_MAXIMIZE))
{
- Swp |= co_WinPosMinMaximize(Wnd, Cmd, &NewPos) |
- SWP_FRAMECHANGED;
-
+ Swp |= co_WinPosMinMaximize(Wnd, Cmd, &NewPos);
if (style & WS_MINIMIZE) EventMsg = EVENT_SYSTEM_MINIMIZEEND;
}
else
{
- if (!WasVisible)
- {
- Swp |= SWP_FRAMECHANGED;
- }
- else ////
+ if (WasVisible)
{
//ERR("co_WinPosShowWindow Exit Good 3\n");
return TRUE;
if ((ShowFlag != WasVisible || Cmd == SW_SHOWNA) && Cmd != SW_SHOWMAXIMIZED && !(Swp & SWP_STATECHANGED))
{
co_IntSendMessageNoWait(Wnd->head.h, WM_SHOWWINDOW, ShowFlag, 0);
- if (!(Wnd->state2 & WNDS2_WIN31COMPAT))
+#if 0 // Fix wine msg test_SetParent:WmSetParentSeq_1:2
+ if (!(Wnd->state2 & WNDS2_WIN31COMPAT)) // <------------- XP sets this bit!
co_IntSendMessageNoWait(Wnd->head.h, WM_SETVISIBLE, ShowFlag, 0);
+#endif
if (!VerifyWnd(Wnd)) return WasVisible;
}
((Cmd == SW_SHOW) || (Cmd == SW_NORMAL)))
{
ERR("WinPosShowWindow Set active\n");
- UserSetActiveWindow(Wnd);
+ //UserSetActiveWindow(Wnd);
+ co_IntSetForegroundWindow(Wnd); // HACK
Swp |= SWP_NOACTIVATE | SWP_NOZORDER;
}
#endif
if (IsChildVisible(Wnd) || Swp & SWP_STATECHANGED)
{
- TRACE("Child is Vis %s or State changed %s. ShowFlag %s\n",
+ TRACE("Child is Vis %s or State changed %s. ShowFlag %s Swp %04x\n",
(IsChildVisible(Wnd) ? "TRUE" : "FALSE"), (Swp & SWP_STATECHANGED ? "TRUE" : "FALSE"),
- (ShowFlag ? "TRUE" : "FALSE"));
+ (ShowFlag ? "TRUE" : "FALSE"),LOWORD(Swp));
co_WinPosSetWindowPos( Wnd,
0 != (Wnd->ExStyle & WS_EX_TOPMOST) ? HWND_TOPMOST : HWND_TOP,
NewPos.left,
NewPos.top,
- NewPos.right, //NewPos.right - NewPos.left,
- NewPos.bottom, //NewPos.bottom - NewPos.top,
+ NewPos.right, // NewPos.right - NewPos.left, when minimized and restore, the window becomes smaller.
+ NewPos.bottom,// NewPos.bottom - NewPos.top,
LOWORD(Swp));
}
else
{
if ( Wnd->spwndParent == UserGetDesktopWindow())
{
- if(!ActivateOtherWindowMin(Wnd))
+ if (!ActivateOtherWindowMin(Wnd))
+ {
co_WinPosActivateOtherWindow(Wnd);
+ }
}
else
+ {
co_WinPosActivateOtherWindow(Wnd);
+ }
}
/* Revert focus to parent */
if (Wnd->spwndParent == UserGetDesktopWindow()) Parent = 0;
co_UserSetFocus(Parent);
}
+ // Hide, just return.
+ if (Cmd == SW_HIDE) return WasVisible;
}
/* FIXME: Check for window destruction. */
{
co_UserSetFocus(Wnd);
// Fix wine Win test_SetFocus todo #3,
- if (!(style & WS_CHILD)) co_IntSendMessageNoWait(UserHMGetHandle(Wnd), WM_ACTIVATE, WA_ACTIVE, 0);
+ if (!(style & WS_CHILD)) co_IntSendMessage(UserHMGetHandle(Wnd), WM_ACTIVATE, WA_ACTIVE, 0);
}
//ERR("co_WinPosShowWindow EXIT\n");
- return(WasVisible);
+ return WasVisible;
}
-static
-PWND FASTCALL
+static PWND
co_WinPosSearchChildren(
- PWND ScopeWin,
- POINT *Point,
- USHORT *HitTest,
- BOOL Ignore
+ IN PWND ScopeWin,
+ IN POINT *Point,
+ IN OUT USHORT *HitTest,
+ IN BOOL Ignore
)
{
- PWND pwndChild;
HWND *List, *phWnd;
+ PWND pwndChild = NULL;
+ /* not visible */
if (!(ScopeWin->style & WS_VISIBLE))
{
return NULL;
}
- if (!Ignore && (ScopeWin->style & WS_DISABLED))
+ /* not in window or in window region */
+ if (!IntPtInWindow(ScopeWin, Point->x, Point->y))
{
return NULL;
}
- if (!IntPtInWindow(ScopeWin, Point->x, Point->y))
+ /* transparent */
+ if ((ScopeWin->ExStyle & (WS_EX_LAYERED|WS_EX_TRANSPARENT)) == (WS_EX_LAYERED|WS_EX_TRANSPARENT))
{
return NULL;
}
- UserReferenceObject(ScopeWin);
+ if (!Ignore && (ScopeWin->style & WS_DISABLED))
+ { /* disabled child */
+ if ((ScopeWin->style & (WS_POPUP|WS_CHILD)) == WS_CHILD) return NULL;
+ /* process the hit error */
+ *HitTest = HTERROR;
+ return ScopeWin;
+ }
- if ( RECTL_bPointInRect(&ScopeWin->rcClient, Point->x, Point->y) )
+ /* not minimized and check if point is inside the window */
+ if (!(ScopeWin->style & WS_MINIMIZE) &&
+ RECTL_bPointInRect(&ScopeWin->rcClient, Point->x, Point->y) )
{
+ UserReferenceObject(ScopeWin);
+
List = IntWinListChildren(ScopeWin);
- if(List)
+ if (List)
{
for (phWnd = List; *phWnd; ++phWnd)
{
pwndChild = co_WinPosSearchChildren(pwndChild, Point, HitTest, Ignore);
- if(pwndChild != NULL)
+ if (pwndChild != NULL)
{
/* We found a window. Don't send any more WM_NCHITTEST messages */
ExFreePoolWithTag(List, USERTAG_WINDOWLIST);
}
ExFreePoolWithTag(List, USERTAG_WINDOWLIST);
}
+ UserDereferenceObject(ScopeWin);
}
if (ScopeWin->head.pti == PsGetCurrentThreadWin32Thread())
{
- *HitTest = (USHORT)co_IntSendMessage(ScopeWin->head.h, WM_NCHITTEST, 0,
- MAKELONG(Point->x, Point->y));
+ *HitTest = (USHORT)co_IntSendMessage(ScopeWin->head.h, WM_NCHITTEST, 0, MAKELONG(Point->x, Point->y));
+
if ((*HitTest) == (USHORT)HTTRANSPARENT)
{
- UserDereferenceObject(ScopeWin);
return NULL;
}
}
else
- *HitTest = HTCLIENT;
+ {
+ if (*HitTest == HTNOWHERE && pwndChild == NULL) *HitTest = HTCLIENT;
+ }
return ScopeWin;
}
-PWND FASTCALL
-co_WinPosWindowFromPoint(PWND ScopeWin, POINT *WinPoint, USHORT* HitTest, BOOL Ignore)
+PWND APIENTRY
+co_WinPosWindowFromPoint(
+ IN PWND ScopeWin,
+ IN POINT *WinPoint,
+ IN OUT USHORT* HitTest,
+ IN BOOL Ignore)
{
PWND Window;
POINT Point = *WinPoint;
}
Status = MmCopyFromCaller(&Safepl, lpwndpl, sizeof(WINDOWPLACEMENT));
- if(!NT_SUCCESS(Status))
+ if (!NT_SUCCESS(Status))
{
SetLastNtError(Status);
RETURN( FALSE);
}
- if(Safepl.length != sizeof(WINDOWPLACEMENT))
- {
- RETURN( FALSE);
- }
+
+ Safepl.length = sizeof(WINDOWPLACEMENT);
IntGetWindowPlacement(Wnd, &Safepl);
Status = MmCopyToCaller(lpwndpl, &Safepl, sizeof(WINDOWPLACEMENT));
- if(!NT_SUCCESS(Status))
+ if (!NT_SUCCESS(Status))
{
SetLastNtError(Status);
RETURN( FALSE);
RETURN( 0);
}
- if (Window->hrgnClip)
+ //// HACK 1 : Work around the lack of supporting DeferWindowPos.
+ if (hrgnCopy)
{
- /* Delete no longer needed region handle */
- IntGdiSetRegionOwner(Window->hrgnClip, GDI_OBJ_HMGR_POWNED);
- GreDeleteObject(Window->hrgnClip);
+ Window->hrgnNewFrame = hrgnCopy; // Should be PSMWP->acvr->hrgnClip
}
-
- if (hrgnCopy)
+ else
{
- /* Set public ownership */
- IntGdiSetRegionOwner(hrgnCopy, GDI_OBJ_HMGR_PUBLIC);
+ Window->hrgnNewFrame = HRGN_WINDOW;
}
- Window->hrgnClip = hrgnCopy;
-
+ //// HACK 2
Ret = co_WinPosSetWindowPos(Window, HWND_TOP, 0, 0, 0, 0, bRedraw ? flags : (flags|SWP_NOREDRAW) );
RETURN( (INT)Ret);
DECLARE_RETURN(BOOL);
USER_REFERENCE_ENTRY Ref;
- TRACE("Enter NtUserShowWindow\n");
+ TRACE("Enter NtUserShowWindow hWnd %p SW_ %d\n",hWnd, nCmdShow);
UserEnterExclusive();
if (!(Window = UserGetWindowObject(hWnd)) || // FIXME:
RETURN( NULL);
CLEANUP:
- if (Window) UserDereferenceObject(Window);
if (DesktopWindow) UserDerefObjectCo(DesktopWindow);
TRACE("Leave NtUserWindowFromPoint, ret=%p\n", _ret_);