Merge lp:~muktupavels/compiz/add-gwd-application into lp:compiz/0.9.12

Proposed by Alberts Muktupāvels
Status: Work in progress
Proposed branch: lp:~muktupavels/compiz/add-gwd-application
Merge into: lp:compiz/0.9.12
Prerequisite: lp:~muktupavels/compiz/gwd-no-g-object-get-with-settings
Diff against target: 1079 lines (+378/-369)
15 files modified
gtk/window-decorator/CMakeLists.txt (+1/-2)
gtk/window-decorator/actionmenu.c (+2/-1)
gtk/window-decorator/blurprops.c (+2/-1)
gtk/window-decorator/decorator.c (+14/-9)
gtk/window-decorator/events.c (+5/-5)
gtk/window-decorator/frames.c (+7/-5)
gtk/window-decorator/gtk-window-decorator.c (+6/-28)
gtk/window-decorator/gtk-window-decorator.h (+2/-11)
gtk/window-decorator/gwd-application.c (+284/-0)
gtk/window-decorator/gwd-application.h (+49/-0)
gtk/window-decorator/gwd-settings-xproperty-storage.c (+0/-214)
gtk/window-decorator/gwd-settings-xproperty-storage.h (+0/-40)
gtk/window-decorator/gwd-theme-metacity.c (+1/-1)
gtk/window-decorator/settings.c (+0/-49)
gtk/window-decorator/wnck.c (+5/-3)
To merge this branch: bzr merge lp:~muktupavels/compiz/add-gwd-application
Reviewer Review Type Date Requested Status
Compiz Maintainers Pending
Review via email: mp+295402@code.launchpad.net
To post a comment you must log in.
4062. By Alberts Muktupāvels

Move GWDSettingsStorage to GWDApplication.

4063. By Alberts Muktupāvels

Move GWDSettingsXPropertyStorage to GWDApplication.

4064. By Alberts Muktupāvels

Remove GWDSettingsXPropertyStorage. We use it only for one function - move it to GWDApplication.

This also fixes memory leaks - shadow colors was strdup-ed, but not freed.

Unmerged revisions

4064. By Alberts Muktupāvels

Remove GWDSettingsXPropertyStorage. We use it only for one function - move it to GWDApplication.

This also fixes memory leaks - shadow colors was strdup-ed, but not freed.

4063. By Alberts Muktupāvels

Move GWDSettingsXPropertyStorage to GWDApplication.

4062. By Alberts Muktupāvels

Move GWDSettingsStorage to GWDApplication.

4061. By Alberts Muktupāvels

