add horiz/vertical options to the maximize action
This commit is contained in:
parent
ee6671c3fa
commit
06ed8ab6c0
2 changed files with 44 additions and 40 deletions
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue