From: Dana Jansens Date: Fri, 22 Jun 2007 19:15:07 +0000 (+0000) Subject: let you use "last" in desktop action X-Git-Url: https://git.dogcows.com/gitweb?a=commitdiff_plain;h=4044b942e74b59599e82bb4834a730c32e49820d;p=chaz%2Fopenbox let you use "last" in desktop action --- diff --git a/openbox/action.c b/openbox/action.c index be54a006..37370e80 100644 --- a/openbox/action.c +++ b/openbox/action.c @@ -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; diff --git a/openbox/actions/desktop.c b/openbox/actions/desktop.c index 2d2014e4..6da47740 100644 --- a/openbox/actions/desktop.c +++ b/openbox/actions/desktop.c @@ -3,6 +3,7 @@ #include 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; }