From: Rémi Bernon rbernon@codeweavers.com
Repurposing the SetFocus callback. --- dlls/win32u/driver.c | 6 +++--- dlls/win32u/input.c | 8 +++++--- dlls/winemac.drv/gdi.c | 2 +- dlls/winemac.drv/macdrv.h | 2 +- dlls/winemac.drv/window.c | 6 +++--- dlls/winex11.drv/event.c | 17 +++-------------- dlls/winex11.drv/init.c | 2 +- dlls/winex11.drv/x11drv.h | 2 +- include/wine/gdi_driver.h | 2 +- 9 files changed, 19 insertions(+), 28 deletions(-)
diff --git a/dlls/win32u/driver.c b/dlls/win32u/driver.c index abee66c0419..2677606a8fc 100644 --- a/dlls/win32u/driver.c +++ b/dlls/win32u/driver.c @@ -824,7 +824,7 @@ static void nulldrv_SetDesktopWindow( HWND hwnd ) { }
-static void nulldrv_SetFocus( HWND hwnd ) +static void nulldrv_ActivateWindow( HWND hwnd, HWND previous ) { }
@@ -1280,7 +1280,7 @@ static const struct user_driver_funcs lazy_load_driver = nulldrv_ScrollDC, nulldrv_SetCapture, loaderdrv_SetDesktopWindow, - nulldrv_SetFocus, + nulldrv_ActivateWindow, loaderdrv_SetLayeredWindowAttributes, nulldrv_SetParent, loaderdrv_SetWindowRgn, @@ -1377,7 +1377,7 @@ void __wine_set_user_driver( const struct user_driver_funcs *funcs, UINT version SET_USER_FUNC(ScrollDC); SET_USER_FUNC(SetCapture); SET_USER_FUNC(SetDesktopWindow); - SET_USER_FUNC(SetFocus); + SET_USER_FUNC(ActivateWindow); SET_USER_FUNC(SetLayeredWindowAttributes); SET_USER_FUNC(SetParent); SET_USER_FUNC(SetWindowRgn); diff --git a/dlls/win32u/input.c b/dlls/win32u/input.c index ad4ba4d77c5..7a2edb4c110 100644 --- a/dlls/win32u/input.c +++ b/dlls/win32u/input.c @@ -1947,8 +1947,6 @@ static HWND set_focus_window( HWND hwnd ) } if (is_window(hwnd)) { - user_driver->pSetFocus(hwnd); - ime_hwnd = get_default_ime_window( hwnd ); if (ime_hwnd) send_message( ime_hwnd, WM_IME_INTERNAL, IME_INTERNAL_ACTIVATE, @@ -2067,7 +2065,11 @@ BOOL set_active_window( HWND hwnd, HWND *prev, BOOL mouse, BOOL focus, DWORD new }
done: - if (hwnd) clip_fullscreen_window( hwnd, FALSE ); + if (hwnd) + { + if (hwnd == NtUserGetForegroundWindow()) user_driver->pActivateWindow( hwnd, previous ); + clip_fullscreen_window( hwnd, FALSE ); + } return TRUE; }
diff --git a/dlls/winemac.drv/gdi.c b/dlls/winemac.drv/gdi.c index 4921fc2f170..d58e0fd280f 100644 --- a/dlls/winemac.drv/gdi.c +++ b/dlls/winemac.drv/gdi.c @@ -286,7 +286,7 @@ static const struct user_driver_funcs macdrv_funcs = .pSetCursor = macdrv_SetCursor, .pSetCursorPos = macdrv_SetCursorPos, .pSetDesktopWindow = macdrv_SetDesktopWindow, - .pSetFocus = macdrv_SetFocus, + .pActivateWindow = macdrv_ActivateWindow, .pSetLayeredWindowAttributes = macdrv_SetLayeredWindowAttributes, .pSetParent = macdrv_SetParent, .pSetWindowRgn = macdrv_SetWindowRgn, diff --git a/dlls/winemac.drv/macdrv.h b/dlls/winemac.drv/macdrv.h index 4457a7e186c..b6eeb4ecb8e 100644 --- a/dlls/winemac.drv/macdrv.h +++ b/dlls/winemac.drv/macdrv.h @@ -136,7 +136,7 @@ static inline RECT rect_from_cgrect(CGRect cgrect) extern LRESULT macdrv_DesktopWindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam); extern void macdrv_DestroyWindow(HWND hwnd); extern void macdrv_SetDesktopWindow(HWND hwnd); -extern void macdrv_SetFocus(HWND hwnd); +extern void macdrv_ActivateWindow(HWND hwnd, HWND previous); extern void macdrv_SetLayeredWindowAttributes(HWND hwnd, COLORREF key, BYTE alpha, DWORD flags); extern void macdrv_SetParent(HWND hwnd, HWND parent, HWND old_parent); diff --git a/dlls/winemac.drv/window.c b/dlls/winemac.drv/window.c index 115820ec376..8314d7dbf19 100644 --- a/dlls/winemac.drv/window.c +++ b/dlls/winemac.drv/window.c @@ -1388,11 +1388,11 @@ void macdrv_DestroyWindow(HWND hwnd)
/***************************************************************** - * SetFocus (MACDRV.@) + * ActivateWindow (MACDRV.@) * - * Set the Mac focus. + * Set the Mac active window. */ -void macdrv_SetFocus(HWND hwnd) +void macdrv_ActivateWindow(HWND hwnd, HWND previous) { struct macdrv_thread_data *thread_data = macdrv_thread_data();
diff --git a/dlls/winex11.drv/event.c b/dlls/winex11.drv/event.c index 977a11a989b..e0d15e55f26 100644 --- a/dlls/winex11.drv/event.c +++ b/dlls/winex11.drv/event.c @@ -1308,25 +1308,14 @@ static BOOL X11DRV_PropertyNotify( HWND hwnd, XEvent *xev )
/***************************************************************** - * SetFocus (X11DRV.@) + * ActivateWindow (X11DRV.@) * * Set the X focus. */ -void X11DRV_SetFocus( HWND hwnd ) +void X11DRV_ActivateWindow( HWND hwnd, HWND previous ) { struct x11drv_win_data *data; - - HWND parent; - - for (;;) - { - if (!(data = get_win_data( hwnd ))) return; - if (data->embedded) break; - parent = NtUserGetAncestor( hwnd, GA_PARENT ); - if (!parent || parent == NtUserGetDesktopWindow()) break; - release_win_data( data ); - hwnd = parent; - } + if (!(data = get_win_data( hwnd ))) return; if (!data->managed || data->embedder) set_input_focus( data ); release_win_data( data ); } diff --git a/dlls/winex11.drv/init.c b/dlls/winex11.drv/init.c index a0bfab2fb46..13dae3ad661 100644 --- a/dlls/winex11.drv/init.c +++ b/dlls/winex11.drv/init.c @@ -454,7 +454,7 @@ static const struct user_driver_funcs x11drv_funcs = .pScrollDC = X11DRV_ScrollDC, .pSetCapture = X11DRV_SetCapture, .pSetDesktopWindow = X11DRV_SetDesktopWindow, - .pSetFocus = X11DRV_SetFocus, + .pActivateWindow = X11DRV_ActivateWindow, .pSetLayeredWindowAttributes = X11DRV_SetLayeredWindowAttributes, .pSetParent = X11DRV_SetParent, .pSetWindowIcon = X11DRV_SetWindowIcon, diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index c6730e51c7d..c9c5fae3636 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -706,7 +706,7 @@ extern XContext winContext; extern XContext cursor_context;
extern BOOL is_current_process_focused(void); -extern void X11DRV_SetFocus( HWND hwnd ); +extern void X11DRV_ActivateWindow( HWND hwnd, HWND previous ); extern void set_window_cursor( Window window, HCURSOR handle ); extern void reapply_cursor_clipping(void); extern void ungrab_clipping_window(void); diff --git a/include/wine/gdi_driver.h b/include/wine/gdi_driver.h index 930ccd4c39b..c70c7e80996 100644 --- a/include/wine/gdi_driver.h +++ b/include/wine/gdi_driver.h @@ -372,7 +372,7 @@ struct user_driver_funcs BOOL (*pScrollDC)(HDC,INT,INT,HRGN); void (*pSetCapture)(HWND,UINT); void (*pSetDesktopWindow)(HWND); - void (*pSetFocus)(HWND); + void (*pActivateWindow)(HWND,HWND); void (*pSetLayeredWindowAttributes)(HWND,COLORREF,BYTE,DWORD); void (*pSetParent)(HWND,HWND,HWND); void (*pSetWindowRgn)(HWND,HRGN,BOOL);