aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorvaxerski <[email protected]>2022-05-16 23:13:32 +0200
committervaxerski <[email protected]>2022-05-16 23:13:32 +0200
commitf09de365d5214ea73e6578bd7a72e6c16740b6a0 (patch)
treee9e3b4c906250614ade7f197f5e946ab219e705f
parent25979fac1d77b2e1bed4a518dfe1897d653c7a89 (diff)
downloadHyprland-f09de365d5214ea73e6578bd7a72e6c16740b6a0.tar.gz
Hyprland-f09de365d5214ea73e6578bd7a72e6c16740b6a0.zip
Added workspace fade transition
-rw-r--r--src/helpers/Workspace.cpp26
-rw-r--r--src/helpers/Workspace.hpp3
-rw-r--r--src/managers/KeybindManager.cpp10
-rw-r--r--src/render/OpenGL.cpp5
-rw-r--r--src/render/Renderer.cpp6
5 files changed, 37 insertions, 13 deletions
diff --git a/src/helpers/Workspace.cpp b/src/helpers/Workspace.cpp
index e4065907..80bf139c 100644
--- a/src/helpers/Workspace.cpp
+++ b/src/helpers/Workspace.cpp
@@ -23,6 +23,8 @@ CWorkspace::CWorkspace(int monitorID) {
m_vRenderOffset.m_pWorkspace = this;
m_vRenderOffset.create(AVARTYPE_VECTOR, &g_pConfigManager->getConfigValuePtr("animations:workspaces_speed")->floatValue, &g_pConfigManager->getConfigValuePtr("animations:workspaces")->intValue, &g_pConfigManager->getConfigValuePtr("animations:workspaces_curve")->strValue, nullptr, AVARDAMAGE_ENTIRE);
+ m_fAlpha.create(AVARTYPE_FLOAT, &g_pConfigManager->getConfigValuePtr("animations:workspaces_speed")->floatValue, &g_pConfigManager->getConfigValuePtr("animations:workspaces")->intValue, &g_pConfigManager->getConfigValuePtr("animations:workspaces_curve")->strValue, nullptr, AVARDAMAGE_ENTIRE);
+ m_fAlpha.setValueAndWarp(255.f);
}
CWorkspace::~CWorkspace() {
@@ -33,4 +35,28 @@ CWorkspace::~CWorkspace() {
wlr_ext_workspace_handle_v1_destroy(m_pWlrHandle);
m_pWlrHandle = nullptr;
}
+}
+
+void CWorkspace::startAnim(bool in, bool left) {
+ const auto ANIMSTYLE = g_pConfigManager->getString("animations:workspaces_style");
+
+ if (ANIMSTYLE == "fade") {
+ if (in) {
+ m_fAlpha.setValueAndWarp(0.f);
+ m_fAlpha = 255.f;
+ } else {
+ m_fAlpha.setValueAndWarp(255.f);
+ m_fAlpha = 0.f;
+ }
+ } else {
+ // fallback is slide
+ const auto PMONITOR = g_pCompositor->getMonitorFromID(m_iMonitorID);
+
+ if (in) {
+ m_vRenderOffset.setValueAndWarp(Vector2D(left ? PMONITOR->vecSize.x : -PMONITOR->vecSize.x, 0));
+ m_vRenderOffset = Vector2D(0, 0);
+ } else {
+ m_vRenderOffset = Vector2D(left ? -PMONITOR->vecSize.x : PMONITOR->vecSize.x, 0);
+ }
+ }
} \ No newline at end of file
diff --git a/src/helpers/Workspace.hpp b/src/helpers/Workspace.hpp
index 3a9abf72..fbf32f6f 100644
--- a/src/helpers/Workspace.hpp
+++ b/src/helpers/Workspace.hpp
@@ -21,4 +21,7 @@ public:
// for animations
CAnimatedVariable m_vRenderOffset;
+ CAnimatedVariable m_fAlpha;
+
+ void startAnim(bool in, bool left);
}; \ No newline at end of file
diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp
index e58819d8..87f0b94d 100644
--- a/src/managers/KeybindManager.cpp
+++ b/src/managers/KeybindManager.cpp
@@ -209,11 +209,10 @@ void CKeybindManager::changeworkspace(std::string args) {
const auto ANIMTOLEFT = workspaceToChangeTo > OLDWORKSPACEID;
// start anim on old workspace
- g_pCompositor->getWorkspaceByID(OLDWORKSPACEID)->m_vRenderOffset = Vector2D(ANIMTOLEFT ? -PMONITOR->vecSize.x : PMONITOR->vecSize.x, 0);
+ g_pCompositor->getWorkspaceByID(OLDWORKSPACEID)->startAnim(false, ANIMTOLEFT);
// start anim on new workspace
- g_pCompositor->getWorkspaceByID(workspaceToChangeTo)->m_vRenderOffset.setValueAndWarp(Vector2D(ANIMTOLEFT ? PMONITOR->vecSize.x : -PMONITOR->vecSize.x, 0));
- g_pCompositor->getWorkspaceByID(workspaceToChangeTo)->m_vRenderOffset = Vector2D(0, 0);
+ g_pCompositor->getWorkspaceByID(workspaceToChangeTo)->startAnim(true, ANIMTOLEFT);
}
@@ -250,14 +249,13 @@ void CKeybindManager::changeworkspace(std::string args) {
const auto ANIMTOLEFT = workspaceToChangeTo > OLDWORKSPACE;
// start anim on old workspace
- g_pCompositor->getWorkspaceByID(OLDWORKSPACE)->m_vRenderOffset = Vector2D(ANIMTOLEFT ? -PMONITOR->vecSize.x : PMONITOR->vecSize.x, 0);
+ g_pCompositor->getWorkspaceByID(OLDWORKSPACE)->startAnim(false, ANIMTOLEFT);
g_pCompositor->m_lWorkspaces.emplace_back(PMONITOR->ID);
const auto PWORKSPACE = &g_pCompositor->m_lWorkspaces.back();
// start anim on new workspace
- PWORKSPACE->m_vRenderOffset.setValueAndWarp(Vector2D(ANIMTOLEFT ? PMONITOR->vecSize.x : -PMONITOR->vecSize.x, 0));
- PWORKSPACE->m_vRenderOffset = Vector2D(0, 0);
+ PWORKSPACE->startAnim(true, ANIMTOLEFT);
// We are required to set the name here immediately
wlr_ext_workspace_handle_v1_set_name(PWORKSPACE->m_pWlrHandle, workspaceName.c_str());
diff --git a/src/render/OpenGL.cpp b/src/render/OpenGL.cpp
index 59bea30d..f82721b6 100644
--- a/src/render/OpenGL.cpp
+++ b/src/render/OpenGL.cpp
@@ -565,10 +565,7 @@ void CHyprOpenGLImpl::renderBorder(wlr_box* box, const CColor& col, int thick, i
wlr_matrix_transpose(glMatrix, glMatrix);
- if (col.a == 255.f)
- glDisable(GL_BLEND);
- else
- glEnable(GL_BLEND);
+ glEnable(GL_BLEND);
glUseProgram(m_shQUAD.program);
diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp
index 22060e83..0d646317 100644
--- a/src/render/Renderer.cpp
+++ b/src/render/Renderer.cpp
@@ -41,7 +41,7 @@ bool shouldRenderWindow(CWindow* pWindow, SMonitor* pMonitor) {
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID);
// if not, check if it maybe is active on a different monitor. vvv might be animation in progress
- if (g_pCompositor->isWorkspaceVisible(pWindow->m_iWorkspaceID) || (PWORKSPACE && PWORKSPACE->m_iMonitorID == pMonitor->ID && PWORKSPACE->m_vRenderOffset.isBeingAnimated()))
+ if (g_pCompositor->isWorkspaceVisible(pWindow->m_iWorkspaceID) || (PWORKSPACE && PWORKSPACE->m_iMonitorID == pMonitor->ID && (PWORKSPACE->m_vRenderOffset.isBeingAnimated() || PWORKSPACE->m_fAlpha.isBeingAnimated())))
return true;
return false;
@@ -96,7 +96,7 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, SMonitor* pMonitor, timespec*
renderdata.w = pWindow->m_vRealSize.vec().x;
renderdata.h = pWindow->m_vRealSize.vec().y;
renderdata.dontRound = pWindow->m_bIsFullscreen;
- renderdata.fadeAlpha = pWindow->m_fAlpha.fl();
+ renderdata.fadeAlpha = pWindow->m_fAlpha.fl() * (PWORKSPACE->m_fAlpha.fl() / 255.f);
renderdata.alpha = pWindow == g_pCompositor->m_pLastWindow ? g_pConfigManager->getFloat("decoration:active_opacity") : g_pConfigManager->getFloat("decoration:inactive_opacity");
// apply window special data
@@ -106,7 +106,7 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, SMonitor* pMonitor, timespec*
// border
if (decorate && !pWindow->m_bX11DoesntWantBorders)
- drawBorderForWindow(pWindow, pMonitor, pWindow->m_fAlpha.fl() * renderdata.alpha, PWORKSPACE->m_vRenderOffset.vec());
+ drawBorderForWindow(pWindow, pMonitor, renderdata.alpha * renderdata.fadeAlpha, PWORKSPACE->m_vRenderOffset.vec());
if (pWindow->m_bIsX11) {
if (pWindow->m_uSurface.xwayland->surface) {