From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/user32/user32.spec | 2 +- dlls/user32/winpos.c | 15 ----- dlls/win32u/gdiobj.c | 1 + dlls/win32u/sysparams.c | 20 ++++++ dlls/win32u/win32u.spec | 2 +- dlls/win32u/win32u_private.h | 3 + dlls/win32u/window.c | 119 +++++++++++++++++++++++++++++++++++ dlls/win32u/wrappers.c | 6 ++ include/ntuser.h | 1 + 9 files changed, 152 insertions(+), 17 deletions(-)
diff --git a/dlls/user32/user32.spec b/dlls/user32/user32.spec index 555023de110..dfa5c2516b9 100644 --- a/dlls/user32/user32.spec +++ b/dlls/user32/user32.spec @@ -725,7 +725,7 @@ @ stdcall -arch=win64 SetWindowLongPtrA(long long long) @ stdcall -arch=win64 SetWindowLongPtrW(long long long) @ stdcall SetWindowLongW(long long long) -@ stdcall SetWindowPlacement(long ptr) +@ stdcall SetWindowPlacement(long ptr) NtUserSetWindowPlacement @ stdcall SetWindowPos(long long long long long long long) NtUserSetWindowPos @ stdcall SetWindowRgn(long long long) NtUserSetWindowRgn @ stdcall SetWindowStationUser(long long) diff --git a/dlls/user32/winpos.c b/dlls/user32/winpos.c index 5987d06c257..d19ebab3e6e 100644 --- a/dlls/user32/winpos.c +++ b/dlls/user32/winpos.c @@ -428,21 +428,6 @@ static BOOL WINPOS_SetPlacement( HWND hwnd, const WINDOWPLACEMENT *wndpl, UINT f }
-/*********************************************************************** - * SetWindowPlacement (USER32.@) - * - * Win95: - * Fails if wndpl->length of Win95 (!) apps is invalid. - */ -BOOL WINAPI SetWindowPlacement( HWND hwnd, const WINDOWPLACEMENT *wpl ) -{ - UINT flags = PLACE_MAX | PLACE_RECT; - if (!wpl) return FALSE; - if (wpl->flags & WPF_SETMINPOSITION) flags |= PLACE_MIN; - return WINPOS_SetPlacement( hwnd, wpl, flags ); -} - - /*********************************************************************** * AnimateWindow (USER32.@) * Shows/Hides a window with an animation diff --git a/dlls/win32u/gdiobj.c b/dlls/win32u/gdiobj.c index 96d52e4d38e..b9c71674e75 100644 --- a/dlls/win32u/gdiobj.c +++ b/dlls/win32u/gdiobj.c @@ -1219,6 +1219,7 @@ static struct unix_funcs unix_funcs = NtUserSetSystemMenu, NtUserSetWindowLong, NtUserSetWindowLongPtr, + NtUserSetWindowPlacement, NtUserSetWindowPos, NtUserSetWindowRgn, NtUserSetWindowWord, diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c index dd494188121..f9491313384 100644 --- a/dlls/win32u/sysparams.c +++ b/dlls/win32u/sysparams.c @@ -1515,6 +1515,26 @@ POINT point_phys_to_win_dpi( HWND hwnd, POINT pt ) return map_dpi_point( pt, get_win_monitor_dpi( hwnd ), get_dpi_for_window( hwnd )); }
+/********************************************************************** + * point_thread_to_win_dpi + */ +POINT point_thread_to_win_dpi( HWND hwnd, POINT pt ) +{ + UINT dpi = get_thread_dpi(); + if (!dpi) dpi = get_win_monitor_dpi( hwnd ); + return map_dpi_point( pt, dpi, get_dpi_for_window( hwnd )); +} + +/********************************************************************** + * rect_thread_to_win_dpi + */ +RECT rect_thread_to_win_dpi( HWND hwnd, RECT rect ) +{ + UINT dpi = get_thread_dpi(); + if (!dpi) dpi = get_win_monitor_dpi( hwnd ); + return map_dpi_rect( rect, dpi, get_dpi_for_window( hwnd ) ); +} + /* map value from system dpi to standard 96 dpi for storing in the registry */ static int map_from_system_dpi( int val ) { diff --git a/dlls/win32u/win32u.spec b/dlls/win32u/win32u.spec index 1c3cbc59dc2..1652446a503 100644 --- a/dlls/win32u/win32u.spec +++ b/dlls/win32u/win32u.spec @@ -1248,7 +1248,7 @@ @ stub NtUserSetWindowGroup @ stdcall NtUserSetWindowLong(long long long long) @ stdcall NtUserSetWindowLongPtr(long long long long) -@ stub NtUserSetWindowPlacement +@ stdcall NtUserSetWindowPlacement(long ptr) @ stdcall NtUserSetWindowPos(long long long long long long long) @ stdcall NtUserSetWindowRgn(long long long) @ stub NtUserSetWindowRgnEx diff --git a/dlls/win32u/win32u_private.h b/dlls/win32u/win32u_private.h index 02784df64f8..c9da765e6a1 100644 --- a/dlls/win32u/win32u_private.h +++ b/dlls/win32u/win32u_private.h @@ -289,6 +289,7 @@ struct unix_funcs BOOL (WINAPI *pNtUserSetSystemMenu)( HWND hwnd, HMENU menu ); LONG (WINAPI *pNtUserSetWindowLong)( HWND hwnd, INT offset, LONG newval, BOOL ansi ); LONG_PTR (WINAPI *pNtUserSetWindowLongPtr)( HWND hwnd, INT offset, LONG_PTR newval, BOOL ansi ); + BOOL (WINAPI *pNtUserSetWindowPlacement)( HWND hwnd, const WINDOWPLACEMENT *wpl ); BOOL (WINAPI *pNtUserSetWindowPos)( HWND hwnd, HWND after, INT x, INT y, INT cx, INT cy, UINT flags ); int (WINAPI *pNtUserSetWindowRgn)( HWND hwnd, HRGN hrgn, BOOL redraw ); WORD (WINAPI *pNtUserSetWindowWord)( HWND hwnd, INT offset, WORD newval ); @@ -418,6 +419,8 @@ extern BOOL is_exiting_thread( DWORD tid ) DECLSPEC_HIDDEN; extern POINT map_dpi_point( POINT pt, UINT dpi_from, UINT dpi_to ) DECLSPEC_HIDDEN; extern RECT map_dpi_rect( RECT rect, UINT dpi_from, UINT dpi_to ) DECLSPEC_HIDDEN; extern POINT point_phys_to_win_dpi( HWND hwnd, POINT pt ) DECLSPEC_HIDDEN; +extern POINT point_thread_to_win_dpi( HWND hwnd, POINT pt ) DECLSPEC_HIDDEN; +extern RECT rect_thread_to_win_dpi( HWND hwnd, RECT rect ) DECLSPEC_HIDDEN; extern HMONITOR monitor_from_point( POINT pt, DWORD flags, UINT dpi ) DECLSPEC_HIDDEN; extern HMONITOR monitor_from_rect( const RECT *rect, DWORD flags, UINT dpi ) DECLSPEC_HIDDEN; extern HMONITOR monitor_from_window( HWND hwnd, DWORD flags, UINT dpi ) DECLSPEC_HIDDEN; diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c index 31512c03e15..e75f47a2fe6 100644 --- a/dlls/win32u/window.c +++ b/dlls/win32u/window.c @@ -48,6 +48,10 @@ static void *user_handles[NB_USER_HANDLES]; #define SWP_AGG_NOCLIENTCHANGE \ (SWP_NOCLIENTSIZE | SWP_NOCLIENTMOVE)
+#define PLACE_MIN 0x0001 +#define PLACE_MAX 0x0002 +#define PLACE_RECT 0x0004 + /*********************************************************************** * alloc_user_handle */ @@ -2484,6 +2488,121 @@ BOOL get_window_placement( HWND hwnd, WINDOWPLACEMENT *placement ) return TRUE; }
+/* make sure the specified rect is visible on screen */ +static void make_rect_onscreen( RECT *rect ) +{ + MONITORINFO info; + HMONITOR monitor = monitor_from_rect( rect, MONITOR_DEFAULTTONEAREST, get_thread_dpi() ); + + info.cbSize = sizeof(info); + if (!monitor || !get_monitor_info( monitor, &info )) return; + /* FIXME: map coordinates from rcWork to rcMonitor */ + if (rect->right <= info.rcWork.left) + { + rect->right += info.rcWork.left - rect->left; + rect->left = info.rcWork.left; + } + else if (rect->left >= info.rcWork.right) + { + rect->left += info.rcWork.right - rect->right; + rect->right = info.rcWork.right; + } + if (rect->bottom <= info.rcWork.top) + { + rect->bottom += info.rcWork.top - rect->top; + rect->top = info.rcWork.top; + } + else if (rect->top >= info.rcWork.bottom) + { + rect->top += info.rcWork.bottom - rect->bottom; + rect->bottom = info.rcWork.bottom; + } +} + +/* make sure the specified point is visible on screen */ +static void make_point_onscreen( POINT *pt ) +{ + RECT rect; + + SetRect( &rect, pt->x, pt->y, pt->x + 1, pt->y + 1 ); + make_rect_onscreen( &rect ); + pt->x = rect.left; + pt->y = rect.top; +} + +static BOOL set_window_placement( HWND hwnd, const WINDOWPLACEMENT *wndpl, UINT flags ) +{ + RECT work_rect = get_maximized_work_rect( hwnd ); + WND *win = get_win_ptr( hwnd ); + WINDOWPLACEMENT wp = *wndpl; + DWORD style; + + if (flags & PLACE_MIN) make_point_onscreen( &wp.ptMinPosition ); + if (flags & PLACE_MAX) make_point_onscreen( &wp.ptMaxPosition ); + if (flags & PLACE_RECT) make_rect_onscreen( &wp.rcNormalPosition ); + + TRACE( "%p: setting min %d,%d max %d,%d normal %s flags %x adjusted to min %d,%d max %d,%d normal %s\n", + hwnd, wndpl->ptMinPosition.x, wndpl->ptMinPosition.y, + wndpl->ptMaxPosition.x, wndpl->ptMaxPosition.y, + wine_dbgstr_rect(&wndpl->rcNormalPosition), flags, + wp.ptMinPosition.x, wp.ptMinPosition.y, wp.ptMaxPosition.x, wp.ptMaxPosition.y, + wine_dbgstr_rect(&wp.rcNormalPosition) ); + + if (!win || win == WND_OTHER_PROCESS || win == WND_DESKTOP) return FALSE; + + if (flags & PLACE_MIN) win->min_pos = point_thread_to_win_dpi( hwnd, wp.ptMinPosition ); + if (flags & PLACE_MAX) + { + win->max_pos = point_thread_to_win_dpi( hwnd, wp.ptMaxPosition ); + update_maximized_pos( win, &work_rect ); + } + if (flags & PLACE_RECT) win->normal_rect = rect_thread_to_win_dpi( hwnd, wp.rcNormalPosition ); + + style = win->dwStyle; + + release_win_ptr( win ); + + if (style & WS_MINIMIZE) + { + if (flags & PLACE_MIN) + { + NtUserSetWindowPos( hwnd, 0, wp.ptMinPosition.x, wp.ptMinPosition.y, 0, 0, + SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE ); + } + } + else if (style & WS_MAXIMIZE) + { + if (flags & PLACE_MAX) + NtUserSetWindowPos( hwnd, 0, wp.ptMaxPosition.x, wp.ptMaxPosition.y, 0, 0, + SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE ); + } + else if (flags & PLACE_RECT) + NtUserSetWindowPos( hwnd, 0, wp.rcNormalPosition.left, wp.rcNormalPosition.top, + wp.rcNormalPosition.right - wp.rcNormalPosition.left, + wp.rcNormalPosition.bottom - wp.rcNormalPosition.top, + SWP_NOZORDER | SWP_NOACTIVATE ); + + NtUserShowWindow( hwnd, wndpl->showCmd ); + + if (is_iconic( hwnd )) + { + if (wndpl->flags & WPF_RESTORETOMAXIMIZED) + win_set_flags( hwnd, WIN_RESTORE_MAX, 0 ); + } + return TRUE; +} + +/*********************************************************************** + * NtUserSetWindowPlacement (win32u.@) + */ +BOOL WINAPI NtUserSetWindowPlacement( HWND hwnd, const WINDOWPLACEMENT *wpl ) +{ + UINT flags = PLACE_MAX | PLACE_RECT; + if (!wpl) return FALSE; + if (wpl->flags & WPF_SETMINPOSITION) flags |= PLACE_MIN; + return set_window_placement( hwnd, wpl, flags ); +} + /***************************************************************************** * NtUserBuildHwndList (win32u.@) */ diff --git a/dlls/win32u/wrappers.c b/dlls/win32u/wrappers.c index 4e750e5aea2..64f823ccd26 100644 --- a/dlls/win32u/wrappers.c +++ b/dlls/win32u/wrappers.c @@ -1227,6 +1227,12 @@ LONG_PTR WINAPI NtUserSetWindowLongPtr( HWND hwnd, INT offset, LONG_PTR newval, return unix_funcs->pNtUserSetWindowLongPtr( hwnd, offset, newval, ansi ); }
+BOOL WINAPI NtUserSetWindowPlacement( HWND hwnd, const WINDOWPLACEMENT *wpl ) +{ + if (!unix_funcs) return 0; + return unix_funcs->pNtUserSetWindowPlacement( hwnd, wpl ); +} + BOOL WINAPI NtUserSetWindowPos( HWND hwnd, HWND after, INT x, INT y, INT cx, INT cy, UINT flags ) { if (!unix_funcs) return 0; diff --git a/include/ntuser.h b/include/ntuser.h index a39fffaedf9..af87d8a5fec 100644 --- a/include/ntuser.h +++ b/include/ntuser.h @@ -641,6 +641,7 @@ BOOL WINAPI NtUserSetThreadDesktop( HDESK handle ); UINT_PTR WINAPI NtUserSetTimer( HWND hwnd, UINT_PTR id, UINT timeout, TIMERPROC proc, ULONG tolerance ); LONG WINAPI NtUserSetWindowLong( HWND hwnd, INT offset, LONG newval, BOOL ansi ); LONG_PTR WINAPI NtUserSetWindowLongPtr( HWND hwnd, INT offset, LONG_PTR newval, BOOL ansi ); +BOOL WINAPI NtUserSetWindowPlacement( HWND hwnd, const WINDOWPLACEMENT *wpl ); BOOL WINAPI NtUserSetWindowPos( HWND hwnd, HWND after, INT x, INT y, INT cx, INT cy, UINT flags ); int WINAPI NtUserSetWindowRgn( HWND hwnd, HRGN hrgn, BOOL redraw ); WORD WINAPI NtUserSetWindowWord( HWND hwnd, INT offset, WORD newval );
From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/user32/sysparams.c | 20 ---- dlls/user32/user32.spec | 2 +- dlls/user32/win.h | 2 - dlls/user32/winpos.c | 208 ----------------------------------- dlls/win32u/gdiobj.c | 1 + dlls/win32u/win32u.spec | 2 +- dlls/win32u/win32u_private.h | 1 + dlls/win32u/window.c | 26 +++++ dlls/win32u/wrappers.c | 6 + include/ntuser.h | 1 + 10 files changed, 37 insertions(+), 232 deletions(-)
diff --git a/dlls/user32/sysparams.c b/dlls/user32/sysparams.c index c42b6c77b0c..ec83a1822a5 100644 --- a/dlls/user32/sysparams.c +++ b/dlls/user32/sysparams.c @@ -739,16 +739,6 @@ POINT point_win_to_thread_dpi( HWND hwnd, POINT pt ) return map_dpi_point( pt, GetDpiForWindow( hwnd ), dpi ); }
-/********************************************************************** - * point_thread_to_win_dpi - */ -POINT point_thread_to_win_dpi( HWND hwnd, POINT pt ) -{ - UINT dpi = get_thread_dpi(); - if (!dpi) dpi = get_win_monitor_dpi( hwnd ); - return map_dpi_point( pt, dpi, GetDpiForWindow( hwnd )); -} - /********************************************************************** * map_dpi_rect */ @@ -774,16 +764,6 @@ RECT rect_win_to_thread_dpi( HWND hwnd, RECT rect ) return map_dpi_rect( rect, GetDpiForWindow( hwnd ), dpi ); }
-/********************************************************************** - * rect_thread_to_win_dpi - */ -RECT rect_thread_to_win_dpi( HWND hwnd, RECT rect ) -{ - UINT dpi = get_thread_dpi(); - if (!dpi) dpi = get_win_monitor_dpi( hwnd ); - return map_dpi_rect( rect, dpi, GetDpiForWindow( hwnd ) ); -} - /********************************************************************** * SetProcessDpiAwarenessContext (USER32.@) */ diff --git a/dlls/user32/user32.spec b/dlls/user32/user32.spec index dfa5c2516b9..d251b80fb70 100644 --- a/dlls/user32/user32.spec +++ b/dlls/user32/user32.spec @@ -673,7 +673,7 @@ @ stdcall SetFocus(long) NtUserSetFocus @ stdcall SetForegroundWindow(long) @ stdcall SetGestureConfig(ptr long long ptr long) -@ stdcall SetInternalWindowPos(long long ptr ptr) +@ stdcall SetInternalWindowPos(long long ptr ptr) NtUserSetInternalWindowPos @ stdcall SetKeyboardState(ptr) NtUserSetKeyboardState @ stdcall SetLastErrorEx(long long) @ stdcall SetLayeredWindowAttributes(ptr long long long) NtUserSetLayeredWindowAttributes diff --git a/dlls/user32/win.h b/dlls/user32/win.h index 2155ea51e94..dfa5fdf3283 100644 --- a/dlls/user32/win.h +++ b/dlls/user32/win.h @@ -70,10 +70,8 @@ extern POINT map_dpi_point( POINT pt, UINT dpi_from, UINT dpi_to ) DECLSPEC_HIDD extern POINT point_win_to_phys_dpi( HWND hwnd, POINT pt ) DECLSPEC_HIDDEN; extern POINT point_phys_to_win_dpi( HWND hwnd, POINT pt ) DECLSPEC_HIDDEN; extern POINT point_win_to_thread_dpi( HWND hwnd, POINT pt ) DECLSPEC_HIDDEN; -extern POINT point_thread_to_win_dpi( HWND hwnd, POINT pt ) DECLSPEC_HIDDEN; extern RECT map_dpi_rect( RECT rect, UINT dpi_from, UINT dpi_to ) DECLSPEC_HIDDEN; extern RECT rect_win_to_thread_dpi( HWND hwnd, RECT rect ) DECLSPEC_HIDDEN; -extern RECT rect_thread_to_win_dpi( HWND hwnd, RECT rect ) DECLSPEC_HIDDEN;
static inline void mirror_rect( const RECT *window_rect, RECT *rect ) { diff --git a/dlls/user32/winpos.c b/dlls/user32/winpos.c index d19ebab3e6e..e4eee036f07 100644 --- a/dlls/user32/winpos.c +++ b/dlls/user32/winpos.c @@ -44,10 +44,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(win); #define ON_BOTTOM_BORDER(hit) \ (((hit) == HTBOTTOM) || ((hit) == HTBOTTOMLEFT) || ((hit) == HTBOTTOMRIGHT))
-#define PLACE_MIN 0x0001 -#define PLACE_MAX 0x0002 -#define PLACE_RECT 0x0004 -
/*********************************************************************** * SwitchToThisWindow (USER32.@) @@ -220,33 +216,6 @@ BOOL WINAPI BringWindowToTop( HWND hwnd ) }
-/******************************************************************* - * get_work_rect - * - * Get the work area that a maximized window can cover, depending on style. - */ -static BOOL get_work_rect( HWND hwnd, RECT *rect ) -{ - HMONITOR monitor = MonitorFromWindow( hwnd, MONITOR_DEFAULTTOPRIMARY ); - MONITORINFO mon_info; - DWORD style; - - if (!monitor) return FALSE; - - mon_info.cbSize = sizeof(mon_info); - GetMonitorInfoW( monitor, &mon_info ); - *rect = mon_info.rcMonitor; - - style = GetWindowLongW( hwnd, GWL_STYLE ); - if (style & WS_MAXIMIZEBOX) - { - if ((style & WS_CAPTION) == WS_CAPTION || !(style & (WS_CHILD | WS_POPUP))) - *rect = mon_info.rcWork; - } - return TRUE; -} - - /*********************************************************************** * GetInternalWindowPos (USER32.@) */ @@ -266,47 +235,6 @@ UINT WINAPI GetInternalWindowPos( HWND hwnd, LPRECT rectWnd, }
-static RECT get_maximized_work_rect( HWND hwnd ) -{ - RECT work_rect = { 0 }; - - if ((GetWindowLongW( hwnd, GWL_STYLE ) & (WS_MINIMIZE | WS_MAXIMIZE)) == WS_MAXIMIZE) - { - if (!get_work_rect( hwnd, &work_rect )) - work_rect = get_primary_monitor_rect(); - } - return work_rect; -} - - -/******************************************************************* - * update_maximized_pos - * - * For top level windows covering the work area, we might have to - * "forget" the maximized position. Windows presumably does this - * to avoid situations where the border style changes, which would - * lead the window to be outside the screen, or the window gets - * reloaded on a different screen, and the "saved" position no - * longer applies to it (despite being maximized). - * - * Some applications (e.g. Imperiums: Greek Wars) depend on this. - */ -static void update_maximized_pos( WND *wnd, RECT *work_rect ) -{ - if (wnd->parent && wnd->parent != GetDesktopWindow()) - return; - - if (wnd->dwStyle & WS_MAXIMIZE) - { - if (wnd->window_rect.left <= work_rect->left && wnd->window_rect.top <= work_rect->top && - wnd->window_rect.right >= work_rect->right && wnd->window_rect.bottom >= work_rect->bottom) - wnd->max_pos.x = wnd->max_pos.y = -1; - } - else - wnd->max_pos.x = wnd->max_pos.y = -1; -} - - /*********************************************************************** * GetWindowPlacement (USER32.@) * @@ -318,115 +246,6 @@ BOOL WINAPI GetWindowPlacement( HWND hwnd, WINDOWPLACEMENT *wndpl ) return NtUserGetWindowPlacement( hwnd, wndpl ); }
-/* make sure the specified rect is visible on screen */ -static void make_rect_onscreen( RECT *rect ) -{ - MONITORINFO info; - HMONITOR monitor = MonitorFromRect( rect, MONITOR_DEFAULTTONEAREST ); - - info.cbSize = sizeof(info); - if (!monitor || !GetMonitorInfoW( monitor, &info )) return; - /* FIXME: map coordinates from rcWork to rcMonitor */ - if (rect->right <= info.rcWork.left) - { - rect->right += info.rcWork.left - rect->left; - rect->left = info.rcWork.left; - } - else if (rect->left >= info.rcWork.right) - { - rect->left += info.rcWork.right - rect->right; - rect->right = info.rcWork.right; - } - if (rect->bottom <= info.rcWork.top) - { - rect->bottom += info.rcWork.top - rect->top; - rect->top = info.rcWork.top; - } - else if (rect->top >= info.rcWork.bottom) - { - rect->top += info.rcWork.bottom - rect->bottom; - rect->bottom = info.rcWork.bottom; - } -} - -/* make sure the specified point is visible on screen */ -static void make_point_onscreen( POINT *pt ) -{ - RECT rect; - - SetRect( &rect, pt->x, pt->y, pt->x + 1, pt->y + 1 ); - make_rect_onscreen( &rect ); - pt->x = rect.left; - pt->y = rect.top; -} - - -/*********************************************************************** - * WINPOS_SetPlacement - */ -static BOOL WINPOS_SetPlacement( HWND hwnd, const WINDOWPLACEMENT *wndpl, UINT flags ) -{ - DWORD style; - RECT work_rect = get_maximized_work_rect( hwnd ); - WND *pWnd = WIN_GetPtr( hwnd ); - WINDOWPLACEMENT wp = *wndpl; - - if (flags & PLACE_MIN) make_point_onscreen( &wp.ptMinPosition ); - if (flags & PLACE_MAX) make_point_onscreen( &wp.ptMaxPosition ); - if (flags & PLACE_RECT) make_rect_onscreen( &wp.rcNormalPosition ); - - TRACE( "%p: setting min %d,%d max %d,%d normal %s flags %x adjusted to min %d,%d max %d,%d normal %s\n", - hwnd, wndpl->ptMinPosition.x, wndpl->ptMinPosition.y, - wndpl->ptMaxPosition.x, wndpl->ptMaxPosition.y, - wine_dbgstr_rect(&wndpl->rcNormalPosition), flags, - wp.ptMinPosition.x, wp.ptMinPosition.y, wp.ptMaxPosition.x, wp.ptMaxPosition.y, - wine_dbgstr_rect(&wp.rcNormalPosition) ); - - if (!pWnd || pWnd == WND_OTHER_PROCESS || pWnd == WND_DESKTOP) return FALSE; - - if (flags & PLACE_MIN) pWnd->min_pos = point_thread_to_win_dpi( hwnd, wp.ptMinPosition ); - if (flags & PLACE_MAX) - { - pWnd->max_pos = point_thread_to_win_dpi( hwnd, wp.ptMaxPosition ); - update_maximized_pos( pWnd, &work_rect ); - } - if (flags & PLACE_RECT) pWnd->normal_rect = rect_thread_to_win_dpi( hwnd, wp.rcNormalPosition ); - - style = pWnd->dwStyle; - - WIN_ReleasePtr( pWnd ); - - if( style & WS_MINIMIZE ) - { - if (flags & PLACE_MIN) - { - NtUserSetWindowPos( hwnd, 0, wp.ptMinPosition.x, wp.ptMinPosition.y, 0, 0, - SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE ); - } - } - else if( style & WS_MAXIMIZE ) - { - if (flags & PLACE_MAX) - NtUserSetWindowPos( hwnd, 0, wp.ptMaxPosition.x, wp.ptMaxPosition.y, 0, 0, - SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE ); - } - else if( flags & PLACE_RECT ) - NtUserSetWindowPos( hwnd, 0, wp.rcNormalPosition.left, wp.rcNormalPosition.top, - wp.rcNormalPosition.right - wp.rcNormalPosition.left, - wp.rcNormalPosition.bottom - wp.rcNormalPosition.top, - SWP_NOZORDER | SWP_NOACTIVATE ); - - NtUserShowWindow( hwnd, wndpl->showCmd ); - - if (IsIconic( hwnd )) - { - /* SDK: ...valid only the next time... */ - if( wndpl->flags & WPF_RESTORETOMAXIMIZED ) - win_set_flags( hwnd, WIN_RESTORE_MAX, 0 ); - } - return TRUE; -} -
/*********************************************************************** * AnimateWindow (USER32.@) @@ -453,33 +272,6 @@ BOOL WINAPI AnimateWindow(HWND hwnd, DWORD dwTime, DWORD dwFlags) return TRUE; }
-/*********************************************************************** - * SetInternalWindowPos (USER32.@) - */ -void WINAPI SetInternalWindowPos( HWND hwnd, UINT showCmd, - LPRECT rect, LPPOINT pt ) -{ - WINDOWPLACEMENT wndpl; - UINT flags; - - wndpl.length = sizeof(wndpl); - wndpl.showCmd = showCmd; - wndpl.flags = flags = 0; - - if( pt ) - { - flags |= PLACE_MIN; - wndpl.flags |= WPF_SETMINPOSITION; - wndpl.ptMinPosition = *pt; - } - if( rect ) - { - flags |= PLACE_RECT; - wndpl.rcNormalPosition = *rect; - } - WINPOS_SetPlacement( hwnd, &wndpl, flags ); -} -
/******************************************************************* * can_activate_window diff --git a/dlls/win32u/gdiobj.c b/dlls/win32u/gdiobj.c index b9c71674e75..053ca5aa8f1 100644 --- a/dlls/win32u/gdiobj.c +++ b/dlls/win32u/gdiobj.c @@ -1212,6 +1212,7 @@ static struct unix_funcs unix_funcs = NtUserSetCursorIconData, NtUserSetCursorPos, NtUserSetFocus, + NtUserSetInternalWindowPos, NtUserSetLayeredWindowAttributes, NtUserSetMenu, NtUserSetParent, diff --git a/dlls/win32u/win32u.spec b/dlls/win32u/win32u.spec index 1652446a503..7ef2a4b2c7e 100644 --- a/dlls/win32u/win32u.spec +++ b/dlls/win32u/win32u.spec @@ -1201,7 +1201,7 @@ @ stub NtUserSetInputServiceState @ stub NtUserSetInteractiveControlFocus @ stub NtUserSetInteractiveCtrlRotationAngle -@ stub NtUserSetInternalWindowPos +@ stdcall NtUserSetInternalWindowPos(long long ptr ptr) @ stdcall -syscall NtUserSetKeyboardState(ptr) @ stdcall NtUserSetLayeredWindowAttributes(ptr long long long) @ stub NtUserSetMagnificationDesktopMagnifierOffsetsDWMUpdated diff --git a/dlls/win32u/win32u_private.h b/dlls/win32u/win32u_private.h index c9da765e6a1..0e1afb80e62 100644 --- a/dlls/win32u/win32u_private.h +++ b/dlls/win32u/win32u_private.h @@ -282,6 +282,7 @@ struct unix_funcs UNICODE_STRING *res_name, struct cursoricon_desc *desc ); BOOL (WINAPI *pNtUserSetCursorPos)( INT x, INT y ); HWND (WINAPI *pNtUserSetFocus)( HWND hwnd ); + void (WINAPI *pNtUserSetInternalWindowPos)( HWND hwnd, UINT cmd, RECT *rect, POINT *pt ); BOOL (WINAPI *pNtUserSetLayeredWindowAttributes)( HWND hwnd, COLORREF key, BYTE alpha, DWORD flags ); BOOL (WINAPI *pNtUserSetMenu)( HWND hwnd, HMENU menu ); HWND (WINAPI *pNtUserSetParent)( HWND hwnd, HWND parent ); diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c index e75f47a2fe6..440052d6e0b 100644 --- a/dlls/win32u/window.c +++ b/dlls/win32u/window.c @@ -3678,6 +3678,32 @@ BOOL WINAPI NtUserEndDeferWindowPosEx( HDWP hdwp, BOOL async ) return TRUE; }
+/*********************************************************************** + * NtUserSetInternalWindowPos (win32u.@) + */ +void WINAPI NtUserSetInternalWindowPos( HWND hwnd, UINT cmd, RECT *rect, POINT *pt ) +{ + WINDOWPLACEMENT wndpl; + UINT flags; + + wndpl.length = sizeof(wndpl); + wndpl.showCmd = cmd; + wndpl.flags = flags = 0; + + if (pt) + { + flags |= PLACE_MIN; + wndpl.flags |= WPF_SETMINPOSITION; + wndpl.ptMinPosition = *pt; + } + if( rect ) + { + flags |= PLACE_RECT; + wndpl.rcNormalPosition = *rect; + } + set_window_placement( hwnd, &wndpl, flags ); +} + /*********************************************************************** * win_set_flags * diff --git a/dlls/win32u/wrappers.c b/dlls/win32u/wrappers.c index 64f823ccd26..953de0caafc 100644 --- a/dlls/win32u/wrappers.c +++ b/dlls/win32u/wrappers.c @@ -1185,6 +1185,12 @@ HWND WINAPI NtUserSetFocus( HWND hwnd ) return unix_funcs->pNtUserSetFocus( hwnd ); }
+void WINAPI NtUserSetInternalWindowPos( HWND hwnd, UINT cmd, RECT *rect, POINT *pt ) +{ + if (!unix_funcs) return; + return unix_funcs->pNtUserSetInternalWindowPos( hwnd, cmd, rect, pt ); +} + BOOL WINAPI NtUserSetLayeredWindowAttributes( HWND hwnd, COLORREF key, BYTE alpha, DWORD flags ) { if (!unix_funcs) return FALSE; diff --git a/include/ntuser.h b/include/ntuser.h index af87d8a5fec..bc60f421f0e 100644 --- a/include/ntuser.h +++ b/include/ntuser.h @@ -625,6 +625,7 @@ BOOL WINAPI NtUserSetCursorIconData( HCURSOR cursor, UNICODE_STRING *module, struct cursoricon_desc *desc ); BOOL WINAPI NtUserSetCursorPos( INT x, INT y ); HWND WINAPI NtUserSetFocus( HWND hwnd ); +void WINAPI NtUserSetInternalWindowPos( HWND hwnd, UINT cmd, RECT *rect, POINT *pt ); BOOL WINAPI NtUserSetKeyboardState( BYTE *state ); BOOL WINAPI NtUserSetLayeredWindowAttributes( HWND hwnd, COLORREF key, BYTE alpha, DWORD flags ); BOOL WINAPI NtUserSetMenu( HWND hwnd, HMENU menu );
From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/user32/user32.spec | 2 +- dlls/user32/winpos.c | 14 +------------- dlls/win32u/gdiobj.c | 1 + dlls/win32u/sysparams.c | 2 +- dlls/win32u/win32u.spec | 2 +- dlls/win32u/win32u_private.h | 2 +- dlls/win32u/window.c | 11 +++++------ dlls/win32u/wrappers.c | 6 ++++++ include/ntuser.h | 8 +------- 9 files changed, 18 insertions(+), 30 deletions(-)
diff --git a/dlls/user32/user32.spec b/dlls/user32/user32.spec index d251b80fb70..c153b6dbfe3 100644 --- a/dlls/user32/user32.spec +++ b/dlls/user32/user32.spec @@ -412,7 +412,7 @@ @ stdcall GetWindowModuleFileName(long ptr long) GetWindowModuleFileNameA @ stdcall GetWindowModuleFileNameA(long ptr long) @ stdcall GetWindowModuleFileNameW(long ptr long) -@ stdcall GetWindowPlacement(long ptr) +@ stdcall GetWindowPlacement(long ptr) NtUserGetWindowPlacement @ stdcall GetWindowRect(long ptr) @ stdcall GetWindowRgn(long long) @ stdcall GetWindowRgnBox(long ptr) diff --git a/dlls/user32/winpos.c b/dlls/user32/winpos.c index e4eee036f07..03fe731ee0e 100644 --- a/dlls/user32/winpos.c +++ b/dlls/user32/winpos.c @@ -225,7 +225,7 @@ UINT WINAPI GetInternalWindowPos( HWND hwnd, LPRECT rectWnd, WINDOWPLACEMENT wndpl;
wndpl.length = sizeof(wndpl); - if (GetWindowPlacement( hwnd, &wndpl )) + if (NtUserGetWindowPlacement( hwnd, &wndpl )) { if (rectWnd) *rectWnd = wndpl.rcNormalPosition; if (ptIcon) *ptIcon = wndpl.ptMinPosition; @@ -235,18 +235,6 @@ UINT WINAPI GetInternalWindowPos( HWND hwnd, LPRECT rectWnd, }
-/*********************************************************************** - * GetWindowPlacement (USER32.@) - * - * Win95: - * Fails if wndpl->length of Win95 (!) apps is invalid. - */ -BOOL WINAPI GetWindowPlacement( HWND hwnd, WINDOWPLACEMENT *wndpl ) -{ - return NtUserGetWindowPlacement( hwnd, wndpl ); -} - - /*********************************************************************** * AnimateWindow (USER32.@) * Shows/Hides a window with an animation diff --git a/dlls/win32u/gdiobj.c b/dlls/win32u/gdiobj.c index 053ca5aa8f1..edb21456d8d 100644 --- a/dlls/win32u/gdiobj.c +++ b/dlls/win32u/gdiobj.c @@ -1184,6 +1184,7 @@ static struct unix_funcs unix_funcs = NtUserGetUpdateRect, NtUserGetUpdateRgn, NtUserGetUpdatedClipboardFormats, + NtUserGetWindowPlacement, NtUserHideCaret, NtUserIsClipboardFormatAvailable, NtUserMapVirtualKeyEx, diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c index f9491313384..8a99e4095f9 100644 --- a/dlls/win32u/sysparams.c +++ b/dlls/win32u/sysparams.c @@ -2163,7 +2163,7 @@ HMONITOR monitor_from_window( HWND hwnd, DWORD flags, UINT dpi ) TRACE( "(%p, 0x%08x)\n", hwnd, flags );
wp.length = sizeof(wp); - if (is_iconic( hwnd ) && get_window_placement( hwnd, &wp )) + if (is_iconic( hwnd ) && NtUserGetWindowPlacement( hwnd, &wp )) return monitor_from_rect( &wp.rcNormalPosition, flags, dpi );
if (get_window_rect( hwnd, &rect, dpi )) diff --git a/dlls/win32u/win32u.spec b/dlls/win32u/win32u.spec index 7ef2a4b2c7e..48c10fd45d3 100644 --- a/dlls/win32u/win32u.spec +++ b/dlls/win32u/win32u.spec @@ -1014,7 +1014,7 @@ @ stub NtUserGetWindowFeedbackSetting @ stub NtUserGetWindowGroupId @ stub NtUserGetWindowMinimizeRect -@ stub NtUserGetWindowPlacement +@ stdcall NtUserGetWindowPlacement(long ptr) @ stub NtUserGetWindowProcessHandle @ stdcall -syscall NtUserGetWindowRgnEx(long long long) @ stub NtUserGhostWindowFromHungWindow diff --git a/dlls/win32u/win32u_private.h b/dlls/win32u/win32u_private.h index 0e1afb80e62..c7340018830 100644 --- a/dlls/win32u/win32u_private.h +++ b/dlls/win32u/win32u_private.h @@ -246,6 +246,7 @@ struct unix_funcs BOOL (WINAPI *pNtUserGetUpdateRect)( HWND hwnd, RECT *rect, BOOL erase ); INT (WINAPI *pNtUserGetUpdateRgn)( HWND hwnd, HRGN hrgn, BOOL erase ); BOOL (WINAPI *pNtUserGetUpdatedClipboardFormats)( UINT *formats, UINT size, UINT *out_size ); + BOOL (WINAPI *pNtUserGetWindowPlacement)( HWND hwnd, WINDOWPLACEMENT *placement ); BOOL (WINAPI *pNtUserHideCaret)( HWND hwnd ); BOOL (WINAPI *pNtUserIsClipboardFormatAvailable)( UINT format ); UINT (WINAPI *pNtUserMapVirtualKeyEx)( UINT code, UINT type, HKL layout ); @@ -442,7 +443,6 @@ extern HWND get_full_window_handle( HWND hwnd ) DECLSPEC_HIDDEN; extern HWND get_parent( HWND hwnd ) DECLSPEC_HIDDEN; extern HWND get_hwnd_message_parent(void) DECLSPEC_HIDDEN; extern DPI_AWARENESS_CONTEXT get_window_dpi_awareness_context( HWND hwnd ) DECLSPEC_HIDDEN; -extern BOOL get_window_placement( HWND hwnd, WINDOWPLACEMENT *placement ) DECLSPEC_HIDDEN; extern MINMAXINFO get_min_max_info( HWND hwnd ) DECLSPEC_HIDDEN; extern HWND get_window_relative( HWND hwnd, UINT rel ) DECLSPEC_HIDDEN; extern DWORD get_window_thread( HWND hwnd, DWORD *process ) DECLSPEC_HIDDEN; diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c index 440052d6e0b..338063f5fb5 100644 --- a/dlls/win32u/window.c +++ b/dlls/win32u/window.c @@ -2400,8 +2400,10 @@ static BOOL empty_point( POINT pt ) return pt.x == -1 && pt.y == -1; }
-/* see GetWindowPlacement */ -BOOL get_window_placement( HWND hwnd, WINDOWPLACEMENT *placement ) +/*********************************************************************** + * NtUserGetWindowPlacement (win32u.@) + */ +BOOL WINAPI NtUserGetWindowPlacement( HWND hwnd, WINDOWPLACEMENT *placement ) { RECT work_rect = get_maximized_work_rect( hwnd ); WND *win = get_win_ptr( hwnd ); @@ -4036,7 +4038,7 @@ static UINT window_min_maximize( HWND hwnd, UINT cmd, RECT *rect ) TRACE( "%p %u\n", hwnd, cmd );
wpl.length = sizeof(wpl); - get_window_placement( hwnd, &wpl ); + NtUserGetWindowPlacement( hwnd, &wpl );
if (call_hooks( WH_CBT, HCBT_MINMAX, (WPARAM)hwnd, cmd, TRUE )) return SWP_NOSIZE | SWP_NOMOVE; @@ -5393,9 +5395,6 @@ ULONG_PTR WINAPI NtUserCallHwndParam( HWND hwnd, DWORD_PTR param, DWORD code ) case NtUserCallHwndParam_GetWindowLongPtrW: return get_window_long_ptr( hwnd, param, FALSE );
- case NtUserCallHwndParam_GetWindowPlacement: - return get_window_placement( hwnd, (WINDOWPLACEMENT *)param ); - case NtUserCallHwndParam_GetWindowRect: return get_window_rect( hwnd, (RECT *)param, get_thread_dpi() );
diff --git a/dlls/win32u/wrappers.c b/dlls/win32u/wrappers.c index 953de0caafc..13b4b7164ab 100644 --- a/dlls/win32u/wrappers.c +++ b/dlls/win32u/wrappers.c @@ -1023,6 +1023,12 @@ BOOL WINAPI NtUserGetUpdatedClipboardFormats( UINT *formats, UINT size, UINT *ou return unix_funcs->pNtUserGetUpdatedClipboardFormats( formats, size, out_size ); }
+BOOL WINAPI NtUserGetWindowPlacement( HWND hwnd, WINDOWPLACEMENT *placement ) +{ + if (!unix_funcs) return FALSE; + return unix_funcs->pNtUserGetWindowPlacement( hwnd, placement ); +} + BOOL WINAPI NtUserIsClipboardFormatAvailable( UINT format ) { if (!unix_funcs) return FALSE; diff --git a/include/ntuser.h b/include/ntuser.h index bc60f421f0e..c7490eaad0a 100644 --- a/include/ntuser.h +++ b/include/ntuser.h @@ -577,6 +577,7 @@ HDESK WINAPI NtUserGetThreadDesktop( DWORD thread ); INT WINAPI NtUserGetUpdateRgn( HWND hwnd, HRGN hrgn, BOOL erase ); BOOL WINAPI NtUserGetUpdatedClipboardFormats( UINT *formats, UINT size, UINT *out_size ); BOOL WINAPI NtUserGetUpdateRect( HWND hwnd, RECT *rect, BOOL erase ); +BOOL WINAPI NtUserGetWindowPlacement( HWND hwnd, WINDOWPLACEMENT *placement ); int WINAPI NtUserGetWindowRgnEx( HWND hwnd, HRGN hrgn, UINT unk ); BOOL WINAPI NtUserHideCaret( HWND hwnd ); NTSTATUS WINAPI NtUserInitializeClientPfnArrays( const struct user_client_procs *client_procsA, @@ -1000,7 +1001,6 @@ enum NtUserCallHwndParam_GetWindowLongW, NtUserCallHwndParam_GetWindowLongPtrA, NtUserCallHwndParam_GetWindowLongPtrW, - NtUserCallHwndParam_GetWindowPlacement, NtUserCallHwndParam_GetWindowRect, NtUserCallHwndParam_GetWindowRelative, NtUserCallHwndParam_GetWindowThread, @@ -1093,12 +1093,6 @@ static inline LONG NtUserGetWindowLongW( HWND hwnd, INT offset ) return NtUserCallHwndParam( hwnd, offset, NtUserCallHwndParam_GetWindowLongW ); }
-static inline BOOL NtUserGetWindowPlacement( HWND hwnd, WINDOWPLACEMENT *wndpl ) -{ - return NtUserCallHwndParam( hwnd, (UINT_PTR)wndpl, - NtUserCallHwndParam_GetWindowPlacement ); -} - static inline BOOL NtUserGetWindowRect( HWND hwnd, RECT *rect ) { return NtUserCallHwndParam( hwnd, (UINT_PTR)rect, NtUserCallHwndParam_GetWindowRect );
From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/user32/desktop.c | 27 +++++--------------------- dlls/win32u/defwnd.c | 37 ++++++++++++++++++++++++++++++++++++ dlls/win32u/message.c | 2 ++ dlls/win32u/win32u_private.h | 1 + include/ntuser.h | 1 + 5 files changed, 46 insertions(+), 22 deletions(-)
diff --git a/dlls/user32/desktop.c b/dlls/user32/desktop.c index 9d1484fdcbb..f2905b0efac 100644 --- a/dlls/user32/desktop.c +++ b/dlls/user32/desktop.c @@ -95,30 +95,13 @@ LRESULT WINAPI DesktopWndProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lP switch (message) { case WM_NCCREATE: - { - CREATESTRUCTW *cs = (CREATESTRUCTW *)lParam; - const GUID *guid = cs->lpCreateParams; - - if (guid) - { - ATOM atom; - WCHAR buffer[37]; - - if (NtUserGetAncestor( hwnd, GA_PARENT )) return FALSE; /* refuse to create non-desktop window */ - - swprintf( buffer, ARRAY_SIZE(buffer), L"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", - guid->Data1, guid->Data2, guid->Data3, - guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3], - guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7] ); - atom = GlobalAddAtomW( buffer ); - SetPropW( hwnd, L"__wine_display_device_guid", ULongToHandle( atom ) ); - } - return TRUE; - } case WM_NCCALCSIZE: - return 0; + return NtUserMessageCall( hwnd, message, wParam, lParam, 0, NtUserDesktopWindowProc, FALSE ); + default: - return DefWindowProcW( hwnd, message, wParam, lParam ); + if (message < WM_USER) + return DefWindowProcW( hwnd, message, wParam, lParam ); + return NtUserMessageCall( hwnd, message, wParam, lParam, 0, NtUserDesktopWindowProc, FALSE ); } }
diff --git a/dlls/win32u/defwnd.c b/dlls/win32u/defwnd.c index 27120a96d98..444abd1657f 100644 --- a/dlls/win32u/defwnd.c +++ b/dlls/win32u/defwnd.c @@ -384,3 +384,40 @@ LRESULT default_window_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam,
return result; } + +LRESULT desktop_window_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) +{ + static const WCHAR wine_display_device_guidW[] = + {'_','_','w','i','n','e','_','d','i','s','p','l','a','y','_','d','e','v','i','c','e', + '_','g','u','i','d',0}; + + switch (msg) + { + case WM_NCCREATE: + { + CREATESTRUCTW *cs = (CREATESTRUCTW *)lparam; + const GUID *guid = cs->lpCreateParams; + + if (guid) + { + ATOM atom = 0; + char buffer[37]; + WCHAR bufferW[37]; + + if (NtUserGetAncestor( hwnd, GA_PARENT )) return FALSE; /* refuse to create non-desktop window */ + + sprintf( buffer, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", + (unsigned int)guid->Data1, guid->Data2, guid->Data3, + guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3], + guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7] ); + NtAddAtom( bufferW, asciiz_to_unicode( bufferW, buffer ) - sizeof(WCHAR), &atom ); + NtUserSetProp( hwnd, wine_display_device_guidW, ULongToHandle( atom ) ); + } + return TRUE; + } + case WM_NCCALCSIZE: + return 0; + } + + return default_window_proc( hwnd, msg, wparam, lparam, FALSE ); +} diff --git a/dlls/win32u/message.c b/dlls/win32u/message.c index e67f9adcbe7..6bb9aa455f5 100644 --- a/dlls/win32u/message.c +++ b/dlls/win32u/message.c @@ -2890,6 +2890,8 @@ LRESULT WINAPI NtUserMessageCall( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpa { switch (type) { + case NtUserDesktopWindowProc: + return desktop_window_proc( hwnd, msg, wparam, lparam ); case NtUserDefWindowProc: return default_window_proc( hwnd, msg, wparam, lparam, ansi ); case NtUserCallWindowProc: diff --git a/dlls/win32u/win32u_private.h b/dlls/win32u/win32u_private.h index c7340018830..2d69cbef78e 100644 --- a/dlls/win32u/win32u_private.h +++ b/dlls/win32u/win32u_private.h @@ -360,6 +360,7 @@ extern void register_window_surface( struct window_surface *old, /* defwnd.c */ extern LRESULT default_window_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, BOOL ansi ) DECLSPEC_HIDDEN; +extern LRESULT desktop_window_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) DECLSPEC_HIDDEN; extern void fill_rect( HDC dc, const RECT *rect, HBRUSH hbrush ) DECLSPEC_HIDDEN;
/* hook.c */ diff --git a/include/ntuser.h b/include/ntuser.h index c7490eaad0a..29de027a334 100644 --- a/include/ntuser.h +++ b/include/ntuser.h @@ -181,6 +181,7 @@ struct render_synthesized_format_params /* NtUserMessageCall codes */ enum { + NtUserDesktopWindowProc = 0x029d, NtUserDefWindowProc = 0x029e, NtUserCallWindowProc = 0x02ab, NtUserSendMessage = 0x02b1,
From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/win32u/defwnd.c | 4 ++++ dlls/win32u/driver.c | 7 +++++++ include/wine/gdi_driver.h | 3 ++- 3 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/dlls/win32u/defwnd.c b/dlls/win32u/defwnd.c index 444abd1657f..9b4edc90eaa 100644 --- a/dlls/win32u/defwnd.c +++ b/dlls/win32u/defwnd.c @@ -417,6 +417,10 @@ LRESULT desktop_window_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) } case WM_NCCALCSIZE: return 0; + + default: + if (msg >= WM_USER && hwnd == get_desktop_window()) + return user_driver->pDesktopWindowProc( hwnd, msg, wparam, lparam ); }
return default_window_proc( hwnd, msg, wparam, lparam, FALSE ); diff --git a/dlls/win32u/driver.c b/dlls/win32u/driver.c index 9185069208a..4dac0760464 100644 --- a/dlls/win32u/driver.c +++ b/dlls/win32u/driver.c @@ -721,6 +721,11 @@ static SHORT nulldrv_VkKeyScanEx( WCHAR ch, HKL layout ) return -256; /* use default implementation */ }
+static LRESULT nulldrv_DesktopWindowProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) +{ + return default_window_proc( hwnd, msg, wparam, lparam, FALSE ); +} + static void nulldrv_DestroyCursorIcon( HCURSOR cursor ) { } @@ -1175,6 +1180,7 @@ static const struct user_driver_funcs lazy_load_driver = /* windowing functions */ loaderdrv_CreateDesktopWindow, loaderdrv_CreateWindow, + nulldrv_DesktopWindowProc, nulldrv_DestroyWindow, loaderdrv_FlashWindowEx, loaderdrv_GetDC, @@ -1247,6 +1253,7 @@ void CDECL __wine_set_user_driver( const struct user_driver_funcs *funcs, UINT v SET_USER_FUNC(UpdateDisplayDevices); SET_USER_FUNC(CreateDesktopWindow); SET_USER_FUNC(CreateWindow); + SET_USER_FUNC(DesktopWindowProc); SET_USER_FUNC(DestroyWindow); SET_USER_FUNC(FlashWindowEx); SET_USER_FUNC(GetDC); diff --git a/include/wine/gdi_driver.h b/include/wine/gdi_driver.h index 82bac557c2a..21fff4d4aa2 100644 --- a/include/wine/gdi_driver.h +++ b/include/wine/gdi_driver.h @@ -168,7 +168,7 @@ struct gdi_dc_funcs };
/* increment this when you change the DC function table */ -#define WINE_GDI_DRIVER_VERSION 78 +#define WINE_GDI_DRIVER_VERSION 79
#define GDI_PRIORITY_NULL_DRV 0 /* null driver */ #define GDI_PRIORITY_FONT_DRV 100 /* any font driver */ @@ -299,6 +299,7 @@ struct user_driver_funcs /* windowing functions */ BOOL (*pCreateDesktopWindow)(HWND); BOOL (*pCreateWindow)(HWND); + LRESULT (*pDesktopWindowProc)(HWND,UINT,WPARAM,LPARAM); void (*pDestroyWindow)(HWND); void (*pFlashWindowEx)(FLASHWINFO*); void (*pGetDC)(HDC,HWND,HWND,const RECT *,const RECT *,DWORD);
From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/winex11.drv/init.c | 1 + dlls/winex11.drv/window.c | 12 +++++------- dlls/winex11.drv/x11drv.h | 1 + 3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/dlls/winex11.drv/init.c b/dlls/winex11.drv/init.c index fc190805401..3bdc05999f1 100644 --- a/dlls/winex11.drv/init.c +++ b/dlls/winex11.drv/init.c @@ -408,6 +408,7 @@ static const struct user_driver_funcs x11drv_funcs = .pUpdateDisplayDevices = X11DRV_UpdateDisplayDevices, .pCreateDesktopWindow = X11DRV_CreateDesktopWindow, .pCreateWindow = X11DRV_CreateWindow, + .pDesktopWindowProc = X11DRV_DesktopWindowProc, .pDestroyWindow = X11DRV_DestroyWindow, .pFlashWindowEx = X11DRV_FlashWindowEx, .pGetDC = X11DRV_GetDC, diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c index 50a848cae86..773fa81f5f3 100644 --- a/dlls/winex11.drv/window.c +++ b/dlls/winex11.drv/window.c @@ -1860,13 +1860,14 @@ BOOL X11DRV_CreateDesktopWindow( HWND hwnd ) }
-static WNDPROC desktop_orig_wndproc; - #define WM_WINE_NOTIFY_ACTIVITY WM_USER #define WM_WINE_DELETE_TAB (WM_USER + 1) #define WM_WINE_ADD_TAB (WM_USER + 2)
-static LRESULT CALLBACK desktop_wndproc_wrapper( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp ) +/********************************************************************** + * DesktopWindowProc (X11DRV.@) + */ +LRESULT X11DRV_DesktopWindowProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp ) { switch (msg) { @@ -1891,7 +1892,7 @@ static LRESULT CALLBACK desktop_wndproc_wrapper( HWND hwnd, UINT msg, WPARAM wp, send_notify_message( (HWND)wp, WM_X11DRV_ADD_TAB, 0, 0 ); break; } - return desktop_orig_wndproc( hwnd, msg, wp, lp ); + return NtUserMessageCall( hwnd, msg, wp, lp, 0, NtUserDefWindowProc, FALSE ); }
/********************************************************************** @@ -1904,9 +1905,6 @@ BOOL X11DRV_CreateWindow( HWND hwnd ) struct x11drv_thread_data *data = x11drv_init_thread_data(); XSetWindowAttributes attr;
- desktop_orig_wndproc = (WNDPROC)NtUserSetWindowLongPtr( hwnd, GWLP_WNDPROC, - (LONG_PTR)desktop_wndproc_wrapper, FALSE ); - /* create the cursor clipping window */ attr.override_redirect = TRUE; attr.event_mask = StructureNotifyMask | FocusChangeMask; diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index 9a775215321..613dc0e05fe 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -218,6 +218,7 @@ extern void X11DRV_UpdateDisplayDevices( const struct gdi_device_manager *device BOOL force, void *param ) DECLSPEC_HIDDEN; extern BOOL X11DRV_CreateDesktopWindow( HWND hwnd ) DECLSPEC_HIDDEN; extern BOOL X11DRV_CreateWindow( HWND hwnd ) DECLSPEC_HIDDEN; +extern LRESULT X11DRV_DesktopWindowProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp ) DECLSPEC_HIDDEN; extern void X11DRV_DestroyWindow( HWND hwnd ) DECLSPEC_HIDDEN; extern void X11DRV_FlashWindowEx( PFLASHWINFO pfinfo ) DECLSPEC_HIDDEN; extern void X11DRV_GetDC( HDC hdc, HWND hwnd, HWND top, const RECT *win_rect,
This merge request was approved by Huw Davies.