Add GWDApplication.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'gtk/window-decorator/CMakeLists.txt'
2--- gtk/window-decorator/CMakeLists.txt 2016-05-22 15:04:14 +0000
3+++ gtk/window-decorator/CMakeLists.txt 2016-05-22 15:04:14 +0000
4@@ -75,11 +75,10 @@
5 forcequit.c
6 tooltip.c
7 actionmenu.c
8- settings.c
9 util.c
10 wnck.c
11 decorator.c
12- ${CMAKE_CURRENT_SOURCE_DIR}/gwd-settings-xproperty-storage.c
13+ ${CMAKE_CURRENT_SOURCE_DIR}/gwd-application.c
14 ${CMAKE_CURRENT_SOURCE_DIR}/gwd-theme.c
15 ${CMAKE_CURRENT_SOURCE_DIR}/gwd-theme-cairo.c
16 ${gwd_theme_metacity}
17
18=== modified file 'gtk/window-decorator/actionmenu.c'
19--- gtk/window-decorator/actionmenu.c 2016-05-22 15:04:14 +0000
20+++ gtk/window-decorator/actionmenu.c 2016-05-22 15:04:14 +0000
21@@ -53,7 +53,8 @@
22
23 if (d->decorated)
24 {
25- if (gwd_theme_get_button_position (gwd_theme, d, BUTTON_MENU,
26+ GWDTheme *theme = gwd_application_get_theme (application);
27+ if (gwd_theme_get_button_position (theme, d, BUTTON_MENU,
28 width, height, &bx, &by,
29 &width, &height))
30 *x = *x - frame->win_extents.left + bx;
31
32=== modified file 'gtk/window-decorator/blurprops.c'
33--- gtk/window-decorator/blurprops.c 2016-05-22 15:04:14 +0000
34+++ gtk/window-decorator/blurprops.c 2016-05-22 15:04:14 +0000
35@@ -20,6 +20,7 @@
36 */
37
38 #include "gtk-window-decorator.h"
39+#include "gwd-application.h"
40 #include "gwd-settings.h"
41
42 void
43@@ -35,7 +36,7 @@
44 Region right_region,
45 int right_offset)
46 {
47- GWDSettings *settings = gwd_theme_get_settings (gwd_theme);
48+ GWDSettings *settings = gwd_application_get_settings (application);
49 gint blur_type = gwd_settings_get_blur_type (settings);
50 Display *xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
51 long *data = NULL;
52
53=== modified file 'gtk/window-decorator/decorator.c'
54--- gtk/window-decorator/decorator.c 2016-05-22 15:04:14 +0000
55+++ gtk/window-decorator/decorator.c 2016-05-22 15:04:14 +0000
56@@ -30,7 +30,8 @@
57 static void
58 draw_window_decoration (decor_t *decor)
59 {
60- gwd_theme_draw_window_decoration (gwd_theme, decor);
61+ GWDTheme *theme = gwd_application_get_theme (application);
62+ gwd_theme_draw_window_decoration (theme, decor);
63 }
64
65 void
66@@ -55,7 +56,7 @@
67 static const PangoFontDescription *
68 get_titlebar_font (decor_frame_t *frame)
69 {
70- GWDSettings *settings = gwd_theme_get_settings (gwd_theme);
71+ GWDSettings *settings = gwd_application_get_settings (application);
72 const gchar *titlebar_font = gwd_settings_get_titlebar_font (settings);
73
74 /* Using system font */
75@@ -188,6 +189,7 @@
76 void
77 update_event_windows (WnckWindow *win)
78 {
79+ GWDTheme *theme = gwd_application_get_theme (application);
80 Display *xdisplay;
81 decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
82 gint x0, y0, width, height, x, y, w, h;
83@@ -238,7 +240,7 @@
84 h = 0;
85
86 if (actions & event_window_actions[i][j] && i >= k && i <= l)
87- gwd_theme_get_event_window_position (gwd_theme, d, i, j, width, height,
88+ gwd_theme_get_event_window_position (theme, d, i, j, width, height,
89 &x, &y, &w, &h);
90
91 /* Reparenting mode - create boxes which we monitor motionnotify on */
92@@ -302,7 +304,7 @@
93 /* Reparenting mode - if there is a button position for this
94 * button then set the geometry */
95 if (d->frame_window &&
96- gwd_theme_get_button_position (gwd_theme, d, i, width, height,
97+ gwd_theme_get_button_position (theme, d, i, width, height,
98 &x, &y, &w, &h))
99 {
100 BoxPtr box = &d->button_windows[i].pos;
101@@ -314,7 +316,7 @@
102 /* Pixmap mode - if there is a button position for this button then map the window
103 * and resize it to this position */
104 else if (!d->frame_window &&
105- gwd_theme_get_button_position (gwd_theme, d, i, width, height,
106+ gwd_theme_get_button_position (theme, d, i, width, height,
107 &x, &y, &w, &h))
108 {
109 Window x11_win = d->button_windows[i].window;
110@@ -398,6 +400,7 @@
111 static void
112 update_window_decoration_name (WnckWindow *win)
113 {
114+ GWDTheme *theme = gwd_application_get_theme (application);
115 decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
116 const gchar *name;
117 glong name_length;
118@@ -416,7 +419,7 @@
119 gint w;
120
121 /* Cairo mode: w = SHRT_MAX */
122- if (!GWD_IS_THEME_CAIRO (gwd_theme))
123+ if (!GWD_IS_THEME_CAIRO (theme))
124 {
125 w = SHRT_MAX;
126 }
127@@ -519,6 +522,7 @@
128 gboolean
129 request_update_window_decoration_size (WnckWindow *win)
130 {
131+ GWDTheme *theme = gwd_application_get_theme (application);
132 decor_t *d;
133 gint width, height;
134 gint x, y, w, h, name_width;
135@@ -539,7 +543,7 @@
136
137 /* Ask the theme to tell us how much space it needs. If this is not successful
138 * update the decoration name and return false */
139- if (!gwd_theme_calc_decoration_size (gwd_theme, d, w, h, name_width, &width, &height))
140+ if (!gwd_theme_calc_decoration_size (theme, d, w, h, name_width, &width, &height))
141 {
142 update_window_decoration_name (win);
143 return FALSE;
144@@ -956,6 +960,7 @@
145 gpointer value,
146 gpointer user_data)
147 {
148+ GWDTheme *theme = gwd_application_get_theme (application);
149 decor_frame_t *frame = (decor_frame_t *) value;
150 tdtd_shadow_options_t *opts;
151 decor_shadow_options_t active_o, inactive_o;
152@@ -968,8 +973,8 @@
153 opts->active_shadow = &active_o;
154 opts->inactive_shadow = &inactive_o;
155
156- gwd_theme_get_shadow (gwd_theme, frame, opts->active_shadow, TRUE);
157- gwd_theme_get_shadow (gwd_theme, frame, opts->inactive_shadow, FALSE);
158+ gwd_theme_get_shadow (theme, frame, opts->active_shadow, TRUE);
159+ gwd_theme_get_shadow (theme, frame, opts->inactive_shadow, FALSE);
160
161 gwd_decor_frame_ref (frame);
162
163
164=== modified file 'gtk/window-decorator/events.c'
165--- gtk/window-decorator/events.c 2016-05-22 15:04:14 +0000
166+++ gtk/window-decorator/events.c 2016-05-22 15:04:14 +0000
167@@ -109,7 +109,7 @@
168 int max,
169 char *tooltip)
170 {
171- GWDSettings *settings = gwd_theme_get_settings (gwd_theme);
172+ GWDSettings *settings = gwd_application_get_settings (application);
173 gboolean use_tooltips = gwd_settings_get_use_tooltips (settings);
174 decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
175 guint state = d->button_states[button];
176@@ -456,7 +456,7 @@
177 handle_mouse_wheel_title_event (WnckWindow *win,
178 unsigned int button)
179 {
180- GWDSettings *settings = gwd_theme_get_settings (gwd_theme);
181+ GWDSettings *settings = gwd_application_get_settings (application);
182 gint wheel_action = gwd_settings_get_mouse_wheel_action (settings);
183
184 switch (wheel_action) {
185@@ -482,7 +482,7 @@
186 decor_event *gtkwd_event,
187 decor_event_type gtkwd_type)
188 {
189- GWDSettings *settings = gwd_theme_get_settings (gwd_theme);
190+ GWDSettings *settings = gwd_application_get_settings (application);
191 static Window last_button_xwindow = None;
192 static Time last_button_time = 0;
193 gint titlebar_action = 0;
194@@ -558,7 +558,7 @@
195 decor_event *gtkwd_event,
196 decor_event_type gtkwd_type)
197 {
198- GWDSettings *settings = gwd_theme_get_settings (gwd_theme);
199+ GWDSettings *settings = gwd_application_get_settings (application);
200 gint titlebar_action = 0;
201 decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
202
203@@ -1034,7 +1034,7 @@
204
205 if (screen)
206 {
207- if (gwd_process_decor_shadow_property_update ())
208+ if (gwd_application_update_shadow_property (application))
209 decorations_changed (screen);
210 }
211 }
212
213=== modified file 'gtk/window-decorator/frames.c'
214--- gtk/window-decorator/frames.c 2016-05-22 15:04:14 +0000
215+++ gtk/window-decorator/frames.c 2016-05-22 15:04:14 +0000
216@@ -264,7 +264,8 @@
217 void
218 decor_frame_refresh (decor_frame_t *frame)
219 {
220- GWDSettings *settings = gwd_theme_get_settings (gwd_theme);
221+ GWDSettings *settings = gwd_application_get_settings (application);
222+ GWDTheme *theme = gwd_application_get_theme (application);
223 const gchar *titlebar_font = gwd_settings_get_titlebar_font (settings);
224 decor_shadow_options_t active_o, inactive_o;
225 decor_shadow_info_t *info;
226@@ -281,10 +282,10 @@
227 frame_update_titlebar_font (frame);
228
229 if (strcmp (frame->type, "switcher") != 0 && strcmp (frame->type, "bare") != 0)
230- gwd_theme_update_border_extents (gwd_theme, frame);
231+ gwd_theme_update_border_extents (theme, frame);
232
233- gwd_theme_get_shadow (gwd_theme, frame, &active_o, TRUE);
234- gwd_theme_get_shadow (gwd_theme, frame, &inactive_o, FALSE);
235+ gwd_theme_get_shadow (theme, frame, &active_o, TRUE);
236+ gwd_theme_get_shadow (theme, frame, &inactive_o, FALSE);
237
238 info = malloc (sizeof (decor_shadow_info_t));
239
240@@ -556,11 +557,12 @@
241 }
242
243 if (font_str) {
244+ GWDTheme *theme = gwd_application_get_theme (application);
245 gint size;
246
247 frame->titlebar_font = pango_font_description_from_string (font_str);
248
249- scale = gwd_theme_get_title_scale (gwd_theme, frame);
250+ scale = gwd_theme_get_title_scale (theme, frame);
251 size = MAX (pango_font_description_get_size (frame->titlebar_font) * scale, 1);
252
253 pango_font_description_set_size (frame->titlebar_font, size);
254
255=== modified file 'gtk/window-decorator/gtk-window-decorator.c'
256--- gtk/window-decorator/gtk-window-decorator.c 2016-05-22 15:04:14 +0000
257+++ gtk/window-decorator/gtk-window-decorator.c 2016-05-22 15:04:14 +0000
258@@ -26,7 +26,7 @@
259 #include "gtk-window-decorator.h"
260 #include "gwd-settings.h"
261
262-GWDTheme *gwd_theme;
263+GWDApplication *application;
264
265 gdouble decoration_alpha = 0.5;
266
267@@ -147,20 +147,6 @@
268 gwd_frames_foreach (set_frames_scales, (gpointer) titlebar_font);
269 }
270
271-static void
272-update_metacity_theme_cb (GWDSettings *settings,
273- const gchar *metacity_theme,
274- gpointer user_data)
275-{
276- GWDThemeType type;
277-
278- type = GWD_THEME_TYPE_CAIRO;
279- if (metacity_theme != NULL)
280- type = GWD_THEME_TYPE_METACITY;
281-
282- g_set_object (&gwd_theme, gwd_theme_new (type, settings));
283-}
284-
285 int
286 main (int argc, char *argv[])
287 {
288@@ -306,23 +292,17 @@
289 screen = wnck_screen_get_default ();
290
291 initialize_decorations ();
292-
293- settings = gwd_settings_new (option_blur_type, option_meta_theme);
294-
295- if (!settings)
296- return 1;
297+
298+ application = gwd_application_new (option_blur_type, option_meta_theme);
299+ settings = gwd_application_get_settings (application);
300
301 g_signal_connect (settings, "update-decorations",
302 G_CALLBACK (update_decorations_cb), NULL);
303 g_signal_connect (settings, "update-frames",
304 G_CALLBACK (update_frames_cb), NULL);
305- g_signal_connect (settings, "update-metacity-theme",
306- G_CALLBACK (update_metacity_theme_cb), NULL);
307
308 gwd_settings_freeze_updates (settings);
309
310- init_settings (settings);
311-
312 for (i = 0; i < 3; ++i)
313 {
314 for (j = 0; j < 3; j++)
315@@ -340,7 +320,7 @@
316
317 if (!create_tooltip_window ())
318 {
319- g_object_unref (settings);
320+ g_object_unref (application);
321
322 fprintf (stderr, "%s, Couldn't create tooltip window\n", argv[0]);
323 return 1;
324@@ -423,9 +403,7 @@
325 gwd_decor_frame_unref (bare_p);
326 gwd_decor_frame_unref (switcher_p);
327
328- g_clear_object (&gwd_theme);
329- fini_settings ();
330- g_clear_object (&settings);
331+ g_clear_object (&application);
332
333 return 0;
334 }
335
336=== modified file 'gtk/window-decorator/gtk-window-decorator.h'
337--- gtk/window-decorator/gtk-window-decorator.h 2016-05-22 15:04:14 +0000
338+++ gtk/window-decorator/gtk-window-decorator.h 2016-05-22 15:04:14 +0000
339@@ -72,7 +72,7 @@
340 #define _(x) gettext (x)
341 #define N_(x) x
342
343-#include "gwd-theme.h"
344+#include "gwd-application.h"
345
346 extern const unsigned short ICON_SPACE;
347
348@@ -99,7 +99,7 @@
349
350 extern gboolean minimal;
351
352-extern GWDTheme *gwd_theme;
353+extern GWDApplication *application;
354
355 extern gdouble decoration_alpha;
356
357@@ -736,13 +736,4 @@
358 gpointer value,
359 gpointer user_data);
360
361-void
362-init_settings (GWDSettings *settings);
363-
364-void
365-fini_settings ();
366-
367-gboolean
368-gwd_process_decor_shadow_property_update ();
369-
370 #endif
371
372=== added file 'gtk/window-decorator/gwd-application.c'
373--- gtk/window-decorator/gwd-application.c 1970-01-01 00:00:00 +0000
374+++ gtk/window-decorator/gwd-application.c 2016-05-22 15:04:14 +0000
375@@ -0,0 +1,284 @@
376+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 4 -*- */
377+
378+/*
379+ * Copyright (C) 2016 Alberts Muktupāvels
380+ *
381+ * This program is free software; you can redistribute it and/or modify
382+ * it under the terms of the GNU General Public License as published by
383+ * the Free Software Foundation; either version 2 of the License, or
384+ * (at your option) any later version.
385+ *
386+ * This program is distributed in the hope that it will be useful,
387+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
388+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
389+ * GNU General Public License for more details.
390+ *
391+ * You should have received a copy of the GNU General Public License
392+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
393+ */
394+
395+#include "config.h"
396+
397+#include <gdk/gdk.h>
398+#include <gdk/gdkx.h>
399+#include <X11/Xatom.h>
400+#include <X11/Xlib.h>
401+
402+#include "gwd-application.h"
403+#include "gwd-settings-storage.h"
404+#include "gwd-theme.h"
405+
406+struct _GWDApplication
407+{
408+ GObject parent;
409+
410+ gint blur_type;
411+ gchar *metacity_theme;
412+
413+ GWDSettings *settings;
414+ GWDSettingsStorage *storage;
415+
416+ GWDTheme *theme;
417+};
418+
419+enum
420+{
421+ PROP_0,
422+
423+ PROP_BLUR_TYPE,
424+ PROP_METACITY_THEME,
425+
426+ LAST_PROP
427+};
428+
429+static GParamSpec *properties[LAST_PROP] = { NULL };
430+
431+G_DEFINE_TYPE (GWDApplication, gwd_application, G_TYPE_OBJECT)
432+
433+static void
434+update_metacity_theme_cb (GWDSettings *settings,
435+ const gchar *metacity_theme,
436+ GWDApplication *application)
437+{
438+ GWDThemeType type = GWD_THEME_TYPE_CAIRO;
439+
440+ if (metacity_theme != NULL)
441+ type = GWD_THEME_TYPE_METACITY;
442+
443+ g_set_object (&application->theme, gwd_theme_new (type, settings));
444+}
445+
446+static void
447+gwd_application_constructed (GObject *object)
448+{
449+ GWDApplication *application = GWD_APPLICATION (object);
450+
451+ G_OBJECT_CLASS (gwd_application_parent_class)->constructed (object);
452+
453+ application->settings = gwd_settings_new (application->blur_type,
454+ application->metacity_theme);
455+
456+ g_signal_connect (application->settings, "update-metacity-theme",
457+ G_CALLBACK (update_metacity_theme_cb), application);
458+
459+ application->storage = gwd_settings_storage_new (application->settings);
460+
461+ gwd_application_update_shadow_property (application);
462+}
463+
464+static void
465+gwd_application_dispose (GObject *object)
466+{
467+ GWDApplication *application = GWD_APPLICATION (object);
468+
469+ g_clear_object (&application->settings);
470+ g_clear_object (&application->storage);
471+
472+ g_clear_object (&application->theme);
473+
474+ G_OBJECT_CLASS (gwd_application_parent_class)->dispose (object);
475+}
476+
477+static void
478+gwd_application_finalize (GObject *object)
479+{
480+ GWDApplication *application = GWD_APPLICATION (object);
481+
482+ g_clear_pointer (&application->metacity_theme, g_free);
483+
484+ G_OBJECT_CLASS (gwd_application_parent_class)->finalize (object);
485+}
486+
487+static void
488+gwd_application_set_property (GObject *object,
489+ guint property_id,
490+ const GValue *value,
491+ GParamSpec *pspec)
492+{
493+ GWDApplication *application = GWD_APPLICATION (object);
494+
495+ switch (property_id) {
496+ case PROP_BLUR_TYPE:
497+ application->blur_type = g_value_get_int (value);
498+ break;
499+
500+ case PROP_METACITY_THEME:
501+ application->metacity_theme = g_value_dup_string (value);
502+ break;
503+
504+ default:
505+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
506+ break;
507+ }
508+}
509+
510+static void
511+gwd_application_class_init (GWDApplicationClass *application_class)
512+{
513+ GObjectClass *object_class = G_OBJECT_CLASS (application_class);
514+
515+ object_class->constructed = gwd_application_constructed;
516+ object_class->dispose = gwd_application_dispose;
517+ object_class->finalize = gwd_application_finalize;
518+ object_class->set_property = gwd_application_set_property;
519+
520+ properties[PROP_BLUR_TYPE] =
521+ g_param_spec_int ("blur-type",
522+ "Blur Type",
523+ "Blur type",
524+ BLUR_TYPE_UNSET, BLUR_TYPE_ALL, BLUR_TYPE_UNSET,
525+ G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
526+ G_PARAM_STATIC_STRINGS);
527+
528+ properties[PROP_METACITY_THEME] =
529+ g_param_spec_string ("metacity-theme",
530+ "Metacity Theme",
531+ "Metacity Theme",
532+ NULL,
533+ G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
534+ G_PARAM_STATIC_STRINGS);
535+
536+ g_object_class_install_properties (object_class, LAST_PROP, properties);
537+}
538+
539+static void
540+gwd_application_init (GWDApplication *application)
541+{
542+}
543+
544+GWDApplication *
545+gwd_application_new (gint blur_type,
546+ const gchar *metacity_theme)
547+{
548+ return g_object_new (GWD_TYPE_APPLICATION,
549+ "blur-type", blur_type,
550+ "metacity-theme", metacity_theme,
551+ NULL);
552+}
553+
554+GWDSettings *
555+gwd_application_get_settings (GWDApplication *application)
556+{
557+ return application->settings;
558+}
559+
560+GWDTheme *
561+gwd_application_get_theme (GWDApplication *application)
562+{
563+ return application->theme;
564+}
565+
566+gboolean
567+gwd_application_update_shadow_property (GWDApplication *application)
568+{
569+ GdkDisplay *display = gdk_display_get_default ();
570+ Display *xdisplay = gdk_x11_display_get_xdisplay (display);
571+ Window xroot = gdk_x11_get_default_root_xwindow ();
572+ gdouble active_radius, inactive_radius;
573+ gdouble active_opacity, inactive_opacity;
574+ gdouble active_x_offset, inactive_x_offset;
575+ gdouble active_y_offset, inactive_y_offset;
576+ gchar *active_color, *inactive_color;
577+ gboolean retval;
578+
579+ {
580+ Atom shadow_properties = XInternAtom (xdisplay, "_COMPIZ_NET_CM_SHADOW_PROPERTIES", False);
581+ gint result, format;
582+ Atom actual;
583+ gulong n, left;
584+ guchar *properties_data;
585+ glong *properties;
586+
587+ result = XGetWindowProperty (xdisplay, xroot, shadow_properties,
588+ 0, 32768, 0, XA_INTEGER,
589+ &actual, &format, &n, &left,
590+ &properties_data);
591+
592+ if (result != Success || n != 8) {
593+ if (properties_data != NULL)
594+ XFree (properties_data);
595+
596+ return FALSE;
597+ }
598+
599+ properties = (glong *) properties_data;
600+
601+ /* Radius and Opacity are multiplied by 1000 to keep precision,
602+ * divide by that much to get our real radius and opacity.
603+ */
604+
605+ active_radius = MAX (0.0, MIN (properties[0] / 1000.0, 48.0));
606+ active_opacity = MAX (0.0, MIN (properties[1] / 1000.0, 6.0));
607+ active_x_offset = MAX (-16, MIN (properties[2], 16));
608+ active_y_offset = MAX (-16, MIN (properties[3], 16));
609+
610+ inactive_radius = MAX (0.0, MIN (properties[4] / 1000.0, 48.0));
611+ inactive_opacity = MAX (0.0, MIN (properties[5] / 1000.0, 6.0));
612+ inactive_x_offset = MAX (-16, MIN (properties[6], 16));
613+ inactive_y_offset = MAX (-16, MIN (properties[7], 16));
614+
615+ XFree (properties_data);
616+ }
617+
618+ {
619+ Atom shadow_color = XInternAtom (xdisplay, "_COMPIZ_NET_CM_SHADOW_COLOR", False);
620+ XTextProperty color_data;
621+ gint result, n;
622+ gchar **color;
623+
624+ result = XGetTextProperty (xdisplay, xroot, &color_data, shadow_color);
625+ if (result == 0)
626+ return FALSE;
627+
628+ result = XTextPropertyToStringList (&color_data, &color, &n);
629+ if (result == 0 || n != 2) {
630+ if (color_data.value != NULL)
631+ XFree (color_data.value);
632+
633+ return FALSE;
634+ }
635+
636+ active_color = g_strdup (color[0]);
637+ inactive_color = g_strdup (color[1]);
638+
639+ XFree (color_data.value);
640+ XFreeStringList (color);
641+ }
642+
643+ retval = gwd_settings_shadow_property_changed (application->settings,
644+ active_radius,
645+ active_opacity,
646+ active_x_offset,
647+ active_y_offset,
648+ active_color,
649+ inactive_radius,
650+ inactive_opacity,
651+ inactive_x_offset,
652+ inactive_y_offset,
653+ inactive_color);
654+
655+ g_free (active_color);
656+ g_free (inactive_color);
657+
658+ return retval;
659+}
660
661=== added file 'gtk/window-decorator/gwd-application.h'
662--- gtk/window-decorator/gwd-application.h 1970-01-01 00:00:00 +0000
663+++ gtk/window-decorator/gwd-application.h 2016-05-22 15:04:14 +0000
664@@ -0,0 +1,49 @@
665+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 4 -*- */
666+
667+/*
668+ * Copyright (C) 2016 Alberts Muktupāvels
669+ *
670+ * This program is free software; you can redistribute it and/or modify
671+ * it under the terms of the GNU General Public License as published by
672+ * the Free Software Foundation; either version 2 of the License, or
673+ * (at your option) any later version.
674+ *
675+ * This program is distributed in the hope that it will be useful,
676+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
677+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
678+ * GNU General Public License for more details.
679+ *
680+ * You should have received a copy of the GNU General Public License
681+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
682+ */
683+
684+#ifndef GWD_APPLICATION_H
685+#define GWD_APPLICATION_H
686+
687+#include <glib-object.h>
688+
689+#include "gwd-settings.h"
690+#include "gwd-theme.h"
691+
692+G_BEGIN_DECLS
693+
694+#define GWD_TYPE_APPLICATION gwd_application_get_type ()
695+G_DECLARE_FINAL_TYPE (GWDApplication, gwd_application,
696+ GWD, APPLICATION, GObject)
697+
698+GWDApplication *
699+gwd_application_new (gint blur_type,
700+ const gchar *metacity_theme);
701+
702+GWDSettings *
703+gwd_application_get_settings (GWDApplication *application);
704+
705+GWDTheme *
706+gwd_application_get_theme (GWDApplication *application);
707+
708+gboolean
709+gwd_application_update_shadow_property (GWDApplication *application);
710+
711+G_END_DECLS
712+
713+#endif
714
715=== removed file 'gtk/window-decorator/gwd-settings-xproperty-storage.c'
716--- gtk/window-decorator/gwd-settings-xproperty-storage.c 2016-05-22 15:04:14 +0000
717+++ gtk/window-decorator/gwd-settings-xproperty-storage.c 1970-01-01 00:00:00 +0000
718@@ -1,214 +0,0 @@
719-/*
720- * Copyright © 2012 Canonical Ltd
721- *
722- * This program is free software; you can redistribute it and/or modify
723- * it under the terms of the GNU General Public License as published by
724- * the Free Software Foundation; either version 2 of the License, or
725- * (at your option) any later version.
726- *
727- * This program is distributed in the hope that it will be useful,
728- * but WITHOUT ANY WARRANTY; without even the implied warranty of
729- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
730- * GNU General Public License for more details.
731- *
732- * You should have received a copy of the GNU General Public License
733- * along with this program; if not, write to the Free Software Foundation,
734- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
735- *
736- * Authored By: Sam Spilsbury <sam.spilsbury@canonical.com>
737- */
738-
739-#include <glib-object.h>
740-#include <string.h>
741-
742-#include "gtk-window-decorator.h"
743-#include "gwd-settings.h"
744-#include "gwd-settings-xproperty-storage.h"
745-
746-struct _GWDSettingsXPropertyStorage
747-{
748- GObject parent;
749-
750- GWDSettings *settings;
751-
752- Display *xdpy;
753- Window root;
754-};
755-
756-enum
757-{
758- PROP_0,
759-
760- PROP_SETTINGS,
761-
762- LAST_PROP
763-};
764-
765-static GParamSpec *storage_properties[LAST_PROP] = { NULL };
766-
767-G_DEFINE_TYPE (GWDSettingsXPropertyStorage, gwd_settings_xproperty_storage,
768- G_TYPE_OBJECT)
769-
770-static void
771-gwd_settings_xproperty_storage_dispose (GObject *object)
772-{
773- GWDSettingsXPropertyStorage *storage;
774-
775- storage = GWD_SETTINGS_XPROPERTY_STORAGE (object);
776-
777- g_clear_object (&storage->settings);
778-
779- G_OBJECT_CLASS (gwd_settings_xproperty_storage_parent_class)->dispose (object);
780-}
781-
782-static void
783-gwd_settings_xproperty_storage_set_property (GObject *object,
784- guint property_id,
785- const GValue *value,
786- GParamSpec *pspec)
787-{
788- GWDSettingsXPropertyStorage *storage;
789-
790- storage = GWD_SETTINGS_XPROPERTY_STORAGE (object);
791-
792- switch (property_id) {
793- case PROP_SETTINGS:
794- g_return_if_fail (!storage->settings);
795- storage->settings = g_value_dup_object (value);
796- break;
797-
798- default:
799- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
800- break;
801- }
802-}
803-
804-static void
805-gwd_settings_xproperty_storage_class_init (GWDSettingsXPropertyStorageClass *klass)
806-{
807- GObjectClass *object_class;
808-
809- object_class = G_OBJECT_CLASS (klass);
810-
811- object_class->dispose = gwd_settings_xproperty_storage_dispose;
812- object_class->set_property = gwd_settings_xproperty_storage_set_property;
813-
814- storage_properties[PROP_SETTINGS] =
815- g_param_spec_object ("settings", "GWDSettings", "GWDSettings",
816- GWD_TYPE_SETTINGS,
817- G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE |
818- G_PARAM_STATIC_STRINGS);
819-
820- g_object_class_install_properties (object_class, LAST_PROP,
821- storage_properties);
822-}
823-
824-static void
825-gwd_settings_xproperty_storage_init (GWDSettingsXPropertyStorage *storage)
826-{
827- GdkDisplay *display;
828-
829- display = gdk_display_get_default ();
830-
831- storage->xdpy = gdk_x11_display_get_xdisplay (display);
832- storage->root = gdk_x11_get_default_root_xwindow ();
833-}
834-
835-GWDSettingsXPropertyStorage *
836-gwd_settings_xproperty_storage_new (GWDSettings *settings)
837-{
838- return g_object_new (GWD_TYPE_SETTINGS_XPROPERTY_STORAGE,
839- "settings", settings,
840- NULL);
841-}
842-
843-gboolean
844-gwd_settings_xproperty_storage_update_all (GWDSettingsXPropertyStorage *storage)
845-{
846- Atom actual;
847- int result, format;
848- unsigned long n, left;
849- unsigned char *prop_data;
850- XTextProperty shadow_color_xtp;
851-
852- gdouble aradius;
853- gdouble aopacity;
854- gint ax_off;
855- gint ay_off;
856- char *active_shadow_color = NULL;
857-
858- gdouble iradius;
859- gdouble iopacity;
860- gint ix_off;
861- gint iy_off;
862- char *inactive_shadow_color = NULL;
863-
864- result = XGetWindowProperty (storage->xdpy, storage->root,
865- compiz_shadow_info_atom, 0, 32768, 0,
866- XA_INTEGER, &actual, &format,
867- &n, &left, &prop_data);
868-
869- if (result != Success)
870- return FALSE;
871-
872- if (n == 8) {
873- long *data = (long *) prop_data;
874- aradius = data[0];
875- aopacity = data[1];
876- ax_off = data[2];
877- ay_off = data[3];
878-
879- iradius = data[4];
880- iopacity = data[5];
881- ix_off = data[6];
882- iy_off = data[7];
883-
884- /* Radius and Opacity are multiplied by 1000 to keep precision,
885- * divide by that much to get our real radius and opacity
886- */
887- aradius /= 1000;
888- aopacity /= 1000;
889- iradius /= 1000;
890- iopacity /= 1000;
891-
892- XFree (prop_data);
893- } else {
894- XFree (prop_data);
895- return FALSE;
896- }
897-
898- result = XGetTextProperty (storage->xdpy, storage->root,
899- &shadow_color_xtp, compiz_shadow_color_atom);
900-
901- if (shadow_color_xtp.value) {
902- int ret_count = 0;
903- char **t_data = NULL;
904-
905- XTextPropertyToStringList (&shadow_color_xtp, &t_data, &ret_count);
906-
907- if (ret_count == 2) {
908- active_shadow_color = strdup (t_data[0]);
909- inactive_shadow_color = strdup (t_data[1]);
910-
911- if (t_data)
912- XFreeStringList (t_data);
913-
914- XFree (shadow_color_xtp.value);
915- } else {
916- XFree (shadow_color_xtp.value);
917- return FALSE;
918- }
919- }
920-
921- return gwd_settings_shadow_property_changed (storage->settings,
922- (gdouble) MAX (0.0, MIN (aradius, 48.0)),
923- (gdouble) MAX (0.0, MIN (aopacity, 6.0)),
924- (gdouble) MAX (-16, MIN (ax_off, 16)),
925- (gdouble) MAX (-16, MIN (ay_off, 16)),
926- active_shadow_color,
927- (gdouble) MAX (0.0, MIN (iradius, 48.0)),
928- (gdouble) MAX (0.0, MIN (iopacity, 6.0)),
929- (gdouble) MAX (-16, MIN (ix_off, 16)),
930- (gdouble) MAX (-16, MIN (iy_off, 16)),
931- inactive_shadow_color);
932-}
933
934=== removed file 'gtk/window-decorator/gwd-settings-xproperty-storage.h'
935--- gtk/window-decorator/gwd-settings-xproperty-storage.h 2016-05-22 15:04:14 +0000
936+++ gtk/window-decorator/gwd-settings-xproperty-storage.h 1970-01-01 00:00:00 +0000
937@@ -1,40 +0,0 @@
938-/*
939- * Copyright © 2012 Canonical Ltd
940- *
941- * This program is free software; you can redistribute it and/or modify
942- * it under the terms of the GNU General Public License as published by
943- * the Free Software Foundation; either version 2 of the License, or
944- * (at your option) any later version.
945- *
946- * This program is distributed in the hope that it will be useful,
947- * but WITHOUT ANY WARRANTY; without even the implied warranty of
948- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
949- * GNU General Public License for more details.
950- *
951- * You should have received a copy of the GNU General Public License
952- * along with this program; if not, write to the Free Software Foundation,
953- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
954- *
955- * Authored By: Sam Spilsbury <sam.spilsbury@canonical.com>
956- */
957-
958-#ifndef GWD_SETTINGS_XPROPERTY_STORAGE_H
959-#define GWD_SETTINGS_XPROPERTY_STORAGE_H
960-
961-#include "gwd-settings.h"
962-
963-G_BEGIN_DECLS
964-
965-#define GWD_TYPE_SETTINGS_XPROPERTY_STORAGE gwd_settings_xproperty_storage_get_type ()
966-G_DECLARE_FINAL_TYPE (GWDSettingsXPropertyStorage, gwd_settings_xproperty_storage,
967- GWD, SETTINGS_XPROPERTY_STORAGE, GObject)
968-
969-GWDSettingsXPropertyStorage *
970-gwd_settings_xproperty_storage_new (GWDSettings *settings);
971-
972-gboolean
973-gwd_settings_xproperty_storage_update_all (GWDSettingsXPropertyStorage *storage);
974-
975-G_END_DECLS
976-
977-#endif
978
979=== modified file 'gtk/window-decorator/gwd-theme-metacity.c'
980--- gtk/window-decorator/gwd-theme-metacity.c 2016-05-22 15:04:14 +0000
981+++ gtk/window-decorator/gwd-theme-metacity.c 2016-05-22 15:04:14 +0000
982@@ -923,7 +923,7 @@
983 decor_t *decor)
984 {
985 GWDThemeMetacity *metacity = GWD_THEME_METACITY (theme);
986- GWDSettings *settings = gwd_theme_get_settings (gwd_theme);
987+ GWDSettings *settings = gwd_theme_get_settings (theme);
988 GdkDisplay *display;
989 GdkScreen *screen;
990 Display *xdisplay;
991
992=== removed file 'gtk/window-decorator/settings.c'
993--- gtk/window-decorator/settings.c 2016-05-22 15:04:14 +0000
994+++ gtk/window-decorator/settings.c 1970-01-01 00:00:00 +0000
995@@ -1,49 +0,0 @@
996-/*
997- * Copyright © 2006 Novell, Inc.
998- *
999- * This library is free software; you can redistribute it and/or
1000- * modify it under the terms of the GNU Lesser General Public
1001- * License as published by the Free Software Foundation; either
1002- * version 2 of the License, or (at your option) any later version.
1003- *
1004- * This library is distributed in the hope that it will be useful,
1005- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1006- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1007- * Lesser General Public License for more details.
1008- *
1009- * You should have received a copy of the GNU Lesser General Public
1010- * License along with this library; if not, write to the
1011- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
1012- * Boston, MA 02111-1307, USA.
1013- *
1014- * Author: David Reveman <davidr@novell.com>
1015- */
1016-
1017-#include "gtk-window-decorator.h"
1018-#include "gwd-settings-storage.h"
1019-#include "gwd-settings-xproperty-storage.h"
1020-
1021-GWDSettingsStorage *storage = NULL;
1022-GWDSettingsXPropertyStorage *xprop_storage = NULL;
1023-
1024-void
1025-init_settings (GWDSettings *settings)
1026-{
1027- storage = gwd_settings_storage_new (settings);
1028- xprop_storage = gwd_settings_xproperty_storage_new (settings);
1029-
1030- gwd_process_decor_shadow_property_update ();
1031-}
1032-
1033-void
1034-fini_settings ()
1035-{
1036- g_clear_object (&storage);
1037- g_clear_object (&xprop_storage);
1038-}
1039-
1040-gboolean
1041-gwd_process_decor_shadow_property_update ()
1042-{
1043- return gwd_settings_xproperty_storage_update_all (xprop_storage);
1044-}
1045
1046=== modified file 'gtk/window-decorator/wnck.c'
1047--- gtk/window-decorator/wnck.c 2016-05-22 15:04:14 +0000
1048+++ gtk/window-decorator/wnck.c 2016-05-22 15:04:14 +0000
1049@@ -29,7 +29,8 @@
1050 static void
1051 draw_window_decoration (decor_t *decor)
1052 {
1053- gwd_theme_draw_window_decoration (gwd_theme, decor);
1054+ GWDTheme *theme = gwd_application_get_theme (application);
1055+ gwd_theme_draw_window_decoration (theme, decor);
1056 }
1057
1058 const gchar *
1059@@ -174,9 +175,10 @@
1060 gpointer value,
1061 gpointer user_data)
1062 {
1063+ GWDTheme *theme = gwd_application_get_theme (application);
1064 decor_frame_t *frame = (decor_frame_t *) value;
1065
1066- gwd_theme_update_border_extents (gwd_theme, frame);
1067+ gwd_theme_update_border_extents (theme, frame);
1068 }
1069
1070 void
1071@@ -190,7 +192,7 @@
1072 gdkdisplay = gdk_display_get_default ();
1073 gdkscreen = gdk_display_get_default_screen (gdkdisplay);
1074
1075- GWDSettings *settings = gwd_theme_get_settings (gwd_theme);
1076+ GWDSettings *settings = gwd_application_get_settings (application);
1077 const gchar *titlebar_font = gwd_settings_get_titlebar_font (settings);
1078
1079 gwd_frames_foreach (set_frames_scales, (gpointer) titlebar_font);

Subscribers

People subscribed via source and target branches