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