]>
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_num_desktops
)
36 if (strcmp(screen_desktop_names
[i
],
37 ((ObMenuEntry
*)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
);
59 void client_menu_show(ObMenu
*self
, int x
, int y
, ObClient
*client
)
65 g_assert(!self
->invalid
);
68 for (i
= 0; i
< screen_num_monitors
; ++i
) {
69 a
= screen_physical_area_monitor(i
);
70 if (RECT_CONTAINS(*a
, x
, y
))
76 newx
= MAX(x
, client
->area
.x
);
77 newy
= MAX(y
, client
->area
.y
);
78 POINT_SET(self
->location
,
79 MIN(newx
, client
->area
.x
+ client
->area
.width
- self
->size
.width
),
80 MIN(newy
, client
->area
.y
+ client
->area
.height
-
83 XMoveWindow(ob_display
, self
->frame
, self
->location
.x
, self
->location
.y
);
86 XMapWindow(ob_display
, self
->frame
);
87 stacking_raise(MENU_AS_WINDOW(self
));
89 } else if (self
->shown
&& self
->open_submenu
) {
90 menu_hide(self
->open_submenu
);
94 void plugin_setup_config() { }
96 void plugin_shutdown() { }
98 void plugin_destroy (ObMenu
*m
)
102 void *plugin_create() /* TODO: need config */
104 ObMenu
*m
= menu_new_full(NULL
, "client-menu", NULL
,
105 client_menu_show
, NULL
, NULL
, NULL
, NULL
);
106 m
->plugin
= PLUGIN_NAME
;
107 menu_add_entry(m
, menu_entry_new_submenu("Send To Workspace",
109 send_to_menu
->parent
= m
;
111 menu_add_entry(m
, menu_entry_new("Iconify",
112 action_from_string("iconify")));
113 menu_add_entry(m
, menu_entry_new("Raise",
114 action_from_string("raise")));
115 menu_add_entry(m
, menu_entry_new("Lower",
116 action_from_string("lower")));
117 menu_add_entry(m
, menu_entry_new("Close",
118 action_from_string("close")));
119 menu_add_entry(m
, menu_entry_new("Shade",
120 action_from_string("toggleshade")));
121 menu_add_entry(m
, menu_entry_new("Omnipresent",
122 action_from_string("toggleomnipresent")));
123 menu_add_entry(m
, menu_entry_new("Decorations",
124 action_from_string("toggledecorations")));
125 menu_add_entry(m
, menu_entry_new_submenu("Layers",
127 layer_menu
->parent
= m
;
142 void plugin_startup()
145 /* create a Send To Workspace ObMenu */
146 send_to_menu
= menu_new_full(NULL
, "send-to-workspace",
147 NULL
, NULL
, client_send_to_update
, NULL
, NULL
, NULL
);
149 layer_menu
= menu_new(NULL
, "layer", NULL
);
150 menu_add_entry(layer_menu
, menu_entry_new("Top Layer",
151 action_from_string("sendtotoplayer")));
152 menu_add_entry(layer_menu
, menu_entry_new("Normal Layer",
153 action_from_string("sendtonormallayer")));
154 menu_add_entry(layer_menu
, menu_entry_new("Bottom Layer",
155 action_from_string("sendtobottomlayer")));
157 t
= (ObMenu
*)plugin_create("client_menu");
This page took 0.038344 seconds and 4 git commands to generate.