Merge lp:~muktupavels/compiz/gwd-theme-style-window into lp:compiz/0.9.12
- gwd-theme-style-window
- Merge into 0.9.12
Status: | Merged |
---|---|
Approved by: | Marco Trevisan (Treviño) |
Approved revision: | 4076 |
Merged at revision: | 4057 |
Proposed branch: | lp:~muktupavels/compiz/gwd-theme-style-window |
Merge into: | lp:compiz/0.9.12 |
Prerequisite: | lp:~muktupavels/compiz/gwd-titlebar-font |
Diff against target: |
1218 lines (+380/-333) 10 files modified
gtk/window-decorator/decorator.c (+23/-26) gtk/window-decorator/frames.c (+2/-252) gtk/window-decorator/gtk-window-decorator.c (+0/-1) gtk/window-decorator/gtk-window-decorator.h (+0/-7) gtk/window-decorator/gwd-theme-cairo.c (+218/-5) gtk/window-decorator/gwd-theme-metacity.c (+29/-18) gtk/window-decorator/gwd-theme.c (+73/-1) gtk/window-decorator/gwd-theme.h (+6/-1) gtk/window-decorator/switcher.c (+19/-22) gtk/window-decorator/wnck.c (+10/-0) |
To merge this branch: | bzr merge lp:~muktupavels/compiz/gwd-theme-style-window |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Marco Trevisan (Treviño) | Approve | ||
Review via email: mp+296867@code.launchpad.net |
Commit message
gtk-window-
- Use only one style window - there is no reason to keep multiple windows. More windows just meant that on style-updated signal we called decorations_changed multiple times for no reason - just extra work.
- Switcher label was added to style window, but my tests shows that it is not needed...
- On style-updated signal _title_color was updated multiple times, but it is used only by Cairo theme.
Description of the change
- Use only one style window - there is no reason to keep multiple windows. More windows just meant that on style-updated signal we called decorations_changed multiple times for no reason - just extra work.
- Switcher label was added to style window, but my tests shows that it is not needed...
- On style-updated signal _title_color was updated multiple times, but it is used only by Cairo theme.
- 4075. By Alberts Muktupāvels
-
Merge with lp:~albertsmuktupavels/compiz/gwd-titlebar-font.
- 4076. By Alberts Muktupāvels
-
Merge with lp:~albertsmuktupavels/compiz/gwd-titlebar-font.
Preview Diff
1 | === modified file 'gtk/window-decorator/decorator.c' |
2 | --- gtk/window-decorator/decorator.c 2016-06-09 14:58:49 +0000 |
3 | +++ gtk/window-decorator/decorator.c 2016-06-09 14:58:49 +0000 |
4 | @@ -55,15 +55,19 @@ |
5 | void |
6 | frame_update_titlebar_font (decor_frame_t *frame) |
7 | { |
8 | + GtkWidget *style_window = gwd_theme_get_style_window (gwd_theme); |
9 | PangoFontDescription *font_desc = gwd_theme_get_titlebar_font (gwd_theme, frame); |
10 | - PangoLanguage *lang = pango_context_get_language (frame->pango_context); |
11 | + PangoLanguage *lang; |
12 | PangoFontMetrics *metrics; |
13 | gint ascent, descent; |
14 | |
15 | frame = gwd_decor_frame_ref (frame); |
16 | |
17 | + if (frame->pango_context == NULL) |
18 | + frame->pango_context = gtk_widget_create_pango_context (style_window); |
19 | pango_context_set_font_description (frame->pango_context, font_desc); |
20 | |
21 | + lang = pango_context_get_language (frame->pango_context); |
22 | metrics = pango_context_get_metrics (frame->pango_context, font_desc, lang); |
23 | ascent = pango_font_metrics_get_ascent (metrics); |
24 | descent = pango_font_metrics_get_descent (metrics); |
25 | @@ -76,14 +80,6 @@ |
26 | gwd_decor_frame_unref (frame); |
27 | } |
28 | |
29 | -void |
30 | -update_frames_titlebar_fonts (gpointer key, |
31 | - gpointer value, |
32 | - gpointer user_data) |
33 | -{ |
34 | - frame_update_titlebar_font ((decor_frame_t *) value); |
35 | -} |
36 | - |
37 | /* |
38 | * update_event_windows |
39 | * |
40 | @@ -284,8 +280,6 @@ |
41 | if (!d->layout) |
42 | { |
43 | d->layout = pango_layout_new (d->frame->pango_context); |
44 | - if (!d->layout) |
45 | - return 0; |
46 | |
47 | pango_layout_set_wrap (d->layout, PANGO_WRAP_CHAR); |
48 | } |
49 | @@ -353,6 +347,10 @@ |
50 | w = 1; |
51 | } |
52 | |
53 | + /* Ensure that a layout is created */ |
54 | + if (d->layout == NULL) |
55 | + d->layout = pango_layout_new (d->frame->pango_context); |
56 | + |
57 | /* Set the maximum width for the layout (in case |
58 | * decoration size < text width) since we |
59 | * still need to show the buttons and the window name */ |
60 | @@ -417,6 +415,7 @@ |
61 | update_window_decoration_icon (WnckWindow *win) |
62 | { |
63 | decor_t *d = g_object_get_data (G_OBJECT (win), "decor"); |
64 | + GtkWidget *style_window = gwd_theme_get_style_window (gwd_theme); |
65 | |
66 | /* Destroy old stuff */ |
67 | if (d->icon) |
68 | @@ -442,8 +441,7 @@ |
69 | |
70 | g_object_ref (G_OBJECT (d->icon_pixbuf)); |
71 | |
72 | - d->icon_surface = surface_new_from_pixbuf (d->icon_pixbuf, |
73 | - d->frame->style_window_rgba); |
74 | + d->icon_surface = surface_new_from_pixbuf (d->icon_pixbuf, style_window); |
75 | |
76 | cr = cairo_create (d->icon_surface); |
77 | d->icon = cairo_pattern_create_for_surface (cairo_get_target (cr)); |
78 | @@ -514,6 +512,7 @@ |
79 | cairo_surface_t *surface, *buffer_surface = NULL; |
80 | Picture picture; |
81 | Display *xdisplay; |
82 | + GtkWidget *style_window; |
83 | |
84 | if (win == NULL) |
85 | return FALSE; |
86 | @@ -524,10 +523,11 @@ |
87 | return FALSE; |
88 | |
89 | xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()); |
90 | + style_window = gwd_theme_get_style_window (gwd_theme); |
91 | |
92 | gdk_error_trap_push (); |
93 | |
94 | - surface = create_native_surface_and_wrap (d->width, d->height, d->frame->style_window_rgba); |
95 | + surface = create_native_surface_and_wrap (d->width, d->height, style_window); |
96 | |
97 | gdk_flush (); |
98 | |
99 | @@ -541,7 +541,7 @@ |
100 | |
101 | gdk_error_trap_push (); |
102 | |
103 | - buffer_surface = create_surface (d->width, d->height, d->frame->style_window_rgba); |
104 | + buffer_surface = create_surface (d->width, d->height, style_window); |
105 | |
106 | gdk_flush (); |
107 | |
108 | @@ -1174,21 +1174,18 @@ |
109 | void |
110 | update_default_decorations (GdkScreen *screen) |
111 | { |
112 | + GdkDisplay *display = gdk_display_get_default (); |
113 | + Display *xdisplay = gdk_x11_display_get_xdisplay (display); |
114 | + Window xroot = RootWindowOfScreen (gdk_x11_screen_get_xscreen (screen)); |
115 | + Atom bareAtom = XInternAtom (xdisplay, DECOR_BARE_ATOM_NAME, FALSE); |
116 | + Atom activeAtom = XInternAtom (xdisplay, DECOR_ACTIVE_ATOM_NAME, FALSE); |
117 | + GtkWidget *style_window = gwd_theme_get_style_window (gwd_theme); |
118 | long *data; |
119 | - Window xroot; |
120 | - GdkDisplay *gdkdisplay = gdk_display_get_default (); |
121 | - Display *xdisplay = gdk_x11_display_get_xdisplay (gdkdisplay); |
122 | - Atom bareAtom, activeAtom; |
123 | decor_frame_t *frame; |
124 | decor_frame_t *bare_frame = gwd_get_decor_frame ("bare"); |
125 | decor_extents_t extents; |
126 | unsigned int i; |
127 | |
128 | - xroot = RootWindowOfScreen (gdk_x11_screen_get_xscreen (screen)); |
129 | - |
130 | - bareAtom = XInternAtom (xdisplay, DECOR_BARE_ATOM_NAME, FALSE); |
131 | - activeAtom = XInternAtom (xdisplay, DECOR_ACTIVE_ATOM_NAME, FALSE); |
132 | - |
133 | if (bare_frame->border_shadow_active) |
134 | { |
135 | decor_layout_t layout; |
136 | @@ -1266,7 +1263,7 @@ |
137 | |
138 | default_frames[i].d->context = i < WINDOW_TYPE_FRAMES_NUM ? &frame->window_context_active : &frame->window_context_inactive; |
139 | default_frames[i].d->shadow = i < WINDOW_TYPE_FRAMES_NUM ? frame->border_shadow_active : frame->border_shadow_inactive; |
140 | - default_frames[i].d->layout = pango_layout_new (frame->pango_context); |
141 | + default_frames[i].d->layout = NULL; |
142 | |
143 | decor_get_default_layout (default_frames[i].d->context, 1, 1, &default_frames[i].d->border_layout); |
144 | |
145 | @@ -1279,7 +1276,7 @@ |
146 | default_frames[i].d->draw = draw_window_decoration; |
147 | default_frames[i].d->surface = create_native_surface_and_wrap (default_frames[i].d->width, |
148 | default_frames[i].d->height, |
149 | - frame->style_window_rgba); |
150 | + style_window); |
151 | |
152 | unsigned int j, k; |
153 | |
154 | |
155 | === modified file 'gtk/window-decorator/frames.c' |
156 | --- gtk/window-decorator/frames.c 2016-06-09 14:58:49 +0000 |
157 | +++ gtk/window-decorator/frames.c 2016-06-09 14:58:49 +0000 |
158 | @@ -32,236 +32,7 @@ |
159 | GHashTable *frame_info_table; |
160 | GHashTable *frames_table; |
161 | |
162 | -/* from clearlooks theme */ |
163 | -static void |
164 | -rgb_to_hls (gdouble *r, |
165 | - gdouble *g, |
166 | - gdouble *b) |
167 | -{ |
168 | - gdouble min; |
169 | - gdouble max; |
170 | - gdouble red; |
171 | - gdouble green; |
172 | - gdouble blue; |
173 | - gdouble h, l, s; |
174 | - gdouble delta; |
175 | - |
176 | - red = *r; |
177 | - green = *g; |
178 | - blue = *b; |
179 | - |
180 | - if (red > green) |
181 | - { |
182 | - if (red > blue) |
183 | - max = red; |
184 | - else |
185 | - max = blue; |
186 | - |
187 | - if (green < blue) |
188 | - min = green; |
189 | - else |
190 | - min = blue; |
191 | - } |
192 | - else |
193 | - { |
194 | - if (green > blue) |
195 | - max = green; |
196 | - else |
197 | - max = blue; |
198 | - |
199 | - if (red < blue) |
200 | - min = red; |
201 | - else |
202 | - min = blue; |
203 | - } |
204 | - |
205 | - l = (max + min) / 2; |
206 | - s = 0; |
207 | - h = 0; |
208 | - |
209 | - if (max != min) |
210 | - { |
211 | - if (l <= 0.5) |
212 | - s = (max - min) / (max + min); |
213 | - else |
214 | - s = (max - min) / (2 - max - min); |
215 | - |
216 | - delta = max -min; |
217 | - if (red == max) |
218 | - h = (green - blue) / delta; |
219 | - else if (green == max) |
220 | - h = 2 + (blue - red) / delta; |
221 | - else if (blue == max) |
222 | - h = 4 + (red - green) / delta; |
223 | - |
224 | - h *= 60; |
225 | - if (h < 0.0) |
226 | - h += 360; |
227 | - } |
228 | - |
229 | - *r = h; |
230 | - *g = l; |
231 | - *b = s; |
232 | -} |
233 | - |
234 | -static void |
235 | -hls_to_rgb (gdouble *h, |
236 | - gdouble *l, |
237 | - gdouble *s) |
238 | -{ |
239 | - gdouble hue; |
240 | - gdouble lightness; |
241 | - gdouble saturation; |
242 | - gdouble m1, m2; |
243 | - gdouble r, g, b; |
244 | - |
245 | - lightness = *l; |
246 | - saturation = *s; |
247 | - |
248 | - if (lightness <= 0.5) |
249 | - m2 = lightness * (1 + saturation); |
250 | - else |
251 | - m2 = lightness + saturation - lightness * saturation; |
252 | - |
253 | - m1 = 2 * lightness - m2; |
254 | - |
255 | - if (saturation == 0) |
256 | - { |
257 | - *h = lightness; |
258 | - *l = lightness; |
259 | - *s = lightness; |
260 | - } |
261 | - else |
262 | - { |
263 | - hue = *h + 120; |
264 | - while (hue > 360) |
265 | - hue -= 360; |
266 | - while (hue < 0) |
267 | - hue += 360; |
268 | - |
269 | - if (hue < 60) |
270 | - r = m1 + (m2 - m1) * hue / 60; |
271 | - else if (hue < 180) |
272 | - r = m2; |
273 | - else if (hue < 240) |
274 | - r = m1 + (m2 - m1) * (240 - hue) / 60; |
275 | - else |
276 | - r = m1; |
277 | - |
278 | - hue = *h; |
279 | - while (hue > 360) |
280 | - hue -= 360; |
281 | - while (hue < 0) |
282 | - hue += 360; |
283 | - |
284 | - if (hue < 60) |
285 | - g = m1 + (m2 - m1) * hue / 60; |
286 | - else if (hue < 180) |
287 | - g = m2; |
288 | - else if (hue < 240) |
289 | - g = m1 + (m2 - m1) * (240 - hue) / 60; |
290 | - else |
291 | - g = m1; |
292 | - |
293 | - hue = *h - 120; |
294 | - while (hue > 360) |
295 | - hue -= 360; |
296 | - while (hue < 0) |
297 | - hue += 360; |
298 | - |
299 | - if (hue < 60) |
300 | - b = m1 + (m2 - m1) * hue / 60; |
301 | - else if (hue < 180) |
302 | - b = m2; |
303 | - else if (hue < 240) |
304 | - b = m1 + (m2 - m1) * (240 - hue) / 60; |
305 | - else |
306 | - b = m1; |
307 | - |
308 | - *h = r; |
309 | - *l = g; |
310 | - *s = b; |
311 | - } |
312 | -} |
313 | - |
314 | -static void |
315 | -shade (const decor_color_t *a, |
316 | - decor_color_t *b, |
317 | - float k) |
318 | -{ |
319 | - double red; |
320 | - double green; |
321 | - double blue; |
322 | - |
323 | - red = a->r; |
324 | - green = a->g; |
325 | - blue = a->b; |
326 | - |
327 | - rgb_to_hls (&red, &green, &blue); |
328 | - |
329 | - green *= k; |
330 | - if (green > 1.0) |
331 | - green = 1.0; |
332 | - else if (green < 0.0) |
333 | - green = 0.0; |
334 | - |
335 | - blue *= k; |
336 | - if (blue > 1.0) |
337 | - blue = 1.0; |
338 | - else if (blue < 0.0) |
339 | - blue = 0.0; |
340 | - |
341 | - hls_to_rgb (&red, &green, &blue); |
342 | - |
343 | - b->r = red; |
344 | - b->g = green; |
345 | - b->b = blue; |
346 | -} |
347 | - |
348 | -static void |
349 | -update_style (GtkWidget *widget) |
350 | -{ |
351 | - GtkStyleContext *context; |
352 | - GdkRGBA bg; |
353 | - decor_color_t spot_color; |
354 | - |
355 | - context = gtk_widget_get_style_context (widget); |
356 | - |
357 | - gtk_style_context_save (context); |
358 | - gtk_style_context_set_state (context, GTK_STATE_FLAG_SELECTED); |
359 | - gtk_style_context_get_background_color (context, GTK_STATE_FLAG_SELECTED, &bg); |
360 | - gtk_style_context_restore (context); |
361 | - |
362 | - spot_color.r = bg.red; |
363 | - spot_color.g = bg.green; |
364 | - spot_color.b = bg.blue; |
365 | - |
366 | - shade (&spot_color, &_title_color[0], 1.05); |
367 | - shade (&_title_color[0], &_title_color[1], 0.85); |
368 | -} |
369 | - |
370 | -static void |
371 | -style_updated (GtkWidget *widget, |
372 | - void *user_data) |
373 | -{ |
374 | - GdkDisplay *gdkdisplay; |
375 | - GdkScreen *gdkscreen; |
376 | - WnckScreen *screen; |
377 | - |
378 | - PangoContext *context = (PangoContext *) user_data; |
379 | - |
380 | - gdkdisplay = gdk_display_get_default (); |
381 | - gdkscreen = gdk_display_get_default_screen (gdkdisplay); |
382 | - screen = wnck_screen_get_default (); |
383 | - |
384 | - update_style (widget); |
385 | - |
386 | - pango_cairo_context_set_resolution (context, gdk_screen_get_resolution (gdkscreen)); |
387 | - |
388 | - decorations_changed (screen); |
389 | -} |
390 | - |
391 | -void |
392 | +static void |
393 | decor_frame_refresh (decor_frame_t *frame) |
394 | { |
395 | decor_shadow_options_t active_o, inactive_o; |
396 | @@ -269,8 +40,6 @@ |
397 | |
398 | gwd_decor_frame_ref (frame); |
399 | |
400 | - update_style (frame->style_window_rgba); |
401 | - |
402 | frame_update_titlebar_font (frame); |
403 | |
404 | if (strcmp (frame->type, "switcher") != 0 && strcmp (frame->type, "bare") != 0) |
405 | @@ -421,8 +190,6 @@ |
406 | decor_frame_t * |
407 | decor_frame_new (const gchar *type) |
408 | { |
409 | - GdkScreen *gdkscreen = gdk_screen_get_default (); |
410 | - GdkVisual *visual; |
411 | decor_frame_t *frame = malloc (sizeof (decor_frame_t)); |
412 | |
413 | if (!frame) |
414 | @@ -438,21 +205,7 @@ |
415 | frame->max_border_shadow_active = NULL; |
416 | frame->max_border_shadow_inactive = NULL; |
417 | |
418 | - frame->style_window_rgba = gtk_window_new (GTK_WINDOW_POPUP); |
419 | - |
420 | - visual = gdk_screen_get_rgba_visual (gdkscreen); |
421 | - if (visual) |
422 | - gtk_widget_set_visual (frame->style_window_rgba, visual); |
423 | - |
424 | - gtk_widget_realize (frame->style_window_rgba); |
425 | - |
426 | - gtk_window_move (GTK_WINDOW (frame->style_window_rgba), -100, -100); |
427 | - |
428 | - frame->pango_context = gtk_widget_create_pango_context (frame->style_window_rgba); |
429 | - |
430 | - g_signal_connect_data (frame->style_window_rgba, "style-updated", |
431 | - G_CALLBACK (style_updated), |
432 | - (gpointer) frame->pango_context, 0, 0); |
433 | + frame->pango_context = NULL; |
434 | |
435 | return frame; |
436 | } |
437 | @@ -474,9 +227,6 @@ |
438 | if (frame->max_border_shadow_inactive) |
439 | decor_shadow_destroy (xdisplay, frame->max_border_shadow_inactive); |
440 | |
441 | - if (frame->style_window_rgba) |
442 | - gtk_widget_destroy (GTK_WIDGET (frame->style_window_rgba)); |
443 | - |
444 | if (frame->pango_context) |
445 | g_object_unref (G_OBJECT (frame->pango_context)); |
446 | |
447 | |
448 | === modified file 'gtk/window-decorator/gtk-window-decorator.c' |
449 | --- gtk/window-decorator/gtk-window-decorator.c 2016-06-09 14:58:49 +0000 |
450 | +++ gtk/window-decorator/gtk-window-decorator.c 2016-06-09 14:58:49 +0000 |
451 | @@ -107,7 +107,6 @@ |
452 | GHashTable *frame_table; |
453 | GtkWidget *action_menu = NULL; |
454 | gboolean action_menu_mapped = FALSE; |
455 | -decor_color_t _title_color[2]; |
456 | gint double_click_timeout = 250; |
457 | |
458 | GtkWidget *tip_window; |
459 | |
460 | === modified file 'gtk/window-decorator/gtk-window-decorator.h' |
461 | --- gtk/window-decorator/gtk-window-decorator.h 2016-06-09 14:58:49 +0000 |
462 | +++ gtk/window-decorator/gtk-window-decorator.h 2016-06-09 14:58:49 +0000 |
463 | @@ -218,7 +218,6 @@ |
464 | decor_context_t max_window_context_active; |
465 | decor_context_t max_window_context_inactive; |
466 | PangoContext *pango_context; |
467 | - GtkWidget *style_window_rgba; |
468 | gint text_height; |
469 | gchar *type; |
470 | |
471 | @@ -279,7 +278,6 @@ |
472 | /* action menu */ |
473 | extern GtkWidget *action_menu; |
474 | extern gboolean action_menu_mapped; |
475 | -extern decor_color_t _title_color[2]; |
476 | extern gint double_click_timeout; |
477 | |
478 | |
479 | @@ -387,11 +385,6 @@ |
480 | update_shadow (void); |
481 | |
482 | void |
483 | -update_frames_titlebar_fonts (gpointer key, |
484 | - gpointer value, |
485 | - gpointer user_data); |
486 | - |
487 | -void |
488 | update_window_decoration (WnckWindow *win); |
489 | |
490 | void |
491 | |
492 | === modified file 'gtk/window-decorator/gwd-theme-cairo.c' |
493 | --- gtk/window-decorator/gwd-theme-cairo.c 2016-06-09 14:58:49 +0000 |
494 | +++ gtk/window-decorator/gwd-theme-cairo.c 2016-06-09 14:58:49 +0000 |
495 | @@ -33,7 +33,9 @@ |
496 | |
497 | struct _GWDThemeCairo |
498 | { |
499 | - GObject parent; |
500 | + GObject parent; |
501 | + |
502 | + decor_color_t title_color[2]; |
503 | }; |
504 | |
505 | G_DEFINE_TYPE (GWDThemeCairo, gwd_theme_cairo, GWD_TYPE_THEME) |
506 | @@ -45,6 +47,195 @@ |
507 | } |
508 | |
509 | static void |
510 | +rgb_to_hls (gdouble *r, |
511 | + gdouble *g, |
512 | + gdouble *b) |
513 | +{ |
514 | + gdouble red = *r; |
515 | + gdouble green = *g; |
516 | + gdouble blue = *b; |
517 | + gdouble min; |
518 | + gdouble max; |
519 | + gdouble h, l, s; |
520 | + gdouble delta; |
521 | + |
522 | + if (red > green) { |
523 | + if (red > blue) |
524 | + max = red; |
525 | + else |
526 | + max = blue; |
527 | + |
528 | + if (green < blue) |
529 | + min = green; |
530 | + else |
531 | + min = blue; |
532 | + } else { |
533 | + if (green > blue) |
534 | + max = green; |
535 | + else |
536 | + max = blue; |
537 | + |
538 | + if (red < blue) |
539 | + min = red; |
540 | + else |
541 | + min = blue; |
542 | + } |
543 | + |
544 | + l = (max + min) / 2; |
545 | + s = 0; |
546 | + h = 0; |
547 | + |
548 | + if (max != min) { |
549 | + if (l <= 0.5) |
550 | + s = (max - min) / (max + min); |
551 | + else |
552 | + s = (max - min) / (2 - max - min); |
553 | + |
554 | + delta = max -min; |
555 | + if (red == max) |
556 | + h = (green - blue) / delta; |
557 | + else if (green == max) |
558 | + h = 2 + (blue - red) / delta; |
559 | + else if (blue == max) |
560 | + h = 4 + (red - green) / delta; |
561 | + |
562 | + h *= 60; |
563 | + if (h < 0.0) |
564 | + h += 360; |
565 | + } |
566 | + |
567 | + *r = h; |
568 | + *g = l; |
569 | + *b = s; |
570 | +} |
571 | + |
572 | +static void |
573 | +hls_to_rgb (gdouble *h, |
574 | + gdouble *l, |
575 | + gdouble *s) |
576 | +{ |
577 | + gdouble lightness = *l; |
578 | + gdouble saturation = *s; |
579 | + gdouble hue; |
580 | + gdouble m1, m2; |
581 | + gdouble r, g, b; |
582 | + |
583 | + if (lightness <= 0.5) |
584 | + m2 = lightness * (1 + saturation); |
585 | + else |
586 | + m2 = lightness + saturation - lightness * saturation; |
587 | + |
588 | + m1 = 2 * lightness - m2; |
589 | + |
590 | + if (saturation == 0) { |
591 | + *h = lightness; |
592 | + *l = lightness; |
593 | + *s = lightness; |
594 | + } else { |
595 | + hue = *h + 120; |
596 | + while (hue > 360) |
597 | + hue -= 360; |
598 | + while (hue < 0) |
599 | + hue += 360; |
600 | + |
601 | + if (hue < 60) |
602 | + r = m1 + (m2 - m1) * hue / 60; |
603 | + else if (hue < 180) |
604 | + r = m2; |
605 | + else if (hue < 240) |
606 | + r = m1 + (m2 - m1) * (240 - hue) / 60; |
607 | + else |
608 | + r = m1; |
609 | + |
610 | + hue = *h; |
611 | + while (hue > 360) |
612 | + hue -= 360; |
613 | + while (hue < 0) |
614 | + hue += 360; |
615 | + |
616 | + if (hue < 60) |
617 | + g = m1 + (m2 - m1) * hue / 60; |
618 | + else if (hue < 180) |
619 | + g = m2; |
620 | + else if (hue < 240) |
621 | + g = m1 + (m2 - m1) * (240 - hue) / 60; |
622 | + else |
623 | + g = m1; |
624 | + |
625 | + hue = *h - 120; |
626 | + while (hue > 360) |
627 | + hue -= 360; |
628 | + while (hue < 0) |
629 | + hue += 360; |
630 | + |
631 | + if (hue < 60) |
632 | + b = m1 + (m2 - m1) * hue / 60; |
633 | + else if (hue < 180) |
634 | + b = m2; |
635 | + else if (hue < 240) |
636 | + b = m1 + (m2 - m1) * (240 - hue) / 60; |
637 | + else |
638 | + b = m1; |
639 | + |
640 | + *h = r; |
641 | + *l = g; |
642 | + *s = b; |
643 | + } |
644 | +} |
645 | + |
646 | +static void |
647 | +shade (const decor_color_t *a, |
648 | + decor_color_t *b, |
649 | + gfloat k) |
650 | +{ |
651 | + gdouble red = a->r; |
652 | + gdouble green = a->g; |
653 | + gdouble blue = a->b; |
654 | + |
655 | + rgb_to_hls (&red, &green, &blue); |
656 | + |
657 | + green *= k; |
658 | + if (green > 1.0) |
659 | + green = 1.0; |
660 | + else if (green < 0.0) |
661 | + green = 0.0; |
662 | + |
663 | + blue *= k; |
664 | + if (blue > 1.0) |
665 | + blue = 1.0; |
666 | + else if (blue < 0.0) |
667 | + blue = 0.0; |
668 | + |
669 | + hls_to_rgb (&red, &green, &blue); |
670 | + |
671 | + b->r = red; |
672 | + b->g = green; |
673 | + b->b = blue; |
674 | +} |
675 | + |
676 | +static void |
677 | +update_title_colors (GWDThemeCairo *cairo) |
678 | +{ |
679 | + GWDTheme *theme = GWD_THEME (cairo); |
680 | + GtkWidget *style_window = gwd_theme_get_style_window (theme); |
681 | + GtkStyleContext *context = gtk_widget_get_style_context (style_window); |
682 | + GdkRGBA bg; |
683 | + decor_color_t spot_color; |
684 | + |
685 | + gtk_style_context_save (context); |
686 | + gtk_style_context_set_state (context, GTK_STATE_FLAG_SELECTED); |
687 | + gtk_style_context_get_background_color (context, GTK_STATE_FLAG_SELECTED, &bg); |
688 | + gtk_style_context_restore (context); |
689 | + |
690 | + spot_color.r = bg.red; |
691 | + spot_color.g = bg.green; |
692 | + spot_color.b = bg.blue; |
693 | + |
694 | + shade (&spot_color, &cairo->title_color[0], 1.05); |
695 | + shade (&cairo->title_color[0], &cairo->title_color[1], 0.85); |
696 | +} |
697 | + |
698 | +static void |
699 | decor_update_window_property (decor_t *d) |
700 | { |
701 | GdkDisplay *display = gdk_display_get_default (); |
702 | @@ -320,11 +511,31 @@ |
703 | } |
704 | |
705 | static void |
706 | +gwd_theme_cairo_constructed (GObject *object) |
707 | +{ |
708 | + GWDThemeCairo *cairo = GWD_THEME_CAIRO (object); |
709 | + |
710 | + G_OBJECT_CLASS (gwd_theme_cairo_parent_class)->constructed (object); |
711 | + |
712 | + update_title_colors (cairo); |
713 | +} |
714 | + |
715 | +static void |
716 | +gwd_theme_cairo_style_updated (GWDTheme *theme) |
717 | +{ |
718 | + GWDThemeCairo *cairo = GWD_THEME_CAIRO (theme); |
719 | + |
720 | + update_title_colors (cairo); |
721 | +} |
722 | + |
723 | +static void |
724 | gwd_theme_cairo_draw_window_decoration (GWDTheme *theme, |
725 | decor_t *decor) |
726 | { |
727 | + GWDThemeCairo *cairo = GWD_THEME_CAIRO (theme); |
728 | + GtkWidget *style_window = gwd_theme_get_style_window (theme); |
729 | + GtkStyleContext *context = gtk_widget_get_style_context (style_window); |
730 | cairo_t *cr; |
731 | - GtkStyleContext *context; |
732 | GdkRGBA bg, fg; |
733 | cairo_surface_t *surface; |
734 | decor_color_t color; |
735 | @@ -338,8 +549,6 @@ |
736 | if (!decor->surface) |
737 | return; |
738 | |
739 | - context = gtk_widget_get_style_context (decor->frame->style_window_rgba); |
740 | - |
741 | gtk_style_context_save (context); |
742 | gtk_style_context_set_state (context, GTK_STATE_FLAG_NORMAL); |
743 | gtk_style_context_get_background_color (context, GTK_STATE_FLAG_NORMAL, &bg); |
744 | @@ -380,7 +589,7 @@ |
745 | draw_shadow_background (decor, cr, decor->shadow, decor->context); |
746 | |
747 | if (decor->active) { |
748 | - decor_color_t *title_color = _title_color; |
749 | + decor_color_t *title_color = cairo->title_color; |
750 | |
751 | alpha = decoration_alpha + 0.3; |
752 | |
753 | @@ -848,8 +1057,12 @@ |
754 | static void |
755 | gwd_theme_cairo_class_init (GWDThemeCairoClass *cairo_class) |
756 | { |
757 | + GObjectClass *object_class = G_OBJECT_CLASS (cairo_class); |
758 | GWDThemeClass *theme_class = GWD_THEME_CLASS (cairo_class); |
759 | |
760 | + object_class->constructed = gwd_theme_cairo_constructed; |
761 | + |
762 | + theme_class->style_updated = gwd_theme_cairo_style_updated; |
763 | theme_class->draw_window_decoration = gwd_theme_cairo_draw_window_decoration; |
764 | theme_class->calc_decoration_size = gwd_theme_cairo_calc_decoration_size; |
765 | theme_class->update_border_extents = gwd_theme_cairo_update_border_extents; |
766 | |
767 | === modified file 'gtk/window-decorator/gwd-theme-metacity.c' |
768 | --- gtk/window-decorator/gwd-theme-metacity.c 2016-06-09 14:58:49 +0000 |
769 | +++ gtk/window-decorator/gwd-theme-metacity.c 2016-06-09 14:58:49 +0000 |
770 | @@ -572,14 +572,14 @@ |
771 | } |
772 | |
773 | static void |
774 | -decor_update_meta_window_property (decor_t *d, |
775 | - MetaTheme *theme, |
776 | - MetaFrameFlags flags, |
777 | - MetaFrameType type, |
778 | - Region top, |
779 | - Region bottom, |
780 | - Region left, |
781 | - Region right) |
782 | +decor_update_meta_window_property (GWDThemeMetacity *metacity, |
783 | + decor_t *d, |
784 | + MetaFrameFlags flags, |
785 | + MetaFrameType type, |
786 | + Region top, |
787 | + Region bottom, |
788 | + Region left, |
789 | + Region right) |
790 | { |
791 | long *data; |
792 | GdkDisplay *display; |
793 | @@ -616,11 +616,13 @@ |
794 | |
795 | /* Add the invisible grab area padding */ |
796 | { |
797 | - GdkScreen *screen = gtk_widget_get_screen (d->frame->style_window_rgba); |
798 | + GWDTheme *theme = GWD_THEME (metacity); |
799 | + GtkWidget *style_window = gwd_theme_get_style_window (theme); |
800 | + GdkScreen *screen = gtk_widget_get_screen (style_window); |
801 | MetaStyleInfo *style_info = meta_theme_create_style_info (screen, d->gtk_theme_variant); |
802 | MetaFrameBorders borders; |
803 | |
804 | - meta_theme_get_frame_borders (theme, style_info, type, |
805 | + meta_theme_get_frame_borders (metacity->theme, style_info, type, |
806 | d->frame->text_height, |
807 | flags, &borders); |
808 | |
809 | @@ -696,7 +698,9 @@ |
810 | MetaFrameGeometry *fgeom, |
811 | MetaFrameType frame_type) |
812 | { |
813 | - GdkScreen *screen = gtk_widget_get_screen (decor->frame->style_window_rgba); |
814 | + GWDTheme *theme = GWD_THEME (metacity); |
815 | + GtkWidget *style_window = gwd_theme_get_style_window (theme); |
816 | + GdkScreen *screen = gtk_widget_get_screen (style_window); |
817 | MetaStyleInfo *style_info = meta_theme_create_style_info (screen, decor->gtk_theme_variant); |
818 | gint client_width; |
819 | gint client_height; |
820 | @@ -936,6 +940,11 @@ |
821 | } |
822 | |
823 | static void |
824 | +gwd_theme_metacity_style_updated (GWDTheme *theme) |
825 | +{ |
826 | +} |
827 | + |
828 | +static void |
829 | gwd_theme_metacity_draw_window_decoration (GWDTheme *theme, |
830 | decor_t *decor) |
831 | { |
832 | @@ -943,9 +952,9 @@ |
833 | GWDSettings *settings = gwd_theme_get_settings (gwd_theme); |
834 | GdkDisplay *display = gdk_display_get_default (); |
835 | Display *xdisplay = gdk_x11_display_get_xdisplay (display); |
836 | - GdkScreen *screen = gtk_widget_get_screen (decor->frame->style_window_rgba); |
837 | + GtkWidget *style_window = gwd_theme_get_style_window (theme); |
838 | + GdkScreen *screen = gtk_widget_get_screen (style_window); |
839 | MetaStyleInfo *style_info = meta_theme_create_style_info (screen, decor->gtk_theme_variant); |
840 | - GtkWidget *style_window = decor->frame->style_window_rgba; |
841 | GtkStyleContext *context = gtk_widget_get_style_context (style_window); |
842 | cairo_surface_t *surface; |
843 | Picture src; |
844 | @@ -1018,7 +1027,7 @@ |
845 | |
846 | cairo_destroy (cr); |
847 | |
848 | - surface = create_surface (fgeom.width, fgeom.height, decor->frame->style_window_rgba); |
849 | + surface = create_surface (fgeom.width, fgeom.height, style_window); |
850 | |
851 | cr = cairo_create (surface); |
852 | |
853 | @@ -1096,8 +1105,7 @@ |
854 | if (left_region) |
855 | XOffsetRegion (left_region, -fgeom.borders.total.left, 0); |
856 | |
857 | - decor_update_meta_window_property (decor, metacity->theme, flags, |
858 | - frame_type, |
859 | + decor_update_meta_window_property (metacity, decor, flags, frame_type, |
860 | top_region, bottom_region, |
861 | left_region, right_region); |
862 | |
863 | @@ -1172,7 +1180,8 @@ |
864 | decor_frame_t *frame) |
865 | { |
866 | GWDThemeMetacity *metacity = GWD_THEME_METACITY (theme); |
867 | - GdkScreen *screen = gtk_widget_get_screen (frame->style_window_rgba); |
868 | + GtkWidget *style_window = gwd_theme_get_style_window (theme); |
869 | + GdkScreen *screen = gtk_widget_get_screen (style_window); |
870 | MetaStyleInfo *style_info = meta_theme_create_style_info (screen, NULL); |
871 | MetaFrameType frame_type = frame_type_from_string (frame->type); |
872 | MetaFrameBorders borders; |
873 | @@ -1414,7 +1423,8 @@ |
874 | decor_frame_t *frame) |
875 | { |
876 | GWDThemeMetacity *metacity = GWD_THEME_METACITY (theme); |
877 | - GdkScreen *screen = gtk_widget_get_screen (frame->style_window_rgba); |
878 | + GtkWidget *style_window = gwd_theme_get_style_window (theme); |
879 | + GdkScreen *screen = gtk_widget_get_screen (style_window); |
880 | MetaStyleInfo *style_info = meta_theme_create_style_info (screen, NULL); |
881 | PangoFontDescription *font_desc = meta_style_info_create_font_desc (style_info); |
882 | MetaFrameType type = frame_type_from_string (frame->type); |
883 | @@ -1436,6 +1446,7 @@ |
884 | object_class->constructed = gwd_theme_metacity_constructed; |
885 | object_class->dispose = gwd_theme_metacity_dispose; |
886 | |
887 | + theme_class->style_updated = gwd_theme_metacity_style_updated; |
888 | theme_class->draw_window_decoration = gwd_theme_metacity_draw_window_decoration; |
889 | theme_class->calc_decoration_size = gwd_theme_metacity_calc_decoration_size; |
890 | theme_class->update_border_extents = gwd_theme_metacity_update_border_extents; |
891 | |
892 | === modified file 'gtk/window-decorator/gwd-theme.c' |
893 | --- gtk/window-decorator/gwd-theme.c 2016-06-09 14:58:49 +0000 |
894 | +++ gtk/window-decorator/gwd-theme.c 2016-06-09 14:58:49 +0000 |
895 | @@ -32,6 +32,8 @@ |
896 | GWDSettings *settings; |
897 | |
898 | PangoFontDescription *titlebar_font; |
899 | + |
900 | + GtkWidget *style_window; |
901 | } GWDThemePrivate; |
902 | |
903 | enum |
904 | @@ -48,6 +50,59 @@ |
905 | G_DEFINE_TYPE_WITH_PRIVATE (GWDTheme, gwd_theme, G_TYPE_OBJECT) |
906 | |
907 | static void |
908 | +frames_update_pango_contexts (gpointer key, |
909 | + gpointer value, |
910 | + gpointer user_data) |
911 | +{ |
912 | + decor_frame_t *frame = (decor_frame_t *) value; |
913 | + GdkDisplay *display = gdk_display_get_default (); |
914 | + GdkScreen *screen = gdk_display_get_default_screen (display); |
915 | + gdouble dpi = gdk_screen_get_resolution (screen); |
916 | + |
917 | + if (frame->pango_context == NULL) |
918 | + return; |
919 | + |
920 | + /* FIXME: PangoContext created by gtk_widget_create_pango_context is not |
921 | + * automatically updated. Resolution is not only thing that can change... |
922 | + */ |
923 | + pango_cairo_context_set_resolution (frame->pango_context, dpi); |
924 | +} |
925 | + |
926 | +static void |
927 | +style_updated_cb (GtkWidget *widget, |
928 | + GWDTheme *theme) |
929 | +{ |
930 | + gwd_frames_foreach (frames_update_pango_contexts, NULL); |
931 | + |
932 | + GWD_THEME_GET_CLASS (theme)->style_updated (theme); |
933 | + |
934 | + decorations_changed (wnck_screen_get_default ()); |
935 | +} |
936 | + |
937 | +static void |
938 | +create_style_window (GWDTheme *theme) |
939 | +{ |
940 | + GWDThemePrivate *priv = gwd_theme_get_instance_private (theme); |
941 | + GdkScreen *screen = gdk_screen_get_default (); |
942 | + GdkVisual *visual = gdk_screen_get_rgba_visual (screen); |
943 | + GtkWindow *window; |
944 | + |
945 | + priv->style_window = gtk_window_new (GTK_WINDOW_POPUP); |
946 | + window = GTK_WINDOW (priv->style_window); |
947 | + |
948 | + if (visual) |
949 | + gtk_widget_set_visual (priv->style_window, visual); |
950 | + |
951 | + gtk_window_move (window, -100, -100); |
952 | + gtk_window_resize (window, 1, 1); |
953 | + |
954 | + gtk_widget_show (priv->style_window); |
955 | + |
956 | + g_signal_connect (priv->style_window, "style-updated", |
957 | + G_CALLBACK (style_updated_cb), theme); |
958 | +} |
959 | + |
960 | +static void |
961 | gwd_theme_constructed (GObject *object) |
962 | { |
963 | GWDTheme *theme = GWD_THEME (object); |
964 | @@ -55,6 +110,7 @@ |
965 | G_OBJECT_CLASS (gwd_theme_parent_class)->constructed (object); |
966 | |
967 | gwd_theme_update_titlebar_font (theme); |
968 | + create_style_window (theme); |
969 | } |
970 | |
971 | static void |
972 | @@ -68,6 +124,8 @@ |
973 | pango_font_description_free (priv->titlebar_font); |
974 | priv->titlebar_font = NULL; |
975 | |
976 | + g_clear_pointer (&priv->style_window, gtk_widget_destroy); |
977 | + |
978 | G_OBJECT_CLASS (gwd_theme_parent_class)->dispose (object); |
979 | } |
980 | |
981 | @@ -112,6 +170,11 @@ |
982 | } |
983 | |
984 | static void |
985 | +gwd_theme_real_style_updated (GWDTheme *theme) |
986 | +{ |
987 | +} |
988 | + |
989 | +static void |
990 | gwd_theme_real_get_shadow (GWDTheme *theme, |
991 | decor_frame_t *frame, |
992 | decor_shadow_options_t *options, |
993 | @@ -205,6 +268,7 @@ |
994 | object_class->get_property = gwd_theme_get_property; |
995 | object_class->set_property = gwd_theme_set_property; |
996 | |
997 | + theme_class->style_updated = gwd_theme_real_style_updated; |
998 | theme_class->get_shadow = gwd_theme_real_get_shadow; |
999 | theme_class->draw_window_decoration = gwd_theme_real_draw_window_decoration; |
1000 | theme_class->calc_decoration_size = gwd_theme_real_calc_decoration_size; |
1001 | @@ -269,6 +333,14 @@ |
1002 | return priv->settings; |
1003 | } |
1004 | |
1005 | +GtkWidget * |
1006 | +gwd_theme_get_style_window (GWDTheme *theme) |
1007 | +{ |
1008 | + GWDThemePrivate *priv = gwd_theme_get_instance_private (theme); |
1009 | + |
1010 | + return priv->style_window; |
1011 | +} |
1012 | + |
1013 | void |
1014 | gwd_theme_get_shadow (GWDTheme *theme, |
1015 | decor_frame_t *frame, |
1016 | @@ -360,7 +432,7 @@ |
1017 | { |
1018 | PangoFontDescription *font_desc = NULL; |
1019 | GWDThemePrivate *priv = gwd_theme_get_instance_private (theme); |
1020 | - GtkStyleContext *context = gtk_widget_get_style_context (frame->style_window_rgba); |
1021 | + GtkStyleContext *context = gtk_widget_get_style_context (priv->style_window); |
1022 | |
1023 | /* Check if Metacity or Cairo will create titlebar font */ |
1024 | font_desc = GWD_THEME_GET_CLASS (theme)->get_titlebar_font (theme, frame); |
1025 | |
1026 | === modified file 'gtk/window-decorator/gwd-theme.h' |
1027 | --- gtk/window-decorator/gwd-theme.h 2016-06-09 14:58:49 +0000 |
1028 | +++ gtk/window-decorator/gwd-theme.h 2016-06-09 14:58:49 +0000 |
1029 | @@ -22,7 +22,7 @@ |
1030 | |
1031 | #include <decoration.h> |
1032 | #include <glib-object.h> |
1033 | -#include <pango/pango.h> |
1034 | +#include <gtk/gtk.h> |
1035 | |
1036 | G_BEGIN_DECLS |
1037 | |
1038 | @@ -37,6 +37,8 @@ |
1039 | { |
1040 | GObjectClass parent_class; |
1041 | |
1042 | + void (* style_updated) (GWDTheme *theme); |
1043 | + |
1044 | void (* get_shadow) (GWDTheme *theme, |
1045 | decor_frame_t *frame, |
1046 | decor_shadow_options_t *options, |
1047 | @@ -97,6 +99,9 @@ |
1048 | GWDSettings * |
1049 | gwd_theme_get_settings (GWDTheme *theme); |
1050 | |
1051 | +GtkWidget * |
1052 | +gwd_theme_get_style_window (GWDTheme *theme); |
1053 | + |
1054 | void |
1055 | gwd_theme_get_shadow (GWDTheme *theme, |
1056 | decor_frame_t *frame, |
1057 | |
1058 | === modified file 'gtk/window-decorator/switcher.c' |
1059 | --- gtk/window-decorator/switcher.c 2016-06-09 14:58:49 +0000 |
1060 | +++ gtk/window-decorator/switcher.c 2016-06-09 14:58:49 +0000 |
1061 | @@ -30,18 +30,20 @@ |
1062 | static void |
1063 | decor_update_switcher_property (decor_t *d) |
1064 | { |
1065 | + GdkDisplay *display = gdk_display_get_default (); |
1066 | + Display *xdisplay = gdk_x11_display_get_xdisplay (display); |
1067 | + GtkWidget *style_window = gwd_theme_get_style_window (gwd_theme); |
1068 | + GtkStyleContext *context = gtk_widget_get_style_context (style_window); |
1069 | long *data; |
1070 | - Display *xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()); |
1071 | gint nQuad; |
1072 | decor_quad_t quads[N_QUADS_MAX]; |
1073 | unsigned int nOffset = 1; |
1074 | unsigned int frame_type = populate_frame_type (d); |
1075 | unsigned int frame_state = populate_frame_state (d); |
1076 | unsigned int frame_actions = populate_frame_actions (d); |
1077 | - GtkStyleContext *context; |
1078 | GdkRGBA fg; |
1079 | long fgColor[4]; |
1080 | - |
1081 | + |
1082 | nQuad = decor_set_lSrStSbX_window_quads (quads, &d->frame->window_context_active, |
1083 | &d->border_layout, |
1084 | d->border_layout.top.x2 - |
1085 | @@ -56,8 +58,6 @@ |
1086 | &d->frame->win_extents, &d->frame->win_extents, |
1087 | 0, 0, quads, nQuad, frame_type, frame_state, frame_actions); |
1088 | |
1089 | - context = gtk_widget_get_style_context (d->frame->style_window_rgba); |
1090 | - |
1091 | gtk_style_context_save (context); |
1092 | gtk_style_context_set_state (context, GTK_STATE_FLAG_NORMAL); |
1093 | gtk_style_context_get_color (context, GTK_STATE_FLAG_NORMAL, &fg); |
1094 | @@ -112,7 +112,6 @@ |
1095 | switcher_label = gtk_label_new (""); |
1096 | switcher_label_obj = gtk_widget_get_accessible (switcher_label); |
1097 | atk_object_set_role (switcher_label_obj, ATK_ROLE_STATUSBAR); |
1098 | - gtk_container_add (GTK_CONTAINER (frame->style_window_rgba), switcher_label); |
1099 | |
1100 | return frame; |
1101 | } |
1102 | @@ -127,9 +126,11 @@ |
1103 | static void |
1104 | draw_switcher_background (decor_t *d) |
1105 | { |
1106 | - Display *xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()); |
1107 | + GdkDisplay *display = gdk_display_get_default (); |
1108 | + Display *xdisplay = gdk_x11_display_get_xdisplay (display); |
1109 | + GtkWidget *style_window = gwd_theme_get_style_window (gwd_theme); |
1110 | + GtkStyleContext *context = gtk_widget_get_style_context (style_window); |
1111 | cairo_t *cr; |
1112 | - GtkStyleContext *context; |
1113 | GdkRGBA bg, fg; |
1114 | decor_color_t color; |
1115 | double alpha = SWITCHER_ALPHA / 65535.0; |
1116 | @@ -141,8 +142,6 @@ |
1117 | if (!d->buffer_surface) |
1118 | return; |
1119 | |
1120 | - context = gtk_widget_get_style_context (d->frame->style_window_rgba); |
1121 | - |
1122 | gtk_style_context_save (context); |
1123 | gtk_style_context_set_state (context, GTK_STATE_FLAG_NORMAL); |
1124 | gtk_style_context_get_background_color (context, GTK_STATE_FLAG_NORMAL, &bg); |
1125 | @@ -329,16 +328,15 @@ |
1126 | static void |
1127 | draw_switcher_foreground (decor_t *d) |
1128 | { |
1129 | - cairo_t *cr; |
1130 | - GtkStyleContext *context; |
1131 | + GtkWidget *style_window = gwd_theme_get_style_window (gwd_theme); |
1132 | + GtkStyleContext *context = gtk_widget_get_style_context (style_window); |
1133 | + cairo_t *cr; |
1134 | GdkRGBA bg, fg; |
1135 | double alpha = SWITCHER_ALPHA / 65535.0; |
1136 | |
1137 | if (!d->surface || !d->buffer_surface) |
1138 | return; |
1139 | |
1140 | - context = gtk_widget_get_style_context (d->frame->style_window_rgba); |
1141 | - |
1142 | gtk_style_context_save (context); |
1143 | gtk_style_context_set_state (context, GTK_STATE_FLAG_NORMAL); |
1144 | gtk_style_context_get_background_color (context, GTK_STATE_FLAG_NORMAL, &bg); |
1145 | @@ -436,24 +434,23 @@ |
1146 | return d; |
1147 | } |
1148 | |
1149 | - |
1150 | gboolean |
1151 | update_switcher_window (Window popup, |
1152 | Window selected) |
1153 | { |
1154 | + GdkDisplay *display = gdk_display_get_default (); |
1155 | + Display *xdisplay = gdk_x11_display_get_xdisplay (display); |
1156 | + GtkWidget *style_window = gwd_theme_get_style_window (gwd_theme); |
1157 | decor_t *d = switcher_window; |
1158 | cairo_surface_t *surface, *buffer_surface = NULL; |
1159 | unsigned int height, width = 0, border, depth; |
1160 | int x, y; |
1161 | Window root_return; |
1162 | WnckWindow *selected_win; |
1163 | - Display *xdisplay; |
1164 | |
1165 | if (!d) |
1166 | d = switcher_window_opened (popup, selected); |
1167 | |
1168 | - xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()); |
1169 | - |
1170 | /* FIXME: Thats a round-trip */ |
1171 | XGetGeometry (gdk_x11_get_default_xdisplay (), popup, &root_return, |
1172 | &x, &y, &width, &height, &border, &depth); |
1173 | @@ -486,8 +483,8 @@ |
1174 | if (!d->layout) |
1175 | { |
1176 | d->layout = pango_layout_new (d->frame->pango_context); |
1177 | - if (d->layout) |
1178 | - pango_layout_set_wrap (d->layout, PANGO_WRAP_CHAR); |
1179 | + |
1180 | + pango_layout_set_wrap (d->layout, PANGO_WRAP_CHAR); |
1181 | } |
1182 | |
1183 | if (d->layout) |
1184 | @@ -538,11 +535,11 @@ |
1185 | switcher_selected_window = selected; |
1186 | } |
1187 | |
1188 | - surface = create_native_surface_and_wrap (width, height, d->frame->style_window_rgba); |
1189 | + surface = create_native_surface_and_wrap (width, height, style_window); |
1190 | if (!surface) |
1191 | return FALSE; |
1192 | |
1193 | - buffer_surface = create_surface (width, height, d->frame->style_window_rgba); |
1194 | + buffer_surface = create_surface (width, height, style_window); |
1195 | if (!buffer_surface) |
1196 | { |
1197 | cairo_surface_destroy (surface); |
1198 | |
1199 | === modified file 'gtk/window-decorator/wnck.c' |
1200 | --- gtk/window-decorator/wnck.c 2016-06-09 14:58:49 +0000 |
1201 | +++ gtk/window-decorator/wnck.c 2016-06-09 14:58:49 +0000 |
1202 | @@ -170,6 +170,16 @@ |
1203 | } |
1204 | |
1205 | static void |
1206 | +update_frames_titlebar_fonts (gpointer key, |
1207 | + gpointer value, |
1208 | + gpointer user_data) |
1209 | +{ |
1210 | + decor_frame_t *frame = (decor_frame_t *) value; |
1211 | + |
1212 | + frame_update_titlebar_font (frame); |
1213 | +} |
1214 | + |
1215 | +static void |
1216 | update_frames_border_extents (gpointer key, |
1217 | gpointer value, |
1218 | gpointer user_data) |
Fine. Good a try to an offscreenwindow once you've time.