From b302dab2f187e364df36237c44b8e48f1e892f04 Mon Sep 17 00:00:00 2001 From: Mark Tiefenbruck Date: Sat, 12 Jan 2008 16:47:40 -0800 Subject: fix some issues with reverting focus --- src/FocusControl.cc | 5 ++++- src/FocusControl.hh | 3 +++ src/ToolFactory.cc | 1 - src/WinClient.cc | 4 +++- src/Window.cc | 10 +++++----- src/fluxbox.cc | 32 ++++++++++---------------------- 6 files changed, 25 insertions(+), 30 deletions(-) diff --git a/src/FocusControl.cc b/src/FocusControl.cc index a81d68f..c17b900 100644 --- a/src/FocusControl.cc +++ b/src/FocusControl.cc @@ -45,6 +45,7 @@ using std::string; WinClient *FocusControl::s_focused_window = 0; FluxboxWindow *FocusControl::s_focused_fbwindow = 0; +WinClient *FocusControl::s_expecting_focus = 0; bool FocusControl::s_reverting = false; namespace { @@ -242,7 +243,7 @@ void FocusControl::stopCyclingFocus() { * is given. */ Focusable *FocusControl::lastFocusedWindow(int workspace) { - if (m_focused_list.empty() || m_screen.isShuttingdown()) return 0; + if (m_screen.isShuttingdown()) return 0; if (workspace < 0 || workspace >= (int) m_screen.numberOfWorkspaces()) return m_focused_list.clientList().front(); @@ -250,6 +251,7 @@ Focusable *FocusControl::lastFocusedWindow(int workspace) { Focusables::iterator it_end = m_focused_list.clientList().end(); for (; it != it_end; ++it) { if ((*it)->fbwindow() && (*it)->acceptsFocus() && + (*it)->fbwindow()->winClient().validateClient() && ((((int)(*it)->fbwindow()->workspaceNumber()) == workspace || (*it)->fbwindow()->isStuck()) && !(*it)->fbwindow()->isIconic())) return *it; @@ -536,6 +538,7 @@ void FocusControl::setFocusedWindow(WinClient *client) { // screen should be ok s_focused_fbwindow = client->fbwindow(); s_focused_window = client; // update focused window + s_expecting_focus = 0; s_focused_fbwindow->setCurrentClient(*client, false); // don't set inputfocus s_focused_fbwindow->setFocusFlag(true); // set focus flag diff --git a/src/FocusControl.hh b/src/FocusControl.hh index 0baa401..4de4310 100644 --- a/src/FocusControl.hh +++ b/src/FocusControl.hh @@ -134,8 +134,10 @@ public: static void unfocusWindow(WinClient &client, bool full_revert = true, bool unfocus_frame = false); static void setFocusedWindow(WinClient *focus_to); static void setFocusedFbWindow(FluxboxWindow *focus_to) { s_focused_fbwindow = focus_to; } + static void setExpectingFocus(WinClient *client) { s_expecting_focus = client; } static WinClient *focusedWindow() { return s_focused_window; } static FluxboxWindow *focusedFbWindow() { return s_focused_fbwindow; } + static WinClient *expectingFocus() { return s_expecting_focus; } private: BScreen &m_screen; @@ -158,6 +160,7 @@ private: static WinClient *s_focused_window; static FluxboxWindow *s_focused_fbwindow; + static WinClient *s_expecting_focus; static bool s_reverting; }; diff --git a/src/ToolFactory.cc b/src/ToolFactory.cc index 074ae71..e6d633e 100644 --- a/src/ToolFactory.cc +++ b/src/ToolFactory.cc @@ -30,7 +30,6 @@ #include "ArrowButton.hh" // Themes -#include "IconbarTheme.hh" #include "WorkspaceNameTheme.hh" #include "ButtonTheme.hh" diff --git a/src/WinClient.cc b/src/WinClient.cc index ed6fe25..450a041 100644 --- a/src/WinClient.cc +++ b/src/WinClient.cc @@ -174,7 +174,8 @@ bool WinClient::acceptsFocus() const { bool WinClient::sendFocus() { if (accepts_input) { - setInputFocus(RevertToParent, CurrentTime); + setInputFocus(RevertToPointerRoot, CurrentTime); + FocusControl::setExpectingFocus(this); return true; } if (!send_focus_message) @@ -198,6 +199,7 @@ bool WinClient::sendFocus() { ce.xclient.data.l[4] = 0l; // send focus msg XSendEvent(display(), window(), false, NoEventMask, &ce); + FocusControl::setExpectingFocus(this); return true; } diff --git a/src/Window.cc b/src/Window.cc index 3e1ad4e..86026c9 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -2353,8 +2353,9 @@ void FluxboxWindow::destroyNotifyEvent(XDestroyWindowEvent &de) { #ifdef DEBUG cerr<<__FILE__<<"("<<__LINE__<<"): DestroyNotifyEvent this="<