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