]> icculus.org git repositories - mikachu/openbox.git/blob - plugins/menu/client_menu.c
replace the focus_backup with the screen_support_win, we dont need 2 offscreen windows.
[mikachu/openbox.git] / 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 #if 0
13 static char *PLUGIN_NAME = "client_menu";
14 #endif
15
16 static Menu *send_to_menu;
17 static Menu *layer_menu;
18
19 typedef struct {
20     gint foo;
21 } Client_Menu_Data;
22
23 #define CLIENT_MENU(m) ((Menu *)m)
24 #define CLIENT_MENU_DATA(m) ((Client_Menu_Data *)((Menu *)m)->plugin_data)
25
26 void client_menu_clean_up(Menu *m) {
27 }
28
29 void client_send_to_update(Menu *self)
30 {
31     guint i = 0;
32     GList *it = self->entries;
33     
34     /* check if we have to update. lame */
35     while (it != NULL) {
36         if (i >= screen_num_desktops)
37             break;
38         if (strcmp(screen_desktop_names[i],
39                    ((MenuEntry *)it->data)->label) != 0)
40             break;
41         ++i;
42         it = it->next;
43     }
44
45     if (it != NULL || i != screen_num_desktops) {
46         menu_clear(self);
47         g_message("update");
48         for (i = 0; i < screen_num_desktops; ++i) {
49             MenuEntry *e;
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);
55         }
56
57         menu_render_full(self);
58     }
59 }
60
61 #if 0
62 void client_menu_show(Menu *self, int x, int y, Client *client)
63 {
64     int newy;
65     g_assert(!self->invalid);
66     g_assert(client);
67     
68     newy = MAX(client->frame->area.y + client->frame->size.top, y);
69     newy -= ob_rr_theme->bwidth;
70     
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);
79
80     if (!self->shown) {
81         XMapWindow(ob_display, self->frame);
82         stacking_raise(MENU_AS_WINDOW(self));
83         self->shown = TRUE;
84     } else if (self->shown && self->open_submenu) {
85         menu_hide(self->open_submenu);
86     }
87 }
88 #endif
89
90 void plugin_setup_config() { }
91
92 void plugin_shutdown() { }
93
94 void plugin_destroy (Menu *m)
95 {
96 }
97
98 void *plugin_create() /* TODO: need config */
99 {
100     Menu *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",
103                                              send_to_menu));
104     send_to_menu->parent = m;
105
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",
121                                              layer_menu));
122     layer_menu->parent = m;
123
124     /* send to desktop
125        iconify
126        raise
127        lower
128        close
129        kill
130        shade
131        omnipresent
132        decorations
133     */
134     return (void *)m;
135 }
136
137 void plugin_startup()
138 {
139     Menu *t;
140     /* create a Send To Workspace Menu */
141     send_to_menu = menu_new_full(NULL, "send-to-workspace",
142                           NULL, NULL, client_send_to_update);
143     
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")));
151                           
152     t = (Menu *)plugin_create("client_menu");
153 }
154