summaryrefslogtreecommitdiff
path: root/src/helpers/Monitor.cpp
diff options
context:
space:
mode:
authorVaxry <43317083+vaxerski@users.noreply.github.com>2023-11-01 18:53:36 +0000
committerGitHub <noreply@github.com>2023-11-01 18:53:36 +0000
commit21e9313c100e005ec2a9a5100c29258a2885546b (patch)
treedcda791982f3aa2b3e4939be67cdda11fd7023e3 /src/helpers/Monitor.cpp
parent7b32b4214d028a173c8192bddaa9e43503326080 (diff)
Core: various unsafe state improvements (#3713)
Fixes #3637
Diffstat (limited to 'src/helpers/Monitor.cpp')
-rw-r--r--src/helpers/Monitor.cpp53
1 files changed, 29 insertions, 24 deletions
diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp
index e96da35c..6d6b40e0 100644
--- a/src/helpers/Monitor.cpp
+++ b/src/helpers/Monitor.cpp
@@ -109,20 +109,20 @@ void CMonitor::onConnect(bool noRule) {
m_bRenderingInitPassed = true;
}
- if (!m_pThisWrap) {
+ std::shared_ptr<CMonitor>* thisWrapper = nullptr;
- // find the wrap
- for (auto& m : g_pCompositor->m_vRealMonitors) {
- if (m->ID == ID) {
- m_pThisWrap = &m;
- break;
- }
+ // find the wrap
+ for (auto& m : g_pCompositor->m_vRealMonitors) {
+ if (m->ID == ID) {
+ thisWrapper = &m;
+ break;
}
}
- if (std::find_if(g_pCompositor->m_vMonitors.begin(), g_pCompositor->m_vMonitors.end(), [&](auto& other) { return other.get() == this; }) == g_pCompositor->m_vMonitors.end()) {
- g_pCompositor->m_vMonitors.push_back(*m_pThisWrap);
- }
+ RASSERT(thisWrapper->get(), "CMonitor::onConnect: Had no wrapper???");
+
+ if (std::find_if(g_pCompositor->m_vMonitors.begin(), g_pCompositor->m_vMonitors.end(), [&](auto& other) { return other.get() == this; }) == g_pCompositor->m_vMonitors.end())
+ g_pCompositor->m_vMonitors.push_back(*thisWrapper);
m_bEnabled = true;
@@ -132,6 +132,8 @@ void CMonitor::onConnect(bool noRule) {
if (!noRule)
g_pHyprRenderer->applyMonitorRule(this, &monitorRule, true);
+ wlr_output_commit(output);
+
wlr_damage_ring_set_bounds(&damage, vecTransformedSize.x, vecTransformedSize.y);
wlr_xcursor_manager_load(g_pCompositor->m_sWLRXCursorMgr, scale);
@@ -152,8 +154,6 @@ void CMonitor::onConnect(bool noRule) {
if (scale < 0.1)
scale = getDefaultScale();
- m_pThisWrap = nullptr;
-
forceFullFrames = 3; // force 3 full frames to make sure there is no blinking due to double-buffering.
//
@@ -184,6 +184,8 @@ void CMonitor::onConnect(bool noRule) {
g_pCompositor->setActiveMonitor(this);
renderTimer = wl_event_loop_add_timer(g_pCompositor->m_sWLEventLoop, ratHandler, this);
+
+ g_pCompositor->scheduleFrameForMonitor(this);
}
void CMonitor::onDisconnect() {
@@ -221,9 +223,6 @@ void CMonitor::onDisconnect() {
g_pConfigManager->m_bWantsMonitorReload = true;
}
- m_bEnabled = false;
- m_bRenderingInitPassed = false;
-
hyprListener_monitorFrame.removeCallback();
hyprListener_monitorDamage.removeCallback();
hyprListener_monitorNeedsFrame.removeCallback();
@@ -248,6 +247,9 @@ void CMonitor::onDisconnect() {
g_pCompositor->enterUnsafeState();
}
+ m_bEnabled = false;
+ m_bRenderingInitPassed = false;
+
if (BACKUPMON) {
// snap cursor
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr, BACKUPMON->vecPosition.x + BACKUPMON->vecTransformedSize.x / 2.f,
@@ -256,7 +258,7 @@ void CMonitor::onDisconnect() {
// move workspaces
std::deque<CWorkspace*> wspToMove;
for (auto& w : g_pCompositor->m_vWorkspaces) {
- if (w->m_iMonitorID == ID) {
+ if (w->m_iMonitorID == ID || !g_pCompositor->getMonitorFromID(w->m_iMonitorID)) {
wspToMove.push_back(w.get());
}
}
@@ -414,19 +416,22 @@ void CMonitor::setMirror(const std::string& mirrorOf) {
vecPosition = RULE.offset;
// push to mvmonitors
- if (!m_pThisWrap) {
- // find the wrap
- for (auto& m : g_pCompositor->m_vRealMonitors) {
- if (m->ID == ID) {
- m_pThisWrap = &m;
- break;
- }
+
+ std::shared_ptr<CMonitor>* thisWrapper = nullptr;
+
+ // find the wrap
+ for (auto& m : g_pCompositor->m_vRealMonitors) {
+ if (m->ID == ID) {
+ thisWrapper = &m;
+ break;
}
}
+ RASSERT(thisWrapper->get(), "CMonitor::setMirror: Had no wrapper???");
+
if (std::find_if(g_pCompositor->m_vMonitors.begin(), g_pCompositor->m_vMonitors.end(), [&](auto& other) { return other.get() == this; }) ==
g_pCompositor->m_vMonitors.end()) {
- g_pCompositor->m_vMonitors.push_back(*m_pThisWrap);
+ g_pCompositor->m_vMonitors.push_back(*thisWrapper);
}
setupDefaultWS(RULE);