From 2bd938c957b27c1055f7f235939c9b8b338d5cbf Mon Sep 17 00:00:00 2001
From: "Owen W. Taylor" <otaylor@fishsoup.net>
Date: Wed, 23 Jun 2010 19:45:05 -0400
Subject: [PATCH] Apply new-windows-always-on-top to newly
raised/activated windows
A window that raises itself or activates itself is in many ways
like a completely new window. (Once a window is out of the user's
site, they really have no idea if it's mapped or has been withdrawn
by the user.)
If the user has set the new-windows-always-on-top key to make the
behavior for a focus-stealing-prevented *new* window "raise but not
focus", then they'll want the same behavior in the case of
windows that attempt to raise or activate themselves as well.
https://bugzilla.gnome.org/show_bug.cgi?id=599261
---
src/core/window.c | 35 +++++++++++++++++++++++++++++---
src/org.gnome.metacity.gschema.xml.in | 6 +++++
2 files changed, 37 insertions(+), 4 deletions(-)
diff --git a/src/core/window.c b/src/core/window.c
index b6a69b0..897161e 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -2970,6 +2970,8 @@ window_activate (MetaWindow *window,
MetaWorkspace *workspace)
{
gboolean can_ignore_outdated_timestamps;
+ gboolean only_raise = FALSE;
+
meta_topic (META_DEBUG_FOCUS,
"_NET_ACTIVE_WINDOW message sent for %s at time %u "
"by client type %u.\n",
@@ -2991,8 +2993,28 @@ window_activate (MetaWindow *window,
"last_user_time (%u) is more recent; ignoring "
" _NET_ACTIVE_WINDOW message.\n",
window->display->last_user_time);
- meta_window_set_demands_attention(window);
- return;
+ if (meta_prefs_get_new_windows_always_on_top () &&
+ meta_prefs_get_raise_on_click ())
+ {
+ /* The new_windows_only_on_top preference causes new
+ * focus-denied windows to get raised but not focused
+ * instead of set to demands attention. For consistency, we
+ * do the same here with windows that are "new to the user"
+ * - that self activate and are focus-stealing prevented. We
+ * can't just raise the window and return here because the
+ * window might be on a different workspace, so we need the
+ * handling below. The check for meta_prefs_get_raise_on_click ()
+ * is because that preference, if off, somewhat unexpectedl
+ * akes windows not raise on self-activation. If that is changed
+ * than the test should be removed here.
+ */
+ only_raise = TRUE;
+ }
+ else
+ {
+ meta_window_set_demands_attention (window);
+ return;
+ }
}
/* For those stupid pagers, get a valid timestamp and show a warning */
@@ -3041,7 +3063,8 @@ window_activate (MetaWindow *window,
meta_topic (META_DEBUG_FOCUS,
"Focusing window %s due to activation\n",
window->desc);
- meta_window_focus (window, timestamp);
+ if (!only_raise)
+ meta_window_focus (window, timestamp);
}
/* This function exists since most of the functionality in window_activate
@@ -4759,11 +4782,15 @@ meta_window_configure_request (MetaWindow *window,
"broken behavior and the request is being ignored.\n",
window->desc);
}
+ /* the new_windows_always_on_top check is because a window that
+ * spontaneously restacks itself to the top is a lot like a new
+ * window that doesn't get focus */
else if (active_window &&
!meta_window_same_application (window, active_window) &&
!meta_window_same_client (window, active_window) &&
XSERVER_TIME_IS_BEFORE (window->net_wm_user_time,
- active_window->net_wm_user_time))
+ active_window->net_wm_user_time) &&
+ !meta_prefs_get_new_windows_always_on_top ())
{
meta_topic (META_DEBUG_STACK,
"Ignoring xconfigure stacking request from %s (with "
diff --git a/src/org.gnome.metacity.gschema.xml.in b/src/org.gnome.metacity.gschema.xml.in
index d69d525..edc1b70 100644
--- a/src/org.gnome.metacity.gschema.xml.in
+++ b/src/org.gnome.metacity.gschema.xml.in
@@ -66,6 +66,12 @@
invariant in the 'click' focus mode that the topmost window always
has focus, so its most suitable for use with the 'mouse' and
'sloppy' focus modes.
+
+ This key also affects windows that try to activate or raise themselves
+ themselves but don't succeed in getting the the focus. Without
+ this key being set, such windows are flashed in the taskbar. With
+ this key set they, like entirely new windows, are raised but not
+ focused.
</_description>
</key>
</schema>
--
1.7.9