Merge lp:~muktupavels/compiz/gwd-support-metacity-3-20 into lp:compiz/0.9.12
- gwd-support-metacity-3-20
- Merge into 0.9.12
Proposed by
Alberts Muktupāvels
Status: | Merged |
---|---|
Approved by: | Marco Trevisan (Treviño) |
Approved revision: | 4047 |
Merged at revision: | 4059 |
Proposed branch: | lp:~muktupavels/compiz/gwd-support-metacity-3-20 |
Merge into: | lp:compiz/0.9.12 |
Prerequisite: | lp:~muktupavels/compiz/gwd-improve-metacity |
Diff against target: |
587 lines (+198/-10) 6 files modified
gtk/CMakeLists.txt (+19/-4) gtk/config.h.gtk.in (+3/-0) gtk/window-decorator/gtk-window-decorator.c (+2/-0) gtk/window-decorator/gwd-settings-storage.c (+67/-2) gtk/window-decorator/gwd-theme-metacity.c (+107/-3) gtk/window-decorator/gwd-theme.c (+0/-1) |
To merge this branch: | bzr merge lp:~muktupavels/compiz/gwd-support-metacity-3-20 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Marco Trevisan (Treviño) | Approve | ||
Review via email: mp+296869@code.launchpad.net |
Commit message
gtk-window-
Description of the change
Support Metacity 3.20.
To post a comment you must log in.
- 4046. By Alberts Muktupāvels
-
If MetaThemeType is META_THEME_TYPE_GTK then use system GTK+ theme.
- 4047. By Alberts Muktupāvels
-
Fix build
Revision history for this message
Sam Spilsbury (smspillaz) : | # |
Revision history for this message
Alberts Muktupāvels (muktupavels) wrote : | # |
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'gtk/CMakeLists.txt' |
2 | --- gtk/CMakeLists.txt 2015-12-10 16:34:35 +0000 |
3 | +++ gtk/CMakeLists.txt 2016-06-09 20:28:29 +0000 |
4 | @@ -25,10 +25,25 @@ |
5 | set (CMAKE_REQUIRED_LIBRARIES "") |
6 | |
7 | if (USE_METACITY) |
8 | - pkg_check_modules (METACITY libmetacity-private>=3.16.0) |
9 | - if (NOT METACITY_FOUND) |
10 | - compiz_set (USE_METACITY 0) |
11 | - endif (NOT METACITY_FOUND) |
12 | + pkg_check_modules (LIBMETACITY libmetacity>=3.19.1) |
13 | + |
14 | + if (LIBMETACITY_FOUND) |
15 | + compiz_set (HAVE_METACITY_3_20_0 1) |
16 | + |
17 | + set (METACITY_INCLUDE_DIRS ${LIBMETACITY_INCLUDE_DIRS}) |
18 | + set (METACITY_LIBRARIES ${LIBMETACITY_LIBRARIES}) |
19 | + else (LIBMETACITY_FOUND) |
20 | + pkg_check_modules (LIBMETACITY_PRIVATE libmetacity-private>=3.16.0) |
21 | + |
22 | + if (LIBMETACITY_PRIVATE_FOUND) |
23 | + compiz_set (HAVE_METACITY_3_20_0 0) |
24 | + |
25 | + set (METACITY_INCLUDE_DIRS ${LIBMETACITY_PRIVATE_INCLUDE_DIRS}) |
26 | + set (METACITY_LIBRARIES ${LIBMETACITY_PRIVATE_LIBRARIES}) |
27 | + else (LIBMETACITY_PRIVATE_FOUND) |
28 | + compiz_set (USE_METACITY 0) |
29 | + endif (LIBMETACITY_PRIVATE_FOUND) |
30 | + endif (LIBMETACITY_FOUND) |
31 | endif (USE_METACITY) |
32 | |
33 | if (USE_GNOME) |
34 | |
35 | === modified file 'gtk/config.h.gtk.in' |
36 | --- gtk/config.h.gtk.in 2015-06-12 18:43:05 +0000 |
37 | +++ gtk/config.h.gtk.in 2016-06-09 20:28:29 +0000 |
38 | @@ -1,4 +1,7 @@ |
39 | /* Define to 1 if Metacity support is enabled */ |
40 | #cmakedefine USE_METACITY 1 |
41 | |
42 | +/* Define to 1 if Metacity version >= 3.20.0 */ |
43 | +#cmakedefine HAVE_METACITY_3_20_0 1 |
44 | + |
45 | #define GETTEXT_PACKAGE "${GETTEXT_PACKAGE}" |
46 | |
47 | === modified file 'gtk/window-decorator/gtk-window-decorator.c' |
48 | --- gtk/window-decorator/gtk-window-decorator.c 2016-06-09 20:28:29 +0000 |
49 | +++ gtk/window-decorator/gtk-window-decorator.c 2016-06-09 20:28:29 +0000 |
50 | @@ -152,6 +152,8 @@ |
51 | type = GWD_THEME_TYPE_METACITY; |
52 | |
53 | g_set_object (&gwd_theme, gwd_theme_new (type, settings)); |
54 | + |
55 | + gwd_theme_update_titlebar_font (gwd_theme); |
56 | } |
57 | |
58 | int |
59 | |
60 | === modified file 'gtk/window-decorator/gwd-settings-storage.c' |
61 | --- gtk/window-decorator/gwd-settings-storage.c 2016-06-09 20:28:29 +0000 |
62 | +++ gtk/window-decorator/gwd-settings-storage.c 2016-06-09 20:28:29 +0000 |
63 | @@ -24,12 +24,22 @@ |
64 | |
65 | #include <gtk/gtk.h> |
66 | |
67 | +#ifdef HAVE_METACITY_3_20_0 |
68 | +#include <libmetacity/meta-theme.h> |
69 | +#endif |
70 | + |
71 | #include "gwd-settings.h" |
72 | #include "gwd-settings-storage.h" |
73 | |
74 | static const gchar * ORG_COMPIZ_GWD = "org.compiz.gwd"; |
75 | static const gchar * ORG_GNOME_DESKTOP_WM_PREFERENCES = "org.gnome.desktop.wm.preferences"; |
76 | + |
77 | +#ifdef HAVE_METACITY_3_20_0 |
78 | +static const gchar * ORG_GNOME_METACITY_THEME = "org.gnome.metacity.theme"; |
79 | +#else |
80 | static const gchar * ORG_GNOME_METACITY = "org.gnome.metacity"; |
81 | +#endif |
82 | + |
83 | static const gchar * ORG_MATE_MARCO_GENERAL = "org.mate.Marco.general"; |
84 | |
85 | static const gchar * ORG_COMPIZ_GWD_KEY_USE_TOOLTIPS = "use-tooltips"; |
86 | @@ -41,7 +51,12 @@ |
87 | static const gchar * ORG_COMPIZ_GWD_KEY_USE_METACITY_THEME = "use-metacity-theme"; |
88 | static const gchar * ORG_COMPIZ_GWD_KEY_MOUSE_WHEEL_ACTION = "mouse-wheel-action"; |
89 | |
90 | +#ifdef HAVE_METACITY_3_20_0 |
91 | +static const gchar * ORG_GNOME_METACITY_THEME_NAME = "name"; |
92 | +static const gchar * ORG_GNOME_METACITY_THEME_TYPE = "type"; |
93 | +#else |
94 | static const gchar * ORG_GNOME_METACITY_THEME = "theme"; |
95 | +#endif |
96 | |
97 | static const gchar * ORG_GNOME_DESKTOP_WM_PREFERENCES_ACTION_DOUBLE_CLICK_TITLEBAR = "action-double-click-titlebar"; |
98 | static const gchar * ORG_GNOME_DESKTOP_WM_PREFERENCES_ACTION_MIDDLE_CLICK_TITLEBAR = "action-middle-click-titlebar"; |
99 | @@ -80,6 +95,7 @@ |
100 | GSettings *marco; |
101 | |
102 | gulong gtk_decoration_layout_id; |
103 | + gulong gtk_theme_name_id; |
104 | }; |
105 | |
106 | enum |
107 | @@ -197,7 +213,17 @@ |
108 | if (storage->current_desktop == GWD_DESKTOP_MATE && storage->marco) { |
109 | metacity_theme_name = g_settings_get_string (storage->marco, ORG_MATE_MARCO_GENERAL_THEME); |
110 | } else if (storage->current_desktop == GWD_DESKTOP_GNOME_FLASHBACK && storage->metacity) { |
111 | +#ifdef HAVE_METACITY_3_20_0 |
112 | + metacity_theme_type = g_settings_get_enum (storage->metacity, ORG_GNOME_METACITY_THEME_TYPE); |
113 | + |
114 | + if (metacity_theme_type == META_THEME_TYPE_GTK) { |
115 | + g_object_get (gtk_settings_get_default (), "gtk-theme-name", &metacity_theme_name, NULL); |
116 | + } else { |
117 | + metacity_theme_name = g_settings_get_string (storage->metacity, ORG_GNOME_METACITY_THEME_NAME); |
118 | + } |
119 | +#else |
120 | metacity_theme_name = g_settings_get_string (storage->metacity, ORG_GNOME_METACITY_THEME); |
121 | +#endif |
122 | } else if (storage->desktop) { |
123 | metacity_theme_name = g_settings_get_string (storage->desktop, ORG_GNOME_DESKTOP_WM_PREFERENCES_THEME); |
124 | } else { |
125 | @@ -359,8 +385,14 @@ |
126 | const gchar *key, |
127 | GWDSettingsStorage *storage) |
128 | { |
129 | +#ifdef HAVE_METACITY_3_20_0 |
130 | + if (strcmp (key, ORG_GNOME_METACITY_THEME_NAME) == 0 || |
131 | + strcmp (key, ORG_GNOME_METACITY_THEME_TYPE) == 0) |
132 | + update_metacity_theme (storage); |
133 | +#else |
134 | if (strcmp (key, ORG_GNOME_METACITY_THEME) == 0) |
135 | update_metacity_theme (storage); |
136 | +#endif |
137 | } |
138 | |
139 | static void |
140 | @@ -391,6 +423,24 @@ |
141 | update_button_layout (storage); |
142 | } |
143 | |
144 | +#ifdef HAVE_METACITY_3_20_0 |
145 | +static void |
146 | +gtk_theme_name_changed (GtkSettings *settings, |
147 | + GParamSpec *pspec, |
148 | + GWDSettingsStorage *storage) |
149 | +{ |
150 | + MetaThemeType type; |
151 | + |
152 | + if (!storage->metacity) |
153 | + return; |
154 | + |
155 | + type = g_settings_get_enum (storage->metacity, ORG_GNOME_METACITY_THEME_TYPE); |
156 | + |
157 | + if (type == META_THEME_TYPE_GTK) |
158 | + update_metacity_theme (storage); |
159 | +} |
160 | +#endif |
161 | + |
162 | static void |
163 | gwd_settings_storage_constructed (GObject *object) |
164 | { |
165 | @@ -435,6 +485,7 @@ |
166 | gwd_settings_storage_dispose (GObject *object) |
167 | { |
168 | GWDSettingsStorage *storage = GWD_SETTINGS_STORAGE (object); |
169 | + GtkSettings *settings = gtk_settings_get_default (); |
170 | |
171 | g_clear_object (&storage->settings); |
172 | |
173 | @@ -444,12 +495,15 @@ |
174 | g_clear_object (&storage->marco); |
175 | |
176 | if (storage->gtk_decoration_layout_id > 0) { |
177 | - GtkSettings *settings = gtk_settings_get_default (); |
178 | - |
179 | g_signal_handler_disconnect (settings, storage->gtk_decoration_layout_id); |
180 | storage->gtk_decoration_layout_id = 0; |
181 | } |
182 | |
183 | + if (storage->gtk_theme_name_id > 0) { |
184 | + g_signal_handler_disconnect (settings, storage->gtk_theme_name_id); |
185 | + storage->gtk_theme_name_id = 0; |
186 | + } |
187 | + |
188 | G_OBJECT_CLASS (gwd_settings_storage_parent_class)->dispose (object); |
189 | } |
190 | |
191 | @@ -519,11 +573,22 @@ |
192 | case GWD_DESKTOP_GNOME_FLASHBACK: |
193 | storage->gwd = get_settings_no_abort (ORG_COMPIZ_GWD); |
194 | storage->desktop = get_settings_no_abort (ORG_GNOME_DESKTOP_WM_PREFERENCES); |
195 | + |
196 | +#ifdef HAVE_METACITY_3_20_0 |
197 | + storage->metacity = get_settings_no_abort (ORG_GNOME_METACITY_THEME); |
198 | +#else |
199 | storage->metacity = get_settings_no_abort (ORG_GNOME_METACITY); |
200 | +#endif |
201 | |
202 | storage->gtk_decoration_layout_id = |
203 | g_signal_connect (gtk_settings_get_default (), "notify::gtk-decoration-layout", |
204 | G_CALLBACK (gtk_decoration_layout_changed), storage); |
205 | + |
206 | +#ifdef HAVE_METACITY_3_20_0 |
207 | + storage->gtk_theme_name_id = |
208 | + g_signal_connect (gtk_settings_get_default (), "notify::gtk-theme-name", |
209 | + G_CALLBACK (gtk_theme_name_changed), storage); |
210 | +#endif |
211 | break; |
212 | |
213 | case GWD_DESKTOP_MATE: |
214 | |
215 | === modified file 'gtk/window-decorator/gwd-theme-metacity.c' |
216 | --- gtk/window-decorator/gwd-theme-metacity.c 2016-06-09 20:28:29 +0000 |
217 | +++ gtk/window-decorator/gwd-theme-metacity.c 2016-06-09 20:28:29 +0000 |
218 | @@ -27,8 +27,12 @@ |
219 | |
220 | #include "config.h" |
221 | |
222 | +#ifdef HAVE_METACITY_3_20_0 |
223 | +#include <libmetacity/meta-theme.h> |
224 | +#else |
225 | #include <metacity-private/theme.h> |
226 | #include <metacity-private/theme-parser.h> |
227 | +#endif |
228 | |
229 | #include "gtk-window-decorator.h" |
230 | #include "gwd-settings.h" |
231 | @@ -40,16 +44,21 @@ |
232 | |
233 | MetaTheme *theme; |
234 | |
235 | +#ifndef HAVE_METACITY_3_20_0 |
236 | GHashTable *style_variants; |
237 | +#endif |
238 | |
239 | gulong button_layout_id; |
240 | MetaButtonLayout button_layout; |
241 | |
242 | +#ifndef HAVE_METACITY_3_20_0 |
243 | const PangoFontDescription *titlebar_font; |
244 | +#endif |
245 | }; |
246 | |
247 | G_DEFINE_TYPE (GWDThemeMetacity, gwd_theme_metacity, GWD_TYPE_THEME) |
248 | |
249 | +#ifndef HAVE_METACITY_3_20_0 |
250 | static MetaStyleInfo * |
251 | get_style_info (GWDThemeMetacity *metacity, |
252 | decor_t *decor) |
253 | @@ -70,6 +79,7 @@ |
254 | |
255 | return style; |
256 | } |
257 | +#endif |
258 | |
259 | static MetaFrameType |
260 | frame_type_from_string (const gchar *str) |
261 | @@ -86,6 +96,7 @@ |
262 | return META_FRAME_TYPE_NORMAL; |
263 | } |
264 | |
265 | +#ifndef HAVE_METACITY_3_20_0 |
266 | static void |
267 | initialize_button_layout (MetaButtonLayout *layout) |
268 | { |
269 | @@ -151,12 +162,18 @@ |
270 | return META_BUTTON_FUNCTION_LAST; |
271 | } |
272 | } |
273 | +#endif |
274 | |
275 | static void |
276 | update_metacity_button_layout_cb (GWDSettings *settings, |
277 | const gchar *button_layout, |
278 | GWDThemeMetacity *metacity) |
279 | { |
280 | +#ifdef HAVE_METACITY_3_20_0 |
281 | + gboolean invert = gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL; |
282 | + |
283 | + metacity->button_layout = meta_button_layout_new (button_layout, invert); |
284 | +#else |
285 | MetaButtonLayout new_layout; |
286 | |
287 | initialize_button_layout (&new_layout); |
288 | @@ -304,6 +321,7 @@ |
289 | } |
290 | |
291 | metacity->button_layout = new_layout; |
292 | +#endif |
293 | } |
294 | |
295 | static MetaButtonType |
296 | @@ -634,8 +652,13 @@ |
297 | MetaFrameBorders borders; |
298 | |
299 | tmp_flags = flags & ~META_FRAME_MAXIMIZED; |
300 | +#ifdef HAVE_METACITY_3_20_0 |
301 | + meta_theme_get_frame_borders (metacity->theme, d->gtk_theme_variant, |
302 | + type, tmp_flags, &borders); |
303 | +#else |
304 | meta_theme_get_frame_borders (metacity->theme, get_style_info (metacity, d), |
305 | type, d->frame->text_height, tmp_flags, &borders); |
306 | +#endif |
307 | |
308 | if (flags & META_FRAME_ALLOWS_HORIZONTAL_RESIZE) { |
309 | frame_win_extents.left += borders.invisible.left; |
310 | @@ -648,8 +671,13 @@ |
311 | } |
312 | |
313 | tmp_flags = flags | META_FRAME_MAXIMIZED; |
314 | +#ifdef HAVE_METACITY_3_20_0 |
315 | + meta_theme_get_frame_borders (metacity->theme, d->gtk_theme_variant, |
316 | + type, tmp_flags, &borders); |
317 | +#else |
318 | meta_theme_get_frame_borders (metacity->theme, get_style_info (metacity, d), |
319 | type, d->frame->text_height, tmp_flags, &borders); |
320 | +#endif |
321 | |
322 | if (flags & META_FRAME_ALLOWS_HORIZONTAL_RESIZE) { |
323 | frame_max_win_extents.left += borders.invisible.left; |
324 | @@ -779,9 +807,15 @@ |
325 | else |
326 | client_height = decor->border_layout.left.y2 - decor->border_layout.left.y1; |
327 | |
328 | +#ifdef HAVE_METACITY_3_20_0 |
329 | + meta_theme_calc_geometry (metacity->theme, decor->gtk_theme_variant, |
330 | + frame_type, *flags, client_width, client_height, |
331 | + &metacity->button_layout, fgeom); |
332 | +#else |
333 | meta_theme_calc_geometry (metacity->theme, get_style_info (metacity, decor), |
334 | frame_type, decor->frame->text_height, *flags, client_width, |
335 | client_height, &metacity->button_layout, fgeom); |
336 | +#endif |
337 | } |
338 | |
339 | static void |
340 | @@ -834,11 +868,11 @@ |
341 | { |
342 | int i; |
343 | |
344 | - for (i = 0; i < MAX_BUTTONS_PER_CORNER; ++i) |
345 | + for (i = 0; i < META_BUTTON_FUNCTION_LAST; ++i) |
346 | if (metacity->button_layout.left_buttons[i] == function) |
347 | return TRUE; |
348 | |
349 | - for (i = 0; i < MAX_BUTTONS_PER_CORNER; ++i) |
350 | + for (i = 0; i < META_BUTTON_FUNCTION_LAST; ++i) |
351 | if (metacity->button_layout.right_buttons[i] == function) |
352 | return TRUE; |
353 | |
354 | @@ -881,7 +915,12 @@ |
355 | { |
356 | GWDSettings *settings = gwd_theme_get_settings (GWD_THEME (metacity)); |
357 | const gchar *metacity_theme_name = gwd_settings_get_metacity_theme_name (settings); |
358 | +#ifdef HAVE_METACITY_3_20_0 |
359 | + gint metacity_theme_type = gwd_settings_get_metacity_theme_type (settings); |
360 | + GError *error = NULL; |
361 | +#else |
362 | MetaTheme *theme; |
363 | +#endif |
364 | |
365 | /* metacity_theme can be NULL only in one case - if user has disabled |
366 | * metacity theme with use-metacity-theme setting. In that case |
367 | @@ -889,6 +928,23 @@ |
368 | */ |
369 | g_assert (metacity_theme_name != NULL); |
370 | |
371 | +#ifdef HAVE_METACITY_3_20_0 |
372 | + if (metacity_theme_type == -1) |
373 | + metacity_theme_type = META_THEME_TYPE_METACITY; |
374 | + |
375 | + metacity->theme = meta_theme_new (metacity_theme_type); |
376 | + |
377 | + if (!meta_theme_load (metacity->theme, metacity_theme_name, &error)) { |
378 | + g_warning ("Failed to load metacity theme '%s': %s", |
379 | + metacity_theme_name, error->message); |
380 | + |
381 | + g_error_free (error); |
382 | + g_clear_object (&metacity->theme); |
383 | + |
384 | + return FALSE; |
385 | + } |
386 | +#else |
387 | + |
388 | /* meta_theme_get_current returns the last good theme, so we will try to |
389 | * load theme manually to know that theme is 100% valid. |
390 | */ |
391 | @@ -905,6 +961,7 @@ |
392 | /* If we are here then we know that this will not fail. */ |
393 | meta_theme_set_current (metacity_theme_name, TRUE); |
394 | metacity->theme = meta_theme_get_current (); |
395 | +#endif |
396 | |
397 | return TRUE; |
398 | } |
399 | @@ -940,7 +997,11 @@ |
400 | { |
401 | GWDThemeMetacity *metacity = GWD_THEME_METACITY (object); |
402 | |
403 | +#ifdef HAVE_METACITY_3_20_0 |
404 | + g_clear_object (&metacity->theme); |
405 | +#else |
406 | g_clear_pointer (&metacity->style_variants, g_hash_table_destroy); |
407 | +#endif |
408 | |
409 | if (metacity->button_layout_id != 0) { |
410 | GWDSettings *settings = gwd_theme_get_settings (GWD_THEME (metacity)); |
411 | @@ -949,7 +1010,9 @@ |
412 | metacity->button_layout_id = 0; |
413 | } |
414 | |
415 | +#ifndef HAVE_METACITY_3_20_0 |
416 | metacity->titlebar_font = NULL; |
417 | +#endif |
418 | |
419 | G_OBJECT_CLASS (gwd_theme_metacity_parent_class)->dispose (object); |
420 | } |
421 | @@ -959,7 +1022,11 @@ |
422 | { |
423 | GWDThemeMetacity *metacity = GWD_THEME_METACITY (theme); |
424 | |
425 | +#ifdef HAVE_METACITY_3_20_0 |
426 | + meta_theme_invalidate (metacity->theme); |
427 | +#else |
428 | g_hash_table_remove_all (metacity->style_variants); |
429 | +#endif |
430 | } |
431 | |
432 | static void |
433 | @@ -971,8 +1038,10 @@ |
434 | GdkDisplay *display = gdk_display_get_default (); |
435 | Display *xdisplay = gdk_x11_display_get_xdisplay (display); |
436 | GtkWidget *style_window = gwd_theme_get_style_window (theme); |
437 | +#ifndef HAVE_METACITY_3_20_0 |
438 | MetaStyleInfo *style_info = get_style_info (metacity, decor); |
439 | GtkStyleContext *context = gtk_widget_get_style_context (style_window); |
440 | +#endif |
441 | cairo_surface_t *surface; |
442 | Picture src; |
443 | MetaButtonState button_states [META_BUTTON_TYPE_LAST]; |
444 | @@ -987,8 +1056,10 @@ |
445 | Region right_region; |
446 | double alpha; |
447 | gboolean shade_alpha; |
448 | +#ifndef HAVE_METACITY_3_20_0 |
449 | MetaFrameStyle *frame_style; |
450 | GdkRGBA bg_rgba; |
451 | +#endif |
452 | |
453 | if (!decor->surface || !decor->picture) |
454 | return; |
455 | @@ -1023,6 +1094,7 @@ |
456 | for (i = 0; i < META_BUTTON_TYPE_LAST; ++i) |
457 | button_states[i] = meta_button_state_for_button_type (metacity, decor, i); |
458 | |
459 | +#ifndef HAVE_METACITY_3_20_0 |
460 | frame_style = meta_theme_get_frame_style (metacity->theme, frame_type, flags); |
461 | |
462 | gtk_style_context_get_background_color (context, GTK_STATE_FLAG_NORMAL, &bg_rgba); |
463 | @@ -1034,6 +1106,7 @@ |
464 | |
465 | bg_rgba.alpha = frame_style->window_background_alpha / 255.0; |
466 | } |
467 | +#endif |
468 | |
469 | /* Draw something that will be almost invisible to user. This is hacky way |
470 | * to fix invisible decorations. */ |
471 | @@ -1048,19 +1121,28 @@ |
472 | |
473 | cr = cairo_create (surface); |
474 | |
475 | +#ifndef HAVE_METACITY_3_20_0 |
476 | gdk_cairo_set_source_rgba (cr, &bg_rgba); |
477 | cairo_set_operator (cr, CAIRO_OPERATOR_OVER); |
478 | cairo_paint (cr); |
479 | +#endif |
480 | |
481 | src = XRenderCreatePicture (xdisplay, cairo_xlib_surface_get_drawable (surface), |
482 | xformat_rgba, 0, NULL); |
483 | |
484 | +#ifdef HAVE_METACITY_3_20_0 |
485 | + meta_theme_draw_frame (metacity->theme, decor->gtk_theme_variant, cr, frame_type, flags, |
486 | + fgeom.width - fgeom.borders.total.left - fgeom.borders.total.right, |
487 | + fgeom.height - fgeom.borders.total.top - fgeom.borders.total.bottom, |
488 | + decor->name, &metacity->button_layout, |
489 | + button_states, decor->icon_pixbuf, NULL); |
490 | +#else |
491 | meta_theme_draw_frame (metacity->theme, style_info, cr, frame_type, flags, |
492 | fgeom.width - fgeom.borders.total.left - fgeom.borders.total.right, |
493 | fgeom.height - fgeom.borders.total.top - fgeom.borders.total.bottom, |
494 | decor->layout, decor->frame->text_height, &metacity->button_layout, |
495 | button_states, decor->icon_pixbuf, NULL); |
496 | - |
497 | +#endif |
498 | |
499 | if (fgeom.borders.visible.top) { |
500 | top_region = get_top_border_region (&fgeom, fgeom.width); |
501 | @@ -1196,23 +1278,35 @@ |
502 | decor_frame_t *frame) |
503 | { |
504 | GWDThemeMetacity *metacity = GWD_THEME_METACITY (theme); |
505 | +#ifndef HAVE_METACITY_3_20_0 |
506 | MetaStyleInfo *style_info = get_style_info (metacity, NULL); |
507 | +#endif |
508 | MetaFrameType frame_type = frame_type_from_string (frame->type); |
509 | MetaFrameBorders borders; |
510 | |
511 | gwd_decor_frame_ref (frame); |
512 | |
513 | +#ifdef HAVE_METACITY_3_20_0 |
514 | + meta_theme_get_frame_borders (metacity->theme, NULL, frame_type, |
515 | + 0, &borders); |
516 | +#else |
517 | meta_theme_get_frame_borders (metacity->theme, style_info, frame_type, |
518 | frame->text_height, 0, &borders); |
519 | +#endif |
520 | |
521 | frame->win_extents.top = borders.visible.top; |
522 | frame->win_extents.bottom = borders.visible.bottom; |
523 | frame->win_extents.left = borders.visible.left; |
524 | frame->win_extents.right = borders.visible.right; |
525 | |
526 | +#ifdef HAVE_METACITY_3_20_0 |
527 | + meta_theme_get_frame_borders (metacity->theme, NULL, frame_type, |
528 | + META_FRAME_MAXIMIZED, &borders); |
529 | +#else |
530 | meta_theme_get_frame_borders (metacity->theme, style_info, frame_type, |
531 | frame->text_height, META_FRAME_MAXIMIZED, |
532 | &borders); |
533 | +#endif |
534 | |
535 | frame->max_win_extents.top = borders.visible.top; |
536 | frame->max_win_extents.bottom = borders.visible.bottom; |
537 | @@ -1427,13 +1521,20 @@ |
538 | { |
539 | GWDThemeMetacity *metacity = GWD_THEME_METACITY (theme); |
540 | |
541 | +#ifdef HAVE_METACITY_3_20_0 |
542 | + meta_theme_set_titlebar_font (metacity->theme, titlebar_font); |
543 | +#else |
544 | metacity->titlebar_font = titlebar_font; |
545 | +#endif |
546 | } |
547 | |
548 | static PangoFontDescription * |
549 | gwd_theme_metacity_get_titlebar_font (GWDTheme *theme, |
550 | decor_frame_t *frame) |
551 | { |
552 | +#ifdef HAVE_METACITY_3_20_0 |
553 | + return NULL; |
554 | +#else |
555 | GWDThemeMetacity *metacity = GWD_THEME_METACITY (theme); |
556 | MetaStyleInfo *style_info = get_style_info (metacity, NULL); |
557 | PangoFontDescription *font_desc = meta_style_info_create_font_desc (style_info); |
558 | @@ -1445,6 +1546,7 @@ |
559 | meta_frame_style_apply_scale (style, font_desc); |
560 | |
561 | return font_desc; |
562 | +#endif |
563 | } |
564 | |
565 | static void |
566 | @@ -1469,8 +1571,10 @@ |
567 | static void |
568 | gwd_theme_metacity_init (GWDThemeMetacity *metacity) |
569 | { |
570 | +#ifndef HAVE_METACITY_3_20_0 |
571 | metacity->style_variants = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, |
572 | (GDestroyNotify) meta_style_info_unref); |
573 | +#endif |
574 | } |
575 | |
576 | /** |
577 | |
578 | === modified file 'gtk/window-decorator/gwd-theme.c' |
579 | --- gtk/window-decorator/gwd-theme.c 2016-06-09 20:28:29 +0000 |
580 | +++ gtk/window-decorator/gwd-theme.c 2016-06-09 20:28:29 +0000 |
581 | @@ -109,7 +109,6 @@ |
582 | |
583 | G_OBJECT_CLASS (gwd_theme_parent_class)->constructed (object); |
584 | |
585 | - gwd_theme_update_titlebar_font (theme); |
586 | create_style_window (theme); |
587 | } |
588 |
"These members aren't strictly dependent on having megacity 3.20 around, so the ifdefs are probably not necessary here."
style_variants and titlebar_font is not used with Metacity 3.20. So there is no need to create and later destroy hash table. Also ifdefs was added to make sure that I don't try to use them with 3.20.