diff options
| author | Vaxry <43317083+vaxerski@users.noreply.github.com> | 2022-12-16 17:17:31 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-12-16 17:17:31 +0000 |
| commit | 98a4fa2b0d79298fa29b048a3ba15c3bf5aed8cd (patch) | |
| tree | 64e78342cf08e5f9ad87bd5f6ea36233133be7bb /src/render | |
| parent | 7c33c7fc64203c17b4f3625a16ae6b4774992c0e (diff) | |
Added clang format (#1239)
* clang-format stuff and format files
Diffstat (limited to 'src/render')
| -rw-r--r-- | src/render/Framebuffer.cpp | 18 | ||||
| -rw-r--r-- | src/render/Framebuffer.hpp | 25 | ||||
| -rw-r--r-- | src/render/OpenGL.cpp | 499 | ||||
| -rw-r--r-- | src/render/OpenGL.hpp | 155 | ||||
| -rw-r--r-- | src/render/Renderer.cpp | 468 | ||||
| -rw-r--r-- | src/render/Renderer.hpp | 32 | ||||
| -rw-r--r-- | src/render/Shader.hpp | 52 | ||||
| -rw-r--r-- | src/render/Texture.cpp | 2 | ||||
| -rw-r--r-- | src/render/Texture.hpp | 25 | ||||
| -rw-r--r-- | src/render/decorations/CHyprDropShadowDecoration.cpp | 44 | ||||
| -rw-r--r-- | src/render/decorations/CHyprDropShadowDecoration.hpp | 20 | ||||
| -rw-r--r-- | src/render/decorations/CHyprGroupBarDecoration.cpp | 19 | ||||
| -rw-r--r-- | src/render/decorations/CHyprGroupBarDecoration.hpp | 22 | ||||
| -rw-r--r-- | src/render/decorations/IHyprWindowDecoration.cpp | 4 | ||||
| -rw-r--r-- | src/render/decorations/IHyprWindowDecoration.hpp | 13 |
15 files changed, 690 insertions, 708 deletions
diff --git a/src/render/Framebuffer.cpp b/src/render/Framebuffer.cpp index a1b45fc8..32d2361b 100644 --- a/src/render/Framebuffer.cpp +++ b/src/render/Framebuffer.cpp @@ -10,7 +10,7 @@ bool CFramebuffer::alloc(int w, int h) { glGenFramebuffers(1, &m_iFb); } - if (m_cTex.m_iTexID == 0) { + if (m_cTex.m_iTexID == 0) { firstAlloc = true; glGenTextures(1, &m_cTex.m_iTexID); glBindTexture(GL_TEXTURE_2D, m_cTex.m_iTexID); @@ -27,8 +27,8 @@ bool CFramebuffer::alloc(int w, int h) { glBindFramebuffer(GL_FRAMEBUFFER, m_iFb); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_cTex.m_iTexID, 0); - // TODO: Allow this with gles2 - #ifndef GLES2 +// TODO: Allow this with gles2 +#ifndef GLES2 if (m_pStencilTex) { glBindTexture(GL_TEXTURE_2D, m_pStencilTex->m_iTexID); glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8, w, h, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, 0); @@ -37,7 +37,7 @@ bool CFramebuffer::alloc(int w, int h) { glFramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, m_pStencilTex->m_iTexID, 0); } - #endif +#endif auto status = glCheckFramebufferStatus(GL_FRAMEBUFFER); RASSERT((status == GL_FRAMEBUFFER_COMPLETE), "Framebuffer incomplete, couldn't create! (FB status: %i)", status); @@ -54,11 +54,11 @@ bool CFramebuffer::alloc(int w, int h) { } void CFramebuffer::bind() { - #ifndef GLES2 +#ifndef GLES2 glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_iFb); - #else +#else glBindFramebuffer(GL_FRAMEBUFFER, m_iFb); - #endif +#endif glViewport(0, 0, g_pHyprOpenGL->m_RenderData.pMonitor->vecPixelSize.x, g_pHyprOpenGL->m_RenderData.pMonitor->vecPixelSize.y); } @@ -72,8 +72,8 @@ void CFramebuffer::release() { } m_cTex.m_iTexID = 0; - m_iFb = -1; - m_Size = Vector2D(); + m_iFb = -1; + m_Size = Vector2D(); } CFramebuffer::~CFramebuffer() { diff --git a/src/render/Framebuffer.hpp b/src/render/Framebuffer.hpp index 2d1e621c..9dacbce3 100644 --- a/src/render/Framebuffer.hpp +++ b/src/render/Framebuffer.hpp @@ -4,24 +4,23 @@ #include "Texture.hpp" class CFramebuffer { -public: - + public: ~CFramebuffer(); - bool alloc(int w, int h); - void bind(); - void release(); - void reset(); - bool isAllocated(); + bool alloc(int w, int h); + void bind(); + void release(); + void reset(); + bool isAllocated(); - Vector2D m_Position; - Vector2D m_Size; - float m_fScale = 1; + Vector2D m_Position; + Vector2D m_Size; + float m_fScale = 1; - CTexture m_cTex; - GLuint m_iFb = -1; + CTexture m_cTex; + GLuint m_iFb = -1; - CTexture* m_pStencilTex = nullptr; + CTexture* m_pStencilTex = nullptr; wl_output_transform m_tTransform; // for saving state };
\ No newline at end of file diff --git a/src/render/OpenGL.cpp b/src/render/OpenGL.cpp index c67f8a49..70a0aa3a 100644 --- a/src/render/OpenGL.cpp +++ b/src/render/OpenGL.cpp @@ -5,9 +5,10 @@ #include "Shaders.hpp" CHyprOpenGLImpl::CHyprOpenGLImpl() { - RASSERT(eglMakeCurrent(wlr_egl_get_display(g_pCompositor->m_sWLREGL), EGL_NO_SURFACE, EGL_NO_SURFACE, wlr_egl_get_context(g_pCompositor->m_sWLREGL)), "Couldn't unset current EGL!"); + RASSERT(eglMakeCurrent(wlr_egl_get_display(g_pCompositor->m_sWLREGL), EGL_NO_SURFACE, EGL_NO_SURFACE, wlr_egl_get_context(g_pCompositor->m_sWLREGL)), + "Couldn't unset current EGL!"); - auto *const EXTENSIONS = (const char*)glGetString(GL_EXTENSIONS); + auto* const EXTENSIONS = (const char*)glGetString(GL_EXTENSIONS); RASSERT(EXTENSIONS, "Couldn't retrieve openGL extensions!"); @@ -21,9 +22,9 @@ CHyprOpenGLImpl::CHyprOpenGLImpl() { Debug::log(LOG, "Renderer: %s", glGetString(GL_RENDERER)); Debug::log(LOG, "Supported extensions size: %d", std::count(m_szExtensions.begin(), m_szExtensions.end(), ' ')); - #ifdef GLES2 +#ifdef GLES2 Debug::log(WARN, "!RENDERER: Using the legacy GLES2 renderer!"); - #endif +#endif pixman_region32_init(&m_rOriginalDamageRegion); @@ -111,8 +112,8 @@ void CHyprOpenGLImpl::begin(CMonitor* pMonitor, pixman_region32_t* pDamage, bool if (m_mMonitorRenderResources.find(pMonitor) == m_mMonitorRenderResources.end() || m_RenderData.pCurrentMonData->primaryFB.m_Size != pMonitor->vecPixelSize) { m_RenderData.pCurrentMonData->stencilTex.allocate(); - m_RenderData.pCurrentMonData->primaryFB.m_pStencilTex = &m_RenderData.pCurrentMonData->stencilTex; - m_RenderData.pCurrentMonData->mirrorFB.m_pStencilTex = &m_RenderData.pCurrentMonData->stencilTex; + m_RenderData.pCurrentMonData->primaryFB.m_pStencilTex = &m_RenderData.pCurrentMonData->stencilTex; + m_RenderData.pCurrentMonData->mirrorFB.m_pStencilTex = &m_RenderData.pCurrentMonData->stencilTex; m_RenderData.pCurrentMonData->mirrorSwapFB.m_pStencilTex = &m_RenderData.pCurrentMonData->stencilTex; m_RenderData.pCurrentMonData->primaryFB.alloc(pMonitor->vecPixelSize.x, pMonitor->vecPixelSize.y); @@ -145,132 +146,132 @@ void CHyprOpenGLImpl::end() { pixman_region32_copy(m_RenderData.pDamage, &m_rOriginalDamageRegion); if (!m_RenderData.pMonitor->mirrors.empty()) - g_pHyprOpenGL->saveBufferForMirror(); // save with original damage region + g_pHyprOpenGL->saveBufferForMirror(); // save with original damage region glBindFramebuffer(GL_FRAMEBUFFER, m_iWLROutputFb); wlr_box monbox = {0, 0, m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y}; clear(CColor(11, 11, 11, 255)); - m_bEndFrame = true; + m_bEndFrame = true; m_bApplyFinalShader = true; renderTexture(m_RenderData.pCurrentMonData->primaryFB.m_cTex, &monbox, 255.f, 0); m_bApplyFinalShader = false; - m_bEndFrame = false; + m_bEndFrame = false; } // reset our data m_RenderData.pMonitor = nullptr; - m_iWLROutputFb = 0; + m_iWLROutputFb = 0; } void CHyprOpenGLImpl::initShaders() { - GLuint prog = createProgram(QUADVERTSRC, QUADFRAGSRC); - m_RenderData.pCurrentMonData->m_shQUAD.program = prog; - m_RenderData.pCurrentMonData->m_shQUAD.proj = glGetUniformLocation(prog, "proj"); - m_RenderData.pCurrentMonData->m_shQUAD.color = glGetUniformLocation(prog, "color"); - m_RenderData.pCurrentMonData->m_shQUAD.posAttrib = glGetAttribLocation(prog, "pos"); - m_RenderData.pCurrentMonData->m_shQUAD.topLeft = glGetUniformLocation(prog, "topLeft"); - m_RenderData.pCurrentMonData->m_shQUAD.fullSize = glGetUniformLocation(prog, "fullSize"); - m_RenderData.pCurrentMonData->m_shQUAD.radius = glGetUniformLocation(prog, "radius"); + GLuint prog = createProgram(QUADVERTSRC, QUADFRAGSRC); + m_RenderData.pCurrentMonData->m_shQUAD.program = prog; + m_RenderData.pCurrentMonData->m_shQUAD.proj = glGetUniformLocation(prog, "proj"); + m_RenderData.pCurrentMonData->m_shQUAD.color = glGetUniformLocation(prog, "color"); + m_RenderData.pCurrentMonData->m_shQUAD.posAttrib = glGetAttribLocation(prog, "pos"); + m_RenderData.pCurrentMonData->m_shQUAD.topLeft = glGetUniformLocation(prog, "topLeft"); + m_RenderData.pCurrentMonData->m_shQUAD.fullSize = glGetUniformLocation(prog, "fullSize"); + m_RenderData.pCurrentMonData->m_shQUAD.radius = glGetUniformLocation(prog, "radius"); m_RenderData.pCurrentMonData->m_shQUAD.primitiveMultisample = glGetUniformLocation(prog, "primitiveMultisample"); - prog = createProgram(TEXVERTSRC, TEXFRAGSRCRGBA); - m_RenderData.pCurrentMonData->m_shRGBA.program = prog; - m_RenderData.pCurrentMonData->m_shRGBA.proj = glGetUniformLocation(prog, "proj"); - m_RenderData.pCurrentMonData->m_shRGBA.tex = glGetUniformLocation(prog, "tex"); - m_RenderData.pCurrentMonData->m_shRGBA.alpha = glGetUniformLocation(prog, "alpha"); - m_RenderData.pCurrentMonData->m_shRGBA.texAttrib = glGetAttribLocation(prog, "texcoord"); - m_RenderData.pCurrentMonData->m_shRGBA.posAttrib = glGetAttribLocation(prog, "pos"); - m_RenderData.pCurrentMonData->m_shRGBA.discardOpaque = glGetUniformLocation(prog, "discardOpaque"); - m_RenderData.pCurrentMonData->m_shRGBA.topLeft = glGetUniformLocation(prog, "topLeft"); - m_RenderData.pCurrentMonData->m_shRGBA.fullSize = glGetUniformLocation(prog, "fullSize"); - m_RenderData.pCurrentMonData->m_shRGBA.radius = glGetUniformLocation(prog, "radius"); + prog = createProgram(TEXVERTSRC, TEXFRAGSRCRGBA); + m_RenderData.pCurrentMonData->m_shRGBA.program = prog; + m_RenderData.pCurrentMonData->m_shRGBA.proj = glGetUniformLocation(prog, "proj"); + m_RenderData.pCurrentMonData->m_shRGBA.tex = glGetUniformLocation(prog, "tex"); + m_RenderData.pCurrentMonData->m_shRGBA.alpha = glGetUniformLocation(prog, "alpha"); + m_RenderData.pCurrentMonData->m_shRGBA.texAttrib = glGetAttribLocation(prog, "texcoord"); + m_RenderData.pCurrentMonData->m_shRGBA.posAttrib = glGetAttribLocation(prog, "pos"); + m_RenderData.pCurrentMonData->m_shRGBA.discardOpaque = glGetUniformLocation(prog, "discardOpaque"); + m_RenderData.pCurrentMonData->m_shRGBA.topLeft = glGetUniformLocation(prog, "topLeft"); + m_RenderData.pCurrentMonData->m_shRGBA.fullSize = glGetUniformLocation(prog, "fullSize"); + m_RenderData.pCurrentMonData->m_shRGBA.radius = glGetUniformLocation(prog, "radius"); m_RenderData.pCurrentMonData->m_shRGBA.primitiveMultisample = glGetUniformLocation(prog, "primitiveMultisample"); - m_RenderData.pCurrentMonData->m_shRGBA.applyTint = glGetUniformLocation(prog, "applyTint"); - m_RenderData.pCurrentMonData->m_shRGBA.tint = glGetUniformLocation(prog, "tint"); - - prog = createProgram(TEXVERTSRC, TEXFRAGSRCRGBX); - m_RenderData.pCurrentMonData->m_shRGBX.program = prog; - m_RenderData.pCurrentMonData->m_shRGBX.tex = glGetUniformLocation(prog, "tex"); - m_RenderData.pCurrentMonData->m_shRGBX.proj = glGetUniformLocation(prog, "proj"); - m_RenderData.pCurrentMonData->m_shRGBX.alpha = glGetUniformLocation(prog, "alpha"); - m_RenderData.pCurrentMonData->m_shRGBX.texAttrib = glGetAttribLocation(prog, "texcoord"); - m_RenderData.pCurrentMonData->m_shRGBX.posAttrib = glGetAttribLocation(prog, "pos"); - m_RenderData.pCurrentMonData->m_shRGBX.discardOpaque = glGetUniformLocation(prog, "discardOpaque"); - m_RenderData.pCurrentMonData->m_shRGBX.topLeft = glGetUniformLocation(prog, "topLeft"); - m_RenderData.pCurrentMonData->m_shRGBX.fullSize = glGetUniformLocation(prog, "fullSize"); - m_RenderData.pCurrentMonData->m_shRGBX.radius = glGetUniformLocation(prog, "radius"); + m_RenderData.pCurrentMonData->m_shRGBA.applyTint = glGetUniformLocation(prog, "applyTint"); + m_RenderData.pCurrentMonData->m_shRGBA.tint = glGetUniformLocation(prog, "tint"); + + prog = createProgram(TEXVERTSRC, TEXFRAGSRCRGBX); + m_RenderData.pCurrentMonData->m_shRGBX.program = prog; + m_RenderData.pCurrentMonData->m_shRGBX.tex = glGetUniformLocation(prog, "tex"); + m_RenderData.pCurrentMonData->m_shRGBX.proj = glGetUniformLocation(prog, "proj"); + m_RenderData.pCurrentMonData->m_shRGBX.alpha = glGetUniformLocation(prog, "alpha"); + m_RenderData.pCurrentMonData->m_shRGBX.texAttrib = glGetAttribLocation(prog, "texcoord"); + m_RenderData.pCurrentMonData->m_shRGBX.posAttrib = glGetAttribLocation(prog, "pos"); + m_RenderData.pCurrentMonData->m_shRGBX.discardOpaque = glGetUniformLocation(prog, "discardOpaque"); + m_RenderData.pCurrentMonData->m_shRGBX.topLeft = glGetUniformLocation(prog, "topLeft"); + m_RenderData.pCurrentMonData->m_shRGBX.fullSize = glGetUniformLocation(prog, "fullSize"); + m_RenderData.pCurrentMonData->m_shRGBX.radius = glGetUniformLocation(prog, "radius"); m_RenderData.pCurrentMonData->m_shRGBX.primitiveMultisample = glGetUniformLocation(prog, "primitiveMultisample"); - m_RenderData.pCurrentMonData->m_shRGBX.applyTint = glGetUniformLocation(prog, "applyTint"); - m_RenderData.pCurrentMonData->m_shRGBX.tint = glGetUniformLocation(prog, "tint"); - - prog = createProgram(TEXVERTSRC, TEXFRAGSRCEXT); - m_RenderData.pCurrentMonData->m_shEXT.program = prog; - m_RenderData.pCurrentMonData->m_shEXT.tex = glGetUniformLocation(prog, "tex"); - m_RenderData.pCurrentMonData->m_shEXT.proj = glGetUniformLocation(prog, "proj"); - m_RenderData.pCurrentMonData->m_shEXT.alpha = glGetUniformLocation(prog, "alpha"); - m_RenderData.pCurrentMonData->m_shEXT.posAttrib = glGetAttribLocation(prog, "pos"); - m_RenderData.pCurrentMonData->m_shEXT.texAttrib = glGetAttribLocation(prog, "texcoord"); - m_RenderData.pCurrentMonData->m_shEXT.discardOpaque = glGetUniformLocation(prog, "discardOpaque"); - m_RenderData.pCurrentMonData->m_shEXT.topLeft = glGetUniformLocation(prog, "topLeft"); - m_RenderData.pCurrentMonData->m_shEXT.fullSize = glGetUniformLocation(prog, "fullSize"); - m_RenderData.pCurrentMonData->m_shEXT.radius = glGetUniformLocation(prog, "radius"); + m_RenderData.pCurrentMonData->m_shRGBX.applyTint = glGetUniformLocation(prog, "applyTint"); + m_RenderData.pCurrentMonData->m_shRGBX.tint = glGetUniformLocation(prog, "tint"); + + prog = createProgram(TEXVERTSRC, TEXFRAGSRCEXT); + m_RenderData.pCurrentMonData->m_shEXT.program = prog; + m_RenderData.pCurrentMonData->m_shEXT.tex = glGetUniformLocation(prog, "tex"); + m_RenderData.pCurrentMonData->m_shEXT.proj = glGetUniformLocation(prog, "proj"); + m_RenderData.pCurrentMonData->m_shEXT.alpha = glGetUniformLocation(prog, "alpha"); + m_RenderData.pCurrentMonData->m_shEXT.posAttrib = glGetAttribLocation(prog, "pos"); + m_RenderData.pCurrentMonData->m_shEXT.texAttrib = glGetAttribLocation(prog, "texcoord"); + m_RenderData.pCurrentMonData->m_shEXT.discardOpaque = glGetUniformLocation(prog, "discardOpaque"); + m_RenderData.pCurrentMonData->m_shEXT.topLeft = glGetUniformLocation(prog, "topLeft"); + m_RenderData.pCurrentMonData->m_shEXT.fullSize = glGetUniformLocation(prog, "fullSize"); + m_RenderData.pCurrentMonData->m_shEXT.radius = glGetUniformLocation(prog, "radius"); m_RenderData.pCurrentMonData->m_shEXT.primitiveMultisample = glGetUniformLocation(prog, "primitiveMultisample"); - m_RenderData.pCurrentMonData->m_shEXT.applyTint = glGetUniformLocation(prog, "applyTint"); - m_RenderData.pCurrentMonData->m_shEXT.tint = glGetUniformLocation(prog, "tint"); - - prog = createProgram(TEXVERTSRC, FRAGBLUR1); - m_RenderData.pCurrentMonData->m_shBLUR1.program = prog; - m_RenderData.pCurrentMonData->m_shBLUR1.tex = glGetUniformLocation(prog, "tex"); - m_RenderData.pCurrentMonData->m_shBLUR1.alpha = glGetUniformLocation(prog, "alpha"); - m_RenderData.pCurrentMonData->m_shBLUR1.proj = glGetUniformLocation(prog, "proj"); + m_RenderData.pCurrentMonData->m_shEXT.applyTint = glGetUniformLocation(prog, "applyTint"); + m_RenderData.pCurrentMonData->m_shEXT.tint = glGetUniformLocation(prog, "tint"); + + prog = createProgram(TEXVERTSRC, FRAGBLUR1); + m_RenderData.pCurrentMonData->m_shBLUR1.program = prog; + m_RenderData.pCurrentMonData->m_shBLUR1.tex = glGetUniformLocation(prog, "tex"); + m_RenderData.pCurrentMonData->m_shBLUR1.alpha = glGetUniformLocation(prog, "alpha"); + m_RenderData.pCurrentMonData->m_shBLUR1.proj = glGetUniformLocation(prog, "proj"); m_RenderData.pCurrentMonData->m_shBLUR1.posAttrib = glGetAttribLocation(prog, "pos"); m_RenderData.pCurrentMonData->m_shBLUR1.texAttrib = glGetAttribLocation(prog, "texcoord"); - m_RenderData.pCurrentMonData->m_shBLUR1.radius = glGetUniformLocation(prog, "radius"); + m_RenderData.pCurrentMonData->m_shBLUR1.radius = glGetUniformLocation(prog, "radius"); m_RenderData.pCurrentMonData->m_shBLUR1.halfpixel = glGetUniformLocation(prog, "halfpixel"); - prog = createProgram(TEXVERTSRC, FRAGBLUR2); - m_RenderData.pCurrentMonData->m_shBLUR2.program = prog; - m_RenderData.pCurrentMonData->m_shBLUR2.tex = glGetUniformLocation(prog, "tex"); - m_RenderData.pCurrentMonData->m_shBLUR2.alpha = glGetUniformLocation(prog, "alpha"); - m_RenderData.pCurrentMonData->m_shBLUR2.proj = glGetUniformLocation(prog, "proj"); + prog = createProgram(TEXVERTSRC, FRAGBLUR2); + m_RenderData.pCurrentMonData->m_shBLUR2.program = prog; + m_RenderData.pCurrentMonData->m_shBLUR2.tex = glGetUniformLocation(prog, "tex"); + m_RenderData.pCurrentMonData->m_shBLUR2.alpha = glGetUniformLocation(prog, "alpha"); + m_RenderData.pCurrentMonData->m_shBLUR2.proj = glGetUniformLocation(prog, "proj"); m_RenderData.pCurrentMonData->m_shBLUR2.posAttrib = glGetAttribLocation(prog, "pos"); m_RenderData.pCurrentMonData->m_shBLUR2.texAttrib = glGetAttribLocation(prog, "texcoord"); - m_RenderData.pCurrentMonData->m_shBLUR2.radius = glGetUniformLocation(prog, "radius"); + m_RenderData.pCurrentMonData->m_shBLUR2.radius = glGetUniformLocation(prog, "radius"); m_RenderData.pCurrentMonData->m_shBLUR2.halfpixel = glGetUniformLocation(prog, "halfpixel"); - prog = createProgram(QUADVERTSRC, FRAGSHADOW); - m_RenderData.pCurrentMonData->m_shSHADOW.program = prog; - m_RenderData.pCurrentMonData->m_shSHADOW.proj = glGetUniformLocation(prog, "proj"); - m_RenderData.pCurrentMonData->m_shSHADOW.posAttrib = glGetAttribLocation(prog, "pos"); - m_RenderData.pCurrentMonData->m_shSHADOW.texAttrib = glGetAttribLocation(prog, "texcoord"); - m_RenderData.pCurrentMonData->m_shSHADOW.topLeft = glGetUniformLocation(prog, "topLeft"); + prog = createProgram(QUADVERTSRC, FRAGSHADOW); + m_RenderData.pCurrentMonData->m_shSHADOW.program = prog; + m_RenderData.pCurrentMonData->m_shSHADOW.proj = glGetUniformLocation(prog, "proj"); + m_RenderData.pCurrentMonData->m_shSHADOW.posAttrib = glGetAttribLocation(prog, "pos"); + m_RenderData.pCurrentMonData->m_shSHADOW.texAttrib = glGetAttribLocation(prog, "texcoord"); + m_RenderData.pCurrentMonData->m_shSHADOW.topLeft = glGetUniformLocation(prog, "topLeft"); m_RenderData.pCurrentMonData->m_shSHADOW.bottomRight = glGetUniformLocation(prog, "bottomRight"); - m_RenderData.pCurrentMonData->m_shSHADOW.fullSize = glGetUniformLocation(prog, "fullSize"); - m_RenderData.pCurrentMonData->m_shSHADOW.radius = glGetUniformLocation(prog, "radius"); - m_RenderData.pCurrentMonData->m_shSHADOW.range = glGetUniformLocation(prog, "range"); + m_RenderData.pCurrentMonData->m_shSHADOW.fullSize = glGetUniformLocation(prog, "fullSize"); + m_RenderData.pCurrentMonData->m_shSHADOW.radius = glGetUniformLocation(prog, "radius"); + m_RenderData.pCurrentMonData->m_shSHADOW.range = glGetUniformLocation(prog, "range"); m_RenderData.pCurrentMonData->m_shSHADOW.shadowPower = glGetUniformLocation(prog, "shadowPower"); - m_RenderData.pCurrentMonData->m_shSHADOW.color = glGetUniformLocation(prog, "color"); - - prog = createProgram(QUADVERTSRC, FRAGBORDER1); - m_RenderData.pCurrentMonData->m_shBORDER1.program = prog; - m_RenderData.pCurrentMonData->m_shBORDER1.proj = glGetUniformLocation(prog, "proj"); - m_RenderData.pCurrentMonData->m_shBORDER1.thick = glGetUniformLocation(prog, "thick"); - m_RenderData.pCurrentMonData->m_shBORDER1.posAttrib = glGetAttribLocation(prog, "pos"); - m_RenderData.pCurrentMonData->m_shBORDER1.texAttrib = glGetAttribLocation(prog, "texcoord"); - m_RenderData.pCurrentMonData->m_shBORDER1.topLeft = glGetUniformLocation(prog, "topLeft"); - m_RenderData.pCurrentMonData->m_shBORDER1.bottomRight = glGetUniformLocation(prog, "bottomRight"); - m_RenderData.pCurrentMonData->m_shBORDER1.fullSize = glGetUniformLocation(prog, "fullSize"); + m_RenderData.pCurrentMonData->m_shSHADOW.color = glGetUniformLocation(prog, "color"); + + prog = createProgram(QUADVERTSRC, FRAGBORDER1); + m_RenderData.pCurrentMonData->m_shBORDER1.program = prog; + m_RenderData.pCurrentMonData->m_shBORDER1.proj = glGetUniformLocation(prog, "proj"); + m_RenderData.pCurrentMonData->m_shBORDER1.thick = glGetUniformLocation(prog, "thick"); + m_RenderData.pCurrentMonData->m_shBORDER1.posAttrib = glGetAttribLocation(prog, "pos"); + m_RenderData.pCurrentMonData->m_shBORDER1.texAttrib = glGetAttribLocation(prog, "texcoord"); + m_RenderData.pCurrentMonData->m_shBORDER1.topLeft = glGetUniformLocation(prog, "topLeft"); + m_RenderData.pCurrentMonData->m_shBORDER1.bottomRight = glGetUniformLocation(prog, "bottomRight"); + m_RenderData.pCurrentMonData->m_shBORDER1.fullSize = glGetUniformLocation(prog, "fullSize"); m_RenderData.pCurrentMonData->m_shBORDER1.fullSizeUntransformed = glGetUniformLocation(prog, "fullSizeUntransformed"); - m_RenderData.pCurrentMonData->m_shBORDER1.radius = glGetUniformLocation(prog, "radius"); - m_RenderData.pCurrentMonData->m_shBORDER1.primitiveMultisample = glGetUniformLocation(prog, "primitiveMultisample"); - m_RenderData.pCurrentMonData->m_shBORDER1.gradient = glGetUniformLocation(prog, "gradient"); - m_RenderData.pCurrentMonData->m_shBORDER1.gradientLength = glGetUniformLocation(prog, "gradientLength"); - m_RenderData.pCurrentMonData->m_shBORDER1.angle = glGetUniformLocation(prog, "angle"); - m_RenderData.pCurrentMonData->m_shBORDER1.alpha = glGetUniformLocation(prog, "alpha"); + m_RenderData.pCurrentMonData->m_shBORDER1.radius = glGetUniformLocation(prog, "radius"); + m_RenderData.pCurrentMonData->m_shBORDER1.primitiveMultisample = glGetUniformLocation(prog, "primitiveMultisample"); + m_RenderData.pCurrentMonData->m_shBORDER1.gradient = glGetUniformLocation(prog, "gradient"); + m_RenderData.pCurrentMonData->m_shBORDER1.gradientLength = glGetUniformLocation(prog, "gradientLength"); + m_RenderData.pCurrentMonData->m_shBORDER1.angle = glGetUniformLocation(prog, "angle"); + m_RenderData.pCurrentMonData->m_shBORDER1.alpha = glGetUniformLocation(prog, "alpha"); m_RenderData.pCurrentMonData->m_bShadersInitialized = true; @@ -294,14 +295,14 @@ void CHyprOpenGLImpl::applyScreenShader(const std::string& path) { std::string fragmentShader((std::istreambuf_iterator<char>(infile)), (std::istreambuf_iterator<char>())); m_sFinalScreenShader.program = createProgram(TEXVERTSRC, fragmentShader, true); - + if (!m_sFinalScreenShader.program) { g_pConfigManager->addParseError("Screen shader parser: Screen shader parse failed"); return; } - m_sFinalScreenShader.proj = glGetUniformLocation(m_sFinalScreenShader.program, "proj"); - m_sFinalScreenShader.tex = glGetUniformLocation(m_sFinalScreenShader.program, "tex"); + m_sFinalScreenShader.proj = glGetUniformLocation(m_sFinalScreenShader.program, "proj"); + m_sFinalScreenShader.tex = glGetUniformLocation(m_sFinalScreenShader.program, "tex"); m_sFinalScreenShader.texAttrib = glGetAttribLocation(m_sFinalScreenShader.program, "texcoord"); m_sFinalScreenShader.posAttrib = glGetAttribLocation(m_sFinalScreenShader.program, "pos"); } @@ -359,13 +360,13 @@ void CHyprOpenGLImpl::scissor(const pixman_box32* pBox, bool transform) { } void CHyprOpenGLImpl::scissor(const int x, const int y, const int w, const int h, bool transform) { - wlr_box box = {x,y,w,h}; + wlr_box box = {x, y, w, h}; scissor(&box, transform); } void CHyprOpenGLImpl::renderRect(wlr_box* box, const CColor& col, int round) { - if(pixman_region32_not_empty(m_RenderData.pDamage)) - renderRectWithDamage(box, col, m_RenderData.pDamage, round); + if (pixman_region32_not_empty(m_RenderData.pDamage)) + renderRectWithDamage(box, col, m_RenderData.pDamage, round); } void CHyprOpenGLImpl::renderRectWithDamage(wlr_box* box, const CColor& col, pixman_region32_t* damage, int round) { @@ -373,7 +374,8 @@ void CHyprOpenGLImpl::renderRectWithDamage(wlr_box* box, const CColor& col, pixm RASSERT(m_RenderData.pMonitor, "Tried to render rect without begin()!"); 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 + 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); @@ -392,13 +394,13 @@ void CHyprOpenGLImpl::renderRectWithDamage(wlr_box* box, const CColor& col, pixm glUniform4f(m_RenderData.pCurrentMonData->m_shQUAD.color, col.r / 255.f, col.g / 255.f, col.b / 255.f, col.a / 255.f); wlr_box transformedBox; - wlr_box_transform(&transformedBox, box, wlr_output_transform_invert(m_RenderData.pMonitor->transform), - m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y); + wlr_box_transform(&transformedBox, box, wlr_output_transform_invert(m_RenderData.pMonitor->transform), m_RenderData.pMonitor->vecTransformedSize.x, + m_RenderData.pMonitor->vecTransformedSize.y); - const auto TOPLEFT = Vector2D(transformedBox.x, transformedBox.y); - const auto FULLSIZE = Vector2D(transformedBox.width, transformedBox.height); + const auto TOPLEFT = Vector2D(transformedBox.x, transformedBox.y); + const auto FULLSIZE = Vector2D(transformedBox.width, transformedBox.height); - static auto *const PMULTISAMPLEEDGES = &g_pConfigManager->getConfigValuePtr("decoration:multisample_edges")->intValue; + static auto* const PMULTISAMPLEEDGES = &g_pConfigManager->getConfigValuePtr("decoration:multisample_edges")->intValue; // Rounded corners glUniform2f(m_RenderData.pCurrentMonData->m_shQUAD.topLeft, (float)TOPLEFT.x, (float)TOPLEFT.y); @@ -425,13 +427,13 @@ void CHyprOpenGLImpl::renderRectWithDamage(wlr_box* box, const CColor& col, pixm } } - pixman_region32_fini(&damageClip); + pixman_region32_fini(&damageClip); } else { - PIXMAN_DAMAGE_FOREACH(damage) { - const auto RECT = RECTSARR[i]; - scissor(&RECT); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - } + PIXMAN_DAMAGE_FOREACH(damage) { + const auto RECT = RECTSARR[i]; + scissor(&RECT); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + } } glDisableVertexAttribArray(m_RenderData.pCurrentMonData->m_shQUAD.posAttrib); @@ -454,18 +456,19 @@ void CHyprOpenGLImpl::renderTexture(const CTexture& tex, wlr_box* pBox, float al scissor((wlr_box*)nullptr); } -void CHyprOpenGLImpl::renderTextureInternalWithDamage(const CTexture& tex, wlr_box* pBox, float alpha, pixman_region32_t* damage, int round, bool discardOpaque, bool noAA, bool allowCustomUV, bool allowDim) { +void CHyprOpenGLImpl::renderTextureInternalWithDamage(const CTexture& tex, wlr_box* pBox, float alpha, pixman_region32_t* damage, int round, bool discardOpaque, bool noAA, + bool allowCustomUV, bool allowDim) { RASSERT(m_RenderData.pMonitor, "Tried to render texture without begin()!"); RASSERT((tex.m_iTexID > 0), "Attempted to draw NULL texture!"); if (!pixman_region32_not_empty(m_RenderData.pDamage)) - return; + return; - static auto *const PDIMINACTIVE = &g_pConfigManager->getConfigValuePtr("decoration:dim_inactive")->intValue; + static auto* const PDIMINACTIVE = &g_pConfigManager->getConfigValuePtr("decoration:dim_inactive")->intValue; // get transform const auto TRANSFORM = wlr_output_transform_invert(!m_bEndFrame ? WL_OUTPUT_TRANSFORM_NORMAL : m_RenderData.pMonitor->transform); - float matrix[9]; + float matrix[9]; wlr_matrix_project_box(matrix, pBox, TRANSFORM, 0, m_RenderData.pMonitor->output->transform_matrix); float glMatrix[9]; @@ -479,21 +482,14 @@ void CHyprOpenGLImpl::renderTextureInternalWithDamage(const CTexture& tex, wlr_b bool usingFinalShader = false; if (m_bApplyFinalShader && m_sFinalScreenShader.program) { - shader = &m_sFinalScreenShader; + shader = &m_sFinalScreenShader; usingFinalShader = true; } else { switch (tex.m_iType) { - case TEXTURE_RGBA: - shader = &m_RenderData.pCurrentMonData->m_shRGBA; - break; - case TEXTURE_RGBX: - shader = &m_RenderData.pCurrentMonData->m_shRGBX; - break; - case TEXTURE_EXTERNAL: - shader = &m_RenderData.pCurrentMonData->m_shEXT; - break; - default: - RASSERT(false, "tex.m_iTarget unsupported!"); + case TEXTURE_RGBA: shader = &m_RenderData.pCurrentMonData->m_shRGBA; break; + case TEXTURE_RGBX: shader = &m_RenderData.pCurrentMonData->m_shRGBX; break; + case TEXTURE_EXTERNAL: shader = &m_RenderData.pCurrentMonData->m_shEXT; break; + default: RASSERT(false, "tex.m_iTarget unsupported!"); } } @@ -517,12 +513,12 @@ void CHyprOpenGLImpl::renderTextureInternalWithDamage(const CTexture& tex, wlr_b } wlr_box transformedBox; - wlr_box_transform(&transformedBox, pBox, wlr_output_transform_invert(m_RenderData.pMonitor->transform), - m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y); + wlr_box_transform(&transformedBox, pBox, wlr_output_transform_invert(m_RenderData.pMonitor->transform), m_RenderData.pMonitor->vecTransformedSize.x, + m_RenderData.pMonitor->vecTransformedSize.y); - const auto TOPLEFT = Vector2D(transformedBox.x, transformedBox.y); - const auto FULLSIZE = Vector2D(transformedBox.width, transformedBox.height); - static auto *const PMULTISAMPLEEDGES = &g_pConfigManager->getConfigValuePtr("decoration:multisample_edges")->intValue; + const auto TOPLEFT = Vector2D(transformedBox.x, transformedBox.y); + const auto FULLSIZE = Vector2D(transformedBox.width, transformedBox.height); + static auto* const PMULTISAMPLEEDGES = &g_pConfigManager->getConfigValuePtr("decoration:multisample_edges")->intValue; if (!usingFinalShader) { // Rounded corners @@ -541,10 +537,10 @@ void CHyprOpenGLImpl::renderTextureInternalWithDamage(const CTexture& tex, wlr_b } const float verts[] = { - m_RenderData.primarySurfaceUVBottomRight.x, m_RenderData.primarySurfaceUVTopLeft.y, // top right - m_RenderData.primarySurfaceUVTopLeft.x, m_RenderData.primarySurfaceUVTopLeft.y, // top left - m_RenderData.primarySurfaceUVBottomRight.x, m_RenderData.primarySurfaceUVBottomRight.y, // bottom right - m_RenderData.primarySurfaceUVTopLeft.x, m_RenderData.primarySurfaceUVBottomRight.y, // bottom left + m_RenderData.primarySurfaceUVBottomRight.x, m_RenderData.primarySurfaceUVTopLeft.y, // top right + m_RenderData.primarySurfaceUVTopLeft.x, m_RenderData.primarySurfaceUVTopLeft.y, // top left + m_RenderData.primarySurfaceUVBottomRight.x, m_RenderData.primarySurfaceUVBottomRight.y, // bottom right + m_RenderData.primarySurfaceUVTopLeft.x, m_RenderData.primarySurfaceUVBottomRight.y, // bottom left }; glVertexAttribPointer(shader->posAttrib, 2, GL_FLOAT, GL_FALSE, 0, fullVerts); @@ -571,13 +567,13 @@ void CHyprOpenGLImpl::renderTextureInternalWithDamage(const CTexture& tex, wlr_b } } - pixman_region32_fini(&damageClip); + pixman_region32_fini(&damageClip); } else { - PIXMAN_DAMAGE_FOREACH(damage) { - const auto RECT = RECTSARR[i]; - scissor(&RECT); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - } + PIXMAN_DAMAGE_FOREACH(damage) { + const auto RECT = RECTSARR[i]; + scissor(&RECT); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + } } glDisableVertexAttribArray(shader->posAttrib); @@ -597,27 +593,28 @@ CFramebuffer* CHyprOpenGLImpl::blurMainFramebufferWithDamage(float a, wlr_box* p // get transforms for the full monitor const auto TRANSFORM = wlr_output_transform_invert(m_RenderData.pMonitor->transform); - float matrix[9]; - wlr_box MONITORBOX = {0, 0, m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y}; + float matrix[9]; + wlr_box MONITORBOX = {0, 0, m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y}; wlr_matrix_project_box(matrix, &MONITORBOX, TRANSFORM, 0, m_RenderData.pMonitor->output->transform_matrix); float glMatrix[9]; wlr_matrix_multiply(glMatrix, m_RenderData.projection, matrix); // get the config settings - static auto *const PBLURSIZE = &g_pConfigManager->getConfigValuePtr("decoration:blur_size")->intValue; - static auto *const PBLURPASSES = &g_pConfigManager->getConfigValuePtr("decoration:blur_passes")->intValue; + static auto* const PBLURSIZE = &g_pConfigManager->getConfigValuePtr("decoration:blur_size")->intValue; + static auto* const PBLURPASSES = &g_pConfigManager->getConfigValuePtr("decoration:blur_passes")->intValue; // prep damage pixman_region32_t damage; pixman_region32_init(&damage); pixman_region32_copy(&damage, originalDamage); - wlr_region_transform(&damage, &damage, wlr_output_transform_invert(m_RenderData.pMonitor->transform), m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y); + wlr_region_transform(&damage, &damage, wlr_output_transform_invert(m_RenderData.pMonitor->transform), m_RenderData.pMonitor->vecTransformedSize.x, + m_RenderData.pMonitor->vecTransformedSize.y); wlr_region_expand(&damage, &damage, pow(2, *PBLURPASSES) * *PBLURSIZE); // helper - const auto PMIRRORFB = &m_RenderData.pCurrentMonData->mirrorFB; - const auto PMIRRORSWAPFB = &m_RenderData.pCurrentMonData->mirrorSwapFB; + const auto PMIRRORFB = &m_RenderData.pCurrentMonData->mirrorFB; + const auto PMIRRORSWAPFB = &m_RenderData.pCurrentMonData->mirrorSwapFB; CFramebuffer* currentRenderToFB = &m_RenderData.pCurrentMonData->primaryFB; @@ -643,11 +640,13 @@ CFramebuffer* CHyprOpenGLImpl::blurMainFramebufferWithDamage(float a, wlr_box* p wlr_matrix_transpose(glMatrix, glMatrix); glUniformMatrix3fv(pShader->proj, 1, GL_FALSE, glMatrix); #endif - glUniform1f(pShader->radius, *PBLURSIZE * (a / 255.f)); // this makes the blursize change with a + glUniform1f(pShader->radius, *PBLURSIZE * (a / 255.f)); // this makes the blursize change with a if (pShader == &m_RenderData.pCurrentMonData->m_shBLUR1) - glUniform2f(m_RenderData.pCurrentMonData->m_shBLUR1.halfpixel, 0.5f / (m_RenderData.pMonitor->vecPixelSize.x / 2.f), 0.5f / (m_RenderData.pMonitor->vecPixelSize.y / 2.f)); + glUniform2f(m_RenderData.pCurrentMonData->m_shBLUR1.halfpixel, 0.5f / (m_RenderData.pMonitor->vecPixelSize.x / 2.f), + 0.5f / (m_RenderData.pMonitor->vecPixelSize.y / 2.f)); else - glUniform2f(m_RenderData.pCurrentMonData->m_shBLUR2.halfpixel, 0.5f / (m_RenderData.pMonitor->vecPixelSize.x * 2.f), 0.5f / (m_RenderData.pMonitor->vecPixelSize.y * 2.f)); + glUniform2f(m_RenderData.pCurrentMonData->m_shBLUR2.halfpixel, 0.5f / (m_RenderData.pMonitor->vecPixelSize.x * 2.f), + 0.5f / (m_RenderData.pMonitor->vecPixelSize.y * 2.f)); glUniform1i(pShader->tex, 0); glVertexAttribPointer(pShader->posAttrib, 2, GL_FLOAT, GL_FALSE, 0, fullVerts); @@ -682,19 +681,19 @@ CFramebuffer* CHyprOpenGLImpl::blurMainFramebufferWithDamage(float a, wlr_box* p // damage region will be scaled, make a temp pixman_region32_t tempDamage; pixman_region32_init(&tempDamage); - wlr_region_scale(&tempDamage, &damage, 1.f / 2.f); // when DOWNscaling, we make the region twice as small because it's the TARGET + wlr_region_scale(&tempDamage, &damage, 1.f / 2.f); // when DOWNscaling, we make the region twice as small because it's the TARGET drawPass(&m_RenderData.pCurrentMonData->m_shBLUR1, &tempDamage); // and draw for (int i = 1; i < *PBLURPASSES; ++i) { wlr_region_scale(&tempDamage, &damage, 1.f / (1 << (i + 1))); - drawPass(&m_RenderData.pCurrentMonData->m_shBLUR1, &tempDamage); // down + drawPass(&m_RenderData.pCurrentMonData->m_shBLUR1, &tempDamage); // down } for (int i = *PBLURPASSES - 1; i >= 0; --i) { - wlr_region_scale(&tempDamage, &damage, 1.f / (1 << i)); // when upsampling we make the region twice as big - drawPass(&m_RenderData.pCurrentMonData->m_shBLUR2, &tempDamage); // up + wlr_region_scale(&tempDamage, &damage, 1.f / (1 << i)); // when upsampling we make the region twice as big + drawPass(&m_RenderData.pCurrentMonData->m_shBLUR2, &tempDamage); // up } // finish @@ -714,9 +713,9 @@ void CHyprOpenGLImpl::markBlurDirtyForMonitor(CMonitor* pMonitor) { } void CHyprOpenGLImpl::preRender(CMonitor* pMonitor) { - static auto *const PBLURNEWOPTIMIZE = &g_pConfigManager->getConfigValuePtr("decoration:blur_new_optimizations")->intValue; - static auto *const PBLURXRAY = &g_pConfigManager->getConfigValuePtr("decoration:blur_xray")->intValue; - static auto *const PBLUR = &g_pConfigManager->getConfigValuePtr("decoration:blur")->intValue; + static auto* const PBLURNEWOPTIMIZE = &g_pConfigManager->getConfigValuePtr("decoration:blur_new_optimizations")->intValue; + static auto* const PBLURXRAY = &g_pConfigManager->getConfigValuePtr("decoration:blur_xray")->intValue; + static auto* const PBLUR = &g_pConfigManager->getConfigValuePtr("decoration:blur")->intValue; if (!*PBLURNEWOPTIMIZE || !m_mMonitorRenderResources[pMonitor].blurFBDirty || !*PBLUR) return; @@ -739,14 +738,14 @@ void CHyprOpenGLImpl::preBlurForCurrentMonitor() { // make the fake dmg pixman_region32_t fakeDamage; pixman_region32_init_rect(&fakeDamage, 0, 0, m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y); - wlr_box wholeMonitor = {0, 0, m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y}; - const auto POUTFB = blurMainFramebufferWithDamage(255, &wholeMonitor, &fakeDamage); + wlr_box wholeMonitor = {0, 0, m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y}; + const auto POUTFB = blurMainFramebufferWithDamage(255, &wholeMonitor, &fakeDamage); // render onto blurFB m_RenderData.pCurrentMonData->blurFB.alloc(m_RenderData.pMonitor->vecPixelSize.x, m_RenderData.pMonitor->vecPixelSize.y); m_RenderData.pCurrentMonData->blurFB.bind(); - clear(CColor(0,0,0,0)); + clear(CColor(0, 0, 0, 0)); m_bEndFrame = true; // fix transformed renderTextureInternalWithDamage(POUTFB->m_cTex, &wholeMonitor, 255, &fakeDamage, 0, false, true, false); @@ -760,14 +759,14 @@ void CHyprOpenGLImpl::preBlurForCurrentMonitor() { } void CHyprOpenGLImpl::preWindowPass() { - static auto *const PBLURNEWOPTIMIZE = &g_pConfigManager->getConfigValuePtr("decoration:blur_new_optimizations")->intValue; - static auto *const PBLURXRAY = &g_pConfigManager->getConfigValuePtr("decoration:blur_xray")->intValue; - static auto *const PBLUR = &g_pConfigManager->getConfigValuePtr("decoration:blur")->intValue; + static auto* const PBLURNEWOPTIMIZE = &g_pConfigManager->getConfigValuePtr("decoration:blur_new_optimizations")->intValue; + static auto* const PBLURXRAY = &g_pConfigManager->getConfigValuePtr("decoration:blur_xray")->intValue; + static auto* const PBLUR = &g_pConfigManager->getConfigValuePtr("decoration:blur")->intValue; if (!m_RenderData.pCurrentMonData->blurFBDirty || !*PBLURNEWOPTIMIZE || !*PBLUR) return; - auto windowShouldBeBlurred = [&] (CWindow* pWindow) -> bool { + auto windowShouldBeBlurred = [&](CWindow* pWindow) -> bool { if (!pWindow) return false; @@ -781,8 +780,8 @@ void CHyprOpenGLImpl::preWindowPass() { pixman_region32_t inverseOpaque; pixman_region32_init(&inverseOpaque); - const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID); - const float A = pWindow->m_fAlpha.fl() * pWindow->m_fActiveInactiveAlpha.fl() * PWORKSPACE->m_fAlpha.fl() / 255.f; + const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID); + const float A = pWindow->m_fAlpha.fl() * pWindow->m_fActiveInactiveAlpha.fl() * PWORKSPACE->m_fAlpha.fl() / 255.f; if (A >= 255.f) { pixman_box32_t surfbox = {0, 0, PSURFACE->current.width, PSURFACE->current.height}; @@ -808,7 +807,7 @@ void CHyprOpenGLImpl::preWindowPass() { // check if window is valid if (!windowShouldBeBlurred(w.get())) continue; - + hasWindows = true; break; } @@ -824,20 +823,21 @@ void CHyprOpenGLImpl::preWindowPass() { void CHyprOpenGLImpl::renderTextureWithBlur(const CTexture& tex, wlr_box* pBox, float a, wlr_surface* pSurface, int round, bool blockBlurOptimization) { RASSERT(m_RenderData.pMonitor, "Tried to render texture with blur without begin()!"); - static auto *const PBLURENABLED = &g_pConfigManager->getConfigValuePtr("decoration:blur")->intValue; - static auto *const PNOBLUROVERSIZED = &g_pConfigManager->getConfigValuePtr("decoration:no_blur_on_oversized")->intValue; - static auto *const PBLURNEWOPTIMIZE = &g_pConfigManager->getConfigValuePtr("decoration:blur_new_optimizations")->intValue; - static auto *const PBLURXRAY = &g_pConfigManager->getConfigValuePtr("decoration:blur_xray")->intValue; + static auto* const PBLURENABLED = &g_pConfigManager->getConfigValuePtr("decoration:blur")->intValue; + static auto* const PNOBLUROVERSIZED = &g_pConfigManager->getConfigValuePtr("decoration:no_blur_on_oversized")->intValue; + static auto* const PBLURNEWOPTIMIZE = &g_pConfigManager->getConfigValuePtr("decoration:blur_new_optimizations")->intValue; + static auto* const PBLURXRAY = &g_pConfigManager->getConfigValuePtr("decoration:blur_xray")->intValue; // make a damage region for this window pixman_region32_t damage; pixman_region32_init(&damage); - pixman_region32_intersect_rect(&damage, m_RenderData.pDamage, pBox->x, pBox->y, pBox->width, pBox->height); // clip it to the box + pixman_region32_intersect_rect(&damage, m_RenderData.pDamage, pBox->x, pBox->y, pBox->width, pBox->height); // clip it to the box - if(!pixman_region32_not_empty(&damage)) - return; + if (!pixman_region32_not_empty(&damage)) + return; - if (*PBLURENABLED == 0 || (*PNOBLUROVERSIZED && m_RenderData.primarySurfaceUVTopLeft != Vector2D(-1, -1)) || (m_pCurrentWindow && m_pCurrentWindow->m_sAdditionalConfigData.forceNoBlur)) { + if (*PBLURENABLED == 0 || (*PNOBLUROVERSIZED && m_RenderData.primarySurfaceUVTopLeft != Vector2D(-1, -1)) || + (m_pCurrentWindow && m_pCurrentWindow->m_sAdditionalConfigData.forceNoBlur)) { renderTexture(tex, pBox, a, round, false, true); return; } @@ -861,7 +861,9 @@ void CHyprOpenGLImpl::renderTextureWithBlur(const CTexture& tex, wlr_box* pBox, } // vvv TODO: layered blur fbs? - const bool USENEWOPTIMIZE = (*PBLURNEWOPTIMIZE && !blockBlurOptimization && ((m_pCurrentWindow && !m_pCurrentWindow->m_bIsFloating) || *PBLURXRAY) && m_RenderData.pCurrentMonData->blurFB.m_cTex.m_iTexID && (!m_pCurrentWindow || !g_pCompositor->isWorkspaceSpecial(m_pCurrentWindow->m_iWorkspaceID) )); + const bool USENEWOPTIMIZE = + (*PBLURNEWOPTIMIZE && !blockBlurOptimization && ((m_pCurrentWindow && !m_pCurrentWindow->m_bIsFloating) || *PBLURXRAY) && + m_RenderData.pCurrentMonData->blurFB.m_cTex.m_iTexID && (!m_pCurrentWindow || !g_pCompositor->isWorkspaceSpecial(m_pCurrentWindow->m_iWorkspaceID))); CFramebuffer* POUTFB = nullptr; if (!USENEWOPTIMIZE) { @@ -886,7 +888,7 @@ void CHyprOpenGLImpl::renderTextureWithBlur(const CTexture& tex, wlr_box* pBox, m_RenderData.pCurrentMonData->primaryFB.bind(); // make a stencil for rounded corners to work with blur - scissor((wlr_box*)nullptr); // allow the entire window and stencil to render + scissor((wlr_box*)nullptr); // allow the entire window and stencil to render glClearStencil(0); glClear(GL_STENCIL_BUFFER_BIT); @@ -897,9 +899,9 @@ void CHyprOpenGLImpl::renderTextureWithBlur(const CTexture& tex, wlr_box* pBox, glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); if (USENEWOPTIMIZE) - renderRect(pBox, CColor(0,0,0,0), round); + renderRect(pBox, CColor(0, 0, 0, 0), round); else - renderTexture(tex, pBox, a, round, true, true); // discard opaque + renderTexture(tex, pBox, a, round, true, true); // discard opaque glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); glStencilFunc(GL_EQUAL, 1, -1); @@ -908,8 +910,8 @@ void CHyprOpenGLImpl::renderTextureWithBlur(const CTexture& tex, wlr_box* pBox, // stencil done. Render everything. wlr_box MONITORBOX = {0, 0, m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y}; // render our great blurred FB - static auto *const PBLURIGNOREOPACITY = &g_pConfigManager->getConfigValuePtr("decoration:blur_ignore_opacity")->intValue; - m_bEndFrame = true; // fix transformed + static auto* const PBLURIGNOREOPACITY = &g_pConfigManager->getConfigValuePtr("decoration:blur_ignore_opacity")->intValue; + m_bEndFrame = true; // fix transformed renderTextureInternalWithDamage(POUTFB->m_cTex, &MONITORBOX, *PBLURIGNOREOPACITY ? 255.f : a, &damage, 0, false, false, false); m_bEndFrame = false; @@ -939,10 +941,10 @@ void CHyprOpenGLImpl::renderBorder(wlr_box* box, const CGradientValueData& grad, RASSERT(m_RenderData.pMonitor, "Tried to render rect without begin()!"); if (!pixman_region32_not_empty(m_RenderData.pDamage) || (m_pCurrentWindow && m_pCurrentWindow->m_sAdditionalConfigData.forceNoBorder)) - return; + return; - static auto *const PBORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue; - static auto *const PMULTISAMPLE = &g_pConfigManager->getConfigValuePtr("decoration:multisample_edges")->intValue; + static auto* const PBORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue; + static auto* const PMULTISAMPLE = &g_pConfigManager->getConfigValuePtr("decoration:multisample_edges")->intValue; if (*PBORDERSIZE < 1) return; @@ -958,7 +960,8 @@ void CHyprOpenGLImpl::renderBorder(wlr_box* box, const CGradientValueData& grad, round += round == 0 ? 0 : scaledBorderSize; 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 + 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); @@ -983,10 +986,10 @@ void CHyprOpenGLImpl::renderBorder(wlr_box* box, const CGradientValueData& grad, glUniform1f(m_RenderData.pCurrentMonData->m_shBORDER1.alpha, a); wlr_box transformedBox; - wlr_box_transform(&transformedBox, box, wlr_output_transform_invert(m_RenderData.pMonitor->transform), - m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y); + wlr_box_transform(&transformedBox, box, wlr_output_transform_invert(m_RenderData.pMonitor->transform), m_RenderData.pMonitor->vecTransformedSize.x, + m_RenderData.pMonitor->vecTransformedSize.y); - const auto TOPLEFT = Vector2D(transformedBox.x, transformedBox.y); + const auto TOPLEFT = Vector2D(transformedBox.x, transformedBox.y); const auto FULLSIZE = Vector2D(transformedBox.width, transformedBox.height); glUniform2f(m_RenderData.pCurrentMonData->m_shBORDER1.topLeft, (float)TOPLEFT.x, (float)TOPLEFT.y); @@ -1015,13 +1018,13 @@ void CHyprOpenGLImpl::renderBorder(wlr_box* box, const CGradientValueData& grad, } } - pixman_region32_fini(&damageClip); + pixman_region32_fini(&damageClip); } else { - PIXMAN_DAMAGE_FOREACH(m_RenderData.pDamage) { - const auto RECT = RECTSARR[i]; - scissor(&RECT); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - } + PIXMAN_DAMAGE_FOREACH(m_RenderData.pDamage) { + const auto RECT = RECTSARR[i]; + scissor(&RECT); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + } } glDisableVertexAttribArray(m_RenderData.pCurrentMonData->m_shBORDER1.posAttrib); @@ -1050,7 +1053,7 @@ void CHyprOpenGLImpl::makeRawWindowSnapshot(CWindow* pWindow, CFramebuffer* pFra begin(PMONITOR, &fakeDamage, true); - clear(CColor(0, 0, 0, 0)); // JIC + clear(CColor(0, 0, 0, 0)); // JIC timespec now; clock_gettime(CLOCK_MONOTONIC, &now); @@ -1072,7 +1075,7 @@ void CHyprOpenGLImpl::makeRawWindowSnapshot(CWindow* pWindow, CFramebuffer* pFra pFramebuffer->bind(); - clear(CColor(0, 0, 0, 0)); // JIC + clear(CColor(0, 0, 0, 0)); // JIC g_pHyprRenderer->renderWindow(pWindow, PMONITOR, &now, false, RENDER_PASS_ALL, true); @@ -1105,7 +1108,7 @@ void CHyprOpenGLImpl::makeWindowSnapshot(CWindow* pWindow) { begin(PMONITOR, &fakeDamage, true); - clear(CColor(0, 0, 0, 0)); // JIC + clear(CColor(0, 0, 0, 0)); // JIC timespec now; clock_gettime(CLOCK_MONOTONIC, &now); @@ -1128,7 +1131,7 @@ void CHyprOpenGLImpl::makeWindowSnapshot(CWindow* pWindow) { PFRAMEBUFFER->bind(); - clear(CColor(0, 0, 0, 0)); // JIC + clear(CColor(0, 0, 0, 0)); // JIC g_pHyprRenderer->renderWindow(pWindow, PMONITOR, &now, !pWindow->m_bX11DoesntWantBorders, RENDER_PASS_ALL); @@ -1169,13 +1172,13 @@ void CHyprOpenGLImpl::makeLayerSnapshot(SLayerSurface* pLayer) { PFRAMEBUFFER->bind(); - clear(CColor(0, 0, 0, 0)); // JIC + clear(CColor(0, 0, 0, 0)); // JIC timespec now; clock_gettime(CLOCK_MONOTONIC, &now); const auto BLURLSSTATUS = pLayer->forceBlur; - pLayer->forceBlur = false; + pLayer->forceBlur = false; // draw the layer g_pHyprRenderer->renderLayer(pLayer, PMONITOR, &now); @@ -1199,19 +1202,15 @@ void CHyprOpenGLImpl::makeLayerSnapshot(SLayerSurface* pLayer) { wlr_output_rollback(PMONITOR->output); } -void CHyprOpenGLImpl::onWindowResizeStart(CWindow* pWindow) { +void CHyprOpenGLImpl::onWindowResizeStart(CWindow* pWindow) {} -} - -void CHyprOpenGLImpl::onWindowResizeEnd(CWindow* pWindow) { - -} +void CHyprOpenGLImpl::onWindowResizeEnd(CWindow* pWindow) {} void CHyprOpenGLImpl::renderSnapshot(CWindow** pWindow) { RASSERT(m_RenderData.pMonitor, "Tried to render snapshot rect without begin()!"); const auto PWINDOW = *pWindow; - auto it = m_mWindowFramebuffers.begin(); + auto it = m_mWindowFramebuffers.begin(); for (; it != m_mWindowFramebuffers.end(); it++) { if (it->first == PWINDOW) { break; @@ -1223,15 +1222,16 @@ void CHyprOpenGLImpl::renderSnapshot(CWindow** pWindow) { const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID); - wlr_box windowBox; + wlr_box windowBox; // some mafs to figure out the correct box // the originalClosedPos is relative to the monitor's pos - Vector2D scaleXY = Vector2D((PMONITOR->scale * PWINDOW->m_vRealSize.vec().x / (PWINDOW->m_vOriginalClosedSize.x * PMONITOR->scale)), (PMONITOR->scale * PWINDOW->m_vRealSize.vec().y / (PWINDOW->m_vOriginalClosedSize.y * PMONITOR->scale))); + Vector2D scaleXY = Vector2D((PMONITOR->scale * PWINDOW->m_vRealSize.vec().x / (PWINDOW->m_vOriginalClosedSize.x * PMONITOR->scale)), + (PMONITOR->scale * PWINDOW->m_vRealSize.vec().y / (PWINDOW->m_vOriginalClosedSize.y * PMONITOR->scale))); - windowBox.width = PMONITOR->vecTransformedSize.x * scaleXY.x; + windowBox.width = PMONITOR->vecTransformedSize.x * scaleXY.x; windowBox.height = PMONITOR->vecTransformedSize.y * scaleXY.y; - windowBox.x = ((PWINDOW->m_vRealPosition.vec().x - PMONITOR->vecPosition.x) * PMONITOR->scale) - ((PWINDOW->m_vOriginalClosedPos.x * PMONITOR->scale) * scaleXY.x); - windowBox.y = ((PWINDOW->m_vRealPosition.vec().y - PMONITOR->vecPosition.y) * PMONITOR->scale) - ((PWINDOW->m_vOriginalClosedPos.y * PMONITOR->scale) * scaleXY.y); + windowBox.x = ((PWINDOW->m_vRealPosition.vec().x - PMONITOR->vecPosition.x) * PMONITOR->scale) - ((PWINDOW->m_vOriginalClosedPos.x * PMONITOR->scale) * scaleXY.x); + windowBox.y = ((PWINDOW->m_vRealPosition.vec().y - PMONITOR->vecPosition.y) * PMONITOR->scale) - ((PWINDOW->m_vOriginalClosedPos.y * PMONITOR->scale) * scaleXY.y); pixman_region32_t fakeDamage; pixman_region32_init_rect(&fakeDamage, 0, 0, PMONITOR->vecTransformedSize.x, PMONITOR->vecTransformedSize.y); @@ -1244,7 +1244,7 @@ void CHyprOpenGLImpl::renderSnapshot(CWindow** pWindow) { pixman_region32_fini(&fakeDamage); - static auto *const PDAMAGEMON = &g_pConfigManager->getConfigValuePtr("misc:damage_entire_on_snapshot")->intValue; + static auto* const PDAMAGEMON = &g_pConfigManager->getConfigValuePtr("misc:damage_entire_on_snapshot")->intValue; if (*PDAMAGEMON) PMONITOR->forceFullFrames += 1; @@ -1254,7 +1254,7 @@ void CHyprOpenGLImpl::renderSnapshot(SLayerSurface** pLayer) { RASSERT(m_RenderData.pMonitor, "Tried to render snapshot rect without begin()!"); const auto PLAYER = *pLayer; - auto it = m_mLayerFramebuffers.begin(); + auto it = m_mLayerFramebuffers.begin(); for (; it != m_mLayerFramebuffers.end(); it++) { if (it->first == PLAYER) { break; @@ -1264,9 +1264,9 @@ void CHyprOpenGLImpl::renderSnapshot(SLayerSurface** pLayer) { if (it == m_mLayerFramebuffers.end() || !it->second.m_cTex.m_iTexID) return; - const auto PMONITOR = g_pCompositor->getMonitorFromID(PLAYER->monitorID); + const auto PMONITOR = g_pCompositor->getMonitorFromID(PLAYER->monitorID); - wlr_box monbox = {0, 0, PMONITOR->vecTransformedSize.x, PMONITOR->vecTransformedSize.y}; + wlr_box monbox = {0, 0, PMONITOR->vecTransformedSize.x, PMONITOR->vecTransformedSize.y}; pixman_region32_t fakeDamage; pixman_region32_init_rect(&fakeDamage, 0, 0, PMONITOR->vecTransformedSize.x, PMONITOR->vecTransformedSize.y); @@ -1279,7 +1279,7 @@ void CHyprOpenGLImpl::renderSnapshot(SLayerSurface** pLayer) { pixman_region32_fini(&fakeDamage); - static auto *const PDAMAGEMON = &g_pConfigManager->getConfigValuePtr("misc:damage_entire_on_snapshot")->intValue; + static auto* const PDAMAGEMON = &g_pConfigManager->getConfigValuePtr("misc:damage_entire_on_snapshot")->intValue; if (*PDAMAGEMON) PMONITOR->forceFullFrames += 1; @@ -1291,16 +1291,17 @@ void CHyprOpenGLImpl::renderRoundedShadow(wlr_box* box, int round, int range, fl RASSERT(m_pCurrentWindow, "Tried to render shadow without a window!"); if (!pixman_region32_not_empty(m_RenderData.pDamage)) - return; + return; - static auto *const PSHADOWPOWER = &g_pConfigManager->getConfigValuePtr("decoration:shadow_render_power")->intValue; + static auto* const PSHADOWPOWER = &g_pConfigManager->getConfigValuePtr("decoration:shadow_render_power")->intValue; - const auto SHADOWPOWER = std::clamp((int)*PSHADOWPOWER, 1, 4); + const auto SHADOWPOWER = std::clamp((int)*PSHADOWPOWER, 1, 4); - const auto col = m_pCurrentWindow->m_cRealShadowColor.col(); + const auto col = m_pCurrentWindow->m_cRealShadowColor.col(); - 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 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); @@ -1318,9 +1319,9 @@ void CHyprOpenGLImpl::renderRoundedShadow(wlr_box* box, int round, int range, fl #endif glUniform4f(m_RenderData.pCurrentMonData->m_shSHADOW.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 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); + const auto FULLSIZE = Vector2D(box->width, box->height); // Rounded corners glUniform2f(m_RenderData.pCurrentMonData->m_shSHADOW.topLeft, (float)TOPLEFT.x, (float)TOPLEFT.y); @@ -1349,13 +1350,13 @@ void CHyprOpenGLImpl::renderRoundedShadow(wlr_box* box, int round, int range, fl } } - pixman_region32_fini(&damageClip); + pixman_region32_fini(&damageClip); } else { - PIXMAN_DAMAGE_FOREACH(m_RenderData.pDamage) { - const auto RECT = RECTSARR[i]; - scissor(&RECT); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - } + PIXMAN_DAMAGE_FOREACH(m_RenderData.pDamage) { + const auto RECT = RECTSARR[i]; + scissor(&RECT); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + } } glDisableVertexAttribArray(m_RenderData.pCurrentMonData->m_shSHADOW.posAttrib); @@ -1375,7 +1376,7 @@ void CHyprOpenGLImpl::saveBufferForMirror() { } void CHyprOpenGLImpl::renderMirrored() { - wlr_box monbox = {0, 0, m_RenderData.pMonitor->vecPixelSize.x, m_RenderData.pMonitor->vecPixelSize.y}; + wlr_box monbox = {0, 0, m_RenderData.pMonitor->vecPixelSize.x, m_RenderData.pMonitor->vecPixelSize.y}; const auto PFB = &m_mMonitorRenderResources[m_RenderData.pMonitor->pMirrorOf].monitorMirrorFB; @@ -1385,7 +1386,7 @@ void CHyprOpenGLImpl::renderMirrored() { renderTexture(PFB->m_cTex, &monbox, 255.f, 0, false, false); } -void CHyprOpenGLImpl::renderSplash(cairo_t *const CAIRO, cairo_surface_t *const CAIROSURFACE, double offsetY) { +void CHyprOpenGLImpl::renderSplash(cairo_t* const CAIRO, cairo_surface_t* const CAIROSURFACE, double offsetY) { cairo_select_font_face(CAIRO, "Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); const auto FONTSIZE = (int)(m_RenderData.pMonitor->vecPixelSize.y / 76); @@ -1406,7 +1407,7 @@ void CHyprOpenGLImpl::renderSplash(cairo_t *const CAIRO, cairo_surface_t *const void CHyprOpenGLImpl::createBGTextureForMonitor(CMonitor* pMonitor) { RASSERT(m_RenderData.pMonitor, "Tried to createBGTex without begin()!"); - static auto *const PNOSPLASH = &g_pConfigManager->getConfigValuePtr("misc:disable_splash_rendering")->intValue; + static auto* const PNOSPLASH = &g_pConfigManager->getConfigValuePtr("misc:disable_splash_rendering")->intValue; // release the last tex if exists const auto PTEX = &m_mMonitorBGTextures[pMonitor]; @@ -1425,7 +1426,7 @@ void CHyprOpenGLImpl::createBGTextureForMonitor(CMonitor* pMonitor) { // get the adequate tex std::string texPath = "/usr/share/hyprland/wall_"; - Vector2D textureSize; + Vector2D textureSize; if (pMonitor->vecTransformedSize.x > 3850) { textureSize = Vector2D(7680, 4320); texPath += "8K.png"; @@ -1441,10 +1442,10 @@ void CHyprOpenGLImpl::createBGTextureForMonitor(CMonitor* pMonitor) { // calc the target box const double MONRATIO = m_RenderData.pMonitor->vecTransformedSize.x / m_RenderData.pMonitor->vecTransformedSize.y; - const double WPRATIO = 1.77; + const double WPRATIO = 1.77; - Vector2D origin; - double scale; + Vector2D origin; + double scale; if (MONRATIO > WPRATIO) { scale = m_RenderData.pMonitor->vecTransformedSize.x / PTEX->m_vSize.x; @@ -1462,7 +1463,7 @@ void CHyprOpenGLImpl::createBGTextureForMonitor(CMonitor* pMonitor) { // create a new one with cairo const auto CAIROSURFACE = cairo_image_surface_create_from_png(texPath.c_str()); - const auto CAIRO = cairo_create(CAIROSURFACE); + const auto CAIRO = cairo_create(CAIROSURFACE); // scale it to fit the current monitor cairo_scale(CAIRO, textureSize.x / pMonitor->vecTransformedSize.x, textureSize.y / pMonitor->vecTransformedSize.y); @@ -1476,10 +1477,10 @@ void CHyprOpenGLImpl::createBGTextureForMonitor(CMonitor* pMonitor) { glBindTexture(GL_TEXTURE_2D, PTEX->m_iTexID); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - #ifndef GLES2 +#ifndef GLES2 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_BLUE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_RED); - #endif +#endif glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, textureSize.x, textureSize.y, 0, GL_RGBA, GL_UNSIGNED_BYTE, DATA); cairo_surface_destroy(CAIROSURFACE); @@ -1491,7 +1492,7 @@ void CHyprOpenGLImpl::createBGTextureForMonitor(CMonitor* pMonitor) { void CHyprOpenGLImpl::clearWithTex() { RASSERT(m_RenderData.pMonitor, "Tried to render BGtex without begin()!"); - static auto *const PRENDERTEX = &g_pConfigManager->getConfigValuePtr("misc:disable_hyprland_logo")->intValue; + static auto* const PRENDERTEX = &g_pConfigManager->getConfigValuePtr("misc:disable_hyprland_logo")->intValue; if (!*PRENDERTEX) { auto TEXIT = m_mMonitorBGTextures.find(m_RenderData.pMonitor); diff --git a/src/render/OpenGL.hpp b/src/render/OpenGL.hpp index 1d7e2128..d550ca0a 100644 --- a/src/render/OpenGL.hpp +++ b/src/render/OpenGL.hpp @@ -15,17 +15,12 @@ class CHyprRenderer; inline const float fullVerts[] = { - 1, 0, // top right - 0, 0, // top left - 1, 1, // bottom right - 0, 1, // bottom left -}; -inline const float fanVertsFull[] = { - -1.0f, -1.0f, - 1.0f, -1.0f, - 1.0f, 1.0f, - -1.0f, 1.0f + 1, 0, // top right + 0, 0, // top left + 1, 1, // bottom right + 0, 1, // bottom left }; +inline const float fanVertsFull[] = {-1.0f, -1.0f, 1.0f, -1.0f, 1.0f, 1.0f, -1.0f, 1.0f}; struct SMonitorRenderData { CFramebuffer primaryFB; @@ -42,118 +37,118 @@ struct SMonitorRenderData { wlr_box backgroundTexBox; // Shaders - bool m_bShadersInitialized = false; - CShader m_shQUAD; - CShader m_shRGBA; - CShader m_shRGBX; - CShader m_shEXT; - CShader m_shBLUR1; - CShader m_shBLUR2; - CShader m_shSHADOW; - CShader m_shBORDER1; + bool m_bShadersInitialized = false; + CShader m_shQUAD; + CShader m_shRGBA; + CShader m_shRGBX; + CShader m_shEXT; + CShader m_shBLUR1; + CShader m_shBLUR2; + CShader m_shSHADOW; + CShader m_shBORDER1; // }; struct SCurrentRenderData { - CMonitor* pMonitor = nullptr; - float projection[9]; + CMonitor* pMonitor = nullptr; + float projection[9]; SMonitorRenderData* pCurrentMonData = nullptr; - pixman_region32_t* pDamage = nullptr; + pixman_region32_t* pDamage = nullptr; - Vector2D primarySurfaceUVTopLeft = Vector2D(-1, -1); - Vector2D primarySurfaceUVBottomRight = Vector2D(-1, -1); + Vector2D primarySurfaceUVTopLeft = Vector2D(-1, -1); + Vector2D primarySurfaceUVBottomRight = Vector2D(-1, -1); - wlr_box clipBox = {}; + wlr_box clipBox = {}; }; class CGradientValueData; class CHyprOpenGLImpl { -public: - + public: CHyprOpenGLImpl(); - void begin(CMonitor*, pixman_region32_t*, bool fake = false); - void end(); + void begin(CMonitor*, pixman_region32_t*, bool fake = false); + void end(); - void renderRect(wlr_box*, const CColor&, int round = 0); - void renderRectWithDamage(wlr_box*, const CColor&, pixman_region32_t* damage, int round = 0); - void renderTexture(wlr_texture*, wlr_box*, float a, int round = 0, bool allowCustomUV = false); - void renderTexture(const CTexture&, wlr_box*, float a, int round = 0, bool discardOpaque = false, bool allowCustomUV = false); - void renderTextureWithBlur(const CTexture&, wlr_box*, float a, wlr_surface* pSurface, int round = 0, bool blockBlurOptimization = false); - void renderRoundedShadow(wlr_box*, int round, int range, float a = 1.0); - void renderBorder(wlr_box*, const CGradientValueData&, int round, float a = 1.0); + void renderRect(wlr_box*, const CColor&, int round = 0); + void renderRectWithDamage(wlr_box*, const CColor&, pixman_region32_t* damage, int round = 0); + void renderTexture(wlr_texture*, wlr_box*, float a, int round = 0, bool allowCustomUV = false); + void renderTexture(const CTexture&, wlr_box*, float a, int round = 0, bool discardOpaque = false, bool allowCustomUV = false); + void renderTextureWithBlur(const CTexture&, wlr_box*, float a, wlr_surface* pSurface, int round = 0, bool blockBlurOptimization = false); + void renderRoundedShadow(wlr_box*, int round, int range, float a = 1.0); + void renderBorder(wlr_box*, const CGradientValueData&, int round, float a = 1.0); - void makeWindowSnapshot(CWindow*); - void makeRawWindowSnapshot(CWindow*, CFramebuffer*); - void makeLayerSnapshot(SLayerSurface*); - void renderSnapshot(CWindow**); - void renderSnapshot(SLayerSurface**); + void makeWindowSnapshot(CWindow*); + void makeRawWindowSnapshot(CWindow*, CFramebuffer*); + void makeLayerSnapshot(SLayerSurface*); + void renderSnapshot(CWindow**); + void renderSnapshot(SLayerSurface**); - void clear(const CColor&); - void clearWithTex(); - void scissor(const wlr_box*, bool transform = true); - void scissor(const pixman_box32*, bool transform = true); - void scissor(const int x, const int y, const int w, const int h, bool transform = true); + void clear(const CColor&); + void clearWithTex(); + void scissor(const wlr_box*, bool transform = true); + void scissor(const pixman_box32*, bool transform = true); + void scissor(const int x, const int y, const int w, const int h, bool transform = true); - void destroyMonitorResources(CMonitor*); + void destroyMonitorResources(CMonitor*); - void markBlurDirtyForMonitor(CMonitor*); + void markBlurDirtyForMonitor(CMonitor*); - void preWindowPass(); - void preRender(CMonitor*); + void preWindowPass(); + void preRender(CMonitor*); - void saveBufferForMirror(); - void renderMirrored(); + void saveBufferForMirror(); + void renderMirrored(); - void onWindowResizeStart(CWindow*); - void onWindowResizeEnd(CWindow*); + void onWindowResizeStart(CWindow*); + void onWindowResizeEnd(CWindow*); - void applyScreenShader(const std::string& path); + void applyScreenShader(const std::string& path); - SCurrentRenderData m_RenderData; + SCurrentRenderData m_RenderData; - GLint m_iCurrentOutputFb = 0; - GLint m_iWLROutputFb = 0; + GLint m_iCurrentOutputFb = 0; + GLint m_iWLROutputFb = 0; - bool m_bReloadScreenShader = true; // at launch it can be set + bool m_bReloadScreenShader = true; // at launch it can be set - CWindow* m_pCurrentWindow = nullptr; // hack to get the current rendered window + CWindow* m_pCurrentWindow = nullptr; // hack to get the current rendered window - pixman_region32_t m_rOriginalDamageRegion; // used for storing the pre-expanded region + pixman_region32_t m_rOriginalDamageRegion; // used for storing the pre-expanded region std::unordered_map<CWindow*, CFramebuffer> m_mWindowFramebuffers; - std::unordered_map<SLayerSurface*, CFramebuffer> m_mLayerFramebuffers; + std::unordered_map<SLayerSurface*, CFramebuffer> m_mLayerFramebuffers; std::unordered_map<CMonitor*, SMonitorRenderData> m_mMonitorRenderResources; - std::unordered_map<CMonitor*, CTexture> m_mMonitorBGTextures; + std::unordered_map<CMonitor*, CTexture> m_mMonitorBGTextures; -private: - std::list<GLuint> m_lBuffers; - std::list<GLuint> m_lTextures; + private: + std::list<GLuint> m_lBuffers; + std::list<GLuint> m_lTextures; - int m_iDRMFD; - std::string m_szExtensions; + int m_iDRMFD; + std::string m_szExtensions; - bool m_bFakeFrame = false; - bool m_bEndFrame = false; - bool m_bApplyFinalShader = false; + bool m_bFakeFrame = false; + bool m_bEndFrame = false; + bool m_bApplyFinalShader = false; - CShader m_sFinalScreenShader; + CShader m_sFinalScreenShader; - GLuint createProgram(const std::string&, const std::string&, bool dynamic = false); - GLuint compileShader(const GLuint&, std::string, bool dynamic = false); - void createBGTextureForMonitor(CMonitor*); - void initShaders(); + GLuint createProgram(const std::string&, const std::string&, bool dynamic = false); + GLuint compileShader(const GLuint&, std::string, bool dynamic = false); + void createBGTextureForMonitor(CMonitor*); + void initShaders(); // returns the out FB, can be either Mirror or MirrorSwap - CFramebuffer* blurMainFramebufferWithDamage(float a, wlr_box* pBox, pixman_region32_t* damage); + CFramebuffer* blurMainFramebufferWithDamage(float a, wlr_box* pBox, pixman_region32_t* damage); - void renderTextureInternalWithDamage(const CTexture&, wlr_box* pBox, float a, pixman_region32_t* damage, int round = 0, bool discardOpaque = false, bool noAA = false, bool allowCustomUV = false, bool allowDim = false); - void renderSplash(cairo_t *const, cairo_surface_t *const, double); + void renderTextureInternalWithDamage(const CTexture&, wlr_box* pBox, float a, pixman_region32_t* damage, int round = 0, bool discardOpaque = false, bool noAA = false, + bool allowCustomUV = false, bool allowDim = false); + void renderSplash(cairo_t* const, cairo_surface_t* const, double); - void preBlurForCurrentMonitor(); + void preBlurForCurrentMonitor(); friend class CHyprRenderer; }; diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 90dfaa71..1196f77e 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -4,7 +4,7 @@ void renderSurface(struct wlr_surface* surface, int x, int y, void* data) { const auto TEXTURE = wlr_surface_get_texture(surface); - const auto RDATA = (SRenderData*)data; + const auto RDATA = (SRenderData*)data; if (!TEXTURE) return; @@ -15,7 +15,7 @@ void renderSurface(struct wlr_surface* surface, int x, int y, void* data) { wlr_box windowBox; if (RDATA->surface && surface == RDATA->surface) windowBox = {(int)outputX + RDATA->x + x, (int)outputY + RDATA->y + y, RDATA->w, RDATA->h}; - else // here we clamp to 2, these might be some tiny specks + else // here we clamp to 2, these might be some tiny specks windowBox = {(int)outputX + RDATA->x + x, (int)outputY + RDATA->y + y, std::max(surface->current.width, 2), std::max(surface->current.height, 2)}; if (RDATA->squishOversized) { @@ -30,9 +30,9 @@ void renderSurface(struct wlr_surface* surface, int x, int y, void* data) { scaleBox(&windowBox, RDATA->output->scale); - static auto *const PROUNDING = &g_pConfigManager->getConfigValuePtr("decoration:rounding")->intValue; + static auto* const PROUNDING = &g_pConfigManager->getConfigValuePtr("decoration:rounding")->intValue; - float rounding = RDATA->dontRound ? 0 : RDATA->rounding == -1 ? *PROUNDING : RDATA->rounding; + float rounding = RDATA->dontRound ? 0 : RDATA->rounding == -1 ? *PROUNDING : RDATA->rounding; rounding *= RDATA->output->scale; rounding -= 1; // to fix a border issue @@ -46,8 +46,7 @@ void renderSurface(struct wlr_surface* surface, int x, int y, void* data) { else g_pHyprOpenGL->renderTexture(TEXTURE, &windowBox, RDATA->fadeAlpha * RDATA->alpha, rounding, true); } - } - else { + } else { g_pHyprOpenGL->renderTexture(TEXTURE, &windowBox, RDATA->fadeAlpha * RDATA->alpha, rounding, true); } @@ -57,7 +56,7 @@ void renderSurface(struct wlr_surface* surface, int x, int y, void* data) { } // reset the UV, we might've set it above - g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft = Vector2D(-1, -1); + g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft = Vector2D(-1, -1); g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight = Vector2D(-1, -1); } @@ -153,7 +152,7 @@ void CHyprRenderer::renderWorkspaceWithFullscreenWindow(CMonitor* pMonitor, CWor for (auto& w : g_pCompositor->m_vWindows) { const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID); - if (w->m_iWorkspaceID != pWorkspace->m_iID || !w->m_bIsFullscreen){ + if (w->m_iWorkspaceID != pWorkspace->m_iID || !w->m_bIsFullscreen) { if (!(PWORKSPACE && (PWORKSPACE->m_vRenderOffset.isBeingAnimated() || PWORKSPACE->m_fAlpha.isBeingAnimated() || PWORKSPACE->m_bForceRendering))) continue; @@ -184,19 +183,20 @@ void CHyprRenderer::renderWorkspaceWithFullscreenWindow(CMonitor* pMonitor, CWor } // and then special windows - if (pMonitor->specialWorkspaceID) for (auto& w : g_pCompositor->m_vWindows) { - if (!g_pCompositor->windowValidMapped(w.get()) && !w->m_bFadingOut) - continue; + if (pMonitor->specialWorkspaceID) + for (auto& w : g_pCompositor->m_vWindows) { + if (!g_pCompositor->windowValidMapped(w.get()) && !w->m_bFadingOut) + continue; - if (w->m_iWorkspaceID != pMonitor->specialWorkspaceID) - continue; + if (w->m_iWorkspaceID != pMonitor->specialWorkspaceID) + continue; - if (!shouldRenderWindow(w.get(), pMonitor)) - continue; + if (!shouldRenderWindow(w.get(), pMonitor)) + continue; - // render the bad boy - renderWindow(w.get(), pMonitor, time, true, RENDER_PASS_ALL); - } + // render the bad boy + renderWindow(w.get(), pMonitor, time, true, RENDER_PASS_ALL); + } // and the overlay layers for (auto& ls : pMonitor->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_TOP]) { @@ -204,7 +204,6 @@ void CHyprRenderer::renderWorkspaceWithFullscreenWindow(CMonitor* pMonitor, CWor renderLayer(ls.get(), pMonitor, time); } - for (auto& ls : pMonitor->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY]) { renderLayer(ls.get(), pMonitor, time); } @@ -226,11 +225,11 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, CMonitor* pMonitor, timespec* return; } - const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID); - const auto REALPOS = pWindow->m_vRealPosition.vec() + (pWindow->m_bPinned ? Vector2D{} : PWORKSPACE->m_vRenderOffset.vec()); - static auto *const PNOFLOATINGBORDERS = &g_pConfigManager->getConfigValuePtr("general:no_border_on_floating")->intValue; + const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID); + const auto REALPOS = pWindow->m_vRealPosition.vec() + (pWindow->m_bPinned ? Vector2D{} : PWORKSPACE->m_vRenderOffset.vec()); + static auto* const PNOFLOATINGBORDERS = &g_pConfigManager->getConfigValuePtr("general:no_border_on_floating")->intValue; - SRenderData renderdata = {pMonitor->output, time, REALPOS.x, REALPOS.y}; + SRenderData renderdata = {pMonitor->output, time, REALPOS.x, REALPOS.y}; if (ignorePosition) { renderdata.x = pMonitor->vecPosition.x; renderdata.y = pMonitor->vecPosition.y; @@ -239,19 +238,20 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, CMonitor* pMonitor, timespec* if (ignoreAllGeometry) decorate = false; - renderdata.surface = g_pXWaylandManager->getWindowSurface(pWindow); - renderdata.w = std::max(pWindow->m_vRealSize.vec().x, 5.0); // clamp the size to min 5, - renderdata.h = std::max(pWindow->m_vRealSize.vec().y, 5.0); // otherwise we'll have issues later with invalid boxes + renderdata.surface = g_pXWaylandManager->getWindowSurface(pWindow); + renderdata.w = std::max(pWindow->m_vRealSize.vec().x, 5.0); // clamp the size to min 5, + renderdata.h = std::max(pWindow->m_vRealSize.vec().y, 5.0); // otherwise we'll have issues later with invalid boxes renderdata.dontRound = (pWindow->m_bIsFullscreen && PWORKSPACE->m_efFullscreenMode == FULLSCREEN_FULL) || (!pWindow->m_sSpecialRenderData.rounding); renderdata.fadeAlpha = pWindow->m_fAlpha.fl() * (pWindow->m_bPinned ? 1.f : (PWORKSPACE->m_fAlpha.fl() / 255.f)); - renderdata.alpha = pWindow->m_fActiveInactiveAlpha.fl(); - renderdata.decorate = decorate && !pWindow->m_bX11DoesntWantBorders && (pWindow->m_bIsFloating ? *PNOFLOATINGBORDERS == 0 : true) && (!pWindow->m_bIsFullscreen || PWORKSPACE->m_efFullscreenMode != FULLSCREEN_FULL); + renderdata.alpha = pWindow->m_fActiveInactiveAlpha.fl(); + renderdata.decorate = decorate && !pWindow->m_bX11DoesntWantBorders && (pWindow->m_bIsFloating ? *PNOFLOATINGBORDERS == 0 : true) && + (!pWindow->m_bIsFullscreen || PWORKSPACE->m_efFullscreenMode != FULLSCREEN_FULL); renderdata.rounding = ignoreAllGeometry ? 0 : pWindow->m_sAdditionalConfigData.rounding; - renderdata.blur = !ignoreAllGeometry; // if it shouldn't, it will be ignored later - renderdata.pWindow = pWindow; + renderdata.blur = !ignoreAllGeometry; // if it shouldn't, it will be ignored later + renderdata.pWindow = pWindow; if (ignoreAllGeometry) { - renderdata.alpha = 1.f; + renderdata.alpha = 1.f; renderdata.fadeAlpha = 255.f; } @@ -265,9 +265,9 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, CMonitor* pMonitor, timespec* Vector2D offset; if (!ignorePosition && pWindow->m_bIsFloating && !pWindow->m_bPinned) { if (PWORKSPACE->m_vRenderOffset.vec().x != 0) { - const auto PWSMON = g_pCompositor->getMonitorFromID(PWORKSPACE->m_iMonitorID); + const auto PWSMON = g_pCompositor->getMonitorFromID(PWORKSPACE->m_iMonitorID); const auto PROGRESS = PWORKSPACE->m_vRenderOffset.vec().x / PWSMON->vecSize.x; - const auto WINBB = pWindow->getFullWindowBoundingBox(); + const auto WINBB = pWindow->getFullWindowBoundingBox(); if (WINBB.x < PWSMON->vecPosition.x) { offset.x = (PWSMON->vecPosition.x - WINBB.x) * PROGRESS; @@ -275,9 +275,9 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, CMonitor* pMonitor, timespec* offset.x = (WINBB.x + WINBB.width - PWSMON->vecPosition.x - PWSMON->vecSize.x) * PROGRESS; } } else if (PWORKSPACE->m_vRenderOffset.vec().y) { - const auto PWSMON = g_pCompositor->getMonitorFromID(PWORKSPACE->m_iMonitorID); + const auto PWSMON = g_pCompositor->getMonitorFromID(PWORKSPACE->m_iMonitorID); const auto PROGRESS = PWORKSPACE->m_vRenderOffset.vec().y / PWSMON->vecSize.y; - const auto WINBB = pWindow->getFullWindowBoundingBox(); + const auto WINBB = pWindow->getFullWindowBoundingBox(); if (WINBB.y < PWSMON->vecPosition.y) { offset.y = (PWSMON->vecPosition.y - WINBB.y) * PROGRESS; @@ -289,25 +289,26 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, CMonitor* pMonitor, timespec* renderdata.x += offset.x; renderdata.y += offset.y; } - + // render window decorations first, if not fullscreen full if (mode == RENDER_PASS_ALL || mode == RENDER_PASS_MAIN) { - if (!pWindow->m_bIsFullscreen || PWORKSPACE->m_efFullscreenMode != FULLSCREEN_FULL) for (auto& wd : pWindow->m_dWindowDecorations) + if (!pWindow->m_bIsFullscreen || PWORKSPACE->m_efFullscreenMode != FULLSCREEN_FULL) + for (auto& wd : pWindow->m_dWindowDecorations) wd->draw(pMonitor, renderdata.alpha * renderdata.fadeAlpha / 255.f, offset); wlr_surface_for_each_surface(g_pXWaylandManager->getWindowSurface(pWindow), renderSurface, &renderdata); if (renderdata.decorate && pWindow->m_sSpecialRenderData.border) { - static auto *const PROUNDING = &g_pConfigManager->getConfigValuePtr("decoration:rounding")->intValue; + static auto* const PROUNDING = &g_pConfigManager->getConfigValuePtr("decoration:rounding")->intValue; - float rounding = renderdata.dontRound ? 0 : renderdata.rounding == -1 ? *PROUNDING : renderdata.rounding; + float rounding = renderdata.dontRound ? 0 : renderdata.rounding == -1 ? *PROUNDING : renderdata.rounding; rounding *= pMonitor->scale; - auto grad = g_pHyprOpenGL->m_pCurrentWindow->m_cRealBorderColor; + auto grad = g_pHyprOpenGL->m_pCurrentWindow->m_cRealBorderColor; const bool ANIMATED = g_pHyprOpenGL->m_pCurrentWindow->m_fBorderAnimationProgress.isBeingAnimated(); - float a1 = renderdata.fadeAlpha * renderdata.alpha / 255.f * (ANIMATED ? g_pHyprOpenGL->m_pCurrentWindow->m_fBorderAnimationProgress.fl() : 1.f); + float a1 = renderdata.fadeAlpha * renderdata.alpha / 255.f * (ANIMATED ? g_pHyprOpenGL->m_pCurrentWindow->m_fBorderAnimationProgress.fl() : 1.f); - wlr_box windowBox = {renderdata.x - pMonitor->vecPosition.x, renderdata.y - pMonitor->vecPosition.y, renderdata.w, renderdata.h}; + wlr_box windowBox = {renderdata.x - pMonitor->vecPosition.x, renderdata.y - pMonitor->vecPosition.y, renderdata.w, renderdata.h}; scaleBox(&windowBox, pMonitor->scale); @@ -328,15 +329,15 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, CMonitor* pMonitor, timespec* renderdata.x -= geom.x; renderdata.y -= geom.y; - renderdata.dontRound = true; // don't round popups - renderdata.pMonitor = pMonitor; + renderdata.dontRound = true; // don't round popups + renderdata.pMonitor = pMonitor; renderdata.squishOversized = false; // don't squish popups wlr_xdg_surface_for_each_popup_surface(pWindow->m_uSurface.xdg, renderSurface, &renderdata); } } - g_pHyprOpenGL->m_pCurrentWindow = nullptr; - g_pHyprOpenGL->m_RenderData.clipBox = { 0, 0, 0, 0 }; + g_pHyprOpenGL->m_pCurrentWindow = nullptr; + g_pHyprOpenGL->m_RenderData.clipBox = {0, 0, 0, 0}; } void CHyprRenderer::renderLayer(SLayerSurface* pLayer, CMonitor* pMonitor, timespec* time) { @@ -345,29 +346,29 @@ void CHyprRenderer::renderLayer(SLayerSurface* pLayer, CMonitor* pMonitor, times return; } - SRenderData renderdata = {pMonitor->output, time, pLayer->geometry.x, pLayer->geometry.y}; - renderdata.fadeAlpha = pLayer->alpha.fl(); - renderdata.blur = pLayer->forceBlur; - renderdata.surface = pLayer->layerSurface->surface; - renderdata.decorate = false; - renderdata.w = pLayer->layerSurface->surface->current.width; - renderdata.h = pLayer->layerSurface->surface->current.height; + SRenderData renderdata = {pMonitor->output, time, pLayer->geometry.x, pLayer->geometry.y}; + renderdata.fadeAlpha = pLayer->alpha.fl(); + renderdata.blur = pLayer->forceBlur; + renderdata.surface = pLayer->layerSurface->surface; + renderdata.decorate = false; + renderdata.w = pLayer->layerSurface->surface->current.width; + renderdata.h = pLayer->layerSurface->surface->current.height; renderdata.blockBlurOptimization = pLayer->layer == ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM || pLayer->layer == ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND; wlr_surface_for_each_surface(pLayer->layerSurface->surface, renderSurface, &renderdata); - renderdata.squishOversized = false; // don't squish popups - renderdata.dontRound = true; + renderdata.squishOversized = false; // don't squish popups + renderdata.dontRound = true; wlr_layer_surface_v1_for_each_popup_surface(pLayer->layerSurface, renderSurface, &renderdata); } void CHyprRenderer::renderIMEPopup(SIMEPopup* pPopup, CMonitor* pMonitor, timespec* time) { SRenderData renderdata = {pMonitor->output, time, pPopup->realX, pPopup->realY}; - renderdata.blur = false; - renderdata.surface = pPopup->pSurface->surface; + renderdata.blur = false; + renderdata.surface = pPopup->pSurface->surface; renderdata.decorate = false; - renderdata.w = pPopup->pSurface->surface->current.width; - renderdata.h = pPopup->pSurface->surface->current.height; + renderdata.w = pPopup->pSurface->surface->current.width; + renderdata.h = pPopup->pSurface->surface->current.height; wlr_surface_for_each_surface(pPopup->pSurface->surface, renderSurface, &renderdata); } @@ -406,14 +407,14 @@ void CHyprRenderer::renderAllClientsForMonitor(const int& ID, timespec* time) { continue; if (w->m_bIsFloating) - continue; // floating are in the second pass + continue; // floating are in the second pass if (g_pCompositor->isWorkspaceSpecial(w->m_iWorkspaceID)) - continue; // special are in the third pass + continue; // special are in the third pass if (!shouldRenderWindow(w.get(), PMONITOR)) continue; - + // render active window after all others of this pass if (w.get() == g_pCompositor->m_pLastWindow) { lastWindow = w.get(); @@ -433,7 +434,7 @@ void CHyprRenderer::renderAllClientsForMonitor(const int& ID, timespec* time) { continue; if (w->m_bIsFloating) - continue; // floating are in the second pass + continue; // floating are in the second pass if (g_pCompositor->isWorkspaceSpecial(w->m_iWorkspaceID)) continue; // special are in the third pass @@ -500,7 +501,7 @@ void CHyprRenderer::calculateUVForWindowSurface(CWindow* pWindow, wlr_surface* p Vector2D uvTL; Vector2D uvBR = Vector2D(1, 1); - wlr_box geom; + wlr_box geom; wlr_xdg_surface_get_geometry(pWindow->m_uSurface.xdg, &geom); const auto SUBSURFACE = g_pXWaylandManager->getWindowSurface(pWindow) != pSurface && main; @@ -517,27 +518,34 @@ void CHyprRenderer::calculateUVForWindowSurface(CWindow* pWindow, wlr_surface* p if (uvBR.x < 0.01f || uvBR.y < 0.01f) { uvTL = Vector2D(); - uvBR = Vector2D(1,1); + uvBR = Vector2D(1, 1); } // TODO: (example: chromium) this still has a tiny "bump" at the end. if (main) { - uvTL = uvTL + (Vector2D((double)geom.x / ((double)pWindow->m_uSurface.xdg->surface->current.width), (double)geom.y / ((double)pWindow->m_uSurface.xdg->surface->current.height)) * (((uvBR.x - uvTL.x) * surfaceSize.x) / surfaceSize.x)); - uvBR = uvBR * Vector2D((double)(geom.width + geom.x) / ((double)pWindow->m_uSurface.xdg->surface->current.width), (double)(geom.y + geom.height) / ((double)pWindow->m_uSurface.xdg->surface->current.height)); + uvTL = uvTL + + (Vector2D((double)geom.x / ((double)pWindow->m_uSurface.xdg->surface->current.width), + (double)geom.y / ((double)pWindow->m_uSurface.xdg->surface->current.height)) * + (((uvBR.x - uvTL.x) * surfaceSize.x) / surfaceSize.x)); + uvBR = uvBR * + Vector2D((double)(geom.width + geom.x) / ((double)pWindow->m_uSurface.xdg->surface->current.width), + (double)(geom.y + geom.height) / ((double)pWindow->m_uSurface.xdg->surface->current.height)); } } else if (main) { // oversized windows' UV adjusting - uvTL = Vector2D((double)geom.x / ((double)pWindow->m_uSurface.xdg->surface->current.width), (double)geom.y / ((double)pWindow->m_uSurface.xdg->surface->current.height)); - uvBR = Vector2D((double)(geom.width + geom.x) / ((double)pWindow->m_uSurface.xdg->surface->current.width), (double)(geom.y + geom.height) / ((double)pWindow->m_uSurface.xdg->surface->current.height)); + uvTL = + Vector2D((double)geom.x / ((double)pWindow->m_uSurface.xdg->surface->current.width), (double)geom.y / ((double)pWindow->m_uSurface.xdg->surface->current.height)); + uvBR = Vector2D((double)(geom.width + geom.x) / ((double)pWindow->m_uSurface.xdg->surface->current.width), + (double)(geom.y + geom.height) / ((double)pWindow->m_uSurface.xdg->surface->current.height)); } // set UV - g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft = uvTL; + g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft = uvTL; g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight = uvBR; if (g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft == Vector2D() && g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight == Vector2D(1, 1)) { // No special UV mods needed - g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft = Vector2D(-1, -1); + g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft = Vector2D(-1, -1); g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight = Vector2D(-1, -1); } @@ -551,12 +559,14 @@ void CHyprRenderer::calculateUVForWindowSurface(CWindow* pWindow, wlr_surface* p if (g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft == Vector2D(-1, -1)) g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft = Vector2D(0, 0); - g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight = Vector2D( - g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight.x * (pWindow->m_vRealSize.vec().x / ((double)geom.width / g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight.x)), - g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight.y * (pWindow->m_vRealSize.vec().y / ((double)geom.height / g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight.y))); + g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight = + Vector2D(g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight.x * + (pWindow->m_vRealSize.vec().x / ((double)geom.width / g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight.x)), + g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight.y * + (pWindow->m_vRealSize.vec().y / ((double)geom.height / g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight.y))); } } else { - g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft = Vector2D(-1, -1); + g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft = Vector2D(-1, -1); g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight = Vector2D(-1, -1); } } @@ -582,7 +592,8 @@ bool CHyprRenderer::attemptDirectScanout(CMonitor* pMonitor) { if (PCANDIDATE->m_fAlpha.fl() != 255.f || PCANDIDATE->m_fActiveInactiveAlpha.fl() != 1.f || PWORKSPACE->m_fAlpha.fl() != 255.f) return false; - if (PCANDIDATE->m_vRealSize.vec() != pMonitor->vecSize || PCANDIDATE->m_vRealPosition.vec() != pMonitor->vecPosition || PCANDIDATE->m_vRealPosition.isBeingAnimated() || PCANDIDATE->m_vRealSize.isBeingAnimated()) + if (PCANDIDATE->m_vRealSize.vec() != pMonitor->vecSize || PCANDIDATE->m_vRealPosition.vec() != pMonitor->vecPosition || PCANDIDATE->m_vRealPosition.isBeingAnimated() || + PCANDIDATE->m_vRealSize.isBeingAnimated()) return false; if (!pMonitor->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY].empty()) @@ -653,7 +664,7 @@ void CHyprRenderer::setWindowScanoutMode(CWindow* pWindow) { } const auto RENDERERDRMFD = wlr_renderer_get_drm_fd(g_pCompositor->m_sWLRRenderer); - const auto BACKENDDRMFD = wlr_backend_get_drm_fd(g_pCompositor->m_sWLRBackend); + const auto BACKENDDRMFD = wlr_backend_get_drm_fd(g_pCompositor->m_sWLRBackend); if (RENDERERDRMFD < 0 || BACKENDDRMFD < 0) return; @@ -677,28 +688,17 @@ void CHyprRenderer::setWindowScanoutMode(CWindow* pWindow) { if (!POUTPUTFORMATS) return; - const auto PRENDERERFORMATS = wlr_renderer_get_dmabuf_texture_formats(g_pCompositor->m_sWLRRenderer); - wlr_drm_format_set scanoutFormats = { 0 }; + const auto PRENDERERFORMATS = wlr_renderer_get_dmabuf_texture_formats(g_pCompositor->m_sWLRRenderer); + wlr_drm_format_set scanoutFormats = {0}; if (!wlr_drm_format_set_intersect(&scanoutFormats, POUTPUTFORMATS, PRENDERERFORMATS)) return; const wlr_linux_dmabuf_feedback_v1_tranche TRANCHES[] = { - { - .target_device = scanoutDevice, - .flags = ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FLAGS_SCANOUT, - .formats = &scanoutFormats - }, { - .target_device = rendererDevice, - .formats = PRENDERERFORMATS - } - }; + {.target_device = scanoutDevice, .flags = ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FLAGS_SCANOUT, .formats = &scanoutFormats}, + {.target_device = rendererDevice, .formats = PRENDERERFORMATS}}; - const wlr_linux_dmabuf_feedback_v1 FEEDBACK = { - .main_device = rendererDevice, - .tranches_len = sizeof(TRANCHES) / sizeof(TRANCHES[0]), - .tranches = TRANCHES - }; + const wlr_linux_dmabuf_feedback_v1 FEEDBACK = {.main_device = rendererDevice, .tranches_len = sizeof(TRANCHES) / sizeof(TRANCHES[0]), .tranches = TRANCHES}; if (!wlr_linux_dmabuf_v1_set_surface_feedback(g_pCompositor->m_sWLRLinuxDMABuf, g_pXWaylandManager->getWindowSurface(pWindow), &FEEDBACK)) { Debug::log(ERR, "Error in scanout mode setting: wlr_linux_dmabuf_v1_set_surface_feedback returned false."); @@ -711,12 +711,12 @@ void CHyprRenderer::setWindowScanoutMode(CWindow* pWindow) { void CHyprRenderer::outputMgrApplyTest(wlr_output_configuration_v1* config, bool test) { wlr_output_configuration_head_v1* head; - bool noError = true; + bool noError = true; wl_list_for_each(head, &config->heads, link) { std::string commandForCfg = ""; - const auto OUTPUT = head->state.output; + const auto OUTPUT = head->state.output; commandForCfg += std::string(OUTPUT->name) + ","; @@ -730,9 +730,11 @@ void CHyprRenderer::outputMgrApplyTest(wlr_output_configuration_v1* config, bool wlr_output_enable(OUTPUT, head->state.enabled); if (head->state.mode) - commandForCfg += std::to_string(head->state.mode->width) + "x" + std::to_string(head->state.mode->height) + "@" + std::to_string(head->state.mode->refresh / 1000.f) + ","; + commandForCfg += + std::to_string(head->state.mode->width) + "x" + std::to_string(head->state.mode->height) + "@" + std::to_string(head->state.mode->refresh / 1000.f) + ","; else - commandForCfg += std::to_string(head->state.custom_mode.width) + "x" + std::to_string(head->state.custom_mode.height) + "@" + std::to_string(head->state.custom_mode.refresh / 1000.f) + ","; + commandForCfg += std::to_string(head->state.custom_mode.width) + "x" + std::to_string(head->state.custom_mode.height) + "@" + + std::to_string(head->state.custom_mode.refresh / 1000.f) + ","; commandForCfg += std::to_string(head->state.x) + "x" + std::to_string(head->state.y) + "," + std::to_string(head->state.scale); @@ -741,7 +743,7 @@ void CHyprRenderer::outputMgrApplyTest(wlr_output_configuration_v1* config, bool std::string transformStr = std::string(OUTPUT->name) + ",transform," + std::to_string((int)OUTPUT->transform); - const auto PMONITOR = g_pCompositor->getMonitorFromName(OUTPUT->name); + const auto PMONITOR = g_pCompositor->getMonitorFromName(OUTPUT->name); if (!PMONITOR || OUTPUT->transform != PMONITOR->transform) g_pConfigManager->parseKeyword("monitor", transformStr); @@ -754,7 +756,7 @@ void CHyprRenderer::outputMgrApplyTest(wlr_output_configuration_v1* config, bool } if (!test) - g_pConfigManager->m_bWantsMonitorReload = true; // for monitor keywords + g_pConfigManager->m_bWantsMonitorReload = true; // for monitor keywords if (noError) wlr_output_configuration_v1_send_succeeded(config); @@ -774,53 +776,41 @@ void apply_exclusive(struct wlr_box* usable_area, uint32_t anchor, int32_t exclu struct { uint32_t singular_anchor; uint32_t anchor_triplet; - int* positive_axis; - int* negative_axis; - int margin; + int* positive_axis; + int* negative_axis; + int margin; } edges[] = { // Top { .singular_anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP, - .anchor_triplet = - ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | - ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT | - ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP, - .positive_axis = &usable_area->y, - .negative_axis = &usable_area->height, - .margin = margin_top, + .anchor_triplet = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT | ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP, + .positive_axis = &usable_area->y, + .negative_axis = &usable_area->height, + .margin = margin_top, }, // Bottom { .singular_anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM, - .anchor_triplet = - ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | - ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT | - ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM, - .positive_axis = NULL, - .negative_axis = &usable_area->height, - .margin = margin_bottom, + .anchor_triplet = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT | ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM, + .positive_axis = NULL, + .negative_axis = &usable_area->height, + .margin = margin_bottom, }, // Left { .singular_anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT, - .anchor_triplet = - ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | - ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | - ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM, - .positive_axis = &usable_area->x, - .negative_axis = &usable_area->width, - .margin = margin_left, + .anchor_triplet = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM, + .positive_axis = &usable_area->x, + .negative_axis = &usable_area->width, + .margin = margin_left, }, // Right { .singular_anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT, - .anchor_triplet = - ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT | - ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | - ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM, - .positive_axis = NULL, - .negative_axis = &usable_area->width, - .margin = margin_right, + .anchor_triplet = ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT | ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM, + .positive_axis = NULL, + .negative_axis = &usable_area->width, + .margin = margin_right, }, }; for (size_t i = 0; i < sizeof(edges) / sizeof(edges[0]); ++i) { @@ -856,9 +846,7 @@ void CHyprRenderer::arrangeLayerArray(CMonitor* pMonitor, const std::vector<std: bounds = *usableArea; } - wlr_box box = { - .width = PSTATE->desired_width, - .height = PSTATE->desired_height}; + wlr_box box = {.width = PSTATE->desired_width, .height = PSTATE->desired_height}; // Horizontal axis const uint32_t both_horiz = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT; if (box.width == 0) { @@ -888,8 +876,7 @@ void CHyprRenderer::arrangeLayerArray(CMonitor* pMonitor, const std::vector<std: // Margin if (box.width == 0) { box.x += PSTATE->margin.left; - box.width = bounds.width - - (PSTATE->margin.left + PSTATE->margin.right); + box.width = bounds.width - (PSTATE->margin.left + PSTATE->margin.right); } else if ((PSTATE->anchor & both_horiz) == both_horiz) { // don't apply margins } else if ((PSTATE->anchor & ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT)) { @@ -899,8 +886,7 @@ void CHyprRenderer::arrangeLayerArray(CMonitor* pMonitor, const std::vector<std: } if (box.height == 0) { box.y += PSTATE->margin.top; - box.height = bounds.height - - (PSTATE->margin.top + PSTATE->margin.bottom); + box.height = bounds.height - (PSTATE->margin.top + PSTATE->margin.bottom); } else if ((PSTATE->anchor & both_vert) == both_vert) { // don't apply margins } else if ((PSTATE->anchor & ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP)) { @@ -919,7 +905,8 @@ void CHyprRenderer::arrangeLayerArray(CMonitor* pMonitor, const std::vector<std: wlr_layer_surface_v1_configure(ls->layerSurface, box.width, box.height); - Debug::log(LOG, "LayerSurface %x arranged: x: %i y: %i w: %i h: %i with margins: t: %i l: %i r: %i b: %i", &ls, box.x, box.y, box.width, box.height, PSTATE->margin.top, PSTATE->margin.left, PSTATE->margin.right, PSTATE->margin.bottom); + Debug::log(LOG, "LayerSurface %x arranged: x: %i y: %i w: %i h: %i with margins: t: %i l: %i r: %i b: %i", &ls, box.x, box.y, box.width, box.height, PSTATE->margin.top, + PSTATE->margin.left, PSTATE->margin.right, PSTATE->margin.bottom); } } @@ -930,8 +917,8 @@ void CHyprRenderer::arrangeLayersForMonitor(const int& monitor) { return; // Reset the reserved - PMONITOR->vecReservedBottomRight = Vector2D(); - PMONITOR->vecReservedTopLeft = Vector2D(); + PMONITOR->vecReservedBottomRight = Vector2D(); + PMONITOR->vecReservedTopLeft = Vector2D(); wlr_box usableArea = {PMONITOR->vecPosition.x, PMONITOR->vecPosition.y, PMONITOR->vecSize.x, PMONITOR->vecSize.y}; @@ -941,16 +928,16 @@ void CHyprRenderer::arrangeLayersForMonitor(const int& monitor) { for (auto& la : PMONITOR->m_aLayerSurfaceLists) arrangeLayerArray(PMONITOR, la, false, &usableArea); - PMONITOR->vecReservedTopLeft = Vector2D(usableArea.x, usableArea.y) - PMONITOR->vecPosition; + PMONITOR->vecReservedTopLeft = Vector2D(usableArea.x, usableArea.y) - PMONITOR->vecPosition; PMONITOR->vecReservedBottomRight = PMONITOR->vecSize - Vector2D(usableArea.width, usableArea.height) - PMONITOR->vecReservedTopLeft; auto ADDITIONALRESERVED = g_pConfigManager->m_mAdditionalReservedAreas.find(PMONITOR->szName); if (ADDITIONALRESERVED == g_pConfigManager->m_mAdditionalReservedAreas.end()) { - ADDITIONALRESERVED = g_pConfigManager->m_mAdditionalReservedAreas.find(""); // glob wildcard + ADDITIONALRESERVED = g_pConfigManager->m_mAdditionalReservedAreas.find(""); // glob wildcard } if (ADDITIONALRESERVED != g_pConfigManager->m_mAdditionalReservedAreas.end()) { - PMONITOR->vecReservedTopLeft = PMONITOR->vecReservedTopLeft + Vector2D(ADDITIONALRESERVED->second.left, ADDITIONALRESERVED->second.top); + PMONITOR->vecReservedTopLeft = PMONITOR->vecReservedTopLeft + Vector2D(ADDITIONALRESERVED->second.left, ADDITIONALRESERVED->second.top); PMONITOR->vecReservedBottomRight = PMONITOR->vecReservedBottomRight + Vector2D(ADDITIONALRESERVED->second.right, ADDITIONALRESERVED->second.bottom); } @@ -960,7 +947,8 @@ void CHyprRenderer::arrangeLayersForMonitor(const int& monitor) { g_pLayoutManager->getCurrentLayout()->recalculateMonitor(monitor); - Debug::log(LOG, "Monitor %s layers arranged: reserved: %f %f %f %f", PMONITOR->szName.c_str(), PMONITOR->vecReservedTopLeft.x, PMONITOR->vecReservedTopLeft.y, PMONITOR->vecReservedBottomRight.x, PMONITOR->vecReservedBottomRight.y); + Debug::log(LOG, "Monitor %s layers arranged: reserved: %f %f %f %f", PMONITOR->szName.c_str(), PMONITOR->vecReservedTopLeft.x, PMONITOR->vecReservedTopLeft.y, + PMONITOR->vecReservedBottomRight.x, PMONITOR->vecReservedBottomRight.y); } void CHyprRenderer::damageSurface(wlr_surface* pSurface, double x, double y) { @@ -1001,10 +989,11 @@ void CHyprRenderer::damageSurface(wlr_surface* pSurface, double x, double y) { pixman_region32_fini(&damageBoxForEach); - static auto *const PLOGDAMAGE = &g_pConfigManager->getConfigValuePtr("debug:log_damage")->intValue; + static auto* const PLOGDAMAGE = &g_pConfigManager->getConfigValuePtr("debug:log_damage")->intValue; if (*PLOGDAMAGE) - Debug::log(LOG, "Damage: Surface (extents): xy: %d, %d wh: %d, %d", damageBox.extents.x1, damageBox.extents.y1, damageBox.extents.x2 - damageBox.extents.x1, damageBox.extents.y2 - damageBox.extents.y1); + Debug::log(LOG, "Damage: Surface (extents): xy: %d, %d wh: %d, %d", damageBox.extents.x1, damageBox.extents.y1, damageBox.extents.x2 - damageBox.extents.x1, + damageBox.extents.y2 - damageBox.extents.y1); pixman_region32_fini(&damageBox); } @@ -1020,7 +1009,7 @@ void CHyprRenderer::damageWindow(CWindow* pWindow) { m->addDamage(&fixedDamageBox); } - static auto *const PLOGDAMAGE = &g_pConfigManager->getConfigValuePtr("debug:log_damage")->intValue; + static auto* const PLOGDAMAGE = &g_pConfigManager->getConfigValuePtr("debug:log_damage")->intValue; if (*PLOGDAMAGE) Debug::log(LOG, "Damage: Window (%s): xy: %d, %d wh: %d, %d", pWindow->m_szTitle.c_str(), damageBox.x, damageBox.y, damageBox.width, damageBox.height); @@ -1030,10 +1019,10 @@ void CHyprRenderer::damageMonitor(CMonitor* pMonitor) { if (g_pCompositor->m_bUnsafeState || pMonitor->isMirror()) return; - wlr_box damageBox = { 0, 0, INT16_MAX, INT16_MAX }; + wlr_box damageBox = {0, 0, INT16_MAX, INT16_MAX}; pMonitor->addDamage(&damageBox); - static auto *const PLOGDAMAGE = &g_pConfigManager->getConfigValuePtr("debug:log_damage")->intValue; + static auto* const PLOGDAMAGE = &g_pConfigManager->getConfigValuePtr("debug:log_damage")->intValue; if (*PLOGDAMAGE) Debug::log(LOG, "Damage: Monitor %s", pMonitor->szName.c_str()); @@ -1052,7 +1041,7 @@ void CHyprRenderer::damageBox(wlr_box* pBox) { m->addDamage(&damageBox); } - static auto *const PLOGDAMAGE = &g_pConfigManager->getConfigValuePtr("debug:log_damage")->intValue; + static auto* const PLOGDAMAGE = &g_pConfigManager->getConfigValuePtr("debug:log_damage")->intValue; if (*PLOGDAMAGE) Debug::log(LOG, "Damage: Box: xy: %d, %d wh: %d, %d", pBox->x, pBox->y, pBox->width, pBox->height); @@ -1072,7 +1061,7 @@ void CHyprRenderer::damageRegion(pixman_region32_t* rg) { void CHyprRenderer::damageMirrorsWith(CMonitor* pMonitor, pixman_region32_t* pRegion) { for (auto& mirror : pMonitor->mirrors) { - Vector2D scale = {mirror->vecSize.x / pMonitor->vecSize.x, mirror->vecSize.y / pMonitor->vecSize.y}; + Vector2D scale = {mirror->vecSize.x / pMonitor->vecSize.x, mirror->vecSize.y / pMonitor->vecSize.y}; pixman_region32_t rg; pixman_region32_init(&rg); @@ -1088,13 +1077,14 @@ void CHyprRenderer::renderDragIcon(CMonitor* pMonitor, timespec* time) { return; SRenderData renderdata = {pMonitor->output, time, g_pInputManager->m_sDrag.pos.x, g_pInputManager->m_sDrag.pos.y}; - renderdata.surface = g_pInputManager->m_sDrag.dragIcon->surface; - renderdata.w = g_pInputManager->m_sDrag.dragIcon->surface->current.width; - renderdata.h = g_pInputManager->m_sDrag.dragIcon->surface->current.height; + renderdata.surface = g_pInputManager->m_sDrag.dragIcon->surface; + renderdata.w = g_pInputManager->m_sDrag.dragIcon->surface->current.width; + renderdata.h = g_pInputManager->m_sDrag.dragIcon->surface->current.height; wlr_surface_for_each_surface(g_pInputManager->m_sDrag.dragIcon->surface, renderSurface, &renderdata); - wlr_box box = {g_pInputManager->m_sDrag.pos.x - 2, g_pInputManager->m_sDrag.pos.y - 2, g_pInputManager->m_sDrag.dragIcon->surface->current.width + 4, g_pInputManager->m_sDrag.dragIcon->surface->current.height + 4}; + wlr_box box = {g_pInputManager->m_sDrag.pos.x - 2, g_pInputManager->m_sDrag.pos.y - 2, g_pInputManager->m_sDrag.dragIcon->surface->current.width + 4, + g_pInputManager->m_sDrag.dragIcon->surface->current.height + 4}; g_pHyprRenderer->damageBox(&box); } @@ -1128,14 +1118,11 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR } // Check if the rule isn't already applied - if (!force - && DELTALESSTHAN(pMonitor->vecPixelSize.x, pMonitorRule->resolution.x, 1) - && DELTALESSTHAN(pMonitor->vecPixelSize.y, pMonitorRule->resolution.y, 1) - && DELTALESSTHAN(pMonitor->refreshRate, pMonitorRule->refreshRate, 1) - && pMonitor->scale == pMonitorRule->scale - && ((DELTALESSTHAN(pMonitor->vecPosition.x, pMonitorRule->offset.x, 1) && DELTALESSTHAN(pMonitor->vecPosition.y, pMonitorRule->offset.y, 1)) || pMonitorRule->offset == Vector2D(-1, -1)) - && pMonitor->transform == pMonitorRule->transform - && pMonitorRule->enable10bit == pMonitor->enabled10bit) { + if (!force && DELTALESSTHAN(pMonitor->vecPixelSize.x, pMonitorRule->resolution.x, 1) && DELTALESSTHAN(pMonitor->vecPixelSize.y, pMonitorRule->resolution.y, 1) && + DELTALESSTHAN(pMonitor->refreshRate, pMonitorRule->refreshRate, 1) && pMonitor->scale == pMonitorRule->scale && + ((DELTALESSTHAN(pMonitor->vecPosition.x, pMonitorRule->offset.x, 1) && DELTALESSTHAN(pMonitor->vecPosition.y, pMonitorRule->offset.y, 1)) || + pMonitorRule->offset == Vector2D(-1, -1)) && + pMonitor->transform == pMonitorRule->transform && pMonitorRule->enable10bit == pMonitor->enabled10bit) { Debug::log(LOG, "Not applying a new rule to %s because it's already applied!", pMonitor->szName.c_str()); return true; @@ -1154,31 +1141,30 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR pMonitor->transform = pMonitorRule->transform; // loop over modes and choose an appropriate one. - if (pMonitorRule->resolution != Vector2D() && pMonitorRule->resolution != Vector2D(-1,-1) && pMonitorRule->resolution != Vector2D(-1,-2)) { + if (pMonitorRule->resolution != Vector2D() && pMonitorRule->resolution != Vector2D(-1, -1) && pMonitorRule->resolution != Vector2D(-1, -2)) { if (!wl_list_empty(&pMonitor->output->modes)) { wlr_output_mode* mode; - bool found = false; + bool found = false; wl_list_for_each(mode, &pMonitor->output->modes, link) { // if delta of refresh rate, w and h chosen and mode is < 1 we accept it - if (DELTALESSTHAN(mode->width, pMonitorRule->resolution.x, 1) && DELTALESSTHAN(mode->height, pMonitorRule->resolution.y, 1) && DELTALESSTHAN(mode->refresh / 1000.f, pMonitorRule->refreshRate, 1)) { + if (DELTALESSTHAN(mode->width, pMonitorRule->resolution.x, 1) && DELTALESSTHAN(mode->height, pMonitorRule->resolution.y, 1) && + DELTALESSTHAN(mode->refresh / 1000.f, pMonitorRule->refreshRate, 1)) { wlr_output_set_mode(pMonitor->output, mode); if (!wlr_output_test(pMonitor->output)) { - Debug::log(LOG, "Monitor %s: REJECTED available mode: %ix%i@%2f!", - pMonitor->output->name, (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate, - mode->width, mode->height, mode->refresh / 1000.f); + Debug::log(LOG, "Monitor %s: REJECTED available mode: %ix%i@%2f!", pMonitor->output->name, (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, + (float)pMonitorRule->refreshRate, mode->width, mode->height, mode->refresh / 1000.f); continue; } - Debug::log(LOG, "Monitor %s: requested %ix%i@%2f, found available mode: %ix%i@%imHz, applying.", - pMonitor->output->name, (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate, - mode->width, mode->height, mode->refresh); + Debug::log(LOG, "Monitor %s: requested %ix%i@%2f, found available mode: %ix%i@%imHz, applying.", pMonitor->output->name, (int)pMonitorRule->resolution.x, + (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate, mode->width, mode->height, mode->refresh); found = true; pMonitor->refreshRate = mode->refresh / 1000.f; - pMonitor->vecSize = Vector2D(mode->width, mode->height); + pMonitor->vecSize = Vector2D(mode->width, mode->height); break; } @@ -1186,7 +1172,7 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR if (!found) { wlr_output_set_custom_mode(pMonitor->output, (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (int)pMonitorRule->refreshRate * 1000); - pMonitor->vecSize = pMonitorRule->resolution; + pMonitor->vecSize = pMonitorRule->resolution; pMonitor->refreshRate = pMonitorRule->refreshRate; if (!wlr_output_test(pMonitor->output)) { @@ -1195,27 +1181,28 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR const auto PREFERREDMODE = wlr_output_preferred_mode(pMonitor->output); if (!PREFERREDMODE) { - Debug::log(ERR, "Monitor %s has NO PREFERRED MODE, and an INVALID one was requested: %ix%i@%2f", - (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate); + Debug::log(ERR, "Monitor %s has NO PREFERRED MODE, and an INVALID one was requested: %ix%i@%2f", (int)pMonitorRule->resolution.x, + (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate); return true; } // Preferred is valid wlr_output_set_mode(pMonitor->output, PREFERREDMODE); - Debug::log(ERR, "Monitor %s got an invalid requested mode: %ix%i@%2f, using the preferred one instead: %ix%i@%2f", - pMonitor->output->name, (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate, - PREFERREDMODE->width, PREFERREDMODE->height, PREFERREDMODE->refresh / 1000.f); + Debug::log(ERR, "Monitor %s got an invalid requested mode: %ix%i@%2f, using the preferred one instead: %ix%i@%2f", pMonitor->output->name, + (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate, PREFERREDMODE->width, PREFERREDMODE->height, + PREFERREDMODE->refresh / 1000.f); pMonitor->refreshRate = PREFERREDMODE->refresh / 1000.f; - pMonitor->vecSize = Vector2D(PREFERREDMODE->width, PREFERREDMODE->height); + pMonitor->vecSize = Vector2D(PREFERREDMODE->width, PREFERREDMODE->height); } else { - Debug::log(LOG, "Set a custom mode %ix%i@%2f (mode not found in monitor modes)", (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate); + Debug::log(LOG, "Set a custom mode %ix%i@%2f (mode not found in monitor modes)", (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, + (float)pMonitorRule->refreshRate); } } } else { wlr_output_set_custom_mode(pMonitor->output, (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (int)pMonitorRule->refreshRate * 1000); - pMonitor->vecSize = pMonitorRule->resolution; + pMonitor->vecSize = pMonitorRule->resolution; pMonitor->refreshRate = pMonitorRule->refreshRate; if (!wlr_output_test(pMonitor->output)) { @@ -1224,94 +1211,96 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR const auto PREFERREDMODE = wlr_output_preferred_mode(pMonitor->output); if (!PREFERREDMODE) { - Debug::log(ERR, "Monitor %s has NO PREFERRED MODE, and an INVALID one was requested: %ix%i@%2f", (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate); + Debug::log(ERR, "Monitor %s has NO PREFERRED MODE, and an INVALID one was requested: %ix%i@%2f", (int)pMonitorRule->resolution.x, + (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate); return true; } // Preferred is valid wlr_output_set_mode(pMonitor->output, PREFERREDMODE); - Debug::log(ERR, "Monitor %s got an invalid requested mode: %ix%i@%2f, using the preferred one instead: %ix%i@%2f", pMonitor->output->name, (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate, PREFERREDMODE->width, PREFERREDMODE->height, PREFERREDMODE->refresh / 1000.f); + Debug::log(ERR, "Monitor %s got an invalid requested mode: %ix%i@%2f, using the preferred one instead: %ix%i@%2f", pMonitor->output->name, + (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate, PREFERREDMODE->width, PREFERREDMODE->height, + PREFERREDMODE->refresh / 1000.f); pMonitor->refreshRate = PREFERREDMODE->refresh / 1000.f; - pMonitor->vecSize = Vector2D(PREFERREDMODE->width, PREFERREDMODE->height); + pMonitor->vecSize = Vector2D(PREFERREDMODE->width, PREFERREDMODE->height); } else { - Debug::log(LOG, "Set a custom mode %ix%i@%2f (mode not found in monitor modes)", (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate); + Debug::log(LOG, "Set a custom mode %ix%i@%2f (mode not found in monitor modes)", (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, + (float)pMonitorRule->refreshRate); } } } else if (pMonitorRule->resolution != Vector2D()) { if (!wl_list_empty(&pMonitor->output->modes)) { wlr_output_mode* mode; - float currentWidth = 0; - float currentHeight = 0; - float currentRefresh = 0; - bool success = false; + float currentWidth = 0; + float currentHeight = 0; + float currentRefresh = 0; + bool success = false; //(-1,-1) indicates a preference to refreshrate over resolution, (-1,-2) preference to resolution - if(pMonitorRule->resolution == Vector2D(-1,-1)) { + if (pMonitorRule->resolution == Vector2D(-1, -1)) { wl_list_for_each(mode, &pMonitor->output->modes, link) { - if( ( mode->width >= currentWidth && mode->height >= currentHeight && mode->refresh >= ( currentRefresh - 1000.f ) ) || mode->refresh > ( currentRefresh + 3000.f ) ) { - wlr_output_set_mode(pMonitor->output, mode); - if (wlr_output_test(pMonitor->output)) { - currentWidth = mode->width; - currentHeight = mode->height; - currentRefresh = mode->refresh; - success = true; - } - } + if ((mode->width >= currentWidth && mode->height >= currentHeight && mode->refresh >= (currentRefresh - 1000.f)) || mode->refresh > (currentRefresh + 3000.f)) { + wlr_output_set_mode(pMonitor->output, mode); + if (wlr_output_test(pMonitor->output)) { + currentWidth = mode->width; + currentHeight = mode->height; + currentRefresh = mode->refresh; + success = true; + } + } } } else { wl_list_for_each(mode, &pMonitor->output->modes, link) { - if( ( mode->width >= currentWidth && mode->height >= currentHeight && mode->refresh >= ( currentRefresh - 1000.f ) ) || ( mode->width > currentWidth && mode->height > currentHeight ) ) { - wlr_output_set_mode(pMonitor->output, mode); - if (wlr_output_test(pMonitor->output)) { - currentWidth = mode->width; - currentHeight = mode->height; - currentRefresh = mode->refresh; - success = true; - } - } + if ((mode->width >= currentWidth && mode->height >= currentHeight && mode->refresh >= (currentRefresh - 1000.f)) || + (mode->width > currentWidth && mode->height > currentHeight)) { + wlr_output_set_mode(pMonitor->output, mode); + if (wlr_output_test(pMonitor->output)) { + currentWidth = mode->width; + currentHeight = mode->height; + currentRefresh = mode->refresh; + success = true; + } + } } } if (!success) { - Debug::log(LOG, "Monitor %s: REJECTED mode: %ix%i@%2f! Falling back to preferred.", - pMonitor->output->name, (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate, - mode->width, mode->height, mode->refresh / 1000.f); + Debug::log(LOG, "Monitor %s: REJECTED mode: %ix%i@%2f! Falling back to preferred.", pMonitor->output->name, (int)pMonitorRule->resolution.x, + (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate, mode->width, mode->height, mode->refresh / 1000.f); const auto PREFERREDMODE = wlr_output_preferred_mode(pMonitor->output); if (!PREFERREDMODE) { - Debug::log(ERR, "Monitor %s has NO PREFERRED MODE, and an INVALID one was requested: %ix%i@%2f", - (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate); + Debug::log(ERR, "Monitor %s has NO PREFERRED MODE, and an INVALID one was requested: %ix%i@%2f", (int)pMonitorRule->resolution.x, + (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate); return true; } // Preferred is valid wlr_output_set_mode(pMonitor->output, PREFERREDMODE); - Debug::log(ERR, "Monitor %s got an invalid requested mode: %ix%i@%2f, using the preferred one instead: %ix%i@%2f", - pMonitor->output->name, (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate, - PREFERREDMODE->width, PREFERREDMODE->height, PREFERREDMODE->refresh / 1000.f); + Debug::log(ERR, "Monitor %s got an invalid requested mode: %ix%i@%2f, using the preferred one instead: %ix%i@%2f", pMonitor->output->name, + (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate, PREFERREDMODE->width, PREFERREDMODE->height, + PREFERREDMODE->refresh / 1000.f); pMonitor->refreshRate = PREFERREDMODE->refresh / 1000.f; - pMonitor->vecSize = Vector2D(PREFERREDMODE->width, PREFERREDMODE->height); + pMonitor->vecSize = Vector2D(PREFERREDMODE->width, PREFERREDMODE->height); } else { - Debug::log(LOG, "Monitor %s: Applying highest mode %ix%i@%2f.", - pMonitor->output->name, (int)currentWidth, (int)currentHeight, (int)currentRefresh / 1000.f, + Debug::log(LOG, "Monitor %s: Applying highest mode %ix%i@%2f.", pMonitor->output->name, (int)currentWidth, (int)currentHeight, (int)currentRefresh / 1000.f, mode->width, mode->height, mode->refresh / 1000.f); pMonitor->refreshRate = currentRefresh / 1000.f; - pMonitor->vecSize = Vector2D(currentWidth, currentHeight); + pMonitor->vecSize = Vector2D(currentWidth, currentHeight); } } } else { const auto PREFERREDMODE = wlr_output_preferred_mode(pMonitor->output); if (!PREFERREDMODE) { - Debug::log(ERR, "Monitor %s has NO PREFERRED MODE", - (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate); + Debug::log(ERR, "Monitor %s has NO PREFERRED MODE", (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate); if (!wl_list_empty(&pMonitor->output->modes)) { wlr_output_mode* mode; @@ -1320,18 +1309,16 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR wlr_output_set_mode(pMonitor->output, mode); if (!wlr_output_test(pMonitor->output)) { - Debug::log(LOG, "Monitor %s: REJECTED available mode: %ix%i@%2f!", - pMonitor->output->name, (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate, - mode->width, mode->height, mode->refresh / 1000.f); + Debug::log(LOG, "Monitor %s: REJECTED available mode: %ix%i@%2f!", pMonitor->output->name, (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, + (float)pMonitorRule->refreshRate, mode->width, mode->height, mode->refresh / 1000.f); continue; } - Debug::log(LOG, "Monitor %s: requested %ix%i@%2f, found available mode: %ix%i@%imHz, applying.", - pMonitor->output->name, (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate, - mode->width, mode->height, mode->refresh); + Debug::log(LOG, "Monitor %s: requested %ix%i@%2f, found available mode: %ix%i@%imHz, applying.", pMonitor->output->name, (int)pMonitorRule->resolution.x, + (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate, mode->width, mode->height, mode->refresh); pMonitor->refreshRate = mode->refresh / 1000.f; - pMonitor->vecSize = Vector2D(mode->width, mode->height); + pMonitor->vecSize = Vector2D(mode->width, mode->height); break; } @@ -1340,14 +1327,14 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR // Preferred is valid wlr_output_set_mode(pMonitor->output, PREFERREDMODE); - pMonitor->vecSize = Vector2D(PREFERREDMODE->width, PREFERREDMODE->height); + pMonitor->vecSize = Vector2D(PREFERREDMODE->width, PREFERREDMODE->height); pMonitor->refreshRate = PREFERREDMODE->refresh / 1000.f; Debug::log(LOG, "Setting preferred mode for %s", pMonitor->output->name); } } - pMonitor->vrrActive = pMonitor->output->pending.adaptive_sync_enabled; // disabled here, will be tested in CConfigManager::ensureVRR() + pMonitor->vrrActive = pMonitor->output->pending.adaptive_sync_enabled; // disabled here, will be tested in CConfigManager::ensureVRR() pMonitor->vecPixelSize = pMonitor->vecSize; @@ -1382,12 +1369,13 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR int x, y; wlr_output_transformed_resolution(pMonitor->output, &x, &y); - pMonitor->vecSize = (Vector2D(x, y) / pMonitor->scale).floor(); - pMonitor->vecTransformedSize = Vector2D(x,y); + pMonitor->vecSize = (Vector2D(x, y) / pMonitor->scale).floor(); + pMonitor->vecTransformedSize = Vector2D(x, y); if (pMonitor->createdByUser) { - wlr_box transformedBox = { 0, 0, (int)pMonitor->vecTransformedSize.x, (int)pMonitor->vecTransformedSize.y }; - wlr_box_transform(&transformedBox, &transformedBox, wlr_output_transform_invert(pMonitor->output->transform), (int)pMonitor->vecTransformedSize.x, (int)pMonitor->vecTransformedSize.y); + wlr_box transformedBox = {0, 0, (int)pMonitor->vecTransformedSize.x, (int)pMonitor->vecTransformedSize.y}; + wlr_box_transform(&transformedBox, &transformedBox, wlr_output_transform_invert(pMonitor->output->transform), (int)pMonitor->vecTransformedSize.x, + (int)pMonitor->vecTransformedSize.y); pMonitor->vecPixelSize = Vector2D(transformedBox.width, transformedBox.height); } @@ -1431,9 +1419,9 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR } void CHyprRenderer::ensureCursorRenderingMode() { - static auto *const PCURSORTIMEOUT = &g_pConfigManager->getConfigValuePtr("general:cursor_inactive_timeout")->intValue; + static auto* const PCURSORTIMEOUT = &g_pConfigManager->getConfigValuePtr("general:cursor_inactive_timeout")->intValue; - const auto PASSEDCURSORSECONDS = g_pInputManager->m_tmrLastCursorMovement.getSeconds(); + const auto PASSEDCURSORSECONDS = g_pInputManager->m_tmrLastCursorMovement.getSeconds(); if (*PCURSORTIMEOUT > 0) { if (*PCURSORTIMEOUT < PASSEDCURSORSECONDS && m_bHasARenderedCursor) { @@ -1444,7 +1432,7 @@ void CHyprRenderer::ensureCursorRenderingMode() { Debug::log(LOG, "Hiding the cursor (timeout)"); for (auto& m : g_pCompositor->m_vMonitors) - g_pHyprRenderer->damageMonitor(m.get()); // TODO: maybe just damage the cursor area? + g_pHyprRenderer->damageMonitor(m.get()); // TODO: maybe just damage the cursor area? } else if (*PCURSORTIMEOUT > PASSEDCURSORSECONDS && !m_bHasARenderedCursor) { m_bHasARenderedCursor = true; @@ -1454,7 +1442,7 @@ void CHyprRenderer::ensureCursorRenderingMode() { Debug::log(LOG, "Showing the cursor (timeout)"); for (auto& m : g_pCompositor->m_vMonitors) - g_pHyprRenderer->damageMonitor(m.get()); // TODO: maybe just damage the cursor area? + g_pHyprRenderer->damageMonitor(m.get()); // TODO: maybe just damage the cursor area? } } else { m_bHasARenderedCursor = true; diff --git a/src/render/Renderer.hpp b/src/render/Renderer.hpp index 38feeb79..804b5b69 100644 --- a/src/render/Renderer.hpp +++ b/src/render/Renderer.hpp @@ -10,14 +10,16 @@ struct SMonitorRule; // TODO: add fuller damage tracking for updating only parts of a window -enum DAMAGETRACKINGMODES { +enum DAMAGETRACKINGMODES +{ DAMAGE_TRACKING_INVALID = -1, - DAMAGE_TRACKING_NONE = 0, + DAMAGE_TRACKING_NONE = 0, DAMAGE_TRACKING_MONITOR, DAMAGE_TRACKING_FULL }; -enum eRenderPassMode { +enum eRenderPassMode +{ RENDER_PASS_ALL = 0, RENDER_PASS_MAIN, RENDER_PASS_POPUP @@ -26,8 +28,7 @@ enum eRenderPassMode { class CToplevelExportProtocolManager; class CHyprRenderer { -public: - + public: void renderAllClientsForMonitor(const int&, timespec*); void outputMgrApplyTest(wlr_output_configuration_v1*, bool); void arrangeLayersForMonitor(const int&); @@ -46,24 +47,23 @@ public: void calculateUVForWindowSurface(CWindow*, wlr_surface*, bool main = false); bool m_bWindowRequestedCursorHide = false; - bool m_bBlockSurfaceFeedback = false; - CWindow* m_pLastScanout = nullptr; + bool m_bBlockSurfaceFeedback = false; + CWindow* m_pLastScanout = nullptr; DAMAGETRACKINGMODES damageTrackingModeFromStr(const std::string&); bool attemptDirectScanout(CMonitor*); void setWindowScanoutMode(CWindow*); -private: - void arrangeLayerArray(CMonitor*, const std::vector<std::unique_ptr<SLayerSurface>>&, bool, wlr_box*); - void renderWorkspaceWithFullscreenWindow(CMonitor*, CWorkspace*, timespec*); - void renderWindow(CWindow*, CMonitor*, timespec*, bool, eRenderPassMode, bool ignorePosition = false, bool ignoreAllGeometry = false); - void renderLayer(SLayerSurface*, CMonitor*, timespec*); - void renderDragIcon(CMonitor*, timespec*); - void renderIMEPopup(SIMEPopup*, CMonitor*, timespec*); - - bool m_bHasARenderedCursor = true; + private: + void arrangeLayerArray(CMonitor*, const std::vector<std::unique_ptr<SLayerSurface>>&, bool, wlr_box*); + void renderWorkspaceWithFullscreenWindow(CMonitor*, CWorkspace*, timespec*); + void renderWindow(CWindow*, CMonitor*, timespec*, bool, eRenderPassMode, bool ignorePosition = false, bool ignoreAllGeometry = false); + void renderLayer(SLayerSurface*, CMonitor*, timespec*); + void renderDragIcon(CMonitor*, timespec*); + void renderIMEPopup(SIMEPopup*, CMonitor*, timespec*); + bool m_bHasARenderedCursor = true; friend class CHyprOpenGLImpl; friend class CToplevelExportProtocolManager; diff --git a/src/render/Shader.hpp b/src/render/Shader.hpp index f107bb6d..a5aa6efb 100644 --- a/src/render/Shader.hpp +++ b/src/render/Shader.hpp @@ -4,43 +4,43 @@ #include <unordered_map> class CShader { -public: + public: ~CShader(); GLuint program = 0; - GLint proj; - GLint color; - GLint tex; - GLint alpha; - GLint posAttrib; - GLint texAttrib; - GLint discardOpaque; + GLint proj; + GLint color; + GLint tex; + GLint alpha; + GLint posAttrib; + GLint texAttrib; + GLint discardOpaque; - GLint topLeft; - GLint bottomRight; - GLint fullSize; - GLint fullSizeUntransformed; - GLint radius; - GLint primitiveMultisample; + GLint topLeft; + GLint bottomRight; + GLint fullSize; + GLint fullSizeUntransformed; + GLint radius; + GLint primitiveMultisample; - GLint thick; + GLint thick; - GLint halfpixel; + GLint halfpixel; - GLint range; - GLint shadowPower; + GLint range; + GLint shadowPower; - GLint applyTint; - GLint tint; + GLint applyTint; + GLint tint; - GLint gradient; - GLint gradientLength; - GLint angle; + GLint gradient; + GLint gradientLength; + GLint angle; - GLint getUniformLocation(const std::string&); + GLint getUniformLocation(const std::string&); - void destroy(); + void destroy(); -private: + private: std::unordered_map<std::string, GLint> m_muUniforms; };
\ No newline at end of file diff --git a/src/render/Texture.cpp b/src/render/Texture.cpp index 01b80145..ff466f32 100644 --- a/src/render/Texture.cpp +++ b/src/render/Texture.cpp @@ -10,7 +10,7 @@ CTexture::CTexture(wlr_texture* tex) { wlr_gles2_texture_get_attribs(tex, &attrs); m_iTarget = attrs.target; - m_iTexID = attrs.tex; + m_iTexID = attrs.tex; if (m_iTarget == GL_TEXTURE_2D) { m_iType = attrs.has_alpha ? TEXTURE_RGBA : TEXTURE_RGBX; diff --git a/src/render/Texture.hpp b/src/render/Texture.hpp index f1211aec..f287089b 100644 --- a/src/render/Texture.hpp +++ b/src/render/Texture.hpp @@ -2,23 +2,24 @@ #include "../defines.hpp" -enum TEXTURETYPE { - TEXTURE_INVALID, // Invalid - TEXTURE_RGBA, // 4 channels - TEXTURE_RGBX, // discard A - TEXTURE_EXTERNAL, // EGLImage +enum TEXTURETYPE +{ + TEXTURE_INVALID, // Invalid + TEXTURE_RGBA, // 4 channels + TEXTURE_RGBX, // discard A + TEXTURE_EXTERNAL, // EGLImage }; class CTexture { -public: + public: CTexture(); CTexture(wlr_texture*); - void destroyTexture(); - void allocate(); + void destroyTexture(); + void allocate(); - TEXTURETYPE m_iType = TEXTURE_RGBA; - GLenum m_iTarget = GL_TEXTURE_2D; - GLuint m_iTexID = 0; - Vector2D m_vSize; + TEXTURETYPE m_iType = TEXTURE_RGBA; + GLenum m_iTarget = GL_TEXTURE_2D; + GLuint m_iTexID = 0; + Vector2D m_vSize; };
\ No newline at end of file diff --git a/src/render/decorations/CHyprDropShadowDecoration.cpp b/src/render/decorations/CHyprDropShadowDecoration.cpp index 131c7431..a46ae290 100644 --- a/src/render/decorations/CHyprDropShadowDecoration.cpp +++ b/src/render/decorations/CHyprDropShadowDecoration.cpp @@ -11,7 +11,7 @@ CHyprDropShadowDecoration::~CHyprDropShadowDecoration() { } SWindowDecorationExtents CHyprDropShadowDecoration::getWindowDecorationExtents() { - static auto *const PSHADOWS = &g_pConfigManager->getConfigValuePtr("decoration:drop_shadow")->intValue; + static auto* const PSHADOWS = &g_pConfigManager->getConfigValuePtr("decoration:drop_shadow")->intValue; if (*PSHADOWS != 1) return {{}, {}}; @@ -24,12 +24,13 @@ eDecorationType CHyprDropShadowDecoration::getDecorationType() { } void CHyprDropShadowDecoration::damageEntire() { - static auto *const PSHADOWS = &g_pConfigManager->getConfigValuePtr("decoration:drop_shadow")->intValue; + 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}; + 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); } @@ -41,7 +42,7 @@ void CHyprDropShadowDecoration::updateWindow(CWindow* pWindow) { const auto WORKSPACEOFFSET = PWORKSPACE && !pWindow->m_bPinned ? PWORKSPACE->m_vRenderOffset.vec() : Vector2D(); if (pWindow->m_vRealPosition.vec() + WORKSPACEOFFSET != m_vLastWindowPos || pWindow->m_vRealSize.vec() != m_vLastWindowSize) { - m_vLastWindowPos = pWindow->m_vRealPosition.vec() + WORKSPACEOFFSET; + m_vLastWindowPos = pWindow->m_vRealPosition.vec() + WORKSPACEOFFSET; m_vLastWindowSize = pWindow->m_vRealSize.vec(); damageEntire(); @@ -62,21 +63,21 @@ void CHyprDropShadowDecoration::draw(CMonitor* pMonitor, float a, const Vector2D if (m_pWindow->m_sAdditionalConfigData.forceNoShadow) 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; - static auto *const PSHADOWIGNOREWINDOW = &g_pConfigManager->getConfigValuePtr("decoration:shadow_ignore_window")->intValue; - static auto *const PSHADOWSCALE = &g_pConfigManager->getConfigValuePtr("decoration:shadow_scale")->floatValue; - static auto *const PSHADOWOFFSET = &g_pConfigManager->getConfigValuePtr("decoration:shadow_offset")->vecValue; + 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; + static auto* const PSHADOWIGNOREWINDOW = &g_pConfigManager->getConfigValuePtr("decoration:shadow_ignore_window")->intValue; + static auto* const PSHADOWSCALE = &g_pConfigManager->getConfigValuePtr("decoration:shadow_scale")->floatValue; + static auto* const PSHADOWOFFSET = &g_pConfigManager->getConfigValuePtr("decoration:shadow_offset")->vecValue; if (*PSHADOWS != 1) return; // disabled - const auto ROUNDING = !m_pWindow->m_sSpecialRenderData.rounding ? 0 : (m_pWindow->m_sAdditionalConfigData.rounding == -1 ? *PROUNDING : m_pWindow->m_sAdditionalConfigData.rounding); + const auto ROUNDING = + !m_pWindow->m_sSpecialRenderData.rounding ? 0 : (m_pWindow->m_sAdditionalConfigData.rounding == -1 ? *PROUNDING : m_pWindow->m_sAdditionalConfigData.rounding); // draw the shadow - wlr_box fullBox = { m_vLastWindowPos.x - *PSHADOWSIZE, m_vLastWindowPos.y - *PSHADOWSIZE, - m_vLastWindowSize.x + 2.0 * *PSHADOWSIZE, m_vLastWindowSize.y + 2.0 * *PSHADOWSIZE }; + wlr_box fullBox = {m_vLastWindowPos.x - *PSHADOWSIZE, m_vLastWindowPos.y - *PSHADOWSIZE, m_vLastWindowSize.x + 2.0 * *PSHADOWSIZE, m_vLastWindowSize.y + 2.0 * *PSHADOWSIZE}; fullBox.x -= pMonitor->vecPosition.x; fullBox.y -= pMonitor->vecPosition.y; @@ -84,9 +85,9 @@ void CHyprDropShadowDecoration::draw(CMonitor* pMonitor, float a, const Vector2D const float SHADOWSCALE = std::clamp(*PSHADOWSCALE, 0.f, 1.f); // scale the box in relation to the center of the box - const Vector2D NEWSIZE = Vector2D { fullBox.width, fullBox.height } * SHADOWSCALE; - fullBox.width = NEWSIZE.x; - fullBox.height = NEWSIZE.y; + const Vector2D NEWSIZE = Vector2D{fullBox.width, fullBox.height} * SHADOWSCALE; + fullBox.width = NEWSIZE.x; + fullBox.height = NEWSIZE.y; if (PSHADOWOFFSET->x < 0) { fullBox.x += PSHADOWOFFSET->x; @@ -104,16 +105,15 @@ void CHyprDropShadowDecoration::draw(CMonitor* pMonitor, float a, const Vector2D fullBox.y += ((m_vLastWindowSize.y + 2.0 * *PSHADOWSIZE) - NEWSIZE.y) / 2.0; } - m_seExtents = { { m_vLastWindowPos.x - fullBox.x - pMonitor->vecPosition.x + 2, - m_vLastWindowPos.y - fullBox.y - pMonitor->vecPosition.y + 2}, - { fullBox.x + fullBox.width + pMonitor->vecPosition.x - m_vLastWindowPos.x - m_vLastWindowSize.x + 2, - fullBox.y + fullBox.height + pMonitor->vecPosition.y - m_vLastWindowPos.y - m_vLastWindowSize.y + 2} }; + m_seExtents = {{m_vLastWindowPos.x - fullBox.x - pMonitor->vecPosition.x + 2, m_vLastWindowPos.y - fullBox.y - pMonitor->vecPosition.y + 2}, + {fullBox.x + fullBox.width + pMonitor->vecPosition.x - m_vLastWindowPos.x - m_vLastWindowSize.x + 2, + fullBox.y + fullBox.height + pMonitor->vecPosition.y - m_vLastWindowPos.y - m_vLastWindowSize.y + 2}}; fullBox.x += offset.x; fullBox.y += offset.y; if (fullBox.width < 1 || fullBox.height < 1) - return; // don't draw invisible shadows + return; // don't draw invisible shadows g_pHyprOpenGL->scissor((wlr_box*)nullptr); @@ -134,7 +134,7 @@ void CHyprDropShadowDecoration::draw(CMonitor* pMonitor, float a, const Vector2D glClearStencil(0); glClear(GL_STENCIL_BUFFER_BIT); glDisable(GL_STENCIL_TEST); - return; // prevent assert failed + return; // prevent assert failed } g_pHyprOpenGL->renderRect(&windowBox, CColor(0, 0, 0, 0), ROUNDING * pMonitor->scale); diff --git a/src/render/decorations/CHyprDropShadowDecoration.hpp b/src/render/decorations/CHyprDropShadowDecoration.hpp index ee8c09a5..3a7ffb2b 100644 --- a/src/render/decorations/CHyprDropShadowDecoration.hpp +++ b/src/render/decorations/CHyprDropShadowDecoration.hpp @@ -3,25 +3,25 @@ #include "IHyprWindowDecoration.hpp" class CHyprDropShadowDecoration : public IHyprWindowDecoration { -public: + public: CHyprDropShadowDecoration(CWindow*); virtual ~CHyprDropShadowDecoration(); virtual SWindowDecorationExtents getWindowDecorationExtents(); - virtual void draw(CMonitor*, float a, const Vector2D& offset); + virtual void draw(CMonitor*, float a, const Vector2D& offset); - virtual eDecorationType getDecorationType(); + virtual eDecorationType getDecorationType(); - virtual void updateWindow(CWindow*); + virtual void updateWindow(CWindow*); - virtual void damageEntire(); + virtual void damageEntire(); -private: - SWindowDecorationExtents m_seExtents; + private: + SWindowDecorationExtents m_seExtents; - CWindow* m_pWindow = nullptr; + CWindow* m_pWindow = nullptr; - Vector2D m_vLastWindowPos; - Vector2D m_vLastWindowSize; + Vector2D m_vLastWindowPos; + Vector2D m_vLastWindowSize; };
\ No newline at end of file diff --git a/src/render/decorations/CHyprGroupBarDecoration.cpp b/src/render/decorations/CHyprGroupBarDecoration.cpp index c3f9047e..b67051bb 100644 --- a/src/render/decorations/CHyprGroupBarDecoration.cpp +++ b/src/render/decorations/CHyprGroupBarDecoration.cpp @@ -5,9 +5,7 @@ CHyprGroupBarDecoration::CHyprGroupBarDecoration(CWindow* pWindow) { m_pWindow = pWindow; } -CHyprGroupBarDecoration::~CHyprGroupBarDecoration() { - -} +CHyprGroupBarDecoration::~CHyprGroupBarDecoration() {} SWindowDecorationExtents CHyprGroupBarDecoration::getWindowDecorationExtents() { return m_seExtents; @@ -28,10 +26,10 @@ void CHyprGroupBarDecoration::updateWindow(CWindow* pWindow) { // we draw 3px above the window's border with 3px const auto PBORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue; - m_seExtents.topLeft = Vector2D(0, *PBORDERSIZE + 3 + 3); + m_seExtents.topLeft = Vector2D(0, *PBORDERSIZE + 3 + 3); m_seExtents.bottomRight = Vector2D(); - m_vLastWindowPos = pWindow->m_vRealPosition.vec() + WORKSPACEOFFSET; + m_vLastWindowPos = pWindow->m_vRealPosition.vec() + WORKSPACEOFFSET; m_vLastWindowSize = pWindow->m_vRealSize.vec(); } @@ -59,7 +57,8 @@ void CHyprGroupBarDecoration::updateWindow(CWindow* pWindow) { } void CHyprGroupBarDecoration::damageEntire() { - 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_seExtents.topLeft.y}; + 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_seExtents.topLeft.y}; g_pHyprRenderer->damageBox(&dm); } @@ -77,7 +76,7 @@ void CHyprGroupBarDecoration::draw(CMonitor* pMonitor, float a, const Vector2D& const int BARW = (m_vLastWindowSize.x - PAD * (barsToDraw - 1)) / barsToDraw; - int xoff = 0; + int xoff = 0; for (int i = 0; i < barsToDraw; ++i) { wlr_box rect = {m_vLastWindowPos.x + xoff - pMonitor->vecPosition.x + offset.x, m_vLastWindowPos.y - m_seExtents.topLeft.y - pMonitor->vecPosition.y + offset.y, BARW, 3}; @@ -87,10 +86,10 @@ void CHyprGroupBarDecoration::draw(CMonitor* pMonitor, float a, const Vector2D& scaleBox(&rect, pMonitor->scale); - static auto *const PGROUPCOLACTIVE = &g_pConfigManager->getConfigValuePtr("dwindle:col.group_border_active")->intValue; - static auto *const PGROUPCOLINACTIVE = &g_pConfigManager->getConfigValuePtr("dwindle:col.group_border")->intValue; + static auto* const PGROUPCOLACTIVE = &g_pConfigManager->getConfigValuePtr("dwindle:col.group_border_active")->intValue; + static auto* const PGROUPCOLINACTIVE = &g_pConfigManager->getConfigValuePtr("dwindle:col.group_border")->intValue; - CColor color = m_dwGroupMembers[i] == g_pCompositor->m_pLastWindow ? CColor(*PGROUPCOLACTIVE) : CColor(*PGROUPCOLINACTIVE); + CColor color = m_dwGroupMembers[i] == g_pCompositor->m_pLastWindow ? CColor(*PGROUPCOLACTIVE) : CColor(*PGROUPCOLINACTIVE); color.a *= a; g_pHyprOpenGL->renderRect(&rect, color); diff --git a/src/render/decorations/CHyprGroupBarDecoration.hpp b/src/render/decorations/CHyprGroupBarDecoration.hpp index 7addd15e..eebfe99d 100644 --- a/src/render/decorations/CHyprGroupBarDecoration.hpp +++ b/src/render/decorations/CHyprGroupBarDecoration.hpp @@ -4,27 +4,27 @@ #include <deque> class CHyprGroupBarDecoration : public IHyprWindowDecoration { -public: + public: CHyprGroupBarDecoration(CWindow*); virtual ~CHyprGroupBarDecoration(); virtual SWindowDecorationExtents getWindowDecorationExtents(); - virtual void draw(CMonitor*, float a, const Vector2D& offset); + virtual void draw(CMonitor*, float a, const Vector2D& offset); - virtual eDecorationType getDecorationType(); + virtual eDecorationType getDecorationType(); - virtual void updateWindow(CWindow*); + virtual void updateWindow(CWindow*); - virtual void damageEntire(); + virtual void damageEntire(); -private: - SWindowDecorationExtents m_seExtents; + private: + SWindowDecorationExtents m_seExtents; - CWindow* m_pWindow = nullptr; + CWindow* m_pWindow = nullptr; - Vector2D m_vLastWindowPos; - Vector2D m_vLastWindowSize; + Vector2D m_vLastWindowPos; + Vector2D m_vLastWindowSize; - std::deque<CWindow*> m_dwGroupMembers; + std::deque<CWindow*> m_dwGroupMembers; };
\ No newline at end of file diff --git a/src/render/decorations/IHyprWindowDecoration.cpp b/src/render/decorations/IHyprWindowDecoration.cpp index 5a7ccd9a..1271a712 100644 --- a/src/render/decorations/IHyprWindowDecoration.cpp +++ b/src/render/decorations/IHyprWindowDecoration.cpp @@ -2,6 +2,4 @@ #include "../../Window.hpp" -IHyprWindowDecoration::~IHyprWindowDecoration() { - -} +IHyprWindowDecoration::~IHyprWindowDecoration() {} diff --git a/src/render/decorations/IHyprWindowDecoration.hpp b/src/render/decorations/IHyprWindowDecoration.hpp index d4062c1d..093b99cf 100644 --- a/src/render/decorations/IHyprWindowDecoration.hpp +++ b/src/render/decorations/IHyprWindowDecoration.hpp @@ -2,7 +2,8 @@ #include "../../defines.hpp" -enum eDecorationType { +enum eDecorationType +{ DECORATION_NONE = -1, DECORATION_GROUPBAR, DECORATION_SHADOW @@ -17,16 +18,16 @@ class CWindow; class CMonitor; interface IHyprWindowDecoration { -public: + public: virtual ~IHyprWindowDecoration() = 0; virtual SWindowDecorationExtents getWindowDecorationExtents() = 0; - virtual void draw(CMonitor*, float a, const Vector2D& offset = Vector2D()) = 0; + virtual void draw(CMonitor*, float a, const Vector2D& offset = Vector2D()) = 0; - virtual eDecorationType getDecorationType() = 0; + virtual eDecorationType getDecorationType() = 0; - virtual void updateWindow(CWindow*) = 0; + virtual void updateWindow(CWindow*) = 0; - virtual void damageEntire() = 0; + virtual void damageEntire() = 0; };
\ No newline at end of file |
