Merge lp:~smspillaz/compiz-core/compiz-core.lim into lp:compiz-core
- compiz-core.lim
- Merge into 0.9.7
Status: | Superseded |
---|---|
Proposed branch: | lp:~smspillaz/compiz-core/compiz-core.lim |
Merge into: | lp:compiz-core |
Diff against target: |
1432 lines (+1077/-11) 16 files modified
gtk/window-decorator/CMakeLists.txt (+6/-0) gtk/window-decorator/decorator.c (+32/-6) gtk/window-decorator/events.c (+115/-3) gtk/window-decorator/gtk-window-decorator.c (+56/-0) gtk/window-decorator/gtk-window-decorator.h (+8/-1) gtk/window-decorator/local-menus/CMakeLists.txt (+60/-0) gtk/window-decorator/local-menus/src/local-menus.c (+423/-0) gtk/window-decorator/local-menus/src/local-menus.h (+120/-0) gtk/window-decorator/local-menus/tests/CMakeLists.txt (+3/-0) gtk/window-decorator/local-menus/tests/check_local_menu_on_off/CMakeLists.txt (+21/-0) gtk/window-decorator/local-menus/tests/check_local_menu_on_off/test-local-menu-on-off.cpp (+27/-0) gtk/window-decorator/local-menus/tests/force_local_menu_on/CMakeLists.txt (+21/-0) gtk/window-decorator/local-menus/tests/force_local_menu_on/test-force-local-menu-on.cpp (+77/-0) gtk/window-decorator/local-menus/tests/test-local-menu.h (+49/-0) gtk/window-decorator/metacity.c (+54/-0) gtk/window-decorator/wnck.c (+5/-1) |
To merge this branch: | bzr merge lp:~smspillaz/compiz-core/compiz-core.lim |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Marco Trevisan (Treviño) | Needs Fixing | ||
Daniel van Vugt | Approve | ||
Alan Griffiths | Abstain | ||
Sam Spilsbury | Pending | ||
Review via email: mp+94641@code.launchpad.net |
This proposal supersedes a proposal from 2012-02-22.
This proposal has been superseded by a proposal from 2012-02-28.
Commit message
Description of the change
Adds support for Ubuntu's "locally integrated menu bars" into gtk-window-
Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal | # |
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal | # |
> 8 +#define GWD_SHOW_LOCAL_MENU (WNCK_WINDOW_
>
> No plausible reason for using a macro. In C++ constants (enum or unsigned
> int) are better as they respect scope rules. Also, should this be inside
> "#ifdef META_HAS_
>
Its C
>
> 296 button_
> 297
> 298 - for (i = 3; i < MAX_BUTTONS_
> 299 + for (i = 4; i < MAX_BUTTONS_
> 300 button_
> 301 }
>
> I'm not sure what the magic number "3"->"4" is. But we now seem to miss 3
> entirely. Is that correct?
Its for initializing the array, though maybe thats wrong. Good find let me check
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal | # |
Please resubmit for target branch lp:compiz-core (0.9.7)
Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal | # |
Looks better
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal | # |
(More work needed to adopt to trevino;s changes)
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal | # |
Fails to build ifndef META_HAS_
[ 0%] Building C object gtk/window-
/home/dan/
/home/dan/
cc1: all warnings being treated as errors
Marco Trevisan (Treviño) (3v1n0) wrote : Posted in a previous version of this proposal | # |
+ gboolean empty = g_strcmp0 (entry_id, "") == 0;
You can do the same with:
gboolean empty = (!entry_id || entry_id[0] == '\0');
Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal | # |
If we're trying to be cryptic...
gboolean empty = g_strcmp0 (entry_id, "") == 0;
can be written:
gboolean empty = !entry_id || !*entry_id;
Marco Trevisan (Treviño) (3v1n0) wrote : Posted in a previous version of this proposal | # |
Ah, Sam remember to update the "EntryActivated" signal against the new signature s(iiuu).
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal | # |
Yep, done
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal | # |
Fails to build for a whole new reason now :(
Scanning dependencies of target gtk_window_
[ 5%] Building CXX object gtk/window-
/home/dan/
/home/dan/
/home/dan/
/home/dan/
make[2]: *** [gtk/window-
make[1]: *** [gtk/window-
make: *** [all] Error 2
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal | # |
Tests needed to be disabled on META_HAS_
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal | # |
Test cases fail (crash). Maybe they need to be disabled if local menus are disabled...
The following tests FAILED:
1 - gtk_window_
2 - gtk_window_
Errors while running CTest
make: *** [test] Error 8
-----
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff709bb70 in ?? () from /usr/lib/
(gdb) bt
#0 0x00007ffff709bb70 in ?? () from /usr/lib/
#1 0x00007ffff709e2f5 in ?? () from /usr/lib/
#2 0x00007ffff6dc29f0 in g_object_unref ()
from /usr/lib/
#3 0x000000000042ef7d in void testing:
#4 0x000000000042751f in testing:
#5 0x000000000042763d in testing:
#6 0x0000000000427787 in testing:
#7 0x0000000000427a17 in testing:
#8 0x000000000042eafd in bool testing:
#9 0x0000000000426c0b in testing:
#10 0x0000000000413145 in main ()
-----
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff709bb70 in ?? () from /usr/lib/
(gdb) bt
#0 0x00007ffff709bb70 in ?? () from /usr/lib/
#1 0x00007ffff709e2f5 in ?? () from /usr/lib/
#2 0x00007ffff6dc29f0 in g_object_unref ()
from /usr/lib/
#3 0x000000000042ef7d in void testing:
#4 0x000000000042751f in testing:
#5 0x000000000042763d in testing:
#6 0x0000000000427787 in testing:
#7 0x0000000000427a17 in testing:
#8 0x000000000042eafd in bool testing:
#9 0x0000000000426c0b in testing:
#10 0x0000000000413145 in main ()
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal | # |
Huh, that's weird. I've disabled META_HAS_
Can you post the output of the individual tests before it reaches the point where they crash? Or do they just crash without outputting anything ?
(Could be something to do with the SetUp () function, so I'll give that a try
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal | # |
Confirmed all unit tests now pass and no obvious bugs in manual testing.
I still think we need to be tidier with the CMake syntax as I've mentioned before...
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal | # |
Yes, one day I'm going to introduce a bunch of functions to the CMake which reduce the verbosity.
Daniel - if you want to test this for realz, you can use the following:
lp:~smspillaz/metacity/metacity.lim
lp:~3v1n0/unity/lim-panel
lp:~indicator-applet-developers/indicator-appmenu/local-menus-single-menu
lp:~smspillaz/light-themes/light-themes.limv4
Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal | # |
Looks OK, Builds OK, automated tests run. (With no META_HAS_
Marco Trevisan (Treviño) (3v1n0) wrote : Posted in a previous version of this proposal | # |
I've tested it, to be even better, maybe you could also sync the title geometries once you opened/closed the menu, but that can be optional.
One thing you need to fix is the double-click over the title, that currently doesn't work as expected.
Look at the logic I've used in PanelTitlebarGr
Then I guess we need to define with design better one case: if a window is unfocused, and the user presses over the title / icon, should we just focus it or also open the menu? Currently we do both, but I'm not sure this is the best choice.
Marco Trevisan (Treviño) (3v1n0) wrote : Posted in a previous version of this proposal | # |
Ah, don't care about syncing geometries. You don't need that and could cause problems to the panel... :)
Marco Trevisan (Treviño) (3v1n0) wrote : Posted in a previous version of this proposal | # |
Ah, one more thing. Please check if the window you're decorating has the "_UBUNTU_
Marco Trevisan (Treviño) (3v1n0) wrote : Posted in a previous version of this proposal | # |
Ah, I forgot... The decorator is still missing to react to the com.canonical.
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal | # |
OK, I'll take care of these two things too. Thanks.
Alan Griffiths (alan-griffiths) wrote : | # |
No obvious errors
Daniel van Vugt (vanvugt) wrote : | # |
Confirmed again all unit tests now pass and no obvious bugs in manual testing.
Though, like Alan, I have not reviewed the theoretical correctness of the code in detail.
Marco Trevisan (Treviño) (3v1n0) wrote : | # |
Mostly it works, well.
By the way, I've tested the support for the EntryActivateRe
This is the stacktrace I have: http://
Actually you should just ignore that signal if no decorated window is in focus.
Sam Spilsbury (smspillaz) wrote : | # |
Ack.
- 3002. By Sam Spilsbury
-
Fix a crash when trying to show the window menu on a non decorated window
- 3003. By Sam Spilsbury
-
Tell us if we have them
- 3004. By Sam Spilsbury
-
Merged lp:compiz-core
- 3005. By Sam Spilsbury
-
We also need to test the property too
- 3006. By Sam Spilsbury
-
Grab buttons too so that we can process motion events on the titlebar and
move the window instead.
Unmerged revisions
Preview Diff
1 | === modified file 'gtk/window-decorator/CMakeLists.txt' | |||
2 | --- gtk/window-decorator/CMakeLists.txt 2011-02-16 17:39:56 +0000 | |||
3 | +++ gtk/window-decorator/CMakeLists.txt 2012-02-25 05:11:17 +0000 | |||
4 | @@ -4,7 +4,10 @@ | |||
5 | 4 | set (CMAKE_INSTALL_RPATH ${libdir}) | 4 | set (CMAKE_INSTALL_RPATH ${libdir}) |
6 | 5 | endif (COMPIZ_BUILD_WITH_RPATH) | 5 | endif (COMPIZ_BUILD_WITH_RPATH) |
7 | 6 | 6 | ||
8 | 7 | add_subdirectory (local-menus) | ||
9 | 8 | |||
10 | 7 | include_directories ( | 9 | include_directories ( |
11 | 10 | ${CMAKE_CURRENT_SOURCE_DIR}/local-menus/src | ||
12 | 8 | ${compiz_SOURCE_DIR}/include | 11 | ${compiz_SOURCE_DIR}/include |
13 | 9 | ${CMAKE_BINARY_DIR}/gtk | 12 | ${CMAKE_BINARY_DIR}/gtk |
14 | 10 | ${GTK_WINDOW_DECORATOR_INCLUDE_DIRS} | 13 | ${GTK_WINDOW_DECORATOR_INCLUDE_DIRS} |
15 | @@ -63,6 +66,9 @@ | |||
16 | 63 | target_link_libraries ( | 66 | target_link_libraries ( |
17 | 64 | gtk-window-decorator | 67 | gtk-window-decorator |
18 | 65 | decoration | 68 | decoration |
19 | 69 | |||
20 | 70 | gtk_window_decorator_local_menus | ||
21 | 71 | |||
22 | 66 | ${GTK_WINDOW_DECORATOR_LIBRARIES} | 72 | ${GTK_WINDOW_DECORATOR_LIBRARIES} |
23 | 67 | ${GCONF_LIBRARIES} | 73 | ${GCONF_LIBRARIES} |
24 | 68 | ${DBUS_GLIB_LIBRARIES} | 74 | ${DBUS_GLIB_LIBRARIES} |
25 | 69 | 75 | ||
26 | === modified file 'gtk/window-decorator/decorator.c' | |||
27 | --- gtk/window-decorator/decorator.c 2012-02-20 07:42:20 +0000 | |||
28 | +++ gtk/window-decorator/decorator.c 2012-02-25 05:11:17 +0000 | |||
29 | @@ -24,6 +24,7 @@ | |||
30 | 24 | */ | 24 | */ |
31 | 25 | 25 | ||
32 | 26 | #include "gtk-window-decorator.h" | 26 | #include "gtk-window-decorator.h" |
33 | 27 | #include "local-menus.h" | ||
34 | 27 | 28 | ||
35 | 28 | decor_frame_t * | 29 | decor_frame_t * |
36 | 29 | create_normal_frame (const gchar *type) | 30 | create_normal_frame (const gchar *type) |
37 | @@ -230,12 +231,16 @@ | |||
38 | 230 | void | 231 | void |
39 | 231 | update_event_windows (WnckWindow *win) | 232 | update_event_windows (WnckWindow *win) |
40 | 232 | { | 233 | { |
41 | 234 | #define GWD_SHOW_LOCAL_MENU (WNCK_WINDOW_ACTION_BELOW << 1) | ||
42 | 233 | Display *xdisplay; | 235 | Display *xdisplay; |
43 | 234 | decor_t *d = g_object_get_data (G_OBJECT (win), "decor"); | 236 | decor_t *d = g_object_get_data (G_OBJECT (win), "decor"); |
44 | 235 | gint x0, y0, width, height, x, y, w, h; | 237 | gint x0, y0, width, height, x, y, w, h; |
45 | 236 | gint i, j, k, l; | 238 | gint i, j, k, l; |
46 | 237 | gint actions = d->actions; | 239 | gint actions = d->actions; |
47 | 238 | 240 | ||
48 | 241 | if (gwd_window_should_have_local_menu (win)) | ||
49 | 242 | actions |= GWD_SHOW_LOCAL_MENU; | ||
50 | 243 | |||
51 | 239 | xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()); | 244 | xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()); |
52 | 240 | 245 | ||
53 | 241 | /* Get the geometry of the client */ | 246 | /* Get the geometry of the client */ |
54 | @@ -298,11 +303,19 @@ | |||
55 | 298 | XMapWindow (xdisplay, d->event_windows[i][j].window); | 303 | XMapWindow (xdisplay, d->event_windows[i][j].window); |
56 | 299 | XMoveResizeWindow (xdisplay, d->event_windows[i][j].window, | 304 | XMoveResizeWindow (xdisplay, d->event_windows[i][j].window, |
57 | 300 | x, y, w, h); | 305 | x, y, w, h); |
58 | 306 | |||
59 | 307 | BoxPtr box = &d->event_windows[i][j].pos; | ||
60 | 308 | box->x1 = x; | ||
61 | 309 | box->x2 = x + w; | ||
62 | 310 | box->y1 = y; | ||
63 | 311 | box->y2 = y + h; | ||
64 | 301 | } | 312 | } |
65 | 302 | /* No parent and no geometry - unmap all event windows */ | 313 | /* No parent and no geometry - unmap all event windows */ |
66 | 303 | else if (!d->frame_window) | 314 | else if (!d->frame_window) |
67 | 304 | { | 315 | { |
68 | 305 | XUnmapWindow (xdisplay, d->event_windows[i][j].window); | 316 | XUnmapWindow (xdisplay, d->event_windows[i][j].window); |
69 | 317 | |||
70 | 318 | memset (&d->event_windows[i][j].pos, 0, sizeof (Box)); | ||
71 | 306 | } | 319 | } |
72 | 307 | } | 320 | } |
73 | 308 | } | 321 | } |
74 | @@ -326,12 +339,18 @@ | |||
75 | 326 | WNCK_WINDOW_ACTION_STICK, | 339 | WNCK_WINDOW_ACTION_STICK, |
76 | 327 | WNCK_WINDOW_ACTION_UNSHADE, | 340 | WNCK_WINDOW_ACTION_UNSHADE, |
77 | 328 | WNCK_WINDOW_ACTION_ABOVE, | 341 | WNCK_WINDOW_ACTION_ABOVE, |
84 | 329 | WNCK_WINDOW_ACTION_UNSTICK | 342 | WNCK_WINDOW_ACTION_UNSTICK, |
85 | 330 | #else | 343 | #else |
86 | 331 | 0, | 344 | 0, |
87 | 332 | 0, | 345 | 0, |
88 | 333 | 0, | 346 | 0, |
89 | 334 | 0, | 347 | 0, |
90 | 348 | 0, | ||
91 | 349 | #endif | ||
92 | 350 | |||
93 | 351 | #ifdef META_HAS_LOCAL_MENUS | ||
94 | 352 | GWD_SHOW_LOCAL_MENU | ||
95 | 353 | #else | ||
96 | 335 | 0 | 354 | 0 |
97 | 336 | #endif | 355 | #endif |
98 | 337 | 356 | ||
99 | @@ -371,10 +390,17 @@ | |||
100 | 371 | Window win = d->button_windows[i].window; | 390 | Window win = d->button_windows[i].window; |
101 | 372 | XMapWindow (xdisplay, win); | 391 | XMapWindow (xdisplay, win); |
102 | 373 | XMoveResizeWindow (xdisplay, win, x, y, w, h); | 392 | XMoveResizeWindow (xdisplay, win, x, y, w, h); |
103 | 393 | |||
104 | 394 | BoxPtr box = &d->button_windows[i].pos; | ||
105 | 395 | box->x1 = x; | ||
106 | 396 | box->x2 = x + w; | ||
107 | 397 | box->y1 = y; | ||
108 | 398 | box->y2 = y + h; | ||
109 | 374 | } | 399 | } |
110 | 375 | else if (!d->frame_window) | 400 | else if (!d->frame_window) |
111 | 376 | { | 401 | { |
112 | 377 | XUnmapWindow (xdisplay, d->button_windows[i].window); | 402 | XUnmapWindow (xdisplay, d->button_windows[i].window); |
113 | 403 | memset (&d->button_windows[i].pos, 0, sizeof (Box)); | ||
114 | 378 | } | 404 | } |
115 | 379 | } | 405 | } |
116 | 380 | 406 | ||
117 | 381 | 407 | ||
118 | === modified file 'gtk/window-decorator/events.c' | |||
119 | --- gtk/window-decorator/events.c 2012-02-20 07:46:35 +0000 | |||
120 | +++ gtk/window-decorator/events.c 2012-02-25 05:11:17 +0000 | |||
121 | @@ -24,6 +24,16 @@ | |||
122 | 24 | */ | 24 | */ |
123 | 25 | 25 | ||
124 | 26 | #include "gtk-window-decorator.h" | 26 | #include "gtk-window-decorator.h" |
125 | 27 | #include "local-menus.h" | ||
126 | 28 | |||
127 | 29 | typedef struct _delayed_move_info | ||
128 | 30 | { | ||
129 | 31 | WnckWindow *win; | ||
130 | 32 | int x_root; | ||
131 | 33 | int y_root; | ||
132 | 34 | unsigned int button; | ||
133 | 35 | unsigned int time; | ||
134 | 36 | } delayed_move_info; | ||
135 | 27 | 37 | ||
136 | 28 | void | 38 | void |
137 | 29 | move_resize_window (WnckWindow *win, | 39 | move_resize_window (WnckWindow *win, |
138 | @@ -65,8 +75,9 @@ | |||
139 | 65 | ev.xclient.data.l[3] = gtkwd_event->button; | 75 | ev.xclient.data.l[3] = gtkwd_event->button; |
140 | 66 | ev.xclient.data.l[4] = 1; | 76 | ev.xclient.data.l[4] = 1; |
141 | 67 | 77 | ||
144 | 68 | XUngrabPointer (xdisplay, gtkwd_event->time); | 78 | XAllowEvents (xdisplay, AsyncKeyboard | AsyncPointer, CurrentTime); |
145 | 69 | XUngrabKeyboard (xdisplay, gtkwd_event->time); | 79 | XUngrabPointer (xdisplay, CurrentTime); |
146 | 80 | XUngrabKeyboard (xdisplay, CurrentTime); | ||
147 | 70 | 81 | ||
148 | 71 | XSendEvent (xdisplay, xroot, FALSE, | 82 | XSendEvent (xdisplay, xroot, FALSE, |
149 | 72 | SubstructureRedirectMask | SubstructureNotifyMask, | 83 | SubstructureRedirectMask | SubstructureNotifyMask, |
150 | @@ -75,6 +86,24 @@ | |||
151 | 75 | XSync (xdisplay, FALSE); | 86 | XSync (xdisplay, FALSE); |
152 | 76 | } | 87 | } |
153 | 77 | 88 | ||
154 | 89 | static gboolean | ||
155 | 90 | move_resize_window_on_timeout (gpointer user_data) | ||
156 | 91 | { | ||
157 | 92 | delayed_move_info *info = (delayed_move_info *) user_data; | ||
158 | 93 | |||
159 | 94 | decor_event event; | ||
160 | 95 | event.x = 0; | ||
161 | 96 | event.y = 0; | ||
162 | 97 | event.x_root = info->x_root; | ||
163 | 98 | event.y_root = info->y_root; | ||
164 | 99 | event.button = info->button; | ||
165 | 100 | event.window = wnck_window_get_xid (info->win); | ||
166 | 101 | |||
167 | 102 | move_resize_window (info->win, WM_MOVERESIZE_MOVE, &event); | ||
168 | 103 | |||
169 | 104 | return FALSE; | ||
170 | 105 | } | ||
171 | 106 | |||
172 | 78 | void | 107 | void |
173 | 79 | common_button_event (WnckWindow *win, | 108 | common_button_event (WnckWindow *win, |
174 | 80 | decor_event *gtkwd_event, | 109 | decor_event *gtkwd_event, |
175 | @@ -380,6 +409,75 @@ | |||
176 | 380 | } | 409 | } |
177 | 381 | 410 | ||
178 | 382 | void | 411 | void |
179 | 412 | on_local_menu_hidden (gpointer user_data) | ||
180 | 413 | { | ||
181 | 414 | Window xid = GPOINTER_TO_INT (user_data); | ||
182 | 415 | WnckWindow *win = wnck_window_get (xid); | ||
183 | 416 | decor_t *d = g_object_get_data (G_OBJECT (win), "decor"); | ||
184 | 417 | |||
185 | 418 | d->button_states[BUTTON_WINDOW_MENU] &= ~PRESSED_EVENT_WINDOW; | ||
186 | 419 | |||
187 | 420 | queue_decor_draw (d); | ||
188 | 421 | } | ||
189 | 422 | |||
190 | 423 | void | ||
191 | 424 | window_menu_button_event (WnckWindow *win, | ||
192 | 425 | decor_event *gtkwd_event, | ||
193 | 426 | decor_event_type gtkwd_type) | ||
194 | 427 | { | ||
195 | 428 | decor_t *d = g_object_get_data (G_OBJECT (win), "decor"); | ||
196 | 429 | guint state = d->button_states[BUTTON_WINDOW_MENU]; | ||
197 | 430 | |||
198 | 431 | common_button_event (win, gtkwd_event, gtkwd_type, | ||
199 | 432 | BUTTON_WINDOW_MENU, 1, _("Window Menu")); | ||
200 | 433 | |||
201 | 434 | switch (gtkwd_type) { | ||
202 | 435 | case GButtonPress: | ||
203 | 436 | if (gtkwd_event->button == 1) | ||
204 | 437 | { | ||
205 | 438 | if (d->button_states[BUTTON_WINDOW_MENU] & BUTTON_EVENT_ACTION_STATE) | ||
206 | 439 | { | ||
207 | 440 | delayed_move_info *info = g_new0 (delayed_move_info, 1); | ||
208 | 441 | |||
209 | 442 | info->button = gtkwd_event->button; | ||
210 | 443 | info->time = gtkwd_event->time; | ||
211 | 444 | info->win = win; | ||
212 | 445 | info->x_root = gtkwd_event->x_root; | ||
213 | 446 | info->y_root = gtkwd_event->y_root; | ||
214 | 447 | |||
215 | 448 | gwd_prepare_show_local_menu ((start_move_window_cb) move_resize_window_on_timeout, (gpointer) info); | ||
216 | 449 | } | ||
217 | 450 | } | ||
218 | 451 | break; | ||
219 | 452 | case GButtonRelease: | ||
220 | 453 | if (gtkwd_event->button == 1) | ||
221 | 454 | if (state) | ||
222 | 455 | { | ||
223 | 456 | int win_x, win_y; | ||
224 | 457 | int box_x = d->button_windows[BUTTON_WINDOW_MENU].pos.x1; | ||
225 | 458 | |||
226 | 459 | wnck_window_get_geometry (win, &win_x, &win_y, NULL, NULL); | ||
227 | 460 | |||
228 | 461 | int x = win_x + box_x; | ||
229 | 462 | int y = win_y + d->context->extents.top; | ||
230 | 463 | |||
231 | 464 | gwd_show_local_menu (gdk_x11_display_get_xdisplay (gdk_display_get_default ()), | ||
232 | 465 | wnck_window_get_xid (win), | ||
233 | 466 | x, y, | ||
234 | 467 | box_x, | ||
235 | 468 | d->context->extents.top, | ||
236 | 469 | gtkwd_event->button, | ||
237 | 470 | gtkwd_event->time, | ||
238 | 471 | (show_window_menu_hidden_cb) on_local_menu_hidden, | ||
239 | 472 | GINT_TO_POINTER (wnck_window_get_xid (d->win))); | ||
240 | 473 | } | ||
241 | 474 | break; | ||
242 | 475 | default: | ||
243 | 476 | break; | ||
244 | 477 | } | ||
245 | 478 | } | ||
246 | 479 | |||
247 | 480 | void | ||
248 | 383 | handle_title_button_event (WnckWindow *win, | 481 | handle_title_button_event (WnckWindow *win, |
249 | 384 | int action, | 482 | int action, |
250 | 385 | decor_event *gtkwd_event) | 483 | decor_event *gtkwd_event) |
251 | @@ -485,7 +583,17 @@ | |||
252 | 485 | 583 | ||
253 | 486 | restack_window (win, Above); | 584 | restack_window (win, Above); |
254 | 487 | 585 | ||
256 | 488 | move_resize_window (win, WM_MOVERESIZE_MOVE, gtkwd_event); | 586 | delayed_move_info *info = g_new0 (delayed_move_info, 1); |
257 | 587 | |||
258 | 588 | info->x_root = gtkwd_event->x_root; | ||
259 | 589 | info->y_root = gtkwd_event->y_root; | ||
260 | 590 | info->button = gtkwd_event->button; | ||
261 | 591 | info->time = gtkwd_event->time; | ||
262 | 592 | info->win = win; | ||
263 | 593 | |||
264 | 594 | move_resize_window_on_timeout ((gpointer) info); | ||
265 | 595 | |||
266 | 596 | g_free (info); | ||
267 | 489 | } | 597 | } |
268 | 490 | } | 598 | } |
269 | 491 | else if (gtkwd_event->button == 2) | 599 | else if (gtkwd_event->button == 2) |
270 | @@ -1031,6 +1139,10 @@ | |||
271 | 1031 | if (get_window_prop (xevent->xproperty.window, select_window_atom, &select)) | 1139 | if (get_window_prop (xevent->xproperty.window, select_window_atom, &select)) |
272 | 1032 | update_switcher_window (xevent->xproperty.window, select); | 1140 | update_switcher_window (xevent->xproperty.window, select); |
273 | 1033 | } | 1141 | } |
274 | 1142 | else if (xevent->xproperty.atom == ubuntu_appmenu_unique_name_atom) | ||
275 | 1143 | { | ||
276 | 1144 | local_menu_cache_reload_xwindow (gdk_x11_display_get_xdisplay (gdkdisplay), xevent->xproperty.window); | ||
277 | 1145 | } | ||
278 | 1034 | break; | 1146 | break; |
279 | 1035 | case DestroyNotify: | 1147 | case DestroyNotify: |
280 | 1036 | g_hash_table_remove (frame_table, | 1148 | g_hash_table_remove (frame_table, |
281 | 1037 | 1149 | ||
282 | === modified file 'gtk/window-decorator/gtk-window-decorator.c' | |||
283 | --- gtk/window-decorator/gtk-window-decorator.c 2011-10-13 12:22:14 +0000 | |||
284 | +++ gtk/window-decorator/gtk-window-decorator.c 2012-02-25 05:11:17 +0000 | |||
285 | @@ -24,6 +24,7 @@ | |||
286 | 24 | */ | 24 | */ |
287 | 25 | 25 | ||
288 | 26 | #include "gtk-window-decorator.h" | 26 | #include "gtk-window-decorator.h" |
289 | 27 | #include "local-menus.h" | ||
290 | 27 | 28 | ||
291 | 28 | gboolean minimal = FALSE; | 29 | gboolean minimal = FALSE; |
292 | 29 | 30 | ||
293 | @@ -48,6 +49,7 @@ | |||
294 | 48 | Atom toolkit_action_atom; | 49 | Atom toolkit_action_atom; |
295 | 49 | Atom toolkit_action_window_menu_atom; | 50 | Atom toolkit_action_window_menu_atom; |
296 | 50 | Atom toolkit_action_force_quit_dialog_atom; | 51 | Atom toolkit_action_force_quit_dialog_atom; |
297 | 52 | Atom ubuntu_appmenu_unique_name_atom; | ||
298 | 51 | 53 | ||
299 | 52 | Atom net_wm_state_atom; | 54 | Atom net_wm_state_atom; |
300 | 53 | Atom net_wm_state_modal_atom; | 55 | Atom net_wm_state_modal_atom; |
301 | @@ -128,6 +130,35 @@ | |||
302 | 128 | "normal", "modal_dialog", "dialog", "menu", "utility" | 130 | "normal", "modal_dialog", "dialog", "menu", "utility" |
303 | 129 | }; | 131 | }; |
304 | 130 | 132 | ||
305 | 133 | Box * | ||
306 | 134 | get_active_window_local_menu_rectangle (gpointer user_data, int *dx, int *dy, int *top_height, Window *xid) | ||
307 | 135 | { | ||
308 | 136 | WnckScreen *screen = (WnckScreen *) user_data; | ||
309 | 137 | WnckWindow *window = wnck_screen_get_active_window (screen); | ||
310 | 138 | int width, height; | ||
311 | 139 | decor_t *d = g_object_get_data (G_OBJECT (window), "decor"); | ||
312 | 140 | |||
313 | 141 | wnck_window_get_geometry (window, dx, dy, &width, &height); | ||
314 | 142 | |||
315 | 143 | *top_height = d->context->extents.top; | ||
316 | 144 | |||
317 | 145 | *xid = wnck_window_get_xid (window); | ||
318 | 146 | |||
319 | 147 | Box *rect = &d->button_windows[BUTTON_WINDOW_MENU].pos; | ||
320 | 148 | |||
321 | 149 | return rect; | ||
322 | 150 | } | ||
323 | 151 | |||
324 | 152 | void | ||
325 | 153 | on_local_menu_window_menu_updated (gpointer user_data) | ||
326 | 154 | { | ||
327 | 155 | Window xid = GPOINTER_TO_INT (user_data); | ||
328 | 156 | WnckWindow *window = wnck_window_get (xid); | ||
329 | 157 | decor_t *d = g_object_get_data (G_OBJECT (window), "decor"); | ||
330 | 158 | |||
331 | 159 | queue_decor_draw (d); | ||
332 | 160 | } | ||
333 | 161 | |||
334 | 131 | int | 162 | int |
335 | 132 | main (int argc, char *argv[]) | 163 | main (int argc, char *argv[]) |
336 | 133 | { | 164 | { |
337 | @@ -304,6 +335,7 @@ | |||
338 | 304 | 335 | ||
339 | 305 | net_wm_state_atom = XInternAtom (xdisplay,"_NET_WM_STATE", 0); | 336 | net_wm_state_atom = XInternAtom (xdisplay,"_NET_WM_STATE", 0); |
340 | 306 | net_wm_state_modal_atom = XInternAtom (xdisplay, "_NET_WM_STATE_MODAL", 0); | 337 | net_wm_state_modal_atom = XInternAtom (xdisplay, "_NET_WM_STATE_MODAL", 0); |
341 | 338 | ubuntu_appmenu_unique_name_atom = XInternAtom (xdisplay, "_UBUNTU_APPMENU_UNIQUE_NAME", 0); | ||
342 | 307 | 339 | ||
343 | 308 | status = decor_acquire_dm_session (xdisplay, | 340 | status = decor_acquire_dm_session (xdisplay, |
344 | 309 | gdk_screen_get_number (gdkscreen), | 341 | gdk_screen_get_number (gdkscreen), |
345 | @@ -448,8 +480,32 @@ | |||
346 | 448 | 480 | ||
347 | 449 | update_default_decorations (gdkscreen); | 481 | update_default_decorations (gdkscreen); |
348 | 450 | 482 | ||
349 | 483 | #ifdef META_HAS_LOCAL_MENUS | ||
350 | 484 | GDBusConnection *conn = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL); | ||
351 | 485 | local_menu_entry_activated_request_funcs funcs = | ||
352 | 486 | { | ||
353 | 487 | get_active_window_local_menu_rectangle, | ||
354 | 488 | on_local_menu_window_menu_updated | ||
355 | 489 | }; | ||
356 | 490 | |||
357 | 491 | if (conn) | ||
358 | 492 | { | ||
359 | 493 | global_lim_listener = g_dbus_proxy_new_sync (conn, 0, NULL, "com.canonical.Unity.Panel.Service", | ||
360 | 494 | "/com/canonical/Unity/Panel/Service", | ||
361 | 495 | "com.canonical.Unity.Panel.Service", | ||
362 | 496 | NULL, NULL); | ||
363 | 497 | |||
364 | 498 | g_signal_connect (G_OBJECT (global_lim_listener), "g-signal", G_CALLBACK (local_menu_entry_activated_request), (gpointer) &funcs); | ||
365 | 499 | } | ||
366 | 500 | #endif | ||
367 | 451 | gtk_main (); | 501 | gtk_main (); |
368 | 502 | #ifdef META_HAS_LOCAL_MENUS | ||
369 | 503 | if (global_lim_listener) | ||
370 | 504 | g_object_unref (global_lim_listener); | ||
371 | 452 | 505 | ||
372 | 506 | if (conn) | ||
373 | 507 | g_object_unref (conn); | ||
374 | 508 | #endif | ||
375 | 453 | win = windows = wnck_screen_get_windows (screen); | 509 | win = windows = wnck_screen_get_windows (screen); |
376 | 454 | 510 | ||
377 | 455 | while (win != NULL) | 511 | while (win != NULL) |
378 | 456 | 512 | ||
379 | === modified file 'gtk/window-decorator/gtk-window-decorator.h' | |||
380 | --- gtk/window-decorator/gtk-window-decorator.h 2011-10-13 12:22:14 +0000 | |||
381 | +++ gtk/window-decorator/gtk-window-decorator.h 2012-02-25 05:11:17 +0000 | |||
382 | @@ -306,6 +306,7 @@ | |||
383 | 306 | extern Atom toolkit_action_force_quit_dialog_atom; | 306 | extern Atom toolkit_action_force_quit_dialog_atom; |
384 | 307 | extern Atom net_wm_state_atom; | 307 | extern Atom net_wm_state_atom; |
385 | 308 | extern Atom net_wm_state_modal_atom; | 308 | extern Atom net_wm_state_modal_atom; |
386 | 309 | extern Atom ubuntu_appmenu_unique_name_atom; | ||
387 | 309 | 310 | ||
388 | 310 | extern Time dm_sn_timestamp; | 311 | extern Time dm_sn_timestamp; |
389 | 311 | 312 | ||
390 | @@ -328,7 +329,8 @@ | |||
391 | 328 | #define BUTTON_UNSHADE 7 | 329 | #define BUTTON_UNSHADE 7 |
392 | 329 | #define BUTTON_UNABOVE 8 | 330 | #define BUTTON_UNABOVE 8 |
393 | 330 | #define BUTTON_UNSTICK 9 | 331 | #define BUTTON_UNSTICK 9 |
395 | 331 | #define BUTTON_NUM 10 | 332 | #define BUTTON_WINDOW_MENU 10 |
396 | 333 | #define BUTTON_NUM 11 | ||
397 | 332 | 334 | ||
398 | 333 | struct _pos { | 335 | struct _pos { |
399 | 334 | int x, y, w, h; | 336 | int x, y, w, h; |
400 | @@ -1013,6 +1015,11 @@ | |||
401 | 1013 | decor_event_type gtkwd_type); | 1015 | decor_event_type gtkwd_type); |
402 | 1014 | 1016 | ||
403 | 1015 | void | 1017 | void |
404 | 1018 | window_menu_button_event (WnckWindow *win, | ||
405 | 1019 | decor_event *gtkwd_event, | ||
406 | 1020 | decor_event_type gtkwd_type); | ||
407 | 1021 | |||
408 | 1022 | void | ||
409 | 1016 | handle_title_button_event (WnckWindow *win, | 1023 | handle_title_button_event (WnckWindow *win, |
410 | 1017 | int action, | 1024 | int action, |
411 | 1018 | decor_event *gtkwd_event); | 1025 | decor_event *gtkwd_event); |
412 | 1019 | 1026 | ||
413 | === added directory 'gtk/window-decorator/local-menus' | |||
414 | === added file 'gtk/window-decorator/local-menus/CMakeLists.txt' | |||
415 | --- gtk/window-decorator/local-menus/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
416 | +++ gtk/window-decorator/local-menus/CMakeLists.txt 2012-02-25 05:11:17 +0000 | |||
417 | @@ -0,0 +1,60 @@ | |||
418 | 1 | pkg_check_modules( | ||
419 | 2 | LOCAL_MENUS | ||
420 | 3 | REQUIRED | ||
421 | 4 | glib-2.0 gio-2.0 libwnck-1.0 gtk+-2.0>=2.18.0 | ||
422 | 5 | ) | ||
423 | 6 | |||
424 | 7 | INCLUDE_DIRECTORIES( | ||
425 | 8 | ${CMAKE_CURRENT_SOURCE_DIR}/include | ||
426 | 9 | ${CMAKE_CURRENT_SOURCE_DIR}/src | ||
427 | 10 | |||
428 | 11 | ${compiz_SOURCE_DIR}/gtk/window-decorator | ||
429 | 12 | |||
430 | 13 | ${Boost_INCLUDE_DIRS} | ||
431 | 14 | |||
432 | 15 | ${LOCAL_MENUS_INCLUDE_DIRS} | ||
433 | 16 | ${METACITY_INCLUDE_DIRS} | ||
434 | 17 | ) | ||
435 | 18 | |||
436 | 19 | LINK_DIRECTORIES (${LOCAL_MENUS_LIBRARY_DIRS}) | ||
437 | 20 | |||
438 | 21 | SET( | ||
439 | 22 | PUBLIC_HEADERS | ||
440 | 23 | ) | ||
441 | 24 | |||
442 | 25 | SET( | ||
443 | 26 | PRIVATE_HEADERS | ||
444 | 27 | ${CMAKE_CURRENT_SOURCE_DIR}/src/local-menus.h | ||
445 | 28 | ) | ||
446 | 29 | |||
447 | 30 | SET( | ||
448 | 31 | SRCS | ||
449 | 32 | ${CMAKE_CURRENT_SOURCE_DIR}/src/local-menus.c | ||
450 | 33 | ) | ||
451 | 34 | |||
452 | 35 | ADD_LIBRARY( | ||
453 | 36 | gtk_window_decorator_local_menus STATIC | ||
454 | 37 | |||
455 | 38 | ${SRCS} | ||
456 | 39 | |||
457 | 40 | ${PUBLIC_HEADERS} | ||
458 | 41 | ${PRIVATE_HEADERS} | ||
459 | 42 | ) | ||
460 | 43 | |||
461 | 44 | IF (COMPIZ_BUILD_TESTING) | ||
462 | 45 | ADD_SUBDIRECTORY( ${CMAKE_CURRENT_SOURCE_DIR}/tests ) | ||
463 | 46 | ENDIF (COMPIZ_BUILD_TESTING) | ||
464 | 47 | |||
465 | 48 | SET_TARGET_PROPERTIES( | ||
466 | 49 | gtk_window_decorator_local_menus PROPERTIES | ||
467 | 50 | PUBLIC_HEADER "${PUBLIC_HEADERS}" | ||
468 | 51 | ) | ||
469 | 52 | |||
470 | 53 | install (FILES ${PUBLIC_HEADERS} DESTINATION ${COMPIZ_CORE_INCLUDE_DIR}) | ||
471 | 54 | |||
472 | 55 | TARGET_LINK_LIBRARIES( | ||
473 | 56 | gtk_window_decorator_local_menus | ||
474 | 57 | |||
475 | 58 | ${LOCAL_MENUS_LIBRARIES} | ||
476 | 59 | ) | ||
477 | 60 | |||
478 | 0 | 61 | ||
479 | === added directory 'gtk/window-decorator/local-menus/include' | |||
480 | === added directory 'gtk/window-decorator/local-menus/src' | |||
481 | === added file 'gtk/window-decorator/local-menus/src/local-menus.c' | |||
482 | --- gtk/window-decorator/local-menus/src/local-menus.c 1970-01-01 00:00:00 +0000 | |||
483 | +++ gtk/window-decorator/local-menus/src/local-menus.c 2012-02-25 05:11:17 +0000 | |||
484 | @@ -0,0 +1,423 @@ | |||
485 | 1 | /* | ||
486 | 2 | * Copyright © 2006 Novell, Inc. | ||
487 | 3 | * | ||
488 | 4 | * This library is free software; you can redistribute it and/or | ||
489 | 5 | * modify it under the terms of the GNU Lesser General Public | ||
490 | 6 | * License as published by the Free Software Foundation; either | ||
491 | 7 | * version 2 of the License, or (at your option) any later version. | ||
492 | 8 | * | ||
493 | 9 | * This library is distributed in the hope that it will be useful, | ||
494 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
495 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
496 | 12 | * Lesser General Public License for more details. | ||
497 | 13 | * | ||
498 | 14 | * You should have received a copy of the GNU Lesser General Public | ||
499 | 15 | * License along with this library; if not, write to the | ||
500 | 16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
501 | 17 | * Boston, MA 02111-1307, USA. | ||
502 | 18 | * | ||
503 | 19 | * Author: David Reveman <davidr@novell.com> | ||
504 | 20 | * | ||
505 | 21 | * 2D Mode: Copyright © 2010 Sam Spilsbury <smspillaz@gmail.com> | ||
506 | 22 | * Frames Management: Copright © 2011 Canonical Ltd. | ||
507 | 23 | * Authored By: Sam Spilsbury <sam.spilsbury@canonical.com> | ||
508 | 24 | */ | ||
509 | 25 | |||
510 | 26 | #include <string.h> | ||
511 | 27 | #include "local-menus.h" | ||
512 | 28 | #include <gdk/gdk.h> | ||
513 | 29 | #include <gdk/gdkx.h> | ||
514 | 30 | |||
515 | 31 | #define GLOBAL 0 | ||
516 | 32 | #define LOCAL 1 | ||
517 | 33 | |||
518 | 34 | #define ALLOWED 2 | ||
519 | 35 | #define NOT_ALLOWED 1 | ||
520 | 36 | |||
521 | 37 | gint menu_mode = GLOBAL; | ||
522 | 38 | |||
523 | 39 | GDBusProxy *global_lim_listener; | ||
524 | 40 | |||
525 | 41 | |||
526 | 42 | #ifdef META_HAS_LOCAL_MENUS | ||
527 | 43 | static void | ||
528 | 44 | gwd_menu_mode_changed (GSettings *settings, | ||
529 | 45 | gchar *key, | ||
530 | 46 | gpointer user_data) | ||
531 | 47 | { | ||
532 | 48 | menu_mode = g_settings_get_enum (settings, "menu-mode"); | ||
533 | 49 | } | ||
534 | 50 | #endif | ||
535 | 51 | |||
536 | 52 | active_local_menu *active_menu; | ||
537 | 53 | pending_local_menu *pending_menu; | ||
538 | 54 | |||
539 | 55 | GHashTable *get_windows_with_menus_table () | ||
540 | 56 | { | ||
541 | 57 | static GHashTable *windows_with_menus = NULL; | ||
542 | 58 | |||
543 | 59 | if (!windows_with_menus) | ||
544 | 60 | windows_with_menus = g_hash_table_new (NULL, NULL); | ||
545 | 61 | |||
546 | 62 | return windows_with_menus; | ||
547 | 63 | } | ||
548 | 64 | |||
549 | 65 | static gboolean read_xprop_for_window (Display *dpy, Window xid) | ||
550 | 66 | { | ||
551 | 67 | Atom ubuntu_appmenu_unique_name = XInternAtom (dpy, "_UBUNTU_APPMENU_UNIQUE_NAME", FALSE); | ||
552 | 68 | Atom utf8_string = XInternAtom (dpy, "UTF8_STRING", FALSE); | ||
553 | 69 | Atom actual; | ||
554 | 70 | int fmt; | ||
555 | 71 | unsigned long nitems, nleft; | ||
556 | 72 | unsigned char *prop; | ||
557 | 73 | XGetWindowProperty (dpy, xid, ubuntu_appmenu_unique_name, | ||
558 | 74 | 0L, 16L, FALSE, utf8_string, &actual, &fmt, &nitems, &nleft, &prop); | ||
559 | 75 | |||
560 | 76 | if (actual == utf8_string && fmt == 8 && nitems > 1) | ||
561 | 77 | { | ||
562 | 78 | g_hash_table_replace (get_windows_with_menus_table (), GINT_TO_POINTER (xid), GINT_TO_POINTER (ALLOWED)); | ||
563 | 79 | return TRUE; | ||
564 | 80 | } | ||
565 | 81 | else | ||
566 | 82 | { | ||
567 | 83 | g_hash_table_replace (get_windows_with_menus_table (), GINT_TO_POINTER (xid), GINT_TO_POINTER (NOT_ALLOWED)); | ||
568 | 84 | return FALSE; | ||
569 | 85 | } | ||
570 | 86 | } | ||
571 | 87 | |||
572 | 88 | gboolean | ||
573 | 89 | local_menu_allowed_on_window (Display *dpy, Window xid) | ||
574 | 90 | { | ||
575 | 91 | gpointer local_menu_allowed_found = g_hash_table_lookup (get_windows_with_menus_table (), GINT_TO_POINTER (xid)); | ||
576 | 92 | |||
577 | 93 | if (local_menu_allowed_found) | ||
578 | 94 | { | ||
579 | 95 | return GPOINTER_TO_INT (local_menu_allowed_found) == ALLOWED; | ||
580 | 96 | } | ||
581 | 97 | else if (dpy && xid) | ||
582 | 98 | { | ||
583 | 99 | return read_xprop_for_window (dpy, xid); | ||
584 | 100 | } | ||
585 | 101 | |||
586 | 102 | return FALSE; | ||
587 | 103 | } | ||
588 | 104 | |||
589 | 105 | gboolean | ||
590 | 106 | gwd_window_should_have_local_menu (WnckWindow *win) | ||
591 | 107 | { | ||
592 | 108 | #ifdef META_HAS_LOCAL_MENUS | ||
593 | 109 | const gchar * const *schemas = g_settings_list_schemas (); | ||
594 | 110 | static GSettings *lim_settings = NULL; | ||
595 | 111 | while (*schemas != NULL && !lim_settings) | ||
596 | 112 | { | ||
597 | 113 | if (g_str_equal (*schemas, "com.canonical.indicator.appmenu")) | ||
598 | 114 | { | ||
599 | 115 | lim_settings = g_settings_new ("com.canonical.indicator.appmenu"); | ||
600 | 116 | menu_mode = g_settings_get_enum (lim_settings, "menu-mode"); | ||
601 | 117 | g_signal_connect (lim_settings, "changed::menu-mode", G_CALLBACK (gwd_menu_mode_changed), NULL); | ||
602 | 118 | break; | ||
603 | 119 | } | ||
604 | 120 | ++schemas; | ||
605 | 121 | } | ||
606 | 122 | |||
607 | 123 | if (lim_settings && win) | ||
608 | 124 | return menu_mode == LOCAL && local_menu_allowed_on_window (gdk_x11_display_get_xdisplay (gdk_display_get_default ()), wnck_window_get_xid (win)); | ||
609 | 125 | #endif | ||
610 | 126 | |||
611 | 127 | return FALSE; | ||
612 | 128 | } | ||
613 | 129 | |||
614 | 130 | gchar * | ||
615 | 131 | gwd_get_entry_id_from_sync_variant (GVariant *args) | ||
616 | 132 | { | ||
617 | 133 | /* We need to get the indicator data once we've called show */ | ||
618 | 134 | |||
619 | 135 | GVariantIter* iter = NULL; | ||
620 | 136 | gchar* name_hint = NULL; | ||
621 | 137 | gchar* indicator_id = NULL; | ||
622 | 138 | gchar* entry_id = NULL; | ||
623 | 139 | gchar* label = NULL; | ||
624 | 140 | gboolean label_sensitive = FALSE; | ||
625 | 141 | gboolean label_visible = FALSE; | ||
626 | 142 | guint32 image_type = 0; | ||
627 | 143 | gchar* image_data = NULL; | ||
628 | 144 | gboolean image_sensitive = FALSE; | ||
629 | 145 | gboolean image_visible = FALSE; | ||
630 | 146 | gint32 priority = -1; | ||
631 | 147 | |||
632 | 148 | g_variant_get (args, "(a(ssssbbusbbi))", &iter); | ||
633 | 149 | while (g_variant_iter_loop (iter, "(ssssbbusbbi)", | ||
634 | 150 | &indicator_id, | ||
635 | 151 | &entry_id, | ||
636 | 152 | &name_hint, | ||
637 | 153 | &label, | ||
638 | 154 | &label_sensitive, | ||
639 | 155 | &label_visible, | ||
640 | 156 | &image_type, | ||
641 | 157 | &image_data, | ||
642 | 158 | &image_sensitive, | ||
643 | 159 | &image_visible, | ||
644 | 160 | &priority)) | ||
645 | 161 | { | ||
646 | 162 | g_variant_unref (args); | ||
647 | 163 | return g_strdup (entry_id); | ||
648 | 164 | } | ||
649 | 165 | |||
650 | 166 | g_variant_unref (args); | ||
651 | 167 | g_assert_not_reached (); | ||
652 | 168 | return NULL; | ||
653 | 169 | } | ||
654 | 170 | #ifdef META_HAS_LOCAL_MENUS | ||
655 | 171 | static void | ||
656 | 172 | on_local_menu_activated (GDBusProxy *proxy, | ||
657 | 173 | gchar *sender_name, | ||
658 | 174 | gchar *signal_name, | ||
659 | 175 | GVariant *parameters, | ||
660 | 176 | gpointer user_data) | ||
661 | 177 | { | ||
662 | 178 | |||
663 | 179 | if (g_strcmp0 (signal_name, "EntryActivated") == 0) | ||
664 | 180 | { | ||
665 | 181 | show_local_menu_data *d = (show_local_menu_data *) user_data; | ||
666 | 182 | gchar *entry_id = NULL; | ||
667 | 183 | gint x_out, y_out; | ||
668 | 184 | guint width, height; | ||
669 | 185 | |||
670 | 186 | g_variant_get (parameters, "(s(iiuu))", &entry_id, &x_out, &y_out, &width, &height, NULL); | ||
671 | 187 | |||
672 | 188 | if (!d->local_menu_entry_id) | ||
673 | 189 | { | ||
674 | 190 | GError *error = NULL; | ||
675 | 191 | GVariant *params = g_variant_new ("(s)", "libappmenu.so", NULL); | ||
676 | 192 | GVariant *args = g_dbus_proxy_call_sync (proxy, "SyncOne", params, 0, 500, NULL, &error); | ||
677 | 193 | |||
678 | 194 | g_assert_no_error (error); | ||
679 | 195 | d->local_menu_entry_id = gwd_get_entry_id_from_sync_variant (args); | ||
680 | 196 | } | ||
681 | 197 | |||
682 | 198 | if (g_strcmp0 (entry_id, d->local_menu_entry_id) == 0) | ||
683 | 199 | { | ||
684 | 200 | d->rect->x = x_out - d->dx; | ||
685 | 201 | d->rect->y = y_out - d->dy; | ||
686 | 202 | d->rect->width = width; | ||
687 | 203 | d->rect->height = height; | ||
688 | 204 | (*d->cb) (d->user_data); | ||
689 | 205 | } | ||
690 | 206 | else if (g_strcmp0 (entry_id, "") == 0) | ||
691 | 207 | { | ||
692 | 208 | memset (d->rect, 0, sizeof (GdkRectangle)); | ||
693 | 209 | (*d->cb) (d->user_data); | ||
694 | 210 | |||
695 | 211 | g_signal_handlers_disconnect_by_func (proxy, on_local_menu_activated, d); | ||
696 | 212 | |||
697 | 213 | if (active_menu) | ||
698 | 214 | { | ||
699 | 215 | g_free (active_menu); | ||
700 | 216 | active_menu = NULL; | ||
701 | 217 | } | ||
702 | 218 | |||
703 | 219 | g_free (d->local_menu_entry_id); | ||
704 | 220 | g_free (d); | ||
705 | 221 | } | ||
706 | 222 | } | ||
707 | 223 | |||
708 | 224 | } | ||
709 | 225 | #endif | ||
710 | 226 | gboolean | ||
711 | 227 | gwd_move_window_instead (gpointer user_data) | ||
712 | 228 | { | ||
713 | 229 | (*pending_menu->cb) (pending_menu->user_data); | ||
714 | 230 | g_free (pending_menu->user_data); | ||
715 | 231 | g_free (pending_menu); | ||
716 | 232 | pending_menu = NULL; | ||
717 | 233 | return FALSE; | ||
718 | 234 | } | ||
719 | 235 | |||
720 | 236 | void | ||
721 | 237 | gwd_prepare_show_local_menu (start_move_window_cb start_move_window, | ||
722 | 238 | gpointer user_data_start_move_window) | ||
723 | 239 | { | ||
724 | 240 | if (pending_menu) | ||
725 | 241 | { | ||
726 | 242 | g_source_remove (pending_menu->move_timeout_id); | ||
727 | 243 | g_free (pending_menu->user_data); | ||
728 | 244 | g_free (pending_menu); | ||
729 | 245 | pending_menu = NULL; | ||
730 | 246 | } | ||
731 | 247 | |||
732 | 248 | pending_menu = g_new0 (pending_local_menu, 1); | ||
733 | 249 | pending_menu->cb = start_move_window; | ||
734 | 250 | pending_menu->user_data = user_data_start_move_window; | ||
735 | 251 | pending_menu->move_timeout_id = g_timeout_add (120, gwd_move_window_instead, pending_menu); | ||
736 | 252 | } | ||
737 | 253 | |||
738 | 254 | #ifdef META_HAS_LOCAL_MENUS | ||
739 | 255 | void | ||
740 | 256 | local_menu_entry_activated_request (GDBusProxy *proxy, | ||
741 | 257 | gchar *sender_name, | ||
742 | 258 | gchar *signal_name, | ||
743 | 259 | GVariant *parameters, | ||
744 | 260 | gpointer user_data) | ||
745 | 261 | { | ||
746 | 262 | if (g_strcmp0 (signal_name, "EntryActivateRequest") == 0) | ||
747 | 263 | { | ||
748 | 264 | gchar *activated_entry_id; | ||
749 | 265 | gchar *local_menu_entry_id; | ||
750 | 266 | local_menu_entry_activated_request_funcs *funcs = (local_menu_entry_activated_request_funcs *) user_data; | ||
751 | 267 | |||
752 | 268 | g_variant_get (parameters, "(s)", &activated_entry_id, NULL); | ||
753 | 269 | |||
754 | 270 | GError *error = NULL; | ||
755 | 271 | GVariant *params = g_variant_new ("(s)", "libappmenu.so", NULL); | ||
756 | 272 | GVariant *args = g_dbus_proxy_call_sync (proxy, "SyncOne", params, 0, 500, NULL, &error); | ||
757 | 273 | |||
758 | 274 | g_assert_no_error (error); | ||
759 | 275 | local_menu_entry_id = gwd_get_entry_id_from_sync_variant (args); | ||
760 | 276 | |||
761 | 277 | if (g_strcmp0 (activated_entry_id, local_menu_entry_id) == 0) | ||
762 | 278 | { | ||
763 | 279 | WnckScreen *screen = wnck_screen_get_for_root (gdk_x11_get_default_root_xwindow ()); | ||
764 | 280 | int dx, dy, top_height; | ||
765 | 281 | Window xid; | ||
766 | 282 | |||
767 | 283 | if (screen) | ||
768 | 284 | { | ||
769 | 285 | Box *rect = (*funcs->active_window_local_menu_rect_callback) ((gpointer) screen, &dx, &dy, &top_height, &xid); | ||
770 | 286 | |||
771 | 287 | if (rect) | ||
772 | 288 | { | ||
773 | 289 | int x = rect->x1; | ||
774 | 290 | int y = top_height; | ||
775 | 291 | |||
776 | 292 | gwd_show_local_menu (gdk_x11_display_get_xdisplay (gdk_display_get_default ()), | ||
777 | 293 | xid, x + dx, y + dy, x, y, 0, 0, | ||
778 | 294 | funcs->show_window_menu_hidden_callback, GINT_TO_POINTER (xid)); | ||
779 | 295 | } | ||
780 | 296 | } | ||
781 | 297 | } | ||
782 | 298 | } | ||
783 | 299 | } | ||
784 | 300 | #endif | ||
785 | 301 | |||
786 | 302 | gboolean | ||
787 | 303 | gwd_show_local_menu (Display *xdisplay, | ||
788 | 304 | Window frame_xwindow, | ||
789 | 305 | int x, | ||
790 | 306 | int y, | ||
791 | 307 | int x_win, | ||
792 | 308 | int y_win, | ||
793 | 309 | int button, | ||
794 | 310 | guint32 timestamp, | ||
795 | 311 | show_window_menu_hidden_cb cb, | ||
796 | 312 | gpointer user_data_show_window_menu) | ||
797 | 313 | { | ||
798 | 314 | if (pending_menu) | ||
799 | 315 | { | ||
800 | 316 | g_source_remove (pending_menu->move_timeout_id); | ||
801 | 317 | g_free (pending_menu->user_data); | ||
802 | 318 | g_free (pending_menu); | ||
803 | 319 | pending_menu = NULL; | ||
804 | 320 | } | ||
805 | 321 | |||
806 | 322 | #ifdef META_HAS_LOCAL_MENUS | ||
807 | 323 | |||
808 | 324 | |||
809 | 325 | XUngrabPointer (gdk_x11_display_get_xdisplay (gdk_display_get_default ()), CurrentTime); | ||
810 | 326 | XUngrabKeyboard (gdk_x11_display_get_xdisplay (gdk_display_get_default ()), CurrentTime); | ||
811 | 327 | XSync (gdk_x11_display_get_xdisplay (gdk_display_get_default ()), FALSE); | ||
812 | 328 | |||
813 | 329 | GDBusProxy *proxy = global_lim_listener; | ||
814 | 330 | |||
815 | 331 | if (proxy) | ||
816 | 332 | { | ||
817 | 333 | GVariant *message = g_variant_new ("(uiiu)", frame_xwindow, x, y, time); | ||
818 | 334 | GError *error = NULL; | ||
819 | 335 | g_dbus_proxy_call_sync (proxy, "ShowAppMenu", message, 0, 500, NULL, &error); | ||
820 | 336 | if (error) | ||
821 | 337 | { | ||
822 | 338 | g_print ("error calling ShowAppMenu: %s\n", error->message); | ||
823 | 339 | return FALSE; | ||
824 | 340 | } | ||
825 | 341 | |||
826 | 342 | show_local_menu_data *data = g_new0 (show_local_menu_data, 1); | ||
827 | 343 | |||
828 | 344 | if (active_menu) | ||
829 | 345 | g_free (active_menu); | ||
830 | 346 | |||
831 | 347 | active_menu = g_new0 (active_local_menu, 1); | ||
832 | 348 | |||
833 | 349 | data->cb = cb; | ||
834 | 350 | data->user_data = user_data_show_window_menu; | ||
835 | 351 | data->rect = &active_menu->rect; | ||
836 | 352 | data->dx = x - x_win; | ||
837 | 353 | data->dy = y - y_win; | ||
838 | 354 | data->local_menu_entry_id = NULL; | ||
839 | 355 | |||
840 | 356 | g_signal_connect (proxy, "g-signal", G_CALLBACK (on_local_menu_activated), data); | ||
841 | 357 | |||
842 | 358 | return TRUE; | ||
843 | 359 | } | ||
844 | 360 | #endif | ||
845 | 361 | return FALSE; | ||
846 | 362 | } | ||
847 | 363 | |||
848 | 364 | void | ||
849 | 365 | force_local_menus_on (WnckWindow *win, | ||
850 | 366 | MetaButtonLayout *button_layout) | ||
851 | 367 | { | ||
852 | 368 | #ifdef META_HAS_LOCAL_MENUS | ||
853 | 369 | if (gwd_window_should_have_local_menu (win)) | ||
854 | 370 | { | ||
855 | 371 | if (button_layout->left_buttons[0] != META_BUTTON_FUNCTION_LAST) | ||
856 | 372 | { | ||
857 | 373 | unsigned int i = 0; | ||
858 | 374 | for (; i < MAX_BUTTONS_PER_CORNER; i++) | ||
859 | 375 | { | ||
860 | 376 | if (button_layout->left_buttons[i] == META_BUTTON_FUNCTION_WINDOW_MENU) | ||
861 | 377 | break; | ||
862 | 378 | else if (button_layout->left_buttons[i] == META_BUTTON_FUNCTION_LAST) | ||
863 | 379 | { | ||
864 | 380 | if ((i + 1) < MAX_BUTTONS_PER_CORNER) | ||
865 | 381 | { | ||
866 | 382 | button_layout->left_buttons[i + 1] = META_BUTTON_FUNCTION_LAST; | ||
867 | 383 | button_layout->left_buttons[i] = META_BUTTON_FUNCTION_WINDOW_MENU; | ||
868 | 384 | break; | ||
869 | 385 | } | ||
870 | 386 | } | ||
871 | 387 | } | ||
872 | 388 | } | ||
873 | 389 | if (button_layout->right_buttons[0] != META_BUTTON_FUNCTION_LAST) | ||
874 | 390 | { | ||
875 | 391 | unsigned int i = 0; | ||
876 | 392 | for (; i < MAX_BUTTONS_PER_CORNER; i++) | ||
877 | 393 | { | ||
878 | 394 | if (button_layout->right_buttons[i] == META_BUTTON_FUNCTION_WINDOW_MENU) | ||
879 | 395 | break; | ||
880 | 396 | else if (button_layout->right_buttons[i] == META_BUTTON_FUNCTION_LAST) | ||
881 | 397 | { | ||
882 | 398 | if ((i + 1) < MAX_BUTTONS_PER_CORNER) | ||
883 | 399 | { | ||
884 | 400 | button_layout->right_buttons[i + 1] = META_BUTTON_FUNCTION_LAST; | ||
885 | 401 | button_layout->right_buttons[i] = META_BUTTON_FUNCTION_WINDOW_MENU; | ||
886 | 402 | break; | ||
887 | 403 | } | ||
888 | 404 | } | ||
889 | 405 | } | ||
890 | 406 | } | ||
891 | 407 | } | ||
892 | 408 | #endif | ||
893 | 409 | } | ||
894 | 410 | |||
895 | 411 | void | ||
896 | 412 | local_menu_cache_notify_window_destroyed (Window xid) | ||
897 | 413 | { | ||
898 | 414 | g_hash_table_remove (get_windows_with_menus_table (), GINT_TO_POINTER (xid)); | ||
899 | 415 | } | ||
900 | 416 | |||
901 | 417 | void | ||
902 | 418 | local_menu_cache_reload_xwindow (Display *dpy, Window xid) | ||
903 | 419 | { | ||
904 | 420 | read_xprop_for_window (dpy, xid); | ||
905 | 421 | } | ||
906 | 422 | |||
907 | 423 | |||
908 | 0 | 424 | ||
909 | === added file 'gtk/window-decorator/local-menus/src/local-menus.h' | |||
910 | --- gtk/window-decorator/local-menus/src/local-menus.h 1970-01-01 00:00:00 +0000 | |||
911 | +++ gtk/window-decorator/local-menus/src/local-menus.h 2012-02-25 05:11:17 +0000 | |||
912 | @@ -0,0 +1,120 @@ | |||
913 | 1 | /* | ||
914 | 2 | * Copyright © 2006 Novell, Inc. | ||
915 | 3 | * | ||
916 | 4 | * This library is free software; you can redistribute it and/or | ||
917 | 5 | * modify it under the terms of the GNU Lesser General Public | ||
918 | 6 | * License as published by the Free Software Foundation; either | ||
919 | 7 | * version 2 of the License, or (at your option) any later version. | ||
920 | 8 | * | ||
921 | 9 | * This library is distributed in the hope that it will be useful, | ||
922 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
923 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
924 | 12 | * Lesser General Public License for more details. | ||
925 | 13 | * | ||
926 | 14 | * You should have received a copy of the GNU Lesser General Public | ||
927 | 15 | * License along with this library; if not, write to the | ||
928 | 16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
929 | 17 | * Boston, MA 02111-1307, USA. | ||
930 | 18 | * | ||
931 | 19 | * Author: David Reveman <davidr@novell.com> | ||
932 | 20 | * | ||
933 | 21 | * 2D Mode: Copyright © 2010 Sam Spilsbury <smspillaz@gmail.com> | ||
934 | 22 | * Frames Management: Copright © 2011 Canonical Ltd. | ||
935 | 23 | * Authored By: Sam Spilsbury <sam.spilsbury@canonical.com> | ||
936 | 24 | */ | ||
937 | 25 | |||
938 | 26 | #ifdef __cplusplus | ||
939 | 27 | extern "C" | ||
940 | 28 | { | ||
941 | 29 | #endif | ||
942 | 30 | |||
943 | 31 | #include <glib.h> | ||
944 | 32 | #include <gio/gio.h> | ||
945 | 33 | #ifndef WNCK_I_KNOW_THIS_IS_UNSTABLE | ||
946 | 34 | #define WNCK_I_KNOW_THIS_IS_UNSTABLE | ||
947 | 35 | #endif | ||
948 | 36 | #include <libwnck/libwnck.h> | ||
949 | 37 | #include <libwnck/window-action-menu.h> | ||
950 | 38 | #include <metacity-private/theme.h> | ||
951 | 39 | #include <X11/Xregion.h> | ||
952 | 40 | |||
953 | 41 | |||
954 | 42 | typedef void (*show_window_menu_hidden_cb) (gpointer); | ||
955 | 43 | typedef void (*start_move_window_cb) (gpointer); | ||
956 | 44 | typedef Box * (*get_active_window_local_menu_rect_cb) (gpointer, int *, int *, int *, Window *); | ||
957 | 45 | |||
958 | 46 | typedef struct _pending_local_menu | ||
959 | 47 | { | ||
960 | 48 | gint move_timeout_id; | ||
961 | 49 | gpointer user_data; | ||
962 | 50 | start_move_window_cb cb; | ||
963 | 51 | } pending_local_menu; | ||
964 | 52 | |||
965 | 53 | typedef struct _active_local_menu | ||
966 | 54 | { | ||
967 | 55 | GdkRectangle rect; | ||
968 | 56 | } active_local_menu; | ||
969 | 57 | |||
970 | 58 | extern active_local_menu *active_menu; | ||
971 | 59 | extern GDBusProxy *global_lim_listener; | ||
972 | 60 | |||
973 | 61 | typedef struct _show_local_menu_data | ||
974 | 62 | { | ||
975 | 63 | show_window_menu_hidden_cb cb; | ||
976 | 64 | gpointer user_data; | ||
977 | 65 | GdkRectangle *rect; | ||
978 | 66 | gint dx; | ||
979 | 67 | gint dy; | ||
980 | 68 | gchar *local_menu_entry_id; | ||
981 | 69 | } show_local_menu_data; | ||
982 | 70 | |||
983 | 71 | typedef struct _local_menu_entry_activated_request_funcs | ||
984 | 72 | { | ||
985 | 73 | get_active_window_local_menu_rect_cb active_window_local_menu_rect_callback; | ||
986 | 74 | show_window_menu_hidden_cb show_window_menu_hidden_callback; | ||
987 | 75 | } local_menu_entry_activated_request_funcs; | ||
988 | 76 | |||
989 | 77 | gboolean | ||
990 | 78 | gwd_window_should_have_local_menu (WnckWindow *win); | ||
991 | 79 | |||
992 | 80 | void | ||
993 | 81 | force_local_menus_on (WnckWindow *win, | ||
994 | 82 | MetaButtonLayout *layout); | ||
995 | 83 | |||
996 | 84 | /* Button Down */ | ||
997 | 85 | void | ||
998 | 86 | gwd_prepare_show_local_menu (start_move_window_cb start_move_window, | ||
999 | 87 | gpointer user_data_start_move_window); | ||
1000 | 88 | |||
1001 | 89 | /* Button Up */ | ||
1002 | 90 | gboolean | ||
1003 | 91 | gwd_show_local_menu (Display *xdisplay, | ||
1004 | 92 | Window frame_xwindow, | ||
1005 | 93 | int x, | ||
1006 | 94 | int y, | ||
1007 | 95 | int x_win, | ||
1008 | 96 | int y_win, | ||
1009 | 97 | int button, | ||
1010 | 98 | guint32 timestamp, | ||
1011 | 99 | show_window_menu_hidden_cb cb, | ||
1012 | 100 | gpointer user_data_show_window_menu); | ||
1013 | 101 | |||
1014 | 102 | void | ||
1015 | 103 | local_menu_cache_notify_window_destroyed (Window xid); | ||
1016 | 104 | |||
1017 | 105 | void | ||
1018 | 106 | local_menu_cache_reload_xwindow (Display *xdisplay, Window xid); | ||
1019 | 107 | |||
1020 | 108 | gboolean | ||
1021 | 109 | local_menu_allowed_on_window (Display *dpy, Window xid); | ||
1022 | 110 | |||
1023 | 111 | void | ||
1024 | 112 | local_menu_entry_activated_request (GDBusProxy *proxy, | ||
1025 | 113 | gchar *sender_name, | ||
1026 | 114 | gchar *signal_name, | ||
1027 | 115 | GVariant *parameters, | ||
1028 | 116 | gpointer user_data); | ||
1029 | 117 | |||
1030 | 118 | #ifdef __cplusplus | ||
1031 | 119 | } | ||
1032 | 120 | #endif | ||
1033 | 0 | 121 | ||
1034 | === added directory 'gtk/window-decorator/local-menus/tests' | |||
1035 | === added file 'gtk/window-decorator/local-menus/tests/CMakeLists.txt' | |||
1036 | --- gtk/window-decorator/local-menus/tests/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
1037 | +++ gtk/window-decorator/local-menus/tests/CMakeLists.txt 2012-02-25 05:11:17 +0000 | |||
1038 | @@ -0,0 +1,3 @@ | |||
1039 | 1 | include_directories (${CMAKE_CURRENT_SOURCE_DIR}) | ||
1040 | 2 | add_subdirectory (check_local_menu_on_off) | ||
1041 | 3 | add_subdirectory (force_local_menu_on) | ||
1042 | 0 | 4 | ||
1043 | === added directory 'gtk/window-decorator/local-menus/tests/check_local_menu_on_off' | |||
1044 | === added file 'gtk/window-decorator/local-menus/tests/check_local_menu_on_off/CMakeLists.txt' | |||
1045 | --- gtk/window-decorator/local-menus/tests/check_local_menu_on_off/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
1046 | +++ gtk/window-decorator/local-menus/tests/check_local_menu_on_off/CMakeLists.txt 2012-02-25 05:11:17 +0000 | |||
1047 | @@ -0,0 +1,21 @@ | |||
1048 | 1 | include_directories (${CMAKE_CURRENT_SOURCE_DIR} | ||
1049 | 2 | ${compiz_SOURCE_DIR}/gtk/window-decorator/local-menus/tests | ||
1050 | 3 | ${compiz_SOURCE_DIR}/gtk/window-decorator | ||
1051 | 4 | ${compiz_SOURCE_DIR}/gtk/window-decorator/local-menus/src) | ||
1052 | 5 | |||
1053 | 6 | add_executable( | ||
1054 | 7 | gtk_window_decorator_check_local_menu_on_off_test | ||
1055 | 8 | |||
1056 | 9 | ${CMAKE_CURRENT_SOURCE_DIR}/test-local-menu-on-off.cpp | ||
1057 | 10 | ) | ||
1058 | 11 | |||
1059 | 12 | target_link_libraries( | ||
1060 | 13 | gtk_window_decorator_check_local_menu_on_off_test | ||
1061 | 14 | |||
1062 | 15 | gtk_window_decorator_local_menus | ||
1063 | 16 | |||
1064 | 17 | ${GTEST_BOTH_LIBRARIES} | ||
1065 | 18 | ${CMAKE_THREAD_LIBS_INIT} # Link in pthread. | ||
1066 | 19 | ) | ||
1067 | 20 | |||
1068 | 21 | add_test (gtk_window_decorator_local_menus_on_off gtk_window_decorator_check_local_menu_on_off_test) | ||
1069 | 0 | 22 | ||
1070 | === added directory 'gtk/window-decorator/local-menus/tests/check_local_menu_on_off/check_local_menu_on_off' | |||
1071 | === added directory 'gtk/window-decorator/local-menus/tests/check_local_menu_on_off/check_local_menu_on_off/CMakeFiles' | |||
1072 | === added file 'gtk/window-decorator/local-menus/tests/check_local_menu_on_off/test-local-menu-on-off.cpp' | |||
1073 | --- gtk/window-decorator/local-menus/tests/check_local_menu_on_off/test-local-menu-on-off.cpp 1970-01-01 00:00:00 +0000 | |||
1074 | +++ gtk/window-decorator/local-menus/tests/check_local_menu_on_off/test-local-menu-on-off.cpp 2012-02-25 05:11:17 +0000 | |||
1075 | @@ -0,0 +1,27 @@ | |||
1076 | 1 | #include "test-local-menu.h" | ||
1077 | 2 | |||
1078 | 3 | #define GLOBAL 0 | ||
1079 | 4 | #define LOCAL 1 | ||
1080 | 5 | #ifdef META_HAS_LOCAL_MENUS | ||
1081 | 6 | |||
1082 | 7 | TEST_F (GtkWindowDecoratorTestLocalMenu, TestOn) | ||
1083 | 8 | { | ||
1084 | 9 | g_settings_set_enum (getSettings (), "menu-mode", LOCAL); | ||
1085 | 10 | gboolean result = gwd_window_should_have_local_menu (getWindow ()); | ||
1086 | 11 | |||
1087 | 12 | EXPECT_TRUE (result); | ||
1088 | 13 | } | ||
1089 | 14 | |||
1090 | 15 | TEST_F (GtkWindowDecoratorTestLocalMenu, TestOff) | ||
1091 | 16 | { | ||
1092 | 17 | g_settings_set_enum (getSettings (), "menu-mode", GLOBAL); | ||
1093 | 18 | gboolean result = gwd_window_should_have_local_menu (getWindow ()); | ||
1094 | 19 | |||
1095 | 20 | EXPECT_FALSE (result); | ||
1096 | 21 | } | ||
1097 | 22 | #else | ||
1098 | 23 | TEST_F (GtkWindowDecoratorTestLocalMenu, NoMenus) | ||
1099 | 24 | { | ||
1100 | 25 | ASSERT_TRUE (true) << "Local menus tests not enabled because META_HAS_LOCAL_MENUS is off"; | ||
1101 | 26 | } | ||
1102 | 27 | #endif | ||
1103 | 0 | 28 | ||
1104 | === added directory 'gtk/window-decorator/local-menus/tests/force_local_menu_on' | |||
1105 | === added file 'gtk/window-decorator/local-menus/tests/force_local_menu_on/CMakeLists.txt' | |||
1106 | --- gtk/window-decorator/local-menus/tests/force_local_menu_on/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
1107 | +++ gtk/window-decorator/local-menus/tests/force_local_menu_on/CMakeLists.txt 2012-02-25 05:11:17 +0000 | |||
1108 | @@ -0,0 +1,21 @@ | |||
1109 | 1 | include_directories (${CMAKE_CURRENT_SOURCE_DIR} | ||
1110 | 2 | ${compiz_SOURCE_DIR}/gtk/window-decorator/local-menus/tests | ||
1111 | 3 | ${compiz_SOURCE_DIR}/gtk/window-decorator | ||
1112 | 4 | ${compiz_SOURCE_DIR}/gtk/window-decorator/local-menus/src) | ||
1113 | 5 | |||
1114 | 6 | add_executable( | ||
1115 | 7 | gtk_window_decorator_force_local_menu_on_test | ||
1116 | 8 | |||
1117 | 9 | ${CMAKE_CURRENT_SOURCE_DIR}/test-force-local-menu-on.cpp | ||
1118 | 10 | ) | ||
1119 | 11 | |||
1120 | 12 | target_link_libraries( | ||
1121 | 13 | gtk_window_decorator_force_local_menu_on_test | ||
1122 | 14 | |||
1123 | 15 | gtk_window_decorator_local_menus | ||
1124 | 16 | |||
1125 | 17 | ${GTEST_BOTH_LIBRARIES} | ||
1126 | 18 | ${CMAKE_THREAD_LIBS_INIT} # Link in pthread. | ||
1127 | 19 | ) | ||
1128 | 20 | |||
1129 | 21 | add_test (gtk_window_decorator_force_local_menu_on gtk_window_decorator_force_local_menu_on_test) | ||
1130 | 0 | 22 | ||
1131 | === added file 'gtk/window-decorator/local-menus/tests/force_local_menu_on/test-force-local-menu-on.cpp' | |||
1132 | --- gtk/window-decorator/local-menus/tests/force_local_menu_on/test-force-local-menu-on.cpp 1970-01-01 00:00:00 +0000 | |||
1133 | +++ gtk/window-decorator/local-menus/tests/force_local_menu_on/test-force-local-menu-on.cpp 2012-02-25 05:11:17 +0000 | |||
1134 | @@ -0,0 +1,77 @@ | |||
1135 | 1 | #include "test-local-menu.h" | ||
1136 | 2 | #include <cstring> | ||
1137 | 3 | |||
1138 | 4 | #define GLOBAL 0 | ||
1139 | 5 | #define LOCAL 1 | ||
1140 | 6 | #ifdef META_HAS_LOCAL_MENUS | ||
1141 | 7 | |||
1142 | 8 | namespace | ||
1143 | 9 | { | ||
1144 | 10 | void initializeMetaButtonLayout (MetaButtonLayout *layout) | ||
1145 | 11 | { | ||
1146 | 12 | memset (layout, 0, sizeof (MetaButtonLayout)); | ||
1147 | 13 | |||
1148 | 14 | unsigned int i; | ||
1149 | 15 | |||
1150 | 16 | for (i = 0; i < MAX_BUTTONS_PER_CORNER; i++) | ||
1151 | 17 | { | ||
1152 | 18 | layout->right_buttons[i] = META_BUTTON_FUNCTION_LAST; | ||
1153 | 19 | layout->left_buttons[i] = META_BUTTON_FUNCTION_LAST; | ||
1154 | 20 | } | ||
1155 | 21 | } | ||
1156 | 22 | } | ||
1157 | 23 | |||
1158 | 24 | class GtkWindowDecoratorTestLocalMenuLayout : | ||
1159 | 25 | public GtkWindowDecoratorTestLocalMenu | ||
1160 | 26 | { | ||
1161 | 27 | public: | ||
1162 | 28 | |||
1163 | 29 | MetaButtonLayout * getLayout () { return &mLayout; } | ||
1164 | 30 | |||
1165 | 31 | virtual void SetUp () | ||
1166 | 32 | { | ||
1167 | 33 | GtkWindowDecoratorTestLocalMenu::SetUp (); | ||
1168 | 34 | ::initializeMetaButtonLayout (&mLayout); | ||
1169 | 35 | g_settings_set_enum (getSettings (), "menu-mode", LOCAL); | ||
1170 | 36 | } | ||
1171 | 37 | |||
1172 | 38 | private: | ||
1173 | 39 | |||
1174 | 40 | MetaButtonLayout mLayout; | ||
1175 | 41 | }; | ||
1176 | 42 | |||
1177 | 43 | TEST_F (GtkWindowDecoratorTestLocalMenuLayout, TestForceNoButtonsSet) | ||
1178 | 44 | { | ||
1179 | 45 | force_local_menus_on (getWindow (), getLayout ()); | ||
1180 | 46 | |||
1181 | 47 | EXPECT_EQ (getLayout ()->right_buttons[0], META_BUTTON_FUNCTION_LAST); | ||
1182 | 48 | EXPECT_EQ (getLayout ()->left_buttons[0], META_BUTTON_FUNCTION_LAST); | ||
1183 | 49 | } | ||
1184 | 50 | |||
1185 | 51 | TEST_F (GtkWindowDecoratorTestLocalMenuLayout, TestForceNoCloseButtonSet) | ||
1186 | 52 | { | ||
1187 | 53 | getLayout ()->right_buttons[0] = META_BUTTON_FUNCTION_CLOSE; | ||
1188 | 54 | |||
1189 | 55 | force_local_menus_on (getWindow (), getLayout ()); | ||
1190 | 56 | |||
1191 | 57 | EXPECT_EQ (getLayout ()->right_buttons[1], META_BUTTON_FUNCTION_WINDOW_MENU); | ||
1192 | 58 | EXPECT_EQ (getLayout ()->left_buttons[0], META_BUTTON_FUNCTION_LAST); | ||
1193 | 59 | } | ||
1194 | 60 | |||
1195 | 61 | TEST_F (GtkWindowDecoratorTestLocalMenuLayout, TestForceNoCloseMinimizeMaximizeButtonSet) | ||
1196 | 62 | { | ||
1197 | 63 | getLayout ()->left_buttons[0] = META_BUTTON_FUNCTION_CLOSE; | ||
1198 | 64 | getLayout ()->left_buttons[1] = META_BUTTON_FUNCTION_CLOSE; | ||
1199 | 65 | getLayout ()->left_buttons[2] = META_BUTTON_FUNCTION_CLOSE; | ||
1200 | 66 | |||
1201 | 67 | force_local_menus_on (getWindow (), getLayout ()); | ||
1202 | 68 | |||
1203 | 69 | EXPECT_EQ (getLayout ()->right_buttons[0], META_BUTTON_FUNCTION_LAST); | ||
1204 | 70 | EXPECT_EQ (getLayout ()->left_buttons[3], META_BUTTON_FUNCTION_WINDOW_MENU); | ||
1205 | 71 | } | ||
1206 | 72 | #else | ||
1207 | 73 | TEST_F (GtkWindowDecoratorTestLocalMenu, NoMenus) | ||
1208 | 74 | { | ||
1209 | 75 | ASSERT_TRUE (true) << "Local menus tests not enabled because META_HAS_LOCAL_MENUS is off"; | ||
1210 | 76 | } | ||
1211 | 77 | #endif | ||
1212 | 0 | 78 | ||
1213 | === added directory 'gtk/window-decorator/local-menus/tests/show_hide_menu' | |||
1214 | === added file 'gtk/window-decorator/local-menus/tests/test-local-menu.h' | |||
1215 | --- gtk/window-decorator/local-menus/tests/test-local-menu.h 1970-01-01 00:00:00 +0000 | |||
1216 | +++ gtk/window-decorator/local-menus/tests/test-local-menu.h 2012-02-25 05:11:17 +0000 | |||
1217 | @@ -0,0 +1,49 @@ | |||
1218 | 1 | #include <gtest/gtest.h> | ||
1219 | 2 | #include <gmock/gmock.h> | ||
1220 | 3 | #include "local-menus.h" | ||
1221 | 4 | #include <X11/Xlib.h> | ||
1222 | 5 | #include <gio/gio.h> | ||
1223 | 6 | |||
1224 | 7 | class GtkWindowDecoratorTestLocalMenu : | ||
1225 | 8 | public ::testing::Test | ||
1226 | 9 | { | ||
1227 | 10 | public: | ||
1228 | 11 | |||
1229 | 12 | #ifdef META_HAS_LOCAL_MENUS | ||
1230 | 13 | WnckWindow * getWindow () { return mWindow; } | ||
1231 | 14 | GSettings * getSettings () { return mSettings; } | ||
1232 | 15 | virtual void SetUp () | ||
1233 | 16 | { | ||
1234 | 17 | gtk_init (NULL, NULL); | ||
1235 | 18 | |||
1236 | 19 | mXDisplay = XOpenDisplay (NULL); | ||
1237 | 20 | mXWindow = XCreateSimpleWindow (mXDisplay, DefaultRootWindow (mXDisplay), 0, 0, 100, 100, 0, 0, 0); | ||
1238 | 21 | |||
1239 | 22 | XMapRaised (mXDisplay, mXWindow); | ||
1240 | 23 | |||
1241 | 24 | XFlush (mXDisplay); | ||
1242 | 25 | |||
1243 | 26 | while (g_main_context_iteration (g_main_context_default (), FALSE)); | ||
1244 | 27 | |||
1245 | 28 | mWindow = wnck_window_get (mXWindow); | ||
1246 | 29 | |||
1247 | 30 | g_setenv("GSETTINGS_BACKEND", "memory", true); | ||
1248 | 31 | mSettings = g_settings_new ("com.canonical.indicator.appmenu"); | ||
1249 | 32 | } | ||
1250 | 33 | |||
1251 | 34 | virtual void TearDown () | ||
1252 | 35 | { | ||
1253 | 36 | XDestroyWindow (mXDisplay, mXWindow); | ||
1254 | 37 | XCloseDisplay (mXDisplay); | ||
1255 | 38 | |||
1256 | 39 | g_object_unref (mSettings); | ||
1257 | 40 | } | ||
1258 | 41 | #endif | ||
1259 | 42 | |||
1260 | 43 | private: | ||
1261 | 44 | |||
1262 | 45 | WnckWindow *mWindow; | ||
1263 | 46 | Window mXWindow; | ||
1264 | 47 | Display *mXDisplay; | ||
1265 | 48 | GSettings *mSettings; | ||
1266 | 49 | }; | ||
1267 | 0 | 50 | ||
1268 | === modified file 'gtk/window-decorator/metacity.c' | |||
1269 | --- gtk/window-decorator/metacity.c 2012-02-16 06:51:37 +0000 | |||
1270 | +++ gtk/window-decorator/metacity.c 2012-02-25 05:11:17 +0000 | |||
1271 | @@ -24,6 +24,7 @@ | |||
1272 | 24 | */ | 24 | */ |
1273 | 25 | 25 | ||
1274 | 26 | #include "gtk-window-decorator.h" | 26 | #include "gtk-window-decorator.h" |
1275 | 27 | #include "local-menus.h" | ||
1276 | 27 | 28 | ||
1277 | 28 | #ifdef USE_METACITY | 29 | #ifdef USE_METACITY |
1278 | 29 | 30 | ||
1279 | @@ -488,6 +489,8 @@ | |||
1280 | 488 | button_layout->right_buttons[i] = META_BUTTON_FUNCTION_LAST; | 489 | button_layout->right_buttons[i] = META_BUTTON_FUNCTION_LAST; |
1281 | 489 | } | 490 | } |
1282 | 490 | 491 | ||
1283 | 492 | force_local_menus_on (d->win, button_layout); | ||
1284 | 493 | |||
1285 | 491 | *flags = 0; | 494 | *flags = 0; |
1286 | 492 | 495 | ||
1287 | 493 | if (d->actions & WNCK_WINDOW_ACTION_CLOSE) | 496 | if (d->actions & WNCK_WINDOW_ACTION_CLOSE) |
1288 | @@ -538,6 +541,12 @@ | |||
1289 | 538 | *flags |= (MetaFrameFlags ) META_FRAME_ABOVE; | 541 | *flags |= (MetaFrameFlags ) META_FRAME_ABOVE; |
1290 | 539 | #endif | 542 | #endif |
1291 | 540 | 543 | ||
1292 | 544 | #ifdef META_HAS_LOCAL_MENUS | ||
1293 | 545 | if (d->win && | ||
1294 | 546 | local_menu_allowed_on_window (gdk_x11_display_get_xdisplay (gdk_display_get_default ()), wnck_window_get_xid (d->win))) | ||
1295 | 547 | *flags |= (MetaFrameFlags ) META_FRAME_ALLOWS_WINDOW_MENU; | ||
1296 | 548 | #endif | ||
1297 | 549 | |||
1298 | 541 | meta_theme_get_frame_borders (theme, | 550 | meta_theme_get_frame_borders (theme, |
1299 | 542 | frame_type, | 551 | frame_type, |
1300 | 543 | d->frame->text_height, | 552 | d->frame->text_height, |
1301 | @@ -558,6 +567,15 @@ | |||
1302 | 558 | else | 567 | else |
1303 | 559 | clip->height = d->border_layout.left.y2 - d->border_layout.left.y1; | 568 | clip->height = d->border_layout.left.y2 - d->border_layout.left.y1; |
1304 | 560 | 569 | ||
1305 | 570 | memset (fgeom, 0, sizeof (MetaFrameGeometry)); | ||
1306 | 571 | |||
1307 | 572 | #ifdef META_HAS_LOCAL_MENUS | ||
1308 | 573 | |||
1309 | 574 | if (d->layout) | ||
1310 | 575 | fgeom->text_layout = g_object_ref (d->layout); | ||
1311 | 576 | |||
1312 | 577 | #endif | ||
1313 | 578 | |||
1314 | 561 | meta_theme_calc_geometry (theme, | 579 | meta_theme_calc_geometry (theme, |
1315 | 562 | frame_type, | 580 | frame_type, |
1316 | 563 | d->frame->text_height, | 581 | d->frame->text_height, |
1317 | @@ -567,6 +585,15 @@ | |||
1318 | 567 | button_layout, | 585 | button_layout, |
1319 | 568 | fgeom); | 586 | fgeom); |
1320 | 569 | 587 | ||
1321 | 588 | #ifdef META_HAS_LOCAL_MENUS | ||
1322 | 589 | |||
1323 | 590 | if (d->layout) | ||
1324 | 591 | g_object_unref (fgeom->text_layout); | ||
1325 | 592 | |||
1326 | 593 | fgeom->text_layout = NULL; | ||
1327 | 594 | |||
1328 | 595 | #endif | ||
1329 | 596 | |||
1330 | 570 | clip->width += left_width + right_width; | 597 | clip->width += left_width + right_width; |
1331 | 571 | clip->height += top_height + bottom_height; | 598 | clip->height += top_height + bottom_height; |
1332 | 572 | } | 599 | } |
1333 | @@ -601,6 +628,11 @@ | |||
1334 | 601 | GdkColor bg_color; | 628 | GdkColor bg_color; |
1335 | 602 | double bg_alpha; | 629 | double bg_alpha; |
1336 | 603 | 630 | ||
1337 | 631 | memset (&button_layout, 0, sizeof (MetaButtonLayout)); | ||
1338 | 632 | |||
1339 | 633 | for (i = 0; i < MAX_BUTTONS_PER_CORNER; i++) | ||
1340 | 634 | button_layout.left_buttons[i] = button_layout.right_buttons[i] = META_BUTTON_FUNCTION_LAST; | ||
1341 | 635 | |||
1342 | 604 | if (!d->pixmap || !d->picture) | 636 | if (!d->pixmap || !d->picture) |
1343 | 605 | return; | 637 | return; |
1344 | 606 | 638 | ||
1345 | @@ -675,6 +707,9 @@ | |||
1346 | 675 | 707 | ||
1347 | 676 | size = MAX (fgeom.top_height, fgeom.bottom_height); | 708 | size = MAX (fgeom.top_height, fgeom.bottom_height); |
1348 | 677 | 709 | ||
1349 | 710 | if (active_menu) | ||
1350 | 711 | g_object_set_data (G_OBJECT (style_window), "local_menu_rect", &active_menu->rect); | ||
1351 | 712 | |||
1352 | 678 | if (rect.width && size) | 713 | if (rect.width && size) |
1353 | 679 | { | 714 | { |
1354 | 680 | XRenderPictFormat *format; | 715 | XRenderPictFormat *format; |
1355 | @@ -899,6 +934,9 @@ | |||
1356 | 899 | XRenderFreePicture (xdisplay, src); | 934 | XRenderFreePicture (xdisplay, src); |
1357 | 900 | } | 935 | } |
1358 | 901 | 936 | ||
1359 | 937 | if (active_menu) | ||
1360 | 938 | g_object_set_data (G_OBJECT (style_window), "local_menu_rect", NULL); | ||
1361 | 939 | |||
1362 | 902 | copy_to_front_buffer (d); | 940 | copy_to_front_buffer (d); |
1363 | 903 | 941 | ||
1364 | 904 | if (d->frame_window) | 942 | if (d->frame_window) |
1365 | @@ -1078,6 +1116,15 @@ | |||
1366 | 1078 | break; | 1116 | break; |
1367 | 1079 | #endif | 1117 | #endif |
1368 | 1080 | 1118 | ||
1369 | 1119 | #ifdef META_HAS_LOCAL_MENUS | ||
1370 | 1120 | case BUTTON_WINDOW_MENU: | ||
1371 | 1121 | if (!meta_button_present (&button_layout, META_BUTTON_FUNCTION_WINDOW_MENU)) | ||
1372 | 1122 | return FALSE; | ||
1373 | 1123 | |||
1374 | 1124 | space = &fgeom.window_menu_rect; | ||
1375 | 1125 | break; | ||
1376 | 1126 | #endif | ||
1377 | 1127 | |||
1378 | 1081 | default: | 1128 | default: |
1379 | 1082 | return FALSE; | 1129 | return FALSE; |
1380 | 1083 | } | 1130 | } |
1381 | @@ -1266,6 +1313,8 @@ | |||
1382 | 1266 | MetaTheme *theme; | 1313 | MetaTheme *theme; |
1383 | 1267 | GdkRectangle clip; | 1314 | GdkRectangle clip; |
1384 | 1268 | 1315 | ||
1385 | 1316 | memset (&fgeom, 0, sizeof (MetaFrameGeometry)); | ||
1386 | 1317 | |||
1387 | 1269 | theme = meta_theme_get_current (); | 1318 | theme = meta_theme_get_current (); |
1388 | 1270 | 1319 | ||
1389 | 1271 | meta_get_decoration_geometry (d, theme, &flags, &fgeom, &button_layout, | 1320 | meta_get_decoration_geometry (d, theme, &flags, &fgeom, &button_layout, |
1390 | @@ -1490,6 +1539,11 @@ | |||
1391 | 1490 | return META_BUTTON_FUNCTION_UNSTICK; | 1539 | return META_BUTTON_FUNCTION_UNSTICK; |
1392 | 1491 | #endif | 1540 | #endif |
1393 | 1492 | 1541 | ||
1394 | 1542 | #ifdef META_HAS_LOCAL_MENUS | ||
1395 | 1543 | else if (strcmp (str, "window_menu") == 0) | ||
1396 | 1544 | return META_BUTTON_FUNCTION_WINDOW_MENU; | ||
1397 | 1545 | #endif | ||
1398 | 1546 | |||
1399 | 1493 | else | 1547 | else |
1400 | 1494 | return META_BUTTON_FUNCTION_LAST; | 1548 | return META_BUTTON_FUNCTION_LAST; |
1401 | 1495 | } | 1549 | } |
1402 | 1496 | 1550 | ||
1403 | === modified file 'gtk/window-decorator/wnck.c' | |||
1404 | --- gtk/window-decorator/wnck.c 2012-02-10 10:23:27 +0000 | |||
1405 | +++ gtk/window-decorator/wnck.c 2012-02-25 05:11:17 +0000 | |||
1406 | @@ -24,6 +24,7 @@ | |||
1407 | 24 | */ | 24 | */ |
1408 | 25 | 25 | ||
1409 | 26 | #include "gtk-window-decorator.h" | 26 | #include "gtk-window-decorator.h" |
1410 | 27 | #include "local-menus.h" | ||
1411 | 27 | 28 | ||
1412 | 28 | const gchar * | 29 | const gchar * |
1413 | 29 | get_frame_type (WnckWindow *win) | 30 | get_frame_type (WnckWindow *win) |
1414 | @@ -738,7 +739,8 @@ | |||
1415 | 738 | stick_button_event, | 739 | stick_button_event, |
1416 | 739 | unshade_button_event, | 740 | unshade_button_event, |
1417 | 740 | unabove_button_event, | 741 | unabove_button_event, |
1419 | 741 | unstick_button_event | 742 | unstick_button_event, |
1420 | 743 | window_menu_button_event | ||
1421 | 742 | }; | 744 | }; |
1422 | 743 | 745 | ||
1423 | 744 | d = calloc (1, sizeof (decor_t)); | 746 | d = calloc (1, sizeof (decor_t)); |
1424 | @@ -784,6 +786,8 @@ | |||
1425 | 784 | window_closed (WnckScreen *screen, | 786 | window_closed (WnckScreen *screen, |
1426 | 785 | WnckWindow *win) | 787 | WnckWindow *win) |
1427 | 786 | { | 788 | { |
1428 | 789 | local_menu_cache_notify_window_destroyed (wnck_window_get_xid (win)); | ||
1429 | 790 | |||
1430 | 787 | decor_t *d = g_object_get_data (G_OBJECT (win), "decor"); | 791 | decor_t *d = g_object_get_data (G_OBJECT (win), "decor"); |
1431 | 788 | 792 | ||
1432 | 789 | if (d) | 793 | if (d) |
8 +#define GWD_SHOW_LOCAL_MENU (WNCK_WINDOW_ ACTION_ BELOW << 1)
No plausible reason for using a macro. In C++ constants (enum or unsigned int) are better as they respect scope rules. Also, should this be inside "#ifdef META_HAS_ LOCAL_MENUS" conditional?
296 button_ layout- >right_ buttons[ 2] = META_BUTTON_ FUNCTION_ CLOSE; PER_CORNER; i++) PER_CORNER; i++) layout- >right_ buttons[ i] = META_BUTTON_ FUNCTION_ LAST;
297
298 - for (i = 3; i < MAX_BUTTONS_
299 + for (i = 4; i < MAX_BUTTONS_
300 button_
301 }
I'm not sure what the magic number "3"->"4" is. But we now seem to miss 3 entirely. Is that correct?