updated on Mon Jan 16 04:00:32 UTC 2012
[aur-mirror.git] / metacity-ubuntu / 18-auto-maximize-windows.patch
blob404adf7e070fb65e0b7c2970cb5f646da31ab36b
1 === modified file 'src/core/display.c'
2 Index: metacity-2.34.1/src/core/display.c
3 ===================================================================
4 --- metacity-2.34.1.orig/src/core/display.c 2011-08-18 00:09:44.199438223 -0400
5 +++ metacity-2.34.1/src/core/display.c 2011-08-18 00:10:26.650462017 -0400
6 @@ -2010,6 +2010,8 @@
8 break;
9 case MapNotify:
10 + if (window && meta_prefs_get_auto_maximize_windows())
11 + meta_window_auto_maximize (window);
12 break;
13 case MapRequest:
14 if (window == NULL)
15 Index: metacity-2.34.1/src/core/prefs.c
16 ===================================================================
17 --- metacity-2.34.1.orig/src/core/prefs.c 2011-08-18 00:10:19.830297517 -0400
18 +++ metacity-2.34.1/src/core/prefs.c 2011-08-18 00:10:26.650462017 -0400
19 @@ -103,6 +103,7 @@
20 static gboolean hide_decorator_tooltip = FALSE;
21 static gboolean show_maximized_titlebars = TRUE;
22 static gboolean workspace_switcher_keyboard_cycle = FALSE;
23 +static gboolean auto_maximize_windows = FALSE;
25 static MetaVisualBellType visual_bell_type = META_VISUAL_BELL_FULLSCREEN_FLASH;
26 static MetaButtonLayout button_layout;
27 @@ -443,6 +444,11 @@
28 &workspace_switcher_keyboard_cycle,
29 FALSE,
31 + { "/apps/metacity/general/auto_maximize_windows",
32 + META_PREF_AUTO_MAXIMIZE_WINDOWS,
33 + &auto_maximize_windows,
34 + FALSE,
35 + },
36 { NULL, 0, NULL, FALSE },
39 @@ -1812,6 +1818,9 @@
41 case META_PREF_WORKSPACE_SWITCHER_KEYBOARD_CYCLE:
42 return "WORKSPACE_SWITCHER_KEYBOARD_CYCLE";
44 + case META_PREF_AUTO_MAXIMIZE_WINDOWS:
45 + return "META_PREF_AUTO_MAXIMIZE_WINDOWS";
48 return "(unknown)";
49 @@ -2773,6 +2782,12 @@
50 return workspace_switcher_keyboard_cycle;
53 +gboolean
54 +meta_prefs_get_auto_maximize_windows (void)
56 + return auto_maximize_windows;
59 guint
60 meta_prefs_get_mouse_button_resize (void)
62 Index: metacity-2.34.1/src/core/window-private.h
63 ===================================================================
64 --- metacity-2.34.1.orig/src/core/window-private.h 2011-03-08 04:31:53.000000000 -0500
65 +++ metacity-2.34.1/src/core/window-private.h 2011-08-18 00:10:26.650462017 -0400
66 @@ -410,6 +410,7 @@
67 void meta_window_maximize_internal (MetaWindow *window,
68 MetaMaximizeFlags directions,
69 MetaRectangle *saved_rect);
70 +void meta_window_auto_maximize (MetaWindow *window);
71 void meta_window_unmaximize (MetaWindow *window,
72 MetaMaximizeFlags directions);
73 void meta_window_make_above (MetaWindow *window);
74 Index: metacity-2.34.1/src/core/window.c
75 ===================================================================
76 --- metacity-2.34.1.orig/src/core/window.c 2011-08-18 00:10:11.330092500 -0400
77 +++ metacity-2.34.1/src/core/window.c 2011-08-18 00:10:26.660462267 -0400
78 @@ -54,8 +54,9 @@
79 #include <X11/extensions/shape.h>
80 #endif
82 -static int destroying_windows_disallowed = 0;
83 +#define AUTO_MAXIMIZE_MINIMUM_COVERAGE 0.75
85 +static int destroying_windows_disallowed = 0;
87 static void update_sm_hints (MetaWindow *window);
88 static void update_net_frame_extents (MetaWindow *window);
89 @@ -2696,6 +2697,30 @@
93 +void
94 +meta_window_auto_maximize (MetaWindow *window)
96 + const MetaXineramaScreenInfo* info;
97 + int screen_surface, window_surface;
98 + double coverage;
100 + if (window->type != META_WINDOW_NORMAL || !window->has_maximize_func)
101 + return;
103 + if (window->maximized_horizontally || window->maximized_vertically)
104 + return;
106 + info = meta_screen_get_xinerama_for_window (window->display->active_screen, window);
107 + g_return_if_fail (info);
108 + screen_surface = info->rect.width * info->rect.height;
109 + g_return_if_fail (screen_surface != 0);
110 + window_surface = window->rect.width * window->rect.height;
111 + coverage = (double)(window_surface) / screen_surface;
113 + if (coverage > AUTO_MAXIMIZE_MINIMUM_COVERAGE && coverage <= 1.0)
114 + meta_window_maximize (window, META_MAXIMIZE_HORIZONTAL | META_MAXIMIZE_VERTICAL);
117 static void
118 unmaximize_window_before_freeing (MetaWindow *window)
120 Index: metacity-2.34.1/src/include/prefs.h
121 ===================================================================
122 --- metacity-2.34.1.orig/src/include/prefs.h 2011-08-18 00:10:19.830297517 -0400
123 +++ metacity-2.34.1/src/include/prefs.h 2011-08-18 00:10:26.660462267 -0400
124 @@ -65,7 +65,8 @@
125 META_PREF_FORCE_FULLSCREEN,
126 META_PREF_HIDE_DECORATOR_TOOLTIP,
127 META_PREF_SHOW_MAXIMIZED_TITLEBARS,
128 - META_PREF_WORKSPACE_SWITCHER_KEYBOARD_CYCLE
129 + META_PREF_AUTO_MAXIMIZE_WINDOWS,
130 + META_PREF_WORKSPACE_SWITCHER_KEYBOARD_CYCLE,
131 } MetaPreference;
133 typedef void (* MetaPrefsChangedFunc) (MetaPreference pref,
134 @@ -127,6 +128,7 @@
135 gboolean meta_prefs_get_capture_before_unmap (void);
136 gboolean meta_prefs_get_workspace_switcher_keyboard_cycle (void);
138 +gboolean meta_prefs_get_auto_maximize_windows (void);
141 * Sets whether the compositor is turned on.
142 Index: metacity-2.34.1/src/metacity.schemas.in.in
143 ===================================================================
144 --- metacity-2.34.1.orig/src/metacity.schemas.in.in 2011-08-18 00:10:19.830297517 -0400
145 +++ metacity-2.34.1/src/metacity.schemas.in.in 2011-08-18 00:10:26.660462267 -0400
146 @@ -357,6 +357,21 @@
147 </schema>
149 <schema>
150 + <key>/schemas/apps/metacity/general/auto_maximize_windows</key>
151 + <applyto>/apps/metacity/general/auto_maximize_windows</applyto>
152 + <owner>metacity</owner>
153 + <type>bool</type>
154 + <default>false</default>
155 + <locale name="C">
156 + <short>Automatically Maximize Windows</short>
157 + <long>
158 + Determines if windows should be automatically maximized when shown
159 + if they already cover most of the screen.
160 + </long>
161 + </locale>
162 + </schema>
164 + <schema>
165 <key>/schemas/apps/metacity/general/audible_bell</key>
166 <applyto>/apps/metacity/general/audible_bell</applyto>
167 <owner>metacity</owner>