1 #include "kernel/debug.h"
2 #include "kernel/menu.h"
3 #include "kernel/menuframe.h"
4 #include "kernel/screen.h"
5 #include "kernel/client.h"
6 #include "kernel/openbox.h"
7 #include "kernel/frame.h"
12 #define CLIENT_MENU_NAME "client-menu"
13 #define SEND_TO_MENU_NAME "client-send-to-menu"
14 #define LAYER_MENU_NAME "client-layer-menu"
36 static void client_update(ObMenuFrame *frame, gpointer data)
38 ObMenu *menu = frame->menu;
42 frame->show_title = FALSE;
44 for (it = menu->entries; it; it = g_list_next(it)) {
46 if (e->type == OB_MENU_ENTRY_TYPE_NORMAL)
47 e->data.normal.enabled = !!frame->client;
53 e = menu_find_entry_id(menu, CLIENT_ICONIFY);
54 e->data.normal.enabled = frame->client->functions & OB_CLIENT_FUNC_ICONIFY;
56 e = menu_find_entry_id(menu, CLIENT_MAXIMIZE);
57 e->data.normal.enabled =frame->client->functions & OB_CLIENT_FUNC_MAXIMIZE;
59 e = menu_find_entry_id(menu, CLIENT_SHADE);
60 e->data.normal.enabled = frame->client->functions & OB_CLIENT_FUNC_SHADE;
62 e = menu_find_entry_id(menu, CLIENT_MOVE);
63 e->data.normal.enabled = frame->client->functions & OB_CLIENT_FUNC_MOVE;
65 e = menu_find_entry_id(menu, CLIENT_RESIZE);
66 e->data.normal.enabled = frame->client->functions & OB_CLIENT_FUNC_RESIZE;
68 e = menu_find_entry_id(menu, CLIENT_CLOSE);
69 e->data.normal.enabled = frame->client->functions & OB_CLIENT_FUNC_CLOSE;
72 static void layer_update(ObMenuFrame *frame, gpointer data)
74 ObMenu *menu = frame->menu;
78 for (it = menu->entries; it; it = g_list_next(it)) {
80 if (e->type == OB_MENU_ENTRY_TYPE_NORMAL)
81 e->data.normal.enabled = !!frame->client;
87 e = menu_find_entry_id(menu, LAYER_TOP);
88 e->data.normal.enabled = !frame->client->above;
90 e = menu_find_entry_id(menu, LAYER_NORMAL);
91 e->data.normal.enabled = (frame->client->above || frame->client->below);
93 e = menu_find_entry_id(menu, LAYER_BOTTOM);
94 e->data.normal.enabled = !frame->client->below;
97 static void send_to_update(ObMenuFrame *frame, gpointer data)
99 ObMenu *menu = frame->menu;
104 menu_clear_entries(menu);
109 for (i = 0; i <= screen_num_desktops; ++i) {
113 if (i >= screen_num_desktops) {
114 menu_add_separator(menu, -1);
117 name = _("All desktops");
120 name = screen_desktop_names[i];
123 act = action_from_string("SendToDesktop");
124 act->data.sendto.desk = desk;
125 act->data.sendto.follow = FALSE;
126 acts = g_slist_prepend(NULL, act);
127 menu_add_normal(menu, desk, name, acts);
129 if (frame->client->desktop == desk) {
130 ObMenuEntry *e = menu_find_entry_id(menu, desk);
132 e->data.normal.enabled = FALSE;
137 void client_menu_startup()
142 menu = menu_new(LAYER_MENU_NAME, _("Layer"), NULL);
143 menu_set_update_func(menu, layer_update);
145 acts = g_slist_prepend(NULL, action_from_string("SendToTopLayer"));
146 menu_add_normal(menu, LAYER_TOP, _("Always on top"), acts);
148 acts = g_slist_prepend(NULL, action_from_string("SendToNormalLayer"));
149 menu_add_normal(menu, LAYER_NORMAL, _("Normal"), acts);
151 acts = g_slist_prepend(NULL, action_from_string("SendToBottomLayer"));
152 menu_add_normal(menu, LAYER_BOTTOM, _("Always on bottom"),acts);
155 menu = menu_new(SEND_TO_MENU_NAME, _("Send to desktop"), NULL);
156 menu_set_update_func(menu, send_to_update);
159 menu = menu_new(CLIENT_MENU_NAME, _("Client menu"), NULL);
160 menu_set_update_func(menu, client_update);
162 menu_add_submenu(menu, CLIENT_SEND_TO, SEND_TO_MENU_NAME);
164 menu_add_submenu(menu, CLIENT_LAYER, LAYER_MENU_NAME);
166 acts = g_slist_prepend(NULL, action_from_string("Iconify"));
167 menu_add_normal(menu, CLIENT_ICONIFY, _("Iconify"), acts);
169 acts = g_slist_prepend(NULL, action_from_string("ToggleMaximizeFull"));
170 menu_add_normal(menu, CLIENT_MAXIMIZE, _("Maximize"), acts);
172 acts = g_slist_prepend(NULL, action_from_string("Raise"));
173 menu_add_normal(menu, CLIENT_RAISE, _("Raise to top"), acts);
175 acts = g_slist_prepend(NULL, action_from_string("Lower"));
176 menu_add_normal(menu, CLIENT_LOWER, _("Lower to bottom"),acts);
178 acts = g_slist_prepend(NULL, action_from_string("ToggleShade"));
179 menu_add_normal(menu, CLIENT_SHADE, _("Roll up/down"), acts);
181 acts = g_slist_prepend(NULL, action_from_string("ToggleDecorations"));
182 menu_add_normal(menu, CLIENT_DECORATE, _("Decorate"), acts);
184 menu_add_separator(menu, -1);
186 acts = g_slist_prepend(NULL, action_from_string("KeyboardMove"));
187 menu_add_normal(menu, CLIENT_MOVE, _("Move"), acts);
189 acts = g_slist_prepend(NULL, action_from_string("KeyboardResize"));
190 menu_add_normal(menu, CLIENT_RESIZE, _("Resize"), acts);
192 menu_add_separator(menu, -1);
194 acts = g_slist_prepend(NULL, action_from_string("Close"));
195 menu_add_normal(menu, CLIENT_CLOSE, _("Close"), acts);