split decorations into decorate/undecorate/toggledecorations

This commit is contained in:
Dana Jansens 2007-07-13 11:29:00 -04:00
parent 6c538915c8
commit ddea4dcedd

View file

@ -1,62 +1,47 @@
#include "openbox/actions.h" #include "openbox/actions.h"
#include "openbox/client.h" #include "openbox/client.h"
typedef struct { static gboolean run_func_on(ObActionsData *data, gpointer options);
gboolean toggle; static gboolean run_func_off(ObActionsData *data, gpointer options);
gboolean on; static gboolean run_func_toggle(ObActionsData *data, gpointer options);
} 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_decorations_startup() void action_decorations_startup()
{ {
actions_register("Decorations", actions_register("Decorate", NULL, NULL, run_func_on, NULL, NULL);
setup_func, actions_register("Undecorate", NULL, NULL, run_func_off, NULL, NULL);
free_func, actions_register("ToggleDecorations", NULL, NULL, run_func_toggle,
run_func,
NULL, NULL); NULL, NULL);
} }
static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node) /* Always return FALSE because its not interactive */
static gboolean run_func_on(ObActionsData *data, gpointer options)
{ {
xmlNodePtr n; if (data->client) {
Options *o; actions_client_move(data, TRUE);
client_set_undecorated(data->client, TRUE);
o = g_new0(Options, 1); actions_client_move(data, FALSE);
o->toggle = TRUE;
if ((n = parse_find_node("state", 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 FALSE;
return o;
}
static void free_func(gpointer options)
{
Options *o = options;
g_free(o);
} }
/* Always return FALSE because its not interactive */ /* 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) { if (data->client) {
actions_client_move(data, TRUE); actions_client_move(data, TRUE);
if (o->toggle || o->on != !data->client->undecorated) client_set_undecorated(data->client, FALSE);
client_set_undecorated(data->client, !data->client->undecorated); actions_client_move(data, FALSE);
}
return FALSE;
}
/* Always return FALSE because its not interactive */
static gboolean run_func_toggle(ObActionsData *data, gpointer options)
{
if (data->client) {
actions_client_move(data, TRUE);
client_set_undecorated(data->client, !data->client->undecorated);
actions_client_move(data, FALSE); actions_client_move(data, FALSE);
} }
return FALSE; return FALSE;
} }