[metacity/gnome-3-24] improve handling of tracking the old focused window during restart
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [metacity/gnome-3-24] improve handling of tracking the old focused window during restart
- Date: Sun, 19 Mar 2017 08:09:59 +0000 (UTC)
commit 546358c15c52158b17a87a69eca9e541cd248300
Author: Owen W. Taylor <otaylor fishsoup net>
Date: Tue May 10 17:36:51 2016 -0400
improve handling of tracking the old focused window during restart
When restarting (X compositor only, obviously), we want to keep
the same window focused. There is code that tries to do this by
calling XGetInputFocus() but the previously focused window will
almost certainly not still be focused by the time we get to the
point where we call XGetInputFocus(), and in fact, probably was
no longer correct after the previous window manager exited, so
the net result is that we tend to focus no window on restart.
A better approach is to leave the _NET_ACTIVE_WINDOW property
set on the root window during exit, and if we find it set when
starting, use that to initialize focus.
https://bugzilla.gnome.org/show_bug.cgi?id=766243
src/core/display.c | 60 ++++++++++++++++++++++++---------------------------
1 files changed, 28 insertions(+), 32 deletions(-)
---
diff --git a/src/core/display.c b/src/core/display.c
index 6cce3c0..feebea5 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -286,6 +286,7 @@ meta_display_open (void)
int i;
guint32 timestamp;
MetaScreen *screen;
+ Window old_active_xwindow;
/* A list of all atom names, so that we can intern them in one go. */
const gchar *atom_names[] = {
@@ -657,6 +658,11 @@ meta_display_open (void)
return FALSE;
}
+ old_active_xwindow = None;
+ meta_prop_get_window (the_display, the_display->screen->xroot,
+ the_display->atom__NET_ACTIVE_WINDOW,
+ &old_active_xwindow);
+
/* We don't composite the windows here because they will be composited
faster with the call to meta_screen_manage_all_windows further down
the code */
@@ -667,43 +673,30 @@ meta_display_open (void)
/* Now manage all existing windows */
meta_screen_manage_all_windows (the_display->screen);
- {
- Window focus;
- int ret_to;
-
- /* kinda bogus because GetInputFocus has no possible errors */
- meta_error_trap_push (the_display);
-
- /* FIXME: This is totally broken; see comment 9 of bug 88194 about this */
- focus = None;
- ret_to = RevertToPointerRoot;
- XGetInputFocus (the_display->xdisplay, &focus, &ret_to);
+ if (old_active_xwindow != None)
+ {
+ MetaWindow *old_active_window;
- /* Force a new FocusIn (does this work?) */
+ old_active_window = meta_display_lookup_x_window (the_display,
+ old_active_xwindow);
- /* Use the same timestamp that was passed to meta_screen_new(),
- * as it is the most recent timestamp.
- */
- if (focus == None || focus == PointerRoot)
- /* Just focus the no_focus_window on the first screen */
- meta_display_focus_the_no_focus_window (the_display,
- the_display->screen,
- timestamp);
- else
- {
- MetaWindow * window;
- window = meta_display_lookup_x_window (the_display, focus);
- if (window)
- meta_display_set_input_focus_window (the_display, window, FALSE, timestamp);
- else
- /* Just focus the no_focus_window on the first screen */
+ if (old_active_window)
+ {
+ meta_window_focus (old_active_window, timestamp);
+ }
+ else
+ {
meta_display_focus_the_no_focus_window (the_display,
the_display->screen,
timestamp);
- }
-
- meta_error_trap_pop (the_display);
- }
+ }
+ }
+ else
+ {
+ meta_display_focus_the_no_focus_window (the_display,
+ the_display->screen,
+ timestamp);
+ }
meta_display_ungrab (the_display);
@@ -3982,6 +3975,9 @@ meta_display_update_active_window_hint (MetaDisplay *display)
{
gulong data[1];
+ if (display->closing)
+ return; /* Leave old value for a replacement */
+
if (display->focus_window)
data[0] = display->focus_window->xwindow;
else
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]