Merge lp:~muktupavels/compiz/gwd-theme-implement-get-button-position into lp:compiz/0.9.12
- gwd-theme-implement-get-button-position
- Merge into 0.9.12
Proposed by
Alberts Muktupāvels
Status: | Merged |
---|---|
Approved by: | Marco Trevisan (Treviño) |
Approved revision: | 4034 |
Merged at revision: | 4030 |
Proposed branch: | lp:~muktupavels/compiz/gwd-theme-implement-get-button-position |
Merge into: | lp:compiz/0.9.12 |
Prerequisite: | lp:~muktupavels/compiz/gwd-theme-implement-get-title-scale |
Diff against target: |
966 lines (+349/-373) 9 files modified
gtk/window-decorator/actionmenu.c (+3/-2) gtk/window-decorator/cairo.c (+0/-77) gtk/window-decorator/decorator.c (+4/-3) gtk/window-decorator/gtk-window-decorator.c (+1/-3) gtk/window-decorator/gtk-window-decorator.h (+1/-28) gtk/window-decorator/gwd-theme-cairo.c (+82/-0) gtk/window-decorator/gwd-theme-metacity.c (+235/-2) gtk/window-decorator/gwd-theme-metacity.h (+10/-0) gtk/window-decorator/metacity.c (+13/-258) |
To merge this branch: | bzr merge lp:~muktupavels/compiz/gwd-theme-implement-get-button-position |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Marco Trevisan (Treviño) | Approve | ||
Sam Spilsbury | Approve | ||
Review via email:
|
Commit message
GWDTheme: implement get_button_
Description of the change
GWDTheme: implement get_button_
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) : | # |
- 4032. By Alberts Muktupāvels
-
Merge changes from lp:~albertsmuktupavels/compiz/gwd-theme-implement-get-title-scale.
- 4033. By Alberts Muktupāvels
-
Fix indentation in actionmenu.c.
- 4034. By Alberts Muktupāvels
-
Assign and declare.
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alberts Muktupāvels (muktupavels) wrote : | # |
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alberts Muktupāvels (muktupavels) wrote : | # |
Does this branch requires any other change?
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'gtk/window-decorator/actionmenu.c' |
2 | --- gtk/window-decorator/actionmenu.c 2014-08-27 19:22:06 +0000 |
3 | +++ gtk/window-decorator/actionmenu.c 2016-05-20 11:08:56 +0000 |
4 | @@ -53,8 +53,9 @@ |
5 | |
6 | if (d->decorated) |
7 | { |
8 | - if ((*theme_get_button_position) (d, BUTTON_MENU, width, height, |
9 | - &bx, &by, &width, &height)) |
10 | + if (gwd_theme_get_button_position (gwd_theme, d, BUTTON_MENU, |
11 | + width, height, &bx, &by, |
12 | + &width, &height)) |
13 | *x = *x - frame->win_extents.left + bx; |
14 | } |
15 | |
16 | |
17 | === modified file 'gtk/window-decorator/cairo.c' |
18 | --- gtk/window-decorator/cairo.c 2016-05-20 11:08:56 +0000 |
19 | +++ gtk/window-decorator/cairo.c 2016-05-20 11:08:56 +0000 |
20 | @@ -823,83 +823,6 @@ |
21 | return FALSE; |
22 | } |
23 | |
24 | -static gboolean |
25 | -button_present (decor_t *d, |
26 | - gint i) |
27 | -{ |
28 | - switch (i) { |
29 | - case BUTTON_MIN: |
30 | - if (d->actions & WNCK_WINDOW_ACTION_MINIMIZE) |
31 | - return TRUE; |
32 | - break; |
33 | - case BUTTON_MAX: |
34 | - if (d->actions & WNCK_WINDOW_ACTION_MAXIMIZE) |
35 | - return TRUE; |
36 | - break; |
37 | - case BUTTON_CLOSE: |
38 | - if (d->actions & WNCK_WINDOW_ACTION_CLOSE) |
39 | - return TRUE; |
40 | - break; |
41 | - case BUTTON_MENU: |
42 | - case BUTTON_SHADE: |
43 | - case BUTTON_ABOVE: |
44 | - case BUTTON_STICK: |
45 | - case BUTTON_UNSHADE: |
46 | - case BUTTON_UNABOVE: |
47 | - case BUTTON_UNSTICK: |
48 | - break; |
49 | - default: |
50 | - break; |
51 | - } |
52 | - |
53 | - return FALSE; |
54 | -} |
55 | - |
56 | -gboolean |
57 | -get_button_position (decor_t *d, |
58 | - gint i, |
59 | - gint width, |
60 | - gint height, |
61 | - gint *x, |
62 | - gint *y, |
63 | - gint *w, |
64 | - gint *h) |
65 | -{ |
66 | - if (i > BUTTON_MENU) |
67 | - return FALSE; |
68 | - |
69 | - if (d->frame_window) |
70 | - { |
71 | - *x = bpos[i].x + bpos[i].xw * width + d->frame->win_extents.left + 4; |
72 | - *y = bpos[i].y + bpos[i].yh * height + bpos[i].yth * |
73 | - (d->frame->titlebar_height - 17) + d->frame->win_extents.top + 2; |
74 | - } |
75 | - else |
76 | - { |
77 | - *x = bpos[i].x + bpos[i].xw * width; |
78 | - *y = bpos[i].y + bpos[i].yh * height + bpos[i].yth * |
79 | - (d->frame->titlebar_height - 17); |
80 | - } |
81 | - |
82 | - *w = bpos[i].w + bpos[i].ww * width; |
83 | - *h = bpos[i].h + bpos[i].hh * height + bpos[i].hth + |
84 | - (d->frame->titlebar_height - 17); |
85 | - |
86 | - /* hack to position multiple buttons on the right */ |
87 | - if (i != BUTTON_MENU) { |
88 | - gint position = 0; |
89 | - gint button = 0; |
90 | - while (button != i) { |
91 | - if (button_present (d, button)) |
92 | - position++; |
93 | - button++; |
94 | - } |
95 | - *x -= 10 + 16 * position; |
96 | - } |
97 | - |
98 | - return TRUE; |
99 | -} |
100 | - |
101 | void |
102 | get_event_window_position (decor_t *d, |
103 | gint i, |
104 | |
105 | === modified file 'gtk/window-decorator/decorator.c' |
106 | --- gtk/window-decorator/decorator.c 2016-05-20 11:08:56 +0000 |
107 | +++ gtk/window-decorator/decorator.c 2016-05-20 11:08:56 +0000 |
108 | @@ -294,7 +294,8 @@ |
109 | /* Reparenting mode - if there is a button position for this |
110 | * button then set the geometry */ |
111 | if (d->frame_window && |
112 | - (*theme_get_button_position) (d, i, width, height, &x, &y, &w, &h)) |
113 | + gwd_theme_get_button_position (gwd_theme, d, i, width, height, |
114 | + &x, &y, &w, &h)) |
115 | { |
116 | BoxPtr box = &d->button_windows[i].pos; |
117 | box->x1 = x; |
118 | @@ -305,8 +306,8 @@ |
119 | /* Pixmap mode - if there is a button position for this button then map the window |
120 | * and resize it to this position */ |
121 | else if (!d->frame_window && |
122 | - (*theme_get_button_position) (d, i, width, height, |
123 | - &x, &y, &w, &h)) |
124 | + gwd_theme_get_button_position (gwd_theme, d, i, width, height, |
125 | + &x, &y, &w, &h)) |
126 | { |
127 | Window x11_win = d->button_windows[i].window; |
128 | XMapWindow (xdisplay, x11_win); |
129 | |
130 | === modified file 'gtk/window-decorator/gtk-window-decorator.c' |
131 | --- gtk/window-decorator/gtk-window-decorator.c 2016-05-20 11:08:56 +0000 |
132 | +++ gtk/window-decorator/gtk-window-decorator.c 2016-05-20 11:08:56 +0000 |
133 | @@ -35,6 +35,7 @@ |
134 | gdouble decoration_alpha = 0.5; |
135 | #ifdef USE_METACITY |
136 | gboolean meta_button_layout_set = FALSE; |
137 | +MetaButtonLayout meta_button_layout; |
138 | #endif |
139 | |
140 | gboolean minimal = FALSE; |
141 | @@ -174,7 +175,6 @@ |
142 | theme_draw_window_decoration = meta_draw_window_decoration; |
143 | theme_calc_decoration_size = meta_calc_decoration_size; |
144 | theme_get_event_window_position = meta_get_event_window_position; |
145 | - theme_get_button_position = meta_get_button_position; |
146 | } else { |
147 | g_log ("gtk-window-decorator", G_LOG_LEVEL_INFO, "using cairo decoration"); |
148 | |
149 | @@ -183,7 +183,6 @@ |
150 | theme_draw_window_decoration = draw_window_decoration; |
151 | theme_calc_decoration_size = calc_decoration_size; |
152 | theme_get_event_window_position = get_event_window_position; |
153 | - theme_get_button_position = get_button_position; |
154 | } |
155 | #else |
156 | type = GWD_THEME_TYPE_CAIRO; |
157 | @@ -191,7 +190,6 @@ |
158 | theme_draw_window_decoration = draw_window_decoration; |
159 | theme_calc_decoration_size = calc_decoration_size; |
160 | theme_get_event_window_position = get_event_window_position; |
161 | - theme_get_button_position = get_button_position; |
162 | #endif |
163 | |
164 | g_set_object (&gwd_theme, gwd_theme_new (type, settings)); |
165 | |
166 | === modified file 'gtk/window-decorator/gtk-window-decorator.h' |
167 | --- gtk/window-decorator/gtk-window-decorator.h 2016-05-20 11:08:56 +0000 |
168 | +++ gtk/window-decorator/gtk-window-decorator.h 2016-05-20 11:08:56 +0000 |
169 | @@ -113,6 +113,7 @@ |
170 | extern gdouble decoration_alpha; |
171 | #ifdef USE_METACITY |
172 | extern gboolean meta_button_layout_set; |
173 | +extern MetaButtonLayout meta_button_layout; |
174 | #endif |
175 | |
176 | extern Atom frame_input_window_atom; |
177 | @@ -324,14 +325,6 @@ |
178 | gint *y, |
179 | gint *w, |
180 | gint *h); |
181 | -gboolean (*theme_get_button_position) (decor_t *d, |
182 | - gint i, |
183 | - gint width, |
184 | - gint height, |
185 | - gint *x, |
186 | - gint *y, |
187 | - gint *w, |
188 | - gint *h); |
189 | |
190 | extern char *program_name; |
191 | |
192 | @@ -563,16 +556,6 @@ |
193 | gint *width, |
194 | gint *height); |
195 | |
196 | -gboolean |
197 | -get_button_position (decor_t *d, |
198 | - gint i, |
199 | - gint width, |
200 | - gint height, |
201 | - gint *x, |
202 | - gint *y, |
203 | - gint *w, |
204 | - gint *h); |
205 | - |
206 | void |
207 | get_event_window_position (decor_t *d, |
208 | gint i, |
209 | @@ -623,16 +606,6 @@ |
210 | gint *width, |
211 | gint *height); |
212 | |
213 | -gboolean |
214 | -meta_get_button_position (decor_t *d, |
215 | - gint i, |
216 | - gint width, |
217 | - gint height, |
218 | - gint *x, |
219 | - gint *y, |
220 | - gint *w, |
221 | - gint *h); |
222 | - |
223 | void |
224 | meta_get_event_window_position (decor_t *d, |
225 | gint i, |
226 | |
227 | === modified file 'gtk/window-decorator/gwd-theme-cairo.c' |
228 | --- gtk/window-decorator/gwd-theme-cairo.c 2016-05-20 11:08:56 +0000 |
229 | +++ gtk/window-decorator/gwd-theme-cairo.c 2016-05-20 11:08:56 +0000 |
230 | @@ -29,6 +29,42 @@ |
231 | |
232 | G_DEFINE_TYPE (GWDThemeCairo, gwd_theme_cairo, GWD_TYPE_THEME) |
233 | |
234 | +static gboolean |
235 | +button_present (decor_t *decor, |
236 | + gint i) |
237 | +{ |
238 | + switch (i) { |
239 | + case BUTTON_MIN: |
240 | + if (decor->actions & WNCK_WINDOW_ACTION_MINIMIZE) |
241 | + return TRUE; |
242 | + break; |
243 | + |
244 | + case BUTTON_MAX: |
245 | + if (decor->actions & WNCK_WINDOW_ACTION_MAXIMIZE) |
246 | + return TRUE; |
247 | + break; |
248 | + |
249 | + case BUTTON_CLOSE: |
250 | + if (decor->actions & WNCK_WINDOW_ACTION_CLOSE) |
251 | + return TRUE; |
252 | + break; |
253 | + |
254 | + case BUTTON_MENU: |
255 | + case BUTTON_SHADE: |
256 | + case BUTTON_ABOVE: |
257 | + case BUTTON_STICK: |
258 | + case BUTTON_UNSHADE: |
259 | + case BUTTON_UNABOVE: |
260 | + case BUTTON_UNSTICK: |
261 | + break; |
262 | + |
263 | + default: |
264 | + break; |
265 | + } |
266 | + |
267 | + return FALSE; |
268 | +} |
269 | + |
270 | static void |
271 | gwd_theme_cairo_update_border_extents (GWDTheme *theme, |
272 | decor_frame_t *frame) |
273 | @@ -44,12 +80,58 @@ |
274 | gwd_decor_frame_unref (frame); |
275 | } |
276 | |
277 | +static gboolean |
278 | +gwd_theme_cairo_get_button_position (GWDTheme *theme, |
279 | + decor_t *decor, |
280 | + gint i, |
281 | + gint width, |
282 | + gint height, |
283 | + gint *x, |
284 | + gint *y, |
285 | + gint *w, |
286 | + gint *h) |
287 | +{ |
288 | + if (i > BUTTON_MENU) |
289 | + return FALSE; |
290 | + |
291 | + if (decor->frame_window) { |
292 | + *x = bpos[i].x + bpos[i].xw * width + decor->frame->win_extents.left + 4; |
293 | + *y = bpos[i].y + bpos[i].yh * height + bpos[i].yth * |
294 | + (decor->frame->titlebar_height - 17) + decor->frame->win_extents.top + 2; |
295 | + } else { |
296 | + *x = bpos[i].x + bpos[i].xw * width; |
297 | + *y = bpos[i].y + bpos[i].yh * height + bpos[i].yth * |
298 | + (decor->frame->titlebar_height - 17); |
299 | + } |
300 | + |
301 | + *w = bpos[i].w + bpos[i].ww * width; |
302 | + *h = bpos[i].h + bpos[i].hh * height + bpos[i].hth + |
303 | + (decor->frame->titlebar_height - 17); |
304 | + |
305 | + /* hack to position multiple buttons on the right */ |
306 | + if (i != BUTTON_MENU) { |
307 | + gint position = 0; |
308 | + gint button = 0; |
309 | + |
310 | + while (button != i) { |
311 | + if (button_present (decor, button)) |
312 | + position++; |
313 | + button++; |
314 | + } |
315 | + |
316 | + *x -= 10 + 16 * position; |
317 | + } |
318 | + |
319 | + return TRUE; |
320 | +} |
321 | + |
322 | static void |
323 | gwd_theme_cairo_class_init (GWDThemeCairoClass *cairo_class) |
324 | { |
325 | GWDThemeClass *theme_class = GWD_THEME_CLASS (cairo_class); |
326 | |
327 | theme_class->update_border_extents = gwd_theme_cairo_update_border_extents; |
328 | + theme_class->get_button_position = gwd_theme_cairo_get_button_position; |
329 | } |
330 | |
331 | static void |
332 | |
333 | === modified file 'gtk/window-decorator/gwd-theme-metacity.c' |
334 | --- gtk/window-decorator/gwd-theme-metacity.c 2016-05-20 11:08:56 +0000 |
335 | +++ gtk/window-decorator/gwd-theme-metacity.c 2016-05-20 11:08:56 +0000 |
336 | @@ -19,8 +19,6 @@ |
337 | |
338 | #include "config.h" |
339 | |
340 | -#include <metacity-private/theme.h> |
341 | - |
342 | #include "gtk-window-decorator.h" |
343 | #include "gwd-theme-metacity.h" |
344 | |
345 | @@ -33,6 +31,154 @@ |
346 | |
347 | G_DEFINE_TYPE (GWDThemeMetacity, gwd_theme_metacity, GWD_TYPE_THEME) |
348 | |
349 | +static gboolean |
350 | +button_present (MetaButtonLayout *button_layout, |
351 | + MetaButtonFunction function) |
352 | +{ |
353 | + int i; |
354 | + |
355 | + for (i = 0; i < MAX_BUTTONS_PER_CORNER; ++i) |
356 | + if (button_layout->left_buttons[i] == function) |
357 | + return TRUE; |
358 | + |
359 | + for (i = 0; i < MAX_BUTTONS_PER_CORNER; ++i) |
360 | + if (button_layout->right_buttons[i] == function) |
361 | + return TRUE; |
362 | + |
363 | + return FALSE; |
364 | +} |
365 | + |
366 | +static MetaButtonFunction |
367 | +button_to_meta_button_function (gint i) |
368 | +{ |
369 | + switch (i) { |
370 | + case BUTTON_MENU: |
371 | + return META_BUTTON_FUNCTION_MENU; |
372 | + case BUTTON_MIN: |
373 | + return META_BUTTON_FUNCTION_MINIMIZE; |
374 | + case BUTTON_MAX: |
375 | + return META_BUTTON_FUNCTION_MAXIMIZE; |
376 | + case BUTTON_CLOSE: |
377 | + return META_BUTTON_FUNCTION_CLOSE; |
378 | + case BUTTON_SHADE: |
379 | + return META_BUTTON_FUNCTION_SHADE; |
380 | + case BUTTON_ABOVE: |
381 | + return META_BUTTON_FUNCTION_ABOVE; |
382 | + case BUTTON_STICK: |
383 | + return META_BUTTON_FUNCTION_STICK; |
384 | + case BUTTON_UNSHADE: |
385 | + return META_BUTTON_FUNCTION_UNSHADE; |
386 | + case BUTTON_UNABOVE: |
387 | + return META_BUTTON_FUNCTION_UNABOVE; |
388 | + case BUTTON_UNSTICK: |
389 | + return META_BUTTON_FUNCTION_UNSTICK; |
390 | + default: |
391 | + break; |
392 | + } |
393 | + |
394 | + return META_BUTTON_FUNCTION_LAST; |
395 | +} |
396 | + |
397 | +void |
398 | +gwd_theme_metacity_get_decoration_geometry (GWDThemeMetacity *metacity, |
399 | + decor_t *decor, |
400 | + MetaFrameFlags *flags, |
401 | + MetaFrameGeometry *fgeom, |
402 | + MetaButtonLayout *button_layout, |
403 | + MetaFrameType frame_type) |
404 | +{ |
405 | + GdkScreen *screen; |
406 | + MetaStyleInfo *style_info; |
407 | + gint client_width; |
408 | + gint client_height; |
409 | + |
410 | + if (!(frame_type < META_FRAME_TYPE_LAST)) |
411 | + frame_type = META_FRAME_TYPE_NORMAL; |
412 | + |
413 | + if (meta_button_layout_set) { |
414 | + *button_layout = meta_button_layout; |
415 | + } else { |
416 | + gint i; |
417 | + |
418 | + button_layout->left_buttons[0] = META_BUTTON_FUNCTION_MENU; |
419 | + |
420 | + for (i = 1; i < MAX_BUTTONS_PER_CORNER; ++i) |
421 | + button_layout->left_buttons[i] = META_BUTTON_FUNCTION_LAST; |
422 | + |
423 | + button_layout->right_buttons[0] = META_BUTTON_FUNCTION_MINIMIZE; |
424 | + button_layout->right_buttons[1] = META_BUTTON_FUNCTION_MAXIMIZE; |
425 | + button_layout->right_buttons[2] = META_BUTTON_FUNCTION_CLOSE; |
426 | + |
427 | + for (i = 3; i < MAX_BUTTONS_PER_CORNER; ++i) |
428 | + button_layout->right_buttons[i] = META_BUTTON_FUNCTION_LAST; |
429 | + } |
430 | + |
431 | + *flags = 0; |
432 | + |
433 | + if (decor->actions & WNCK_WINDOW_ACTION_CLOSE) |
434 | + *flags |= (MetaFrameFlags ) META_FRAME_ALLOWS_DELETE; |
435 | + |
436 | + if (decor->actions & WNCK_WINDOW_ACTION_MINIMIZE) |
437 | + *flags |= (MetaFrameFlags ) META_FRAME_ALLOWS_MINIMIZE; |
438 | + |
439 | + if (decor->actions & WNCK_WINDOW_ACTION_MAXIMIZE) |
440 | + *flags |= (MetaFrameFlags ) META_FRAME_ALLOWS_MAXIMIZE; |
441 | + |
442 | + *flags |= (MetaFrameFlags ) META_FRAME_ALLOWS_MENU; |
443 | + |
444 | + if (decor->actions & WNCK_WINDOW_ACTION_RESIZE) { |
445 | + if (!(decor->state & WNCK_WINDOW_STATE_MAXIMIZED_VERTICALLY)) |
446 | + *flags |= (MetaFrameFlags ) META_FRAME_ALLOWS_VERTICAL_RESIZE; |
447 | + |
448 | + if (!(decor->state & WNCK_WINDOW_STATE_MAXIMIZED_HORIZONTALLY)) |
449 | + *flags |= (MetaFrameFlags ) META_FRAME_ALLOWS_HORIZONTAL_RESIZE; |
450 | + } |
451 | + |
452 | + if (decor->actions & WNCK_WINDOW_ACTION_MOVE) |
453 | + *flags |= (MetaFrameFlags ) META_FRAME_ALLOWS_MOVE; |
454 | + |
455 | + if (decor->actions & WNCK_WINDOW_ACTION_MAXIMIZE) |
456 | + *flags |= (MetaFrameFlags ) META_FRAME_ALLOWS_MAXIMIZE; |
457 | + |
458 | + if (decor->actions & WNCK_WINDOW_ACTION_SHADE) |
459 | + *flags |= (MetaFrameFlags ) META_FRAME_ALLOWS_SHADE; |
460 | + |
461 | + if (decor->active) |
462 | + *flags |= (MetaFrameFlags ) META_FRAME_HAS_FOCUS; |
463 | + |
464 | + if ((decor->state & META_MAXIMIZED) == META_MAXIMIZED) |
465 | + *flags |= (MetaFrameFlags ) META_FRAME_MAXIMIZED; |
466 | + |
467 | + if (decor->state & WNCK_WINDOW_STATE_STICKY) |
468 | + *flags |= (MetaFrameFlags ) META_FRAME_STUCK; |
469 | + |
470 | + if (decor->state & WNCK_WINDOW_STATE_FULLSCREEN) |
471 | + *flags |= (MetaFrameFlags ) META_FRAME_FULLSCREEN; |
472 | + |
473 | + if (decor->state & WNCK_WINDOW_STATE_SHADED) |
474 | + *flags |= (MetaFrameFlags ) META_FRAME_SHADED; |
475 | + |
476 | + if (decor->state & WNCK_WINDOW_STATE_ABOVE) |
477 | + *flags |= (MetaFrameFlags ) META_FRAME_ABOVE; |
478 | + |
479 | + client_width = decor->border_layout.top.x2 - decor->border_layout.top.x1; |
480 | + client_width -= decor->context->right_space + decor->context->left_space; |
481 | + |
482 | + if (decor->border_layout.rotation) |
483 | + client_height = decor->border_layout.left.x2 - decor->border_layout.left.x1; |
484 | + else |
485 | + client_height = decor->border_layout.left.y2 - decor->border_layout.left.y1; |
486 | + |
487 | + screen = gtk_widget_get_screen (decor->frame->style_window_rgba); |
488 | + style_info = meta_theme_create_style_info (screen, decor->gtk_theme_variant); |
489 | + |
490 | + meta_theme_calc_geometry (metacity->theme, style_info, frame_type, |
491 | + decor->frame->text_height, *flags, client_width, |
492 | + client_height, button_layout, fgeom); |
493 | + |
494 | + meta_style_info_unref (style_info); |
495 | +} |
496 | + |
497 | static GObject * |
498 | gwd_theme_metacity_constructor (GType type, |
499 | guint n_properties, |
500 | @@ -96,6 +242,92 @@ |
501 | gwd_decor_frame_unref (frame); |
502 | } |
503 | |
504 | +static gboolean |
505 | +gwd_theme_metacity_get_button_position (GWDTheme *theme, |
506 | + decor_t *decor, |
507 | + gint i, |
508 | + gint width, |
509 | + gint height, |
510 | + gint *x, |
511 | + gint *y, |
512 | + gint *w, |
513 | + gint *h) |
514 | +{ |
515 | + GWDThemeMetacity *metacity = GWD_THEME_METACITY (theme); |
516 | + MetaFrameGeometry fgeom; |
517 | + MetaFrameType frame_type; |
518 | + MetaFrameFlags flags; |
519 | + MetaButtonLayout button_layout; |
520 | + MetaButtonFunction button_function; |
521 | + MetaButtonSpace *space; |
522 | + |
523 | + if (!decor->context) { |
524 | + /* undecorated windows implicitly have no buttons */ |
525 | + return FALSE; |
526 | + } |
527 | + |
528 | + frame_type = meta_frame_type_from_string (decor->frame->type); |
529 | + if (!(frame_type < META_FRAME_TYPE_LAST)) |
530 | + frame_type = META_FRAME_TYPE_NORMAL; |
531 | + |
532 | + gwd_theme_metacity_get_decoration_geometry (metacity, decor, &flags, &fgeom, |
533 | + &button_layout, frame_type); |
534 | + |
535 | + button_function = button_to_meta_button_function (i); |
536 | + if (!button_present (&button_layout, button_function)) |
537 | + return FALSE; |
538 | + |
539 | + switch (i) { |
540 | + case BUTTON_MENU: |
541 | + space = &fgeom.menu_rect; |
542 | + break; |
543 | + case BUTTON_MIN: |
544 | + space = &fgeom.min_rect; |
545 | + break; |
546 | + case BUTTON_MAX: |
547 | + space = &fgeom.max_rect; |
548 | + break; |
549 | + case BUTTON_CLOSE: |
550 | + space = &fgeom.close_rect; |
551 | + break; |
552 | + case BUTTON_SHADE: |
553 | + space = &fgeom.shade_rect; |
554 | + break; |
555 | + case BUTTON_ABOVE: |
556 | + space = &fgeom.above_rect; |
557 | + break; |
558 | + case BUTTON_STICK: |
559 | + space = &fgeom.stick_rect; |
560 | + break; |
561 | + case BUTTON_UNSHADE: |
562 | + space = &fgeom.unshade_rect; |
563 | + break; |
564 | + case BUTTON_UNABOVE: |
565 | + space = &fgeom.unabove_rect; |
566 | + break; |
567 | + case BUTTON_UNSTICK: |
568 | + space = &fgeom.unstick_rect; |
569 | + break; |
570 | + default: |
571 | + return FALSE; |
572 | + } |
573 | + |
574 | + if (!space->clickable.width && !space->clickable.height) |
575 | + return FALSE; |
576 | + |
577 | + *x = space->clickable.x; |
578 | + *y = space->clickable.y; |
579 | + *w = space->clickable.width; |
580 | + *h = space->clickable.height; |
581 | + |
582 | + if (decor->frame_window) { |
583 | + *x += decor->frame->win_extents.left + 4; |
584 | + *y += decor->frame->win_extents.top + 2; |
585 | + } |
586 | + |
587 | + return TRUE; |
588 | +} |
589 | + |
590 | static gfloat |
591 | gwd_theme_metacity_get_title_scale (GWDTheme *theme, |
592 | decor_frame_t *frame) |
593 | @@ -119,6 +351,7 @@ |
594 | object_class->constructor = gwd_theme_metacity_constructor; |
595 | |
596 | theme_class->update_border_extents = gwd_theme_metacity_update_border_extents; |
597 | + theme_class->get_button_position = gwd_theme_metacity_get_button_position; |
598 | theme_class->get_title_scale = gwd_theme_metacity_get_title_scale; |
599 | } |
600 | |
601 | |
602 | === modified file 'gtk/window-decorator/gwd-theme-metacity.h' |
603 | --- gtk/window-decorator/gwd-theme-metacity.h 2016-05-20 11:08:56 +0000 |
604 | +++ gtk/window-decorator/gwd-theme-metacity.h 2016-05-20 11:08:56 +0000 |
605 | @@ -20,6 +20,8 @@ |
606 | #ifndef GWD_THEME_METACITY_H |
607 | #define GWD_THEME_METACITY_H |
608 | |
609 | +#include <metacity-private/theme.h> |
610 | + |
611 | #include "gwd-theme.h" |
612 | |
613 | G_BEGIN_DECLS |
614 | @@ -28,6 +30,14 @@ |
615 | G_DECLARE_FINAL_TYPE (GWDThemeMetacity, gwd_theme_metacity, |
616 | GWD, THEME_METACITY, GWDTheme) |
617 | |
618 | +void |
619 | +gwd_theme_metacity_get_decoration_geometry (GWDThemeMetacity *metacity, |
620 | + decor_t *decor, |
621 | + MetaFrameFlags *flags, |
622 | + MetaFrameGeometry *fgeom, |
623 | + MetaButtonLayout *button_layout, |
624 | + MetaFrameType frame_type); |
625 | + |
626 | G_END_DECLS |
627 | |
628 | #endif |
629 | |
630 | === modified file 'gtk/window-decorator/metacity.c' |
631 | --- gtk/window-decorator/metacity.c 2016-05-20 11:08:56 +0000 |
632 | +++ gtk/window-decorator/metacity.c 2016-05-20 11:08:56 +0000 |
633 | @@ -24,28 +24,10 @@ |
634 | */ |
635 | |
636 | #include "gtk-window-decorator.h" |
637 | +#include "gwd-theme-metacity.h" |
638 | |
639 | #ifdef USE_METACITY |
640 | |
641 | -MetaButtonLayout meta_button_layout; |
642 | - |
643 | -static gboolean |
644 | -meta_button_present (MetaButtonLayout *button_layout, |
645 | - MetaButtonFunction function) |
646 | -{ |
647 | - int i; |
648 | - |
649 | - for (i = 0; i < MAX_BUTTONS_PER_CORNER; ++i) |
650 | - if (button_layout->left_buttons[i] == function) |
651 | - return TRUE; |
652 | - |
653 | - for (i = 0; i < MAX_BUTTONS_PER_CORNER; ++i) |
654 | - if (button_layout->right_buttons[i] == function) |
655 | - return TRUE; |
656 | - |
657 | - return FALSE; |
658 | -} |
659 | - |
660 | static void |
661 | decor_update_meta_window_property (decor_t *d, |
662 | MetaTheme *theme, |
663 | @@ -486,109 +468,6 @@ |
664 | return META_BUTTON_STATE_NORMAL; |
665 | } |
666 | |
667 | -static void |
668 | -meta_get_decoration_geometry (decor_t *d, |
669 | - MetaTheme *theme, |
670 | - MetaFrameFlags *flags, |
671 | - MetaFrameGeometry *fgeom, |
672 | - MetaButtonLayout *button_layout, |
673 | - MetaFrameType frame_type) |
674 | -{ |
675 | - GdkScreen *screen; |
676 | - MetaStyleInfo *style_info; |
677 | - gint client_width; |
678 | - gint client_height; |
679 | - |
680 | - if (!(frame_type < META_FRAME_TYPE_LAST)) |
681 | - frame_type = META_FRAME_TYPE_NORMAL; |
682 | - |
683 | - if (meta_button_layout_set) |
684 | - { |
685 | - *button_layout = meta_button_layout; |
686 | - } |
687 | - else |
688 | - { |
689 | - gint i; |
690 | - |
691 | - button_layout->left_buttons[0] = META_BUTTON_FUNCTION_MENU; |
692 | - |
693 | - for (i = 1; i < MAX_BUTTONS_PER_CORNER; ++i) |
694 | - button_layout->left_buttons[i] = META_BUTTON_FUNCTION_LAST; |
695 | - |
696 | - button_layout->right_buttons[0] = META_BUTTON_FUNCTION_MINIMIZE; |
697 | - button_layout->right_buttons[1] = META_BUTTON_FUNCTION_MAXIMIZE; |
698 | - button_layout->right_buttons[2] = META_BUTTON_FUNCTION_CLOSE; |
699 | - |
700 | - for (i = 3; i < MAX_BUTTONS_PER_CORNER; ++i) |
701 | - button_layout->right_buttons[i] = META_BUTTON_FUNCTION_LAST; |
702 | - } |
703 | - |
704 | - *flags = 0; |
705 | - |
706 | - if (d->actions & WNCK_WINDOW_ACTION_CLOSE) |
707 | - *flags |= (MetaFrameFlags ) META_FRAME_ALLOWS_DELETE; |
708 | - |
709 | - if (d->actions & WNCK_WINDOW_ACTION_MINIMIZE) |
710 | - *flags |= (MetaFrameFlags ) META_FRAME_ALLOWS_MINIMIZE; |
711 | - |
712 | - if (d->actions & WNCK_WINDOW_ACTION_MAXIMIZE) |
713 | - *flags |= (MetaFrameFlags ) META_FRAME_ALLOWS_MAXIMIZE; |
714 | - |
715 | - *flags |= (MetaFrameFlags ) META_FRAME_ALLOWS_MENU; |
716 | - |
717 | - if (d->actions & WNCK_WINDOW_ACTION_RESIZE) |
718 | - { |
719 | - if (!(d->state & WNCK_WINDOW_STATE_MAXIMIZED_VERTICALLY)) |
720 | - *flags |= (MetaFrameFlags ) META_FRAME_ALLOWS_VERTICAL_RESIZE; |
721 | - if (!(d->state & WNCK_WINDOW_STATE_MAXIMIZED_HORIZONTALLY)) |
722 | - *flags |= (MetaFrameFlags ) META_FRAME_ALLOWS_HORIZONTAL_RESIZE; |
723 | - } |
724 | - |
725 | - if (d->actions & WNCK_WINDOW_ACTION_MOVE) |
726 | - *flags |= (MetaFrameFlags ) META_FRAME_ALLOWS_MOVE; |
727 | - |
728 | - if (d->actions & WNCK_WINDOW_ACTION_MAXIMIZE) |
729 | - *flags |= (MetaFrameFlags ) META_FRAME_ALLOWS_MAXIMIZE; |
730 | - |
731 | - if (d->actions & WNCK_WINDOW_ACTION_SHADE) |
732 | - *flags |= (MetaFrameFlags ) META_FRAME_ALLOWS_SHADE; |
733 | - |
734 | - if (d->active) |
735 | - *flags |= (MetaFrameFlags ) META_FRAME_HAS_FOCUS; |
736 | - |
737 | - if ((d->state & META_MAXIMIZED) == META_MAXIMIZED) |
738 | - *flags |= (MetaFrameFlags ) META_FRAME_MAXIMIZED; |
739 | - |
740 | - if (d->state & WNCK_WINDOW_STATE_STICKY) |
741 | - *flags |= (MetaFrameFlags ) META_FRAME_STUCK; |
742 | - |
743 | - if (d->state & WNCK_WINDOW_STATE_FULLSCREEN) |
744 | - *flags |= (MetaFrameFlags ) META_FRAME_FULLSCREEN; |
745 | - |
746 | - if (d->state & WNCK_WINDOW_STATE_SHADED) |
747 | - *flags |= (MetaFrameFlags ) META_FRAME_SHADED; |
748 | - |
749 | - if (d->state & WNCK_WINDOW_STATE_ABOVE) |
750 | - *flags |= (MetaFrameFlags ) META_FRAME_ABOVE; |
751 | - |
752 | - client_width = d->border_layout.top.x2 - d->border_layout.top.x1; |
753 | - client_width -= d->context->right_space + d->context->left_space; |
754 | - |
755 | - if (d->border_layout.rotation) |
756 | - client_height = d->border_layout.left.x2 - d->border_layout.left.x1; |
757 | - else |
758 | - client_height = d->border_layout.left.y2 - d->border_layout.left.y1; |
759 | - |
760 | - screen = gtk_widget_get_screen (d->frame->style_window_rgba); |
761 | - style_info = meta_theme_create_style_info (screen, d->gtk_theme_variant); |
762 | - |
763 | - meta_theme_calc_geometry (theme, style_info, frame_type, d->frame->text_height, |
764 | - *flags, client_width, client_height, |
765 | - button_layout, fgeom); |
766 | - |
767 | - meta_style_info_unref (style_info); |
768 | -} |
769 | - |
770 | void |
771 | meta_draw_window_decoration (decor_t *d) |
772 | { |
773 | @@ -661,8 +540,9 @@ |
774 | if (frame_type == META_FRAME_TYPE_LAST) |
775 | frame_type = META_FRAME_TYPE_NORMAL; |
776 | |
777 | - meta_get_decoration_geometry (d, theme, &flags, &fgeom, &button_layout, |
778 | - frame_type); |
779 | + gwd_theme_metacity_get_decoration_geometry (GWD_THEME_METACITY (gwd_theme), |
780 | + d, &flags, &fgeom, |
781 | + &button_layout, frame_type); |
782 | |
783 | if ((d->prop_xid || !d->buffer_surface) && !d->frame_window) |
784 | draw_shadow_background (d, cr, d->shadow, d->context); |
785 | @@ -820,7 +700,6 @@ |
786 | static void |
787 | meta_calc_button_size (decor_t *d) |
788 | { |
789 | - MetaTheme *theme; |
790 | MetaFrameType frame_type; |
791 | MetaFrameFlags flags; |
792 | MetaFrameGeometry fgeom; |
793 | @@ -833,14 +712,13 @@ |
794 | return; |
795 | } |
796 | |
797 | - theme = meta_theme_get_current (); |
798 | - |
799 | frame_type = meta_frame_type_from_string (d->frame->type); |
800 | if (!(frame_type < META_FRAME_TYPE_LAST)) |
801 | frame_type = META_FRAME_TYPE_NORMAL; |
802 | |
803 | - meta_get_decoration_geometry (d, theme, &flags, &fgeom, &button_layout, |
804 | - frame_type); |
805 | + gwd_theme_metacity_get_decoration_geometry (GWD_THEME_METACITY (gwd_theme), |
806 | + d, &flags, &fgeom, |
807 | + &button_layout, frame_type); |
808 | |
809 | width = d->border_layout.top.x2 - d->border_layout.top.x1 - |
810 | d->context->left_space - d->context->right_space + |
811 | @@ -858,7 +736,8 @@ |
812 | |
813 | if (d->actions & button_actions[i]) |
814 | { |
815 | - if (meta_get_button_position (d, i, width, 256, &x, &y, &w, &h)) |
816 | + if (gwd_theme_get_button_position (gwd_theme, d, i, width, 256, |
817 | + &x, &y, &w, &h)) |
818 | { |
819 | if (x > width / 2 && x < min_x) |
820 | min_x = x; |
821 | @@ -869,128 +748,6 @@ |
822 | d->button_width = width - min_x; |
823 | } |
824 | |
825 | -static MetaButtonFunction |
826 | -button_to_meta_button_function (gint i) |
827 | -{ |
828 | - switch (i) |
829 | - { |
830 | - case BUTTON_MENU: |
831 | - return META_BUTTON_FUNCTION_MENU; |
832 | - case BUTTON_MIN: |
833 | - return META_BUTTON_FUNCTION_MINIMIZE; |
834 | - case BUTTON_MAX: |
835 | - return META_BUTTON_FUNCTION_MAXIMIZE; |
836 | - case BUTTON_CLOSE: |
837 | - return META_BUTTON_FUNCTION_CLOSE; |
838 | - case BUTTON_SHADE: |
839 | - return META_BUTTON_FUNCTION_SHADE; |
840 | - case BUTTON_ABOVE: |
841 | - return META_BUTTON_FUNCTION_ABOVE; |
842 | - case BUTTON_STICK: |
843 | - return META_BUTTON_FUNCTION_STICK; |
844 | - case BUTTON_UNSHADE: |
845 | - return META_BUTTON_FUNCTION_UNSHADE; |
846 | - case BUTTON_UNABOVE: |
847 | - return META_BUTTON_FUNCTION_UNABOVE; |
848 | - case BUTTON_UNSTICK: |
849 | - return META_BUTTON_FUNCTION_UNSTICK; |
850 | - default: |
851 | - break; |
852 | - } |
853 | - |
854 | - return META_BUTTON_FUNCTION_LAST; |
855 | -} |
856 | - |
857 | -gboolean |
858 | -meta_get_button_position (decor_t *d, |
859 | - gint i, |
860 | - gint width, |
861 | - gint height, |
862 | - gint *x, |
863 | - gint *y, |
864 | - gint *w, |
865 | - gint *h) |
866 | -{ |
867 | - MetaButtonLayout button_layout; |
868 | - MetaFrameGeometry fgeom; |
869 | - MetaFrameType frame_type; |
870 | - MetaFrameFlags flags; |
871 | - MetaTheme *theme; |
872 | - MetaButtonFunction button_function; |
873 | - MetaButtonSpace *space; |
874 | - |
875 | - if (!d->context) |
876 | - { |
877 | - /* undecorated windows implicitly have no buttons */ |
878 | - return FALSE; |
879 | - } |
880 | - |
881 | - theme = meta_theme_get_current (); |
882 | - |
883 | - frame_type = meta_frame_type_from_string (d->frame->type); |
884 | - if (!(frame_type < META_FRAME_TYPE_LAST)) |
885 | - frame_type = META_FRAME_TYPE_NORMAL; |
886 | - |
887 | - meta_get_decoration_geometry (d, theme, &flags, &fgeom, &button_layout, |
888 | - frame_type); |
889 | - |
890 | - button_function = button_to_meta_button_function (i); |
891 | - if (!meta_button_present (&button_layout, button_function)) |
892 | - return FALSE; |
893 | - |
894 | - switch (i) |
895 | - { |
896 | - case BUTTON_MENU: |
897 | - space = &fgeom.menu_rect; |
898 | - break; |
899 | - case BUTTON_MIN: |
900 | - space = &fgeom.min_rect; |
901 | - break; |
902 | - case BUTTON_MAX: |
903 | - space = &fgeom.max_rect; |
904 | - break; |
905 | - case BUTTON_CLOSE: |
906 | - space = &fgeom.close_rect; |
907 | - break; |
908 | - case BUTTON_SHADE: |
909 | - space = &fgeom.shade_rect; |
910 | - break; |
911 | - case BUTTON_ABOVE: |
912 | - space = &fgeom.above_rect; |
913 | - break; |
914 | - case BUTTON_STICK: |
915 | - space = &fgeom.stick_rect; |
916 | - break; |
917 | - case BUTTON_UNSHADE: |
918 | - space = &fgeom.unshade_rect; |
919 | - break; |
920 | - case BUTTON_UNABOVE: |
921 | - space = &fgeom.unabove_rect; |
922 | - break; |
923 | - case BUTTON_UNSTICK: |
924 | - space = &fgeom.unstick_rect; |
925 | - break; |
926 | - default: |
927 | - return FALSE; |
928 | - } |
929 | - |
930 | - if (!space->clickable.width && !space->clickable.height) |
931 | - return FALSE; |
932 | - |
933 | - *x = space->clickable.x; |
934 | - *y = space->clickable.y; |
935 | - *w = space->clickable.width; |
936 | - *h = space->clickable.height; |
937 | - |
938 | - if (d->frame_window) |
939 | - { |
940 | - *x += d->frame->win_extents.left + 4; |
941 | - *y += d->frame->win_extents.top + 2; |
942 | - } |
943 | - |
944 | - return TRUE; |
945 | -} |
946 | - |
947 | gboolean |
948 | meta_calc_decoration_size (decor_t *d, |
949 | gint w, |
950 | @@ -1109,12 +866,10 @@ |
951 | MetaButtonLayout button_layout; |
952 | MetaFrameGeometry fgeom; |
953 | MetaFrameFlags flags; |
954 | - MetaTheme *theme; |
955 | - |
956 | - theme = meta_theme_get_current (); |
957 | - |
958 | - meta_get_decoration_geometry (d, theme, &flags, &fgeom, &button_layout, |
959 | - meta_frame_type_from_string (d->frame->type)); |
960 | + |
961 | + gwd_theme_metacity_get_decoration_geometry (GWD_THEME_METACITY (gwd_theme), |
962 | + d, &flags, &fgeom, &button_layout, |
963 | + meta_frame_type_from_string (d->frame->type)); |
964 | |
965 | width += fgeom.borders.total.right + fgeom.borders.total.left; |
966 | height += fgeom.borders.total.top + fgeom.borders.total.bottom; |
Branch updated.
- meta_button_layout is still used, but as global variable it will be removed / is removed gwd-remove- global- button- layout- variables branch.
- "Will this break when the user changes their theme?". No. :)