diff --git a/src/core/place.c b/src/core/place.c index 6c0efc128..fea6beaed 100644 --- a/src/core/place.c +++ b/src/core/place.c @@ -318,6 +318,19 @@ window_overlaps_focus_window (MetaWindow *window) &overlap); } +static gboolean +window_place_centered (MetaWindow *window) +{ + MetaWindowType type; + + type = window->type; + + return (type == META_WINDOW_DIALOG || + type == META_WINDOW_MODAL_DIALOG || + type == META_WINDOW_SPLASHSCREEN || + (type == META_WINDOW_NORMAL && meta_prefs_get_center_new_windows ())); +} + static void avoid_being_obscured_as_second_modal_dialog (MetaWindow *window, int *x, @@ -737,9 +750,7 @@ meta_window_place (MetaWindow *window, * on the sides of the parent window or something. */ - if (window->type == META_WINDOW_DIALOG || - window->type == META_WINDOW_MODAL_DIALOG || - window->type == META_WINDOW_SPLASHSCREEN) + if (window_place_centered (window)) { /* Center on current monitor */ int w, h; diff --git a/src/core/prefs.c b/src/core/prefs.c index 716967a67..c3bf10520 100644 --- a/src/core/prefs.c +++ b/src/core/prefs.c @@ -80,6 +80,7 @@ static MetaKeyCombo overlay_key_combo = { 0, 0, 0 }; static GDesktopFocusMode focus_mode = G_DESKTOP_FOCUS_MODE_CLICK; static GDesktopFocusNewWindows focus_new_windows = G_DESKTOP_FOCUS_NEW_WINDOWS_SMART; static gboolean raise_on_click = TRUE; +static gboolean center_new_windows = FALSE; static gboolean attach_modal_dialogs = FALSE; static char* current_theme = NULL; static int num_workspaces = 4; @@ -272,6 +273,13 @@ static MetaBoolPreference preferences_bool[] = }, &attach_modal_dialogs, }, + { + { "center-new-windows", + SCHEMA_MUTTER, + META_PREF_CENTER_NEW_WINDOWS, + }, + ¢er_new_windows, + }, { { "raise-on-click", SCHEMA_GENERAL, @@ -1214,6 +1222,12 @@ meta_prefs_get_focus_new_windows (void) return focus_new_windows; } +gboolean +meta_prefs_get_center_new_windows (void) +{ + return center_new_windows; +} + gboolean meta_prefs_get_attach_modal_dialogs (void) { @@ -1729,6 +1743,9 @@ meta_preference_to_string (MetaPreference pref) case META_PREF_FOCUS_NEW_WINDOWS: return "FOCUS_NEW_WINDOWS"; + case META_PREF_CENTER_NEW_WINDOWS: + return "CENTER_NEW_WINDOWS"; + case META_PREF_ATTACH_MODAL_DIALOGS: return "ATTACH_MODAL_DIALOGS"; diff --git a/src/meta/prefs.h b/src/meta/prefs.h index de2ab1793..b43a23923 100644 --- a/src/meta/prefs.h +++ b/src/meta/prefs.h @@ -64,6 +64,7 @@ * @META_PREF_WORKSPACES_ONLY_ON_PRIMARY: workspaces only on primary * @META_PREF_DRAGGABLE_BORDER_WIDTH: draggable border width * @META_PREF_AUTO_MAXIMIZE: auto-maximize + * @META_PREF_CENTER_NEW_WINDOWS: center new windows */ /* Keep in sync with GSettings schemas! */ @@ -100,7 +101,8 @@ typedef enum META_PREF_FORCE_FULLSCREEN, META_PREF_WORKSPACES_ONLY_ON_PRIMARY, META_PREF_DRAGGABLE_BORDER_WIDTH, - META_PREF_AUTO_MAXIMIZE + META_PREF_AUTO_MAXIMIZE, + META_PREF_CENTER_NEW_WINDOWS } MetaPreference; typedef void (* MetaPrefsChangedFunc) (MetaPreference pref, @@ -138,6 +140,7 @@ gboolean meta_prefs_get_gnome_accessibility (void); gboolean meta_prefs_get_gnome_animations (void); gboolean meta_prefs_get_edge_tiling (void); gboolean meta_prefs_get_auto_maximize (void); +gboolean meta_prefs_get_center_new_windows (void); void meta_prefs_get_button_layout (MetaButtonLayout *button_layout); diff --git a/src/org.gnome.mutter.gschema.xml.in b/src/org.gnome.mutter.gschema.xml.in index 9d83cf3aa..cffeeb8c5 100644 --- a/src/org.gnome.mutter.gschema.xml.in +++ b/src/org.gnome.mutter.gschema.xml.in @@ -93,6 +93,15 @@ + + false + <_summary>Place new windows in the center + <_description> + When true, the new windows will always be put in the center of the + active screen of the monitor. + + +