1 #include "openbox/action.h"
2 #include "openbox/action_value.h"
3 #include "openbox/misc.h"
4 #include "openbox/client.h"
5 #include "openbox/frame.h"
6 #include "openbox/geom.h"
13 static gpointer setup_func(GHashTable *config);
14 static void free_func(gpointer o);
15 static gboolean run_func(ObActionData *data, gpointer options);
17 void action_movetoedge_startup(void)
19 action_register("MoveToEdge", OB_ACTION_DEFAULT_FILTER_SINGLE,
20 setup_func, free_func, run_func);
23 static gpointer setup_func(GHashTable *config)
28 o = g_slice_new0(Options);
29 o->dir = OB_DIRECTION_NORTH;
31 v = g_hash_table_lookup(config, "direction");
32 if (v && action_value_is_string(v)) {
33 const gchar *s = action_value_string(v);
34 if (!g_ascii_strcasecmp(s, "north") ||
35 !g_ascii_strcasecmp(s, "up"))
36 o->dir = OB_DIRECTION_NORTH;
37 else if (!g_ascii_strcasecmp(s, "south") ||
38 !g_ascii_strcasecmp(s, "down"))
39 o->dir = OB_DIRECTION_SOUTH;
40 else if (!g_ascii_strcasecmp(s, "west") ||
41 !g_ascii_strcasecmp(s, "left"))
42 o->dir = OB_DIRECTION_WEST;
43 else if (!g_ascii_strcasecmp(s, "east") ||
44 !g_ascii_strcasecmp(s, "right"))
45 o->dir = OB_DIRECTION_EAST;
51 static void free_func(gpointer o)
53 g_slice_free(Options, o);
56 /* Always return FALSE because its not interactive */
57 static gboolean run_func(ObActionData *data, gpointer options)
64 client_find_move_directional(data->client, o->dir, &x, &y);
65 if (x != data->client->area.x || y != data->client->area.y) {
66 action_client_move(data, TRUE);
67 client_move(data->client, x, y);
68 action_client_move(data, FALSE);