97b0323
From c4fba8198bacc8ecf911cb15c9cd9314f3204a85 Mon Sep 17 00:00:00 2001
97b0323
From: Owen W. Taylor <otaylor@fishsoup.net>
97b0323
Date: Wed, 21 Oct 2009 19:22:35 -0400
97b0323
Subject: [PATCH] Add a new_windows_always_on_top preference
97b0323
97b0323
Add a /apps/metacity/general/new_windows_always_on_top preference.
97b0323
When set, new windows are always placed on top, even if they are
97b0323
denied focus.
97b0323
97b0323
This is useful on large screens and multihead setups where the
97b0323
tasklist can be hard to notice and difficult to mouse to, so the
97b0323
normal behavior of flashing in the tasklist is less effective.
97b0323
---
97b0323
 src/core/prefs.c           |   17 ++++++++++++++++-
97b0323
 src/core/window.c          |    6 +++++-
97b0323
 src/include/prefs.h        |    2 ++
97b0323
 src/metacity.schemas.in.in |   29 +++++++++++++++++++++++++++++
97b0323
 4 files changed, 52 insertions(+), 2 deletions(-)
97b0323
97b0323
diff --git a/src/core/prefs.c b/src/core/prefs.c
97b0323
index e03c816..1bf888b 100644
97b0323
--- a/src/core/prefs.c
97b0323
+++ b/src/core/prefs.c
97b0323
@@ -79,6 +79,7 @@ static MetaFocusMode focus_mode = META_FOCUS_MODE_CLICK;
97b0323
 static MetaFocusNewWindows focus_new_windows = META_FOCUS_NEW_WINDOWS_SMART;
97b0323
 static GSList *no_focus_windows = NULL;
97b0323
 static gboolean raise_on_click = TRUE;
97b0323
+static gboolean new_windows_always_on_top = TRUE;
97b0323
 static char* current_theme = NULL;
97b0323
 static int num_workspaces = 4;
97b0323
 static MetaActionTitlebar action_double_click_titlebar = META_ACTION_TITLEBAR_TOGGLE_MAXIMIZE;
97b0323
@@ -358,6 +359,11 @@ static MetaBoolPreference preferences_bool[] =
97b0323
       &raise_on_click,
97b0323
       TRUE,
97b0323
     },
97b0323
+    { "/apps/metacity/general/new_windows_always_on_top",
97b0323
+      META_PREF_NEW_WINDOWS_ALWAYS_ON_TOP,
97b0323
+      &new_windows_always_on_top,
97b0323
+      TRUE,
97b0323
+    },
97b0323
     { "/apps/metacity/general/titlebar_uses_system_font",
97b0323
       META_PREF_TITLEBAR_FONT, /* note! shares a pref */
97b0323
       &use_system_font,
97b0323
@@ -1271,6 +1277,12 @@ meta_prefs_get_raise_on_click (void)
97b0323
   return raise_on_click || focus_mode == META_FOCUS_MODE_CLICK;
97b0323
 }
97b0323
 
97b0323
+gboolean
97b0323
+meta_prefs_get_new_windows_always_on_top (void)
97b0323
+{
97b0323
+  return new_windows_always_on_top;
97b0323
+}
97b0323
+
97b0323
 const char*
97b0323
 meta_prefs_get_theme (void)
97b0323
 {
97b0323
@@ -1709,7 +1721,10 @@ meta_preference_to_string (MetaPreference pref)
97b0323
 
97b0323
     case META_PREF_RAISE_ON_CLICK:
97b0323
       return "RAISE_ON_CLICK";
97b0323
-      
97b0323
+
97b0323
+    case META_PREF_NEW_WINDOWS_ALWAYS_ON_TOP:
97b0323
+      return "NEW_WINDOWS_ALWAYS_ON_TOP";
97b0323
+
97b0323
     case META_PREF_THEME:
97b0323
       return "THEME";
97b0323
 
97b0323
diff --git a/src/core/window.c b/src/core/window.c
97b0323
index 10da47a..0ae6a01 100644
97b0323
--- a/src/core/window.c
97b0323
+++ b/src/core/window.c
97b0323
@@ -1983,7 +1983,7 @@ window_state_on_map (MetaWindow *window,
97b0323
   if (!(window->input || window->take_focus))
97b0323
     {
97b0323
       *takes_focus = FALSE;
97b0323
-      return;
97b0323
+      goto out;
97b0323
     }
97b0323
 
97b0323
   /* Terminal usage may be different; some users intend to launch
97b0323
@@ -2030,6 +2030,10 @@ window_state_on_map (MetaWindow *window,
97b0323
       /* The default is correct for these */
97b0323
       break;
97b0323
     }
97b0323
+
97b0323
+ out:
97b0323
+  if (meta_prefs_get_new_windows_always_on_top ())
97b0323
+    *places_on_top = TRUE;
97b0323
 }
