]>
Dogcows Code - chaz/openbox/blob - openbox/actions/resizerelative.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 */
14 static gpointer
setup_func(xmlNodePtr node
);
15 static gboolean
run_func(ObActionsData
*data
, gpointer options
);
17 void action_resizerelative_startup(void)
19 actions_register("ResizeRelative", setup_func
, g_free
, run_func
);
22 static gpointer
setup_func(xmlNodePtr node
)
27 o
= g_new0(Options
, 1);
29 if ((n
= obt_xml_find_node(node
, "left")))
30 o
->left
= obt_xml_node_int(n
);
31 if ((n
= obt_xml_find_node(node
, "right")))
32 o
->right
= obt_xml_node_int(n
);
33 if ((n
= obt_xml_find_node(node
, "top")) ||
34 (n
= obt_xml_find_node(node
, "up")))
35 o
->top
= obt_xml_node_int(n
);
36 if ((n
= obt_xml_find_node(node
, "bottom")) ||
37 (n
= obt_xml_find_node(node
, "down")))
38 o
->bottom
= obt_xml_node_int(n
);
43 /* Always return FALSE because its not interactive */
44 static gboolean
run_func(ObActionsData
*data
, gpointer options
)
49 ObClient
*c
= data
->client
;
50 gint x
, y
, ow
, xoff
, nw
, oh
, yoff
, nh
, lw
, lh
;
55 xoff
= -o
->left
* c
->size_inc
.width
;
56 nw
= ow
+ o
->right
* c
->size_inc
.width
57 + o
->left
* c
->size_inc
.width
;
59 yoff
= -o
->top
* c
->size_inc
.height
;
60 nh
= oh
+ o
->bottom
* c
->size_inc
.height
61 + o
->top
* c
->size_inc
.height
;
63 client_try_configure(c
, &x
, &y
, &nw
, &nh
, &lw
, &lh
, TRUE
);
64 xoff
= xoff
== 0 ? 0 :
65 (xoff
< 0 ? MAX(xoff
, ow
-nw
) : MIN(xoff
, ow
-nw
));
66 yoff
= yoff
== 0 ? 0 :
67 (yoff
< 0 ? MAX(yoff
, oh
-nh
) : MIN(yoff
, oh
-nh
));
69 actions_client_move(data
, TRUE
);
70 client_move_resize(c
, x
+ xoff
, y
+ yoff
, nw
, nh
);
71 actions_client_move(data
, FALSE
);
This page took 0.035228 seconds and 4 git commands to generate.