From: Dana Jansens Date: Fri, 22 Jun 2007 15:39:20 +0000 (+0000) Subject: add max horz/vert actions. add toggle/on/off ability to all the maximize actions. X-Git-Url: https://git.dogcows.com/gitweb?a=commitdiff_plain;h=d468f85300f2ec00daa08754f8e782c75a1f8590;p=chaz%2Fopenbox add max horz/vert actions. add toggle/on/off ability to all the maximize actions. add shade action. --- diff --git a/Makefile.am b/Makefile.am index 82cdfed3..a63af6c0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -167,6 +167,8 @@ openbox_openbox_SOURCES = \ openbox/actions/iconify.c \ openbox/actions/lower.c \ openbox/actions/maximize.c \ + openbox/actions/maximizehorizontal.c \ + openbox/actions/maximizevertical.c \ openbox/actions/move.c \ openbox/actions/moverelative.c \ openbox/actions/moveto.c \ @@ -174,6 +176,7 @@ openbox_openbox_SOURCES = \ openbox/actions/raiselower.c \ openbox/actions/reconfigure.c \ openbox/actions/restart.c \ + openbox/actions/shade.c \ openbox/actions/showdesktop.c \ openbox/actions/showmenu.c \ openbox/actions/unfocus.c \ diff --git a/openbox/action.c b/openbox/action.c index dca4ede4..1bc85db2 100644 --- a/openbox/action.c +++ b/openbox/action.c @@ -469,31 +469,11 @@ ActionString actionstrings[] = action_unshaderaise, setup_client_action }, - { - "shade", - action_shade, - setup_client_action - }, - { - "unshade", - action_unshade, - setup_client_action - }, - { - "toggleshade", - action_toggle_shade, - setup_client_action - }, { "toggleomnipresent", action_toggle_omnipresent, setup_client_action }, - { - "moverelativehorz", - action_move_relative_horz, - setup_client_action - }, { "resizerelativevert", action_resize_relative_vert, @@ -950,27 +930,6 @@ void action_kill(union ActionData *data) client_kill(data->client.any.c); } -void action_shade(union ActionData *data) -{ - client_action_start(data); - client_shade(data->client.any.c, TRUE); - client_action_end(data, config_focus_under_mouse); -} - -void action_unshade(union ActionData *data) -{ - client_action_start(data); - client_shade(data->client.any.c, FALSE); - client_action_end(data, config_focus_under_mouse); -} - -void action_toggle_shade(union ActionData *data) -{ - client_action_start(data); - client_shade(data->client.any.c, !data->client.any.c->shaded); - client_action_end(data, config_focus_under_mouse); -} - void action_toggle_omnipresent(union ActionData *data) { client_set_desktop(data->client.any.c, @@ -999,15 +958,6 @@ void action_resize_relative_vert(union ActionData *data) } } -void action_move_relative(union ActionData *data) -{ - ObClient *c = data->relative.any.c; - client_action_start(data); - client_move(c, c->area.x + data->relative.deltax, c->area.y + - data->relative.deltay); - client_action_end(data, FALSE); -} - void action_resize_relative(union ActionData *data) { ObClient *c = data->relative.any.c; diff --git a/openbox/actions/all.c b/openbox/actions/all.c index cbd9f137..64587f46 100644 --- a/openbox/actions/all.c +++ b/openbox/actions/all.c @@ -21,6 +21,9 @@ void action_all_startup() action_iconify_startup(); action_fullscreen_startup(); action_maximize_startup(); + action_maximizehorizontal_startup(); + action_maximizevertical_startup(); action_moveto_startup(); action_moverelative_startup(); + action_shade_startup(); } diff --git a/openbox/actions/all.h b/openbox/actions/all.h index f026106e..bc25461f 100644 --- a/openbox/actions/all.h +++ b/openbox/actions/all.h @@ -22,7 +22,10 @@ void action_unfocus_startup(); void action_iconify_startup(); void action_fullscreen_startup(); void action_maximize_startup(); +void action_maximizehorizontal_startup(); +void action_maximizevertical_startup(); void action_moveto_startup(); void action_moverelative_startup(); +void action_shade_startup(); #endif diff --git a/openbox/actions/maximize.c b/openbox/actions/maximize.c index ebfb1e5c..cc2d44e2 100644 --- a/openbox/actions/maximize.c +++ b/openbox/actions/maximize.c @@ -2,8 +2,8 @@ #include "openbox/client.h" typedef struct { - gboolean vertical; - gboolean horizontal; + gboolean toggle; + gboolean on; } Options; static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node); @@ -25,13 +25,17 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node) Options *o; o = g_new0(Options, 1); - o->vertical = TRUE; - o->horizontal = TRUE; + o->toggle = TRUE; + + if ((n = parse_find_node("maximize", node))) { + gchar *s = parse_string(doc, n); + if (g_ascii_strcasecmp(s, "toggle")) { + o->toggle = FALSE; + o->on = parse_bool(doc, n); + } + g_free(s); + } - 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; } @@ -50,14 +54,12 @@ static gboolean run_func(ObActionsData *data, gpointer options) if (data->client) { actions_client_move(data, TRUE); - 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) + if (o->toggle) client_maximize(data->client, !data->client->max_horz || !data->client->max_vert, 0); + else + client_maximize(data->client, o->on, 0); actions_client_move(data, FALSE); } diff --git a/openbox/actions/maximizehorizontal.c b/openbox/actions/maximizehorizontal.c new file mode 100644 index 00000000..aaaaa51a --- /dev/null +++ b/openbox/actions/maximizehorizontal.c @@ -0,0 +1,66 @@ +#include "openbox/actions.h" +#include "openbox/client.h" + +typedef struct { + gboolean toggle; + gboolean on; +} 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_maximizehorizontal_startup() +{ + actions_register("MaximizeHorizontal", + 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->toggle = TRUE; + + if ((n = parse_find_node("maximize", node))) { + gchar *s = parse_string(doc, n); + if (g_ascii_strcasecmp(s, "toggle")) { + o->toggle = FALSE; + o->on = parse_bool(doc, n); + } + g_free(s); + } + + 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); + + if (o->toggle) + client_maximize(data->client, !data->client->max_horz, 1); + else + client_maximize(data->client, o->on, 1); + + actions_client_move(data, FALSE); + } + + return FALSE; +} diff --git a/openbox/actions/maximizevertical.c b/openbox/actions/maximizevertical.c new file mode 100644 index 00000000..73e1b757 --- /dev/null +++ b/openbox/actions/maximizevertical.c @@ -0,0 +1,66 @@ +#include "openbox/actions.h" +#include "openbox/client.h" + +typedef struct { + gboolean toggle; + gboolean on; +} 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_maximizevertical_startup() +{ + actions_register("MaximizeVertical", + 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->toggle = TRUE; + + if ((n = parse_find_node("maximize", node))) { + gchar *s = parse_string(doc, n); + if (g_ascii_strcasecmp(s, "toggle")) { + o->toggle = FALSE; + o->on = parse_bool(doc, n); + } + g_free(s); + } + + 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); + + if (o->toggle) + client_maximize(data->client, !data->client->max_vert, 2); + else + client_maximize(data->client, o->on, 2); + + actions_client_move(data, FALSE); + } + + return FALSE; +} diff --git a/openbox/actions/shade.c b/openbox/actions/shade.c new file mode 100644 index 00000000..f5c111b9 --- /dev/null +++ b/openbox/actions/shade.c @@ -0,0 +1,64 @@ +#include "openbox/actions.h" +#include "openbox/client.h" + +typedef struct { + gboolean toggle; + gboolean on; +} 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_shade_startup() +{ + actions_register("Shade", + 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->toggle = TRUE; + + if ((n = parse_find_node("shade", node))) { + gchar *s = parse_string(doc, n); + if (g_ascii_strcasecmp(s, "toggle")) { + o->toggle = FALSE; + o->on = parse_bool(doc, n); + } + g_free(s); + } + + 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); + if (o->toggle) + client_shade(data->client, !data->client->shaded); + else + client_shade(data->client, o->on); + actions_client_move(data, FALSE); + } + + return FALSE; +}