1 #include "openbox/action.h"
2 #include "openbox/action_list_run.h"
3 #include "openbox/config_value.h"
4 #include "openbox/misc.h"
5 #include "openbox/client.h"
6 #include "openbox/client_set.h"
7 #include "openbox/frame.h"
8 #include "openbox/geom.h"
15 static gpointer setup_func(GHashTable *config);
16 static void free_func(gpointer o);
17 static gboolean run_func(const ObClientSet *set,
18 const ObActionListRun *data, gpointer options);
20 void action_movetoedge_startup(void)
22 action_register("MoveToEdge", OB_ACTION_DEFAULT_FILTER_SINGLE,
23 setup_func, free_func, run_func);
26 static gpointer setup_func(GHashTable *config)
31 o = g_slice_new0(Options);
32 o->dir = OB_DIRECTION_NORTH;
34 v = g_hash_table_lookup(config, "direction");
35 if (v && config_value_is_string(v)) {
36 const gchar *s = config_value_string(v);
37 if (!g_ascii_strcasecmp(s, "north") ||
38 !g_ascii_strcasecmp(s, "up"))
39 o->dir = OB_DIRECTION_NORTH;
40 else if (!g_ascii_strcasecmp(s, "south") ||
41 !g_ascii_strcasecmp(s, "down"))
42 o->dir = OB_DIRECTION_SOUTH;
43 else if (!g_ascii_strcasecmp(s, "west") ||
44 !g_ascii_strcasecmp(s, "left"))
45 o->dir = OB_DIRECTION_WEST;
46 else if (!g_ascii_strcasecmp(s, "east") ||
47 !g_ascii_strcasecmp(s, "right"))
48 o->dir = OB_DIRECTION_EAST;
54 static void free_func(gpointer o)
56 g_slice_free(Options, o);
59 static gboolean each_run(ObClient *c, const ObActionListRun *data,
65 client_find_move_directional(c, o->dir, &x, &y);
66 if (x != c->area.x || y != c->area.y)
71 /* Always return FALSE because its not interactive */
72 static gboolean run_func(const ObClientSet *set,
73 const ObActionListRun *data, gpointer options)
75 if (!client_set_is_empty(set)) {
76 action_client_move(data, TRUE);
77 client_set_run(set, data, each_run, options);
78 action_client_move(data, FALSE);