]> Dogcows Code - chaz/openbox/blobdiff - openbox/action.c
add client_set_undecorated().
[chaz/openbox] / openbox / action.c
index efc7f1ef513b89dba2bac42d9fb692e2ef2e3556..b3fdf0f18f5b025792a1f0c1bdd64f2e6b208bbe 100644 (file)
@@ -1,3 +1,21 @@
+/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
+
+   action.c for the Openbox window manager
+   Copyright (c) 2003        Ben Jansens
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   See the COPYING file for a copy of the GNU General Public License.
+*/
+
 #include "debug.h"
 #include "client.h"
 #include "focus.h"
 #include "openbox.h"
 #include "grab.h"
 #include "keyboard.h"
+#include "event.h"
+#include "config.h"
 
 #include <glib.h>
 
-typedef struct ActionString {
-    char *name;
+inline void client_action_start(union ActionData *data)
+{
+    if (config_focus_follow)
+        if (data->any.context != OB_FRAME_CONTEXT_CLIENT && !data->any.button)
+            grab_pointer(TRUE, OB_CURSOR_NONE);
+}
+
+inline void client_action_end(union ActionData *data)
+{
+    if (config_focus_follow)
+        if (data->any.context != OB_FRAME_CONTEXT_CLIENT) {
+            if (!data->any.button) {
+                grab_pointer(FALSE, OB_CURSOR_NONE);
+            } else {
+                ObClient *c;
+
+                /* usually this is sorta redundant, but with a press action
+                   the enter event will come as a GrabNotify which is
+                   ignored, so this will handle that case */
+                if ((c = client_under_pointer()))
+                    event_enter_client(c);
+            }
+        }
+}
+
+typedef struct
+{
+    const gchar *name;
     void (*func)(union ActionData *);
     void (*setup)(ObAction **, ObUserAction uact);
 } ActionString;
@@ -42,7 +88,7 @@ void action_free(ObAction *a)
 }
 
 void setup_action_directional_focus_north(ObAction **a, ObUserAction uact)
