]> Dogcows Code - chaz/openbox/blob - plugins/menu/client_menu.c
rename 'xinerama' stuff to 'monitors' to be more generic and descriptive.
[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 #include "render/theme.h"
11
12 static char *PLUGIN_NAME = "client_menu";
13
14 static Menu *send_to_menu;
15 static Menu *layer_menu;
16
17 typedef struct {
18
19 } Client_Menu_Data;
20
21 #define CLIENT_MENU(m) ((Menu *)m)
22 #define CLIENT_MENU_DATA(m) ((Client_Menu_Data *)((Menu *)m)->plugin_data)
23
24 void client_menu_clean_up(Menu *m) {
25 }
26
27 void client_send_to_update(Menu *self)
28 {
29 guint i = 0;
30 GList *it = self->entries;
31
32 /* check if we have to update. lame */
33 while (it != NULL) {
34 if (i >= screen_num_desktops)
35 break;
36 if (strcmp(screen_desktop_names[i],
37 ((MenuEntry *)it->data)->label) != 0)
38 break;
39 ++i;
40 it = it->next;
41 }
42
43 if (it != NULL || i != screen_num_desktops) {
44 menu_clear(self);
45 g_message("update");
46 for (i = 0; i < screen_num_desktops; ++i) {
47 MenuEntry *e;
48 Action *a = action_from_string("sendtodesktop");
49 a->data.sendto.desk = i;
50 a->data.sendto.follow = FALSE;
51 e = menu_entry_new(screen_desktop_names[i], a);
52 menu_add_entry(self, e);
53 }
54
55 menu_render_full(self);
56 }
57 }
58
59 #if 0
60 void client_menu_show(Menu *self, int x, int y, Client *client)
61 {
62 int newy;
63 g_assert(!self->invalid);
64 g_assert(client);
65
66 newy = MAX(client->frame->area.y + client->frame->size.top, y);
67 newy -= ob_rr_theme->bwidth;
68
69 /* XXX do xinerama shit like in menu.c! im not coding it now because
70 this function isnt even being used right now... */
71 POINT_SET(self->location,
72 MIN(x, screen_physical_size.width - self->size.width -
73 ob_rr_theme->bwidth * 2),
74 MIN(newy, screen_physical_size.height - self->size.height -
75 ob_rr_theme->bwidth * 2));
76 XMoveWindow(ob_display, self->frame, self->location.x, self->location.y);
77
78 if (!self->shown) {
79 XMapWindow(ob_display, self->frame);
80 stacking_raise(MENU_AS_WINDOW(self));
81 self->shown = TRUE;
82 } else if (self->shown && self->open_submenu) {
83 menu_hide(self->open_submenu);
84 }
85 }
86 #endif
87
88 void plugin_setup_config() { }
89
90 void plugin_shutdown() { }
91
92 void plugin_destroy (Menu *m)
93 {
94 }
95
96 void *plugin_create() /* TODO: need config */
97 {
98 Menu *m = menu_new_full(NULL, "client-menu", NULL,
99 /*client_menu_show*/NULL, NULL);
100 menu_add_entry(m, menu_entry_new_submenu("Send To Workspace",
101 send_to_menu));
102 send_to_menu->parent = m;
103
104 menu_add_entry(m, menu_entry_new("Iconify",
105 action_from_string("iconify")));
106 menu_add_entry(m, menu_entry_new("Raise",
107 action_from_string("raise")));
108 menu_add_entry(m, menu_entry_new("Lower",
109 action_from_string("lower")));
110 menu_add_entry(m, menu_entry_new("Close",
111 action_from_string("close")));
112 menu_add_entry(m, menu_entry_new("Shade",
113 action_from_string("toggleshade")));
114 menu_add_entry(m, menu_entry_new("Omnipresent",
115 action_from_string("toggleomnipresent")));
116 menu_add_entry(m, menu_entry_new("Decorations",
117 action_from_string("toggledecorations")));
118 menu_add_entry(m, menu_entry_new_submenu("Layers",
119 layer_menu));
120 layer_menu->parent = m;
121
122 /* send to desktop
123 iconify
124 raise
125 lower
126 close
127 kill
128 shade
129 omnipresent
130 decorations
131 */
132 return (void *)m;
133 }
134
135 void plugin_startup()
136 {
137 Menu *t;
138 /* create a Send To Workspace Menu */
139 send_to_menu = menu_new_full(NULL, "send-to-workspace",
140 NULL, NULL, client_send_to_update);
141
142 layer_menu = menu_new(NULL, "layer", NULL);
143 menu_add_entry(layer_menu, menu_entry_new("Top Layer",
144 action_from_string("sendtotoplayer")));
145 menu_add_entry(layer_menu, menu_entry_new("Normal Layer",
146 action_from_string("sendtonormallayer")));
147 menu_add_entry(layer_menu, menu_entry_new("Bottom Layer",
148 action_from_string("sendtobottomlayer")));
149
150 t = (Menu *)plugin_create("client_menu");
151 }
152
This page took 0.038333 seconds and 4 git commands to generate.