]>
Dogcows Code - chaz/openbox/blob - growtoedge.c
501c64dee9ac74a1f669b3f7ce48b7e9023a3a06
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()
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 /* Always return FALSE because its not interactive */
61 static gboolean
run_func(ObActionsData
*data
, gpointer options
)
66 gint x
, y
, w
, h
, realw
, realh
, lw
, lh
;
68 /* don't allow vertical resize if shaded */
69 if (o
->dir
!= OB_DIRECTION_NORTH
|| o
->dir
!= OB_DIRECTION_SOUTH
||
70 !data
->client
->shaded
)
72 client_find_resize_directional(data
->client
, o
->dir
, TRUE
,
76 client_try_configure(data
->client
, &x
, &y
, &realw
, &realh
,
78 /* if it's going to be resized smaller than it intended, don't
79 move the window over */
80 if (x
!= data
->client
->area
.x
) x
+= w
- realw
;
81 if (y
!= data
->client
->area
.y
) y
+= h
- realh
;
83 if (x
!= data
->client
->area
.x
|| y
!= data
->client
->area
.y
||
84 w
!= data
->client
->area
.width
||
85 h
!= data
->client
->area
.height
)
87 actions_client_move(data
, TRUE
);
88 client_move_resize(data
->client
, x
, y
, realw
, realh
);
89 actions_client_move(data
, FALSE
);
This page took 0.041178 seconds and 3 git commands to generate.