Commit 3b73e127 authored by Alexandre Julliard's avatar Alexandre Julliard

Get rid of the remaining WIN_FindWndPtr calls.

parent 34955ea6
...@@ -731,10 +731,8 @@ ...@@ -731,10 +731,8 @@
@ cdecl WINPOS_ActivateOtherWindow(long) @ cdecl WINPOS_ActivateOtherWindow(long)
@ cdecl WINPOS_GetMinMaxInfo(long ptr ptr ptr ptr) @ cdecl WINPOS_GetMinMaxInfo(long ptr ptr ptr ptr)
@ cdecl WINPOS_ShowIconTitle(long long) @ cdecl WINPOS_ShowIconTitle(long long)
@ cdecl WIN_FindWndPtr(long)
@ cdecl WIN_GetPtr(long) @ cdecl WIN_GetPtr(long)
@ cdecl WIN_LinkWindow(long long long) @ cdecl WIN_LinkWindow(long long long)
@ cdecl WIN_ListChildren(long) @ cdecl WIN_ListChildren(long)
@ cdecl WIN_ReleaseWndPtr(ptr)
@ cdecl WIN_SetStyle(long long long) @ cdecl WIN_SetStyle(long long long)
@ cdecl WIN_UnlinkWindow(long) @ cdecl WIN_UnlinkWindow(long)
...@@ -920,13 +920,14 @@ BOOL X11DRV_SetWindowPos( WINDOWPOS *winpos ) ...@@ -920,13 +920,14 @@ BOOL X11DRV_SetWindowPos( WINDOWPOS *winpos )
* *
* Find a suitable place for an iconic window. * Find a suitable place for an iconic window.
*/ */
static POINT WINPOS_FindIconPos( WND* wndPtr, POINT pt ) static POINT WINPOS_FindIconPos( HWND hwnd, POINT pt )
{ {
RECT rectParent; RECT rectParent;
HWND *list; HWND *list, parent;
short x, y, xspacing, yspacing; short x, y, xspacing, yspacing;
GetClientRect( wndPtr->parent, &rectParent ); parent = GetAncestor( hwnd, GA_PARENT );
GetClientRect( parent, &rectParent );
if ((pt.x >= rectParent.left) && (pt.x + GetSystemMetrics(SM_CXICON) < rectParent.right) && if ((pt.x >= rectParent.left) && (pt.x + GetSystemMetrics(SM_CXICON) < rectParent.right) &&
(pt.y >= rectParent.top) && (pt.y + GetSystemMetrics(SM_CYICON) < rectParent.bottom)) (pt.y >= rectParent.top) && (pt.y + GetSystemMetrics(SM_CYICON) < rectParent.bottom))
return pt; /* The icon already has a suitable position */ return pt; /* The icon already has a suitable position */
...@@ -934,7 +935,7 @@ static POINT WINPOS_FindIconPos( WND* wndPtr, POINT pt ) ...@@ -934,7 +935,7 @@ static POINT WINPOS_FindIconPos( WND* wndPtr, POINT pt )
xspacing = GetSystemMetrics(SM_CXICONSPACING); xspacing = GetSystemMetrics(SM_CXICONSPACING);
yspacing = GetSystemMetrics(SM_CYICONSPACING); yspacing = GetSystemMetrics(SM_CYICONSPACING);
list = WIN_ListChildren( wndPtr->parent ); list = WIN_ListChildren( parent );
y = rectParent.bottom; y = rectParent.bottom;
for (;;) for (;;)
{ {
...@@ -950,7 +951,7 @@ static POINT WINPOS_FindIconPos( WND* wndPtr, POINT pt ) ...@@ -950,7 +951,7 @@ static POINT WINPOS_FindIconPos( WND* wndPtr, POINT pt )
for (i = 0; list[i]; i++) for (i = 0; list[i]; i++)
{ {
if (list[i] == wndPtr->hwndSelf) continue; if (list[i] == hwnd) continue;
if (!IsIconic( list[i] )) continue; if (!IsIconic( list[i] )) continue;
if (!(childPtr = WIN_GetPtr( list[i] )) || childPtr == WND_OTHER_PROCESS) if (!(childPtr = WIN_GetPtr( list[i] )) || childPtr == WND_OTHER_PROCESS)
continue; continue;
...@@ -1006,26 +1007,23 @@ UINT WINPOS_MinMaximize( HWND hwnd, UINT cmd, LPRECT rect ) ...@@ -1006,26 +1007,23 @@ UINT WINPOS_MinMaximize( HWND hwnd, UINT cmd, LPRECT rect )
if (IsIconic( hwnd )) if (IsIconic( hwnd ))
{ {
if (cmd == SW_MINIMIZE) return SWP_NOSIZE | SWP_NOMOVE; if (cmd == SW_MINIMIZE) return SWP_NOSIZE | SWP_NOMOVE;
if (!SendMessageA( hwnd, WM_QUERYOPEN, 0, 0 )) return SWP_NOSIZE | SWP_NOMOVE; if (!SendMessageW( hwnd, WM_QUERYOPEN, 0, 0 )) return SWP_NOSIZE | SWP_NOMOVE;
swpFlags |= SWP_NOCOPYBITS; swpFlags |= SWP_NOCOPYBITS;
} }
if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
size.x = wndPtr->rectWindow.left;
size.y = wndPtr->rectWindow.top;
switch( cmd ) switch( cmd )
{ {
case SW_MINIMIZE: case SW_MINIMIZE:
if (!(wndPtr = WIN_GetPtr( hwnd )) || wndPtr == WND_OTHER_PROCESS) return 0;
if( wndPtr->dwStyle & WS_MAXIMIZE) wndPtr->flags |= WIN_RESTORE_MAX; if( wndPtr->dwStyle & WS_MAXIMIZE) wndPtr->flags |= WIN_RESTORE_MAX;
else wndPtr->flags &= ~WIN_RESTORE_MAX; else wndPtr->flags &= ~WIN_RESTORE_MAX;
WIN_ReleasePtr( wndPtr );
WIN_SetStyle( hwnd, WS_MINIMIZE, WS_MAXIMIZE ); WIN_SetStyle( hwnd, WS_MINIMIZE, WS_MAXIMIZE );
X11DRV_set_iconic_state( hwnd ); X11DRV_set_iconic_state( hwnd );
wpl.ptMinPosition = WINPOS_FindIconPos( wndPtr, wpl.ptMinPosition ); wpl.ptMinPosition = WINPOS_FindIconPos( hwnd, wpl.ptMinPosition );
SetRect( rect, wpl.ptMinPosition.x, wpl.ptMinPosition.y, SetRect( rect, wpl.ptMinPosition.x, wpl.ptMinPosition.y,
GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON) ); GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON) );
...@@ -1048,10 +1046,15 @@ UINT WINPOS_MinMaximize( HWND hwnd, UINT cmd, LPRECT rect ) ...@@ -1048,10 +1046,15 @@ UINT WINPOS_MinMaximize( HWND hwnd, UINT cmd, LPRECT rect )
old_style = WIN_SetStyle( hwnd, 0, WS_MINIMIZE | WS_MAXIMIZE ); old_style = WIN_SetStyle( hwnd, 0, WS_MINIMIZE | WS_MAXIMIZE );
if (old_style & WS_MINIMIZE) if (old_style & WS_MINIMIZE)
{ {
BOOL restore_max;
WINPOS_ShowIconTitle( hwnd, FALSE ); WINPOS_ShowIconTitle( hwnd, FALSE );
X11DRV_set_iconic_state( hwnd ); X11DRV_set_iconic_state( hwnd );
if( wndPtr->flags & WIN_RESTORE_MAX) if (!(wndPtr = WIN_GetPtr( hwnd )) || wndPtr == WND_OTHER_PROCESS) return 0;
restore_max = (wndPtr->flags & WIN_RESTORE_MAX) != 0;
WIN_ReleasePtr( wndPtr );
if (restore_max)
{ {
/* Restore to maximized position */ /* Restore to maximized position */
WINPOS_GetMinMaxInfo( hwnd, &size, &wpl.ptMaxPosition, NULL, NULL); WINPOS_GetMinMaxInfo( hwnd, &size, &wpl.ptMaxPosition, NULL, NULL);
...@@ -1071,7 +1074,6 @@ UINT WINPOS_MinMaximize( HWND hwnd, UINT cmd, LPRECT rect ) ...@@ -1071,7 +1074,6 @@ UINT WINPOS_MinMaximize( HWND hwnd, UINT cmd, LPRECT rect )
break; break;
} }
WIN_ReleaseWndPtr( wndPtr );
return swpFlags; return swpFlags;
} }
...@@ -1081,22 +1083,21 @@ UINT WINPOS_MinMaximize( HWND hwnd, UINT cmd, LPRECT rect ) ...@@ -1081,22 +1083,21 @@ UINT WINPOS_MinMaximize( HWND hwnd, UINT cmd, LPRECT rect )
*/ */
BOOL X11DRV_ShowWindow( HWND hwnd, INT cmd ) BOOL X11DRV_ShowWindow( HWND hwnd, INT cmd )
{ {
WND* wndPtr = WIN_FindWndPtr( hwnd ); WND *wndPtr;
BOOL wasVisible, showFlag; LONG style = GetWindowLongW( hwnd, GWL_STYLE );
RECT newPos = {0, 0, 0, 0}; BOOL wasVisible = (style & WS_VISIBLE) != 0;
UINT swp = 0; BOOL showFlag = TRUE;
RECT newPos = {0, 0, 0, 0};
if (!wndPtr) return FALSE; UINT swp = 0;
hwnd = wndPtr->hwndSelf; /* make it a full handle */
wasVisible = (wndPtr->dwStyle & WS_VISIBLE) != 0;
TRACE("hwnd=%p, cmd=%d, wasVisible %d\n", hwnd, cmd, wasVisible); TRACE("hwnd=%p, cmd=%d, wasVisible %d\n", hwnd, cmd, wasVisible);
switch(cmd) switch(cmd)
{ {
case SW_HIDE: case SW_HIDE:
if (!wasVisible) goto END; if (!wasVisible) return FALSE;
showFlag = FALSE;
swp |= SWP_HIDEWINDOW | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER; swp |= SWP_HIDEWINDOW | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER;
break; break;
...@@ -1109,25 +1110,24 @@ BOOL X11DRV_ShowWindow( HWND hwnd, INT cmd ) ...@@ -1109,25 +1110,24 @@ BOOL X11DRV_ShowWindow( HWND hwnd, INT cmd )
/* fall through */ /* fall through */
case SW_MINIMIZE: case SW_MINIMIZE:
swp |= SWP_FRAMECHANGED; swp |= SWP_FRAMECHANGED;
if( !(wndPtr->dwStyle & WS_MINIMIZE) ) if( !(style & WS_MINIMIZE) )
swp |= WINPOS_MinMaximize( hwnd, SW_MINIMIZE, &newPos ); swp |= WINPOS_MinMaximize( hwnd, SW_MINIMIZE, &newPos );
else swp |= SWP_NOSIZE | SWP_NOMOVE; else swp |= SWP_NOSIZE | SWP_NOMOVE;
break; break;
case SW_SHOWMAXIMIZED: /* same as SW_MAXIMIZE */ case SW_SHOWMAXIMIZED: /* same as SW_MAXIMIZE */
swp |= SWP_SHOWWINDOW | SWP_FRAMECHANGED; swp |= SWP_SHOWWINDOW | SWP_FRAMECHANGED;
if( !(wndPtr->dwStyle & WS_MAXIMIZE) ) if( !(style & WS_MAXIMIZE) )
swp |= WINPOS_MinMaximize( hwnd, SW_MAXIMIZE, &newPos ); swp |= WINPOS_MinMaximize( hwnd, SW_MAXIMIZE, &newPos );
else swp |= SWP_NOSIZE | SWP_NOMOVE; else swp |= SWP_NOSIZE | SWP_NOMOVE;
break; break;
case SW_SHOWNA: case SW_SHOWNA:
swp |= SWP_NOACTIVATE | SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE; swp |= SWP_NOACTIVATE | SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE;
if( wndPtr->dwStyle & WS_CHILD) swp |= SWP_NOZORDER; if (style & WS_CHILD) swp |= SWP_NOZORDER;
break; break;
case SW_SHOW: case SW_SHOW:
if (wasVisible) goto END; if (wasVisible) return TRUE;
swp |= SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE; swp |= SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE;
break; break;
...@@ -1141,21 +1141,20 @@ BOOL X11DRV_ShowWindow( HWND hwnd, INT cmd ) ...@@ -1141,21 +1141,20 @@ BOOL X11DRV_ShowWindow( HWND hwnd, INT cmd )
case SW_SHOWDEFAULT: /* FIXME: should have its own handler */ case SW_SHOWDEFAULT: /* FIXME: should have its own handler */
swp |= SWP_SHOWWINDOW; swp |= SWP_SHOWWINDOW;
if( wndPtr->dwStyle & (WS_MINIMIZE | WS_MAXIMIZE) ) if (style & (WS_MINIMIZE | WS_MAXIMIZE))
swp |= WINPOS_MinMaximize( hwnd, SW_RESTORE, &newPos ); swp |= WINPOS_MinMaximize( hwnd, SW_RESTORE, &newPos );
else swp |= SWP_NOSIZE | SWP_NOMOVE; else swp |= SWP_NOSIZE | SWP_NOMOVE;
break; break;
} }
showFlag = (cmd != SW_HIDE);
if (showFlag != wasVisible || cmd == SW_SHOWNA) if (showFlag != wasVisible || cmd == SW_SHOWNA)
{ {
SendMessageW( hwnd, WM_SHOWWINDOW, showFlag, 0 ); SendMessageW( hwnd, WM_SHOWWINDOW, showFlag, 0 );
if (!IsWindow( hwnd )) goto END; if (!IsWindow( hwnd )) return wasVisible;
} }
/* ShowWindow won't activate a not being maximized child window */ /* ShowWindow won't activate a not being maximized child window */
if ((wndPtr->dwStyle & WS_CHILD) && cmd != SW_MAXIMIZE) if ((style & WS_CHILD) && cmd != SW_MAXIMIZE)
swp |= SWP_NOACTIVATE | SWP_NOZORDER; swp |= SWP_NOACTIVATE | SWP_NOZORDER;
SetWindowPos( hwnd, HWND_TOP, newPos.left, newPos.top, SetWindowPos( hwnd, HWND_TOP, newPos.left, newPos.top,
...@@ -1181,26 +1180,28 @@ BOOL X11DRV_ShowWindow( HWND hwnd, INT cmd ) ...@@ -1181,26 +1180,28 @@ BOOL X11DRV_ShowWindow( HWND hwnd, INT cmd )
SetFocus(parent); SetFocus(parent);
} }
} }
if (!IsWindow( hwnd )) goto END;
else if( wndPtr->dwStyle & WS_MINIMIZE ) WINPOS_ShowIconTitle( hwnd, TRUE ); if (IsIconic(hwnd)) WINPOS_ShowIconTitle( hwnd, TRUE );
if (!(wndPtr = WIN_GetPtr( hwnd )) || wndPtr == WND_OTHER_PROCESS) return wasVisible;
if (wndPtr->flags & WIN_NEED_SIZE) if (wndPtr->flags & WIN_NEED_SIZE)
{ {
/* should happen only in CreateWindowEx() */ /* should happen only in CreateWindowEx() */
int wParam = SIZE_RESTORED; int wParam = SIZE_RESTORED;
RECT client = wndPtr->rectClient;
wndPtr->flags &= ~WIN_NEED_SIZE; wndPtr->flags &= ~WIN_NEED_SIZE;
if (wndPtr->dwStyle & WS_MAXIMIZE) wParam = SIZE_MAXIMIZED; if (wndPtr->dwStyle & WS_MAXIMIZE) wParam = SIZE_MAXIMIZED;
else if (wndPtr->dwStyle & WS_MINIMIZE) wParam = SIZE_MINIMIZED; else if (wndPtr->dwStyle & WS_MINIMIZE) wParam = SIZE_MINIMIZED;
SendMessageA( hwnd, WM_SIZE, wParam, WIN_ReleasePtr( wndPtr );
MAKELONG(wndPtr->rectClient.right-wndPtr->rectClient.left,
wndPtr->rectClient.bottom-wndPtr->rectClient.top)); SendMessageW( hwnd, WM_SIZE, wParam,
SendMessageA( hwnd, WM_MOVE, 0, MAKELONG( client.right - client.left, client.bottom - client.top ));
MAKELONG(wndPtr->rectClient.left, wndPtr->rectClient.top) ); SendMessageW( hwnd, WM_MOVE, 0, MAKELONG( client.left, client.top ));
} }
else WIN_ReleasePtr( wndPtr );
END:
WIN_ReleaseWndPtr(wndPtr);
return wasVisible; return wasVisible;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment