mirror of
https://github.com/youwen5/nixos.git
synced 2024-11-25 02:03:51 -08:00
71 lines
3.4 KiB
Diff
71 lines
3.4 KiB
Diff
|
From 946ed1f32ae8e3840d1b3bb04c6e048ca7501fba Mon Sep 17 00:00:00 2001
|
||
|
From: ParaN3xus <136563585+ParaN3xus@users.noreply.github.com>
|
||
|
Date: Wed, 21 Aug 2024 18:24:42 +0800
|
||
|
Subject: [PATCH 14/20] core: add option to control which window to focus on
|
||
|
close (#7368)
|
||
|
|
||
|
---
|
||
|
src/config/ConfigDescriptions.hpp | 9 ++++++++-
|
||
|
src/config/ConfigManager.cpp | 1 +
|
||
|
src/events/Windows.cpp | 7 ++++++-
|
||
|
3 files changed, 15 insertions(+), 2 deletions(-)
|
||
|
|
||
|
diff --git a/src/config/ConfigDescriptions.hpp b/src/config/ConfigDescriptions.hpp
|
||
|
index 3c830132..73b995ae 100644
|
||
|
--- a/src/config/ConfigDescriptions.hpp
|
||
|
+++ b/src/config/ConfigDescriptions.hpp
|
||
|
@@ -453,6 +453,13 @@ inline static const std::vector<SConfigOptionDescription> CONFIG_OPTIONS = {
|
||
|
.type = CONFIG_OPTION_INT,
|
||
|
.data = SConfigOptionDescription::SRangeData{1, 0, 3},
|
||
|
},
|
||
|
+ SConfigOptionDescription{
|
||
|
+ .value = "input:focus_on_close",
|
||
|
+ .description = "Controls the window focus behavior when a window is closed. When set to 0, focus will shift to the next window candidate. When set to 1, focus will shift "
|
||
|
+ "to the window under the cursor.",
|
||
|
+ .type = CONFIG_OPTION_CHOICE,
|
||
|
+ .data = SConfigOptionDescription::SChoiceData{0, "next,cursor"},
|
||
|
+ },
|
||
|
SConfigOptionDescription{
|
||
|
.value = "input:mouse_refocus",
|
||
|
.description = "if disabled, mouse focus won't switch to the hovered window unless the mouse crosses a window boundary when follow_mouse=1.",
|
||
|
@@ -1341,4 +1348,4 @@ inline static const std::vector<SConfigOptionDescription> CONFIG_OPTIONS = {
|
||
|
.type = CONFIG_OPTION_BOOL,
|
||
|
.data = SConfigOptionDescription::SBoolData{true},
|
||
|
},
|
||
|
-};
|
||
|
\ No newline at end of file
|
||
|
+};
|
||
|
diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp
|
||
|
index 1856bd49..155b75d3 100644
|
||
|
--- a/src/config/ConfigManager.cpp
|
||
|
+++ b/src/config/ConfigManager.cpp
|
||
|
@@ -449,6 +449,7 @@ CConfigManager::CConfigManager() {
|
||
|
m_pConfig->addConfigValue("animations:first_launch_animation", Hyprlang::INT{1});
|
||
|
|
||
|
m_pConfig->addConfigValue("input:follow_mouse", Hyprlang::INT{1});
|
||
|
+ m_pConfig->addConfigValue("input:focus_on_close", Hyprlang::INT{0});
|
||
|
m_pConfig->addConfigValue("input:mouse_refocus", Hyprlang::INT{1});
|
||
|
m_pConfig->addConfigValue("input:special_fallthrough", Hyprlang::INT{0});
|
||
|
m_pConfig->addConfigValue("input:off_window_axis_events", Hyprlang::INT{1});
|
||
|
diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp
|
||
|
index 2eb7038f..e4e3900b 100644
|
||
|
--- a/src/events/Windows.cpp
|
||
|
+++ b/src/events/Windows.cpp
|
||
|
@@ -648,7 +648,12 @@ void Events::listener_unmapWindow(void* owner, void* data) {
|
||
|
|
||
|
// refocus on a new window if needed
|
||
|
if (wasLastWindow) {
|
||
|
- const auto PWINDOWCANDIDATE = g_pLayoutManager->getCurrentLayout()->getNextWindowCandidate(PWINDOW);
|
||
|
+ static auto FOCUSONCLOSE = CConfigValue<Hyprlang::INT>("input:focus_on_close");
|
||
|
+ PHLWINDOW PWINDOWCANDIDATE = nullptr;
|
||
|
+ if (*FOCUSONCLOSE)
|
||
|
+ PWINDOWCANDIDATE = (g_pCompositor->vectorToWindowUnified(g_pInputManager->getMouseCoordsInternal(), RESERVED_EXTENTS | INPUT_EXTENTS | ALLOW_FLOATING));
|
||
|
+ else
|
||
|
+ PWINDOWCANDIDATE = g_pLayoutManager->getCurrentLayout()->getNextWindowCandidate(PWINDOW);
|
||
|
|
||
|
Debug::log(LOG, "On closed window, new focused candidate is {}", PWINDOWCANDIDATE);
|
||
|
|
||
|
--
|
||
|
2.45.2
|
||
|
|