Merge lp:~compiz-team/compiz-core/oneiric.uwd_fixes into lp:~compiz-team/compiz-core/oneiric.new_uwd

Proposed by Sam Spilsbury
Status: Merged
Approved by: Jason Smith
Approved revision: 2798
Merged at revision: 2784
Proposed branch: lp:~compiz-team/compiz-core/oneiric.uwd_fixes
Merge into: lp:~compiz-team/compiz-core/oneiric.new_uwd
Diff against target: 4244 lines (+1202/-1299)
30 files modified
gtk/CMakeLists.txt (+0/-5)
gtk/config.h.gtk.in (+0/-25)
gtk/window-decorator/CMakeLists.txt (+3/-156)
gtk/window-decorator/config.h.gtk.in (+0/-25)
gtk/window-decorator/decoration-test.c (+0/-537)
gtk/window-decorator/decoration-test.h (+8/-5)
gtk/window-decorator/decoration_inspector/CMakeLists.txt (+3/-1)
gtk/window-decorator/decoration_inspector/decoration_inspector.c (+17/-19)
gtk/window-decorator/simple_decorator/CMakeLists.txt (+3/-1)
gtk/window-decorator/simple_decorator/simple-decorator.c (+4/-0)
gtk/window-decorator/src/CMakeLists.txt (+155/-0)
gtk/window-decorator/src/cairo.c (+7/-6)
gtk/window-decorator/src/config.h.gtk.in (+25/-0)
gtk/window-decorator/src/decorator.c (+6/-46)
gtk/window-decorator/src/events.c (+187/-106)
gtk/window-decorator/src/frames.c (+2/-0)
gtk/window-decorator/src/gtk-window-decorator.c (+21/-17)
gtk/window-decorator/src/gtk-window-decorator.h (+27/-14)
gtk/window-decorator/src/metacity.c (+209/-90)
gtk/window-decorator/src/settings.c (+0/-2)
gtk/window-decorator/src/switcher.c (+1/-1)
gtk/window-decorator/src/util.c (+10/-0)
gtk/window-decorator/src/wnck.c (+120/-97)
gtk/window-decorator/test-cache.c (+0/-116)
gtk/window-decorator/test-cache/CMakeLists.txt (+9/-0)
gtk/window-decorator/test-cache/test-cache.c (+116/-0)
include/decoration.h (+66/-2)
libdecoration/decoration.c (+32/-1)
plugins/decor/src/decor.cpp (+168/-27)
plugins/decor/src/decor.h (+3/-0)
To merge this branch: bzr merge lp:~compiz-team/compiz-core/oneiric.uwd_fixes
Reviewer Review Type Date Requested Status
Jason Smith (community) Approve
Review via email: mp+72196@code.launchpad.net

This proposal supersedes a proposal from 2011-08-16.

Description of the change

Various UWD fixes to get the review process started. Needs LP bug references.

To post a comment you must log in.
Revision history for this message
Jason Smith (jassmith) wrote : Posted in a previous version of this proposal

+1, have tested and read code, nothing stuck out

review: Approve
Revision history for this message
Jason Smith (jassmith) wrote :

