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, NULL, NULL);
23 /* 3.4-compatibility */
24 actions_register("MoveToEdgeNorth", setup_north_func, g_free, run_func,
26 actions_register("MoveToEdgeSouth", setup_south_func, g_free, run_func,
28 actions_register("MoveToEdgeEast", setup_east_func, g_free, run_func,
30 actions_register("MoveToEdgeWest", setup_west_func, g_free, run_func,
34 static gpointer setup_func(xmlNodePtr node)
39 o = g_new0(Options, 1);
40 o->dir = OB_DIRECTION_NORTH;
42 if ((n = obt_parse_find_node(node, "direction"))) {
43 gchar *s = obt_parse_node_string(n);
44 if (!g_ascii_strcasecmp(s, "north") ||
45 !g_ascii_strcasecmp(s, "up"))
46 o->dir = OB_DIRECTION_NORTH;
47 else if (!g_ascii_strcasecmp(s, "south") ||
48 !g_ascii_strcasecmp(s, "down"))
49 o->dir = OB_DIRECTION_SOUTH;
50 else if (!g_ascii_strcasecmp(s, "west") ||
51 !g_ascii_strcasecmp(s, "left"))
52 o->dir = OB_DIRECTION_WEST;
53 else if (!g_ascii_strcasecmp(s, "east") ||
54 !g_ascii_strcasecmp(s, "right"))
55 o->dir = OB_DIRECTION_EAST;
62 /* Always return FALSE because its not interactive */
63 static gboolean run_func(ObActionsData *data, gpointer options)
70 client_find_move_directional(data->client, o->dir, &x, &y);
71 if (x != data->client->area.x || y != data->client->area.y) {
72 actions_client_move(data, TRUE);
73 client_move(data->client, x, y);
74 actions_client_move(data, FALSE);
81 /* 3.4-compatibility */
82 static gpointer setup_north_func(xmlNodePtr node)
84 Options *o = g_new0(Options, 1);
85 o->dir = OB_DIRECTION_NORTH;
89 static gpointer setup_south_func(xmlNodePtr node)
91 Options *o = g_new0(Options, 1);
92 o->dir = OB_DIRECTION_SOUTH;
96 static gpointer setup_east_func(xmlNodePtr node)
98 Options *o = g_new0(Options, 1);
99 o->dir = OB_DIRECTION_EAST;
103 static gpointer setup_west_func(xmlNodePtr node)
105 Options *o = g_new0(Options, 1);
106 o->dir = OB_DIRECTION_WEST;