prefs: Add center-new-windows setting

This commit is contained in:
Rico Tzschichholz 2014-04-25 15:26:24 +02:00
parent 63f1a10e33
commit ca75513880
4 changed files with 44 additions and 4 deletions

View File

@ -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;

View File

@ -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,
},
&center_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";

View File

@ -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);

View File

@ -93,6 +93,15 @@
</_description>
</key>
<key name="center-new-windows" type="b">
<default>false</default>
<_summary>Place new windows in the center</_summary>
<_description>
When true, the new windows will always be put in the center of the
active screen of the monitor.
</_description>
</key>
<child name="keybindings" schema="org.gnome.mutter.keybindings"/>
</schema>