]>
Dogcows Code - chaz/openbox/blob - plugins/menu/client_menu.c
1 #include "kernel/debug.h"
2 #include "kernel/menu.h"
3 #include "kernel/screen.h"
4 #include "kernel/client.h"
5 #include "kernel/openbox.h"
6 #include "kernel/frame.h"
8 #include "render/theme.h"
12 static char *PLUGIN_NAME
= "client_menu";
14 static ObMenu
*send_to_menu
;
15 static ObMenu
*layer_menu
;
21 #define CLIENT_MENU(m) ((ObMenu *)m)
22 #define CLIENT_MENU_DATA(m) ((Client_Menu_Data *)((ObMenu *)m)->plugin_data)
24 void client_menu_clean_up(ObMenu
*m
) {
27 void client_send_to_update(ObMenu
*self
)
30 GList
*it
= self
->entries
;
32 /* check if we have to update. lame */
34 if (i
== screen_desktop
) {
35 if (((ObMenuEntry
*)it
->data
)->enabled
)
38 if (!((ObMenuEntry
*)it
->data
)->enabled
)
41 if (i
>= screen_num_desktops
)
43 if (strcmp(screen_desktop_names
[i
],
44 ((ObMenuEntry
*)it
->data
)->label
) != 0)
50 if (it
!= NULL
|| i
!= screen_num_desktops
) {
53 for (i
= 0; i
< screen_num_desktops
; ++i
) {
55 ObAction
*a
= action_from_string("sendtodesktop");
56 a
->data
.sendto
.desk
= i
;
57 a
->data
.sendto
.follow
= FALSE
;
58 e
= menu_entry_new(screen_desktop_names
[i
], a
);
59 if (i
== screen_desktop
)
61 menu_add_entry(self
, e
);
68 void client_menu_show(ObMenu
*self
, int x
, int y
, ObClient
*client
)
74 g_assert(!self
->invalid
);
77 for (i
= 0; i
< screen_num_monitors
; ++i
) {
78 a
= screen_physical_area_monitor(i
);
79 if (RECT_CONTAINS(*a
, x
, y
))
85 newx
= MAX(x
, client
->area
.x
);
86 newy
= MAX(y
, client
->area
.y
);
87 POINT_SET(self
->location
,
88 MIN(newx
, client
->area
.x
+ client
->area
.width
- self
->size
.width
),
89 MIN(newy
, client
->area
.y
+ client
->area
.height
-
92 XMoveWindow(ob_display
, self
->frame
, self
->location
.x
, self
->location
.y
);
95 XMapWindow(ob_display
, self
->frame
);
96 stacking_raise(MENU_AS_WINDOW(self
));
98 } else if (self
->shown
&& self
->open_submenu
) {
99 menu_hide(self
->open_submenu
);
103 void plugin_setup_config() { }
105 void plugin_shutdown() { }
107 void plugin_destroy (ObMenu
*m
)
111 void *plugin_create() /* TODO: need config */
113 ObMenu
*m
= menu_new_full(NULL
, "client-menu", NULL
,
114 client_menu_show
, NULL
, NULL
, NULL
, NULL
);
115 m
->plugin
= PLUGIN_NAME
;
116 menu_add_entry(m
, menu_entry_new_submenu("Send To Workspace",
118 send_to_menu
->parent
= m
;
120 menu_add_entry(m
, menu_entry_new("Iconify",
121 action_from_string("iconify")));
122 menu_add_entry(m
, menu_entry_new("Raise",
123 action_from_string("raise")));
124 menu_add_entry(m
, menu_entry_new("Lower",
125 action_from_string("lower")));
126 menu_add_entry(m
, menu_entry_new("Close",
127 action_from_string("close")));
128 menu_add_entry(m
, menu_entry_new("Shade",
129 action_from_string("toggleshade")));
130 menu_add_entry(m
, menu_entry_new("Omnipresent",
131 action_from_string("toggleomnipresent")));
132 menu_add_entry(m
, menu_entry_new("Decorations",
133 action_from_string("toggledecorations")));
134 menu_add_entry(m
, menu_entry_new_submenu("Layers",
136 layer_menu
->parent
= m
;
151 void plugin_startup()
154 /* create a Send To Workspace ObMenu */
155 send_to_menu
= menu_new_full(NULL
, "send-to-workspace",
156 NULL
, NULL
, client_send_to_update
, NULL
, NULL
, NULL
);
158 layer_menu
= menu_new(NULL
, "layer", NULL
);
159 menu_add_entry(layer_menu
, menu_entry_new("Top Layer",
160 action_from_string("sendtotoplayer")));
161 menu_add_entry(layer_menu
, menu_entry_new("Normal Layer",
162 action_from_string("sendtonormallayer")));
163 menu_add_entry(layer_menu
, menu_entry_new("Bottom Layer",
164 action_from_string("sendtobottomlayer")));
166 t
= (ObMenu
*)plugin_create("client_menu");
This page took 0.038683 seconds and 4 git commands to generate.