output: handle needs_frame

This commit is contained in:
vaxerski 2023-04-07 17:25:56 +01:00
parent cd1b982b2a
commit 41d1fdedf2
4 changed files with 15 additions and 4 deletions

View file

@ -99,6 +99,7 @@ namespace Events {
DYNLISTENFUNC(monitorDestroy);
DYNLISTENFUNC(monitorStateRequest);
DYNLISTENFUNC(monitorDamage);
DYNLISTENFUNC(monitorNeedsFrame);
// XWayland
LISTENER(readyXWayland);

View file

@ -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);
}

View file

@ -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() {

View file

@ -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