Merge lp:~muktupavels/compiz/gwd-support-metacity-3-22 into lp:compiz/0.9.13
- gwd-support-metacity-3-22
- Merge into 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 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Marco Trevisan (Treviño) | Approve | ||
Review via email:
|
Commit message
GWD: add support for metacity 3.22
Description of the change
To post a comment you must log in.
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
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.
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 2016-10-26 18:31:46 +0000 | |||
3 | +++ gtk/CMakeLists.txt 2016-10-26 18:31:46 +0000 | |||
4 | @@ -28,6 +28,8 @@ | |||
5 | 28 | pkg_check_modules (LIBMETACITY libmetacity>=3.20.0) | 28 | pkg_check_modules (LIBMETACITY libmetacity>=3.20.0) |
6 | 29 | 29 | ||
7 | 30 | if (LIBMETACITY_FOUND) | 30 | if (LIBMETACITY_FOUND) |
8 | 31 | compiz_pkg_check_modules (HAVE_METACITY_3_22_0 libmetacity>=3.22.0) | ||
9 | 32 | |||
10 | 31 | set (METACITY_INCLUDE_DIRS ${LIBMETACITY_INCLUDE_DIRS}) | 33 | set (METACITY_INCLUDE_DIRS ${LIBMETACITY_INCLUDE_DIRS}) |
11 | 32 | set (METACITY_LIBRARIES ${LIBMETACITY_LIBRARIES}) | 34 | set (METACITY_LIBRARIES ${LIBMETACITY_LIBRARIES}) |
12 | 33 | else (LIBMETACITY_FOUND) | 35 | else (LIBMETACITY_FOUND) |
13 | 34 | 36 | ||
14 | === modified file 'gtk/config.h.gtk.in' | |||
15 | --- gtk/config.h.gtk.in 2016-10-26 18:31:46 +0000 | |||
16 | +++ gtk/config.h.gtk.in 2016-10-26 18:31:46 +0000 | |||
17 | @@ -1,4 +1,7 @@ | |||
18 | 1 | /* Define to 1 if Metacity support is enabled */ | 1 | /* Define to 1 if Metacity support is enabled */ |
19 | 2 | #cmakedefine USE_METACITY 1 | 2 | #cmakedefine USE_METACITY 1 |
20 | 3 | 3 | ||
21 | 4 | /* Define to 1 if Metacity version >= 3.22.0 */ | ||
22 | 5 | #cmakedefine HAVE_METACITY_3_22_0 1 | ||
23 | 6 | |||
24 | 4 | #define GETTEXT_PACKAGE "${GETTEXT_PACKAGE}" | 7 | #define GETTEXT_PACKAGE "${GETTEXT_PACKAGE}" |
25 | 5 | 8 | ||
26 | === modified file 'gtk/window-decorator/gwd-theme-metacity.c' | |||
27 | --- gtk/window-decorator/gwd-theme-metacity.c 2016-10-26 18:31:46 +0000 | |||
28 | +++ gtk/window-decorator/gwd-theme-metacity.c 2016-10-26 18:31:46 +0000 | |||
29 | @@ -40,7 +40,10 @@ | |||
30 | 40 | MetaTheme *theme; | 40 | MetaTheme *theme; |
31 | 41 | 41 | ||
32 | 42 | gulong button_layout_id; | 42 | gulong button_layout_id; |
33 | 43 | |||
34 | 44 | #ifndef HAVE_METACITY_3_22_0 | ||
35 | 43 | MetaButtonLayout button_layout; | 45 | MetaButtonLayout button_layout; |
36 | 46 | #endif | ||
37 | 44 | }; | 47 | }; |
38 | 45 | 48 | ||
39 | 46 | G_DEFINE_TYPE (GWDThemeMetacity, gwd_theme_metacity, GWD_TYPE_THEME) | 49 | G_DEFINE_TYPE (GWDThemeMetacity, gwd_theme_metacity, GWD_TYPE_THEME) |
40 | @@ -67,9 +70,70 @@ | |||
41 | 67 | { | 70 | { |
42 | 68 | gboolean invert = gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL; | 71 | gboolean invert = gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL; |
43 | 69 | 72 | ||
44 | 73 | #ifdef HAVE_METACITY_3_22_0 | ||
45 | 74 | meta_theme_set_button_layout (metacity->theme, button_layout, invert); | ||
46 | 75 | #else | ||
47 | 70 | metacity->button_layout = meta_button_layout_new (button_layout, invert); | 76 | metacity->button_layout = meta_button_layout_new (button_layout, invert); |
50 | 71 | } | 77 | #endif |
51 | 72 | 78 | } | |
52 | 79 | |||
53 | 80 | static MetaButtonState | ||
54 | 81 | meta_button_state (gint state) | ||
55 | 82 | { | ||
56 | 83 | if (state & IN_EVENT_WINDOW) { | ||
57 | 84 | if (state & PRESSED_EVENT_WINDOW) | ||
58 | 85 | return META_BUTTON_STATE_PRESSED; | ||
59 | 86 | |||
60 | 87 | return META_BUTTON_STATE_PRELIGHT; | ||
61 | 88 | } | ||
62 | 89 | |||
63 | 90 | return META_BUTTON_STATE_NORMAL; | ||
64 | 91 | } | ||
65 | 92 | |||
66 | 93 | #ifdef HAVE_METACITY_3_22_0 | ||
67 | 94 | static MetaButtonState | ||
68 | 95 | meta_button_state_for_button_type (decor_t *decor, | ||
69 | 96 | MetaButtonType type) | ||
70 | 97 | { | ||
71 | 98 | switch (type) { | ||
72 | 99 | case META_BUTTON_TYPE_CLOSE: | ||
73 | 100 | return meta_button_state (decor->button_states[BUTTON_CLOSE]); | ||
74 | 101 | case META_BUTTON_TYPE_MAXIMIZE: | ||
75 | 102 | return meta_button_state (decor->button_states[BUTTON_MAX]); | ||
76 | 103 | case META_BUTTON_TYPE_MINIMIZE: | ||
77 | 104 | return meta_button_state (decor->button_states[BUTTON_MIN]); | ||
78 | 105 | case META_BUTTON_TYPE_MENU: | ||
79 | 106 | return meta_button_state (decor->button_states[BUTTON_MENU]); | ||
80 | 107 | case META_BUTTON_TYPE_SHADE: | ||
81 | 108 | return meta_button_state (decor->button_states[BUTTON_SHADE]); | ||
82 | 109 | case META_BUTTON_TYPE_ABOVE: | ||
83 | 110 | return meta_button_state (decor->button_states[BUTTON_ABOVE]); | ||
84 | 111 | case META_BUTTON_TYPE_STICK: | ||
85 | 112 | return meta_button_state (decor->button_states[BUTTON_STICK]); | ||
86 | 113 | case META_BUTTON_TYPE_UNSHADE: | ||
87 | 114 | return meta_button_state (decor->button_states[BUTTON_UNSHADE]); | ||
88 | 115 | case META_BUTTON_TYPE_UNABOVE: | ||
89 | 116 | return meta_button_state (decor->button_states[BUTTON_UNABOVE]); | ||
90 | 117 | case META_BUTTON_TYPE_UNSTICK: | ||
91 | 118 | return meta_button_state (decor->button_states[BUTTON_UNSTICK]); | ||
92 | 119 | default: | ||
93 | 120 | break; | ||
94 | 121 | } | ||
95 | 122 | |||
96 | 123 | return META_BUTTON_STATE_NORMAL; | ||
97 | 124 | } | ||
98 | 125 | |||
99 | 126 | static MetaButtonState | ||
100 | 127 | update_button_state (MetaButtonType type, | ||
101 | 128 | GdkRectangle rect, | ||
102 | 129 | gpointer user_data) | ||
103 | 130 | { | ||
104 | 131 | decor_t *decor = (decor_t *) user_data; | ||
105 | 132 | |||
106 | 133 | return meta_button_state_for_button_type (decor, type); | ||
107 | 134 | } | ||
108 | 135 | |||
109 | 136 | #else | ||
110 | 73 | static MetaButtonType | 137 | static MetaButtonType |
111 | 74 | meta_function_to_type (MetaButtonFunction function) | 138 | meta_function_to_type (MetaButtonFunction function) |
112 | 75 | { | 139 | { |
113 | @@ -102,19 +166,6 @@ | |||
114 | 102 | } | 166 | } |
115 | 103 | 167 | ||
116 | 104 | static MetaButtonState | 168 | static MetaButtonState |
117 | 105 | meta_button_state (gint state) | ||
118 | 106 | { | ||
119 | 107 | if (state & IN_EVENT_WINDOW) { | ||
120 | 108 | if (state & PRESSED_EVENT_WINDOW) | ||
121 | 109 | return META_BUTTON_STATE_PRESSED; | ||
122 | 110 | |||
123 | 111 | return META_BUTTON_STATE_PRELIGHT; | ||
124 | 112 | } | ||
125 | 113 | |||
126 | 114 | return META_BUTTON_STATE_NORMAL; | ||
127 | 115 | } | ||
128 | 116 | |||
129 | 117 | static MetaButtonState | ||
130 | 118 | meta_button_state_for_button_type (GWDThemeMetacity *metacity, | 169 | meta_button_state_for_button_type (GWDThemeMetacity *metacity, |
131 | 119 | decor_t *decor, | 170 | decor_t *decor, |
132 | 120 | MetaButtonType type) | 171 | MetaButtonType type) |
133 | @@ -168,6 +219,7 @@ | |||
134 | 168 | 219 | ||
135 | 169 | return META_BUTTON_STATE_NORMAL; | 220 | return META_BUTTON_STATE_NORMAL; |
136 | 170 | } | 221 | } |
137 | 222 | #endif | ||
138 | 171 | 223 | ||
139 | 172 | static gint | 224 | static gint |
140 | 173 | radius_to_width (gint radius, | 225 | radius_to_width (gint radius, |
141 | @@ -537,9 +589,15 @@ | |||
142 | 537 | else | 589 | else |
143 | 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; |
144 | 539 | 591 | ||
145 | 592 | #ifdef HAVE_METACITY_3_22_0 | ||
146 | 593 | meta_theme_calc_geometry (metacity->theme, decor->gtk_theme_variant, | ||
147 | 594 | frame_type, *flags, client_width, client_height, | ||
148 | 595 | fgeom); | ||
149 | 596 | #else | ||
150 | 540 | meta_theme_calc_geometry (metacity->theme, decor->gtk_theme_variant, | 597 | meta_theme_calc_geometry (metacity->theme, decor->gtk_theme_variant, |
151 | 541 | frame_type, *flags, client_width, client_height, | 598 | frame_type, *flags, client_width, client_height, |
152 | 542 | &metacity->button_layout, fgeom); | 599 | &metacity->button_layout, fgeom); |
153 | 600 | #endif | ||
154 | 543 | } | 601 | } |
155 | 544 | 602 | ||
156 | 545 | static void | 603 | static void |
157 | @@ -586,6 +644,38 @@ | |||
158 | 586 | decor->button_width = width - min_x; | 644 | decor->button_width = width - min_x; |
159 | 587 | } | 645 | } |
160 | 588 | 646 | ||
161 | 647 | #ifdef HAVE_METACITY_3_22_0 | ||
162 | 648 | static MetaButtonType | ||
163 | 649 | button_type_to_meta_button_type (gint button_type) | ||
164 | 650 | { | ||
165 | 651 | switch (button_type) { | ||
166 | 652 | case BUTTON_MENU: | ||
167 | 653 | return META_BUTTON_TYPE_MENU; | ||
168 | 654 | case BUTTON_MIN: | ||
169 | 655 | return META_BUTTON_TYPE_MINIMIZE; | ||
170 | 656 | case BUTTON_MAX: | ||
171 | 657 | return META_BUTTON_TYPE_MAXIMIZE; | ||
172 | 658 | case BUTTON_CLOSE: | ||
173 | 659 | return META_BUTTON_TYPE_CLOSE; | ||
174 | 660 | case BUTTON_SHADE: | ||
175 | 661 | return META_BUTTON_TYPE_SHADE; | ||
176 | 662 | case BUTTON_ABOVE: | ||
177 | 663 | return META_BUTTON_TYPE_ABOVE; | ||
178 | 664 | case BUTTON_STICK: | ||
179 | 665 | return META_BUTTON_TYPE_STICK; | ||
180 | 666 | case BUTTON_UNSHADE: | ||
181 | 667 | return META_BUTTON_TYPE_UNSHADE; | ||
182 | 668 | case BUTTON_UNABOVE: | ||
183 | 669 | return META_BUTTON_TYPE_UNABOVE; | ||
184 | 670 | case BUTTON_UNSTICK: | ||
185 | 671 | return META_BUTTON_TYPE_UNSTICK; | ||
186 | 672 | default: | ||
187 | 673 | break; | ||
188 | 674 | } | ||
189 | 675 | |||
190 | 676 | return META_BUTTON_TYPE_LAST; | ||
191 | 677 | } | ||
192 | 678 | #else | ||
193 | 589 | static gboolean | 679 | static gboolean |
194 | 590 | button_present (GWDThemeMetacity *metacity, | 680 | button_present (GWDThemeMetacity *metacity, |
195 | 591 | MetaButtonFunction function) | 681 | MetaButtonFunction function) |
196 | @@ -633,6 +723,7 @@ | |||
197 | 633 | 723 | ||
198 | 634 | return META_BUTTON_FUNCTION_LAST; | 724 | return META_BUTTON_FUNCTION_LAST; |
199 | 635 | } | 725 | } |
200 | 726 | #endif | ||
201 | 636 | 727 | ||
202 | 637 | static gboolean | 728 | static gboolean |
203 | 638 | setup_theme (GWDThemeMetacity *metacity) | 729 | setup_theme (GWDThemeMetacity *metacity) |
204 | @@ -728,12 +819,10 @@ | |||
205 | 728 | GtkWidget *style_window = gwd_theme_get_style_window (theme); | 819 | GtkWidget *style_window = gwd_theme_get_style_window (theme); |
206 | 729 | cairo_surface_t *surface; | 820 | cairo_surface_t *surface; |
207 | 730 | Picture src; | 821 | Picture src; |
208 | 731 | MetaButtonState button_states [META_BUTTON_TYPE_LAST]; | ||
209 | 732 | MetaFrameGeometry fgeom; | 822 | MetaFrameGeometry fgeom; |
210 | 733 | MetaFrameFlags flags; | 823 | MetaFrameFlags flags; |
211 | 734 | MetaFrameType frame_type; | 824 | MetaFrameType frame_type; |
212 | 735 | cairo_t *cr; | 825 | cairo_t *cr; |
213 | 736 | gint i; | ||
214 | 737 | Region top_region; | 826 | Region top_region; |
215 | 738 | Region bottom_region; | 827 | Region bottom_region; |
216 | 739 | Region left_region; | 828 | Region left_region; |
217 | @@ -773,8 +862,12 @@ | |||
218 | 773 | draw_shadow_background (decor, cr, decor->shadow, decor->context); | 862 | draw_shadow_background (decor, cr, decor->shadow, decor->context); |
219 | 774 | } | 863 | } |
220 | 775 | 864 | ||
222 | 776 | for (i = 0; i < META_BUTTON_TYPE_LAST; ++i) | 865 | #ifndef HAVE_METACITY_3_22_0 |
223 | 866 | MetaButtonState button_states [META_BUTTON_TYPE_LAST]; | ||
224 | 867 | |||
225 | 868 | for (gint i = 0; i < META_BUTTON_TYPE_LAST; ++i) | ||
226 | 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); |
227 | 870 | #endif | ||
228 | 778 | 871 | ||
229 | 779 | /* Draw something that will be almost invisible to user. This is hacky way | 872 | /* Draw something that will be almost invisible to user. This is hacky way |
230 | 780 | * to fix invisible decorations. */ | 873 | * to fix invisible decorations. */ |
231 | @@ -791,11 +884,18 @@ | |||
232 | 791 | src = XRenderCreatePicture (xdisplay, cairo_xlib_surface_get_drawable (surface), | 884 | src = XRenderCreatePicture (xdisplay, cairo_xlib_surface_get_drawable (surface), |
233 | 792 | xformat_rgba, 0, NULL); | 885 | xformat_rgba, 0, NULL); |
234 | 793 | 886 | ||
235 | 887 | #ifdef HAVE_METACITY_3_22_0 | ||
236 | 888 | meta_theme_draw_frame (metacity->theme, decor->gtk_theme_variant, cr, frame_type, flags, | ||
237 | 889 | fgeom.width - fgeom.borders.total.left - fgeom.borders.total.right, | ||
238 | 890 | fgeom.height - fgeom.borders.total.top - fgeom.borders.total.bottom, | ||
239 | 891 | decor->name, update_button_state, decor, decor->icon_pixbuf, NULL); | ||
240 | 892 | #else | ||
241 | 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, |
242 | 795 | fgeom.width - fgeom.borders.total.left - fgeom.borders.total.right, | 894 | fgeom.width - fgeom.borders.total.left - fgeom.borders.total.right, |
243 | 796 | fgeom.height - fgeom.borders.total.top - fgeom.borders.total.bottom, | 895 | fgeom.height - fgeom.borders.total.top - fgeom.borders.total.bottom, |
244 | 797 | decor->name, &metacity->button_layout, | 896 | decor->name, &metacity->button_layout, |
245 | 798 | button_states, decor->icon_pixbuf, NULL); | 897 | button_states, decor->icon_pixbuf, NULL); |
246 | 898 | #endif | ||
247 | 799 | 899 | ||
248 | 800 | if (fgeom.borders.visible.top + fgeom.borders.shadow.top) { | 900 | if (fgeom.borders.visible.top + fgeom.borders.shadow.top) { |
249 | 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); |
250 | @@ -1123,8 +1223,10 @@ | |||
251 | 1123 | MetaFrameGeometry fgeom; | 1223 | MetaFrameGeometry fgeom; |
252 | 1124 | MetaFrameType frame_type; | 1224 | MetaFrameType frame_type; |
253 | 1125 | MetaFrameFlags flags; | 1225 | MetaFrameFlags flags; |
254 | 1226 | #ifndef HAVE_METACITY_3_22_0 | ||
255 | 1126 | MetaButtonFunction button_function; | 1227 | MetaButtonFunction button_function; |
256 | 1127 | MetaButtonSpace *space; | 1228 | MetaButtonSpace *space; |
257 | 1229 | #endif | ||
258 | 1128 | 1230 | ||
259 | 1129 | if (!decor->context) { | 1231 | if (!decor->context) { |
260 | 1130 | /* undecorated windows implicitly have no buttons */ | 1232 | /* undecorated windows implicitly have no buttons */ |
261 | @@ -1135,6 +1237,34 @@ | |||
262 | 1135 | 1237 | ||
263 | 1136 | get_decoration_geometry (metacity, decor, &flags, &fgeom, frame_type); | 1238 | get_decoration_geometry (metacity, decor, &flags, &fgeom, frame_type); |
264 | 1137 | 1239 | ||
265 | 1240 | #ifdef HAVE_METACITY_3_22_0 | ||
266 | 1241 | MetaButtonType button_type = button_type_to_meta_button_type (i); | ||
267 | 1242 | MetaButton **buttons = meta_theme_get_buttons (metacity->theme); | ||
268 | 1243 | |||
269 | 1244 | for (gint index = 0; buttons[index]; index++) { | ||
270 | 1245 | if (meta_button_get_type (buttons[index]) == button_type) { | ||
271 | 1246 | GdkRectangle rect; | ||
272 | 1247 | |||
273 | 1248 | meta_button_get_event_rect (buttons[index], &rect); | ||
274 | 1249 | |||
275 | 1250 | if (rect.width != 0 && rect.height != 0) { | ||
276 | 1251 | *x = rect.x; | ||
277 | 1252 | *y = rect.y; | ||
278 | 1253 | *w = rect.width; | ||
279 | 1254 | *h = rect.height; | ||
280 | 1255 | |||
281 | 1256 | *x = *x - fgeom.borders.invisible.left + fgeom.borders.resize.left; | ||
282 | 1257 | *y = *y - fgeom.borders.invisible.top + fgeom.borders.resize.top; | ||
283 | 1258 | |||
284 | 1259 | g_free (buttons); | ||
285 | 1260 | return TRUE; | ||
286 | 1261 | } | ||
287 | 1262 | } | ||
288 | 1263 | } | ||
289 | 1264 | |||
290 | 1265 | g_free (buttons); | ||
291 | 1266 | return FALSE; | ||
292 | 1267 | #else | ||
293 | 1138 | button_function = button_to_meta_button_function (i); | 1268 | button_function = button_to_meta_button_function (i); |
294 | 1139 | if (!button_present (metacity, button_function)) | 1269 | if (!button_present (metacity, button_function)) |
295 | 1140 | return FALSE; | 1270 | return FALSE; |
296 | @@ -1186,6 +1316,7 @@ | |||
297 | 1186 | *y = *y - fgeom.borders.invisible.top + fgeom.borders.resize.top; | 1316 | *y = *y - fgeom.borders.invisible.top + fgeom.borders.resize.top; |
298 | 1187 | 1317 | ||
299 | 1188 | return TRUE; | 1318 | return TRUE; |
300 | 1319 | #endif | ||
301 | 1189 | } | 1320 | } |
302 | 1190 | 1321 | ||
303 | 1191 | static void | 1322 | static void |
I'm ok with this