diff options
| author | Vaxry <vaxry@vaxry.net> | 2024-04-23 01:28:20 +0100 |
|---|---|---|
| committer | Vaxry <vaxry@vaxry.net> | 2024-04-23 01:49:23 +0100 |
| commit | 29308b94ca2d95597b3c4e3ac1d3edbcd2f23cdd (patch) | |
| tree | bc7c9b36fc4941f17c81625964e5110118695b10 /src/events/Windows.cpp | |
| parent | 7778f01194d84fae18827fd338299dd7482ef7c5 (diff) | |
windows: add misc:initial_workspace_tracking
By default enabled, will track the initial opened workspace of a window spawned for 2 minutes or until it's moved to a different workspace.
For example: you run a launcher and open an app on workspace 1, but quickly switch to workspace 2. The app will now open on workspace 1 regardless of your switch.
Diffstat (limited to 'src/events/Windows.cpp')
| -rw-r--r-- | src/events/Windows.cpp | 44 |
1 files changed, 33 insertions, 11 deletions
diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp index a351ef67..cb67af2f 100644 --- a/src/events/Windows.cpp +++ b/src/events/Windows.cpp @@ -3,6 +3,7 @@ #include "../Compositor.hpp" #include "../helpers/WLClasses.hpp" #include "../managers/input/InputManager.hpp" +#include "../managers/TokenManager.hpp" #include "../render/Renderer.hpp" #include "../config/ConfigValue.hpp" @@ -44,13 +45,14 @@ void setAnimToMove(void* data) { void Events::listener_mapWindow(void* owner, void* data) { CWindow* PWINDOW = (CWindow*)owner; - static auto PINACTIVEALPHA = CConfigValue<Hyprlang::FLOAT>("decoration:inactive_opacity"); - static auto PACTIVEALPHA = CConfigValue<Hyprlang::FLOAT>("decoration:active_opacity"); - static auto PDIMSTRENGTH = CConfigValue<Hyprlang::FLOAT>("decoration:dim_strength"); - static auto PSWALLOW = CConfigValue<Hyprlang::INT>("misc:enable_swallow"); - static auto PSWALLOWREGEX = CConfigValue<std::string>("misc:swallow_regex"); - static auto PSWALLOWEXREGEX = CConfigValue<std::string>("misc:swallow_exception_regex"); - static auto PNEWTAKESOVERFS = CConfigValue<Hyprlang::INT>("misc:new_window_takes_over_fullscreen"); + static auto PINACTIVEALPHA = CConfigValue<Hyprlang::FLOAT>("decoration:inactive_opacity"); + static auto PACTIVEALPHA = CConfigValue<Hyprlang::FLOAT>("decoration:active_opacity"); + static auto PDIMSTRENGTH = CConfigValue<Hyprlang::FLOAT>("decoration:dim_strength"); + static auto PSWALLOW = CConfigValue<Hyprlang::INT>("misc:enable_swallow"); + static auto PSWALLOWREGEX = CConfigValue<std::string>("misc:swallow_regex"); + static auto PSWALLOWEXREGEX = CConfigValue<std::string>("misc:swallow_exception_regex"); + static auto PNEWTAKESOVERFS = CConfigValue<Hyprlang::INT>("misc:new_window_takes_over_fullscreen"); + static auto PINITIALWSTRACKING = CConfigValue<Hyprlang::INT>("misc:initial_workspace_tracking"); auto PMONITOR = g_pCompositor->m_pLastMonitor; if (!g_pCompositor->m_pLastMonitor) { @@ -67,6 +69,28 @@ void Events::listener_mapWindow(void* owner, void* data) { PWINDOW->m_iX11Type = PWINDOW->m_bIsX11 ? (PWINDOW->m_uSurface.xwayland->override_redirect ? 2 : 1) : 1; PWINDOW->m_bFirstMap = true; + // check for token + std::string requestedWorkspace = ""; + bool workspaceSilent = false; + + if (*PINITIALWSTRACKING) { + const auto WINDOWENV = PWINDOW->getEnv(); + if (WINDOWENV.contains("HL_INITIAL_WORKSPACE_TOKEN")) { + const auto SZTOKEN = WINDOWENV.at("HL_INITIAL_WORKSPACE_TOKEN"); + Debug::log(LOG, "New window contains HL_INITIAL_WORKSPACE_TOKEN: {}", SZTOKEN); + const auto TOKEN = g_pTokenManager->getToken(SZTOKEN); + if (TOKEN) { + // find workspace and use it + std::string WS = std::any_cast<std::string>(TOKEN->data); + + Debug::log(LOG, "HL_INITIAL_WORKSPACE_TOKEN {} -> {}", SZTOKEN, WS); + + requestedWorkspace = WS; + workspaceSilent = true; + } + } + } + if (g_pInputManager->m_bLastFocusOnLS) // waybar fix g_pInputManager->releaseAllMouseButtons(); @@ -108,10 +132,8 @@ void Events::listener_mapWindow(void* owner, void* data) { } // window rules - const auto WINDOWRULES = g_pConfigManager->getMatchingRules(PWINDOW, false); - std::string requestedWorkspace = ""; - bool workspaceSilent = false; - bool requestsFullscreen = PWINDOW->m_bWantsInitialFullscreen || + const auto WINDOWRULES = g_pConfigManager->getMatchingRules(PWINDOW, false); + bool requestsFullscreen = PWINDOW->m_bWantsInitialFullscreen || (!PWINDOW->m_bIsX11 && PWINDOW->m_uSurface.xdg->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL && PWINDOW->m_uSurface.xdg->toplevel->requested.fullscreen) || (PWINDOW->m_bIsX11 && PWINDOW->m_uSurface.xwayland->fullscreen); bool requestsFakeFullscreen = false; |
