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: |
1152 lines (+873/-11) 15 files modified
gtk/window-decorator/CMakeLists.txt (+6/-0) gtk/window-decorator/decorator.c (+32/-6) gtk/window-decorator/events.c (+109/-3) gtk/window-decorator/gtk-window-decorator.h (+7/-1) gtk/window-decorator/local-menus/CMakeLists.txt (+60/-0) gtk/window-decorator/local-menus/src/local-menus.c (+331/-0) gtk/window-decorator/local-menus/src/local-menus.h (+95/-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 (+20/-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 (+70/-0) gtk/window-decorator/local-menus/tests/test-local-menu.h (+48/-0) gtk/window-decorator/metacity.c (+48/-0) gtk/window-decorator/wnck.c (+2/-1) |
To merge this branch: | bzr merge lp:~smspillaz/compiz-core/compiz-core.lim |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Daniel van Vugt | Needs Fixing | ||
Alan Griffiths | Pending | ||
Review via email: mp+93949@code.launchpad.net |
This proposal supersedes a proposal from 2012-02-06.
This proposal has been superseded by a proposal from 2012-02-22.
Commit message
Description of the change
Adds support for Ubuntu's "locally integrated menu bars" into gtk-window-
No tests as of yet, but I'll try and write some for
showing/hiding
forcing them on/off
positions etc
soonish.
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 : | # |
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
- 2996. By Sam Spilsbury
-
Also ifdef the local menus tests
- 2997. By Sam Spilsbury
-
Don't run global setup or teardown functions if no local menus
- 2998. By Sam Spilsbury
-
Merge lp:compiz-core and allow alt-accelerator to open menus as well as reading the xprop
to determine if local menus are applicable - 2999. By Sam Spilsbury
-
Fix memory error and menu button not showing
- 3000. By Sam Spilsbury
-
Fix placement of menus on alt-accelerator, remove debug messages
- 3001. By Sam Spilsbury
-
Fix build failure without META_HAS_
LOCAL_MENUS - 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-21 10:38:22 +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-21 10:38:22 +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-21 10:38:22 +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,73 @@ | |||
176 | 380 | } | 409 | } |
177 | 381 | 410 | ||
178 | 382 | void | 411 | void |
179 | 412 | on_local_menu_hidden (gpointer user_data) | ||
180 | 413 | { | ||
181 | 414 | decor_t *d = (decor_t *) user_data; | ||
182 | 415 | |||
183 | 416 | d->button_states[BUTTON_WINDOW_MENU] &= ~PRESSED_EVENT_WINDOW; | ||
184 | 417 | |||
185 | 418 | queue_decor_draw (d); | ||
186 | 419 | } | ||
187 | 420 | |||
188 | 421 | void | ||
189 | 422 | window_menu_button_event (WnckWindow *win, | ||
190 | 423 | decor_event *gtkwd_event, | ||
191 | 424 | decor_event_type gtkwd_type) | ||
192 | 425 | { | ||
193 | 426 | decor_t *d = g_object_get_data (G_OBJECT (win), "decor"); | ||
194 | 427 | guint state = d->button_states[BUTTON_WINDOW_MENU]; | ||
195 | 428 | |||
196 | 429 | common_button_event (win, gtkwd_event, gtkwd_type, | ||
197 | 430 | BUTTON_WINDOW_MENU, 1, _("Window Menu")); | ||
198 | 431 | |||
199 | 432 | switch (gtkwd_type) { | ||
200 | 433 | case GButtonPress: | ||
201 | 434 | if (gtkwd_event->button == 1) | ||
202 | 435 | { | ||
203 | 436 | if (d->button_states[BUTTON_WINDOW_MENU] & BUTTON_EVENT_ACTION_STATE) | ||
204 | 437 | { | ||
205 | 438 | delayed_move_info *info = g_new0 (delayed_move_info, 1); | ||
206 | 439 | |||
207 | 440 | info->button = gtkwd_event->button; | ||
208 | 441 | info->time = gtkwd_event->time; | ||
209 | 442 | info->win = win; | ||
210 | 443 | info->x_root = gtkwd_event->x_root; | ||
211 | 444 | info->y_root = gtkwd_event->y_root; | ||
212 | 445 | |||
213 | 446 | gwd_prepare_show_local_menu ((start_move_window_cb) move_resize_window_on_timeout, (gpointer) info); | ||
214 | 447 | } | ||
215 | 448 | } | ||
216 | 449 | break; | ||
217 | 450 | case GButtonRelease: | ||
218 | 451 | if (gtkwd_event->button == 1) | ||
219 | 452 | if (state) | ||
220 | 453 | { | ||
221 | 454 | int win_x, win_y; | ||
222 | 455 | int box_x = d->button_windows[BUTTON_WINDOW_MENU].pos.x1; | ||
223 | 456 | |||
224 | 457 | wnck_window_get_geometry (win, &win_x, &win_y, NULL, NULL); | ||
225 | 458 | |||
226 | 459 | int x = win_x + box_x; | ||
227 | 460 | int y = win_y + d->context->extents.top; | ||
228 | 461 | |||
229 | 462 | gwd_show_local_menu (gdk_x11_display_get_xdisplay (gdk_display_get_default ()), | ||
230 | 463 | wnck_window_get_xid (win), | ||
231 | 464 | x, y, | ||
232 | 465 | box_x, | ||
233 | 466 | d->context->extents.top, | ||
234 | 467 | gtkwd_event->button, | ||
235 | 468 | gtkwd_event->time, | ||
236 | 469 | (show_window_menu_hidden_cb) on_local_menu_hidden, | ||
237 | 470 | (gpointer) d); | ||
238 | 471 | } | ||
239 | 472 | break; | ||
240 | 473 | default: | ||
241 | 474 | break; | ||
242 | 475 | } | ||
243 | 476 | } | ||
244 | 477 | |||
245 | 478 | void | ||
246 | 383 | handle_title_button_event (WnckWindow *win, | 479 | handle_title_button_event (WnckWindow *win, |
247 | 384 | int action, | 480 | int action, |
248 | 385 | decor_event *gtkwd_event) | 481 | decor_event *gtkwd_event) |
249 | @@ -485,7 +581,17 @@ | |||
250 | 485 | 581 | ||
251 | 486 | restack_window (win, Above); | 582 | restack_window (win, Above); |
252 | 487 | 583 | ||
254 | 488 | move_resize_window (win, WM_MOVERESIZE_MOVE, gtkwd_event); | 584 | delayed_move_info *info = g_new0 (delayed_move_info, 1); |
255 | 585 | |||
256 | 586 | info->x_root = gtkwd_event->x_root; | ||
257 | 587 | info->y_root = gtkwd_event->y_root; | ||
258 | 588 | info->button = gtkwd_event->button; | ||
259 | 589 | info->time = gtkwd_event->time; | ||
260 | 590 | info->win = win; | ||
261 | 591 | |||
262 | 592 | move_resize_window_on_timeout ((gpointer) info); | ||
263 | 593 | |||
264 | 594 | g_free (info); | ||
265 | 489 | } | 595 | } |
266 | 490 | } | 596 | } |
267 | 491 | else if (gtkwd_event->button == 2) | 597 | else if (gtkwd_event->button == 2) |
268 | 492 | 598 | ||
269 | === modified file 'gtk/window-decorator/gtk-window-decorator.h' | |||
270 | --- gtk/window-decorator/gtk-window-decorator.h 2011-10-13 12:22:14 +0000 | |||
271 | +++ gtk/window-decorator/gtk-window-decorator.h 2012-02-21 10:38:22 +0000 | |||
272 | @@ -328,7 +328,8 @@ | |||
273 | 328 | #define BUTTON_UNSHADE 7 | 328 | #define BUTTON_UNSHADE 7 |
274 | 329 | #define BUTTON_UNABOVE 8 | 329 | #define BUTTON_UNABOVE 8 |
275 | 330 | #define BUTTON_UNSTICK 9 | 330 | #define BUTTON_UNSTICK 9 |
277 | 331 | #define BUTTON_NUM 10 | 331 | #define BUTTON_WINDOW_MENU 10 |
278 | 332 | #define BUTTON_NUM 11 | ||
279 | 332 | 333 | ||
280 | 333 | struct _pos { | 334 | struct _pos { |
281 | 334 | int x, y, w, h; | 335 | int x, y, w, h; |
282 | @@ -1013,6 +1014,11 @@ | |||
283 | 1013 | decor_event_type gtkwd_type); | 1014 | decor_event_type gtkwd_type); |
284 | 1014 | 1015 | ||
285 | 1015 | void | 1016 | void |
286 | 1017 | window_menu_button_event (WnckWindow *win, | ||
287 | 1018 | decor_event *gtkwd_event, | ||
288 | 1019 | decor_event_type gtkwd_type); | ||
289 | 1020 | |||
290 | 1021 | void | ||
291 | 1016 | handle_title_button_event (WnckWindow *win, | 1022 | handle_title_button_event (WnckWindow *win, |
292 | 1017 | int action, | 1023 | int action, |
293 | 1018 | decor_event *gtkwd_event); | 1024 | decor_event *gtkwd_event); |
294 | 1019 | 1025 | ||
295 | === added directory 'gtk/window-decorator/local-menus' | |||
296 | === added file 'gtk/window-decorator/local-menus/CMakeLists.txt' | |||
297 | --- gtk/window-decorator/local-menus/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
298 | +++ gtk/window-decorator/local-menus/CMakeLists.txt 2012-02-21 10:38:22 +0000 | |||
299 | @@ -0,0 +1,60 @@ | |||
300 | 1 | pkg_check_modules( | ||
301 | 2 | LOCAL_MENUS | ||
302 | 3 | REQUIRED | ||
303 | 4 | glib-2.0 gio-2.0 libwnck-1.0 gtk+-2.0>=2.18.0 | ||
304 | 5 | ) | ||
305 | 6 | |||
306 | 7 | INCLUDE_DIRECTORIES( | ||
307 | 8 | ${CMAKE_CURRENT_SOURCE_DIR}/include | ||
308 | 9 | ${CMAKE_CURRENT_SOURCE_DIR}/src | ||
309 | 10 | |||
310 | 11 | ${compiz_SOURCE_DIR}/gtk/window-decorator | ||
311 | 12 | |||
312 | 13 | ${Boost_INCLUDE_DIRS} | ||
313 | 14 | |||
314 | 15 | ${LOCAL_MENUS_INCLUDE_DIRS} | ||
315 | 16 | ${METACITY_INCLUDE_DIRS} | ||
316 | 17 | ) | ||
317 | 18 | |||
318 | 19 | LINK_DIRECTORIES (${LOCAL_MENUS_LIBRARY_DIRS}) | ||
319 | 20 | |||
320 | 21 | SET( | ||
321 | 22 | PUBLIC_HEADERS | ||
322 | 23 | ) | ||
323 | 24 | |||
324 | 25 | SET( | ||
325 | 26 | PRIVATE_HEADERS | ||
326 | 27 | ${CMAKE_CURRENT_SOURCE_DIR}/src/local-menus.h | ||
327 | 28 | ) | ||
328 | 29 | |||
329 | 30 | SET( | ||
330 | 31 | SRCS | ||
331 | 32 | ${CMAKE_CURRENT_SOURCE_DIR}/src/local-menus.c | ||
332 | 33 | ) | ||
333 | 34 | |||
334 | 35 | ADD_LIBRARY( | ||
335 | 36 | gtk_window_decorator_local_menus STATIC | ||
336 | 37 | |||
337 | 38 | ${SRCS} | ||
338 | 39 | |||
339 | 40 | ${PUBLIC_HEADERS} | ||
340 | 41 | ${PRIVATE_HEADERS} | ||
341 | 42 | ) | ||
342 | 43 | |||
343 | 44 | IF (COMPIZ_BUILD_TESTING) | ||
344 | 45 | ADD_SUBDIRECTORY( ${CMAKE_CURRENT_SOURCE_DIR}/tests ) | ||
345 | 46 | ENDIF (COMPIZ_BUILD_TESTING) | ||
346 | 47 | |||
347 | 48 | SET_TARGET_PROPERTIES( | ||
348 | 49 | gtk_window_decorator_local_menus PROPERTIES | ||
349 | 50 | PUBLIC_HEADER "${PUBLIC_HEADERS}" | ||
350 | 51 | ) | ||
351 | 52 | |||
352 | 53 | install (FILES ${PUBLIC_HEADERS} DESTINATION ${COMPIZ_CORE_INCLUDE_DIR}) | ||
353 | 54 | |||
354 | 55 | TARGET_LINK_LIBRARIES( | ||
355 | 56 | gtk_window_decorator_local_menus | ||
356 | 57 | |||
357 | 58 | ${LOCAL_MENUS_LIBRARIES} | ||
358 | 59 | ) | ||
359 | 60 | |||
360 | 0 | 61 | ||
361 | === added directory 'gtk/window-decorator/local-menus/include' | |||
362 | === added directory 'gtk/window-decorator/local-menus/src' | |||
363 | === added file 'gtk/window-decorator/local-menus/src/local-menus.c' | |||
364 | --- gtk/window-decorator/local-menus/src/local-menus.c 1970-01-01 00:00:00 +0000 | |||
365 | +++ gtk/window-decorator/local-menus/src/local-menus.c 2012-02-21 10:38:22 +0000 | |||
366 | @@ -0,0 +1,331 @@ | |||
367 | 1 | /* | ||
368 | 2 | * Copyright © 2006 Novell, Inc. | ||
369 | 3 | * | ||
370 | 4 | * This library is free software; you can redistribute it and/or | ||
371 | 5 | * modify it under the terms of the GNU Lesser General Public | ||
372 | 6 | * License as published by the Free Software Foundation; either | ||
373 | 7 | * version 2 of the License, or (at your option) any later version. | ||
374 | 8 | * | ||
375 | 9 | * This library is distributed in the hope that it will be useful, | ||
376 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
377 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
378 | 12 | * Lesser General Public License for more details. | ||
379 | 13 | * | ||
380 | 14 | * You should have received a copy of the GNU Lesser General Public | ||
381 | 15 | * License along with this library; if not, write to the | ||
382 | 16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
383 | 17 | * Boston, MA 02111-1307, USA. | ||
384 | 18 | * | ||
385 | 19 | * Author: David Reveman <davidr@novell.com> | ||
386 | 20 | * | ||
387 | 21 | * 2D Mode: Copyright © 2010 Sam Spilsbury <smspillaz@gmail.com> | ||
388 | 22 | * Frames Management: Copright © 2011 Canonical Ltd. | ||
389 | 23 | * Authored By: Sam Spilsbury <sam.spilsbury@canonical.com> | ||
390 | 24 | */ | ||
391 | 25 | |||
392 | 26 | #include <string.h> | ||
393 | 27 | #include "local-menus.h" | ||
394 | 28 | #include <gdk/gdk.h> | ||
395 | 29 | #include <gdk/gdkx.h> | ||
396 | 30 | |||
397 | 31 | #define GLOBAL 0 | ||
398 | 32 | #define LOCAL 1 | ||
399 | 33 | |||
400 | 34 | gint menu_mode = GLOBAL; | ||
401 | 35 | |||
402 | 36 | #ifdef META_HAS_LOCAL_MENUS | ||
403 | 37 | static void | ||
404 | 38 | gwd_menu_mode_changed (GSettings *settings, | ||
405 | 39 | gchar *key, | ||
406 | 40 | gpointer user_data) | ||
407 | 41 | { | ||
408 | 42 | menu_mode = g_settings_get_enum (settings, "menu-mode"); | ||
409 | 43 | } | ||
410 | 44 | #endif | ||
411 | 45 | |||
412 | 46 | active_local_menu *active_menu; | ||
413 | 47 | pending_local_menu *pending_menu; | ||
414 | 48 | |||
415 | 49 | gboolean | ||
416 | 50 | gwd_window_should_have_local_menu (WnckWindow *win) | ||
417 | 51 | { | ||
418 | 52 | #ifdef META_HAS_LOCAL_MENUS | ||
419 | 53 | const gchar * const *schemas = g_settings_list_schemas (); | ||
420 | 54 | static GSettings *lim_settings = NULL; | ||
421 | 55 | while (*schemas != NULL && !lim_settings) | ||
422 | 56 | { | ||
423 | 57 | if (g_str_equal (*schemas, "com.canonical.indicator.appmenu")) | ||
424 | 58 | { | ||
425 | 59 | lim_settings = g_settings_new ("com.canonical.indicator.appmenu"); | ||
426 | 60 | menu_mode = g_settings_get_enum (lim_settings, "menu-mode"); | ||
427 | 61 | g_signal_connect (lim_settings, "changed::menu-mode", G_CALLBACK (gwd_menu_mode_changed), NULL); | ||
428 | 62 | break; | ||
429 | 63 | } | ||
430 | 64 | ++schemas; | ||
431 | 65 | } | ||
432 | 66 | |||
433 | 67 | if (lim_settings) | ||
434 | 68 | return menu_mode == LOCAL; | ||
435 | 69 | #endif | ||
436 | 70 | |||
437 | 71 | return FALSE; | ||
438 | 72 | } | ||
439 | 73 | |||
440 | 74 | gchar * | ||
441 | 75 | gwd_get_entry_id_from_sync_variant (GVariant *args) | ||
442 | 76 | { | ||
443 | 77 | /* We need to get the indicator data once we've called show */ | ||
444 | 78 | |||
445 | 79 | GVariantIter* iter = NULL; | ||
446 | 80 | gchar* name_hint = NULL; | ||
447 | 81 | gchar* indicator_id = NULL; | ||
448 | 82 | gchar* entry_id = NULL; | ||
449 | 83 | gchar* label = NULL; | ||
450 | 84 | gboolean label_sensitive = FALSE; | ||
451 | 85 | gboolean label_visible = FALSE; | ||
452 | 86 | guint32 image_type = 0; | ||
453 | 87 | gchar* image_data = NULL; | ||
454 | 88 | gboolean image_sensitive = FALSE; | ||
455 | 89 | gboolean image_visible = FALSE; | ||
456 | 90 | gint32 priority = -1; | ||
457 | 91 | |||
458 | 92 | g_variant_get (args, "(a(ssssbbusbbi))", &iter); | ||
459 | 93 | while (g_variant_iter_loop (iter, "(ssssbbusbbi)", | ||
460 | 94 | &indicator_id, | ||
461 | 95 | &entry_id, | ||
462 | 96 | &name_hint, | ||
463 | 97 | &label, | ||
464 | 98 | &label_sensitive, | ||
465 | 99 | &label_visible, | ||
466 | 100 | &image_type, | ||
467 | 101 | &image_data, | ||
468 | 102 | &image_sensitive, | ||
469 | 103 | &image_visible, | ||
470 | 104 | &priority)) | ||
471 | 105 | { | ||
472 | 106 | g_variant_unref (args); | ||
473 | 107 | return g_strdup (entry_id); | ||
474 | 108 | } | ||
475 | 109 | |||
476 | 110 | g_variant_unref (args); | ||
477 | 111 | g_assert_not_reached (); | ||
478 | 112 | return NULL; | ||
479 | 113 | } | ||
480 | 114 | #ifdef META_HAS_LOCAL_MENUS | ||
481 | 115 | static void | ||
482 | 116 | on_local_menu_activated (GDBusProxy *proxy, | ||
483 | 117 | gchar *sender_name, | ||
484 | 118 | gchar *signal_name, | ||
485 | 119 | GVariant *parameters, | ||
486 | 120 | gpointer user_data) | ||
487 | 121 | { | ||
488 | 122 | |||
489 | 123 | if (g_strcmp0 (signal_name, "EntryActivated") == 0) | ||
490 | 124 | { | ||
491 | 125 | show_local_menu_data *d = (show_local_menu_data *) user_data; | ||
492 | 126 | gchar *entry_id = NULL; | ||
493 | 127 | gint x_out, y_out; | ||
494 | 128 | guint width, height; | ||
495 | 129 | |||
496 | 130 | g_variant_get (parameters, "(s(iiuu))", &entry_id, &x_out, &y_out, &width, &height, NULL); | ||
497 | 131 | |||
498 | 132 | if (!d->local_menu_entry_id) | ||
499 | 133 | { | ||
500 | 134 | GError *error = NULL; | ||
501 | 135 | GVariant *params = g_variant_new ("(s)", "libappmenu.so", NULL); | ||
502 | 136 | GVariant *args = g_dbus_proxy_call_sync (proxy, "SyncOne", params, 0, 500, NULL, &error); | ||
503 | 137 | |||
504 | 138 | g_assert_no_error (error); | ||
505 | 139 | d->local_menu_entry_id = gwd_get_entry_id_from_sync_variant (args); | ||
506 | 140 | } | ||
507 | 141 | |||
508 | 142 | if (g_strcmp0 (entry_id, d->local_menu_entry_id) == 0) | ||
509 | 143 | { | ||
510 | 144 | d->rect->x = x_out - d->dx; | ||
511 | 145 | d->rect->y = y_out - d->dy; | ||
512 | 146 | d->rect->width = width; | ||
513 | 147 | d->rect->height = height; | ||
514 | 148 | } | ||
515 | 149 | else if (g_strcmp0 (entry_id, "") == 0) | ||
516 | 150 | { | ||
517 | 151 | memset (d->rect, 0, sizeof (GdkRectangle)); | ||
518 | 152 | (*d->cb) (d->user_data); | ||
519 | 153 | |||
520 | 154 | g_signal_handlers_disconnect_by_func (d->proxy, on_local_menu_activated, d); | ||
521 | 155 | |||
522 | 156 | g_object_unref (d->proxy); | ||
523 | 157 | g_object_unref (d->conn); | ||
524 | 158 | |||
525 | 159 | if (active_menu) | ||
526 | 160 | { | ||
527 | 161 | g_free (active_menu); | ||
528 | 162 | active_menu = NULL; | ||
529 | 163 | } | ||
530 | 164 | |||
531 | 165 | g_free (d->local_menu_entry_id); | ||
532 | 166 | g_free (d); | ||
533 | 167 | } | ||
534 | 168 | } | ||
535 | 169 | |||
536 | 170 | } | ||
537 | 171 | #endif | ||
538 | 172 | gboolean | ||
539 | 173 | gwd_move_window_instead (gpointer user_data) | ||
540 | 174 | { | ||
541 | 175 | (*pending_menu->cb) (pending_menu->user_data); | ||
542 | 176 | g_free (pending_menu->user_data); | ||
543 | 177 | g_free (pending_menu); | ||
544 | 178 | pending_menu = NULL; | ||
545 | 179 | return FALSE; | ||
546 | 180 | } | ||
547 | 181 | |||
548 | 182 | void | ||
549 | 183 | gwd_prepare_show_local_menu (start_move_window_cb start_move_window, | ||
550 | 184 | gpointer user_data_start_move_window) | ||
551 | 185 | { | ||
552 | 186 | if (pending_menu) | ||
553 | 187 | { | ||
554 | 188 | g_source_remove (pending_menu->move_timeout_id); | ||
555 | 189 | g_free (pending_menu->user_data); | ||
556 | 190 | g_free (pending_menu); | ||
557 | 191 | pending_menu = NULL; | ||
558 | 192 | } | ||
559 | 193 | |||
560 | 194 | pending_menu = g_new0 (pending_local_menu, 1); | ||
561 | 195 | pending_menu->cb = start_move_window; | ||
562 | 196 | pending_menu->user_data = user_data_start_move_window; | ||
563 | 197 | pending_menu->move_timeout_id = g_timeout_add (120, gwd_move_window_instead, pending_menu); | ||
564 | 198 | } | ||
565 | 199 | |||
566 | 200 | void | ||
567 | 201 | gwd_show_local_menu (Display *xdisplay, | ||
568 | 202 | Window frame_xwindow, | ||
569 | 203 | int x, | ||
570 | 204 | int y, | ||
571 | 205 | int x_win, | ||
572 | 206 | int y_win, | ||
573 | 207 | int button, | ||
574 | 208 | guint32 timestamp, | ||
575 | 209 | show_window_menu_hidden_cb cb, | ||
576 | 210 | gpointer user_data_show_window_menu) | ||
577 | 211 | { | ||
578 | 212 | if (pending_menu) | ||
579 | 213 | { | ||
580 | 214 | g_source_remove (pending_menu->move_timeout_id); | ||
581 | 215 | g_free (pending_menu->user_data); | ||
582 | 216 | g_free (pending_menu); | ||
583 | 217 | pending_menu = NULL; | ||
584 | 218 | } | ||
585 | 219 | |||
586 | 220 | #ifdef META_HAS_LOCAL_MENUS | ||
587 | 221 | GError *error = NULL; | ||
588 | 222 | GDBusConnection *conn = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error); | ||
589 | 223 | |||
590 | 224 | |||
591 | 225 | XUngrabPointer (gdk_x11_display_get_xdisplay (gdk_display_get_default ()), CurrentTime); | ||
592 | 226 | XUngrabKeyboard (gdk_x11_display_get_xdisplay (gdk_display_get_default ()), CurrentTime); | ||
593 | 227 | XSync (gdk_x11_display_get_xdisplay (gdk_display_get_default ()), FALSE); | ||
594 | 228 | |||
595 | 229 | if (!conn) | ||
596 | 230 | { | ||
597 | 231 | g_print ("error getting connection: %s\n", error->message); | ||
598 | 232 | return; | ||
599 | 233 | } | ||
600 | 234 | |||
601 | 235 | GDBusProxy *proxy = g_dbus_proxy_new_sync (conn, 0, NULL, "com.canonical.Unity.Panel.Service", | ||
602 | 236 | "/com/canonical/Unity/Panel/Service", | ||
603 | 237 | "com.canonical.Unity.Panel.Service", | ||
604 | 238 | NULL, &error); | ||
605 | 239 | |||
606 | 240 | if (proxy) | ||
607 | 241 | { | ||
608 | 242 | GVariant *message = g_variant_new ("(uiiu)", frame_xwindow, x, y, time); | ||
609 | 243 | g_dbus_proxy_call_sync (proxy, "ShowAppMenu", message, 0, 500, NULL, &error); | ||
610 | 244 | if (error) | ||
611 | 245 | { | ||
612 | 246 | g_print ("error calling ShowAppMenu: %s\n", error->message); | ||
613 | 247 | g_object_unref (proxy); | ||
614 | 248 | g_object_unref (conn); | ||
615 | 249 | return; | ||
616 | 250 | } | ||
617 | 251 | |||
618 | 252 | show_local_menu_data *data = g_new0 (show_local_menu_data, 1); | ||
619 | 253 | |||
620 | 254 | if (active_menu) | ||
621 | 255 | g_free (active_menu); | ||
622 | 256 | |||
623 | 257 | active_menu = g_new0 (active_local_menu, 1); | ||
624 | 258 | |||
625 | 259 | data->conn = g_object_ref (conn); | ||
626 | 260 | data->proxy = g_object_ref (proxy); | ||
627 | 261 | data->cb = cb; | ||
628 | 262 | data->user_data = user_data_show_window_menu; | ||
629 | 263 | data->rect = &active_menu->rect; | ||
630 | 264 | data->dx = x - x_win; | ||
631 | 265 | data->dy = y - y_win; | ||
632 | 266 | data->local_menu_entry_id = NULL; | ||
633 | 267 | |||
634 | 268 | g_signal_connect (proxy, "g-signal", G_CALLBACK (on_local_menu_activated), data); | ||
635 | 269 | |||
636 | 270 | g_object_unref (conn); | ||
637 | 271 | g_object_unref (proxy); | ||
638 | 272 | |||
639 | 273 | return; | ||
640 | 274 | } | ||
641 | 275 | else | ||
642 | 276 | { | ||
643 | 277 | g_print ("error getting proxy: %s\n", error->message); | ||
644 | 278 | } | ||
645 | 279 | |||
646 | 280 | g_object_unref (conn); | ||
647 | 281 | #endif | ||
648 | 282 | } | ||
649 | 283 | |||
650 | 284 | void | ||
651 | 285 | force_local_menus_on (WnckWindow *win, | ||
652 | 286 | MetaButtonLayout *button_layout) | ||
653 | 287 | { | ||
654 | 288 | #ifdef META_HAS_LOCAL_MENUS | ||
655 | 289 | if (gwd_window_should_have_local_menu (win)) | ||
656 | 290 | { | ||
657 | 291 | if (button_layout->left_buttons[0] != META_BUTTON_FUNCTION_LAST) | ||
658 | 292 | { | ||
659 | 293 | unsigned int i = 0; | ||
660 | 294 | for (; i < MAX_BUTTONS_PER_CORNER; i++) | ||
661 | 295 | { | ||
662 | 296 | if (button_layout->left_buttons[i] == META_BUTTON_FUNCTION_WINDOW_MENU) | ||
663 | 297 | break; | ||
664 | 298 | else if (button_layout->left_buttons[i] == META_BUTTON_FUNCTION_LAST) | ||
665 | 299 | { | ||
666 | 300 | if ((i + 1) < MAX_BUTTONS_PER_CORNER) | ||
667 | 301 | { | ||
668 | 302 | button_layout->left_buttons[i + 1] = META_BUTTON_FUNCTION_LAST; | ||
669 | 303 | button_layout->left_buttons[i] = META_BUTTON_FUNCTION_WINDOW_MENU; | ||
670 | 304 | break; | ||
671 | 305 | } | ||
672 | 306 | } | ||
673 | 307 | } | ||
674 | 308 | } | ||
675 | 309 | if (button_layout->right_buttons[0] != META_BUTTON_FUNCTION_LAST) | ||
676 | 310 | { | ||
677 | 311 | unsigned int i = 0; | ||
678 | 312 | for (; i < MAX_BUTTONS_PER_CORNER; i++) | ||
679 | 313 | { | ||
680 | 314 | if (button_layout->right_buttons[i] == META_BUTTON_FUNCTION_WINDOW_MENU) | ||
681 | 315 | break; | ||
682 | 316 | else if (button_layout->right_buttons[i] == META_BUTTON_FUNCTION_LAST) | ||
683 | 317 | { | ||
684 | 318 | if ((i + 1) < MAX_BUTTONS_PER_CORNER) | ||
685 | 319 | { | ||
686 | 320 | button_layout->right_buttons[i + 1] = META_BUTTON_FUNCTION_LAST; | ||
687 | 321 | button_layout->right_buttons[i] = META_BUTTON_FUNCTION_WINDOW_MENU; | ||
688 | 322 | break; | ||
689 | 323 | } | ||
690 | 324 | } | ||
691 | 325 | } | ||
692 | 326 | } | ||
693 | 327 | } | ||
694 | 328 | #endif | ||
695 | 329 | } | ||
696 | 330 | |||
697 | 331 | |||
698 | 0 | 332 | ||
699 | === added file 'gtk/window-decorator/local-menus/src/local-menus.h' | |||
700 | --- gtk/window-decorator/local-menus/src/local-menus.h 1970-01-01 00:00:00 +0000 | |||
701 | +++ gtk/window-decorator/local-menus/src/local-menus.h 2012-02-21 10:38:22 +0000 | |||
702 | @@ -0,0 +1,95 @@ | |||
703 | 1 | /* | ||
704 | 2 | * Copyright © 2006 Novell, Inc. | ||
705 | 3 | * | ||
706 | 4 | * This library is free software; you can redistribute it and/or | ||
707 | 5 | * modify it under the terms of the GNU Lesser General Public | ||
708 | 6 | * License as published by the Free Software Foundation; either | ||
709 | 7 | * version 2 of the License, or (at your option) any later version. | ||
710 | 8 | * | ||
711 | 9 | * This library is distributed in the hope that it will be useful, | ||
712 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
713 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
714 | 12 | * Lesser General Public License for more details. | ||
715 | 13 | * | ||
716 | 14 | * You should have received a copy of the GNU Lesser General Public | ||
717 | 15 | * License along with this library; if not, write to the | ||
718 | 16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
719 | 17 | * Boston, MA 02111-1307, USA. | ||
720 | 18 | * | ||
721 | 19 | * Author: David Reveman <davidr@novell.com> | ||
722 | 20 | * | ||
723 | 21 | * 2D Mode: Copyright © 2010 Sam Spilsbury <smspillaz@gmail.com> | ||
724 | 22 | * Frames Management: Copright © 2011 Canonical Ltd. | ||
725 | 23 | * Authored By: Sam Spilsbury <sam.spilsbury@canonical.com> | ||
726 | 24 | */ | ||
727 | 25 | |||
728 | 26 | #ifdef __cplusplus | ||
729 | 27 | extern "C" | ||
730 | 28 | { | ||
731 | 29 | #endif | ||
732 | 30 | |||
733 | 31 | #include <glib.h> | ||
734 | 32 | #include <gio/gio.h> | ||
735 | 33 | #ifndef WNCK_I_KNOW_THIS_IS_UNSTABLE | ||
736 | 34 | #define WNCK_I_KNOW_THIS_IS_UNSTABLE | ||
737 | 35 | #endif | ||
738 | 36 | #include <libwnck/libwnck.h> | ||
739 | 37 | #include <libwnck/window-action-menu.h> | ||
740 | 38 | #include <metacity-private/theme.h> | ||
741 | 39 | |||
742 | 40 | typedef void (*show_window_menu_hidden_cb) (gpointer); | ||
743 | 41 | typedef void (*start_move_window_cb) (gpointer); | ||
744 | 42 | |||
745 | 43 | typedef struct _pending_local_menu | ||
746 | 44 | { | ||
747 | 45 | gint move_timeout_id; | ||
748 | 46 | gpointer user_data; | ||
749 | 47 | start_move_window_cb cb; | ||
750 | 48 | } pending_local_menu; | ||
751 | 49 | |||
752 | 50 | typedef struct _active_local_menu | ||
753 | 51 | { | ||
754 | 52 | GdkRectangle rect; | ||
755 | 53 | } active_local_menu; | ||
756 | 54 | |||
757 | 55 | extern active_local_menu *active_menu; | ||
758 | 56 | |||
759 | 57 | typedef struct _show_local_menu_data | ||
760 | 58 | { | ||
761 | 59 | GDBusConnection *conn; | ||
762 | 60 | GDBusProxy *proxy; | ||
763 | 61 | show_window_menu_hidden_cb cb; | ||
764 | 62 | gpointer user_data; | ||
765 | 63 | GdkRectangle *rect; | ||
766 | 64 | gint dx; | ||
767 | 65 | gint dy; | ||
768 | 66 | gchar *local_menu_entry_id; | ||
769 | 67 | } show_local_menu_data; | ||
770 | 68 | |||
771 | 69 | gboolean | ||
772 | 70 | gwd_window_should_have_local_menu (WnckWindow *win); | ||
773 | 71 | |||
774 | 72 | void | ||
775 | 73 | force_local_menus_on (WnckWindow *win, | ||
776 | 74 | MetaButtonLayout *layout); | ||
777 | 75 | |||
778 | 76 | /* Button Down */ | ||
779 | 77 | void | ||
780 | 78 | gwd_prepare_show_local_menu (start_move_window_cb start_move_window, | ||
781 | 79 | gpointer user_data_start_move_window); | ||
782 | 80 | |||
783 | 81 | /* Button Up */ | ||
784 | 82 | void | ||
785 | 83 | gwd_show_local_menu (Display *xdisplay, | ||
786 | 84 | Window frame_xwindow, | ||
787 | 85 | int x, | ||
788 | 86 | int y, | ||
789 | 87 | int x_win, | ||
790 | 88 | int y_win, | ||
791 | 89 | int button, | ||
792 | 90 | guint32 timestamp, | ||
793 | 91 | show_window_menu_hidden_cb cb, | ||
794 | 92 | gpointer user_data_show_window_menu); | ||
795 | 93 | #ifdef __cplusplus | ||
796 | 94 | } | ||
797 | 95 | #endif | ||
798 | 0 | 96 | ||
799 | === added directory 'gtk/window-decorator/local-menus/tests' | |||
800 | === added file 'gtk/window-decorator/local-menus/tests/CMakeLists.txt' | |||
801 | --- gtk/window-decorator/local-menus/tests/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
802 | +++ gtk/window-decorator/local-menus/tests/CMakeLists.txt 2012-02-21 10:38:22 +0000 | |||
803 | @@ -0,0 +1,3 @@ | |||
804 | 1 | include_directories (${CMAKE_CURRENT_SOURCE_DIR}) | ||
805 | 2 | add_subdirectory (check_local_menu_on_off) | ||
806 | 3 | add_subdirectory (force_local_menu_on) | ||
807 | 0 | 4 | ||
808 | === added directory 'gtk/window-decorator/local-menus/tests/check_local_menu_on_off' | |||
809 | === added file 'gtk/window-decorator/local-menus/tests/check_local_menu_on_off/CMakeLists.txt' | |||
810 | --- gtk/window-decorator/local-menus/tests/check_local_menu_on_off/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
811 | +++ gtk/window-decorator/local-menus/tests/check_local_menu_on_off/CMakeLists.txt 2012-02-21 10:38:22 +0000 | |||
812 | @@ -0,0 +1,21 @@ | |||
813 | 1 | include_directories (${CMAKE_CURRENT_SOURCE_DIR} | ||
814 | 2 | ${compiz_SOURCE_DIR}/gtk/window-decorator/local-menus/tests | ||
815 | 3 | ${compiz_SOURCE_DIR}/gtk/window-decorator | ||
816 | 4 | ${compiz_SOURCE_DIR}/gtk/window-decorator/local-menus/src) | ||
817 | 5 | |||
818 | 6 | add_executable( | ||
819 | 7 | gtk_window_decorator_check_local_menu_on_off_test | ||
820 | 8 | |||
821 | 9 | ${CMAKE_CURRENT_SOURCE_DIR}/test-local-menu-on-off.cpp | ||
822 | 10 | ) | ||
823 | 11 | |||
824 | 12 | target_link_libraries( | ||
825 | 13 | gtk_window_decorator_check_local_menu_on_off_test | ||
826 | 14 | |||
827 | 15 | gtk_window_decorator_local_menus | ||
828 | 16 | |||
829 | 17 | ${GTEST_BOTH_LIBRARIES} | ||
830 | 18 | ${CMAKE_THREAD_LIBS_INIT} # Link in pthread. | ||
831 | 19 | ) | ||
832 | 20 | |||
833 | 21 | add_test (gtk_window_decorator_local_menus_on_off gtk_window_decorator_check_local_menu_on_off_test) | ||
834 | 0 | 22 | ||
835 | === added directory 'gtk/window-decorator/local-menus/tests/check_local_menu_on_off/check_local_menu_on_off' | |||
836 | === added directory 'gtk/window-decorator/local-menus/tests/check_local_menu_on_off/check_local_menu_on_off/CMakeFiles' | |||
837 | === added file 'gtk/window-decorator/local-menus/tests/check_local_menu_on_off/test-local-menu-on-off.cpp' | |||
838 | --- gtk/window-decorator/local-menus/tests/check_local_menu_on_off/test-local-menu-on-off.cpp 1970-01-01 00:00:00 +0000 | |||
839 | +++ gtk/window-decorator/local-menus/tests/check_local_menu_on_off/test-local-menu-on-off.cpp 2012-02-21 10:38:22 +0000 | |||
840 | @@ -0,0 +1,20 @@ | |||
841 | 1 | #include "test-local-menu.h" | ||
842 | 2 | |||
843 | 3 | #define GLOBAL 0 | ||
844 | 4 | #define LOCAL 1 | ||
845 | 5 | |||
846 | 6 | TEST_F (GtkWindowDecoratorTestLocalMenu, TestOn) | ||
847 | 7 | { | ||
848 | 8 | g_settings_set_enum (getSettings (), "menu-mode", LOCAL); | ||
849 | 9 | gboolean result = gwd_window_should_have_local_menu (getWindow ()); | ||
850 | 10 | |||
851 | 11 | EXPECT_TRUE (result); | ||
852 | 12 | } | ||
853 | 13 | |||
854 | 14 | TEST_F (GtkWindowDecoratorTestLocalMenu, TestOff) | ||
855 | 15 | { | ||
856 | 16 | g_settings_set_enum (getSettings (), "menu-mode", GLOBAL); | ||
857 | 17 | gboolean result = gwd_window_should_have_local_menu (getWindow ()); | ||
858 | 18 | |||
859 | 19 | EXPECT_FALSE (result); | ||
860 | 20 | } | ||
861 | 0 | 21 | ||
862 | === added directory 'gtk/window-decorator/local-menus/tests/force_local_menu_on' | |||
863 | === added file 'gtk/window-decorator/local-menus/tests/force_local_menu_on/CMakeLists.txt' | |||
864 | --- gtk/window-decorator/local-menus/tests/force_local_menu_on/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
865 | +++ gtk/window-decorator/local-menus/tests/force_local_menu_on/CMakeLists.txt 2012-02-21 10:38:22 +0000 | |||
866 | @@ -0,0 +1,21 @@ | |||
867 | 1 | include_directories (${CMAKE_CURRENT_SOURCE_DIR} | ||
868 | 2 | ${compiz_SOURCE_DIR}/gtk/window-decorator/local-menus/tests | ||
869 | 3 | ${compiz_SOURCE_DIR}/gtk/window-decorator | ||
870 | 4 | ${compiz_SOURCE_DIR}/gtk/window-decorator/local-menus/src) | ||
871 | 5 | |||
872 | 6 | add_executable( | ||
873 | 7 | gtk_window_decorator_force_local_menu_on_test | ||
874 | 8 | |||
875 | 9 | ${CMAKE_CURRENT_SOURCE_DIR}/test-force-local-menu-on.cpp | ||
876 | 10 | ) | ||
877 | 11 | |||
878 | 12 | target_link_libraries( | ||
879 | 13 | gtk_window_decorator_force_local_menu_on_test | ||
880 | 14 | |||
881 | 15 | gtk_window_decorator_local_menus | ||
882 | 16 | |||
883 | 17 | ${GTEST_BOTH_LIBRARIES} | ||
884 | 18 | ${CMAKE_THREAD_LIBS_INIT} # Link in pthread. | ||
885 | 19 | ) | ||
886 | 20 | |||
887 | 21 | add_test (gtk_window_decorator_force_local_menu_on gtk_window_decorator_force_local_menu_on_test) | ||
888 | 0 | 22 | ||
889 | === added file 'gtk/window-decorator/local-menus/tests/force_local_menu_on/test-force-local-menu-on.cpp' | |||
890 | --- gtk/window-decorator/local-menus/tests/force_local_menu_on/test-force-local-menu-on.cpp 1970-01-01 00:00:00 +0000 | |||
891 | +++ gtk/window-decorator/local-menus/tests/force_local_menu_on/test-force-local-menu-on.cpp 2012-02-21 10:38:22 +0000 | |||
892 | @@ -0,0 +1,70 @@ | |||
893 | 1 | #include "test-local-menu.h" | ||
894 | 2 | #include <cstring> | ||
895 | 3 | |||
896 | 4 | #define GLOBAL 0 | ||
897 | 5 | #define LOCAL 1 | ||
898 | 6 | |||
899 | 7 | namespace | ||
900 | 8 | { | ||
901 | 9 | void initializeMetaButtonLayout (MetaButtonLayout *layout) | ||
902 | 10 | { | ||
903 | 11 | memset (layout, 0, sizeof (MetaButtonLayout)); | ||
904 | 12 | |||
905 | 13 | unsigned int i; | ||
906 | 14 | |||
907 | 15 | for (i = 0; i < MAX_BUTTONS_PER_CORNER; i++) | ||
908 | 16 | { | ||
909 | 17 | layout->right_buttons[i] = META_BUTTON_FUNCTION_LAST; | ||
910 | 18 | layout->left_buttons[i] = META_BUTTON_FUNCTION_LAST; | ||
911 | 19 | } | ||
912 | 20 | } | ||
913 | 21 | } | ||
914 | 22 | |||
915 | 23 | class GtkWindowDecoratorTestLocalMenuLayout : | ||
916 | 24 | public GtkWindowDecoratorTestLocalMenu | ||
917 | 25 | { | ||
918 | 26 | public: | ||
919 | 27 | |||
920 | 28 | MetaButtonLayout * getLayout () { return &mLayout; } | ||
921 | 29 | |||
922 | 30 | virtual void SetUp () | ||
923 | 31 | { | ||
924 | 32 | GtkWindowDecoratorTestLocalMenu::SetUp (); | ||
925 | 33 | ::initializeMetaButtonLayout (&mLayout); | ||
926 | 34 | g_settings_set_enum (getSettings (), "menu-mode", LOCAL); | ||
927 | 35 | } | ||
928 | 36 | |||
929 | 37 | private: | ||
930 | 38 | |||
931 | 39 | MetaButtonLayout mLayout; | ||
932 | 40 | }; | ||
933 | 41 | |||
934 | 42 | TEST_F (GtkWindowDecoratorTestLocalMenuLayout, TestForceNoButtonsSet) | ||
935 | 43 | { | ||
936 | 44 | force_local_menus_on (getWindow (), getLayout ()); | ||
937 | 45 | |||
938 | 46 | EXPECT_EQ (getLayout ()->right_buttons[0], META_BUTTON_FUNCTION_LAST); | ||
939 | 47 | EXPECT_EQ (getLayout ()->left_buttons[0], META_BUTTON_FUNCTION_LAST); | ||
940 | 48 | } | ||
941 | 49 | |||
942 | 50 | TEST_F (GtkWindowDecoratorTestLocalMenuLayout, TestForceNoCloseButtonSet) | ||
943 | 51 | { | ||
944 | 52 | getLayout ()->right_buttons[0] = META_BUTTON_FUNCTION_CLOSE; | ||
945 | 53 | |||
946 | 54 | force_local_menus_on (getWindow (), getLayout ()); | ||
947 | 55 | |||
948 | 56 | EXPECT_EQ (getLayout ()->right_buttons[1], META_BUTTON_FUNCTION_WINDOW_MENU); | ||
949 | 57 | EXPECT_EQ (getLayout ()->left_buttons[0], META_BUTTON_FUNCTION_LAST); | ||
950 | 58 | } | ||
951 | 59 | |||
952 | 60 | TEST_F (GtkWindowDecoratorTestLocalMenuLayout, TestForceNoCloseMinimizeMaximizeButtonSet) | ||
953 | 61 | { | ||
954 | 62 | getLayout ()->left_buttons[0] = META_BUTTON_FUNCTION_CLOSE; | ||
955 | 63 | getLayout ()->left_buttons[1] = META_BUTTON_FUNCTION_CLOSE; | ||
956 | 64 | getLayout ()->left_buttons[2] = META_BUTTON_FUNCTION_CLOSE; | ||
957 | 65 | |||
958 | 66 | force_local_menus_on (getWindow (), getLayout ()); | ||
959 | 67 | |||
960 | 68 | EXPECT_EQ (getLayout ()->right_buttons[0], META_BUTTON_FUNCTION_LAST); | ||
961 | 69 | EXPECT_EQ (getLayout ()->left_buttons[3], META_BUTTON_FUNCTION_WINDOW_MENU); | ||
962 | 70 | } | ||
963 | 0 | 71 | ||
964 | === added directory 'gtk/window-decorator/local-menus/tests/show_hide_menu' | |||
965 | === added file 'gtk/window-decorator/local-menus/tests/test-local-menu.h' | |||
966 | --- gtk/window-decorator/local-menus/tests/test-local-menu.h 1970-01-01 00:00:00 +0000 | |||
967 | +++ gtk/window-decorator/local-menus/tests/test-local-menu.h 2012-02-21 10:38:22 +0000 | |||
968 | @@ -0,0 +1,48 @@ | |||
969 | 1 | #include <gtest/gtest.h> | ||
970 | 2 | #include <gmock/gmock.h> | ||
971 | 3 | #include "local-menus.h" | ||
972 | 4 | #include <X11/Xlib.h> | ||
973 | 5 | #include <gio/gio.h> | ||
974 | 6 | |||
975 | 7 | class GtkWindowDecoratorTestLocalMenu : | ||
976 | 8 | public ::testing::Test | ||
977 | 9 | { | ||
978 | 10 | public: | ||
979 | 11 | |||
980 | 12 | WnckWindow * getWindow () { return mWindow; } | ||
981 | 13 | GSettings * getSettings () { return mSettings; } | ||
982 | 14 | |||
983 | 15 | virtual void SetUp () | ||
984 | 16 | { | ||
985 | 17 | gtk_init (NULL, NULL); | ||
986 | 18 | |||
987 | 19 | mXDisplay = XOpenDisplay (NULL); | ||
988 | 20 | mXWindow = XCreateSimpleWindow (mXDisplay, DefaultRootWindow (mXDisplay), 0, 0, 100, 100, 0, 0, 0); | ||
989 | 21 | |||
990 | 22 | XMapRaised (mXDisplay, mXWindow); | ||
991 | 23 | |||
992 | 24 | XFlush (mXDisplay); | ||
993 | 25 | |||
994 | 26 | while (g_main_context_iteration (g_main_context_default (), FALSE)); | ||
995 | 27 | |||
996 | 28 | mWindow = wnck_window_get (mXWindow); | ||
997 | 29 | |||
998 | 30 | g_setenv("GSETTINGS_BACKEND", "memory", true); | ||
999 | 31 | mSettings = g_settings_new ("com.canonical.indicator.appmenu"); | ||
1000 | 32 | } | ||
1001 | 33 | |||
1002 | 34 | virtual void TearDown () | ||
1003 | 35 | { | ||
1004 | 36 | XDestroyWindow (mXDisplay, mXWindow); | ||
1005 | 37 | XCloseDisplay (mXDisplay); | ||
1006 | 38 | |||
1007 | 39 | g_object_unref (mSettings); | ||
1008 | 40 | } | ||
1009 | 41 | |||
1010 | 42 | private: | ||
1011 | 43 | |||
1012 | 44 | WnckWindow *mWindow; | ||
1013 | 45 | Window mXWindow; | ||
1014 | 46 | Display *mXDisplay; | ||
1015 | 47 | GSettings *mSettings; | ||
1016 | 48 | }; | ||
1017 | 0 | 49 | ||
1018 | === modified file 'gtk/window-decorator/metacity.c' | |||
1019 | --- gtk/window-decorator/metacity.c 2012-02-16 06:51:37 +0000 | |||
1020 | +++ gtk/window-decorator/metacity.c 2012-02-21 10:38:22 +0000 | |||
1021 | @@ -24,6 +24,7 @@ | |||
1022 | 24 | */ | 24 | */ |
1023 | 25 | 25 | ||
1024 | 26 | #include "gtk-window-decorator.h" | 26 | #include "gtk-window-decorator.h" |
1025 | 27 | #include "local-menus.h" | ||
1026 | 27 | 28 | ||
1027 | 28 | #ifdef USE_METACITY | 29 | #ifdef USE_METACITY |
1028 | 29 | 30 | ||
1029 | @@ -488,6 +489,8 @@ | |||
1030 | 488 | button_layout->right_buttons[i] = META_BUTTON_FUNCTION_LAST; | 489 | button_layout->right_buttons[i] = META_BUTTON_FUNCTION_LAST; |
1031 | 489 | } | 490 | } |
1032 | 490 | 491 | ||
1033 | 492 | force_local_menus_on (d->win, button_layout); | ||
1034 | 493 | |||
1035 | 491 | *flags = 0; | 494 | *flags = 0; |
1036 | 492 | 495 | ||
1037 | 493 | if (d->actions & WNCK_WINDOW_ACTION_CLOSE) | 496 | if (d->actions & WNCK_WINDOW_ACTION_CLOSE) |
1038 | @@ -558,6 +561,15 @@ | |||
1039 | 558 | else | 561 | else |
1040 | 559 | clip->height = d->border_layout.left.y2 - d->border_layout.left.y1; | 562 | clip->height = d->border_layout.left.y2 - d->border_layout.left.y1; |
1041 | 560 | 563 | ||
1042 | 564 | memset (fgeom, 0, sizeof (MetaFrameGeometry)); | ||
1043 | 565 | |||
1044 | 566 | #ifdef META_HAS_LOCAL_MENUS | ||
1045 | 567 | |||
1046 | 568 | if (d->layout) | ||
1047 | 569 | fgeom->text_layout = g_object_ref (d->layout); | ||
1048 | 570 | |||
1049 | 571 | #endif | ||
1050 | 572 | |||
1051 | 561 | meta_theme_calc_geometry (theme, | 573 | meta_theme_calc_geometry (theme, |
1052 | 562 | frame_type, | 574 | frame_type, |
1053 | 563 | d->frame->text_height, | 575 | d->frame->text_height, |
1054 | @@ -567,6 +579,15 @@ | |||
1055 | 567 | button_layout, | 579 | button_layout, |
1056 | 568 | fgeom); | 580 | fgeom); |
1057 | 569 | 581 | ||
1058 | 582 | #ifdef META_HAS_LOCAL_MENUS | ||
1059 | 583 | |||
1060 | 584 | if (d->layout) | ||
1061 | 585 | g_object_unref (fgeom->text_layout); | ||
1062 | 586 | |||
1063 | 587 | fgeom->text_layout = NULL; | ||
1064 | 588 | |||
1065 | 589 | #endif | ||
1066 | 590 | |||
1067 | 570 | clip->width += left_width + right_width; | 591 | clip->width += left_width + right_width; |
1068 | 571 | clip->height += top_height + bottom_height; | 592 | clip->height += top_height + bottom_height; |
1069 | 572 | } | 593 | } |
1070 | @@ -601,6 +622,11 @@ | |||
1071 | 601 | GdkColor bg_color; | 622 | GdkColor bg_color; |
1072 | 602 | double bg_alpha; | 623 | double bg_alpha; |
1073 | 603 | 624 | ||
1074 | 625 | memset (&button_layout, 0, sizeof (MetaButtonLayout)); | ||
1075 | 626 | |||
1076 | 627 | for (i = 0; i < MAX_BUTTONS_PER_CORNER; i++) | ||
1077 | 628 | button_layout.left_buttons[i] = button_layout.right_buttons[i] = META_BUTTON_FUNCTION_LAST; | ||
1078 | 629 | |||
1079 | 604 | if (!d->pixmap || !d->picture) | 630 | if (!d->pixmap || !d->picture) |
1080 | 605 | return; | 631 | return; |
1081 | 606 | 632 | ||
1082 | @@ -675,6 +701,9 @@ | |||
1083 | 675 | 701 | ||
1084 | 676 | size = MAX (fgeom.top_height, fgeom.bottom_height); | 702 | size = MAX (fgeom.top_height, fgeom.bottom_height); |
1085 | 677 | 703 | ||
1086 | 704 | if (active_menu) | ||
1087 | 705 | g_object_set_data (G_OBJECT (style_window), "local_menu_rect", &active_menu->rect); | ||
1088 | 706 | |||
1089 | 678 | if (rect.width && size) | 707 | if (rect.width && size) |
1090 | 679 | { | 708 | { |
1091 | 680 | XRenderPictFormat *format; | 709 | XRenderPictFormat *format; |
1092 | @@ -899,6 +928,9 @@ | |||
1093 | 899 | XRenderFreePicture (xdisplay, src); | 928 | XRenderFreePicture (xdisplay, src); |
1094 | 900 | } | 929 | } |
1095 | 901 | 930 | ||
1096 | 931 | if (active_menu) | ||
1097 | 932 | g_object_set_data (G_OBJECT (style_window), "local_menu_rect", NULL); | ||
1098 | 933 | |||
1099 | 902 | copy_to_front_buffer (d); | 934 | copy_to_front_buffer (d); |
1100 | 903 | 935 | ||
1101 | 904 | if (d->frame_window) | 936 | if (d->frame_window) |
1102 | @@ -1078,6 +1110,15 @@ | |||
1103 | 1078 | break; | 1110 | break; |
1104 | 1079 | #endif | 1111 | #endif |
1105 | 1080 | 1112 | ||
1106 | 1113 | #ifdef META_HAS_LOCAL_MENUS | ||
1107 | 1114 | case BUTTON_WINDOW_MENU: | ||
1108 | 1115 | if (!meta_button_present (&button_layout, META_BUTTON_FUNCTION_WINDOW_MENU)) | ||
1109 | 1116 | return FALSE; | ||
1110 | 1117 | |||
1111 | 1118 | space = &fgeom.window_menu_rect; | ||
1112 | 1119 | break; | ||
1113 | 1120 | #endif | ||
1114 | 1121 | |||
1115 | 1081 | default: | 1122 | default: |
1116 | 1082 | return FALSE; | 1123 | return FALSE; |
1117 | 1083 | } | 1124 | } |
1118 | @@ -1266,6 +1307,8 @@ | |||
1119 | 1266 | MetaTheme *theme; | 1307 | MetaTheme *theme; |
1120 | 1267 | GdkRectangle clip; | 1308 | GdkRectangle clip; |
1121 | 1268 | 1309 | ||
1122 | 1310 | memset (&fgeom, 0, sizeof (MetaFrameGeometry)); | ||
1123 | 1311 | |||
1124 | 1269 | theme = meta_theme_get_current (); | 1312 | theme = meta_theme_get_current (); |
1125 | 1270 | 1313 | ||
1126 | 1271 | meta_get_decoration_geometry (d, theme, &flags, &fgeom, &button_layout, | 1314 | meta_get_decoration_geometry (d, theme, &flags, &fgeom, &button_layout, |
1127 | @@ -1490,6 +1533,11 @@ | |||
1128 | 1490 | return META_BUTTON_FUNCTION_UNSTICK; | 1533 | return META_BUTTON_FUNCTION_UNSTICK; |
1129 | 1491 | #endif | 1534 | #endif |
1130 | 1492 | 1535 | ||
1131 | 1536 | #ifdef META_HAS_LOCAL_MENUS | ||
1132 | 1537 | else if (strcmp (str, "window_menu") == 0) | ||
1133 | 1538 | return META_BUTTON_FUNCTION_WINDOW_MENU; | ||
1134 | 1539 | #endif | ||
1135 | 1540 | |||
1136 | 1493 | else | 1541 | else |
1137 | 1494 | return META_BUTTON_FUNCTION_LAST; | 1542 | return META_BUTTON_FUNCTION_LAST; |
1138 | 1495 | } | 1543 | } |
1139 | 1496 | 1544 | ||
1140 | === modified file 'gtk/window-decorator/wnck.c' | |||
1141 | --- gtk/window-decorator/wnck.c 2012-02-10 10:23:27 +0000 | |||
1142 | +++ gtk/window-decorator/wnck.c 2012-02-21 10:38:22 +0000 | |||
1143 | @@ -738,7 +738,8 @@ | |||
1144 | 738 | stick_button_event, | 738 | stick_button_event, |
1145 | 739 | unshade_button_event, | 739 | unshade_button_event, |
1146 | 740 | unabove_button_event, | 740 | unabove_button_event, |
1148 | 741 | unstick_button_event | 741 | unstick_button_event, |
1149 | 742 | window_menu_button_event | ||
1150 | 742 | }; | 743 | }; |
1151 | 743 | 744 | ||
1152 | 744 | d = calloc (1, sizeof (decor_t)); | 745 | d = calloc (1, sizeof (decor_t)); |
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?