]> Dogcows Code - chaz/openbox/blob - openbox/actions/maximize.c
add a missing #include
[chaz/openbox] / openbox / actions / maximize.c
1 #include "openbox/actions.h"
2 #include "openbox/client.h"
3
4 /* These match the values for client_maximize */
5 typedef enum {
6 BOTH = 0,
7 HORZ = 1,
8 VERT = 2
9 } MaxDirection;
10
11 typedef struct {
12 MaxDirection dir;
13 } Options;
14
15 static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
16 static gboolean run_func_on(ObActionsData *data, gpointer options);
17 static gboolean run_func_off(ObActionsData *data, gpointer options);
18 static gboolean run_func_toggle(ObActionsData *data, gpointer options);
19
20 void action_maximize_startup(void)
21 {
22 actions_register("Maximize", setup_func, g_free, run_func_on,
23 NULL, NULL);
24 actions_register("Unmaximize", setup_func, g_free, run_func_off,
25 NULL, NULL);
26 actions_register("ToggleMaximize", setup_func, g_free, run_func_toggle,
27 NULL, NULL);
28 }
29
30 static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
31 {
32 xmlNodePtr n;
33 Options *o;
34
35 o = g_new0(Options, 1);
36 o->dir = BOTH;
37
38 if ((n = parse_find_node("direction", node))) {
39 gchar *s = parse_string(doc, n);
40 if (!g_ascii_strcasecmp(s, "vertical") ||
41 !g_ascii_strcasecmp(s, "vert"))
42 o->dir = VERT;
43 else if (!g_ascii_strcasecmp(s, "horizontal") ||
44 !g_ascii_strcasecmp(s, "horz"))
45 o->dir = HORZ;
46 g_free(s);
47 }
48
49 return o;
50 }
51
52 /* Always return FALSE because its not interactive */
53 static gboolean run_func_on(ObActionsData *data, gpointer options)
54 {
55 Options *o = options;
56 if (data->client) {
57 actions_client_move(data, TRUE);
58 client_maximize(data->client, TRUE, o->dir);
59 actions_client_move(data, FALSE);
60 }
61 return FALSE;
62 }
63
64 /* Always return FALSE because its not interactive */
65 static gboolean run_func_off(ObActionsData *data, gpointer options)
66 {
67 Options *o = options;
68 if (data->client) {
69 actions_client_move(data, TRUE);
70 client_maximize(data->client, FALSE, o->dir);
71 actions_client_move(data, FALSE);
72 }
73 return FALSE;
74 }
75
76 /* Always return FALSE because its not interactive */
77 static gboolean run_func_toggle(ObActionsData *data, gpointer options)
78 {
79 Options *o = options;
80 if (data->client) {
81 gboolean toggle;
82 actions_client_move(data, TRUE);
83 toggle = ((o->dir == HORZ && !data->client->max_horz) ||
84 (o->dir == VERT && !data->client->max_vert) ||
85 (o->dir == BOTH &&
86 !(data->client->max_horz && data->client->max_vert)));
87 client_maximize(data->client, toggle, o->dir);
88 actions_client_move(data, FALSE);
89 }
90 return FALSE;
91 }
This page took 0.037533 seconds and 4 git commands to generate.