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"
6 #include <stdlib.h> /* for atoi */
15 static gpointer setup_func(xmlNodePtr node);
16 static void free_func(gpointer o);
17 static gboolean run_func(ObActionsData *data, gpointer options);
19 void action_moverelative_startup(void)
21 actions_register("MoveRelative", setup_func, free_func, run_func);
24 static gpointer setup_func(xmlNodePtr node)
30 o = g_slice_new0(Options);
32 if ((n = obt_xml_find_node(node, "x"))) {
33 s = obt_xml_node_string(n);
34 config_parse_relative_number(s, &o->x, &o->x_denom);
37 if ((n = obt_xml_find_node(node, "y"))) {
38 s = obt_xml_node_string(n);
39 config_parse_relative_number(s, &o->y, &o->y_denom);
46 static void free_func(gpointer o)
48 g_slice_free(Options, o);
51 /* Always return FALSE because its not interactive */
52 static gboolean run_func(ObActionsData *data, gpointer options)
58 gint x, y, lw, lh, w, h;
63 if (o->x_denom || o->y_denom) {
66 carea = screen_area(c->desktop, client_monitor(c), NULL);
68 x = (x * carea->width) / o->x_denom;
70 y = (y * carea->height) / o->y_denom;
76 client_try_configure(c, &x, &y, &w, &h, &lw, &lh, TRUE);
77 client_find_onscreen(c, &x, &y, w, h, FALSE);
79 actions_client_move(data, TRUE);
80 client_configure(c, x, y, w, h, TRUE, TRUE, FALSE);
81 actions_client_move(data, FALSE);