all repos — fluxbox @ f9ade8947c08a7f1a4485b44da2403a55a3c04e1

custom fork of the fluxbox windowmanager

properly revert focus when two windows close at the same time
markt markt
commit

f9ade8947c08a7f1a4485b44da2403a55a3c04e1

parent

f4d1af12083863f1aa63c88e3eb55a9317758fc1

6 files changed, 19 insertions(+), 6 deletions(-)

jump to
M ChangeLogChangeLog

@@ -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
M src/FbTk/FbWindow.hhsrc/FbTk/FbWindow.hh

@@ -137,7 +137,7 @@

} 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
M src/WinClient.ccsrc/WinClient.cc

@@ -66,6 +66,7 @@ m_win(fbwin),

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(""),

@@ -186,6 +187,11 @@ ce.xclient.data.l[4] = 0l;

// send focus msg XSendEvent(display(), window(), false, NoEventMask, &ce); 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) {
M src/WinClient.hhsrc/WinClient.hh

@@ -53,6 +53,9 @@

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 @@ // number of transients which we are modal for

// 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;
M src/Window.ccsrc/Window.cc

@@ -2112,7 +2112,7 @@ // did focus change? notify listeners

if (was_focused != focus) { m_focussig.notify(); if (m_client) - m_client->focusSig().notify(); + m_client->receivedFocus(); } }
M src/fluxbox.ccsrc/fluxbox.cc

@@ -1297,12 +1297,12 @@ // We also assume that any remaining active one is the last focused one

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