From 861a3efb0f531eae767926d18c4d690366306bfe Mon Sep 17 00:00:00 2001
From: "Owen W. Taylor" <otaylor@fishsoup.net>
Date: Wed, 21 Oct 2009 19:22:35 -0400
Subject: [PATCH] Add a new-windows-always-on-top preference
Add a new-windows-always-on-top preference. When set, new windows
are always placed on top, even if they are denied focus.
This is useful on large screens and multihead setups where the
tasklist can be hard to notice and difficult to mouse to, so the
normal behavior of flashing in the tasklist is less effective.
---
src/core/prefs.c | 20 +++++++++++++++++++-
src/core/window.c | 6 +++++-
src/include/prefs.h | 2 ++
src/metacity-schemas.convert | 1 +
src/org.gnome.metacity.gschema.xml.in | 22 ++++++++++++++++++++++
5 files changed, 49 insertions(+), 2 deletions(-)
diff --git a/src/core/prefs.c b/src/core/prefs.c
index 24a98cd..949f6ed 100644
--- a/src/core/prefs.c
+++ b/src/core/prefs.c
@@ -73,6 +73,7 @@ static GDesktopFocusMode focus_mode = G_DESKTOP_FOCUS_MODE_CLICK;
static GDesktopFocusNewWindows focus_new_windows = G_DESKTOP_FOCUS_NEW_WINDOWS_SMART;
static GSList *no_focus_windows = NULL;
static gboolean raise_on_click = TRUE;
+static gboolean new_windows_always_on_top = TRUE;
static char* current_theme = NULL;
static int num_workspaces = 4;
static GDesktopTitlebarAction action_double_click_titlebar = G_DESKTOP_TITLEBAR_ACTION_TOGGLE_MAXIMIZE;
@@ -261,6 +262,14 @@ static MetaBoolPreference preferences_bool[] =
TRUE,
},
{
+ { "new-windows-always-on-top",
+ SCHEMA_METACITY,
+ META_PREF_NEW_WINDOWS_ALWAYS_ON_TOP,
+ },
+ &new_windows_always_on_top,
+ TRUE,
+ },
+ {
{ "titlebar-uses-system-font",
SCHEMA_GENERAL,
META_PREF_TITLEBAR_FONT, /* note! shares a pref */
@@ -920,6 +929,12 @@ meta_prefs_get_raise_on_click (void)
return raise_on_click || focus_mode == G_DESKTOP_FOCUS_MODE_CLICK;
}
+gboolean
+meta_prefs_get_new_windows_always_on_top (void)
+{
+ return new_windows_always_on_top;
+}
+
const char*
meta_prefs_get_theme (void)
{
@@ -1386,7 +1401,10 @@ meta_preference_to_string (MetaPreference pref)
case META_PREF_RAISE_ON_CLICK:
return "RAISE_ON_CLICK";
-
+
+ case META_PREF_NEW_WINDOWS_ALWAYS_ON_TOP:
+ return "NEW_WINDOWS_ALWAYS_ON_TOP";
+
case META_PREF_THEME:
return "THEME";
diff --git a/src/core/window.c b/src/core/window.c
index 6f5c280..b6a69b0 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -2008,7 +2008,7 @@ window_state_on_map (MetaWindow *window,
if (!(window->input || window->take_focus))
{
*takes_focus = FALSE;
- return;
+ goto out;
}
/* Terminal usage may be different; some users intend to launch
@@ -2055,6 +2055,10 @@ window_state_on_map (MetaWindow *window,
/* The default is correct for these */
break;
}
+
+ out:
+ if (meta_prefs_get_new_windows_always_on_top ())
+ *places_on_top = TRUE;
}
static gboolean
diff --git a/src/include/prefs.h b/src/include/prefs.h
index b86843c..c49e93d 100644
--- a/src/include/prefs.h
+++ b/src/include/prefs.h
@@ -37,6 +37,7 @@ typedef enum
META_PREF_FOCUS_MODE,
META_PREF_FOCUS_NEW_WINDOWS,
META_PREF_RAISE_ON_CLICK,
+ META_PREF_NEW_WINDOWS_ALWAYS_ON_TOP,
META_PREF_ACTION_DOUBLE_CLICK_TITLEBAR,
META_PREF_ACTION_MIDDLE_CLICK_TITLEBAR,
META_PREF_ACTION_RIGHT_CLICK_TITLEBAR,
@@ -81,6 +82,7 @@ guint meta_prefs_get_mouse_button_menu (void);
GDesktopFocusMode meta_prefs_get_focus_mode (void);
GDesktopFocusNewWindows meta_prefs_get_focus_new_windows (void);
gboolean meta_prefs_get_raise_on_click (void);
+gboolean meta_prefs_get_new_windows_always_on_top (void);
const char* meta_prefs_get_theme (void);
/* returns NULL if GTK default should be used */
const PangoFontDescription* meta_prefs_get_titlebar_font (void);
diff --git a/src/metacity-schemas.convert b/src/metacity-schemas.convert
index 9c271c6..f1fce08 100644
--- a/src/metacity-schemas.convert
+++ b/src/metacity-schemas.convert
@@ -2,3 +2,4 @@
compositing-manager = /apps/metacity/general/compositing_manager
reduced-resources = /apps/metacity/general/reduced_resources
no-focus-windows = /apps/metacity/general/no_focus_windows
+new-windows-always-on-top = /apps/metacity/general/new_windows_always_on_top
diff --git a/src/org.gnome.metacity.gschema.xml.in b/src/org.gnome.metacity.gschema.xml.in
index e4f86bd..d69d525 100644
--- a/src/org.gnome.metacity.gschema.xml.in
+++ b/src/org.gnome.metacity.gschema.xml.in
@@ -46,6 +46,28 @@
this setting.
</_description>
</key>
+ <key name="new-windows-always-on-top" type="b">
+ <default>false</default>
+ <_summary>Whether new windows should always be placed on top</_summary>
+ <_description>
+ The normal behavior is that if a new window is not given the
+ focus (since, for example, the user has interacted with another
+ window after launching an application), then if the window would
+ be stacked on top of the focus window, the window is instead
+ stacked beneath and flashed in the taskbar. This behavior can
+ be annoying on large screens and multihead setups where the
+ taskbar is hard to notice and difficult to get to, so this option,
+ if set, disables this behavior, and new windows are always placed
+ on top, whether or not they get focus.
+
+ Note that if this option is set, a new window may completely hide
+ the focus window but not get focus itself, which can be quite confusing
+ to users. Also, note that setting this option breaks the normal
+ 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.
+ </_description>
+ </key>
</schema>
</schemalist>
--
1.7.9