From: Dana Jansens Date: Fri, 22 Jun 2007 19:10:00 +0000 (+0000) Subject: add directionaldesktop action X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=6973d5b8a50844ef8eecf076f8f15d5ece4270ef;p=chaz%2Fopenbox add directionaldesktop action --- diff --git a/Makefile.am b/Makefile.am index 5134c9c8..63c3f843 100644 --- a/Makefile.am +++ b/Makefile.am @@ -163,6 +163,7 @@ openbox_openbox_SOURCES = \ openbox/actions/decorations.c \ openbox/actions/desktop.c \ openbox/actions/directionalcyclewindows.c \ + openbox/actions/directionaldesktop.c \ openbox/actions/directionaltargetwindow.c \ openbox/actions/execute.c \ openbox/actions/exit.c \ diff --git a/openbox/action.c b/openbox/action.c index 58a0e61f..be54a006 100644 --- a/openbox/action.c +++ b/openbox/action.c @@ -390,36 +390,6 @@ ActionString actionstrings[] = action_send_to_desktop_dir, setup_action_send_to_desktop_down }, - { - "desktopnext", - action_desktop_dir, - setup_action_desktop_next - }, - { - "desktopprevious", - action_desktop_dir, - setup_action_desktop_prev - }, - { - "desktopright", - action_desktop_dir, - setup_action_desktop_right - }, - { - "desktopleft", - action_desktop_dir, - setup_action_desktop_left - }, - { - "desktopup", - action_desktop_dir, - setup_action_desktop_up - }, - { - "desktopdown", - action_desktop_dir, - setup_action_desktop_down - }, { "toggledockautohide", action_toggle_dockautohide, @@ -607,12 +577,6 @@ ObAction *action_parse(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node, if (act->data.sendto.desk > 0) act->data.sendto.desk--; if ((n = parse_find_node("follow", node->xmlChildrenNode))) act->data.sendto.follow = parse_bool(doc, n); - } else if (act->func == action_desktop_dir) { - if ((n = parse_find_node("wrap", node->xmlChildrenNode))) - act->data.desktopdir.wrap = parse_bool(doc, n); - if ((n = parse_find_node("dialog", node->xmlChildrenNode))) - act->data.desktopdir.inter.any.interactive = - parse_bool(doc, n); } else if (act->func == action_send_to_desktop_dir) { if ((n = parse_find_node("wrap", node->xmlChildrenNode))) act->data.sendtodir.wrap = parse_bool(doc, n); diff --git a/openbox/actions/all.c b/openbox/actions/all.c index 3fb4f816..cb3f9871 100644 --- a/openbox/actions/all.c +++ b/openbox/actions/all.c @@ -33,4 +33,5 @@ void action_all_startup() action_resize_startup(); action_decorations_startup(); action_desktop_startup(); + action_directionaldesktop_startup(); } diff --git a/openbox/actions/all.h b/openbox/actions/all.h index 290c8f14..ea0a3d25 100644 --- a/openbox/actions/all.h +++ b/openbox/actions/all.h @@ -34,5 +34,6 @@ void action_directionaltargetwindow_startup(); void action_resize_startup(); void action_decorations_startup(); void action_desktop_startup(); +void action_directionaldesktop_startup(); #endif diff --git a/openbox/actions/desktop.c b/openbox/actions/desktop.c index 7461d849..2d2014e4 100644 --- a/openbox/actions/desktop.c +++ b/openbox/actions/desktop.c @@ -12,7 +12,7 @@ static gboolean run_func(ObActionsData *data, gpointer options); void action_desktop_startup() { - actions_register("desktop", + actions_register("Desktop", setup_func, free_func, run_func, diff --git a/openbox/actions/directionalcyclewindows.c b/openbox/actions/directionalcyclewindows.c index 6554eeff..65cc05b5 100644 --- a/openbox/actions/directionalcyclewindows.c +++ b/openbox/actions/directionalcyclewindows.c @@ -50,17 +50,21 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node) o->desktop_windows = parse_bool(doc, n); if ((n = parse_find_node("direction", node))) { gchar *s = parse_string(doc, n); - if (!g_ascii_strcasecmp(s, "north")) + if (!g_ascii_strcasecmp(s, "north") || + !g_ascii_strcasecmp(s, "up")) o->direction = OB_DIRECTION_NORTH; else if (!g_ascii_strcasecmp(s, "northwest")) o->direction = OB_DIRECTION_NORTHWEST; else if (!g_ascii_strcasecmp(s, "northeast")) o->direction = OB_DIRECTION_NORTHEAST; - else if (!g_ascii_strcasecmp(s, "west")) + else if (!g_ascii_strcasecmp(s, "west") || + !g_ascii_strcasecmp(s, "left")) o->direction = OB_DIRECTION_WEST; - else if (!g_ascii_strcasecmp(s, "east")) + else if (!g_ascii_strcasecmp(s, "east") || + !g_ascii_strcasecmp(s, "right")) o->direction = OB_DIRECTION_EAST; - else if (!g_ascii_strcasecmp(s, "south")) + else if (!g_ascii_strcasecmp(s, "south") || + !g_ascii_strcasecmp(s, "down")) o->direction = OB_DIRECTION_NORTH; else if (!g_ascii_strcasecmp(s, "southwest")) o->direction = OB_DIRECTION_NORTHWEST; diff --git a/openbox/actions/directionaldesktop.c b/openbox/actions/directionaldesktop.c new file mode 100644 index 00000000..c052e6e0 --- /dev/null +++ b/openbox/actions/directionaldesktop.c @@ -0,0 +1,84 @@ +#include "openbox/actions.h" +#include "openbox/screen.h" +#include + +typedef struct { + gboolean linear; + gboolean wrap; + ObDirection dir; +} Options; + +static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node); +static void free_func(gpointer options); +static gboolean run_func(ObActionsData *data, gpointer options); + +void action_directionaldesktop_startup() +{ + actions_register("DirectionalDesktop", + setup_func, + free_func, + run_func, + NULL, NULL); +} + +static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node) +{ + xmlNodePtr n; + Options *o; + + o = g_new0(Options, 1); + o->wrap = TRUE; + o->dir = OB_DIRECTION_EAST; + + if ((n = parse_find_node("wrap", node))) + o->wrap = parse_bool(doc, n); + if ((n = parse_find_node("direction", node))) { + gchar *s = parse_string(doc, n); + if (!g_ascii_strcasecmp(s, "next")) { + o->linear = TRUE; + o->dir = OB_DIRECTION_EAST; + } + else if (!g_ascii_strcasecmp(s, "previous")) { + o->linear = TRUE; + o->dir = OB_DIRECTION_WEST; + } + else if (!g_ascii_strcasecmp(s, "north") || + !g_ascii_strcasecmp(s, "up")) + o->dir = OB_DIRECTION_NORTH; + else if (!g_ascii_strcasecmp(s, "south") || + !g_ascii_strcasecmp(s, "down")) + o->dir = OB_DIRECTION_SOUTH; + else if (!g_ascii_strcasecmp(s, "west") || + !g_ascii_strcasecmp(s, "left")) + o->dir = OB_DIRECTION_WEST; + else if (!g_ascii_strcasecmp(s, "east") || + !g_ascii_strcasecmp(s, "right")) + o->dir = OB_DIRECTION_EAST; + g_free(s); + } + + return o; +} + +static void free_func(gpointer options) +{ + Options *o = options; + + g_free(o); +} + +/* Always return FALSE because its not interactive */ +static gboolean run_func(ObActionsData *data, gpointer options) +{ + Options *o = options; + guint d; + + d = screen_cycle_desktop(o->dir, + o->wrap, + o->linear, + FALSE, TRUE, FALSE); + if (d != screen_desktop) + screen_set_desktop(d, TRUE); + + return FALSE; +} diff --git a/openbox/actions/directionaltargetwindow.c b/openbox/actions/directionaltargetwindow.c index 93d33fbe..ac6d8b72 100644 --- a/openbox/actions/directionaltargetwindow.c +++ b/openbox/actions/directionaltargetwindow.c @@ -42,17 +42,21 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node) o->desktop_windows = parse_bool(doc, n); if ((n = parse_find_node("direction", node))) { gchar *s = parse_string(doc, n); - if (!g_ascii_strcasecmp(s, "north")) + if (!g_ascii_strcasecmp(s, "north") || + !g_ascii_strcasecmp(s, "up")) o->direction = OB_DIRECTION_NORTH; else if (!g_ascii_strcasecmp(s, "northwest")) o->direction = OB_DIRECTION_NORTHWEST; else if (!g_ascii_strcasecmp(s, "northeast")) o->direction = OB_DIRECTION_NORTHEAST; - else if (!g_ascii_strcasecmp(s, "west")) + else if (!g_ascii_strcasecmp(s, "west") || + !g_ascii_strcasecmp(s, "left")) o->direction = OB_DIRECTION_WEST; - else if (!g_ascii_strcasecmp(s, "east")) + else if (!g_ascii_strcasecmp(s, "east") || + !g_ascii_strcasecmp(s, "right")) o->direction = OB_DIRECTION_EAST; - else if (!g_ascii_strcasecmp(s, "south")) + else if (!g_ascii_strcasecmp(s, "south") || + !g_ascii_strcasecmp(s, "down")) o->direction = OB_DIRECTION_NORTH; else if (!g_ascii_strcasecmp(s, "southwest")) o->direction = OB_DIRECTION_NORTHWEST;