]> Dogcows Code - chaz/openbox/commitdiff
be smart about skipping focusing a window from unmap events, watch the unmap_ignore
authorDana Jansens <danakj@orodu.net>
Thu, 23 Jan 2003 15:43:55 +0000 (15:43 +0000)
committerDana Jansens <danakj@orodu.net>
Thu, 23 Jan 2003 15:43:55 +0000 (15:43 +0000)
src/client.cc
src/client.hh

index 94813a2e319c1521c0819b4e00a399ba0190e2ad..91d61f4bd20392904744e19f06e675ebfde4b4c9 100644 (file)
@@ -1248,7 +1248,7 @@ void Client::fullscreen(bool fs)
 }
 
 
-bool Client::focus() const
+bool Client::focus()
 {
   // won't try focus if the client doesn't want it, or if the window isn't
   // visible on the screen
@@ -1257,12 +1257,21 @@ bool Client::focus() const
   if (_focused) return true;
 
   // do a check to see if the window has already been unmapped or destroyed
+  // do this intelligently while watching out for unmaps we've generated
+  // (ignore_unmaps > 0)
   XEvent ev;
-  if (XCheckTypedWindowEvent(**otk::display, _window, UnmapNotify, &ev) ||
-      XCheckTypedWindowEvent(**otk::display, _window, DestroyNotify, &ev)) {
+  if (XCheckTypedWindowEvent(**otk::display, _window, DestroyNotify, &ev)) {
     XPutBackEvent(**otk::display, &ev);
     return false;
   }
+  while (XCheckTypedWindowEvent(**otk::display, _window, UnmapNotify, &ev)) {
+    if (ignore_unmaps) {
+      --ignore_unmaps;
+    } else {
+      XPutBackEvent(**otk::display, &ev);
+      return false;
+    }
+  }
 
   if (_can_focus)
     XSetInputFocus(**otk::display, _window,
@@ -1397,7 +1406,7 @@ void Client::unmapHandler(const XUnmapEvent &e)
 {
   if (ignore_unmaps) {
 #ifdef    DEBUG
-    printf("Ignored UnmapNotify for 0x%lx (event 0x%lx)\n", e.window, e.event);
+//  printf("Ignored UnmapNotify for 0x%lx (event 0x%lx)\n", e.window, e.event);
 #endif // DEBUG
     ignore_unmaps--;
     return;
index 8f04dc649d2e26187fce64059e3337a700c052b8..420a8c4a5a73aa52c41e60abe0d45e25ddaae1f4 100644 (file)
@@ -580,7 +580,7 @@ BB    @param window The window id that the Client class should handle
   void resize(Corner anchor, int w, int h);
 
   //! Attempt to focus the client window
-  bool focus() const;
+  bool focus();
 
   //! Remove focus from the client window
   void unfocus() const;
This page took 0.023929 seconds and 4 git commands to generate.