let you use "last" in desktop action
authorDana Jansens <danakj@orodu.net>
Fri, 22 Jun 2007 19:15:07 +0000 (19:15 +0000)
committerDana Jansens <danakj@orodu.net>
Fri, 22 Jun 2007 19:15:07 +0000 (19:15 +0000)
openbox/action.c
openbox/actions/desktop.c

index be54a00..37370e8 100644 (file)
@@ -773,27 +773,6 @@ void action_send_to_desktop(union ActionData *data)
     }
 }
 
-void action_desktop_dir(union ActionData *data)
-{
-    guint d;
-
-    d = screen_cycle_desktop(data->desktopdir.dir,
-                             data->desktopdir.wrap,
-                             data->desktopdir.linear,
-                             data->desktopdir.inter.any.interactive,
-                             data->desktopdir.inter.final,
-                             data->desktopdir.inter.cancel);
-    /* only move the desktop when the action is complete. if we switch
-       desktops during the interactive action, focus will move but with
-       NotifyWhileGrabbed and applications don't like that. */
-    if (!data->sendtodir.inter.any.interactive ||
-        (data->sendtodir.inter.final && !data->sendtodir.inter.cancel))
-    {
-        if (d != screen_desktop)
-            screen_set_desktop(d, TRUE);
-    }
-}
-
 void action_send_to_desktop_dir(union ActionData *data)
 {
     ObClient *c = data->sendtodir.inter.any.c;
index 2d2014e..6da4774 100644 (file)
@@ -3,6 +3,7 @@
 #include <glib.h>
 
 typedef struct {
+    gboolean last;
     guint desktop;
 } Options;
 
@@ -26,8 +27,14 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
 
     o = g_new0(Options, 1);
 
-    if ((n = parse_find_node("desktop", node)))
-        o->desktop = parse_int(doc, n) - 1;
+    if ((n = parse_find_node("desktop", node))) {
+        gchar *s = parse_string(doc, n);
+        if (!g_ascii_strcasecmp(s, "last"))
+            o->last = TRUE;
+        else
+            o->desktop = parse_int(doc, n) - 1;
+        g_free(s);
+    }
     return o;
 }
 
@@ -42,9 +49,15 @@ static void free_func(gpointer options)
 static gboolean run_func(ObActionsData *data, gpointer options)
 {
     Options *o = options;
+    guint d;
 
-    if (o->desktop < screen_num_desktops)
-        screen_set_desktop(o->desktop, TRUE);
+    if (o->last)
+        d = screen_last_desktop;
+    else
+        d = o->desktop;
+
+    if (d < screen_num_desktops)
+        screen_set_desktop(d, TRUE);
 
     return FALSE;
 }