From 9229f8bc9ceae2505d7715cdea6e75aeb1b2c78b Mon Sep 17 00:00:00 2001
From: markt <markt>
Date: Tue, 25 Jul 2006 21:54:58 +0000
Subject: don't revert focus away from command dialogs

---
 ChangeLog            | 2 ++
 src/CommandDialog.cc | 3 +++
 src/fluxbox.cc       | 3 ++-
 src/fluxbox.hh       | 2 ++
 4 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 8fea633..e12a650 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,8 @@
  (Format: Year/Month/Day)
 Changes for 1.0rc3:
 *06/07/25:
+   * Fix so that focus doesn't revert away from command dialogs (Mark)
+     fluxbox.cc/hh CommandDialog.cc
    * Fix background style item so that it works when the previous style
      didn't have one set (Mark)
      Screen.cc RootTheme.hh
diff --git a/src/CommandDialog.cc b/src/CommandDialog.cc
index f28d789..3fab06b 100644
--- a/src/CommandDialog.cc
+++ b/src/CommandDialog.cc
@@ -29,6 +29,7 @@
 #include "WinClient.hh"
 #include "CommandParser.hh"
 #include "FocusControl.hh"
+#include "fluxbox.hh"
 
 #include "FbTk/ImageControl.hh"
 #include "FbTk/EventManager.hh"
@@ -74,6 +75,7 @@ void CommandDialog::show() {
     FbTk::FbWindow::show();
     m_textbox.setInputFocus();
     m_label.clear();
+    Fluxbox::instance()->setShowingDialog(true);
     // resize to correct width, which should be the width of label text
     // no need to truncate label text in this dialog
     // but if label text size < 200 we set 200
@@ -88,6 +90,7 @@ void CommandDialog::show() {
 
 void CommandDialog::hide() {
     FbTk::FbWindow::hide();
+    Fluxbox::instance()->setShowingDialog(false);
 
     // return focus to fluxbox window
     if (FocusControl::focusedFbWindow())
diff --git a/src/fluxbox.cc b/src/fluxbox.cc
index 2cb599b..59859ad 100644
--- a/src/fluxbox.cc
+++ b/src/fluxbox.cc
@@ -222,6 +222,7 @@ Fluxbox::Fluxbox(int argc, char **argv, const char *dpy_name, const char *rcfile
       m_rc_file(rcfilename ? rcfilename : ""),
       m_argv(argv), m_argc(argc),
       m_revert_screen(0),
+      m_showing_dialog(false),
       m_starting(true),
       m_restarting(false),
       m_shutdown(false),
@@ -1786,7 +1787,7 @@ void Fluxbox::timed_reconfigure() {
 
 void Fluxbox::revert_focus() {
     if (m_revert_screen && !FocusControl::focusedWindow() &&
-        !FbTk::Menu::focused())
+        !FbTk::Menu::focused() && !m_showing_dialog)
         FocusControl::revertFocus(*m_revert_screen);
 }
 
diff --git a/src/fluxbox.hh b/src/fluxbox.hh
index e7bc18d..9855637 100644
--- a/src/fluxbox.hh
+++ b/src/fluxbox.hh
@@ -186,6 +186,7 @@ public:
 
     void timed_reconfigure();
     void revert_focus();
+    void setShowingDialog(bool value) { m_showing_dialog = value; }
 
     bool isStartup() const { return m_starting; }
     bool isRestarting() const { return m_restarting; }
@@ -293,6 +294,7 @@ private:
     ///< when we execute reconfig command we must wait until next event round
     FbTk::Timer m_reconfig_timer, m_revert_timer;
     BScreen *m_revert_screen;
+    bool m_showing_dialog;
 
     std::auto_ptr<Keys> m_key;
 
-- 
cgit v0.11.2