-{ 
+{
     (*a)->data.interdiraction.inter.any.interactive = TRUE;
     (*a)->data.interdiraction.direction = OB_DIRECTION_NORTH;
 }
@@ -91,11 +137,13 @@ void setup_action_directional_focus_northwest(ObAction **a, ObUserAction uact)
 
 void setup_action_send_to_desktop(ObAction **a, ObUserAction uact)
 {
+    (*a)->data.sendto.any.client_action = OB_CLIENT_ACTION_ALWAYS;
     (*a)->data.sendto.follow = TRUE;
 }
 
 void setup_action_send_to_desktop_prev(ObAction **a, ObUserAction uact)
 {
+    (*a)->data.sendtodir.inter.any.client_action = OB_CLIENT_ACTION_ALWAYS;
     (*a)->data.sendtodir.inter.any.interactive = TRUE;
     (*a)->data.sendtodir.dir = OB_DIRECTION_WEST;
     (*a)->data.sendtodir.linear = TRUE;
@@ -105,6 +153,7 @@ void setup_action_send_to_desktop_prev(ObAction **a, ObUserAction uact)
 
 void setup_action_send_to_desktop_next(ObAction **a, ObUserAction uact)
 {
+    (*a)->data.sendtodir.inter.any.client_action = OB_CLIENT_ACTION_ALWAYS;
     (*a)->data.sendtodir.inter.any.interactive = TRUE;
     (*a)->data.sendtodir.dir = OB_DIRECTION_EAST;
     (*a)->data.sendtodir.linear = TRUE;
@@ -114,6 +163,7 @@ void setup_action_send_to_desktop_next(ObAction **a, ObUserAction uact)
 
 void setup_action_send_to_desktop_left(ObAction **a, ObUserAction uact)
 {
+    (*a)->data.sendtodir.inter.any.client_action = OB_CLIENT_ACTION_ALWAYS;
     (*a)->data.sendtodir.inter.any.interactive = TRUE;
     (*a)->data.sendtodir.dir = OB_DIRECTION_WEST;
     (*a)->data.sendtodir.linear = FALSE;
@@ -123,6 +173,7 @@ void setup_action_send_to_desktop_left(ObAction **a, ObUserAction uact)
 
 void setup_action_send_to_desktop_right(ObAction **a, ObUserAction uact)
 {
+    (*a)->data.sendtodir.inter.any.client_action = OB_CLIENT_ACTION_ALWAYS;
     (*a)->data.sendtodir.inter.any.interactive = TRUE;
     (*a)->data.sendtodir.dir = OB_DIRECTION_EAST;
     (*a)->data.sendtodir.linear = FALSE;
@@ -132,6 +183,7 @@ void setup_action_send_to_desktop_right(ObAction **a, ObUserAction uact)
 
 void setup_action_send_to_desktop_up(ObAction **a, ObUserAction uact)
 {
+    (*a)->data.sendtodir.inter.any.client_action = OB_CLIENT_ACTION_ALWAYS;
     (*a)->data.sendtodir.inter.any.interactive = TRUE;
     (*a)->data.sendtodir.dir = OB_DIRECTION_NORTH;
     (*a)->data.sendtodir.linear = FALSE;
@@ -141,6 +193,7 @@ void setup_action_send_to_desktop_up(ObAction **a, ObUserAction uact)
 
 void setup_action_send_to_desktop_down(ObAction **a, ObUserAction uact)
 {
+    (*a)->data.sendtodir.inter.any.client_action = OB_CLIENT_ACTION_ALWAYS;
     (*a)->data.sendtodir.inter.any.interactive = TRUE;
     (*a)->data.sendtodir.dir = OB_DIRECTION_SOUTH;
     (*a)->data.sendtodir.linear = FALSE;
@@ -212,61 +265,73 @@ void setup_action_cycle_windows_previous(ObAction **a, ObUserAction uact)
 
 void setup_action_movetoedge_north(ObAction **a, ObUserAction uact)
 {
+    (*a)->data.diraction.any.client_action = OB_CLIENT_ACTION_ALWAYS;
     (*a)->data.diraction.direction = OB_DIRECTION_NORTH;
 }
 
 void setup_action_movetoedge_south(ObAction **a, ObUserAction uact)
 {
+    (*a)->data.diraction.any.client_action = OB_CLIENT_ACTION_ALWAYS;
     (*a)->data.diraction.direction = OB_DIRECTION_SOUTH;
 }
 
 void setup_action_movetoedge_east(ObAction **a, ObUserAction uact)
 {
+    (*a)->data.diraction.any.client_action = OB_CLIENT_ACTION_ALWAYS;
     (*a)->data.diraction.direction = OB_DIRECTION_EAST;
 }
 
 void setup_action_movetoedge_west(ObAction **a, ObUserAction uact)
 {
+    (*a)->data.diraction.any.client_action = OB_CLIENT_ACTION_ALWAYS;
     (*a)->data.diraction.direction = OB_DIRECTION_WEST;
 }
 
 void setup_action_growtoedge_north(ObAction **a, ObUserAction uact)
 {
+    (*a)->data.diraction.any.client_action = OB_CLIENT_ACTION_ALWAYS;
     (*a)->data.diraction.direction = OB_DIRECTION_NORTH;
 }
 
 void setup_action_growtoedge_south(ObAction **a, ObUserAction uact)
 {
+    (*a)->data.diraction.any.client_action = OB_CLIENT_ACTION_ALWAYS;
     (*a)->data.diraction.direction = OB_DIRECTION_SOUTH;
 }
 
 void setup_action_growtoedge_east(ObAction **a, ObUserAction uact)
 {
+    (*a)->data.diraction.any.client_action = OB_CLIENT_ACTION_ALWAYS;
     (*a)->data.diraction.direction = OB_DIRECTION_EAST;
 }
 
 void setup_action_growtoedge_west(ObAction **a, ObUserAction uact)
 {
+    (*a)->data.diraction.any.client_action = OB_CLIENT_ACTION_ALWAYS;
     (*a)->data.diraction.direction = OB_DIRECTION_WEST;
 }
 
 void setup_action_top_layer(ObAction **a, ObUserAction uact)
 {
+    (*a)->data.layer.any.client_action = OB_CLIENT_ACTION_ALWAYS;
     (*a)->data.layer.layer = 1;
 }
 
 void setup_action_normal_layer(ObAction **a, ObUserAction uact)
 {
+    (*a)->data.layer.any.client_action = OB_CLIENT_ACTION_ALWAYS;
     (*a)->data.layer.layer = 0;
 }
 
 void setup_action_bottom_layer(ObAction **a, ObUserAction uact)
 {
+    (*a)->data.layer.any.client_action = OB_CLIENT_ACTION_ALWAYS;
     (*a)->data.layer.layer = -1;
 }
 
 void setup_action_move(ObAction **a, ObUserAction uact)
 {
+    (*a)->data.moveresize.any.client_action = OB_CLIENT_ACTION_ALWAYS;
     (*a)->data.moveresize.move = TRUE;
     (*a)->data.moveresize.keyboard =
         (uact == OB_USER_ACTION_KEYBOARD_KEY ||
@@ -275,6 +340,7 @@ void setup_action_move(ObAction **a, ObUserAction uact)
 
 void setup_action_resize(ObAction **a, ObUserAction uact)
 {
+    (*a)->data.moveresize.any.client_action = OB_CLIENT_ACTION_ALWAYS;
     (*a)->data.moveresize.move = FALSE;
     (*a)->data.moveresize.keyboard =
         (uact == OB_USER_ACTION_KEYBOARD_KEY ||
@@ -283,6 +349,7 @@ void setup_action_resize(ObAction **a, ObUserAction uact)
 
 void setup_action_showmenu(ObAction **a, ObUserAction uact)
 {
+    (*a)->data.showmenu.any.client_action = OB_CLIENT_ACTION_OPTIONAL;
     /* you cannot call ShowMenu from inside a menu, cuz the menu code makes
        assumptions that there is only one menu (and submenus) open at
        a time! */
@@ -292,6 +359,11 @@ void setup_action_showmenu(ObAction **a, ObUserAction uact)
     }
 }
 
+void setup_client_action(ObAction **a, ObUserAction uact)
+{
+    (*a)->data.any.client_action = OB_CLIENT_ACTION_ALWAYS;
+}
+
 ActionString actionstrings[] =
 {
     {
@@ -342,142 +414,142 @@ ActionString actionstrings[] =
     {
         "activate",
         action_activate,
-        NULL
+        setup_client_action
     },
     {
         "focus",
         action_focus,
-        NULL
+        setup_client_action
     },
     {
         "unfocus",
         action_unfocus,
-        NULL
+        setup_client_action
     },
     {
         "iconify",
         action_iconify,
-        NULL
+        setup_client_action
     },
     {
         "raiselower",
         action_raiselower,
-        NULL
+        setup_client_action
     },
     {
         "raise",
         action_raise,
-        NULL
+        setup_client_action
     },
     {
         "lower",
         action_lower,
-        NULL
+        setup_client_action
     },
     {
         "close",
         action_close,
-        NULL
+        setup_client_action
     },
     {
         "kill",
         action_kill,
-        NULL
+        setup_client_action
     },
     {
         "shadelower",
         action_shadelower,
-        NULL
+        setup_client_action
     },
     {
         "unshaderaise",
         action_unshaderaise,
-        NULL
+        setup_client_action
     },
     {
         "shade",
         action_shade,
-        NULL
+        setup_client_action
     },
     {
         "unshade",
         action_unshade,
-        NULL
+        setup_client_action
     },
     {
         "toggleshade",
         action_toggle_shade,
-        NULL
+        setup_client_action
     },
     {
         "toggleomnipresent",
         action_toggle_omnipresent,
-        NULL
+        setup_client_action
     },
     {
         "moverelativehorz",
         action_move_relative_horz,
-        NULL
+        setup_client_action
     },
     {
         "moverelativevert",
         action_move_relative_vert,
-        NULL
+        setup_client_action
     },
     {
         "resizerelativehorz",
         action_resize_relative_horz,
-        NULL
+        setup_client_action
     },
     {
         "resizerelativevert",
         action_resize_relative_vert,
-        NULL
+        setup_client_action
     },
     {
         "maximizefull",
         action_maximize_full,
-        NULL
+        setup_client_action
     },
     {
         "unmaximizefull",
         action_unmaximize_full,
-        NULL
+        setup_client_action
     },
     {
         "togglemaximizefull",
         action_toggle_maximize_full,
-        NULL
+        setup_client_action
     },
     {
         "maximizehorz",
         action_maximize_horz,
-        NULL
+        setup_client_action
     },
     {
         "unmaximizehorz",
         action_unmaximize_horz,
-        NULL
+        setup_client_action
     },
     {
         "togglemaximizehorz",
         action_toggle_maximize_horz,
-        NULL
+        setup_client_action
     },
     {
         "maximizevert",
         action_maximize_vert,
-        NULL
+        setup_client_action
     },
     {
         "unmaximizevert",
         action_unmaximize_vert,
-        NULL
+        setup_client_action
     },
     {
         "togglemaximizevert",
         action_toggle_maximize_vert,
-        NULL
+        setup_client_action
     },
     {
         "sendtodesktop",
@@ -552,7 +624,7 @@ ActionString actionstrings[] =
     {
         "toggledecorations",
         action_toggle_decorations,
-        NULL
+        setup_client_action
     },
     {
         "move",
@@ -686,7 +758,7 @@ ActionString actionstrings[] =
     }
 };
 
-ObAction *action_from_string(char *name, ObUserAction uact)
+ObAction *action_from_string(const gchar *name, ObUserAction uact)
 {
     ObAction *a = NULL;
     gboolean exist = FALSE;
@@ -723,7 +795,7 @@ ObAction *action_parse(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
             if (act->func == action_execute || act->func == action_restart) {
                 if ((n = parse_find_node("execute", node->xmlChildrenNode))) {
                     gchar *s = parse_string(doc, n);
-                    act->data.execute.path = ob_expand_tilde(s);
+                    act->data.execute.path = parse_expand_tilde(s);
                     g_free(s);
                 }
             } else if (act->func == action_showmenu) {
@@ -766,27 +838,60 @@ ObAction *action_parse(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
     return act;
 }
 
-void action_run_full(ObAction *a, struct _ObClient *c,
+void action_run_list(GSList *acts, ObClient *c, ObFrameContext context,
                      guint state, guint button, gint x, gint y,
                      gboolean cancel, gboolean done)
 {
+    GSList *it;
+    ObAction *a;
+    gboolean inter = FALSE;
+
+    if (!acts)
+        return;
+
     if (x < 0 && y < 0)
         screen_pointer_pos(&x, &y);
 
-    a->data.any.c = c;
-    a->data.any.x = x;
-    a->data.any.y = y;
-
-    a->data.any.button = button;
+    if (grab_on_keyboard())
+        inter = TRUE;
+    else
+        for (it = acts; it; it = g_slist_next(it)) {
+            a = it->data;
+            if (a->data.any.interactive) {
+                inter = TRUE;
+                break;
+            }
+        }
 
-    if (a->data.any.interactive) {
-        a->data.inter.cancel = cancel;
-        a->data.inter.final = done;
-        if (!(cancel || done))
-            keyboard_interactive_grab(state, c, a);
+    if (!inter) {
+        /* sometimes when we execute another app as an action,
+           it won't work right unless we XUngrabKeyboard first,
+           even though we grabbed the key/button Asychronously.
+           e.g. "gnome-panel-control --main-menu" */
+        XUngrabKeyboard(ob_display, event_lasttime);
     }
 
-    a->func(&a->data);
+    for (it = acts; it; it = g_slist_next(it)) {
+        a = it->data;
+
+        if (!(a->data.any.client_action == OB_CLIENT_ACTION_ALWAYS && !c)) {
+            a->data.any.c = a->data.any.client_action ? c : NULL;
+            a->data.any.context = context;
+            a->data.any.x = x;
+            a->data.any.y = y;
+
+            a->data.any.button = button;
+
+            if (a->data.any.interactive) {
+                a->data.inter.cancel = cancel;
+                a->data.inter.final = done;
+                if (!(cancel || done))
+                    keyboard_interactive_grab(state, a->data.any.c, a);
+            }
+
+            a->func(&a->data);
+        }
+    }
 }
 
 void action_execute(union ActionData *data)
@@ -800,6 +905,7 @@ void action_execute(union ActionData *data)
                 g_warning("failed to execute '%s': %s",
                           cmd, e->message);
             }
+            g_free(cmd);
         } else {
             g_warning("failed to convert '%s' from utf8", data->execute.path);
         }
@@ -808,26 +914,22 @@ void action_execute(union ActionData *data)
 
 void action_activate(union ActionData *data)
 {
-    if (data->activate.any.c)
-        client_activate(data->activate.any.c, data->activate.here);
+    client_activate(data->activate.any.c, data->activate.here);
 }
 
 void action_focus(union ActionData *data)
 {
-    if (data->client.any.c)
-        client_focus(data->client.any.c);
+    client_focus(data->client.any.c);
 }
 
 void action_unfocus (union ActionData *data)
 {
-    if (data->client.any.c)
-        client_unfocus(data->client.any.c);
+    client_unfocus(data->client.any.c);
 }
 
 void action_iconify(union ActionData *data)
 {
-    if (data->client.any.c)
-        client_iconify(data->client.any.c, TRUE, TRUE);
+    client_iconify(data->client.any.c, TRUE, TRUE);
 }
 
 void action_raiselower(union ActionData *data)
@@ -836,8 +938,6 @@ void action_raiselower(union ActionData *data)
     GList *it;
     gboolean raise = FALSE;
 
-    if (!c) return;
-
     for (it = stacking_list; it; it = g_list_next(it)) {
         ObClient *cit = it->data;
 
@@ -853,202 +953,203 @@ void action_raiselower(union ActionData *data)
         }
     }
 
-    if (raise)
+    if (raise) {
+        client_action_start(data);
         stacking_raise(CLIENT_AS_WINDOW(c));
-    else
+        client_action_end(data);
+    } else {
+        client_action_start(data);
         stacking_lower(CLIENT_AS_WINDOW(c));
+        client_action_end(data);
+    }
 }
 
 void action_raise(union ActionData *data)
 {
-    if (data->client.any.c)
-        stacking_raise(CLIENT_AS_WINDOW(data->client.any.c));
+    client_action_start(data);
+    stacking_raise(CLIENT_AS_WINDOW(data->client.any.c));
+    client_action_end(data);
 }
 
 void action_unshaderaise(union ActionData *data)
 {
-    if (data->client.any.c) {
-        if (data->client.any.c->shaded) {
-            grab_pointer(TRUE, OB_CURSOR_NONE);
-            client_shade(data->client.any.c, FALSE);
-            grab_pointer(FALSE, OB_CURSOR_NONE);
-        } else
-            stacking_raise(CLIENT_AS_WINDOW(data->client.any.c));
+    if (data->client.any.c->shaded) {
+        client_action_start(data);
+        client_shade(data->client.any.c, FALSE);
+        client_action_end(data);
+    } else {
+        client_action_start(data);
+        stacking_raise(CLIENT_AS_WINDOW(data->client.any.c));
+        client_action_end(data);
     }
 }
 
 void action_shadelower(union ActionData *data)
 {
-    if (data->client.any.c) {
-        if (data->client.any.c->shaded)
-            stacking_lower(CLIENT_AS_WINDOW(data->client.any.c));
-        else {
-            grab_pointer(TRUE, OB_CURSOR_NONE);
-            client_shade(data->client.any.c, TRUE);
-            grab_pointer(FALSE, OB_CURSOR_NONE);
-        }
+    if (data->client.any.c->shaded)
+        stacking_lower(CLIENT_AS_WINDOW(data->client.any.c));
+    else {
+        client_action_start(data);
+        client_shade(data->client.any.c, TRUE);
+        client_action_end(data);
     }
 }
 
 void action_lower(union ActionData *data)
 {
-    if (data->client.any.c)
-        stacking_lower(CLIENT_AS_WINDOW(data->client.any.c));
+    client_action_start(data);
+    stacking_lower(CLIENT_AS_WINDOW(data->client.any.c));
+    client_action_end(data);
 }
 
 void action_close(union ActionData *data)
 {
-    if (data->client.any.c)
-        client_close(data->client.any.c);
+    client_close(data->client.any.c);
 }
 
 void action_kill(union ActionData *data)
 {
-    if (data->client.any.c)
-        client_kill(data->client.any.c);
+    client_kill(data->client.any.c);
 }
 
 void action_shade(union ActionData *data)
 {
-    if (data->client.any.c) { 
-        grab_pointer(TRUE, OB_CURSOR_NONE);
-        client_shade(data->client.any.c, TRUE);
-        grab_pointer(FALSE, OB_CURSOR_NONE);
-    }
+    client_action_start(data);
+    client_shade(data->client.any.c, TRUE);
+    client_action_end(data);
 }
 
 void action_unshade(union ActionData *data)
 {
-    if (data->client.any.c) {
-        grab_pointer(TRUE, OB_CURSOR_NONE);
-        client_shade(data->client.any.c, FALSE);
-        grab_pointer(FALSE, OB_CURSOR_NONE);
-    }
+    client_action_start(data);
+    client_shade(data->client.any.c, FALSE);
+    client_action_end(data);
 }
 
 void action_toggle_shade(union ActionData *data)
 {
-    if (data->client.any.c) {
-        grab_pointer(TRUE, OB_CURSOR_NONE);
-        client_shade(data->client.any.c, !data->client.any.c->shaded);
-        grab_pointer(FALSE, OB_CURSOR_NONE);
-    }
+    client_action_start(data);
+    client_shade(data->client.any.c, !data->client.any.c->shaded);
+    client_action_end(data);
 }
 
 void action_toggle_omnipresent(union ActionData *data)
 { 
-    if (data->client.any.c)
-        client_set_desktop(data->client.any.c,
-                           data->client.any.c->desktop == DESKTOP_ALL ?
-                           screen_desktop : DESKTOP_ALL, FALSE);
+    client_set_desktop(data->client.any.c,
+                       data->client.any.c->desktop == DESKTOP_ALL ?
+                       screen_desktop : DESKTOP_ALL, FALSE);
 }
 
 void action_move_relative_horz(union ActionData *data)
 {
     ObClient *c = data->relative.any.c;
-    if (c) {
-        grab_pointer(TRUE, OB_CURSOR_NONE);
-        client_move(c, c->area.x + data->relative.delta, c->area.y);
-        grab_pointer(FALSE, OB_CURSOR_NONE);
-    }
+    client_action_start(data);
+    client_move(c, c->area.x + data->relative.delta, c->area.y);
+    client_action_end(data);
 }
 
 void action_move_relative_vert(union ActionData *data)
 {
     ObClient *c = data->relative.any.c;
-    if (c) {
-        grab_pointer(TRUE, OB_CURSOR_NONE);
-        client_move(c, c->area.x, c->area.y + data->relative.delta);
-        grab_pointer(FALSE, OB_CURSOR_NONE);
-    }
+    client_action_start(data);
+    client_move(c, c->area.x, c->area.y + data->relative.delta);
+    client_action_end(data);
 }
 
 void action_resize_relative_horz(union ActionData *data)
 {
     ObClient *c = data->relative.any.c;
-    if (c) {
-        grab_pointer(TRUE, OB_CURSOR_NONE);
-        client_resize(c,
-                      c->area.width + data->relative.delta * c->size_inc.width,
-                      c->area.height);
-        grab_pointer(FALSE, OB_CURSOR_NONE);
-    }
+    client_action_start(data);
+    client_resize(c,
+                  c->area.width + data->relative.delta * c->size_inc.width,
+                  c->area.height);
+    client_action_end(data);
 }
 
 void action_resize_relative_vert(union ActionData *data)
 {
     ObClient *c = data->relative.any.c;
-    if (c && !c->shaded) {
-        grab_pointer(TRUE, OB_CURSOR_NONE);
+    if (!c->shaded) {
+        client_action_start(data);
         client_resize(c, c->area.width, c->area.height +
                       data->relative.delta * c->size_inc.height);
-        grab_pointer(FALSE, OB_CURSOR_NONE);
+        client_action_end(data);
     }
 }
 
 void action_maximize_full(union ActionData *data)
 {
-    if (data->client.any.c)
-        client_maximize(data->client.any.c, TRUE, 0, TRUE);
+    client_action_start(data);
+    client_maximize(data->client.any.c, TRUE, 0, TRUE);
+    client_action_end(data);
 }
 
 void action_unmaximize_full(union ActionData *data)
 {
-    if (data->client.any.c)
-        client_maximize(data->client.any.c, FALSE, 0, TRUE);
+    client_action_start(data);
+    client_maximize(data->client.any.c, FALSE, 0, TRUE);
+    client_action_end(data);
 }
 
 void action_toggle_maximize_full(union ActionData *data)
 {
-    if (data->client.any.c)
-        client_maximize(data->client.any.c,
-                        !(data->client.any.c->max_horz ||
-                          data->client.any.c->max_vert),
-                        0, TRUE);
+    client_action_start(data);
+    client_maximize(data->client.any.c,
+                    !(data->client.any.c->max_horz ||
+                      data->client.any.c->max_vert),
+                    0, TRUE);
+    client_action_end(data);
 }
 
 void action_maximize_horz(union ActionData *data)
 {
-    if (data->client.any.c)
-        client_maximize(data->client.any.c, TRUE, 1, TRUE);
+    client_action_start(data);
+    client_maximize(data->client.any.c, TRUE, 1, TRUE);
+    client_action_end(data);
 }
 
 void action_unmaximize_horz(union ActionData *data)
 {
-    if (data->client.any.c)
-        client_maximize(data->client.any.c, FALSE, 1, TRUE);
+    client_action_start(data);
+    client_maximize(data->client.any.c, FALSE, 1, TRUE);
+    client_action_end(data);
 }
 
 void action_toggle_maximize_horz(union ActionData *data)
 {
-    if (data->client.any.c)
-        client_maximize(data->client.any.c,
-                        !data->client.any.c->max_horz, 1, TRUE);
+    client_action_start(data);
+    client_maximize(data->client.any.c,
+                    !data->client.any.c->max_horz, 1, TRUE);
+    client_action_end(data);
 }
 
 void action_maximize_vert(union ActionData *data)
 {
-    if (data->client.any.c)
-        client_maximize(data->client.any.c, TRUE, 2, TRUE);
+    client_action_start(data);
+    client_maximize(data->client.any.c, TRUE, 2, TRUE);
+    client_action_end(data);
 }
 
 void action_unmaximize_vert(union ActionData *data)
 {
-    if (data->client.any.c)
-        client_maximize(data->client.any.c, FALSE, 2, TRUE);
+    client_action_start(data);
+    client_maximize(data->client.any.c, FALSE, 2, TRUE);
+    client_action_end(data);
 }
 
 void action_toggle_maximize_vert(union ActionData *data)
 {
-    if (data->client.any.c)
-        client_maximize(data->client.any.c, !data->client.any.c->max_vert, 2, TRUE);
+    client_action_start(data);
+    client_maximize(data->client.any.c,
+                    !data->client.any.c->max_vert, 2, TRUE);
+    client_action_end(data);
 }
 
 void action_send_to_desktop(union ActionData *data)
 {
     ObClient *c = data->sendto.any.c;
 
-    if (!c || !client_normal(c)) return;
+    if (!client_normal(c)) return;
 
     if (data->sendto.desk < screen_num_desktops ||
         data->sendto.desk == DESKTOP_ALL) {
@@ -1075,7 +1176,11 @@ void action_desktop_dir(union ActionData *data)
                              data->desktopdir.inter.any.interactive,
                              data->desktopdir.inter.final,
                              data->desktopdir.inter.cancel);
-    screen_set_desktop(d);
+    if (!data->sendtodir.inter.any.interactive ||
+        !data->sendtodir.inter.final)
+    {
+        screen_set_desktop(d);
+    }
 }
 
 void action_send_to_desktop_dir(union ActionData *data)
@@ -1083,16 +1188,20 @@ void action_send_to_desktop_dir(union ActionData *data)
     ObClient *c = data->sendtodir.inter.any.c;
     guint d;
 
-    if (!c || !client_normal(c)) return;
+    if (!client_normal(c)) return;
 
     d = screen_cycle_desktop(data->sendtodir.dir, data->sendtodir.wrap,
                              data->sendtodir.linear,
                              data->sendtodir.inter.any.interactive,
                              data->sendtodir.inter.final,
                              data->sendtodir.inter.cancel);
-    client_set_desktop(c, d, data->sendtodir.follow);
-    if (data->sendtodir.follow)
-        screen_set_desktop(d);
+    if (!data->sendtodir.inter.any.interactive ||
+        !data->sendtodir.inter.final)
+    {
+        client_set_desktop(c, d, data->sendtodir.follow);
+        if (data->sendtodir.follow)
+            screen_set_desktop(d);
+    }
 }
 
 void action_desktop_last(union ActionData *data)
@@ -1104,10 +1213,9 @@ void action_toggle_decorations(union ActionData *data)
 {
     ObClient *c = data->client.any.c;
 
-    if (!c) return;
-
-    c->decorate = !c->decorate;
-    client_setup_decor_and_functions(c);
+    client_action_start(data);
+    client_set_undecorated(c, !c->undecorated);
+    client_action_end(data);
 }
 
 static guint32 pick_corner(int x, int y, int cx, int cy, int cw, int ch)
@@ -1130,7 +1238,7 @@ void action_moveresize(union ActionData *data)
     ObClient *c = data->moveresize.any.c;
     guint32 corner;
 
-    if (!c || !client_normal(c)) return;
+    if (!client_normal(c)) return;
 
     if (data->moveresize.keyboard) {
         corner = (data->moveresize.move ?
@@ -1166,7 +1274,7 @@ void action_restart(union ActionData *data)
 
 void action_exit(union ActionData *data)
 {
-    ob_exit();
+    ob_exit(0);
 }
 
 void action_showmenu(union ActionData *data)
@@ -1197,8 +1305,6 @@ void action_movetoedge(union ActionData *data)
     int x, y;
     ObClient *c = data->diraction.any.c;
 
-    if (!c)
-        return;
     x = c->frame->area.x;
     y = c->frame->area.y;
     
@@ -1221,21 +1327,18 @@ void action_movetoedge(union ActionData *data)
         g_assert_not_reached();
     }
     frame_frame_gravity(c->frame, &x, &y);
-    grab_pointer(TRUE, OB_CURSOR_NONE);
+    client_action_start(data);
     client_move(c, x, y);
-    grab_pointer(FALSE, OB_CURSOR_NONE);
-
+    client_action_end(data);
 }
 
 void action_growtoedge(union ActionData *data)
 {
     int x, y, width, height, dest;
     ObClient *c = data->diraction.any.c;
-    Rect *a = screen_area(c->desktop);
+    Rect *a;
 
-    if (!c)
-        return;
-    
+    a = screen_area(c->desktop);
     x = c->frame->area.x;
     y = c->frame->area.y;
     width = c->frame->area.width;
@@ -1286,27 +1389,26 @@ void action_growtoedge(union ActionData *data)
     frame_frame_gravity(c->frame, &x, &y);
     width -= c->frame->size.left + c->frame->size.right;
     height -= c->frame->size.top + c->frame->size.bottom;
-    grab_pointer(TRUE, OB_CURSOR_NONE);
+    client_action_start(data);
     client_move_resize(c, x, y, width, height);
-    grab_pointer(FALSE, OB_CURSOR_NONE);
+    client_action_end(data);
 }
 
 void action_send_to_layer(union ActionData *data)
 {
-    if (data->layer.any.c)
-        client_set_layer(data->layer.any.c, data->layer.layer);
+    client_set_layer(data->layer.any.c, data->layer.layer);
 }
 
 void action_toggle_layer(union ActionData *data)
 {
     ObClient *c = data->layer.any.c;
 
-    if (c) {
-        if (data->layer.layer < 0)
-            client_set_layer(c, c->below ? 0 : -1);
-        else if (data->layer.layer > 0)
-            client_set_layer(c, c->above ? 0 : 1);
-    }
+    client_action_start(data);
+    if (data->layer.layer < 0)
+        client_set_layer(c, c->below ? 0 : -1);
+    else if (data->layer.layer > 0)
+        client_set_layer(c, c->above ? 0 : 1);
+    client_action_end(data);
 }
 
 void action_toggle_show_desktop(union ActionData *data)
This page took 0.040912 seconds and 4 git commands to generate.