1 #include "openbox/actions.h"
2 #include "openbox/misc.h"
3 #include "openbox/client.h"
4 #include "openbox/frame.h"
5 #include "openbox/screen.h"
12 static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
13 static gpointer setup_north_func(ObParseInst *i,
14 xmlDocPtr doc, xmlNodePtr node);
15 static gpointer setup_south_func(ObParseInst *i,
16 xmlDocPtr doc, xmlNodePtr node);
17 static gpointer setup_east_func(ObParseInst *i,
18 xmlDocPtr doc, xmlNodePtr node);
19 static gpointer setup_west_func(ObParseInst *i,
20 xmlDocPtr doc, xmlNodePtr node);
21 static void free_func(gpointer options);
22 static gboolean run_func(ObActionsData *data, gpointer options);
24 void action_growtoedge_startup()
26 actions_register("GrowToEdge",
31 actions_register("GrowToEdgeNorth",
36 actions_register("GrowToEdgeSouth",
41 actions_register("GrowToEdgeEast",
46 actions_register("GrowToEdgeWest",
53 static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
58 o = g_new0(Options, 1);
59 o->dir = OB_DIRECTION_NORTH;
61 if ((n = parse_find_node("direction", node))) {
62 gchar *s = parse_string(doc, n);
63 if (!g_ascii_strcasecmp(s, "north") ||
64 !g_ascii_strcasecmp(s, "up"))
65 o->dir = OB_DIRECTION_NORTH;
66 else if (!g_ascii_strcasecmp(s, "south") ||
67 !g_ascii_strcasecmp(s, "down"))
68 o->dir = OB_DIRECTION_SOUTH;
69 else if (!g_ascii_strcasecmp(s, "west") ||
70 !g_ascii_strcasecmp(s, "left"))
71 o->dir = OB_DIRECTION_WEST;
72 else if (!g_ascii_strcasecmp(s, "east") ||
73 !g_ascii_strcasecmp(s, "right"))
74 o->dir = OB_DIRECTION_EAST;
81 static gpointer setup_north_func(ObParseInst *i,
82 xmlDocPtr doc, xmlNodePtr node)
84 Options *o = g_new0(Options, 1);
85 o->dir = OB_DIRECTION_NORTH;
89 static gpointer setup_south_func(ObParseInst *i,
90 xmlDocPtr doc, xmlNodePtr node)
92 Options *o = g_new0(Options, 1);
93 o->dir = OB_DIRECTION_SOUTH;
97 static gpointer setup_east_func(ObParseInst *i,
98 xmlDocPtr doc, xmlNodePtr node)
100 Options *o = g_new0(Options, 1);
101 o->dir = OB_DIRECTION_EAST;
105 static gpointer setup_west_func(ObParseInst *i,
106 xmlDocPtr doc, xmlNodePtr node)
108 Options *o = g_new0(Options, 1);
109 o->dir = OB_DIRECTION_WEST;
113 static void free_func(gpointer options)
115 Options *o = options;
120 /* Always return FALSE because its not interactive */
121 static gboolean run_func(ObActionsData *data, gpointer options)
123 Options *o = options;
128 /* don't allow vertical resize if shaded */
129 if (o->dir != OB_DIRECTION_NORTH || o->dir != OB_DIRECTION_SOUTH ||
130 !data->client->shaded)
132 client_find_resize_directional(data->client, o->dir, TRUE,
134 if (x != data->client->area.x || y != data->client->area.y ||
135 w != data->client->area.width ||
136 h != data->client->area.height)
138 actions_client_move(data, TRUE);
139 client_move_resize(data->client, x, y, w, h);
140 actions_client_move(data, FALSE);