From fc502861a45704a8f7cd21282cbccd7e5ac620f3 Mon Sep 17 00:00:00 2001
From: markt <markt>
Date: Sun, 14 Jan 2007 19:02:01 +0000
Subject: make sure we ungrab the keyboard when changing the alt-tab screen, or
 else we'll lose an entire keystroke!\

---
 ChangeLog      | 2 ++
 src/fluxbox.cc | 7 ++++++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 166c15c..79e0654 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -9,6 +9,8 @@ Changes for 1.0rc3:
      - fixed bug with style backgrounds not getting set when changing styles
      - updated default styles to be valid wrt background options
      RootTheme.cc/hh Screen.cc FbTk/Theme.hh
+   * Minor fix for window cycling on multiple screens (Mark)
+     fluxbox.cc
 *07/01/13:
    * Only change focus order when user specifically focuses a window (Mark)
      Screen.cc Window.cc FocusControl.cc/hh
diff --git a/src/fluxbox.cc b/src/fluxbox.cc
index e492fb5..89b37fe 100644
--- a/src/fluxbox.cc
+++ b/src/fluxbox.cc
@@ -1129,8 +1129,11 @@ void Fluxbox::handleKeyEvent(XKeyEvent &ke) {
         if (!m_key->doAction(ke)) // could still be cycling
             m_watching_screen = old_watching_screen;
         else if (old_watching_screen &&
-                 m_watching_screen != old_watching_screen)
+                 m_watching_screen != old_watching_screen) {
             old_watching_screen->notifyReleasedKeys(ke);
+            if (!m_watching_screen)
+                XUngrabKeyboard(FbTk::App::instance()->display(), CurrentTime);
+        }
         break;
     case KeyRelease: {
         // we ignore most key releases unless we need to use
@@ -1852,6 +1855,8 @@ void Fluxbox::watchKeyRelease(BScreen &screen, unsigned int mods) {
 
     // just make sure we are saving the mods with any other flags (xkb)
     m_watch_keyrelease = FbTk::KeyUtil::instance().isolateModifierMask(mods);
+    // TODO: it's possible (and happens to me sometimes) for the mods to be
+    // released before we grab the keyboard -- not sure of a good way to fix it
     XGrabKeyboard(FbTk::App::instance()->display(),
                   screen.rootWindow().window(), True,
                   GrabModeAsync, GrabModeAsync, CurrentTime);
-- 
cgit v0.11.2