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
=== modified file 'gtk/window-decorator/CMakeLists.txt'
--- gtk/window-decorator/CMakeLists.txt 2016-05-22 15:04:14 +0000
+++ gtk/window-decorator/CMakeLists.txt 2016-05-22 15:04:14 +0000
@@ -75,11 +75,10 @@
75 forcequit.c75 forcequit.c
76 tooltip.c76 tooltip.c
77 actionmenu.c77 actionmenu.c
78 settings.c
79 util.c78 util.c
80 wnck.c79 wnck.c
81 decorator.c80 decorator.c
82 ${CMAKE_CURRENT_SOURCE_DIR}/gwd-settings-xproperty-storage.c81 ${CMAKE_CURRENT_SOURCE_DIR}/gwd-application.c
83 ${CMAKE_CURRENT_SOURCE_DIR}/gwd-theme.c82 ${CMAKE_CURRENT_SOURCE_DIR}/gwd-theme.c
84 ${CMAKE_CURRENT_SOURCE_DIR}/gwd-theme-cairo.c83 ${CMAKE_CURRENT_SOURCE_DIR}/gwd-theme-cairo.c
85 ${gwd_theme_metacity}84 ${gwd_theme_metacity}
8685
=== modified file 'gtk/window-decorator/actionmenu.c'
--- gtk/window-decorator/actionmenu.c 2016-05-22 15:04:14 +0000
+++ gtk/window-decorator/actionmenu.c 2016-05-22 15:04:14 +0000
@@ -53,7 +53,8 @@
5353
54 if (d->decorated)54 if (d->decorated)
55 {55 {
56 if (gwd_theme_get_button_position (gwd_theme, d, BUTTON_MENU,56 GWDTheme *theme = gwd_application_get_theme (application);
57 if (gwd_theme_get_button_position (theme, d, BUTTON_MENU,
57 width, height, &bx, &by,58 width, height, &bx, &by,
58 &width, &height))59 &width, &height))
59 *x = *x - frame->win_extents.left + bx;60 *x = *x - frame->win_extents.left + bx;
6061
=== modified file 'gtk/window-decorator/blurprops.c'
--- gtk/window-decorator/blurprops.c 2016-05-22 15:04:14 +0000
+++ gtk/window-decorator/blurprops.c 2016-05-22 15:04:14 +0000
@@ -20,6 +20,7 @@
20 */20 */
2121
22#include "gtk-window-decorator.h"22#include "gtk-window-decorator.h"
23#include "gwd-application.h"
23#include "gwd-settings.h"24#include "gwd-settings.h"
2425
25void26void
@@ -35,7 +36,7 @@
35 Region right_region,36 Region right_region,
36 int right_offset)37 int right_offset)
37{38{
38 GWDSettings *settings = gwd_theme_get_settings (gwd_theme);39 GWDSettings *settings = gwd_application_get_settings (application);
39 gint blur_type = gwd_settings_get_blur_type (settings);40 gint blur_type = gwd_settings_get_blur_type (settings);
40 Display *xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());41 Display *xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
41 long *data = NULL;42 long *data = NULL;
4243
=== modified file 'gtk/window-decorator/decorator.c'
--- gtk/window-decorator/decorator.c 2016-05-22 15:04:14 +0000
+++ gtk/window-decorator/decorator.c 2016-05-22 15:04:14 +0000
@@ -30,7 +30,8 @@
30static void30static void
31draw_window_decoration (decor_t *decor)31draw_window_decoration (decor_t *decor)
32{32{
33 gwd_theme_draw_window_decoration (gwd_theme, decor);33 GWDTheme *theme = gwd_application_get_theme (application);
34 gwd_theme_draw_window_decoration (theme, decor);
34}35}
3536
36void37void
@@ -55,7 +56,7 @@
55static const PangoFontDescription *56static const PangoFontDescription *
56get_titlebar_font (decor_frame_t *frame)57get_titlebar_font (decor_frame_t *frame)
57{58{
58 GWDSettings *settings = gwd_theme_get_settings (gwd_theme);59 GWDSettings *settings = gwd_application_get_settings (application);
59 const gchar *titlebar_font = gwd_settings_get_titlebar_font (settings);60 const gchar *titlebar_font = gwd_settings_get_titlebar_font (settings);
6061
61 /* Using system font */62 /* Using system font */
@@ -188,6 +189,7 @@
188void189void
189update_event_windows (WnckWindow *win)190update_event_windows (WnckWindow *win)
190{191{
192 GWDTheme *theme = gwd_application_get_theme (application);
191 Display *xdisplay;193 Display *xdisplay;
192 decor_t *d = g_object_get_data (G_OBJECT (win), "decor");194 decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
193 gint x0, y0, width, height, x, y, w, h;195 gint x0, y0, width, height, x, y, w, h;
@@ -238,7 +240,7 @@
238 h = 0;240 h = 0;
239241
240 if (actions & event_window_actions[i][j] && i >= k && i <= l)242 if (actions & event_window_actions[i][j] && i >= k && i <= l)
241 gwd_theme_get_event_window_position (gwd_theme, d, i, j, width, height,243 gwd_theme_get_event_window_position (theme, d, i, j, width, height,
242 &x, &y, &w, &h);244 &x, &y, &w, &h);
243245
244 /* Reparenting mode - create boxes which we monitor motionnotify on */246 /* Reparenting mode - create boxes which we monitor motionnotify on */
@@ -302,7 +304,7 @@
302 /* Reparenting mode - if there is a button position for this304 /* Reparenting mode - if there is a button position for this
303 * button then set the geometry */305 * button then set the geometry */
304 if (d->frame_window &&306 if (d->frame_window &&
305 gwd_theme_get_button_position (gwd_theme, d, i, width, height,307 gwd_theme_get_button_position (theme, d, i, width, height,
306 &x, &y, &w, &h))308 &x, &y, &w, &h))
307 {309 {
308 BoxPtr box = &d->button_windows[i].pos;310 BoxPtr box = &d->button_windows[i].pos;
@@ -314,7 +316,7 @@
314 /* Pixmap mode - if there is a button position for this button then map the window316 /* Pixmap mode - if there is a button position for this button then map the window
315 * and resize it to this position */317 * and resize it to this position */
316 else if (!d->frame_window &&318 else if (!d->frame_window &&
317 gwd_theme_get_button_position (gwd_theme, d, i, width, height,319 gwd_theme_get_button_position (theme, d, i, width, height,
318 &x, &y, &w, &h))320 &x, &y, &w, &h))
319 {321 {
320 Window x11_win = d->button_windows[i].window;322 Window x11_win = d->button_windows[i].window;
@@ -398,6 +400,7 @@
398static void400static void
399update_window_decoration_name (WnckWindow *win)401update_window_decoration_name (WnckWindow *win)
400{402{
403 GWDTheme *theme = gwd_application_get_theme (application);
401 decor_t *d = g_object_get_data (G_OBJECT (win), "decor");404 decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
402 const gchar *name;405 const gchar *name;
403 glong name_length;406 glong name_length;
@@ -416,7 +419,7 @@
416 gint w;419 gint w;
417420
418 /* Cairo mode: w = SHRT_MAX */421 /* Cairo mode: w = SHRT_MAX */
419 if (!GWD_IS_THEME_CAIRO (gwd_theme))422 if (!GWD_IS_THEME_CAIRO (theme))
420 {423 {
421 w = SHRT_MAX;424 w = SHRT_MAX;
422 }425 }
@@ -519,6 +522,7 @@
519gboolean522gboolean
520request_update_window_decoration_size (WnckWindow *win)523request_update_window_decoration_size (WnckWindow *win)
521{524{
525 GWDTheme *theme = gwd_application_get_theme (application);
522 decor_t *d;526 decor_t *d;
523 gint width, height;527 gint width, height;
524 gint x, y, w, h, name_width;528 gint x, y, w, h, name_width;
@@ -539,7 +543,7 @@
539543
540 /* Ask the theme to tell us how much space it needs. If this is not successful544 /* Ask the theme to tell us how much space it needs. If this is not successful
541 * update the decoration name and return false */545 * update the decoration name and return false */
542 if (!gwd_theme_calc_decoration_size (gwd_theme, d, w, h, name_width, &width, &height))546 if (!gwd_theme_calc_decoration_size (theme, d, w, h, name_width, &width, &height))
543 {547 {
544 update_window_decoration_name (win);548 update_window_decoration_name (win);
545 return FALSE;549 return FALSE;
@@ -956,6 +960,7 @@
956 gpointer value,960 gpointer value,
957 gpointer user_data)961 gpointer user_data)
958{962{
963 GWDTheme *theme = gwd_application_get_theme (application);
959 decor_frame_t *frame = (decor_frame_t *) value;964 decor_frame_t *frame = (decor_frame_t *) value;
960 tdtd_shadow_options_t *opts;965 tdtd_shadow_options_t *opts;
961 decor_shadow_options_t active_o, inactive_o;966 decor_shadow_options_t active_o, inactive_o;
@@ -968,8 +973,8 @@
968 opts->active_shadow = &active_o;973 opts->active_shadow = &active_o;
969 opts->inactive_shadow = &inactive_o;974 opts->inactive_shadow = &inactive_o;
970975
971 gwd_theme_get_shadow (gwd_theme, frame, opts->active_shadow, TRUE);976 gwd_theme_get_shadow (theme, frame, opts->active_shadow, TRUE);
972 gwd_theme_get_shadow (gwd_theme, frame, opts->inactive_shadow, FALSE);977 gwd_theme_get_shadow (theme, frame, opts->inactive_shadow, FALSE);
973978
974 gwd_decor_frame_ref (frame);979 gwd_decor_frame_ref (frame);
975980
976981
=== modified file 'gtk/window-decorator/events.c'
--- gtk/window-decorator/events.c 2016-05-22 15:04:14 +0000
+++ gtk/window-decorator/events.c 2016-05-22 15:04:14 +0000
@@ -109,7 +109,7 @@
109 int max,109 int max,
110 char *tooltip)110 char *tooltip)
111{111{
112 GWDSettings *settings = gwd_theme_get_settings (gwd_theme);112 GWDSettings *settings = gwd_application_get_settings (application);
113 gboolean use_tooltips = gwd_settings_get_use_tooltips (settings);113 gboolean use_tooltips = gwd_settings_get_use_tooltips (settings);
114 decor_t *d = g_object_get_data (G_OBJECT (win), "decor");114 decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
115 guint state = d->button_states[button];115 guint state = d->button_states[button];
@@ -456,7 +456,7 @@
456handle_mouse_wheel_title_event (WnckWindow *win,456handle_mouse_wheel_title_event (WnckWindow *win,
457 unsigned int button)457 unsigned int button)
458{458{
459 GWDSettings *settings = gwd_theme_get_settings (gwd_theme);459 GWDSettings *settings = gwd_application_get_settings (application);
460 gint wheel_action = gwd_settings_get_mouse_wheel_action (settings);460 gint wheel_action = gwd_settings_get_mouse_wheel_action (settings);
461461
462 switch (wheel_action) {462 switch (wheel_action) {
@@ -482,7 +482,7 @@
482 decor_event *gtkwd_event,482 decor_event *gtkwd_event,
483 decor_event_type gtkwd_type)483 decor_event_type gtkwd_type)
484{484{
485 GWDSettings *settings = gwd_theme_get_settings (gwd_theme);485 GWDSettings *settings = gwd_application_get_settings (application);
486 static Window last_button_xwindow = None;486 static Window last_button_xwindow = None;
487 static Time last_button_time = 0;487 static Time last_button_time = 0;
488 gint titlebar_action = 0;488 gint titlebar_action = 0;
@@ -558,7 +558,7 @@
558 decor_event *gtkwd_event,558 decor_event *gtkwd_event,
559 decor_event_type gtkwd_type)559 decor_event_type gtkwd_type)
560{560{
561 GWDSettings *settings = gwd_theme_get_settings (gwd_theme);561 GWDSettings *settings = gwd_application_get_settings (application);
562 gint titlebar_action = 0;562 gint titlebar_action = 0;
563 decor_t *d = g_object_get_data (G_OBJECT (win), "decor");563 decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
564564
@@ -1034,7 +1034,7 @@
10341034
1035 if (screen)1035 if (screen)
1036 {1036 {
1037 if (gwd_process_decor_shadow_property_update ())1037 if (gwd_application_update_shadow_property (application))
1038 decorations_changed (screen);1038 decorations_changed (screen);
1039 }1039 }
1040 }1040 }
10411041
=== modified file 'gtk/window-decorator/frames.c'
--- gtk/window-decorator/frames.c 2016-05-22 15:04:14 +0000
+++ gtk/window-decorator/frames.c 2016-05-22 15:04:14 +0000
@@ -264,7 +264,8 @@
264void264void
265decor_frame_refresh (decor_frame_t *frame)265decor_frame_refresh (decor_frame_t *frame)
266{266{
267 GWDSettings *settings = gwd_theme_get_settings (gwd_theme);267 GWDSettings *settings = gwd_application_get_settings (application);
268 GWDTheme *theme = gwd_application_get_theme (application);
268 const gchar *titlebar_font = gwd_settings_get_titlebar_font (settings);269 const gchar *titlebar_font = gwd_settings_get_titlebar_font (settings);
269 decor_shadow_options_t active_o, inactive_o;270 decor_shadow_options_t active_o, inactive_o;
270 decor_shadow_info_t *info;271 decor_shadow_info_t *info;
@@ -281,10 +282,10 @@
281 frame_update_titlebar_font (frame);282 frame_update_titlebar_font (frame);
282283
283 if (strcmp (frame->type, "switcher") != 0 && strcmp (frame->type, "bare") != 0)284 if (strcmp (frame->type, "switcher") != 0 && strcmp (frame->type, "bare") != 0)
284 gwd_theme_update_border_extents (gwd_theme, frame);285 gwd_theme_update_border_extents (theme, frame);
285286
286 gwd_theme_get_shadow (gwd_theme, frame, &active_o, TRUE);287 gwd_theme_get_shadow (theme, frame, &active_o, TRUE);
287 gwd_theme_get_shadow (gwd_theme, frame, &inactive_o, FALSE);288 gwd_theme_get_shadow (theme, frame, &inactive_o, FALSE);
288289
289 info = malloc (sizeof (decor_shadow_info_t));290 info = malloc (sizeof (decor_shadow_info_t));
290291
@@ -556,11 +557,12 @@
556 }557 }
557558
558 if (font_str) {559 if (font_str) {
560 GWDTheme *theme = gwd_application_get_theme (application);
559 gint size;561 gint size;
560562
561 frame->titlebar_font = pango_font_description_from_string (font_str);563 frame->titlebar_font = pango_font_description_from_string (font_str);
562564
563 scale = gwd_theme_get_title_scale (gwd_theme, frame);565 scale = gwd_theme_get_title_scale (theme, frame);
564 size = MAX (pango_font_description_get_size (frame->titlebar_font) * scale, 1);566 size = MAX (pango_font_description_get_size (frame->titlebar_font) * scale, 1);
565567
566 pango_font_description_set_size (frame->titlebar_font, size);568 pango_font_description_set_size (frame->titlebar_font, size);
567569
=== modified file 'gtk/window-decorator/gtk-window-decorator.c'
--- gtk/window-decorator/gtk-window-decorator.c 2016-05-22 15:04:14 +0000
+++ gtk/window-decorator/gtk-window-decorator.c 2016-05-22 15:04:14 +0000
@@ -26,7 +26,7 @@
26#include "gtk-window-decorator.h"26#include "gtk-window-decorator.h"
27#include "gwd-settings.h"27#include "gwd-settings.h"
2828
29GWDTheme *gwd_theme;29GWDApplication *application;
3030
31gdouble decoration_alpha = 0.5;31gdouble decoration_alpha = 0.5;
3232
@@ -147,20 +147,6 @@
147 gwd_frames_foreach (set_frames_scales, (gpointer) titlebar_font);147 gwd_frames_foreach (set_frames_scales, (gpointer) titlebar_font);
148}148}
149149
150static void
151update_metacity_theme_cb (GWDSettings *settings,
152 const gchar *metacity_theme,
153 gpointer user_data)
154{
155 GWDThemeType type;
156
157 type = GWD_THEME_TYPE_CAIRO;
158 if (metacity_theme != NULL)
159 type = GWD_THEME_TYPE_METACITY;
160
161 g_set_object (&gwd_theme, gwd_theme_new (type, settings));
162}
163
164int150int
165main (int argc, char *argv[])151main (int argc, char *argv[])
166{152{
@@ -306,23 +292,17 @@
306 screen = wnck_screen_get_default ();292 screen = wnck_screen_get_default ();
307293
308 initialize_decorations ();294 initialize_decorations ();
309295
310 settings = gwd_settings_new (option_blur_type, option_meta_theme);296 application = gwd_application_new (option_blur_type, option_meta_theme);
311297 settings = gwd_application_get_settings (application);
312 if (!settings)
313 return 1;
314298
315 g_signal_connect (settings, "update-decorations",299 g_signal_connect (settings, "update-decorations",
316 G_CALLBACK (update_decorations_cb), NULL);300 G_CALLBACK (update_decorations_cb), NULL);
317 g_signal_connect (settings, "update-frames",301 g_signal_connect (settings, "update-frames",
318 G_CALLBACK (update_frames_cb), NULL);302 G_CALLBACK (update_frames_cb), NULL);
319 g_signal_connect (settings, "update-metacity-theme",
320 G_CALLBACK (update_metacity_theme_cb), NULL);
321303
322 gwd_settings_freeze_updates (settings);304 gwd_settings_freeze_updates (settings);
323305
324 init_settings (settings);
325
326 for (i = 0; i < 3; ++i)306 for (i = 0; i < 3; ++i)
327 {307 {
328 for (j = 0; j < 3; j++)308 for (j = 0; j < 3; j++)
@@ -340,7 +320,7 @@
340320
341 if (!create_tooltip_window ())321 if (!create_tooltip_window ())
342 {322 {
343 g_object_unref (settings);323 g_object_unref (application);
344324
345 fprintf (stderr, "%s, Couldn't create tooltip window\n", argv[0]);325 fprintf (stderr, "%s, Couldn't create tooltip window\n", argv[0]);
346 return 1;326 return 1;
@@ -423,9 +403,7 @@
423 gwd_decor_frame_unref (bare_p);403 gwd_decor_frame_unref (bare_p);
424 gwd_decor_frame_unref (switcher_p);404 gwd_decor_frame_unref (switcher_p);
425405
426 g_clear_object (&gwd_theme);406 g_clear_object (&application);
427 fini_settings ();
428 g_clear_object (&settings);
429407
430 return 0;408 return 0;
431}409}
432410
=== modified file 'gtk/window-decorator/gtk-window-decorator.h'
--- gtk/window-decorator/gtk-window-decorator.h 2016-05-22 15:04:14 +0000
+++ gtk/window-decorator/gtk-window-decorator.h 2016-05-22 15:04:14 +0000
@@ -72,7 +72,7 @@
72#define _(x) gettext (x)72#define _(x) gettext (x)
73#define N_(x) x73#define N_(x) x
7474
75#include "gwd-theme.h"75#include "gwd-application.h"
7676
77extern const unsigned short ICON_SPACE;77extern const unsigned short ICON_SPACE;
7878
@@ -99,7 +99,7 @@
9999
100extern gboolean minimal;100extern gboolean minimal;
101101
102extern GWDTheme *gwd_theme;102extern GWDApplication *application;
103103
104extern gdouble decoration_alpha;104extern gdouble decoration_alpha;
105105
@@ -736,13 +736,4 @@
736 gpointer value,736 gpointer value,
737 gpointer user_data);737 gpointer user_data);
738738
739void
740init_settings (GWDSettings *settings);
741
742void
743fini_settings ();
744
745gboolean
746gwd_process_decor_shadow_property_update ();
747
748#endif739#endif
749740
=== added file 'gtk/window-decorator/gwd-application.c'
--- gtk/window-decorator/gwd-application.c 1970-01-01 00:00:00 +0000
+++ gtk/window-decorator/gwd-application.c 2016-05-22 15:04:14 +0000
@@ -0,0 +1,284 @@
1/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 4 -*- */
2
3/*
4 * Copyright (C) 2016 Alberts Muktupāvels
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include "config.h"
21
22#include <gdk/gdk.h>
23#include <gdk/gdkx.h>
24#include <X11/Xatom.h>
25#include <X11/Xlib.h>
26
27#include "gwd-application.h"
28#include "gwd-settings-storage.h"
29#include "gwd-theme.h"
30
31struct _GWDApplication
32{
33 GObject parent;
34
35 gint blur_type;
36 gchar *metacity_theme;
37
38 GWDSettings *settings;
39 GWDSettingsStorage *storage;
40
41 GWDTheme *theme;
42};
43
44enum
45{
46 PROP_0,
47
48 PROP_BLUR_TYPE,
49 PROP_METACITY_THEME,
50
51 LAST_PROP
52};
53
54static GParamSpec *properties[LAST_PROP] = { NULL };
55
56G_DEFINE_TYPE (GWDApplication, gwd_application, G_TYPE_OBJECT)
57
58static void
59update_metacity_theme_cb (GWDSettings *settings,
60 const gchar *metacity_theme,
61 GWDApplication *application)
62{
63 GWDThemeType type = GWD_THEME_TYPE_CAIRO;
64
65 if (metacity_theme != NULL)
66 type = GWD_THEME_TYPE_METACITY;
67
68 g_set_object (&application->theme, gwd_theme_new (type, settings));
69}
70
71static void
72gwd_application_constructed (GObject *object)
73{
74 GWDApplication *application = GWD_APPLICATION (object);
75
76 G_OBJECT_CLASS (gwd_application_parent_class)->constructed (object);
77
78 application->settings = gwd_settings_new (application->blur_type,
79 application->metacity_theme);
80
81 g_signal_connect (application->settings, "update-metacity-theme",
82 G_CALLBACK (update_metacity_theme_cb), application);
83
84 application->storage = gwd_settings_storage_new (application->settings);
85
86 gwd_application_update_shadow_property (application);
87}
88
89static void
90gwd_application_dispose (GObject *object)
91{
92 GWDApplication *application = GWD_APPLICATION (object);
93
94 g_clear_object (&application->settings);
95 g_clear_object (&application->storage);
96
97 g_clear_object (&application->theme);
98
99 G_OBJECT_CLASS (gwd_application_parent_class)->dispose (object);
100}
101
102static void
103gwd_application_finalize (GObject *object)
104{
105 GWDApplication *application = GWD_APPLICATION (object);
106
107 g_clear_pointer (&application->metacity_theme, g_free);
108
109 G_OBJECT_CLASS (gwd_application_parent_class)->finalize (object);
110}
111
112static void
113gwd_application_set_property (GObject *object,
114 guint property_id,
115 const GValue *value,
116 GParamSpec *pspec)
117{
118 GWDApplication *application = GWD_APPLICATION (object);
119
120 switch (property_id) {
121 case PROP_BLUR_TYPE:
122 application->blur_type = g_value_get_int (value);
123 break;
124
125 case PROP_METACITY_THEME:
126 application->metacity_theme = g_value_dup_string (value);
127 break;
128
129 default:
130 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
131 break;
132 }
133}
134
135static void
136gwd_application_class_init (GWDApplicationClass *application_class)
137{
138 GObjectClass *object_class = G_OBJECT_CLASS (application_class);
139
140 object_class->constructed = gwd_application_constructed;
141 object_class->dispose = gwd_application_dispose;
142 object_class->finalize = gwd_application_finalize;
143 object_class->set_property = gwd_application_set_property;
144
145 properties[PROP_BLUR_TYPE] =
146 g_param_spec_int ("blur-type",
147 "Blur Type",
148 "Blur type",
149 BLUR_TYPE_UNSET, BLUR_TYPE_ALL, BLUR_TYPE_UNSET,
150 G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
151 G_PARAM_STATIC_STRINGS);
152
153 properties[PROP_METACITY_THEME] =
154 g_param_spec_string ("metacity-theme",
155 "Metacity Theme",
156 "Metacity Theme",
157 NULL,
158 G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
159 G_PARAM_STATIC_STRINGS);
160
161 g_object_class_install_properties (object_class, LAST_PROP, properties);
162}
163
164static void
165gwd_application_init (GWDApplication *application)
166{
167}
168
169GWDApplication *
170gwd_application_new (gint blur_type,
171 const gchar *metacity_theme)
172{
173 return g_object_new (GWD_TYPE_APPLICATION,
174 "blur-type", blur_type,
175 "metacity-theme", metacity_theme,
176 NULL);
177}
178
179GWDSettings *
180gwd_application_get_settings (GWDApplication *application)
181{
182 return application->settings;
183}
184
185GWDTheme *
186gwd_application_get_theme (GWDApplication *application)
187{
188 return application->theme;
189}
190
191gboolean
192gwd_application_update_shadow_property (GWDApplication *application)
193{
194 GdkDisplay *display = gdk_display_get_default ();
195 Display *xdisplay = gdk_x11_display_get_xdisplay (display);
196 Window xroot = gdk_x11_get_default_root_xwindow ();
197 gdouble active_radius, inactive_radius;
198 gdouble active_opacity, inactive_opacity;
199 gdouble active_x_offset, inactive_x_offset;
200 gdouble active_y_offset, inactive_y_offset;
201 gchar *active_color, *inactive_color;
202 gboolean retval;
203
204 {
205 Atom shadow_properties = XInternAtom (xdisplay, "_COMPIZ_NET_CM_SHADOW_PROPERTIES", False);
206 gint result, format;
207 Atom actual;
208 gulong n, left;
209 guchar *properties_data;
210 glong *properties;
211
212 result = XGetWindowProperty (xdisplay, xroot, shadow_properties,
213 0, 32768, 0, XA_INTEGER,
214 &actual, &format, &n, &left,
215 &properties_data);
216
217 if (result != Success || n != 8) {
218 if (properties_data != NULL)
219 XFree (properties_data);
220
221 return FALSE;
222 }
223
224 properties = (glong *) properties_data;
225
226 /* Radius and Opacity are multiplied by 1000 to keep precision,
227 * divide by that much to get our real radius and opacity.
228 */
229
230 active_radius = MAX (0.0, MIN (properties[0] / 1000.0, 48.0));
231 active_opacity = MAX (0.0, MIN (properties[1] / 1000.0, 6.0));
232 active_x_offset = MAX (-16, MIN (properties[2], 16));
233 active_y_offset = MAX (-16, MIN (properties[3], 16));
234
235 inactive_radius = MAX (0.0, MIN (properties[4] / 1000.0, 48.0));
236 inactive_opacity = MAX (0.0, MIN (properties[5] / 1000.0, 6.0));
237 inactive_x_offset = MAX (-16, MIN (properties[6], 16));
238 inactive_y_offset = MAX (-16, MIN (properties[7], 16));
239
240 XFree (properties_data);
241 }
242
243 {
244 Atom shadow_color = XInternAtom (xdisplay, "_COMPIZ_NET_CM_SHADOW_COLOR", False);
245 XTextProperty color_data;
246 gint result, n;
247 gchar **color;
248
249 result = XGetTextProperty (xdisplay, xroot, &color_data, shadow_color);
250 if (result == 0)
251 return FALSE;
252
253 result = XTextPropertyToStringList (&color_data, &color, &n);
254 if (result == 0 || n != 2) {
255 if (color_data.value != NULL)
256 XFree (color_data.value);
257
258 return FALSE;
259 }
260
261 active_color = g_strdup (color[0]);
262 inactive_color = g_strdup (color[1]);
263
264 XFree (color_data.value);
265 XFreeStringList (color);
266 }
267
268 retval = gwd_settings_shadow_property_changed (application->settings,
269 active_radius,
270 active_opacity,
271 active_x_offset,
272 active_y_offset,
273 active_color,
274 inactive_radius,
275 inactive_opacity,
276 inactive_x_offset,
277 inactive_y_offset,
278 inactive_color);
279
280 g_free (active_color);
281 g_free (inactive_color);
282
283 return retval;
284}
0285
=== added file 'gtk/window-decorator/gwd-application.h'
--- gtk/window-decorator/gwd-application.h 1970-01-01 00:00:00 +0000
+++ gtk/window-decorator/gwd-application.h 2016-05-22 15:04:14 +0000
@@ -0,0 +1,49 @@
1/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 4 -*- */
2
3/*
4 * Copyright (C) 2016 Alberts Muktupāvels
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef GWD_APPLICATION_H
21#define GWD_APPLICATION_H
22
23#include <glib-object.h>
24
25#include "gwd-settings.h"
26#include "gwd-theme.h"
27
28G_BEGIN_DECLS
29
30#define GWD_TYPE_APPLICATION gwd_application_get_type ()
31G_DECLARE_FINAL_TYPE (GWDApplication, gwd_application,
32 GWD, APPLICATION, GObject)
33
34GWDApplication *
35gwd_application_new (gint blur_type,
36 const gchar *metacity_theme);
37
38GWDSettings *
39gwd_application_get_settings (GWDApplication *application);
40
41GWDTheme *
42gwd_application_get_theme (GWDApplication *application);
43
44gboolean
45gwd_application_update_shadow_property (GWDApplication *application);
46
47G_END_DECLS
48
49#endif
050
=== removed file 'gtk/window-decorator/gwd-settings-xproperty-storage.c'
--- gtk/window-decorator/gwd-settings-xproperty-storage.c 2016-05-22 15:04:14 +0000
+++ gtk/window-decorator/gwd-settings-xproperty-storage.c 1970-01-01 00:00:00 +0000
@@ -1,214 +0,0 @@
1/*
2 * Copyright © 2012 Canonical Ltd
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 *
18 * Authored By: Sam Spilsbury <sam.spilsbury@canonical.com>
19 */
20
21#include <glib-object.h>
22#include <string.h>
23
24#include "gtk-window-decorator.h"
25#include "gwd-settings.h"
26#include "gwd-settings-xproperty-storage.h"
27
28struct _GWDSettingsXPropertyStorage
29{
30 GObject parent;
31
32 GWDSettings *settings;
33
34 Display *xdpy;
35 Window root;
36};
37
38enum
39{
40 PROP_0,
41
42 PROP_SETTINGS,
43
44 LAST_PROP
45};
46
47static GParamSpec *storage_properties[LAST_PROP] = { NULL };
48
49G_DEFINE_TYPE (GWDSettingsXPropertyStorage, gwd_settings_xproperty_storage,
50 G_TYPE_OBJECT)
51
52static void
53gwd_settings_xproperty_storage_dispose (GObject *object)
54{
55 GWDSettingsXPropertyStorage *storage;
56
57 storage = GWD_SETTINGS_XPROPERTY_STORAGE (object);
58
59 g_clear_object (&storage->settings);
60
61 G_OBJECT_CLASS (gwd_settings_xproperty_storage_parent_class)->dispose (object);
62}
63
64static void
65gwd_settings_xproperty_storage_set_property (GObject *object,
66 guint property_id,
67 const GValue *value,
68 GParamSpec *pspec)
69{
70 GWDSettingsXPropertyStorage *storage;
71
72 storage = GWD_SETTINGS_XPROPERTY_STORAGE (object);
73
74 switch (property_id) {
75 case PROP_SETTINGS:
76 g_return_if_fail (!storage->settings);
77 storage->settings = g_value_dup_object (value);
78 break;
79
80 default:
81 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
82 break;
83 }
84}
85
86static void
87gwd_settings_xproperty_storage_class_init (GWDSettingsXPropertyStorageClass *klass)
88{
89 GObjectClass *object_class;
90
91 object_class = G_OBJECT_CLASS (klass);
92
93 object_class->dispose = gwd_settings_xproperty_storage_dispose;
94 object_class->set_property = gwd_settings_xproperty_storage_set_property;
95
96 storage_properties[PROP_SETTINGS] =
97 g_param_spec_object ("settings", "GWDSettings", "GWDSettings",
98 GWD_TYPE_SETTINGS,
99 G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE |
100 G_PARAM_STATIC_STRINGS);
101
102 g_object_class_install_properties (object_class, LAST_PROP,
103 storage_properties);
104}
105
106static void
107gwd_settings_xproperty_storage_init (GWDSettingsXPropertyStorage *storage)
108{
109 GdkDisplay *display;
110
111 display = gdk_display_get_default ();
112
113 storage->xdpy = gdk_x11_display_get_xdisplay (display);
114 storage->root = gdk_x11_get_default_root_xwindow ();
115}
116
117GWDSettingsXPropertyStorage *
118gwd_settings_xproperty_storage_new (GWDSettings *settings)
119{
120 return g_object_new (GWD_TYPE_SETTINGS_XPROPERTY_STORAGE,
121 "settings", settings,
122 NULL);
123}
124
125gboolean
126gwd_settings_xproperty_storage_update_all (GWDSettingsXPropertyStorage *storage)
127{
128 Atom actual;
129 int result, format;
130 unsigned long n, left;
131 unsigned char *prop_data;
132 XTextProperty shadow_color_xtp;
133
134 gdouble aradius;
135 gdouble aopacity;
136 gint ax_off;
137 gint ay_off;
138 char *active_shadow_color = NULL;
139
140 gdouble iradius;
141 gdouble iopacity;
142 gint ix_off;
143 gint iy_off;
144 char *inactive_shadow_color = NULL;
145
146 result = XGetWindowProperty (storage->xdpy, storage->root,
147 compiz_shadow_info_atom, 0, 32768, 0,
148 XA_INTEGER, &actual, &format,
149 &n, &left, &prop_data);
150
151 if (result != Success)
152 return FALSE;
153
154 if (n == 8) {
155 long *data = (long *) prop_data;
156 aradius = data[0];
157 aopacity = data[1];
158 ax_off = data[2];
159 ay_off = data[3];
160
161 iradius = data[4];
162 iopacity = data[5];
163 ix_off = data[6];
164 iy_off = data[7];
165
166 /* Radius and Opacity are multiplied by 1000 to keep precision,
167 * divide by that much to get our real radius and opacity
168 */
169 aradius /= 1000;
170 aopacity /= 1000;
171 iradius /= 1000;
172 iopacity /= 1000;
173
174 XFree (prop_data);
175 } else {
176 XFree (prop_data);
177 return FALSE;
178 }
179
180 result = XGetTextProperty (storage->xdpy, storage->root,
181 &shadow_color_xtp, compiz_shadow_color_atom);
182
183 if (shadow_color_xtp.value) {
184 int ret_count = 0;
185 char **t_data = NULL;
186
187 XTextPropertyToStringList (&shadow_color_xtp, &t_data, &ret_count);
188
189 if (ret_count == 2) {
190 active_shadow_color = strdup (t_data[0]);
191 inactive_shadow_color = strdup (t_data[1]);
192
193 if (t_data)
194 XFreeStringList (t_data);
195
196 XFree (shadow_color_xtp.value);
197 } else {
198 XFree (shadow_color_xtp.value);
199 return FALSE;
200 }
201 }
202
203 return gwd_settings_shadow_property_changed (storage->settings,
204 (gdouble) MAX (0.0, MIN (aradius, 48.0)),
205 (gdouble) MAX (0.0, MIN (aopacity, 6.0)),
206 (gdouble) MAX (-16, MIN (ax_off, 16)),
207 (gdouble) MAX (-16, MIN (ay_off, 16)),
208 active_shadow_color,
209 (gdouble) MAX (0.0, MIN (iradius, 48.0)),
210 (gdouble) MAX (0.0, MIN (iopacity, 6.0)),
211 (gdouble) MAX (-16, MIN (ix_off, 16)),
212 (gdouble) MAX (-16, MIN (iy_off, 16)),
213 inactive_shadow_color);
214}
2150
=== removed file 'gtk/window-decorator/gwd-settings-xproperty-storage.h'
--- gtk/window-decorator/gwd-settings-xproperty-storage.h 2016-05-22 15:04:14 +0000
+++ gtk/window-decorator/gwd-settings-xproperty-storage.h 1970-01-01 00:00:00 +0000
@@ -1,40 +0,0 @@
1/*
2 * Copyright © 2012 Canonical Ltd
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 *
18 * Authored By: Sam Spilsbury <sam.spilsbury@canonical.com>
19 */
20
21#ifndef GWD_SETTINGS_XPROPERTY_STORAGE_H
22#define GWD_SETTINGS_XPROPERTY_STORAGE_H
23
24#include "gwd-settings.h"
25
26G_BEGIN_DECLS
27
28#define GWD_TYPE_SETTINGS_XPROPERTY_STORAGE gwd_settings_xproperty_storage_get_type ()
29G_DECLARE_FINAL_TYPE (GWDSettingsXPropertyStorage, gwd_settings_xproperty_storage,
30 GWD, SETTINGS_XPROPERTY_STORAGE, GObject)
31
32GWDSettingsXPropertyStorage *
33gwd_settings_xproperty_storage_new (GWDSettings *settings);
34
35gboolean
36gwd_settings_xproperty_storage_update_all (GWDSettingsXPropertyStorage *storage);
37
38G_END_DECLS
39
40#endif
410
=== modified file 'gtk/window-decorator/gwd-theme-metacity.c'
--- gtk/window-decorator/gwd-theme-metacity.c 2016-05-22 15:04:14 +0000
+++ gtk/window-decorator/gwd-theme-metacity.c 2016-05-22 15:04:14 +0000
@@ -923,7 +923,7 @@
923 decor_t *decor)923 decor_t *decor)
924{924{
925 GWDThemeMetacity *metacity = GWD_THEME_METACITY (theme);925 GWDThemeMetacity *metacity = GWD_THEME_METACITY (theme);
926 GWDSettings *settings = gwd_theme_get_settings (gwd_theme);926 GWDSettings *settings = gwd_theme_get_settings (theme);
927 GdkDisplay *display;927 GdkDisplay *display;
928 GdkScreen *screen;928 GdkScreen *screen;
929 Display *xdisplay;929 Display *xdisplay;
930930
=== removed file 'gtk/window-decorator/settings.c'
--- gtk/window-decorator/settings.c 2016-05-22 15:04:14 +0000
+++ gtk/window-decorator/settings.c 1970-01-01 00:00:00 +0000
@@ -1,49 +0,0 @@
1/*
2 * Copyright © 2006 Novell, Inc.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 *
19 * Author: David Reveman <davidr@novell.com>
20 */
21
22#include "gtk-window-decorator.h"
23#include "gwd-settings-storage.h"
24#include "gwd-settings-xproperty-storage.h"
25
26GWDSettingsStorage *storage = NULL;
27GWDSettingsXPropertyStorage *xprop_storage = NULL;
28
29void
30init_settings (GWDSettings *settings)
31{
32 storage = gwd_settings_storage_new (settings);
33 xprop_storage = gwd_settings_xproperty_storage_new (settings);
34
35 gwd_process_decor_shadow_property_update ();
36}
37
38void
39fini_settings ()
40{
41 g_clear_object (&storage);
42 g_clear_object (&xprop_storage);
43}
44
45gboolean
46gwd_process_decor_shadow_property_update ()
47{
48 return gwd_settings_xproperty_storage_update_all (xprop_storage);
49}
500
=== modified file 'gtk/window-decorator/wnck.c'
--- gtk/window-decorator/wnck.c 2016-05-22 15:04:14 +0000
+++ gtk/window-decorator/wnck.c 2016-05-22 15:04:14 +0000
@@ -29,7 +29,8 @@
29static void29static void
30draw_window_decoration (decor_t *decor)30draw_window_decoration (decor_t *decor)
31{31{
32 gwd_theme_draw_window_decoration (gwd_theme, decor);32 GWDTheme *theme = gwd_application_get_theme (application);
33 gwd_theme_draw_window_decoration (theme, decor);
33}34}
3435
35const gchar *36const gchar *
@@ -174,9 +175,10 @@
174 gpointer value,175 gpointer value,
175 gpointer user_data)176 gpointer user_data)
176{177{
178 GWDTheme *theme = gwd_application_get_theme (application);
177 decor_frame_t *frame = (decor_frame_t *) value;179 decor_frame_t *frame = (decor_frame_t *) value;
178180
179 gwd_theme_update_border_extents (gwd_theme, frame);181 gwd_theme_update_border_extents (theme, frame);
180}182}
181183
182void184void
@@ -190,7 +192,7 @@
190 gdkdisplay = gdk_display_get_default ();192 gdkdisplay = gdk_display_get_default ();
191 gdkscreen = gdk_display_get_default_screen (gdkdisplay);193 gdkscreen = gdk_display_get_default_screen (gdkdisplay);
192194
193 GWDSettings *settings = gwd_theme_get_settings (gwd_theme);195 GWDSettings *settings = gwd_application_get_settings (application);
194 const gchar *titlebar_font = gwd_settings_get_titlebar_font (settings);196 const gchar *titlebar_font = gwd_settings_get_titlebar_font (settings);
195197
196 gwd_frames_foreach (set_frames_scales, (gpointer) titlebar_font);198 gwd_frames_foreach (set_frames_scales, (gpointer) titlebar_font);

Subscribers

People subscribed via source and target branches