summaryrefslogtreecommitdiffstats
path: root/mini-wm.c
diff options
context:
space:
mode:
authorMike Fulbright <msf@redhat.com>2002-08-01 00:12:23 +0000
committerMike Fulbright <msf@redhat.com>2002-08-01 00:12:23 +0000
commita5ba4a375a2ba0c87d369bebc58a767223710e99 (patch)
tree0d39813c729a95fdb007436a6715e4981fb5a2a7 /mini-wm.c
parent21874518dac195c8720fc9109c37ea09df2da9ef (diff)
downloadanaconda-a5ba4a375a2ba0c87d369bebc58a767223710e99.tar.gz
anaconda-a5ba4a375a2ba0c87d369bebc58a767223710e99.tar.xz
anaconda-a5ba4a375a2ba0c87d369bebc58a767223710e99.zip
mini-wm from otaylor
Diffstat (limited to 'mini-wm.c')
-rw-r--r--mini-wm.c84
1 files changed, 84 insertions, 0 deletions
diff --git a/mini-wm.c b/mini-wm.c
new file mode 100644
index 000000000..e988dbd5b
--- /dev/null
+++ b/mini-wm.c
@@ -0,0 +1,84 @@
+/*
+ * mini-wm.c - simple keyboard focus handling 'wm'.
+ *
+ * Owen Taylor <otaylor@redhat.com>
+ *
+ * Copyright 2002 Red Hat, Inc.
+ *
+ * This software may be freely redistributed under the terms of the GNU
+ * public license.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+
+#include <stdio.h>
+
+#include <gdk/gdkx.h>
+#include <gdk/gdkx.h>
+
+static void
+check_focus ()
+{
+ Window *children;
+ unsigned int n_children;
+ Window root;
+ Window parent;
+
+ XQueryTree (GDK_DISPLAY(), GDK_ROOT_WINDOW(),
+ &root, &parent, &children, &n_children);
+
+ if (n_children > 0) {
+ gdk_error_trap_push ();
+ XSetInputFocus (GDK_DISPLAY(), children[n_children-1],
+ RevertToPointerRoot, CurrentTime);
+ XSync (GDK_DISPLAY(), 0);
+ if (gdk_error_trap_pop () != 0)
+ printf("Failed on XSetInputFocus()");
+ }
+
+ XFree (children);
+}
+
+GdkFilterReturn
+mini_wm_root_filter (GdkXEvent *xevent,
+ GdkEvent *event,
+ gpointer data)
+{
+ XEvent *xev = xevent;
+
+ if (xev->xany.type == MapNotify ||
+ xev->xany.type == UnmapNotify ||
+ xev->xany.type == ConfigureNotify)
+ check_focus ();
+
+ return GDK_FILTER_CONTINUE;
+}
+
+void
+mini_wm_start (void)
+{
+ XWindowAttributes attrs;
+
+ XGetWindowAttributes (GDK_DISPLAY(), GDK_ROOT_WINDOW(), &attrs);
+ XSelectInput (GDK_DISPLAY(), GDK_ROOT_WINDOW(),
+ attrs.your_event_mask | SubstructureNotifyMask);
+
+ gdk_window_add_filter (GDK_ROOT_PARENT (), mini_wm_root_filter, NULL);
+}
+
+int main( int argc,
+ char *argv[] )
+{
+
+ gtk_init (&argc, &argv);
+
+ mini_wm_start ();
+
+ gtk_main();
+
+ return(0);
+}