]> Dogcows Code - chaz/openbox/commitdiff
allow focus_fallback to query if a client can be focused without changing the focus...
authorDana Jansens <danakj@orodu.net>
Wed, 4 Jun 2003 17:16:50 +0000 (17:16 +0000)
committerDana Jansens <danakj@orodu.net>
Wed, 4 Jun 2003 17:16:50 +0000 (17:16 +0000)
openbox/client.c
openbox/client.h
openbox/focus.c

index 9e56de050dbdb29c371628e4b58b831f7918b0ed..40b0836e1c61276e9688fdb4c0639cf04f116596 100644 (file)
@@ -2239,10 +2239,30 @@ Client *client_focus_target(Client *self)
     return self;
 }
 
+gboolean client_can_focus(Client *self)
+{
+    /* same code as in client_focus */
+
+    /* choose the correct target */
+    self = client_focus_target(self);
+
+    if (!self->frame->visible)
+        return FALSE;
+
+    if (!((self->can_focus || self->focus_notify) &&
+          (self->desktop == screen_desktop ||
+           self->desktop == DESKTOP_ALL) &&
+          !self->iconic))
+       return FALSE;
+    return TRUE;
+}
+
 gboolean client_focus(Client *self)
 {
     XEvent ev;
 
+    /* same code as in client_can_focus */
+
     /* choose the correct target */
     self = client_focus_target(self);
 
index 5d84df0b3a26777c940f961b4969c6f4fe3c69f2..ad8f506b075a8d2e1c96194f308bbe0ffdb53ce4 100644 (file)
@@ -430,6 +430,10 @@ void client_set_state(Client *self, Atom action, long data1, long data2);
    Client passed to it or another Client if appropriate. */
 Client *client_focus_target(Client *self);
 
+/*! Returns what client_focus would return if passed the same client, but
+  without focusing it or modifying the focus order lists. */
+gboolean client_can_focus(Client *self);
+
 /*! Attempt to focus the client window */
 gboolean client_focus(Client *self);
 
index de98d63bacea38b3667f9e2177dd8e6d8ebab500..5909ca773449ece98bee8e3043e222739740ef42 100644 (file)
@@ -15,6 +15,7 @@
 
 #include <X11/Xlib.h>
 #include <glib.h>
+#include <assert.h>
 
 Client *focus_client = NULL;
 GList **focus_order = NULL; /* these lists are created when screen_startup
@@ -213,8 +214,11 @@ void focus_fallback(FallbackType type)
                 for (sit = old->group->members; sit; sit = sit->next)
                     if (sit->data == it->data)
                         if (sit->data != old && client_normal(sit->data))
-                            if (client_focus(sit->data))
+                            if (client_can_focus(sit->data)) {
+                                gboolean r = client_focus(sit->data);
+                                assert(r);
                                 return;
+                            }
         }
     }
 
This page took 0.029306 seconds and 4 git commands to generate.