Merge lp:~muktupavels/compiz/gwd-support-metacity-3-20 into lp:compiz/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
Reviewer Review Type Date Requested Status
Marco Trevisan (Treviño) Approve
Review via email: mp+296869@code.launchpad.net

Commit message

gtk-window-decorator: support Metacity 3.20.

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 :

"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.

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
=== modified file 'gtk/CMakeLists.txt'
--- gtk/CMakeLists.txt 2015-12-10 16:34:35 +0000
+++ gtk/CMakeLists.txt 2016-06-09 20:28:29 +0000
@@ -25,10 +25,25 @@
25 set (CMAKE_REQUIRED_LIBRARIES "")25 set (CMAKE_REQUIRED_LIBRARIES "")
2626
27 if (USE_METACITY)27 if (USE_METACITY)
28 pkg_check_modules (METACITY libmetacity-private>=3.16.0)28 pkg_check_modules (LIBMETACITY libmetacity>=3.19.1)
29 if (NOT METACITY_FOUND)29
30 compiz_set (USE_METACITY 0)30 if (LIBMETACITY_FOUND)
31 endif (NOT METACITY_FOUND)31 compiz_set (HAVE_METACITY_3_20_0 1)
32
33 set (METACITY_INCLUDE_DIRS ${LIBMETACITY_INCLUDE_DIRS})
34 set (METACITY_LIBRARIES ${LIBMETACITY_LIBRARIES})
35 else (LIBMETACITY_FOUND)
36 pkg_check_modules (LIBMETACITY_PRIVATE libmetacity-private>=3.16.0)
37
38 if (LIBMETACITY_PRIVATE_FOUND)
39 compiz_set (HAVE_METACITY_3_20_0 0)
40
41 set (METACITY_INCLUDE_DIRS ${LIBMETACITY_PRIVATE_INCLUDE_DIRS})
42 set (METACITY_LIBRARIES ${LIBMETACITY_PRIVATE_LIBRARIES})
43 else (LIBMETACITY_PRIVATE_FOUND)
44 compiz_set (USE_METACITY 0)
45 endif (LIBMETACITY_PRIVATE_FOUND)
46 endif (LIBMETACITY_FOUND)
32 endif (USE_METACITY)47 endif (USE_METACITY)
3348
34 if (USE_GNOME)49 if (USE_GNOME)
3550
=== modified file 'gtk/config.h.gtk.in'
--- gtk/config.h.gtk.in 2015-06-12 18:43:05 +0000
+++ gtk/config.h.gtk.in 2016-06-09 20:28:29 +0000
@@ -1,4 +1,7 @@
1/* Define to 1 if Metacity support is enabled */1/* Define to 1 if Metacity support is enabled */
2#cmakedefine USE_METACITY 12#cmakedefine USE_METACITY 1
33
4/* Define to 1 if Metacity version >= 3.20.0 */
5#cmakedefine HAVE_METACITY_3_20_0 1
6
4#define GETTEXT_PACKAGE "${GETTEXT_PACKAGE}"7#define GETTEXT_PACKAGE "${GETTEXT_PACKAGE}"
58
=== modified file 'gtk/window-decorator/gtk-window-decorator.c'
--- gtk/window-decorator/gtk-window-decorator.c 2016-06-09 20:28:29 +0000
+++ gtk/window-decorator/gtk-window-decorator.c 2016-06-09 20:28:29 +0000
@@ -152,6 +152,8 @@
152 type = GWD_THEME_TYPE_METACITY;152 type = GWD_THEME_TYPE_METACITY;
153153
154 g_set_object (&gwd_theme, gwd_theme_new (type, settings));154 g_set_object (&gwd_theme, gwd_theme_new (type, settings));
155
156 gwd_theme_update_titlebar_font (gwd_theme);
155}157}
156158
157int159int
158160
=== modified file 'gtk/window-decorator/gwd-settings-storage.c'
--- gtk/window-decorator/gwd-settings-storage.c 2016-06-09 20:28:29 +0000
+++ gtk/window-decorator/gwd-settings-storage.c 2016-06-09 20:28:29 +0000
@@ -24,12 +24,22 @@
2424
25#include <gtk/gtk.h>25#include <gtk/gtk.h>
2626
27#ifdef HAVE_METACITY_3_20_0
28#include <libmetacity/meta-theme.h>
29#endif
30
27#include "gwd-settings.h"31#include "gwd-settings.h"
28#include "gwd-settings-storage.h"32#include "gwd-settings-storage.h"
2933
30static const gchar * ORG_COMPIZ_GWD = "org.compiz.gwd";34static const gchar * ORG_COMPIZ_GWD = "org.compiz.gwd";
31static const gchar * ORG_GNOME_DESKTOP_WM_PREFERENCES = "org.gnome.desktop.wm.preferences";35static const gchar * ORG_GNOME_DESKTOP_WM_PREFERENCES = "org.gnome.desktop.wm.preferences";
36
37#ifdef HAVE_METACITY_3_20_0
38static const gchar * ORG_GNOME_METACITY_THEME = "org.gnome.metacity.theme";
39#else
32static const gchar * ORG_GNOME_METACITY = "org.gnome.metacity";40static const gchar * ORG_GNOME_METACITY = "org.gnome.metacity";
41#endif
42
33static const gchar * ORG_MATE_MARCO_GENERAL = "org.mate.Marco.general";43static const gchar * ORG_MATE_MARCO_GENERAL = "org.mate.Marco.general";
3444
35static const gchar * ORG_COMPIZ_GWD_KEY_USE_TOOLTIPS = "use-tooltips";45static const gchar * ORG_COMPIZ_GWD_KEY_USE_TOOLTIPS = "use-tooltips";
@@ -41,7 +51,12 @@
41static const gchar * ORG_COMPIZ_GWD_KEY_USE_METACITY_THEME = "use-metacity-theme";51static const gchar * ORG_COMPIZ_GWD_KEY_USE_METACITY_THEME = "use-metacity-theme";
42static const gchar * ORG_COMPIZ_GWD_KEY_MOUSE_WHEEL_ACTION = "mouse-wheel-action";52static const gchar * ORG_COMPIZ_GWD_KEY_MOUSE_WHEEL_ACTION = "mouse-wheel-action";
4353
54#ifdef HAVE_METACITY_3_20_0
55static const gchar * ORG_GNOME_METACITY_THEME_NAME = "name";
56static const gchar * ORG_GNOME_METACITY_THEME_TYPE = "type";
57#else
44static const gchar * ORG_GNOME_METACITY_THEME = "theme";58static const gchar * ORG_GNOME_METACITY_THEME = "theme";
59#endif
4560
46static const gchar * ORG_GNOME_DESKTOP_WM_PREFERENCES_ACTION_DOUBLE_CLICK_TITLEBAR = "action-double-click-titlebar";61static const gchar * ORG_GNOME_DESKTOP_WM_PREFERENCES_ACTION_DOUBLE_CLICK_TITLEBAR = "action-double-click-titlebar";
47static const gchar * ORG_GNOME_DESKTOP_WM_PREFERENCES_ACTION_MIDDLE_CLICK_TITLEBAR = "action-middle-click-titlebar";62static const gchar * ORG_GNOME_DESKTOP_WM_PREFERENCES_ACTION_MIDDLE_CLICK_TITLEBAR = "action-middle-click-titlebar";
@@ -80,6 +95,7 @@
80 GSettings *marco;95 GSettings *marco;
8196
82 gulong gtk_decoration_layout_id;97 gulong gtk_decoration_layout_id;
98 gulong gtk_theme_name_id;
83};99};
84100
85enum101enum
@@ -197,7 +213,17 @@
197 if (storage->current_desktop == GWD_DESKTOP_MATE && storage->marco) {213 if (storage->current_desktop == GWD_DESKTOP_MATE && storage->marco) {
198 metacity_theme_name = g_settings_get_string (storage->marco, ORG_MATE_MARCO_GENERAL_THEME);214 metacity_theme_name = g_settings_get_string (storage->marco, ORG_MATE_MARCO_GENERAL_THEME);
199 } else if (storage->current_desktop == GWD_DESKTOP_GNOME_FLASHBACK && storage->metacity) {215 } else if (storage->current_desktop == GWD_DESKTOP_GNOME_FLASHBACK && storage->metacity) {
216#ifdef HAVE_METACITY_3_20_0
217 metacity_theme_type = g_settings_get_enum (storage->metacity, ORG_GNOME_METACITY_THEME_TYPE);
218
219 if (metacity_theme_type == META_THEME_TYPE_GTK) {
220 g_object_get (gtk_settings_get_default (), "gtk-theme-name", &metacity_theme_name, NULL);
221 } else {
222 metacity_theme_name = g_settings_get_string (storage->metacity, ORG_GNOME_METACITY_THEME_NAME);
223 }
224#else
200 metacity_theme_name = g_settings_get_string (storage->metacity, ORG_GNOME_METACITY_THEME);225 metacity_theme_name = g_settings_get_string (storage->metacity, ORG_GNOME_METACITY_THEME);
226#endif
201 } else if (storage->desktop) {227 } else if (storage->desktop) {
202 metacity_theme_name = g_settings_get_string (storage->desktop, ORG_GNOME_DESKTOP_WM_PREFERENCES_THEME);228 metacity_theme_name = g_settings_get_string (storage->desktop, ORG_GNOME_DESKTOP_WM_PREFERENCES_THEME);
203 } else {229 } else {
@@ -359,8 +385,14 @@
359 const gchar *key,385 const gchar *key,
360 GWDSettingsStorage *storage)386 GWDSettingsStorage *storage)
361{387{
388#ifdef HAVE_METACITY_3_20_0
389 if (strcmp (key, ORG_GNOME_METACITY_THEME_NAME) == 0 ||
390 strcmp (key, ORG_GNOME_METACITY_THEME_TYPE) == 0)
391 update_metacity_theme (storage);
392#else
362 if (strcmp (key, ORG_GNOME_METACITY_THEME) == 0)393 if (strcmp (key, ORG_GNOME_METACITY_THEME) == 0)
363 update_metacity_theme (storage);394 update_metacity_theme (storage);
395#endif
364}396}
365397
366static void398static void
@@ -391,6 +423,24 @@
391 update_button_layout (storage);423 update_button_layout (storage);
392}424}
393425
426#ifdef HAVE_METACITY_3_20_0
427static void
428gtk_theme_name_changed (GtkSettings *settings,
429 GParamSpec *pspec,
430 GWDSettingsStorage *storage)
431{
432 MetaThemeType type;
433
434 if (!storage->metacity)
435 return;
436
437 type = g_settings_get_enum (storage->metacity, ORG_GNOME_METACITY_THEME_TYPE);
438
439 if (type == META_THEME_TYPE_GTK)
440 update_metacity_theme (storage);
441}
442#endif
443
394static void444static void
395gwd_settings_storage_constructed (GObject *object)445gwd_settings_storage_constructed (GObject *object)
396{446{
@@ -435,6 +485,7 @@
435gwd_settings_storage_dispose (GObject *object)485gwd_settings_storage_dispose (GObject *object)
436{486{
437 GWDSettingsStorage *storage = GWD_SETTINGS_STORAGE (object);487 GWDSettingsStorage *storage = GWD_SETTINGS_STORAGE (object);
488 GtkSettings *settings = gtk_settings_get_default ();
438489
439 g_clear_object (&storage->settings);490 g_clear_object (&storage->settings);
440491
@@ -444,12 +495,15 @@
444 g_clear_object (&storage->marco);495 g_clear_object (&storage->marco);
445496
446 if (storage->gtk_decoration_layout_id > 0) {497 if (storage->gtk_decoration_layout_id > 0) {
447 GtkSettings *settings = gtk_settings_get_default ();
448
449 g_signal_handler_disconnect (settings, storage->gtk_decoration_layout_id);498 g_signal_handler_disconnect (settings, storage->gtk_decoration_layout_id);
450 storage->gtk_decoration_layout_id = 0;499 storage->gtk_decoration_layout_id = 0;
451 }500 }
452501
502 if (storage->gtk_theme_name_id > 0) {
503 g_signal_handler_disconnect (settings, storage->gtk_theme_name_id);
504 storage->gtk_theme_name_id = 0;
505 }
506
453 G_OBJECT_CLASS (gwd_settings_storage_parent_class)->dispose (object);507 G_OBJECT_CLASS (gwd_settings_storage_parent_class)->dispose (object);
454}508}
455509
@@ -519,11 +573,22 @@
519 case GWD_DESKTOP_GNOME_FLASHBACK:573 case GWD_DESKTOP_GNOME_FLASHBACK:
520 storage->gwd = get_settings_no_abort (ORG_COMPIZ_GWD);574 storage->gwd = get_settings_no_abort (ORG_COMPIZ_GWD);
521 storage->desktop = get_settings_no_abort (ORG_GNOME_DESKTOP_WM_PREFERENCES);575 storage->desktop = get_settings_no_abort (ORG_GNOME_DESKTOP_WM_PREFERENCES);
576
577#ifdef HAVE_METACITY_3_20_0
578 storage->metacity = get_settings_no_abort (ORG_GNOME_METACITY_THEME);
579#else
522 storage->metacity = get_settings_no_abort (ORG_GNOME_METACITY);580 storage->metacity = get_settings_no_abort (ORG_GNOME_METACITY);
581#endif
523582
524 storage->gtk_decoration_layout_id =583 storage->gtk_decoration_layout_id =
525 g_signal_connect (gtk_settings_get_default (), "notify::gtk-decoration-layout",584 g_signal_connect (gtk_settings_get_default (), "notify::gtk-decoration-layout",
526 G_CALLBACK (gtk_decoration_layout_changed), storage);585 G_CALLBACK (gtk_decoration_layout_changed), storage);
586
587#ifdef HAVE_METACITY_3_20_0
588 storage->gtk_theme_name_id =
589 g_signal_connect (gtk_settings_get_default (), "notify::gtk-theme-name",
590 G_CALLBACK (gtk_theme_name_changed), storage);
591#endif
527 break;592 break;
528593
529 case GWD_DESKTOP_MATE:594 case GWD_DESKTOP_MATE:
530595
=== modified file 'gtk/window-decorator/gwd-theme-metacity.c'
--- gtk/window-decorator/gwd-theme-metacity.c 2016-06-09 20:28:29 +0000
+++ gtk/window-decorator/gwd-theme-metacity.c 2016-06-09 20:28:29 +0000
@@ -27,8 +27,12 @@
2727
28#include "config.h"28#include "config.h"
2929
30#ifdef HAVE_METACITY_3_20_0
31#include <libmetacity/meta-theme.h>
32#else
30#include <metacity-private/theme.h>33#include <metacity-private/theme.h>
31#include <metacity-private/theme-parser.h>34#include <metacity-private/theme-parser.h>
35#endif
3236
33#include "gtk-window-decorator.h"37#include "gtk-window-decorator.h"
34#include "gwd-settings.h"38#include "gwd-settings.h"
@@ -40,16 +44,21 @@
4044
41 MetaTheme *theme;45 MetaTheme *theme;
4246
47#ifndef HAVE_METACITY_3_20_0
43 GHashTable *style_variants;48 GHashTable *style_variants;
49#endif
4450
45 gulong button_layout_id;51 gulong button_layout_id;
46 MetaButtonLayout button_layout;52 MetaButtonLayout button_layout;
4753
54#ifndef HAVE_METACITY_3_20_0
48 const PangoFontDescription *titlebar_font;55 const PangoFontDescription *titlebar_font;
56#endif
49};57};
5058
51G_DEFINE_TYPE (GWDThemeMetacity, gwd_theme_metacity, GWD_TYPE_THEME)59G_DEFINE_TYPE (GWDThemeMetacity, gwd_theme_metacity, GWD_TYPE_THEME)
5260
61#ifndef HAVE_METACITY_3_20_0
53static MetaStyleInfo *62static MetaStyleInfo *
54get_style_info (GWDThemeMetacity *metacity,63get_style_info (GWDThemeMetacity *metacity,
55 decor_t *decor)64 decor_t *decor)
@@ -70,6 +79,7 @@
7079
71 return style;80 return style;
72}81}
82#endif
7383
74static MetaFrameType84static MetaFrameType
75frame_type_from_string (const gchar *str)85frame_type_from_string (const gchar *str)
@@ -86,6 +96,7 @@
86 return META_FRAME_TYPE_NORMAL;96 return META_FRAME_TYPE_NORMAL;
87}97}
8898
99#ifndef HAVE_METACITY_3_20_0
89static void100static void
90initialize_button_layout (MetaButtonLayout *layout)101initialize_button_layout (MetaButtonLayout *layout)
91{102{
@@ -151,12 +162,18 @@
151 return META_BUTTON_FUNCTION_LAST;162 return META_BUTTON_FUNCTION_LAST;
152 }163 }
153}164}
165#endif
154166
155static void167static void
156update_metacity_button_layout_cb (GWDSettings *settings,168update_metacity_button_layout_cb (GWDSettings *settings,
157 const gchar *button_layout,169 const gchar *button_layout,
158 GWDThemeMetacity *metacity)170 GWDThemeMetacity *metacity)
159{171{
172#ifdef HAVE_METACITY_3_20_0
173 gboolean invert = gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL;
174
175 metacity->button_layout = meta_button_layout_new (button_layout, invert);
176#else
160 MetaButtonLayout new_layout;177 MetaButtonLayout new_layout;
161178
162 initialize_button_layout (&new_layout);179 initialize_button_layout (&new_layout);
@@ -304,6 +321,7 @@
304 }321 }
305322
306 metacity->button_layout = new_layout;323 metacity->button_layout = new_layout;
324#endif
307}325}
308326
309static MetaButtonType327static MetaButtonType
@@ -634,8 +652,13 @@
634 MetaFrameBorders borders;652 MetaFrameBorders borders;
635653
636 tmp_flags = flags & ~META_FRAME_MAXIMIZED;654 tmp_flags = flags & ~META_FRAME_MAXIMIZED;
655#ifdef HAVE_METACITY_3_20_0
656 meta_theme_get_frame_borders (metacity->theme, d->gtk_theme_variant,
657 type, tmp_flags, &borders);
658#else
637 meta_theme_get_frame_borders (metacity->theme, get_style_info (metacity, d),659 meta_theme_get_frame_borders (metacity->theme, get_style_info (metacity, d),
638 type, d->frame->text_height, tmp_flags, &borders);660 type, d->frame->text_height, tmp_flags, &borders);
661#endif
639662
640 if (flags & META_FRAME_ALLOWS_HORIZONTAL_RESIZE) {663 if (flags & META_FRAME_ALLOWS_HORIZONTAL_RESIZE) {
641 frame_win_extents.left += borders.invisible.left;664 frame_win_extents.left += borders.invisible.left;
@@ -648,8 +671,13 @@
648 }671 }
649672
650 tmp_flags = flags | META_FRAME_MAXIMIZED;673 tmp_flags = flags | META_FRAME_MAXIMIZED;
674#ifdef HAVE_METACITY_3_20_0
675 meta_theme_get_frame_borders (metacity->theme, d->gtk_theme_variant,
676 type, tmp_flags, &borders);
677#else
651 meta_theme_get_frame_borders (metacity->theme, get_style_info (metacity, d),678 meta_theme_get_frame_borders (metacity->theme, get_style_info (metacity, d),
652 type, d->frame->text_height, tmp_flags, &borders);679 type, d->frame->text_height, tmp_flags, &borders);
680#endif
653681
654 if (flags & META_FRAME_ALLOWS_HORIZONTAL_RESIZE) {682 if (flags & META_FRAME_ALLOWS_HORIZONTAL_RESIZE) {
655 frame_max_win_extents.left += borders.invisible.left;683 frame_max_win_extents.left += borders.invisible.left;
@@ -779,9 +807,15 @@
779 else807 else
780 client_height = decor->border_layout.left.y2 - decor->border_layout.left.y1;808 client_height = decor->border_layout.left.y2 - decor->border_layout.left.y1;
781809
810#ifdef HAVE_METACITY_3_20_0
811 meta_theme_calc_geometry (metacity->theme, decor->gtk_theme_variant,
812 frame_type, *flags, client_width, client_height,
813 &metacity->button_layout, fgeom);
814#else
782 meta_theme_calc_geometry (metacity->theme, get_style_info (metacity, decor),815 meta_theme_calc_geometry (metacity->theme, get_style_info (metacity, decor),
783 frame_type, decor->frame->text_height, *flags, client_width,816 frame_type, decor->frame->text_height, *flags, client_width,
784 client_height, &metacity->button_layout, fgeom);817 client_height, &metacity->button_layout, fgeom);
818#endif
785}819}
786820
787static void821static void
@@ -834,11 +868,11 @@
834{868{
835 int i;869 int i;
836870
837 for (i = 0; i < MAX_BUTTONS_PER_CORNER; ++i)871 for (i = 0; i < META_BUTTON_FUNCTION_LAST; ++i)
838 if (metacity->button_layout.left_buttons[i] == function)872 if (metacity->button_layout.left_buttons[i] == function)
839 return TRUE;873 return TRUE;
840874
841 for (i = 0; i < MAX_BUTTONS_PER_CORNER; ++i)875 for (i = 0; i < META_BUTTON_FUNCTION_LAST; ++i)
842 if (metacity->button_layout.right_buttons[i] == function)876 if (metacity->button_layout.right_buttons[i] == function)
843 return TRUE;877 return TRUE;
844878
@@ -881,7 +915,12 @@
881{915{
882 GWDSettings *settings = gwd_theme_get_settings (GWD_THEME (metacity));916 GWDSettings *settings = gwd_theme_get_settings (GWD_THEME (metacity));
883 const gchar *metacity_theme_name = gwd_settings_get_metacity_theme_name (settings);917 const gchar *metacity_theme_name = gwd_settings_get_metacity_theme_name (settings);
918#ifdef HAVE_METACITY_3_20_0
919 gint metacity_theme_type = gwd_settings_get_metacity_theme_type (settings);
920 GError *error = NULL;
921#else
884 MetaTheme *theme;922 MetaTheme *theme;
923#endif
885924
886 /* metacity_theme can be NULL only in one case - if user has disabled925 /* metacity_theme can be NULL only in one case - if user has disabled
887 * metacity theme with use-metacity-theme setting. In that case926 * metacity theme with use-metacity-theme setting. In that case
@@ -889,6 +928,23 @@
889 */928 */
890 g_assert (metacity_theme_name != NULL);929 g_assert (metacity_theme_name != NULL);
891930
931#ifdef HAVE_METACITY_3_20_0
932 if (metacity_theme_type == -1)
933 metacity_theme_type = META_THEME_TYPE_METACITY;
934
935 metacity->theme = meta_theme_new (metacity_theme_type);
936
937 if (!meta_theme_load (metacity->theme, metacity_theme_name, &error)) {
938 g_warning ("Failed to load metacity theme '%s': %s",
939 metacity_theme_name, error->message);
940
941 g_error_free (error);
942 g_clear_object (&metacity->theme);
943
944 return FALSE;
945 }
946#else
947
892 /* meta_theme_get_current returns the last good theme, so we will try to948 /* meta_theme_get_current returns the last good theme, so we will try to
893 * load theme manually to know that theme is 100% valid.949 * load theme manually to know that theme is 100% valid.
894 */950 */
@@ -905,6 +961,7 @@
905 /* If we are here then we know that this will not fail. */961 /* If we are here then we know that this will not fail. */
906 meta_theme_set_current (metacity_theme_name, TRUE);962 meta_theme_set_current (metacity_theme_name, TRUE);
907 metacity->theme = meta_theme_get_current ();963 metacity->theme = meta_theme_get_current ();
964#endif
908965
909 return TRUE;966 return TRUE;
910}967}
@@ -940,7 +997,11 @@
940{997{
941 GWDThemeMetacity *metacity = GWD_THEME_METACITY (object);998 GWDThemeMetacity *metacity = GWD_THEME_METACITY (object);
942999
1000#ifdef HAVE_METACITY_3_20_0
1001 g_clear_object (&metacity->theme);
1002#else
943 g_clear_pointer (&metacity->style_variants, g_hash_table_destroy);1003 g_clear_pointer (&metacity->style_variants, g_hash_table_destroy);
1004#endif
9441005
945 if (metacity->button_layout_id != 0) {1006 if (metacity->button_layout_id != 0) {
946 GWDSettings *settings = gwd_theme_get_settings (GWD_THEME (metacity));1007 GWDSettings *settings = gwd_theme_get_settings (GWD_THEME (metacity));
@@ -949,7 +1010,9 @@
949 metacity->button_layout_id = 0;1010 metacity->button_layout_id = 0;
950 }1011 }
9511012
1013#ifndef HAVE_METACITY_3_20_0
952 metacity->titlebar_font = NULL;1014 metacity->titlebar_font = NULL;
1015#endif
9531016
954 G_OBJECT_CLASS (gwd_theme_metacity_parent_class)->dispose (object);1017 G_OBJECT_CLASS (gwd_theme_metacity_parent_class)->dispose (object);
955}1018}
@@ -959,7 +1022,11 @@
959{1022{
960 GWDThemeMetacity *metacity = GWD_THEME_METACITY (theme);1023 GWDThemeMetacity *metacity = GWD_THEME_METACITY (theme);
9611024
1025#ifdef HAVE_METACITY_3_20_0
1026 meta_theme_invalidate (metacity->theme);
1027#else
962 g_hash_table_remove_all (metacity->style_variants);1028 g_hash_table_remove_all (metacity->style_variants);
1029#endif
963}1030}
9641031
965static void1032static void
@@ -971,8 +1038,10 @@
971 GdkDisplay *display = gdk_display_get_default ();1038 GdkDisplay *display = gdk_display_get_default ();
972 Display *xdisplay = gdk_x11_display_get_xdisplay (display);1039 Display *xdisplay = gdk_x11_display_get_xdisplay (display);
973 GtkWidget *style_window = gwd_theme_get_style_window (theme);1040 GtkWidget *style_window = gwd_theme_get_style_window (theme);
1041#ifndef HAVE_METACITY_3_20_0
974 MetaStyleInfo *style_info = get_style_info (metacity, decor);1042 MetaStyleInfo *style_info = get_style_info (metacity, decor);
975 GtkStyleContext *context = gtk_widget_get_style_context (style_window);1043 GtkStyleContext *context = gtk_widget_get_style_context (style_window);
1044#endif
976 cairo_surface_t *surface;1045 cairo_surface_t *surface;
977 Picture src;1046 Picture src;
978 MetaButtonState button_states [META_BUTTON_TYPE_LAST];1047 MetaButtonState button_states [META_BUTTON_TYPE_LAST];
@@ -987,8 +1056,10 @@
987 Region right_region;1056 Region right_region;
988 double alpha;1057 double alpha;
989 gboolean shade_alpha;1058 gboolean shade_alpha;
1059#ifndef HAVE_METACITY_3_20_0
990 MetaFrameStyle *frame_style;1060 MetaFrameStyle *frame_style;
991 GdkRGBA bg_rgba;1061 GdkRGBA bg_rgba;
1062#endif
9921063
993 if (!decor->surface || !decor->picture)1064 if (!decor->surface || !decor->picture)
994 return;1065 return;
@@ -1023,6 +1094,7 @@
1023 for (i = 0; i < META_BUTTON_TYPE_LAST; ++i)1094 for (i = 0; i < META_BUTTON_TYPE_LAST; ++i)
1024 button_states[i] = meta_button_state_for_button_type (metacity, decor, i);1095 button_states[i] = meta_button_state_for_button_type (metacity, decor, i);
10251096
1097#ifndef HAVE_METACITY_3_20_0
1026 frame_style = meta_theme_get_frame_style (metacity->theme, frame_type, flags);1098 frame_style = meta_theme_get_frame_style (metacity->theme, frame_type, flags);
10271099
1028 gtk_style_context_get_background_color (context, GTK_STATE_FLAG_NORMAL, &bg_rgba);1100 gtk_style_context_get_background_color (context, GTK_STATE_FLAG_NORMAL, &bg_rgba);
@@ -1034,6 +1106,7 @@
10341106
1035 bg_rgba.alpha = frame_style->window_background_alpha / 255.0;1107 bg_rgba.alpha = frame_style->window_background_alpha / 255.0;
1036 }1108 }
1109#endif
10371110
1038 /* Draw something that will be almost invisible to user. This is hacky way1111 /* Draw something that will be almost invisible to user. This is hacky way
1039 * to fix invisible decorations. */1112 * to fix invisible decorations. */
@@ -1048,19 +1121,28 @@
10481121
1049 cr = cairo_create (surface);1122 cr = cairo_create (surface);
10501123
1124#ifndef HAVE_METACITY_3_20_0
1051 gdk_cairo_set_source_rgba (cr, &bg_rgba);1125 gdk_cairo_set_source_rgba (cr, &bg_rgba);
1052 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);1126 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
1053 cairo_paint (cr);1127 cairo_paint (cr);
1128#endif
10541129
1055 src = XRenderCreatePicture (xdisplay, cairo_xlib_surface_get_drawable (surface),1130 src = XRenderCreatePicture (xdisplay, cairo_xlib_surface_get_drawable (surface),
1056 xformat_rgba, 0, NULL);1131 xformat_rgba, 0, NULL);
10571132
1133#ifdef HAVE_METACITY_3_20_0
1134 meta_theme_draw_frame (metacity->theme, decor->gtk_theme_variant, cr, frame_type, flags,
1135 fgeom.width - fgeom.borders.total.left - fgeom.borders.total.right,
1136 fgeom.height - fgeom.borders.total.top - fgeom.borders.total.bottom,
1137 decor->name, &metacity->button_layout,
1138 button_states, decor->icon_pixbuf, NULL);
1139#else
1058 meta_theme_draw_frame (metacity->theme, style_info, cr, frame_type, flags,1140 meta_theme_draw_frame (metacity->theme, style_info, cr, frame_type, flags,
1059 fgeom.width - fgeom.borders.total.left - fgeom.borders.total.right,1141 fgeom.width - fgeom.borders.total.left - fgeom.borders.total.right,
1060 fgeom.height - fgeom.borders.total.top - fgeom.borders.total.bottom,1142 fgeom.height - fgeom.borders.total.top - fgeom.borders.total.bottom,
1061 decor->layout, decor->frame->text_height, &metacity->button_layout,1143 decor->layout, decor->frame->text_height, &metacity->button_layout,
1062 button_states, decor->icon_pixbuf, NULL);1144 button_states, decor->icon_pixbuf, NULL);
10631145#endif
10641146
1065 if (fgeom.borders.visible.top) {1147 if (fgeom.borders.visible.top) {
1066 top_region = get_top_border_region (&fgeom, fgeom.width);1148 top_region = get_top_border_region (&fgeom, fgeom.width);
@@ -1196,23 +1278,35 @@
1196 decor_frame_t *frame)1278 decor_frame_t *frame)
1197{1279{
1198 GWDThemeMetacity *metacity = GWD_THEME_METACITY (theme);1280 GWDThemeMetacity *metacity = GWD_THEME_METACITY (theme);
1281#ifndef HAVE_METACITY_3_20_0
1199 MetaStyleInfo *style_info = get_style_info (metacity, NULL);1282 MetaStyleInfo *style_info = get_style_info (metacity, NULL);
1283#endif
1200 MetaFrameType frame_type = frame_type_from_string (frame->type);1284 MetaFrameType frame_type = frame_type_from_string (frame->type);
1201 MetaFrameBorders borders;1285 MetaFrameBorders borders;
12021286
1203 gwd_decor_frame_ref (frame);1287 gwd_decor_frame_ref (frame);
12041288
1289#ifdef HAVE_METACITY_3_20_0
1290 meta_theme_get_frame_borders (metacity->theme, NULL, frame_type,
1291 0, &borders);
1292#else
1205 meta_theme_get_frame_borders (metacity->theme, style_info, frame_type,1293 meta_theme_get_frame_borders (metacity->theme, style_info, frame_type,
1206 frame->text_height, 0, &borders);1294 frame->text_height, 0, &borders);
1295#endif
12071296
1208 frame->win_extents.top = borders.visible.top;1297 frame->win_extents.top = borders.visible.top;
1209 frame->win_extents.bottom = borders.visible.bottom;1298 frame->win_extents.bottom = borders.visible.bottom;
1210 frame->win_extents.left = borders.visible.left;1299 frame->win_extents.left = borders.visible.left;
1211 frame->win_extents.right = borders.visible.right;1300 frame->win_extents.right = borders.visible.right;
12121301
1302#ifdef HAVE_METACITY_3_20_0
1303 meta_theme_get_frame_borders (metacity->theme, NULL, frame_type,
1304 META_FRAME_MAXIMIZED, &borders);
1305#else
1213 meta_theme_get_frame_borders (metacity->theme, style_info, frame_type,1306 meta_theme_get_frame_borders (metacity->theme, style_info, frame_type,
1214 frame->text_height, META_FRAME_MAXIMIZED,1307 frame->text_height, META_FRAME_MAXIMIZED,
1215 &borders);1308 &borders);
1309#endif
12161310
1217 frame->max_win_extents.top = borders.visible.top;1311 frame->max_win_extents.top = borders.visible.top;
1218 frame->max_win_extents.bottom = borders.visible.bottom;1312 frame->max_win_extents.bottom = borders.visible.bottom;
@@ -1427,13 +1521,20 @@
1427{1521{
1428 GWDThemeMetacity *metacity = GWD_THEME_METACITY (theme);1522 GWDThemeMetacity *metacity = GWD_THEME_METACITY (theme);
14291523
1524#ifdef HAVE_METACITY_3_20_0
1525 meta_theme_set_titlebar_font (metacity->theme, titlebar_font);
1526#else
1430 metacity->titlebar_font = titlebar_font;1527 metacity->titlebar_font = titlebar_font;
1528#endif
1431}1529}
14321530
1433static PangoFontDescription *1531static PangoFontDescription *
1434gwd_theme_metacity_get_titlebar_font (GWDTheme *theme,1532gwd_theme_metacity_get_titlebar_font (GWDTheme *theme,
1435 decor_frame_t *frame)1533 decor_frame_t *frame)
1436{1534{
1535#ifdef HAVE_METACITY_3_20_0
1536 return NULL;
1537#else
1437 GWDThemeMetacity *metacity = GWD_THEME_METACITY (theme);1538 GWDThemeMetacity *metacity = GWD_THEME_METACITY (theme);
1438 MetaStyleInfo *style_info = get_style_info (metacity, NULL);1539 MetaStyleInfo *style_info = get_style_info (metacity, NULL);
1439 PangoFontDescription *font_desc = meta_style_info_create_font_desc (style_info);1540 PangoFontDescription *font_desc = meta_style_info_create_font_desc (style_info);
@@ -1445,6 +1546,7 @@
1445 meta_frame_style_apply_scale (style, font_desc);1546 meta_frame_style_apply_scale (style, font_desc);
14461547
1447 return font_desc;1548 return font_desc;
1549#endif
1448}1550}
14491551
1450static void1552static void
@@ -1469,8 +1571,10 @@
1469static void1571static void
1470gwd_theme_metacity_init (GWDThemeMetacity *metacity)1572gwd_theme_metacity_init (GWDThemeMetacity *metacity)
1471{1573{
1574#ifndef HAVE_METACITY_3_20_0
1472 metacity->style_variants = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,1575 metacity->style_variants = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
1473 (GDestroyNotify) meta_style_info_unref);1576 (GDestroyNotify) meta_style_info_unref);
1577#endif
1474}1578}
14751579
1476/**1580/**
14771581
=== modified file 'gtk/window-decorator/gwd-theme.c'
--- gtk/window-decorator/gwd-theme.c 2016-06-09 20:28:29 +0000
+++ gtk/window-decorator/gwd-theme.c 2016-06-09 20:28:29 +0000
@@ -109,7 +109,6 @@
109109
110 G_OBJECT_CLASS (gwd_theme_parent_class)->constructed (object);110 G_OBJECT_CLASS (gwd_theme_parent_class)->constructed (object);
111111
112 gwd_theme_update_titlebar_font (theme);
113 create_style_window (theme);112 create_style_window (theme);
114}113}
115114

Subscribers

People subscribed via source and target branches