aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorLucas Reis <[email protected]>2024-06-19 10:24:28 -0400
committerGitHub <[email protected]>2024-06-19 16:24:28 +0200
commit20a465f69d342c5caead27df696d228492ea02e8 (patch)
tree9dcb0bb9dad50ad3e148b14b372fda799fc38ef0
parentfb15b7aa2a9bba0f0693f84d0c65d386942583f8 (diff)
downloadHyprland-20a465f69d342c5caead27df696d228492ea02e8.tar.gz
Hyprland-20a465f69d342c5caead27df696d228492ea02e8.zip
pointer: use software rendering when monitor is mirrored (#6587)
* pointer_manager: add lock/unlock software wrappers that receive the raw pointer * monitor: lock/unlock software pointer rendering when adding/removing mirrored screens * use relative path in includes
-rw-r--r--src/helpers/Monitor.cpp10
-rw-r--r--src/managers/PointerManager.cpp18
-rw-r--r--src/managers/PointerManager.hpp2
3 files changed, 30 insertions, 0 deletions
diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp
index da6da873..e99e16ef 100644
--- a/src/helpers/Monitor.cpp
+++ b/src/helpers/Monitor.cpp
@@ -6,6 +6,7 @@
#include "../devices/ITouch.hpp"
#include "../protocols/LayerShell.hpp"
#include "../protocols/PresentationTime.hpp"
+#include "../managers/PointerManager.hpp"
#include <hyprutils/string/String.hpp>
using namespace Hyprutils::String;
@@ -248,6 +249,9 @@ void CMonitor::onDisconnect(bool destroy) {
// remove mirror
if (pMirrorOf) {
pMirrorOf->mirrors.erase(std::find_if(pMirrorOf->mirrors.begin(), pMirrorOf->mirrors.end(), [&](const auto& other) { return other == this; }));
+
+ // unlock software for mirrored monitor
+ g_pPointerManager->unlockSoftwareForMonitor(pMirrorOf);
pMirrorOf = nullptr;
}
@@ -471,6 +475,9 @@ void CMonitor::setMirror(const std::string& mirrorOf) {
if (pMirrorOf) {
pMirrorOf->mirrors.erase(std::find_if(pMirrorOf->mirrors.begin(), pMirrorOf->mirrors.end(), [&](const auto& other) { return other == this; }));
+
+ // unlock software for mirrored monitor
+ g_pPointerManager->unlockSoftwareForMonitor(pMirrorOf);
}
pMirrorOf = nullptr;
@@ -540,6 +547,9 @@ void CMonitor::setMirror(const std::string& mirrorOf) {
g_pCompositor->setActiveMonitor(g_pCompositor->m_vMonitors.front().get());
g_pCompositor->sanityCheckWorkspaces();
+
+ // Software lock mirrored monitor
+ g_pPointerManager->lockSoftwareForMonitor(PMIRRORMON);
}
events.modeChanged.emit();
diff --git a/src/managers/PointerManager.cpp b/src/managers/PointerManager.cpp
index 05059669..d3da5eff 100644
--- a/src/managers/PointerManager.cpp
+++ b/src/managers/PointerManager.cpp
@@ -164,6 +164,15 @@ void CPointerManager::unlockSoftwareAll() {
updateCursorBackend();
}
+void CPointerManager::lockSoftwareForMonitor(CMonitor* Monitor) {
+ for (auto& m : g_pCompositor->m_vMonitors) {
+ if (m->ID == Monitor->ID) {
+ lockSoftwareForMonitor(m);
+ return;
+ }
+ }
+}
+
void CPointerManager::lockSoftwareForMonitor(SP<CMonitor> mon) {
auto state = stateFor(mon);
state->softwareLocks++;
@@ -172,6 +181,15 @@ void CPointerManager::lockSoftwareForMonitor(SP<CMonitor> mon) {
updateCursorBackend();
}
+void CPointerManager::unlockSoftwareForMonitor(CMonitor* Monitor) {
+ for (auto& m : g_pCompositor->m_vMonitors) {
+ if (m->ID == Monitor->ID) {
+ unlockSoftwareForMonitor(m);
+ return;
+ }
+ }
+}
+
void CPointerManager::unlockSoftwareForMonitor(SP<CMonitor> mon) {
auto state = stateFor(mon);
state->softwareLocks--;
diff --git a/src/managers/PointerManager.hpp b/src/managers/PointerManager.hpp
index c3673e16..545b76fb 100644
--- a/src/managers/PointerManager.hpp
+++ b/src/managers/PointerManager.hpp
@@ -43,6 +43,8 @@ class CPointerManager {
void lockSoftwareForMonitor(SP<CMonitor> pMonitor);
void unlockSoftwareForMonitor(SP<CMonitor> pMonitor);
+ void lockSoftwareForMonitor(CMonitor* pMonitor);
+ void unlockSoftwareForMonitor(CMonitor* pMonitor);
void lockSoftwareAll();
void unlockSoftwareAll();