[mutter/wip/carlosg/xwayland-on-demand: 20/27] x11: Split X11 focus change requests to a separate function



commit d635be227af9df450a4579c622d50bed702da29e
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
    
    Just a minor refactor.

 src/x11/events.c                   |  2 +-
 src/x11/meta-x11-display-private.h |  3 +++
 src/x11/meta-x11-display.c         | 35 +++++++++++++++++++++++------------
 3 files changed, 27 insertions(+), 13 deletions(-)
---
diff --git a/src/x11/events.c b/src/x11/events.c
index a842be75a..02c8509dc 100644
--- a/src/x11/events.c
+++ b/src/x11/events.c
@@ -807,7 +807,7 @@ handle_window_focus_event (MetaX11Display *x11_display,
        x11_display->server_focus_serial == x11_display->focus_serial))
     {
       meta_display_update_focus_window (display, focus_window);
-      meta_x11_display_update_focus_window (display,
+      meta_x11_display_update_focus_window (x11_display,
                                             focus_window ?
                                             focus_window->xwindow : None,
                                             x11_display->server_focus_serial,
diff --git a/src/x11/meta-x11-display-private.h b/src/x11/meta-x11-display-private.h
index 002095b84..65fd611a5 100644
--- a/src/x11/meta-x11-display-private.h
+++ b/src/x11/meta-x11-display-private.h
@@ -242,5 +242,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 1e116971c..622da4ef4 100644
--- a/src/x11/meta-x11-display.c
+++ b/src/x11/meta-x11-display.c
@@ -1835,17 +1835,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
@@ -1858,8 +1852,6 @@ request_xserver_input_focus_change (MetaX11Display *x11_display,
    */
   XGrabServer (x11_display->xdisplay);
 
-  serial = XNextRequest (x11_display->xdisplay);
-
   XSetInputFocus (x11_display->xdisplay,
                   xwindow,
                   RevertToPointerRoot,
@@ -1873,6 +1865,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);
+
+  serial = XNextRequest (x11_display->xdisplay);
+
+  meta_x11_display_set_input_focus (x11_display, xwindow, timestamp);
   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]