summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2004-06-16 21:45:56 +0000
committerHavoc Pennington <hp@src.gnome.org>2004-06-16 21:45:56 +0000
commit61b9cbca78c6c179977e06cd6ed1de1857bd669b (patch)
tree074e00c6441c8d912fbb1f88550cd71942040b3f
parentf663f443f35511dffe0c575c637ad853744b1d28 (diff)
downloadmetacity-61b9cbca78c6c179977e06cd6ed1de1857bd669b.tar.gz
add hacky "no focus on map" pref patch (clearly labeled as a hack only in
2004-06-16 Havoc Pennington <hp@redhat.com> * add hacky "no focus on map" pref patch (clearly labeled as a hack only in rhel3)
-rw-r--r--ChangeLog5
-rw-r--r--src/metacity.schemas.in44
-rw-r--r--src/prefs.c91
-rw-r--r--src/prefs.h6
-rw-r--r--src/window.c8
5 files changed, 148 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index fb8dde72..4996f70f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2004-06-16 Havoc Pennington <hp@redhat.com>
+ * add hacky "no focus on map" pref patch (clearly labeled as a
+ hack only in rhel3)
+
+2004-06-16 Havoc Pennington <hp@redhat.com>
+
* create a RHEL3 branch to manage layering on some patches from
our RPM, this is a dead-end branch for my convenience. Initially
commit all the RPM patches.
diff --git a/src/metacity.schemas.in b/src/metacity.schemas.in
index 17a87004..20efa117 100644
--- a/src/metacity.schemas.in
+++ b/src/metacity.schemas.in
@@ -225,6 +225,50 @@
</locale>
</schema>
+ <schema>
+ <key>/schemas/apps/metacity/rhel3_workarounds/normal_window_focus_on_map</key>
+ <applyto>/apps/metacity/rhel3_workarounds/normal_window_focus_on_map</applyto>
+ <owner>metacity</owner>
+ <type>bool</type>
+ <default>true</default>
+ <locale name="C">
+ <short>If true, newly mapped normal windows are focused</short>
+ <long>
+ If true, metacity will give focus to all newly mapped normal
+ windows. If false, metacity will only give focus to newly mapped
+ normal windows when you when the desktop or a dock application is
+ focused. This setting is a temporary workaround; in GNOME 2.8 and later,
+ it isn't required because the desktop should automatically determine whether
+ focusing a new window is appropriate (i.e. we should fix broken cases on a
+ case-by-case basis, not via global toggle).
+ </long>
+ </locale>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/metacity/rhel3_workarounds/dialog_window_focus_on_map</key>
+ <applyto>/apps/metacity/rhel3_workarounds/dialog_window_focus_on_map</applyto>
+ <owner>metacity</owner>
+ <type>bool</type>
+ <default>true</default>
+ <locale name="C">
+ <short>If true, newly mapped dialog windows are focused</short>
+ <long>
+ If true, metacity will give focus to all newly mapped dialog
+ windows. If false, metacity will only give focus to newly mapped
+ dialog windows when the desktop or a dock application is
+ focused or they are attached to the current main window that you have
+ focused.
+
+ This setting is a temporary workaround; in GNOME 2.8 and
+later,
+ it isn't required because the desktop should automatically determine whether
+ focusing a new window is appropriate (i.e. we should fix broken cases on a
+ case-by-case basis, not via global toggle).
+ </long>
+ </locale>
+ </schema>
+
<!-- Window Keybindings -->
<schema>
diff --git a/src/prefs.c b/src/prefs.c
index 8f7f2f56..0f464bd6 100644
--- a/src/prefs.c
+++ b/src/prefs.c
@@ -48,6 +48,8 @@
#define KEY_DISABLE_WORKAROUNDS "/apps/metacity/general/disable_workarounds"
#define KEY_BUTTON_LAYOUT "/apps/metacity/general/button_layout"
#define KEY_REDUCED_RESOURCES "/apps/metacity/general/reduced_resources"
+#define KEY_NORMAL_WINDOW_FOCUS_ON_MAP "/apps/metacity/rhel3_workarounds/normal_window_focus_on_map"
+#define KEY_DIALOG_WINDOW_FOCUS_ON_MAP "/apps/metacity/rhel3_workarounds/dialog_window_focus_on_map"
#define KEY_COMMAND_PREFIX "/apps/metacity/keybinding_commands/command_"
#define KEY_SCREEN_BINDINGS_PREFIX "/apps/metacity/global_keybindings"
@@ -75,7 +77,10 @@ static gboolean disable_workarounds = FALSE;
static gboolean auto_raise = FALSE;
static gboolean auto_raise_delay = 500;
static gboolean reduced_resources = FALSE;
-
+static gboolean normal_window_focus_on_map = TRUE;
+static gboolean dialog_window_focus_on_map = TRUE;
+
+
static MetaButtonLayout button_layout = {
{
META_BUTTON_FUNCTION_MENU,
@@ -119,6 +124,8 @@ static gboolean update_command (const char *name,
static gboolean update_workspace_name (const char *name,
const char *value);
static gboolean update_reduced_resources (gboolean value);
+static gboolean update_normal_window_focus_on_map(gboolean value);
+static gboolean update_dialog_window_focus_on_map(gboolean value);
static void change_notify (GConfClient *client,
guint cnxn_id,
@@ -367,6 +374,16 @@ meta_prefs_init (void)
&err);
cleanup_error (&err);
update_reduced_resources (bool_val);
+
+ bool_val = gconf_client_get_bool (default_client, KEY_NORMAL_WINDOW_FOCUS_ON_MAP,
+ &err);
+ cleanup_error (&err);
+ update_normal_window_focus_on_map (bool_val);
+
+ bool_val = gconf_client_get_bool (default_client, KEY_DIALOG_WINDOW_FOCUS_ON_MAP,
+ &err);
+ cleanup_error (&err);
+ update_dialog_window_focus_on_map (bool_val);
#endif /* HAVE_GCONF */
/* Load keybindings prefs */
@@ -699,6 +716,38 @@ change_notify (GConfClient *client,
if (update_reduced_resources (b))
queue_changed (META_PREF_REDUCED_RESOURCES);
}
+ else if (strcmp (key, KEY_NORMAL_WINDOW_FOCUS_ON_MAP) == 0)
+ {
+ gboolean b;
+
+ if (value && value->type != GCONF_VALUE_BOOL)
+ {
+ meta_warning (_("GConf key \"%s\" is set to an invalid type\n"),
+ KEY_NORMAL_WINDOW_FOCUS_ON_MAP);
+ goto out;
+ }
+
+ b = value ? gconf_value_get_bool (value) : normal_window_focus_on_map;
+
+ if (update_normal_window_focus_on_map (b))
+ queue_changed (META_PREF_NORMAL_WINDOW_FOCUS_ON_MAP);
+ }
+ else if (strcmp (key, KEY_DIALOG_WINDOW_FOCUS_ON_MAP) == 0)
+ {
+ gboolean b;
+
+ if (value && value->type != GCONF_VALUE_BOOL)
+ {
+ meta_warning (_("GConf key \"%s\" is set to an invalid type\n"),
+ KEY_DIALOG_WINDOW_FOCUS_ON_MAP);
+ goto out;
+ }
+
+ b = value ? gconf_value_get_bool (value) : dialog_window_focus_on_map;
+
+ if (update_dialog_window_focus_on_map (b))
+ queue_changed (META_PREF_DIALOG_WINDOW_FOCUS_ON_MAP);
+ }
else
{
meta_topic (META_DEBUG_PREFS, "Key %s doesn't mean anything to Metacity\n",
@@ -1172,6 +1221,26 @@ update_reduced_resources (gboolean value)
return old != reduced_resources;
}
+
+static gboolean
+update_normal_window_focus_on_map (gboolean value)
+{
+ gboolean old = normal_window_focus_on_map;
+
+ normal_window_focus_on_map = value;
+
+ return old != normal_window_focus_on_map;
+}
+
+static gboolean
+update_dialog_window_focus_on_map (gboolean value)
+{
+ gboolean old = dialog_window_focus_on_map;
+
+ dialog_window_focus_on_map = value;
+
+ return old != dialog_window_focus_on_map;
+}
#endif /* HAVE_GCONF */
#ifdef WITH_VERBOSE_MODE
@@ -1230,6 +1299,14 @@ meta_preference_to_string (MetaPreference pref)
case META_PREF_REDUCED_RESOURCES:
return "REDUCED_RESOURCES";
break;
+
+ case META_PREF_NORMAL_WINDOW_FOCUS_ON_MAP:
+ return "NORMAL_WINDOW_FOCUS_ON_MAP";
+ break;
+
+ case META_PREF_DIALOG_WINDOW_FOCUS_ON_MAP:
+ return "DIALOG_WINDOW_FOCUS_ON_MAP";
+ break;
}
return "(unknown)";
@@ -1855,6 +1932,18 @@ meta_prefs_get_reduced_resources ()
return reduced_resources;
}
+gboolean
+meta_prefs_get_normal_window_focus_on_map ()
+{
+ return normal_window_focus_on_map;
+}
+
+gboolean
+meta_prefs_get_dialog_window_focus_on_map ()
+{
+ return dialog_window_focus_on_map;
+}
+
MetaKeyBindingAction
meta_prefs_get_keybinding_action (const char *name)
{
diff --git a/src/prefs.h b/src/prefs.h
index 8940d33e..5d9b8518 100644
--- a/src/prefs.h
+++ b/src/prefs.h
@@ -43,7 +43,9 @@ typedef enum
META_PREF_COMMANDS,
META_PREF_BUTTON_LAYOUT,
META_PREF_WORKSPACE_NAMES,
- META_PREF_REDUCED_RESOURCES
+ META_PREF_REDUCED_RESOURCES,
+ META_PREF_NORMAL_WINDOW_FOCUS_ON_MAP,
+ META_PREF_DIALOG_WINDOW_FOCUS_ON_MAP
} MetaPreference;
typedef void (* MetaPrefsChangedFunc) (MetaPreference pref,
@@ -68,6 +70,8 @@ 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_reduced_resources (void);
+gboolean meta_prefs_get_normal_window_focus_on_map (void);
+gboolean meta_prefs_get_dialog_window_focus_on_map (void);
const char* meta_prefs_get_command (int i);
diff --git a/src/window.c b/src/window.c
index 46ba0283..c5c640e7 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1504,8 +1504,8 @@ window_takes_focus_on_map (MetaWindow *window)
break;
case META_WINDOW_NORMAL:
- /* Always focus new windows */
- return TRUE;
+ if (meta_prefs_get_normal_window_focus_on_map()) /* Always focus new windows */
+ return TRUE;
/* Old Windows-XP style rule for reference */
/* Focus only if the current focus is on a desktop element
@@ -1523,8 +1523,8 @@ window_takes_focus_on_map (MetaWindow *window)
case META_WINDOW_DIALOG:
case META_WINDOW_MODAL_DIALOG:
- /* Always focus */
- return TRUE;
+ if (meta_prefs_get_dialog_window_focus_on_map()) /* Always focus new windows */
+ return TRUE;
/* Old Windows-XP style rule for reference */
/* Focus only if the transient parent has focus */