]> Dogcows Code - chaz/openbox/blob - openbox/actions/moverelative.c
1d1189cdb7c089d26ef74dd00e3052ef77cce863
[chaz/openbox] / openbox / actions / moverelative.c
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 */
6
7 typedef struct {
8 gint x;
9 gint y;
10 } Options;
11
12 static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
13 static void free_func(gpointer options);
14 static gboolean run_func(ObActionsData *data, gpointer options);
15
16 void action_moverelative_startup(void)
17 {
18 actions_register("MoveRelative",
19 setup_func,
20 free_func,
21 run_func,
22 NULL, NULL);
23 }
24
25 static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
26 {
27 xmlNodePtr n;
28 Options *o;
29
30 o = g_new0(Options, 1);
31
32 if ((n = parse_find_node("x", node)))
33 o->x = parse_int(doc, n);
34 if ((n = parse_find_node("y", node)))
35 o->y = parse_int(doc, n);
36
37 return o;
38 }
39
40 static void free_func(gpointer options)
41 {
42 Options *o = options;
43
44 g_free(o);
45 }
46
47 /* Always return FALSE because its not interactive */
48 static gboolean run_func(ObActionsData *data, gpointer options)
49 {
50 Options *o = options;
51
52 if (data->client) {
53 ObClient *c;
54 gint x, y, lw, lh, w, h;
55
56 c = data->client;
57 x = data->client->area.x + o->x;
58 y = data->client->area.y + o->y;
59 w = data->client->area.width;
60 h = data->client->area.height;
61 client_try_configure(data->client, &x, &y, &w, &h, &lw, &lh, TRUE);
62 client_find_onscreen(data->client, &x, &y, w, h, FALSE);
63
64 actions_client_move(data, TRUE);
65 client_configure(data->client, x, y, w, h, TRUE, TRUE, FALSE);
66 actions_client_move(data, FALSE);
67 }
68
69 return FALSE;
70 }
This page took 0.04047 seconds and 3 git commands to generate.