[mutter/wip/carlosg/x11less-preparations: 10/15] core: Untangle input focus management
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/carlosg/x11less-preparations: 10/15] core: Untangle input focus management
- Date: Wed, 30 Jan 2019 15:58:18 +0000 (UTC)
commit b243a601a244ac73a0be2654c21940043ae3e986
Author: Carlos Garnacho <carlosg gnome org>
Date: Sun Dec 30 22:59:40 2018 +0100
core: Untangle input focus management
In all places (including src/wayland) we tap into meta_x11_display* focus
API, which then calls meta_display* API. This relation is backwards, so
rework input focus management so it's the other way around.
We now have high-level meta_display_(un)set_input_focus functions, which
perform the backend-independent maintenance, and calls into the X11
functions where relevant. These functions are what callers should use.
src/core/display-private.h | 7 +++++
src/core/display.c | 52 ++++++++++++++++++++++++++++++++---
src/core/window.c | 3 +--
src/core/workspace.c | 6 ++---
src/wayland/meta-window-wayland.c | 10 ++++---
src/x11/meta-x11-display.c | 57 ++++-----------------------------------
src/x11/window-x11.c | 19 +++++++------
7 files changed, 79 insertions(+), 75 deletions(-)
---
diff --git a/src/core/display-private.h b/src/core/display-private.h
index 94eba4d25..9c095ad4a 100644
--- a/src/core/display-private.h
+++ b/src/core/display-private.h
@@ -356,6 +356,13 @@ void meta_display_sync_wayland_input_focus (MetaDisplay *display);
void meta_display_update_focus_window (MetaDisplay *display,
MetaWindow *window);
+void meta_display_set_input_focus (MetaDisplay *display,
+ MetaWindow *window,
+ gboolean focus_frame,
+ guint32 timestamp);
+void meta_display_unset_input_focus (MetaDisplay *display,
+ guint32 timestamp);
+
void meta_display_sanity_check_timestamps (MetaDisplay *display,
guint32 timestamp);
gboolean meta_display_timestamp_too_old (MetaDisplay *display,
diff --git a/src/core/display.c b/src/core/display.c
index 6e21f35de..1fb51c2c6 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -770,10 +770,10 @@ meta_display_open (void)
if (old_active_window)
meta_window_focus (old_active_window, timestamp);
else
- meta_x11_display_focus_the_no_focus_window (display->x11_display, timestamp);
+ meta_display_unset_input_focus (display, timestamp);
}
- else if (display->x11_display)
- meta_x11_display_focus_the_no_focus_window (display->x11_display, timestamp);
+ else
+ meta_display_unset_input_focus (display, timestamp);
meta_idle_monitor_init_dbus ();
@@ -1296,6 +1296,52 @@ meta_display_timestamp_too_old (MetaDisplay *display,
return FALSE;
}
+void
+meta_display_set_input_focus (MetaDisplay *display,
+ MetaWindow *window,
+ gboolean focus_frame,
+ guint32 timestamp)
+{
+ if (meta_display_timestamp_too_old (display, ×tamp))
+ return;
+
+ if (display->x11_display)
+ {
+ MetaX11Display *x11_display = display->x11_display;
+ Window xwindow;
+ gulong serial;
+
+ meta_x11_error_trap_push (x11_display);
+
+ if (window)
+ xwindow = focus_frame ? window->frame->xwindow : window->xwindow;
+ else
+ xwindow = x11_display->no_focus_window;
+
+ meta_x11_display_set_input_focus (x11_display, xwindow, timestamp);
+ serial = XNextRequest (x11_display->xdisplay);
+
+ meta_x11_display_update_focus_window (x11_display, xwindow, serial, TRUE);
+ }
+
+ meta_display_update_focus_window (display, window);
+
+ if (display->x11_display)
+ meta_x11_error_trap_pop (display->x11_display);
+
+ display->last_focus_time = timestamp;
+
+ if (window == NULL || window != display->autoraise_window)
+ meta_display_remove_autoraise_callback (display);
+}
+
+void
+meta_display_unset_input_focus (MetaDisplay *display,
+ guint32 timestamp)
+{
+ meta_display_set_input_focus (display, NULL, FALSE, timestamp);
+}
+
void
meta_display_register_wayland_window (MetaDisplay *display,
MetaWindow *window)
diff --git a/src/core/window.c b/src/core/window.c
index 340068357..7a16a1ce8 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -8083,8 +8083,7 @@ mouse_mode_focus (MetaWindow *window,
"Unsetting focus from %s due to mouse entering "
"the DESKTOP window\n",
display->focus_window->desc);
- meta_x11_display_focus_the_no_focus_window (display->x11_display,
- timestamp);
+ meta_display_unset_input_focus (display, timestamp);
}
}
}
diff --git a/src/core/workspace.c b/src/core/workspace.c
index a88c9784c..6a2a4a871 100644
--- a/src/core/workspace.c
+++ b/src/core/workspace.c
@@ -1314,8 +1314,7 @@ meta_workspace_focus_default_window (MetaWorkspace *workspace,
meta_topic (META_DEBUG_FOCUS,
"Setting focus to no_focus_window, since no valid "
"window to focus found.\n");
- meta_x11_display_focus_the_no_focus_window (workspace->display->x11_display,
- timestamp);
+ meta_display_unset_input_focus (workspace->display, timestamp);
}
}
}
@@ -1387,8 +1386,7 @@ focus_ancestor_or_top_window (MetaWorkspace *workspace,
else
{
meta_topic (META_DEBUG_FOCUS, "No MRU window to focus found; focusing no_focus_window.\n");
- meta_x11_display_focus_the_no_focus_window (workspace->display->x11_display,
- timestamp);
+ meta_display_unset_input_focus (workspace->display, timestamp);
}
}
diff --git a/src/wayland/meta-window-wayland.c b/src/wayland/meta-window-wayland.c
index dffee486d..9a10f80dc 100644
--- a/src/wayland/meta-window-wayland.c
+++ b/src/wayland/meta-window-wayland.c
@@ -142,10 +142,12 @@ meta_window_wayland_focus (MetaWindow *window,
guint32 timestamp)
{
if (window->input)
- meta_x11_display_set_input_focus_window (window->display->x11_display,
- window,
- FALSE,
- timestamp);
+ {
+ meta_display_set_input_focus (window->display,
+ window,
+ FALSE,
+ timestamp);
+ }
}
static void
diff --git a/src/x11/meta-x11-display.c b/src/x11/meta-x11-display.c
index 1eab8fde0..f7f6a3a52 100644
--- a/src/x11/meta-x11-display.c
+++ b/src/x11/meta-x11-display.c
@@ -1852,64 +1852,17 @@ meta_x11_display_set_input_focus (MetaX11Display *x11_display,
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, ×tamp))
- 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);
-
- meta_x11_error_trap_pop (x11_display);
-
- x11_display->display->last_focus_time = timestamp;
-
- if (meta_window == NULL || meta_window != x11_display->display->autoraise_window)
- meta_display_remove_autoraise_callback (x11_display->display);
-}
-
-void
-meta_x11_display_set_input_focus_window (MetaX11Display *x11_display,
- MetaWindow *window,
- gboolean focus_frame,
- guint32 timestamp)
-{
- request_xserver_input_focus_change (x11_display,
- window,
- focus_frame ? window->frame->xwindow : window->xwindow,
- timestamp);
-}
-
void
meta_x11_display_set_input_focus_xwindow (MetaX11Display *x11_display,
Window window,
guint32 timestamp)
{
- request_xserver_input_focus_change (x11_display,
- NULL,
- window,
- timestamp);
-}
+ gulong serial;
-void
-meta_x11_display_focus_the_no_focus_window (MetaX11Display *x11_display,
- guint32 timestamp)
-{
- request_xserver_input_focus_change (x11_display,
- NULL,
- x11_display->no_focus_window,
- timestamp);
+ meta_display_unset_input_focus (x11_display->display, timestamp);
+ serial = XNextRequest (x11_display->xdisplay);
+ meta_x11_display_set_input_focus (x11_display, window, timestamp);
+ meta_x11_display_update_focus_window (x11_display, window, serial, TRUE);
}
static MetaX11DisplayLogicalMonitorData *
diff --git a/src/x11/window-x11.c b/src/x11/window-x11.c
index 0fc2b436f..4d9339ccd 100644
--- a/src/x11/window-x11.c
+++ b/src/x11/window-x11.c
@@ -757,10 +757,10 @@ meta_window_x11_focus (MetaWindow *window,
{
meta_topic (META_DEBUG_FOCUS,
"Focusing frame of %s\n", window->desc);
- meta_x11_display_set_input_focus_window (window->display->x11_display,
- window,
- TRUE,
- timestamp);
+ meta_display_set_input_focus (window->display,
+ window,
+ TRUE,
+ timestamp);
}
else
{
@@ -769,10 +769,10 @@ meta_window_x11_focus (MetaWindow *window,
meta_topic (META_DEBUG_FOCUS,
"Setting input focus on %s since input = true\n",
window->desc);
- meta_x11_display_set_input_focus_window (window->display->x11_display,
- window,
- FALSE,
- timestamp);
+ meta_display_set_input_focus (window->display,
+ window,
+ FALSE,
+ timestamp);
}
if (window->take_focus)
@@ -795,8 +795,7 @@ meta_window_x11_focus (MetaWindow *window,
*/
if (window->display->focus_window != NULL &&
window->display->focus_window->unmanaging)
- meta_x11_display_focus_the_no_focus_window (window->display->x11_display,
- timestamp);
+ meta_display_unset_input_focus (window->display, timestamp);
}
request_take_focus (window, timestamp);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]