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
This commit is contained in:
Lucas Reis 2024-06-19 10:24:28 -04:00 committed by GitHub
parent fb15b7aa2a
commit 20a465f69d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 30 additions and 0 deletions

View file

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

View file

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

View file

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