mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-02 11:05:58 +01:00
internal: add a new monitor auto system
This commit is contained in:
parent
a0cf890292
commit
13886a264f
6 changed files with 54 additions and 2 deletions
|
@ -2485,3 +2485,37 @@ void CCompositor::setIdleActivityInhibit(bool enabled) {
|
|||
wlr_idle_set_enabled(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat, enabled);
|
||||
wlr_idle_notifier_v1_set_inhibited(g_pCompositor->m_sWLRIdleNotifier, !enabled);
|
||||
}
|
||||
|
||||
void CCompositor::arrangeMonitors() {
|
||||
std::vector<CMonitor*> toArrange;
|
||||
std::vector<CMonitor*> arranged;
|
||||
|
||||
for (auto& m : m_vMonitors)
|
||||
toArrange.push_back(m.get());
|
||||
|
||||
for (auto it = toArrange.begin(); it != toArrange.end(); ++it) {
|
||||
auto m = *it;
|
||||
|
||||
if (m->activeMonitorRule.offset > Vector2D{-1, -1}) {
|
||||
// explicit.
|
||||
m->moveTo(m->activeMonitorRule.offset);
|
||||
arranged.push_back(m);
|
||||
it = toArrange.erase(it);
|
||||
|
||||
if (it == toArrange.end())
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// auto left
|
||||
int maxOffset = 0;
|
||||
for (auto& m : arranged) {
|
||||
if (m->vecPosition.x + m->vecSize.x > maxOffset)
|
||||
maxOffset = m->vecPosition.x + m->vecSize.x;
|
||||
}
|
||||
|
||||
for (auto& m : toArrange) {
|
||||
m->moveTo({maxOffset, 0});
|
||||
maxOffset += m->vecPosition.x;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -202,6 +202,7 @@ class CCompositor {
|
|||
CWindow* getForceFocus();
|
||||
void notifyIdleActivity();
|
||||
void setIdleActivityInhibit(bool inhibit);
|
||||
void arrangeMonitors();
|
||||
|
||||
std::string explicitConfigPath;
|
||||
|
||||
|
|
|
@ -489,6 +489,8 @@ void CMonitor::setMirror(const std::string& mirrorOf) {
|
|||
// remove from mvmonitors
|
||||
std::erase_if(g_pCompositor->m_vMonitors, [&](const auto& other) { return other.get() == this; });
|
||||
|
||||
g_pCompositor->arrangeMonitors();
|
||||
|
||||
g_pCompositor->setActiveMonitor(g_pCompositor->m_vMonitors.front().get());
|
||||
|
||||
g_pCompositor->sanityCheckWorkspaces();
|
||||
|
@ -622,3 +624,10 @@ void CMonitor::setSpecialWorkspace(CWorkspace* const pWorkspace) {
|
|||
void CMonitor::setSpecialWorkspace(const int& id) {
|
||||
setSpecialWorkspace(g_pCompositor->getWorkspaceByID(id));
|
||||
}
|
||||
|
||||
void CMonitor::moveTo(const Vector2D& pos) {
|
||||
vecPosition = pos;
|
||||
|
||||
if (!isMirror())
|
||||
wlr_output_layout_add(g_pCompositor->m_sWLROutputLayout, output, (int)vecPosition.x, (int)vecPosition.y);
|
||||
}
|
||||
|
|
|
@ -109,6 +109,7 @@ class CMonitor {
|
|||
void changeWorkspace(const int& id, bool internal = false);
|
||||
void setSpecialWorkspace(CWorkspace* const pWorkspace);
|
||||
void setSpecialWorkspace(const int& id);
|
||||
void moveTo(const Vector2D& pos);
|
||||
|
||||
std::shared_ptr<CMonitor>* m_pThisWrap = nullptr;
|
||||
bool m_bEnabled = false;
|
||||
|
|
|
@ -43,6 +43,14 @@ class Vector2D {
|
|||
return Vector2D(this->x / a.x, this->y / a.y);
|
||||
}
|
||||
|
||||
bool operator>(const Vector2D& a) const {
|
||||
return this->x > a.x && this->y > a.y;
|
||||
}
|
||||
|
||||
bool operator<(const Vector2D& a) const {
|
||||
return this->x < a.x && this->y < a.y;
|
||||
}
|
||||
|
||||
double distance(const Vector2D& other) const;
|
||||
|
||||
Vector2D clamp(const Vector2D& min, const Vector2D& max = Vector2D()) const;
|
||||
|
|
|
@ -1903,8 +1903,7 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
|
|||
g_pHyprOpenGL->destroyMonitorResources(pMonitor);
|
||||
|
||||
// updato wlroots
|
||||
if (!pMonitor->isMirror())
|
||||
wlr_output_layout_add(g_pCompositor->m_sWLROutputLayout, pMonitor->output, (int)pMonitor->vecPosition.x, (int)pMonitor->vecPosition.y);
|
||||
g_pCompositor->arrangeMonitors();
|
||||
|
||||
wlr_damage_ring_set_bounds(&pMonitor->damage, pMonitor->vecTransformedSize.x, pMonitor->vecTransformedSize.y);
|
||||
|
||||
|
|
Loading…
Reference in a new issue