X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=openbox%2Factions%2Fmovetoedge.c;h=ef5b69201f54f8229cb0a4e7c0ffabe347569b93;hb=d179d6428ae585a3b8a13479bfe4586e41de2ff9;hp=8a4044beb06edc4a58fe2b468c0c11b667b9ea08;hpb=2a4cd4f6bd9f6b5a43ea6a825e964fb1f4dccd80;p=chaz%2Fopenbox diff --git a/openbox/actions/movetoedge.c b/openbox/actions/movetoedge.c index 8a4044be..ef5b6920 100644 --- a/openbox/actions/movetoedge.c +++ b/openbox/actions/movetoedge.c @@ -9,29 +9,35 @@ typedef struct { ObDirection dir; } Options; -static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node); -static void free_func(gpointer options); +static gpointer setup_func(xmlNodePtr node); +static void free_func(gpointer o); static gboolean run_func(ObActionsData *data, gpointer options); +/* 3.4-compatibility */ +static gpointer setup_north_func(xmlNodePtr node); +static gpointer setup_south_func(xmlNodePtr node); +static gpointer setup_east_func(xmlNodePtr node); +static gpointer setup_west_func(xmlNodePtr node); -void action_movetofromedge_startup() +void action_movetoedge_startup(void) { - actions_register("MoveToEdge", - setup_func, - free_func, - run_func, - NULL, NULL); + actions_register("MoveToEdge", setup_func, free_func, run_func); + /* 3.4-compatibility */ + actions_register("MoveToEdgeNorth", setup_north_func, free_func, run_func); + actions_register("MoveToEdgeSouth", setup_south_func, free_func, run_func); + actions_register("MoveToEdgeEast", setup_east_func, free_func, run_func); + actions_register("MoveToEdgeWest", setup_west_func, free_func, run_func); } -static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node) +static gpointer setup_func(xmlNodePtr node) { xmlNodePtr n; Options *o; - o = g_new0(Options, 1); + o = g_slice_new0(Options); o->dir = OB_DIRECTION_NORTH; - if ((n = parse_find_node("direction", node))) { - gchar *s = parse_string(doc, n); + if ((n = obt_xml_find_node(node, "direction"))) { + gchar *s = obt_xml_node_string(n); if (!g_ascii_strcasecmp(s, "north") || !g_ascii_strcasecmp(s, "up")) o->dir = OB_DIRECTION_NORTH; @@ -50,11 +56,9 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node) return o; } -static void free_func(gpointer options) +static void free_func(gpointer o) { - Options *o = options; - - g_free(o); + g_slice_free(Options, o); } /* Always return FALSE because its not interactive */ @@ -67,11 +71,41 @@ static gboolean run_func(ObActionsData *data, gpointer options) client_find_move_directional(data->client, o->dir, &x, &y); if (x != data->client->area.x || y != data->client->area.y) { - actions_client_move(data, FALSE); - client_move(data->client, x, y); actions_client_move(data, TRUE); + client_move(data->client, x, y); + actions_client_move(data, FALSE); } } return FALSE; } + +/* 3.4-compatibility */ +static gpointer setup_north_func(xmlNodePtr node) +{ + Options *o = g_slice_new0(Options); + o->dir = OB_DIRECTION_NORTH; + return o; +} + +static gpointer setup_south_func(xmlNodePtr node) +{ + Options *o = g_slice_new0(Options); + o->dir = OB_DIRECTION_SOUTH; + return o; +} + +static gpointer setup_east_func(xmlNodePtr node) +{ + Options *o = g_slice_new0(Options); + o->dir = OB_DIRECTION_EAST; + return o; +} + +static gpointer setup_west_func(xmlNodePtr node) +{ + Options *o = g_slice_new0(Options); + o->dir = OB_DIRECTION_WEST; + return o; +} +