else {
ObActionParser *p = action_parser_new();
o->actions = action_parser_read_string(p,
- "focus\n"
- "raise\n"
- "unshade\n");
+ "focus\n"
+ "raise\n"
+ "shade set:off\n");
action_parser_unref(p);
}
#include "openbox/action.h"
#include "openbox/action_list_run.h"
+#include "openbox/config_value.h"
#include "openbox/client.h"
#include "openbox/client_set.h"
-static gboolean run_func_on(const ObClientSet *set,
- const ObActionListRun *data, gpointer options);
-static gboolean run_func_off(const ObClientSet *set,
- const ObActionListRun *data, gpointer options);
-static gboolean run_func_toggle(const ObClientSet *set,
- const ObActionListRun *data, gpointer options);
+typedef struct {
+ gboolean toggle;
+ gboolean set;
+} Options;
+
+static gpointer setup_func(GHashTable *config);
+static void free_func(gpointer o);
+static gboolean run_func(const ObClientSet *set,
+ const ObActionListRun *data, gpointer options);
void action_decorations_startup(void)
{
action_register("Decorate", OB_ACTION_DEFAULT_FILTER_SINGLE,
- NULL, NULL, run_func_on);
- action_register("Undecorate", OB_ACTION_DEFAULT_FILTER_SINGLE,
- NULL, NULL, run_func_off);
- action_register("ToggleDecorations", OB_ACTION_DEFAULT_FILTER_SINGLE,
- NULL, NULL, run_func_toggle);
+ setup_func, free_func, run_func);
}
-static gboolean each_on(ObClient *c, const ObActionListRun *data, gpointer o)
+static gpointer setup_func(GHashTable *config)
{
- client_set_undecorated(data->target, FALSE);
- return TRUE;
-}
+ ObConfigValue *v;
+ Options *o;
-/* Always return FALSE because its not interactive */
-static gboolean run_func_on(const ObClientSet *set,
- const ObActionListRun *data, gpointer options)
-{
- if (!client_set_is_empty(set)) {
- action_client_move(data, TRUE);
- client_set_run(set, data, each_on, options);
- action_client_move(data, FALSE);
+ o = g_slice_new0(Options);
+ o->toggle = TRUE;
+ o->set = FALSE;
+
+ v = g_hash_table_lookup(config, "set");
+ if (v && config_value_is_string(v)) {
+ const gchar *s = config_value_string(v);
+ if (!g_ascii_strcasecmp(s, "on"))
+ o->toggle = FALSE;
+ else if (!g_ascii_strcasecmp(s, "off")) {
+ o->toggle = FALSE;
+ o->set = TRUE;
+ }
}
- return FALSE;
-}
-static gboolean each_off(ObClient *c, const ObActionListRun *data, gpointer o)
-{
- client_set_undecorated(data->target, TRUE);
- return TRUE;
+ return o;
}
-/* Always return FALSE because its not interactive */
-static gboolean run_func_off(const ObClientSet *set,
- const ObActionListRun *data, gpointer options)
+static void free_func(gpointer o)
{
- if (!client_set_is_empty(set)) {
- action_client_move(data, TRUE);
- client_set_run(set, data, each_off, options);
- action_client_move(data, FALSE);
- }
- return FALSE;
+ g_slice_free(Options, o);
}
-static gboolean each_flip(ObClient *c, const ObActionListRun *data, gpointer o)
+static gboolean each_run(ObClient *c, const ObActionListRun *data,
+ gpointer options)
{
- client_set_undecorated(data->target, !c->undecorated);
+ Options *o = options;
+ client_set_undecorated(data->target, o->toggle ? !c->undecorated : o->set);
return TRUE;
}
/* Always return FALSE because its not interactive */
-static gboolean run_func_toggle(const ObClientSet *set,
- const ObActionListRun *data, gpointer options)
+static gboolean run_func(const ObClientSet *set,
+ const ObActionListRun *data, gpointer options)
{
if (!client_set_is_empty(set)) {
action_client_move(data, TRUE);
- client_set_run(set, data, each_flip, options);
+ client_set_run(set, data, each_run, options);
action_client_move(data, FALSE);
}
return FALSE;
o->actions = action_parser_read_string(p,
"focus\n"
"raise\n"
- "unshade\n");
+ "shade set:off\n");
action_parser_unref(p);
}
#include "openbox/action.h"
#include "openbox/action_list_run.h"
+#include "openbox/config_value.h"
#include "openbox/client.h"
#include "openbox/client_set.h"
-static gboolean run_func_on(const ObClientSet *set,
- const ObActionListRun *data, gpointer options);
-static gboolean run_func_off(const ObClientSet *set,
- const ObActionListRun *data, gpointer options);
-static gboolean run_func_toggle(const ObClientSet *set,
- const ObActionListRun *data, gpointer options);
+typedef struct {
+ gboolean toggle;
+ gboolean set;
+} Options;
+
+static gpointer setup_func(GHashTable *config);
+static void free_func(gpointer o);
+static gboolean run_func(const ObClientSet *set,
+ const ObActionListRun *data, gpointer options);
void action_fullscreen_startup(void)
{
action_register("Fullscreen", OB_ACTION_DEFAULT_FILTER_SINGLE,
- NULL, NULL, run_func_on);
- action_register("Unfullscreen", OB_ACTION_DEFAULT_FILTER_SINGLE,
- NULL, NULL, run_func_off);
- action_register("ToggleFullscreen", OB_ACTION_DEFAULT_FILTER_SINGLE,
- NULL, NULL, run_func_toggle);
+ setup_func, free_func, run_func);
}
-static gboolean each_on(ObClient *c, const ObActionListRun *data,
- gpointer options)
+static gpointer setup_func(GHashTable *config)
{
- client_fullscreen(c, TRUE);
- return TRUE;
-}
+ ObConfigValue *v;
+ Options *o;
-/* Always return FALSE because its not interactive */
-static gboolean run_func_on(const ObClientSet *set,
- const ObActionListRun *data, gpointer options)
-{
- action_client_move(data, TRUE);
- client_set_run(set, data, each_on, options);
- action_client_move(data, FALSE);
- return FALSE;
-}
+ o = g_slice_new0(Options);
+ o->toggle = TRUE;
+ o->set = TRUE;
-static gboolean each_off(ObClient *c, const ObActionListRun *data,
- gpointer options)
-{
- client_fullscreen(c, FALSE);
- return TRUE;
+ v = g_hash_table_lookup(config, "set");
+ if (v && config_value_is_string(v)) {
+ const gchar *s = config_value_string(v);
+ if (!g_ascii_strcasecmp(s, "on"))
+ o->toggle = FALSE;
+ else if (!g_ascii_strcasecmp(s, "off")) {
+ o->toggle = FALSE;
+ o->set = FALSE;
+ }
+ }
+ return o;
}
-/* Always return FALSE because its not interactive */
-static gboolean run_func_off(const ObClientSet *set,
- const ObActionListRun *data, gpointer options)
+static void free_func(gpointer o)
{
- action_client_move(data, TRUE);
- client_set_run(set, data, each_off, options);
- action_client_move(data, FALSE);
- return FALSE;
+ g_slice_free(Options, o);
}
-static gboolean each_toggle(ObClient *c, const ObActionListRun *data,
+static gboolean each_run(ObClient *c, const ObActionListRun *data,
gpointer options)
{
- client_fullscreen(c, !c->fullscreen);
+ Options *o = options;
+ client_fullscreen(c, o->toggle ? !c->fullscreen : o->set);
return TRUE;
}
/* Always return FALSE because its not interactive */
-static gboolean run_func_toggle(const ObClientSet *set,
- const ObActionListRun *data, gpointer options)
+static gboolean run_func(const ObClientSet *set,
+ const ObActionListRun *data, gpointer options)
{
- if (!client_set_is_empty(set)) {
- action_client_move(data, TRUE);
- client_set_run(set, data, each_toggle, options);
- action_client_move(data, FALSE);
- }
+ action_client_move(data, TRUE);
+ client_set_run(set, data, each_run, options);
+ action_client_move(data, FALSE);
return FALSE;
}
typedef struct {
MaxDirection dir;
+ gboolean toggle;
+ gboolean set;
} Options;
static gpointer setup_func(GHashTable *config);
static void free_func(gpointer o);
-static gboolean run_func_on(const ObClientSet *set,
- const ObActionListRun *data, gpointer options);
-static gboolean run_func_off(const ObClientSet *set,
- const ObActionListRun *data, gpointer options);
-static gboolean run_func_toggle(const ObClientSet *set,
- const ObActionListRun *data, gpointer options);
+static gboolean run_func(const ObClientSet *set,
+ const ObActionListRun *data, gpointer options);
void action_maximize_startup(void)
{
action_register("Maximize", OB_ACTION_DEFAULT_FILTER_SINGLE,
- setup_func, free_func, run_func_on);
- action_register("Unmaximize", OB_ACTION_DEFAULT_FILTER_SINGLE,
- setup_func, free_func, run_func_off);
- action_register("ToggleMaximize", OB_ACTION_DEFAULT_FILTER_SINGLE,
- setup_func, free_func, run_func_toggle);
+ setup_func, free_func, run_func);
}
static gpointer setup_func(GHashTable *config)
o = g_slice_new0(Options);
o->dir = BOTH;
+ o->toggle = TRUE;
+ o->set = TRUE;
v = g_hash_table_lookup(config, "dir");
if (v && config_value_is_string(v)) {
!g_ascii_strcasecmp(s, "horz"))
o->dir = HORZ;
}
+ v = g_hash_table_lookup(config, "set");
+ if (v && config_value_is_string(v)) {
+ const gchar *s = config_value_string(v);
+ if (!g_ascii_strcasecmp(s, "on"))
+ o->toggle = FALSE;
+ else if (!g_ascii_strcasecmp(s, "off")) {
+ o->toggle = FALSE;
+ o->set = FALSE;
+ }
+ }
return o;
}
g_slice_free(Options, o);
}
-static gboolean each_on(ObClient *c, const ObActionListRun *data,
+static gboolean each_run(ObClient *c, const ObActionListRun *data,
gpointer options)
-{
- Options *o = options;
- if (data->target) {
- action_client_move(data, TRUE);
- client_maximize(data->target, TRUE, o->dir);
- action_client_move(data, FALSE);
- }
- return TRUE;
-}
-
-/* Always return FALSE because its not interactive */
-static gboolean run_func_on(const ObClientSet *set,
- const ObActionListRun *data, gpointer options)
-{
- if (!client_set_is_empty(set)) {
- action_client_move(data, TRUE);
- client_set_run(set, data, each_on, options);
- action_client_move(data, FALSE);
- }
- return FALSE;
-}
-
-static gboolean each_off(ObClient *c, const ObActionListRun *data,
- gpointer options)
-{
- Options *o = options;
- if (data->target) {
- action_client_move(data, TRUE);
- client_maximize(data->target, FALSE, o->dir);
- action_client_move(data, FALSE);
- }
- return TRUE;
-}
-
-/* Always return FALSE because its not interactive */
-static gboolean run_func_off(const ObClientSet *set,
- const ObActionListRun *data, gpointer options)
-{
- if (!client_set_is_empty(set)) {
- action_client_move(data, TRUE);
- client_set_run(set, data, each_off, options);
- action_client_move(data, FALSE);
- }
- return FALSE;
-}
-
-static gboolean each_toggle(ObClient *c, const ObActionListRun *data,
- gpointer options)
{
Options *o = options;
gboolean toggle;
- toggle = ((o->dir == HORZ && !data->target->max_horz) ||
- (o->dir == VERT && !data->target->max_vert) ||
- (o->dir == BOTH &&
- !(data->target->max_horz && data->target->max_vert)));
- client_maximize(data->target, toggle, o->dir);
+ toggle = ((o->dir == HORZ && !c->max_horz) ||
+ (o->dir == VERT && !c->max_vert) ||
+ (o->dir == BOTH && !(c->max_horz && c->max_vert)));
+ client_maximize(data->target, (o->toggle ? toggle : o->set), o->dir);
return TRUE;
}
/* Always return FALSE because its not interactive */
-static gboolean run_func_toggle(const ObClientSet *set,
- const ObActionListRun *data, gpointer options)
+static gboolean run_func(const ObClientSet *set,
+ const ObActionListRun *data, gpointer options)
{
if (!client_set_is_empty(set)) {
action_client_move(data, TRUE);
- client_set_run(set, data, each_toggle, options);
+ client_set_run(set, data, each_run, options);
action_client_move(data, FALSE);
}
return FALSE;
#include "openbox/action.h"
#include "openbox/action_list_run.h"
+#include "openbox/config_value.h"
#include "openbox/client.h"
#include "openbox/client_set.h"
#include "openbox/screen.h"
-static gboolean run_func_on(const ObClientSet *set,
- const ObActionListRun *data, gpointer options);
-static gboolean run_func_off(const ObClientSet *set,
- const ObActionListRun *data, gpointer options);
-static gboolean run_func_toggle(const ObClientSet *set,
- const ObActionListRun *data, gpointer options);
+typedef struct {
+ gboolean toggle;
+ gboolean set;
+} Options;
+
+static gpointer setup_func(GHashTable *config);
+static void free_func(gpointer o);
+static gboolean run_func(const ObClientSet *set,
+ const ObActionListRun *data, gpointer options);
void action_omnipresent_startup(void)
{
action_register("Omnipresent", OB_ACTION_DEFAULT_FILTER_SINGLE,
- NULL, NULL, run_func_on);
- action_register("Unomnipresent", OB_ACTION_DEFAULT_FILTER_SINGLE,
- NULL, NULL, run_func_off);
- action_register("ToggleOmnipresent", OB_ACTION_DEFAULT_FILTER_SINGLE,
- NULL, NULL, run_func_toggle);
+ setup_func, free_func, run_func);
}
-static gboolean each_off(ObClient *c, const ObActionListRun *data,
- gpointer options)
+static gpointer setup_func(GHashTable *config)
{
- client_set_desktop(c, FALSE, FALSE, TRUE);
- return TRUE;
-}
+ ObConfigValue *v;
+ Options *o;
-/* Always return FALSE because its not interactive */
-static gboolean run_func_off(const ObClientSet *set,
- const ObActionListRun *data, gpointer options)
-{
- if (!client_set_is_empty(set)) {
- action_client_move(data, TRUE);
- client_set_run(set, data, each_off, options);
- action_client_move(data, FALSE);
+ o = g_slice_new0(Options);
+ o->toggle = TRUE;
+ o->set = TRUE;
+
+ v = g_hash_table_lookup(config, "set");
+ if (v && config_value_is_string(v)) {
+ const gchar *s = config_value_string(v);
+ if (!g_ascii_strcasecmp(s, "on"))
+ o->toggle = FALSE;
+ else if (!g_ascii_strcasecmp(s, "off")) {
+ o->toggle = FALSE;
+ o->set = FALSE;
+ }
}
- return FALSE;
-}
-static gboolean each_on(ObClient *c, const ObActionListRun *data,
- gpointer options)
-{
- client_set_desktop(c, TRUE, FALSE, TRUE);
- return TRUE;
+ return o;
}
-/* Always return FALSE because its not interactive */
-static gboolean run_func_on(const ObClientSet *set,
- const ObActionListRun *data, gpointer options)
+static void free_func(gpointer o)
{
- if (!client_set_is_empty(set)) {
- action_client_move(data, TRUE);
- client_set_run(set, data, each_on, options);
- action_client_move(data, FALSE);
- }
- return FALSE;
+ g_slice_free(Options, o);
}
-static gboolean each_toggle(ObClient *c, const ObActionListRun *data,
+static gboolean each_run(ObClient *c, const ObActionListRun *data,
gpointer options)
{
- gboolean omni = c->desktop == DESKTOP_ALL ? screen_desktop : DESKTOP_ALL;
- client_set_desktop(c, omni, FALSE, TRUE);
+ Options *o = options;
+ guint toggle;
+ toggle = c->desktop == DESKTOP_ALL ? screen_desktop : DESKTOP_ALL;
+ client_set_desktop(c, (o->toggle ? toggle :
+ (o->set ? DESKTOP_ALL : screen_desktop)),
+ FALSE, TRUE);
return TRUE;
}
/* Always return FALSE because its not interactive */
-static gboolean run_func_toggle(const ObClientSet *set,
- const ObActionListRun *data, gpointer options)
+static gboolean run_func(const ObClientSet *set,
+ const ObActionListRun *data, gpointer options)
{
if (!client_set_is_empty(set)) {
action_client_move(data, TRUE);
- client_set_run(set, data, each_toggle, options);
+ client_set_run(set, data, each_run, options);
action_client_move(data, FALSE);
}
return FALSE;
#include "openbox/action.h"
#include "openbox/action_list_run.h"
+#include "openbox/config_value.h"
#include "openbox/client.h"
#include "openbox/client_set.h"
-static gboolean run_func_on(const ObClientSet *set,
- const ObActionListRun *data, gpointer options);
-static gboolean run_func_off(const ObClientSet *set,
- const ObActionListRun *data, gpointer options);
-static gboolean run_func_toggle(const ObClientSet *set,
- const ObActionListRun *data, gpointer options);
+typedef struct {
+ gboolean toggle;
+ gboolean set;
+} Options;
+
+static gpointer setup_func(GHashTable *config);
+static void free_func(gpointer o);
+static gboolean run_func(const ObClientSet *set,
+ const ObActionListRun *data, gpointer options);
void action_shade_startup(void)
{
action_register("Shade", OB_ACTION_DEFAULT_FILTER_SINGLE,
- NULL, NULL, run_func_on);
- action_register("Unshade", OB_ACTION_DEFAULT_FILTER_SINGLE,
- NULL, NULL, run_func_off);
- action_register("ToggleShade", OB_ACTION_DEFAULT_FILTER_SINGLE,
- NULL, NULL, run_func_toggle);
+ setup_func, free_func, run_func);
}
-static gboolean each_on(ObClient *c, const ObActionListRun *data,
- gpointer options)
+static gpointer setup_func(GHashTable *config)
{
- client_shade(c, TRUE);
- return TRUE;
-}
+ ObConfigValue *v;
+ Options *o;
-/* Always return FALSE because its not interactive */
-static gboolean run_func_on(const ObClientSet *set,
- const ObActionListRun *data, gpointer options)
-{
- if (data->target) {
- action_client_move(data, TRUE);
- client_set_run(set, data, each_on, options);
- action_client_move(data, FALSE);
+ o = g_slice_new0(Options);
+ o->toggle = TRUE;
+ o->set = TRUE;
+
+ v = g_hash_table_lookup(config, "set");
+ if (v && config_value_is_string(v)) {
+ const gchar *s = config_value_string(v);
+ if (!g_ascii_strcasecmp(s, "on"))
+ o->toggle = FALSE;
+ else if (!g_ascii_strcasecmp(s, "off")) {
+ o->toggle = FALSE;
+ o->set = FALSE;
+ }
}
- return FALSE;
-}
-static gboolean each_off(ObClient *c, const ObActionListRun *data,
- gpointer options)
-{
- client_shade(c, FALSE);
- return TRUE;
+ return o;
}
-/* Always return FALSE because its not interactive */
-static gboolean run_func_off(const ObClientSet *set,
- const ObActionListRun *data, gpointer options)
+static void free_func(gpointer o)
{
- if (data->target) {
- action_client_move(data, TRUE);
- client_set_run(set, data, each_off, options);
- action_client_move(data, FALSE);
- }
- return FALSE;
+ g_slice_free(Options, o);
}
-static gboolean each_toggle(ObClient *c, const ObActionListRun *data,
- gpointer options)
+static gboolean each_run(ObClient *c, const ObActionListRun *data,
+ gpointer options)
{
- client_shade(c, !c->shaded);
+ Options *o = options;
+ client_shade(c, o->toggle ? !c->shaded : o->set);
return TRUE;
}
/* Always return FALSE because its not interactive */
-static gboolean run_func_toggle(const ObClientSet *set,
- const ObActionListRun *data, gpointer options)
+static gboolean run_func(const ObClientSet *set,
+ const ObActionListRun *data, gpointer options)
{
if (data->target) {
action_client_move(data, TRUE);
- client_set_run(set, data, each_toggle, options);
+ client_set_run(set, data, each_run, options);
action_client_move(data, FALSE);
}
return FALSE;
{ "Left", "AllDesktops", OB_MOUSE_ACTION_CLICK, "Raise" },
{ "Left", "Shade", OB_MOUSE_ACTION_CLICK, "Raise" },
{ "Left", "Close", OB_MOUSE_ACTION_CLICK, "Close" },
- { "Left", "Maximize", OB_MOUSE_ACTION_CLICK, "ToggleMaximize" },
+ { "Left", "Maximize", OB_MOUSE_ACTION_CLICK, "Maximize" },
{ "Left", "Iconify", OB_MOUSE_ACTION_CLICK, "Iconify" },
- { "Left", "AllDesktops", OB_MOUSE_ACTION_CLICK, "ToggleOmnipresent" },
- { "Left", "Shade", OB_MOUSE_ACTION_CLICK, "ToggleShade" },
+ { "Left", "AllDesktops", OB_MOUSE_ACTION_CLICK, "Omnipresent" },
+ { "Left", "Shade", OB_MOUSE_ACTION_CLICK, "Shade" },
{ "Left", "TLCorner", OB_MOUSE_ACTION_MOTION, "Resize" },
{ "Left", "TRCorner", OB_MOUSE_ACTION_MOTION, "Resize" },
{ "Left", "BLCorner", OB_MOUSE_ACTION_MOTION, "Resize" },