diff --git a/src/events/Events.hpp b/src/events/Events.hpp index 26db2b22..d0a1df39 100644 --- a/src/events/Events.hpp +++ b/src/events/Events.hpp @@ -99,6 +99,7 @@ namespace Events { DYNLISTENFUNC(monitorDestroy); DYNLISTENFUNC(monitorStateRequest); DYNLISTENFUNC(monitorDamage); + DYNLISTENFUNC(monitorNeedsFrame); // XWayland LISTENER(readyXWayland); diff --git a/src/events/Monitors.cpp b/src/events/Monitors.cpp index 4749ff22..c9bb6dd7 100644 --- a/src/events/Monitors.cpp +++ b/src/events/Monitors.cpp @@ -203,3 +203,9 @@ void Events::listener_monitorDamage(void* owner, void* data) { PMONITOR->addDamage(E->damage); } + +void Events::listener_monitorNeedsFrame(void* owner, void* data) { + const auto PMONITOR = (CMonitor*)owner; + + g_pCompositor->scheduleFrameForMonitor(PMONITOR); +} diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp index e12598eb..e1cf54cd 100644 --- a/src/helpers/Monitor.cpp +++ b/src/helpers/Monitor.cpp @@ -21,10 +21,12 @@ void CMonitor::onConnect(bool noRule) { hyprListener_monitorFrame.removeCallback(); hyprListener_monitorStateRequest.removeCallback(); hyprListener_monitorDamage.removeCallback(); + hyprListener_monitorNeedsFrame.removeCallback(); hyprListener_monitorFrame.initCallback(&output->events.frame, &Events::listener_monitorFrame, this); hyprListener_monitorDestroy.initCallback(&output->events.destroy, &Events::listener_monitorDestroy, this); hyprListener_monitorStateRequest.initCallback(&output->events.request_state, &Events::listener_monitorStateRequest, this); hyprListener_monitorDamage.initCallback(&output->events.damage, &Events::listener_monitorDamage, this); + hyprListener_monitorNeedsFrame.initCallback(&output->events.needs_frame, &Events::listener_monitorNeedsFrame, this); if (m_bEnabled) { wlr_output_enable(output, 1); @@ -218,6 +220,7 @@ void CMonitor::onDisconnect() { hyprListener_monitorFrame.removeCallback(); hyprListener_monitorDamage.removeCallback(); + hyprListener_monitorNeedsFrame.removeCallback(); for (size_t i = 0; i < 4; ++i) { for (auto& ls : m_aLayerSurfaceLayers[i]) { @@ -293,13 +296,13 @@ void CMonitor::onDisconnect() { } void CMonitor::addDamage(const pixman_region32_t* rg) { - wlr_damage_ring_add(&damage, rg); - g_pCompositor->scheduleFrameForMonitor(this); + if (wlr_damage_ring_add(&damage, rg)) + g_pCompositor->scheduleFrameForMonitor(this); } void CMonitor::addDamage(const wlr_box* box) { - wlr_damage_ring_add_box(&damage, box); - g_pCompositor->scheduleFrameForMonitor(this); + if (wlr_damage_ring_add_box(&damage, box)) + g_pCompositor->scheduleFrameForMonitor(this); } bool CMonitor::isMirror() { diff --git a/src/helpers/Monitor.hpp b/src/helpers/Monitor.hpp index 3414f698..bb475189 100644 --- a/src/helpers/Monitor.hpp +++ b/src/helpers/Monitor.hpp @@ -66,6 +66,7 @@ class CMonitor { DYNLISTENER(monitorDestroy); DYNLISTENER(monitorStateRequest); DYNLISTENER(monitorDamage); + DYNLISTENER(monitorNeedsFrame); // hack: a group = workspaces on a monitor. // I don't really care lol :P