1 #include "openbox/actions.h"
2 #include "openbox/client.h"
3 #include "openbox/screen.h"
4 #include "openbox/frame.h"
5 #include <stdlib.h> /* for atoi */
17 static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
18 static void free_func(gpointer options);
19 static gboolean run_func(ObActionsData *data, gpointer options);
21 void action_moveto_startup()
23 actions_register("MoveTo",
30 static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
35 o = g_new0(Options, 1);
40 if ((n = parse_find_node("x", node))) {
41 gchar *s = parse_string(doc, n);
42 if (!g_ascii_strcasecmp(s, "center"))
47 if (s[0] == '-' || s[0] == '+')
55 if ((n = parse_find_node("y", node))) {
56 gchar *s = parse_string(doc, n);
57 if (!g_ascii_strcasecmp(s, "center"))
62 if (s[0] == '-' || s[0] == '+')
70 if ((n = parse_find_node("monitor", node)))
71 o->monitor = parse_int(doc, n) - 1;
76 static void free_func(gpointer options)
83 /* Always return FALSE because its not interactive */
84 static gboolean run_func(ObActionsData *data, gpointer options)
92 gint x, y, lw, lh, w, h;
96 cmon = client_monitor(c);
97 if (mon < 0) mon = cmon;
98 area = screen_area(c->desktop, mon, NULL);
99 carea = screen_area(c->desktop, cmon, NULL);
102 if (o->xcenter) x = (area->width - c->frame->area.width) / 2;
103 else if (x == G_MININT) x = c->frame->area.x - carea->x;
104 else if (o->xopposite) x = area->width - c->frame->area.width;
108 if (o->ycenter) y = (area->height - c->frame->area.height) / 2;
109 else if (y == G_MININT) y = c->frame->area.y - carea->y;
110 else if (o->yopposite) y = area->height - c->frame->area.height;
116 frame_frame_gravity(c->frame, &x, &y); /* get the client coords */
117 client_try_configure(c, &x, &y, &w, &h, &lw, &lh, TRUE);
118 /* force it on screen if its moving to another monitor */
119 client_find_onscreen(c, &x, &y, w, h, mon != cmon);
121 actions_client_move(data, TRUE);
122 client_configure(c, x, y, w, h, TRUE, TRUE, FALSE);
123 actions_client_move(data, FALSE);