From 37a24132b5cd444fca025259f05618eec52935b2 Mon Sep 17 00:00:00 2001 From: Jim Ramsay Date: Fri, 28 May 2010 15:50:15 -0400 Subject: Implement StrictMouseFocus As noted in the previous commit, StrictMouseFocus now works as advertised: Focus follows mouse on every EnterNotify event (except when the "ClientMenu" closes or during alt+tab window cycling) --- src/ClientMenu.cc | 7 ++++++- src/FocusControl.cc | 19 ++++++++++++++----- src/FocusControl.hh | 10 ++++++++-- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/src/ClientMenu.cc b/src/ClientMenu.cc index 02df7e4..67ec374 100644 --- a/src/ClientMenu.cc +++ b/src/ClientMenu.cc @@ -25,6 +25,7 @@ #include "Screen.hh" #include "Window.hh" #include "WindowCmd.hh" +#include "FocusControl.hh" #include #include "FbTk/MenuItem.hh" @@ -56,8 +57,12 @@ public: m_client.focus(); fbwin->raise(); - if ((mods & ControlMask) == 0) + if ((mods & ControlMask) == 0) { + // Ignore any focus changes due to this menu closing + // (even in StrictMouseFocus mode) + m_client.screen().focusControl().ignoreAtPointer(true); parent->hide(); + } } const std::string &label() const { return m_client.title(); } diff --git a/src/FocusControl.cc b/src/FocusControl.cc index eeacc3b..63ca773 100644 --- a/src/FocusControl.cc +++ b/src/FocusControl.cc @@ -401,21 +401,30 @@ void FocusControl::dirFocus(FluxboxWindow &win, FocusDir dir) { } -void FocusControl::ignoreAtPointer() +void FocusControl::ignoreAtPointer(bool force) { - int ignore_i; + int ignore_i, ignore_x, ignore_y; unsigned int ignore_ui; Window ignore_w; XQueryPointer(m_screen.rootWindow().display(), m_screen.rootWindow().window(), &ignore_w, &ignore_w, - &m_ignore_mouse_x, &m_ignore_mouse_y, + &ignore_x, &ignore_y, &ignore_i, &ignore_i, &ignore_ui); + + this->ignoreAt(ignore_x, ignore_y, force); +} + +void FocusControl::ignoreAt(int x, int y, bool force) +{ + if (force || this->focusModel() == MOUSEFOCUS) { + m_ignore_mouse_x = x; m_ignore_mouse_y = y; + } } -void FocusControl::ignoreAt(int x, int y) +void FocusControl::ignoreCancel() { - m_ignore_mouse_x = x; m_ignore_mouse_y = y; + m_ignore_mouse_x = m_ignore_mouse_y = -1; } bool FocusControl::isIgnored(int x, int y) diff --git a/src/FocusControl.hh b/src/FocusControl.hh index 72eec11..c265253 100644 --- a/src/FocusControl.hh +++ b/src/FocusControl.hh @@ -96,9 +96,15 @@ public: bool isMouseTabFocus() const { return tabFocusModel() == MOUSETABFOCUS; } /// Set the "ignore" pointer location to the current pointer location - void ignoreAtPointer(); + /// @param force If true, ignore even in StrictMouseFocus mode + void ignoreAtPointer(bool force = false); /// Set the "ignore" pointer location to the given coordinates - void ignoreAt(int x, int y); + /// @param x Current X position of the pointer + /// @param y Current Y position of the pointer + /// @param force If true, ignore even in StrictMouseFocus mode + void ignoreAt(int x, int y, bool force = false); + /// unset the "ignore" pointer location + void ignoreCancel(); /// @return true if events at the given X/Y coordinate should be ignored /// (ie, they were previously cached via one of the ignoreAt calls) bool isIgnored(int x, int y); -- cgit v0.11.2