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: |
1087 lines (+808/-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 (+270/-0) gtk/window-decorator/local-menus/src/local-menus.h (+91/-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 | Approve | ||
Review via email: mp+91639@code.launchpad.net |
This proposal supersedes a proposal from 2012-02-02.
This proposal has been superseded by a proposal from 2012-02-21.
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)
- 2987. By Sam Spilsbury
-
Show the flair in the right place
Alan Griffiths (alan-griffiths) wrote : | # |
Looks better
- 2988. By Sam Spilsbury
-
Use the right key
- 2989. By Sam Spilsbury
-
Use the correct key
Sam Spilsbury (smspillaz) wrote : | # |
(More work needed to adopt to trevino;s changes)
- 2990. By Sam Spilsbury
-
Merged from lp:compiz-core
Daniel van Vugt (vanvugt) wrote : | # |
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 : | # |
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 : | # |
Ah, Sam remember to update the "EntryActivated" signal against the new signature s(iiuu).
Sam Spilsbury (smspillaz) wrote : | # |
Yep, done
- 2991. By Sam Spilsbury
-
Merged from lp:compiz-core
- 2992. By Sam Spilsbury
-
Merged from lp:compiz-core
- 2993. By Sam Spilsbury
-
Merge lp:compiz-core
- 2994. By Sam Spilsbury
-
Fix incorrect variant and initial button layout
- 2995. By Sam Spilsbury
-
Fix build without META_HAS_
LOCAL_MENUS - 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-07 07:03:18 +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 2011-10-13 11:31:37 +0000 | |||
28 | +++ gtk/window-decorator/decorator.c 2012-02-07 07:03:18 +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 | d->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 2011-10-13 12:22:14 +0000 | |||
120 | +++ gtk/window-decorator/events.c 2012-02-07 07:03:18 +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-07 07:03:18 +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-07 07:03:18 +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-07 07:03:18 +0000 | |||
366 | @@ -0,0 +1,270 @@ | |||
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 "local-menus.h" | ||
393 | 27 | #include <gdk/gdk.h> | ||
394 | 28 | #include <gdk/gdkx.h> | ||
395 | 29 | |||
396 | 30 | #define GLOBAL 0 | ||
397 | 31 | #define LOCAL 1 | ||
398 | 32 | |||
399 | 33 | gint menu_mode = GLOBAL; | ||
400 | 34 | |||
401 | 35 | static void | ||
402 | 36 | gwd_menu_mode_changed (GSettings *settings, | ||
403 | 37 | gchar *key, | ||
404 | 38 | gpointer user_data) | ||
405 | 39 | { | ||
406 | 40 | menu_mode = g_settings_get_enum (settings, "menu-mode"); | ||
407 | 41 | } | ||
408 | 42 | |||
409 | 43 | active_local_menu *active_menu; | ||
410 | 44 | pending_local_menu *pending_menu; | ||
411 | 45 | |||
412 | 46 | gboolean | ||
413 | 47 | gwd_window_should_have_local_menu (WnckWindow *win) | ||
414 | 48 | { | ||
415 | 49 | #ifdef META_HAS_LOCAL_MENUS | ||
416 | 50 | const gchar * const *schemas = g_settings_list_schemas (); | ||
417 | 51 | static GSettings *lim_settings = NULL; | ||
418 | 52 | while (*schemas != NULL && !lim_settings) | ||
419 | 53 | { | ||
420 | 54 | if (g_str_equal (*schemas, "com.canonical.indicator.appmenu")) | ||
421 | 55 | { | ||
422 | 56 | lim_settings = g_settings_new ("com.canonical.indicator.appmenu"); | ||
423 | 57 | menu_mode = g_settings_get_enum (lim_settings, "menu-mode"); | ||
424 | 58 | g_signal_connect (lim_settings, "changed::menu-mode", G_CALLBACK (gwd_menu_mode_changed), NULL); | ||
425 | 59 | break; | ||
426 | 60 | } | ||
427 | 61 | ++schemas; | ||
428 | 62 | } | ||
429 | 63 | |||
430 | 64 | if (lim_settings) | ||
431 | 65 | return menu_mode; | ||
432 | 66 | #endif | ||
433 | 67 | |||
434 | 68 | return FALSE; | ||
435 | 69 | } | ||
436 | 70 | |||
437 | 71 | static void | ||
438 | 72 | on_local_menu_activated (GDBusProxy *proxy, | ||
439 | 73 | gchar *sender_name, | ||
440 | 74 | gchar *signal_name, | ||
441 | 75 | GVariant *parameters, | ||
442 | 76 | gpointer user_data) | ||
443 | 77 | { | ||
444 | 78 | #ifdef META_HAS_LOCAL_MENUS | ||
445 | 79 | if (g_strcmp0 (signal_name, "EntryActivated") == 0) | ||
446 | 80 | { | ||
447 | 81 | gchar *entry_id = NULL; | ||
448 | 82 | |||
449 | 83 | g_variant_get (parameters, "(s)", &entry_id, NULL); | ||
450 | 84 | |||
451 | 85 | gboolean empty = g_strcmp0 (entry_id, "") == 0; | ||
452 | 86 | |||
453 | 87 | if (empty) | ||
454 | 88 | { | ||
455 | 89 | show_local_menu_data *d = (show_local_menu_data *) user_data; | ||
456 | 90 | |||
457 | 91 | (*d->cb) (d->user_data); | ||
458 | 92 | |||
459 | 93 | g_signal_handlers_disconnect_by_func (d->proxy, on_local_menu_activated, d); | ||
460 | 94 | |||
461 | 95 | g_object_unref (d->proxy); | ||
462 | 96 | g_object_unref (d->conn); | ||
463 | 97 | |||
464 | 98 | if (active_menu) | ||
465 | 99 | { | ||
466 | 100 | g_free (active_menu); | ||
467 | 101 | active_menu = NULL; | ||
468 | 102 | } | ||
469 | 103 | } | ||
470 | 104 | } | ||
471 | 105 | #endif | ||
472 | 106 | } | ||
473 | 107 | |||
474 | 108 | gboolean | ||
475 | 109 | gwd_move_window_instead (gpointer user_data) | ||
476 | 110 | { | ||
477 | 111 | (*pending_menu->cb) (pending_menu->user_data); | ||
478 | 112 | g_free (pending_menu->user_data); | ||
479 | 113 | g_free (pending_menu); | ||
480 | 114 | pending_menu = NULL; | ||
481 | 115 | return FALSE; | ||
482 | 116 | } | ||
483 | 117 | |||
484 | 118 | void | ||
485 | 119 | gwd_prepare_show_local_menu (start_move_window_cb start_move_window, | ||
486 | 120 | gpointer user_data_start_move_window) | ||
487 | 121 | { | ||
488 | 122 | if (pending_menu) | ||
489 | 123 | { | ||
490 | 124 | g_source_remove (pending_menu->move_timeout_id); | ||
491 | 125 | g_free (pending_menu->user_data); | ||
492 | 126 | g_free (pending_menu); | ||
493 | 127 | pending_menu = NULL; | ||
494 | 128 | } | ||
495 | 129 | |||
496 | 130 | pending_menu = g_new0 (pending_local_menu, 1); | ||
497 | 131 | pending_menu->cb = start_move_window; | ||
498 | 132 | pending_menu->user_data = user_data_start_move_window; | ||
499 | 133 | pending_menu->move_timeout_id = g_timeout_add (150, gwd_move_window_instead, pending_menu); | ||
500 | 134 | } | ||
501 | 135 | |||
502 | 136 | void | ||
503 | 137 | gwd_show_local_menu (Display *xdisplay, | ||
504 | 138 | Window frame_xwindow, | ||
505 | 139 | int x, | ||
506 | 140 | int y, | ||
507 | 141 | int x_win, | ||
508 | 142 | int y_win, | ||
509 | 143 | int button, | ||
510 | 144 | guint32 timestamp, | ||
511 | 145 | show_window_menu_hidden_cb cb, | ||
512 | 146 | gpointer user_data_show_window_menu) | ||
513 | 147 | { | ||
514 | 148 | if (pending_menu) | ||
515 | 149 | { | ||
516 | 150 | g_source_remove (pending_menu->move_timeout_id); | ||
517 | 151 | g_free (pending_menu->user_data); | ||
518 | 152 | g_free (pending_menu); | ||
519 | 153 | pending_menu = NULL; | ||
520 | 154 | } | ||
521 | 155 | |||
522 | 156 | #ifdef META_HAS_LOCAL_MENUS | ||
523 | 157 | GError *error = NULL; | ||
524 | 158 | GDBusConnection *conn = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error); | ||
525 | 159 | gint x_out, y_out; | ||
526 | 160 | guint width, height; | ||
527 | 161 | |||
528 | 162 | XUngrabPointer (gdk_x11_display_get_xdisplay (gdk_display_get_default ()), CurrentTime); | ||
529 | 163 | XUngrabKeyboard (gdk_x11_display_get_xdisplay (gdk_display_get_default ()), CurrentTime); | ||
530 | 164 | XSync (gdk_x11_display_get_xdisplay (gdk_display_get_default ()), FALSE); | ||
531 | 165 | |||
532 | 166 | if (!conn) | ||
533 | 167 | { | ||
534 | 168 | g_print ("error getting connection: %s\n", error->message); | ||
535 | 169 | return; | ||
536 | 170 | } | ||
537 | 171 | |||
538 | 172 | GDBusProxy *proxy = g_dbus_proxy_new_sync (conn, 0, NULL, "com.canonical.Unity.Panel.Service", | ||
539 | 173 | "/com/canonical/Unity/Panel/Service", | ||
540 | 174 | "com.canonical.Unity.Panel.Service", | ||
541 | 175 | NULL, &error); | ||
542 | 176 | |||
543 | 177 | if (proxy) | ||
544 | 178 | { | ||
545 | 179 | GVariant *message = g_variant_new ("(uiiu)", frame_xwindow, x, y, time); | ||
546 | 180 | GVariant *reply = g_dbus_proxy_call_sync (proxy, "ShowAppMenu", message, 0, 500, NULL, &error); | ||
547 | 181 | if (error) | ||
548 | 182 | { | ||
549 | 183 | g_print ("error calling ShowAppMenu: %s\n", error->message); | ||
550 | 184 | g_object_unref (proxy); | ||
551 | 185 | g_object_unref (conn); | ||
552 | 186 | return; | ||
553 | 187 | } | ||
554 | 188 | |||
555 | 189 | show_local_menu_data *data = g_new0 (show_local_menu_data, 1); | ||
556 | 190 | g_variant_get (reply, "(iiuu)", &x_out, &y_out, &width, &height, NULL); | ||
557 | 191 | |||
558 | 192 | if (active_menu) | ||
559 | 193 | g_free (active_menu); | ||
560 | 194 | |||
561 | 195 | active_menu = g_new0 (active_local_menu, 1); | ||
562 | 196 | |||
563 | 197 | active_menu->rect.x = x_out - (x - x_win); | ||
564 | 198 | active_menu->rect.y = y_out - (x - y_win); | ||
565 | 199 | active_menu->rect.width = width; | ||
566 | 200 | active_menu->rect.height = height; | ||
567 | 201 | |||
568 | 202 | data->conn = g_object_ref (conn); | ||
569 | 203 | data->proxy = g_object_ref (proxy); | ||
570 | 204 | data->cb = cb; | ||
571 | 205 | data->user_data = user_data_show_window_menu; | ||
572 | 206 | |||
573 | 207 | g_signal_connect (proxy, "g-signal", G_CALLBACK (on_local_menu_activated), data); | ||
574 | 208 | |||
575 | 209 | g_object_unref (conn); | ||
576 | 210 | g_object_unref (proxy); | ||
577 | 211 | |||
578 | 212 | return; | ||
579 | 213 | } | ||
580 | 214 | else | ||
581 | 215 | { | ||
582 | 216 | g_print ("error getting proxy: %s\n", error->message); | ||
583 | 217 | } | ||
584 | 218 | |||
585 | 219 | g_object_unref (conn); | ||
586 | 220 | #endif | ||
587 | 221 | } | ||
588 | 222 | |||
589 | 223 | void | ||
590 | 224 | force_local_menus_on (WnckWindow *win, | ||
591 | 225 | MetaButtonLayout *button_layout) | ||
592 | 226 | { | ||
593 | 227 | #ifdef META_HAS_LOCAL_MENUS | ||
594 | 228 | if (gwd_window_should_have_local_menu (win)) | ||
595 | 229 | { | ||
596 | 230 | if (button_layout->left_buttons[0] != META_BUTTON_FUNCTION_LAST) | ||
597 | 231 | { | ||
598 | 232 | unsigned int i = 0; | ||
599 | 233 | for (; i < MAX_BUTTONS_PER_CORNER; i++) | ||
600 | 234 | { | ||
601 | 235 | if (button_layout->left_buttons[i] == META_BUTTON_FUNCTION_WINDOW_MENU) | ||
602 | 236 | break; | ||
603 | 237 | else if (button_layout->left_buttons[i] == META_BUTTON_FUNCTION_LAST) | ||
604 | 238 | { | ||
605 | 239 | if ((i + 1) < MAX_BUTTONS_PER_CORNER) | ||
606 | 240 | { | ||
607 | 241 | button_layout->left_buttons[i + 1] = META_BUTTON_FUNCTION_LAST; | ||
608 | 242 | button_layout->left_buttons[i] = META_BUTTON_FUNCTION_WINDOW_MENU; | ||
609 | 243 | break; | ||
610 | 244 | } | ||
611 | 245 | } | ||
612 | 246 | } | ||
613 | 247 | } | ||
614 | 248 | if (button_layout->right_buttons[0] != META_BUTTON_FUNCTION_LAST) | ||
615 | 249 | { | ||
616 | 250 | unsigned int i = 0; | ||
617 | 251 | for (; i < MAX_BUTTONS_PER_CORNER; i++) | ||
618 | 252 | { | ||
619 | 253 | if (button_layout->right_buttons[i] == META_BUTTON_FUNCTION_WINDOW_MENU) | ||
620 | 254 | break; | ||
621 | 255 | else if (button_layout->right_buttons[i] == META_BUTTON_FUNCTION_LAST) | ||
622 | 256 | { | ||
623 | 257 | if ((i + 1) < MAX_BUTTONS_PER_CORNER) | ||
624 | 258 | { | ||
625 | 259 | button_layout->right_buttons[i + 1] = META_BUTTON_FUNCTION_LAST; | ||
626 | 260 | button_layout->right_buttons[i] = META_BUTTON_FUNCTION_WINDOW_MENU; | ||
627 | 261 | break; | ||
628 | 262 | } | ||
629 | 263 | } | ||
630 | 264 | } | ||
631 | 265 | } | ||
632 | 266 | } | ||
633 | 267 | #endif | ||
634 | 268 | } | ||
635 | 269 | |||
636 | 270 | |||
637 | 0 | 271 | ||
638 | === added file 'gtk/window-decorator/local-menus/src/local-menus.h' | |||
639 | --- gtk/window-decorator/local-menus/src/local-menus.h 1970-01-01 00:00:00 +0000 | |||
640 | +++ gtk/window-decorator/local-menus/src/local-menus.h 2012-02-07 07:03:18 +0000 | |||
641 | @@ -0,0 +1,91 @@ | |||
642 | 1 | /* | ||
643 | 2 | * Copyright © 2006 Novell, Inc. | ||
644 | 3 | * | ||
645 | 4 | * This library is free software; you can redistribute it and/or | ||
646 | 5 | * modify it under the terms of the GNU Lesser General Public | ||
647 | 6 | * License as published by the Free Software Foundation; either | ||
648 | 7 | * version 2 of the License, or (at your option) any later version. | ||
649 | 8 | * | ||
650 | 9 | * This library is distributed in the hope that it will be useful, | ||
651 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
652 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
653 | 12 | * Lesser General Public License for more details. | ||
654 | 13 | * | ||
655 | 14 | * You should have received a copy of the GNU Lesser General Public | ||
656 | 15 | * License along with this library; if not, write to the | ||
657 | 16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
658 | 17 | * Boston, MA 02111-1307, USA. | ||
659 | 18 | * | ||
660 | 19 | * Author: David Reveman <davidr@novell.com> | ||
661 | 20 | * | ||
662 | 21 | * 2D Mode: Copyright © 2010 Sam Spilsbury <smspillaz@gmail.com> | ||
663 | 22 | * Frames Management: Copright © 2011 Canonical Ltd. | ||
664 | 23 | * Authored By: Sam Spilsbury <sam.spilsbury@canonical.com> | ||
665 | 24 | */ | ||
666 | 25 | |||
667 | 26 | #ifdef __cplusplus | ||
668 | 27 | extern "C" | ||
669 | 28 | { | ||
670 | 29 | #endif | ||
671 | 30 | |||
672 | 31 | #include <glib.h> | ||
673 | 32 | #include <gio/gio.h> | ||
674 | 33 | #ifndef WNCK_I_KNOW_THIS_IS_UNSTABLE | ||
675 | 34 | #define WNCK_I_KNOW_THIS_IS_UNSTABLE | ||
676 | 35 | #endif | ||
677 | 36 | #include <libwnck/libwnck.h> | ||
678 | 37 | #include <libwnck/window-action-menu.h> | ||
679 | 38 | #include <metacity-private/theme.h> | ||
680 | 39 | |||
681 | 40 | typedef void (*show_window_menu_hidden_cb) (gpointer); | ||
682 | 41 | typedef void (*start_move_window_cb) (gpointer); | ||
683 | 42 | |||
684 | 43 | typedef struct _pending_local_menu | ||
685 | 44 | { | ||
686 | 45 | gint move_timeout_id; | ||
687 | 46 | gpointer user_data; | ||
688 | 47 | start_move_window_cb cb; | ||
689 | 48 | } pending_local_menu; | ||
690 | 49 | |||
691 | 50 | typedef struct _active_local_menu | ||
692 | 51 | { | ||
693 | 52 | GdkRectangle rect; | ||
694 | 53 | } active_local_menu; | ||
695 | 54 | |||
696 | 55 | extern active_local_menu *active_menu; | ||
697 | 56 | |||
698 | 57 | typedef struct _show_local_menu_data | ||
699 | 58 | { | ||
700 | 59 | GDBusConnection *conn; | ||
701 | 60 | GDBusProxy *proxy; | ||
702 | 61 | show_window_menu_hidden_cb cb; | ||
703 | 62 | gpointer user_data; | ||
704 | 63 | } show_local_menu_data; | ||
705 | 64 | |||
706 | 65 | gboolean | ||
707 | 66 | gwd_window_should_have_local_menu (WnckWindow *win); | ||
708 | 67 | |||
709 | 68 | void | ||
710 | 69 | force_local_menus_on (WnckWindow *win, | ||
711 | 70 | MetaButtonLayout *layout); | ||
712 | 71 | |||
713 | 72 | /* Button Down */ | ||
714 | 73 | void | ||
715 | 74 | gwd_prepare_show_local_menu (start_move_window_cb start_move_window, | ||
716 | 75 | gpointer user_data_start_move_window); | ||
717 | 76 | |||
718 | 77 | /* Button Up */ | ||
719 | 78 | void | ||
720 | 79 | gwd_show_local_menu (Display *xdisplay, | ||
721 | 80 | Window frame_xwindow, | ||
722 | 81 | int x, | ||
723 | 82 | int y, | ||
724 | 83 | int x_win, | ||
725 | 84 | int y_win, | ||
726 | 85 | int button, | ||
727 | 86 | guint32 timestamp, | ||
728 | 87 | show_window_menu_hidden_cb cb, | ||
729 | 88 | gpointer user_data_show_window_menu); | ||
730 | 89 | #ifdef __cplusplus | ||
731 | 90 | } | ||
732 | 91 | #endif | ||
733 | 0 | 92 | ||
734 | === added directory 'gtk/window-decorator/local-menus/tests' | |||
735 | === added file 'gtk/window-decorator/local-menus/tests/CMakeLists.txt' | |||
736 | --- gtk/window-decorator/local-menus/tests/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
737 | +++ gtk/window-decorator/local-menus/tests/CMakeLists.txt 2012-02-07 07:03:18 +0000 | |||
738 | @@ -0,0 +1,3 @@ | |||
739 | 1 | include_directories (${CMAKE_CURRENT_SOURCE_DIR}) | ||
740 | 2 | add_subdirectory (check_local_menu_on_off) | ||
741 | 3 | add_subdirectory (force_local_menu_on) | ||
742 | 0 | 4 | ||
743 | === added directory 'gtk/window-decorator/local-menus/tests/check_local_menu_on_off' | |||
744 | === added file 'gtk/window-decorator/local-menus/tests/check_local_menu_on_off/CMakeLists.txt' | |||
745 | --- gtk/window-decorator/local-menus/tests/check_local_menu_on_off/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
746 | +++ gtk/window-decorator/local-menus/tests/check_local_menu_on_off/CMakeLists.txt 2012-02-07 07:03:18 +0000 | |||
747 | @@ -0,0 +1,21 @@ | |||
748 | 1 | include_directories (${CMAKE_CURRENT_SOURCE_DIR} | ||
749 | 2 | ${compiz_SOURCE_DIR}/gtk/window-decorator/local-menus/tests | ||
750 | 3 | ${compiz_SOURCE_DIR}/gtk/window-decorator | ||
751 | 4 | ${compiz_SOURCE_DIR}/gtk/window-decorator/local-menus/src) | ||
752 | 5 | |||
753 | 6 | add_executable( | ||
754 | 7 | gtk_window_decorator_check_local_menu_on_off_test | ||
755 | 8 | |||
756 | 9 | ${CMAKE_CURRENT_SOURCE_DIR}/test-local-menu-on-off.cpp | ||
757 | 10 | ) | ||
758 | 11 | |||
759 | 12 | target_link_libraries( | ||
760 | 13 | gtk_window_decorator_check_local_menu_on_off_test | ||
761 | 14 | |||
762 | 15 | gtk_window_decorator_local_menus | ||
763 | 16 | |||
764 | 17 | ${GTEST_BOTH_LIBRARIES} | ||
765 | 18 | ${CMAKE_THREAD_LIBS_INIT} # Link in pthread. | ||
766 | 19 | ) | ||
767 | 20 | |||
768 | 21 | add_test (gtk_window_decorator_local_menus_on_off gtk_window_decorator_check_local_menu_on_off_test) | ||
769 | 0 | 22 | ||
770 | === added directory 'gtk/window-decorator/local-menus/tests/check_local_menu_on_off/check_local_menu_on_off' | |||
771 | === added directory 'gtk/window-decorator/local-menus/tests/check_local_menu_on_off/check_local_menu_on_off/CMakeFiles' | |||
772 | === added file 'gtk/window-decorator/local-menus/tests/check_local_menu_on_off/test-local-menu-on-off.cpp' | |||
773 | --- gtk/window-decorator/local-menus/tests/check_local_menu_on_off/test-local-menu-on-off.cpp 1970-01-01 00:00:00 +0000 | |||
774 | +++ gtk/window-decorator/local-menus/tests/check_local_menu_on_off/test-local-menu-on-off.cpp 2012-02-07 07:03:18 +0000 | |||
775 | @@ -0,0 +1,20 @@ | |||
776 | 1 | #include "test-local-menu.h" | ||
777 | 2 | |||
778 | 3 | #define GLOBAL 0 | ||
779 | 4 | #define LOCAL 1 | ||
780 | 5 | |||
781 | 6 | TEST_F (GtkWindowDecoratorTestLocalMenu, TestOn) | ||
782 | 7 | { | ||
783 | 8 | g_settings_set_enum (getSettings (), "menu-mode", LOCAL); | ||
784 | 9 | gboolean result = gwd_window_should_have_local_menu (getWindow ()); | ||
785 | 10 | |||
786 | 11 | EXPECT_TRUE (result); | ||
787 | 12 | } | ||
788 | 13 | |||
789 | 14 | TEST_F (GtkWindowDecoratorTestLocalMenu, TestOff) | ||
790 | 15 | { | ||
791 | 16 | g_settings_set_enum (getSettings (), "menu-mode", GLOBAL); | ||
792 | 17 | gboolean result = gwd_window_should_have_local_menu (getWindow ()); | ||
793 | 18 | |||
794 | 19 | EXPECT_FALSE (result); | ||
795 | 20 | } | ||
796 | 0 | 21 | ||
797 | === added directory 'gtk/window-decorator/local-menus/tests/force_local_menu_on' | |||
798 | === added file 'gtk/window-decorator/local-menus/tests/force_local_menu_on/CMakeLists.txt' | |||
799 | --- gtk/window-decorator/local-menus/tests/force_local_menu_on/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
800 | +++ gtk/window-decorator/local-menus/tests/force_local_menu_on/CMakeLists.txt 2012-02-07 07:03:18 +0000 | |||
801 | @@ -0,0 +1,21 @@ | |||
802 | 1 | include_directories (${CMAKE_CURRENT_SOURCE_DIR} | ||
803 | 2 | ${compiz_SOURCE_DIR}/gtk/window-decorator/local-menus/tests | ||
804 | 3 | ${compiz_SOURCE_DIR}/gtk/window-decorator | ||
805 | 4 | ${compiz_SOURCE_DIR}/gtk/window-decorator/local-menus/src) | ||
806 | 5 | |||
807 | 6 | add_executable( | ||
808 | 7 | gtk_window_decorator_force_local_menu_on_test | ||
809 | 8 | |||
810 | 9 | ${CMAKE_CURRENT_SOURCE_DIR}/test-force-local-menu-on.cpp | ||
811 | 10 | ) | ||
812 | 11 | |||
813 | 12 | target_link_libraries( | ||
814 | 13 | gtk_window_decorator_force_local_menu_on_test | ||
815 | 14 | |||
816 | 15 | gtk_window_decorator_local_menus | ||
817 | 16 | |||
818 | 17 | ${GTEST_BOTH_LIBRARIES} | ||
819 | 18 | ${CMAKE_THREAD_LIBS_INIT} # Link in pthread. | ||
820 | 19 | ) | ||
821 | 20 | |||
822 | 21 | add_test (gtk_window_decorator_force_local_menu_on gtk_window_decorator_force_local_menu_on_test) | ||
823 | 0 | 22 | ||
824 | === added file 'gtk/window-decorator/local-menus/tests/force_local_menu_on/test-force-local-menu-on.cpp' | |||
825 | --- gtk/window-decorator/local-menus/tests/force_local_menu_on/test-force-local-menu-on.cpp 1970-01-01 00:00:00 +0000 | |||
826 | +++ gtk/window-decorator/local-menus/tests/force_local_menu_on/test-force-local-menu-on.cpp 2012-02-07 07:03:18 +0000 | |||
827 | @@ -0,0 +1,70 @@ | |||
828 | 1 | #include "test-local-menu.h" | ||
829 | 2 | #include <cstring> | ||
830 | 3 | |||
831 | 4 | #define GLOBAL 0 | ||
832 | 5 | #define LOCAL 1 | ||
833 | 6 | |||
834 | 7 | namespace | ||
835 | 8 | { | ||
836 | 9 | void initializeMetaButtonLayout (MetaButtonLayout *layout) | ||
837 | 10 | { | ||
838 | 11 | memset (layout, 0, sizeof (MetaButtonLayout)); | ||
839 | 12 | |||
840 | 13 | unsigned int i; | ||
841 | 14 | |||
842 | 15 | for (i = 0; i < MAX_BUTTONS_PER_CORNER; i++) | ||
843 | 16 | { | ||
844 | 17 | layout->right_buttons[i] = META_BUTTON_FUNCTION_LAST; | ||
845 | 18 | layout->left_buttons[i] = META_BUTTON_FUNCTION_LAST; | ||
846 | 19 | } | ||
847 | 20 | } | ||
848 | 21 | } | ||
849 | 22 | |||
850 | 23 | class GtkWindowDecoratorTestLocalMenuLayout : | ||
851 | 24 | public GtkWindowDecoratorTestLocalMenu | ||
852 | 25 | { | ||
853 | 26 | public: | ||
854 | 27 | |||
855 | 28 | MetaButtonLayout * getLayout () { return &mLayout; } | ||
856 | 29 | |||
857 | 30 | virtual void SetUp () | ||
858 | 31 | { | ||
859 | 32 | GtkWindowDecoratorTestLocalMenu::SetUp (); | ||
860 | 33 | ::initializeMetaButtonLayout (&mLayout); | ||
861 | 34 | g_settings_set_enum (getSettings (), "menu-mode", LOCAL); | ||
862 | 35 | } | ||
863 | 36 | |||
864 | 37 | private: | ||
865 | 38 | |||
866 | 39 | MetaButtonLayout mLayout; | ||
867 | 40 | }; | ||
868 | 41 | |||
869 | 42 | TEST_F (GtkWindowDecoratorTestLocalMenuLayout, TestForceNoButtonsSet) | ||
870 | 43 | { | ||
871 | 44 | force_local_menus_on (getWindow (), getLayout ()); | ||
872 | 45 | |||
873 | 46 | EXPECT_EQ (getLayout ()->right_buttons[0], META_BUTTON_FUNCTION_LAST); | ||
874 | 47 | EXPECT_EQ (getLayout ()->left_buttons[0], META_BUTTON_FUNCTION_LAST); | ||
875 | 48 | } | ||
876 | 49 | |||
877 | 50 | TEST_F (GtkWindowDecoratorTestLocalMenuLayout, TestForceNoCloseButtonSet) | ||
878 | 51 | { | ||
879 | 52 | getLayout ()->right_buttons[0] = META_BUTTON_FUNCTION_CLOSE; | ||
880 | 53 | |||
881 | 54 | force_local_menus_on (getWindow (), getLayout ()); | ||
882 | 55 | |||
883 | 56 | EXPECT_EQ (getLayout ()->right_buttons[1], META_BUTTON_FUNCTION_WINDOW_MENU); | ||
884 | 57 | EXPECT_EQ (getLayout ()->left_buttons[0], META_BUTTON_FUNCTION_LAST); | ||
885 | 58 | } | ||
886 | 59 | |||
887 | 60 | TEST_F (GtkWindowDecoratorTestLocalMenuLayout, TestForceNoCloseMinimizeMaximizeButtonSet) | ||
888 | 61 | { | ||
889 | 62 | getLayout ()->left_buttons[0] = META_BUTTON_FUNCTION_CLOSE; | ||
890 | 63 | getLayout ()->left_buttons[1] = META_BUTTON_FUNCTION_CLOSE; | ||
891 | 64 | getLayout ()->left_buttons[2] = META_BUTTON_FUNCTION_CLOSE; | ||
892 | 65 | |||
893 | 66 | force_local_menus_on (getWindow (), getLayout ()); | ||
894 | 67 | |||
895 | 68 | EXPECT_EQ (getLayout ()->right_buttons[0], META_BUTTON_FUNCTION_LAST); | ||
896 | 69 | EXPECT_EQ (getLayout ()->left_buttons[3], META_BUTTON_FUNCTION_WINDOW_MENU); | ||
897 | 70 | } | ||
898 | 0 | 71 | ||
899 | === added directory 'gtk/window-decorator/local-menus/tests/show_hide_menu' | |||
900 | === added file 'gtk/window-decorator/local-menus/tests/test-local-menu.h' | |||
901 | --- gtk/window-decorator/local-menus/tests/test-local-menu.h 1970-01-01 00:00:00 +0000 | |||
902 | +++ gtk/window-decorator/local-menus/tests/test-local-menu.h 2012-02-07 07:03:18 +0000 | |||
903 | @@ -0,0 +1,48 @@ | |||
904 | 1 | #include <gtest/gtest.h> | ||
905 | 2 | #include <gmock/gmock.h> | ||
906 | 3 | #include "local-menus.h" | ||
907 | 4 | #include <X11/Xlib.h> | ||
908 | 5 | #include <gio/gio.h> | ||
909 | 6 | |||
910 | 7 | class GtkWindowDecoratorTestLocalMenu : | ||
911 | 8 | public ::testing::Test | ||
912 | 9 | { | ||
913 | 10 | public: | ||
914 | 11 | |||
915 | 12 | WnckWindow * getWindow () { return mWindow; } | ||
916 | 13 | GSettings * getSettings () { return mSettings; } | ||
917 | 14 | |||
918 | 15 | virtual void SetUp () | ||
919 | 16 | { | ||
920 | 17 | gtk_init (NULL, NULL); | ||
921 | 18 | |||
922 | 19 | mXDisplay = XOpenDisplay (NULL); | ||
923 | 20 | mXWindow = XCreateSimpleWindow (mXDisplay, DefaultRootWindow (mXDisplay), 0, 0, 100, 100, 0, 0, 0); | ||
924 | 21 | |||
925 | 22 | XMapRaised (mXDisplay, mXWindow); | ||
926 | 23 | |||
927 | 24 | XFlush (mXDisplay); | ||
928 | 25 | |||
929 | 26 | while (g_main_context_iteration (g_main_context_default (), FALSE)); | ||
930 | 27 | |||
931 | 28 | mWindow = wnck_window_get (mXWindow); | ||
932 | 29 | |||
933 | 30 | g_setenv("GSETTINGS_BACKEND", "memory", true); | ||
934 | 31 | mSettings = g_settings_new ("com.canonical.indicator.appmenu"); | ||
935 | 32 | } | ||
936 | 33 | |||
937 | 34 | virtual void TearDown () | ||
938 | 35 | { | ||
939 | 36 | XDestroyWindow (mXDisplay, mXWindow); | ||
940 | 37 | XCloseDisplay (mXDisplay); | ||
941 | 38 | |||
942 | 39 | g_object_unref (mSettings); | ||
943 | 40 | } | ||
944 | 41 | |||
945 | 42 | private: | ||
946 | 43 | |||
947 | 44 | WnckWindow *mWindow; | ||
948 | 45 | Window mXWindow; | ||
949 | 46 | Display *mXDisplay; | ||
950 | 47 | GSettings *mSettings; | ||
951 | 48 | }; | ||
952 | 0 | 49 | ||
953 | === modified file 'gtk/window-decorator/metacity.c' | |||
954 | --- gtk/window-decorator/metacity.c 2012-01-12 06:48:58 +0000 | |||
955 | +++ gtk/window-decorator/metacity.c 2012-02-07 07:03:18 +0000 | |||
956 | @@ -24,6 +24,7 @@ | |||
957 | 24 | */ | 24 | */ |
958 | 25 | 25 | ||
959 | 26 | #include "gtk-window-decorator.h" | 26 | #include "gtk-window-decorator.h" |
960 | 27 | #include "local-menus.h" | ||
961 | 27 | 28 | ||
962 | 28 | #ifdef USE_METACITY | 29 | #ifdef USE_METACITY |
963 | 29 | 30 | ||
964 | @@ -488,6 +489,8 @@ | |||
965 | 488 | button_layout->right_buttons[i] = META_BUTTON_FUNCTION_LAST; | 489 | button_layout->right_buttons[i] = META_BUTTON_FUNCTION_LAST; |
966 | 489 | } | 490 | } |
967 | 490 | 491 | ||
968 | 492 | force_local_menus_on (d->win, button_layout); | ||
969 | 493 | |||
970 | 491 | *flags = 0; | 494 | *flags = 0; |
971 | 492 | 495 | ||
972 | 493 | if (d->actions & WNCK_WINDOW_ACTION_CLOSE) | 496 | if (d->actions & WNCK_WINDOW_ACTION_CLOSE) |
973 | @@ -558,6 +561,15 @@ | |||
974 | 558 | else | 561 | else |
975 | 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; |
976 | 560 | 563 | ||
977 | 564 | memset (fgeom, 0, sizeof (MetaFrameGeometry)); | ||
978 | 565 | |||
979 | 566 | #ifdef META_HAS_LOCAL_MENUS | ||
980 | 567 | |||
981 | 568 | if (d->layout) | ||
982 | 569 | fgeom->text_layout = g_object_ref (d->layout); | ||
983 | 570 | |||
984 | 571 | #endif | ||
985 | 572 | |||
986 | 561 | meta_theme_calc_geometry (theme, | 573 | meta_theme_calc_geometry (theme, |
987 | 562 | frame_type, | 574 | frame_type, |
988 | 563 | d->frame->text_height, | 575 | d->frame->text_height, |
989 | @@ -567,6 +579,15 @@ | |||
990 | 567 | button_layout, | 579 | button_layout, |
991 | 568 | fgeom); | 580 | fgeom); |
992 | 569 | 581 | ||
993 | 582 | #ifdef META_HAS_LOCAL_MENUS | ||
994 | 583 | |||
995 | 584 | if (d->layout) | ||
996 | 585 | g_object_unref (fgeom->text_layout); | ||
997 | 586 | |||
998 | 587 | fgeom->text_layout = NULL; | ||
999 | 588 | |||
1000 | 589 | #endif | ||
1001 | 590 | |||
1002 | 570 | clip->width += left_width + right_width; | 591 | clip->width += left_width + right_width; |
1003 | 571 | clip->height += top_height + bottom_height; | 592 | clip->height += top_height + bottom_height; |
1004 | 572 | } | 593 | } |
1005 | @@ -601,6 +622,11 @@ | |||
1006 | 601 | GdkColor bg_color; | 622 | GdkColor bg_color; |
1007 | 602 | double bg_alpha; | 623 | double bg_alpha; |
1008 | 603 | 624 | ||
1009 | 625 | memset (&button_layout, 0, sizeof (MetaButtonLayout)); | ||
1010 | 626 | |||
1011 | 627 | for (i = 0; i < MAX_BUTTONS_PER_CORNER; i++) | ||
1012 | 628 | button_layout.left_buttons[i] = button_layout.right_buttons[i] = META_BUTTON_FUNCTION_LAST; | ||
1013 | 629 | |||
1014 | 604 | if (!d->pixmap || !d->picture) | 630 | if (!d->pixmap || !d->picture) |
1015 | 605 | return; | 631 | return; |
1016 | 606 | 632 | ||
1017 | @@ -675,6 +701,9 @@ | |||
1018 | 675 | 701 | ||
1019 | 676 | size = MAX (fgeom.top_height, fgeom.bottom_height); | 702 | size = MAX (fgeom.top_height, fgeom.bottom_height); |
1020 | 677 | 703 | ||
1021 | 704 | if (active_menu) | ||
1022 | 705 | g_object_set_data (G_OBJECT (style_window), "local_menu_rect", &active_menu->rect); | ||
1023 | 706 | |||
1024 | 678 | if (rect.width && size) | 707 | if (rect.width && size) |
1025 | 679 | { | 708 | { |
1026 | 680 | XRenderPictFormat *format; | 709 | XRenderPictFormat *format; |
1027 | @@ -899,6 +928,9 @@ | |||
1028 | 899 | XRenderFreePicture (xdisplay, src); | 928 | XRenderFreePicture (xdisplay, src); |
1029 | 900 | } | 929 | } |
1030 | 901 | 930 | ||
1031 | 931 | if (active_menu) | ||
1032 | 932 | g_object_set_data (G_OBJECT (style_window), "local_menu_rect", NULL); | ||
1033 | 933 | |||
1034 | 902 | copy_to_front_buffer (d); | 934 | copy_to_front_buffer (d); |
1035 | 903 | 935 | ||
1036 | 904 | if (d->frame_window) | 936 | if (d->frame_window) |
1037 | @@ -1078,6 +1110,15 @@ | |||
1038 | 1078 | break; | 1110 | break; |
1039 | 1079 | #endif | 1111 | #endif |
1040 | 1080 | 1112 | ||
1041 | 1113 | #ifdef META_HAS_LOCAL_MENUS | ||
1042 | 1114 | case BUTTON_WINDOW_MENU: | ||
1043 | 1115 | if (!meta_button_present (&button_layout, META_BUTTON_FUNCTION_WINDOW_MENU)) | ||
1044 | 1116 | return FALSE; | ||
1045 | 1117 | |||
1046 | 1118 | space = &fgeom.window_menu_rect; | ||
1047 | 1119 | break; | ||
1048 | 1120 | #endif | ||
1049 | 1121 | |||
1050 | 1081 | default: | 1122 | default: |
1051 | 1082 | return FALSE; | 1123 | return FALSE; |
1052 | 1083 | } | 1124 | } |
1053 | @@ -1266,6 +1307,8 @@ | |||
1054 | 1266 | MetaTheme *theme; | 1307 | MetaTheme *theme; |
1055 | 1267 | GdkRectangle clip; | 1308 | GdkRectangle clip; |
1056 | 1268 | 1309 | ||
1057 | 1310 | memset (&fgeom, 0, sizeof (MetaFrameGeometry)); | ||
1058 | 1311 | |||
1059 | 1269 | theme = meta_theme_get_current (); | 1312 | theme = meta_theme_get_current (); |
1060 | 1270 | 1313 | ||
1061 | 1271 | meta_get_decoration_geometry (d, theme, &flags, &fgeom, &button_layout, | 1314 | meta_get_decoration_geometry (d, theme, &flags, &fgeom, &button_layout, |
1062 | @@ -1490,6 +1533,11 @@ | |||
1063 | 1490 | return META_BUTTON_FUNCTION_UNSTICK; | 1533 | return META_BUTTON_FUNCTION_UNSTICK; |
1064 | 1491 | #endif | 1534 | #endif |
1065 | 1492 | 1535 | ||
1066 | 1536 | #ifdef META_HAS_LOCAL_MENUS | ||
1067 | 1537 | else if (strcmp (str, "window_menu") == 0) | ||
1068 | 1538 | return META_BUTTON_FUNCTION_WINDOW_MENU; | ||
1069 | 1539 | #endif | ||
1070 | 1540 | |||
1071 | 1493 | else | 1541 | else |
1072 | 1494 | return META_BUTTON_FUNCTION_LAST; | 1542 | return META_BUTTON_FUNCTION_LAST; |
1073 | 1495 | } | 1543 | } |
1074 | 1496 | 1544 | ||
1075 | === modified file 'gtk/window-decorator/wnck.c' | |||
1076 | --- gtk/window-decorator/wnck.c 2011-10-13 09:53:38 +0000 | |||
1077 | +++ gtk/window-decorator/wnck.c 2012-02-07 07:03:18 +0000 | |||
1078 | @@ -727,7 +727,8 @@ | |||
1079 | 727 | stick_button_event, | 727 | stick_button_event, |
1080 | 728 | unshade_button_event, | 728 | unshade_button_event, |
1081 | 729 | unabove_button_event, | 729 | unabove_button_event, |
1083 | 730 | unstick_button_event | 730 | unstick_button_event, |
1084 | 731 | window_menu_button_event | ||
1085 | 731 | }; | 732 | }; |
1086 | 732 | 733 | ||
1087 | 733 | d = calloc (1, sizeof (decor_t)); | 734 | 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?