3 #include "kernel/menu.h"
4 #include "kernel/screen.h"
5 #include "kernel/client.h"
6 #include "kernel/openbox.h"
8 #include "kernel/frame.h"
10 #include "render/theme.h"
13 static char *PLUGIN_NAME = "client_menu";
16 static ObMenu *send_to_menu;
17 static ObMenu *layer_menu;
23 #define CLIENT_MENU(m) ((ObMenu *)m)
24 #define CLIENT_MENU_DATA(m) ((Client_Menu_Data *)((ObMenu *)m)->plugin_data)
26 void client_menu_clean_up(ObMenu *m) {
29 void client_send_to_update(ObMenu *self)
32 GList *it = self->entries;
34 /* check if we have to update. lame */
36 if (i >= screen_num_desktops)
38 if (strcmp(screen_desktop_names[i],
39 ((ObMenuEntry *)it->data)->label) != 0)
45 if (it != NULL || i != screen_num_desktops) {
48 for (i = 0; i < screen_num_desktops; ++i) {
50 Action *a = action_from_string("sendtodesktop");
51 a->data.sendto.desk = i;
52 a->data.sendto.follow = FALSE;
53 e = menu_entry_new(screen_desktop_names[i], a);
54 menu_add_entry(self, e);
57 menu_render_full(self);
62 void client_menu_show(ObMenu *self, int x, int y, Client *client)
65 g_assert(!self->invalid);
68 newy = MAX(client->frame->area.y + client->frame->size.top, y);
69 newy -= ob_rr_theme->bwidth;
71 /* XXX do xinerama shit like in menu.c! im not coding it now because
72 this function isnt even being used right now... */
73 POINT_SET(self->location,
74 MIN(x, screen_physical_size.width - self->size.width -
75 ob_rr_theme->bwidth * 2),
76 MIN(newy, screen_physical_size.height - self->size.height -
77 ob_rr_theme->bwidth * 2));
78 XMoveWindow(ob_display, self->frame, self->location.x, self->location.y);
81 XMapWindow(ob_display, self->frame);
82 stacking_raise(MENU_AS_WINDOW(self));
84 } else if (self->shown && self->open_submenu) {
85 menu_hide(self->open_submenu);
90 void plugin_setup_config() { }
92 void plugin_shutdown() { }
94 void plugin_destroy (ObMenu *m)
98 void *plugin_create() /* TODO: need config */
100 ObMenu *m = menu_new_full(NULL, "client-menu", NULL,
101 /*client_menu_show*/NULL, NULL);
102 menu_add_entry(m, menu_entry_new_submenu("Send To Workspace",
104 send_to_menu->parent = m;
106 menu_add_entry(m, menu_entry_new("Iconify",
107 action_from_string("iconify")));
108 menu_add_entry(m, menu_entry_new("Raise",
109 action_from_string("raise")));
110 menu_add_entry(m, menu_entry_new("Lower",
111 action_from_string("lower")));
112 menu_add_entry(m, menu_entry_new("Close",
113 action_from_string("close")));
114 menu_add_entry(m, menu_entry_new("Shade",
115 action_from_string("toggleshade")));
116 menu_add_entry(m, menu_entry_new("Omnipresent",
117 action_from_string("toggleomnipresent")));
118 menu_add_entry(m, menu_entry_new("Decorations",
119 action_from_string("toggledecorations")));
120 menu_add_entry(m, menu_entry_new_submenu("Layers",
122 layer_menu->parent = m;
137 void plugin_startup()
140 /* create a Send To Workspace ObMenu */
141 send_to_menu = menu_new_full(NULL, "send-to-workspace",
142 NULL, NULL, client_send_to_update);
144 layer_menu = menu_new(NULL, "layer", NULL);
145 menu_add_entry(layer_menu, menu_entry_new("Top Layer",
146 action_from_string("sendtotoplayer")));
147 menu_add_entry(layer_menu, menu_entry_new("Normal Layer",
148 action_from_string("sendtonormallayer")));
149 menu_add_entry(layer_menu, menu_entry_new("Bottom Layer",
150 action_from_string("sendtobottomlayer")));
152 t = (ObMenu *)plugin_create("client_menu");