]>
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(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
);
15 static void free_func(gpointer options
);
16 static gboolean
run_func(ObActionsData
*data
, gpointer options
);
18 void action_resizerelative_startup(void)
20 actions_register("ResizeRelative",
27 static gpointer
setup_func(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
)
32 o
= g_new0(Options
, 1);
34 if ((n
= parse_find_node("left", node
)))
35 o
->left
= parse_int(doc
, n
);
36 if ((n
= parse_find_node("right", node
)))
37 o
->right
= parse_int(doc
, n
);
38 if ((n
= parse_find_node("top", node
)) ||
39 (n
= parse_find_node("up", node
)))
40 o
->top
= parse_int(doc
, n
);
41 if ((n
= parse_find_node("bottom", node
)) ||
42 (n
= parse_find_node("down", node
)))
43 o
->bottom
= parse_int(doc
, n
);
48 static void free_func(gpointer options
)
55 /* Always return FALSE because its not interactive */
56 static gboolean
run_func(ObActionsData
*data
, gpointer options
)
61 ObClient
*c
= data
->client
;
62 gint x
, y
, ow
, xoff
, nw
, oh
, yoff
, nh
, lw
, lh
;
67 xoff
= -o
->left
* c
->size_inc
.width
;
68 nw
= ow
+ o
->right
* c
->size_inc
.width
69 + o
->left
* c
->size_inc
.width
;
71 yoff
= -o
->top
* c
->size_inc
.height
;
72 nh
= oh
+ o
->bottom
* c
->size_inc
.height
73 + o
->top
* c
->size_inc
.height
;
75 client_try_configure(c
, &x
, &y
, &nw
, &nh
, &lw
, &lh
, TRUE
);
76 xoff
= xoff
== 0 ? 0 :
77 (xoff
< 0 ? MAX(xoff
, ow
-nw
) : MIN(xoff
, ow
-nw
));
78 yoff
= yoff
== 0 ? 0 :
79 (yoff
< 0 ? MAX(yoff
, oh
-nh
) : MIN(yoff
, oh
-nh
));
81 actions_client_move(data
, TRUE
);
82 client_move_resize(c
, x
+ xoff
, y
+ yoff
, nw
, nh
);
83 actions_client_move(data
, FALSE
);
This page took 0.036811 seconds and 4 git commands to generate.