all repos — fluxbox @ 37a24132b5cd444fca025259f05618eec52935b2

custom fork of the fluxbox windowmanager

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)
Jim Ramsay jim.ramsay@motorola.com
commit

37a24132b5cd444fca025259f05618eec52935b2

parent

cdbaf5c04d07e8310c661e12e354724a619e5911

3 files changed, 28 insertions(+), 8 deletions(-)

jump to
M src/ClientMenu.ccsrc/ClientMenu.cc

@@ -25,6 +25,7 @@ #include "Layer.hh"

#include "Screen.hh" #include "Window.hh" #include "WindowCmd.hh" +#include "FocusControl.hh" #include <X11/keysym.h> #include "FbTk/MenuItem.hh"

@@ -56,8 +57,12 @@ FbTk::Menu *parent = menu();

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(); }
M src/FocusControl.ccsrc/FocusControl.cc

@@ -401,21 +401,30 @@ foundwin->focus();

} -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) +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::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)
M src/FocusControl.hhsrc/FocusControl.hh

@@ -96,9 +96,15 @@ /// @return true if tab focus mode is mouse tab focus

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