diff --git a/hyprtester/plugin/src/main.cpp b/hyprtester/plugin/src/main.cpp index d8f3c971..f8f858b4 100644 --- a/hyprtester/plugin/src/main.cpp +++ b/hyprtester/plugin/src/main.cpp @@ -296,6 +296,24 @@ static SDispatchResult checkRule(std::string in) { return {}; } +static SDispatchResult floatingFocusOnFullscreen(std::string in) { + const auto PLASTWINDOW = Desktop::focusState()->window(); + + if (!PLASTWINDOW) + return {.success = false, .error = "No window"}; + + if (!PLASTWINDOW->m_isFloating) + return {.success = false, .error = "Window must be floating"}; + + if (PLASTWINDOW->m_alpha != 1.f) + return {.success = false, .error = "floating window doesnt restore it opacity when focused on fullscreen workspace"}; + + if (!PLASTWINDOW->m_createdOverFullscreen) + return {.success = false, .error = "floating window doesnt get flagged as createdOverFullscreen"}; + + return {}; +} + APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) { PHANDLE = handle; @@ -309,6 +327,7 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) { HyprlandAPI::addDispatcherV2(PHANDLE, "plugin:test:keybind", ::keybind); HyprlandAPI::addDispatcherV2(PHANDLE, "plugin:test:add_rule", ::addRule); HyprlandAPI::addDispatcherV2(PHANDLE, "plugin:test:check_rule", ::checkRule); + HyprlandAPI::addDispatcherV2(PHANDLE, "plugin:test:floating_focus_on_fullscreen", ::floatingFocusOnFullscreen); // init mouse g_mouse = CTestMouse::create(false); diff --git a/hyprtester/src/tests/main/window.cpp b/hyprtester/src/tests/main/window.cpp index 8cdd8a47..524ed893 100644 --- a/hyprtester/src/tests/main/window.cpp +++ b/hyprtester/src/tests/main/window.cpp @@ -378,6 +378,26 @@ static void testMaximizeSize() { EXPECT(Tests::windowCount(), 0); } +static void testFloatingFocusOnFullscreen() { + NLog::log("{}Testing floating focus on fullscreen", Colors::GREEN); + + EXPECT(spawnKitty("kitty_A"), true); + OK(getFromSocket("/dispatch togglefloating")); + + EXPECT(spawnKitty("kitty_B"), true); + OK(getFromSocket("/dispatch fullscreen 1")); + + OK(getFromSocket("/dispatch cyclenext")); + + OK(getFromSocket("/dispatch plugin:test:floating_focus_on_fullscreen")); + + NLog::log("{}Killing all windows", Colors::YELLOW); + Tests::killAllWindows(); + + NLog::log("{}Expecting 0 windows", Colors::YELLOW); + EXPECT(Tests::windowCount(), 0); +} + static void testGroupFallbackFocus() { NLog::log("{}Testing group fallback focus", Colors::GREEN); @@ -994,6 +1014,7 @@ static bool test() { testGroupRules(); testMaximizeSize(); + testFloatingFocusOnFullscreen(); testBringActiveToTopMouseMovement(); testGroupFallbackFocus(); testInitialFloatSize(); diff --git a/src/desktop/state/FocusState.cpp b/src/desktop/state/FocusState.cpp index 2c1158be..0712fc10 100644 --- a/src/desktop/state/FocusState.cpp +++ b/src/desktop/state/FocusState.cpp @@ -8,6 +8,7 @@ #include "../../managers/HookSystemManager.hpp" #include "../../xwayland/XSurface.hpp" #include "../../protocols/PointerConstraints.hpp" +#include "managers/animation/DesktopAnimationManager.hpp" using namespace Desktop; @@ -32,6 +33,7 @@ static SFullscreenWorkspaceFocusResult onFullscreenWorkspaceFocusWindow(PHLWINDO if (pWindow->m_isFloating) { // if the window is floating, just bring it to the top pWindow->m_createdOverFullscreen = true; + g_pDesktopAnimationManager->setFullscreenFloatingFade(pWindow, 1.f); g_pHyprRenderer->damageWindow(pWindow); return {}; } diff --git a/src/managers/animation/DesktopAnimationManager.cpp b/src/managers/animation/DesktopAnimationManager.cpp index 9470ec27..9a1fc081 100644 --- a/src/managers/animation/DesktopAnimationManager.cpp +++ b/src/managers/animation/DesktopAnimationManager.cpp @@ -8,6 +8,7 @@ #include "../../config/ConfigManager.hpp" #include "../../Compositor.hpp" +#include "desktop/DesktopTypes.hpp" #include "wlr-layer-shell-unstable-v1.hpp" void CDesktopAnimationManager::startAnimation(PHLWINDOW pWindow, eAnimationType type, bool force) { @@ -484,6 +485,13 @@ void CDesktopAnimationManager::setFullscreenFadeAnimation(PHLWORKSPACE ws, eAnim } } +void CDesktopAnimationManager::setFullscreenFloatingFade(PHLWINDOW pWindow, float fade) { + if (pWindow->m_fadingOut || !pWindow->m_isFloating) + return; + + *pWindow->m_alpha = fade; +} + void CDesktopAnimationManager::overrideFullscreenFadeAmount(PHLWORKSPACE ws, float fade, PHLWINDOW exclude) { for (auto const& w : g_pCompositor->m_windows) { if (w == exclude) diff --git a/src/managers/animation/DesktopAnimationManager.hpp b/src/managers/animation/DesktopAnimationManager.hpp index f27f09d2..fa86425e 100644 --- a/src/managers/animation/DesktopAnimationManager.hpp +++ b/src/managers/animation/DesktopAnimationManager.hpp @@ -16,6 +16,7 @@ class CDesktopAnimationManager { void startAnimation(PHLWORKSPACE ws, eAnimationType type, bool left = true, bool instant = false); void setFullscreenFadeAnimation(PHLWORKSPACE ws, eAnimationType type); + void setFullscreenFloatingFade(PHLWINDOW pWindow, float fade); void overrideFullscreenFadeAmount(PHLWORKSPACE ws, float fade, PHLWINDOW exclude = nullptr); private: