workspaces: refactor class member vars (#10167)
This commit is contained in:
parent
0e80ecc534
commit
02d7badd15
37 changed files with 687 additions and 688 deletions
|
|
@ -180,7 +180,7 @@ void CLayerSurface::onMap() {
|
|||
|
||||
CBox geomFixed = {m_geometry.x + PMONITOR->vecPosition.x, m_geometry.y + PMONITOR->vecPosition.y, m_geometry.width, m_geometry.height};
|
||||
g_pHyprRenderer->damageBox(geomFixed);
|
||||
const bool FULLSCREEN = PMONITOR->activeWorkspace && PMONITOR->activeWorkspace->m_bHasFullscreenWindow && PMONITOR->activeWorkspace->m_efFullscreenMode == FSMODE_FULLSCREEN;
|
||||
const bool FULLSCREEN = PMONITOR->activeWorkspace && PMONITOR->activeWorkspace->m_hasFullscreenWindow && PMONITOR->activeWorkspace->m_fullscreenMode == FSMODE_FULLSCREEN;
|
||||
|
||||
startAnimation(!(m_layer == ZWLR_LAYER_SHELL_V1_LAYER_TOP && FULLSCREEN && !GRABSFOCUS));
|
||||
m_readyToDelete = false;
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ void CPopup::onCommit(bool ignoreSiblings) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (!m_windowOwner.expired() && (!m_windowOwner->m_bIsMapped || !m_windowOwner->m_pWorkspace->m_bVisible)) {
|
||||
if (!m_windowOwner.expired() && (!m_windowOwner->m_bIsMapped || !m_windowOwner->m_pWorkspace->m_visible)) {
|
||||
m_lastSize = m_resource->surface->surface->current.size;
|
||||
|
||||
static auto PLOGDAMAGE = CConfigValue<Hyprlang::INT>("debug:log_damage");
|
||||
|
|
@ -301,9 +301,9 @@ Vector2D CPopup::size() {
|
|||
|
||||
void CPopup::sendScale() {
|
||||
if (!m_windowOwner.expired())
|
||||
g_pCompositor->setPreferredScaleForSurface(m_wlSurface->resource(), m_windowOwner->m_pWLSurface->m_fLastScale);
|
||||
g_pCompositor->setPreferredScaleForSurface(m_wlSurface->resource(), m_windowOwner->m_pWLSurface->m_lastScaleFloat);
|
||||
else if (!m_layerOwner.expired())
|
||||
g_pCompositor->setPreferredScaleForSurface(m_wlSurface->resource(), m_layerOwner->m_surface->m_fLastScale);
|
||||
g_pCompositor->setPreferredScaleForSurface(m_wlSurface->resource(), m_layerOwner->m_surface->m_lastScaleFloat);
|
||||
else
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,17 +6,17 @@
|
|||
CRuleRegexContainer::CRuleRegexContainer(const std::string& regex_) {
|
||||
const bool NEGATIVE = regex_.starts_with("negative:");
|
||||
|
||||
negative = NEGATIVE;
|
||||
regex = makeUnique<RE2>(NEGATIVE ? regex_.substr(9) : regex_);
|
||||
m_negative = NEGATIVE;
|
||||
m_regex = makeUnique<RE2>(NEGATIVE ? regex_.substr(9) : regex_);
|
||||
|
||||
// TODO: maybe pop an error?
|
||||
if (!regex->ok())
|
||||
if (!m_regex->ok())
|
||||
Debug::log(ERR, "RuleRegexContainer: regex {} failed to parse!", regex_);
|
||||
}
|
||||
|
||||
bool CRuleRegexContainer::passes(const std::string& str) const {
|
||||
if (!regex)
|
||||
if (!m_regex)
|
||||
return false;
|
||||
|
||||
return RE2::FullMatch(str, *regex) != negative;
|
||||
return RE2::FullMatch(str, *m_regex) != m_negative;
|
||||
}
|
||||
|
|
@ -16,6 +16,6 @@ class CRuleRegexContainer {
|
|||
bool passes(const std::string& str) const;
|
||||
|
||||
private:
|
||||
Hyprutils::Memory::CUniquePointer<re2::RE2> regex;
|
||||
bool negative = false;
|
||||
Hyprutils::Memory::CUniquePointer<re2::RE2> m_regex;
|
||||
bool m_negative = false;
|
||||
};
|
||||
|
|
@ -8,9 +8,9 @@
|
|||
#include "../managers/input/InputManager.hpp"
|
||||
|
||||
UP<CSubsurface> CSubsurface::create(PHLWINDOW pOwner) {
|
||||
auto subsurface = UP<CSubsurface>(new CSubsurface());
|
||||
subsurface->m_pWindowParent = pOwner;
|
||||
subsurface->m_pSelf = subsurface;
|
||||
auto subsurface = UP<CSubsurface>(new CSubsurface());
|
||||
subsurface->m_windowParent = pOwner;
|
||||
subsurface->m_self = subsurface;
|
||||
|
||||
subsurface->initSignals();
|
||||
subsurface->initExistingSubsurfaces(pOwner->m_pWLSurface->resource());
|
||||
|
|
@ -18,155 +18,155 @@ UP<CSubsurface> CSubsurface::create(PHLWINDOW pOwner) {
|
|||
}
|
||||
|
||||
UP<CSubsurface> CSubsurface::create(WP<CPopup> pOwner) {
|
||||
auto subsurface = UP<CSubsurface>(new CSubsurface());
|
||||
subsurface->m_pPopupParent = pOwner;
|
||||
subsurface->m_pSelf = subsurface;
|
||||
auto subsurface = UP<CSubsurface>(new CSubsurface());
|
||||
subsurface->m_popupParent = pOwner;
|
||||
subsurface->m_self = subsurface;
|
||||
subsurface->initSignals();
|
||||
subsurface->initExistingSubsurfaces(pOwner->m_wlSurface->resource());
|
||||
return subsurface;
|
||||
}
|
||||
|
||||
UP<CSubsurface> CSubsurface::create(SP<CWLSubsurfaceResource> pSubsurface, PHLWINDOW pOwner) {
|
||||
auto subsurface = UP<CSubsurface>(new CSubsurface());
|
||||
subsurface->m_pWindowParent = pOwner;
|
||||
subsurface->m_pSubsurface = pSubsurface;
|
||||
subsurface->m_pSelf = subsurface;
|
||||
subsurface->m_pWLSurface = CWLSurface::create();
|
||||
subsurface->m_pWLSurface->assign(pSubsurface->surface.lock(), subsurface.get());
|
||||
auto subsurface = UP<CSubsurface>(new CSubsurface());
|
||||
subsurface->m_windowParent = pOwner;
|
||||
subsurface->m_subsurface = pSubsurface;
|
||||
subsurface->m_self = subsurface;
|
||||
subsurface->m_wlSurface = CWLSurface::create();
|
||||
subsurface->m_wlSurface->assign(pSubsurface->surface.lock(), subsurface.get());
|
||||
subsurface->initSignals();
|
||||
subsurface->initExistingSubsurfaces(pSubsurface->surface.lock());
|
||||
return subsurface;
|
||||
}
|
||||
|
||||
UP<CSubsurface> CSubsurface::create(SP<CWLSubsurfaceResource> pSubsurface, WP<CPopup> pOwner) {
|
||||
auto subsurface = UP<CSubsurface>(new CSubsurface());
|
||||
subsurface->m_pPopupParent = pOwner;
|
||||
subsurface->m_pSubsurface = pSubsurface;
|
||||
subsurface->m_pSelf = subsurface;
|
||||
subsurface->m_pWLSurface = CWLSurface::create();
|
||||
subsurface->m_pWLSurface->assign(pSubsurface->surface.lock(), subsurface.get());
|
||||
auto subsurface = UP<CSubsurface>(new CSubsurface());
|
||||
subsurface->m_popupParent = pOwner;
|
||||
subsurface->m_subsurface = pSubsurface;
|
||||
subsurface->m_self = subsurface;
|
||||
subsurface->m_wlSurface = CWLSurface::create();
|
||||
subsurface->m_wlSurface->assign(pSubsurface->surface.lock(), subsurface.get());
|
||||
subsurface->initSignals();
|
||||
subsurface->initExistingSubsurfaces(pSubsurface->surface.lock());
|
||||
return subsurface;
|
||||
}
|
||||
|
||||
void CSubsurface::initSignals() {
|
||||
if (m_pSubsurface) {
|
||||
listeners.commitSubsurface = m_pSubsurface->surface->events.commit.registerListener([this](std::any d) { onCommit(); });
|
||||
listeners.destroySubsurface = m_pSubsurface->events.destroy.registerListener([this](std::any d) { onDestroy(); });
|
||||
listeners.mapSubsurface = m_pSubsurface->surface->events.map.registerListener([this](std::any d) { onMap(); });
|
||||
listeners.unmapSubsurface = m_pSubsurface->surface->events.unmap.registerListener([this](std::any d) { onUnmap(); });
|
||||
listeners.newSubsurface =
|
||||
m_pSubsurface->surface->events.newSubsurface.registerListener([this](std::any d) { onNewSubsurface(std::any_cast<SP<CWLSubsurfaceResource>>(d)); });
|
||||
if (m_subsurface) {
|
||||
m_listeners.commitSubsurface = m_subsurface->surface->events.commit.registerListener([this](std::any d) { onCommit(); });
|
||||
m_listeners.destroySubsurface = m_subsurface->events.destroy.registerListener([this](std::any d) { onDestroy(); });
|
||||
m_listeners.mapSubsurface = m_subsurface->surface->events.map.registerListener([this](std::any d) { onMap(); });
|
||||
m_listeners.unmapSubsurface = m_subsurface->surface->events.unmap.registerListener([this](std::any d) { onUnmap(); });
|
||||
m_listeners.newSubsurface =
|
||||
m_subsurface->surface->events.newSubsurface.registerListener([this](std::any d) { onNewSubsurface(std::any_cast<SP<CWLSubsurfaceResource>>(d)); });
|
||||
} else {
|
||||
if (m_pWindowParent)
|
||||
listeners.newSubsurface = m_pWindowParent->m_pWLSurface->resource()->events.newSubsurface.registerListener(
|
||||
[this](std::any d) { onNewSubsurface(std::any_cast<SP<CWLSubsurfaceResource>>(d)); });
|
||||
else if (m_pPopupParent)
|
||||
listeners.newSubsurface = m_pPopupParent->m_wlSurface->resource()->events.newSubsurface.registerListener(
|
||||
if (m_windowParent)
|
||||
m_listeners.newSubsurface = m_windowParent->m_pWLSurface->resource()->events.newSubsurface.registerListener(
|
||||
[this](std::any d) { onNewSubsurface(std::any_cast<SP<CWLSubsurfaceResource>>(d)); });
|
||||
else if (m_popupParent)
|
||||
m_listeners.newSubsurface =
|
||||
m_popupParent->m_wlSurface->resource()->events.newSubsurface.registerListener([this](std::any d) { onNewSubsurface(std::any_cast<SP<CWLSubsurfaceResource>>(d)); });
|
||||
else
|
||||
ASSERT(false);
|
||||
}
|
||||
}
|
||||
|
||||
void CSubsurface::checkSiblingDamage() {
|
||||
if (!m_pParent)
|
||||
if (!m_parent)
|
||||
return; // ??????????
|
||||
|
||||
const double SCALE = m_pWindowParent.lock() && m_pWindowParent->m_bIsX11 ? 1.0 / m_pWindowParent->m_fX11SurfaceScaledBy : 1.0;
|
||||
const double SCALE = m_windowParent.lock() && m_windowParent->m_bIsX11 ? 1.0 / m_windowParent->m_fX11SurfaceScaledBy : 1.0;
|
||||
|
||||
for (auto const& n : m_pParent->m_vChildren) {
|
||||
for (auto const& n : m_parent->m_children) {
|
||||
if (n.get() == this)
|
||||
continue;
|
||||
|
||||
const auto COORDS = n->coordsGlobal();
|
||||
g_pHyprRenderer->damageSurface(n->m_pWLSurface->resource(), COORDS.x, COORDS.y, SCALE);
|
||||
g_pHyprRenderer->damageSurface(n->m_wlSurface->resource(), COORDS.x, COORDS.y, SCALE);
|
||||
}
|
||||
}
|
||||
|
||||
void CSubsurface::recheckDamageForSubsurfaces() {
|
||||
for (auto const& n : m_vChildren) {
|
||||
for (auto const& n : m_children) {
|
||||
const auto COORDS = n->coordsGlobal();
|
||||
g_pHyprRenderer->damageSurface(n->m_pWLSurface->resource(), COORDS.x, COORDS.y);
|
||||
g_pHyprRenderer->damageSurface(n->m_wlSurface->resource(), COORDS.x, COORDS.y);
|
||||
}
|
||||
}
|
||||
|
||||
void CSubsurface::onCommit() {
|
||||
// no damaging if it's not visible
|
||||
if (!m_pWindowParent.expired() && (!m_pWindowParent->m_bIsMapped || !m_pWindowParent->m_pWorkspace->m_bVisible)) {
|
||||
m_vLastSize = m_pWLSurface->resource()->current.size;
|
||||
if (!m_windowParent.expired() && (!m_windowParent->m_bIsMapped || !m_windowParent->m_pWorkspace->m_visible)) {
|
||||
m_lastSize = m_wlSurface->resource()->current.size;
|
||||
|
||||
static auto PLOGDAMAGE = CConfigValue<Hyprlang::INT>("debug:log_damage");
|
||||
if (*PLOGDAMAGE)
|
||||
Debug::log(LOG, "Refusing to commit damage from a subsurface of {} because it's invisible.", m_pWindowParent.lock());
|
||||
Debug::log(LOG, "Refusing to commit damage from a subsurface of {} because it's invisible.", m_windowParent.lock());
|
||||
return;
|
||||
}
|
||||
|
||||
const auto COORDS = coordsGlobal();
|
||||
|
||||
g_pHyprRenderer->damageSurface(m_pWLSurface->resource(), COORDS.x, COORDS.y);
|
||||
g_pHyprRenderer->damageSurface(m_wlSurface->resource(), COORDS.x, COORDS.y);
|
||||
|
||||
if (m_pPopupParent && !m_pPopupParent->inert() && m_pPopupParent->m_wlSurface)
|
||||
m_pPopupParent->recheckTree();
|
||||
if (!m_pWindowParent.expired()) // I hate you firefox why are you doing this
|
||||
m_pWindowParent->m_pPopupHead->recheckTree();
|
||||
if (m_popupParent && !m_popupParent->inert() && m_popupParent->m_wlSurface)
|
||||
m_popupParent->recheckTree();
|
||||
if (!m_windowParent.expired()) // I hate you firefox why are you doing this
|
||||
m_windowParent->m_pPopupHead->recheckTree();
|
||||
|
||||
// I do not think this is correct, but it solves a lot of issues with some apps (e.g. firefox)
|
||||
checkSiblingDamage();
|
||||
|
||||
if (m_vLastSize != m_pWLSurface->resource()->current.size || m_vLastPosition != m_pSubsurface->position) {
|
||||
if (m_lastSize != m_wlSurface->resource()->current.size || m_lastPosition != m_subsurface->position) {
|
||||
damageLastArea();
|
||||
m_vLastSize = m_pWLSurface->resource()->current.size;
|
||||
m_vLastPosition = m_pSubsurface->position;
|
||||
m_lastSize = m_wlSurface->resource()->current.size;
|
||||
m_lastPosition = m_subsurface->position;
|
||||
}
|
||||
}
|
||||
|
||||
void CSubsurface::onDestroy() {
|
||||
// destroy children
|
||||
m_vChildren.clear();
|
||||
m_children.clear();
|
||||
|
||||
m_bInert = true;
|
||||
m_inert = true;
|
||||
|
||||
if (!m_pSubsurface)
|
||||
if (!m_subsurface)
|
||||
return; // dummy node, nothing to do, it's the parent dying
|
||||
|
||||
// kill ourselves
|
||||
std::erase_if(m_pParent->m_vChildren, [this](const auto& other) { return other.get() == this; });
|
||||
std::erase_if(m_parent->m_children, [this](const auto& other) { return other.get() == this; });
|
||||
}
|
||||
|
||||
void CSubsurface::onNewSubsurface(SP<CWLSubsurfaceResource> pSubsurface) {
|
||||
WP<CSubsurface> PSUBSURFACE;
|
||||
|
||||
if (!m_pWindowParent.expired())
|
||||
PSUBSURFACE = m_vChildren.emplace_back(CSubsurface::create(pSubsurface, m_pWindowParent.lock()));
|
||||
else if (m_pPopupParent)
|
||||
PSUBSURFACE = m_vChildren.emplace_back(CSubsurface::create(pSubsurface, m_pPopupParent));
|
||||
if (!m_windowParent.expired())
|
||||
PSUBSURFACE = m_children.emplace_back(CSubsurface::create(pSubsurface, m_windowParent.lock()));
|
||||
else if (m_popupParent)
|
||||
PSUBSURFACE = m_children.emplace_back(CSubsurface::create(pSubsurface, m_popupParent));
|
||||
|
||||
PSUBSURFACE->m_pSelf = PSUBSURFACE;
|
||||
PSUBSURFACE->m_self = PSUBSURFACE;
|
||||
|
||||
ASSERT(PSUBSURFACE);
|
||||
|
||||
PSUBSURFACE->m_pParent = m_pSelf;
|
||||
PSUBSURFACE->m_parent = m_self;
|
||||
}
|
||||
|
||||
void CSubsurface::onMap() {
|
||||
m_vLastSize = m_pWLSurface->resource()->current.size;
|
||||
m_vLastPosition = m_pSubsurface->position;
|
||||
m_lastSize = m_wlSurface->resource()->current.size;
|
||||
m_lastPosition = m_subsurface->position;
|
||||
|
||||
const auto COORDS = coordsGlobal();
|
||||
CBox box{COORDS, m_vLastSize};
|
||||
CBox box{COORDS, m_lastSize};
|
||||
box.expand(4);
|
||||
g_pHyprRenderer->damageBox(box);
|
||||
|
||||
if (!m_pWindowParent.expired())
|
||||
m_pWindowParent->updateSurfaceScaleTransformDetails();
|
||||
if (!m_windowParent.expired())
|
||||
m_windowParent->updateSurfaceScaleTransformDetails();
|
||||
}
|
||||
|
||||
void CSubsurface::onUnmap() {
|
||||
damageLastArea();
|
||||
|
||||
if (m_pWLSurface->resource() == g_pCompositor->m_lastFocus)
|
||||
if (m_wlSurface->resource() == g_pCompositor->m_lastFocus)
|
||||
g_pInputManager->releaseAllMouseButtons();
|
||||
|
||||
g_pInputManager->simulateMouseMovement();
|
||||
|
|
@ -175,25 +175,25 @@ void CSubsurface::onUnmap() {
|
|||
}
|
||||
|
||||
void CSubsurface::damageLastArea() {
|
||||
const auto COORDS = coordsGlobal() + m_vLastPosition - m_pSubsurface->position;
|
||||
CBox box{COORDS, m_vLastSize};
|
||||
const auto COORDS = coordsGlobal() + m_lastPosition - m_subsurface->position;
|
||||
CBox box{COORDS, m_lastSize};
|
||||
box.expand(4);
|
||||
g_pHyprRenderer->damageBox(box);
|
||||
}
|
||||
|
||||
Vector2D CSubsurface::coordsRelativeToParent() {
|
||||
if (!m_pSubsurface)
|
||||
if (!m_subsurface)
|
||||
return {};
|
||||
return m_pSubsurface->posRelativeToParent();
|
||||
return m_subsurface->posRelativeToParent();
|
||||
}
|
||||
|
||||
Vector2D CSubsurface::coordsGlobal() {
|
||||
Vector2D coords = coordsRelativeToParent();
|
||||
|
||||
if (!m_pWindowParent.expired())
|
||||
coords += m_pWindowParent->m_vRealPosition->value();
|
||||
else if (m_pPopupParent)
|
||||
coords += m_pPopupParent->coordsGlobal();
|
||||
if (!m_windowParent.expired())
|
||||
coords += m_windowParent->m_vRealPosition->value();
|
||||
else if (m_popupParent)
|
||||
coords += m_popupParent->coordsGlobal();
|
||||
|
||||
return coords;
|
||||
}
|
||||
|
|
@ -207,16 +207,16 @@ void CSubsurface::initExistingSubsurfaces(SP<CWLSurfaceResource> pSurface) {
|
|||
}
|
||||
|
||||
Vector2D CSubsurface::size() {
|
||||
return m_pWLSurface->resource()->current.size;
|
||||
return m_wlSurface->resource()->current.size;
|
||||
}
|
||||
|
||||
bool CSubsurface::visible() {
|
||||
if (!m_pWindowParent.expired())
|
||||
return g_pHyprRenderer->shouldRenderWindow(m_pWindowParent.lock());
|
||||
if (m_pPopupParent)
|
||||
return m_pPopupParent->visible();
|
||||
if (m_pParent)
|
||||
return m_pParent->visible();
|
||||
if (!m_windowParent.expired())
|
||||
return g_pHyprRenderer->shouldRenderWindow(m_windowParent.lock());
|
||||
if (m_popupParent)
|
||||
return m_popupParent->visible();
|
||||
if (m_parent)
|
||||
return m_parent->visible();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ class CSubsurface {
|
|||
|
||||
void recheckDamageForSubsurfaces();
|
||||
|
||||
WP<CSubsurface> m_pSelf;
|
||||
WP<CSubsurface> m_self;
|
||||
|
||||
private:
|
||||
CSubsurface() = default;
|
||||
|
|
@ -45,22 +45,22 @@ class CSubsurface {
|
|||
CHyprSignalListener mapSubsurface;
|
||||
CHyprSignalListener unmapSubsurface;
|
||||
CHyprSignalListener newSubsurface;
|
||||
} listeners;
|
||||
} m_listeners;
|
||||
|
||||
WP<CWLSubsurfaceResource> m_pSubsurface;
|
||||
SP<CWLSurface> m_pWLSurface;
|
||||
Vector2D m_vLastSize = {};
|
||||
Vector2D m_vLastPosition = {};
|
||||
WP<CWLSubsurfaceResource> m_subsurface;
|
||||
SP<CWLSurface> m_wlSurface;
|
||||
Vector2D m_lastSize = {};
|
||||
Vector2D m_lastPosition = {};
|
||||
|
||||
// if nullptr, means it's a dummy node
|
||||
WP<CSubsurface> m_pParent;
|
||||
WP<CSubsurface> m_parent;
|
||||
|
||||
PHLWINDOWREF m_pWindowParent;
|
||||
WP<CPopup> m_pPopupParent;
|
||||
PHLWINDOWREF m_windowParent;
|
||||
WP<CPopup> m_popupParent;
|
||||
|
||||
std::vector<UP<CSubsurface>> m_vChildren;
|
||||
std::vector<UP<CSubsurface>> m_children;
|
||||
|
||||
bool m_bInert = false;
|
||||
bool m_inert = false;
|
||||
|
||||
void initSignals();
|
||||
void initExistingSubsurfaces(SP<CWLSurfaceResource> pSurface);
|
||||
|
|
|
|||
|
|
@ -6,37 +6,37 @@
|
|||
#include "../render/Renderer.hpp"
|
||||
|
||||
void CWLSurface::assign(SP<CWLSurfaceResource> pSurface) {
|
||||
m_pResource = pSurface;
|
||||
m_resource = pSurface;
|
||||
init();
|
||||
m_bInert = false;
|
||||
m_inert = false;
|
||||
}
|
||||
|
||||
void CWLSurface::assign(SP<CWLSurfaceResource> pSurface, PHLWINDOW pOwner) {
|
||||
m_pWindowOwner = pOwner;
|
||||
m_pResource = pSurface;
|
||||
m_windowOwner = pOwner;
|
||||
m_resource = pSurface;
|
||||
init();
|
||||
m_bInert = false;
|
||||
m_inert = false;
|
||||
}
|
||||
|
||||
void CWLSurface::assign(SP<CWLSurfaceResource> pSurface, PHLLS pOwner) {
|
||||
m_pLayerOwner = pOwner;
|
||||
m_pResource = pSurface;
|
||||
m_layerOwner = pOwner;
|
||||
m_resource = pSurface;
|
||||
init();
|
||||
m_bInert = false;
|
||||
m_inert = false;
|
||||
}
|
||||
|
||||
void CWLSurface::assign(SP<CWLSurfaceResource> pSurface, CSubsurface* pOwner) {
|
||||
m_pSubsurfaceOwner = pOwner;
|
||||
m_pResource = pSurface;
|
||||
m_subsurfaceOwner = pOwner;
|
||||
m_resource = pSurface;
|
||||
init();
|
||||
m_bInert = false;
|
||||
m_inert = false;
|
||||
}
|
||||
|
||||
void CWLSurface::assign(SP<CWLSurfaceResource> pSurface, CPopup* pOwner) {
|
||||
m_pPopupOwner = pOwner;
|
||||
m_pResource = pSurface;
|
||||
m_popupOwner = pOwner;
|
||||
m_resource = pSurface;
|
||||
init();
|
||||
m_bInert = false;
|
||||
m_inert = false;
|
||||
}
|
||||
|
||||
void CWLSurface::unassign() {
|
||||
|
|
@ -48,66 +48,66 @@ CWLSurface::~CWLSurface() {
|
|||
}
|
||||
|
||||
bool CWLSurface::exists() const {
|
||||
return m_pResource;
|
||||
return m_resource;
|
||||
}
|
||||
|
||||
SP<CWLSurfaceResource> CWLSurface::resource() const {
|
||||
return m_pResource.lock();
|
||||
return m_resource.lock();
|
||||
}
|
||||
|
||||
bool CWLSurface::small() const {
|
||||
if (!validMapped(m_pWindowOwner) || !exists())
|
||||
if (!validMapped(m_windowOwner) || !exists())
|
||||
return false;
|
||||
|
||||
if (!m_pResource->current.texture)
|
||||
if (!m_resource->current.texture)
|
||||
return false;
|
||||
|
||||
const auto O = m_pWindowOwner.lock();
|
||||
const auto O = m_windowOwner.lock();
|
||||
|
||||
return O->m_vReportedSize.x > m_pResource->current.size.x + 1 || O->m_vReportedSize.y > m_pResource->current.size.y + 1;
|
||||
return O->m_vReportedSize.x > m_resource->current.size.x + 1 || O->m_vReportedSize.y > m_resource->current.size.y + 1;
|
||||
}
|
||||
|
||||
Vector2D CWLSurface::correctSmallVec() const {
|
||||
if (!validMapped(m_pWindowOwner) || !exists() || !small() || m_bFillIgnoreSmall)
|
||||
if (!validMapped(m_windowOwner) || !exists() || !small() || m_fillIgnoreSmall)
|
||||
return {};
|
||||
|
||||
const auto SIZE = getViewporterCorrectedSize();
|
||||
const auto O = m_pWindowOwner.lock();
|
||||
const auto O = m_windowOwner.lock();
|
||||
|
||||
return Vector2D{(O->m_vReportedSize.x - SIZE.x) / 2, (O->m_vReportedSize.y - SIZE.y) / 2}.clamp({}, {INFINITY, INFINITY}) * (O->m_vRealSize->value() / O->m_vReportedSize);
|
||||
}
|
||||
|
||||
Vector2D CWLSurface::correctSmallVecBuf() const {
|
||||
if (!exists() || !small() || m_bFillIgnoreSmall || !m_pResource->current.texture)
|
||||
if (!exists() || !small() || m_fillIgnoreSmall || !m_resource->current.texture)
|
||||
return {};
|
||||
|
||||
const auto SIZE = getViewporterCorrectedSize();
|
||||
const auto BS = m_pResource->current.bufferSize;
|
||||
const auto BS = m_resource->current.bufferSize;
|
||||
|
||||
return Vector2D{(BS.x - SIZE.x) / 2, (BS.y - SIZE.y) / 2}.clamp({}, {INFINITY, INFINITY});
|
||||
}
|
||||
|
||||
Vector2D CWLSurface::getViewporterCorrectedSize() const {
|
||||
if (!exists() || !m_pResource->current.texture)
|
||||
if (!exists() || !m_resource->current.texture)
|
||||
return {};
|
||||
|
||||
return m_pResource->current.viewport.hasDestination ? m_pResource->current.viewport.destination : m_pResource->current.bufferSize;
|
||||
return m_resource->current.viewport.hasDestination ? m_resource->current.viewport.destination : m_resource->current.bufferSize;
|
||||
}
|
||||
|
||||
CRegion CWLSurface::computeDamage() const {
|
||||
if (!m_pResource->current.texture)
|
||||
if (!m_resource->current.texture)
|
||||
return {};
|
||||
|
||||
CRegion damage = m_pResource->current.accumulateBufferDamage();
|
||||
damage.transform(wlTransformToHyprutils(m_pResource->current.transform), m_pResource->current.bufferSize.x, m_pResource->current.bufferSize.y);
|
||||
CRegion damage = m_resource->current.accumulateBufferDamage();
|
||||
damage.transform(wlTransformToHyprutils(m_resource->current.transform), m_resource->current.bufferSize.x, m_resource->current.bufferSize.y);
|
||||
|
||||
const auto BUFSIZE = m_pResource->current.bufferSize;
|
||||
const auto BUFSIZE = m_resource->current.bufferSize;
|
||||
const auto CORRECTVEC = correctSmallVecBuf();
|
||||
|
||||
if (m_pResource->current.viewport.hasSource)
|
||||
damage.intersect(m_pResource->current.viewport.source);
|
||||
if (m_resource->current.viewport.hasSource)
|
||||
damage.intersect(m_resource->current.viewport.source);
|
||||
|
||||
const auto SCALEDSRCSIZE = m_pResource->current.viewport.hasSource ? m_pResource->current.viewport.source.size() * m_pResource->current.scale : m_pResource->current.bufferSize;
|
||||
const auto SCALEDSRCSIZE = m_resource->current.viewport.hasSource ? m_resource->current.viewport.source.size() * m_resource->current.scale : m_resource->current.bufferSize;
|
||||
|
||||
damage.scale({BUFSIZE.x / SCALEDSRCSIZE.x, BUFSIZE.y / SCALEDSRCSIZE.y});
|
||||
damage.translate(CORRECTVEC);
|
||||
|
|
@ -115,107 +115,107 @@ CRegion CWLSurface::computeDamage() const {
|
|||
// go from buffer coords in the damage to hl logical
|
||||
|
||||
const auto BOX = getSurfaceBoxGlobal();
|
||||
const Vector2D SCALE = BOX.has_value() ? BOX->size() / m_pResource->current.bufferSize :
|
||||
Vector2D{1.0 / m_pResource->current.scale, 1.0 / m_pResource->current.scale /* Wrong... but we can't really do better */};
|
||||
const Vector2D SCALE = BOX.has_value() ? BOX->size() / m_resource->current.bufferSize :
|
||||
Vector2D{1.0 / m_resource->current.scale, 1.0 / m_resource->current.scale /* Wrong... but we can't really do better */};
|
||||
|
||||
damage.scale(SCALE);
|
||||
|
||||
if (m_pWindowOwner)
|
||||
damage.scale(m_pWindowOwner->m_fX11SurfaceScaledBy); // fix xwayland:force_zero_scaling stuff that will be fucked by the above a bit
|
||||
if (m_windowOwner)
|
||||
damage.scale(m_windowOwner->m_fX11SurfaceScaledBy); // fix xwayland:force_zero_scaling stuff that will be fucked by the above a bit
|
||||
|
||||
return damage;
|
||||
}
|
||||
|
||||
void CWLSurface::destroy() {
|
||||
if (!m_pResource)
|
||||
if (!m_resource)
|
||||
return;
|
||||
|
||||
events.destroy.emit();
|
||||
m_events.destroy.emit();
|
||||
|
||||
m_pConstraint.reset();
|
||||
m_constraint.reset();
|
||||
|
||||
listeners.destroy.reset();
|
||||
m_pResource->hlSurface.reset();
|
||||
m_pWindowOwner.reset();
|
||||
m_pLayerOwner.reset();
|
||||
m_pPopupOwner = nullptr;
|
||||
m_pSubsurfaceOwner = nullptr;
|
||||
m_bInert = true;
|
||||
m_listeners.destroy.reset();
|
||||
m_resource->hlSurface.reset();
|
||||
m_windowOwner.reset();
|
||||
m_layerOwner.reset();
|
||||
m_popupOwner = nullptr;
|
||||
m_subsurfaceOwner = nullptr;
|
||||
m_inert = true;
|
||||
|
||||
if (g_pHyprRenderer && g_pHyprRenderer->m_sLastCursorData.surf && g_pHyprRenderer->m_sLastCursorData.surf->get() == this)
|
||||
g_pHyprRenderer->m_sLastCursorData.surf.reset();
|
||||
|
||||
m_pResource.reset();
|
||||
m_resource.reset();
|
||||
|
||||
Debug::log(LOG, "CWLSurface {:x} called destroy()", (uintptr_t)this);
|
||||
}
|
||||
|
||||
void CWLSurface::init() {
|
||||
if (!m_pResource)
|
||||
if (!m_resource)
|
||||
return;
|
||||
|
||||
RASSERT(!m_pResource->hlSurface, "Attempted to duplicate CWLSurface ownership!");
|
||||
RASSERT(!m_resource->hlSurface, "Attempted to duplicate CWLSurface ownership!");
|
||||
|
||||
m_pResource->hlSurface = self.lock();
|
||||
m_resource->hlSurface = m_self.lock();
|
||||
|
||||
listeners.destroy = m_pResource->events.destroy.registerListener([this](std::any d) { destroy(); });
|
||||
m_listeners.destroy = m_resource->events.destroy.registerListener([this](std::any d) { destroy(); });
|
||||
|
||||
Debug::log(LOG, "CWLSurface {:x} called init()", (uintptr_t)this);
|
||||
}
|
||||
|
||||
PHLWINDOW CWLSurface::getWindow() const {
|
||||
return m_pWindowOwner.lock();
|
||||
return m_windowOwner.lock();
|
||||
}
|
||||
|
||||
PHLLS CWLSurface::getLayer() const {
|
||||
return m_pLayerOwner.lock();
|
||||
return m_layerOwner.lock();
|
||||
}
|
||||
|
||||
CPopup* CWLSurface::getPopup() const {
|
||||
return m_pPopupOwner;
|
||||
return m_popupOwner;
|
||||
}
|
||||
|
||||
CSubsurface* CWLSurface::getSubsurface() const {
|
||||
return m_pSubsurfaceOwner;
|
||||
return m_subsurfaceOwner;
|
||||
}
|
||||
|
||||
bool CWLSurface::desktopComponent() const {
|
||||
return !m_pLayerOwner.expired() || !m_pWindowOwner.expired() || m_pSubsurfaceOwner || m_pPopupOwner;
|
||||
return !m_layerOwner.expired() || !m_windowOwner.expired() || m_subsurfaceOwner || m_popupOwner;
|
||||
}
|
||||
|
||||
std::optional<CBox> CWLSurface::getSurfaceBoxGlobal() const {
|
||||
if (!desktopComponent())
|
||||
return {};
|
||||
|
||||
if (!m_pWindowOwner.expired())
|
||||
return m_pWindowOwner->getWindowMainSurfaceBox();
|
||||
if (!m_pLayerOwner.expired())
|
||||
return m_pLayerOwner->m_geometry;
|
||||
if (m_pPopupOwner)
|
||||
return CBox{m_pPopupOwner->coordsGlobal(), m_pPopupOwner->size()};
|
||||
if (m_pSubsurfaceOwner)
|
||||
return CBox{m_pSubsurfaceOwner->coordsGlobal(), m_pSubsurfaceOwner->size()};
|
||||
if (!m_windowOwner.expired())
|
||||
return m_windowOwner->getWindowMainSurfaceBox();
|
||||
if (!m_layerOwner.expired())
|
||||
return m_layerOwner->m_geometry;
|
||||
if (m_popupOwner)
|
||||
return CBox{m_popupOwner->coordsGlobal(), m_popupOwner->size()};
|
||||
if (m_subsurfaceOwner)
|
||||
return CBox{m_subsurfaceOwner->coordsGlobal(), m_subsurfaceOwner->size()};
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
void CWLSurface::appendConstraint(WP<CPointerConstraint> constraint) {
|
||||
m_pConstraint = constraint;
|
||||
m_constraint = constraint;
|
||||
}
|
||||
|
||||
SP<CPointerConstraint> CWLSurface::constraint() const {
|
||||
return m_pConstraint.lock();
|
||||
return m_constraint.lock();
|
||||
}
|
||||
|
||||
bool CWLSurface::visible() {
|
||||
if (!m_pWindowOwner.expired())
|
||||
return g_pHyprRenderer->shouldRenderWindow(m_pWindowOwner.lock());
|
||||
if (!m_pLayerOwner.expired())
|
||||
if (!m_windowOwner.expired())
|
||||
return g_pHyprRenderer->shouldRenderWindow(m_windowOwner.lock());
|
||||
if (!m_layerOwner.expired())
|
||||
return true;
|
||||
if (m_pPopupOwner)
|
||||
return m_pPopupOwner->visible();
|
||||
if (m_pSubsurfaceOwner)
|
||||
return m_pSubsurfaceOwner->visible();
|
||||
if (m_popupOwner)
|
||||
return m_popupOwner->visible();
|
||||
if (m_subsurfaceOwner)
|
||||
return m_subsurfaceOwner->visible();
|
||||
return true; // non-desktop, we don't know much.
|
||||
}
|
||||
|
||||
|
|
@ -226,9 +226,9 @@ SP<CWLSurface> CWLSurface::fromResource(SP<CWLSurfaceResource> pSurface) {
|
|||
}
|
||||
|
||||
bool CWLSurface::keyboardFocusable() const {
|
||||
if (m_pWindowOwner || m_pPopupOwner || m_pSubsurfaceOwner)
|
||||
if (m_windowOwner || m_popupOwner || m_subsurfaceOwner)
|
||||
return true;
|
||||
if (m_pLayerOwner && m_pLayerOwner->m_layerSurface)
|
||||
return m_pLayerOwner->m_layerSurface->current.interactivity != ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_NONE;
|
||||
if (m_layerOwner && m_layerOwner->m_layerSurface)
|
||||
return m_layerOwner->m_layerSurface->current.interactivity != ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_NONE;
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ class CWLSurfaceResource;
|
|||
class CWLSurface {
|
||||
public:
|
||||
static SP<CWLSurface> create() {
|
||||
auto p = SP<CWLSurface>(new CWLSurface);
|
||||
p->self = p;
|
||||
auto p = SP<CWLSurface>(new CWLSurface);
|
||||
p->m_self = p;
|
||||
return p;
|
||||
}
|
||||
~CWLSurface();
|
||||
|
|
@ -53,17 +53,17 @@ class CWLSurface {
|
|||
SP<CPointerConstraint> constraint() const;
|
||||
|
||||
// allow stretching. Useful for plugins.
|
||||
bool m_bFillIgnoreSmall = false;
|
||||
bool m_fillIgnoreSmall = false;
|
||||
|
||||
// track surface data and avoid dupes
|
||||
float m_fLastScale = 0;
|
||||
int m_iLastScale = 0;
|
||||
wl_output_transform m_eLastTransform = (wl_output_transform)-1;
|
||||
float m_lastScaleFloat = 0;
|
||||
int m_lastScaleInt = 0;
|
||||
wl_output_transform m_lastTransform = (wl_output_transform)-1;
|
||||
|
||||
//
|
||||
CWLSurface& operator=(SP<CWLSurfaceResource> pSurface) {
|
||||
destroy();
|
||||
m_pResource = pSurface;
|
||||
m_resource = pSurface;
|
||||
init();
|
||||
|
||||
return *this;
|
||||
|
|
@ -84,32 +84,32 @@ class CWLSurface {
|
|||
static SP<CWLSurface> fromResource(SP<CWLSurfaceResource> pSurface);
|
||||
|
||||
// used by the alpha-modifier protocol
|
||||
float m_fAlphaModifier = 1.F;
|
||||
float m_alphaModifier = 1.F;
|
||||
|
||||
// used by the hyprland-surface protocol
|
||||
float m_fOverallOpacity = 1.F;
|
||||
float m_overallOpacity = 1.F;
|
||||
CRegion m_visibleRegion;
|
||||
|
||||
struct {
|
||||
CSignal destroy;
|
||||
} events;
|
||||
} m_events;
|
||||
|
||||
WP<CWLSurface> self;
|
||||
WP<CWLSurface> m_self;
|
||||
|
||||
private:
|
||||
CWLSurface() = default;
|
||||
|
||||
bool m_bInert = true;
|
||||
bool m_inert = true;
|
||||
|
||||
WP<CWLSurfaceResource> m_pResource;
|
||||
WP<CWLSurfaceResource> m_resource;
|
||||
|
||||
PHLWINDOWREF m_pWindowOwner;
|
||||
PHLLSREF m_pLayerOwner;
|
||||
CPopup* m_pPopupOwner = nullptr;
|
||||
CSubsurface* m_pSubsurfaceOwner = nullptr;
|
||||
PHLWINDOWREF m_windowOwner;
|
||||
PHLLSREF m_layerOwner;
|
||||
CPopup* m_popupOwner = nullptr;
|
||||
CSubsurface* m_subsurfaceOwner = nullptr;
|
||||
|
||||
//
|
||||
WP<CPointerConstraint> m_pConstraint;
|
||||
WP<CPointerConstraint> m_constraint;
|
||||
|
||||
void destroy();
|
||||
void init();
|
||||
|
|
@ -117,7 +117,7 @@ class CWLSurface {
|
|||
|
||||
struct {
|
||||
CHyprSignalListener destroy;
|
||||
} listeners;
|
||||
} m_listeners;
|
||||
|
||||
friend class CPointerConstraint;
|
||||
friend class CXxColorManagerV4;
|
||||
|
|
|
|||
|
|
@ -396,7 +396,7 @@ void CWindow::updateSurfaceScaleTransformDetails(bool force) {
|
|||
m_pWLSurface->resource()->breadthfirst(
|
||||
[PMONITOR](SP<CWLSurfaceResource> s, const Vector2D& offset, void* d) {
|
||||
const auto PSURFACE = CWLSurface::fromResource(s);
|
||||
if (PSURFACE && PSURFACE->m_fLastScale == PMONITOR->scale)
|
||||
if (PSURFACE && PSURFACE->m_lastScaleFloat == PMONITOR->scale)
|
||||
return;
|
||||
|
||||
PROTO::fractional->sendScale(s, PMONITOR->scale);
|
||||
|
|
@ -452,8 +452,8 @@ void CWindow::moveToWorkspace(PHLWORKSPACE pWorkspace) {
|
|||
g_pCompositor->updateAllWindowsAnimatedDecorationValues();
|
||||
|
||||
if (valid(pWorkspace)) {
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{"movewindow", std::format("{:x},{}", (uintptr_t)this, pWorkspace->m_szName)});
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{"movewindowv2", std::format("{:x},{},{}", (uintptr_t)this, pWorkspace->m_iID, pWorkspace->m_szName)});
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{"movewindow", std::format("{:x},{}", (uintptr_t)this, pWorkspace->m_name)});
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{"movewindowv2", std::format("{:x},{},{}", (uintptr_t)this, pWorkspace->m_id, pWorkspace->m_name)});
|
||||
EMIT_HOOK_EVENT("moveWindow", (std::vector<std::any>{m_pSelf.lock(), pWorkspace}));
|
||||
}
|
||||
|
||||
|
|
@ -464,8 +464,8 @@ void CWindow::moveToWorkspace(PHLWORKSPACE pWorkspace) {
|
|||
}
|
||||
}
|
||||
|
||||
if (OLDWORKSPACE && g_pCompositor->isWorkspaceSpecial(OLDWORKSPACE->m_iID) && OLDWORKSPACE->getWindows() == 0 && *PCLOSEONLASTSPECIAL) {
|
||||
if (const auto PMONITOR = OLDWORKSPACE->m_pMonitor.lock(); PMONITOR)
|
||||
if (OLDWORKSPACE && g_pCompositor->isWorkspaceSpecial(OLDWORKSPACE->m_id) && OLDWORKSPACE->getWindows() == 0 && *PCLOSEONLASTSPECIAL) {
|
||||
if (const auto PMONITOR = OLDWORKSPACE->m_monitor.lock(); PMONITOR)
|
||||
PMONITOR->setSpecialWorkspace(nullptr);
|
||||
}
|
||||
}
|
||||
|
|
@ -514,7 +514,7 @@ void CWindow::onUnmap() {
|
|||
}
|
||||
}
|
||||
|
||||
m_iLastWorkspace = m_pWorkspace->m_iID;
|
||||
m_iLastWorkspace = m_pWorkspace->m_id;
|
||||
|
||||
std::erase_if(g_pCompositor->m_windowFocusHistory, [this](const auto& other) { return other.expired() || other == m_pSelf; });
|
||||
|
||||
|
|
@ -1153,10 +1153,10 @@ bool CWindow::opaque() {
|
|||
|
||||
const auto PWORKSPACE = m_pWorkspace;
|
||||
|
||||
if (m_pWLSurface->small() && !m_pWLSurface->m_bFillIgnoreSmall)
|
||||
if (m_pWLSurface->small() && !m_pWLSurface->m_fillIgnoreSmall)
|
||||
return false;
|
||||
|
||||
if (PWORKSPACE->m_fAlpha->value() != 1.f)
|
||||
if (PWORKSPACE->m_alpha->value() != 1.f)
|
||||
return false;
|
||||
|
||||
if (m_bIsX11 && m_pXWaylandSurface && m_pXWaylandSurface->surface && m_pXWaylandSurface->surface->current.texture)
|
||||
|
|
@ -1273,16 +1273,16 @@ void CWindow::onWorkspaceAnimUpdate() {
|
|||
return;
|
||||
|
||||
const auto WINBB = getFullWindowBoundingBox();
|
||||
if (PWORKSPACE->m_vRenderOffset->value().x != 0) {
|
||||
const auto PROGRESS = PWORKSPACE->m_vRenderOffset->value().x / PWSMON->vecSize.x;
|
||||
if (PWORKSPACE->m_renderOffset->value().x != 0) {
|
||||
const auto PROGRESS = PWORKSPACE->m_renderOffset->value().x / PWSMON->vecSize.x;
|
||||
|
||||
if (WINBB.x < PWSMON->vecPosition.x)
|
||||
offset.x += (PWSMON->vecPosition.x - WINBB.x) * PROGRESS;
|
||||
|
||||
if (WINBB.x + WINBB.width > PWSMON->vecPosition.x + PWSMON->vecSize.x)
|
||||
offset.x += (WINBB.x + WINBB.width - PWSMON->vecPosition.x - PWSMON->vecSize.x) * PROGRESS;
|
||||
} else if (PWORKSPACE->m_vRenderOffset->value().y != 0) {
|
||||
const auto PROGRESS = PWORKSPACE->m_vRenderOffset->value().y / PWSMON->vecSize.y;
|
||||
} else if (PWORKSPACE->m_renderOffset->value().y != 0) {
|
||||
const auto PROGRESS = PWORKSPACE->m_renderOffset->value().y / PWSMON->vecSize.y;
|
||||
|
||||
if (WINBB.y < PWSMON->vecPosition.y)
|
||||
offset.y += (PWSMON->vecPosition.y - WINBB.y) * PROGRESS;
|
||||
|
|
@ -1338,7 +1338,7 @@ bool CWindow::isEffectiveInternalFSMode(const eFullscreenMode MODE) {
|
|||
}
|
||||
|
||||
WORKSPACEID CWindow::workspaceID() {
|
||||
return m_pWorkspace ? m_pWorkspace->m_iID : m_iLastWorkspace;
|
||||
return m_pWorkspace ? m_pWorkspace->m_id : m_iLastWorkspace;
|
||||
}
|
||||
|
||||
MONITORID CWindow::monitorID() {
|
||||
|
|
@ -1346,7 +1346,7 @@ MONITORID CWindow::monitorID() {
|
|||
}
|
||||
|
||||
bool CWindow::onSpecialWorkspace() {
|
||||
return m_pWorkspace ? m_pWorkspace->m_bIsSpecialWorkspace : g_pCompositor->isWorkspaceSpecial(m_iLastWorkspace);
|
||||
return m_pWorkspace ? m_pWorkspace->m_isSpecialWorkspace : g_pCompositor->isWorkspaceSpecial(m_iLastWorkspace);
|
||||
}
|
||||
|
||||
std::unordered_map<std::string, std::string> CWindow::getEnv() {
|
||||
|
|
|
|||
|
|
@ -17,76 +17,76 @@ PHLWORKSPACE CWorkspace::create(WORKSPACEID id, PHLMONITOR monitor, std::string
|
|||
}
|
||||
|
||||
CWorkspace::CWorkspace(WORKSPACEID id, PHLMONITOR monitor, std::string name, bool special, bool isEmpty) :
|
||||
m_iID(id), m_szName(name), m_pMonitor(monitor), m_bIsSpecialWorkspace(special), m_bWasCreatedEmpty(isEmpty) {
|
||||
m_id(id), m_name(name), m_monitor(monitor), m_isSpecialWorkspace(special), m_wasCreatedEmpty(isEmpty) {
|
||||
;
|
||||
}
|
||||
|
||||
void CWorkspace::init(PHLWORKSPACE self) {
|
||||
m_pSelf = self;
|
||||
m_self = self;
|
||||
|
||||
g_pAnimationManager->createAnimation(Vector2D(0, 0), m_vRenderOffset,
|
||||
g_pConfigManager->getAnimationPropertyConfig(m_bIsSpecialWorkspace ? "specialWorkspaceIn" : "workspacesIn"), self, AVARDAMAGE_ENTIRE);
|
||||
g_pAnimationManager->createAnimation(1.f, m_fAlpha, g_pConfigManager->getAnimationPropertyConfig(m_bIsSpecialWorkspace ? "specialWorkspaceIn" : "workspacesIn"), self,
|
||||
g_pAnimationManager->createAnimation(Vector2D(0, 0), m_renderOffset, g_pConfigManager->getAnimationPropertyConfig(m_isSpecialWorkspace ? "specialWorkspaceIn" : "workspacesIn"),
|
||||
self, AVARDAMAGE_ENTIRE);
|
||||
g_pAnimationManager->createAnimation(1.f, m_alpha, g_pConfigManager->getAnimationPropertyConfig(m_isSpecialWorkspace ? "specialWorkspaceIn" : "workspacesIn"), self,
|
||||
AVARDAMAGE_ENTIRE);
|
||||
|
||||
const auto RULEFORTHIS = g_pConfigManager->getWorkspaceRuleFor(self);
|
||||
if (RULEFORTHIS.defaultName.has_value())
|
||||
m_szName = RULEFORTHIS.defaultName.value();
|
||||
m_name = RULEFORTHIS.defaultName.value();
|
||||
|
||||
m_pFocusedWindowHook = g_pHookSystem->hookDynamic("closeWindow", [this](void* self, SCallbackInfo& info, std::any param) {
|
||||
m_focusedWindowHook = g_pHookSystem->hookDynamic("closeWindow", [this](void* self, SCallbackInfo& info, std::any param) {
|
||||
const auto PWINDOW = std::any_cast<PHLWINDOW>(param);
|
||||
|
||||
if (PWINDOW == m_pLastFocusedWindow.lock())
|
||||
m_pLastFocusedWindow.reset();
|
||||
if (PWINDOW == m_lastFocusedWindow.lock())
|
||||
m_lastFocusedWindow.reset();
|
||||
});
|
||||
|
||||
m_bInert = false;
|
||||
m_inert = false;
|
||||
|
||||
const auto WORKSPACERULE = g_pConfigManager->getWorkspaceRuleFor(self);
|
||||
m_bPersistent = WORKSPACERULE.isPersistent;
|
||||
m_persistent = WORKSPACERULE.isPersistent;
|
||||
|
||||
if (self->m_bWasCreatedEmpty)
|
||||
if (self->m_wasCreatedEmpty)
|
||||
if (auto cmd = WORKSPACERULE.onCreatedEmptyRunCmd)
|
||||
g_pKeybindManager->spawnWithRules(*cmd, self);
|
||||
|
||||
g_pEventManager->postEvent({"createworkspace", m_szName});
|
||||
g_pEventManager->postEvent({"createworkspacev2", std::format("{},{}", m_iID, m_szName)});
|
||||
g_pEventManager->postEvent({"createworkspace", m_name});
|
||||
g_pEventManager->postEvent({"createworkspacev2", std::format("{},{}", m_id, m_name)});
|
||||
EMIT_HOOK_EVENT("createWorkspace", this);
|
||||
}
|
||||
|
||||
SWorkspaceIDName CWorkspace::getPrevWorkspaceIDName() const {
|
||||
return m_sPrevWorkspace;
|
||||
return m_prevWorkspace;
|
||||
}
|
||||
|
||||
CWorkspace::~CWorkspace() {
|
||||
Debug::log(LOG, "Destroying workspace ID {}", m_iID);
|
||||
Debug::log(LOG, "Destroying workspace ID {}", m_id);
|
||||
|
||||
// check if g_pHookSystem and g_pEventManager exist, they might be destroyed as in when the compositor is closing.
|
||||
if (g_pHookSystem)
|
||||
g_pHookSystem->unhook(m_pFocusedWindowHook);
|
||||
g_pHookSystem->unhook(m_focusedWindowHook);
|
||||
|
||||
if (g_pEventManager) {
|
||||
g_pEventManager->postEvent({"destroyworkspace", m_szName});
|
||||
g_pEventManager->postEvent({"destroyworkspacev2", std::format("{},{}", m_iID, m_szName)});
|
||||
g_pEventManager->postEvent({"destroyworkspace", m_name});
|
||||
g_pEventManager->postEvent({"destroyworkspacev2", std::format("{},{}", m_id, m_name)});
|
||||
EMIT_HOOK_EVENT("destroyWorkspace", this);
|
||||
}
|
||||
}
|
||||
|
||||
void CWorkspace::startAnim(bool in, bool left, bool instant) {
|
||||
if (!instant) {
|
||||
const std::string ANIMNAME = std::format("{}{}", m_bIsSpecialWorkspace ? "specialWorkspace" : "workspaces", in ? "In" : "Out");
|
||||
const std::string ANIMNAME = std::format("{}{}", m_isSpecialWorkspace ? "specialWorkspace" : "workspaces", in ? "In" : "Out");
|
||||
|
||||
m_fAlpha->setConfig(g_pConfigManager->getAnimationPropertyConfig(ANIMNAME));
|
||||
m_vRenderOffset->setConfig(g_pConfigManager->getAnimationPropertyConfig(ANIMNAME));
|
||||
m_alpha->setConfig(g_pConfigManager->getAnimationPropertyConfig(ANIMNAME));
|
||||
m_renderOffset->setConfig(g_pConfigManager->getAnimationPropertyConfig(ANIMNAME));
|
||||
}
|
||||
|
||||
const auto ANIMSTYLE = m_fAlpha->getStyle();
|
||||
const auto ANIMSTYLE = m_alpha->getStyle();
|
||||
static auto PWORKSPACEGAP = CConfigValue<Hyprlang::INT>("general:gaps_workspaces");
|
||||
|
||||
// set floating windows offset callbacks
|
||||
m_vRenderOffset->setUpdateCallback([&](auto) {
|
||||
m_renderOffset->setUpdateCallback([&](auto) {
|
||||
for (auto const& w : g_pCompositor->m_windows) {
|
||||
if (!validMapped(w) || w->workspaceID() != m_iID)
|
||||
if (!validMapped(w) || w->workspaceID() != m_id)
|
||||
continue;
|
||||
|
||||
w->onWorkspaceAnimUpdate();
|
||||
|
|
@ -94,7 +94,7 @@ void CWorkspace::startAnim(bool in, bool left, bool instant) {
|
|||
});
|
||||
|
||||
if (ANIMSTYLE.starts_with("slidefade")) {
|
||||
const auto PMONITOR = m_pMonitor.lock();
|
||||
const auto PMONITOR = m_monitor.lock();
|
||||
float movePerc = 100.f;
|
||||
|
||||
if (ANIMSTYLE.find('%') != std::string::npos) {
|
||||
|
|
@ -104,84 +104,84 @@ void CWorkspace::startAnim(bool in, bool left, bool instant) {
|
|||
} catch (std::exception& e) { Debug::log(ERR, "Error in startAnim: invalid percentage"); }
|
||||
}
|
||||
|
||||
m_fAlpha->setValueAndWarp(1.f);
|
||||
m_vRenderOffset->setValueAndWarp(Vector2D(0, 0));
|
||||
m_alpha->setValueAndWarp(1.f);
|
||||
m_renderOffset->setValueAndWarp(Vector2D(0, 0));
|
||||
|
||||
if (ANIMSTYLE.starts_with("slidefadevert")) {
|
||||
if (in) {
|
||||
m_fAlpha->setValueAndWarp(0.f);
|
||||
m_vRenderOffset->setValueAndWarp(Vector2D(0.0, (left ? PMONITOR->vecSize.y : -PMONITOR->vecSize.y) * (movePerc / 100.f)));
|
||||
*m_fAlpha = 1.f;
|
||||
*m_vRenderOffset = Vector2D(0, 0);
|
||||
m_alpha->setValueAndWarp(0.f);
|
||||
m_renderOffset->setValueAndWarp(Vector2D(0.0, (left ? PMONITOR->vecSize.y : -PMONITOR->vecSize.y) * (movePerc / 100.f)));
|
||||
*m_alpha = 1.f;
|
||||
*m_renderOffset = Vector2D(0, 0);
|
||||
} else {
|
||||
m_fAlpha->setValueAndWarp(1.f);
|
||||
*m_fAlpha = 0.f;
|
||||
*m_vRenderOffset = Vector2D(0.0, (left ? -PMONITOR->vecSize.y : PMONITOR->vecSize.y) * (movePerc / 100.f));
|
||||
m_alpha->setValueAndWarp(1.f);
|
||||
*m_alpha = 0.f;
|
||||
*m_renderOffset = Vector2D(0.0, (left ? -PMONITOR->vecSize.y : PMONITOR->vecSize.y) * (movePerc / 100.f));
|
||||
}
|
||||
} else {
|
||||
if (in) {
|
||||
m_fAlpha->setValueAndWarp(0.f);
|
||||
m_vRenderOffset->setValueAndWarp(Vector2D((left ? PMONITOR->vecSize.x : -PMONITOR->vecSize.x) * (movePerc / 100.f), 0.0));
|
||||
*m_fAlpha = 1.f;
|
||||
*m_vRenderOffset = Vector2D(0, 0);
|
||||
m_alpha->setValueAndWarp(0.f);
|
||||
m_renderOffset->setValueAndWarp(Vector2D((left ? PMONITOR->vecSize.x : -PMONITOR->vecSize.x) * (movePerc / 100.f), 0.0));
|
||||
*m_alpha = 1.f;
|
||||
*m_renderOffset = Vector2D(0, 0);
|
||||
} else {
|
||||
m_fAlpha->setValueAndWarp(1.f);
|
||||
*m_fAlpha = 0.f;
|
||||
*m_vRenderOffset = Vector2D((left ? -PMONITOR->vecSize.x : PMONITOR->vecSize.x) * (movePerc / 100.f), 0.0);
|
||||
m_alpha->setValueAndWarp(1.f);
|
||||
*m_alpha = 0.f;
|
||||
*m_renderOffset = Vector2D((left ? -PMONITOR->vecSize.x : PMONITOR->vecSize.x) * (movePerc / 100.f), 0.0);
|
||||
}
|
||||
}
|
||||
} else if (ANIMSTYLE == "fade") {
|
||||
m_vRenderOffset->setValueAndWarp(Vector2D(0, 0)); // fix a bug, if switching from slide -> fade.
|
||||
m_renderOffset->setValueAndWarp(Vector2D(0, 0)); // fix a bug, if switching from slide -> fade.
|
||||
|
||||
if (in) {
|
||||
m_fAlpha->setValueAndWarp(0.f);
|
||||
*m_fAlpha = 1.f;
|
||||
m_alpha->setValueAndWarp(0.f);
|
||||
*m_alpha = 1.f;
|
||||
} else {
|
||||
m_fAlpha->setValueAndWarp(1.f);
|
||||
*m_fAlpha = 0.f;
|
||||
m_alpha->setValueAndWarp(1.f);
|
||||
*m_alpha = 0.f;
|
||||
}
|
||||
} else if (ANIMSTYLE == "slidevert") {
|
||||
// fallback is slide
|
||||
const auto PMONITOR = m_pMonitor.lock();
|
||||
const auto PMONITOR = m_monitor.lock();
|
||||
const auto YDISTANCE = PMONITOR->vecSize.y + *PWORKSPACEGAP;
|
||||
|
||||
m_fAlpha->setValueAndWarp(1.f); // fix a bug, if switching from fade -> slide.
|
||||
m_alpha->setValueAndWarp(1.f); // fix a bug, if switching from fade -> slide.
|
||||
|
||||
if (in) {
|
||||
m_vRenderOffset->setValueAndWarp(Vector2D(0.0, left ? YDISTANCE : -YDISTANCE));
|
||||
*m_vRenderOffset = Vector2D(0, 0);
|
||||
m_renderOffset->setValueAndWarp(Vector2D(0.0, left ? YDISTANCE : -YDISTANCE));
|
||||
*m_renderOffset = Vector2D(0, 0);
|
||||
} else {
|
||||
*m_vRenderOffset = Vector2D(0.0, left ? -YDISTANCE : YDISTANCE);
|
||||
*m_renderOffset = Vector2D(0.0, left ? -YDISTANCE : YDISTANCE);
|
||||
}
|
||||
} else {
|
||||
// fallback is slide
|
||||
const auto PMONITOR = m_pMonitor.lock();
|
||||
const auto PMONITOR = m_monitor.lock();
|
||||
const auto XDISTANCE = PMONITOR->vecSize.x + *PWORKSPACEGAP;
|
||||
|
||||
m_fAlpha->setValueAndWarp(1.f); // fix a bug, if switching from fade -> slide.
|
||||
m_alpha->setValueAndWarp(1.f); // fix a bug, if switching from fade -> slide.
|
||||
|
||||
if (in) {
|
||||
m_vRenderOffset->setValueAndWarp(Vector2D(left ? XDISTANCE : -XDISTANCE, 0.0));
|
||||
*m_vRenderOffset = Vector2D(0, 0);
|
||||
m_renderOffset->setValueAndWarp(Vector2D(left ? XDISTANCE : -XDISTANCE, 0.0));
|
||||
*m_renderOffset = Vector2D(0, 0);
|
||||
} else {
|
||||
*m_vRenderOffset = Vector2D(left ? -XDISTANCE : XDISTANCE, 0.0);
|
||||
*m_renderOffset = Vector2D(left ? -XDISTANCE : XDISTANCE, 0.0);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_bIsSpecialWorkspace) {
|
||||
if (m_isSpecialWorkspace) {
|
||||
// required for open/close animations
|
||||
if (in) {
|
||||
m_fAlpha->setValueAndWarp(0.f);
|
||||
*m_fAlpha = 1.f;
|
||||
m_alpha->setValueAndWarp(0.f);
|
||||
*m_alpha = 1.f;
|
||||
} else {
|
||||
m_fAlpha->setValueAndWarp(1.f);
|
||||
*m_fAlpha = 0.f;
|
||||
m_alpha->setValueAndWarp(1.f);
|
||||
*m_alpha = 0.f;
|
||||
}
|
||||
}
|
||||
|
||||
if (instant) {
|
||||
m_vRenderOffset->warp();
|
||||
m_fAlpha->warp();
|
||||
m_renderOffset->warp();
|
||||
m_alpha->warp();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -194,39 +194,39 @@ void CWorkspace::moveToMonitor(const MONITORID& id) {
|
|||
}
|
||||
|
||||
PHLWINDOW CWorkspace::getLastFocusedWindow() {
|
||||
if (!validMapped(m_pLastFocusedWindow) || m_pLastFocusedWindow->workspaceID() != m_iID)
|
||||
if (!validMapped(m_lastFocusedWindow) || m_lastFocusedWindow->workspaceID() != m_id)
|
||||
return nullptr;
|
||||
|
||||
return m_pLastFocusedWindow.lock();
|
||||
return m_lastFocusedWindow.lock();
|
||||
}
|
||||
|
||||
void CWorkspace::rememberPrevWorkspace(const PHLWORKSPACE& prev) {
|
||||
if (!prev) {
|
||||
m_sPrevWorkspace.id = -1;
|
||||
m_sPrevWorkspace.name = "";
|
||||
m_prevWorkspace.id = -1;
|
||||
m_prevWorkspace.name = "";
|
||||
return;
|
||||
}
|
||||
|
||||
if (prev->m_iID == m_iID) {
|
||||
if (prev->m_id == m_id) {
|
||||
Debug::log(LOG, "Tried to set prev workspace to the same as current one");
|
||||
return;
|
||||
}
|
||||
|
||||
m_sPrevWorkspace.id = prev->m_iID;
|
||||
m_sPrevWorkspace.name = prev->m_szName;
|
||||
m_prevWorkspace.id = prev->m_id;
|
||||
m_prevWorkspace.name = prev->m_name;
|
||||
|
||||
prev->m_pMonitor->addPrevWorkspaceID(prev->m_iID);
|
||||
prev->m_monitor->addPrevWorkspaceID(prev->m_id);
|
||||
}
|
||||
|
||||
std::string CWorkspace::getConfigName() {
|
||||
if (m_bIsSpecialWorkspace) {
|
||||
return m_szName;
|
||||
if (m_isSpecialWorkspace) {
|
||||
return m_name;
|
||||
}
|
||||
|
||||
if (m_iID > 0)
|
||||
return std::to_string(m_iID);
|
||||
if (m_id > 0)
|
||||
return std::to_string(m_id);
|
||||
|
||||
return "name:" + m_szName;
|
||||
return "name:" + m_name;
|
||||
}
|
||||
|
||||
bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
|
||||
|
|
@ -241,12 +241,12 @@ bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
|
|||
if (wsid == WORKSPACE_INVALID)
|
||||
return false;
|
||||
|
||||
return wsid == m_iID;
|
||||
return wsid == m_id;
|
||||
|
||||
} else if (selector.starts_with("name:")) {
|
||||
return m_szName == selector.substr(5);
|
||||
return m_name == selector.substr(5);
|
||||
} else if (selector.starts_with("special")) {
|
||||
return m_szName == selector;
|
||||
return m_name == selector;
|
||||
} else {
|
||||
// parse selector
|
||||
|
||||
|
|
@ -306,7 +306,7 @@ bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (std::clamp(m_iID, from, to) != m_iID)
|
||||
if (std::clamp(m_id, from, to) != m_id)
|
||||
return false;
|
||||
continue;
|
||||
}
|
||||
|
|
@ -321,7 +321,7 @@ bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
|
|||
|
||||
const auto SHOULDBESPECIAL = configStringToInt(prop);
|
||||
|
||||
if (SHOULDBESPECIAL && (bool)*SHOULDBESPECIAL != m_bIsSpecialWorkspace)
|
||||
if (SHOULDBESPECIAL && (bool)*SHOULDBESPECIAL != m_isSpecialWorkspace)
|
||||
return false;
|
||||
continue;
|
||||
}
|
||||
|
|
@ -336,7 +336,7 @@ bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
|
|||
|
||||
const auto PMONITOR = g_pCompositor->getMonitorFromString(prop);
|
||||
|
||||
if (!(PMONITOR ? PMONITOR == m_pMonitor : false))
|
||||
if (!(PMONITOR ? PMONITOR == m_monitor : false))
|
||||
return false;
|
||||
continue;
|
||||
}
|
||||
|
|
@ -349,14 +349,14 @@ bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
|
|||
|
||||
prop = prop.substr(2, prop.length() - 3);
|
||||
|
||||
if (prop.starts_with("s:") && !m_szName.starts_with(prop.substr(2)))
|
||||
if (prop.starts_with("s:") && !m_name.starts_with(prop.substr(2)))
|
||||
return false;
|
||||
if (prop.starts_with("e:") && !m_szName.ends_with(prop.substr(2)))
|
||||
if (prop.starts_with("e:") && !m_name.ends_with(prop.substr(2)))
|
||||
return false;
|
||||
|
||||
const auto WANTSNAMED = configStringToInt(prop);
|
||||
|
||||
if (WANTSNAMED && *WANTSNAMED != (m_iID <= -1337))
|
||||
if (WANTSNAMED && *WANTSNAMED != (m_id <= -1337))
|
||||
return false;
|
||||
continue;
|
||||
}
|
||||
|
|
@ -481,15 +481,15 @@ bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
|
|||
|
||||
switch (FSSTATE) {
|
||||
case -1: // no fullscreen
|
||||
if (m_bHasFullscreenWindow)
|
||||
if (m_hasFullscreenWindow)
|
||||
return false;
|
||||
break;
|
||||
case 0: // fullscreen full
|
||||
if (!m_bHasFullscreenWindow || m_efFullscreenMode != FSMODE_FULLSCREEN)
|
||||
if (!m_hasFullscreenWindow || m_fullscreenMode != FSMODE_FULLSCREEN)
|
||||
return false;
|
||||
break;
|
||||
case 1: // maximized
|
||||
if (!m_bHasFullscreenWindow || m_efFullscreenMode != FSMODE_MAXIMIZED)
|
||||
if (!m_hasFullscreenWindow || m_fullscreenMode != FSMODE_MAXIMIZED)
|
||||
return false;
|
||||
break;
|
||||
default: break;
|
||||
|
|
@ -509,23 +509,23 @@ bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
|
|||
}
|
||||
|
||||
void CWorkspace::markInert() {
|
||||
m_bInert = true;
|
||||
m_iID = WORKSPACE_INVALID;
|
||||
m_bVisible = false;
|
||||
m_pMonitor.reset();
|
||||
m_inert = true;
|
||||
m_id = WORKSPACE_INVALID;
|
||||
m_visible = false;
|
||||
m_monitor.reset();
|
||||
}
|
||||
|
||||
bool CWorkspace::inert() {
|
||||
return m_bInert;
|
||||
return m_inert;
|
||||
}
|
||||
|
||||
MONITORID CWorkspace::monitorID() {
|
||||
return m_pMonitor ? m_pMonitor->ID : MONITOR_INVALID;
|
||||
return m_monitor ? m_monitor->ID : MONITOR_INVALID;
|
||||
}
|
||||
|
||||
PHLWINDOW CWorkspace::getFullscreenWindow() {
|
||||
for (auto const& w : g_pCompositor->m_windows) {
|
||||
if (w->m_pWorkspace == m_pSelf && w->isFullscreen())
|
||||
if (w->m_pWorkspace == m_self && w->isFullscreen())
|
||||
return w;
|
||||
}
|
||||
|
||||
|
|
@ -533,21 +533,21 @@ PHLWINDOW CWorkspace::getFullscreenWindow() {
|
|||
}
|
||||
|
||||
bool CWorkspace::isVisible() {
|
||||
return m_bVisible;
|
||||
return m_visible;
|
||||
}
|
||||
|
||||
bool CWorkspace::isVisibleNotCovered() {
|
||||
const auto PMONITOR = m_pMonitor.lock();
|
||||
const auto PMONITOR = m_monitor.lock();
|
||||
if (PMONITOR->activeSpecialWorkspace)
|
||||
return PMONITOR->activeSpecialWorkspace->m_iID == m_iID;
|
||||
return PMONITOR->activeSpecialWorkspace->m_id == m_id;
|
||||
|
||||
return PMONITOR->activeWorkspace->m_iID == m_iID;
|
||||
return PMONITOR->activeWorkspace->m_id == m_id;
|
||||
}
|
||||
|
||||
int CWorkspace::getWindows(std::optional<bool> onlyTiled, std::optional<bool> onlyPinned, std::optional<bool> onlyVisible) {
|
||||
int no = 0;
|
||||
for (auto const& w : g_pCompositor->m_windows) {
|
||||
if (w->workspaceID() != m_iID || !w->m_bIsMapped)
|
||||
if (w->workspaceID() != m_id || !w->m_bIsMapped)
|
||||
continue;
|
||||
if (onlyTiled.has_value() && w->m_bIsFloating == onlyTiled.value())
|
||||
continue;
|
||||
|
|
@ -564,7 +564,7 @@ int CWorkspace::getWindows(std::optional<bool> onlyTiled, std::optional<bool> on
|
|||
int CWorkspace::getGroups(std::optional<bool> onlyTiled, std::optional<bool> onlyPinned, std::optional<bool> onlyVisible) {
|
||||
int no = 0;
|
||||
for (auto const& w : g_pCompositor->m_windows) {
|
||||
if (w->workspaceID() != m_iID || !w->m_bIsMapped)
|
||||
if (w->workspaceID() != m_id || !w->m_bIsMapped)
|
||||
continue;
|
||||
if (!w->m_sGroupData.head)
|
||||
continue;
|
||||
|
|
@ -581,7 +581,7 @@ int CWorkspace::getGroups(std::optional<bool> onlyTiled, std::optional<bool> onl
|
|||
|
||||
PHLWINDOW CWorkspace::getFirstWindow() {
|
||||
for (auto const& w : g_pCompositor->m_windows) {
|
||||
if (w->m_pWorkspace == m_pSelf && w->m_bIsMapped && !w->isHidden())
|
||||
if (w->m_pWorkspace == m_self && w->m_bIsMapped && !w->isHidden())
|
||||
return w;
|
||||
}
|
||||
|
||||
|
|
@ -589,10 +589,10 @@ PHLWINDOW CWorkspace::getFirstWindow() {
|
|||
}
|
||||
|
||||
PHLWINDOW CWorkspace::getTopLeftWindow() {
|
||||
const auto PMONITOR = m_pMonitor.lock();
|
||||
const auto PMONITOR = m_monitor.lock();
|
||||
|
||||
for (auto const& w : g_pCompositor->m_windows) {
|
||||
if (w->m_pWorkspace != m_pSelf || !w->m_bIsMapped || w->isHidden())
|
||||
if (w->m_pWorkspace != m_self || !w->m_bIsMapped || w->isHidden())
|
||||
continue;
|
||||
|
||||
const auto WINDOWIDEALBB = w->getWindowIdealBoundingBoxIgnoreReserved();
|
||||
|
|
@ -605,7 +605,7 @@ PHLWINDOW CWorkspace::getTopLeftWindow() {
|
|||
|
||||
bool CWorkspace::hasUrgentWindow() {
|
||||
for (auto const& w : g_pCompositor->m_windows) {
|
||||
if (w->m_pWorkspace == m_pSelf && w->m_bIsMapped && w->m_bIsUrgent)
|
||||
if (w->m_pWorkspace == m_self && w->m_bIsMapped && w->m_bIsUrgent)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -614,7 +614,7 @@ bool CWorkspace::hasUrgentWindow() {
|
|||
|
||||
void CWorkspace::updateWindowDecos() {
|
||||
for (auto const& w : g_pCompositor->m_windows) {
|
||||
if (w->m_pWorkspace != m_pSelf)
|
||||
if (w->m_pWorkspace != m_self)
|
||||
continue;
|
||||
|
||||
w->updateWindowDecos();
|
||||
|
|
@ -622,10 +622,10 @@ void CWorkspace::updateWindowDecos() {
|
|||
}
|
||||
|
||||
void CWorkspace::updateWindowData() {
|
||||
const auto WORKSPACERULE = g_pConfigManager->getWorkspaceRuleFor(m_pSelf.lock());
|
||||
const auto WORKSPACERULE = g_pConfigManager->getWorkspaceRuleFor(m_self.lock());
|
||||
|
||||
for (auto const& w : g_pCompositor->m_windows) {
|
||||
if (w->m_pWorkspace != m_pSelf)
|
||||
if (w->m_pWorkspace != m_self)
|
||||
continue;
|
||||
|
||||
w->updateWindowData(WORKSPACERULE);
|
||||
|
|
@ -634,7 +634,7 @@ void CWorkspace::updateWindowData() {
|
|||
|
||||
void CWorkspace::forceReportSizesToWindows() {
|
||||
for (auto const& w : g_pCompositor->m_windows) {
|
||||
if (w->m_pWorkspace != m_pSelf || !w->m_bIsMapped || w->isHidden())
|
||||
if (w->m_pWorkspace != m_self || !w->m_bIsMapped || w->isHidden())
|
||||
continue;
|
||||
|
||||
w->sendWindowSize(true);
|
||||
|
|
@ -642,26 +642,26 @@ void CWorkspace::forceReportSizesToWindows() {
|
|||
}
|
||||
|
||||
void CWorkspace::rename(const std::string& name) {
|
||||
if (g_pCompositor->isWorkspaceSpecial(m_iID))
|
||||
if (g_pCompositor->isWorkspaceSpecial(m_id))
|
||||
return;
|
||||
|
||||
Debug::log(LOG, "CWorkspace::rename: Renaming workspace {} to '{}'", m_iID, name);
|
||||
m_szName = name;
|
||||
Debug::log(LOG, "CWorkspace::rename: Renaming workspace {} to '{}'", m_id, name);
|
||||
m_name = name;
|
||||
|
||||
const auto WORKSPACERULE = g_pConfigManager->getWorkspaceRuleFor(m_pSelf.lock());
|
||||
m_bPersistent = WORKSPACERULE.isPersistent;
|
||||
const auto WORKSPACERULE = g_pConfigManager->getWorkspaceRuleFor(m_self.lock());
|
||||
m_persistent = WORKSPACERULE.isPersistent;
|
||||
|
||||
if (WORKSPACERULE.isPersistent)
|
||||
g_pCompositor->ensurePersistentWorkspacesPresent(std::vector<SWorkspaceRule>{WORKSPACERULE}, m_pSelf.lock());
|
||||
g_pCompositor->ensurePersistentWorkspacesPresent(std::vector<SWorkspaceRule>{WORKSPACERULE}, m_self.lock());
|
||||
|
||||
g_pEventManager->postEvent({"renameworkspace", std::to_string(m_iID) + "," + m_szName});
|
||||
g_pEventManager->postEvent({"renameworkspace", std::to_string(m_id) + "," + m_name});
|
||||
}
|
||||
|
||||
void CWorkspace::updateWindows() {
|
||||
m_bHasFullscreenWindow = std::ranges::any_of(g_pCompositor->m_windows, [this](const auto& w) { return w->m_bIsMapped && w->m_pWorkspace == m_pSelf && w->isFullscreen(); });
|
||||
m_hasFullscreenWindow = std::ranges::any_of(g_pCompositor->m_windows, [this](const auto& w) { return w->m_bIsMapped && w->m_pWorkspace == m_self && w->isFullscreen(); });
|
||||
|
||||
for (auto const& w : g_pCompositor->m_windows) {
|
||||
if (!w->m_bIsMapped || w->m_pWorkspace != m_pSelf)
|
||||
if (!w->m_bIsMapped || w->m_pWorkspace != m_self)
|
||||
continue;
|
||||
|
||||
w->updateDynamicRules();
|
||||
|
|
|
|||
|
|
@ -24,39 +24,39 @@ class CWorkspace {
|
|||
|
||||
// Workspaces ID-based have IDs > 0
|
||||
// and workspaces name-based have IDs starting with -1337
|
||||
WORKSPACEID m_iID = WORKSPACE_INVALID;
|
||||
std::string m_szName = "";
|
||||
PHLMONITORREF m_pMonitor;
|
||||
WORKSPACEID m_id = WORKSPACE_INVALID;
|
||||
std::string m_name = "";
|
||||
PHLMONITORREF m_monitor;
|
||||
|
||||
bool m_bHasFullscreenWindow = false;
|
||||
eFullscreenMode m_efFullscreenMode = FSMODE_NONE;
|
||||
bool m_hasFullscreenWindow = false;
|
||||
eFullscreenMode m_fullscreenMode = FSMODE_NONE;
|
||||
|
||||
wl_array m_wlrCoordinateArr;
|
||||
|
||||
// for animations
|
||||
PHLANIMVAR<Vector2D> m_vRenderOffset;
|
||||
PHLANIMVAR<float> m_fAlpha;
|
||||
bool m_bForceRendering = false;
|
||||
PHLANIMVAR<Vector2D> m_renderOffset;
|
||||
PHLANIMVAR<float> m_alpha;
|
||||
bool m_forceRendering = false;
|
||||
|
||||
// allows damage to propagate.
|
||||
bool m_bVisible = false;
|
||||
bool m_visible = false;
|
||||
|
||||
// "scratchpad"
|
||||
bool m_bIsSpecialWorkspace = false;
|
||||
bool m_isSpecialWorkspace = false;
|
||||
|
||||
// last window
|
||||
PHLWINDOWREF m_pLastFocusedWindow;
|
||||
PHLWINDOWREF m_lastFocusedWindow;
|
||||
|
||||
// user-set
|
||||
bool m_bDefaultFloating = false;
|
||||
bool m_bDefaultPseudo = false;
|
||||
bool m_defaultFloating = false;
|
||||
bool m_defaultPseudo = false;
|
||||
|
||||
// last monitor (used on reconnect)
|
||||
std::string m_szLastMonitor = "";
|
||||
std::string m_lastMonitor = "";
|
||||
|
||||
bool m_bWasCreatedEmpty = true;
|
||||
bool m_wasCreatedEmpty = true;
|
||||
|
||||
bool m_bPersistent = false;
|
||||
bool m_persistent = false;
|
||||
|
||||
// Inert: destroyed and invalid. If this is true, release the ptr you have.
|
||||
bool inert();
|
||||
|
|
@ -88,11 +88,11 @@ class CWorkspace {
|
|||
void init(PHLWORKSPACE self);
|
||||
// Previous workspace ID and name is stored during a workspace change, allowing travel
|
||||
// to the previous workspace.
|
||||
SWorkspaceIDName m_sPrevWorkspace;
|
||||
SWorkspaceIDName m_prevWorkspace;
|
||||
|
||||
SP<HOOK_CALLBACK_FN> m_pFocusedWindowHook;
|
||||
bool m_bInert = true;
|
||||
WP<CWorkspace> m_pSelf;
|
||||
SP<HOOK_CALLBACK_FN> m_focusedWindowHook;
|
||||
bool m_inert = true;
|
||||
WP<CWorkspace> m_self;
|
||||
};
|
||||
|
||||
inline bool valid(const PHLWORKSPACE& ref) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue