Alexandre Julliard : winex11: Add a helper function to set input focus for non-managed windows.

Alexandre Julliard julliard at winehq.org
Tue Sep 18 14:04:29 CDT 2012


Module: wine
Branch: master
Commit: b8edf184ee33acce8b102d968e4bd5063ab97dc9
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=b8edf184ee33acce8b102d968e4bd5063ab97dc9

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Tue Sep 18 11:20:07 2012 +0200

winex11: Add a helper function to set input focus for non-managed windows.

---

 dlls/winex11.drv/event.c  |   44 +++++++++++++++++++++++++++++++++++++++++++-
 dlls/winex11.drv/window.c |   30 ------------------------------
 2 files changed, 43 insertions(+), 31 deletions(-)

diff --git a/dlls/winex11.drv/event.c b/dlls/winex11.drv/event.c
index 0e8ba04..1c0cec3 100644
--- a/dlls/winex11.drv/event.c
+++ b/dlls/winex11.drv/event.c
@@ -530,6 +530,31 @@ static inline BOOL can_activate_window( HWND hwnd )
 
 
 /**********************************************************************
+ *              set_input_focus
+ *
+ * Try to force focus for non-managed windows.
+ */
+static void set_input_focus( Display *display, Window window )
+{
+    XWindowChanges changes;
+    DWORD timestamp;
+
+    if (!window) return;
+
+    if (EVENT_x11_time_to_win32_time(0))
+        /* ICCCM says don't use CurrentTime, so try to use last message time if possible */
+        /* FIXME: this is not entirely correct */
+        timestamp = GetMessageTime() - EVENT_x11_time_to_win32_time(0);
+    else
+        timestamp = CurrentTime;
+
+    /* Set X focus and install colormap */
+    changes.stack_mode = Above;
+    XConfigureWindow( display, window, CWStackMode, &changes );
+    XSetInputFocus( display, window, RevertToParent, timestamp );
+}
+
+/**********************************************************************
  *              set_focus
  */
 static void set_focus( Display *display, HWND hwnd, Time time )
@@ -855,7 +880,8 @@ static void X11DRV_MapNotify( HWND hwnd, XEvent *event )
     if (!data->managed)
     {
         HWND hwndFocus = GetFocus();
-        if (hwndFocus && IsChild( hwnd, hwndFocus )) X11DRV_SetFocus(hwndFocus);  /* FIXME */
+        if (hwndFocus && IsChild( hwnd, hwndFocus ))
+            set_input_focus( thread_display(), data->whole_window );
     }
 }
 
@@ -1240,6 +1266,22 @@ void wait_for_withdrawn_state( HWND hwnd, BOOL set )
 }
 
 
+/*****************************************************************
+ *		SetFocus   (X11DRV.@)
+ *
+ * Set the X focus.
+ */
+void CDECL X11DRV_SetFocus( HWND hwnd )
+{
+    Display *display = thread_display();
+    struct x11drv_win_data *data;
+
+    if (!(hwnd = GetAncestor( hwnd, GA_ROOT ))) return;
+    if (!(data = X11DRV_get_win_data( hwnd ))) return;
+    if (!data->managed) set_input_focus( display, data->whole_window );
+}
+
+
 static HWND find_drop_window( HWND hQueryWnd, LPPOINT lpPt )
 {
     RECT tempRect;
diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c
index 421d67d..94edb81 100644
--- a/dlls/winex11.drv/window.c
+++ b/dlls/winex11.drv/window.c
@@ -1989,36 +1989,6 @@ void CDECL X11DRV_SetParent( HWND hwnd, HWND parent, HWND old_parent )
 }
 
 
-/*****************************************************************
- *		SetFocus   (X11DRV.@)
- *
- * Set the X focus.
- */
-void CDECL X11DRV_SetFocus( HWND hwnd )
-{
-    Display *display = thread_display();
-    struct x11drv_win_data *data;
-    XWindowChanges changes;
-    DWORD timestamp;
-
-    if (!(hwnd = GetAncestor( hwnd, GA_ROOT ))) return;
-    if (!(data = X11DRV_get_win_data( hwnd ))) return;
-    if (data->managed || !data->whole_window) return;
-
-    if (EVENT_x11_time_to_win32_time(0))
-        /* ICCCM says don't use CurrentTime, so try to use last message time if possible */
-        /* FIXME: this is not entirely correct */
-        timestamp = GetMessageTime() - EVENT_x11_time_to_win32_time(0);
-    else
-        timestamp = CurrentTime;
-
-    /* Set X focus and install colormap */
-    changes.stack_mode = Above;
-    XConfigureWindow( display, data->whole_window, CWStackMode, &changes );
-    XSetInputFocus( display, data->whole_window, RevertToParent, timestamp );
-}
-
-
 static inline RECT get_surface_rect( const RECT *visible_rect )
 {
     RECT rect;




More information about the wine-cvs mailing list