[mutter/wip/carlosg/x11less-preparations: 8/18] x11: Split X11 focus change requests to a separate function



commit 961b809d6b1a9005a2400c93423b01d4417d9028
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sun Dec 30 21:23:07 2018 +0100

    x11: Split X11 focus change requests to a separate function
    
    Separate the XSetInputFocus() call into a distinct MetaX11Display call.
    Just a minor refactor.
    
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/420

 src/x11/meta-x11-display-private.h |  3 +++
 src/x11/meta-x11-display.c         | 35 +++++++++++++++++++++++------------
 2 files changed, 26 insertions(+), 12 deletions(-)
---
diff --git a/src/x11/meta-x11-display-private.h b/src/x11/meta-x11-display-private.h
index ef0aba5d1..722d1c5bc 100644
--- a/src/x11/meta-x11-display-private.h
+++ b/src/x11/meta-x11-display-private.h
@@ -231,5 +231,8 @@ void meta_x11_display_update_focus_window (MetaX11Display *x11_display,
                                            Window          xwindow,
                                            gulong          serial,
                                            gboolean        focused_by_us);
+void meta_x11_display_set_input_focus (MetaX11Display *x11_display,
+                                       Window          xwindow,
+                                       guint32         timestamp);
 
 #endif /* META_X11_DISPLAY_PRIVATE_H */
diff --git a/src/x11/meta-x11-display.c b/src/x11/meta-x11-display.c
index e855d9877..1eab8fde0 100644
--- a/src/x11/meta-x11-display.c
+++ b/src/x11/meta-x11-display.c
@@ -1819,17 +1819,11 @@ meta_x11_display_update_focus_window (MetaX11Display *x11_display,
   meta_x11_display_update_active_window_hint (x11_display);
 }
 
-static void
-request_xserver_input_focus_change (MetaX11Display *x11_display,
-                                    MetaWindow     *meta_window,
-                                    Window          xwindow,
-                                    guint32         timestamp)
+void
+meta_x11_display_set_input_focus (MetaX11Display *x11_display,
+                                  Window          xwindow,
+                                  guint32         timestamp)
 {
-  gulong serial;
-
-  if (meta_display_timestamp_too_old (x11_display->display, &timestamp))
-    return;
-
   meta_x11_error_trap_push (x11_display);
 
   /* In order for mutter to know that the focus request succeeded, we track
@@ -1842,8 +1836,6 @@ request_xserver_input_focus_change (MetaX11Display *x11_display,
    */
   XGrabServer (x11_display->xdisplay);
 
-  serial = XNextRequest (x11_display->xdisplay);
-
   XSetInputFocus (x11_display->xdisplay,
                   xwindow,
                   RevertToPointerRoot,
@@ -1857,6 +1849,25 @@ request_xserver_input_focus_change (MetaX11Display *x11_display,
   XUngrabServer (x11_display->xdisplay);
   XFlush (x11_display->xdisplay);
 
+  meta_x11_error_trap_pop (x11_display);
+}
+
+static void
+request_xserver_input_focus_change (MetaX11Display *x11_display,
+                                    MetaWindow     *meta_window,
+                                    Window          xwindow,
+                                    guint32         timestamp)
+{
+  gulong serial;
+
+  if (meta_display_timestamp_too_old (x11_display->display, &timestamp))
+    return;
+
+  meta_x11_error_trap_push (x11_display);
+
+  meta_x11_display_set_input_focus (x11_display, xwindow, timestamp);
+  serial = XNextRequest (x11_display->xdisplay);
+
   meta_display_update_focus_window (x11_display->display, meta_window);
   meta_x11_display_update_focus_window (x11_display, xwindow, serial, TRUE);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]