]> Dogcows Code - chaz/openbox/blobdiff - openbox/client_menu.c
separate roll up and roll down.
[chaz/openbox] / openbox / client_menu.c
index 0d4aa57f1418216e432b5aac46fa08470a25afde..b0a483838956efcb66114c1335489a03ed093f39 100644 (file)
@@ -45,7 +45,8 @@ enum {
     CLIENT_ICONIFY,
     CLIENT_RESTORE,
     CLIENT_MAXIMIZE,
-    CLIENT_SHADE,
+    CLIENT_ROLL_UP,
+    CLIENT_ROLL_DOWN,
     CLIENT_DECORATE,
     CLIENT_MOVE,
     CLIENT_RESIZE,
@@ -77,8 +78,11 @@ static gboolean client_menu_update(ObMenuFrame *frame, gpointer data)
                 *en = ((c->functions & OB_CLIENT_FUNC_MAXIMIZE) &&
                        (!c->max_horz || !c->max_vert));
                 break;
-            case CLIENT_SHADE:
-                *en = c->functions & OB_CLIENT_FUNC_SHADE;
+            case CLIENT_ROLL_UP:
+                *en = c->functions & OB_CLIENT_FUNC_SHADE && !c->shaded;
+                break;
+            case CLIENT_ROLL_DOWN:
+                *en = c->functions & OB_CLIENT_FUNC_SHADE && c->shaded;
                 break;
             case CLIENT_MOVE:
                 *en = c->functions & OB_CLIENT_FUNC_MOVE;
@@ -100,47 +104,54 @@ static gboolean client_menu_update(ObMenuFrame *frame, gpointer data)
     return TRUE; /* show the menu */
 }
 
