? no_raise_on_focus.diff
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/metacity/ChangeLog,v
retrieving revision 1.791
diff -u -p -r1.791 ChangeLog
--- ChangeLog	24 Jan 2004 16:20:35 -0000	1.791
+++ ChangeLog	26 Jan 2004 10:44:51 -0000
@@ -1,4 +1,12 @@
+2004-01-26  Martin Grimme  <martin@pycage.de>
+
+	* src/metacity.schemas.in: 
+	* src/prefs.c: 
+	* src/prefs.h: 
+	* src/display.c (event_callback): Implemented NO_RAISE_ON_FOCUS option
+	where windows don't get raised when receiving the focus.
+
 2004-01-24  James M. Cape  <jcape@ignore-your.tv>
 
 	* src/themes/Esco/metacity-theme-1.xml: Updated this theme.
 
Index: src/display.c
===================================================================
RCS file: /cvs/gnome/metacity/src/display.c,v
retrieving revision 1.213
diff -u -p -r1.213 display.c
--- src/display.c	10 Jan 2004 17:16:05 -0000	1.213
+++ src/display.c	26 Jan 2004 10:44:57 -0000
@@ -1380,7 +1380,7 @@ event_callback (XEvent   *event,
                    * in click to focus mode? The debate rages.
                    * Feel free to change TRUE to FALSE or vice versa
                    */
-                  if (TRUE /* meta_prefs_get_focus_mode () == META_FOCUS_MODE_CLICK */) 
+                  if (! meta_prefs_get_no_raise_on_focus () /* meta_prefs_get_focus_mode () == META_FOCUS_MODE_CLICK */) 
                     {
                       meta_window_raise (window);
                       
Index: src/metacity.schemas.in
===================================================================
RCS file: /cvs/gnome/metacity/src/metacity.schemas.in,v
retrieving revision 1.33
diff -u -p -r1.33 metacity.schemas.in
--- src/metacity.schemas.in	17 Jan 2004 18:59:42 -0000	1.33
+++ src/metacity.schemas.in	26 Jan 2004 10:45:01 -0000
@@ -110,6 +110,22 @@
     </schema>
 
     <schema>
+      <key>/schemas/apps/metacity/general/no_raise_on_focus</key>
+      <applyto>/apps/metacity/general/no_raise_on_focus</applyto>
+      <owner>metacity</owner>
+      <type>bool</type>
+      <default>false</default>
+      <locale name="C">
+         <short>Does not raise windows receiving focus</short>
+         <long>
+          If true, then windows that receive the focus will not be
+          raised automatically, unless you click on the frame or
+          titlebar.
+         </long>
+      </locale>
+    </schema>
+
+    <schema>
       <key>/schemas/apps/metacity/general/theme</key>
       <applyto>/apps/metacity/general/theme</applyto>
       <owner>metacity</owner>
Index: src/prefs.c
===================================================================
RCS file: /cvs/gnome/metacity/src/prefs.c,v
retrieving revision 1.45
diff -u -p -r1.45 prefs.c
--- src/prefs.c	12 Oct 2003 06:25:38 -0000	1.45
+++ src/prefs.c	26 Jan 2004 10:45:03 -0000
@@ -44,6 +44,7 @@
 #define KEY_ACTION_DOUBLE_CLICK_TITLEBAR "/apps/metacity/general/action_double_click_titlebar"
 #define KEY_AUTO_RAISE "/apps/metacity/general/auto_raise"
 #define KEY_AUTO_RAISE_DELAY "/apps/metacity/general/auto_raise_delay"
+#define KEY_NO_RAISE_ON_FOCUS "/apps/metacity/general/no_raise_on_focus"
 #define KEY_THEME "/apps/metacity/general/theme"
 #define KEY_USE_SYSTEM_FONT  "/apps/metacity/general/titlebar_uses_system_font"
 #define KEY_TITLEBAR_FONT "/apps/metacity/general/titlebar_font"
@@ -82,6 +83,7 @@ static gboolean application_based = FALS
 static gboolean disable_workarounds = FALSE;
 static gboolean auto_raise = FALSE;
 static gboolean auto_raise_delay = 500;
+static gboolean no_raise_on_focus = FALSE;
 static gboolean provide_visual_bell = TRUE;
 static gboolean bell_is_audible = TRUE;
 static gboolean reduced_resources = FALSE;
@@ -121,6 +123,7 @@ static gboolean update_disable_workaroun
 static gboolean update_action_double_click_titlebar (const char *value);
 static gboolean update_auto_raise          (gboolean   value);
 static gboolean update_auto_raise_delay    (int        value);
+static gboolean update_no_raise_on_focus   (gboolean   value);
 static gboolean update_button_layout      (const char *value);
 static gboolean update_window_binding     (const char *name,
                                            const char *value);
@@ -332,6 +335,11 @@ meta_prefs_init (void)
 				  &err);
   cleanup_error (&err);
   update_auto_raise_delay (int_val);
+
+  bool_val = gconf_client_get_bool (default_client, KEY_NO_RAISE_ON_FOCUS,
+				    &err);
+  cleanup_error (&err);
+  update_no_raise_on_focus (bool_val);
   
 
   str_val = gconf_client_get_string (default_client, KEY_THEME,
@@ -663,6 +671,22 @@ change_notify (GConfClient    *client,
         queue_changed (META_PREF_AUTO_RAISE_DELAY);
     
     }
+  else if (strcmp (key, KEY_NO_RAISE_ON_FOCUS) == 0)
+    {
+      gboolean b;
+
+      if (value && value->type != GCONF_VALUE_BOOL)
+        {
+          meta_warning (_("GConf key \"%s\" is set to an invalid type\n"),
+                        KEY_NO_RAISE_ON_FOCUS);
+          goto out;
+        }
+
+      b = value ? gconf_value_get_bool (value) : no_raise_on_focus;
+
+      if (update_no_raise_on_focus (b))
+        queue_changed (META_PREF_NO_RAISE_ON_FOCUS);
+    }
   else if (str_has_prefix (key, KEY_COMMAND_PREFIX))
     {
       const char *str;
@@ -1266,6 +1290,16 @@ update_auto_raise_delay (int value)
 }
 
 static gboolean
+update_no_raise_on_focus (gboolean value)
+{
+  gboolean old = no_raise_on_focus;
+
+  no_raise_on_focus = value;
+
+  return old != no_raise_on_focus;
+}
+
+static gboolean
 update_reduced_resources (gboolean value)
 {
   gboolean old = reduced_resources;
@@ -1318,6 +1352,9 @@ meta_preference_to_string (MetaPreferenc
     case META_PREF_AUTO_RAISE_DELAY:
       return "AUTO_RAISE_DELAY";
 
+    case META_PREF_NO_RAISE_ON_FOCUS:
+      return "NO_RAISE_ON_FOCUS";
+
     case META_PREF_COMMANDS:
       return "COMMANDS";
 
@@ -2014,6 +2051,12 @@ meta_prefs_get_auto_raise_delay ()
 }
 
 gboolean
+meta_prefs_get_no_raise_on_focus ()
+{
+  return no_raise_on_focus;
+}
+
+gboolean
 meta_prefs_get_reduced_resources ()
 {
   return reduced_resources;
Index: src/prefs.h
===================================================================
RCS file: /cvs/gnome/metacity/src/prefs.h,v
retrieving revision 1.33
diff -u -p -r1.33 prefs.h
--- src/prefs.h	12 Oct 2003 06:25:38 -0000	1.33
+++ src/prefs.h	26 Jan 2004 10:45:04 -0000
@@ -33,6 +33,7 @@ typedef enum
   META_PREF_ACTION_DOUBLE_CLICK_TITLEBAR,
   META_PREF_AUTO_RAISE,
   META_PREF_AUTO_RAISE_DELAY,
+  META_PREF_NO_RAISE_ON_FOCUS,
   META_PREF_THEME,
   META_PREF_TITLEBAR_FONT,
   META_PREF_NUM_WORKSPACES,
@@ -70,6 +71,7 @@ gboolean                    meta_prefs_g
 gboolean                    meta_prefs_get_disable_workarounds (void);
 gboolean                    meta_prefs_get_auto_raise         (void);
 int                         meta_prefs_get_auto_raise_delay   (void);
+gboolean                    meta_prefs_get_no_raise_on_focus  (void);
 gboolean                    meta_prefs_get_reduced_resources  (void);
 
 const char*                 meta_prefs_get_command            (int i);
