summaryrefslogtreecommitdiff
path: root/openbox/client_menu.c
diff options
context:
space:
mode:
authorDana Jansens <danakj@orodu.net>2007-04-26 05:08:33 +0000
committerDana Jansens <danakj@orodu.net>2007-04-26 05:08:33 +0000
commit26879183e96f5a0d981e6ae76fda82a0d4564b20 (patch)
treee956f1589a75b4e37b30670b3c1b7803faeac642 /openbox/client_menu.c
parent853a5b6b042cad94aa9c81290ed3bed34a6ae90d (diff)
place the client menu at the top left of the window when opening it with a key binding.
change how the first menus are placed. place them like other people place menus. maybe this is good, maybe it is bad, we will see..
Diffstat (limited to 'openbox/client_menu.c')
-rw-r--r--openbox/client_menu.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/openbox/client_menu.c b/openbox/client_menu.c
index be767155..4efef8a8 100644
--- a/openbox/client_menu.c
+++ b/openbox/client_menu.c
@@ -157,6 +157,69 @@ static void send_to_update(ObMenuFrame *frame, gpointer data)
}
}
+static void client_menu_place(ObMenuFrame *frame, gint *x, gint *y,
+ gint button, gpointer data)
+{
+ gint dx, dy;
+
+ if (button == 0 && frame->client) {
+ *x = frame->client->frame->area.x;
+
+ /* try below the titlebar */
+ *y = frame->client->frame->area.y + frame->client->frame->size.top -
+ frame->client->frame->bwidth;
+ menu_frame_move_on_screen(frame, *x, *y, &dx, &dy);
+ if (dy != 0) {
+ /* try above the titlebar */
+ *y = frame->client->frame->area.y + frame->client->frame->bwidth -
+ frame->area.height;
+ menu_frame_move_on_screen(frame, *x, *y, &dx, &dy);
+ }
+ if (dy != 0) {
+ /* didnt fit either way, use move on screen's values */
+ *y = frame->client->frame->area.y + frame->client->frame->size.top;
+ menu_frame_move_on_screen(frame, *x, *y, &dx, &dy);
+ }
+
+ *x += dx;
+ *y += dy;
+ } else {
+ gint myx, myy;
+
+ myx = *x;
+ myy = *y;
+
+ /* try to the bottom right of the cursor */
+ menu_frame_move_on_screen(frame, myx, myy, &dx, &dy);
+ if (dx != 0 || dy != 0) {
+ /* try to the bottom left of the cursor */
+ myx = *x - frame->area.width;
+ myy = *y;
+ menu_frame_move_on_screen(frame, myx, myy, &dx, &dy);
+ }
+ if (dx != 0 || dy != 0) {
+ /* try to the top right of the cursor */
+ myx = *x;
+ myy = *y - frame->area.height;
+ menu_frame_move_on_screen(frame, myx, myy, &dx, &dy);
+ }
+ if (dx != 0 || dy != 0) {
+ /* try to the top left of the cursor */
+ myx = *x - frame->area.width;
+ myy = *y - frame->area.height;
+ menu_frame_move_on_screen(frame, myx, myy, &dx, &dy);
+ }
+ if (dx != 0 || dy != 0) {
+ /* if didnt fit on either side so just use what it says */
+ myx = *x;
+ myy = *y;
+ menu_frame_move_on_screen(frame, myx, myy, &dx, &dy);
+ }
+ *x = myx + dx;
+ *y = myy + dy;
+ }
+}
+
void client_menu_startup()
{
GSList *acts;
@@ -189,6 +252,7 @@ void client_menu_startup()
menu = menu_new(CLIENT_MENU_NAME, _("Client menu"), TRUE, NULL);
menu_show_all_shortcuts(menu, TRUE);
menu_set_update_func(menu, client_update);
+ menu_set_place_func(menu, client_menu_place);
menu_add_submenu(menu, CLIENT_SEND_TO, SEND_TO_MENU_NAME);