From 18a09c1a7ffdd0cbb9246f8f823c4426a776ba73 Mon Sep 17 00:00:00 2001 From: fluxgen Date: Sat, 21 Sep 2002 16:02:22 +0000 Subject: fixed check in setLastFocusedWindow --- src/Workspace.cc | 24 ++++++++++++++++++------ src/Workspace.hh | 4 ++-- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/Workspace.cc b/src/Workspace.cc index 7d87a20..9319f0c 100644 --- a/src/Workspace.cc +++ b/src/Workspace.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Workspace.cc,v 1.30 2002/09/12 14:55:11 rathnor Exp $ +// $Id: Workspace.cc,v 1.31 2002/09/21 16:02:22 fluxgen Exp $ #include "Workspace.hh" @@ -91,6 +91,13 @@ Workspace::~Workspace() { } +void Workspace::setLastFocusedWindow(FluxboxWindow *win) { + // make sure we have this window in the list + if (std::find(windowList.begin(), windowList.end(), win) != windowList.end()) + lastfocus = win; + else + lastfocus = 0; +} int Workspace::addWindow(FluxboxWindow *w, bool place) { if (w == 0) @@ -150,6 +157,10 @@ int Workspace::removeWindow(FluxboxWindow *w) { if (w == 0) return -1; + if (lastfocus == w) { + lastfocus = 0; + } + stackingList.remove(w); if (w->isFocused()) { @@ -177,10 +188,8 @@ int Workspace::removeWindow(FluxboxWindow *w) { } } - if (lastfocus == w) - lastfocus = 0; + - //could be faster? Windows::iterator it = windowList.begin(); Windows::iterator it_end = windowList.end(); for (; it != it_end; ++it) { @@ -203,7 +212,10 @@ int Workspace::removeWindow(FluxboxWindow *w) { (*it)->setWindowNumber(i); } } - + + if (lastfocus == w || windowList.empty()) + lastfocus = 0; + return windowList.size(); } @@ -411,7 +423,7 @@ bool Workspace::isLastWindow(FluxboxWindow *w) const{ return (w == windowList.back()); } -void Workspace::setCurrent(void) { +void Workspace::setCurrent() { screen->changeWorkspaceID(m_id); } diff --git a/src/Workspace.hh b/src/Workspace.hh index 0c2b1cb..18db91c 100644 --- a/src/Workspace.hh +++ b/src/Workspace.hh @@ -44,10 +44,10 @@ public: typedef std::vector Windows; typedef std::vector Stack; - Workspace(BScreen *screen, unsigned int workspaceid = 0); + explicit Workspace(BScreen *screen, unsigned int workspaceid = 0); ~Workspace(); - inline void setLastFocusedWindow(FluxboxWindow *w) { lastfocus = w; } + void setLastFocusedWindow(FluxboxWindow *w); /** Set workspace name */ -- cgit v0.11.2