X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=openbox%2Factions%2Fmaximize.c;h=45e8b38ed55801812a61f897c473fbd860c5db08;hb=fdabb69f4f25596df972caa76c85c2aeba26226e;hp=508c2d375d0c4a85651ecb424703ac9f849001f5;hpb=ee6671c3fac371b7d631976953e304e1f761e928;p=chaz%2Fopenbox diff --git a/openbox/actions/maximize.c b/openbox/actions/maximize.c index 508c2d37..45e8b38e 100644 --- a/openbox/actions/maximize.c +++ b/openbox/actions/maximize.c @@ -1,26 +1,91 @@ #include "openbox/actions.h" #include "openbox/client.h" -static gboolean run_func(ObActionsData *data, gpointer options); +/* These match the values for client_maximize */ +typedef enum { + BOTH = 0, + HORZ = 1, + VERT = 2 +} MaxDirection; -void action_maximize_startup() +typedef struct { + MaxDirection dir; +} Options; + +static gpointer setup_func(xmlNodePtr node); +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(void) { - actions_register("Maximize", - NULL, NULL, - 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); } +static gpointer setup_func(xmlNodePtr node) +{ + xmlNodePtr n; + Options *o; + + o = g_new0(Options, 1); + o->dir = BOTH; + + if ((n = obt_parse_find_node(node, "direction"))) { + gchar *s = obt_parse_node_string(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; +} + +/* Always return FALSE because its not interactive */ +static gboolean run_func_on(ObActionsData *data, gpointer options) +{ + Options *o = options; + 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); - client_maximize(data->client, - !(data->client->max_horz || data->client->max_vert), - 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; }