]>
Dogcows Code - chaz/openbox/blob - plugins/menu/client_menu.c
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 #include "render/theme.h"
12 static char *PLUGIN_NAME
= "client_menu";
14 static Menu
*send_to_menu
;
15 static Menu
*layer_menu
;
21 #define CLIENT_MENU(m) ((Menu *)m)
22 #define CLIENT_MENU_DATA(m) ((Client_Menu_Data *)((Menu *)m)->plugin_data)
24 void client_menu_clean_up(Menu
*m
) {
27 void client_send_to_update(Menu
*self
)
30 GList
*it
= self
->entries
;
32 /* check if we have to update. lame */
34 if (i
>= screen_num_desktops
)
36 if (strcmp(screen_desktop_names
[i
],
37 ((MenuEntry
*)it
->data
)->label
) != 0)
43 if (it
!= NULL
|| i
!= screen_num_desktops
) {
46 for (i
= 0; i
< screen_num_desktops
; ++i
) {
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
);
55 menu_render_full(self
);
59 void client_menu_show(Menu
*self
, int x
, int y
, Client
*client
)
62 g_assert(!self
->invalid
);
65 newy
= MAX(client
->frame
->area
.y
+ client
->frame
->size
.top
, y
);
66 newy
-= ob_rr_theme
->bwidth
;
68 /* XXX do xinerama shit like in menu.c! im not coding it now because
69 this function isnt even being used right now... */
70 POINT_SET(self
->location
,
71 MIN(x
, screen_physical_size
.width
- self
->size
.width
-
72 ob_rr_theme
->bwidth
* 2),
73 MIN(newy
, screen_physical_size
.height
- self
->size
.height
-
74 ob_rr_theme
->bwidth
* 2));
75 XMoveWindow(ob_display
, self
->frame
, self
->location
.x
, self
->location
.y
);
78 XMapWindow(ob_display
, self
->frame
);
79 stacking_raise(MENU_AS_WINDOW(self
));
81 } else if (self
->shown
&& self
->open_submenu
) {
82 menu_hide(self
->open_submenu
);
86 void plugin_setup_config() { }
88 void plugin_shutdown() { }
90 void plugin_destroy (Menu
*m
)
94 void *plugin_create() /* TODO: need config */
96 Menu
*m
= menu_new_full(NULL
, "client-menu", NULL
,
97 /*client_menu_show*/NULL
, NULL
);
98 menu_add_entry(m
, menu_entry_new_submenu("Send To Workspace",
100 send_to_menu
->parent
= m
;
102 menu_add_entry(m
, menu_entry_new("Iconify",
103 action_from_string("iconify")));
104 menu_add_entry(m
, menu_entry_new("Raise",
105 action_from_string("raise")));
106 menu_add_entry(m
, menu_entry_new("Lower",
107 action_from_string("lower")));
108 menu_add_entry(m
, menu_entry_new("Close",
109 action_from_string("close")));
110 menu_add_entry(m
, menu_entry_new("Shade",
111 action_from_string("toggleshade")));
112 menu_add_entry(m
, menu_entry_new("Omnipresent",
113 action_from_string("toggleomnipresent")));
114 menu_add_entry(m
, menu_entry_new("Decorations",
115 action_from_string("toggledecorations")));
116 menu_add_entry(m
, menu_entry_new_submenu("Layers",
118 layer_menu
->parent
= m
;
133 void plugin_startup()
136 /* create a Send To Workspace Menu */
137 send_to_menu
= menu_new_full(NULL
, "send-to-workspace",
138 NULL
, NULL
, client_send_to_update
);
140 layer_menu
= menu_new(NULL
, "layer", NULL
);
141 menu_add_entry(layer_menu
, menu_entry_new("Top Layer",
142 action_from_string("sendtotoplayer")));
143 menu_add_entry(layer_menu
, menu_entry_new("Normal Layer",
144 action_from_string("sendtonormallayer")));
145 menu_add_entry(layer_menu
, menu_entry_new("Bottom Layer",
146 action_from_string("sendtobottomlayer")));
148 t
= (Menu
*)plugin_create("client_menu");
This page took 0.03852 seconds and 4 git commands to generate.