[PATCH v3 02/10] winex11.drv: Call XSetInputFocus only, whenever WM_TAKE_FOCUS is received.

Rémi Bernon rbernon at codeweavers.com
Mon Oct 7 08:02:08 CDT 2019


This will trigger a normal FocusIn event for the corresponding window,
which would then call set_focus.

It makes the handling of Focus events simpler by avoiding different
codepaths depending on whether or not WM_TAKE_FOCUS is used. We can
then also safely delay the WM_ACTIVATE messages without delaying the
input focus from the WM perspective.

Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
---
 dlls/winex11.drv/event.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/dlls/winex11.drv/event.c b/dlls/winex11.drv/event.c
index 32fdf23bf35..0fb91265a69 100644
--- a/dlls/winex11.drv/event.c
+++ b/dlls/winex11.drv/event.c
@@ -730,7 +730,7 @@ static void handle_wm_protocols( HWND hwnd, XClientMessageEvent *event )
                                        MAKELONG(HTCAPTION,WM_LBUTTONDOWN) );
             if (ma != MA_NOACTIVATEANDEAT && ma != MA_NOACTIVATE)
             {
-                set_focus( event->display, hwnd, event_time );
+                XSetInputFocus( event->display, X11DRV_get_whole_window( hwnd ), RevertToParent, event_time );
                 return;
             }
         }
@@ -739,7 +739,7 @@ static void handle_wm_protocols( HWND hwnd, XClientMessageEvent *event )
             hwnd = GetForegroundWindow();
             if (!hwnd) hwnd = last_focus;
             if (!hwnd) hwnd = GetDesktopWindow();
-            set_focus( event->display, hwnd, event_time );
+            XSetInputFocus( event->display, X11DRV_get_whole_window( hwnd ), RevertToParent, event_time );
             return;
         }
         /* try to find some other window to give the focus to */
@@ -747,7 +747,8 @@ static void handle_wm_protocols( HWND hwnd, XClientMessageEvent *event )
         if (hwnd) hwnd = GetAncestor( hwnd, GA_ROOT );
         if (!hwnd) hwnd = GetActiveWindow();
         if (!hwnd) hwnd = last_focus;
-        if (hwnd && can_activate_window(hwnd)) set_focus( event->display, hwnd, event_time );
+        if (hwnd && can_activate_window(hwnd))
+            XSetInputFocus( event->display, X11DRV_get_whole_window( hwnd ), RevertToParent, event_time );
     }
     else if (protocol == x11drv_atom(_NET_WM_PING))
     {
@@ -815,11 +816,7 @@ static BOOL X11DRV_FocusIn( HWND hwnd, XEvent *xev )
     }
 
     if ((xic = X11DRV_get_ic( hwnd ))) XSetICFocus( xic );
-    if (use_take_focus)
-    {
-        if (hwnd == GetForegroundWindow()) clip_fullscreen_window( hwnd, FALSE );
-        return TRUE;
-    }
+    if (use_take_focus && hwnd == GetForegroundWindow()) clip_fullscreen_window( hwnd, FALSE );
 
     if (!can_activate_window(hwnd))
     {
-- 
2.23.0




More information about the wine-devel mailing list