From f9ade8947c08a7f1a4485b44da2403a55a3c04e1 Mon Sep 17 00:00:00 2001 From: markt Date: Thu, 20 Jul 2006 07:15:59 +0000 Subject: properly revert focus when two windows close at the same time --- ChangeLog | 3 +++ src/FbTk/FbWindow.hh | 2 +- src/WinClient.cc | 6 ++++++ src/WinClient.hh | 4 ++++ src/Window.cc | 2 +- src/fluxbox.cc | 8 ++++---- 6 files changed, 19 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 195f5b0..1c362e4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ (Format: Year/Month/Day) Changes for 1.0rc3: +*06/07/20: + * Properly revert focus when two windows close simultaneously (Mark) + WinClient.cc/hh FbTk/FbWindow.hh fluxbox.cc Window.cc *06/07/19: * Preserve order of focused windows on restart (Mark) Workspace.cc Screen.cc FocusControl.cc/hh diff --git a/src/FbTk/FbWindow.hh b/src/FbTk/FbWindow.hh index c5494b0..0226121 100644 --- a/src/FbTk/FbWindow.hh +++ b/src/FbTk/FbWindow.hh @@ -137,7 +137,7 @@ public: } virtual void lower(); virtual void raise(); - void setInputFocus(int revert_to, int time); + virtual void setInputFocus(int revert_to, int time); /// defines a cursor for this window void setCursor(Cursor cur); #ifdef NOT_USED diff --git a/src/WinClient.cc b/src/WinClient.cc index 4e508fb..0eddac5 100644 --- a/src/WinClient.cc +++ b/src/WinClient.cc @@ -66,6 +66,7 @@ WinClient::WinClient(Window win, BScreen &screen, FluxboxWindow *fbwin):FbTk::Fb m_modal(0), send_focus_message(false), send_close_message(false), + m_waiting_focus(false), m_win_gravity(0), m_title(""), m_icon_title(""), m_class_name(""), m_instance_name(""), @@ -188,6 +189,11 @@ bool WinClient::sendFocus() { return true; } +void WinClient::setInputFocus(int revert_to, int time) { + FbTk::FbWindow::setInputFocus(revert_to, time); + m_waiting_focus = true; +} + void WinClient::sendClose(bool forceful) { if (forceful || !send_close_message) XKillClient(display(), window()); diff --git a/src/WinClient.hh b/src/WinClient.hh index 3a9d792..4808807 100644 --- a/src/WinClient.hh +++ b/src/WinClient.hh @@ -53,6 +53,9 @@ public: bool sendFocus(); // returns whether we sent a message or not // i.e. whether we assume the focus will get taken bool acceptsFocus() const; // will this window accept focus (according to hints) + void setInputFocus(int revert_to, int time); + inline bool isWaitingFocus() { return m_waiting_focus; } + void receivedFocus() { m_waiting_focus = false; m_focussig.notify(); } void sendClose(bool forceful = false); // not aware of anything that makes this false at present inline bool isClosable() const { return true; } @@ -197,6 +200,7 @@ private: // or indicates that we are modal if don't have any transients int m_modal; bool send_focus_message, send_close_message; + bool m_waiting_focus; int m_win_gravity; diff --git a/src/Window.cc b/src/Window.cc index 2bb19a2..aa9a2b7 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -2112,7 +2112,7 @@ void FluxboxWindow::setFocusFlag(bool focus) { if (was_focused != focus) { m_focussig.notify(); if (m_client) - m_client->focusSig().notify(); + m_client->receivedFocus(); } } diff --git a/src/fluxbox.cc b/src/fluxbox.cc index 9625465..99dfff6 100644 --- a/src/fluxbox.cc +++ b/src/fluxbox.cc @@ -1297,12 +1297,12 @@ void Fluxbox::update(FbTk::Subject *changedsub) { // This is where we revert focus on window close // NOWHERE ELSE!!! - if (FocusControl::focusedWindow() == &client) + if (FocusControl::focusedWindow() == &client) { FocusControl::unfocusWindow(client); - - // failed to revert focus? - if (FocusControl::focusedWindow() == &client) + // make sure nothing else uses this window before focus reverts FocusControl::setFocusedWindow(0); + } else if (!FocusControl::focusedWindow() && client.isWaitingFocus()) + FocusControl::revertFocus(screen); } } -- cgit v0.11.2