properly revert focus when two windows close at the same time

This commit is contained in:
markt 2006-07-20 07:15:59 +00:00
parent f4d1af1208
commit f9ade8947c
6 changed files with 19 additions and 6 deletions

View file

@ -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

View file

@ -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

View file

@ -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());

View file

@ -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;

View file

@ -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();
}
}

View file

@ -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);
}
}