97b0323
 
97b0323
 static gboolean
97b0323
diff --git a/src/include/prefs.h b/src/include/prefs.h
97b0323
index 6698dfe..8c7cd09 100644
97b0323
--- a/src/include/prefs.h
97b0323
+++ b/src/include/prefs.h
97b0323
@@ -35,6 +35,7 @@ typedef enum
97b0323
   META_PREF_FOCUS_MODE,
97b0323
   META_PREF_FOCUS_NEW_WINDOWS,
97b0323
   META_PREF_RAISE_ON_CLICK,
97b0323
+  META_PREF_NEW_WINDOWS_ALWAYS_ON_TOP,
97b0323
   META_PREF_ACTION_DOUBLE_CLICK_TITLEBAR,
97b0323
   META_PREF_ACTION_MIDDLE_CLICK_TITLEBAR,
97b0323
   META_PREF_ACTION_RIGHT_CLICK_TITLEBAR,
97b0323
@@ -81,6 +82,7 @@ guint                       meta_prefs_get_mouse_button_menu  (void);
97b0323
 MetaFocusMode               meta_prefs_get_focus_mode         (void);
97b0323
 MetaFocusNewWindows         meta_prefs_get_focus_new_windows  (void);
97b0323
 gboolean                    meta_prefs_get_raise_on_click     (void);
97b0323
+gboolean                    meta_prefs_get_new_windows_always_on_top (void);
97b0323
 const char*                 meta_prefs_get_theme              (void);
97b0323
 /* returns NULL if GTK default should be used */
97b0323
 const PangoFontDescription* meta_prefs_get_titlebar_font      (void);
97b0323
diff --git a/src/metacity.schemas.in.in b/src/metacity.schemas.in.in
97b0323
index 25ca5f3..14155fa 100644
97b0323
--- a/src/metacity.schemas.in.in
97b0323
+++ b/src/metacity.schemas.in.in
97b0323
@@ -166,6 +166,35 @@
97b0323
     </schema>
97b0323
 
97b0323
     <schema>
97b0323
+      <key>/schemas/apps/metacity/general/new_windows_always_on_top</key>
97b0323
+      <applyto>/apps/metacity/general/new_windows_always_on_top</applyto>
97b0323
+      <owner>metacity</owner>
97b0323
+      <type>bool</type>
97b0323
+      <default>false</default>
97b0323
+      <locale name="C">
97b0323
+         <short>Whether new windows should always be placed on top</short>
97b0323
+         <long>
97b0323
+           The normal behavior is that if a new window is not given the
97b0323
+	   focus (since, for example, the user has interacted with another
97b0323
+	   window after launching an application), then if the window would
97b0323
+	   be stacked on top of the focus window, the window is instead
97b0323
+	   stacked beneath and flashed in the taskbar. This behavior can
97b0323
+	   be annoying on large screens and multihead setups where the
97b0323
+	   taskbar is hard to notice and difficult to get to, so this option,
97b0323
+	   if set, disables this behavior, and new windows are always placed
97b0323
+	   on top, whether or not they get focus.
97b0323
+
97b0323
+           Note that if this option is set, a new window may completely hide
97b0323
+	   the focus window but not get focus itself, which can be quite confusing
97b0323
+	   to users. Also, note that setting this option breaks the normal
97b0323
+	   invariant in the 'click' focus mode that the topmost window always
97b0323
+	   has focus, so its most suitable for use with the 'mouse' and
97b0323
+	   'sloppy' focus modes.
97b0323
+         </long>
97b0323
+      </locale>
97b0323
+    </schema>
97b0323
+
97b0323
+    <schema>
97b0323
       <key>/schemas/apps/metacity/general/action_double_click_titlebar</key>
97b0323
       <applyto>/apps/metacity/general/action_double_click_titlebar</applyto>
97b0323
       <owner>metacity</owner>
97b0323
-- 
97b0323
1.6.5.rc2
97b0323