diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp index 52d6c6f59..9659483f3 100644 --- a/src/events/Windows.cpp +++ b/src/events/Windows.cpp @@ -200,6 +200,8 @@ void Events::listener_unmapWindow(void* owner, void* data) { PWINDOW->m_bFadingOut = true; g_pCompositor->m_lWindowsFadingOut.push_back(PWINDOW); + + g_pHyprRenderer->damageMonitor(g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID)); } void Events::listener_commitWindow(void* owner, void* data) { diff --git a/src/layout/DwindleLayout.cpp b/src/layout/DwindleLayout.cpp index aeddbb8f8..2af7a2e22 100644 --- a/src/layout/DwindleLayout.cpp +++ b/src/layout/DwindleLayout.cpp @@ -412,6 +412,8 @@ void CHyprDwindleLayout::onBeginDragWindow() { m_vBeginDragPositionXY = DRAGGINGWINDOW->m_vRealPosition; m_vBeginDragSizeXY = DRAGGINGWINDOW->m_vRealSize; m_vLastDragXY = m_vBeginDragXY; + + g_pHyprRenderer->damageWindow(DRAGGINGWINDOW); } void CHyprDwindleLayout::onEndDragWindow() { @@ -422,6 +424,7 @@ void CHyprDwindleLayout::onEndDragWindow() { changeWindowFloatingMode(DRAGGINGWINDOW); } + g_pHyprRenderer->damageWindow(DRAGGINGWINDOW); } void CHyprDwindleLayout::onMouseMove(const Vector2D& mousePos) { @@ -433,8 +436,14 @@ void CHyprDwindleLayout::onMouseMove(const Vector2D& mousePos) { const auto DELTA = Vector2D(mousePos.x - m_vBeginDragXY.x, mousePos.y - m_vBeginDragXY.y); const auto TICKDELTA = Vector2D(mousePos.x - m_vLastDragXY.x, mousePos.y - m_vLastDragXY.y); + + if (abs(TICKDELTA.x) < 1.f && abs(TICKDELTA.y) < 1.f) + return; + m_vLastDragXY = mousePos; + g_pHyprRenderer->damageWindow(DRAGGINGWINDOW); + if (g_pInputManager->dragButton == BTN_LEFT) { DRAGGINGWINDOW->m_vRealPosition = m_vBeginDragPositionXY + DELTA; DRAGGINGWINDOW->m_vEffectivePosition = DRAGGINGWINDOW->m_vRealPosition; @@ -515,6 +524,8 @@ void CHyprDwindleLayout::onMouseMove(const Vector2D& mousePos) { DRAGGINGWINDOW->m_iMonitorID = PMONITOR->ID; DRAGGINGWINDOW->m_iWorkspaceID = PMONITOR->activeWorkspace; } + + g_pHyprRenderer->damageWindow(DRAGGINGWINDOW); } void CHyprDwindleLayout::onWindowCreatedFloating(CWindow* pWindow) { diff --git a/src/render/OpenGL.cpp b/src/render/OpenGL.cpp index e9fbe7fe5..15d233fe4 100644 --- a/src/render/OpenGL.cpp +++ b/src/render/OpenGL.cpp @@ -179,6 +179,8 @@ void CHyprOpenGLImpl::clear(const CColor& color) { glClear(GL_COLOR_BUFFER_BIT); } } + + scissor((wlr_box*)nullptr); } void CHyprOpenGLImpl::scissor(const wlr_box* pBox) { @@ -248,6 +250,7 @@ void CHyprOpenGLImpl::renderTexture(wlr_texture* tex, wlr_box* pBox, float alpha void CHyprOpenGLImpl::renderTexture(const CTexture& tex, wlr_box* pBox, float alpha, int round) { RASSERT(m_RenderData.pMonitor, "Tried to render texture without begin()!"); + // TODO: optimize this, this is bad if (pixman_region32_not_empty(m_RenderData.pDamage)) { PIXMAN_DAMAGE_FOREACH(m_RenderData.pDamage) { const auto RECT = RECTSARR[i]; @@ -256,6 +259,8 @@ void CHyprOpenGLImpl::renderTexture(const CTexture& tex, wlr_box* pBox, float al renderTextureInternal(tex, pBox, alpha, round); } } + + scissor((wlr_box*)nullptr); } void CHyprOpenGLImpl::renderTextureInternal(const CTexture& tex, wlr_box* pBox, float alpha, int round) { @@ -329,12 +334,28 @@ void CHyprOpenGLImpl::renderTextureInternal(const CTexture& tex, wlr_box* pBox, glBindTexture(tex.m_iTarget, 0); } +void CHyprOpenGLImpl::renderTextureWithBlur(const CTexture& tex, wlr_box* pBox, float a, int round) { + RASSERT(m_RenderData.pMonitor, "Tried to render texture with blur without begin()!"); + + // TODO: optimize this, this is bad + if (pixman_region32_not_empty(m_RenderData.pDamage)) { + PIXMAN_DAMAGE_FOREACH(m_RenderData.pDamage) { + const auto RECT = RECTSARR[i]; + scissor(&RECT); + + renderTextureWithBlurInternal(tex, pBox, a, round); + } + } + + scissor((wlr_box*)nullptr); +} + // This is probably not the quickest method possible, // feel free to contribute if you have a better method. // cheers. // 2-pass pseudo-gaussian blur -void CHyprOpenGLImpl::renderTextureWithBlur(const CTexture& tex, wlr_box* pBox, float a, int round) { +void CHyprOpenGLImpl::renderTextureWithBlurInternal(const CTexture& tex, wlr_box* pBox, float a, int round) { RASSERT(m_RenderData.pMonitor, "Tried to render texture without begin()!"); RASSERT((tex.m_iTexID > 0), "Attempted to draw NULL texture!"); diff --git a/src/render/OpenGL.hpp b/src/render/OpenGL.hpp index 97a279971..ae22a477f 100644 --- a/src/render/OpenGL.hpp +++ b/src/render/OpenGL.hpp @@ -90,6 +90,7 @@ private: void createBGTextureForMonitor(SMonitor*); void renderTextureInternal(const CTexture&, wlr_box* pBox, float a, int round = 0); + void renderTextureWithBlurInternal(const CTexture&, wlr_box*, float a, int round = 0); }; diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index f7eb1dbee..f81e9e715 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -21,7 +21,6 @@ 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}; - g_pHyprOpenGL->scissor(&windowBox); } else { windowBox = {(int)outputX + RDATA->x + x, (int)outputY + RDATA->y + y, surface->current.width, surface->current.height}; } @@ -456,9 +455,9 @@ void CHyprRenderer::damageWindow(CWindow* pWindow) { for (auto& m : g_pCompositor->m_lMonitors) wlr_output_damage_add_box(m.damage, &damageBox); } else { - // damage by effective size & pos + border size + 1 (JIC) + // damage by real size & pos + border size * 2 (JIC) const auto BORDERSIZE = g_pConfigManager->getInt("general:border_size"); - wlr_box damageBox = { pWindow->m_vEffectivePosition.x - BORDERSIZE - 1, pWindow->m_vEffectivePosition.y - BORDERSIZE - 1, pWindow->m_vEffectiveSize.x + 2 * BORDERSIZE + 2, pWindow->m_vEffectiveSize.y + 2 * BORDERSIZE + 2}; + wlr_box damageBox = { pWindow->m_vRealPosition.x - BORDERSIZE * 2 - 1, pWindow->m_vRealPosition.y - BORDERSIZE * 2 - 1, pWindow->m_vRealSize.x + 4 * BORDERSIZE + 2, pWindow->m_vRealSize.y + 4 * BORDERSIZE + 2}; for (auto& m : g_pCompositor->m_lMonitors) wlr_output_damage_add_box(m.damage, &damageBox); }