mirror of
https://github.com/hyprwm/Hyprland.git
synced 2025-08-06 15:11:57 -07:00
input: Map touch devices and tablets bound to an output (#3544)
* Map bound touch devices and tablets to an output * Add "[[Auto]]" default option for auto detecting outputs for touch inputs * Bind new monitors to configured touch and tablet devices * Use Monitor::matchesStaticSelector in CConfigManager::getMonitorRuleFor * Use Monitor::matchesStaticSelector in CCompositor::getMonitorFromString
This commit is contained in:
@@ -465,7 +465,7 @@ CConfigManager::CConfigManager() {
|
||||
m_pConfig->addConfigValue("input:touchpad:drag_lock", {0L});
|
||||
m_pConfig->addConfigValue("input:touchpad:scroll_factor", {1.f});
|
||||
m_pConfig->addConfigValue("input:touchdevice:transform", {0L});
|
||||
m_pConfig->addConfigValue("input:touchdevice:output", {STRVAL_EMPTY});
|
||||
m_pConfig->addConfigValue("input:touchdevice:output", {"[[Auto]]"});
|
||||
m_pConfig->addConfigValue("input:touchdevice:enabled", {1L});
|
||||
m_pConfig->addConfigValue("input:tablet:transform", {0L});
|
||||
m_pConfig->addConfigValue("input:tablet:output", {STRVAL_EMPTY});
|
||||
@@ -907,33 +907,21 @@ std::string CConfigManager::getDeviceString(const std::string& dev, const std::s
|
||||
return VAL;
|
||||
}
|
||||
|
||||
SMonitorRule CConfigManager::getMonitorRuleFor(const std::string& name, const std::string& displayName) {
|
||||
SMonitorRule* found = nullptr;
|
||||
|
||||
SMonitorRule CConfigManager::getMonitorRuleFor(const CMonitor& PMONITOR) {
|
||||
for (auto& r : m_dMonitorRules) {
|
||||
if (r.name == name ||
|
||||
(r.name.starts_with("desc:") &&
|
||||
(r.name.substr(5) == displayName || r.name.substr(5) == removeBeginEndSpacesTabs(displayName.substr(0, displayName.find_first_of('(')))))) {
|
||||
found = &r;
|
||||
break;
|
||||
if (PMONITOR.matchesStaticSelector(r.name)) {
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
if (found)
|
||||
return *found;
|
||||
|
||||
Debug::log(WARN, "No rule found for {}, trying to use the first.", name);
|
||||
Debug::log(WARN, "No rule found for {}, trying to use the first.", PMONITOR.szName);
|
||||
|
||||
for (auto& r : m_dMonitorRules) {
|
||||
if (r.name == "") {
|
||||
found = &r;
|
||||
break;
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
if (found)
|
||||
return *found;
|
||||
|
||||
Debug::log(WARN, "No rules configured. Using the default hardcoded one.");
|
||||
|
||||
return SMonitorRule{.name = "", .resolution = Vector2D(0, 0), .offset = Vector2D(-INT32_MAX, -INT32_MAX), .scale = -1}; // 0, 0 is preferred and -1, -1 is auto
|
||||
@@ -1173,7 +1161,7 @@ void CConfigManager::performMonitorReload() {
|
||||
if (!m->output || m->isUnsafeFallback)
|
||||
continue;
|
||||
|
||||
auto rule = getMonitorRuleFor(m->szName, m->szDescription);
|
||||
auto rule = getMonitorRuleFor(*m);
|
||||
|
||||
if (!g_pHyprRenderer->applyMonitorRule(m.get(), &rule)) {
|
||||
overAgain = true;
|
||||
@@ -1230,7 +1218,7 @@ void CConfigManager::ensureMonitorStatus() {
|
||||
if (!rm->output || rm->isUnsafeFallback)
|
||||
continue;
|
||||
|
||||
auto rule = getMonitorRuleFor(rm->szName, rm->szDescription);
|
||||
auto rule = getMonitorRuleFor(*rm);
|
||||
|
||||
if (rule.disabled == rm->m_bEnabled)
|
||||
g_pHyprRenderer->applyMonitorRule(rm.get(), &rule);
|
||||
|
Reference in New Issue
Block a user