Add "visible" filter for windows on current desktop.
authorDana Jansens <danakj@orodu.net>
Mon, 24 Oct 2011 23:40:11 +0000 (19:40 -0400)
committerDana Jansens <danakj@orodu.net>
Mon, 24 Oct 2011 23:40:11 +0000 (19:40 -0400)
Makefile.am
openbox/filters/_all.c
openbox/filters/_all.h
openbox/filters/visible.c [new file with mode: 0644]

index b7c86544a6cf2c31d36a54d2c1b841e061f8cbf8..47cbd9a9fa3e1e4a13372018236f6729f1fc079c 100644 (file)
@@ -239,6 +239,7 @@ openbox_openbox_SOURCES = \
        openbox/filters/_all.h \
        openbox/filters/all.c \
        openbox/filters/target.c \
+       openbox/filters/visible.c \
        openbox/action.c \
        openbox/action.h \
        openbox/action_filter.c \
index 2d4ff360c52e82bfcc25a26baa2045eab14dd564..07621cdd98aef3db43058d4a4e046d70cd993d4c 100644 (file)
 
 #include "_all.h"
 
+void filter_all_startup(void);
+void filter_target_startup(void);
+void filter_visible_startup(void);
+
 void filters__all_startup(void)
 {
     filter_all_startup();
     filter_target_startup();
+    filter_visible_startup();
 }
index f15fdaeda702b4460e12a47736b256a59e897d7a..28522fb80b9ce050beec397da017b454f02a2ad3 100644 (file)
@@ -17,6 +17,3 @@
 */
 
 void filters__all_startup(void);
-
-void filter_all_startup(void);
-void filter_target_startup(void);
diff --git a/openbox/filters/visible.c b/openbox/filters/visible.c
new file mode 100644 (file)
index 0000000..39c8078
--- /dev/null
@@ -0,0 +1,43 @@
+/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
+
+   filters/visible.c for the Openbox window manager
+   Copyright (c) 2011             Dana Jansens
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   See the COPYING file for a copy of the GNU General Public License.
+*/
+
+#include "openbox/action_filter.h"
+#include "openbox/action_list_run.h"
+#include "openbox/client.h"
+#include "openbox/client_set.h"
+#include "openbox/screen.h"
+
+static gboolean test_visible(ObClient *c, gpointer data)
+{
+    return screen_compare_desktops(c->desktop, screen_desktop);
+}
+
+static ObClientSet* filter(gboolean invert, const ObActionListRun *data,
+                           gpointer setup_data)
+{
+    return client_set_expand(client_set_empty(), test_visible, NULL);
+}
+
+/*! The "visible" filter matches all clients that are visible currently
+  (including iconic windows).  In the classic paradigm this is all windows
+  visible on the current desktop.
+*/
+void filter_visible_startup(void)
+{
+    action_filter_register("visible", NULL, NULL, filter);
+}