From f85c6416c6f5e56c75178ecb24c11e346069197d Mon Sep 17 00:00:00 2001 From: MightyPlaza <123664421+MightyPlaza@users.noreply.github.com> Date: Fri, 12 Jul 2024 21:05:19 +0000 Subject: [PATCH 1/5] renderer: fix a few xray regressions (#6855) * fix xray unset modified: src/render/OpenGL.cpp * fix xwray unset modified: src/render/OpenGL.cpp --- src/render/OpenGL.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/render/OpenGL.cpp b/src/render/OpenGL.cpp index 2b603868..2556fafc 100644 --- a/src/render/OpenGL.cpp +++ b/src/render/OpenGL.cpp @@ -434,7 +434,7 @@ bool CHyprOpenGLImpl::passRequiresIntrospection(CMonitor* pMonitor) { if (!w->m_bIsFloating && *POPTIM && !w->onSpecialWorkspace()) continue; - if (w->m_sWindowData.noBlur.valueOrDefault() || w->m_sWindowData.xray.valueOrDefault() == true) + if (w->m_sWindowData.noBlur.valueOrDefault() || !w->m_sWindowData.xray.hasValue() || w->m_sWindowData.xray.valueOrDefault()) continue; if (w->opaque()) @@ -1717,7 +1717,7 @@ bool CHyprOpenGLImpl::shouldUseNewBlurOptimizations(PHLLS pLayer, PHLWINDOW pWin if (!m_RenderData.pCurrentMonData->blurFB.m_cTex->m_iTexID) return false; - if (pWindow && !pWindow->m_sWindowData.xray.valueOrDefault()) + if (pWindow && pWindow->m_sWindowData.xray.hasValue() && !pWindow->m_sWindowData.xray.valueOrDefault()) return false; if (pLayer && pLayer->xray == 0) From 7486576fa7a3d394254cb07734679df4b2469071 Mon Sep 17 00:00:00 2001 From: Junxuan Liao <70618504+MikeWalrus@users.noreply.github.com> Date: Sat, 13 Jul 2024 18:32:08 +0800 Subject: [PATCH 2/5] session-lock: send `locked` after the lock screen is properly rendered (#6850) The protocol says: > The locked event "must not be sent until a new "locked" frame (either from a > session lock surface or the compositor blanking the output) has been presented > on all outputs and no security sensitive normal/unlocked content is possibly > visible". This helps users ensure the screen is properly locked before suspending the machine. (e.g. with swaylock --ready-fd) --- src/managers/SessionLockManager.cpp | 15 +++++++++++++-- src/managers/SessionLockManager.hpp | 8 +++++++- src/render/Renderer.cpp | 3 +++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/managers/SessionLockManager.cpp b/src/managers/SessionLockManager.cpp index b4695e0e..83ff3ee7 100644 --- a/src/managers/SessionLockManager.cpp +++ b/src/managers/SessionLockManager.cpp @@ -3,6 +3,7 @@ #include "../config/ConfigValue.hpp" #include "../protocols/FractionalScale.hpp" #include "../protocols/SessionLock.hpp" +#include SSessionLockSurface::SSessionLockSurface(SP surface_) : surface(surface_) { pWlrSurface = surface->surface(); @@ -77,7 +78,6 @@ void CSessionLockManager::onNewSessionLock(SP pLock) { g_pHyprRenderer->damageMonitor(m.get()); }); - pLock->sendLocked(); g_pCompositor->focusSurface(nullptr); } @@ -102,7 +102,6 @@ SSessionLockSurface* CSessionLockManager::getSessionLockSurfaceForMonitor(uint64 } // We don't want the red screen to flash. -// This violates the protocol a bit, but tries to handle the missing sync between a lock surface beeing created and the red screen beeing drawn. float CSessionLockManager::getRedScreenAlphaForMonitor(uint64_t id) { if (!m_pSessionLock) return 0.F; @@ -118,6 +117,18 @@ float CSessionLockManager::getRedScreenAlphaForMonitor(uint64_t id) { return std::clamp(NOMAPPEDSURFACETIMER->second.getSeconds() - /* delay for screencopy */ 0.5f, 0.f, 1.f); } +void CSessionLockManager::onLockscreenRenderedOnMonitor(uint64_t id) { + if (!m_pSessionLock || m_pSessionLock->m_hasSentLocked) + return; + m_pSessionLock->m_lockedMonitors.emplace(id); + const auto MONITORS = g_pCompositor->m_vMonitors; + const bool LOCKED = std::all_of(MONITORS.begin(), MONITORS.end(), [this](auto m) { return m_pSessionLock->m_lockedMonitors.contains(m->ID); }); + if (LOCKED) { + m_pSessionLock->lock->sendLocked(); + m_pSessionLock->m_hasSentLocked = true; + } +} + bool CSessionLockManager::isSurfaceSessionLock(SP pSurface) { // TODO: this has some edge cases when it's wrong (e.g. destroyed lock but not yet surfaces) // but can be easily fixed when I rewrite wlr_surface diff --git a/src/managers/SessionLockManager.hpp b/src/managers/SessionLockManager.hpp index fe4a4434..b01ee288 100644 --- a/src/managers/SessionLockManager.hpp +++ b/src/managers/SessionLockManager.hpp @@ -5,6 +5,7 @@ #include "../helpers/signal/Signal.hpp" #include #include +#include class CSessionLockSurface; class CSessionLock; @@ -37,6 +38,9 @@ struct SSessionLock { CHyprSignalListener unlock; CHyprSignalListener destroy; } listeners; + + bool m_hasSentLocked = false; + std::unordered_set m_lockedMonitors; }; class CSessionLockManager { @@ -54,6 +58,8 @@ class CSessionLockManager { void removeSessionLockSurface(SSessionLockSurface*); + void onLockscreenRenderedOnMonitor(uint64_t id); + private: UP m_pSessionLock; @@ -64,4 +70,4 @@ class CSessionLockManager { void onNewSessionLock(SP pWlrLock); }; -inline std::unique_ptr g_pSessionLockManager; \ No newline at end of file +inline std::unique_ptr g_pSessionLockManager; diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 955a16b9..a7f3c941 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -990,8 +990,11 @@ void CHyprRenderer::renderLockscreen(CMonitor* pMonitor, timespec* now, const CB if (ALPHA < 1.f) /* animate */ damageMonitor(pMonitor); + else + g_pSessionLockManager->onLockscreenRenderedOnMonitor(pMonitor->ID); } else { renderSessionLockSurface(PSLS, pMonitor, now); + g_pSessionLockManager->onLockscreenRenderedOnMonitor(pMonitor->ID); } } } From 13bc7e1e1415a0b17db609774f59b594c7633941 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Sat, 13 Jul 2024 12:36:29 +0200 Subject: [PATCH 3/5] style: fix clang-format --- src/Compositor.cpp | 3 ++- src/config/ConfigDataValues.hpp | 14 +++++++------- src/helpers/MiscFunctions.cpp | 8 ++------ src/macros.hpp | 3 +-- src/managers/PointerManager.cpp | 3 +-- src/managers/input/InputManager.cpp | 3 +-- src/managers/input/TextInput.cpp | 9 +++------ src/protocols/Tablet.cpp | 3 +-- src/render/Renderbuffer.cpp | 3 +-- 9 files changed, 19 insertions(+), 30 deletions(-) diff --git a/src/Compositor.cpp b/src/Compositor.cpp index 2abc1144..d1c51075 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -702,7 +702,8 @@ PHLWINDOW CCompositor::vectorToWindowUnified(const Vector2D& pos, uint8_t proper for (auto& w : m_vWindows | std::views::reverse) { const auto BB = w->getWindowBoxUnified(properties); CBox box = BB.copy().expand(w->m_iX11Type == 2 ? BORDER_GRAB_AREA : 0); - if (w->m_bIsFloating && w->m_bIsMapped && !w->isHidden() && !w->m_bX11ShouldntFocus && w->m_bPinned && !w->m_sWindowData.noFocus.valueOrDefault() && w != pIgnoreWindow) { + if (w->m_bIsFloating && w->m_bIsMapped && !w->isHidden() && !w->m_bX11ShouldntFocus && w->m_bPinned && !w->m_sWindowData.noFocus.valueOrDefault() && + w != pIgnoreWindow) { if (box.containsPoint(g_pPointerManager->position())) return w; diff --git a/src/config/ConfigDataValues.hpp b/src/config/ConfigDataValues.hpp index 322bd14a..37c9fc92 100644 --- a/src/config/ConfigDataValues.hpp +++ b/src/config/ConfigDataValues.hpp @@ -20,11 +20,11 @@ class ICustomConfigValueData { class CGradientValueData : public ICustomConfigValueData { public: - CGradientValueData(){}; + CGradientValueData() {}; CGradientValueData(CColor col) { m_vColors.push_back(col); }; - virtual ~CGradientValueData(){}; + virtual ~CGradientValueData() {}; virtual eConfigValueDataTypes getDataType() { return CVD_TYPE_GRADIENT; @@ -67,11 +67,11 @@ class CGradientValueData : public ICustomConfigValueData { class CCssGapData : public ICustomConfigValueData { public: - CCssGapData() : top(0), right(0), bottom(0), left(0){}; - CCssGapData(int64_t global) : top(global), right(global), bottom(global), left(global){}; - CCssGapData(int64_t vertical, int64_t horizontal) : top(vertical), right(horizontal), bottom(vertical), left(horizontal){}; - CCssGapData(int64_t top, int64_t horizontal, int64_t bottom) : top(top), right(horizontal), bottom(bottom), left(horizontal){}; - CCssGapData(int64_t top, int64_t right, int64_t bottom, int64_t left) : top(top), right(right), bottom(bottom), left(left){}; + CCssGapData() : top(0), right(0), bottom(0), left(0) {}; + CCssGapData(int64_t global) : top(global), right(global), bottom(global), left(global) {}; + CCssGapData(int64_t vertical, int64_t horizontal) : top(vertical), right(horizontal), bottom(vertical), left(horizontal) {}; + CCssGapData(int64_t top, int64_t horizontal, int64_t bottom) : top(top), right(horizontal), bottom(bottom), left(horizontal) {}; + CCssGapData(int64_t top, int64_t right, int64_t bottom, int64_t left) : top(top), right(right), bottom(bottom), left(left) {}; /* Css like directions */ int64_t top; diff --git a/src/helpers/MiscFunctions.cpp b/src/helpers/MiscFunctions.cpp index aa034254..712e4e50 100644 --- a/src/helpers/MiscFunctions.cpp +++ b/src/helpers/MiscFunctions.cpp @@ -649,13 +649,9 @@ void matrixProjection(float mat[9], int w, int h, wl_output_transform tr) { int64_t getPPIDof(int64_t pid) { #if defined(KERN_PROC_PID) int mib[] = { - CTL_KERN, - KERN_PROC, - KERN_PROC_PID, - (int)pid, + CTL_KERN, KERN_PROC, KERN_PROC_PID, (int)pid, #if defined(__NetBSD__) || defined(__OpenBSD__) - sizeof(KINFO_PROC), - 1, + sizeof(KINFO_PROC), 1, #endif }; u_int miblen = sizeof(mib) / sizeof(mib[0]); diff --git a/src/macros.hpp b/src/macros.hpp index 67f6301b..f1393cbd 100644 --- a/src/macros.hpp +++ b/src/macros.hpp @@ -40,8 +40,7 @@ #define STICKS(a, b) abs((a) - (b)) < 2 -#define HYPRATOM(name) \ - { name, 0 } +#define HYPRATOM(name) {name, 0} #define RASSERT(expr, reason, ...) \ if (!(expr)) { \ diff --git a/src/managers/PointerManager.cpp b/src/managers/PointerManager.cpp index e34aa54b..7090645f 100644 --- a/src/managers/PointerManager.cpp +++ b/src/managers/PointerManager.cpp @@ -235,8 +235,7 @@ void CPointerManager::setCursorBuffer(wlr_buffer* buf, const Vector2D& hotspot, currentCursorImage.size = {buf->width, buf->height}; currentCursorImage.pBuffer = wlr_buffer_lock(buf); - currentCursorImage.hyprListener_destroyBuffer.initCallback( - &buf->events.destroy, [this](void* owner, void* data) { resetCursorImage(); }, this, "CPointerManager"); + currentCursorImage.hyprListener_destroyBuffer.initCallback(&buf->events.destroy, [this](void* owner, void* data) { resetCursorImage(); }, this, "CPointerManager"); } currentCursorImage.hotspot = hotspot; diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index 9180e9cd..b2bbd577 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -1624,8 +1624,7 @@ void CInputManager::newSwitch(wlr_input_device* pDevice) { Debug::log(LOG, "New switch with name \"{}\" added", pDevice->name); - PNEWDEV->hyprListener_destroy.initCallback( - &pDevice->events.destroy, [&](void* owner, void* data) { destroySwitch((SSwitchDevice*)owner); }, PNEWDEV, "SwitchDevice"); + PNEWDEV->hyprListener_destroy.initCallback(&pDevice->events.destroy, [&](void* owner, void* data) { destroySwitch((SSwitchDevice*)owner); }, PNEWDEV, "SwitchDevice"); const auto PSWITCH = wlr_switch_from_input_device(pDevice); diff --git a/src/managers/input/TextInput.cpp b/src/managers/input/TextInput.cpp index 4c7ffe6e..635a8b01 100644 --- a/src/managers/input/TextInput.cpp +++ b/src/managers/input/TextInput.cpp @@ -41,14 +41,11 @@ void CTextInput::initCallbacks() { g_pInputManager->m_sIMERelay.removeTextInput(this); }); } else { - hyprListener_textInputEnable.initCallback( - &pV1Input->sEnable, [this](void* owner, void* data) { onEnabled(); }, this, "textInput"); + hyprListener_textInputEnable.initCallback(&pV1Input->sEnable, [this](void* owner, void* data) { onEnabled(); }, this, "textInput"); - hyprListener_textInputCommit.initCallback( - &pV1Input->sCommit, [this](void* owner, void* data) { onCommit(); }, this, "textInput"); + hyprListener_textInputCommit.initCallback(&pV1Input->sCommit, [this](void* owner, void* data) { onCommit(); }, this, "textInput"); - hyprListener_textInputDisable.initCallback( - &pV1Input->sDisable, [this](void* owner, void* data) { onDisabled(); }, this, "textInput"); + hyprListener_textInputDisable.initCallback(&pV1Input->sDisable, [this](void* owner, void* data) { onDisabled(); }, this, "textInput"); hyprListener_textInputDestroy.initCallback( &pV1Input->sDestroy, diff --git a/src/protocols/Tablet.cpp b/src/protocols/Tablet.cpp index 518ea5bd..7b62f245 100644 --- a/src/protocols/Tablet.cpp +++ b/src/protocols/Tablet.cpp @@ -215,8 +215,7 @@ void CTabletToolV2Resource::queueFrame() { if (frameSource) return; - frameSource = wl_event_loop_add_idle( - g_pCompositor->m_sWLEventLoop, [](void* data) { ((CTabletToolV2Resource*)data)->sendFrame(false); }, this); + frameSource = wl_event_loop_add_idle(g_pCompositor->m_sWLEventLoop, [](void* data) { ((CTabletToolV2Resource*)data)->sendFrame(false); }, this); } void CTabletToolV2Resource::sendFrame(bool removeSource) { diff --git a/src/render/Renderbuffer.cpp b/src/render/Renderbuffer.cpp index b55a921b..3f591d13 100644 --- a/src/render/Renderbuffer.cpp +++ b/src/render/Renderbuffer.cpp @@ -58,8 +58,7 @@ CRenderbuffer::CRenderbuffer(wlr_buffer* buffer, uint32_t format) : m_pWlrBuffer glBindFramebuffer(GL_FRAMEBUFFER, 0); - hyprListener_destroyBuffer.initCallback( - &buffer->events.destroy, [this](void* owner, void* data) { g_pHyprRenderer->onRenderbufferDestroy(this); }, this, "CRenderbuffer"); + hyprListener_destroyBuffer.initCallback(&buffer->events.destroy, [this](void* owner, void* data) { g_pHyprRenderer->onRenderbufferDestroy(this); }, this, "CRenderbuffer"); } CRenderbuffer::CRenderbuffer(SP buffer, uint32_t format) : m_pHLBuffer(buffer), m_uDrmFormat(format) { From 1f6466895326defef370a378f9d7b61a7e246df7 Mon Sep 17 00:00:00 2001 From: Tim Waterhouse Date: Sat, 13 Jul 2024 03:53:23 -0700 Subject: [PATCH 4/5] ext-foreign-toplevel: Send done after title and class (#6857) According to the spec (https://wayland.app/protocols/ext-foreign-toplevel-list-v1#ext_foreign_toplevel_handle_v1:event:title), clients should wait for the done signal before applying updates --- src/protocols/ForeignToplevel.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/protocols/ForeignToplevel.cpp b/src/protocols/ForeignToplevel.cpp index 40420da7..f7b3886f 100644 --- a/src/protocols/ForeignToplevel.cpp +++ b/src/protocols/ForeignToplevel.cpp @@ -81,6 +81,7 @@ void CForeignToplevelList::onTitle(PHLWINDOW pWindow) { return; H->resource->sendTitle(pWindow->m_szTitle.c_str()); + H->resource->sendDone(); } void CForeignToplevelList::onClass(PHLWINDOW pWindow) { @@ -92,6 +93,7 @@ void CForeignToplevelList::onClass(PHLWINDOW pWindow) { return; H->resource->sendAppId(pWindow->m_szClass.c_str()); + H->resource->sendDone(); } void CForeignToplevelList::onUnmap(PHLWINDOW pWindow) { From a770a88e0962f37c0b6f36f1876cbf27db4cf3c9 Mon Sep 17 00:00:00 2001 From: David De Sousa Date: Sat, 13 Jul 2024 12:53:53 +0200 Subject: [PATCH 5/5] toplevelexport: fix flipped r/b channels when sharing windows (#6861) fixes #6823 --- src/protocols/ToplevelExport.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/protocols/ToplevelExport.cpp b/src/protocols/ToplevelExport.cpp index 287538b5..d4c66c3b 100644 --- a/src/protocols/ToplevelExport.cpp +++ b/src/protocols/ToplevelExport.cpp @@ -409,7 +409,8 @@ bool CToplevelExportProtocolManager::copyFrameShm(SScreencopyFrame* frame, times glPixelStorei(GL_PACK_ALIGNMENT, 1); - glReadPixels(0, 0, frame->box.width, frame->box.height, PFORMAT->glFormat, PFORMAT->glType, pixelData); + auto glFormat = PFORMAT->flipRB ? GL_BGRA_EXT : GL_RGBA; + glReadPixels(0, 0, frame->box.width, frame->box.height, glFormat, PFORMAT->glType, pixelData); if (frame->overlayCursor) { g_pPointerManager->unlockSoftwareForMonitor(PMONITOR->self.lock());