diff -Nur -x '*.orig' -x '*~' metacity-2.24.0/src/core/prefs.c metacity-2.24.0.new/src/core/prefs.c --- metacity-2.24.0/src/core/prefs.c 2009-01-15 17:40:34.000000000 +0100 +++ metacity-2.24.0.new/src/core/prefs.c 2009-01-15 17:45:56.000000000 +0100 @@ -62,6 +62,8 @@ #define KEY_WORKSPACE_NAME_PREFIX "/apps/metacity/workspace_names/name_" +#define KEY_NEVER_MAXIMIZE "/apps/metacity/general/never_maximize" + #ifdef HAVE_GCONF static GConfClient *default_client = NULL; @@ -93,6 +95,8 @@ static char *cursor_theme = NULL; static int cursor_size = 24; static gboolean compositing_manager = FALSE; +static gboolean start_maximized = TRUE; +static GSList* never_maximize = NULL; static MetaVisualBellType visual_bell_type = META_VISUAL_BELL_FULLSCREEN_FLASH; static MetaButtonLayout button_layout; @@ -406,6 +410,11 @@ &compositing_manager, FALSE, }, + { "/apps/metacity/general/start_maximized", + META_PREF_START_MAXIMIZED, + &start_maximized, + FALSE, + }, { NULL, 0, NULL, FALSE }, }; @@ -600,6 +609,14 @@ } } +static void +handle_preference_init_list (void) +{ + never_maximize = gconf_client_get_list (default_client, + KEY_NEVER_MAXIMIZE, + GCONF_VALUE_STRING, NULL); +} + static gboolean handle_preference_update_enum (const gchar *key, GConfValue *value) { @@ -983,6 +1000,7 @@ KEY_GNOME_ACCESSIBILITY, "/desktop/gnome/peripherals/mouse", "/desktop/gnome/interface", + KEY_NEVER_MAXIMIZE, NULL, }; @@ -1016,6 +1034,7 @@ handle_preference_init_bool (); handle_preference_init_string (); handle_preference_init_int (); + handle_preference_init_list (); /* @@@ Is there any reason we don't do the add_dir here? */ for (gconf_dir_cursor=gconf_dirs_we_are_interested_in; @@ -1199,6 +1218,15 @@ if (update_workspace_name (key, str)) queue_changed (META_PREF_WORKSPACE_NAMES); } + else if (g_str_has_prefix (key, KEY_NEVER_MAXIMIZE)) + { + if (never_maximize != NULL) + g_slist_free (never_maximize); + + never_maximize = gconf_client_get_list (default_client, + KEY_NEVER_MAXIMIZE, + GCONF_VALUE_STRING, NULL); + } else { meta_topic (META_DEBUG_PREFS, "Key %s doesn't mean anything to Metacity\n", @@ -1778,6 +1806,9 @@ case META_PREF_COMPOSITING_MANAGER: return "COMPOSITING_MANAGER"; + + case META_PREF_START_MAXIMIZED: + return "START_MAXIMIZED"; } return "(unknown)"; @@ -2944,6 +2975,25 @@ return compositing_manager; } +gboolean +meta_prefs_get_start_maximized (void) +{ + return start_maximized; +} + +gboolean +meta_prefs_never_maximize (const char *klass) +{ + GSList *iter; + + for (iter = never_maximize; iter; iter = iter->next) + { + if (iter->data && !strcmp (iter->data, klass)) return TRUE; + } + + return FALSE; +} + #ifndef HAVE_GCONF static void init_button_layout(void) diff -Nur -x '*.orig' -x '*~' metacity-2.24.0/src/core/window.c metacity-2.24.0.new/src/core/window.c --- metacity-2.24.0/src/core/window.c 2009-01-15 17:40:34.000000000 +0100 +++ metacity-2.24.0.new/src/core/window.c 2009-01-15 17:46:18.000000000 +0100 @@ -118,6 +118,8 @@ static void unmaximize_window_before_freeing (MetaWindow *window); static void unminimize_window_and_all_transient_parents (MetaWindow *window); +static gboolean maximus_is_candidate (MetaWindow *window); + /* Idle handlers for the three queues. The "data" parameter in each case * will be a GINT_TO_POINTER of the index into the queue arrays to use. * @@ -507,6 +509,7 @@ window->mwm_has_resize_func = TRUE; window->decorated = TRUE; + window->suppress_decoration = FALSE; window->has_close_func = TRUE; window->has_minimize_func = TRUE; window->has_maximize_func = TRUE; @@ -620,6 +623,15 @@ window->placed = TRUE; } + /* "Start Maximized" behaviour for netbooks */ + if (maximus_is_candidate (window)) + { + window->maximize_horizontally_after_placement = TRUE; + window->maximize_vertically_after_placement = TRUE; + window->suppress_decoration = TRUE; + window->decorated = FALSE; + } + /* Apply any window attributes such as initial workspace * based on startup notification */ @@ -2630,6 +2642,7 @@ (unmaximize_vertically && window->maximized_vertically)) { MetaRectangle target_rect; + gboolean unsuppress; meta_topic (META_DEBUG_WINDOW_OPS, "Unmaximizing %s%s\n", @@ -2658,6 +2671,17 @@ target_rect.height = window->saved_rect.height; } + /* "Start Maximized" behaviour for netbooks */ + unsuppress = window->suppress_decoration; + + if (unsuppress) + { + window->suppress_decoration = FALSE; + recalc_window_features (window); + if (window->decorated) + meta_window_ensure_frame (window); + } + /* Window's size hints may have changed while maximized, making * saved_rect invalid. #329152 */ @@ -2688,6 +2712,9 @@ recalc_window_features (window); set_net_wm_state (window); + + if (unsuppress) + meta_window_queue (window, META_QUEUE_CALC_SHOWING); } } @@ -6305,6 +6332,10 @@ window->has_maximize_func = FALSE; } + /* "Start Maximized" behaviour for netbooks */ + if (window->suppress_decoration) + window->decorated = FALSE; + meta_topic (META_DEBUG_WINDOW_OPS, "Window %s fullscreen = %d not resizable, maximizable = %d fullscreenable = %d min size %dx%d max size %dx%d\n", window->desc, @@ -8172,3 +8203,43 @@ { return window->xwindow; } + +static gboolean +maximus_is_candidate (MetaWindow *window) +{ + /* From maximus, Neil J Patel */ + static const gchar *default_exclude_classes[] = + { + "Bluetooth-properties", + "Bluetooth-wizard", + "Ekiga", + "Gcalctool", + "Gimp", + "Gnome-dictionary", + "Gnome-launguage-selector", + "Gnome-nettool", + "Gnome-volume-control", + "Kiten", + "Kmplot", + "Nm-editor", + "Pidgin", + "Update-manager", + "Skype", + "Transmission" + }; + guint i; + + if (!meta_prefs_get_start_maximized ()) return FALSE; + if (!window->has_resize_func) return FALSE; + if (window->type != META_WINDOW_NORMAL) return FALSE; + if (window->res_class == NULL) return FALSE; + + for (i = 0; i < G_N_ELEMENTS (default_exclude_classes); i++) + { + if (!strcmp (default_exclude_classes[i], window->res_class)) + return FALSE; + } + + return !meta_prefs_never_maximize (window->res_class); +} + diff -Nur -x '*.orig' -x '*~' metacity-2.24.0/src/core/window-private.h metacity-2.24.0.new/src/core/window-private.h --- metacity-2.24.0/src/core/window-private.h 2009-01-15 17:40:34.000000000 +0100 +++ metacity-2.24.0.new/src/core/window-private.h 2009-01-15 17:46:37.000000000 +0100 @@ -208,6 +208,9 @@ guint has_resize_func : 1; guint has_fullscreen_func : 1; + /* Suppress decoration */ + guint suppress_decoration : 1; + /* Weird "_NET_WM_STATE_MODAL" flag */ guint wm_state_modal : 1; diff -Nur -x '*.orig' -x '*~' metacity-2.24.0/src/include/prefs.h metacity-2.24.0.new/src/include/prefs.h --- metacity-2.24.0/src/include/prefs.h 2009-01-15 17:40:34.000000000 +0100 +++ metacity-2.24.0.new/src/include/prefs.h 2009-01-15 17:47:00.000000000 +0100 @@ -59,7 +59,8 @@ META_PREF_GNOME_ANIMATIONS, META_PREF_CURSOR_THEME, META_PREF_CURSOR_SIZE, - META_PREF_COMPOSITING_MANAGER + META_PREF_COMPOSITING_MANAGER, + META_PREF_START_MAXIMIZED } MetaPreference; typedef void (* MetaPrefsChangedFunc) (MetaPreference pref, @@ -113,6 +114,9 @@ int meta_prefs_get_cursor_size (void); gboolean meta_prefs_get_compositing_manager (void); +gboolean meta_prefs_get_start_maximized (void); +gboolean meta_prefs_never_maximize (const char *klass); + /* Screen bindings */ #define META_KEYBINDING_WORKSPACE_1 "switch_to_workspace_1" #define META_KEYBINDING_WORKSPACE_2 "switch_to_workspace_2" diff -Nur -x '*.orig' -x '*~' metacity-2.24.0/src/metacity.schemas metacity-2.24.0.new/src/metacity.schemas --- metacity-2.24.0/src/metacity.schemas 2009-01-15 17:40:34.000000000 +0100 +++ metacity-2.24.0.new/src/metacity.schemas 2009-01-15 17:47:28.000000000 +0100 @@ -6441,6 +6441,38 @@ + /schemas/apps/metacity/general/start_maximized + /apps/metacity/general/start_maximized + metacity + bool + false + + Start Maximized + + Determines whether new windows should appear maximized and + undecorated, typically for use with small-screen netbooks. + + + + + + /schemas/apps/metacity/general/never_maximize + /apps/metacity/general/never_maximize + metacity + list + string + [] + + Never Maximize + + A list of window class names that should never be + automatically maximized when start_maximized is + enabled. + + + + + /schemas/apps/metacity/workspace_names/name /apps/metacity/workspace_names/name_1 /apps/metacity/workspace_names/name_2 diff -Nur -x '*.orig' -x '*~' metacity-2.24.0/src/metacity.schemas.in metacity-2.24.0.new/src/metacity.schemas.in --- metacity-2.24.0/src/metacity.schemas.in 2009-01-15 17:40:34.000000000 +0100 +++ metacity-2.24.0.new/src/metacity.schemas.in 2009-01-15 17:47:38.000000000 +0100 @@ -341,6 +341,38 @@ + /schemas/apps/metacity/general/start_maximized + /apps/metacity/general/start_maximized + metacity + bool + false + + Start Maximized + + Determines whether new windows should appear maximized and + undecorated, typically for use with small-screen netbooks. + + + + + + /schemas/apps/metacity/general/never_maximize + /apps/metacity/general/never_maximize + metacity + list + string + [] + + Never Maximize + + A list of window class names that should never be + automatically maximized when start_maximized is + enabled. + + + + + /schemas/apps/metacity/workspace_names/name /apps/metacity/workspace_names/name_1 /apps/metacity/workspace_names/name_2