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 static char *PLUGIN_NAME = "client_menu";
12 static Menu *send_to_menu;
13 static Menu *layer_menu;
19 #define CLIENT_MENU(m) ((Menu *)m)
20 #define CLIENT_MENU_DATA(m) ((Client_Menu_Data *)((Menu *)m)->plugin_data)
23 void client_menu_clean_up(Menu *m) {
26 void client_send_to_update(Menu *self)
30 for (i = 0; i < screen_num_desktops; ++i) {
32 Action *a = action_from_string("sendtodesktop");
33 a->data.sendto.desk = i;
34 a->data.sendto.follow = FALSE;
35 e = menu_entry_new(screen_desktop_names[i], a);
36 menu_add_entry(self, e);
39 menu_render_full(self);
42 void client_menu_show(Menu *self, int x, int y, Client *client)
45 g_assert(!self->invalid);
48 newy = client->frame->area.y + client->frame->a_focused_title->area.height;
50 XMoveWindow(ob_display, self->frame,
51 MIN(x, screen_physical_size.width - self->size.width),
52 MIN(newy, screen_physical_size.height - self->size.height));
53 POINT_SET(self->location,
54 MIN(x, screen_physical_size.width - self->size.width),
55 MIN(newy, screen_physical_size.height - self->size.height));
58 XMapWindow(ob_display, self->frame);
59 stacking_raise(MENU_AS_WINDOW(self));
61 } else if (self->shown && self->open_submenu) {
62 menu_hide(self->open_submenu);
66 void plugin_setup_config() { }
68 void plugin_shutdown() { }
70 void plugin_destroy (Menu *m)
74 void *plugin_create() /* TODO: need config */
76 Menu *m = menu_new_full(NULL, "client-menu", NULL,
77 client_menu_show, NULL);
78 menu_add_entry(m, menu_entry_new_submenu("Send To Workspace",
80 send_to_menu->parent = m;
82 menu_add_entry(m, menu_entry_new("Iconify",
83 action_from_string("iconify")));
84 menu_add_entry(m, menu_entry_new("Raise",
85 action_from_string("raise")));
86 menu_add_entry(m, menu_entry_new("Lower",
87 action_from_string("lower")));
88 menu_add_entry(m, menu_entry_new("Close",
89 action_from_string("close")));
90 menu_add_entry(m, menu_entry_new("Shade",
91 action_from_string("toggleshade")));
92 menu_add_entry(m, menu_entry_new("Omnipresent",
93 action_from_string("toggleomnipresent")));
94 menu_add_entry(m, menu_entry_new_submenu("Layers",
96 layer_menu->parent = m;
111 void plugin_startup()
114 /* create a Send To Workspace Menu */
115 send_to_menu = menu_new_full(NULL, "send-to-workspace",
116 NULL, NULL, client_send_to_update);
118 layer_menu = menu_new(NULL, "layer", NULL);
119 menu_add_entry(layer_menu, menu_entry_new("Top Layer",
120 action_from_string("sendtotoplayer")));
121 menu_add_entry(layer_menu, menu_entry_new("Normal Layer",
122 action_from_string("sendtonormallayer")));
123 menu_add_entry(layer_menu, menu_entry_new("Bottom Layer",
124 action_from_string("sendtobottomlayer")));
126 t = (Menu *)plugin_create("client_menu");