From 45a44f969048d232939c6931fe7ab15cf0e85b87 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Fri, 24 Jun 2022 22:28:54 +0200 Subject: added noblur --- src/render/OpenGL.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/render') diff --git a/src/render/OpenGL.cpp b/src/render/OpenGL.cpp index 85dd29be..92c9d9c9 100644 --- a/src/render/OpenGL.cpp +++ b/src/render/OpenGL.cpp @@ -566,7 +566,7 @@ void CHyprOpenGLImpl::renderTextureWithBlur(const CTexture& tex, wlr_box* pBox, static auto *const PBLURENABLED = &g_pConfigManager->getConfigValuePtr("decoration:blur")->intValue; static auto* const PNOBLUROVERSIZED = &g_pConfigManager->getConfigValuePtr("decoration:no_blur_on_oversized")->intValue; - if (*PBLURENABLED == 0 || (*PNOBLUROVERSIZED && m_RenderData.primarySurfaceUVTopLeft != Vector2D(-1, -1))) { + if (*PBLURENABLED == 0 || (*PNOBLUROVERSIZED && m_RenderData.primarySurfaceUVTopLeft != Vector2D(-1, -1)) || (m_pCurrentWindow && m_pCurrentWindow->m_sAdditionalConfigData.forceNoBlur)) { renderTexture(tex, pBox, a, round, false, border, true); return; } -- cgit v1.2.3 From eb13be1240dfe83b42e26621069aeb09ecf39b66 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Fri, 24 Jun 2022 22:45:30 +0200 Subject: fix one of the stupidest things i've ever written I am embarrassed. --- src/render/Renderer.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'src/render') diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 8118af48..4525dde8 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -194,12 +194,7 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, SMonitor* pMonitor, timespec* g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft = Vector2D(-1, -1); g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight = Vector2D(-1, -1); - if (pWindow->m_bIsX11) { - if (pWindow->m_uSurface.xwayland->surface) { - wlr_surface_for_each_surface(pWindow->m_uSurface.xwayland->surface, renderSurface, &renderdata); - } - } - else { + if (!pWindow->m_bIsX11) { renderdata.dontRound = false; // restore dontround renderdata.pMonitor = pMonitor; wlr_xdg_surface_for_each_popup_surface(pWindow->m_uSurface.xdg, renderSurface, &renderdata); -- cgit v1.2.3 From 72c86b99eb87b23c11fdc795ec6f3668f283b95c Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Fri, 24 Jun 2022 23:27:02 +0200 Subject: added general:cursor_inactive_timeout --- src/render/Renderer.cpp | 30 ++++++++++++++++++++++++++++++ src/render/Renderer.hpp | 3 +++ 2 files changed, 33 insertions(+) (limited to 'src/render') diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 4525dde8..a917a1cc 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -754,3 +754,33 @@ void CHyprRenderer::applyMonitorRule(SMonitor* pMonitor, SMonitorRule* pMonitorR // frame skip pMonitor->framesToSkip = 1; } + +void CHyprRenderer::ensureCursorRenderingMode() { + static auto *const PCURSORTIMEOUT = &g_pConfigManager->getConfigValuePtr("general:cursor_inactive_timeout")->intValue; + + const auto PASSEDCURSORSECONDS = g_pInputManager->m_tmrLastCursorMovement.getSeconds(); + + if (*PCURSORTIMEOUT > 0) { + if (*PCURSORTIMEOUT < PASSEDCURSORSECONDS && m_bHasARenderedCursor) { + m_bHasARenderedCursor = false; + + wlr_cursor_set_surface(g_pCompositor->m_sWLRCursor, nullptr, 0, 0); // hide + + Debug::log(LOG, "Hiding the cursor (timeout)"); + + for (auto& m : g_pCompositor->m_lMonitors) + g_pHyprRenderer->damageMonitor(&m); // TODO: maybe just damage the cursor area? + } else if (*PCURSORTIMEOUT > PASSEDCURSORSECONDS && !m_bHasARenderedCursor) { + m_bHasARenderedCursor = true; + + wlr_xcursor_manager_set_cursor_image(g_pCompositor->m_sWLRXCursorMgr, "left_ptr", g_pCompositor->m_sWLRCursor); + + Debug::log(LOG, "Showing the cursor (timeout)"); + + for (auto& m : g_pCompositor->m_lMonitors) + g_pHyprRenderer->damageMonitor(&m); // TODO: maybe just damage the cursor area? + } + } else { + m_bHasARenderedCursor = true; + } +} \ No newline at end of file diff --git a/src/render/Renderer.hpp b/src/render/Renderer.hpp index 24caa09d..73508623 100644 --- a/src/render/Renderer.hpp +++ b/src/render/Renderer.hpp @@ -31,6 +31,7 @@ public: void applyMonitorRule(SMonitor*, SMonitorRule*, bool force = false); bool shouldRenderWindow(CWindow*, SMonitor*); bool shouldRenderWindow(CWindow*); + void ensureCursorRenderingMode(); DAMAGETRACKINGMODES damageTrackingModeFromStr(const std::string&); @@ -41,6 +42,8 @@ private: void renderLayer(SLayerSurface*, SMonitor*, timespec*); void renderDragIcon(SMonitor*, timespec*); + bool m_bHasARenderedCursor = true; + friend class CHyprOpenGLImpl; }; -- cgit v1.2.3 From 747ff3369d6377628e3e27e3b108c8d61cbc5733 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sat, 25 Jun 2022 20:28:40 +0200 Subject: added drop shadows --- src/render/OpenGL.cpp | 68 ++++ src/render/OpenGL.hpp | 2 + src/render/Renderer.cpp | 5 +- src/render/Shaders.hpp | 341 +-------------------- .../decorations/CHyprDropShadowDecoration.cpp | 66 ++++ .../decorations/CHyprDropShadowDecoration.hpp | 27 ++ src/render/decorations/IHyprWindowDecoration.hpp | 3 +- src/render/shaders/Shadow.hpp | 83 +++++ src/render/shaders/Textures.hpp | 341 +++++++++++++++++++++ 9 files changed, 593 insertions(+), 343 deletions(-) create mode 100644 src/render/decorations/CHyprDropShadowDecoration.cpp create mode 100644 src/render/decorations/CHyprDropShadowDecoration.hpp create mode 100644 src/render/shaders/Shadow.hpp create mode 100644 src/render/shaders/Textures.hpp (limited to 'src/render') diff --git a/src/render/OpenGL.cpp b/src/render/OpenGL.cpp index 92c9d9c9..9951939d 100644 --- a/src/render/OpenGL.cpp +++ b/src/render/OpenGL.cpp @@ -75,6 +75,12 @@ CHyprOpenGLImpl::CHyprOpenGLImpl() { m_shBLUR2.posAttrib = glGetAttribLocation(prog, "pos"); m_shBLUR2.texAttrib = glGetAttribLocation(prog, "texcoord"); + prog = createProgram(QUADVERTSRC, FRAGSHADOW); + m_shSHADOW.program = prog; + m_shSHADOW.proj = glGetUniformLocation(prog, "proj"); + m_shSHADOW.posAttrib = glGetAttribLocation(prog, "pos"); + m_shSHADOW.texAttrib = glGetAttribLocation(prog, "texcoord"); + Debug::log(LOG, "Shaders initialized successfully."); // End shaders @@ -858,6 +864,68 @@ void CHyprOpenGLImpl::renderSnapshot(SLayerSurface** pLayer) { pixman_region32_fini(&fakeDamage); } +void CHyprOpenGLImpl::renderRoundedShadow(wlr_box* box, int round, int range) { + RASSERT(m_RenderData.pMonitor, "Tried to render shadow without begin()!"); + RASSERT((box->width > 0 && box->height > 0), "Tried to render shadow with width/height < 0!"); + + static auto *const PSHADOWCOL = &g_pConfigManager->getConfigValuePtr("decoration:col.shadow")->intValue; + static auto *const PSHADOWPOWER = &g_pConfigManager->getConfigValuePtr("decoration:shadow_render_power")->intValue; + static auto *const PSHADOWIGNOREWINDOW = &g_pConfigManager->getConfigValuePtr("decoration:shadow_ignore_window")->intValue; + + const auto SHADOWPOWER = std::clamp((int)*PSHADOWPOWER, 1, 4); + + const auto col = CColor(*PSHADOWCOL); + + float matrix[9]; + wlr_matrix_project_box(matrix, box, wlr_output_transform_invert(!m_bEndFrame ? WL_OUTPUT_TRANSFORM_NORMAL : m_RenderData.pMonitor->transform), 0, m_RenderData.pMonitor->output->transform_matrix); // TODO: write own, don't use WLR here + + float glMatrix[9]; + wlr_matrix_multiply(glMatrix, m_RenderData.projection, matrix); + wlr_matrix_multiply(glMatrix, matrixFlip180, glMatrix); + + wlr_matrix_transpose(glMatrix, glMatrix); + + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + glUseProgram(m_shSHADOW.program); + + glUniformMatrix3fv(m_shSHADOW.proj, 1, GL_FALSE, glMatrix); + glUniform4f(glGetUniformLocation(m_shSHADOW.program, "color"), col.r / 255.f, col.g / 255.f, col.b / 255.f, col.a / 255.f); + + const auto TOPLEFT = Vector2D(range + round, range + round); + const auto BOTTOMRIGHT = Vector2D(box->width - (range + round), box->height - (range + round)); + const auto FULLSIZE = Vector2D(box->width, box->height); + + // Rounded corners + glUniform2f(glGetUniformLocation(m_shSHADOW.program, "topLeft"), (float)TOPLEFT.x, (float)TOPLEFT.y); + glUniform2f(glGetUniformLocation(m_shSHADOW.program, "bottomRight"), (float)BOTTOMRIGHT.x, (float)BOTTOMRIGHT.y); + glUniform2f(glGetUniformLocation(m_shSHADOW.program, "fullSize"), (float)FULLSIZE.x, (float)FULLSIZE.y); + glUniform1f(glGetUniformLocation(m_shSHADOW.program, "radius"), range + round); + glUniform1f(glGetUniformLocation(m_shSHADOW.program, "range"), range); + glUniform1f(glGetUniformLocation(m_shSHADOW.program, "shadowPower"), SHADOWPOWER); + glUniform1i(glGetUniformLocation(m_shSHADOW.program, "ignoreWindow"), *PSHADOWIGNOREWINDOW); + + glVertexAttribPointer(m_shSHADOW.posAttrib, 2, GL_FLOAT, GL_FALSE, 0, fullVerts); + glVertexAttribPointer(m_shSHADOW.texAttrib, 2, GL_FLOAT, GL_FALSE, 0, fullVerts); + + glEnableVertexAttribArray(m_shSHADOW.posAttrib); + glEnableVertexAttribArray(m_shSHADOW.texAttrib); + + if (pixman_region32_not_empty(m_RenderData.pDamage)) { + PIXMAN_DAMAGE_FOREACH(m_RenderData.pDamage) { + const auto RECT = RECTSARR[i]; + scissor(&RECT); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + } + } + + glDisableVertexAttribArray(m_shSHADOW.posAttrib); + glDisableVertexAttribArray(m_shSHADOW.texAttrib); + + glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); +} + void CHyprOpenGLImpl::createBGTextureForMonitor(SMonitor* pMonitor) { RASSERT(m_RenderData.pMonitor, "Tried to createBGTex without begin()!"); diff --git a/src/render/OpenGL.hpp b/src/render/OpenGL.hpp index 0648e73a..5cae6486 100644 --- a/src/render/OpenGL.hpp +++ b/src/render/OpenGL.hpp @@ -61,6 +61,7 @@ public: void renderTexture(wlr_texture*, wlr_box*, float a, int round = 0); void renderTexture(const CTexture&, wlr_box*, float a, int round = 0, bool discardOpaque = false, bool border = false, bool allowPrimary = false); void renderTextureWithBlur(const CTexture&, wlr_box*, float a, wlr_surface* pSurface, int round = 0, bool border = false); + void renderRoundedShadow(wlr_box*, int round, int range); void makeWindowSnapshot(CWindow*); void makeLayerSnapshot(SLayerSurface*); @@ -106,6 +107,7 @@ private: CShader m_shEXT; CShader m_shBLUR1; CShader m_shBLUR2; + CShader m_shSHADOW; // GLuint createProgram(const std::string&, const std::string&); diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index a917a1cc..5d99565b 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -569,7 +569,7 @@ void CHyprRenderer::damageWindow(CWindow* pWindow) { // damage by size & pos // TODO TEMP: revise when added shadows/etc - wlr_box damageBox = {pWindow->m_vRealPosition.vec().x, pWindow->m_vRealPosition.vec().y, pWindow->m_vRealSize.vec().x, pWindow->m_vRealSize.vec().y}; + wlr_box damageBox = pWindow->getFullWindowBoundingBox(); for (auto& m : g_pCompositor->m_lMonitors) { wlr_box fixedDamageBox = damageBox; fixedDamageBox.x -= m.vecPosition.x; @@ -584,8 +584,7 @@ void CHyprRenderer::damageWindow(CWindow* pWindow) { Debug::log(LOG, "Damage: Window floated (%s): xy: %d, %d wh: %d, %d", pWindow->m_szTitle.c_str(), damageBox.x, damageBox.y, damageBox.width, damageBox.height); } else { // damage by real size & pos + border size * 2 (JIC) - static auto *const PBORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue; - wlr_box damageBox = { pWindow->m_vRealPosition.vec().x - *PBORDERSIZE - 1, pWindow->m_vRealPosition.vec().y - *PBORDERSIZE - 1, pWindow->m_vRealSize.vec().x + 2 * *PBORDERSIZE + 2, pWindow->m_vRealSize.vec().y + 2 * *PBORDERSIZE + 2}; + wlr_box damageBox = pWindow->getFullWindowBoundingBox(); for (auto& m : g_pCompositor->m_lMonitors) { wlr_box fixedDamageBox = damageBox; fixedDamageBox.x -= m.vecPosition.x; diff --git a/src/render/Shaders.hpp b/src/render/Shaders.hpp index d01e7775..ac7f9424 100644 --- a/src/render/Shaders.hpp +++ b/src/render/Shaders.hpp @@ -1,341 +1,4 @@ #pragma once -#include - -inline static constexpr auto ROUNDED_SHADER_FUNC = [](const std::string colorVarName) -> std::string { - return R"#( - if (pixCoord[0] < topLeft[0]) { - // we're close left - if (pixCoord[1] < topLeft[1]) { - // top - - if (ignoreCorners == 1) { - discard; - return; - } - - float topLeftDistance = distance(topLeft, pixCoord); - - if (topLeftDistance > radius - 1.0) { - if (primitiveMultisample == 0 && topLeftDistance > radius) { - discard; - return; - } else if (primitiveMultisample == 1) { - float distances = 0.0; - if (distance(topLeft, pixCoord + vec2(0.25, 0.25)) < radius) { distances = distances + 1.0; } - if (distance(topLeft, pixCoord + vec2(0.75, 0.25)) < radius) { distances = distances + 1.0; } - if (distance(topLeft, pixCoord + vec2(0.25, 0.75)) < radius) { distances = distances + 1.0; } - if (distance(topLeft, pixCoord + vec2(0.75, 0.75)) < radius) { distances = distances + 1.0; } - - if (distances == 0.0) { - discard; - return; - } - - distances = distances / 4.0; - - gl_FragColor = )#" + colorVarName + R"#( * distances; - return; - } - } - } else if (pixCoord[1] > bottomRight[1]) { - // bottom - - if (ignoreCorners == 1) { - discard; - return; - } - - float topLeftDistance = distance(vec2(topLeft[0], bottomRight[1]), pixCoord); - - if (topLeftDistance > radius - 1.0) { - if (primitiveMultisample == 0 && topLeftDistance > radius) { - discard; - return; - } else if (primitiveMultisample == 1) { - float distances = 0.0; - if (distance(vec2(topLeft[0], bottomRight[1]), pixCoord + vec2(0.25, 0.25)) < radius) { distances = distances + 1.0; } - if (distance(vec2(topLeft[0], bottomRight[1]), pixCoord + vec2(0.75, 0.25)) < radius) { distances = distances + 1.0; } - if (distance(vec2(topLeft[0], bottomRight[1]), pixCoord + vec2(0.25, 0.75)) < radius) { distances = distances + 1.0; } - if (distance(vec2(topLeft[0], bottomRight[1]), pixCoord + vec2(0.75, 0.75)) < radius) { distances = distances + 1.0; } - - if (distances == 0.0) { - discard; - return; - } - - distances = distances / 4.0; - - gl_FragColor = )#" + colorVarName + R"#( * distances; - return; - } - } - } - } - else if (pixCoord[0] > bottomRight[0]) { - // we're close right - if (pixCoord[1] < topLeft[1]) { - // top - - if (ignoreCorners == 1) { - discard; - return; - } - - float topLeftDistance = distance(vec2(bottomRight[0], topLeft[1]), pixCoord); - - if (topLeftDistance > radius - 1.0) { - if (primitiveMultisample == 0 && topLeftDistance > radius) { - discard; - return; - } else if (primitiveMultisample == 1) { - float distances = 0.0; - if (distance(vec2(bottomRight[0], topLeft[1]), pixCoord + vec2(0.25, 0.25)) < radius) { distances = distances + 1.0; } - if (distance(vec2(bottomRight[0], topLeft[1]), pixCoord + vec2(0.75, 0.25)) < radius) { distances = distances + 1.0; } - if (distance(vec2(bottomRight[0], topLeft[1]), pixCoord + vec2(0.25, 0.75)) < radius) { distances = distances + 1.0; } - if (distance(vec2(bottomRight[0], topLeft[1]), pixCoord + vec2(0.75, 0.75)) < radius) { distances = distances + 1.0; } - - if (distances == 0.0) { - discard; - return; - } - - distances = distances / 4.0; - - gl_FragColor = )#" + colorVarName + R"#( * distances; - return; - } - } - } else if (pixCoord[1] > bottomRight[1]) { - // bottom - - if (ignoreCorners == 1) { - discard; - return; - } - - float topLeftDistance = distance(bottomRight, pixCoord); - - if (topLeftDistance > radius - 1.0) { - if (primitiveMultisample == 0 && topLeftDistance > radius) { - discard; - return; - } else if (primitiveMultisample == 1) { - float distances = 0.0; - if (distance(bottomRight, pixCoord + vec2(0.25, 0.25)) < radius) { distances = distances + 1.0; } - if (distance(bottomRight, pixCoord + vec2(0.75, 0.25)) < radius) { distances = distances + 1.0; } - if (distance(bottomRight, pixCoord + vec2(0.25, 0.75)) < radius) { distances = distances + 1.0; } - if (distance(bottomRight, pixCoord + vec2(0.75, 0.75)) < radius) { distances = distances + 1.0; } - - if (distances == 0.0) { - discard; - return; - } - - distances = distances / 4.0; - - gl_FragColor = )#" + colorVarName + R"#( * distances; - return; - } - } - } - } - )#"; -}; - -inline const std::string QUADVERTSRC = R"#( -uniform mat3 proj; -uniform vec4 color; -attribute vec2 pos; -attribute vec2 texcoord; -varying vec4 v_color; -varying vec2 v_texcoord; - -void main() { - gl_Position = vec4(proj * vec3(pos, 1.0), 1.0); - v_color = color; - v_texcoord = texcoord; -})#"; - -inline const std::string QUADFRAGSRC = R"#( -precision mediump float; -varying vec4 v_color; -varying vec2 v_texcoord; - -uniform vec2 topLeft; -uniform vec2 bottomRight; -uniform vec2 fullSize; -uniform float radius; - -uniform int primitiveMultisample; -uniform int ignoreCorners; - -void main() { - if (radius == 0.0) { - gl_FragColor = v_color; - return; - } - - vec2 pixCoord = fullSize * v_texcoord; - - )#" + ROUNDED_SHADER_FUNC("v_color") + R"#( - - gl_FragColor = v_color; -})#"; - -inline const std::string TEXVERTSRC = R"#( -uniform mat3 proj; -attribute vec2 pos; -attribute vec2 texcoord; -varying vec2 v_texcoord; - -void main() { - gl_Position = vec4(proj * vec3(pos, 1.0), 1.0); - v_texcoord = texcoord; -})#"; - -inline const std::string TEXFRAGSRCRGBA = R"#( -precision mediump float; -varying vec2 v_texcoord; // is in 0-1 -uniform sampler2D tex; -uniform float alpha; - -uniform vec2 topLeft; -uniform vec2 bottomRight; -uniform vec2 fullSize; -uniform float radius; - -uniform int discardOpaque; - -uniform int primitiveMultisample; -uniform int ignoreCorners; - -void main() { - - vec4 pixColor = texture2D(tex, v_texcoord); - - if (discardOpaque == 1 && pixColor[3] * alpha == 1.0) { - discard; - return; - } - - vec2 pixCoord = fullSize * v_texcoord; - - )#" + ROUNDED_SHADER_FUNC("pixColor") + - R"#( - - gl_FragColor = pixColor * alpha; -})#"; - -inline const std::string TEXFRAGSRCRGBX = R"#( -precision mediump float; -varying vec2 v_texcoord; -uniform sampler2D tex; -uniform float alpha; - -uniform vec2 topLeft; -uniform vec2 bottomRight; -uniform vec2 fullSize; -uniform float radius; - -uniform int discardOpaque; - -uniform int primitiveMultisample; -uniform int ignoreCorners; - -void main() { - - if (discardOpaque == 1 && alpha == 1.0) { - discard; - return; - } - - vec4 pixColor = vec4(texture2D(tex, v_texcoord).rgb, 1.0); - - vec2 pixCoord = fullSize * v_texcoord; - - )#" + ROUNDED_SHADER_FUNC("pixColor") + R"#( - - gl_FragColor = pixColor * alpha; -})#"; - -inline const std::string FRAGBLUR1 = R"#( -#version 100 -precision mediump float; -varying mediump vec2 v_texcoord; // is in 0-1 -uniform sampler2D tex; - -uniform float radius; -uniform vec2 halfpixel; - -void main() { - vec2 uv = v_texcoord * 2.0; - - vec4 sum = texture2D(tex, uv) * 4.0; - sum += texture2D(tex, uv - halfpixel.xy * radius); - sum += texture2D(tex, uv + halfpixel.xy * radius); - sum += texture2D(tex, uv + vec2(halfpixel.x, -halfpixel.y) * radius); - sum += texture2D(tex, uv - vec2(halfpixel.x, -halfpixel.y) * radius); - gl_FragColor = sum / 8.0; -} -)#"; - -inline const std::string FRAGBLUR2 = R"#( -#version 100 -precision mediump float; -varying mediump vec2 v_texcoord; // is in 0-1 -uniform sampler2D tex; - -uniform float radius; -uniform vec2 halfpixel; - -void main() { - vec2 uv = v_texcoord / 2.0; - - vec4 sum = texture2D(tex, uv + vec2(-halfpixel.x * 2.0, 0.0) * radius); - - sum += texture2D(tex, uv + vec2(-halfpixel.x, halfpixel.y) * radius) * 2.0; - sum += texture2D(tex, uv + vec2(0.0, halfpixel.y * 2.0) * radius); - sum += texture2D(tex, uv + vec2(halfpixel.x, halfpixel.y) * radius) * 2.0; - sum += texture2D(tex, uv + vec2(halfpixel.x * 2.0, 0.0) * radius); - sum += texture2D(tex, uv + vec2(halfpixel.x, -halfpixel.y) * radius) * 2.0; - sum += texture2D(tex, uv + vec2(0.0, -halfpixel.y * 2.0) * radius); - sum += texture2D(tex, uv + vec2(-halfpixel.x, -halfpixel.y) * radius) * 2.0; - - gl_FragColor = sum / 12.0; -} -)#"; - -inline const std::string TEXFRAGSRCEXT = R"#( -#extension GL_OES_EGL_image_external : require - -precision mediump float; -varying vec2 v_texcoord; -uniform samplerExternalOES texture0; -uniform float alpha; - -uniform vec2 topLeft; -uniform vec2 bottomRight; -uniform vec2 fullSize; -uniform float radius; - -uniform int discardOpaque; - -uniform int primitiveMultisample; -uniform int ignoreCorners; - -void main() { - - vec4 pixColor = texture2D(texture0, v_texcoord); - - if (discardOpaque == 1 && pixColor[3] * alpha == 1.0) { - discard; - return; - } - - vec2 pixCoord = fullSize * v_texcoord; - - )#" + ROUNDED_SHADER_FUNC("pixColor") + R"#( - - gl_FragColor = pixColor * alpha; -})#"; +#include "shaders/Textures.hpp" +#include "shaders/Shadow.hpp" \ No newline at end of file diff --git a/src/render/decorations/CHyprDropShadowDecoration.cpp b/src/render/decorations/CHyprDropShadowDecoration.cpp new file mode 100644 index 00000000..528e00cf --- /dev/null +++ b/src/render/decorations/CHyprDropShadowDecoration.cpp @@ -0,0 +1,66 @@ +#include "CHyprDropShadowDecoration.hpp" + +#include "../../Compositor.hpp" + +CHyprDropShadowDecoration::CHyprDropShadowDecoration(CWindow* pWindow) { + m_pWindow = pWindow; +} + +CHyprDropShadowDecoration::~CHyprDropShadowDecoration() { + updateWindow(m_pWindow); +} + +SWindowDecorationExtents CHyprDropShadowDecoration::getWindowDecorationExtents() { + static auto *const PSHADOWS = &g_pConfigManager->getConfigValuePtr("decoration:drop_shadow")->intValue; + + if (*PSHADOWS != 1) + return {{}, {}}; + + return m_seExtents; +} + +eDecorationType CHyprDropShadowDecoration::getDecorationType() { + return DECORATION_SHADOW; +} + +void CHyprDropShadowDecoration::damageEntire() { + static auto *const PSHADOWS = &g_pConfigManager->getConfigValuePtr("decoration:drop_shadow")->intValue; + + if (*PSHADOWS != 1) + return; // disabled + + wlr_box dm = {m_vLastWindowPos.x - m_seExtents.topLeft.x, m_vLastWindowPos.y - m_seExtents.topLeft.y, m_vLastWindowSize.x + m_seExtents.topLeft.x + m_seExtents.bottomRight.x, m_vLastWindowSize.y + m_seExtents.topLeft.y + m_seExtents.bottomRight.y}; + g_pHyprRenderer->damageBox(&dm); +} + +void CHyprDropShadowDecoration::updateWindow(CWindow* pWindow) { + damageEntire(); +} + +void CHyprDropShadowDecoration::draw(SMonitor* pMonitor) { + + if (!g_pCompositor->windowValidMapped(m_pWindow)) + return; + + static auto *const PSHADOWS = &g_pConfigManager->getConfigValuePtr("decoration:drop_shadow")->intValue; + static auto *const PSHADOWSIZE = &g_pConfigManager->getConfigValuePtr("decoration:shadow_range")->intValue; + static auto *const PROUNDING = &g_pConfigManager->getConfigValuePtr("decoration:rounding")->intValue; + + if (*PSHADOWS != 1) + return; // disabled + + // update the extents if needed + if (*PSHADOWSIZE != m_seExtents.topLeft.x) + m_seExtents = {{*PSHADOWSIZE + 2, *PSHADOWSIZE + 2}, {*PSHADOWSIZE + 2, *PSHADOWSIZE + 2}}; + + m_vLastWindowPos = m_pWindow->m_vRealPosition.vec(); + m_vLastWindowSize = m_pWindow->m_vRealSize.vec(); + + // draw the shadow + wlr_box fullBox = {m_vLastWindowPos.x - m_seExtents.topLeft.x + 2, m_vLastWindowPos.y - m_seExtents.topLeft.y + 2, m_vLastWindowSize.x + m_seExtents.topLeft.x + m_seExtents.bottomRight.x - 4, m_vLastWindowSize.y + m_seExtents.topLeft.y + m_seExtents.bottomRight.y - 4}; + + fullBox.x -= pMonitor->vecPosition.x; + fullBox.y -= pMonitor->vecPosition.y; + + g_pHyprOpenGL->renderRoundedShadow(&fullBox, *PROUNDING, *PSHADOWSIZE); +} diff --git a/src/render/decorations/CHyprDropShadowDecoration.hpp b/src/render/decorations/CHyprDropShadowDecoration.hpp new file mode 100644 index 00000000..2a248a2f --- /dev/null +++ b/src/render/decorations/CHyprDropShadowDecoration.hpp @@ -0,0 +1,27 @@ +#pragma once + +#include "IHyprWindowDecoration.hpp" + +class CHyprDropShadowDecoration : public IHyprWindowDecoration { +public: + CHyprDropShadowDecoration(CWindow*); + virtual ~CHyprDropShadowDecoration(); + + virtual SWindowDecorationExtents getWindowDecorationExtents(); + + virtual void draw(SMonitor*); + + virtual eDecorationType getDecorationType(); + + virtual void updateWindow(CWindow*); + + virtual void damageEntire(); + +private: + SWindowDecorationExtents m_seExtents; + + CWindow* m_pWindow = nullptr; + + Vector2D m_vLastWindowPos; + Vector2D m_vLastWindowSize; +}; \ No newline at end of file diff --git a/src/render/decorations/IHyprWindowDecoration.hpp b/src/render/decorations/IHyprWindowDecoration.hpp index 0815273d..e9011a29 100644 --- a/src/render/decorations/IHyprWindowDecoration.hpp +++ b/src/render/decorations/IHyprWindowDecoration.hpp @@ -4,7 +4,8 @@ enum eDecorationType { DECORATION_NONE = -1, - DECORATION_GROUPBAR + DECORATION_GROUPBAR, + DECORATION_SHADOW }; struct SWindowDecorationExtents { diff --git a/src/render/shaders/Shadow.hpp b/src/render/shaders/Shadow.hpp new file mode 100644 index 00000000..f54124fa --- /dev/null +++ b/src/render/shaders/Shadow.hpp @@ -0,0 +1,83 @@ +#pragma once + +#include + +inline const std::string FRAGSHADOW = R"#( +precision mediump float; +varying vec4 v_color; +varying vec2 v_texcoord; + +uniform vec2 topLeft; +uniform vec2 bottomRight; +uniform vec2 fullSize; +uniform float radius; +uniform float range; +uniform float shadowPower; +uniform int ignoreWindow; + +float pixAlphaRoundedDistance(float distanceToCorner) { + if (distanceToCorner > radius) { + return 0.0; + } + + if (distanceToCorner > radius - range) { + return pow((range - (distanceToCorner - radius + range)) / range, shadowPower); // i think? + } + + return 1.0; +} + +void main() { + + vec4 pixColor = v_color; + float originalAlpha = pixColor[3]; + + bool done = false; + + vec2 pixCoord = fullSize * v_texcoord; + + // ok, now we check the distance to a border. + + if (pixCoord[0] < topLeft[0]) { + if (pixCoord[1] < topLeft[1]) { + // top left + pixColor[3] = pixColor[3] * pixAlphaRoundedDistance(distance(pixCoord, topLeft)); + done = true; + } else if (pixCoord[1] > bottomRight[1]) { + // bottom left + pixColor[3] = pixColor[3] * pixAlphaRoundedDistance(distance(pixCoord, vec2(topLeft[0], bottomRight[1]))); + done = true; + } + } else if (pixCoord[0] > bottomRight[0]) { + if (pixCoord[1] < topLeft[1]) { + // top right + pixColor[3] = pixColor[3] * pixAlphaRoundedDistance(distance(pixCoord, vec2(bottomRight[0], topLeft[1]))); + done = true; + } else if (pixCoord[1] > bottomRight[1]) { + // bottom right + pixColor[3] = pixColor[3] * pixAlphaRoundedDistance(distance(pixCoord, bottomRight)); + done = true; + } + } + + if (!done) { + // distance to all straight bb borders + float distanceT = pixCoord[1]; + float distanceB = fullSize[1] - pixCoord[1]; + float distanceL = pixCoord[0]; + float distanceR = fullSize[0] - pixCoord[0]; + + // get the smallest + float smallest = min(min(distanceT, distanceB), min(distanceL, distanceR)); + + if (smallest < range) { + pixColor[3] = pixColor[3] * pow((smallest / range), shadowPower); + } + } + + if (pixColor[3] == 0.0 || (ignoreWindow == 1 && pixColor[3] == originalAlpha)) { + discard; return; + } + + gl_FragColor = pixColor; +})#"; \ No newline at end of file diff --git a/src/render/shaders/Textures.hpp b/src/render/shaders/Textures.hpp new file mode 100644 index 00000000..d01e7775 --- /dev/null +++ b/src/render/shaders/Textures.hpp @@ -0,0 +1,341 @@ +#pragma once + +#include + +inline static constexpr auto ROUNDED_SHADER_FUNC = [](const std::string colorVarName) -> std::string { + return R"#( + if (pixCoord[0] < topLeft[0]) { + // we're close left + if (pixCoord[1] < topLeft[1]) { + // top + + if (ignoreCorners == 1) { + discard; + return; + } + + float topLeftDistance = distance(topLeft, pixCoord); + + if (topLeftDistance > radius - 1.0) { + if (primitiveMultisample == 0 && topLeftDistance > radius) { + discard; + return; + } else if (primitiveMultisample == 1) { + float distances = 0.0; + if (distance(topLeft, pixCoord + vec2(0.25, 0.25)) < radius) { distances = distances + 1.0; } + if (distance(topLeft, pixCoord + vec2(0.75, 0.25)) < radius) { distances = distances + 1.0; } + if (distance(topLeft, pixCoord + vec2(0.25, 0.75)) < radius) { distances = distances + 1.0; } + if (distance(topLeft, pixCoord + vec2(0.75, 0.75)) < radius) { distances = distances + 1.0; } + + if (distances == 0.0) { + discard; + return; + } + + distances = distances / 4.0; + + gl_FragColor = )#" + colorVarName + R"#( * distances; + return; + } + } + } else if (pixCoord[1] > bottomRight[1]) { + // bottom + + if (ignoreCorners == 1) { + discard; + return; + } + + float topLeftDistance = distance(vec2(topLeft[0], bottomRight[1]), pixCoord); + + if (topLeftDistance > radius - 1.0) { + if (primitiveMultisample == 0 && topLeftDistance > radius) { + discard; + return; + } else if (primitiveMultisample == 1) { + float distances = 0.0; + if (distance(vec2(topLeft[0], bottomRight[1]), pixCoord + vec2(0.25, 0.25)) < radius) { distances = distances + 1.0; } + if (distance(vec2(topLeft[0], bottomRight[1]), pixCoord + vec2(0.75, 0.25)) < radius) { distances = distances + 1.0; } + if (distance(vec2(topLeft[0], bottomRight[1]), pixCoord + vec2(0.25, 0.75)) < radius) { distances = distances + 1.0; } + if (distance(vec2(topLeft[0], bottomRight[1]), pixCoord + vec2(0.75, 0.75)) < radius) { distances = distances + 1.0; } + + if (distances == 0.0) { + discard; + return; + } + + distances = distances / 4.0; + + gl_FragColor = )#" + colorVarName + R"#( * distances; + return; + } + } + } + } + else if (pixCoord[0] > bottomRight[0]) { + // we're close right + if (pixCoord[1] < topLeft[1]) { + // top + + if (ignoreCorners == 1) { + discard; + return; + } + + float topLeftDistance = distance(vec2(bottomRight[0], topLeft[1]), pixCoord); + + if (topLeftDistance > radius - 1.0) { + if (primitiveMultisample == 0 && topLeftDistance > radius) { + discard; + return; + } else if (primitiveMultisample == 1) { + float distances = 0.0; + if (distance(vec2(bottomRight[0], topLeft[1]), pixCoord + vec2(0.25, 0.25)) < radius) { distances = distances + 1.0; } + if (distance(vec2(bottomRight[0], topLeft[1]), pixCoord + vec2(0.75, 0.25)) < radius) { distances = distances + 1.0; } + if (distance(vec2(bottomRight[0], topLeft[1]), pixCoord + vec2(0.25, 0.75)) < radius) { distances = distances + 1.0; } + if (distance(vec2(bottomRight[0], topLeft[1]), pixCoord + vec2(0.75, 0.75)) < radius) { distances = distances + 1.0; } + + if (distances == 0.0) { + discard; + return; + } + + distances = distances / 4.0; + + gl_FragColor = )#" + colorVarName + R"#( * distances; + return; + } + } + } else if (pixCoord[1] > bottomRight[1]) { + // bottom + + if (ignoreCorners == 1) { + discard; + return; + } + + float topLeftDistance = distance(bottomRight, pixCoord); + + if (topLeftDistance > radius - 1.0) { + if (primitiveMultisample == 0 && topLeftDistance > radius) { + discard; + return; + } else if (primitiveMultisample == 1) { + float distances = 0.0; + if (distance(bottomRight, pixCoord + vec2(0.25, 0.25)) < radius) { distances = distances + 1.0; } + if (distance(bottomRight, pixCoord + vec2(0.75, 0.25)) < radius) { distances = distances + 1.0; } + if (distance(bottomRight, pixCoord + vec2(0.25, 0.75)) < radius) { distances = distances + 1.0; } + if (distance(bottomRight, pixCoord + vec2(0.75, 0.75)) < radius) { distances = distances + 1.0; } + + if (distances == 0.0) { + discard; + return; + } + + distances = distances / 4.0; + + gl_FragColor = )#" + colorVarName + R"#( * distances; + return; + } + } + } + } + )#"; +}; + +inline const std::string QUADVERTSRC = R"#( +uniform mat3 proj; +uniform vec4 color; +attribute vec2 pos; +attribute vec2 texcoord; +varying vec4 v_color; +varying vec2 v_texcoord; + +void main() { + gl_Position = vec4(proj * vec3(pos, 1.0), 1.0); + v_color = color; + v_texcoord = texcoord; +})#"; + +inline const std::string QUADFRAGSRC = R"#( +precision mediump float; +varying vec4 v_color; +varying vec2 v_texcoord; + +uniform vec2 topLeft; +uniform vec2 bottomRight; +uniform vec2 fullSize; +uniform float radius; + +uniform int primitiveMultisample; +uniform int ignoreCorners; + +void main() { + if (radius == 0.0) { + gl_FragColor = v_color; + return; + } + + vec2 pixCoord = fullSize * v_texcoord; + + )#" + ROUNDED_SHADER_FUNC("v_color") + R"#( + + gl_FragColor = v_color; +})#"; + +inline const std::string TEXVERTSRC = R"#( +uniform mat3 proj; +attribute vec2 pos; +attribute vec2 texcoord; +varying vec2 v_texcoord; + +void main() { + gl_Position = vec4(proj * vec3(pos, 1.0), 1.0); + v_texcoord = texcoord; +})#"; + +inline const std::string TEXFRAGSRCRGBA = R"#( +precision mediump float; +varying vec2 v_texcoord; // is in 0-1 +uniform sampler2D tex; +uniform float alpha; + +uniform vec2 topLeft; +uniform vec2 bottomRight; +uniform vec2 fullSize; +uniform float radius; + +uniform int discardOpaque; + +uniform int primitiveMultisample; +uniform int ignoreCorners; + +void main() { + + vec4 pixColor = texture2D(tex, v_texcoord); + + if (discardOpaque == 1 && pixColor[3] * alpha == 1.0) { + discard; + return; + } + + vec2 pixCoord = fullSize * v_texcoord; + + )#" + ROUNDED_SHADER_FUNC("pixColor") + + R"#( + + gl_FragColor = pixColor * alpha; +})#"; + +inline const std::string TEXFRAGSRCRGBX = R"#( +precision mediump float; +varying vec2 v_texcoord; +uniform sampler2D tex; +uniform float alpha; + +uniform vec2 topLeft; +uniform vec2 bottomRight; +uniform vec2 fullSize; +uniform float radius; + +uniform int discardOpaque; + +uniform int primitiveMultisample; +uniform int ignoreCorners; + +void main() { + + if (discardOpaque == 1 && alpha == 1.0) { + discard; + return; + } + + vec4 pixColor = vec4(texture2D(tex, v_texcoord).rgb, 1.0); + + vec2 pixCoord = fullSize * v_texcoord; + + )#" + ROUNDED_SHADER_FUNC("pixColor") + R"#( + + gl_FragColor = pixColor * alpha; +})#"; + +inline const std::string FRAGBLUR1 = R"#( +#version 100 +precision mediump float; +varying mediump vec2 v_texcoord; // is in 0-1 +uniform sampler2D tex; + +uniform float radius; +uniform vec2 halfpixel; + +void main() { + vec2 uv = v_texcoord * 2.0; + + vec4 sum = texture2D(tex, uv) * 4.0; + sum += texture2D(tex, uv - halfpixel.xy * radius); + sum += texture2D(tex, uv + halfpixel.xy * radius); + sum += texture2D(tex, uv + vec2(halfpixel.x, -halfpixel.y) * radius); + sum += texture2D(tex, uv - vec2(halfpixel.x, -halfpixel.y) * radius); + gl_FragColor = sum / 8.0; +} +)#"; + +inline const std::string FRAGBLUR2 = R"#( +#version 100 +precision mediump float; +varying mediump vec2 v_texcoord; // is in 0-1 +uniform sampler2D tex; + +uniform float radius; +uniform vec2 halfpixel; + +void main() { + vec2 uv = v_texcoord / 2.0; + + vec4 sum = texture2D(tex, uv + vec2(-halfpixel.x * 2.0, 0.0) * radius); + + sum += texture2D(tex, uv + vec2(-halfpixel.x, halfpixel.y) * radius) * 2.0; + sum += texture2D(tex, uv + vec2(0.0, halfpixel.y * 2.0) * radius); + sum += texture2D(tex, uv + vec2(halfpixel.x, halfpixel.y) * radius) * 2.0; + sum += texture2D(tex, uv + vec2(halfpixel.x * 2.0, 0.0) * radius); + sum += texture2D(tex, uv + vec2(halfpixel.x, -halfpixel.y) * radius) * 2.0; + sum += texture2D(tex, uv + vec2(0.0, -halfpixel.y * 2.0) * radius); + sum += texture2D(tex, uv + vec2(-halfpixel.x, -halfpixel.y) * radius) * 2.0; + + gl_FragColor = sum / 12.0; +} +)#"; + +inline const std::string TEXFRAGSRCEXT = R"#( +#extension GL_OES_EGL_image_external : require + +precision mediump float; +varying vec2 v_texcoord; +uniform samplerExternalOES texture0; +uniform float alpha; + +uniform vec2 topLeft; +uniform vec2 bottomRight; +uniform vec2 fullSize; +uniform float radius; + +uniform int discardOpaque; + +uniform int primitiveMultisample; +uniform int ignoreCorners; + +void main() { + + vec4 pixColor = texture2D(texture0, v_texcoord); + + if (discardOpaque == 1 && pixColor[3] * alpha == 1.0) { + discard; + return; + } + + vec2 pixCoord = fullSize * v_texcoord; + + )#" + ROUNDED_SHADER_FUNC("pixColor") + R"#( + + gl_FragColor = pixColor * alpha; +})#"; -- cgit v1.2.3 From 2955698f2833920c2356429c4cf7771ebf7e2d56 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sat, 25 Jun 2022 20:31:54 +0200 Subject: fix fade with deco --- src/render/OpenGL.cpp | 4 ++-- src/render/OpenGL.hpp | 2 +- src/render/Renderer.cpp | 2 +- src/render/decorations/CHyprDropShadowDecoration.cpp | 4 ++-- src/render/decorations/CHyprDropShadowDecoration.hpp | 2 +- src/render/decorations/CHyprGroupBarDecoration.cpp | 3 ++- src/render/decorations/CHyprGroupBarDecoration.hpp | 2 +- src/render/decorations/IHyprWindowDecoration.hpp | 2 +- 8 files changed, 11 insertions(+), 10 deletions(-) (limited to 'src/render') diff --git a/src/render/OpenGL.cpp b/src/render/OpenGL.cpp index 9951939d..e44e108b 100644 --- a/src/render/OpenGL.cpp +++ b/src/render/OpenGL.cpp @@ -864,7 +864,7 @@ void CHyprOpenGLImpl::renderSnapshot(SLayerSurface** pLayer) { pixman_region32_fini(&fakeDamage); } -void CHyprOpenGLImpl::renderRoundedShadow(wlr_box* box, int round, int range) { +void CHyprOpenGLImpl::renderRoundedShadow(wlr_box* box, int round, int range, float a) { RASSERT(m_RenderData.pMonitor, "Tried to render shadow without begin()!"); RASSERT((box->width > 0 && box->height > 0), "Tried to render shadow with width/height < 0!"); @@ -891,7 +891,7 @@ void CHyprOpenGLImpl::renderRoundedShadow(wlr_box* box, int round, int range) { glUseProgram(m_shSHADOW.program); glUniformMatrix3fv(m_shSHADOW.proj, 1, GL_FALSE, glMatrix); - glUniform4f(glGetUniformLocation(m_shSHADOW.program, "color"), col.r / 255.f, col.g / 255.f, col.b / 255.f, col.a / 255.f); + glUniform4f(glGetUniformLocation(m_shSHADOW.program, "color"), col.r / 255.f, col.g / 255.f, col.b / 255.f, col.a / 255.f * a); const auto TOPLEFT = Vector2D(range + round, range + round); const auto BOTTOMRIGHT = Vector2D(box->width - (range + round), box->height - (range + round)); diff --git a/src/render/OpenGL.hpp b/src/render/OpenGL.hpp index 5cae6486..9d6e098d 100644 --- a/src/render/OpenGL.hpp +++ b/src/render/OpenGL.hpp @@ -61,7 +61,7 @@ public: void renderTexture(wlr_texture*, wlr_box*, float a, int round = 0); void renderTexture(const CTexture&, wlr_box*, float a, int round = 0, bool discardOpaque = false, bool border = false, bool allowPrimary = false); void renderTextureWithBlur(const CTexture&, wlr_box*, float a, wlr_surface* pSurface, int round = 0, bool border = false); - void renderRoundedShadow(wlr_box*, int round, int range); + void renderRoundedShadow(wlr_box*, int round, int range, float a = 1.0); void makeWindowSnapshot(CWindow*); void makeLayerSnapshot(SLayerSurface*); diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 5d99565b..affb49ff 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -168,7 +168,7 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, SMonitor* pMonitor, timespec* // render window decorations first for (auto& wd : pWindow->m_dWindowDecorations) - wd->draw(pMonitor); + wd->draw(pMonitor, renderdata.alpha * renderdata.fadeAlpha / 255.f); if (!pWindow->m_bIsX11) { diff --git a/src/render/decorations/CHyprDropShadowDecoration.cpp b/src/render/decorations/CHyprDropShadowDecoration.cpp index 528e00cf..6933e687 100644 --- a/src/render/decorations/CHyprDropShadowDecoration.cpp +++ b/src/render/decorations/CHyprDropShadowDecoration.cpp @@ -37,7 +37,7 @@ void CHyprDropShadowDecoration::updateWindow(CWindow* pWindow) { damageEntire(); } -void CHyprDropShadowDecoration::draw(SMonitor* pMonitor) { +void CHyprDropShadowDecoration::draw(SMonitor* pMonitor, float a) { if (!g_pCompositor->windowValidMapped(m_pWindow)) return; @@ -62,5 +62,5 @@ void CHyprDropShadowDecoration::draw(SMonitor* pMonitor) { fullBox.x -= pMonitor->vecPosition.x; fullBox.y -= pMonitor->vecPosition.y; - g_pHyprOpenGL->renderRoundedShadow(&fullBox, *PROUNDING, *PSHADOWSIZE); + g_pHyprOpenGL->renderRoundedShadow(&fullBox, *PROUNDING, *PSHADOWSIZE, a); } diff --git a/src/render/decorations/CHyprDropShadowDecoration.hpp b/src/render/decorations/CHyprDropShadowDecoration.hpp index 2a248a2f..f734c111 100644 --- a/src/render/decorations/CHyprDropShadowDecoration.hpp +++ b/src/render/decorations/CHyprDropShadowDecoration.hpp @@ -9,7 +9,7 @@ public: virtual SWindowDecorationExtents getWindowDecorationExtents(); - virtual void draw(SMonitor*); + virtual void draw(SMonitor*, float a); virtual eDecorationType getDecorationType(); diff --git a/src/render/decorations/CHyprGroupBarDecoration.cpp b/src/render/decorations/CHyprGroupBarDecoration.cpp index 25d74065..2bb486ee 100644 --- a/src/render/decorations/CHyprGroupBarDecoration.cpp +++ b/src/render/decorations/CHyprGroupBarDecoration.cpp @@ -68,7 +68,7 @@ void CHyprGroupBarDecoration::damageEntire() { g_pHyprRenderer->damageBox(&dm); } -void CHyprGroupBarDecoration::draw(SMonitor* pMonitor) { +void CHyprGroupBarDecoration::draw(SMonitor* pMonitor, float a) { // get how many bars we will draw int barsToDraw = m_dwGroupMembers.size(); @@ -88,6 +88,7 @@ void CHyprGroupBarDecoration::draw(SMonitor* pMonitor) { break; CColor color = m_dwGroupMembers[i] == g_pCompositor->m_pLastWindow ? CColor(g_pConfigManager->getInt("dwindle:col.group_border_active")) : CColor(g_pConfigManager->getInt("dwindle:col.group_border")); + color.a *= a; g_pHyprOpenGL->renderRect(&rect, color); xoff += PAD + BARW; diff --git a/src/render/decorations/CHyprGroupBarDecoration.hpp b/src/render/decorations/CHyprGroupBarDecoration.hpp index 74a597a6..76baab65 100644 --- a/src/render/decorations/CHyprGroupBarDecoration.hpp +++ b/src/render/decorations/CHyprGroupBarDecoration.hpp @@ -10,7 +10,7 @@ public: virtual SWindowDecorationExtents getWindowDecorationExtents(); - virtual void draw(SMonitor*); + virtual void draw(SMonitor*, float a); virtual eDecorationType getDecorationType(); diff --git a/src/render/decorations/IHyprWindowDecoration.hpp b/src/render/decorations/IHyprWindowDecoration.hpp index e9011a29..21219b36 100644 --- a/src/render/decorations/IHyprWindowDecoration.hpp +++ b/src/render/decorations/IHyprWindowDecoration.hpp @@ -22,7 +22,7 @@ public: virtual SWindowDecorationExtents getWindowDecorationExtents() = 0; - virtual void draw(SMonitor*) = 0; + virtual void draw(SMonitor*, float a) = 0; virtual eDecorationType getDecorationType() = 0; -- cgit v1.2.3 From f5c2dfc706776986ab9ff81a2512cc88f8aaef19 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sun, 26 Jun 2022 13:43:32 +0200 Subject: a bit of fixes to cursor hiding --- src/render/Renderer.cpp | 7 ++++++- src/render/Renderer.hpp | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'src/render') diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index affb49ff..f7328997 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -772,7 +772,8 @@ void CHyprRenderer::ensureCursorRenderingMode() { } else if (*PCURSORTIMEOUT > PASSEDCURSORSECONDS && !m_bHasARenderedCursor) { m_bHasARenderedCursor = true; - wlr_xcursor_manager_set_cursor_image(g_pCompositor->m_sWLRXCursorMgr, "left_ptr", g_pCompositor->m_sWLRCursor); + if (!m_bWindowRequestedCursorHide) + wlr_xcursor_manager_set_cursor_image(g_pCompositor->m_sWLRXCursorMgr, "left_ptr", g_pCompositor->m_sWLRCursor); Debug::log(LOG, "Showing the cursor (timeout)"); @@ -782,4 +783,8 @@ void CHyprRenderer::ensureCursorRenderingMode() { } else { m_bHasARenderedCursor = true; } +} + +bool CHyprRenderer::shouldRenderCursor() { + return m_bHasARenderedCursor; } \ No newline at end of file diff --git a/src/render/Renderer.hpp b/src/render/Renderer.hpp index 73508623..43a241ed 100644 --- a/src/render/Renderer.hpp +++ b/src/render/Renderer.hpp @@ -32,6 +32,9 @@ public: bool shouldRenderWindow(CWindow*, SMonitor*); bool shouldRenderWindow(CWindow*); void ensureCursorRenderingMode(); + bool shouldRenderCursor(); + + bool m_bWindowRequestedCursorHide = false; DAMAGETRACKINGMODES damageTrackingModeFromStr(const std::string&); -- cgit v1.2.3