1 #include "openbox/actions.h"
2 #include "openbox/misc.h"
3 #include "openbox/client.h"
4 #include "openbox/frame.h"
12 static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
13 static gpointer setup_to_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
14 static gpointer setup_from_func(ObParseInst *i,xmlDocPtr doc, xmlNodePtr node);
15 static void free_func(gpointer options);
16 static gboolean run_func(ObActionsData *data, gpointer options);
18 void action_movetofromedge_startup()
20 actions_register("MoveToEdge",
25 actions_register("MoveFromEdge",
32 static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
37 o = g_new0(Options, 1);
38 o->dir = OB_DIRECTION_NORTH;
40 if ((n = parse_find_node("direction", node))) {
41 gchar *s = parse_string(doc, n);
42 if (!g_ascii_strcasecmp(s, "north") ||
43 !g_ascii_strcasecmp(s, "up"))
44 o->dir = OB_DIRECTION_NORTH;
45 else if (!g_ascii_strcasecmp(s, "south") ||
46 !g_ascii_strcasecmp(s, "down"))
47 o->dir = OB_DIRECTION_SOUTH;
48 else if (!g_ascii_strcasecmp(s, "west") ||
49 !g_ascii_strcasecmp(s, "left"))
50 o->dir = OB_DIRECTION_WEST;
51 else if (!g_ascii_strcasecmp(s, "east") ||
52 !g_ascii_strcasecmp(s, "right"))
53 o->dir = OB_DIRECTION_EAST;
60 static gpointer setup_to_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
62 Options *o = setup_func(i, doc, node);
67 static gpointer setup_from_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
69 Options *o = setup_func(i, doc, node);
74 static void free_func(gpointer options)
81 /* Always return FALSE because its not interactive */
82 static gboolean run_func(ObActionsData *data, gpointer options)
88 ObClient *c = data->client;
94 case OB_DIRECTION_NORTH:
95 y = client_directional_edge_search(c, OB_DIRECTION_NORTH,
97 - (o->hang ? c->frame->area.height : 0);
99 case OB_DIRECTION_WEST:
100 x = client_directional_edge_search(c, OB_DIRECTION_WEST,
102 - (o->hang ? c->frame->area.width : 0);
104 case OB_DIRECTION_SOUTH:
105 y = client_directional_edge_search(c, OB_DIRECTION_SOUTH,
107 - (o->hang ? 0 : c->frame->area.height);
109 case OB_DIRECTION_EAST:
110 x = client_directional_edge_search(c, OB_DIRECTION_EAST,
112 - (o->hang ? 0 : c->frame->area.width);
115 g_assert_not_reached();
117 frame_frame_gravity(c->frame, &x, &y);
119 actions_client_move(data, FALSE);
120 client_move(c, x, y);
121 actions_client_move(data, TRUE);