+ }
+ return TRUE; /* show the menu */
+}
+
+static void send_to_menu_execute(ObMenuEntry *e, ObMenuFrame *f,
+ ObClient *c, guint state, gpointer data,
+ Time time)
+{
+ g_assert(c);
+
+ client_set_desktop(c, e->id, FALSE);
+ /* the client won't even be on the screen anymore, so hide the menu */
+ if (f)
+ menu_frame_hide_all();
+}
+
+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);