X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=openbox%2Fclient_menu.c;h=acb525300ad181f436817e648eebf33919fb00d0;hb=280529221e9349aa07c6c498df6b80b3a8951198;hp=da6ac2d9994ae9a81ae117c4161a3e66688be816;hpb=31d7680274cdf2fa3c45b8c8d56db2b5d8fbc111;p=chaz%2Fopenbox diff --git a/openbox/client_menu.c b/openbox/client_menu.c index da6ac2d9..acb52530 100644 --- a/openbox/client_menu.c +++ b/openbox/client_menu.c @@ -125,7 +125,7 @@ static gboolean send_to_update(ObMenuFrame *frame, gpointer data) guint i; GSList *acts; ObAction *act; - ObMenuEntry *e;; + ObMenuEntry *e; menu_clear_entries(menu); @@ -169,6 +169,32 @@ static gboolean send_to_update(ObMenuFrame *frame, gpointer data) return TRUE; /* show the menu */ } +static void desktop_change_callback(ObClient *c, gpointer data) +{ + ObMenuFrame *frame = data; + if (c == frame->client) { + /* adding/removing entries while it's shown is not fun, so just hide + the menu and reshow it */ + if (frame->parent) { + ObMenuEntryFrame *me = frame->parent_entry; + ObMenuFrame *parent = frame->parent; + menu_frame_select(parent, NULL, TRUE); + menu_frame_select(parent, me, TRUE); + } else + menu_frame_hide(frame); + } +} + +static void show_callback(ObMenuFrame *frame, gpointer data) +{ + client_add_desktop_notify(desktop_change_callback, frame); +} + +static void hide_callback(ObMenuFrame *frame, gpointer data) +{ + client_remove_desktop_notify(desktop_change_callback); +} + static void client_menu_place(ObMenuFrame *frame, gint *x, gint *y, gint button, gpointer data) { @@ -259,6 +285,8 @@ void client_menu_startup() menu = menu_new(SEND_TO_MENU_NAME, _("&Send to desktop"), TRUE, NULL); menu_set_update_func(menu, send_to_update); + menu_set_show_func(menu, show_callback); + menu_set_hide_func(menu, hide_callback); menu = menu_new(CLIENT_MENU_NAME, _("Client menu"), TRUE, NULL);