]>
Dogcows Code - chaz/openbox/blob - openbox/actions/growtoedge.c
44e528724d016a16d9ef204aad1f494533769433
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"
13 static gpointer
setup_func(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
);
14 static gpointer
setup_shrink_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_growtoedge_startup()
20 actions_register("GrowToEdge",
26 actions_register("ShrinkToEdge",
33 static gpointer
setup_func(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
)
38 o
= g_new0(Options
, 1);
39 o
->dir
= OB_DIRECTION_NORTH
;
42 if ((n
= parse_find_node("direction", node
))) {
43 gchar
*s
= parse_string(doc
, n
);
44 if (!g_ascii_strcasecmp(s
, "north") ||
45 !g_ascii_strcasecmp(s
, "up"))
46 o
->dir
= OB_DIRECTION_NORTH
;
47 else if (!g_ascii_strcasecmp(s
, "south") ||
48 !g_ascii_strcasecmp(s
, "down"))
49 o
->dir
= OB_DIRECTION_SOUTH
;
50 else if (!g_ascii_strcasecmp(s
, "west") ||
51 !g_ascii_strcasecmp(s
, "left"))
52 o
->dir
= OB_DIRECTION_WEST
;
53 else if (!g_ascii_strcasecmp(s
, "east") ||
54 !g_ascii_strcasecmp(s
, "right"))
55 o
->dir
= OB_DIRECTION_EAST
;
62 static gpointer
setup_shrink_func(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
)
66 o
= setup_func(i
, doc
, node
);
72 static void free_func(gpointer options
)
79 static gboolean
do_grow(ObActionsData
*data
, gint x
, gint y
, gint w
, gint h
)
81 gint realw
, realh
, lw
, lh
;
85 client_try_configure(data
->client
, &x
, &y
, &realw
, &realh
,
87 /* if it's going to be resized smaller than it intended, don't
88 move the window over */
89 if (x
!= data
->client
->area
.x
) x
+= w
- realw
;
90 if (y
!= data
->client
->area
.y
) y
+= h
- realh
;
92 if (x
!= data
->client
->area
.x
|| y
!= data
->client
->area
.y
||
93 realw
!= data
->client
->area
.width
||
94 realh
!= data
->client
->area
.height
)
96 actions_client_move(data
, TRUE
);
97 client_move_resize(data
->client
, x
, y
, realw
, realh
);
98 actions_client_move(data
, FALSE
);
104 /* Always return FALSE because its not interactive */
105 static gboolean
run_func(ObActionsData
*data
, gpointer options
)
107 Options
*o
= options
;
113 /* don't allow vertical resize if shaded */
114 ((o
->dir
== OB_DIRECTION_NORTH
|| o
->dir
== OB_DIRECTION_SOUTH
) &&
115 data
->client
->shaded
))
122 client_find_resize_directional(data
->client
, o
->dir
, TRUE
,
124 if (do_grow(data
, x
, y
, w
, h
))
128 /* we couldn't grow, so try shrink! */
129 opp
= (o
->dir
== OB_DIRECTION_NORTH
? OB_DIRECTION_SOUTH
:
130 (o
->dir
== OB_DIRECTION_SOUTH
? OB_DIRECTION_NORTH
:
131 (o
->dir
== OB_DIRECTION_EAST
? OB_DIRECTION_WEST
:
132 OB_DIRECTION_EAST
)));
133 client_find_resize_directional(data
->client
, opp
, FALSE
,
136 case OB_DIRECTION_NORTH
:
137 half
= data
->client
->area
.y
+ data
->client
->area
.height
/ 2;
143 case OB_DIRECTION_SOUTH
:
144 half
= data
->client
->area
.height
/ 2;
148 case OB_DIRECTION_WEST
:
149 half
= data
->client
->area
.x
+ data
->client
->area
.width
/ 2;
155 case OB_DIRECTION_EAST
:
156 half
= data
->client
->area
.width
/ 2;
160 default: g_assert_not_reached();
162 if (do_grow(data
, x
, y
, w
, h
))
This page took 0.043668 seconds and 4 git commands to generate.