1 #include "openbox/action.h"
2 #include "openbox/action_list_run.h"
3 #include "openbox/action_value.h"
4 #include "openbox/client.h"
6 /* These match the values for client_maximize */
17 static gpointer setup_func(GHashTable *config);
18 static void free_func(gpointer o);
19 static gboolean run_func_on(const ObActionListRun *data, gpointer options);
20 static gboolean run_func_off(const ObActionListRun *data, gpointer options);
21 static gboolean run_func_toggle(const ObActionListRun *data, gpointer options);
23 void action_maximize_startup(void)
25 action_register("Maximize", OB_ACTION_DEFAULT_FILTER_SINGLE,
26 setup_func, free_func, run_func_on);
27 action_register("Unmaximize", OB_ACTION_DEFAULT_FILTER_SINGLE,
28 setup_func, free_func, run_func_off);
29 action_register("ToggleMaximize", OB_ACTION_DEFAULT_FILTER_SINGLE,
30 setup_func, free_func, run_func_toggle);
33 static gpointer setup_func(GHashTable *config)
38 o = g_slice_new0(Options);
41 v = g_hash_table_lookup(config, "dir");
42 if (v && action_value_is_string(v)) {
43 const gchar *s = action_value_string(v);
44 if (!g_ascii_strcasecmp(s, "vertical") ||
45 !g_ascii_strcasecmp(s, "vert"))
47 else if (!g_ascii_strcasecmp(s, "horizontal") ||
48 !g_ascii_strcasecmp(s, "horz"))
55 static void free_func(gpointer o)
57 g_slice_free(Options, o);
60 /* Always return FALSE because its not interactive */
61 static gboolean run_func_on(const ObActionListRun *data, gpointer options)
65 action_client_move(data, TRUE);
66 client_maximize(data->client, TRUE, o->dir);
67 action_client_move(data, FALSE);
72 /* Always return FALSE because its not interactive */
73 static gboolean run_func_off(const ObActionListRun *data, gpointer options)
77 action_client_move(data, TRUE);
78 client_maximize(data->client, FALSE, o->dir);
79 action_client_move(data, FALSE);
84 /* Always return FALSE because its not interactive */
85 static gboolean run_func_toggle(const ObActionListRun *data, gpointer options)
90 action_client_move(data, TRUE);
91 toggle = ((o->dir == HORZ && !data->client->max_horz) ||
92 (o->dir == VERT && !data->client->max_vert) ||
94 !(data->client->max_horz && data->client->max_vert)));
95 client_maximize(data->client, toggle, o->dir);
96 action_client_move(data, FALSE);