all repos — fluxbox @ be2f40a10d9c11a56c0c53307be5557a127027e9

custom fork of the fluxbox windowmanager

use a timer to make sure focus always reverts if possible
markt markt
commit

be2f40a10d9c11a56c0c53307be5557a127027e9

parent

b0b28c4bbb20ffcf56b445caca112d8866c9c788

M ChangeLogChangeLog

@@ -1,5 +1,8 @@

(Format: Year/Month/Day) Changes for 1.0rc3: +*06/07/23: + * Use a timer to make sure focus always reverts if possible (Mark) + fluxbox.cc/hh and reverse patch from 06/07/20 *06/07/22: * Ewmh compliance updates: (Mark) - implemented _NET_WM_MOVERESIZE_CANCEL (new in version 1.4.draft-1)
M src/FbTk/FbWindow.hhsrc/FbTk/FbWindow.hh

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

} virtual void lower(); virtual void raise(); - virtual void setInputFocus(int revert_to, int time); + 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,7 +66,6 @@ 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(""),

@@ -187,11 +186,6 @@ 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,9 +53,6 @@

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

@@ -200,7 +197,6 @@ // 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->receivedFocus(); + m_client->focusSig().notify(); } }
M src/fluxbox.ccsrc/fluxbox.cc

@@ -221,6 +221,7 @@ m_last_time(0),

m_masked(0), m_rc_file(rcfilename ? rcfilename : ""), m_argv(argv), m_argc(argc), + m_revert_screen(0), m_starting(true), m_restarting(false), m_shutdown(false),

@@ -273,6 +274,13 @@ to.tv_usec = 1;

m_reconfig_timer.setTimeout(to); m_reconfig_timer.setCommand(reconfig_cmd); m_reconfig_timer.fireOnce(true); + + // set a timer to revert focus on FocusOut, in case no FocusIn arrives + FbTk::RefCount<FbTk::Command> revert_cmd(new FbTk::SimpleCommand<Fluxbox>(*this, &Fluxbox::revert_focus)); + m_revert_timer.setCommand(revert_cmd); + m_revert_timer.setTimeout(to); + m_revert_timer.fireOnce(true); + // XSynchronize(disp, True); s_singleton = this;

@@ -681,9 +689,6 @@ screen = (*it);

break; // found the screen, no more search } } - - if (screen != 0) - FocusControl::revertFocus(*screen); } // try FbTk::EventHandler first

@@ -877,9 +882,12 @@ cerr<<__FILE__<<"("<<__FUNCTION__<<") Focus out is not a FluxboxWindow !!"<<endl;

#endif // DEBUG } else if (winclient && winclient == FocusControl::focusedWindow() && (winclient->fbwindow() == 0 - || !winclient->fbwindow()->isMoving())) + || !winclient->fbwindow()->isMoving())) { // we don't unfocus a moving window FocusControl::setFocusedWindow(0); + m_revert_screen = &winclient->screen(); + m_revert_timer.start(); + } } break; case ClientMessage:

@@ -1300,8 +1308,9 @@ if (FocusControl::focusedWindow() == &client) {

FocusControl::unfocusWindow(client); // make sure nothing else uses this window before focus reverts FocusControl::setFocusedWindow(0); - } else if (!FocusControl::focusedWindow() && client.isWaitingFocus()) - FocusControl::revertFocus(screen); + m_revert_screen = &screen; + m_revert_timer.start(); + } } }

@@ -1774,6 +1783,11 @@ if (m_reread_menu_wait)

real_rereadMenu(); m_reconfigure_wait = m_reread_menu_wait = false; +} + +void Fluxbox::revert_focus() { + if (m_revert_screen && !FocusControl::focusedWindow()) + FocusControl::revertFocus(*m_revert_screen); } bool Fluxbox::validateClient(const WinClient *client) const {
M src/fluxbox.hhsrc/fluxbox.hh

@@ -185,6 +185,7 @@ void attachSignals(FluxboxWindow &win);

void attachSignals(WinClient &winclient); void timed_reconfigure(); + void revert_focus(); bool isStartup() const { return m_starting; } bool isRestarting() const { return m_restarting; }

@@ -289,7 +290,9 @@ std::string m_restart_argument; ///< what to restart

XEvent m_last_event; - FbTk::Timer m_reconfig_timer; ///< when we execute reconfig command we must wait at least to next event round + ///< when we execute reconfig command we must wait until next event round + FbTk::Timer m_reconfig_timer, m_revert_timer; + BScreen *m_revert_screen; std::auto_ptr<Keys> m_key;