]> Dogcows Code - chaz/openbox/blob - openbox/actions/maximize.c
add horiz/vertical options to the maximize action
[chaz/openbox] / openbox / actions / maximize.c
1 #include "openbox/actions.h"
2 #include "openbox/client.h"
3
4 typedef struct {
5 gboolean vertical;
6 gboolean horizontal;
7 } Options;
8
9 static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
10 static void free_func(gpointer options);
11 static gboolean run_func(ObActionsData *data, gpointer options);
12
13 void action_maximize_startup()
14 {
15 actions_register("Maximize",
16 setup_func,
17 free_func,
18 run_func,
19 NULL, NULL);
20 }
21
22 static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
23 {
24 xmlNodePtr n;
25 Options *o;
26
27 o = g_new0(Options, 1);
28 o->vertical = TRUE;
29 o->horizontal = TRUE;
30
31 if ((n = parse_find_node("vertical", node)))
32 o->vertical = parse_bool(doc, n);
33 if ((n = parse_find_node("horizontal", node)))
34 o->horizontal = parse_bool(doc, n);
35 return o;
36 }
37
38 static void free_func(gpointer options)
39 {
40 Options *o = options;
41
42 g_free(o);
43 }
44
45 /* Always return FALSE because its not interactive */
46 static gboolean run_func(ObActionsData *data, gpointer options)
47 {
48 Options *o = options;
49
50 if (data->client) {
51 actions_client_move(data, TRUE);
52
53 if (o->horizontal && !o->vertical)
54 client_maximize(data->client, !data->client->max_horz, 1);
55 else if (!o->horizontal && o->vertical)
56 client_maximize(data->client, !data->client->max_vert, 2);
57 else if (o->horizontal && o->vertical)
58 client_maximize(data->client,
59 !data->client->max_horz || !data->client->max_vert,
60 0);
61
62 actions_client_move(data, FALSE);
63 }
64
65 return FALSE;
66 }
This page took 0.037742 seconds and 5 git commands to generate.