Merge lp:~muktupavels/compiz/gwd-support-metacity-3-22 into lp:compiz/0.9.13

Proposed by Alberts Muktupāvels
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: 4086
Merged at revision: 4094
Proposed branch: lp:~muktupavels/compiz/gwd-support-metacity-3-22
Merge into: lp:compiz/0.9.13
Prerequisite: lp:~muktupavels/compiz/gwd-use-resize-border
Diff against target: 303 lines (+154/-18)
3 files modified
gtk/CMakeLists.txt (+2/-0)
gtk/config.h.gtk.in (+3/-0)
gtk/window-decorator/gwd-theme-metacity.c (+149/-18)
To merge this branch: bzr merge lp:~muktupavels/compiz/gwd-support-metacity-3-22
Reviewer Review Type Date Requested Status
Marco Trevisan (Treviño) Approve
Review via email: mp+304690@code.launchpad.net

Commit message

GWD: add support for metacity 3.22

To post a comment you must log in.
Revision history for this message
Sam Spilsbury (smspillaz) :
4085. By Alberts Muktupāvels

Rename button_to_meta_button_type to button_type_to_meta_button_type.

4086. By Alberts Muktupāvels

Simplify code.

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

I'm ok with this

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 2016-10-26 18:31:46 +0000
+++ gtk/CMakeLists.txt 2016-10-26 18:31:46 +0000
@@ -28,6 +28,8 @@
28 pkg_check_modules (LIBMETACITY libmetacity>=3.20.0)28 pkg_check_modules (LIBMETACITY libmetacity>=3.20.0)
2929
30 if (LIBMETACITY_FOUND)30 if (LIBMETACITY_FOUND)
31 compiz_pkg_check_modules (HAVE_METACITY_3_22_0 libmetacity>=3.22.0)
32
31 set (METACITY_INCLUDE_DIRS ${LIBMETACITY_INCLUDE_DIRS})33 set (METACITY_INCLUDE_DIRS ${LIBMETACITY_INCLUDE_DIRS})
32 set (METACITY_LIBRARIES ${LIBMETACITY_LIBRARIES})34 set (METACITY_LIBRARIES ${LIBMETACITY_LIBRARIES})
33 else (LIBMETACITY_FOUND)35 else (LIBMETACITY_FOUND)
3436
=== modified file 'gtk/config.h.gtk.in'
--- gtk/config.h.gtk.in 2016-10-26 18:31:46 +0000
+++ gtk/config.h.gtk.in 2016-10-26 18:31:46 +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.22.0 */
5#cmakedefine HAVE_METACITY_3_22_0 1
6
4#define GETTEXT_PACKAGE "${GETTEXT_PACKAGE}"7#define GETTEXT_PACKAGE "${GETTEXT_PACKAGE}"
58
=== modified file 'gtk/window-decorator/gwd-theme-metacity.c'
--- gtk/window-decorator/gwd-theme-metacity.c 2016-10-26 18:31:46 +0000
+++ gtk/window-decorator/gwd-theme-metacity.c 2016-10-26 18:31:46 +0000
@@ -40,7 +40,10 @@
40 MetaTheme *theme;40 MetaTheme *theme;
4141
42 gulong button_layout_id;42 gulong button_layout_id;
43
44#ifndef HAVE_METACITY_3_22_0
43 MetaButtonLayout button_layout;45 MetaButtonLayout button_layout;
46#endif
44};47};
4548
46G_DEFINE_TYPE (GWDThemeMetacity, gwd_theme_metacity, GWD_TYPE_THEME)49G_DEFINE_TYPE (GWDThemeMetacity, gwd_theme_metacity, GWD_TYPE_THEME)
@@ -67,9 +70,70 @@
67{70{
68 gboolean invert = gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL;71 gboolean invert = gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL;
6972
73#ifdef HAVE_METACITY_3_22_0
74 meta_theme_set_button_layout (metacity->theme, button_layout, invert);
75#else
70 metacity->button_layout = meta_button_layout_new (button_layout, invert);76 metacity->button_layout = meta_button_layout_new (button_layout, invert);
71}77#endif
7278}
79
80static MetaButtonState
81meta_button_state (gint state)
82{
83 if (state & IN_EVENT_WINDOW) {
84 if (state & PRESSED_EVENT_WINDOW)
85 return META_BUTTON_STATE_PRESSED;
86
87 return META_BUTTON_STATE_PRELIGHT;
88 }
89
90 return META_BUTTON_STATE_NORMAL;
91}
92
93#ifdef HAVE_METACITY_3_22_0
94static MetaButtonState
95meta_button_state_for_button_type (decor_t *decor,
96 MetaButtonType type)
97{
98 switch (type) {
99 case META_BUTTON_TYPE_CLOSE:
100 return meta_button_state (decor->button_states[BUTTON_CLOSE]);
101 case META_BUTTON_TYPE_MAXIMIZE:
102 return meta_button_state (decor->button_states[BUTTON_MAX]);
103 case META_BUTTON_TYPE_MINIMIZE:
104 return meta_button_state (decor->button_states[BUTTON_MIN]);
105 case META_BUTTON_TYPE_MENU:
106 return meta_button_state (decor->button_states[BUTTON_MENU]);
107 case META_BUTTON_TYPE_SHADE:
108 return meta_button_state (decor->button_states[BUTTON_SHADE]);
109 case META_BUTTON_TYPE_ABOVE:
110 return meta_button_state (decor->button_states[BUTTON_ABOVE]);
111 case META_BUTTON_TYPE_STICK:
112 return meta_button_state (decor->button_states[BUTTON_STICK]);
113 case META_BUTTON_TYPE_UNSHADE:
114 return meta_button_state (decor->button_states[BUTTON_UNSHADE]);
115 case META_BUTTON_TYPE_UNABOVE:
116 return meta_button_state (decor->button_states[BUTTON_UNABOVE]);
117 case META_BUTTON_TYPE_UNSTICK:
118 return meta_button_state (decor->button_states[BUTTON_UNSTICK]);
119 default:
120 break;
121 }
122
123 return META_BUTTON_STATE_NORMAL;
124}
125
126static MetaButtonState
127update_button_state (MetaButtonType type,
128 GdkRectangle rect,
129 gpointer user_data)
130{
131 decor_t *decor = (decor_t *) user_data;
132
133 return meta_button_state_for_button_type (decor, type);
134}
135
136#else
73static MetaButtonType137static MetaButtonType
74meta_function_to_type (MetaButtonFunction function)138meta_function_to_type (MetaButtonFunction function)
75{139{
@@ -102,19 +166,6 @@
102}166}
103167
104static MetaButtonState168static MetaButtonState
105meta_button_state (gint state)
106{
107 if (state & IN_EVENT_WINDOW) {
108 if (state & PRESSED_EVENT_WINDOW)
109 return META_BUTTON_STATE_PRESSED;
110
111 return META_BUTTON_STATE_PRELIGHT;
112 }
113
114 return META_BUTTON_STATE_NORMAL;
115}
116
117static MetaButtonState
118meta_button_state_for_button_type (GWDThemeMetacity *metacity,169meta_button_state_for_button_type (GWDThemeMetacity *metacity,
119 decor_t *decor,170 decor_t *decor,
120 MetaButtonType type)171 MetaButtonType type)
@@ -168,6 +219,7 @@
168219
169 return META_BUTTON_STATE_NORMAL;220 return META_BUTTON_STATE_NORMAL;
170}221}
222#endif
171223
172static gint224static gint
173radius_to_width (gint radius,225radius_to_width (gint radius,
@@ -537,9 +589,15 @@
537 else589 else
538 client_height = decor->border_layout.left.y2 - decor->border_layout.left.y1;590 client_height = decor->border_layout.left.y2 - decor->border_layout.left.y1;
539591
592#ifdef HAVE_METACITY_3_22_0
593 meta_theme_calc_geometry (metacity->theme, decor->gtk_theme_variant,
594 frame_type, *flags, client_width, client_height,
595 fgeom);
596#else
540 meta_theme_calc_geometry (metacity->theme, decor->gtk_theme_variant,597 meta_theme_calc_geometry (metacity->theme, decor->gtk_theme_variant,
541 frame_type, *flags, client_width, client_height,598 frame_type, *flags, client_width, client_height,
542 &metacity->button_layout, fgeom);599 &metacity->button_layout, fgeom);
600#endif
543}601}
544602
545static void603static void
@@ -586,6 +644,38 @@
586 decor->button_width = width - min_x;644 decor->button_width = width - min_x;
587}645}
588646
647#ifdef HAVE_METACITY_3_22_0
648static MetaButtonType
649button_type_to_meta_button_type (gint button_type)
650{
651 switch (button_type) {
652 case BUTTON_MENU:
653 return META_BUTTON_TYPE_MENU;
654 case BUTTON_MIN:
655 return META_BUTTON_TYPE_MINIMIZE;
656 case BUTTON_MAX:
657 return META_BUTTON_TYPE_MAXIMIZE;
658 case BUTTON_CLOSE:
659 return META_BUTTON_TYPE_CLOSE;
660 case BUTTON_SHADE:
661 return META_BUTTON_TYPE_SHADE;
662 case BUTTON_ABOVE:
663 return META_BUTTON_TYPE_ABOVE;
664 case BUTTON_STICK:
665 return META_BUTTON_TYPE_STICK;
666 case BUTTON_UNSHADE:
667 return META_BUTTON_TYPE_UNSHADE;
668 case BUTTON_UNABOVE:
669 return META_BUTTON_TYPE_UNABOVE;
670 case BUTTON_UNSTICK:
671 return META_BUTTON_TYPE_UNSTICK;
672 default:
673 break;
674 }
675
676 return META_BUTTON_TYPE_LAST;
677}
678#else
589static gboolean679static gboolean
590button_present (GWDThemeMetacity *metacity,680button_present (GWDThemeMetacity *metacity,
591 MetaButtonFunction function)681 MetaButtonFunction function)
@@ -633,6 +723,7 @@
633723
634 return META_BUTTON_FUNCTION_LAST;724 return META_BUTTON_FUNCTION_LAST;
635}725}
726#endif
636727
637static gboolean728static gboolean
638setup_theme (GWDThemeMetacity *metacity)729setup_theme (GWDThemeMetacity *metacity)
@@ -728,12 +819,10 @@
728 GtkWidget *style_window = gwd_theme_get_style_window (theme);819 GtkWidget *style_window = gwd_theme_get_style_window (theme);
729 cairo_surface_t *surface;820 cairo_surface_t *surface;
730 Picture src;821 Picture src;
731 MetaButtonState button_states [META_BUTTON_TYPE_LAST];
732 MetaFrameGeometry fgeom;822 MetaFrameGeometry fgeom;
733 MetaFrameFlags flags;823 MetaFrameFlags flags;
734 MetaFrameType frame_type;824 MetaFrameType frame_type;
735 cairo_t *cr;825 cairo_t *cr;
736 gint i;
737 Region top_region;826 Region top_region;
738 Region bottom_region;827 Region bottom_region;
739 Region left_region;828 Region left_region;
@@ -773,8 +862,12 @@
773 draw_shadow_background (decor, cr, decor->shadow, decor->context);862 draw_shadow_background (decor, cr, decor->shadow, decor->context);
774 }863 }
775864
776 for (i = 0; i < META_BUTTON_TYPE_LAST; ++i)865#ifndef HAVE_METACITY_3_22_0
866 MetaButtonState button_states [META_BUTTON_TYPE_LAST];
867
868 for (gint i = 0; i < META_BUTTON_TYPE_LAST; ++i)
777 button_states[i] = meta_button_state_for_button_type (metacity, decor, i);869 button_states[i] = meta_button_state_for_button_type (metacity, decor, i);
870#endif
778871
779 /* Draw something that will be almost invisible to user. This is hacky way872 /* Draw something that will be almost invisible to user. This is hacky way
780 * to fix invisible decorations. */873 * to fix invisible decorations. */
@@ -791,11 +884,18 @@
791 src = XRenderCreatePicture (xdisplay, cairo_xlib_surface_get_drawable (surface),884 src = XRenderCreatePicture (xdisplay, cairo_xlib_surface_get_drawable (surface),
792 xformat_rgba, 0, NULL);885 xformat_rgba, 0, NULL);
793886
887#ifdef HAVE_METACITY_3_22_0
888 meta_theme_draw_frame (metacity->theme, decor->gtk_theme_variant, cr, frame_type, flags,
889 fgeom.width - fgeom.borders.total.left - fgeom.borders.total.right,
890 fgeom.height - fgeom.borders.total.top - fgeom.borders.total.bottom,
891 decor->name, update_button_state, decor, decor->icon_pixbuf, NULL);
892#else
794 meta_theme_draw_frame (metacity->theme, decor->gtk_theme_variant, cr, frame_type, flags,893 meta_theme_draw_frame (metacity->theme, decor->gtk_theme_variant, cr, frame_type, flags,
795 fgeom.width - fgeom.borders.total.left - fgeom.borders.total.right,894 fgeom.width - fgeom.borders.total.left - fgeom.borders.total.right,
796 fgeom.height - fgeom.borders.total.top - fgeom.borders.total.bottom,895 fgeom.height - fgeom.borders.total.top - fgeom.borders.total.bottom,
797 decor->name, &metacity->button_layout,896 decor->name, &metacity->button_layout,
798 button_states, decor->icon_pixbuf, NULL);897 button_states, decor->icon_pixbuf, NULL);
898#endif
799899
800 if (fgeom.borders.visible.top + fgeom.borders.shadow.top) {900 if (fgeom.borders.visible.top + fgeom.borders.shadow.top) {
801 top_region = get_top_border_region (&fgeom, !decor->frame->has_shadow_extents);901 top_region = get_top_border_region (&fgeom, !decor->frame->has_shadow_extents);
@@ -1123,8 +1223,10 @@
1123 MetaFrameGeometry fgeom;1223 MetaFrameGeometry fgeom;
1124 MetaFrameType frame_type;1224 MetaFrameType frame_type;
1125 MetaFrameFlags flags;1225 MetaFrameFlags flags;
1226#ifndef HAVE_METACITY_3_22_0
1126 MetaButtonFunction button_function;1227 MetaButtonFunction button_function;
1127 MetaButtonSpace *space;1228 MetaButtonSpace *space;
1229#endif
11281230
1129 if (!decor->context) {1231 if (!decor->context) {
1130 /* undecorated windows implicitly have no buttons */1232 /* undecorated windows implicitly have no buttons */
@@ -1135,6 +1237,34 @@
11351237
1136 get_decoration_geometry (metacity, decor, &flags, &fgeom, frame_type);1238 get_decoration_geometry (metacity, decor, &flags, &fgeom, frame_type);
11371239
1240#ifdef HAVE_METACITY_3_22_0
1241 MetaButtonType button_type = button_type_to_meta_button_type (i);
1242 MetaButton **buttons = meta_theme_get_buttons (metacity->theme);
1243
1244 for (gint index = 0; buttons[index]; index++) {
1245 if (meta_button_get_type (buttons[index]) == button_type) {
1246 GdkRectangle rect;
1247
1248 meta_button_get_event_rect (buttons[index], &rect);
1249
1250 if (rect.width != 0 && rect.height != 0) {
1251 *x = rect.x;
1252 *y = rect.y;
1253 *w = rect.width;
1254 *h = rect.height;
1255
1256 *x = *x - fgeom.borders.invisible.left + fgeom.borders.resize.left;
1257 *y = *y - fgeom.borders.invisible.top + fgeom.borders.resize.top;
1258
1259 g_free (buttons);
1260 return TRUE;
1261 }
1262 }
1263 }
1264
1265 g_free (buttons);
1266 return FALSE;
1267#else
1138 button_function = button_to_meta_button_function (i);1268 button_function = button_to_meta_button_function (i);
1139 if (!button_present (metacity, button_function))1269 if (!button_present (metacity, button_function))
1140 return FALSE;1270 return FALSE;
@@ -1186,6 +1316,7 @@
1186 *y = *y - fgeom.borders.invisible.top + fgeom.borders.resize.top;1316 *y = *y - fgeom.borders.invisible.top + fgeom.borders.resize.top;
11871317
1188 return TRUE;1318 return TRUE;
1319#endif
1189}1320}
11901321
1191static void1322static void

Subscribers

People subscribed via source and target branches