]>
Dogcows Code - chaz/openbox/blob - openbox/actions/growtoedge.c
1 #include "openbox/actions.h"
2 #include "openbox/misc.h"
3 #include "openbox/client.h"
4 #include "openbox/frame.h"
5 #include "openbox/screen.h"
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
);
16 void action_growtoedge_startup(void)
18 actions_register("GrowToEdge",
25 static gpointer
setup_func(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
)
30 o
= g_new0(Options
, 1);
31 o
->dir
= OB_DIRECTION_NORTH
;
33 if ((n
= parse_find_node("direction", node
))) {
34 gchar
*s
= parse_string(doc
, n
);
35 if (!g_ascii_strcasecmp(s
, "north") ||
36 !g_ascii_strcasecmp(s
, "up"))
37 o
->dir
= OB_DIRECTION_NORTH
;
38 else if (!g_ascii_strcasecmp(s
, "south") ||
39 !g_ascii_strcasecmp(s
, "down"))
40 o
->dir
= OB_DIRECTION_SOUTH
;
41 else if (!g_ascii_strcasecmp(s
, "west") ||
42 !g_ascii_strcasecmp(s
, "left"))
43 o
->dir
= OB_DIRECTION_WEST
;
44 else if (!g_ascii_strcasecmp(s
, "east") ||
45 !g_ascii_strcasecmp(s
, "right"))
46 o
->dir
= OB_DIRECTION_EAST
;
53 static void free_func(gpointer options
)
60 static gboolean
do_grow(ObActionsData
*data
, gint x
, gint y
, gint w
, gint h
)
62 gint realw
, realh
, lw
, lh
;
66 client_try_configure(data
->client
, &x
, &y
, &realw
, &realh
,
68 /* if it's going to be resized smaller than it intended, don't
69 move the window over */
70 if (x
!= data
->client
->area
.x
) x
+= w
- realw
;
71 if (y
!= data
->client
->area
.y
) y
+= h
- realh
;
73 if (x
!= data
->client
->area
.x
|| y
!= data
->client
->area
.y
||
74 realw
!= data
->client
->area
.width
||
75 realh
!= data
->client
->area
.height
)
77 actions_client_move(data
, TRUE
);
78 client_move_resize(data
->client
, x
, y
, realw
, realh
);
79 actions_client_move(data
, FALSE
);
85 /* Always return FALSE because its not interactive */
86 static gboolean
run_func(ObActionsData
*data
, gpointer options
)
94 /* don't allow vertical resize if shaded */
95 ((o
->dir
== OB_DIRECTION_NORTH
|| o
->dir
== OB_DIRECTION_SOUTH
) &&
96 data
->client
->shaded
))
102 client_find_resize_directional(data
->client
, o
->dir
, TRUE
,
104 if (do_grow(data
, x
, y
, w
, h
))
107 /* we couldn't grow, so try shrink! */
108 opp
= (o
->dir
== OB_DIRECTION_NORTH
? OB_DIRECTION_SOUTH
:
109 (o
->dir
== OB_DIRECTION_SOUTH
? OB_DIRECTION_NORTH
:
110 (o
->dir
== OB_DIRECTION_EAST
? OB_DIRECTION_WEST
:
111 OB_DIRECTION_EAST
)));
112 client_find_resize_directional(data
->client
, opp
, FALSE
,
115 case OB_DIRECTION_NORTH
:
116 half
= data
->client
->area
.y
+ data
->client
->area
.height
/ 2;
122 case OB_DIRECTION_SOUTH
:
123 half
= data
->client
->area
.height
/ 2;
127 case OB_DIRECTION_WEST
:
128 half
= data
->client
->area
.x
+ data
->client
->area
.width
/ 2;
134 case OB_DIRECTION_EAST
:
135 half
= data
->client
->area
.width
/ 2;
139 default: g_assert_not_reached();
141 if (do_grow(data
, x
, y
, w
, h
))
This page took 0.042837 seconds and 4 git commands to generate.