From 9ed25584a17269efe85e63fe560bf00c495258c1 Mon Sep 17 00:00:00 2001
From: markt <markt>
Date: Fri, 23 Nov 2007 18:41:23 +0000
Subject: make sure window commands operate on the right window

---
 src/Toolbar.cc      | 3 +++
 src/WorkspaceCmd.cc | 9 +++++++++
 2 files changed, 12 insertions(+)

diff --git a/src/Toolbar.cc b/src/Toolbar.cc
index 2694a4c..3639df7 100644
--- a/src/Toolbar.cc
+++ b/src/Toolbar.cc
@@ -35,6 +35,7 @@
 #include "fluxbox.hh"
 #include "Keys.hh"
 #include "Screen.hh"
+#include "WindowCmd.hh"
 #include "IntResMenuItem.hh"
 #include "BoolMenuItem.hh"
 
@@ -524,6 +525,7 @@ void Toolbar::reconfigure() {
 
 
 void Toolbar::buttonPressEvent(XButtonEvent &be) {
+    WindowCmd<void>::setWindow(0);
     if (Fluxbox::instance()->keys()->doAction(be.type, be.state, be.button,
                                               Keys::ON_TOOLBAR))
         return;
@@ -557,6 +559,7 @@ void Toolbar::buttonPressEvent(XButtonEvent &be) {
 }
 
 void Toolbar::enterNotifyEvent(XCrossingEvent &ce) {
+    WindowCmd<void>::setWindow(0);
     Fluxbox::instance()->keys()->doAction(ce.type, ce.state, 0,
                                           Keys::ON_TOOLBAR);
     if (! doAutoHide()) {
diff --git a/src/WorkspaceCmd.cc b/src/WorkspaceCmd.cc
index af0f3c5..536019c 100644
--- a/src/WorkspaceCmd.cc
+++ b/src/WorkspaceCmd.cc
@@ -54,12 +54,15 @@ void WindowListCmd::execute() {
 
         FocusControl::Focusables::iterator it = win_list.begin(),
                                            it_end = win_list.end();
+        // save old value, so we can restore it later
+        WinClient *old = WindowCmd<void>::client();
         for (; it != it_end; ++it) {
             if (m_pat.match(**it) && (*it)->fbwindow()) {
                 WindowCmd<void>::setWindow((*it)->fbwindow());
                 m_cmd->execute();
             }
         }
+        WindowCmd<void>::setClient(old);
     }
 }
 
@@ -70,6 +73,8 @@ bool SomeCmd::bool_execute() {
 
         FocusControl::Focusables::iterator it = win_list.begin(),
                                            it_end = win_list.end();
+        // save old value, so we can restore it later
+        WinClient *old = WindowCmd<void>::client();
         for (; it != it_end; ++it) {
             WinClient *client = dynamic_cast<WinClient *>(*it);
             if (!client) continue;
@@ -77,6 +82,7 @@ bool SomeCmd::bool_execute() {
             if (m_cmd->bool_execute())
                 return true;
         }
+        WindowCmd<void>::setClient(old);
     }
     return false;
 }
@@ -88,6 +94,8 @@ bool EveryCmd::bool_execute() {
 
         FocusControl::Focusables::iterator it = win_list.begin(),
                                            it_end = win_list.end();
+        // save old value, so we can restore it later
+        WinClient *old = WindowCmd<void>::client();
         for (; it != it_end; ++it) {
             WinClient *client = dynamic_cast<WinClient *>(*it);
             if (!client) continue;
@@ -95,6 +103,7 @@ bool EveryCmd::bool_execute() {
             if (!m_cmd->bool_execute())
                 return false;
         }
+        WindowCmd<void>::setClient(old);
     }
     return true;
 }
-- 
cgit v0.11.2