- act = action_from_string("SendToDesktop");
- act->data.sendto.desk = desk;
- act->data.sendto.follow = FALSE;
- acts = g_slist_prepend(NULL, act);
- menu_add_normal(menu, desk, name, acts);
+ for (it = menu->entries; it; it = g_list_next(it)) {
+ ObMenuEntry *e = it->data;
+ guint desk = e->id;
+
+ e->data.normal.enabled = c->desktop != desk;
+
+ if ((desk == DESKTOP_ALL && c->desktop != DESKTOP_ALL) ||
+ (c->desktop == DESKTOP_ALL && desk == screen_desktop))
+ {
+ e->data.normal.mask = ob_rr_theme->btn_desk->mask;
+ set_icon_color(e);
+ } else
+ e->data.normal.mask = NULL;
+ }
+
+ return TRUE; /* show the menu */
+}
+
+static void send_to_menu_execute(ObMenuEntry *e, ObMenuFrame *f,
+ ObClient *c, guint state, gpointer data)
+{
+ g_assert(c);
+
+ client_set_desktop(c, e->id, FALSE, FALSE);
+ if (f && c->desktop != screen_desktop && c->desktop != DESKTOP_ALL)
+ /* the client won't even be on the screen anymore, so hide the menu */
+ menu_frame_hide_all();
+ else if (f) {
+ send_to_menu_update(f, (gpointer)1);
+ menu_frame_render(f);
+ }
+}
+
+static void client_menu_place(ObMenuFrame *frame, gint *x, gint *y,
+ gboolean mouse, gpointer data)
+{
+ gint dx, dy;
+
+ if (!mouse && 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);
+ }