diff options
| author | Dana Jansens <danakj@orodu.net> | 2007-07-13 12:03:40 -0400 |
|---|---|---|
| committer | Dana Jansens <danakj@orodu.net> | 2007-07-13 12:03:40 -0400 |
| commit | 3e94f9e642a060413a7316f605de7637f91434d5 (patch) | |
| tree | 9d19d097eaad86c0ef489730d3e08a48e0dce810 /openbox/actions/maximize.c | |
| parent | 27aec195acea0d28272c155ebd3f2bdd43c050cf (diff) | |
redo the maximize actions into maximize/unmaximize/togglemaximize with a <direction> argument
Diffstat (limited to 'openbox/actions/maximize.c')
| -rw-r--r-- | openbox/actions/maximize.c | 77 |
1 files changed, 50 insertions, 27 deletions
diff --git a/openbox/actions/maximize.c b/openbox/actions/maximize.c index 443ff7e7..8bb0cc95 100644 --- a/openbox/actions/maximize.c +++ b/openbox/actions/maximize.c @@ -1,21 +1,29 @@ #include "openbox/actions.h" #include "openbox/client.h" +/* These match the values for client_maximize */ +typedef enum { + BOTH = 0, + HORZ = 1, + VERT = 2 +} MaxDirection; + typedef struct { - gboolean toggle; - gboolean on; + MaxDirection dir; } Options; static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node); -static void free_func(gpointer options); -static gboolean run_func(ObActionsData *data, gpointer options); +static gboolean run_func_on(ObActionsData *data, gpointer options); +static gboolean run_func_off(ObActionsData *data, gpointer options); +static gboolean run_func_toggle(ObActionsData *data, gpointer options); void action_maximize_startup() { - actions_register("Maximize", - setup_func, - free_func, - run_func, + actions_register("Maximize", setup_func, g_free, run_func_on, + NULL, NULL); + actions_register("Unmaximize", setup_func, g_free, run_func_off, + NULL, NULL); + actions_register("ToggleMaximize", setup_func, g_free, run_func_toggle, NULL, NULL); } @@ -25,44 +33,59 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node) Options *o; o = g_new0(Options, 1); - o->toggle = TRUE; + o->dir = BOTH; - if ((n = parse_find_node("state", node))) { + if ((n = parse_find_node("direction", node))) { gchar *s = parse_string(doc, n); - if (g_ascii_strcasecmp(s, "toggle")) { - o->toggle = FALSE; - o->on = parse_bool(doc, n); - } + if (!g_ascii_strcasecmp(s, "vertical") || + !g_ascii_strcasecmp(s, "vert")) + o->dir = VERT; + else if (!g_ascii_strcasecmp(s, "horizontal") || + !g_ascii_strcasecmp(s, "horz")) + o->dir = HORZ; g_free(s); } return o; } -static void free_func(gpointer options) +/* Always return FALSE because its not interactive */ +static gboolean run_func_on(ObActionsData *data, gpointer options) { Options *o = options; - - g_free(o); + if (data->client) { + actions_client_move(data, TRUE); + client_maximize(data->client, TRUE, o->dir); + actions_client_move(data, FALSE); + } + return FALSE; } /* Always return FALSE because its not interactive */ -static gboolean run_func(ObActionsData *data, gpointer options) +static gboolean run_func_off(ObActionsData *data, gpointer options) { Options *o = options; - if (data->client) { actions_client_move(data, TRUE); - - if (o->toggle) - client_maximize(data->client, - !data->client->max_horz || !data->client->max_vert, - 0); - else - client_maximize(data->client, o->on, 0); - + client_maximize(data->client, FALSE, o->dir); actions_client_move(data, FALSE); } + return FALSE; +} +/* Always return FALSE because its not interactive */ +static gboolean run_func_toggle(ObActionsData *data, gpointer options) +{ + Options *o = options; + if (data->client) { + gboolean toggle; + actions_client_move(data, TRUE); + toggle = ((o->dir == HORZ && !data->client->max_horz) || + (o->dir == VERT && !data->client->max_vert) || + (o->dir == BOTH && + !(data->client->max_horz && data->client->max_vert))); + client_maximize(data->client, toggle, o->dir); + actions_client_move(data, FALSE); + } return FALSE; } |
