monitor desc support (#2670)

* monitor desc

* monitor desc
This commit is contained in:
MightyPlaza 2023-07-09 21:10:35 +00:00 committed by GitHub
parent b99ac063ea
commit d9f7f039e1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 3 deletions

View file

@ -499,6 +499,16 @@ CMonitor* CCompositor::getMonitorFromName(const std::string& name) {
return nullptr;
}
CMonitor* CCompositor::getMonitorFromDesc(const std::string& desc) {
for (auto& m : m_vMonitors) {
if (desc == m->output->description) {
return m.get();
}
}
return nullptr;
}
CMonitor* CCompositor::getMonitorFromCursor() {
const auto COORDS = Vector2D(m_sWLRCursor->x, m_sWLRCursor->y);

View file

@ -28,8 +28,7 @@
#include "hyprerror/HyprError.hpp"
#include "plugins/PluginSystem.hpp"
enum eManagersInitStage
{
enum eManagersInitStage {
STAGE_PRIORITY = 0,
STAGE_LATE
};
@ -125,6 +124,7 @@ class CCompositor {
CMonitor* getMonitorFromID(const int&);
CMonitor* getMonitorFromName(const std::string&);
CMonitor* getMonitorFromDesc(const std::string&);
CMonitor* getMonitorFromCursor();
CMonitor* getMonitorFromVector(const Vector2D&);
void removeWindowFromVectorSafe(CWindow*);

View file

@ -2106,7 +2106,11 @@ void CConfigManager::addParseError(const std::string& err) {
}
CMonitor* CConfigManager::getBoundMonitorForWS(const std::string& wsname) {
return g_pCompositor->getMonitorFromName(getBoundMonitorStringForWS(wsname));
auto monitor = getBoundMonitorStringForWS(wsname);
if (monitor.substr(0, 5) == "desc:")
return g_pCompositor->getMonitorFromDesc(monitor.substr(5));
else
return g_pCompositor->getMonitorFromName(monitor);
}
std::string CConfigManager::getBoundMonitorStringForWS(const std::string& wsname) {