-static void client_menu_execute(ObMenuEntry *e, guint state, gpointer data,
+static void client_menu_execute(ObMenuEntry *e, ObMenuFrame *f,
+                                ObClient *c, guint state, gpointer data,
                                 Time time)
 {
-    GList *it;
-    ObMenuFrame *f;
-    ObClient *c;
-
-    /* find our frame */
-    for (it = menu_frame_visible; it; it = g_list_next(it)) {
-        f = it->data;
-        /* yay this is our menu frame */
-        if (f->menu == e->menu)
-            break;
-    }
-    g_assert(it);
+    gint x, y;
 
-    c = f->client;
+    g_assert(c);
 
     switch (e->id) {
     case CLIENT_ICONIFY:
-        client_iconify(c, TRUE, FALSE);
         /* the client won't be on screen anymore so hide the menu */
         menu_frame_hide_all();
-        return; /* and don't update */
+        f = NULL; /* and don't update */
+
+        client_iconify(c, TRUE, FALSE, FALSE);
+        break;
     case CLIENT_RESTORE:
         client_maximize(c, FALSE, 0);
         break;
     case CLIENT_MAXIMIZE:
         client_maximize(c, TRUE, 0);
         break;
-    case CLIENT_SHADE:
-        client_shade(c, !c->shaded);
+    case CLIENT_ROLL_UP:
+        client_shade(c, TRUE);
+        break;
+    case CLIENT_ROLL_DOWN:
+        client_shade(c, FALSE);
         break;
     case CLIENT_DECORATE:
         client_set_undecorated(c, !c->undecorated);
         break;
     case CLIENT_MOVE:
-        moveresize_start(c,0,0,0, prop_atoms.net_wm_moveresize_move_keyboard);
+        /* this needs to grab the keyboard so hide the menu */
+        menu_frame_hide_all();
+        f = NULL; /* and don't update */
+
+        screen_pointer_pos(&x, &y);
+        moveresize_start(c, x, y, 0,
+                         prop_atoms.net_wm_moveresize_move_keyboard);
         break;
     case CLIENT_RESIZE:
-        moveresize_start(c,0,0,0,prop_atoms.net_wm_moveresize_size_keyboard);
+        /* this needs to grab the keyboard so hide the menu */
+        menu_frame_hide_all();
+        f = NULL; /* and don't update */
+
+        screen_pointer_pos(&x, &y);
+        moveresize_start(c, x, y, 0,
+                         prop_atoms.net_wm_moveresize_size_keyboard);
         break;
     case CLIENT_CLOSE:
         client_close(c);
@@ -150,8 +161,10 @@ static void client_menu_execute(ObMenuEntry *e, guint state, gpointer data,
     }
 
     /* update the menu cuz stuff can have changed */
-    client_menu_update(f, NULL);
-    menu_frame_render(f);
+    if (f) {
+        client_menu_update(f, NULL);
+        menu_frame_render(f);
+    }
 }
 
 static gboolean layer_menu_update(ObMenuFrame *frame, gpointer data)
@@ -186,38 +199,31 @@ static gboolean layer_menu_update(ObMenuFrame *frame, gpointer data)
     return TRUE; /* show the menu */
 }
 
-static void layer_menu_execute(ObMenuEntry *e, guint state, gpointer data,
+static void layer_menu_execute(ObMenuEntry *e, ObMenuFrame *f,
+                               ObClient *c, guint state, gpointer data,
                                Time time)
 {
-    GList *it;
-    ObMenuFrame *f;
-
-    /* find our frame */
-    for (it = menu_frame_visible; it; it = g_list_next(it)) {
-        f = it->data;
-        /* yay this is our menu frame */
-        if (f->menu == e->menu)
-            break;
-    }
-    g_assert(it);
+    g_assert(c);
 
     switch (e->id) {
     case LAYER_TOP:
-        client_set_layer(f->client, 1);
+        client_set_layer(c, 1);
         break;
     case LAYER_NORMAL:
-        client_set_layer(f->client, 0);
+        client_set_layer(c, 0);
         break;
     case LAYER_BOTTOM:
-        client_set_layer(f->client, -1);
+        client_set_layer(c, -1);
         break;
     default:
         g_assert_not_reached();
     }
 
     /* update the menu cuz stuff can have changed */
-    layer_menu_update(f, NULL);
-    menu_frame_render(f);
+    if (f) {
+        layer_menu_update(f, NULL);
+        menu_frame_render(f);
+    }
 }
 
 static gboolean send_to_menu_update(ObMenuFrame *frame, gpointer data)
@@ -264,24 +270,16 @@ static gboolean send_to_menu_update(ObMenuFrame *frame, gpointer data)
     return TRUE; /* show the menu */
 }
 
-static void send_to_menu_execute(ObMenuEntry *e, guint state, gpointer data,
+static void send_to_menu_execute(ObMenuEntry *e, ObMenuFrame *f,
+                                 ObClient *c, guint state, gpointer data,
                                  Time time)
 {
-    GList *it;
-    ObMenuFrame *f;
-
-    /* find our frame */
-    for (it = menu_frame_visible; it; it = g_list_next(it)) {
-        f = it->data;
-        /* yay this is our menu frame */
-        if (f->menu == e->menu)
-            break;
-    }
-    g_assert(it);
+    g_assert(c);
 
-    client_set_desktop(f->client, e->id, FALSE);
+    client_set_desktop(c, e->id, FALSE);
     /* the client won't even be on the screen anymore, so hide the menu */
-    menu_frame_hide_all();
+    if (f)
+        menu_frame_hide_all();
 }
 
 static void client_menu_place(ObMenuFrame *frame, gint *x, gint *y,
@@ -400,13 +398,9 @@ void client_menu_startup()
     e->data.normal.mask_disabled_selected_color =
         ob_rr_theme->menu_disabled_selected_color;
 
-    e = menu_add_normal(menu, CLIENT_SHADE, _("&Roll up/down"), NULL, TRUE);
-    e->data.normal.mask = ob_rr_theme->shade_mask;
-    e->data.normal.mask_normal_color = ob_rr_theme->menu_color;
-    e->data.normal.mask_selected_color = ob_rr_theme->menu_selected_color;
-    e->data.normal.mask_disabled_color = ob_rr_theme->menu_disabled_color;
-    e->data.normal.mask_disabled_selected_color =
-        ob_rr_theme->menu_disabled_selected_color;
+    menu_add_normal(menu, CLIENT_ROLL_UP, _("Roll &up"), NULL, TRUE);
+
+    menu_add_normal(menu, CLIENT_ROLL_DOWN, _("Roll do&wn"), NULL, TRUE);
 
     menu_add_normal(menu, CLIENT_DECORATE, _("Un/&Decorate"), NULL, TRUE);
 
This page took 0.031518 seconds and 4 git commands to generate.