aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/helpers/Monitor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/helpers/Monitor.cpp')
-rw-r--r--src/helpers/Monitor.cpp32
1 files changed, 24 insertions, 8 deletions
diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp
index d8bae3a8..e1cf54cd 100644
--- a/src/helpers/Monitor.cpp
+++ b/src/helpers/Monitor.cpp
@@ -8,13 +8,25 @@ int ratHandler(void* data) {
return 1;
}
+CMonitor::CMonitor() {
+ wlr_damage_ring_init(&damage);
+}
+
+CMonitor::~CMonitor() {
+ wlr_damage_ring_finish(&damage);
+}
+
void CMonitor::onConnect(bool noRule) {
hyprListener_monitorDestroy.removeCallback();
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);
@@ -114,13 +126,13 @@ void CMonitor::onConnect(bool noRule) {
if (!noRule)
g_pHyprRenderer->applyMonitorRule(this, &monitorRule, true);
+ wlr_damage_ring_set_bounds(&damage, vecTransformedSize.x, vecTransformedSize.y);
+
wlr_xcursor_manager_load(g_pCompositor->m_sWLRXCursorMgr, scale);
Debug::log(LOG, "Added new monitor with name %s at %i,%i with size %ix%i, pointer %x", output->name, (int)vecPosition.x, (int)vecPosition.y, (int)vecPixelSize.x,
(int)vecPixelSize.y, output);
- damage = wlr_output_damage_create(output);
-
// add a WLR workspace group
if (!pWLRWorkspaceGroupHandle) {
pWLRWorkspaceGroupHandle = wlr_ext_workspace_group_handle_v1_create(g_pCompositor->m_sWLREXTWorkspaceMgr);
@@ -131,6 +143,8 @@ void CMonitor::onConnect(bool noRule) {
setupDefaultWS(monitorRule);
scale = monitorRule.scale;
+ if (scale < 0.1)
+ scale = getDefaultScale();
m_pThisWrap = nullptr;
@@ -205,6 +219,8 @@ void CMonitor::onDisconnect() {
m_bRenderingInitPassed = false;
hyprListener_monitorFrame.removeCallback();
+ hyprListener_monitorDamage.removeCallback();
+ hyprListener_monitorNeedsFrame.removeCallback();
for (size_t i = 0; i < 4; ++i) {
for (auto& ls : m_aLayerSurfaceLayers[i]) {
@@ -251,8 +267,6 @@ void CMonitor::onDisconnect() {
activeWorkspace = -1;
- wlr_output_damage_destroy(damage);
-
wlr_output_layout_remove(g_pCompositor->m_sWLROutputLayout, output);
wlr_output_enable(output, false);
@@ -281,12 +295,14 @@ void CMonitor::onDisconnect() {
std::erase_if(g_pCompositor->m_vMonitors, [&](std::shared_ptr<CMonitor>& el) { return el.get() == this; });
}
-void CMonitor::addDamage(pixman_region32_t* rg) {
- wlr_output_damage_add(damage, rg);
+void CMonitor::addDamage(const pixman_region32_t* rg) {
+ if (wlr_damage_ring_add(&damage, rg))
+ g_pCompositor->scheduleFrameForMonitor(this);
}
-void CMonitor::addDamage(wlr_box* box) {
- wlr_output_damage_add_box(damage, box);
+void CMonitor::addDamage(const wlr_box* box) {
+ if (wlr_damage_ring_add_box(&damage, box))
+ g_pCompositor->scheduleFrameForMonitor(this);
}
bool CMonitor::isMirror() {