use a timer to make sure focus always reverts if possible

This commit is contained in:
markt 2006-07-23 09:51:54 +00:00
parent b0b28c4bbb
commit be2f40a10d
7 changed files with 29 additions and 19 deletions

View file

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

View file

@ -137,7 +137,7 @@ public:
}
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

View file

@ -66,7 +66,6 @@ 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(""),
@ -189,11 +188,6 @@ 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,9 +53,6 @@ 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; }
@ -200,7 +197,6 @@ 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->receivedFocus();
m_client->focusSig().notify();
}
}

View file

@ -221,6 +221,7 @@ Fluxbox::Fluxbox(int argc, char **argv, const char *dpy_name, const char *rcfile
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 @@ Fluxbox::Fluxbox(int argc, char **argv, const char *dpy_name, const char *rcfile
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 @@ void Fluxbox::handleEvent(XEvent * const e) {
break; // found the screen, no more search
}
}
if (screen != 0)
FocusControl::revertFocus(*screen);
}
// try FbTk::EventHandler first
@ -877,9 +882,12 @@ void Fluxbox::handleEvent(XEvent * const e) {
#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 @@ void Fluxbox::update(FbTk::Subject *changedsub) {
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();
}
}
}
@ -1776,6 +1785,11 @@ void Fluxbox::timed_reconfigure() {
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 {
WinClientMap::const_iterator it =
find_if(m_window_search.begin(),

View file

@ -185,6 +185,7 @@ public:
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 @@ private:
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;