]> Dogcows Code - chaz/openbox/blob - plugins/menu/client_menu.c
let the client menu open below the top of the window, just limit it at the titlebar
[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
25 void client_menu_clean_up(Menu *m) {
26 }
27
28 void client_send_to_update(Menu *self)
29 {
30 guint i;
31
32 for (i = 0; i < screen_num_desktops; ++i) {
33 MenuEntry *e;
34 Action *a = action_from_string("sendtodesktop");
35 a->data.sendto.desk = i;
36 a->data.sendto.follow = FALSE;
37 e = menu_entry_new(screen_desktop_names[i], a);
38 menu_add_entry(self, e);
39 }
40
41 menu_render_full(self);
42 }
43
44 void client_menu_show(Menu *self, int x, int y, Client *client)
45 {
46 int newy;
47 g_assert(!self->invalid);
48 g_assert(client);
49
50 newy = MAX(client->frame->area.y +
51 client->frame->a_focused_title->area.height + theme_bwidth,
52 y - theme_bwidth);
53
54 POINT_SET(self->location,
55 MIN(x, screen_physical_size.width - self->size.width -
56 theme_bwidth * 2),
57 MIN(newy, screen_physical_size.height - self->size.height -
58 theme_bwidth * 2));
59 XMoveWindow(ob_display, self->frame, self->location.x, self->location.y);
60
61 if (!self->shown) {
62 XMapWindow(ob_display, self->frame);
63 stacking_raise(MENU_AS_WINDOW(self));
64 self->shown = TRUE;
65 } else if (self->shown && self->open_submenu) {
66 menu_hide(self->open_submenu);
67 }
68 }
69
70 void plugin_setup_config() { }
71
72 void plugin_shutdown() { }
73
74 void plugin_destroy (Menu *m)
75 {
76 }
77
78 void *plugin_create() /* TODO: need config */
79 {
80 Menu *m = menu_new_full(NULL, "client-menu", NULL,
81 client_menu_show, NULL);
82 menu_add_entry(m, menu_entry_new_submenu("Send To Workspace",
83 send_to_menu));
84 send_to_menu->parent = m;
85
86 menu_add_entry(m, menu_entry_new("Iconify",
87 action_from_string("iconify")));
88 menu_add_entry(m, menu_entry_new("Raise",
89 action_from_string("raise")));
90 menu_add_entry(m, menu_entry_new("Lower",
91 action_from_string("lower")));
92 menu_add_entry(m, menu_entry_new("Close",
93 action_from_string("close")));
94 menu_add_entry(m, menu_entry_new("Shade",
95 action_from_string("toggleshade")));
96 menu_add_entry(m, menu_entry_new("Omnipresent",
97 action_from_string("toggleomnipresent")));
98 menu_add_entry(m, menu_entry_new("Decorations",
99 action_from_string("toggledecorations")));
100 menu_add_entry(m, menu_entry_new_submenu("Layers",
101 layer_menu));
102 layer_menu->parent = m;
103
104 /* send to desktop
105 iconify
106 raise
107 lower
108 close
109 kill
110 shade
111 omnipresent
112 decorations
113 */
114 return (void *)m;
115 }
116
117 void plugin_startup()
118 {
119 Menu *t;
120 /* create a Send To Workspace Menu */
121 send_to_menu = menu_new_full(NULL, "send-to-workspace",
122 NULL, NULL, client_send_to_update);
123
124 layer_menu = menu_new(NULL, "layer", NULL);
125 menu_add_entry(layer_menu, menu_entry_new("Top Layer",
126 action_from_string("sendtotoplayer")));
127 menu_add_entry(layer_menu, menu_entry_new("Normal Layer",
128 action_from_string("sendtonormallayer")));
129 menu_add_entry(layer_menu, menu_entry_new("Bottom Layer",
130 action_from_string("sendtobottomlayer")));
131
132 t = (Menu *)plugin_create("client_menu");
133 }
134
This page took 0.043654 seconds and 5 git commands to generate.