Add SkipTaskbar/SkipPager actions (bug #3334)
authorDana Jansens <danakj@orodu.net>
Fri, 14 Oct 2011 20:46:18 +0000 (16:46 -0400)
committerDana Jansens <danakj@orodu.net>
Sun, 16 Oct 2011 22:56:02 +0000 (18:56 -0400)
Makefile.am
openbox/actions/_all.c
openbox/actions/_all.h
openbox/actions/skip_taskbar_pager.c [new file with mode: 0644]
openbox/client.c
openbox/client.h

index 9c1084d1c735afaafddaabeb2d9e85e56f95bde6..b7c86544a6cf2c31d36a54d2c1b841e061f8cbf8 100644 (file)
@@ -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 \
index c25f0e5d76fff3b2092cfb449c68625bcaa4f3d4..de6e290dd89cd154f32858a699baba6ca8e7ee2b 100644 (file)
@@ -56,4 +56,5 @@ void actions__all_startup(void)
     action_movetoedge_startup();
     action_growtoedge_startup();
     action_focustobottom_startup();
+    action_skip_taskbar_pager_startup();
 }
index b27055edf664becf257932e493c0d9fa6c830140..1545be8fa4bd0047fce1d53bf79411ee88a06432 100644 (file)
@@ -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 (file)
index 0000000..d4344ad
--- /dev/null
@@ -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;
+}
index 146d5f4e0f635a45677ff10ac077ec241f8c9164..a9c6ba3f18a7496fe535e5193b7996ef557cfb86 100644 (file)
@@ -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) {
index 18c88ec1bbf16829e7da604c3e796e13003342b7..d74e8713da10ce416a62a6b314e23420f578dd00 100644 (file)
@@ -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);