1 #include "openbox/actions.h"
2 #include "openbox/client.h"
3 #include "openbox/screen.h"
4 #include "openbox/frame.h"
5 #include "openbox/config.h"
14 static gpointer setup_func(xmlNodePtr node);
15 static void free_func(gpointer o);
16 static gboolean run_func(ObActionsData *data, gpointer options);
18 void action_moverelative_startup(void)
20 actions_register("MoveRelative", setup_func, free_func, run_func);
23 static gpointer setup_func(xmlNodePtr node)
29 o = g_slice_new0(Options);
31 if ((n = obt_xml_find_node(node, "x"))) {
32 s = obt_xml_node_string(n);
33 config_parse_relative_number(s, &o->x, &o->x_denom);
36 if ((n = obt_xml_find_node(node, "y"))) {
37 s = obt_xml_node_string(n);
38 config_parse_relative_number(s, &o->y, &o->y_denom);
45 static void free_func(gpointer o)
47 g_slice_free(Options, o);
50 /* Always return FALSE because its not interactive */
51 static gboolean run_func(ObActionsData *data, gpointer options)
57 gint x, y, lw, lh, w, h;
62 if (o->x_denom || o->y_denom) {
65 carea = screen_area(c->desktop, client_monitor(c), NULL);
67 x = (x * carea->width) / o->x_denom;
69 y = (y * carea->height) / o->y_denom;
75 client_try_configure(c, &x, &y, &w, &h, &lw, &lh, TRUE);
76 client_find_onscreen(c, &x, &y, w, h, FALSE);
78 actions_client_move(data, TRUE);
79 client_configure(c, x, y, w, h, TRUE, TRUE, FALSE);
80 actions_client_move(data, FALSE);