Commit fb630411 authored by Alexandre Julliard's avatar Alexandre Julliard

user32: Add helper functions to get and set the window internal flags.

parent 568b0804
......@@ -572,12 +572,7 @@ static LRESULT DEFWND_DefWinProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPa
break;
case WM_ISACTIVEICON:
{
WND *wndPtr = WIN_GetPtr( hwnd );
BOOL ret = (wndPtr->flags & WIN_NCACTIVATED) != 0;
WIN_ReleasePtr( wndPtr );
return ret;
}
return (win_get_flags( hwnd ) & WIN_NCACTIVATED) != 0;
case WM_NOTIFYFORMAT:
if (IsWindowUnicode(hwnd)) return NFR_UNICODE;
......
......@@ -1054,12 +1054,7 @@ LRESULT MDIClientWndProc_common( HWND hwnd, UINT message, WPARAM wParam, LPARAM
if (!(ci = get_client_info( hwnd )))
{
if (message == WM_NCCREATE)
{
WND *wndPtr = WIN_GetPtr( hwnd );
wndPtr->flags |= WIN_ISMDICLIENT;
WIN_ReleasePtr( wndPtr );
}
if (message == WM_NCCREATE) win_set_flags( hwnd, WIN_ISMDICLIENT, 0 );
return unicode ? DefWindowProcW( hwnd, message, wParam, lParam ) :
DefWindowProcA( hwnd, message, wParam, lParam );
}
......
......@@ -1126,20 +1126,13 @@ LRESULT NC_HandleNCPaint( HWND hwnd , HRGN clip)
*/
LRESULT NC_HandleNCActivate( HWND hwnd, WPARAM wParam, LPARAM lParam )
{
HWND parent;
WND* wndPtr = WIN_GetPtr( hwnd );
if (!wndPtr || wndPtr == WND_OTHER_PROCESS) return FALSE;
/* Lotus Notes draws menu descriptions in the caption of its main
* window. When it wants to restore original "system" view, it just
* sends WM_NCACTIVATE message to itself. Any optimizations here in
* attempt to minimize redrawings lead to a not restored caption.
*/
if (wParam) wndPtr->flags |= WIN_NCACTIVATED;
else wndPtr->flags &= ~WIN_NCACTIVATED;
parent = wndPtr->parent;
WIN_ReleasePtr( wndPtr );
if (wParam) win_set_flags( hwnd, WIN_NCACTIVATED, 0 );
else win_set_flags( hwnd, 0, WIN_NCACTIVATED );
/* This isn't documented but is reproducible in at least XP SP2 and
* Outlook 2007 depends on it
......@@ -1151,8 +1144,8 @@ LRESULT NC_HandleNCActivate( HWND hwnd, WPARAM wParam, LPARAM lParam )
else
NC_DoNCPaint( hwnd, (HRGN)1 );
if (parent == GetDesktopWindow())
PostMessageW( parent, WM_PARENTNOTIFY, WM_NCACTIVATE, (LPARAM)hwnd );
if (GetAncestor( hwnd, GA_PARENT ) == GetDesktopWindow())
PostMessageW( GetDesktopWindow(), WM_PARENTNOTIFY, WM_NCACTIVATE, (LPARAM)hwnd );
}
return TRUE;
......
......@@ -664,6 +664,24 @@ HWND WIN_IsCurrentThread( HWND hwnd )
/***********************************************************************
* win_set_flags
*
* Set the flags of a window and return the previous value.
*/
UINT win_set_flags( HWND hwnd, UINT set_mask, UINT clear_mask )
{
UINT ret;
WND *ptr = WIN_GetPtr( hwnd );
if (!ptr || ptr == WND_OTHER_PROCESS || ptr == WND_DESKTOP) return 0;
ret = ptr->flags;
ptr->flags = (ret & ~clear_mask) | set_mask;
WIN_ReleasePtr( ptr );
return ret;
}
/***********************************************************************
* WIN_GetFullHandle
*
* Convert a possibly truncated window handle to a full 32-bit handle.
......@@ -1323,16 +1341,7 @@ HWND WIN_CreateWindowEx( CREATESTRUCTW *cs, LPCWSTR className, HINSTANCE module,
/* Fix the styles for MDI children */
if (cs->dwExStyle & WS_EX_MDICHILD)
{
UINT flags = 0;
wndPtr = WIN_GetPtr(cs->hwndParent);
if (wndPtr && wndPtr != WND_OTHER_PROCESS && wndPtr != WND_DESKTOP)
{
flags = wndPtr->flags;
WIN_ReleasePtr(wndPtr);
}
if (!(flags & WIN_ISMDICLIENT))
if (!(win_get_flags( cs->hwndParent ) & WIN_ISMDICLIENT))
{
WARN("WS_EX_MDICHILD, but parent %p is not MDIClient\n", cs->hwndParent);
return 0;
......@@ -1627,17 +1636,13 @@ HWND WIN_CreateWindowEx( CREATESTRUCTW *cs, LPCWSTR className, HINSTANCE module,
/* send the size messages */
if (!(wndPtr = WIN_GetPtr( hwnd )) ||
wndPtr == WND_OTHER_PROCESS || wndPtr == WND_DESKTOP) return 0;
if (!(wndPtr->flags & WIN_NEED_SIZE))
if (!(win_get_flags( hwnd ) & WIN_NEED_SIZE))
{
WIN_ReleasePtr( wndPtr );
WIN_GetRectangles( hwnd, COORDS_PARENT, NULL, &rect );
SendMessageW( hwnd, WM_SIZE, SIZE_RESTORED,
MAKELONG(rect.right-rect.left, rect.bottom-rect.top));
SendMessageW( hwnd, WM_MOVE, 0, MAKELONG( rect.left, rect.top ) );
}
else WIN_ReleasePtr( wndPtr );
/* Show the window, maximizing or minimizing if needed */
......@@ -3212,7 +3217,6 @@ HWND WINAPI GetWindow( HWND hwnd, UINT rel )
BOOL WINAPI ShowOwnedPopups( HWND owner, BOOL fShow )
{
int count = 0;
WND *pWnd;
HWND *win_array = WIN_ListChildren( GetDesktopWindow() );
if (!win_array) return TRUE;
......@@ -3221,35 +3225,24 @@ BOOL WINAPI ShowOwnedPopups( HWND owner, BOOL fShow )
while (--count >= 0)
{
if (GetWindow( win_array[count], GW_OWNER ) != owner) continue;
if (!(pWnd = WIN_GetPtr( win_array[count] ))) continue;
if (pWnd == WND_OTHER_PROCESS) continue;
if (fShow)
{
if (pWnd->flags & WIN_NEEDS_SHOW_OWNEDPOPUP)
{
WIN_ReleasePtr( pWnd );
if (win_get_flags( win_array[count] ) & WIN_NEEDS_SHOW_OWNEDPOPUP)
/* In Windows, ShowOwnedPopups(TRUE) generates
* WM_SHOWWINDOW messages with SW_PARENTOPENING,
* regardless of the state of the owner
*/
SendMessageW(win_array[count], WM_SHOWWINDOW, SW_SHOWNORMAL, SW_PARENTOPENING);
continue;
}
}
else
{
if (pWnd->dwStyle & WS_VISIBLE)
{
WIN_ReleasePtr( pWnd );
if (GetWindowLongW( win_array[count], GWL_STYLE ) & WS_VISIBLE)
/* In Windows, ShowOwnedPopups(FALSE) generates
* WM_SHOWWINDOW messages with SW_PARENTCLOSING,
* regardless of the state of the owner
*/
SendMessageW(win_array[count], WM_SHOWWINDOW, SW_HIDE, SW_PARENTCLOSING);
continue;
}
}
WIN_ReleasePtr( pWnd );
}
HeapFree( GetProcessHeap(), 0, win_array );
return TRUE;
......
......@@ -88,6 +88,7 @@ extern WND *WIN_GetPtr( HWND hwnd ) DECLSPEC_HIDDEN;
extern HWND WIN_GetFullHandle( HWND hwnd ) DECLSPEC_HIDDEN;
extern HWND WIN_IsCurrentProcess( HWND hwnd ) DECLSPEC_HIDDEN;
extern HWND WIN_IsCurrentThread( HWND hwnd ) DECLSPEC_HIDDEN;
extern UINT win_set_flags( HWND hwnd, UINT set_mask, UINT clear_mask ) DECLSPEC_HIDDEN;
extern HWND WIN_SetOwner( HWND hwnd, HWND owner ) DECLSPEC_HIDDEN;
extern ULONG WIN_SetStyle( HWND hwnd, ULONG set_bits, ULONG clear_bits ) DECLSPEC_HIDDEN;
extern BOOL WIN_GetRectangles( HWND hwnd, enum coords_relative relative, RECT *rectWindow, RECT *rectClient ) DECLSPEC_HIDDEN;
......@@ -137,4 +138,9 @@ static inline void mirror_rect( const RECT *window_rect, RECT *rect )
rect->right = width - tmp;
}
static inline UINT win_get_flags( HWND hwnd )
{
return win_set_flags( hwnd, 0, 0 );
}
#endif /* __WINE_WIN_H */
......@@ -940,7 +940,6 @@ static POINT WINPOS_FindIconPos( HWND hwnd, POINT pt )
*/
UINT WINPOS_MinMaximize( HWND hwnd, UINT cmd, LPRECT rect )
{
WND *wndPtr;
UINT swpFlags = 0;
POINT size;
LONG old_style;
......@@ -974,10 +973,8 @@ UINT WINPOS_MinMaximize( HWND hwnd, UINT cmd, LPRECT rect )
case SW_SHOWMINIMIZED:
case SW_FORCEMINIMIZE:
case SW_MINIMIZE:
if (!(wndPtr = WIN_GetPtr( hwnd )) || wndPtr == WND_OTHER_PROCESS) return 0;
if( wndPtr->dwStyle & WS_MAXIMIZE) wndPtr->flags |= WIN_RESTORE_MAX;
else wndPtr->flags &= ~WIN_RESTORE_MAX;
WIN_ReleasePtr( wndPtr );
if (IsZoomed( hwnd )) win_set_flags( hwnd, WIN_RESTORE_MAX, 0 );
else win_set_flags( hwnd, 0, WIN_RESTORE_MAX );
old_style = WIN_SetStyle( hwnd, WS_MINIMIZE, WS_MAXIMIZE );
......@@ -999,11 +996,7 @@ UINT WINPOS_MinMaximize( HWND hwnd, UINT cmd, LPRECT rect )
old_style = WIN_SetStyle( hwnd, WS_MAXIMIZE, WS_MINIMIZE );
if (old_style & WS_MINIMIZE)
{
if ((wndPtr = WIN_GetPtr( hwnd )) && wndPtr != WND_OTHER_PROCESS)
{
wndPtr->flags |= WIN_RESTORE_MAX;
WIN_ReleasePtr( wndPtr );
}
win_set_flags( hwnd, WIN_RESTORE_MAX, 0 );
WINPOS_ShowIconTitle( hwnd, FALSE );
}
......@@ -1013,11 +1006,7 @@ UINT WINPOS_MinMaximize( HWND hwnd, UINT cmd, LPRECT rect )
break;
case SW_SHOWNOACTIVATE:
if ((wndPtr = WIN_GetPtr( hwnd )) && wndPtr != WND_OTHER_PROCESS)
{
wndPtr->flags &= ~WIN_RESTORE_MAX;
WIN_ReleasePtr( wndPtr );
}
win_set_flags( hwnd, 0, WIN_RESTORE_MAX );
/* fall through */
case SW_SHOWNORMAL:
case SW_RESTORE:
......@@ -1025,14 +1014,8 @@ UINT WINPOS_MinMaximize( HWND hwnd, UINT cmd, LPRECT rect )
old_style = WIN_SetStyle( hwnd, 0, WS_MINIMIZE | WS_MAXIMIZE );
if (old_style & WS_MINIMIZE)
{
BOOL restore_max;
WINPOS_ShowIconTitle( hwnd, FALSE );
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)
if (win_get_flags( hwnd ) & WIN_RESTORE_MAX)
{
/* Restore to maximized position */
WINPOS_GetMinMaxInfo( hwnd, &size, &wpl.ptMaxPosition, NULL, NULL);
......@@ -1454,14 +1437,7 @@ static BOOL WINPOS_SetPlacement( HWND hwnd, const WINDOWPLACEMENT *wndpl, UINT f
/* SDK: ...valid only the next time... */
if( wndpl->flags & WPF_RESTORETOMAXIMIZED )
{
pWnd = WIN_GetPtr( hwnd );
if (pWnd && pWnd != WND_OTHER_PROCESS)
{
pWnd->flags |= WIN_RESTORE_MAX;
WIN_ReleasePtr( pWnd );
}
}
win_set_flags( hwnd, WIN_RESTORE_MAX, 0 );
}
return TRUE;
}
......
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