mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-26 22:45:59 +01:00
Add follow mouse mode to avoid refocusing under cursor (#2135)
* Add follow mouse mode to avoid refocusing under cursor
This commit is contained in:
parent
e195a51cd4
commit
f40272d509
3 changed files with 8 additions and 1 deletions
|
@ -151,6 +151,7 @@ void CConfigManager::setDefaultVars() {
|
||||||
configValues["animations:enabled"].intValue = 1;
|
configValues["animations:enabled"].intValue = 1;
|
||||||
|
|
||||||
configValues["input:follow_mouse"].intValue = 1;
|
configValues["input:follow_mouse"].intValue = 1;
|
||||||
|
configValues["input:mouse_refocus"].intValue = 1;
|
||||||
configValues["input:sensitivity"].floatValue = 0.f;
|
configValues["input:sensitivity"].floatValue = 0.f;
|
||||||
configValues["input:accel_profile"].strValue = STRVAL_EMPTY;
|
configValues["input:accel_profile"].strValue = STRVAL_EMPTY;
|
||||||
configValues["input:kb_file"].strValue = STRVAL_EMPTY;
|
configValues["input:kb_file"].strValue = STRVAL_EMPTY;
|
||||||
|
|
|
@ -47,6 +47,7 @@ void CInputManager::simulateMouseMovement() {
|
||||||
|
|
||||||
void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
|
void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
|
||||||
static auto* const PFOLLOWMOUSE = &g_pConfigManager->getConfigValuePtr("input:follow_mouse")->intValue;
|
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 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 PFOLLOWONDND = &g_pConfigManager->getConfigValuePtr("misc:always_follow_on_dnd")->intValue;
|
||||||
static auto* const PHOGFOCUS = &g_pConfigManager->getConfigValuePtr("misc:layers_hog_keyboard_focus")->intValue;
|
static auto* const PHOGFOCUS = &g_pConfigManager->getConfigValuePtr("misc:layers_hog_keyboard_focus")->intValue;
|
||||||
|
@ -382,9 +383,11 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
|
||||||
m_bLastFocusOnLS = false;
|
m_bLastFocusOnLS = false;
|
||||||
return; // don't enter any new surfaces
|
return; // don't enter any new surfaces
|
||||||
} else {
|
} else {
|
||||||
if ((FOLLOWMOUSE != 3 && allowKeyboardRefocus) || refocus)
|
if (((FOLLOWMOUSE != 3 && allowKeyboardRefocus) && (*PMOUSEREFOCUS || m_pLastMouseFocus != pFoundWindow)) || refocus) {
|
||||||
|
m_pLastMouseFocus = pFoundWindow;
|
||||||
g_pCompositor->focusWindow(pFoundWindow, foundSurface);
|
g_pCompositor->focusWindow(pFoundWindow, foundSurface);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
m_bLastFocusOnLS = false;
|
m_bLastFocusOnLS = false;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -175,6 +175,9 @@ class CInputManager {
|
||||||
// for hiding cursor on touch
|
// for hiding cursor on touch
|
||||||
bool m_bLastInputTouch = false;
|
bool m_bLastInputTouch = false;
|
||||||
|
|
||||||
|
// for tracking mouse refocus
|
||||||
|
CWindow* m_pLastMouseFocus = nullptr;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_bCursorImageOverridden = false;
|
bool m_bCursorImageOverridden = false;
|
||||||
eBorderIconDirection m_eBorderIconDirection = BORDERICON_NONE;
|
eBorderIconDirection m_eBorderIconDirection = BORDERICON_NONE;
|
||||||
|
|
Loading…
Reference in a new issue