From: Dana Jansens Date: Fri, 14 Oct 2011 20:46:18 +0000 (-0400) Subject: Add SkipTaskbar/SkipPager actions (bug #3334) X-Git-Url: http://git.openbox.org/?a=commitdiff_plain;h=de106de4a358454c252f5bff9e67c739f75628a4;p=dana%2Fopenbox.git Add SkipTaskbar/SkipPager actions (bug #3334) --- diff --git a/Makefile.am b/Makefile.am index 9c1084d1..b7c86544 100644 --- a/Makefile.am +++ b/Makefile.am @@ -233,6 +233,7 @@ openbox_openbox_SOURCES = \ openbox/actions/shade.c \ openbox/actions/showdesktop.c \ openbox/actions/showmenu.c \ + openbox/actions/skip_taskbar_pager.c \ openbox/actions/unfocus.c \ openbox/filters/_all.c \ openbox/filters/_all.h \ diff --git a/openbox/actions/_all.c b/openbox/actions/_all.c index c25f0e5d..de6e290d 100644 --- a/openbox/actions/_all.c +++ b/openbox/actions/_all.c @@ -56,4 +56,5 @@ void actions__all_startup(void) action_movetoedge_startup(); action_growtoedge_startup(); action_focustobottom_startup(); + action_skip_taskbar_pager_startup(); } diff --git a/openbox/actions/_all.h b/openbox/actions/_all.h index b27055ed..1545be8f 100644 --- a/openbox/actions/_all.h +++ b/openbox/actions/_all.h @@ -54,3 +54,4 @@ void action_layer_startup(void); void action_movetoedge_startup(void); void action_growtoedge_startup(void); void action_focustobottom_startup(void); +void action_skip_taskbar_pager_startup(void); diff --git a/openbox/actions/skip_taskbar_pager.c b/openbox/actions/skip_taskbar_pager.c new file mode 100644 index 00000000..d4344ad0 --- /dev/null +++ b/openbox/actions/skip_taskbar_pager.c @@ -0,0 +1,99 @@ +/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*- */ + +#include "openbox/action.h" +#include "openbox/action_list_run.h" +#include "openbox/config_value.h" +#include "openbox/client.h" +#include "openbox/client_set.h" + +typedef enum { + TASKBAR, + PAGER +} SkipType; + +typedef struct { + SkipType type; + gboolean toggle; + gboolean set; +} Options; + +static gpointer setup_taskbar_func(GHashTable *config); +static gpointer setup_pager_func(GHashTable *config); +static void free_func(gpointer o); +static gboolean run_func(const ObClientSet *set, + const ObActionListRun *data, gpointer options); + +void action_skip_taskbar_pager_startup(void) +{ + action_register("SkipTaskbar", OB_ACTION_DEFAULT_FILTER_SINGLE, + setup_taskbar_func, free_func, run_func); + action_register("SkipPager", OB_ACTION_DEFAULT_FILTER_SINGLE, + setup_pager_func, free_func, run_func); +} + +static gpointer setup_func(GHashTable *config) +{ + ObConfigValue *v; + Options *o; + + 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 o; +} + +static gpointer setup_taskbar_func(GHashTable *config) +{ + Options *o = setup_func(config); + o->type = TASKBAR; + return o; +} + +static gpointer setup_pager_func(GHashTable *config) +{ + Options *o = setup_func(config); + o->type = PAGER; + return o; +} + +static void free_func(gpointer o) +{ + g_slice_free(Options, o); +} + +static gboolean each_run(ObClient *c, const ObActionListRun *data, + gpointer options) +{ + Options *o = options; + gboolean toggle; + if (o->type == TASKBAR) { + toggle = !data->target->skip_taskbar; + client_set_skip_taskbar(data->target, (o->toggle ? toggle : o->set)); + } + else { + toggle = !data->target->skip_pager; + client_set_skip_pager(data->target, (o->toggle ? toggle : o->set)); + } + return TRUE; +} + +/* Always return FALSE because its not interactive */ +static gboolean run_func(const ObClientSet *set, + const ObActionListRun *data, gpointer options) +{ + if (!client_set_is_empty(set)) + client_set_run(set, data, each_run, options); + return FALSE; +} diff --git a/openbox/client.c b/openbox/client.c index 146d5f4e..a9c6ba3f 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -3499,6 +3499,18 @@ void client_shade(ObClient *self, gboolean shade) frame_adjust_area(self->frame, FALSE, TRUE, FALSE); } +void client_set_skip_taskbar(ObClient *self, gboolean skip) +{ + self->skip_taskbar = skip; + client_change_state(self); +} + +void client_set_skip_pager(ObClient *self, gboolean skip) +{ + self->skip_pager = skip; + client_change_state(self); +} + static void client_ping_event(ObClient *self, gboolean dead) { if (self->not_responding != dead) { diff --git a/openbox/client.h b/openbox/client.h index 18c88ec1..d74e8713 100644 --- a/openbox/client.h +++ b/openbox/client.h @@ -522,6 +522,12 @@ void client_shade(ObClient *self, gboolean shade); /*! Set a client window to have decorations or not */ void client_set_undecorated(ObClient *self, gboolean undecorated); +/*! Set a client window to be skipped by the taskbar or not */ +void client_set_skip_taskbar(ObClient *self, gboolean skip); + +/*! Set a client window to be skipped by the taskbar or not */ +void client_set_skip_pager(ObClient *self, gboolean skip); + /*! Hilite the window to make the user notice it */ void client_hilite(ObClient *self, gboolean hilite);