]> Dogcows Code - chaz/openbox/blob - plugins/menu/client_menu.c
layers submenu on client
[chaz/openbox] / plugins / menu / client_menu.c
1 #include <glib.h>
2
3 #include "kernel/menu.h"
4 #include "kernel/screen.h"
5 #include "kernel/client.h"
6 #include "kernel/openbox.h"
7
8 #include "kernel/frame.h"
9
10 static char *PLUGIN_NAME = "client_menu";
11
12 static Menu *send_to_menu;
13 static Menu *layer_menu;
14
15 typedef struct {
16
17 } Client_Menu_Data;
18
19 #define CLIENT_MENU(m) ((Menu *)m)
20 #define CLIENT_MENU_DATA(m) ((Client_Menu_Data *)((Menu *)m)->plugin_data)
21
22
23 void client_menu_clean_up(Menu *m) {
24 }
25
26 void client_send_to_update(Menu *self)
27 {
28 guint i;
29
30 for (i = 0; i < screen_num_desktops; ++i) {
31 MenuEntry *e;
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);
37 }
38
39 menu_render_full(self);
40 }
41
42 void client_menu_show(Menu *self, int x, int y, Client *client)
43 {
44 int newy;
45 g_assert(!self->invalid);
46 g_assert(client);
47
48 newy = client->frame->area.y + client->frame->a_focused_title->area.height;
49
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));
56
57 if (!self->shown) {
58 XMapWindow(ob_display, self->frame);
59 stacking_raise(MENU_AS_WINDOW(self));
60 self->shown = TRUE;
61 } else if (self->shown && self->open_submenu) {
62 menu_hide(self->open_submenu);
63 }
64 }
65
66 void plugin_setup_config() { }
67
68 void plugin_shutdown() { }
69
70 void plugin_destroy (Menu *m)
71 {
72 }
73
74 void *plugin_create() /* TODO: need config */
75 {
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",
79 send_to_menu));
80 send_to_menu->parent = m;
81
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",
95 layer_menu));
96 layer_menu->parent = m;
97
98 /* send to desktop
99 iconify
100 raise
101 lower
102 close
103 kill
104 shade
105 omnipresent
106 decorations
107 */
108 return (void *)m;
109 }
110
111 void plugin_startup()
112 {
113 Menu *t;
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);
117
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")));
125
126 t = (Menu *)plugin_create("client_menu");
127 }
128
This page took 0.048074 seconds and 5 git commands to generate.