From efb948846fa598f9d14e6bfbba9591a3bb8819ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Tue, 30 Oct 2012 18:07:02 -0400 Subject: [PATCH] window: Only advertise fullscreen menu item if client supports it If the client doesn't set a fullscreen handler, we can't go fullscreen and shouldn't advertise that in the window menu. The menu implementation is a little simplistic, so we just move the "Fullscreen" entry to the end of the list and don't count it if we don't want it in the menu. https://bugs.freedesktop.org/show_bug.cgi?id=47751 https://bugs.freedesktop.org/show_bug.cgi?id=48106 --- clients/window.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/clients/window.c b/clients/window.c index ece9229d..d5a14dd0 100644 --- a/clients/window.c +++ b/clients/window.c @@ -1766,24 +1766,24 @@ frame_menu_func(struct window *window, int index, void *data) else display_exit(window->display); break; - case 1: /* fullscreen */ - /* we don't have a way to get out of fullscreen for now */ - if (window->fullscreen_handler) - window->fullscreen_handler(window, window->user_data); - break; - case 2: /* move to workspace above */ + case 1: /* move to workspace above */ display = window->display; if (display->workspace > 0) workspace_manager_move_surface(display->workspace_manager, window->surface, display->workspace - 1); break; - case 3: /* move to workspace below */ + case 2: /* move to workspace below */ display = window->display; if (display->workspace < display->workspace_count - 1) workspace_manager_move_surface(display->workspace_manager, window->surface, display->workspace + 1); + case 3: /* fullscreen */ + /* we don't have a way to get out of fullscreen for now */ + if (window->fullscreen_handler) + window->fullscreen_handler(window, window->user_data); + break; break; } } @@ -1793,16 +1793,22 @@ window_show_frame_menu(struct window *window, struct input *input, uint32_t time) { int32_t x, y; + int count; static const char *entries[] = { - "Close", "Fullscreen", - "Move to workspace above", "Move to workspace below" + "Close", + "Move to workspace above", "Move to workspace below", + "Fullscreen" }; + if (window->fullscreen_handler) + count = ARRAY_LENGTH(entries); + else + count = ARRAY_LENGTH(entries) - 1; + input_get_position(input, &x, &y); window_show_menu(window->display, input, time, window, - x - 10, y - 10, frame_menu_func, entries, - ARRAY_LENGTH(entries)); + x - 10, y - 10, frame_menu_func, entries, count); } static int