1 #include "openbox/actions.h"
2 #include "openbox/misc.h"
3 #include "openbox/client.h"
4 #include "openbox/frame.h"
5 #include "openbox/geom.h"
12 static gpointer setup_func(xmlNodePtr node);
13 static gboolean run_func(ObActionsData *data, gpointer options);
14 /* 3.4-compatibility */
15 static gpointer setup_north_func(xmlNodePtr node);
16 static gpointer setup_south_func(xmlNodePtr node);
17 static gpointer setup_east_func(xmlNodePtr node);
18 static gpointer setup_west_func(xmlNodePtr node);
20 void action_movetoedge_startup(void)
22 actions_register("MoveToEdge", setup_func, g_free, run_func);
23 /* 3.4-compatibility */
24 actions_register("MoveToEdgeNorth", setup_north_func, g_free, run_func);
25 actions_register("MoveToEdgeSouth", setup_south_func, g_free, run_func);
26 actions_register("MoveToEdgeEast", setup_east_func, g_free, run_func);
27 actions_register("MoveToEdgeWest", setup_west_func, g_free, run_func);
30 static gpointer setup_func(xmlNodePtr node)
35 o = g_new0(Options, 1);
36 o->dir = OB_DIRECTION_NORTH;
38 if ((n = obt_parse_find_node(node, "direction"))) {
39 gchar *s = obt_parse_node_string(n);
40 if (!g_ascii_strcasecmp(s, "north") ||
41 !g_ascii_strcasecmp(s, "up"))
42 o->dir = OB_DIRECTION_NORTH;
43 else if (!g_ascii_strcasecmp(s, "south") ||
44 !g_ascii_strcasecmp(s, "down"))
45 o->dir = OB_DIRECTION_SOUTH;
46 else if (!g_ascii_strcasecmp(s, "west") ||
47 !g_ascii_strcasecmp(s, "left"))
48 o->dir = OB_DIRECTION_WEST;
49 else if (!g_ascii_strcasecmp(s, "east") ||
50 !g_ascii_strcasecmp(s, "right"))
51 o->dir = OB_DIRECTION_EAST;
58 /* Always return FALSE because its not interactive */
59 static gboolean run_func(ObActionsData *data, gpointer options)
66 client_find_move_directional(data->client, o->dir, &x, &y);
67 if (x != data->client->area.x || y != data->client->area.y) {
68 actions_client_move(data, TRUE);
69 client_move(data->client, x, y);
70 actions_client_move(data, FALSE);
77 /* 3.4-compatibility */
78 static gpointer setup_north_func(xmlNodePtr node)
80 Options *o = g_new0(Options, 1);
81 o->dir = OB_DIRECTION_NORTH;
85 static gpointer setup_south_func(xmlNodePtr node)
87 Options *o = g_new0(Options, 1);
88 o->dir = OB_DIRECTION_SOUTH;
92 static gpointer setup_east_func(xmlNodePtr node)
94 Options *o = g_new0(Options, 1);
95 o->dir = OB_DIRECTION_EAST;
99 static gpointer setup_west_func(xmlNodePtr node)
101 Options *o = g_new0(Options, 1);
102 o->dir = OB_DIRECTION_WEST;