Merge lp:~sil2100/compiz-core/cherry_rev3137 into lp:compiz-core
- cherry_rev3137
- Merge into 0.9.7
Status: | Merged |
---|---|
Merged at revision: | 3103 |
Proposed branch: | lp:~sil2100/compiz-core/cherry_rev3137 |
Merge into: | lp:compiz-core |
Diff against target: |
1474 lines (+856/-67) 15 files modified
gtk/window-decorator/decorator.c (+55/-25) gtk/window-decorator/events.c (+12/-1) gtk/window-decorator/gtk-window-decorator.c (+9/-0) gtk/window-decorator/gtk-window-decorator.h (+8/-0) gtk/window-decorator/wnck.c (+13/-11) include/decoration.h (+18/-0) libdecoration/decoration.c (+86/-0) plugins/decor/CMakeLists.txt (+3/-1) plugins/decor/src/decor.cpp (+99/-22) plugins/decor/src/decor.h (+35/-7) plugins/decor/src/pixmap-requests/CMakeLists.txt (+62/-0) plugins/decor/src/pixmap-requests/include/pixmap-requests.h (+188/-0) plugins/decor/src/pixmap-requests/src/pixmap-requests.cpp (+93/-0) plugins/decor/src/pixmap-requests/tests/CMakeLists.txt (+15/-0) plugins/decor/src/pixmap-requests/tests/pixmap-requests/src/test-decor-pixmap-requests.cpp (+160/-0) |
To merge this branch: | bzr merge lp:~sil2100/compiz-core/cherry_rev3137 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Daniel van Vugt | Approve | ||
Review via email: mp+110572@code.launchpad.net |
Description of the change
Cherry picked from 0.9.8 branch:
Add synchronization primitives to the decoration protocol so that there isn't a race where we bind a texture that's being freed.
Things changed
* update_
* decor_post_pending : tells the decorated process that a new decoration is pending
* decor_post_request : tells the decorator that a new pixmap can be drawn to
* decor_post_
I also did some necessary refactoring so we could get this under test, namely:
DecorPixmap class (implements DecorPixmapInte
X11DecorPixmapR
X11DecorPixmapR
X11PixmapDeletor class (implements DecorPixmapDele
DecorationListF
DecorationInter
Tests included (Google Mock)
Resubmitted to cover a potential race condition in LP#996901
Daniel van Vugt (vanvugt) wrote : | # |
Łukasz Zemczak (sil2100) wrote : | # |
Good question, it seems they actually might. So hm, this cherry-pick might not be entirely safe. Daniel - could you somehow mark bug-fixes in bug reports which break the ABI? This would make picking changes for SRUs much easier.
Daniel van Vugt (vanvugt) wrote : | # |
Yes, we're meant to update abiversion.h so it should be easy to tell. But people often forget :(
Daniel van Vugt (vanvugt) wrote : | # |
It works and the bugs appear fixed.
I can't run the test cases for some reason, but that's not caused by this proposal in particular. See bug 1014957.
Preview Diff
1 | === modified file 'gtk/window-decorator/decorator.c' | |||
2 | --- gtk/window-decorator/decorator.c 2012-03-30 07:01:48 +0000 | |||
3 | +++ gtk/window-decorator/decorator.c 2012-06-15 17:09:21 +0000 | |||
4 | @@ -564,6 +564,52 @@ | |||
5 | 564 | } | 564 | } |
6 | 565 | } | 565 | } |
7 | 566 | 566 | ||
8 | 567 | /* | ||
9 | 568 | * request_update_window_decoration_size | ||
10 | 569 | * Description: asks the rendering process to allow a size update | ||
11 | 570 | * for pixmap synchronization */ | ||
12 | 571 | |||
13 | 572 | |||
14 | 573 | gboolean | ||
15 | 574 | request_update_window_decoration_size (WnckWindow *win) | ||
16 | 575 | { | ||
17 | 576 | decor_t *d; | ||
18 | 577 | gint width, height; | ||
19 | 578 | gint x, y, w, h, name_width; | ||
20 | 579 | |||
21 | 580 | if (win == NULL) | ||
22 | 581 | return FALSE; | ||
23 | 582 | |||
24 | 583 | d = g_object_get_data (G_OBJECT (win), "decor"); | ||
25 | 584 | |||
26 | 585 | if (!d->decorated) | ||
27 | 586 | return FALSE; | ||
28 | 587 | |||
29 | 588 | /* Get the geometry of the window, we'll need it later */ | ||
30 | 589 | wnck_window_get_client_window_geometry (win, &x, &y, &w, &h); | ||
31 | 590 | |||
32 | 591 | /* Get the width of the name */ | ||
33 | 592 | name_width = max_window_name_width (win); | ||
34 | 593 | |||
35 | 594 | /* Ask the theme to tell us how much space it needs. If this is not successful | ||
36 | 595 | * update the decoration name and return false */ | ||
37 | 596 | if (!(*theme_calc_decoration_size) (d, w, h, name_width, &width, &height)) | ||
38 | 597 | { | ||
39 | 598 | update_window_decoration_name (win); | ||
40 | 599 | return FALSE; | ||
41 | 600 | } | ||
42 | 601 | |||
43 | 602 | d->width = width; | ||
44 | 603 | d->height = height; | ||
45 | 604 | |||
46 | 605 | decor_post_pending (gdk_x11_display_get_xdisplay (gdk_display_get_default ()), | ||
47 | 606 | wnck_window_get_xid (win), | ||
48 | 607 | populate_frame_type (d), | ||
49 | 608 | populate_frame_state (d), | ||
50 | 609 | populate_frame_actions (d)); | ||
51 | 610 | |||
52 | 611 | return TRUE; | ||
53 | 612 | } | ||
54 | 567 | 613 | ||
55 | 568 | /* | 614 | /* |
56 | 569 | * update_window_decoration_size | 615 | * update_window_decoration_size |
57 | @@ -581,8 +627,6 @@ | |||
58 | 581 | decor_t *d; | 627 | decor_t *d; |
59 | 582 | GdkPixmap *pixmap, *buffer_pixmap = NULL; | 628 | GdkPixmap *pixmap, *buffer_pixmap = NULL; |
60 | 583 | Picture picture; | 629 | Picture picture; |
61 | 584 | gint width, height; | ||
62 | 585 | gint x, y, w, h, name_width; | ||
63 | 586 | Display *xdisplay; | 630 | Display *xdisplay; |
64 | 587 | XRenderPictFormat *format; | 631 | XRenderPictFormat *format; |
65 | 588 | 632 | ||
66 | @@ -591,30 +635,19 @@ | |||
67 | 591 | 635 | ||
68 | 592 | d = g_object_get_data (G_OBJECT (win), "decor"); | 636 | d = g_object_get_data (G_OBJECT (win), "decor"); |
69 | 593 | 637 | ||
70 | 638 | if (!d->decorated) | ||
71 | 639 | return FALSE; | ||
72 | 640 | |||
73 | 594 | xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()); | 641 | xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()); |
74 | 595 | 642 | ||
75 | 596 | /* Get the geometry of the window, we'll need it later */ | ||
76 | 597 | wnck_window_get_client_window_geometry (win, &x, &y, &w, &h); | ||
77 | 598 | |||
78 | 599 | /* Get the width of the name */ | ||
79 | 600 | name_width = max_window_name_width (win); | ||
80 | 601 | |||
81 | 602 | /* Ask the theme to tell us how much space it needs. If this is not successful | ||
82 | 603 | * update the decoration name and return false */ | ||
83 | 604 | if (!(*theme_calc_decoration_size) (d, w, h, name_width, &width, &height)) | ||
84 | 605 | { | ||
85 | 606 | update_window_decoration_name (win); | ||
86 | 607 | return FALSE; | ||
87 | 608 | } | ||
88 | 609 | |||
89 | 610 | gdk_error_trap_push (); | 643 | gdk_error_trap_push (); |
90 | 611 | 644 | ||
91 | 612 | /* Get the correct depth for the frame window in reparenting mode, otherwise | 645 | /* Get the correct depth for the frame window in reparenting mode, otherwise |
92 | 613 | * enforce 32 */ | 646 | * enforce 32 */ |
93 | 614 | if (d->frame_window) | 647 | if (d->frame_window) |
95 | 615 | pixmap = create_pixmap (width, height, d->frame->style_window_rgb); | 648 | pixmap = create_pixmap (d->width, d->height, d->frame->style_window_rgb); |
96 | 616 | else | 649 | else |
98 | 617 | pixmap = create_pixmap (width, height, d->frame->style_window_rgba); | 650 | pixmap = create_pixmap (d->width, d->height, d->frame->style_window_rgba); |
99 | 618 | 651 | ||
100 | 619 | gdk_flush (); | 652 | gdk_flush (); |
101 | 620 | 653 | ||
102 | @@ -628,9 +661,9 @@ | |||
103 | 628 | gdk_error_trap_push (); | 661 | gdk_error_trap_push (); |
104 | 629 | 662 | ||
105 | 630 | if (d->frame_window) | 663 | if (d->frame_window) |
107 | 631 | buffer_pixmap = create_pixmap (width, height, d->frame->style_window_rgb); | 664 | buffer_pixmap = create_pixmap (d->width, d->height, d->frame->style_window_rgb); |
108 | 632 | else | 665 | else |
110 | 633 | buffer_pixmap = create_pixmap (width, height, d->frame->style_window_rgba); | 666 | buffer_pixmap = create_pixmap (d->width, d->height, d->frame->style_window_rgba); |
111 | 634 | 667 | ||
112 | 635 | gdk_flush (); | 668 | gdk_flush (); |
113 | 636 | 669 | ||
114 | @@ -649,7 +682,7 @@ | |||
115 | 649 | 682 | ||
116 | 650 | /* Destroy the old pixmaps and pictures */ | 683 | /* Destroy the old pixmaps and pictures */ |
117 | 651 | if (d->pixmap) | 684 | if (d->pixmap) |
119 | 652 | g_object_unref (G_OBJECT (d->pixmap)); | 685 | g_hash_table_insert (destroyed_pixmaps_table, GINT_TO_POINTER (GDK_PIXMAP_XID (d->pixmap)), d->pixmap); |
120 | 653 | 686 | ||
121 | 654 | if (d->buffer_pixmap) | 687 | if (d->buffer_pixmap) |
122 | 655 | g_object_unref (G_OBJECT (d->buffer_pixmap)); | 688 | g_object_unref (G_OBJECT (d->buffer_pixmap)); |
123 | @@ -667,9 +700,6 @@ | |||
124 | 667 | 700 | ||
125 | 668 | d->picture = picture; | 701 | d->picture = picture; |
126 | 669 | 702 | ||
127 | 670 | d->width = width; | ||
128 | 671 | d->height = height; | ||
129 | 672 | |||
130 | 673 | d->prop_xid = wnck_window_get_xid (win); | 703 | d->prop_xid = wnck_window_get_xid (win); |
131 | 674 | 704 | ||
132 | 675 | update_window_decoration_name (win); | 705 | update_window_decoration_name (win); |
133 | @@ -1205,7 +1235,7 @@ | |||
134 | 1205 | d->context = NULL; | 1235 | d->context = NULL; |
135 | 1206 | d->width = d->height = 0; | 1236 | d->width = d->height = 0; |
136 | 1207 | 1237 | ||
138 | 1208 | update_window_decoration_size (win); | 1238 | request_update_window_decoration_size (win); |
139 | 1209 | update_event_windows (win); | 1239 | update_event_windows (win); |
140 | 1210 | } | 1240 | } |
141 | 1211 | } | 1241 | } |
142 | 1212 | 1242 | ||
143 | === modified file 'gtk/window-decorator/events.c' | |||
144 | --- gtk/window-decorator/events.c 2012-03-30 07:01:48 +0000 | |||
145 | +++ gtk/window-decorator/events.c 2012-06-15 17:09:21 +0000 | |||
146 | @@ -1014,7 +1014,7 @@ | |||
147 | 1014 | update_window_decoration_state (win); | 1014 | update_window_decoration_state (win); |
148 | 1015 | update_window_decoration_actions (win); | 1015 | update_window_decoration_actions (win); |
149 | 1016 | update_window_decoration_icon (win); | 1016 | update_window_decoration_icon (win); |
151 | 1017 | update_window_decoration_size (win); | 1017 | request_update_window_decoration_size (win); |
152 | 1018 | update_event_windows (win); | 1018 | update_event_windows (win); |
153 | 1019 | } | 1019 | } |
154 | 1020 | else | 1020 | else |
155 | @@ -1069,6 +1069,17 @@ | |||
156 | 1069 | } | 1069 | } |
157 | 1070 | } | 1070 | } |
158 | 1071 | } | 1071 | } |
159 | 1072 | else if (xevent->xclient.message_type == decor_request_atom) | ||
160 | 1073 | { | ||
161 | 1074 | WnckWindow *win = wnck_window_get (xevent->xclient.window); | ||
162 | 1075 | |||
163 | 1076 | if (win) | ||
164 | 1077 | update_window_decoration_size (win); | ||
165 | 1078 | } | ||
166 | 1079 | else if (xevent->xclient.message_type == decor_delete_pixmap_atom) | ||
167 | 1080 | { | ||
168 | 1081 | g_hash_table_remove (destroyed_pixmaps_table, GINT_TO_POINTER (xevent->xclient.data.l[0])); | ||
169 | 1082 | } | ||
170 | 1072 | default: | 1083 | default: |
171 | 1073 | break; | 1084 | break; |
172 | 1074 | } | 1085 | } |
173 | 1075 | 1086 | ||
174 | === modified file 'gtk/window-decorator/gtk-window-decorator.c' | |||
175 | --- gtk/window-decorator/gtk-window-decorator.c 2012-03-30 07:01:48 +0000 | |||
176 | +++ gtk/window-decorator/gtk-window-decorator.c 2012-06-15 17:09:21 +0000 | |||
177 | @@ -48,6 +48,9 @@ | |||
178 | 48 | Atom toolkit_action_atom; | 48 | Atom toolkit_action_atom; |
179 | 49 | Atom toolkit_action_window_menu_atom; | 49 | Atom toolkit_action_window_menu_atom; |
180 | 50 | Atom toolkit_action_force_quit_dialog_atom; | 50 | Atom toolkit_action_force_quit_dialog_atom; |
181 | 51 | Atom decor_request_atom; | ||
182 | 52 | Atom decor_pending_atom; | ||
183 | 53 | Atom decor_delete_pixmap_atom; | ||
184 | 51 | 54 | ||
185 | 52 | Atom net_wm_state_atom; | 55 | Atom net_wm_state_atom; |
186 | 53 | Atom net_wm_state_modal_atom; | 56 | Atom net_wm_state_modal_atom; |
187 | @@ -103,6 +106,7 @@ | |||
188 | 103 | GtkWidget *switcher_label; | 106 | GtkWidget *switcher_label; |
189 | 104 | 107 | ||
190 | 105 | GHashTable *frame_table; | 108 | GHashTable *frame_table; |
191 | 109 | GHashTable *destroyed_pixmaps_table; | ||
192 | 106 | GtkWidget *action_menu = NULL; | 110 | GtkWidget *action_menu = NULL; |
193 | 107 | gboolean action_menu_mapped = FALSE; | 111 | gboolean action_menu_mapped = FALSE; |
194 | 108 | decor_color_t _title_color[2]; | 112 | decor_color_t _title_color[2]; |
195 | @@ -305,6 +309,10 @@ | |||
196 | 305 | net_wm_state_atom = XInternAtom (xdisplay,"_NET_WM_STATE", 0); | 309 | net_wm_state_atom = XInternAtom (xdisplay,"_NET_WM_STATE", 0); |
197 | 306 | net_wm_state_modal_atom = XInternAtom (xdisplay, "_NET_WM_STATE_MODAL", 0); | 310 | net_wm_state_modal_atom = XInternAtom (xdisplay, "_NET_WM_STATE_MODAL", 0); |
198 | 307 | 311 | ||
199 | 312 | decor_request_atom = XInternAtom (xdisplay, "_COMPIZ_DECOR_REQUEST", 0); | ||
200 | 313 | decor_pending_atom = XInternAtom (xdisplay, "_COMPIZ_DECOR_PENDING", 0); | ||
201 | 314 | decor_delete_pixmap_atom = XInternAtom (xdisplay, "_COMPIZ_DECOR_DELETE_PIXMAP", 0); | ||
202 | 315 | |||
203 | 308 | status = decor_acquire_dm_session (xdisplay, | 316 | status = decor_acquire_dm_session (xdisplay, |
204 | 309 | gdk_screen_get_number (gdkscreen), | 317 | gdk_screen_get_number (gdkscreen), |
205 | 310 | "gwd", replace, &dm_sn_timestamp); | 318 | "gwd", replace, &dm_sn_timestamp); |
206 | @@ -390,6 +398,7 @@ | |||
207 | 390 | xformat_rgb = XRenderFindStandardFormat (xdisplay, PictStandardRGB24); | 398 | xformat_rgb = XRenderFindStandardFormat (xdisplay, PictStandardRGB24); |
208 | 391 | 399 | ||
209 | 392 | frame_table = g_hash_table_new (NULL, NULL); | 400 | frame_table = g_hash_table_new (NULL, NULL); |
210 | 401 | destroyed_pixmaps_table = g_hash_table_new_full (NULL, NULL, NULL, g_object_unref); | ||
211 | 393 | 402 | ||
212 | 394 | if (!create_tooltip_window ()) | 403 | if (!create_tooltip_window ()) |
213 | 395 | { | 404 | { |
214 | 396 | 405 | ||
215 | === modified file 'gtk/window-decorator/gtk-window-decorator.h' | |||
216 | --- gtk/window-decorator/gtk-window-decorator.h 2012-03-30 07:01:48 +0000 | |||
217 | +++ gtk/window-decorator/gtk-window-decorator.h 2012-06-15 17:09:21 +0000 | |||
218 | @@ -306,6 +306,9 @@ | |||
219 | 306 | extern Atom toolkit_action_force_quit_dialog_atom; | 306 | extern Atom toolkit_action_force_quit_dialog_atom; |
220 | 307 | extern Atom net_wm_state_atom; | 307 | extern Atom net_wm_state_atom; |
221 | 308 | extern Atom net_wm_state_modal_atom; | 308 | extern Atom net_wm_state_modal_atom; |
222 | 309 | extern Atom decor_request_atom; | ||
223 | 310 | extern Atom decor_pending_atom; | ||
224 | 311 | extern Atom decor_delete_pixmap_atom; | ||
225 | 309 | 312 | ||
226 | 310 | extern Time dm_sn_timestamp; | 313 | extern Time dm_sn_timestamp; |
227 | 311 | 314 | ||
228 | @@ -511,6 +514,7 @@ | |||
229 | 511 | 514 | ||
230 | 512 | /* list of all decorations */ | 515 | /* list of all decorations */ |
231 | 513 | extern GHashTable *frame_table; | 516 | extern GHashTable *frame_table; |
232 | 517 | extern GHashTable *destroyed_pixmaps_table; | ||
233 | 514 | 518 | ||
234 | 515 | /* action menu */ | 519 | /* action menu */ |
235 | 516 | extern GtkWidget *action_menu; | 520 | extern GtkWidget *action_menu; |
236 | @@ -628,9 +632,13 @@ | |||
237 | 628 | void | 632 | void |
238 | 629 | destroy_bare_frame (); | 633 | destroy_bare_frame (); |
239 | 630 | 634 | ||
240 | 635 | /* Don't use directly */ | ||
241 | 631 | gboolean | 636 | gboolean |
242 | 632 | update_window_decoration_size (WnckWindow *win); | 637 | update_window_decoration_size (WnckWindow *win); |
243 | 633 | 638 | ||
244 | 639 | gboolean | ||
245 | 640 | request_update_window_decoration_size (WnckWindow *win); | ||
246 | 641 | |||
247 | 634 | void | 642 | void |
248 | 635 | update_window_decoration_name (WnckWindow *win); | 643 | update_window_decoration_name (WnckWindow *win); |
249 | 636 | 644 | ||
250 | 637 | 645 | ||
251 | === modified file 'gtk/window-decorator/wnck.c' | |||
252 | --- gtk/window-decorator/wnck.c 2012-03-30 07:01:48 +0000 | |||
253 | +++ gtk/window-decorator/wnck.c 2012-06-15 17:09:21 +0000 | |||
254 | @@ -80,7 +80,7 @@ | |||
255 | 80 | 80 | ||
256 | 81 | if (d->decorated) | 81 | if (d->decorated) |
257 | 82 | { | 82 | { |
259 | 83 | if (!update_window_decoration_size (win)) | 83 | if (!request_update_window_decoration_size (win)) |
260 | 84 | queue_decor_draw (d); | 84 | queue_decor_draw (d); |
261 | 85 | } | 85 | } |
262 | 86 | } | 86 | } |
263 | @@ -102,7 +102,7 @@ | |||
264 | 102 | d->client_width = width; | 102 | d->client_width = width; |
265 | 103 | d->client_height = height; | 103 | d->client_height = height; |
266 | 104 | 104 | ||
268 | 105 | update_window_decoration_size (win); | 105 | request_update_window_decoration_size (win); |
269 | 106 | update_event_windows (win); | 106 | update_event_windows (win); |
270 | 107 | } | 107 | } |
271 | 108 | } | 108 | } |
272 | @@ -128,7 +128,7 @@ | |||
273 | 128 | if (d->decorated) | 128 | if (d->decorated) |
274 | 129 | { | 129 | { |
275 | 130 | update_window_decoration_state (win); | 130 | update_window_decoration_state (win); |
277 | 131 | if (!update_window_decoration_size (win)) | 131 | if (!request_update_window_decoration_size (win)) |
278 | 132 | queue_decor_draw (d); | 132 | queue_decor_draw (d); |
279 | 133 | 133 | ||
280 | 134 | update_event_windows (win); | 134 | update_event_windows (win); |
281 | @@ -143,7 +143,7 @@ | |||
282 | 143 | if (d->decorated) | 143 | if (d->decorated) |
283 | 144 | { | 144 | { |
284 | 145 | update_window_decoration_actions (win); | 145 | update_window_decoration_actions (win); |
286 | 146 | if (!update_window_decoration_size (win)) | 146 | if (!request_update_window_decoration_size (win)) |
287 | 147 | queue_decor_draw (d); | 147 | queue_decor_draw (d); |
288 | 148 | 148 | ||
289 | 149 | update_event_windows (win); | 149 | update_event_windows (win); |
290 | @@ -422,7 +422,7 @@ | |||
291 | 422 | update_window_decoration_state (win); | 422 | update_window_decoration_state (win); |
292 | 423 | update_window_decoration_actions (win); | 423 | update_window_decoration_actions (win); |
293 | 424 | update_window_decoration_icon (win); | 424 | update_window_decoration_icon (win); |
295 | 425 | update_window_decoration_size (win); | 425 | request_update_window_decoration_size (win); |
296 | 426 | 426 | ||
297 | 427 | update_event_windows (win); | 427 | update_event_windows (win); |
298 | 428 | } | 428 | } |
299 | @@ -585,7 +585,7 @@ | |||
300 | 585 | if (win) | 585 | if (win) |
301 | 586 | { | 586 | { |
302 | 587 | d = g_object_get_data (G_OBJECT (win), "decor"); | 587 | d = g_object_get_data (G_OBJECT (win), "decor"); |
304 | 588 | if (d && d->pixmap) | 588 | if (d) |
305 | 589 | { | 589 | { |
306 | 590 | d->active = wnck_window_is_active (win); | 590 | d->active = wnck_window_is_active (win); |
307 | 591 | 591 | ||
308 | @@ -642,8 +642,9 @@ | |||
309 | 642 | * then we need to redraw the decoration anyways | 642 | * then we need to redraw the decoration anyways |
310 | 643 | * since the image would have changed */ | 643 | * since the image would have changed */ |
311 | 644 | if (d->win != NULL && | 644 | if (d->win != NULL && |
314 | 645 | !update_window_decoration_size (d->win) && | 645 | !request_update_window_decoration_size (d->win) && |
315 | 646 | d->decorated) | 646 | d->decorated && |
316 | 647 | d->pixmap) | ||
317 | 647 | queue_decor_draw (d); | 648 | queue_decor_draw (d); |
318 | 648 | 649 | ||
319 | 649 | } | 650 | } |
320 | @@ -653,7 +654,7 @@ | |||
321 | 653 | if (win) | 654 | if (win) |
322 | 654 | { | 655 | { |
323 | 655 | d = g_object_get_data (G_OBJECT (win), "decor"); | 656 | d = g_object_get_data (G_OBJECT (win), "decor"); |
325 | 656 | if (d && d->pixmap) | 657 | if (d) |
326 | 657 | { | 658 | { |
327 | 658 | d->active = wnck_window_is_active (win); | 659 | d->active = wnck_window_is_active (win); |
328 | 659 | 660 | ||
329 | @@ -710,8 +711,9 @@ | |||
330 | 710 | * then we need to redraw the decoration anyways | 711 | * then we need to redraw the decoration anyways |
331 | 711 | * since the image would have changed */ | 712 | * since the image would have changed */ |
332 | 712 | if (d->win != NULL && | 713 | if (d->win != NULL && |
335 | 713 | !update_window_decoration_size (d->win) && | 714 | !request_update_window_decoration_size (d->win) && |
336 | 714 | d->decorated) | 715 | d->decorated && |
337 | 716 | d->pixmap) | ||
338 | 715 | queue_decor_draw (d); | 717 | queue_decor_draw (d); |
339 | 716 | 718 | ||
340 | 717 | } | 719 | } |
341 | 718 | 720 | ||
342 | === modified file 'include/decoration.h' | |||
343 | --- include/decoration.h 2012-02-09 07:48:57 +0000 | |||
344 | +++ include/decoration.h 2012-06-15 17:09:21 +0000 | |||
345 | @@ -492,6 +492,24 @@ | |||
346 | 492 | XEvent *event, | 492 | XEvent *event, |
347 | 493 | Time dm_sn_timestamp); | 493 | Time dm_sn_timestamp); |
348 | 494 | 494 | ||
349 | 495 | int | ||
350 | 496 | decor_post_pending (Display *xdisplay, | ||
351 | 497 | Window client, | ||
352 | 498 | unsigned int frame_state, | ||
353 | 499 | unsigned int frame_type, | ||
354 | 500 | unsigned int frame_actions); | ||
355 | 501 | |||
356 | 502 | int | ||
357 | 503 | decor_post_delete_pixmap (Display *xdisplay, | ||
358 | 504 | Pixmap pixmap); | ||
359 | 505 | |||
360 | 506 | int | ||
361 | 507 | decor_post_generate_request (Display *xdisplay, | ||
362 | 508 | Window client, | ||
363 | 509 | unsigned int frame_type, | ||
364 | 510 | unsigned int frame_state, | ||
365 | 511 | unsigned int frame_actions); | ||
366 | 512 | |||
367 | 495 | #ifdef __cplusplus | 513 | #ifdef __cplusplus |
368 | 496 | } | 514 | } |
369 | 497 | #endif | 515 | #endif |
370 | 498 | 516 | ||
371 | === modified file 'libdecoration/decoration.c' | |||
372 | --- libdecoration/decoration.c 2012-02-27 06:43:04 +0000 | |||
373 | +++ libdecoration/decoration.c 2012-06-15 17:09:21 +0000 | |||
374 | @@ -2877,6 +2877,92 @@ | |||
375 | 2877 | } | 2877 | } |
376 | 2878 | 2878 | ||
377 | 2879 | int | 2879 | int |
378 | 2880 | decor_post_pending (Display *xdisplay, | ||
379 | 2881 | Window client, | ||
380 | 2882 | unsigned int frame_state, | ||
381 | 2883 | unsigned int frame_type, | ||
382 | 2884 | unsigned int frame_actions) | ||
383 | 2885 | { | ||
384 | 2886 | XEvent event; | ||
385 | 2887 | |||
386 | 2888 | Atom decor_pending = XInternAtom (xdisplay, "_COMPIZ_DECOR_PENDING", FALSE); | ||
387 | 2889 | |||
388 | 2890 | /* Send a client message indicating that a new | ||
389 | 2891 | * decoration can be generated for this window | ||
390 | 2892 | */ | ||
391 | 2893 | event.xclient.type = ClientMessage; | ||
392 | 2894 | event.xclient.window = client; | ||
393 | 2895 | event.xclient.message_type = decor_pending; | ||
394 | 2896 | event.xclient.format = 32; | ||
395 | 2897 | event.xclient.data.l[0] = frame_type; | ||
396 | 2898 | event.xclient.data.l[1] = frame_state; | ||
397 | 2899 | event.xclient.data.l[2] = frame_actions; | ||
398 | 2900 | event.xclient.data.l[3] = 0; | ||
399 | 2901 | event.xclient.data.l[4] = 0; | ||
400 | 2902 | |||
401 | 2903 | XSendEvent (xdisplay, DefaultRootWindow (xdisplay), 0, | ||
402 | 2904 | StructureNotifyMask, &event); | ||
403 | 2905 | |||
404 | 2906 | return 1; | ||
405 | 2907 | } | ||
406 | 2908 | |||
407 | 2909 | int | ||
408 | 2910 | decor_post_generate_request (Display *xdisplay, | ||
409 | 2911 | Window client, | ||
410 | 2912 | unsigned int frame_type, | ||
411 | 2913 | unsigned int frame_state, | ||
412 | 2914 | unsigned int frame_actions) | ||
413 | 2915 | { | ||
414 | 2916 | XEvent event; | ||
415 | 2917 | |||
416 | 2918 | Atom decor_request = XInternAtom (xdisplay, "_COMPIZ_DECOR_REQUEST", FALSE); | ||
417 | 2919 | |||
418 | 2920 | /* Send a client message indicating that a new | ||
419 | 2921 | * decoration can be generated for this window | ||
420 | 2922 | */ | ||
421 | 2923 | event.xclient.type = ClientMessage; | ||
422 | 2924 | event.xclient.window = client; | ||
423 | 2925 | event.xclient.message_type = decor_request; | ||
424 | 2926 | event.xclient.format = 32; | ||
425 | 2927 | event.xclient.data.l[0] = frame_type; | ||
426 | 2928 | event.xclient.data.l[1] = frame_state; | ||
427 | 2929 | event.xclient.data.l[2] = frame_actions; | ||
428 | 2930 | event.xclient.data.l[3] = 0; | ||
429 | 2931 | event.xclient.data.l[4] = 0; | ||
430 | 2932 | |||
431 | 2933 | XSendEvent (xdisplay, DefaultRootWindow (xdisplay), 0, | ||
432 | 2934 | StructureNotifyMask, &event); | ||
433 | 2935 | |||
434 | 2936 | return 1; | ||
435 | 2937 | } | ||
436 | 2938 | |||
437 | 2939 | int | ||
438 | 2940 | decor_post_delete_pixmap (Display *xdisplay, | ||
439 | 2941 | Pixmap pixmap) | ||
440 | 2942 | { | ||
441 | 2943 | XEvent event; | ||
442 | 2944 | |||
443 | 2945 | Atom decor_delete_pixmap = XInternAtom (xdisplay, "_COMPIZ_DECOR_DELETE_PIXMAP", FALSE); | ||
444 | 2946 | |||
445 | 2947 | /* Send a client message indicating that a new | ||
446 | 2948 | * decoration can be generated for this window | ||
447 | 2949 | */ | ||
448 | 2950 | event.xclient.type = ClientMessage; | ||
449 | 2951 | event.xclient.window = DefaultRootWindow (xdisplay); | ||
450 | 2952 | event.xclient.message_type = decor_delete_pixmap; | ||
451 | 2953 | event.xclient.format = 32; | ||
452 | 2954 | event.xclient.data.l[0] = pixmap; | ||
453 | 2955 | event.xclient.data.l[1] = 0; | ||
454 | 2956 | event.xclient.data.l[2] = 0; | ||
455 | 2957 | event.xclient.data.l[3] = 0; | ||
456 | 2958 | event.xclient.data.l[4] = 0; | ||
457 | 2959 | |||
458 | 2960 | XSendEvent (xdisplay, DefaultRootWindow (xdisplay), 0, | ||
459 | 2961 | StructureNotifyMask, &event); | ||
460 | 2962 | |||
461 | 2963 | return 1; | ||
462 | 2964 | } | ||
463 | 2965 | int | ||
464 | 2880 | decor_acquire_dm_session (Display *xdisplay, | 2966 | decor_acquire_dm_session (Display *xdisplay, |
465 | 2881 | int screen, | 2967 | int screen, |
466 | 2882 | const char *name, | 2968 | const char *name, |
467 | 2883 | 2969 | ||
468 | === modified file 'plugins/decor/CMakeLists.txt' | |||
469 | --- plugins/decor/CMakeLists.txt 2012-03-30 14:29:18 +0000 | |||
470 | +++ plugins/decor/CMakeLists.txt 2012-06-15 17:09:21 +0000 | |||
471 | @@ -4,10 +4,12 @@ | |||
472 | 4 | include (CompizCommon) | 4 | include (CompizCommon) |
473 | 5 | 5 | ||
474 | 6 | include_directories (${CMAKE_CURRENT_SOURCE_DIR}/src/clip-groups/include/) | 6 | include_directories (${CMAKE_CURRENT_SOURCE_DIR}/src/clip-groups/include/) |
475 | 7 | include_directories (${CMAKE_CURRENT_SOURCE_DIR}/src/pixmap-requests/include/) | ||
476 | 7 | 8 | ||
478 | 8 | compiz_plugin(decor PLUGINDEPS composite opengl LIBRARIES decoration compiz_decor_clip_groups) | 9 | compiz_plugin(decor PLUGINDEPS composite opengl LIBRARIES decoration compiz_decor_clip_groups compiz_decor_pixmap_requests) |
479 | 9 | 10 | ||
480 | 10 | add_subdirectory (src/clip-groups) | 11 | add_subdirectory (src/clip-groups) |
481 | 12 | add_subdirectory (src/pixmap-requests) | ||
482 | 11 | 13 | ||
483 | 12 | if (COMPIZ_BUILD_WITH_RPATH AND NOT COMPIZ_DISABLE_PLUGIN_DECOR) | 14 | if (COMPIZ_BUILD_WITH_RPATH AND NOT COMPIZ_DISABLE_PLUGIN_DECOR) |
484 | 13 | 15 | ||
485 | 14 | 16 | ||
486 | === modified file 'plugins/decor/src/decor.cpp' | |||
487 | --- plugins/decor/src/decor.cpp 2012-04-23 05:50:23 +0000 | |||
488 | +++ plugins/decor/src/decor.cpp 2012-06-15 17:09:21 +0000 | |||
489 | @@ -303,7 +303,6 @@ | |||
490 | 303 | } | 303 | } |
491 | 304 | 304 | ||
492 | 305 | static bool bindFailed; | 305 | static bool bindFailed; |
493 | 306 | |||
494 | 307 | /* | 306 | /* |
495 | 308 | * DecorTexture::DecorTexture | 307 | * DecorTexture::DecorTexture |
496 | 309 | * | 308 | * |
497 | @@ -314,7 +313,7 @@ | |||
498 | 314 | * for this pixmap | 313 | * for this pixmap |
499 | 315 | */ | 314 | */ |
500 | 316 | 315 | ||
502 | 317 | DecorTexture::DecorTexture (Pixmap pixmap) : | 316 | DecorTexture::DecorTexture (DecorPixmapInterface::Ptr pixmap) : |
503 | 318 | status (true), | 317 | status (true), |
504 | 319 | refCount (1), | 318 | refCount (1), |
505 | 320 | pixmap (pixmap), | 319 | pixmap (pixmap), |
506 | @@ -324,7 +323,7 @@ | |||
507 | 324 | Window root; | 323 | Window root; |
508 | 325 | int i; | 324 | int i; |
509 | 326 | 325 | ||
511 | 327 | if (!XGetGeometry (screen->dpy (), pixmap, &root, | 326 | if (!XGetGeometry (screen->dpy (), pixmap->getPixmap (), &root, |
512 | 328 | &i, &i, &width, &height, &ui, &depth)) | 327 | &i, &i, &width, &height, &ui, &depth)) |
513 | 329 | { | 328 | { |
514 | 330 | status = false; | 329 | status = false; |
515 | @@ -332,7 +331,7 @@ | |||
516 | 332 | } | 331 | } |
517 | 333 | 332 | ||
518 | 334 | bindFailed = false; | 333 | bindFailed = false; |
520 | 335 | textures = GLTexture::bindPixmapToTexture (pixmap, width, height, depth); | 334 | textures = GLTexture::bindPixmapToTexture (pixmap->getPixmap (), width, height, depth); |
521 | 336 | if (textures.size () != 1) | 335 | if (textures.size () != 1) |
522 | 337 | { | 336 | { |
523 | 338 | bindFailed = true; | 337 | bindFailed = true; |
524 | @@ -343,7 +342,7 @@ | |||
525 | 343 | if (!DecorScreen::get (screen)->optionGetMipmap ()) | 342 | if (!DecorScreen::get (screen)->optionGetMipmap ()) |
526 | 344 | textures[0]->setMipmap (false); | 343 | textures[0]->setMipmap (false); |
527 | 345 | 344 | ||
529 | 346 | damage = XDamageCreate (screen->dpy (), pixmap, | 345 | damage = XDamageCreate (screen->dpy (), pixmap->getPixmap (), |
530 | 347 | XDamageReportRawRectangles); | 346 | XDamageReportRawRectangles); |
531 | 348 | } | 347 | } |
532 | 349 | 348 | ||
533 | @@ -378,13 +377,16 @@ | |||
534 | 378 | return NULL; | 377 | return NULL; |
535 | 379 | 378 | ||
536 | 380 | foreach (DecorTexture *t, textures) | 379 | foreach (DecorTexture *t, textures) |
538 | 381 | if (t->pixmap == pixmap) | 380 | if (t->pixmap->getPixmap () == pixmap) |
539 | 382 | { | 381 | { |
540 | 383 | t->refCount++; | 382 | t->refCount++; |
541 | 384 | return t; | 383 | return t; |
542 | 385 | } | 384 | } |
543 | 386 | 385 | ||
545 | 387 | DecorTexture *texture = new DecorTexture (pixmap); | 386 | X11PixmapDeletor::Ptr dl = boost::make_shared <X11PixmapDeletor> (screen->dpy ()); |
546 | 387 | DecorPixmap::Ptr pm = boost::make_shared <DecorPixmap> (pixmap, dl); | ||
547 | 388 | |||
548 | 389 | DecorTexture *texture = new DecorTexture (boost::shared_static_cast <DecorPixmapInterface> (pm)); | ||
549 | 388 | 390 | ||
550 | 389 | if (!texture->status) | 391 | if (!texture->status) |
551 | 390 | { | 392 | { |
552 | @@ -520,7 +522,8 @@ | |||
553 | 520 | long *prop, | 522 | long *prop, |
554 | 521 | unsigned int size, | 523 | unsigned int size, |
555 | 522 | unsigned int type, | 524 | unsigned int type, |
557 | 523 | unsigned int nOffset) | 525 | unsigned int nOffset, |
558 | 526 | DecorPixmapRequestorInterface *requestor) | ||
559 | 524 | { | 527 | { |
560 | 525 | unsigned int frameType, frameState, frameActions; | 528 | unsigned int frameType, frameState, frameActions; |
561 | 526 | Pixmap pixmap = None; | 529 | Pixmap pixmap = None; |
562 | @@ -568,7 +571,7 @@ | |||
563 | 568 | throw std::exception (); | 571 | throw std::exception (); |
564 | 569 | } | 572 | } |
565 | 570 | 573 | ||
567 | 571 | return Decoration::Ptr (new Decoration (type, border, input, maxBorder, maxInput, frameType, frameState, frameActions, minWidth, minHeight, pixmap, quad, nQuad)); | 574 | return Decoration::Ptr (new Decoration (type, border, input, maxBorder, maxInput, frameType, frameState, frameActions, minWidth, minHeight, pixmap, quad, nQuad, id, requestor)); |
568 | 572 | } | 575 | } |
569 | 573 | 576 | ||
570 | 574 | Decoration::Decoration (int type, | 577 | Decoration::Decoration (int type, |
571 | @@ -583,7 +586,9 @@ | |||
572 | 583 | unsigned int minHeight, | 586 | unsigned int minHeight, |
573 | 584 | Pixmap pixmap, | 587 | Pixmap pixmap, |
574 | 585 | const boost::shared_array <decor_quad_t> &quad, | 588 | const boost::shared_array <decor_quad_t> &quad, |
576 | 586 | unsigned int nQuad) : | 589 | unsigned int nQuad, |
577 | 590 | Window owner, | ||
578 | 591 | DecorPixmapRequestorInterface *requestor) : | ||
579 | 587 | texture (DecorScreen::get (screen)->getTexture (pixmap)), | 592 | texture (DecorScreen::get (screen)->getTexture (pixmap)), |
580 | 588 | border (border.left, border.right, border.top, border.bottom), | 593 | border (border.left, border.right, border.top, border.bottom), |
581 | 589 | input (input.left, input.right, input.top, input.bottom), | 594 | input (input.left, input.right, input.top, input.bottom), |
582 | @@ -596,7 +601,9 @@ | |||
583 | 596 | frameActions (frameActions), | 601 | frameActions (frameActions), |
584 | 597 | quad (quad), | 602 | quad (quad), |
585 | 598 | nQuad (nQuad), | 603 | nQuad (nQuad), |
587 | 599 | type (type) | 604 | type (type), |
588 | 605 | updateState (0), | ||
589 | 606 | mPixmapReceiver (requestor, this) | ||
590 | 600 | { | 607 | { |
591 | 601 | int left, right, top, bottom; | 608 | int left, right, top, bottom; |
592 | 602 | int x1, y1, x2, y2; | 609 | int x1, y1, x2, y2; |
593 | @@ -657,6 +664,30 @@ | |||
594 | 657 | DecorScreen::get (screen)->releaseTexture (texture); | 664 | DecorScreen::get (screen)->releaseTexture (texture); |
595 | 658 | } | 665 | } |
596 | 659 | 666 | ||
597 | 667 | DecorPixmapReceiverInterface & | ||
598 | 668 | Decoration::receiverInterface () | ||
599 | 669 | { | ||
600 | 670 | return mPixmapReceiver; | ||
601 | 671 | } | ||
602 | 672 | |||
603 | 673 | unsigned int | ||
604 | 674 | Decoration::getFrameType () const | ||
605 | 675 | { | ||
606 | 676 | return frameType; | ||
607 | 677 | } | ||
608 | 678 | |||
609 | 679 | unsigned int | ||
610 | 680 | Decoration::getFrameState () const | ||
611 | 681 | { | ||
612 | 682 | return frameState; | ||
613 | 683 | } | ||
614 | 684 | |||
615 | 685 | unsigned int | ||
616 | 686 | Decoration::getFrameActions () const | ||
617 | 687 | { | ||
618 | 688 | return frameActions; | ||
619 | 689 | } | ||
620 | 690 | |||
621 | 660 | /* | 691 | /* |
622 | 661 | * DecorationList is a class which allows multiple decorations | 692 | * DecorationList is a class which allows multiple decorations |
623 | 662 | * to be stored in a list and read from a window property, which | 693 | * to be stored in a list and read from a window property, which |
624 | @@ -692,7 +723,8 @@ | |||
625 | 692 | 723 | ||
626 | 693 | bool | 724 | bool |
627 | 694 | DecorationList::updateDecoration (Window id, | 725 | DecorationList::updateDecoration (Window id, |
629 | 695 | Atom decorAtom) | 726 | Atom decorAtom, |
630 | 727 | DecorPixmapRequestorInterface *requestor) | ||
631 | 696 | { | 728 | { |
632 | 697 | unsigned long n, nleft; | 729 | unsigned long n, nleft; |
633 | 698 | unsigned char *data; | 730 | unsigned char *data; |
634 | @@ -701,6 +733,12 @@ | |||
635 | 701 | int result, format; | 733 | int result, format; |
636 | 702 | unsigned int type; | 734 | unsigned int type; |
637 | 703 | 735 | ||
638 | 736 | /* Dispatch any new updates */ | ||
639 | 737 | foreach (const Decoration::Ptr &d, mList) | ||
640 | 738 | { | ||
641 | 739 | d->mPixmapReceiver.update (); | ||
642 | 740 | } | ||
643 | 741 | |||
644 | 704 | result = XGetWindowProperty (screen->dpy (), id, | 742 | result = XGetWindowProperty (screen->dpy (), id, |
645 | 705 | decorAtom, 0L, | 743 | decorAtom, 0L, |
646 | 706 | PROP_HEADER_SIZE + 6 * (BASE_PROP_SIZE + | 744 | PROP_HEADER_SIZE + 6 * (BASE_PROP_SIZE + |
647 | @@ -770,7 +808,9 @@ | |||
648 | 770 | maxBorder.top = d->maxBorder.top; | 808 | maxBorder.top = d->maxBorder.top; |
649 | 771 | maxBorder.bottom = d->maxBorder.bottom; | 809 | maxBorder.bottom = d->maxBorder.bottom; |
650 | 772 | 810 | ||
652 | 773 | int num = decor_match_pixmap (prop, n, &d->texture->pixmap, &input, &border, &maxInput, &maxBorder, | 811 | Pixmap pm = d->texture->pixmap->getPixmap (); |
653 | 812 | |||
654 | 813 | int num = decor_match_pixmap (prop, n, &pm, &input, &border, &maxInput, &maxBorder, | ||
655 | 774 | d->minWidth, d->minHeight, d->frameType, d->frameState, d->frameActions, | 814 | d->minWidth, d->minHeight, d->frameType, d->frameState, d->frameActions, |
656 | 775 | d->quad.get (), d->nQuad); | 815 | d->quad.get (), d->nQuad); |
657 | 776 | if (num != -1) | 816 | if (num != -1) |
658 | @@ -788,7 +828,7 @@ | |||
659 | 788 | try | 828 | try |
660 | 789 | { | 829 | { |
661 | 790 | std::list <Decoration::Ptr>::iterator it = mList.begin (); | 830 | std::list <Decoration::Ptr>::iterator it = mList.begin (); |
663 | 791 | Decoration::Ptr d = Decoration::create (id, prop, n, type, i); | 831 | Decoration::Ptr d = Decoration::create (id, prop, n, type, i, requestor); |
664 | 792 | 832 | ||
665 | 793 | /* Try to replace an existing decoration */ | 833 | /* Try to replace an existing decoration */ |
666 | 794 | for (; it != mList.end (); it++) | 834 | for (; it != mList.end (); it++) |
667 | @@ -873,7 +913,7 @@ | |||
668 | 873 | { | 913 | { |
669 | 874 | bindFailed = false; | 914 | bindFailed = false; |
670 | 875 | 915 | ||
672 | 876 | decor.updateDecoration (window->id (), dScreen->winDecorAtom); | 916 | decor.updateDecoration (window->id (), dScreen->winDecorAtom, &mRequestor); |
673 | 877 | if (bindFailed) | 917 | if (bindFailed) |
674 | 878 | pixmapFailed = true; | 918 | pixmapFailed = true; |
675 | 879 | else | 919 | else |
676 | @@ -1230,6 +1270,22 @@ | |||
677 | 1230 | return (decorActions == 0); | 1270 | return (decorActions == 0); |
678 | 1231 | } | 1271 | } |
679 | 1232 | 1272 | ||
680 | 1273 | DecorationInterface::Ptr | ||
681 | 1274 | DecorationList::findMatchingDecoration (unsigned int frameType, | ||
682 | 1275 | unsigned int frameState, | ||
683 | 1276 | unsigned int frameActions) | ||
684 | 1277 | { | ||
685 | 1278 | foreach (const Decoration::Ptr &d, mList) | ||
686 | 1279 | { | ||
687 | 1280 | if (d->frameType == frameType && | ||
688 | 1281 | d->frameState == frameState && | ||
689 | 1282 | d->frameActions == frameActions) | ||
690 | 1283 | return boost::shared_static_cast <DecorationInterface> (d); | ||
691 | 1284 | } | ||
692 | 1285 | |||
693 | 1286 | return DecorationInterface::Ptr (); | ||
694 | 1287 | } | ||
695 | 1288 | |||
696 | 1233 | /* | 1289 | /* |
697 | 1234 | * DecorationList::findMatchingDecoration | 1290 | * DecorationList::findMatchingDecoration |
698 | 1235 | * | 1291 | * |
699 | @@ -2053,7 +2109,7 @@ | |||
700 | 2053 | { | 2109 | { |
701 | 2054 | for (i = 0; i < DECOR_NUM; i++) | 2110 | for (i = 0; i < DECOR_NUM; i++) |
702 | 2055 | { | 2111 | { |
704 | 2056 | decor[i].updateDecoration (screen->root (), decorAtom[i]); | 2112 | decor[i].updateDecoration (screen->root (), decorAtom[i], &mRequestor); |
705 | 2057 | } | 2113 | } |
706 | 2058 | } | 2114 | } |
707 | 2059 | else | 2115 | else |
708 | @@ -2261,6 +2317,7 @@ | |||
709 | 2261 | isSwitcher = false; | 2317 | isSwitcher = false; |
710 | 2262 | } | 2318 | } |
711 | 2263 | 2319 | ||
712 | 2320 | |||
713 | 2264 | /* | 2321 | /* |
714 | 2265 | * DecorScreen::handleEvent | 2322 | * DecorScreen::handleEvent |
715 | 2266 | * | 2323 | * |
716 | @@ -2295,6 +2352,18 @@ | |||
717 | 2295 | if (w) | 2352 | if (w) |
718 | 2296 | DecorWindow::get (w)->update (true); | 2353 | DecorWindow::get (w)->update (true); |
719 | 2297 | } | 2354 | } |
720 | 2355 | /* A decoration is pending creation, allow it to be created */ | ||
721 | 2356 | if (event->xclient.message_type == decorPendingAtom) | ||
722 | 2357 | { | ||
723 | 2358 | CompWindow *w = screen->findWindow (event->xclient.window); | ||
724 | 2359 | |||
725 | 2360 | if (w) | ||
726 | 2361 | { | ||
727 | 2362 | DecorWindow *dw = DecorWindow::get (w); | ||
728 | 2363 | |||
729 | 2364 | dw->mRequestor.handlePending (event->xclient.data.l); | ||
730 | 2365 | } | ||
731 | 2366 | } | ||
732 | 2298 | default: | 2367 | default: |
733 | 2299 | /* Check for damage events. If the output or input window | 2368 | /* Check for damage events. If the output or input window |
734 | 2300 | * or a texture is updated then damage output extents. | 2369 | * or a texture is updated then damage output extents. |
735 | @@ -2309,7 +2378,7 @@ | |||
736 | 2309 | 2378 | ||
737 | 2310 | foreach (DecorTexture *t, textures) | 2379 | foreach (DecorTexture *t, textures) |
738 | 2311 | { | 2380 | { |
740 | 2312 | if (t->pixmap == de->drawable) | 2381 | if (t->pixmap->getPixmap () == de->drawable) |
741 | 2313 | { | 2382 | { |
742 | 2314 | foreach (CompWindow *w, screen->windows ()) | 2383 | foreach (CompWindow *w, screen->windows ()) |
743 | 2315 | { | 2384 | { |
744 | @@ -2368,7 +2437,6 @@ | |||
745 | 2368 | { | 2437 | { |
746 | 2369 | DECOR_WINDOW (w); | 2438 | DECOR_WINDOW (w); |
747 | 2370 | dw->updateDecoration (); | 2439 | dw->updateDecoration (); |
748 | 2371 | |||
749 | 2372 | dw->update (true); | 2440 | dw->update (true); |
750 | 2373 | } | 2441 | } |
751 | 2374 | } | 2442 | } |
752 | @@ -2401,7 +2469,8 @@ | |||
753 | 2401 | if (event->xproperty.atom == decorAtom[i]) | 2469 | if (event->xproperty.atom == decorAtom[i]) |
754 | 2402 | { | 2470 | { |
755 | 2403 | decor[i].updateDecoration (screen->root (), | 2471 | decor[i].updateDecoration (screen->root (), |
757 | 2404 | decorAtom[i]); | 2472 | decorAtom[i], |
758 | 2473 | &mRequestor); | ||
759 | 2405 | 2474 | ||
760 | 2406 | foreach (CompWindow *w, screen->windows ()) | 2475 | foreach (CompWindow *w, screen->windows ()) |
761 | 2407 | DecorWindow::get (w)->update (true); | 2476 | DecorWindow::get (w)->update (true); |
762 | @@ -2935,8 +3004,11 @@ | |||
763 | 2935 | 0, | 3004 | 0, |
764 | 2936 | None, | 3005 | None, |
765 | 2937 | boost::shared_array <decor_quad_t> (NULL), | 3006 | boost::shared_array <decor_quad_t> (NULL), |
768 | 2938 | 0)), | 3007 | 0, |
769 | 2939 | mMenusClipGroup (CompMatch ("type=Dock | type=DropdownMenu | type=PopupMenu")) | 3008 | screen->root (), |
770 | 3009 | NULL)), | ||
771 | 3010 | mMenusClipGroup (CompMatch ("type=Dock | type=DropdownMenu | type=PopupMenu")), | ||
772 | 3011 | mRequestor (screen->dpy (), screen->root (), &(decor[DECOR_ACTIVE])) | ||
773 | 2940 | { | 3012 | { |
774 | 2941 | supportingDmCheckAtom = | 3013 | supportingDmCheckAtom = |
775 | 2942 | XInternAtom (s->dpy (), DECOR_SUPPORTING_DM_CHECK_ATOM_NAME, 0); | 3014 | XInternAtom (s->dpy (), DECOR_SUPPORTING_DM_CHECK_ATOM_NAME, 0); |
776 | @@ -2958,6 +3030,10 @@ | |||
777 | 2958 | XInternAtom (s->dpy (), DECOR_TYPE_WINDOW_ATOM_NAME, 0); | 3030 | XInternAtom (s->dpy (), DECOR_TYPE_WINDOW_ATOM_NAME, 0); |
778 | 2959 | decorSwitchWindowAtom = | 3031 | decorSwitchWindowAtom = |
779 | 2960 | XInternAtom (s->dpy (), DECOR_SWITCH_WINDOW_ATOM_NAME, 0); | 3032 | XInternAtom (s->dpy (), DECOR_SWITCH_WINDOW_ATOM_NAME, 0); |
780 | 3033 | decorPendingAtom = | ||
781 | 3034 | XInternAtom (s->dpy (), "_COMPIZ_DECOR_PENDING", 0); | ||
782 | 3035 | decorRequestAtom = | ||
783 | 3036 | XInternAtom (s->dpy (), "_COMPIZ_DECOR_REQUEST", 0); | ||
784 | 2961 | requestFrameExtentsAtom = | 3037 | requestFrameExtentsAtom = |
785 | 2962 | XInternAtom (s->dpy (), "_NET_REQUEST_FRAME_EXTENTS", 0); | 3038 | XInternAtom (s->dpy (), "_NET_REQUEST_FRAME_EXTENTS", 0); |
786 | 2963 | shadowColorAtom = | 3039 | shadowColorAtom = |
787 | @@ -3013,7 +3089,8 @@ | |||
788 | 3013 | frameExtentsRequested (false), | 3089 | frameExtentsRequested (false), |
789 | 3014 | mClipGroup (NULL), | 3090 | mClipGroup (NULL), |
790 | 3015 | mOutputRegion (window->outputRect ()), | 3091 | mOutputRegion (window->outputRect ()), |
792 | 3016 | mInputRegion (window->inputRect ()) | 3092 | mInputRegion (window->inputRect ()), |
793 | 3093 | mRequestor (screen->dpy (), w->id (), &decor) | ||
794 | 3017 | { | 3094 | { |
795 | 3018 | WindowInterface::setHandler (window); | 3095 | WindowInterface::setHandler (window); |
796 | 3019 | 3096 | ||
797 | 3020 | 3097 | ||
798 | === modified file 'plugins/decor/src/decor.h' | |||
799 | --- plugins/decor/src/decor.h 2012-04-23 05:50:23 +0000 | |||
800 | +++ plugins/decor/src/decor.h 2012-06-15 17:09:21 +0000 | |||
801 | @@ -25,6 +25,7 @@ | |||
802 | 25 | 25 | ||
803 | 26 | #include <boost/shared_ptr.hpp> | 26 | #include <boost/shared_ptr.hpp> |
804 | 27 | #include <boost/shared_array.hpp> | 27 | #include <boost/shared_array.hpp> |
805 | 28 | #include <boost/make_shared.hpp> | ||
806 | 28 | #include <core/window.h> | 29 | #include <core/window.h> |
807 | 29 | #include <core/pluginclasshandler.h> | 30 | #include <core/pluginclasshandler.h> |
808 | 30 | 31 | ||
809 | @@ -34,6 +35,7 @@ | |||
810 | 34 | #include <core/windowextents.h> | 35 | #include <core/windowextents.h> |
811 | 35 | 36 | ||
812 | 36 | #include <clip-groups.h> | 37 | #include <clip-groups.h> |
813 | 38 | #include <pixmap-requests.h> | ||
814 | 37 | 39 | ||
815 | 38 | #include "decor_options.h" | 40 | #include "decor_options.h" |
816 | 39 | 41 | ||
817 | @@ -76,30 +78,36 @@ | |||
818 | 76 | class DecorTexture { | 78 | class DecorTexture { |
819 | 77 | 79 | ||
820 | 78 | public: | 80 | public: |
822 | 79 | DecorTexture (Pixmap pixmap); | 81 | DecorTexture (DecorPixmapInterface::Ptr pixmap); |
823 | 80 | ~DecorTexture (); | 82 | ~DecorTexture (); |
824 | 81 | 83 | ||
825 | 82 | public: | 84 | public: |
826 | 83 | bool status; | 85 | bool status; |
827 | 84 | int refCount; | 86 | int refCount; |
829 | 85 | Pixmap pixmap; | 87 | DecorPixmapInterface::Ptr pixmap; |
830 | 86 | Damage damage; | 88 | Damage damage; |
831 | 87 | GLTexture::List textures; | 89 | GLTexture::List textures; |
832 | 88 | }; | 90 | }; |
833 | 89 | 91 | ||
834 | 90 | class DecorWindow; | 92 | class DecorWindow; |
835 | 91 | 93 | ||
837 | 92 | class Decoration { | 94 | class Decoration : |
838 | 95 | public DecorationInterface | ||
839 | 96 | { | ||
840 | 93 | 97 | ||
841 | 94 | public: | 98 | public: |
842 | 95 | 99 | ||
843 | 96 | typedef boost::shared_ptr <Decoration> Ptr; | 100 | typedef boost::shared_ptr <Decoration> Ptr; |
844 | 97 | 101 | ||
845 | 102 | static const unsigned int UpdateRequested = 1 << 0; | ||
846 | 103 | static const unsigned int UpdatesPending = 1 << 1; | ||
847 | 104 | |||
848 | 98 | static Decoration::Ptr create (Window id, | 105 | static Decoration::Ptr create (Window id, |
849 | 99 | long *prop, | 106 | long *prop, |
850 | 100 | unsigned int size, | 107 | unsigned int size, |
851 | 101 | unsigned int type, | 108 | unsigned int type, |
853 | 102 | unsigned int nOffset); | 109 | unsigned int nOffset, |
854 | 110 | DecorPixmapRequestorInterface *requestor); | ||
855 | 103 | 111 | ||
856 | 104 | Decoration (int type, | 112 | Decoration (int type, |
857 | 105 | const decor_extents_t &border, | 113 | const decor_extents_t &border, |
858 | @@ -113,10 +121,18 @@ | |||
859 | 113 | unsigned int minHeight, | 121 | unsigned int minHeight, |
860 | 114 | Pixmap pixmap, | 122 | Pixmap pixmap, |
861 | 115 | const boost::shared_array <decor_quad_t> &quad, | 123 | const boost::shared_array <decor_quad_t> &quad, |
863 | 116 | unsigned int nQuad); | 124 | unsigned int nQuad, |
864 | 125 | Window owner, | ||
865 | 126 | DecorPixmapRequestorInterface *); | ||
866 | 117 | 127 | ||
867 | 118 | ~Decoration (); | 128 | ~Decoration (); |
868 | 119 | 129 | ||
869 | 130 | DecorPixmapReceiverInterface & receiverInterface (); | ||
870 | 131 | |||
871 | 132 | unsigned int getFrameType () const; | ||
872 | 133 | unsigned int getFrameState () const; | ||
873 | 134 | unsigned int getFrameActions () const; | ||
874 | 135 | |||
875 | 120 | public: | 136 | public: |
876 | 121 | int refCount; | 137 | int refCount; |
877 | 122 | DecorTexture *texture; | 138 | DecorTexture *texture; |
878 | @@ -133,12 +149,19 @@ | |||
879 | 133 | boost::shared_array <decor_quad_t> quad; | 149 | boost::shared_array <decor_quad_t> quad; |
880 | 134 | int nQuad; | 150 | int nQuad; |
881 | 135 | int type; | 151 | int type; |
882 | 152 | |||
883 | 153 | unsigned int updateState; | ||
884 | 154 | X11DecorPixmapReceiver mPixmapReceiver; | ||
885 | 136 | }; | 155 | }; |
886 | 137 | 156 | ||
888 | 138 | class DecorationList | 157 | class DecorationList : |
889 | 158 | public DecorationListFindMatchingInterface | ||
890 | 139 | { | 159 | { |
891 | 140 | public: | 160 | public: |
893 | 141 | bool updateDecoration (Window id, Atom decorAtom); | 161 | bool updateDecoration (Window id, Atom decorAtom, DecorPixmapRequestorInterface *requestor); |
894 | 162 | DecorationInterface::Ptr findMatchingDecoration(unsigned int frameType, | ||
895 | 163 | unsigned int frameState, | ||
896 | 164 | unsigned int frameActions); | ||
897 | 142 | const Decoration::Ptr & findMatchingDecoration (CompWindow *w, bool sizeCheck); | 165 | const Decoration::Ptr & findMatchingDecoration (CompWindow *w, bool sizeCheck); |
898 | 143 | void clear () | 166 | void clear () |
899 | 144 | { | 167 | { |
900 | @@ -215,6 +238,8 @@ | |||
901 | 215 | Atom shadowColorAtom; | 238 | Atom shadowColorAtom; |
902 | 216 | Atom shadowInfoAtom; | 239 | Atom shadowInfoAtom; |
903 | 217 | Atom decorSwitchWindowAtom; | 240 | Atom decorSwitchWindowAtom; |
904 | 241 | Atom decorPendingAtom; | ||
905 | 242 | Atom decorRequestAtom; | ||
906 | 218 | 243 | ||
907 | 219 | Window dmWin; | 244 | Window dmWin; |
908 | 220 | int dmSupports; | 245 | int dmSupports; |
909 | @@ -229,6 +254,7 @@ | |||
910 | 229 | CompTimer decoratorStart; | 254 | CompTimer decoratorStart; |
911 | 230 | 255 | ||
912 | 231 | MatchedDecorClipGroup mMenusClipGroup; | 256 | MatchedDecorClipGroup mMenusClipGroup; |
913 | 257 | X11DecorPixmapRequestor mRequestor; | ||
914 | 232 | }; | 258 | }; |
915 | 233 | 259 | ||
916 | 234 | class DecorWindow : | 260 | class DecorWindow : |
917 | @@ -335,6 +361,8 @@ | |||
918 | 335 | DecorClipGroupInterface *mClipGroup; | 361 | DecorClipGroupInterface *mClipGroup; |
919 | 336 | CompRegion mOutputRegion; | 362 | CompRegion mOutputRegion; |
920 | 337 | CompRegion mInputRegion; | 363 | CompRegion mInputRegion; |
921 | 364 | |||
922 | 365 | X11DecorPixmapRequestor mRequestor; | ||
923 | 338 | }; | 366 | }; |
924 | 339 | 367 | ||
925 | 340 | class DecorPluginVTable : | 368 | class DecorPluginVTable : |
926 | 341 | 369 | ||
927 | === added directory 'plugins/decor/src/pixmap-requests' | |||
928 | === added file 'plugins/decor/src/pixmap-requests/CMakeLists.txt' | |||
929 | --- plugins/decor/src/pixmap-requests/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
930 | +++ plugins/decor/src/pixmap-requests/CMakeLists.txt 2012-06-15 17:09:21 +0000 | |||
931 | @@ -0,0 +1,62 @@ | |||
932 | 1 | pkg_check_modules ( | ||
933 | 2 | GLIBMM | ||
934 | 3 | REQUIRED | ||
935 | 4 | glibmm-2.4 glib-2.0 | ||
936 | 5 | ) | ||
937 | 6 | |||
938 | 7 | INCLUDE_DIRECTORIES ( | ||
939 | 8 | ${CMAKE_CURRENT_SOURCE_DIR}/include | ||
940 | 9 | ${CMAKE_CURRENT_SOURCE_DIR}/src | ||
941 | 10 | |||
942 | 11 | ${compiz_SOURCE_DIR}/src/point/include | ||
943 | 12 | ${compiz_SOURCE_DIR}/src/rect/include | ||
944 | 13 | ${compiz_SOURCE_DIR}/src/window/geometry/include | ||
945 | 14 | ${compiz_SOURCE_DIR}/src/window/geometry-saver/include | ||
946 | 15 | ${compiz_SOURCE_DIR}/src/window/extents/include | ||
947 | 16 | ${compiz_SOURCE_DIR}/include | ||
948 | 17 | |||
949 | 18 | ${Boost_INCLUDE_DIRS} | ||
950 | 19 | |||
951 | 20 | ${GLIBMM_INCLUDE_DIRS} | ||
952 | 21 | ) | ||
953 | 22 | |||
954 | 23 | LINK_DIRECTORIES (${GLIBMM_LIBRARY_DIRS}) | ||
955 | 24 | |||
956 | 25 | SET ( | ||
957 | 26 | PUBLIC_HEADERS | ||
958 | 27 | ) | ||
959 | 28 | |||
960 | 29 | SET ( | ||
961 | 30 | PRIVATE_HEADERS | ||
962 | 31 | ${CMAKE_CURRENT_SOURCE_DIR}/include/pixmap-requests.h | ||
963 | 32 | ) | ||
964 | 33 | |||
965 | 34 | SET( | ||
966 | 35 | SRCS | ||
967 | 36 | ${CMAKE_CURRENT_SOURCE_DIR}/src/pixmap-requests.cpp | ||
968 | 37 | ) | ||
969 | 38 | |||
970 | 39 | ADD_LIBRARY( | ||
971 | 40 | compiz_decor_pixmap_requests STATIC | ||
972 | 41 | |||
973 | 42 | ${SRCS} | ||
974 | 43 | |||
975 | 44 | ${PUBLIC_HEADERS} | ||
976 | 45 | ${PRIVATE_HEADERS} | ||
977 | 46 | ) | ||
978 | 47 | |||
979 | 48 | if (COMPIZ_BUILD_TESTING) | ||
980 | 49 | ADD_SUBDIRECTORY( ${CMAKE_CURRENT_SOURCE_DIR}/tests ) | ||
981 | 50 | endif (COMPIZ_BUILD_TESTING) | ||
982 | 51 | |||
983 | 52 | SET_TARGET_PROPERTIES( | ||
984 | 53 | compiz_decor_pixmap_requests PROPERTIES | ||
985 | 54 | PUBLIC_HEADER "${PUBLIC_HEADERS}" | ||
986 | 55 | ) | ||
987 | 56 | |||
988 | 57 | TARGET_LINK_LIBRARIES( | ||
989 | 58 | compiz_decor_pixmap_requests | ||
990 | 59 | |||
991 | 60 | compiz_core | ||
992 | 61 | ${GLIBMM_LIBRARIES} | ||
993 | 62 | ) | ||
994 | 0 | 63 | ||
995 | === added directory 'plugins/decor/src/pixmap-requests/include' | |||
996 | === added file 'plugins/decor/src/pixmap-requests/include/pixmap-requests.h' | |||
997 | --- plugins/decor/src/pixmap-requests/include/pixmap-requests.h 1970-01-01 00:00:00 +0000 | |||
998 | +++ plugins/decor/src/pixmap-requests/include/pixmap-requests.h 2012-06-15 17:09:21 +0000 | |||
999 | @@ -0,0 +1,188 @@ | |||
1000 | 1 | /* | ||
1001 | 2 | * Copyright © 2005 Novell, Inc. | ||
1002 | 3 | * | ||
1003 | 4 | * Permission to use, copy, modify, distribute, and sell this software | ||
1004 | 5 | * and its documentation for any purpose is hereby granted without | ||
1005 | 6 | * fee, provided that the above copyright notice appear in all copies | ||
1006 | 7 | * and that both that copyright notice and this permission notice | ||
1007 | 8 | * appear in supporting documentation, and that the name of | ||
1008 | 9 | * Novell, Inc. not be used in advertising or publicity pertaining to | ||
1009 | 10 | * distribution of the software without specific, written prior permission. | ||
1010 | 11 | * Novell, Inc. makes no representations about the suitability of this | ||
1011 | 12 | * software for any purpose. It is provided "as is" without express or | ||
1012 | 13 | * implied warranty. | ||
1013 | 14 | * | ||
1014 | 15 | * NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, | ||
1015 | 16 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN | ||
1016 | 17 | * NO EVENT SHALL NOVELL, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR | ||
1017 | 18 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS | ||
1018 | 19 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, | ||
1019 | 20 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION | ||
1020 | 21 | * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
1021 | 22 | * | ||
1022 | 23 | * Author: David Reveman <davidr@novell.com> | ||
1023 | 24 | */ | ||
1024 | 25 | |||
1025 | 26 | #ifndef _COMPIZ_DECOR_PIXMAP_REQUESTS_H | ||
1026 | 27 | #define _COMPIZ_DECOR_PIXMAP_REQUESTS_H | ||
1027 | 28 | |||
1028 | 29 | #include <boost/shared_ptr.hpp> | ||
1029 | 30 | #include <boost/shared_array.hpp> | ||
1030 | 31 | #include <boost/make_shared.hpp> | ||
1031 | 32 | #include <decoration.h> | ||
1032 | 33 | |||
1033 | 34 | #include <X11/Xlib.h> | ||
1034 | 35 | |||
1035 | 36 | class DecorPixmapInterface | ||
1036 | 37 | { | ||
1037 | 38 | public: | ||
1038 | 39 | |||
1039 | 40 | typedef boost::shared_ptr <DecorPixmapInterface> Ptr; | ||
1040 | 41 | |||
1041 | 42 | virtual ~DecorPixmapInterface () {}; | ||
1042 | 43 | |||
1043 | 44 | virtual Pixmap getPixmap () = 0; | ||
1044 | 45 | }; | ||
1045 | 46 | |||
1046 | 47 | class DecorPixmapReceiverInterface | ||
1047 | 48 | { | ||
1048 | 49 | public: | ||
1049 | 50 | |||
1050 | 51 | virtual ~DecorPixmapReceiverInterface () {} | ||
1051 | 52 | |||
1052 | 53 | virtual void pending () = 0; | ||
1053 | 54 | virtual void update () = 0; | ||
1054 | 55 | }; | ||
1055 | 56 | |||
1056 | 57 | /* So far, nothing particularly interesting here | ||
1057 | 58 | * we just need a way to pass around pointers for | ||
1058 | 59 | * testing */ | ||
1059 | 60 | class DecorationInterface | ||
1060 | 61 | { | ||
1061 | 62 | public: | ||
1062 | 63 | |||
1063 | 64 | typedef boost::shared_ptr <DecorationInterface> Ptr; | ||
1064 | 65 | |||
1065 | 66 | virtual ~DecorationInterface () {} | ||
1066 | 67 | |||
1067 | 68 | virtual DecorPixmapReceiverInterface & receiverInterface () = 0; | ||
1068 | 69 | virtual unsigned int getFrameType () const = 0; | ||
1069 | 70 | virtual unsigned int getFrameState () const = 0; | ||
1070 | 71 | virtual unsigned int getFrameActions () const = 0; | ||
1071 | 72 | }; | ||
1072 | 73 | |||
1073 | 74 | class DecorPixmapDeletionInterface | ||
1074 | 75 | { | ||
1075 | 76 | public: | ||
1076 | 77 | |||
1077 | 78 | typedef boost::shared_ptr <DecorPixmapDeletionInterface> Ptr; | ||
1078 | 79 | |||
1079 | 80 | virtual ~DecorPixmapDeletionInterface () {} | ||
1080 | 81 | |||
1081 | 82 | virtual int postDeletePixmap (Pixmap pixmap) = 0; | ||
1082 | 83 | }; | ||
1083 | 84 | |||
1084 | 85 | class X11PixmapDeletor : | ||
1085 | 86 | public DecorPixmapDeletionInterface | ||
1086 | 87 | { | ||
1087 | 88 | public: | ||
1088 | 89 | |||
1089 | 90 | typedef boost::shared_ptr <X11PixmapDeletor> Ptr; | ||
1090 | 91 | |||
1091 | 92 | X11PixmapDeletor (Display *dpy) : | ||
1092 | 93 | mDisplay (dpy) | ||
1093 | 94 | { | ||
1094 | 95 | } | ||
1095 | 96 | |||
1096 | 97 | int postDeletePixmap (Pixmap pixmap) { return decor_post_delete_pixmap (mDisplay, pixmap); } | ||
1097 | 98 | |||
1098 | 99 | private: | ||
1099 | 100 | |||
1100 | 101 | Display *mDisplay; | ||
1101 | 102 | }; | ||
1102 | 103 | |||
1103 | 104 | class DecorPixmap : | ||
1104 | 105 | public DecorPixmapInterface | ||
1105 | 106 | { | ||
1106 | 107 | public: | ||
1107 | 108 | |||
1108 | 109 | typedef boost::shared_ptr <DecorPixmap> Ptr; | ||
1109 | 110 | |||
1110 | 111 | DecorPixmap (Pixmap p, DecorPixmapDeletionInterface::Ptr deletor); | ||
1111 | 112 | ~DecorPixmap (); | ||
1112 | 113 | |||
1113 | 114 | Pixmap getPixmap (); | ||
1114 | 115 | |||
1115 | 116 | private: | ||
1116 | 117 | |||
1117 | 118 | Pixmap mPixmap; | ||
1118 | 119 | DecorPixmapDeletionInterface::Ptr mDeletor; | ||
1119 | 120 | }; | ||
1120 | 121 | |||
1121 | 122 | class DecorPixmapRequestorInterface | ||
1122 | 123 | { | ||
1123 | 124 | public: | ||
1124 | 125 | |||
1125 | 126 | virtual ~DecorPixmapRequestorInterface () {} | ||
1126 | 127 | |||
1127 | 128 | virtual int postGenerateRequest (unsigned int frameType, | ||
1128 | 129 | unsigned int frameState, | ||
1129 | 130 | unsigned int frameActions) = 0; | ||
1130 | 131 | |||
1131 | 132 | virtual void handlePending (long *data) = 0; | ||
1132 | 133 | }; | ||
1133 | 134 | |||
1134 | 135 | class DecorationListFindMatchingInterface | ||
1135 | 136 | { | ||
1136 | 137 | public: | ||
1137 | 138 | |||
1138 | 139 | virtual ~DecorationListFindMatchingInterface () {} | ||
1139 | 140 | |||
1140 | 141 | virtual DecorationInterface::Ptr findMatchingDecoration (unsigned int frameType, | ||
1141 | 142 | unsigned int frameState, | ||
1142 | 143 | unsigned int frameActions) = 0; | ||
1143 | 144 | }; | ||
1144 | 145 | |||
1145 | 146 | class X11DecorPixmapRequestor : | ||
1146 | 147 | public DecorPixmapRequestorInterface | ||
1147 | 148 | { | ||
1148 | 149 | public: | ||
1149 | 150 | |||
1150 | 151 | X11DecorPixmapRequestor (Display *dpy, | ||
1151 | 152 | Window xid, | ||
1152 | 153 | DecorationListFindMatchingInterface *listFinder); | ||
1153 | 154 | |||
1154 | 155 | int postGenerateRequest (unsigned int frameType, | ||
1155 | 156 | unsigned int frameState, | ||
1156 | 157 | unsigned int frameActions); | ||
1157 | 158 | |||
1158 | 159 | void handlePending (long *data); | ||
1159 | 160 | |||
1160 | 161 | private: | ||
1161 | 162 | |||
1162 | 163 | Display *mDpy; | ||
1163 | 164 | Window mWindow; | ||
1164 | 165 | DecorationListFindMatchingInterface *mListFinder; | ||
1165 | 166 | }; | ||
1166 | 167 | |||
1167 | 168 | class X11DecorPixmapReceiver : | ||
1168 | 169 | public DecorPixmapReceiverInterface | ||
1169 | 170 | { | ||
1170 | 171 | public: | ||
1171 | 172 | |||
1172 | 173 | static const unsigned int UpdateRequested = 1 << 0; | ||
1173 | 174 | static const unsigned int UpdatesPending = 1 << 1; | ||
1174 | 175 | |||
1175 | 176 | X11DecorPixmapReceiver (DecorPixmapRequestorInterface *, | ||
1176 | 177 | DecorationInterface *decor); | ||
1177 | 178 | |||
1178 | 179 | void pending (); | ||
1179 | 180 | void update (); | ||
1180 | 181 | private: | ||
1181 | 182 | |||
1182 | 183 | unsigned int mUpdateState; | ||
1183 | 184 | DecorPixmapRequestorInterface *mDecorPixmapRequestor; | ||
1184 | 185 | DecorationInterface *mDecoration; | ||
1185 | 186 | }; | ||
1186 | 187 | |||
1187 | 188 | #endif | ||
1188 | 0 | 189 | ||
1189 | === added directory 'plugins/decor/src/pixmap-requests/src' | |||
1190 | === added file 'plugins/decor/src/pixmap-requests/src/pixmap-requests.cpp' | |||
1191 | --- plugins/decor/src/pixmap-requests/src/pixmap-requests.cpp 1970-01-01 00:00:00 +0000 | |||
1192 | +++ plugins/decor/src/pixmap-requests/src/pixmap-requests.cpp 2012-06-15 17:09:21 +0000 | |||
1193 | @@ -0,0 +1,93 @@ | |||
1194 | 1 | #include "pixmap-requests.h" | ||
1195 | 2 | #include <boost/foreach.hpp> | ||
1196 | 3 | #include <algorithm> | ||
1197 | 4 | |||
1198 | 5 | #ifndef foreach | ||
1199 | 6 | #define foreach BOOST_FOREACH | ||
1200 | 7 | #endif | ||
1201 | 8 | |||
1202 | 9 | DecorPixmap::DecorPixmap (Pixmap pixmap, DecorPixmapDeletionInterface::Ptr d) : | ||
1203 | 10 | mPixmap (pixmap), | ||
1204 | 11 | mDeletor (d) | ||
1205 | 12 | { | ||
1206 | 13 | } | ||
1207 | 14 | |||
1208 | 15 | DecorPixmap::~DecorPixmap () | ||
1209 | 16 | { | ||
1210 | 17 | mDeletor->postDeletePixmap (mPixmap); | ||
1211 | 18 | } | ||
1212 | 19 | |||
1213 | 20 | Pixmap | ||
1214 | 21 | DecorPixmap::getPixmap () | ||
1215 | 22 | { | ||
1216 | 23 | return mPixmap; | ||
1217 | 24 | } | ||
1218 | 25 | |||
1219 | 26 | X11DecorPixmapReceiver::X11DecorPixmapReceiver (DecorPixmapRequestorInterface *requestor, | ||
1220 | 27 | DecorationInterface *decor) : | ||
1221 | 28 | mUpdateState (0), | ||
1222 | 29 | mDecorPixmapRequestor (requestor), | ||
1223 | 30 | mDecoration (decor) | ||
1224 | 31 | { | ||
1225 | 32 | } | ||
1226 | 33 | |||
1227 | 34 | void | ||
1228 | 35 | X11DecorPixmapReceiver::pending () | ||
1229 | 36 | { | ||
1230 | 37 | if (mUpdateState & X11DecorPixmapReceiver::UpdateRequested) | ||
1231 | 38 | mUpdateState |= X11DecorPixmapReceiver::UpdatesPending; | ||
1232 | 39 | else | ||
1233 | 40 | { | ||
1234 | 41 | mUpdateState |= X11DecorPixmapReceiver::UpdateRequested; | ||
1235 | 42 | |||
1236 | 43 | mDecorPixmapRequestor->postGenerateRequest (mDecoration->getFrameType (), | ||
1237 | 44 | mDecoration->getFrameState (), | ||
1238 | 45 | mDecoration->getFrameActions ()); | ||
1239 | 46 | } | ||
1240 | 47 | } | ||
1241 | 48 | |||
1242 | 49 | void X11DecorPixmapReceiver::update () | ||
1243 | 50 | { | ||
1244 | 51 | if (mUpdateState & X11DecorPixmapReceiver::UpdatesPending) | ||
1245 | 52 | mDecorPixmapRequestor->postGenerateRequest (mDecoration->getFrameType (), | ||
1246 | 53 | mDecoration->getFrameState (), | ||
1247 | 54 | mDecoration->getFrameActions ()); | ||
1248 | 55 | |||
1249 | 56 | mUpdateState = 0; | ||
1250 | 57 | } | ||
1251 | 58 | |||
1252 | 59 | X11DecorPixmapRequestor::X11DecorPixmapRequestor (Display *dpy, | ||
1253 | 60 | Window window, | ||
1254 | 61 | DecorationListFindMatchingInterface *listFinder) : | ||
1255 | 62 | mDpy (dpy), | ||
1256 | 63 | mWindow (window), | ||
1257 | 64 | mListFinder (listFinder) | ||
1258 | 65 | { | ||
1259 | 66 | } | ||
1260 | 67 | |||
1261 | 68 | int | ||
1262 | 69 | X11DecorPixmapRequestor::postGenerateRequest (unsigned int frameType, | ||
1263 | 70 | unsigned int frameState, | ||
1264 | 71 | unsigned int frameActions) | ||
1265 | 72 | { | ||
1266 | 73 | return decor_post_generate_request (mDpy, | ||
1267 | 74 | mWindow, | ||
1268 | 75 | frameType, | ||
1269 | 76 | frameState, | ||
1270 | 77 | frameActions); | ||
1271 | 78 | } | ||
1272 | 79 | |||
1273 | 80 | void | ||
1274 | 81 | X11DecorPixmapRequestor::handlePending (long *data) | ||
1275 | 82 | { | ||
1276 | 83 | DecorationInterface::Ptr d = mListFinder->findMatchingDecoration (static_cast <unsigned int> (data[0]), | ||
1277 | 84 | static_cast <unsigned int> (data[1]), | ||
1278 | 85 | static_cast <unsigned int> (data[2])); | ||
1279 | 86 | |||
1280 | 87 | if (d) | ||
1281 | 88 | d->receiverInterface ().pending (); | ||
1282 | 89 | else | ||
1283 | 90 | postGenerateRequest (static_cast <unsigned int> (data[0]), | ||
1284 | 91 | static_cast <unsigned int> (data[1]), | ||
1285 | 92 | static_cast <unsigned int> (data[2])); | ||
1286 | 93 | } | ||
1287 | 0 | 94 | ||
1288 | === added directory 'plugins/decor/src/pixmap-requests/tests' | |||
1289 | === added file 'plugins/decor/src/pixmap-requests/tests/CMakeLists.txt' | |||
1290 | --- plugins/decor/src/pixmap-requests/tests/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
1291 | +++ plugins/decor/src/pixmap-requests/tests/CMakeLists.txt 2012-06-15 17:09:21 +0000 | |||
1292 | @@ -0,0 +1,15 @@ | |||
1293 | 1 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}) | ||
1294 | 2 | |||
1295 | 3 | add_executable (compiz_test_decor_pixmap_requests | ||
1296 | 4 | ${CMAKE_CURRENT_SOURCE_DIR}/pixmap-requests/src/test-decor-pixmap-requests.cpp) | ||
1297 | 5 | |||
1298 | 6 | target_link_libraries (compiz_test_decor_pixmap_requests | ||
1299 | 7 | compiz_decor_pixmap_requests | ||
1300 | 8 | decoration | ||
1301 | 9 | ${GTEST_BOTH_LIBRARIES} | ||
1302 | 10 | ${GMOCK_LIBRARY} | ||
1303 | 11 | ${GMOCK_MAIN_LIBRARY} | ||
1304 | 12 | ${CMAKE_THREAD_LIBS_INIT} # Link in pthread. | ||
1305 | 13 | ) | ||
1306 | 14 | |||
1307 | 15 | gtest_add_tests (compiz_test_decor_pixmap_requests "" ${CMAKE_CURRENT_SOURCE_DIR}/pixmap-requests/src/test-decor-pixmap-requests.cpp) | ||
1308 | 0 | 16 | ||
1309 | === added directory 'plugins/decor/src/pixmap-requests/tests/pixmap-requests' | |||
1310 | === added directory 'plugins/decor/src/pixmap-requests/tests/pixmap-requests/src' | |||
1311 | === added file 'plugins/decor/src/pixmap-requests/tests/pixmap-requests/src/test-decor-pixmap-requests.cpp' | |||
1312 | --- plugins/decor/src/pixmap-requests/tests/pixmap-requests/src/test-decor-pixmap-requests.cpp 1970-01-01 00:00:00 +0000 | |||
1313 | +++ plugins/decor/src/pixmap-requests/tests/pixmap-requests/src/test-decor-pixmap-requests.cpp 2012-06-15 17:09:21 +0000 | |||
1314 | @@ -0,0 +1,160 @@ | |||
1315 | 1 | /* | ||
1316 | 2 | * Copyright © 2012 Canonical Ltd. | ||
1317 | 3 | * | ||
1318 | 4 | * Permission to use, copy, modify, distribute, and sell this software | ||
1319 | 5 | * and its documentation for any purpose is hereby granted without | ||
1320 | 6 | * fee, provided that the above copyright notice appear in all copies | ||
1321 | 7 | * and that both that copyright notice and this permission notice | ||
1322 | 8 | * appear in supporting documentation, and that the name of | ||
1323 | 9 | * Canonical Ltd. not be used in advertising or publicity pertaining to | ||
1324 | 10 | * distribution of the software without specific, written prior permission. | ||
1325 | 11 | * Canonical Ltd. makes no representations about the suitability of this | ||
1326 | 12 | * software for any purpose. It is provided "as is" without express or | ||
1327 | 13 | * implied warranty. | ||
1328 | 14 | * | ||
1329 | 15 | * CANONICAL, LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, | ||
1330 | 16 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN | ||
1331 | 17 | * NO EVENT SHALL CANONICAL, LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR | ||
1332 | 18 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS | ||
1333 | 19 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, | ||
1334 | 20 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION | ||
1335 | 21 | * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
1336 | 22 | * | ||
1337 | 23 | * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com> | ||
1338 | 24 | */ | ||
1339 | 25 | |||
1340 | 26 | #include <gtest/gtest.h> | ||
1341 | 27 | #include <gmock/gmock.h> | ||
1342 | 28 | #include <iostream> | ||
1343 | 29 | #include "pixmap-requests.h" | ||
1344 | 30 | |||
1345 | 31 | using ::testing::Return; | ||
1346 | 32 | |||
1347 | 33 | class DecorPixmapRequestsTest : | ||
1348 | 34 | public ::testing::Test | ||
1349 | 35 | { | ||
1350 | 36 | }; | ||
1351 | 37 | |||
1352 | 38 | class MockDecorPixmapDeletor : | ||
1353 | 39 | public DecorPixmapDeletionInterface | ||
1354 | 40 | { | ||
1355 | 41 | public: | ||
1356 | 42 | |||
1357 | 43 | MOCK_METHOD1 (postDeletePixmap, int (Pixmap p)); | ||
1358 | 44 | }; | ||
1359 | 45 | |||
1360 | 46 | class MockDecorPixmapReceiver : | ||
1361 | 47 | public DecorPixmapReceiverInterface | ||
1362 | 48 | { | ||
1363 | 49 | public: | ||
1364 | 50 | |||
1365 | 51 | MOCK_METHOD0 (pending, void ()); | ||
1366 | 52 | MOCK_METHOD0 (update, void ()); | ||
1367 | 53 | }; | ||
1368 | 54 | |||
1369 | 55 | class MockDecoration : | ||
1370 | 56 | public DecorationInterface | ||
1371 | 57 | { | ||
1372 | 58 | public: | ||
1373 | 59 | |||
1374 | 60 | MOCK_METHOD0 (receiverInterface, DecorPixmapReceiverInterface & ()); | ||
1375 | 61 | MOCK_CONST_METHOD0 (getFrameType, unsigned int ()); | ||
1376 | 62 | MOCK_CONST_METHOD0 (getFrameState, unsigned int ()); | ||
1377 | 63 | MOCK_CONST_METHOD0 (getFrameActions, unsigned int ()); | ||
1378 | 64 | }; | ||
1379 | 65 | |||
1380 | 66 | class MockDecorationListFindMatching : | ||
1381 | 67 | public DecorationListFindMatchingInterface | ||
1382 | 68 | { | ||
1383 | 69 | public: | ||
1384 | 70 | |||
1385 | 71 | MOCK_METHOD3 (findMatchingDecoration, DecorationInterface::Ptr (unsigned int, unsigned int, unsigned int)); | ||
1386 | 72 | }; | ||
1387 | 73 | |||
1388 | 74 | class MockDecorPixmapRequestor : | ||
1389 | 75 | public DecorPixmapRequestorInterface | ||
1390 | 76 | { | ||
1391 | 77 | public: | ||
1392 | 78 | |||
1393 | 79 | MOCK_METHOD3 (postGenerateRequest, int (unsigned int, unsigned int, unsigned int)); | ||
1394 | 80 | MOCK_METHOD1 (handlePending, void (long *)); | ||
1395 | 81 | }; | ||
1396 | 82 | |||
1397 | 83 | TEST(DecorPixmapRequestsTest, TestDestroyPixmapDeletes) | ||
1398 | 84 | { | ||
1399 | 85 | boost::shared_ptr <MockDecorPixmapDeletor> mockDeletor = boost::make_shared <MockDecorPixmapDeletor> (); | ||
1400 | 86 | DecorPixmap pm (1, boost::shared_static_cast<DecorPixmapDeletionInterface> (mockDeletor)); | ||
1401 | 87 | |||
1402 | 88 | EXPECT_CALL (*(mockDeletor.get ()), postDeletePixmap (1)).WillOnce (Return (1)); | ||
1403 | 89 | } | ||
1404 | 90 | |||
1405 | 91 | TEST(DecorPixmapRequestsTest, TestPendingGeneratesRequest) | ||
1406 | 92 | { | ||
1407 | 93 | MockDecorPixmapRequestor mockRequestor; | ||
1408 | 94 | MockDecoration mockDecoration; | ||
1409 | 95 | X11DecorPixmapReceiver receiver (&mockRequestor, &mockDecoration); | ||
1410 | 96 | |||
1411 | 97 | EXPECT_CALL (mockDecoration, getFrameActions ()).WillOnce (Return (3)); | ||
1412 | 98 | EXPECT_CALL (mockDecoration, getFrameState ()).WillOnce (Return (2)); | ||
1413 | 99 | EXPECT_CALL (mockDecoration, getFrameType ()).WillOnce (Return (1)); | ||
1414 | 100 | |||
1415 | 101 | EXPECT_CALL (mockRequestor, postGenerateRequest (1, 2, 3)); | ||
1416 | 102 | |||
1417 | 103 | receiver.pending (); | ||
1418 | 104 | } | ||
1419 | 105 | |||
1420 | 106 | TEST(DecorPixmapRequestsTest, TestPendingGeneratesOnlyOneRequest) | ||
1421 | 107 | { | ||
1422 | 108 | MockDecorPixmapRequestor mockRequestor; | ||
1423 | 109 | MockDecoration mockDecoration; | ||
1424 | 110 | X11DecorPixmapReceiver receiver (&mockRequestor, &mockDecoration); | ||
1425 | 111 | |||
1426 | 112 | EXPECT_CALL (mockDecoration, getFrameActions ()).WillOnce (Return (3)); | ||
1427 | 113 | EXPECT_CALL (mockDecoration, getFrameState ()).WillOnce (Return (2)); | ||
1428 | 114 | EXPECT_CALL (mockDecoration, getFrameType ()).WillOnce (Return (1)); | ||
1429 | 115 | |||
1430 | 116 | EXPECT_CALL (mockRequestor, postGenerateRequest (1, 2, 3)); | ||
1431 | 117 | |||
1432 | 118 | receiver.pending (); | ||
1433 | 119 | receiver.pending (); | ||
1434 | 120 | } | ||
1435 | 121 | |||
1436 | 122 | TEST(DecorPixmapRequestsTest, TestUpdateGeneratesRequestIfNewOnePending) | ||
1437 | 123 | { | ||
1438 | 124 | MockDecorPixmapRequestor mockRequestor; | ||
1439 | 125 | MockDecoration mockDecoration; | ||
1440 | 126 | X11DecorPixmapReceiver receiver (&mockRequestor, &mockDecoration); | ||
1441 | 127 | |||
1442 | 128 | EXPECT_CALL (mockDecoration, getFrameActions ()).WillOnce (Return (3)); | ||
1443 | 129 | EXPECT_CALL (mockDecoration, getFrameState ()).WillOnce (Return (2)); | ||
1444 | 130 | EXPECT_CALL (mockDecoration, getFrameType ()).WillOnce (Return (1)); | ||
1445 | 131 | |||
1446 | 132 | EXPECT_CALL (mockRequestor, postGenerateRequest (1, 2, 3)); | ||
1447 | 133 | |||
1448 | 134 | receiver.pending (); | ||
1449 | 135 | receiver.pending (); | ||
1450 | 136 | |||
1451 | 137 | EXPECT_CALL (mockDecoration, getFrameActions ()).WillOnce (Return (3)); | ||
1452 | 138 | EXPECT_CALL (mockDecoration, getFrameState ()).WillOnce (Return (2)); | ||
1453 | 139 | EXPECT_CALL (mockDecoration, getFrameType ()).WillOnce (Return (1)); | ||
1454 | 140 | |||
1455 | 141 | EXPECT_CALL (mockRequestor, postGenerateRequest (1, 2, 3)); | ||
1456 | 142 | |||
1457 | 143 | receiver.update (); | ||
1458 | 144 | } | ||
1459 | 145 | |||
1460 | 146 | TEST(DecorPixmapRequestsTest, TestUpdateGeneratesNoRequestIfNoNewOnePending) | ||
1461 | 147 | { | ||
1462 | 148 | MockDecorPixmapRequestor mockRequestor; | ||
1463 | 149 | MockDecoration mockDecoration; | ||
1464 | 150 | X11DecorPixmapReceiver receiver (&mockRequestor, &mockDecoration); | ||
1465 | 151 | |||
1466 | 152 | EXPECT_CALL (mockDecoration, getFrameActions ()).WillOnce (Return (3)); | ||
1467 | 153 | EXPECT_CALL (mockDecoration, getFrameState ()).WillOnce (Return (2)); | ||
1468 | 154 | EXPECT_CALL (mockDecoration, getFrameType ()).WillOnce (Return (1)); | ||
1469 | 155 | |||
1470 | 156 | EXPECT_CALL (mockRequestor, postGenerateRequest (1, 2, 3)); | ||
1471 | 157 | |||
1472 | 158 | receiver.pending (); | ||
1473 | 159 | receiver.update (); | ||
1474 | 160 | } |
I assume the ABI changes here don't affect Unity builds?... Better to ask a silly question now than later :)