From: Dana Jansens Date: Fri, 22 Jun 2007 14:47:10 +0000 (+0000) Subject: add horiz/vertical options to the maximize action X-Git-Url: https://git.dogcows.com/gitweb?a=commitdiff_plain;h=06ed8ab6c03337710acba8d6a70781456e979384;p=chaz%2Fopenbox add horiz/vertical options to the maximize action --- diff --git a/openbox/action.c b/openbox/action.c index 7dd9da48..5b1fcd6c 100644 --- a/openbox/action.c +++ b/openbox/action.c @@ -1127,42 +1127,6 @@ void action_resize_relative(union ActionData *data) client_action_end(data, FALSE); } -void action_maximize_horz(union ActionData *data) -{ - client_action_start(data); - client_maximize(data->client.any.c, TRUE, 1); - client_action_end(data, config_focus_under_mouse); -} - -void action_unmaximize_horz(union ActionData *data) -{ - client_action_start(data); - client_maximize(data->client.any.c, FALSE, 1); - client_action_end(data, config_focus_under_mouse); -} - -void action_toggle_maximize_horz(union ActionData *data) -{ - client_action_start(data); - client_maximize(data->client.any.c, - !data->client.any.c->max_horz, 1); - client_action_end(data, config_focus_under_mouse); -} - -void action_maximize_vert(union ActionData *data) -{ - client_action_start(data); - client_maximize(data->client.any.c, TRUE, 2); - client_action_end(data, config_focus_under_mouse); -} - -void action_unmaximize_vert(union ActionData *data) -{ - client_action_start(data); - client_maximize(data->client.any.c, FALSE, 2); - client_action_end(data, config_focus_under_mouse); -} - void action_toggle_maximize_vert(union ActionData *data) { client_action_start(data); diff --git a/openbox/actions/maximize.c b/openbox/actions/maximize.c index 508c2d37..ebfb1e5c 100644 --- a/openbox/actions/maximize.c +++ b/openbox/actions/maximize.c @@ -1,24 +1,64 @@ #include "openbox/actions.h" #include "openbox/client.h" +typedef struct { + gboolean vertical; + gboolean horizontal; +} 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); void action_maximize_startup() { actions_register("Maximize", - NULL, NULL, + setup_func, + free_func, run_func, NULL, NULL); } +static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node) +{ + xmlNodePtr n; + Options *o; + + o = g_new0(Options, 1); + o->vertical = TRUE; + o->horizontal = TRUE; + + if ((n = parse_find_node("vertical", node))) + o->vertical = parse_bool(doc, n); + if ((n = parse_find_node("horizontal", node))) + o->horizontal = parse_bool(doc, n); + return o; +} + +static void free_func(gpointer options) +{ + Options *o = options; + + g_free(o); +} + /* Always return FALSE because its not interactive */ static gboolean run_func(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); + + if (o->horizontal && !o->vertical) + client_maximize(data->client, !data->client->max_horz, 1); + else if (!o->horizontal && o->vertical) + client_maximize(data->client, !data->client->max_vert, 2); + else if (o->horizontal && o->vertical) + client_maximize(data->client, + !data->client->max_horz || !data->client->max_vert, + 0); + actions_client_move(data, FALSE); }