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 void free_func(gpointer o);
14 static gboolean run_func(ObActionsData *data, gpointer options);
15 /* 3.4-compatibility */
16 static gpointer setup_north_func(xmlNodePtr node);
17 static gpointer setup_south_func(xmlNodePtr node);
18 static gpointer setup_east_func(xmlNodePtr node);
19 static gpointer setup_west_func(xmlNodePtr node);
21 void action_movetoedge_startup(void)
23 actions_register("MoveToEdge", setup_func, free_func, run_func);
24 /* 3.4-compatibility */
25 actions_register("MoveToEdgeNorth", setup_north_func, free_func, run_func);
26 actions_register("MoveToEdgeSouth", setup_south_func, free_func, run_func);
27 actions_register("MoveToEdgeEast", setup_east_func, free_func, run_func);
28 actions_register("MoveToEdgeWest", setup_west_func, free_func, run_func);
31 static gpointer setup_func(xmlNodePtr node)
36 o = g_slice_new0(Options);
37 o->dir = OB_DIRECTION_NORTH;
39 if ((n = obt_xml_find_node(node, "direction"))) {
40 gchar *s = obt_xml_node_string(n);
41 if (!g_ascii_strcasecmp(s, "north") ||
42 !g_ascii_strcasecmp(s, "up"))
43 o->dir = OB_DIRECTION_NORTH;
44 else if (!g_ascii_strcasecmp(s, "south") ||
45 !g_ascii_strcasecmp(s, "down"))
46 o->dir = OB_DIRECTION_SOUTH;
47 else if (!g_ascii_strcasecmp(s, "west") ||
48 !g_ascii_strcasecmp(s, "left"))
49 o->dir = OB_DIRECTION_WEST;
50 else if (!g_ascii_strcasecmp(s, "east") ||
51 !g_ascii_strcasecmp(s, "right"))
52 o->dir = OB_DIRECTION_EAST;
59 static void free_func(gpointer o)
61 g_slice_free(Options, o);
64 /* Always return FALSE because its not interactive */
65 static gboolean run_func(ObActionsData *data, gpointer options)
72 client_find_move_directional(data->client, o->dir, &x, &y);
73 if (x != data->client->area.x || y != data->client->area.y) {
74 actions_client_move(data, TRUE);
75 client_move(data->client, x, y);
76 actions_client_move(data, FALSE);
83 /* 3.4-compatibility */
84 static gpointer setup_north_func(xmlNodePtr node)
86 Options *o = g_slice_new0(Options);
87 o->dir = OB_DIRECTION_NORTH;
91 static gpointer setup_south_func(xmlNodePtr node)
93 Options *o = g_slice_new0(Options);
94 o->dir = OB_DIRECTION_SOUTH;
98 static gpointer setup_east_func(xmlNodePtr node)
100 Options *o = g_slice_new0(Options);
101 o->dir = OB_DIRECTION_EAST;
105 static gpointer setup_west_func(xmlNodePtr node)
107 Options *o = g_slice_new0(Options);
108 o->dir = OB_DIRECTION_WEST;