mirror of
https://github.com/hyprwm/Hyprland.git
synced 2024-12-22 07:01:34 +03:00
don't add existing and invalid monitors
This commit is contained in:
parent
f5645805d8
commit
b76b32b458
@ -255,6 +255,16 @@ SMonitor* CCompositor::getMonitorFromID(const int& id) {
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SMonitor* CCompositor::getMonitorFromName(const std::string& name) {
|
||||||
|
for (auto& m : m_lMonitors) {
|
||||||
|
if (m.szName == name) {
|
||||||
|
return &m;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
SMonitor* CCompositor::getMonitorFromCursor() {
|
SMonitor* CCompositor::getMonitorFromCursor() {
|
||||||
const auto COORDS = Vector2D(m_sWLRCursor->x, m_sWLRCursor->y);
|
const auto COORDS = Vector2D(m_sWLRCursor->x, m_sWLRCursor->y);
|
||||||
|
|
||||||
|
@ -86,6 +86,7 @@ public:
|
|||||||
// ------------------------------------------------- //
|
// ------------------------------------------------- //
|
||||||
|
|
||||||
SMonitor* getMonitorFromID(const int&);
|
SMonitor* getMonitorFromID(const int&);
|
||||||
|
SMonitor* getMonitorFromName(const std::string&);
|
||||||
SMonitor* getMonitorFromCursor();
|
SMonitor* getMonitorFromCursor();
|
||||||
SMonitor* getMonitorFromVector(const Vector2D&);
|
SMonitor* getMonitorFromVector(const Vector2D&);
|
||||||
void removeWindowFromVectorSafe(CWindow*);
|
void removeWindowFromVectorSafe(CWindow*);
|
||||||
|
@ -48,6 +48,16 @@ void Events::listener_newOutput(wl_listener* listener, void* data) {
|
|||||||
// new monitor added, let's accomodate for that.
|
// new monitor added, let's accomodate for that.
|
||||||
const auto OUTPUT = (wlr_output*)data;
|
const auto OUTPUT = (wlr_output*)data;
|
||||||
|
|
||||||
|
if (!OUTPUT->name) {
|
||||||
|
Debug::log(ERR, "New monitor has no name?? Ignoring");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (g_pCompositor->getMonitorFromName(std::string(OUTPUT->name))) {
|
||||||
|
Debug::log(WARN, "Monitor with name %s already exists, not adding as new!", OUTPUT->name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// get monitor rule that matches
|
// get monitor rule that matches
|
||||||
SMonitorRule monitorRule = g_pConfigManager->getMonitorRuleFor(OUTPUT->name);
|
SMonitorRule monitorRule = g_pConfigManager->getMonitorRuleFor(OUTPUT->name);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user