summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoroutfoxxed <outfoxxed@outfoxxed.me>2023-04-25 15:00:34 +0000
committerGitHub <noreply@github.com>2023-04-25 16:00:34 +0100
commitf40272d50954fd0995714b789215c938b2bd455d (patch)
tree4b503f7c16fe4f9e52238fa09a0ff38f0be6ac76 /src
parente195a51cd4dd1cb15a04d9b67e3aec67199c5bea (diff)
Add follow mouse mode to avoid refocusing under cursor (#2135)
* Add follow mouse mode to avoid refocusing under cursor
Diffstat (limited to 'src')
-rw-r--r--src/config/ConfigManager.cpp1
-rw-r--r--src/managers/input/InputManager.cpp5
-rw-r--r--src/managers/input/InputManager.hpp3
3 files changed, 8 insertions, 1 deletions
diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp
index ef1055eb..50c53f27 100644
--- a/src/config/ConfigManager.cpp
+++ b/src/config/ConfigManager.cpp
@@ -151,6 +151,7 @@ void CConfigManager::setDefaultVars() {
configValues["animations:enabled"].intValue = 1;
configValues["input:follow_mouse"].intValue = 1;
+ configValues["input:mouse_refocus"].intValue = 1;
configValues["input:sensitivity"].floatValue = 0.f;
configValues["input:accel_profile"].strValue = STRVAL_EMPTY;
configValues["input:kb_file"].strValue = STRVAL_EMPTY;
diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp
index bfe88678..4778ed3a 100644
--- a/src/managers/input/InputManager.cpp
+++ b/src/managers/input/InputManager.cpp
@@ -47,6 +47,7 @@ void CInputManager::simulateMouseMovement() {
void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
static auto* const PFOLLOWMOUSE = &g_pConfigManager->getConfigValuePtr("input:follow_mouse")->intValue;
+ static auto* const PMOUSEREFOCUS = &g_pConfigManager->getConfigValuePtr("input:mouse_refocus")->intValue;
static auto* const PMOUSEDPMS = &g_pConfigManager->getConfigValuePtr("misc:mouse_move_enables_dpms")->intValue;
static auto* const PFOLLOWONDND = &g_pConfigManager->getConfigValuePtr("misc:always_follow_on_dnd")->intValue;
static auto* const PHOGFOCUS = &g_pConfigManager->getConfigValuePtr("misc:layers_hog_keyboard_focus")->intValue;
@@ -382,8 +383,10 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
m_bLastFocusOnLS = false;
return; // don't enter any new surfaces
} else {
- if ((FOLLOWMOUSE != 3 && allowKeyboardRefocus) || refocus)
+ if (((FOLLOWMOUSE != 3 && allowKeyboardRefocus) && (*PMOUSEREFOCUS || m_pLastMouseFocus != pFoundWindow)) || refocus) {
+ m_pLastMouseFocus = pFoundWindow;
g_pCompositor->focusWindow(pFoundWindow, foundSurface);
+ }
}
m_bLastFocusOnLS = false;
diff --git a/src/managers/input/InputManager.hpp b/src/managers/input/InputManager.hpp
index a98ad497..f536072f 100644
--- a/src/managers/input/InputManager.hpp
+++ b/src/managers/input/InputManager.hpp
@@ -175,6 +175,9 @@ class CInputManager {
// for hiding cursor on touch
bool m_bLastInputTouch = false;
+ // for tracking mouse refocus
+ CWindow* m_pLastMouseFocus = nullptr;
+
private:
bool m_bCursorImageOverridden = false;
eBorderIconDirection m_eBorderIconDirection = BORDERICON_NONE;