wlr-output-configuration: Improve output configuration (#7571)

This commit is contained in:
Vaxry 2024-09-26 11:10:53 +01:00 committed by GitHub
parent b1ad2d8066
commit caaa9b11e4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 181 additions and 77 deletions

View file

@ -7,6 +7,7 @@
#include "helpers/varlist/VarList.hpp" #include "helpers/varlist/VarList.hpp"
#include "../protocols/LayerShell.hpp" #include "../protocols/LayerShell.hpp"
#include "../xwayland/XWayland.hpp" #include "../xwayland/XWayland.hpp"
#include "../protocols/OutputManagement.hpp"
#include <cstddef> #include <cstddef>
#include <cstdint> #include <cstdint>
@ -1079,28 +1080,69 @@ std::string CConfigManager::getDeviceString(const std::string& dev, const std::s
return VAL; return VAL;
} }
SMonitorRule CConfigManager::getMonitorRuleFor(const CMonitor& PMONITOR) { SMonitorRule CConfigManager::getMonitorRuleFor(const SP<CMonitor> PMONITOR) {
auto applyWlrOutputConfig = [PMONITOR](SMonitorRule rule) -> SMonitorRule {
const auto CONFIG = PROTO::outputManagement->getOutputStateFor(PMONITOR);
if (!CONFIG)
return rule;
Debug::log(LOG, "CConfigManager::getMonitorRuleFor: found a wlr_output_manager override for {}", PMONITOR->szName);
Debug::log(LOG, " > overriding enabled: {} -> {}", !rule.disabled, !CONFIG->enabled);
rule.disabled = !CONFIG->enabled;
if ((CONFIG->committedProperties & OUTPUT_HEAD_COMMITTED_MODE) || (CONFIG->committedProperties & OUTPUT_HEAD_COMMITTED_CUSTOM_MODE)) {
Debug::log(LOG, " > overriding mode: {:.0f}x{:.0f}@{:.2f}Hz -> {:.0f}x{:.0f}@{:.2f}Hz", rule.resolution.x, rule.resolution.y, rule.refreshRate, CONFIG->resolution.x,
CONFIG->resolution.y, CONFIG->refresh / 1000.F);
rule.resolution = CONFIG->resolution;
rule.refreshRate = CONFIG->refresh / 1000.F;
}
if (CONFIG->committedProperties & OUTPUT_HEAD_COMMITTED_POSITION) {
Debug::log(LOG, " > overriding offset: {:.0f}, {:.0f} -> {:.0f}, {:.0f}", rule.offset.x, rule.offset.y, CONFIG->position.x, CONFIG->position.y);
rule.offset = CONFIG->position;
}
if (CONFIG->committedProperties & OUTPUT_HEAD_COMMITTED_TRANSFORM) {
Debug::log(LOG, " > overriding transform: {} -> {}", (uint8_t)rule.transform, (uint8_t)CONFIG->transform);
rule.transform = CONFIG->transform;
}
if (CONFIG->committedProperties & OUTPUT_HEAD_COMMITTED_SCALE) {
Debug::log(LOG, " > overriding scale: {} -> {}", (uint8_t)rule.scale, (uint8_t)CONFIG->scale);
rule.scale = CONFIG->scale;
}
if (CONFIG->committedProperties & OUTPUT_HEAD_COMMITTED_ADAPTIVE_SYNC) {
Debug::log(LOG, " > overriding vrr: {} -> {}", rule.vrr.value_or(0), CONFIG->adaptiveSync);
rule.vrr = (int)CONFIG->adaptiveSync;
}
return rule;
};
for (auto const& r : m_dMonitorRules | std::views::reverse) { for (auto const& r : m_dMonitorRules | std::views::reverse) {
if (PMONITOR.matchesStaticSelector(r.name)) { if (PMONITOR->matchesStaticSelector(r.name)) {
return r; return applyWlrOutputConfig(r);
} }
} }
Debug::log(WARN, "No rule found for {}, trying to use the first.", PMONITOR.szName); Debug::log(WARN, "No rule found for {}, trying to use the first.", PMONITOR->szName);
for (auto const& r : m_dMonitorRules) { for (auto const& r : m_dMonitorRules) {
if (r.name.empty()) { if (r.name.empty()) {
return r; return applyWlrOutputConfig(r);
} }
} }
Debug::log(WARN, "No rules configured. Using the default hardcoded one."); Debug::log(WARN, "No rules configured. Using the default hardcoded one.");
return SMonitorRule{.autoDir = eAutoDirs::DIR_AUTO_RIGHT, return applyWlrOutputConfig(SMonitorRule{.autoDir = eAutoDirs::DIR_AUTO_RIGHT,
.name = "", .name = "",
.resolution = Vector2D(0, 0), .resolution = Vector2D(0, 0),
.offset = Vector2D(-INT32_MAX, -INT32_MAX), .offset = Vector2D(-INT32_MAX, -INT32_MAX),
.scale = -1}; // 0, 0 is preferred and -1, -1 is auto .scale = -1}); // 0, 0 is preferred and -1, -1 is auto
} }
SWorkspaceRule CConfigManager::getWorkspaceRuleFor(PHLWORKSPACE pWorkspace) { SWorkspaceRule CConfigManager::getWorkspaceRuleFor(PHLWORKSPACE pWorkspace) {
@ -1459,7 +1501,7 @@ void CConfigManager::performMonitorReload() {
if (!m->output || m->isUnsafeFallback) if (!m->output || m->isUnsafeFallback)
continue; continue;
auto rule = getMonitorRuleFor(*m); auto rule = getMonitorRuleFor(m);
if (!g_pHyprRenderer->applyMonitorRule(m.get(), &rule)) { if (!g_pHyprRenderer->applyMonitorRule(m.get(), &rule)) {
overAgain = true; overAgain = true;
@ -1516,7 +1558,7 @@ void CConfigManager::ensureMonitorStatus() {
if (!rm->output || rm->isUnsafeFallback) if (!rm->output || rm->isUnsafeFallback)
continue; continue;
auto rule = getMonitorRuleFor(*rm); auto rule = getMonitorRuleFor(rm);
if (rule.disabled == rm->m_bEnabled) if (rule.disabled == rm->m_bEnabled)
g_pHyprRenderer->applyMonitorRule(rm.get(), &rule); g_pHyprRenderer->applyMonitorRule(rm.get(), &rule);

View file

@ -169,7 +169,7 @@ class CConfigManager {
static std::string getMainConfigPath(); static std::string getMainConfigPath();
const std::string getConfigString(); const std::string getConfigString();
SMonitorRule getMonitorRuleFor(const CMonitor&); SMonitorRule getMonitorRuleFor(const SP<CMonitor>);
SWorkspaceRule getWorkspaceRuleFor(PHLWORKSPACE workspace); SWorkspaceRule getWorkspaceRuleFor(PHLWORKSPACE workspace);
std::string getDefaultWorkspaceFor(const std::string&); std::string getDefaultWorkspaceFor(const std::string&);

View file

@ -114,7 +114,7 @@ void CMonitor::onConnect(bool noRule) {
createdByUser = true; // should be true. WL and Headless backends should be addable / removable createdByUser = true; // should be true. WL and Headless backends should be addable / removable
// get monitor rule that matches // get monitor rule that matches
SMonitorRule monitorRule = g_pConfigManager->getMonitorRuleFor(*this); SMonitorRule monitorRule = g_pConfigManager->getMonitorRuleFor(self.lock());
// if it's disabled, disable and ignore // if it's disabled, disable and ignore
if (monitorRule.disabled) { if (monitorRule.disabled) {
@ -489,7 +489,7 @@ void CMonitor::setMirror(const std::string& mirrorOf) {
pMirrorOf = nullptr; pMirrorOf = nullptr;
// set rule // set rule
const auto RULE = g_pConfigManager->getMonitorRuleFor(*this); const auto RULE = g_pConfigManager->getMonitorRuleFor(self.lock());
vecPosition = RULE.offset; vecPosition = RULE.offset;

View file

@ -1943,7 +1943,7 @@ SDispatchResult CKeybindManager::forceRendererReload(std::string args) {
if (!m->output) if (!m->output)
continue; continue;
auto rule = g_pConfigManager->getMonitorRuleFor(*m); auto rule = g_pConfigManager->getMonitorRuleFor(m);
if (!g_pHyprRenderer->applyMonitorRule(m.get(), &rule, true)) { if (!g_pHyprRenderer->applyMonitorRule(m.get(), &rule, true)) {
overAgain = true; overAgain = true;
break; break;

View file

@ -307,10 +307,15 @@ COutputConfiguration::COutputConfiguration(SP<CZwlrOutputConfigurationV1> resour
LOGM(LOG, "disableHead on {}", PMONITOR->szName); LOGM(LOG, "disableHead on {}", PMONITOR->szName);
PMONITOR->activeMonitorRule.disabled = true; SWlrManagerSavedOutputState newState;
if (!g_pConfigManager->replaceMonitorRule(PMONITOR->activeMonitorRule)) if (owner->monitorStates.contains(PMONITOR->szName))
g_pConfigManager->appendMonitorRule(PMONITOR->activeMonitorRule); newState = owner->monitorStates.at(PMONITOR->szName);
g_pHyprRenderer->applyMonitorRule(PMONITOR, &PMONITOR->activeMonitorRule, false);
newState.enabled = false;
g_pConfigManager->m_bWantsMonitorReload = true;
owner->monitorStates[PMONITOR->szName] = newState;
}); });
resource->setTest([this](CZwlrOutputConfigurationV1* r) { resource->setTest([this](CZwlrOutputConfigurationV1* r) {
@ -346,6 +351,11 @@ bool COutputConfiguration::applyTestConfiguration(bool test) {
LOGM(LOG, "Applying configuration"); LOGM(LOG, "Applying configuration");
if (!owner) {
LOGM(ERR, "applyTestConfiguration: no owner?!");
return false;
}
for (auto const& headw : heads) { for (auto const& headw : heads) {
auto head = headw.lock(); auto head = headw.lock();
@ -357,41 +367,59 @@ bool COutputConfiguration::applyTestConfiguration(bool test) {
if (!PMONITOR) if (!PMONITOR)
continue; continue;
LOGM(LOG, "Applying config for monitor {}", PMONITOR->szName); LOGM(LOG, "Saving config for monitor {}", PMONITOR->szName);
SMonitorRule newRule = PMONITOR->activeMonitorRule; SWlrManagerSavedOutputState newState;
newRule.name = PMONITOR->szName; if (owner->monitorStates.contains(PMONITOR->szName))
newRule.disabled = false; newState = owner->monitorStates.at(PMONITOR->szName);
if (head->committedProperties & COutputConfigurationHead::eCommittedProperties::OUTPUT_HEAD_COMMITTED_MODE) { newState.enabled = true;
newRule.resolution = head->state.mode->getMode()->pixelSize;
newRule.refreshRate = head->state.mode->getMode()->refreshRate / 1000.F; if (head->state.committedProperties & eWlrOutputCommittedProperties::OUTPUT_HEAD_COMMITTED_MODE) {
} else if (head->committedProperties & COutputConfigurationHead::eCommittedProperties::OUTPUT_HEAD_COMMITTED_CUSTOM_MODE) { newState.resolution = head->state.mode->getMode()->pixelSize;
newRule.resolution = head->state.customMode.size; newState.refresh = head->state.mode->getMode()->refreshRate;
newRule.refreshRate = head->state.customMode.refresh / 1000.F; newState.committedProperties |= eWlrOutputCommittedProperties::OUTPUT_HEAD_COMMITTED_MODE;
LOGM(LOG, " > Mode: {:.0f}x{:.0f}@{}mHz", newState.resolution.x, newState.resolution.y, newState.refresh);
} else if (head->state.committedProperties & eWlrOutputCommittedProperties::OUTPUT_HEAD_COMMITTED_CUSTOM_MODE) {
newState.resolution = head->state.customMode.size;
newState.refresh = head->state.customMode.refresh;
newState.committedProperties |= eWlrOutputCommittedProperties::OUTPUT_HEAD_COMMITTED_CUSTOM_MODE;
LOGM(LOG, " > Custom mode: {:.0f}x{:.0f}@{}mHz", newState.resolution.x, newState.resolution.y, newState.refresh);
} }
if (head->committedProperties & COutputConfigurationHead::eCommittedProperties::OUTPUT_HEAD_COMMITTED_POSITION) if (head->state.committedProperties & eWlrOutputCommittedProperties::OUTPUT_HEAD_COMMITTED_POSITION) {
newRule.offset = head->state.position; newState.position = head->state.position;
newState.committedProperties |= eWlrOutputCommittedProperties::OUTPUT_HEAD_COMMITTED_POSITION;
LOGM(LOG, " > Position: {:.0f}, {:.0f}", head->state.position.x, head->state.position.y);
}
if (head->committedProperties & COutputConfigurationHead::eCommittedProperties::OUTPUT_HEAD_COMMITTED_ADAPTIVE_SYNC) if (head->state.committedProperties & eWlrOutputCommittedProperties::OUTPUT_HEAD_COMMITTED_ADAPTIVE_SYNC) {
newRule.vrr = head->state.adaptiveSync; newState.adaptiveSync = head->state.adaptiveSync;
newState.committedProperties |= eWlrOutputCommittedProperties::OUTPUT_HEAD_COMMITTED_ADAPTIVE_SYNC;
LOGM(LOG, " > vrr: {}", newState.adaptiveSync);
}
if (head->committedProperties & COutputConfigurationHead::eCommittedProperties::OUTPUT_HEAD_COMMITTED_SCALE) if (head->state.committedProperties & eWlrOutputCommittedProperties::OUTPUT_HEAD_COMMITTED_SCALE) {
newRule.scale = head->state.scale; newState.scale = head->state.scale;
newState.committedProperties |= eWlrOutputCommittedProperties::OUTPUT_HEAD_COMMITTED_SCALE;
LOGM(LOG, " > scale: {:.2f}", newState.scale);
}
if (head->committedProperties & COutputConfigurationHead::eCommittedProperties::OUTPUT_HEAD_COMMITTED_TRANSFORM) if (head->state.committedProperties & eWlrOutputCommittedProperties::OUTPUT_HEAD_COMMITTED_TRANSFORM) {
newRule.transform = head->state.transform; newState.transform = head->state.transform;
newState.committedProperties |= eWlrOutputCommittedProperties::OUTPUT_HEAD_COMMITTED_TRANSFORM;
LOGM(LOG, " > transform: {}", (uint8_t)newState.transform);
}
// reset properties for next set. // reset properties for next set.
head->committedProperties = 0; head->state.committedProperties = 0;
if (!g_pConfigManager->replaceMonitorRule(newRule))
g_pConfigManager->appendMonitorRule(newRule);
g_pConfigManager->m_bWantsMonitorReload = true; g_pConfigManager->m_bWantsMonitorReload = true;
owner->monitorStates[PMONITOR->szName] = newState;
} }
LOGM(LOG, "Applied configuration"); LOGM(LOG, "Saved configuration");
return true; return true;
} }
@ -417,12 +445,12 @@ COutputConfigurationHead::COutputConfigurationHead(SP<CZwlrOutputConfigurationHe
return; return;
} }
if (committedProperties & OUTPUT_HEAD_COMMITTED_MODE) { if (state.committedProperties & OUTPUT_HEAD_COMMITTED_MODE) {
resource->error(ZWLR_OUTPUT_CONFIGURATION_HEAD_V1_ERROR_ALREADY_SET, "Property already set"); resource->error(ZWLR_OUTPUT_CONFIGURATION_HEAD_V1_ERROR_ALREADY_SET, "Property already set");
return; return;
} }
committedProperties |= OUTPUT_HEAD_COMMITTED_MODE; state.committedProperties |= OUTPUT_HEAD_COMMITTED_MODE;
state.mode = MODE; state.mode = MODE;
LOGM(LOG, " | configHead for {}: set mode to {}x{}@{}", pMonitor->szName, MODE->getMode()->pixelSize.x, MODE->getMode()->pixelSize.y, MODE->getMode()->refreshRate); LOGM(LOG, " | configHead for {}: set mode to {}x{}@{}", pMonitor->szName, MODE->getMode()->pixelSize.x, MODE->getMode()->pixelSize.y, MODE->getMode()->refreshRate);
@ -434,7 +462,7 @@ COutputConfigurationHead::COutputConfigurationHead(SP<CZwlrOutputConfigurationHe
return; return;
} }
if (committedProperties & OUTPUT_HEAD_COMMITTED_CUSTOM_MODE) { if (state.committedProperties & OUTPUT_HEAD_COMMITTED_CUSTOM_MODE) {
resource->error(ZWLR_OUTPUT_CONFIGURATION_HEAD_V1_ERROR_ALREADY_SET, "Property already set"); resource->error(ZWLR_OUTPUT_CONFIGURATION_HEAD_V1_ERROR_ALREADY_SET, "Property already set");
return; return;
} }
@ -444,7 +472,7 @@ COutputConfigurationHead::COutputConfigurationHead(SP<CZwlrOutputConfigurationHe
return; return;
} }
committedProperties |= OUTPUT_HEAD_COMMITTED_CUSTOM_MODE; state.committedProperties |= OUTPUT_HEAD_COMMITTED_CUSTOM_MODE;
state.customMode = {{w, h}, (uint32_t)refresh}; state.customMode = {{w, h}, (uint32_t)refresh};
LOGM(LOG, " | configHead for {}: set custom mode to {}x{}@{}", pMonitor->szName, w, h, refresh); LOGM(LOG, " | configHead for {}: set custom mode to {}x{}@{}", pMonitor->szName, w, h, refresh);
@ -456,12 +484,12 @@ COutputConfigurationHead::COutputConfigurationHead(SP<CZwlrOutputConfigurationHe
return; return;
} }
if (committedProperties & OUTPUT_HEAD_COMMITTED_POSITION) { if (state.committedProperties & OUTPUT_HEAD_COMMITTED_POSITION) {
resource->error(ZWLR_OUTPUT_CONFIGURATION_HEAD_V1_ERROR_ALREADY_SET, "Property already set"); resource->error(ZWLR_OUTPUT_CONFIGURATION_HEAD_V1_ERROR_ALREADY_SET, "Property already set");
return; return;
} }
committedProperties |= OUTPUT_HEAD_COMMITTED_POSITION; state.committedProperties |= OUTPUT_HEAD_COMMITTED_POSITION;
state.position = {x, y}; state.position = {x, y};
LOGM(LOG, " | configHead for {}: set pos to {}, {}", pMonitor->szName, x, y); LOGM(LOG, " | configHead for {}: set pos to {}, {}", pMonitor->szName, x, y);
@ -473,7 +501,7 @@ COutputConfigurationHead::COutputConfigurationHead(SP<CZwlrOutputConfigurationHe
return; return;
} }
if (committedProperties & OUTPUT_HEAD_COMMITTED_TRANSFORM) { if (state.committedProperties & OUTPUT_HEAD_COMMITTED_TRANSFORM) {
resource->error(ZWLR_OUTPUT_CONFIGURATION_HEAD_V1_ERROR_ALREADY_SET, "Property already set"); resource->error(ZWLR_OUTPUT_CONFIGURATION_HEAD_V1_ERROR_ALREADY_SET, "Property already set");
return; return;
} }
@ -483,7 +511,7 @@ COutputConfigurationHead::COutputConfigurationHead(SP<CZwlrOutputConfigurationHe
return; return;
} }
committedProperties |= OUTPUT_HEAD_COMMITTED_TRANSFORM; state.committedProperties |= OUTPUT_HEAD_COMMITTED_TRANSFORM;
state.transform = (wl_output_transform)transform; state.transform = (wl_output_transform)transform;
LOGM(LOG, " | configHead for {}: set transform to {}", pMonitor->szName, transform); LOGM(LOG, " | configHead for {}: set transform to {}", pMonitor->szName, transform);
@ -495,7 +523,7 @@ COutputConfigurationHead::COutputConfigurationHead(SP<CZwlrOutputConfigurationHe
return; return;
} }
if (committedProperties & OUTPUT_HEAD_COMMITTED_SCALE) { if (state.committedProperties & OUTPUT_HEAD_COMMITTED_SCALE) {
resource->error(ZWLR_OUTPUT_CONFIGURATION_HEAD_V1_ERROR_ALREADY_SET, "Property already set"); resource->error(ZWLR_OUTPUT_CONFIGURATION_HEAD_V1_ERROR_ALREADY_SET, "Property already set");
return; return;
} }
@ -507,7 +535,7 @@ COutputConfigurationHead::COutputConfigurationHead(SP<CZwlrOutputConfigurationHe
return; return;
} }
committedProperties |= OUTPUT_HEAD_COMMITTED_SCALE; state.committedProperties |= OUTPUT_HEAD_COMMITTED_SCALE;
state.scale = scale; state.scale = scale;
LOGM(LOG, " | configHead for {}: set scale to {:.2f}", pMonitor->szName, scale); LOGM(LOG, " | configHead for {}: set scale to {:.2f}", pMonitor->szName, scale);
@ -519,7 +547,7 @@ COutputConfigurationHead::COutputConfigurationHead(SP<CZwlrOutputConfigurationHe
return; return;
} }
if (committedProperties & OUTPUT_HEAD_COMMITTED_ADAPTIVE_SYNC) { if (state.committedProperties & OUTPUT_HEAD_COMMITTED_ADAPTIVE_SYNC) {
resource->error(ZWLR_OUTPUT_CONFIGURATION_HEAD_V1_ERROR_ALREADY_SET, "Property already set"); resource->error(ZWLR_OUTPUT_CONFIGURATION_HEAD_V1_ERROR_ALREADY_SET, "Property already set");
return; return;
} }
@ -529,7 +557,7 @@ COutputConfigurationHead::COutputConfigurationHead(SP<CZwlrOutputConfigurationHe
return; return;
} }
committedProperties |= OUTPUT_HEAD_COMMITTED_ADAPTIVE_SYNC; state.committedProperties |= OUTPUT_HEAD_COMMITTED_ADAPTIVE_SYNC;
state.adaptiveSync = as; state.adaptiveSync = as;
LOGM(LOG, " | configHead for {}: set adaptiveSync to {}", pMonitor->szName, as); LOGM(LOG, " | configHead for {}: set adaptiveSync to {}", pMonitor->szName, as);
@ -601,3 +629,14 @@ SP<COutputMode> COutputManagementProtocol::modeFromResource(wl_resource* r) {
return nullptr; return nullptr;
} }
SP<SWlrManagerSavedOutputState> COutputManagementProtocol::getOutputStateFor(SP<CMonitor> pMonitor) {
for (auto const& m : m_vManagers) {
if (!m->monitorStates.contains(pMonitor->szName))
continue;
return makeShared<SWlrManagerSavedOutputState>(m->monitorStates.at(pMonitor->szName));
}
return nullptr;
}

View file

@ -3,6 +3,7 @@
#include <memory> #include <memory>
#include <vector> #include <vector>
#include <cstdint> #include <cstdint>
#include <unordered_map>
#include "WaylandProtocol.hpp" #include "WaylandProtocol.hpp"
#include "wlr-output-management-unstable-v1.hpp" #include "wlr-output-management-unstable-v1.hpp"
#include "../helpers/signal/Signal.hpp" #include "../helpers/signal/Signal.hpp"
@ -13,6 +14,43 @@ class CMonitor;
class COutputHead; class COutputHead;
class COutputMode; class COutputMode;
struct SMonitorRule;
enum eWlrOutputCommittedProperties : uint32_t {
OUTPUT_HEAD_COMMITTED_MODE = (1 << 0),
OUTPUT_HEAD_COMMITTED_CUSTOM_MODE = (1 << 1),
OUTPUT_HEAD_COMMITTED_POSITION = (1 << 2),
OUTPUT_HEAD_COMMITTED_TRANSFORM = (1 << 3),
OUTPUT_HEAD_COMMITTED_SCALE = (1 << 4),
OUTPUT_HEAD_COMMITTED_ADAPTIVE_SYNC = (1 << 5),
};
struct SWlrManagerOutputState {
uint32_t committedProperties = 0;
WP<COutputMode> mode;
struct {
Vector2D size;
uint32_t refresh = 0;
} customMode;
Vector2D position;
wl_output_transform transform = WL_OUTPUT_TRANSFORM_NORMAL;
float scale = 1.F;
bool adaptiveSync = false;
bool enabled = true;
};
struct SWlrManagerSavedOutputState {
uint32_t committedProperties = 0;
Vector2D resolution;
uint32_t refresh = 0;
Vector2D position;
wl_output_transform transform = WL_OUTPUT_TRANSFORM_NORMAL;
float scale = 1.F;
bool adaptiveSync = false;
bool enabled = true;
};
class COutputManager { class COutputManager {
public: public:
COutputManager(SP<CZwlrOutputManagerV1> resource_); COutputManager(SP<CZwlrOutputManagerV1> resource_);
@ -21,6 +59,9 @@ class COutputManager {
void ensureMonitorSent(CMonitor* pMonitor); void ensureMonitorSent(CMonitor* pMonitor);
void sendDone(); void sendDone();
// holds the states for this manager.
std::unordered_map<std::string, SWlrManagerSavedOutputState> monitorStates;
private: private:
SP<CZwlrOutputManagerV1> resource; SP<CZwlrOutputManagerV1> resource;
bool stopped = false; bool stopped = false;
@ -82,28 +123,7 @@ class COutputConfigurationHead {
bool good(); bool good();
enum eCommittedProperties : uint32_t { SWlrManagerOutputState state;
OUTPUT_HEAD_COMMITTED_MODE = (1 << 0),
OUTPUT_HEAD_COMMITTED_CUSTOM_MODE = (1 << 1),
OUTPUT_HEAD_COMMITTED_POSITION = (1 << 2),
OUTPUT_HEAD_COMMITTED_TRANSFORM = (1 << 3),
OUTPUT_HEAD_COMMITTED_SCALE = (1 << 4),
OUTPUT_HEAD_COMMITTED_ADAPTIVE_SYNC = (1 << 5),
};
uint32_t committedProperties = 0;
struct {
WP<COutputMode> mode;
struct {
Vector2D size;
uint32_t refresh = 0;
} customMode;
Vector2D position;
wl_output_transform transform = WL_OUTPUT_TRANSFORM_NORMAL;
float scale = 1.F;
bool adaptiveSync = false;
} state;
private: private:
SP<CZwlrOutputConfigurationHeadV1> resource; SP<CZwlrOutputConfigurationHeadV1> resource;
@ -136,6 +156,9 @@ class COutputManagementProtocol : public IWaylandProtocol {
virtual void bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id); virtual void bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id);
// doesn't have to return one
SP<SWlrManagerSavedOutputState> getOutputStateFor(SP<CMonitor> pMonitor);
private: private:
void destroyResource(COutputManager* resource); void destroyResource(COutputManager* resource);
void destroyResource(COutputHead* resource); void destroyResource(COutputHead* resource);