+1 again

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'gtk/CMakeLists.txt'
--- gtk/CMakeLists.txt 2011-08-11 08:56:52 +0000
+++ gtk/CMakeLists.txt 2011-08-19 15:05:12 +0000
@@ -42,10 +42,5 @@
42 compiz_set (USE_GNOME_KEYBINDINGS 0)42 compiz_set (USE_GNOME_KEYBINDINGS 0)
43endif (NOT USE_GNOME)43endif (NOT USE_GNOME)
4444
45configure_file (
46 ${CMAKE_CURRENT_SOURCE_DIR}/config.h.gtk.in
47 ${CMAKE_CURRENT_BINARY_DIR}/config.h
48)
49
50add_subdirectory (gnome)45add_subdirectory (gnome)
51add_subdirectory (window-decorator)46add_subdirectory (window-decorator)
5247
=== removed file 'gtk/config.h.gtk.in'
--- gtk/config.h.gtk.in 2008-10-14 10:27:55 +0000
+++ gtk/config.h.gtk.in 1970-01-01 00:00:00 +0000
@@ -1,25 +0,0 @@
1/* Define to 1 if Metacity support is enabled */
2#cmakedefine USE_METACITY 1
3
4/* Define to 1 if Gconf support is enabled */
5#cmakedefine USE_GCONF 1
6
7/* Define to 1 if you have the `wnck_window_has_name' function. */
8#cmakedefine HAVE_WNCK_WINDOW_HAS_NAME 1
9
10/* Define to 1 if libwnck version >= 2_18_1 */
11#cmakedefine HAVE_LIBWNCK_2_18_1 1
12
13/* Define to 1 if libwnck version >= 2_19_4 */
14#cmakedefine HAVE_LIBWNCK_2_19_4 1
15
16/* Define to 1 if metacity version >= 2.15.21 */
17#cmakedefine HAVE_METACITY_2_15_21 1
18
19/* Define to 1 if metacity version >= 2.17.0 */
20#cmakedefine HAVE_METACITY_2_17_0 1
21
22/* Define to 1 if metacity version >= 2.23.2 */
23#cmakedefine HAVE_METACITY_2_23_2 1
24
25#define GETTEXT_PACKAGE "${GETTEXT_PACKAGE}"
260
=== modified file 'gtk/window-decorator/CMakeLists.txt'
--- gtk/window-decorator/CMakeLists.txt 2011-08-11 16:42:06 +0000
+++ gtk/window-decorator/CMakeLists.txt 2011-08-19 15:05:12 +0000
@@ -36,162 +36,9 @@
36 pangocairo36 pangocairo
37 )37 )
38 if (UNITY_WINDOW_DECORATOR_FOUND)38 if (UNITY_WINDOW_DECORATOR_FOUND)
39 include (CheckFunctionExists)39
40 set (CMAKE_REQUIRED_FLAGS ${UNITY_WINDOW_DECORATOR_CFLAGS})40 add_subdirectory (test-cache)
41 set (CMAKE_REQUIRED_LIBRARIES ${UNITY_WINDOW_DECORATOR_LIBRARIES})41 add_subdirectory (src)
42 list (FIND CMAKE_REQUIRED_FLAGS "-D_REENTRANT" REENTRANT_INDEX)
43 if (REENTRANT_INDEX)
44 list (REMOVE_AT CMAKE_REQUIRED_FLAGS REENTRANT_INDEX)
45 list (APPEND CMAKE_REQUIRED_FLAGS "-D_REENTRANT=1")
46 endif (REENTRANT_INDEX)
47 check_function_exists (wnck_window_has_name HAVE_WNCK_WINDOW_HAS_NAME)
48 set (CMAKE_REQUIRED_FLAGS "")
49 set (CMAKE_REQUIRED_LIBRARIES "")
50
51 compiz_pkg_check_modules (HAVE_LIBWNCK_2_18_1 libwnck-1.0>=2.18.1)
52 compiz_pkg_check_modules (HAVE_LIBWNCK_2_19_4 libwnck-1.0>=2.19.4)
53
54 if (BUILD_METACITY)
55 pkg_check_modules (METACITY libmetacity-private)
56 if (METACITY_FOUND)
57 compiz_pkg_check_modules (HAVE_METACITY_2_15_21 libmetacity-private>=2.15.21)
58 compiz_pkg_check_modules (HAVE_METACITY_2_17_0 libmetacity-private>=2.17.0)
59 compiz_pkg_check_modules (HAVE_METACITY_2_23_2 libmetacity-private>=2.23.2)
60 else (METACITY_FOUND)
61 compiz_set (USE_METACITY 0)
62 endif (METACITY_FOUND)
63 endif (BUILD_METACITY)
64
65 if (COMPIZ_BUILD_WITH_RPATH)
66 set (CMAKE_INSTALL_RPATH ${libdir})
67 endif (COMPIZ_BUILD_WITH_RPATH)
68
69 configure_file (
70 ${CMAKE_CURRENT_SOURCE_DIR}/config.h.gtk.in
71 ${CMAKE_CURRENT_BINARY_DIR}/config.h
72 )
73
74 include_directories (
75 ${compiz_SOURCE_DIR}/include
76 ${CMAKE_CURRENT_BINARY_DIR}
77 ${UNITY_WINDOW_DECORATOR_INCLUDE_DIRS}
78 ${METACITY_INCLUDE_DIRS}
79 ${GCONF_INCLUDE_DIRS}
80 ${DBUS_GLIB_INCLUDE_DIRS}
81 )
82
83 add_definitions (
84 -DHAVE_CONFIG_H
85 -DALL_LINGUAS=\"${ALL_LINGUAS}\"
86 -DLOCALEDIR=\\\"${datadir}/locale\\\"
87 )
88
89 link_directories (
90 ${UNITY_WINDOW_DECORATOR_LIBRARY_DIRS}
91 ${COMPIZ_LINK_DIRS}
92 )
93
94 if (USE_GCONF_UNITY_WINDOW_DECORATOR)
95
96 if (NOT COMPIZ_INSTALL_GCONF_SCHEMA_DIR)
97 set (SCHEMADIR "${CMAKE_INSTALL_PREFIX}/share/gconf/schemas")
98 else (NOT COMPIZ_INSTALL_GCONF_SCHEMA_DIR)
99 set (SCHEMADIR "${COMPIZ_INSTALL_GCONF_SCHEMA_DIR}")
100 endif (NOT COMPIZ_INSTALL_GCONF_SCHEMA_DIR)
101
102 set (gwd_schema ${CMAKE_CURRENT_BINARY_DIR}/gwd.schemas)
103
104 compiz_translate_xml (
105 ${CMAKE_CURRENT_SOURCE_DIR}/gwd.schemas.in
106 ${gwd_schema}
107 )
108
109 compiz_install_gconf_schema (${CMAKE_CURRENT_BINARY_DIR}/gwd.schemas ${SCHEMADIR})
110
111 endif (USE_GCONF_UNITY_WINDOW_DECORATOR)
112
113 add_executable (unity-window-decorator
114 gtk-window-decorator.c
115 blurprops.c
116 decorprops.c
117 cairo.c
118 gdk.c
119 switcher.c
120 metacity.c
121 events.c
122 forcequit.c
123 actionmenu.c
124 settings.c
125 util.c
126 style.c
127 wnck.c
128 decorator.c
129 frames.c
130 ${gwd_schema}
131 )
132
133 add_executable (gtk-window-decorator
134 gtk-window-decorator.c
135 blurprops.c
136 decorprops.c
137 cairo.c
138 gdk.c
139 switcher.c
140 metacity.c
141 events.c
142 forcequit.c
143 actionmenu.c
144 settings.c
145 util.c
146 style.c
147 wnck.c
148 decorator.c
149 frames.c
150 ${gwd_schema}
151 )
152
153 if (USE_METACITY)
154 set (metacitylibs ${METACITY_LIBRARIES})
155 endif (USE_METACITY)
156
157 set_target_properties (
158 unity-window-decorator PROPERTIES
159 INSTALL_RPATH_USE_LINK_PATH 0
160 )
161
162 target_link_libraries (unity-window-decorator
163 decoration
164 ${UNITY_WINDOW_DECORATOR_LIBRARIES}
165 ${GCONF_LIBRARIES}
166 ${DBUS_GLIB_LIBRARIES}
167 ${metacitylibs}
168 )
169
170 install (
171 TARGETS unity-window-decorator
172 DESTINATION ${COMPIZ_DESTDIR}${exec_prefix}
173 RUNTIME DESTINATION bin
174 )
175
176 set_target_properties (
177 gtk-window-decorator PROPERTIES
178 INSTALL_RPATH_USE_LINK_PATH 0
179 )
180
181 target_link_libraries (gtk-window-decorator
182 decoration
183 ${UNITY_WINDOW_DECORATOR_LIBRARIES}
184 ${GCONF_LIBRARIES}
185 ${DBUS_GLIB_LIBRARIES}
186 ${metacitylibs}
187 )
188
189 install (
190 TARGETS gtk-window-decorator
191 DESTINATION ${COMPIZ_DESTDIR}${exec_prefix}
192 RUNTIME DESTINATION bin
193 )
194
195 add_subdirectory (simple_decorator)42 add_subdirectory (simple_decorator)
196 add_subdirectory (decoration_inspector)43 add_subdirectory (decoration_inspector)
19744
19845
=== removed file 'gtk/window-decorator/config.h.gtk.in'
--- gtk/window-decorator/config.h.gtk.in 2011-08-11 08:56:52 +0000
+++ gtk/window-decorator/config.h.gtk.in 1970-01-01 00:00:00 +0000
@@ -1,25 +0,0 @@
1/* Define to 1 if Metacity support is enabled */
2#cmakedefine USE_METACITY 1
3
4/* Define to 1 if Gconf support is enabled */
5#cmakedefine USE_GCONF 1
6
7/* Define to 1 if you have the `wnck_window_has_name' function. */
8#cmakedefine HAVE_WNCK_WINDOW_HAS_NAME 1
9
10/* Define to 1 if libwnck version >= 2_18_1 */
11#cmakedefine HAVE_LIBWNCK_2_18_1 1
12
13/* Define to 1 if libwnck version >= 2_19_4 */
14#cmakedefine HAVE_LIBWNCK_2_19_4 1
15
16/* Define to 1 if metacity version >= 2.15.21 */
17#cmakedefine HAVE_METACITY_2_15_21 1
18
19/* Define to 1 if metacity version >= 2.17.0 */
20#cmakedefine HAVE_METACITY_2_17_0 1
21
22/* Define to 1 if metacity version >= 2.23.2 */
23#cmakedefine HAVE_METACITY_2_23_2 1
24
25#define GETTEXT_PACKAGE "${GETTEXT_PACKAGE}"
260
=== added file 'gtk/window-decorator/decoration-test.c'
--- gtk/window-decorator/decoration-test.c 1970-01-01 00:00:00 +0000
+++ gtk/window-decorator/decoration-test.c 2011-08-19 15:05:12 +0000
@@ -0,0 +1,540 @@
1/*
2 * decoration-test.h
3 *
4 * Copyright (c) 2011 Canonical Ltd.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 *
19 * Authored by:
20 * Sam Spilsbury <sam.spilsbury@canonical.com>
21 */
22#ifndef _GNU_SOURCE
23#define _GNU_SOURCE
24#endif
25#include "decoration-test.h"
26
27
28int fasprintf (char **strret, const char *fmt, ... )
29{
30 char *orig = NULL;
31 int ret = 1;
32
33 if (*strret)
34 orig = *strret;
35
36 va_list args;
37 va_start (args, fmt);
38 ret = vasprintf (strret, fmt, args);
39 va_end (args);
40
41 if (orig)
42 free (orig);
43
44 return ret;
45}
46
47
48char *
49print_gravity (void *d)
50{
51 char *str = NULL;
52 int gravity = *((int *) d);
53 fasprintf (&str, "");
54
55 if (gravity & GRAVITY_WEST)
56 fasprintf (&str, "%sGRAVITY_WEST ", str);
57 if (gravity & GRAVITY_EAST)
58 fasprintf (&str, "%sGRAVITY_EAST ", str);
59 if (gravity & GRAVITY_NORTH)
60 fasprintf (&str, "%sGRAVITY_NORTH ", str);
61 if (gravity & GRAVITY_SOUTH)
62 fasprintf (&str, "%sGRAVITY_SOUTH ", str);
63
64 return str;
65}
66
67char *
68print_stretch (void *d)
69{
70 char *str = NULL;
71 int stretch = *((int *) d);
72 fasprintf (&str, "");
73
74 if (stretch & STRETCH_X)
75 fasprintf (&str, "%sSTRETCH_X ", str);
76 if (stretch & STRETCH_Y)
77 fasprintf (&str, "%sSTRETCH_Y ", str);
78
79 return str;
80}
81
82char *
83print_align (void *d)
84{
85 char *str = NULL;
86 int align = *((int *) d);
87 fasprintf (&str, "");
88
89 if (align & ALIGN_LEFT)
90 fasprintf (&str, "%sALIGN_LEFT ", str);
91 if (align & ALIGN_RIGHT)
92 fasprintf (&str, "%sALIGN_RIGHT ", str);
93 if (align & ALIGN_TOP)
94 fasprintf (&str, "%sALIGN_TOP ", str);
95 if (align & ALIGN_BOTTOM)
96 fasprintf (&str, "%sALIGN BOTTOM ", str);
97
98 return str;
99}
100
101char *
102print_clamp (void *d)
103{
104 char *str = NULL;
105 int clamp = *((int *) d);
106 fasprintf (&str, "");
107
108 if (clamp & CLAMP_HORZ)
109 fasprintf (&str, "%sCLAMP_HORZ ", str);
110 if (clamp & CLAMP_VERT)
111 fasprintf (&str, "%sCLAMP_VERT ", str);
112
113 return str;
114}
115
116char *
117print_frame_type (void *d)
118{
119 char *str = NULL;
120 unsigned int frame_type = *((unsigned int *) d);
121 fasprintf (&str, "");
122
123 if (frame_type & DECOR_WINDOW_TYPE_NORMAL)
124 fasprintf (&str, "%sDECOR_WINDOW_TYPE_NORMAL ", str);
125 if (frame_type & DECOR_WINDOW_TYPE_DIALOG)
126 fasprintf (&str, "%sDECOR_WINDOW_TYPE_DIALOG ", str);
127 if (frame_type & DECOR_WINDOW_TYPE_MENU)
128 fasprintf (&str, "%sDECOR_WINDOW_TYPE_MENU ", str);
129 if (frame_type & DECOR_WINDOW_TYPE_UTILITY)
130 fasprintf (&str, "%sDECOR_WINDOW_TYPE_UTILITY ", str);
131 if (frame_type & DECOR_WINDOW_TYPE_BARE)
132 fasprintf (&str, "%sDECOR_WINDOW_TYPE_BARE ", str);
133 if (frame_type & DECOR_WINDOW_TYPE_SWITCHER)
134 fasprintf (&str, "%sDECOR_WINDOW_TYPE_SWITCHER ", str);
135
136 return str;
137}
138
139char *
140print_frame_actions (void *d)
141{
142 char *str = NULL;
143 unsigned int frame_actions = *((unsigned int *) d);
144 fasprintf (&str, "");
145
146 if (frame_actions & DECOR_WINDOW_ACTION_RESIZE_HORZ)
147 fasprintf (&str, "%sDECOR_WINDOW_ACTION_RESIZE_HORZ ", str);
148 if (frame_actions & DECOR_WINDOW_ACTION_RESIZE_VERT)
149 fasprintf (&str, "%sDECOR_WINDOW_ACTION_RESIZE_VERT ", str);
150 if (frame_actions & DECOR_WINDOW_ACTION_CLOSE)
151 fasprintf (&str, "%sDECOR_WINDOW_ACTION_CLOSE ", str);
152 if (frame_actions & DECOR_WINDOW_ACTION_MINIMIZE)
153 fasprintf (&str, "%sDECOR_WINDOW_ACTION_MINIMIZE ", str);
154 if (frame_actions & DECOR_WINDOW_ACTION_UNMINIMIZE)
155 fasprintf (&str, "%sDECOR_WINDOW_ACTION_UNMINIMIZE ", str);
156 if (frame_actions & DECOR_WINDOW_ACTION_MAXIMIZE_HORZ)
157 fasprintf (&str, "%sDECOR_WINDOW_ACTION_MAXIMIZE_HORZ ", str);
158 if (frame_actions & DECOR_WINDOW_ACTION_MAXIMIZE_VERT)
159 fasprintf (&str, "%sDECOR_WINDOW_ACTION_MAXIMIZE_VERT ", str);
160 if (frame_actions & DECOR_WINDOW_ACTION_UNMAXIMIZE_HORZ)
161 fasprintf (&str, "%sDECOR_WINDOW_ACTION_UNMAXIMIZE_HORZ ", str);
162 if (frame_actions & DECOR_WINDOW_ACTION_UNMAXIMIZE_VERT)
163 fasprintf (&str, "%sDECOR_WINDOW_ACTION_UNMAXIMIZE_VERT ", str);
164 if (frame_actions & DECOR_WINDOW_ACTION_SHADE)
165 fasprintf (&str, "%sDECOR_WINDOW_ACTION_SHADE ", str);
166 if (frame_actions & DECOR_WINDOW_ACTION_UNSHADE)
167 fasprintf (&str, "%sDECOR_WINDOW_ACTION_UNSHADE ", str);
168 if (frame_actions & DECOR_WINDOW_ACTION_STICK)
169 fasprintf (&str, "%sDECOR_WINDOW_ACTION_STICK ", str);
170 if (frame_actions & DECOR_WINDOW_ACTION_UNSTICK)
171 fasprintf (&str, "%sDECOR_WINDOW_ACTION_UNSTICK ", str);
172 if (frame_actions & DECOR_WINDOW_ACTION_FULLSCREEN)
173 fasprintf (&str, "%sDECOR_WINDOW_ACTION_FULLSCREEN ", str);
174 if (frame_actions & DECOR_WINDOW_ACTION_ABOVE)
175 fasprintf (&str, "%sDECOR_WINDOW_ACTION_ABOVE ", str);
176 if (frame_actions & DECOR_WINDOW_ACTION_BELOW)
177 fasprintf (&str, "%sDECOR_WINDOW_ACTION_BELOW ", str);
178 if (frame_actions & DECOR_WINDOW_ACTION_MOVE)
179 fasprintf (&str, "%sDECOR_WINDOW_ACTION_MOVE ", str);
180
181 return str;
182}
183
184char *
185print_frame_state (void *d)
186{
187 char *str = NULL;
188 unsigned int frame_state = *((unsigned int *) d);
189 fasprintf (&str, "");
190
191 if (frame_state & DECOR_WINDOW_STATE_FOCUS)
192 fasprintf (&str, "%sDECOR_WINDOW_STATE_FOCUS ", str);
193 if (frame_state & DECOR_WINDOW_STATE_MAXIMIZED_VERT)
194 fasprintf (&str, "%sDECOR_WINDOW_STATE_MAXIMIZED_VERT ", str);
195 if (frame_state & DECOR_WINDOW_STATE_MAXIMIZED_HORZ)
196 fasprintf (&str, "%sDECOR_WINDOW_STATE_MAXIMIZED_HORZ ", str);
197 if (frame_state & DECOR_WINDOW_STATE_SHADED)
198 fasprintf (&str, "%sDECOR_WINDOW_STATE_SHADED ", str);
199 if (frame_state & DECOR_WINDOW_STATE_COMPOSITED)
200 fasprintf (&str, "%sDECOR_WINDOW_STATE_COMPOSITED ", str);
201 if (frame_state & DECOR_WINDOW_STATE_MODAL)
202 fasprintf (&str, "%sDECOR_WINDOW_STATE_MODAL ", str);
203
204 return str;
205}
206
207char *
208print_unsigned_hex (void *d)
209{
210 char *str = NULL;
211 unsigned int hex = *((unsigned int *) d);
212 fasprintf (&str, "");
213
214 fasprintf (&str, "%s0x%x", str, hex);
215
216 return str;
217}
218
219char *
220print_int (void *d)
221{
222 char *str = NULL;
223 unsigned int i = *((unsigned int *) d);
224
225 fasprintf (&str, "%s%i", str, i);
226
227 return str;
228}
229
230char *
231print_box (void *d)
232{
233 decor_point_t *point = ((decor_point_t *) d);
234 char *str = print_gravity ((void *) &(point->gravity));
235 fasprintf (&str, "");
236
237 fasprintf (&str, "%s : x: %i y: %i", str, point->x, point->y);
238
239 return str;
240}
241
242char *
243print_float (void *d)
244{
245 char *str = NULL;
246 float f = *((float *) d);
247
248 fasprintf (&str, "%s%f", str, f);
249
250 return str;
251}
252
253char *
254print_extents (void *d)
255{
256 decor_extents_t *extents = ((decor_extents_t *) d);
257 char *str = NULL;
258 fasprintf (&str, "");
259
260 fasprintf (&str, "%s : left: %i right: %i: top: %i: bottom: %i", str, extents->left, extents->right, extents->top, extents->bottom);
261
262 return str;
263}
264
265void
266dump_decoration_data (long int *d_ptr)
267{
268 unsigned int i;
269
270 printf ("size: wrote: %li\n", *d_ptr++);
271 printf ("type: wrote: %li\n", *d_ptr++);
272 printf ("frame_type: wrote: %li\n", *d_ptr++);
273 printf ("frame_state: wrote: 0x%lx\n", *d_ptr++);
274 printf ("frame_actions: wrote: 0x%lx\n", *d_ptr++);
275 printf ("pixmap: wrote: 0x%lx\n", *d_ptr++);
276
277 printf ("fl: wrote: %li\n", *d_ptr++);
278 printf ("ft: wrote: %li\n", *d_ptr++);
279 printf ("ft: wrote: %li\n", *d_ptr++);
280 printf ("fb: wrote: %li\n", *d_ptr++);
281 printf ("bl: wrote: %li\n", *d_ptr++);
282 printf ("bt: wrote: %li\n", *d_ptr++);
283 printf ("bt: wrote: %li\n", *d_ptr++);
284 printf ("bb: wrote: %li\n", *d_ptr++);
285
286 printf ("min_width: wrote: %li\n", *d_ptr++);
287 printf ("min_height: wrote: %li\n", *d_ptr++);
288
289 i = *d_ptr++;
290 printf ("nQuad: wrote: %li\n", *d_ptr++);
291 while (i--)
292 {
293 printf ("quad %i flags: wrote: 0x%lx ", i, *d_ptr++);
294 int gravityv = *d_ptr;
295 char *gravity = print_gravity (&gravityv);
296 int gravity2v = *d_ptr >> 4;
297 char *gravity2 = print_gravity (&gravity2v);
298 int alignv = *d_ptr >> 8;
299 char *align = print_align (&alignv);
300 int clampv = *d_ptr >> 10;
301 char *clamp = print_clamp (&clampv);
302 int stretchv = *d_ptr >> 12;
303 char *stretch = print_stretch (&stretchv);
304
305 printf ("%s ", gravity);
306 printf ("%s ", gravity2);
307 printf ("%s ", align);
308 printf ("%s ", clamp);
309 printf ("%s ", stretch);
310 printf ("\n");
311
312 free (gravity);
313 free (gravity2);
314 free (align);
315 free (clamp);
316 free (stretch);
317
318 printf ("quad %i p1x: wrote: %li\n", i, *d_ptr++);
319 printf ("quad %i p1y: wrote: %li\n", i, *d_ptr++);
320 printf ("quad %i p2x: wrote: %li\n", i, *d_ptr++);
321 printf ("quad %i p2y: wrote: %li\n", i, *d_ptr++);
322 printf ("quad %i max_width: wrote: %li\n", i, *d_ptr++);
323 printf ("quad %i max_height: wrote: %li\n", i, *d_ptr++);
324 printf ("quad %i matrix x0: wrote: %li\n", i, *d_ptr++);
325 printf ("quad %i matrix y0: wrote: %li\n", i, *d_ptr++);
326 }
327}
328
329void
330dump_decoration (decoration *d)
331{
332 unsigned int i;
333 printf ("decoration * %p contains : \n", d);
334
335 printf ("frame_type: 0x%x\n", d->frame_type);
336 printf ("frame_state: 0x%x\n", d->frame_state);
337 printf ("frame_actions: 0x%x\n", d->frame_actions);
338 printf ("pixmap: 0x%x\n", (unsigned int) d->p);
339 printf ("frame left: %i\n", d->extents.left);
340 printf ("frame right: %i\n", d->extents.right);
341 printf ("frame top: %i\n", d->extents.top);
342 printf ("frame bottom: %i\n", d->extents.bottom);
343 printf ("input left: %i\n", d->extents.left);
344 printf ("input right: %i\n", d->extents.right);
345 printf ("input top: %i\n", d->extents.top);
346 printf ("input bottom: %i\n", d->extents.bottom);
347 printf ("n quads: %i\n", d->nQuad);
348
349 for (i = 0; i < d->nQuad; i++)
350 {
351 int gravityv = d->quads[i].p1.gravity;
352 char *gravity = print_gravity (&gravityv);
353 int gravity2v = d->quads[i].p2.gravity;
354 char *gravity2 = print_gravity (&gravity2v);
355 int alignv = d->quads[i].align;
356 char *align = print_align (&alignv);
357 int clampv = d->quads[i].clamp;
358 char *clamp = print_clamp (&clampv);
359 int stretchv = d->quads[i].stretch;
360 char *stretch = print_stretch (&stretchv);
361
362 printf ("quad %i p1: x: %i\n", i, d->quads[i].p1.x);
363 printf ("quad %i p1: y: %i\n", i, d->quads[i].p1.y);
364 printf ("quad %i p1: gravity: 0x%x ", i, gravityv);
365 printf ("%s ", gravity);
366 printf ("\n");
367
368 printf ("quad %i p2: x: %i\n", i, d->quads[i].p2.x);
369 printf ("quad %i p2: y: %i\n", i, d->quads[i].p2.y);
370 printf ("quad %i p2: gravity: 0x%x ", i, gravity2v);
371 printf ("%s ", gravity2);
372 printf ("\n");
373
374 printf ("quad %i max_width: %i\n", i, d->quads[i].max_width);
375 printf ("quad %i max_height: %i\n", i, d->quads[i].max_height);
376
377 printf ("quad %i align: 0x%x :", i, alignv);
378 printf ("%s ", align);
379 printf ("\n");
380
381 printf ("quad %i clamp: 0x%x :", i, clampv);
382 printf ("%s ", clamp);
383 printf ("\n");
384
385 printf ("quad %i stretch: 0x%x :", i, clampv);
386 printf ("%s ", stretch);
387 printf ("\n");
388
389 printf ("\n");
390
391 free (gravity);
392 free (gravity2);
393 free (align);
394 free (clamp);
395 free (stretch);
396
397 }
398}
399
400void
401destroy_decoration (decoration *d,
402 decor_cache_t *cache)
403{
404 if (!decor_cache_remove_subproperty (cache,
405 d->frame_type,
406 d->frame_state,
407 d->frame_actions,
408 d->property))
409 printf ("can't remove property 0x%x 0x%x 0x%x from %p...\n", d->frame_type, d->frame_state, d->frame_actions, cache->data);
410
411 free (d);
412}
413
414decoration *
415load_decoration_from_property (long int *data)
416{
417 decoration *d = calloc (1, sizeof (decoration));
418
419 /* safe-ish, wouldn't count on it */
420 d->nQuad = decor_pixmap_property_to_quads (data, &d->p, &d->extents, &d->extents, &d->min_width, &d->min_height, &d->frame_type, &d->frame_state, &d->frame_actions, d->quads);
421 // memcpy (&d->property->data, data, sizeof (long int) * data[1]);
422
423 return d;
424}
425
426char *
427data_to_string (long int *data, unsigned int data_size)
428{
429 char *string = NULL;
430 int i = 0;
431
432 fasprintf (&string, "");
433
434 for (; i < data_size; i++)
435 fasprintf (&string, "%s%li, ", string, data[i]);
436
437 return string;
438}
439
440long int *
441string_to_data (const char *string, unsigned int *data_size)
442{
443 char *save;
444 char *tok;
445 char *working;
446 long int *data, *orig_data;
447
448 working = strdup (string);
449
450 *data_size = 0;
451 tok = strtok_r (working, ", ", &save);
452
453 while (tok != NULL)
454 {
455 tok = strtok_r (NULL, ", ", &save);
456 (*data_size)++;
457 }
458
459 free (working);
460
461 orig_data = data = calloc (*data_size + 1, sizeof (long int));
462 working = strdup (string);
463
464 save = NULL;
465
466 *data_size = 0;
467 tok = strtok_r (working, ", ", &save);
468
469 while (tok != NULL)
470 {
471 if (!sscanf (tok, "%li", data))
472 printf ("couldn't parse %s", tok);
473
474 tok = strtok_r (NULL, ", ", &save);
475 data++;
476 }
477
478 free (working);
479
480 return orig_data;
481}
482
483
484decoration *
485create_decoration_from_info (Pixmap p,
486 int el,
487 int er,
488 int et,
489 int eb,
490 int ls,
491 int rs,
492 int ts,
493 int bs,
494 int lcs,
495 int rcs,
496 int tcs,
497 int bcs,
498 int mw,
499 int mh,
500 unsigned int frame_type,
501 unsigned int frame_state,
502 unsigned int frame_actions,
503 decor_cache_t *cache)
504{
505 decoration *d = calloc (1, sizeof (decoration));
506
507 d->p = p;
508
509 d->extents.left = el;
510 d->extents.right = er;
511 d->extents.top = et;
512 d->extents.bottom = eb;
513
514 d->context.extents = d->extents;
515 d->context.left_space = ls;
516 d->context.right_space = rs;
517 d->context.top_space = ts;
518 d->context.bottom_space = bs;
519 d->context.left_corner_space = lcs;
520 d->context.right_corner_space = rcs;
521 d->context.top_corner_space = tcs;
522 d->context.bottom_corner_space = bcs;
523
524 d->min_width = mw;
525 d->min_height = mh;
526
527 d->frame_type = frame_type;
528 d->frame_state = frame_state;
529 d->frame_actions = frame_actions;
530
531 decor_get_default_layout (&d->context, mw, mh, &d->layout);
532 d->nQuad = decor_set_lSrStSbS_window_quads (d->quads, &d->context, &d->layout);
533 d->property = decor_cache_append_pixmap (cache, d->nQuad);
534
535 decor_subproperty_set_pixmap (d->property, d->p, &d->extents, &d->extents,
536 0, 0, d->quads, d->nQuad, d->frame_type,
537 d->frame_state, d->frame_actions);
538
539 return d;
540}
0541
=== removed file 'gtk/window-decorator/decoration-test.c'
--- gtk/window-decorator/decoration-test.c 2011-08-11 08:56:52 +0000
+++ gtk/window-decorator/decoration-test.c 1970-01-01 00:00:00 +0000
@@ -1,537 +0,0 @@
1/*
2 * decoration-test.h
3 *
4 * Copyright (c) 2011 Canonical Ltd.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 *
19 * Authored by:
20 * Sam Spilsbury <sam.spilsbury@canonical.com>
21 */
22
23#include "decoration-test.h"
24
25int fasprintf (char **strret, const char *fmt, ... )
26{
27 char *orig = NULL;
28 int ret = 1;
29
30 if (*strret)
31 orig = *strret;
32
33 va_list args;
34 va_start (args, fmt);
35 ret = vasprintf (strret, fmt, args);
36 va_end (args);
37
38 if (orig)
39 free (orig);
40
41 return ret;
42}
43
44
45char *
46print_gravity (void *d)
47{
48 char *str = NULL;
49 int gravity = *((int *) d);
50 fasprintf (&str, "");
51
52 if (gravity & GRAVITY_WEST)
53 fasprintf (&str, "%sGRAVITY_WEST ", str);
54 if (gravity & GRAVITY_EAST)
55 fasprintf (&str, "%sGRAVITY_EAST ", str);
56 if (gravity & GRAVITY_NORTH)
57 fasprintf (&str, "%sGRAVITY_NORTH ", str);
58 if (gravity & GRAVITY_SOUTH)
59 fasprintf (&str, "%sGRAVITY_SOUTH ", str);
60
61 return str;
62}
63
64char *
65print_stretch (void *d)
66{
67 char *str = NULL;
68 int stretch = *((int *) d);
69 fasprintf (&str, "");
70
71 if (stretch & STRETCH_X)
72 fasprintf (&str, "%sSTRETCH_X ", str);
73 if (stretch & STRETCH_Y)
74 fasprintf (&str, "%sSTRETCH_Y ", str);
75
76 return str;
77}
78
79char *
80print_align (void *d)
81{
82 char *str = NULL;
83 int align = *((int *) d);
84 fasprintf (&str, "");
85
86 if (align & ALIGN_LEFT)
87 fasprintf (&str, "%sALIGN_LEFT ", str);
88 if (align & ALIGN_RIGHT)
89 fasprintf (&str, "%sALIGN_RIGHT ", str);
90 if (align & ALIGN_TOP)
91 fasprintf (&str, "%sALIGN_TOP ", str);
92 if (align & ALIGN_BOTTOM)
93 fasprintf (&str, "%sALIGN BOTTOM ", str);
94
95 return str;
96}
97
98char *
99print_clamp (void *d)
100{
101 char *str = NULL;
102 int clamp = *((int *) d);
103 fasprintf (&str, "");
104
105 if (clamp & CLAMP_HORZ)
106 fasprintf (&str, "%sCLAMP_HORZ ", str);
107 if (clamp & CLAMP_VERT)
108 fasprintf (&str, "%sCLAMP_VERT ", str);
109
110 return str;
111}
112
113char *
114print_frame_type (void *d)
115{
116 char *str = NULL;
117 unsigned int frame_type = *((unsigned int *) d);
118 fasprintf (&str, "");
119
120 if (frame_type & DECOR_WINDOW_TYPE_NORMAL)
121 fasprintf (&str, "%sDECOR_WINDOW_TYPE_NORMAL ", str);
122 if (frame_type & DECOR_WINDOW_TYPE_DIALOG)
123 fasprintf (&str, "%sDECOR_WINDOW_TYPE_DIALOG ", str);
124 if (frame_type & DECOR_WINDOW_TYPE_MENU)
125 fasprintf (&str, "%sDECOR_WINDOW_TYPE_MENU ", str);
126 if (frame_type & DECOR_WINDOW_TYPE_UTILITY)
127 fasprintf (&str, "%sDECOR_WINDOW_TYPE_UTILITY ", str);
128 if (frame_type & DECOR_WINDOW_TYPE_BARE)
129 fasprintf (&str, "%sDECOR_WINDOW_TYPE_BARE ", str);
130 if (frame_type & DECOR_WINDOW_TYPE_SWITCHER)
131 fasprintf (&str, "%sDECOR_WINDOW_TYPE_SWITCHER ", str);
132
133 return str;
134}
135
136char *
137print_frame_actions (void *d)
138{
139 char *str = NULL;
140 unsigned int frame_actions = *((unsigned int *) d);
141 fasprintf (&str, "");
142
143 if (frame_actions & DECOR_WINDOW_ACTION_RESIZE_HORZ)
144 fasprintf (&str, "%sDECOR_WINDOW_ACTION_RESIZE_HORZ ", str);
145 if (frame_actions & DECOR_WINDOW_ACTION_RESIZE_VERT)
146 fasprintf (&str, "%sDECOR_WINDOW_ACTION_RESIZE_VERT ", str);
147 if (frame_actions & DECOR_WINDOW_ACTION_CLOSE)
148 fasprintf (&str, "%sDECOR_WINDOW_ACTION_CLOSE ", str);
149 if (frame_actions & DECOR_WINDOW_ACTION_MINIMIZE)
150 fasprintf (&str, "%sDECOR_WINDOW_ACTION_MINIMIZE ", str);
151 if (frame_actions & DECOR_WINDOW_ACTION_UNMINIMIZE)
152 fasprintf (&str, "%sDECOR_WINDOW_ACTION_UNMINIMIZE ", str);
153 if (frame_actions & DECOR_WINDOW_ACTION_MAXIMIZE_HORZ)
154 fasprintf (&str, "%sDECOR_WINDOW_ACTION_MAXIMIZE_HORZ ", str);
155 if (frame_actions & DECOR_WINDOW_ACTION_MAXIMIZE_VERT)
156 fasprintf (&str, "%sDECOR_WINDOW_ACTION_MAXIMIZE_VERT ", str);
157 if (frame_actions & DECOR_WINDOW_ACTION_UNMAXIMIZE_HORZ)
158 fasprintf (&str, "%sDECOR_WINDOW_ACTION_UNMAXIMIZE_HORZ ", str);
159 if (frame_actions & DECOR_WINDOW_ACTION_UNMAXIMIZE_VERT)
160 fasprintf (&str, "%sDECOR_WINDOW_ACTION_UNMAXIMIZE_VERT ", str);
161 if (frame_actions & DECOR_WINDOW_ACTION_SHADE)
162 fasprintf (&str, "%sDECOR_WINDOW_ACTION_SHADE ", str);
163 if (frame_actions & DECOR_WINDOW_ACTION_UNSHADE)
164 fasprintf (&str, "%sDECOR_WINDOW_ACTION_UNSHADE ", str);
165 if (frame_actions & DECOR_WINDOW_ACTION_STICK)
166 fasprintf (&str, "%sDECOR_WINDOW_ACTION_STICK ", str);
167 if (frame_actions & DECOR_WINDOW_ACTION_UNSTICK)
168 fasprintf (&str, "%sDECOR_WINDOW_ACTION_UNSTICK ", str);
169 if (frame_actions & DECOR_WINDOW_ACTION_FULLSCREEN)
170 fasprintf (&str, "%sDECOR_WINDOW_ACTION_FULLSCREEN ", str);
171 if (frame_actions & DECOR_WINDOW_ACTION_ABOVE)
172 fasprintf (&str, "%sDECOR_WINDOW_ACTION_ABOVE ", str);
173 if (frame_actions & DECOR_WINDOW_ACTION_BELOW)
174 fasprintf (&str, "%sDECOR_WINDOW_ACTION_BELOW ", str);
175 if (frame_actions & DECOR_WINDOW_ACTION_MOVE)
176 fasprintf (&str, "%sDECOR_WINDOW_ACTION_MOVE ", str);
177
178 return str;
179}
180
181char *
182print_frame_state (void *d)
183{
184 char *str = NULL;
185 unsigned int frame_state = *((unsigned int *) d);
186 fasprintf (&str, "");
187
188 if (frame_state & DECOR_WINDOW_STATE_FOCUS)
189 fasprintf (&str, "%sDECOR_WINDOW_STATE_FOCUS ", str);
190 if (frame_state & DECOR_WINDOW_STATE_MAXIMIZED_VERT)
191 fasprintf (&str, "%sDECOR_WINDOW_STATE_MAXIMIZED_VERT ", str);
192 if (frame_state & DECOR_WINDOW_STATE_MAXIMIZED_HORZ)
193 fasprintf (&str, "%sDECOR_WINDOW_STATE_MAXIMIZED_HORZ ", str);
194 if (frame_state & DECOR_WINDOW_STATE_SHADED)
195 fasprintf (&str, "%sDECOR_WINDOW_STATE_SHADED ", str);
196 if (frame_state & DECOR_WINDOW_STATE_COMPOSITED)
197 fasprintf (&str, "%sDECOR_WINDOW_STATE_COMPOSITED ", str);
198 if (frame_state & DECOR_WINDOW_STATE_MODAL)
199 fasprintf (&str, "%sDECOR_WINDOW_STATE_MODAL ", str);
200
201 return str;
202}
203
204char *
205print_unsigned_hex (void *d)
206{
207 char *str = NULL;
208 unsigned int hex = *((unsigned int *) d);
209 fasprintf (&str, "");
210
211 fasprintf (&str, "%s0x%x", str, hex);
212
213 return str;
214}
215
216char *
217print_int (void *d)
218{
219 char *str = NULL;
220 unsigned int i = *((unsigned int *) d);
221
222 fasprintf (&str, "%s%i", str, i);
223
224 return str;
225}
226
227char *
228print_box (void *d)
229{
230 decor_point_t *point = ((decor_point_t *) d);
231 char *str = print_gravity ((void *) &(point->gravity));
232 fasprintf (&str, "");
233
234 fasprintf (&str, "%s : x: %i y: %i", str, point->x, point->y);
235
236 return str;
237}
238
239char *
240print_float (void *d)
241{
242 char *str = NULL;
243 float f = *((float *) d);
244
245 fasprintf (&str, "%s%f", str, f);
246
247 return str;
248}
249
250char *
251print_extents (void *d)
252{
253 decor_extents_t *extents = ((decor_extents_t *) d);
254 char *str = NULL;
255 fasprintf (&str, "");
256
257 fasprintf (&str, "%s : left: %i right: %i: top: %i: bottom: %i", str, extents->left, extents->right, extents->top, extents->bottom);
258
259 return str;
260}
261
262void
263dump_decoration_data (long int *d_ptr)
264{
265 unsigned int i;
266
267 printf ("size: wrote: %li\n", *d_ptr++);
268 printf ("type: wrote: %li\n", *d_ptr++);
269 printf ("frame_type: wrote: %li\n", *d_ptr++);
270 printf ("frame_state: wrote: 0x%lx\n", *d_ptr++);
271 printf ("frame_actions: wrote: 0x%lx\n", *d_ptr++);
272 printf ("pixmap: wrote: 0x%lx\n", *d_ptr++);
273
274 printf ("fl: wrote: %li\n", *d_ptr++);
275 printf ("ft: wrote: %li\n", *d_ptr++);
276 printf ("ft: wrote: %li\n", *d_ptr++);
277 printf ("fb: wrote: %li\n", *d_ptr++);
278 printf ("bl: wrote: %li\n", *d_ptr++);
279 printf ("bt: wrote: %li\n", *d_ptr++);
280 printf ("bt: wrote: %li\n", *d_ptr++);
281 printf ("bb: wrote: %li\n", *d_ptr++);
282
283 printf ("min_width: wrote: %li\n", *d_ptr++);
284 printf ("min_height: wrote: %li\n", *d_ptr++);
285
286 i = *d_ptr++;
287 printf ("nQuad: wrote: %li\n", *d_ptr++);
288 while (i--)
289 {
290 printf ("quad %i flags: wrote: 0x%lx ", i, *d_ptr++);
291 int gravityv = *d_ptr;
292 char *gravity = print_gravity (&gravityv);
293 int gravity2v = *d_ptr >> 4;
294 char *gravity2 = print_gravity (&gravity2v);
295 int alignv = *d_ptr >> 8;
296 char *align = print_align (&alignv);
297 int clampv = *d_ptr >> 10;
298 char *clamp = print_clamp (&clampv);
299 int stretchv = *d_ptr >> 12;
300 char *stretch = print_stretch (&stretchv);
301
302 printf ("%s ", gravity);
303 printf ("%s ", gravity2);
304 printf ("%s ", align);
305 printf ("%s ", clamp);
306 printf ("%s ", stretch);
307 printf ("\n");
308
309 free (gravity);
310 free (gravity2);
311 free (align);
312 free (clamp);
313 free (stretch);
314
315 printf ("quad %i p1x: wrote: %li\n", i, *d_ptr++);
316 printf ("quad %i p1y: wrote: %li\n", i, *d_ptr++);
317 printf ("quad %i p2x: wrote: %li\n", i, *d_ptr++);
318 printf ("quad %i p2y: wrote: %li\n", i, *d_ptr++);
319 printf ("quad %i max_width: wrote: %li\n", i, *d_ptr++);
320 printf ("quad %i max_height: wrote: %li\n", i, *d_ptr++);
321 printf ("quad %i matrix x0: wrote: %li\n", i, *d_ptr++);
322 printf ("quad %i matrix y0: wrote: %li\n", i, *d_ptr++);
323 }
324}
325
326void
327dump_decoration (decoration *d)
328{
329 unsigned int i;
330 printf ("decoration * %p contains : \n", d);
331
332 printf ("frame_type: 0x%x\n", d->frame_type);
333 printf ("frame_state: 0x%x\n", d->frame_state);
334 printf ("frame_actions: 0x%x\n", d->frame_actions);
335 printf ("pixmap: 0x%x\n", d->p);
336 printf ("frame left: %i\n", d->extents.left);
337 printf ("frame right: %i\n", d->extents.right);
338 printf ("frame top: %i\n", d->extents.top);
339 printf ("frame bottom: %i\n", d->extents.bottom);
340 printf ("input left: %i\n", d->extents.left);
341 printf ("input right: %i\n", d->extents.right);
342 printf ("input top: %i\n", d->extents.top);
343 printf ("input bottom: %i\n", d->extents.bottom);
344 printf ("n quads: %i\n", d->nQuad);
345
346 for (i = 0; i < d->nQuad; i++)
347 {
348 int gravityv = d->quads[i].p1.gravity;
349 char *gravity = print_gravity (&gravityv);
350 int gravity2v = d->quads[i].p2.gravity;
351 char *gravity2 = print_gravity (&gravity2v);
352 int alignv = d->quads[i].align;
353 char *align = print_align (&alignv);
354 int clampv = d->quads[i].clamp;
355 char *clamp = print_clamp (&clampv);
356 int stretchv = d->quads[i].stretch;
357 char *stretch = print_stretch (&stretchv);
358
359 printf ("quad %i p1: x: %i\n", i, d->quads[i].p1.x);
360 printf ("quad %i p1: y: %i\n", i, d->quads[i].p1.y);
361 printf ("quad %i p1: gravity: 0x%x ", i, gravityv);
362 printf ("%s ", gravity);
363 printf ("\n");
364
365 printf ("quad %i p2: x: %i\n", i, d->quads[i].p2.x);
366 printf ("quad %i p2: y: %i\n", i, d->quads[i].p2.y);
367 printf ("quad %i p2: gravity: 0x%x ", i, gravity2v);
368 printf ("%s ", gravity2);
369 printf ("\n");
370
371 printf ("quad %i max_width: %i\n", i, d->quads[i].max_width);
372 printf ("quad %i max_height: %i\n", i, d->quads[i].max_height);
373
374 printf ("quad %i align: 0x%x :", i, alignv);
375 printf ("%s ", align);
376 printf ("\n");
377
378 printf ("quad %i clamp: 0x%x :", i, clampv);
379 printf ("%s ", clamp);
380 printf ("\n");
381
382 printf ("quad %i stretch: 0x%x :", i, clampv);
383 printf ("%s ", stretch);
384 printf ("\n");
385
386 printf ("\n");
387
388 free (gravity);
389 free (gravity2);
390 free (align);
391 free (clamp);
392 free (stretch);
393
394 }
395}
396
397void
398destroy_decoration (decoration *d,
399 decor_cache_t *cache)
400{
401 if (!decor_cache_remove_subproperty (cache,
402 d->frame_type,
403 d->frame_state,
404 d->frame_actions,
405 d->property))
406 printf ("can't remove property 0x%x 0x%x 0x%x from %p...\n", d->frame_type, d->frame_state, d->frame_actions, cache->data);
407
408 free (d);
409}
410
411decoration *
412load_decoration_from_property (long int *data)
413{
414 decoration *d = calloc (1, sizeof (decoration));
415
416 /* safe-ish, wouldn't count on it */
417 d->nQuad = decor_pixmap_property_to_quads (data, &d->p, &d->extents, &d->extents, &d->min_width, &d->min_height, &d->frame_type, &d->frame_state, &d->frame_actions, d->quads);
418 // memcpy (&d->property->data, data, sizeof (long int) * data[1]);
419
420 return d;
421}
422
423char *
424data_to_string (long int *data, unsigned int data_size)
425{
426 char *string = NULL;
427 int i = 0;
428
429 fasprintf (&string, "");
430
431 for (; i < data_size; i++)
432 fasprintf (&string, "%s%li, ", string, data[i]);
433
434 return string;
435}
436
437long int *
438string_to_data (const char *string, unsigned int *data_size)
439{
440 char *save;
441 char *tok;
442 char *working;
443 long int *data, *orig_data;
444
445 working = strdup (string);
446
447 *data_size = 0;
448 tok = strtok_r (working, ", ", &save);
449
450 while (tok != NULL)
451 {
452 tok = strtok_r (NULL, ", ", &save);
453 (*data_size)++;
454 }
455
456 free (working);
457
458 orig_data = data = calloc (*data_size + 1, sizeof (long int));
459 working = strdup (string);
460
461 save = NULL;
462
463 *data_size = 0;
464 tok = strtok_r (working, ", ", &save);
465
466 while (tok != NULL)
467 {
468 if (!sscanf (tok, "%li", data))
469 printf ("couldn't parse %s", tok);
470
471 tok = strtok_r (NULL, ", ", &save);
472 data++;
473 }
474
475 free (working);
476
477 return orig_data;
478}
479
480
481decoration *
482create_decoration_from_info (Pixmap p,
483 int el,
484 int er,
485 int et,
486 int eb,
487 int ls,
488 int rs,
489 int ts,
490 int bs,
491 int lcs,
492 int rcs,
493 int tcs,
494 int bcs,
495 int mw,
496 int mh,
497 unsigned int frame_type,
498 unsigned int frame_state,
499 unsigned int frame_actions,
500 decor_cache_t *cache)
501{
502 decoration *d = calloc (1, sizeof (decoration));
503
504 d->p = p;
505
506 d->extents.left = el;
507 d->extents.right = er;
508 d->extents.top = et;
509 d->extents.bottom = eb;
510
511 d->context.extents = d->extents;
512 d->context.left_space = ls;
513 d->context.right_space = rs;
514 d->context.top_space = ts;
515 d->context.bottom_space = bs;
516 d->context.left_corner_space = lcs;
517 d->context.right_corner_space = rcs;
518 d->context.top_corner_space = tcs;
519 d->context.bottom_corner_space = bcs;
520
521 d->min_width = mw;
522 d->min_height = mh;
523
524 d->frame_type = frame_type;
525 d->frame_state = frame_state;
526 d->frame_actions = frame_actions;
527
528 decor_get_default_layout (&d->context, mw, mh, &d->layout);
529 d->nQuad = decor_set_lSrStSbS_window_quads (d->quads, &d->context, &d->layout);
530 d->property = decor_cache_append_pixmap (cache, d->nQuad);
531
532 decor_subproperty_set_pixmap (d->property, d->p, &d->extents, &d->extents,
533 0, 0, d->quads, d->nQuad, d->frame_type,
534 d->frame_state, d->frame_actions);
535
536 return d;
537}
5380
=== modified file 'gtk/window-decorator/decoration-test.h'
--- gtk/window-decorator/decoration-test.h 2011-08-11 08:56:52 +0000
+++ gtk/window-decorator/decoration-test.h 2011-08-19 15:05:12 +0000
@@ -23,21 +23,24 @@
23#ifndef _COMPIZ_DECORATION_TEST_H23#ifndef _COMPIZ_DECORATION_TEST_H
24#define _COMPIZ_DECORATION_TEST_H24#define _COMPIZ_DECORATION_TEST_H
2525
26#include "gtk-window-decorator.h"
27#define _GNU_SOURCE26#define _GNU_SOURCE
28#include <stdio.h>27#include <stdio.h>
29#include <stdarg.h>28#include <stdarg.h>
29#include <decoration.h>
30#include <X11/Xlib.h>
31#include <X11/Xatom.h>
32#include <stdlib.h>
3033
31typedef struct _decoration34typedef struct _decoration
32{35{
33 guint32 frame_type;36 unsigned int frame_type;
34 guint32 frame_state;37 unsigned int frame_state;
35 guint32 frame_actions;38 unsigned int frame_actions;
36 decor_extents_t extents;39 decor_extents_t extents;
37 decor_context_t context;40 decor_context_t context;
38 decor_layout_t layout;41 decor_layout_t layout;
39 decor_quad_t quads[N_QUADS_MAX];42 decor_quad_t quads[N_QUADS_MAX];
40 guint32 nQuad;43 unsigned int nQuad;
41 int min_width;44 int min_width;
42 int min_height;45 int min_height;
43 Pixmap p;46 Pixmap p;
4447
=== modified file 'gtk/window-decorator/decoration_inspector/CMakeLists.txt'
--- gtk/window-decorator/decoration_inspector/CMakeLists.txt 2011-08-11 08:56:52 +0000
+++ gtk/window-decorator/decoration_inspector/CMakeLists.txt 2011-08-19 15:05:12 +0000
@@ -1,5 +1,7 @@
1pkg_check_modules (DECORATION_INSPECTOR REQUIRED gtk+-3.0 libdecoration)1pkg_check_modules (DECORATION_INSPECTOR REQUIRED gtk+-3.0 libdecoration)
2include_directories (${DECORATION_INSPECTOR_INCLUDE_DIRECTORES} ..)2include_directories (${DECORATION_INSPECTOR_INCLUDE_DIRS}
3 ${compiz_SOURCE_DIR}/include
4 ..)
3add_definitions (-DPREFIX=\\\"${CMAKE_INSTALL_PREFIX}\\\")5add_definitions (-DPREFIX=\\\"${CMAKE_INSTALL_PREFIX}\\\")
46
5add_executable (decoration_inspector decoration_inspector.c ../decoration-test.c)7add_executable (decoration_inspector decoration_inspector.c ../decoration-test.c)
68
=== modified file 'gtk/window-decorator/decoration_inspector/decoration_inspector.c'
--- gtk/window-decorator/decoration_inspector/decoration_inspector.c 2011-08-11 08:56:52 +0000
+++ gtk/window-decorator/decoration_inspector/decoration_inspector.c 2011-08-19 15:05:12 +0000
@@ -20,7 +20,14 @@
20 * Sam Spilsbury <sam.spilsbury@canonical.com>20 * Sam Spilsbury <sam.spilsbury@canonical.com>
21 */21 */
2222
23#ifndef _GNU_SOURCE
24#define _GNU_SOURCE
25#endif
23#include <gtk/gtk.h>26#include <gtk/gtk.h>
27#include <gdk/gdk.h>
28#include <gdk/gdkx.h>
29#include <cairo.h>
30#include <cairo-xlib.h>
24#include "decoration-test.h"31#include "decoration-test.h"
2532
26GObject *ib1 = NULL;33GObject *ib1 = NULL;
@@ -63,8 +70,6 @@
63 GdkPixbuf *pb;70 GdkPixbuf *pb;
64 XVisualInfo visual_info;71 XVisualInfo visual_info;
6572
66 printf ("d->p is 0x%x\n", d->p);
67
68 XGetGeometry (xdisplay, d->p, &root, &x, &y, &width, &height, &border, &depth);73 XGetGeometry (xdisplay, d->p, &root, &x, &y, &width, &height, &border, &depth);
69 XMatchVisualInfo (xdisplay, DefaultScreen (xdisplay), 32, TrueColor, &visual_info);74 XMatchVisualInfo (xdisplay, DefaultScreen (xdisplay), 32, TrueColor, &visual_info);
7075
@@ -150,7 +155,6 @@
150 cairo_set_source_rgba (cr, 0.0, 0.0, 1.0, 0.3);155 cairo_set_source_rgba (cr, 0.0, 0.0, 1.0, 0.3);
151156
152 cairo_move_to (cr, 0, 0);157 cairo_move_to (cr, 0, 0);
153 g_debug ("rect: %i %i %i %i p: %i %i", px + x1, py + y1, px + (x2 - x1), py + (y2 - y1), px, py);
154 cairo_rectangle (cr, (px + x1), (py + y1), (x2 - x1), (y2 - y1));158 cairo_rectangle (cr, (px + x1), (py + y1), (x2 - x1), (y2 - y1));
155 cairo_fill (cr);159 cairo_fill (cr);
156160
@@ -202,8 +206,6 @@
202 c.y0 -=206 c.y0 -=
203 y1 * c.yy +207 y1 * c.yy +
204 x1 * c.yx;208 x1 * c.yx;
205
206 printf ("c for quad %i is :\n xx: %f yx %f\n xy: %f yy: %f\n x0: %f y0: %f\n", nQuad, c.xx, c.yx, c.xy, c.yy, c.x0, c.y0);
207209
208 quad++;210 quad++;
209 }211 }
@@ -655,9 +657,6 @@
655 property_type_combo = gtk_builder_get_object (builder, "property_type_combo");657 property_type_combo = gtk_builder_get_object (builder, "property_type_combo");
656658
657 long *ret = NULL;659 long *ret = NULL;
658 const gchar *text = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (property_type_combo));
659
660 g_debug ("%s", text);
661660
662 if (g_strcmp0 ("data", arg) == 0)661 if (g_strcmp0 ("data", arg) == 0)
663 {662 {
@@ -677,8 +676,6 @@
677676
678 sscanf (window_id_string, "0x%x", &window);677 sscanf (window_id_string, "0x%x", &window);
679678
680 g_debug ("window is 0x%x", window);
681
682 if (window)679 if (window)
683 {680 {
684 Display *xdisplay = gdk_x11_display_get_xdisplay (gdk_display_get_default ());681 Display *xdisplay = gdk_x11_display_get_xdisplay (gdk_display_get_default ());
@@ -698,7 +695,9 @@
698695
699 if (result != Success || !n || !data)696 if (result != Success || !n || !data)
700 {697 {
701 fprintf (stderr, "failed to read property %i %i (type %i fmt %i)!\n", n, nleft, actual, format);698 fprintf (stderr, "failed to read property %li %li (type %i fmt %i)!\n", n, nleft,
699 (unsigned int) actual,
700 (unsigned int) format);
702 return NULL;701 return NULL;
703 }702 }
704703
@@ -737,8 +736,6 @@
737 GtkTreeIter iter;736 GtkTreeIter iter;
738 GtkTreePath *last = gtk_tree_path_copy (path);737 GtkTreePath *last = gtk_tree_path_copy (path);
739738
740 g_debug ("activated row");
741
742 if (gtk_tree_model_get_iter (model, &iter, last))739 if (gtk_tree_model_get_iter (model, &iter, last))
743 {740 {
744 gint decoration_num;741 gint decoration_num;
@@ -761,12 +758,13 @@
761 decoration_num = atoi (str);758 decoration_num = atoi (str);
762759
763 data = pos = get_decorations_data (builder);760 data = pos = get_decorations_data (builder);
761
762 if (!data)
763 return;
764 decorations = calloc (decor_property_get_num (data), sizeof (decoration *));764 decorations = calloc (decor_property_get_num (data), sizeof (decoration *));
765765
766 pos += 2;766 pos += 2;
767767
768 g_debug ("there are %i decorations", decor_property_get_num (data));
769
770 for (i = 0 ; i < decor_property_get_num (data); i++)768 for (i = 0 ; i < decor_property_get_num (data); i++)
771 {769 {
772 decorations[i] = load_decoration_from_property (pos);770 decorations[i] = load_decoration_from_property (pos);
@@ -787,7 +785,6 @@
787 GtkBuilder *builder = (GtkBuilder *) user_data;785 GtkBuilder *builder = (GtkBuilder *) user_data;
788 decoration **decorations;786 decoration **decorations;
789 decoration *d;787 decoration *d;
790 decor_cache_t *cache = g_object_get_data (G_OBJECT (builder), "all_decoration_data");
791 long int *data, *pos;788 long int *data, *pos;
792 unsigned int i, j;789 unsigned int i, j;
793 GtkTreeStore *store = gtk_tree_store_new (COLUMN_N, G_TYPE_STRING, G_TYPE_STRING);790 GtkTreeStore *store = gtk_tree_store_new (COLUMN_N, G_TYPE_STRING, G_TYPE_STRING);
@@ -817,12 +814,14 @@
817 gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), NULL);814 gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), NULL);
818815
819 data = pos = get_decorations_data (builder);816 data = pos = get_decorations_data (builder);
817
818 if (!data)
819 return;
820
820 decorations = calloc (decor_property_get_num (data), sizeof (decoration *));821 decorations = calloc (decor_property_get_num (data), sizeof (decoration *));
821822
822 pos += 2;823 pos += 2;
823824
824 g_debug ("there are %i decorations", decor_property_get_num (data));
825
826 for (i = 0 ; i < decor_property_get_num (data); i++)825 for (i = 0 ; i < decor_property_get_num (data); i++)
827 {826 {
828 decorations[i] = load_decoration_from_property (pos);827 decorations[i] = load_decoration_from_property (pos);
@@ -836,7 +835,6 @@
836835
837 asprintf (&label, "Decoration %i:", i);836 asprintf (&label, "Decoration %i:", i);
838 asprintf (&hex_data, "%i", i);837 asprintf (&hex_data, "%i", i);
839 g_debug ("processing: %s", label);
840 gtk_tree_store_append (store, &master_iter, NULL);838 gtk_tree_store_append (store, &master_iter, NULL);
841 gtk_tree_store_set (store, &master_iter, COLUMN_LABEL, label, COLUMN_DATA, hex_data, -1);839 gtk_tree_store_set (store, &master_iter, COLUMN_LABEL, label, COLUMN_DATA, hex_data, -1);
842840
843841
=== modified file 'gtk/window-decorator/simple_decorator/CMakeLists.txt'
--- gtk/window-decorator/simple_decorator/CMakeLists.txt 2011-08-11 08:56:52 +0000
+++ gtk/window-decorator/simple_decorator/CMakeLists.txt 2011-08-19 15:05:12 +0000
@@ -1,5 +1,7 @@
1pkg_check_modules (SIMPLE_DECORATOR REQUIRED x11 cairo-xlib libdecoration libpng)1pkg_check_modules (SIMPLE_DECORATOR REQUIRED x11 cairo-xlib libdecoration libpng)
2include_directories (${SIMPLE_DECORATOR_INCLUDE_DIRECTORES} ..)2include_directories (${SIMPLE_DECORATOR_INCLUDE_DIRS}
3 ${compiz_SOURCE_DIR}/include
4 ..)
3add_definitions (-DPREFIX=\\\"${CMAKE_INSTALL_PREFIX}\\\")5add_definitions (-DPREFIX=\\\"${CMAKE_INSTALL_PREFIX}\\\")
46
5add_executable (simple-decorator simple-decorator.c ../decoration-test.c)7add_executable (simple-decorator simple-decorator.c ../decoration-test.c)
68
=== modified file 'gtk/window-decorator/simple_decorator/simple-decorator.c'
--- gtk/window-decorator/simple_decorator/simple-decorator.c 2011-08-11 08:56:52 +0000
+++ gtk/window-decorator/simple_decorator/simple-decorator.c 2011-08-19 15:05:12 +0000
@@ -29,6 +29,10 @@
29#include <X11/Xatom.h>29#include <X11/Xatom.h>
30#include <cairo/cairo-xlib.h>30#include <cairo/cairo-xlib.h>
31#include <png.h>31#include <png.h>
32#include <signal.h>
33
34#define TRUE 1
35#define FALSE 0
3236
33typedef struct _simple_decoration {37typedef struct _simple_decoration {
34 Display *display;38 Display *display;
3539
=== added directory 'gtk/window-decorator/src'
=== added file 'gtk/window-decorator/src/CMakeLists.txt'
--- gtk/window-decorator/src/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ gtk/window-decorator/src/CMakeLists.txt 2011-08-19 15:05:12 +0000
@@ -0,0 +1,155 @@
1include (CheckFunctionExists)
2set (CMAKE_REQUIRED_FLAGS ${UNITY_WINDOW_DECORATOR_CFLAGS})
3set (CMAKE_REQUIRED_LIBRARIES ${UNITY_WINDOW_DECORATOR_LIBRARIES})
4list (FIND CMAKE_REQUIRED_FLAGS "-D_REENTRANT" REENTRANT_INDEX)
5if (REENTRANT_INDEX)
6 list (REMOVE_AT CMAKE_REQUIRED_FLAGS REENTRANT_INDEX)
7 list (APPEND CMAKE_REQUIRED_FLAGS "-D_REENTRANT=1")
8endif (REENTRANT_INDEX)
9check_function_exists (wnck_window_has_name HAVE_WNCK_WINDOW_HAS_NAME)
10set (CMAKE_REQUIRED_FLAGS "")
11set (CMAKE_REQUIRED_LIBRARIES "")
12
13compiz_pkg_check_modules (HAVE_LIBWNCK_2_18_1 libwnck-1.0>=2.18.1)
14compiz_pkg_check_modules (HAVE_LIBWNCK_2_19_4 libwnck-1.0>=2.19.4)
15
16if (BUILD_METACITY)
17 pkg_check_modules (METACITY libmetacity-private)
18 if (METACITY_FOUND)
19 compiz_pkg_check_modules (HAVE_METACITY_2_15_21 libmetacity-private>=2.15.21)
20 compiz_pkg_check_modules (HAVE_METACITY_2_17_0 libmetacity-private>=2.17.0)
21 compiz_pkg_check_modules (HAVE_METACITY_2_23_2 libmetacity-private>=2.23.2)
22 else (METACITY_FOUND)
23 compiz_set (USE_METACITY 0)
24 endif (METACITY_FOUND)
25endif (BUILD_METACITY)
26
27if (COMPIZ_BUILD_WITH_RPATH)
28 set (CMAKE_INSTALL_RPATH ${libdir})
29endif (COMPIZ_BUILD_WITH_RPATH)
30
31configure_file (
32 ${CMAKE_CURRENT_SOURCE_DIR}/config.h.gtk.in
33 ${CMAKE_CURRENT_BINARY_DIR}/config.h
34)
35
36include_directories (
37 ${compiz_SOURCE_DIR}/include
38 ${CMAKE_CURRENT_BINARY_DIR}
39 ${UNITY_WINDOW_DECORATOR_INCLUDE_DIRS}
40 ${METACITY_INCLUDE_DIRS}
41 ${GCONF_INCLUDE_DIRS}
42 ${DBUS_GLIB_INCLUDE_DIRS}
43)
44
45add_definitions (
46 -DHAVE_CONFIG_H
47 -DALL_LINGUAS=\"${ALL_LINGUAS}\"
48 -DLOCALEDIR=\\\"${datadir}/locale\\\"
49)
50
51link_directories (
52 ${UNITY_WINDOW_DECORATOR_LIBRARY_DIRS}
53 ${COMPIZ_LINK_DIRS}
54)
55
56if (USE_GCONF_UNITY_WINDOW_DECORATOR)
57
58 if (NOT COMPIZ_INSTALL_GCONF_SCHEMA_DIR)
59 set (SCHEMADIR "${CMAKE_INSTALL_PREFIX}/share/gconf/schemas")
60 else (NOT COMPIZ_INSTALL_GCONF_SCHEMA_DIR)
61 set (SCHEMADIR "${COMPIZ_INSTALL_GCONF_SCHEMA_DIR}")
62 endif (NOT COMPIZ_INSTALL_GCONF_SCHEMA_DIR)
63
64 set (gwd_schema ${CMAKE_CURRENT_BINARY_DIR}/gwd.schemas)
65
66 compiz_translate_xml (
67 ${CMAKE_CURRENT_SOURCE_DIR}/gwd.schemas.in
68 ${gwd_schema}
69 )
70
71 compiz_install_gconf_schema (${CMAKE_CURRENT_BINARY_DIR}/gwd.schemas ${SCHEMADIR})
72
73endif (USE_GCONF_UNITY_WINDOW_DECORATOR)
74
75add_executable (unity-window-decorator
76 gtk-window-decorator.c
77 blurprops.c
78 decorprops.c
79 cairo.c
80 gdk.c
81 switcher.c
82 metacity.c
83 events.c
84 forcequit.c
85 actionmenu.c
86 settings.c
87 util.c
88 style.c
89 wnck.c
90 decorator.c
91 frames.c
92 ${gwd_schema}
93)
94
95add_executable (gtk-window-decorator
96 gtk-window-decorator.c
97 blurprops.c
98 decorprops.c
99 cairo.c
100 gdk.c
101 switcher.c
102 metacity.c
103 events.c
104 forcequit.c
105 actionmenu.c
106 settings.c
107 util.c
108 style.c
109 wnck.c
110 decorator.c
111 frames.c
112 ${gwd_schema}
113)
114
115if (USE_METACITY)
116 set (metacitylibs ${METACITY_LIBRARIES})
117endif (USE_METACITY)
118
119set_target_properties (
120 unity-window-decorator PROPERTIES
121 INSTALL_RPATH_USE_LINK_PATH 0
122)
123
124target_link_libraries (unity-window-decorator
125 decoration
126 ${UNITY_WINDOW_DECORATOR_LIBRARIES}
127 ${GCONF_LIBRARIES}
128 ${DBUS_GLIB_LIBRARIES}
129 ${metacitylibs}
130)
131
132install (
133 TARGETS unity-window-decorator
134 DESTINATION ${COMPIZ_DESTDIR}${exec_prefix}
135 RUNTIME DESTINATION bin
136)
137
138set_target_properties (
139 gtk-window-decorator PROPERTIES
140 INSTALL_RPATH_USE_LINK_PATH 0
141)
142
143target_link_libraries (gtk-window-decorator
144 decoration
145 ${UNITY_WINDOW_DECORATOR_LIBRARIES}
146 ${GCONF_LIBRARIES}
147 ${DBUS_GLIB_LIBRARIES}
148 ${metacitylibs}
149)
150
151install (
152 TARGETS gtk-window-decorator
153 DESTINATION ${COMPIZ_DESTDIR}${exec_prefix}
154 RUNTIME DESTINATION bin
155)
0156
=== renamed file 'gtk/window-decorator/actionmenu.c' => 'gtk/window-decorator/src/actionmenu.c'
=== renamed file 'gtk/window-decorator/blurprops.c' => 'gtk/window-decorator/src/blurprops.c'
=== renamed file 'gtk/window-decorator/cairo.c' => 'gtk/window-decorator/src/cairo.c'
--- gtk/window-decorator/cairo.c 2011-08-11 19:38:07 +0000
+++ gtk/window-decorator/src/cairo.c 2011-08-19 15:05:12 +0000
@@ -131,14 +131,15 @@
131}131}
132132
133void133void
134draw_shadow_background (GWDDecoration *d,134draw_shadow_background (Picture p,
135 cairo_t *cr,135 cairo_t *cr,
136 decor_shadow_t *s,136 decor_shadow_t *s,
137 decor_context_t *c)137 decor_context_t *c,
138 decor_layout_t *layout)
138{139{
139 Display *xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());140 Display *xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
140141
141 if (!s || !s->picture ||!d->picture)142 if (!s || !s->picture || !p)
142 {143 {
143 cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 0.0);144 cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 0.0);
144 cairo_paint (cr);145 cairo_paint (cr);
@@ -147,8 +148,8 @@
147 {148 {
148 decor_fill_picture_extents_with_shadow (xdisplay,149 decor_fill_picture_extents_with_shadow (xdisplay,
149 s, c,150 s, c,
150 d->picture,151 p,
151 &d->border_layout);152 layout);
152 }153 }
153}154}
154155
@@ -348,7 +349,7 @@
348 cairo_set_line_width (cr, 1.0);349 cairo_set_line_width (cr, 1.0);
349350
350 if (d->frame->frame_state & DECOR_WINDOW_STATE_COMPOSITED)351 if (d->frame->frame_state & DECOR_WINDOW_STATE_COMPOSITED)
351 draw_shadow_background (d, cr, d->frame->shadow, &d->frame->context);352 draw_shadow_background (d->picture, cr, d->frame->shadow, &d->frame->context, &d->border_layout);
352353
353 if (d->frame->frame_state & DECOR_WINDOW_STATE_FOCUS)354 if (d->frame->frame_state & DECOR_WINDOW_STATE_FOCUS)
354 {355 {
355356
=== added file 'gtk/window-decorator/src/config.h.gtk.in'
--- gtk/window-decorator/src/config.h.gtk.in 1970-01-01 00:00:00 +0000
+++ gtk/window-decorator/src/config.h.gtk.in 2011-08-19 15:05:12 +0000
@@ -0,0 +1,25 @@
1/* Define to 1 if Metacity support is enabled */
2#cmakedefine USE_METACITY 1
3
4/* Define to 1 if Gconf support is enabled */
5#cmakedefine USE_GCONF 1
6
7/* Define to 1 if you have the `wnck_window_has_name' function. */
8#cmakedefine HAVE_WNCK_WINDOW_HAS_NAME 1
9
10/* Define to 1 if libwnck version >= 2_18_1 */
11#cmakedefine HAVE_LIBWNCK_2_18_1 1
12
13/* Define to 1 if libwnck version >= 2_19_4 */
14#cmakedefine HAVE_LIBWNCK_2_19_4 1
15
16/* Define to 1 if metacity version >= 2.15.21 */
17#cmakedefine HAVE_METACITY_2_15_21 1
18
19/* Define to 1 if metacity version >= 2.17.0 */
20#cmakedefine HAVE_METACITY_2_17_0 1
21
22/* Define to 1 if metacity version >= 2.23.2 */
23#cmakedefine HAVE_METACITY_2_23_2 1
24
25#define GETTEXT_PACKAGE "${GETTEXT_PACKAGE}"
026
=== renamed file 'gtk/window-decorator/decorator.c' => 'gtk/window-decorator/src/decorator.c'
--- gtk/window-decorator/decorator.c 2011-08-11 19:38:07 +0000
+++ gtk/window-decorator/src/decorator.c 2011-08-19 15:05:12 +0000
@@ -87,12 +87,6 @@
87 frame_update_titlebar_font ((GWDFrame *) value);87 frame_update_titlebar_font ((GWDFrame *) value);
88}88}
8989
90void
91update_titlebar_font ()
92{
93 gwd_frames_foreach (update_frames_titlebar_fonts, NULL);
94}
95
9690
97/*91/*
98 * update_event_windows92 * update_event_windows
@@ -393,13 +387,7 @@
393 /* Need to get a minimum width for the name */387 /* Need to get a minimum width for the name */
394 else if (d->window)388 else if (d->window)
395 {389 {
396 gint width;390 w = d->window->client_geometry.width - ICON_SPACE - 2 - d->button_width;
397
398 wnck_window_get_client_window_geometry (d->window->win,
399 NULL, NULL,
400 &width, NULL);
401
402 w = width - ICON_SPACE - 2 - d->button_width;
403 if (w < 1)391 if (w < 1)
404 w = 1;392 w = 1;
405 }393 }
@@ -634,6 +622,7 @@
634 d.height = height;622 d.height = height;
635 d.draw = theme_draw_window_decoration;623 d.draw = theme_draw_window_decoration;
636 d.picture = picture;624 d.picture = picture;
625 d.window = NULL;
637 d.frame->context = *c;626 d.frame->context = *c;
638627
639 decor_get_default_layout (&d.frame->context, 1, 1, &d.border_layout);628 decor_get_default_layout (&d.frame->context, 1, 1, &d.border_layout);
@@ -857,14 +846,6 @@
857846
858}847}
859848
860int
861update_shadow (void)
862{
863 gwd_frames_foreach (update_frames_shadows, NULL);
864
865 return 1;
866}
867
868/*849/*
869 * populate_type850 * populate_type
870 *851 *
@@ -1083,10 +1064,6 @@
1083 GList *it = w->decorations;1064 GList *it = w->decorations;
1084 int xp, yp, wp, hp;1065 int xp, yp, wp, hp;
10851066
1086 /* FIXME: remove */
1087 guint32 frame_type = populate_frame_type (win);
1088 guint32 frame_state = populate_frame_state (win);
1089
1090 /* force size update */1067 /* force size update */
1091 wnck_window_get_client_window_geometry (w->win, &xp, &yp, &hp, &wp);1068 wnck_window_get_client_window_geometry (w->win, &xp, &yp, &hp, &wp);
10921069
@@ -1100,24 +1077,17 @@
1100 GWDDecoration *d = (GWDDecoration *) it->data;1077 GWDDecoration *d = (GWDDecoration *) it->data;
11011078
1102 if (update_window_decoration_size (d, &w->client_geometry, wnck_window_get_name (w->win)) &&1079 if (update_window_decoration_size (d, &w->client_geometry, wnck_window_get_name (w->win)) &&
1103 frame_type == d->frame->frame_type &&1080 w->type == d->frame->frame_type &&
1104 frame_state == d->frame->frame_state &&1081 w->state == d->frame->frame_state &&
1105 w->frame_window)1082 w->frame_window)
1083 {
1106 update_event_windows (w->frame_window);1084 update_event_windows (w->frame_window);
1085 }
11071086
1108 it = g_list_next (it);1087 it = g_list_next (it);
1109 }1088 }
1110}1089}
11111090
1112static struct timeval this_tv;
1113static struct timeval last_tv;
1114
1115#define print_time(...) \
1116 gettimeofday (&this_tv, NULL); \
1117 printf ("TIME DEBUG: time: %li %s", this_tv.tv_usec - last_tv.tv_usec, __VA_ARGS__); \
1118 last_tv = this_tv; \
1119
1120
1121/*1091/*
1122 * update_property_on_window1092 * update_property_on_window
1123 *1093 *
@@ -1129,12 +1099,6 @@
1129 GdkDisplay *gdkdisplay = gdk_display_get_default ();1099 GdkDisplay *gdkdisplay = gdk_display_get_default ();
1130 Display *xdisplay = gdk_x11_display_get_xdisplay (gdkdisplay);1100 Display *xdisplay = gdk_x11_display_get_xdisplay (gdkdisplay);
11311101
1132 gettimeofday (&this_tv, NULL);
1133
1134 gettimeofday (&this_tv, NULL);
1135 //printf ("TIME DEBUG: %s time: %li on window 0x%x\n", G_STRFUNC, this_tv.tv_usec - last_tv.tv_usec, window->xid);
1136 last_tv = this_tv;
1137
1138 gdk_error_trap_push ();1102 gdk_error_trap_push ();
1139 XChangeProperty (xdisplay, window->xid,1103 XChangeProperty (xdisplay, window->xid,
1140 win_decor_atom,1104 win_decor_atom,
@@ -1143,10 +1107,6 @@
1143 window->cache->size);1107 window->cache->size);
1144 gdk_display_sync (gdk_display_get_default ());1108 gdk_display_sync (gdk_display_get_default ());
1145 gdk_error_trap_pop ();1109 gdk_error_trap_pop ();
1146
1147 gettimeofday (&this_tv, NULL);
1148 //printf ("TIME DEBUG: %s done: %li on window 0x%x\n", G_STRFUNC, this_tv.tv_usec - last_tv.tv_usec, window->xid);
1149 last_tv = this_tv;
1150}1110}
11511111
1152/*1112/*
11531113
=== renamed file 'gtk/window-decorator/decorprops.c' => 'gtk/window-decorator/src/decorprops.c'
=== renamed file 'gtk/window-decorator/events.c' => 'gtk/window-decorator/src/events.c'
--- gtk/window-decorator/events.c 2011-08-12 09:01:24 +0000
+++ gtk/window-decorator/src/events.c 2011-08-19 15:05:12 +0000
@@ -25,11 +25,6 @@
2525
26#include "gtk-window-decorator.h"26#include "gtk-window-decorator.h"
2727
28/* FIXME: This is a hack until we can
29 * figure out why gdk is giving us events
30 * twice */
31gulong last_event_serial = 0;
32
33void28void
34move_resize_window (WnckWindow *win,29move_resize_window (WnckWindow *win,
35 int direction,30 int direction,
@@ -96,12 +91,18 @@
96 {91 {
97 GdkCursor* cursor;92 GdkCursor* cursor;
98 GdkWindow* window = create_foreign_window (w->frame_window->xid);93 GdkWindow* window = create_foreign_window (w->frame_window->xid);
99 cursor = gdk_cursor_new (GDK_LEFT_PTR);94
100 gdk_error_trap_push ();95 if (window)
101 gdk_window_set_cursor (window, cursor);96 {
102 gdk_cursor_unref (cursor);97 cursor = gdk_cursor_new (GDK_LEFT_PTR);
103 gdk_display_sync (gdk_display_get_default ());98 gdk_error_trap_push ();
104 if (gdk_error_trap_pop ())99 gdk_window_set_cursor (window, cursor);
100 gdk_cursor_unref (cursor);
101 gdk_display_sync (gdk_display_get_default ());
102 if (gdk_error_trap_pop ())
103 return;
104 }
105 else
105 return;106 return;
106 }107 }
107108
@@ -459,11 +460,16 @@
459 {460 {
460 GdkCursor* cursor = gdk_cursor_new (GDK_LEFT_PTR);461 GdkCursor* cursor = gdk_cursor_new (GDK_LEFT_PTR);
461 GdkWindow* window = create_foreign_window (w->frame_window->xid);462 GdkWindow* window = create_foreign_window (w->frame_window->xid);
462 gdk_error_trap_push ();463 if (window)
463 gdk_window_set_cursor (window, cursor);464 {
464 gdk_cursor_unref (cursor);465 gdk_error_trap_push ();
465 gdk_display_sync (gdk_display_get_default ());466 gdk_window_set_cursor (window, cursor);
466 if (gdk_error_trap_pop ())467 gdk_cursor_unref (cursor);
468 gdk_display_sync (gdk_display_get_default ());
469 if (gdk_error_trap_pop ())
470 return;
471 }
472 else
467 return;473 return;
468 }474 }
469475
@@ -562,13 +568,16 @@
562568
563 if (cursor)569 if (cursor)
564 {570 {
565 GdkWindow* window = create_foreign_window (w->frame_window->xid);571 GdkWindow *window = create_foreign_window (w->frame_window->xid);
566 gdk_error_trap_push ();572 if (window)
567 gdk_window_set_cursor (window, cursor);573 {
568 gdk_cursor_unref (cursor);574 gdk_error_trap_push ();
569 gdk_display_sync (gdk_display_get_default ());575 gdk_window_set_cursor (window, cursor);
570 if (gdk_error_trap_pop ())576 gdk_cursor_unref (cursor);
571 return;577 gdk_display_sync (gdk_display_get_default ());
578 if (gdk_error_trap_pop ())
579 return;
580 }
572 }581 }
573 }582 }
574583
@@ -883,45 +892,42 @@
883}892}
884893
885GdkFilterReturn894GdkFilterReturn
886event_filter_func (GdkXEvent *gdkxevent,895event_handler (GdkXEvent *event,
887 GdkEvent *event,896 GdkEvent *gevent,
888 gpointer data)897 gpointer data)
889{898{
890 GdkDisplay *gdkdisplay;899 GdkDisplay *gdkdisplay;
891 XEvent *xevent = gdkxevent;
892 gulong xid = 0;900 gulong xid = 0;
893 Window select = 0;901 Window select = 0;
902 XEvent *xevent = (XEvent *) event;
894903
895 gdkdisplay = gdk_display_get_default ();904 gdkdisplay = gdk_display_get_default ();
896905
897 /* Hack, see above */
898 if (last_event_serial == xevent->xany.serial)
899 {
900 last_event_serial = 0;
901 return GDK_FILTER_CONTINUE;
902 }
903
904 last_event_serial = xevent->xany.serial;
905
906 switch (xevent->type) {906 switch (xevent->type) {
907 case CreateNotify:907 case CreateNotify:
908 {908 {
909 GdkWindow *toplevel = create_foreign_window (xevent->xcreatewindow.window);909 if (xevent->xcreatewindow.parent == gdk_x11_get_default_root_xwindow ())
910
911 if (toplevel)
912 {910 {
913 gdk_window_set_events (toplevel,911 GdkWindow *toplevel = create_foreign_window (xevent->xcreatewindow.window);
914 gdk_window_get_events (toplevel) |
915 GDK_PROPERTY_CHANGE_MASK |
916 GDK_FOCUS_CHANGE_MASK);
917 gdk_window_add_filter (toplevel, event_filter_func, NULL);
918912
919 if (!wnck_window_get (xevent->xcreatewindow.window))913 if (toplevel)
920 {914 {
921 /* check if the window is a switcher and update accordingly */915 if (!wnck_window_get (xevent->xcreatewindow.window))
922916 {
923 if (get_window_prop (xevent->xcreatewindow.window, select_window_atom, &select))917 gdk_error_trap_push ();
924 update_switcher_window (xevent->xcreatewindow.window, select);918 gdk_window_set_events (toplevel,
919 gdk_window_get_events (toplevel) |
920 GDK_PROPERTY_CHANGE_MASK |
921 GDK_FOCUS_CHANGE_MASK);
922 gdk_display_sync (gdk_display_get_default ());
923 if (gdk_error_trap_pop ())
924 g_warning ("X Error while trying to set window events");
925
926 /* check if the window is a switcher and update accordingly */
927
928 if (get_window_prop (xevent->xcreatewindow.window, select_window_atom, &select))
929 update_switcher_window (xevent->xcreatewindow.window, select);
930 }
925 }931 }
926 }932 }
927 }933 }
@@ -1064,92 +1070,169 @@
1064 unsigned int mask;1070 unsigned int mask;
1065 XButtonEvent eb;1071 XButtonEvent eb;
10661072
1073 gdk_error_trap_push ();
1067 XQueryPointer (gdk_x11_display_get_xdisplay (gdk_display_get_default ()),1074 XQueryPointer (gdk_x11_display_get_xdisplay (gdk_display_get_default ()),
1068 last_clicked_frame->frame_window->xid,1075 last_clicked_frame->frame_window->xid,
1069 &root,1076 &root,
1070 &child,1077 &child,
1071 &x_root, &y_root, &x, &y, &mask);1078 &x_root, &y_root, &x, &y, &mask);
10721079 gdk_display_sync (gdk_display_get_default ());
1073 eb.type = ButtonRelease;1080 if (!gdk_error_trap_pop ())
1074 eb.send_event = FALSE;1081 {
1075 eb.time = CurrentTime;1082 eb.type = ButtonRelease;
1076 eb.x = (double) x;1083 eb.send_event = FALSE;
1077 eb.y = (double) y;1084 eb.time = CurrentTime;
1078 eb.x_root = (double) x_root;1085 eb.x = (double) x;
1079 eb.y_root = (double) y_root;1086 eb.y = (double) y;
1080 eb.state = 0;1087 eb.x_root = (double) x_root;
1081 eb.button = 0;1088 eb.y_root = (double) y_root;
10821089 eb.state = 0;
1083 if (last_clicked_frame)1090 eb.button = 0;
1084 frame_handle_button_release (&eb, last_clicked_frame);1091
1092 if (last_clicked_frame)
1093 frame_handle_button_release (&eb, last_clicked_frame);
1094 }
1085 }1095 }
1086 case ButtonPress:1096 case ButtonPress:
1087 {1097 {
1088 GWDWindow *w = g_hash_table_lookup (frame_table, GINT_TO_POINTER (xevent->xbutton.window));1098 GWDFrameWindow *fw = g_hash_table_lookup (frame_table, GINT_TO_POINTER (xevent->xbutton.window));
10891099
1090 if (w)1100 if (fw)
1091 {1101 {
1092 frame_handle_button_press ((XButtonEvent *) xevent, w);1102 frame_handle_button_press ((XButtonEvent *) xevent, fw->window);
1093 return GDK_FILTER_REMOVE;
1094 }1103 }
10951104
1096 break;1105 break;
1097 }1106 }
1098 case ButtonRelease:1107 case ButtonRelease:
1099 {1108 {
1100 GWDWindow *w = g_hash_table_lookup (frame_table, GINT_TO_POINTER (xevent->xbutton.window));1109 GWDFrameWindow *fw = g_hash_table_lookup (frame_table, GINT_TO_POINTER (xevent->xbutton.window));
11011110
1102 if (w)1111 if (fw)
1103 {1112 {
1104 frame_handle_button_release ((XButtonEvent *) xevent, w);1113 frame_handle_button_release ((XButtonEvent *) xevent, fw->window);
1105 return GDK_FILTER_REMOVE;
1106 }1114 }
11071115
1108 break;1116 break;
1109 }1117 }
1110 case MotionNotify:1118 case MotionNotify:
1111 {1119 {
1112 GWDWindow *w = g_hash_table_lookup (frame_table, GINT_TO_POINTER (xevent->xmotion.window));1120 GWDFrameWindow *fw = g_hash_table_lookup (frame_table, GINT_TO_POINTER (xevent->xmotion.window));
11131121
1114 if (w)1122 if (fw)
1115 {1123 {
1116 frame_handle_motion ((XMotionEvent *) xevent, w);1124 frame_handle_motion ((XMotionEvent *) xevent, fw->window);
1117 return GDK_FILTER_REMOVE;1125 }
1118 }1126
11191127 break;
1128 }
1129 case LeaveNotify:
1130 {
1131 GWDFrameWindow *fw = g_hash_table_lookup (frame_table, GINT_TO_POINTER (xevent->xcrossing.window));
1132
1133 if (fw && xevent->xcrossing.mode == NotifyNormal)
1134 {
1135 guint state[BUTTON_NUM];
1136 memcpy (state, fw->button_states, sizeof (guint) * BUTTON_NUM);
1137
1138 GWDDecoration *d = gwd_decoration_get (fw->window,
1139 fw->window->type,
1140 fw->window->state,
1141 fw->window->actions);
1142 /* Reset button states as we are no longer in this frame window */
1143 memset (&fw->button_states, 0, sizeof (guint) * BUTTON_NUM);
1144
1145 fw->last_entered = NULL;
1146
1147 if (memcmp (state, fw->button_states, sizeof (guint) * BUTTON_NUM))
1148 queue_decor_draw (d);
1149 }
1120 break;1150 break;
1121 }1151 }
1122 case DestroyNotify:1152 case DestroyNotify:
1123 {1153 {
1124 GWDWindow *w = g_hash_table_lookup (frame_table, GINT_TO_POINTER (xevent->xdestroywindow.window));1154 GWDFrameWindow *fw = g_hash_table_lookup (frame_table, GINT_TO_POINTER (xevent->xdestroywindow.window));
11251155
1126 /* The parent window went away, we must remove our frame window */1156 /* The parent window went away, we must remove our frame window */
1127 if (w)1157 if (fw)
1128 {1158 {
1129 gboolean safe = FALSE;1159 /* The reality is that we're racing with gtk to get rid of
11301160 * the window before it dies server side, things could get
1131 if (xevent->xdestroywindow.window == w->frame_window->container_xid)1161 * hairy here */
1132 safe = TRUE;1162 gdk_error_trap_push ();
11331163 gwd_frame_window_delete (fw, TRUE);
1134 gwd_frame_window_delete (w->frame_window, safe);1164 gdk_error_trap_pop ();
1135 w->frame_window = NULL;1165 fw->window->frame_window = NULL;
1136 }1166 }
11371167
1138 return GDK_FILTER_REMOVE;
1139 break;1168 break;
1140 }1169 }
1141 case ReparentNotify:1170 case ReparentNotify:
1142 {1171 {
1143 GWDWindow *w = g_hash_table_lookup (frame_table, GINT_TO_POINTER (xevent->xreparent.window));1172 GWDFrameWindow *fw = g_hash_table_lookup (frame_table, GINT_TO_POINTER (xevent->xreparent.window));
11441173
1145 /* The parent window went away, we must remove our frame window */1174 /* Compiz unreparented the decoration
1146 if (w && xevent->xreparent.parent == gdk_x11_get_default_root_xwindow ())1175 * so we must remove our frame window
1176 * as well */
1177 if (fw)
1147 {1178 {
1148 gwd_frame_window_delete (w->frame_window, FALSE);1179 GdkWindow *backing_window = gtk_widget_get_window (GTK_WIDGET (fw->container));
1149 w->frame_window = NULL;1180 GdkWindow *compiz_frame_window = create_foreign_window (fw->xid);
1181
1182 if (xevent->xreparent.parent == gdk_x11_get_default_root_xwindow ())
1183 {
1184 gwd_frame_window_delete (fw, TRUE);
1185 }
1186 else
1187 {
1188 unsigned int i, j;
1189 static event_callback callback[3][3] = {
1190 { top_left_event, top_event, top_right_event },
1191 { left_event, title_event, right_event },
1192 { bottom_left_event, bottom_event, bottom_right_event }
1193 };
1194 static event_callback button_callback[BUTTON_NUM] = {
1195 close_button_event,
1196 max_button_event,
1197 min_button_event,
1198 menu_button_event,
1199 shade_button_event,
1200 above_button_event,
1201 stick_button_event,
1202 unshade_button_event,
1203 unabove_button_event,
1204 unstick_button_event
1205 };
1206
1207 /* Checking if the window is mapped
1208 * seems to help in the case where
1209 * GDK sends the same event multiple times */
1210 if (compiz_frame_window &&
1211 backing_window &&
1212 !gdk_window_is_viewable (backing_window))
1213 {
1214 gdk_window_set_events (compiz_frame_window,
1215 GDK_STRUCTURE_MASK |
1216 GDK_SUBSTRUCTURE_MASK);
1217 gdk_window_set_events (backing_window, GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
1218 GDK_BUTTON_PRESS_MASK |
1219 GDK_BUTTON_RELEASE_MASK |
1220 GDK_LEAVE_NOTIFY_MASK);
1221
1222 gtk_widget_show_all (GTK_WIDGET (fw->container));
1223
1224 for (i = 0; i < 3; i++)
1225 for (j = 0; j < 3; j++)
1226 fw->event_windows[i][j].callback = callback[i][j];
1227
1228 for (i = 0; i < BUTTON_NUM; i++)
1229 fw->button_windows[i].callback = button_callback[i];
1230
1231 update_event_windows (fw);
1232 }
1233 }
1150 }1234 }
11511235
1152 return GDK_FILTER_REMOVE;
1153 break;1236 break;
1154 }1237 }
1155 case ClientMessage:1238 case ClientMessage:
@@ -1188,6 +1271,7 @@
1188 }1271 }
1189 }1272 }
1190 }1273 }
1274 break;
1191 default:1275 default:
1192 break;1276 break;
1193 }1277 }
@@ -1196,26 +1280,23 @@
1196}1280}
11971281
1198GdkFilterReturn1282GdkFilterReturn
1199selection_event_filter_func (GdkXEvent *gdkxevent,1283selection_event_handler (GdkXEvent *event,
1200 GdkEvent *event,1284 GdkEvent *gdkevent,
1201 gpointer data)1285 gpointer user_data)
1202{1286{
1203 Display *xdisplay;1287 XEvent *xevent = (XEvent *) event;
1204 GdkDisplay *gdkdisplay;1288
1205 XEvent *xevent = gdkxevent;1289 switch (xevent->type)
1206 int status;1290 {
1207
1208 gdkdisplay = gdk_display_get_default ();
1209 xdisplay = GDK_DISPLAY_XDISPLAY (gdkdisplay);
1210
1211 switch (xevent->type) {
1212 case SelectionRequest:1291 case SelectionRequest:
1213 decor_handle_selection_request (xdisplay, xevent, dm_sn_timestamp);1292 decor_handle_selection_request (gdk_x11_display_get_xdisplay (gdk_display_get_default ()), xevent, dm_sn_timestamp);
1214 break;1293 break;
1215 case SelectionClear:1294 case SelectionClear:
1216 status = decor_handle_selection_clear (xdisplay, xevent, 0);1295 {
1296 int status = decor_handle_selection_clear (gdk_x11_display_get_xdisplay (gdk_display_get_default ()), xevent, 0);
1217 if (status == DECOR_SELECTION_GIVE_UP)1297 if (status == DECOR_SELECTION_GIVE_UP)
1218 gtk_main_quit ();1298 gtk_main_quit ();
1299 }
1219 default:1300 default:
1220 break;1301 break;
1221 }1302 }
12221303
=== renamed file 'gtk/window-decorator/forcequit.c' => 'gtk/window-decorator/src/forcequit.c'
=== renamed file 'gtk/window-decorator/frames.c' => 'gtk/window-decorator/src/frames.c'
--- gtk/window-decorator/frames.c 2011-08-11 19:38:07 +0000
+++ gtk/window-decorator/src/frames.c 2011-08-19 15:05:12 +0000
@@ -22,6 +22,8 @@
2222
23#include "gtk-window-decorator.h"23#include "gtk-window-decorator.h"
2424
25
26
25typedef struct _decor_frame_type_info27typedef struct _decor_frame_type_info
26{28{
27 create_frame_proc create_func;29 create_frame_proc create_func;
2830
=== renamed file 'gtk/window-decorator/gdk.c' => 'gtk/window-decorator/src/gdk.c'
=== renamed file 'gtk/window-decorator/gtk-window-decorator.c' => 'gtk/window-decorator/src/gtk-window-decorator.c'
--- gtk/window-decorator/gtk-window-decorator.c 2011-08-11 19:38:07 +0000
+++ gtk/window-decorator/src/gtk-window-decorator.c 2011-08-19 15:05:12 +0000
@@ -49,8 +49,6 @@
4949
50Atom net_wm_state_atom;50Atom net_wm_state_atom;
51Atom net_wm_state_modal_atom;51Atom net_wm_state_modal_atom;
52
53
54Time dm_sn_timestamp;52Time dm_sn_timestamp;
5553
56struct _cursor cursor[3][3] = {54struct _cursor cursor[3][3] = {
@@ -273,7 +271,7 @@
273 FALSE);271 FALSE);
274272
275 net_wm_state_atom = XInternAtom (xdisplay,"_NET_WM_STATE", 0);273 net_wm_state_atom = XInternAtom (xdisplay,"_NET_WM_STATE", 0);
276 net_wm_state_modal_atom = XInternAtom (xdisplay, "_NET_MW_STATE_MODAL", 0);274 net_wm_state_modal_atom = XInternAtom (xdisplay, "_NET_WM_STATE_MODAL", 0);
277275
278 status = decor_acquire_dm_session (xdisplay,276 status = decor_acquire_dm_session (xdisplay,
279 gdk_screen_get_number (gdkscreen),277 gdk_screen_get_number (gdkscreen),
@@ -366,7 +364,7 @@
366 wnck_set_client_type (WNCK_CLIENT_TYPE_PAGER);364 wnck_set_client_type (WNCK_CLIENT_TYPE_PAGER);
367365
368 gdk_window_add_filter (NULL,366 gdk_window_add_filter (NULL,
369 selection_event_filter_func,367 selection_event_handler,
370 NULL);368 NULL);
371369
372 if (!minimal)370 if (!minimal)
@@ -374,25 +372,29 @@
374 GdkWindow *root = create_foreign_window (gdk_x11_get_default_root_xwindow ());372 GdkWindow *root = create_foreign_window (gdk_x11_get_default_root_xwindow ());
375 gwd_default_decorations_window = gwd_window_new (gdk_x11_get_default_root_xwindow ());373 gwd_default_decorations_window = gwd_window_new (gdk_x11_get_default_root_xwindow ());
376374
377 gdk_window_add_filter (NULL,375 gdk_window_add_filter (NULL,
378 event_filter_func,376 event_handler,
379 NULL);377 NULL);
380 378
381 XQueryTree (xdisplay, gdk_x11_get_default_root_xwindow (),379 XQueryTree (xdisplay, gdk_x11_get_default_root_xwindow (),
382 &root_ret, &parent_ret, &children, &nchildren);380 &root_ret, &parent_ret, &children, &nchildren);
383381
384 for (i = 0; i < nchildren; i++)382 for (i = 0; i < nchildren; i++)
385 {383 {
386 GdkWindow *toplevel = create_foreign_window (children[i]);384 GdkWindow *toplevel = create_foreign_window (children[i]);
387
388 /* Need property notify on all windows */385 /* Need property notify on all windows */
389386
390 gdk_window_set_events (toplevel,387 if (toplevel)
391 gdk_window_get_events (toplevel) |388 {
392 GDK_PROPERTY_CHANGE_MASK |389 gdk_error_trap_push ();
393 GDK_FOCUS_CHANGE_MASK);390 gdk_window_set_events (toplevel,
394391 gdk_window_get_events (toplevel) |
395 gdk_window_add_filter (toplevel, event_filter_func, NULL);392 GDK_PROPERTY_CHANGE_MASK |
393 GDK_FOCUS_CHANGE_MASK);
394 gdk_display_sync (gdk_display_get_default ());
395 if (gdk_error_trap_pop ())
396 g_warning ("X Error while trying to set events");
397 }
396 }398 }
397399
398 /* Need MapNotify on new windows */400 /* Need MapNotify on new windows */
@@ -402,8 +404,8 @@
402 GDK_VISIBILITY_NOTIFY_MASK |404 GDK_VISIBILITY_NOTIFY_MASK |
403 GDK_SUBSTRUCTURE_MASK |405 GDK_SUBSTRUCTURE_MASK |
404 GDK_FOCUS_CHANGE_MASK);406 GDK_FOCUS_CHANGE_MASK);
405 407
406 connect_screen (screen);408 connect_screen (screen);
407 }409 }
408410
409 decor_set_dm_check_hint (xdisplay, gdk_screen_get_number (gdkscreen),411 decor_set_dm_check_hint (xdisplay, gdk_screen_get_number (gdkscreen),
@@ -428,6 +430,8 @@
428 if (gwd_default_decorations_window)430 if (gwd_default_decorations_window)
429 gwd_window_delete (gwd_default_decorations_window);431 gwd_window_delete (gwd_default_decorations_window);
430432
433 gdk_display_sync (gdk_display_get_default ());
434
431 if (switcher_label)435 if (switcher_label)
432 g_object_unref (switcher_label);436 g_object_unref (switcher_label);
433437
434438
=== renamed file 'gtk/window-decorator/gtk-window-decorator.h' => 'gtk/window-decorator/src/gtk-window-decorator.h'
--- gtk/window-decorator/gtk-window-decorator.h 2011-08-11 19:38:07 +0000
+++ gtk/window-decorator/src/gtk-window-decorator.h 2011-08-19 15:05:12 +0000
@@ -29,6 +29,10 @@
29#include <config.h>29#include <config.h>
30#endif30#endif
3131
32#ifndef _GNU_SOURCE
33#define _GNU_SOURCE
34#endif
35
32#include "decoration.h"36#include "decoration.h"
3337
34#include <X11/Xlib.h>38#include <X11/Xlib.h>
@@ -69,6 +73,8 @@
69#include <gtk/gtk.h>73#include <gtk/gtk.h>
70#include <gdk/gdkx.h>74#include <gdk/gdkx.h>
71#include <gdk/gdk.h>75#include <gdk/gdk.h>
76#include <gdk/gdkpixbuf.h>
77
7278
73#ifdef USE_GCONF79#ifdef USE_GCONF
74#include <gconf/gconf-client.h>80#include <gconf/gconf-client.h>
@@ -105,6 +111,7 @@
105#include <unistd.h>111#include <unistd.h>
106#include <sys/types.h>112#include <sys/types.h>
107#include <signal.h>113#include <signal.h>
114#include <stdio.h>
108115
109#include <libintl.h>116#include <libintl.h>
110#define _(x) gettext (x)117#define _(x) gettext (x)
@@ -416,6 +423,7 @@
416 event_window button_windows[BUTTON_NUM];423 event_window button_windows[BUTTON_NUM];
417 guint button_states[BUTTON_NUM];424 guint button_states[BUTTON_NUM];
418 GtkWidget *container;425 GtkWidget *container;
426 GtkWidget *event_box;
419 event_window *last_entered;427 event_window *last_entered;
420 Window xid;428 Window xid;
421 Window container_xid;429 Window container_xid;
@@ -684,16 +692,10 @@
684void692void
685update_event_windows (GWDFrameWindow *fw);693update_event_windows (GWDFrameWindow *fw);
686694
687int
688update_shadow (void);
689
690gboolean695gboolean
691shadow_property_changed (WnckScreen *screen);696shadow_property_changed (WnckScreen *screen);
692697
693void698void
694update_titlebar_font ();
695
696void
697update_window_decoration (WnckWindow *win);699update_window_decoration (WnckWindow *win);
698700
699void701void
@@ -705,6 +707,16 @@
705void707void
706copy_to_front_buffer (GWDDecoration *d);708copy_to_front_buffer (GWDDecoration *d);
707709
710void
711update_frames_titlebar_fonts (gpointer key,
712 gpointer value,
713 gpointer user_data);
714
715void
716update_frames_shadows (gpointer key,
717 gpointer value,
718 gpointer user_data);
719
708/* wnck.c*/720/* wnck.c*/
709721
710void722void
@@ -797,10 +809,11 @@
797#define SHADE_BOTTOM (1 << 3)809#define SHADE_BOTTOM (1 << 3)
798810
799void811void
800draw_shadow_background (GWDDecoration *d,812draw_shadow_background (Picture p,
801 cairo_t *cr,813 cairo_t *cr,
802 decor_shadow_t *s,814 decor_shadow_t *s,
803 decor_context_t *c);815 decor_context_t *c,
816 decor_layout_t *layout);
804817
805void818void
806draw_window_decoration (GWDDecoration *d);819draw_window_decoration (GWDDecoration *d);
@@ -1148,14 +1161,14 @@
1148 GWDWindow *);1161 GWDWindow *);
11491162
1150GdkFilterReturn1163GdkFilterReturn
1151selection_event_filter_func (GdkXEvent *gdkxevent,1164event_handler (GdkXEvent *event,
1152 GdkEvent *event,1165 GdkEvent *gevent,
1153 gpointer data);1166 gpointer data);
11541167
1155GdkFilterReturn1168GdkFilterReturn
1156event_filter_func (GdkXEvent *gdkxevent,1169selection_event_handler (GdkXEvent *event,
1157 GdkEvent *event,1170 GdkEvent *gdkevent,
1158 gpointer data);1171 gpointer user_data);
11591172
1160/* forcequit.c */1173/* forcequit.c */
11611174
11621175
=== renamed file 'gtk/window-decorator/gwd.schemas.in' => 'gtk/window-decorator/src/gwd.schemas.in'
=== renamed file 'gtk/window-decorator/metacity.c' => 'gtk/window-decorator/src/metacity.c'
--- gtk/window-decorator/metacity.c 2011-08-11 19:38:07 +0000
+++ gtk/window-decorator/src/metacity.c 2011-08-19 15:05:12 +0000
@@ -24,7 +24,6 @@
24 */24 */
2525
26#include "gtk-window-decorator.h"26#include "gtk-window-decorator.h"
27#include "decoration-test.h"
2827
29#ifdef USE_METACITY28#ifdef USE_METACITY
3029
@@ -229,7 +228,8 @@
229228
230static Region229static Region
231meta_get_top_border_region (const MetaFrameGeometry *fgeom,230meta_get_top_border_region (const MetaFrameGeometry *fgeom,
232 int width)231 int width,
232 gboolean clip)
233{233{
234 Region corners_xregion, border_xregion;234 Region corners_xregion, border_xregion;
235 XRectangle xrect;235 XRectangle xrect;
@@ -247,36 +247,38 @@
247 &bottom_left_radius,247 &bottom_left_radius,
248 &bottom_right_radius);248 &bottom_right_radius);
249249
250 if (top_left_radius)250 if (clip)
251 {251 {
252 for (i = 0; i < top_left_radius; i++)252 if (top_left_radius)
253 {253 {
254 w = radius_to_width (top_left_radius, i);254 for (i = 0; i < top_left_radius; i++)
255255 {
256 xrect.x = 0;256 w = radius_to_width (top_left_radius, i);
257 xrect.y = i;257
258 xrect.width = w;258 xrect.x = 0;
259 xrect.height = 1;259 xrect.y = i;
260260 xrect.width = w;
261 XUnionRectWithRegion (&xrect, corners_xregion, corners_xregion);261 xrect.height = 1;
262 }262
263 }263 XUnionRectWithRegion (&xrect, corners_xregion, corners_xregion);
264264 }
265 if (top_right_radius)265 }
266 {266
267 for (i = 0; i < top_right_radius; i++)267 if (top_right_radius)
268 {268 {
269 w = radius_to_width (top_right_radius, i);269 for (i = 0; i < top_right_radius; i++)
270270 {
271 xrect.x = width - w;271 w = radius_to_width (top_right_radius, i);
272 xrect.y = i;272
273 xrect.width = w;273 xrect.x = width - w;
274 xrect.height = 1;274 xrect.y = i;
275275 xrect.width = w;
276 XUnionRectWithRegion (&xrect, corners_xregion, corners_xregion);276 xrect.height = 1;
277 }277
278 }278 XUnionRectWithRegion (&xrect, corners_xregion, corners_xregion);
279279 }
280 }
281 }
280 border_xregion = XCreateRegion ();282 border_xregion = XCreateRegion ();
281283
282 xrect.x = 0;284 xrect.x = 0;
@@ -295,7 +297,8 @@
295297
296static Region298static Region
297meta_get_bottom_border_region (const MetaFrameGeometry *fgeom,299meta_get_bottom_border_region (const MetaFrameGeometry *fgeom,
298 int width)300 int width,
301 gboolean clip)
299{302{
300 Region corners_xregion, border_xregion;303 Region corners_xregion, border_xregion;
301 XRectangle xrect;304 XRectangle xrect;
@@ -313,33 +316,36 @@
313 &bottom_left_radius,316 &bottom_left_radius,
314 &bottom_right_radius);317 &bottom_right_radius);
315318
316 if (bottom_left_radius)319 if (clip)
317 {320 {
318 for (i = 0; i < bottom_left_radius; i++)321 if (bottom_left_radius)
319 {322 {
320 w = radius_to_width (bottom_left_radius, i);323 for (i = 0; i < bottom_left_radius; i++)
321324 {
322 xrect.x = 0;325 w = radius_to_width (bottom_left_radius, i);
323 xrect.y = fgeom->bottom_height - i - 1;326
324 xrect.width = w;327 xrect.x = 0;
325 xrect.height = 1;328 xrect.y = fgeom->bottom_height - i - 1;
326329 xrect.width = w;
327 XUnionRectWithRegion (&xrect, corners_xregion, corners_xregion);330 xrect.height = 1;
331
332 XUnionRectWithRegion (&xrect, corners_xregion, corners_xregion);
333 }
328 }334 }
329 }
330335
331 if (bottom_right_radius)336 if (bottom_right_radius)
332 {
333 for (i = 0; i < bottom_right_radius; i++)
334 {337 {
335 w = radius_to_width (bottom_right_radius, i);338 for (i = 0; i < bottom_right_radius; i++)
336339 {
337 xrect.x = width - w;340 w = radius_to_width (bottom_right_radius, i);
338 xrect.y = fgeom->bottom_height - i - 1;341
339 xrect.width = w;342 xrect.x = width - w;
340 xrect.height = 1;343 xrect.y = fgeom->bottom_height - i - 1;
341344 xrect.width = w;
342 XUnionRectWithRegion (&xrect, corners_xregion, corners_xregion);345 xrect.height = 1;
346
347 XUnionRectWithRegion (&xrect, corners_xregion, corners_xregion);
348 }
343 }349 }
344 }350 }
345351
@@ -519,22 +525,6 @@
519 DECOR_WINDOW_STATE_MAXIMIZED_VERT)))525 DECOR_WINDOW_STATE_MAXIMIZED_VERT)))
520 flags |= (MetaFrameFlags ) META_FRAME_MAXIMIZED;526 flags |= (MetaFrameFlags ) META_FRAME_MAXIMIZED;
521527
522 /* FIXME: do we really need to support all these ? */
523
524 //if (d->frame->frame_state & DECOR_WINDOW_STATE_STICK)
525 //flags |= (MetaFrameFlags ) META_FRAME_STUCK;
526
527 //if (d->frame->frame_state & DECOR_WINDOW_STATE_FULLSCREEN)
528 //flags |= (MetaFrameFlags ) META_FRAME_FULLSCREEN;
529
530 //if (d->frame->frame_state & DECOR_WINDOW_STATE_SHADED)
531 //flags |= (MetaFrameFlags ) META_FRAME_SHADED;
532
533#ifdef HAVE_METACITY_2_17_0
534 //if (d->frame->frame_state & DECOR_WINDOW_STATE_ABOVE)
535 //flags |= (MetaFrameFlags ) META_FRAME_ABOVE;
536#endif
537
538 if (frame_state & DECOR_WINDOW_STATE_FOCUS)528 if (frame_state & DECOR_WINDOW_STATE_FOCUS)
539 flags |= (MetaFrameFlags ) META_FRAME_HAS_FOCUS;529 flags |= (MetaFrameFlags ) META_FRAME_HAS_FOCUS;
540530
@@ -656,6 +646,43 @@
656}646}
657647
658void648void
649meta_rounded_rectangle (cairo_t *cr,
650 double x,
651 double y,
652 double w,
653 double h,
654 int r_tl,
655 int r_tr,
656 int r_bl,
657 int r_br)
658{
659 if (r_tl > 0)
660 cairo_move_to (cr, x + r_tl, y);
661 else
662 cairo_move_to (cr, x, y);
663
664 if (r_tr > 0)
665 cairo_arc (cr, x + w - r_tr, y + r_tr, r_tr, M_PI * 1.5, M_PI * 2.0);
666 else
667 cairo_line_to (cr, x + w, y);
668
669 if (r_br > 0)
670 cairo_arc (cr, x + w - r_br, y + h - r_br, r_br, 0.0, M_PI * 0.5);
671 else
672 cairo_line_to (cr, x + w, y + h);
673
674 if (r_bl > 0)
675 cairo_arc (cr, x + r_bl, y + h - r_bl, r_bl, M_PI * 0.5, M_PI);
676 else
677 cairo_line_to (cr, x, y + h);
678
679 if (r_tl > 0)
680 cairo_arc (cr, x + r_tl, y + r_tl, r_tl, M_PI, M_PI * 1.5);
681 else
682 cairo_line_to (cr, x, y);
683}
684
685void
659meta_draw_window_decoration (GWDDecoration *d)686meta_draw_window_decoration (GWDDecoration *d)
660{687{
661 Display *xdisplay =688 Display *xdisplay =
@@ -669,7 +696,7 @@
669 MetaFrameType frame_type;696 MetaFrameType frame_type;
670 MetaTheme *theme;697 MetaTheme *theme;
671 GtkStyle *style;698 GtkStyle *style;
672 cairo_t *cr;699 cairo_t *bg_cr, *final_cr;
673 gint size, i;700 gint size, i;
674 GdkRectangle clip, rect;701 GdkRectangle clip, rect;
675 GdkDrawable *drawable;702 GdkDrawable *drawable;
@@ -686,6 +713,14 @@
686 GdkColor bg_color;713 GdkColor bg_color;
687 double bg_alpha;714 double bg_alpha;
688 GdkPixbuf *icon_pixbuf;715 GdkPixbuf *icon_pixbuf;
716 int top_left_radius;
717 int top_right_radius;
718 int bottom_left_radius;
719 int bottom_right_radius;
720 gboolean clip_drawing = d->window ? FALSE : TRUE;
721 XRenderPictFormat *format;
722 Picture tmp;
723 GdkPixmap *tmp_pixmap;
689724
690 if (!d->pixmap || !d->picture)725 if (!d->pixmap || !d->picture)
691 return;726 return;
@@ -698,13 +733,30 @@
698 if (settings->decoration_alpha == 1.0)733 if (settings->decoration_alpha == 1.0)
699 alpha = 1.0;734 alpha = 1.0;
700735
736 if (!(d->frame->frame_state & DECOR_WINDOW_STATE_COMPOSITED))
737 {
738 GdkColormap *cmap;
739
740 cmap = get_colormap_for_drawable (GDK_DRAWABLE (d->pixmap));
741 tmp_pixmap = create_pixmap (d->width, d->height, d->frame->style_window);
742 gdk_drawable_set_colormap (GDK_DRAWABLE (tmp_pixmap), cmap);
743 }
744 else
745 tmp_pixmap = create_pixmap (d->width, d->height, d->frame->style_window);
746
747 format = get_format_for_drawable (d, GDK_DRAWABLE (tmp_pixmap));
748 tmp = XRenderCreatePicture (xdisplay, GDK_PIXMAP_XID (tmp_pixmap),
749 format, 0, NULL);
750
701 style = gtk_widget_get_style (d->frame->style_window);751 style = gtk_widget_get_style (d->frame->style_window);
702 style_window = d->frame->style_window;752 style_window = d->frame->style_window;
703753
704 drawable = d->buffer_pixmap ? d->buffer_pixmap : d->pixmap;754 drawable = tmp_pixmap;
705 cr = gdk_cairo_create (GDK_DRAWABLE (drawable));755 bg_cr = gdk_cairo_create (GDK_DRAWABLE (drawable));
756 final_cr = gdk_cairo_create (GDK_DRAWABLE (d->buffer_pixmap ? d->buffer_pixmap : d->pixmap));
706757
707 cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);758 cairo_set_operator (bg_cr, CAIRO_OPERATOR_SOURCE);
759 cairo_set_operator (final_cr, CAIRO_OPERATOR_SOURCE);
708760
709 theme = meta_theme_get_current ();761 theme = meta_theme_get_current ();
710 frame_type = meta_frame_type_from_string (frame_type_string (d->frame->frame_type, d->frame->frame_state));762 frame_type = meta_frame_type_from_string (frame_type_string (d->frame->frame_type, d->frame->frame_state));
@@ -715,13 +767,22 @@
715 meta_get_decoration_geometry (d, theme, &flags, &fgeom, &button_layout,767 meta_get_decoration_geometry (d, theme, &flags, &fgeom, &button_layout,
716 frame_type, &clip);768 frame_type, &clip);
717769
770 meta_get_corner_radius (&fgeom,
771 &top_left_radius,
772 &top_right_radius,
773 &bottom_left_radius,
774 &bottom_right_radius);
775
718 /* FIXME: I have no idea why this fixes disappearing titlebars776 /* FIXME: I have no idea why this fixes disappearing titlebars
719 * on windows that have no shadow, but it does */777 * on windows that have no shadow, but it does */
720 if (!d->window ||778 if (!d->window ||
721 (d->frame->frame_state & DECOR_WINDOW_STATE_COMPOSITED &&779 (d->frame->frame_state & DECOR_WINDOW_STATE_COMPOSITED &&
722 d->frame->shadow &&780 d->frame->shadow &&
723 (d->frame->shadow->width || d->frame->shadow->height)))781 (d->frame->shadow->width || d->frame->shadow->height)))
724 draw_shadow_background (d, cr, d->frame->shadow, &d->frame->context);782 {
783 draw_shadow_background (tmp, bg_cr, NULL, &d->frame->context, &d->border_layout);
784 draw_shadow_background (d->picture, final_cr, d->frame->shadow, &d->frame->context, &d->border_layout);
785 }
725786
726 for (i = 0; i < META_BUTTON_TYPE_LAST; i++)787 for (i = 0; i < META_BUTTON_TYPE_LAST; i++)
727 if (d->window && d->window->frame_window)788 if (d->window && d->window->frame_window)
@@ -747,8 +808,6 @@
747 }808 }
748#endif809#endif
749810
750 cairo_destroy (cr);
751
752 rect.x = 0;811 rect.x = 0;
753 rect.y = 0;812 rect.y = 0;
754 rect.width = clip.width;813 rect.width = clip.width;
@@ -757,7 +816,7 @@
757816
758 if (rect.width && size)817 if (rect.width && size)
759 {818 {
760 XRenderPictFormat *format;819 cairo_t *cr;
761820
762 if (!(d->frame->frame_state & DECOR_WINDOW_STATE_COMPOSITED))821 if (!(d->frame->frame_state & DECOR_WINDOW_STATE_COMPOSITED))
763 {822 {
@@ -802,19 +861,40 @@
802 icon_pixbuf,861 icon_pixbuf,
803 NULL);862 NULL);
804863
805 top_region = meta_get_top_border_region (&fgeom, clip.width);864 /* clear area around corners */
865 cairo_save (cr);
866 cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
867 cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
868 cairo_rectangle (cr,
869 rect.x,
870 rect.y,
871 rect.width,
872 rect.height);
873 meta_rounded_rectangle (cr,
874 rect.x,
875 rect.y,
876 rect.width,
877 rect.height,
878 top_left_radius,
879 top_right_radius,
880 0,
881 0);
882 cairo_fill (cr);
883 cairo_restore (cr);
884
885 top_region = meta_get_top_border_region (&fgeom, clip.width, clip_drawing);
806886
807 decor_blend_border_picture (xdisplay,887 decor_blend_border_picture (xdisplay,
808 &d->frame->context,888 &d->frame->context,
809 src,889 src,
810 0, 0,890 0, 0,
811 d->picture,891 tmp,
812 &d->border_layout,892 &d->border_layout,
813 BORDER_TOP,893 BORDER_TOP,
814 top_region,894 top_region,
815 alpha * 0xffff,895 alpha * 0xffff,
816 shade_alpha,896 shade_alpha,
817 0);897 0);
818 }898 }
819899
820 if (fgeom.bottom_height)900 if (fgeom.bottom_height)
@@ -842,13 +922,33 @@
842 icon_pixbuf,922 icon_pixbuf,
843 NULL);923 NULL);
844924
845 bottom_region = meta_get_bottom_border_region (&fgeom, clip.width);925 cairo_save (cr);
926 cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
927 cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
928 cairo_rectangle (cr,
929 rect.x,
930 rect.y,
931 rect.width,
932 rect.height);
933 meta_rounded_rectangle (cr,
934 rect.x,
935 rect.y,
936 rect.width,
937 rect.height,
938 0,
939 0,
940 bottom_left_radius,
941 bottom_right_radius);
942 cairo_fill (cr);
943 cairo_restore (cr);
944
945 bottom_region = meta_get_bottom_border_region (&fgeom, clip.width, clip_drawing);
846946
847 decor_blend_border_picture (xdisplay,947 decor_blend_border_picture (xdisplay,
848 &d->frame->context,948 &d->frame->context,
849 src,949 src,
850 0, 0,950 0, 0,
851 d->picture,951 tmp,
852 &d->border_layout,952 &d->border_layout,
853 BORDER_BOTTOM,953 BORDER_BOTTOM,
854 bottom_region,954 bottom_region,
@@ -871,7 +971,7 @@
871971
872 if (size && rect.height)972 if (size && rect.height)
873 {973 {
874 XRenderPictFormat *format;974 cairo_t *cr;
875975
876 if (d->frame->frame_state & DECOR_WINDOW_STATE_COMPOSITED)976 if (d->frame->frame_state & DECOR_WINDOW_STATE_COMPOSITED)
877 {977 {
@@ -923,13 +1023,14 @@
923 &d->frame->context,1023 &d->frame->context,
924 src,1024 src,
925 0, 0,1025 0, 0,
926 d->picture,1026 tmp,
927 &d->border_layout,1027 &d->border_layout,
928 BORDER_LEFT,1028 BORDER_LEFT,
929 left_region,1029 left_region,
930 alpha * 0xffff,1030 0xffff,
931 shade_alpha,1031 shade_alpha,
932 0);1032 0);
1033
933 }1034 }
9341035
935 if (fgeom.right_width)1036 if (fgeom.right_width)
@@ -963,22 +1064,40 @@
963 &d->frame->context,1064 &d->frame->context,
964 src,1065 src,
965 0, 0,1066 0, 0,
966 d->picture,1067 tmp,
967 &d->border_layout,1068 &d->border_layout,
968 BORDER_RIGHT,1069 BORDER_RIGHT,
969 right_region,1070 right_region,
970 alpha * 0xffff,1071 0xffff,
971 shade_alpha,1072 shade_alpha,
972 0);1073 0);
1074
973 }1075 }
9741076
975 cairo_destroy (cr);1077 XRenderComposite (xdisplay,
1078 PictOpOver,
1079 tmp,
1080 None,
1081 d->picture,
1082 0,
1083 0,
1084 0,
1085 0,
1086 0,
1087 0,
1088 d->width,
1089 d->height);
1090
1091 cairo_destroy (bg_cr);
9761092
977 g_object_unref (G_OBJECT (pixmap));1093 g_object_unref (G_OBJECT (pixmap));
9781094
979 XRenderFreePicture (xdisplay, src);1095 XRenderFreePicture (xdisplay, src);
980 }1096 }
9811097
1098 g_object_unref (G_OBJECT (tmp_pixmap));
1099 XRenderFreePicture (xdisplay, tmp);
1100
982 /* FIXME: Shouldn't need to copy from d->pixmap directly into d->image_box1101 /* FIXME: Shouldn't need to copy from d->pixmap directly into d->image_box
983 * there should be a way to get from d->buffer_pixmap to d->image_box */1102 * there should be a way to get from d->buffer_pixmap to d->image_box */
984 copy_to_front_buffer (d);1103 copy_to_front_buffer (d);
9851104
=== renamed file 'gtk/window-decorator/settings.c' => 'gtk/window-decorator/src/settings.c'
--- gtk/window-decorator/settings.c 2011-08-11 08:56:52 +0000
+++ gtk/window-decorator/src/settings.c 2011-08-19 15:05:12 +0000
@@ -334,8 +334,6 @@
334 gwd_decor_frame_unref (frame);334 gwd_decor_frame_unref (frame);
335}335}
336336
337#warning set_frames_scales
338
339void337void
340set_frames_scales (gpointer key,338set_frames_scales (gpointer key,
341 gpointer value,339 gpointer value,
342340
=== renamed file 'gtk/window-decorator/style.c' => 'gtk/window-decorator/src/style.c'
=== renamed file 'gtk/window-decorator/switcher.c' => 'gtk/window-decorator/src/switcher.c'
--- gtk/window-decorator/switcher.c 2011-08-11 17:35:20 +0000
+++ gtk/window-decorator/src/switcher.c 2011-08-19 15:05:12 +0000
@@ -112,7 +112,7 @@
112112
113 cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);113 cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
114114
115 draw_shadow_background (d, cr, d->frame->shadow, &d->frame->context);115 draw_shadow_background (d->picture, cr, d->frame->shadow, &d->frame->context, &d->border_layout);
116116
117 fill_rounded_rectangle (cr,117 fill_rounded_rectangle (cr,
118 x1 + 0.5,118 x1 + 0.5,
119119
=== renamed file 'gtk/window-decorator/util.c' => 'gtk/window-decorator/src/util.c'
--- gtk/window-decorator/util.c 2011-08-11 09:51:45 +0000
+++ gtk/window-decorator/src/util.c 2011-08-19 15:05:12 +0000
@@ -123,6 +123,9 @@
123 unsigned long n, left;123 unsigned long n, left;
124 unsigned char *prop_data;124 unsigned char *prop_data;
125 Atom *data;125 Atom *data;
126 gint err;
127
128 gdk_error_trap_push ();
126129
127 result = XGetWindowProperty (gdk_x11_get_default_xdisplay (),130 result = XGetWindowProperty (gdk_x11_get_default_xdisplay (),
128 xwindow,131 xwindow,
@@ -130,6 +133,13 @@
130 0L, 1024L, FALSE, XA_ATOM, &actual, &format,133 0L, 1024L, FALSE, XA_ATOM, &actual, &format,
131 &n, &left, &prop_data);134 &n, &left, &prop_data);
132135
136 err = gdk_error_trap_pop ();
137 if (err != Success || result != Success)
138 {
139 g_warning ("X Error while trying to fetch property");
140 return 0;
141 }
142
133 data = (Atom *) prop_data;143 data = (Atom *) prop_data;
134144
135 if (result == Success && data)145 if (result == Success && data)
136146
=== renamed file 'gtk/window-decorator/wnck.c' => 'gtk/window-decorator/src/wnck.c'
--- gtk/window-decorator/wnck.c 2011-08-11 19:38:07 +0000
+++ gtk/window-decorator/src/wnck.c 2011-08-19 15:05:12 +0000
@@ -79,7 +79,6 @@
79{79{
80 GWDWindow *w = g_object_get_data (G_OBJECT (win), "decor");80 GWDWindow *w = g_object_get_data (G_OBJECT (win), "decor");
81 GList *it = w->decorations;81 GList *it = w->decorations;
82
83 while (it)82 while (it)
84 {83 {
85 GdkPixbuf *pb = wnck_window_get_mini_icon (win);84 GdkPixbuf *pb = wnck_window_get_mini_icon (win);
@@ -142,14 +141,12 @@
142 GList *windows;141 GList *windows;
143 Window select;142 Window select;
144143
145 update_shadow ();
146 gwd_frames_foreach (update_frames_defaults, NULL);
147 gwd_frames_foreach (set_frames_scales, (gpointer) settings->font);144 gwd_frames_foreach (set_frames_scales, (gpointer) settings->font);
148145 gwd_frames_foreach (update_frames_titlebar_fonts, NULL);
149 update_titlebar_font ();
150
151 gwd_frames_foreach (update_frames_border_extents,146 gwd_frames_foreach (update_frames_border_extents,
152 NULL);147 NULL);
148 gwd_frames_foreach (update_frames_shadows, NULL);
149 gwd_frames_foreach (update_frames_defaults, NULL);
153150
154 if (minimal)151 if (minimal)
155 return;152 return;
@@ -160,6 +157,7 @@
160 while (windows != NULL)157 while (windows != NULL)
161 {158 {
162 GWDWindow *w = g_object_get_data (G_OBJECT (windows->data), "decor");159 GWDWindow *w = g_object_get_data (G_OBJECT (windows->data), "decor");
160
163 GList *it = w->decorations;161 GList *it = w->decorations;
164162
165#ifdef USE_METACITY163#ifdef USE_METACITY
@@ -167,13 +165,13 @@
167 {165 {
168 GWDDecoration *d = (GWDDecoration *) it->data;166 GWDDecoration *d = (GWDDecoration *) it->data;
169 if (d->draw == draw_window_decoration ||167 if (d->draw == draw_window_decoration ||
170 d->draw == meta_draw_window_decoration)168 d->draw == meta_draw_window_decoration)
171 d->draw = theme_draw_window_decoration;169 d->draw = theme_draw_window_decoration;
172 it = g_list_next (it);170 it = g_list_next (it);
173 }171 }
174#endif172#endif
173 update_window_decoration (windows->data);
175174
176 update_window_decoration (WNCK_WINDOW (windows->data));
177 windows = windows->next;175 windows = windows->next;
178 }176 }
179177
@@ -244,9 +242,11 @@
244 GWDDecoration *d;242 GWDDecoration *d;
245243
246 /* Inhibit the generation of new decorations for244 /* Inhibit the generation of new decorations for
247 * windows which are not decorated and managed*/245 * windows which are not decorated and managed
248 if (!(window->mwm_prop & (MWM_DECOR_ALL | MWM_DECOR_TITLE)) &&246 * or destroyed */
249 window->win)247 if ((!(window->mwm_prop & (MWM_DECOR_ALL | MWM_DECOR_TITLE)) &&
248 window->win) ||
249 !window->xid)
250 {250 {
251 if (window != gwd_default_decorations_window)251 if (window != gwd_default_decorations_window)
252 {252 {
@@ -295,10 +295,10 @@
295 d->window->icon = update_window_decoration_icon (d->window->icon,295 d->window->icon = update_window_decoration_icon (d->window->icon,
296 icon,296 icon,
297 d->frame->style_window);297 d->frame->style_window);
298
299 update_window_decoration_size (d, client_geometry, name);
300 }298 }
301299
300 update_window_decoration_size (d, client_geometry, name);
301
302 /* If this is the default decorations window and the302 /* If this is the default decorations window and the
303 * default implementation is NULL, then it means that303 * default implementation is NULL, then it means that
304 * we're in decor_frame_refresh and the defeault implementation304 * we're in decor_frame_refresh and the defeault implementation
@@ -458,6 +458,12 @@
458 win->force_quit_dialog = NULL;458 win->force_quit_dialog = NULL;
459 win->xid = xid;459 win->xid = xid;
460 win->frame_window = NULL;460 win->frame_window = NULL;
461 memset (&win->client_geometry, 0, sizeof (XRectangle));
462 win->mwm_prop = 0;
463 win->net_wm_state_modal_atom = 0;
464 win->actions = 0;
465 win->state = 0;
466 win->type = DECOR_WINDOW_TYPE_BARE;
461467
462 /* Managed window */468 /* Managed window */
463 if (win->win)469 if (win->win)
@@ -466,9 +472,20 @@
466 GdkWindow *client = create_foreign_window (win->xid);472 GdkWindow *client = create_foreign_window (win->xid);
467 int xp, yp, wp, hp;473 int xp, yp, wp, hp;
468474
469 gdk_window_set_events (client, gdk_window_get_events (client) |475 gdk_error_trap_push ();
470 GDK_PROPERTY_CHANGE_MASK);476 if (client)
471 gdk_window_add_filter (client, event_filter_func, NULL);477 gdk_window_set_events (client, gdk_window_get_events (client) |
478 GDK_PROPERTY_CHANGE_MASK);
479
480 gdk_display_sync (gdk_display_get_default ());
481 if (gdk_error_trap_pop () || !client)
482 {
483 g_warning ("attempted to create GWDWindow for"\
484 "destroyed window 0x%x", (guint32) xid);
485 win->xid = 0;
486 return win;
487 }
488
472 wnck_window_get_client_window_geometry (win->win, &xp, &yp, &hp, &wp);489 wnck_window_get_client_window_geometry (win->win, &xp, &yp, &hp, &wp);
473490
474 win->client_geometry.x = xp;491 win->client_geometry.x = xp;
@@ -502,15 +519,22 @@
502 {519 {
503 g_warning ("attempted to create GWDWindow for"\520 g_warning ("attempted to create GWDWindow for"\
504 "destroyed window 0x%x", (guint32) xid);521 "destroyed window 0x%x", (guint32) xid);
505522 win->xid = 0;
506 return NULL;523 return win;
507 }524 }
508525
509 /* always 0 */526 if (xid == root)
510 win->actions = 0;527 {
511 win->state = 0;528 x = 0;
512 win->type = DECOR_WINDOW_TYPE_BARE;529 y = 0;
513 win->mwm_prop = 0;530 width = 1;
531 height = 1;
532 }
533
534 win->client_geometry.x = x;
535 win->client_geometry.y = y;
536 win->client_geometry.width = width;
537 win->client_geometry.height = height;
514 }538 }
515539
516 win->cache = decor_cache_new ();540 win->cache = decor_cache_new ();
@@ -566,7 +590,10 @@
566 win->icon = update_window_decoration_icon (win->icon, NULL, NULL);590 win->icon = update_window_decoration_icon (win->icon, NULL, NULL);
567591
568 if (win->frame_window)592 if (win->frame_window)
593 {
569 gwd_frame_window_delete (win->frame_window, FALSE);594 gwd_frame_window_delete (win->frame_window, FALSE);
595 win->frame_window->window = NULL;
596 }
570597
571 if (win->force_quit_dialog)598 if (win->force_quit_dialog)
572 g_object_unref (G_OBJECT (win->force_quit_dialog));599 g_object_unref (G_OBJECT (win->force_quit_dialog));
@@ -599,7 +626,6 @@
599 GdkColormap *colormap;626 GdkColormap *colormap;
600 GdkWindow *compiz_frame_window = create_foreign_window (frame_window);627 GdkWindow *compiz_frame_window = create_foreign_window (frame_window);
601 GdkWindow *backing_window;628 GdkWindow *backing_window;
602 unsigned int i, j;
603629
604 if (!compiz_frame_window)630 if (!compiz_frame_window)
605 {631 {
@@ -607,83 +633,47 @@
607 return NULL;633 return NULL;
608 }634 }
609635
610 static event_callback callback[3][3] = {
611 { top_left_event, top_event, top_right_event },
612 { left_event, title_event, right_event },
613 { bottom_left_event, bottom_event, bottom_right_event }
614 };
615 static event_callback button_callback[BUTTON_NUM] = {
616 close_button_event,
617 max_button_event,
618 min_button_event,
619 menu_button_event,
620 shade_button_event,
621 above_button_event,
622 stick_button_event,
623 unshade_button_event,
624 unabove_button_event,
625 unstick_button_event
626 };
627
628 fw->window = win;636 fw->window = win;
629 fw->xid = frame_window;637 fw->xid = frame_window;
630 fw->atom = atom;638 fw->atom = atom;
631 fw->container = gtk_window_new (GTK_WINDOW_POPUP);639 fw->container = gtk_window_new (GTK_WINDOW_POPUP);
640 fw->event_box = gtk_event_box_new ();
632641
633 colormap = get_colormap_for_drawable (GDK_DRAWABLE (compiz_frame_window));642 colormap = get_colormap_for_drawable (GDK_DRAWABLE (compiz_frame_window));
634 gtk_widget_set_colormap (GTK_WIDGET (fw->container), colormap);643 gtk_widget_set_colormap (GTK_WIDGET (fw->container), colormap);
635644
645 g_object_set (G_OBJECT (fw->container), "has-resize-grip", FALSE, NULL);
646 g_object_set (G_OBJECT (fw->container), "destroy-with-parent", TRUE, NULL);
647 g_object_set (G_OBJECT (fw->container), "focus-on-map", FALSE, NULL);
648 g_object_set (G_OBJECT (fw->container), "accept-focus", FALSE, NULL);
649 gdk_error_trap_push ();
636 gtk_widget_realize (GTK_WIDGET (fw->container));650 gtk_widget_realize (GTK_WIDGET (fw->container));
637 backing_window = gtk_widget_get_window (GTK_WIDGET (fw->container));651 backing_window = gtk_widget_get_window (GTK_WIDGET (fw->container));
638652
653 fw->container_xid = GDK_WINDOW_XID (backing_window);
654
639 /* Remove the input shape of the output window */655 /* Remove the input shape of the output window */
640 gdk_error_trap_push ();
641 XShapeSelectInput (gdk_x11_display_get_xdisplay (gdk_display_get_default ()), GDK_WINDOW_XID (backing_window), NoEventMask);
642 XShapeCombineRectangles (gdk_x11_display_get_xdisplay (gdk_display_get_default ()), GDK_WINDOW_XID (backing_window),
643 ShapeInput, 0, 0, NULL, 0, ShapeSet, 0);
644
645 XSetWindowAttributes attrib;
646
647 /* Don't let events from this window screw up processing */
648 attrib.do_not_propagate_mask = ButtonPressMask | ButtonReleaseMask | PointerMotionMask;
649 XChangeWindowAttributes (gdk_x11_display_get_xdisplay (gdk_display_get_default ()), GDK_WINDOW_XID (backing_window), CWDontPropagate, &attrib);
650
651 /* Reparent this window into the backing window */
652 XReparentWindow (gdk_x11_display_get_xdisplay (gdk_display_get_default ()), GDK_WINDOW_XID (backing_window), fw->xid, 0, 0);
653 XLowerWindow (gdk_x11_display_get_xdisplay (gdk_display_get_default ()), GDK_WINDOW_XID (backing_window));
654
655 gdk_display_sync (gdk_display_get_default ());656 gdk_display_sync (gdk_display_get_default ());
656 if (!gdk_error_trap_pop ())657 if (!gdk_error_trap_pop ())
657 {658 {
658 gtk_widget_show_all (GTK_WIDGET (fw->container));
659
660 for (i = 0; i < 3; i++)
661 for (j = 0; j < 3; j++)
662 fw->event_windows[i][j].callback = callback[i][j];
663
664 for (i = 0; i < BUTTON_NUM; i++)
665 fw->button_windows[i].callback = button_callback[i];
666
667 fw->container_xid = GDK_WINDOW_XID (backing_window);
668
669 update_event_windows (fw);
670
671 gdk_window_set_events (backing_window,
672 GDK_STRUCTURE_MASK);
673 gdk_window_set_events (compiz_frame_window,659 gdk_window_set_events (compiz_frame_window,
674 gdk_window_get_events (compiz_frame_window) |660 gdk_window_get_events (compiz_frame_window) |
675 GDK_POINTER_MOTION_MASK |661 GDK_STRUCTURE_MASK |
676 GDK_BUTTON_PRESS_MASK |662 GDK_SUBSTRUCTURE_MASK);
677 GDK_BUTTON_RELEASE_MASK |
678 GDK_STRUCTURE_MASK);
679 gdk_window_add_filter (compiz_frame_window, event_filter_func, NULL);
680 gdk_window_add_filter (backing_window, event_filter_func, NULL);
681663
682 g_hash_table_insert (frame_table, GINT_TO_POINTER (fw->xid), win);664 decor_request_embed_window (gdk_x11_display_get_xdisplay (gdk_display_get_default ()),
683 g_hash_table_insert (frame_table, GINT_TO_POINTER (fw->container_xid), win);665 gdk_x11_get_default_screen (),
666 win->xid,
667 fw->container_xid,
668 fw->xid,
669 0,
670 0);
671 g_hash_table_insert (frame_table, GINT_TO_POINTER (fw->xid), fw);
672 g_hash_table_insert (frame_table, GINT_TO_POINTER (fw->container_xid), fw);
684 }673 }
685 else674 else
686 {675 {
676 g_warning ("failed to create input window for 0x%x", fw->window->xid);
687 gtk_widget_destroy (GTK_WIDGET (fw->container));677 gtk_widget_destroy (GTK_WIDGET (fw->container));
688 free (fw);678 free (fw);
689 return NULL;679 return NULL;
@@ -693,18 +683,54 @@
693}683}
694684
695void685void
696gwd_frame_window_delete (GWDFrameWindow *fw, gboolean safe)686gwd_frame_window_delete (GWDFrameWindow *fw, gboolean unreparented)
697{687{
698688 gboolean safe = FALSE;
699 if (!safe && fw->container)689
700 gtk_widget_destroy (GTK_WIDGET (fw->container));690 /* Triple check that ... */
701 else if (safe && fw->container)691 if (!safe)
702 g_warning ("seems like some buggy application deleted our frame window, trying to work around, but I might leak memory in the process, sorry!");692 {
703693 gdk_display_sync (gdk_display_get_default ());
704 g_hash_table_remove (frame_table, GINT_TO_POINTER (fw->xid));694
705 g_hash_table_remove (frame_table, GINT_TO_POINTER (fw->container_xid));695 XEvent e;
706696 if (XCheckTypedWindowEvent (gdk_x11_display_get_xdisplay (gdk_display_get_default ()),
707 free (fw);697 fw->xid, DestroyNotify, &e))
698 {
699 g_warning ("deleting destroyed window");
700 XPutBackEvent (gdk_x11_display_get_xdisplay (gdk_display_get_default ()), &e);
701 safe = TRUE;
702 }
703 }
704
705 /* Wait until the unreparent notification
706 * comes around */
707 if (!unreparented)
708 {
709 decor_request_embed_window (gdk_x11_display_get_xdisplay (gdk_display_get_default ()),
710 gdk_x11_get_default_screen (),
711 fw->window->xid,
712 fw->container_xid,
713 fw->xid,
714 0,
715 0);
716 }
717 else
718 {
719 if (last_clicked_frame &&
720 last_clicked_frame->frame_window == fw)
721 last_clicked_frame = NULL;
722
723 if (fw->container)
724 gtk_widget_destroy (GTK_WIDGET (fw->container));
725
726 g_hash_table_remove (frame_table, GINT_TO_POINTER (fw->xid));
727 g_hash_table_remove (frame_table, GINT_TO_POINTER (fw->container_xid));
728
729 if (fw->window)
730 fw->window->frame_window = NULL;
731
732 free (fw);
733 }
708}734}
709735
710void736void
@@ -738,9 +764,7 @@
738 {764 {
739 GWDWindow *w = g_object_get_data (G_OBJECT (win), "decor");765 GWDWindow *w = g_object_get_data (G_OBJECT (win), "decor");
740766
741 /* g_object_get_data can return NULL here since767 /* On startup this can be NULL */
742 * the window could have just been destroyed */
743
744 if (w)768 if (w)
745 {769 {
746 w->state &= ~(DECOR_WINDOW_STATE_FOCUS);770 w->state &= ~(DECOR_WINDOW_STATE_FOCUS);
@@ -755,7 +779,6 @@
755 GWDWindow *w = g_object_get_data (G_OBJECT (win), "decor");779 GWDWindow *w = g_object_get_data (G_OBJECT (win), "decor");
756780
757 w->state |= DECOR_WINDOW_STATE_FOCUS;781 w->state |= DECOR_WINDOW_STATE_FOCUS;
758
759 gwd_decoration_get (w, w->type, w->state, w->actions);782 gwd_decoration_get (w, w->type, w->state, w->actions);
760 }783 }
761}784}
762785
=== added directory 'gtk/window-decorator/test-cache'
=== removed file 'gtk/window-decorator/test-cache.c'
--- gtk/window-decorator/test-cache.c 2011-08-11 08:56:52 +0000
+++ gtk/window-decorator/test-cache.c 1970-01-01 00:00:00 +0000
@@ -1,116 +0,0 @@
1/*
2 * test-cache.c
3 *
4 * Copyright (c) 2011 Canonical Ltd.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 *
19 * Authored by:
20 * Sam Spilsbury <sam.spilsbury@canonical.com>
21 */
22
23#include "decoration-test.h"
24
25int main (void)
26{
27 char *data_string;
28 decor_cache_t *cache = decor_cache_new ();
29 decor_subproperty_t *s1, *s2, *s3;
30 decoration *d1 = NULL;
31 decoration *d2 = NULL;
32 decoration *d3 = NULL;
33
34 g_debug ("create decoration 1");
35
36 d1 = create_decoration_from_info (None, 5, 5, 5, 5,
37 10, 10, 10, 10, 5, 5, 5, 5,
38 100, 100,
39 DECOR_WINDOW_TYPE_NORMAL,
40 DECOR_WINDOW_STATE_FOCUS |
41 DECOR_WINDOW_STATE_COMPOSITED,
42 0,
43 cache);
44
45 g_debug ("create decoration 2");
46
47 d2 = create_decoration_from_info (None, 5, 5, 5, 5,
48 10, 10, 10, 10, 5, 5, 5, 5,
49 100, 100,
50 DECOR_WINDOW_TYPE_NORMAL,
51 DECOR_WINDOW_STATE_COMPOSITED,
52 0,
53 cache);
54
55 g_debug ("create decoration 3");
56
57 d3 = create_decoration_from_info (None, 5, 5, 5, 5,
58 10, 10, 10, 10, 5, 5, 5, 5,
59 100, 100,
60 DECOR_WINDOW_TYPE_DIALOG,
61 DECOR_WINDOW_STATE_COMPOSITED,
62 0,
63 cache);
64
65 g_debug ("Writing pixmap property");
66
67 dump_decoration_data (d1->property->data);
68 dump_decoration_data (d2->property->data);
69 dump_decoration_data (d3->property->data);
70
71 printf ("Property contains : { ");
72 data_string = data_to_string (cache->data, cache->size);
73 printf ("%s", data_string);
74 printf ("}\n");
75 free (data_string);
76 data_string = NULL;
77
78 g_debug ("Reading pixmap property");
79
80 s1 = d1->property;
81 free (d1);
82
83 s2 = d2->property;
84 free (d2);
85
86 s3 = d3->property;
87 free (d3);
88
89 d1 = load_decoration_from_property (s1->data);
90 d1->property = s1;
91 d2 = load_decoration_from_property (s2->data);
92 d2->property = s2;
93 d3 = load_decoration_from_property (s3->data);
94 d3->property = s3;
95
96 dump_decoration (d1);
97 dump_decoration (d2);
98 dump_decoration (d3);
99
100 g_debug ("Delete decoration 2");
101 destroy_decoration (d2, cache);
102
103 dump_decoration (d1);
104 dump_decoration (d3);
105
106 g_debug ("Delete decoration 3");
107 destroy_decoration (d3, cache);
108
109 dump_decoration (d1);
110
111 g_debug ("Delete decoration 1");
112 destroy_decoration (d1, cache);
113
114 decor_cache_destroy (cache);
115 return 0;
116}
1170
=== added file 'gtk/window-decorator/test-cache/CMakeLists.txt'
--- gtk/window-decorator/test-cache/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ gtk/window-decorator/test-cache/CMakeLists.txt 2011-08-19 15:05:12 +0000
@@ -0,0 +1,9 @@
1pkg_check_modules (TEST_CACHE REQUIRED libdecoration)
2include_directories (${TEST_CACHE_INCLUDE_DIRS}
3 ${compiz_SOURCE_DIR}/include
4 ..)
5add_definitions (-DPREFIX=\\\"${CMAKE_INSTALL_PREFIX}\\\")
6
7add_executable (test-cache test-cache.c ../decoration-test.c)
8
9target_link_libraries (test-cache ${TEST_CACHE_LIBRARIES})
010
=== added file 'gtk/window-decorator/test-cache/test-cache.c'
--- gtk/window-decorator/test-cache/test-cache.c 1970-01-01 00:00:00 +0000
+++ gtk/window-decorator/test-cache/test-cache.c 2011-08-19 15:05:12 +0000
@@ -0,0 +1,116 @@
1/*
2 * test-cache.c
3 *
4 * Copyright (c) 2011 Canonical Ltd.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 *
19 * Authored by:
20 * Sam Spilsbury <sam.spilsbury@canonical.com>
21 */
22
23#include "decoration-test.h"
24
25int main (void)
26{
27 char *data_string;
28 decor_cache_t *cache = decor_cache_new ();
29 decor_subproperty_t *s1, *s2, *s3;
30 decoration *d1 = NULL;
31 decoration *d2 = NULL;
32 decoration *d3 = NULL;
33
34 printf ("create decoration 1\n");
35
36 d1 = create_decoration_from_info (None, 5, 5, 5, 5,
37 10, 10, 10, 10, 5, 5, 5, 5,
38 100, 100,
39 DECOR_WINDOW_TYPE_NORMAL,
40 DECOR_WINDOW_STATE_FOCUS |
41 DECOR_WINDOW_STATE_COMPOSITED,
42 0,
43 cache);
44
45 printf ("create decoration 2\n");
46
47 d2 = create_decoration_from_info (None, 5, 5, 5, 5,
48 10, 10, 10, 10, 5, 5, 5, 5,
49 100, 100,
50 DECOR_WINDOW_TYPE_NORMAL,
51 DECOR_WINDOW_STATE_COMPOSITED,
52 0,
53 cache);
54
55 printf ("create decoration 3\n");
56
57 d3 = create_decoration_from_info (None, 5, 5, 5, 5,
58 10, 10, 10, 10, 5, 5, 5, 5,
59 100, 100,
60 DECOR_WINDOW_TYPE_DIALOG,
61 DECOR_WINDOW_STATE_COMPOSITED,
62 0,
63 cache);
64
65 printf ("Writing pixmap property\n");
66
67 dump_decoration_data (d1->property->data);
68 dump_decoration_data (d2->property->data);
69 dump_decoration_data (d3->property->data);
70
71 printf ("Property contains : { ");
72 data_string = data_to_string (cache->data, cache->size);
73 printf ("%s", data_string);
74 printf ("}\n");
75 free (data_string);
76 data_string = NULL;
77
78 printf ("Reading pixmap property\n");
79
80 s1 = d1->property;
81 free (d1);
82
83 s2 = d2->property;
84 free (d2);
85
86 s3 = d3->property;
87 free (d3);
88
89 d1 = load_decoration_from_property (s1->data);
90 d1->property = s1;
91 d2 = load_decoration_from_property (s2->data);
92 d2->property = s2;
93 d3 = load_decoration_from_property (s3->data);
94 d3->property = s3;
95
96 dump_decoration (d1);
97 dump_decoration (d2);
98 dump_decoration (d3);
99
100 printf ("Delete decoration 2\n");
101 destroy_decoration (d2, cache);
102
103 dump_decoration (d1);
104 dump_decoration (d3);
105
106 printf ("Delete decoration 3\n");
107 destroy_decoration (d3, cache);
108
109 dump_decoration (d1);
110
111 printf ("Delete decoration 1\n");
112 destroy_decoration (d1, cache);
113
114 decor_cache_destroy (cache);
115 return 0;
116}
0117
=== modified file 'include/decoration.h'
--- include/decoration.h 2011-08-11 19:38:07 +0000
+++ include/decoration.h 2011-08-19 15:05:12 +0000
@@ -21,6 +21,8 @@
21 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.21 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 *22 *
23 * Author: David Reveman <davidr@novell.com>23 * Author: David Reveman <davidr@novell.com>
24 * Frame Cache System: Copyright (c) 2011 Canonical Ltd.
25 * Authored By: Sam Spilsbury <sam.spilsbury@canonical.com>
24 */26 */
2527
26#ifndef _DECORATION_H28#ifndef _DECORATION_H
@@ -40,6 +42,7 @@
40#define DECOR_BARE_ATOM_NAME "_COMPIZ_WINDOW_DECOR_BARE"42#define DECOR_BARE_ATOM_NAME "_COMPIZ_WINDOW_DECOR_BARE"
41#define DECOR_NORMAL_ATOM_NAME "_COMPIZ_WINDOW_DECOR_NORMAL"43#define DECOR_NORMAL_ATOM_NAME "_COMPIZ_WINDOW_DECOR_NORMAL"
42#define DECOR_ACTIVE_ATOM_NAME "_COMPIZ_WINDOW_DECOR_ACTIVE"44#define DECOR_ACTIVE_ATOM_NAME "_COMPIZ_WINDOW_DECOR_ACTIVE"
45#define DECOR_REQUEST_EMBED_WINDOW_ATOM_NAME "_COMPIZ_EMBED_DECOR_WINDOW"
43#define DECOR_WINDOW_ATOM_NAME "_COMPIZ_WINDOW_DECOR"46#define DECOR_WINDOW_ATOM_NAME "_COMPIZ_WINDOW_DECOR"
44#define DECOR_BLUR_ATOM_NAME "_COMPIZ_WM_WINDOW_BLUR_DECOR"47#define DECOR_BLUR_ATOM_NAME "_COMPIZ_WM_WINDOW_BLUR_DECOR"
45#define DECOR_SWITCH_WINDOW_ATOM_NAME "_COMPIZ_SWITCH_SELECT_WINDOW"48#define DECOR_SWITCH_WINDOW_ATOM_NAME "_COMPIZ_SWITCH_SELECT_WINDOW"
@@ -226,19 +229,35 @@
226int229int
227decor_version (void);230decor_version (void);
228231
232/* Allocates a new cache object */
233
229decor_cache_t *234decor_cache_t *
230decor_cache_new ();235decor_cache_new ();
231236
237/* Destroys the cache object */
238
232void239void
233decor_cache_destroy (decor_cache_t *);240decor_cache_destroy (decor_cache_t *);
234241
242/* Appends the size of a window property to a cache
243 * object, returning a structure representing the
244 * index of that property inside of the cache */
245
235decor_subproperty_t *246decor_subproperty_t *
236decor_cache_append_window (decor_cache_t *cache);247decor_cache_append_window (decor_cache_t *cache);
237248
249/* Appends the size of a pixmap property to a cache
250 * object, returning a structure representing the
251 * index of that property inside of the cache
252 *
253 * nQuad: maximum number of quads allowed in the
254 * property */
255
238decor_subproperty_t *256decor_subproperty_t *
239decor_cache_append_pixmap (decor_cache_t *cache,257decor_cache_append_pixmap (decor_cache_t *cache,
240 unsigned int nQuad);258 unsigned int nQuad);
241259
260/* Writes pixmap information to a pixmap subproperty */
242void261void
243decor_subproperty_set_pixmap (decor_subproperty_t *property,262decor_subproperty_set_pixmap (decor_subproperty_t *property,
244 Pixmap pixmap,263 Pixmap pixmap,
@@ -252,6 +271,7 @@
252 unsigned int frame_state,271 unsigned int frame_state,
253 unsigned int frame_actions);272 unsigned int frame_actions);
254273
274/* Writes window information to a pixmap subproperty */
255void275void
256decor_subproperty_set_window (decor_subproperty_t *cache,276decor_subproperty_set_window (decor_subproperty_t *cache,
257 decor_extents_t *input,277 decor_extents_t *input,
@@ -276,15 +296,20 @@
276int296int
277decor_subproperty_get_type (long int *);297decor_subproperty_get_type (long int *);
278298
299/* Retreive the next subproperty index in the data */
279long *300long *
280decor_get_next_subproperty (long int *data,301decor_get_next_subproperty (long int *data,
281 long *property,302 long *property,
282 unsigned int *n);303 unsigned int *n);
283304
284/* frame_type, frame_state and frame_actions here305/*
306 * Removes the subproperty specified at the index in property
307 * from the cache object and reallocates the cache, updating
308 * the indexes for the other properties automatically
309 *
310 * frame_type, frame_state and frame_actions here
285 * are all used for error detection, though maybe311 * are all used for error detection, though maybe
286 * they should be removed in the future */312 * they should be removed in the future */
287
288int313int
289decor_cache_remove_subproperty (decor_cache_t *cache,314decor_cache_remove_subproperty (decor_cache_t *cache,
290 unsigned int frame_type,315 unsigned int frame_type,
@@ -292,6 +317,10 @@
292 unsigned int frame_actions,317 unsigned int frame_actions,
293 decor_subproperty_t *property);318 decor_subproperty_t *property);
294319
320/*
321 * Reads serialized pixmap property information into
322 * a set of quads, pixmap and minimum geometry + metadata */
323
295int324int
296decor_pixmap_property_to_quads (long *data,325decor_pixmap_property_to_quads (long *data,
297 Pixmap *pixmap,326 Pixmap *pixmap,
@@ -304,6 +333,10 @@
304 unsigned int *frame_actions,333 unsigned int *frame_actions,
305 decor_quad_t *quad);334 decor_quad_t *quad);
306335
336/*
337 * Reads serialized window property information into
338 * a set of minimum geometry + metadata */
339
307int340int
308decor_window_property (long *data,341decor_window_property (long *data,
309 decor_extents_t *input,342 decor_extents_t *input,
@@ -449,6 +482,12 @@
449 int height,482 int height,
450 decor_layout_t *layout);483 decor_layout_t *layout);
451484
485/*
486 * Fills the specified picture with the shadow extents
487 * according to the frame layout information in layout
488 * and context
489 */
490
452void491void
453decor_fill_picture_extents_with_shadow (Display *xdisplay,492decor_fill_picture_extents_with_shadow (Display *xdisplay,
454 decor_shadow_t *shadow,493 decor_shadow_t *shadow,
@@ -468,6 +507,16 @@
468 unsigned short alpha,507 unsigned short alpha,
469 int shade_alpha);508 int shade_alpha);
470509
510/*
511 * Blends a part of the frame into an existing
512 * XRenderPicture, clipping by region and
513 * padding as appropriate. Also applies a
514 * translucent fade-out to the decoration
515 * if that was specified
516 *
517 * Use ignore_src_alpha to force painting an
518 * opaque decoration */
519
471void520void
472decor_blend_border_picture (Display *xdisplay,521decor_blend_border_picture (Display *xdisplay,
473 decor_context_t *context,522 decor_context_t *context,
@@ -482,6 +531,21 @@
482 int shade_alpha,531 int shade_alpha,
483 int ignore_src_alpha);532 int ignore_src_alpha);
484533
534/*
535 * Convenience function for decorations to request that
536 * one of their windows be reparented into the frame
537 * window that compiz gave it. Specify None in
538 * embed to have the frame unreparented */
539
540int
541decor_request_embed_window (Display *xdisplay,
542 int screen,
543 Window client,
544 Window embed,
545 Window frame,
546 int x_off,
547 int y_off);
548
485#define DECOR_ACQUIRE_STATUS_SUCCESS 0549#define DECOR_ACQUIRE_STATUS_SUCCESS 0
486#define DECOR_ACQUIRE_STATUS_FAILED 1550#define DECOR_ACQUIRE_STATUS_FAILED 1
487#define DECOR_ACQUIRE_STATUS_OTHER_DM_RUNNING 2551#define DECOR_ACQUIRE_STATUS_OTHER_DM_RUNNING 2
488552
=== modified file 'libdecoration/decoration.c'
--- libdecoration/decoration.c 2011-08-11 19:38:07 +0000
+++ libdecoration/decoration.c 2011-08-19 15:05:12 +0000
@@ -530,7 +530,6 @@
530 }530 }
531 else531 else
532 {532 {
533 /* There has to be something better than this ... */
534 data = data + decor_subproperty_get_size (data);533 data = data + decor_subproperty_get_size (data);
535 (*n)++;534 (*n)++;
536 }535 }
@@ -3037,6 +3036,38 @@
3037}3036}
30383037
3039int3038int
3039decor_request_embed_window (Display *xdisplay,
3040 int screen,
3041 Window client,
3042 Window embed,
3043 Window frame,
3044 int x_off,
3045 int y_off)
3046{
3047 XEvent event;
3048 Atom embed_window_atom = XInternAtom (xdisplay,
3049 DECOR_REQUEST_EMBED_WINDOW_ATOM_NAME,
3050 0);
3051
3052 /* Send client message indicating that we want to embed
3053 * this 'embed' window into the frame for the client */
3054 event.xclient.type = ClientMessage;
3055 event.xclient.window = client;
3056 event.xclient.message_type = embed_window_atom;
3057 event.xclient.format = 32;
3058 event.xclient.data.l[0] = embed;
3059 event.xclient.data.l[1] = frame;
3060 event.xclient.data.l[2] = x_off;
3061 event.xclient.data.l[3] = y_off;
3062 event.xclient.data.l[4] = 0;
3063
3064 XSendEvent (xdisplay, XRootWindow (xdisplay, screen), 0,
3065 StructureNotifyMask, &event);
3066
3067 return 1;
3068}
3069
3070int
3040decor_acquire_dm_session (Display *xdisplay,3071decor_acquire_dm_session (Display *xdisplay,
3041 int screen,3072 int screen,
3042 const char *name,3073 const char *name,
30433074
=== modified file 'plugins/decor/src/decor.cpp'
--- plugins/decor/src/decor.cpp 2011-08-11 19:39:44 +0000
+++ plugins/decor/src/decor.cpp 2011-08-19 15:05:12 +0000
@@ -42,6 +42,29 @@
4242
43COMPIZ_PLUGIN_20090315 (decor, DecorPluginVTable)43COMPIZ_PLUGIN_20090315 (decor, DecorPluginVTable)
4444
45/*
46 * Count the number of bits which are currently
47 * set in an interger. */
48static unsigned int
49numBits (unsigned int i)
50{
51#ifdef __GNUC__
52 return __builtin_popcount (i);
53#else
54 unsigned int count = 0;
55 /* software implementation */
56 while (i > 0)
57 {
58 if (i & 1)
59 count++;
60
61 i >> 1;
62 }
63
64 return count;
65#endif
66}
67
45/* From core */68/* From core */
4669
47bool70bool
@@ -857,7 +880,7 @@
857DecorWindow::matchType (CompWindow *w,880DecorWindow::matchType (CompWindow *w,
858 unsigned int decorType)881 unsigned int decorType)
859{882{
860 const unsigned int nTypeStates = 5;883 const unsigned int nTypeStates = 4;
861 unsigned int i;884 unsigned int i;
862 struct typestate {885 struct typestate {
863 unsigned int compFlag;886 unsigned int compFlag;
@@ -865,7 +888,8 @@
865 } typeStates[] =888 } typeStates[] =
866 {889 {
867 { CompWindowTypeNormalMask, DECOR_WINDOW_TYPE_NORMAL },890 { CompWindowTypeNormalMask, DECOR_WINDOW_TYPE_NORMAL },
868 { CompWindowTypeDialogMask, DECOR_WINDOW_TYPE_DIALOG },891 { CompWindowTypeDialogMask |
892 CompWindowTypeModalDialogMask, DECOR_WINDOW_TYPE_DIALOG },
869 { CompWindowTypeMenuMask, DECOR_WINDOW_TYPE_MENU },893 { CompWindowTypeMenuMask, DECOR_WINDOW_TYPE_MENU },
870 { CompWindowTypeUtilMask, DECOR_WINDOW_TYPE_UTILITY}894 { CompWindowTypeUtilMask, DECOR_WINDOW_TYPE_UTILITY}
871 };895 };
@@ -975,7 +999,7 @@
975 if (DecorWindow::matchType (w, d->frameType))999 if (DecorWindow::matchType (w, d->frameType))
976 {1000 {
977 /* Prefer the highest number of bits */1001 /* Prefer the highest number of bits */
978 if (matchedType < d->frameType && (!sizeCheck || dw->checkSize (d)))1002 if (numBits (matchedType) < numBits (d->frameType) && (!sizeCheck || dw->checkSize (d)))
979 {1003 {
980 decoration = d;1004 decoration = d;
981 matchedType = d->frameType;1005 matchedType = d->frameType;
@@ -983,7 +1007,7 @@
9831007
984 if (DecorWindow::matchState (w, d->frameState) && (!sizeCheck || dw->checkSize (d)))1008 if (DecorWindow::matchState (w, d->frameState) && (!sizeCheck || dw->checkSize (d)))
985 {1009 {
986 if (matchedState < d->frameState)1010 if (numBits (matchedState) < numBits (d->frameState))
987 {1011 {
988 decoration = d;1012 decoration = d;
989 matchedState = d->frameState;1013 matchedState = d->frameState;
@@ -991,7 +1015,7 @@
9911015
992 if (DecorWindow::matchActions (w, d->frameActions) && (!sizeCheck || dw->checkSize (d)))1016 if (DecorWindow::matchActions (w, d->frameActions) && (!sizeCheck || dw->checkSize (d)))
993 {1017 {
994 if (matchedActions < d->frameActions)1018 if (numBits (matchedActions) < numBits (d->frameActions))
995 {1019 {
996 decoration = d;1020 decoration = d;
997 matchedActions = d->frameActions;1021 matchedActions = d->frameActions;
@@ -1061,7 +1085,7 @@
1061 if (decorate)1085 if (decorate)
1062 {1086 {
1063 /* Attempt to find a matching */1087 /* Attempt to find a matching */
1064 decoration = decor.findMatchingDecoration (window, true);1088 decoration = decor.findMatchingDecoration (window, true);
10651089
1066 if (!decoration)1090 if (!decoration)
1067 {1091 {
@@ -1219,21 +1243,52 @@
1219 Window parent;1243 Window parent;
1220 Window *children;1244 Window *children;
1221 unsigned int nchildren;1245 unsigned int nchildren;
1222 XEvent e;1246 std::vector<XEvent> events;
12231247 bool pending = true;
1224 /* Unreparent all the children of this window first into a1248 bool alive = true;
1225 * the root window. Once the property is deleted it is the DM's1249
1226 * responsibility to get rid of the decoration ... though that may1250 /* Check pending events on StructureNotifyMask to see if this frame window
1227 * come with artifacts */1251 * has already been destroyed, in which case unreparenting its children
1228 if (XCheckTypedWindowEvent (screen->dpy (), inputFrame, DestroyNotify, &e))1252 * is pointless since the save sets will do that for us
1229 {1253 *
1230 XPutBackEvent (screen->dpy (), &e);1254 * Note: we can't use XCheckTypedEvent here since we also have SubstructureNotifyMask
1255 * on the inputFrame and may recieve DestroyNotify events for its children */
1256 while (pending)
1257 {
1258 XEvent e;
1259 pending = XCheckWindowEvent (screen->dpy (), inputFrame, StructureNotifyMask, &e);
1260
1261 if (pending)
1262 {
1263 events.push_back (e);
1264 if (e.type == DestroyNotify && e.xdestroywindow.window == inputFrame)
1265 {
1266 alive = false;
1267 break;
1268 }
1269 }
1270 }
1271
1272 /* Put all the events back in the queue */
1273 while (events.size ())
1274 {
1275 XPutBackEvent (screen->dpy (), &events.back ());
1276 events.pop_back ();
1277 }
1278
1279 if (!alive)
1280 {
1281 inputFrame = 0;
1231 }1282 }
1232 else1283 else
1233 {1284 {
1234 Status s = XQueryTree (screen->dpy (), inputFrame, &root,1285 Status s = XQueryTree (screen->dpy (), inputFrame, &root,
1235 &parent, &children, &nchildren);1286 &parent, &children, &nchildren);
12361287
1288 /* Unreparent all the children of this window first into a
1289 * the root window. Once the property is deleted it is the DM's
1290 * responsibility to get rid of the decoration ... though that may
1291 * come with artifacts */
1237 if (s && nchildren && children)1292 if (s && nchildren && children)
1238 {1293 {
1239 for (unsigned int i = 0; i < nchildren; i++)1294 for (unsigned int i = 0; i < nchildren; i++)
@@ -1256,6 +1311,8 @@
1256 inputFrame = None;1311 inputFrame = None;
1257 frameRegion = CompRegion ();1312 frameRegion = CompRegion ();
12581313
1314 dScreen->frames.erase (inputFrame);
1315
1259 oldX = 0;1316 oldX = 0;
1260 oldY = 0;1317 oldY = 0;
1261 oldWidth = 0;1318 oldWidth = 0;
@@ -1268,17 +1325,42 @@
1268 Window parent;1325 Window parent;
1269 Window *children;1326 Window *children;
1270 unsigned int nchildren;1327 unsigned int nchildren;
1271 XEvent e;1328 std::vector<XEvent> events;
1329 bool pending = true;
1330 bool alive = true;
1331
1332 /* Unreparent all the children of this window first into a
1333 * the root window. Once the property is deleted it is the DM's
1334 * responsibility to get rid of the decoration ... though that may
1335 * come with artifacts */
12721336
1273 XDamageDestroy (screen->dpy (), frameDamage);1337 XDamageDestroy (screen->dpy (), frameDamage);
12741338
1275 /* Unreparent all the children of this window first into a1339 while (pending)
1276 * the root window. Once the property is deleted it is the DM's1340 {
1277 * responsibility to get rid of the decoration ... though that may1341 XEvent e;
1278 * come with artifacts */1342 pending = XCheckWindowEvent (screen->dpy (), outputFrame, StructureNotifyMask, &e);
1279 if (XCheckTypedWindowEvent (screen->dpy (), outputFrame, DestroyNotify, &e))1343
1280 {1344 if (pending)
1281 XPutBackEvent (screen->dpy (), &e);1345 {
1346 events.push_back (e);
1347 if (e.type == DestroyNotify && e.xdestroywindow.window == inputFrame)
1348 {
1349 alive = false;
1350 break;
1351 }
1352 }
1353 }
1354
1355 while (events.size ())
1356 {
1357 XPutBackEvent (screen->dpy (), &events.back ());
1358 events.pop_back ();
1359 }
1360
1361 if (!alive)
1362 {
1363 outputFrame = 0;
1282 }1364 }
1283 else1365 else
1284 {1366 {
@@ -1359,9 +1441,8 @@
1359 {1441 {
1360 XSetWindowAttributes attr;1442 XSetWindowAttributes attr;
13611443
1362 attr.event_mask = StructureNotifyMask;1444 attr.event_mask = StructureNotifyMask | SubstructureNotifyMask;
1363 attr.override_redirect = true;1445 attr.override_redirect = true;
1364
1365 /* cough */1446 /* cough */
1366 /* Yeah, so as it turns out you can't reparent an InputOuput1447 /* Yeah, so as it turns out you can't reparent an InputOuput
1367 * window into an InputOnly one, which is what some decorators1448 * window into an InputOnly one, which is what some decorators
@@ -1387,6 +1468,8 @@
1387 if (screen->XShape ())1468 if (screen->XShape ())
1388 XShapeSelectInput (screen->dpy (), inputFrame, ShapeNotifyMask);1469 XShapeSelectInput (screen->dpy (), inputFrame, ShapeNotifyMask);
13891470
1471 dScreen->frames[inputFrame] = this;
1472
1390 oldX = 0;1473 oldX = 0;
1391 oldY = 0;1474 oldY = 0;
1392 oldWidth = 0;1475 oldWidth = 0;
@@ -1475,7 +1558,7 @@
1475 XSetWindowAttributes attr;1558 XSetWindowAttributes attr;
14761559
1477 attr.background_pixel = 0x0;1560 attr.background_pixel = 0x0;
1478 attr.event_mask = StructureNotifyMask;1561 attr.event_mask = StructureNotifyMask | SubstructureNotifyMask;
1479 attr.override_redirect = true;1562 attr.override_redirect = true;
14801563
1481 outputFrame = XCreateWindow (screen->dpy (), window->frame (),1564 outputFrame = XCreateWindow (screen->dpy (), window->frame (),
@@ -1796,6 +1879,10 @@
1796 CompWindow *w;1879 CompWindow *w;
17971880
1798 switch (event->type) {1881 switch (event->type) {
1882 case MapRequest:
1883 if (frames.find (event->xmaprequest.parent) != frames.end ())
1884 XMapWindow (screen->dpy (), event->xmaprequest.window);
1885 break;
1799 case DestroyNotify:1886 case DestroyNotify:
1800 w = screen->findWindow (event->xdestroywindow.window);1887 w = screen->findWindow (event->xdestroywindow.window);
1801 if (w)1888 if (w)
@@ -1803,6 +1890,16 @@
1803 if (w->id () == dmWin)1890 if (w->id () == dmWin)
1804 checkForDm (true);1891 checkForDm (true);
1805 }1892 }
1893 else
1894 {
1895 if (frames.find (event->xdestroywindow.event) != frames.end ())
1896 {
1897 DecorWindow *dw = frames[event->xdestroywindow.event];
1898
1899 XChangeSaveSet (screen->dpy (), event->xdestroywindow.window, SetModeDelete);
1900 dw->decoratorWindows.remove (event->xdestroywindow.window);
1901 }
1902 }
1806 break;1903 break;
1807 case ClientMessage:1904 case ClientMessage:
1808 if (event->xclient.message_type == requestFrameExtentsAtom)1905 if (event->xclient.message_type == requestFrameExtentsAtom)
@@ -1811,6 +1908,48 @@
1811 if (w)1908 if (w)
1812 DecorWindow::get (w)->update (true);1909 DecorWindow::get (w)->update (true);
1813 }1910 }
1911 /* The decoration manager requested for us to embed
1912 * one of its frame windows, so do that */
1913 if (event->xclient.message_type == decorRequestEmbedWindowAtom)
1914 {
1915 w = screen->findWindow (event->xclient.window);
1916 if (w)
1917 {
1918 DecorWindow *dw = DecorWindow::get (w);
1919 Window embed = event->xclient.data.l[0];
1920 Window frame = event->xclient.data.l[1];
1921
1922 if (frame)
1923 {
1924 XChangeSaveSet (screen->dpy (), embed, SetModeInsert);
1925 XReparentWindow (screen->dpy (),
1926 embed,
1927 frame,
1928 0,
1929 0);
1930
1931 dw->decoratorWindows.push_back (embed);
1932 }
1933 /* In case the decoration manager specifies no frame, it doesn't
1934 * wish for this frame window to be embedded anymore */
1935 else
1936 {
1937 std::list<Window>::iterator it = std::find (dw->decoratorWindows.begin(),
1938 dw->decoratorWindows.end(),
1939 frame);
1940
1941 if (it != dw->decoratorWindows.end ())
1942 {
1943 XChangeSaveSet (screen->dpy (), embed, SetModeDelete);
1944 XReparentWindow (screen->dpy (),
1945 embed,
1946 screen->root (),
1947 event->xclient.data.l[1],
1948 event->xclient.data.l[2]);
1949 }
1950 }
1951 }
1952 }
1814 default:1953 default:
1815 if (cmActive &&1954 if (cmActive &&
1816 event->type == cScreen->damageEvent () + XDamageNotify)1955 event->type == cScreen->damageEvent () + XDamageNotify)
@@ -1928,7 +2067,7 @@
1928 break;2067 break;
1929 case DestroyNotify:2068 case DestroyNotify:
1930 /* Only for when the client window gets destroyed */2069 /* Only for when the client window gets destroyed */
1931 w = screen->findTopLevelWindow (event->xproperty.window);2070 w = screen->findTopLevelWindow (event->xdestroywindow.window);
1932 if (w)2071 if (w)
1933 {2072 {
1934 DECOR_WINDOW (w);2073 DECOR_WINDOW (w);
@@ -2278,6 +2417,8 @@
2278 XInternAtom (s->dpy (), "_COMPIZ_NET_CM_SHADOW_COLOR", 0);2417 XInternAtom (s->dpy (), "_COMPIZ_NET_CM_SHADOW_COLOR", 0);
2279 shadowInfoAtom =2418 shadowInfoAtom =
2280 XInternAtom (s->dpy (), "_COMPIZ_NET_CM_SHADOW_PROPERTIES", 0);2419 XInternAtom (s->dpy (), "_COMPIZ_NET_CM_SHADOW_PROPERTIES", 0);
2420 decorRequestEmbedWindowAtom =
2421 XInternAtom (s->dpy (), DECOR_REQUEST_EMBED_WINDOW_ATOM_NAME, 0);
22812422
2282 windowDefault.texture = NULL;2423 windowDefault.texture = NULL;
2283 windowDefault.minWidth = 0;2424 windowDefault.minWidth = 0;
22842425
=== modified file 'plugins/decor/src/decor.h'
--- plugins/decor/src/decor.h 2011-08-11 19:38:07 +0000
+++ plugins/decor/src/decor.h 2011-08-19 15:05:12 +0000
@@ -160,6 +160,7 @@
160 Atom shadowColorAtom;160 Atom shadowColorAtom;
161 Atom shadowInfoAtom;161 Atom shadowInfoAtom;
162 Atom decorSwitchWindowAtom;162 Atom decorSwitchWindowAtom;
163 Atom decorRequestEmbedWindowAtom;
163164
164 Window dmWin;165 Window dmWin;
165 int dmSupports;166 int dmSupports;
@@ -258,6 +259,8 @@
258 bool unshading;259 bool unshading;
259 bool shading;260 bool shading;
260 bool isSwitcher;261 bool isSwitcher;
262
263 std::list<Window> decoratorWindows;
261};264};
262265
263class DecorPluginVTable :266class DecorPluginVTable :

Subscribers

People subscribed via source and target branches

to all changes: