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)
This commit is contained in:
parent
cdbaf5c04d
commit
37a24132b5
3 changed files with 28 additions and 8 deletions
|
@ -25,6 +25,7 @@
|
|||
#include "Screen.hh"
|
||||
#include "Window.hh"
|
||||
#include "WindowCmd.hh"
|
||||
#include "FocusControl.hh"
|
||||
#include <X11/keysym.h>
|
||||
|
||||
#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(); }
|
||||
|
|
|
@ -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)
|
||||
void FocusControl::ignoreAt(int x, int y, bool force)
|
||||
{
|
||||
m_ignore_mouse_x = x; m_ignore_mouse_y = y;
|
||||
if (force || this->focusModel() == MOUSEFOCUS) {
|
||||
m_ignore_mouse_x = x; m_ignore_mouse_y = y;
|
||||
}
|
||||
}
|
||||
|
||||
void FocusControl::ignoreCancel()
|
||||
{
|
||||
m_ignore_mouse_x = m_ignore_mouse_y = -1;
|
||||
}
|
||||
|
||||
bool FocusControl::isIgnored(int x, int y)
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue