mirror of
https://github.com/hyprwm/Hyprland
synced 2025-02-17 00:02:35 +01:00
parent
a3309b51a2
commit
0b215c5f24
9 changed files with 73 additions and 27 deletions
|
@ -90,7 +90,7 @@ PHLLS CLayerSurface::create(wlr_layer_surface_v1* pWLRLS) {
|
||||||
|
|
||||||
pLS->alpha.setValueAndWarp(0.f);
|
pLS->alpha.setValueAndWarp(0.f);
|
||||||
|
|
||||||
pLS->surface.assign(pWLRLS->surface);
|
pLS->surface.assign(pWLRLS->surface, pLS);
|
||||||
|
|
||||||
return pLS;
|
return pLS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,8 +71,8 @@ void CPopup::initAllSignals() {
|
||||||
if (!m_pWLR) {
|
if (!m_pWLR) {
|
||||||
if (!m_pWindowOwner.expired())
|
if (!m_pWindowOwner.expired())
|
||||||
hyprListener_newPopup.initCallback(&m_pWindowOwner.lock()->m_uSurface.xdg->events.new_popup, ::onNewPopup, this, "CPopup Head");
|
hyprListener_newPopup.initCallback(&m_pWindowOwner.lock()->m_uSurface.xdg->events.new_popup, ::onNewPopup, this, "CPopup Head");
|
||||||
else if (m_pLayerOwner)
|
else if (!m_pLayerOwner.expired())
|
||||||
hyprListener_newPopup.initCallback(&m_pLayerOwner->layerSurface->events.new_popup, ::onNewPopup, this, "CPopup Head");
|
hyprListener_newPopup.initCallback(&m_pLayerOwner.lock()->layerSurface->events.new_popup, ::onNewPopup, this, "CPopup Head");
|
||||||
else
|
else
|
||||||
ASSERT(false);
|
ASSERT(false);
|
||||||
|
|
||||||
|
@ -119,8 +119,8 @@ void CPopup::onMap() {
|
||||||
unconstrain();
|
unconstrain();
|
||||||
sendScale();
|
sendScale();
|
||||||
|
|
||||||
if (m_pLayerOwner && m_pLayerOwner->layer < ZWLR_LAYER_SHELL_V1_LAYER_TOP)
|
if (!m_pLayerOwner.expired() && m_pLayerOwner.lock()->layer < ZWLR_LAYER_SHELL_V1_LAYER_TOP)
|
||||||
g_pHyprOpenGL->markBlurDirtyForMonitor(g_pCompositor->getMonitorFromID(m_pLayerOwner->layer));
|
g_pHyprOpenGL->markBlurDirtyForMonitor(g_pCompositor->getMonitorFromID(m_pLayerOwner.lock()->layer));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPopup::onUnmap() {
|
void CPopup::onUnmap() {
|
||||||
|
@ -136,8 +136,8 @@ void CPopup::onUnmap() {
|
||||||
|
|
||||||
g_pInputManager->simulateMouseMovement();
|
g_pInputManager->simulateMouseMovement();
|
||||||
|
|
||||||
if (m_pLayerOwner && m_pLayerOwner->layer < ZWLR_LAYER_SHELL_V1_LAYER_TOP)
|
if (!m_pLayerOwner.expired() && m_pLayerOwner.lock()->layer < ZWLR_LAYER_SHELL_V1_LAYER_TOP)
|
||||||
g_pHyprOpenGL->markBlurDirtyForMonitor(g_pCompositor->getMonitorFromID(m_pLayerOwner->layer));
|
g_pHyprOpenGL->markBlurDirtyForMonitor(g_pCompositor->getMonitorFromID(m_pLayerOwner.lock()->layer));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPopup::onCommit(bool ignoreSiblings) {
|
void CPopup::onCommit(bool ignoreSiblings) {
|
||||||
|
@ -178,8 +178,8 @@ void CPopup::onCommit(bool ignoreSiblings) {
|
||||||
|
|
||||||
m_bRequestedReposition = false;
|
m_bRequestedReposition = false;
|
||||||
|
|
||||||
if (m_pLayerOwner && m_pLayerOwner->layer < ZWLR_LAYER_SHELL_V1_LAYER_TOP)
|
if (!m_pLayerOwner.expired() && m_pLayerOwner.lock()->layer < ZWLR_LAYER_SHELL_V1_LAYER_TOP)
|
||||||
g_pHyprOpenGL->markBlurDirtyForMonitor(g_pCompositor->getMonitorFromID(m_pLayerOwner->layer));
|
g_pHyprOpenGL->markBlurDirtyForMonitor(g_pCompositor->getMonitorFromID(m_pLayerOwner.lock()->layer));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPopup::onReposition() {
|
void CPopup::onReposition() {
|
||||||
|
@ -232,8 +232,8 @@ Vector2D CPopup::localToGlobal(const Vector2D& rel) {
|
||||||
Vector2D CPopup::t1ParentCoords() {
|
Vector2D CPopup::t1ParentCoords() {
|
||||||
if (!m_pWindowOwner.expired())
|
if (!m_pWindowOwner.expired())
|
||||||
return m_pWindowOwner.lock()->m_vRealPosition.value();
|
return m_pWindowOwner.lock()->m_vRealPosition.value();
|
||||||
if (m_pLayerOwner)
|
if (!m_pLayerOwner.expired())
|
||||||
return m_pLayerOwner->realPosition.value();
|
return m_pLayerOwner.lock()->realPosition.value();
|
||||||
|
|
||||||
ASSERT(false);
|
ASSERT(false);
|
||||||
return {};
|
return {};
|
||||||
|
@ -262,8 +262,19 @@ Vector2D CPopup::size() {
|
||||||
void CPopup::sendScale() {
|
void CPopup::sendScale() {
|
||||||
if (!m_pWindowOwner.expired())
|
if (!m_pWindowOwner.expired())
|
||||||
g_pCompositor->setPreferredScaleForSurface(m_sWLSurface.wlr(), m_pWindowOwner.lock()->m_pWLSurface.m_fLastScale);
|
g_pCompositor->setPreferredScaleForSurface(m_sWLSurface.wlr(), m_pWindowOwner.lock()->m_pWLSurface.m_fLastScale);
|
||||||
else if (m_pLayerOwner)
|
else if (!m_pLayerOwner.expired())
|
||||||
g_pCompositor->setPreferredScaleForSurface(m_sWLSurface.wlr(), m_pLayerOwner->surface.m_fLastScale);
|
g_pCompositor->setPreferredScaleForSurface(m_sWLSurface.wlr(), m_pLayerOwner.lock()->surface.m_fLastScale);
|
||||||
else
|
else
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CPopup::visible() {
|
||||||
|
if (!m_pWindowOwner.expired())
|
||||||
|
return g_pHyprRenderer->shouldRenderWindow(m_pWindowOwner.lock());
|
||||||
|
if (!m_pLayerOwner.expired())
|
||||||
|
return true;
|
||||||
|
if (m_pParent)
|
||||||
|
return m_pParent->visible();
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
|
@ -29,12 +29,14 @@ class CPopup {
|
||||||
|
|
||||||
void recheckTree();
|
void recheckTree();
|
||||||
|
|
||||||
|
bool visible();
|
||||||
|
|
||||||
CWLSurface m_sWLSurface;
|
CWLSurface m_sWLSurface;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// T1 owners, each popup has to have one of these
|
// T1 owners, each popup has to have one of these
|
||||||
PHLWINDOWREF m_pWindowOwner;
|
PHLWINDOWREF m_pWindowOwner;
|
||||||
PHLLS m_pLayerOwner;
|
PHLLSREF m_pLayerOwner;
|
||||||
|
|
||||||
// T2 owners
|
// T2 owners
|
||||||
CPopup* m_pParent = nullptr;
|
CPopup* m_pParent = nullptr;
|
||||||
|
|
|
@ -227,3 +227,14 @@ void CSubsurface::initExistingSubsurfaces(wlr_surface* pSurface) {
|
||||||
Vector2D CSubsurface::size() {
|
Vector2D CSubsurface::size() {
|
||||||
return {m_sWLSurface.wlr()->current.width, m_sWLSurface.wlr()->current.height};
|
return {m_sWLSurface.wlr()->current.width, m_sWLSurface.wlr()->current.height};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
|
@ -29,6 +29,8 @@ class CSubsurface {
|
||||||
void onMap();
|
void onMap();
|
||||||
void onUnmap();
|
void onUnmap();
|
||||||
|
|
||||||
|
bool visible();
|
||||||
|
|
||||||
void recheckDamageForSubsurfaces();
|
void recheckDamageForSubsurfaces();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -197,3 +197,15 @@ void CWLSurface::onCommit() {
|
||||||
std::shared_ptr<CPointerConstraint> CWLSurface::constraint() {
|
std::shared_ptr<CPointerConstraint> CWLSurface::constraint() {
|
||||||
return m_pConstraint.lock();
|
return m_pConstraint.lock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CWLSurface::visible() {
|
||||||
|
if (!m_pWindowOwner.expired())
|
||||||
|
return g_pHyprRenderer->shouldRenderWindow(m_pWindowOwner.lock());
|
||||||
|
if (!m_pLayerOwner.expired())
|
||||||
|
return true;
|
||||||
|
if (m_pPopupOwner)
|
||||||
|
return m_pPopupOwner->visible();
|
||||||
|
if (m_pSubsurfaceOwner)
|
||||||
|
return m_pSubsurfaceOwner->visible();
|
||||||
|
return true; // non-desktop, we don't know much.
|
||||||
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ class CWLSurface {
|
||||||
Vector2D getViewporterCorrectedSize() const;
|
Vector2D getViewporterCorrectedSize() const;
|
||||||
CRegion logicalDamage() const;
|
CRegion logicalDamage() const;
|
||||||
void onCommit();
|
void onCommit();
|
||||||
|
bool visible();
|
||||||
|
|
||||||
// getters for owners.
|
// getters for owners.
|
||||||
PHLWINDOW getWindow();
|
PHLWINDOW getWindow();
|
||||||
|
|
|
@ -14,26 +14,33 @@ void CInputManager::newIdleInhibitor(std::any inhibitor) {
|
||||||
recheckIdleInhibitorStatus();
|
recheckIdleInhibitorStatus();
|
||||||
});
|
});
|
||||||
|
|
||||||
const auto PWINDOW = g_pCompositor->getWindowFromSurface(PINHIBIT->inhibitor->surface);
|
auto WLSurface = CWLSurface::surfaceFromWlr(PINHIBIT->inhibitor->surface);
|
||||||
|
|
||||||
|
if (!WLSurface) {
|
||||||
|
Debug::log(LOG, "Inhibitor has no HL Surface attached to it, likely meaning it's a non-desktop element. Ignoring.");
|
||||||
|
PINHIBIT->inert = true;
|
||||||
|
recheckIdleInhibitorStatus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
PINHIBIT->surfaceDestroyListener = WLSurface->events.destroy.registerListener(
|
||||||
|
[this, PINHIBIT](std::any data) { std::erase_if(m_vIdleInhibitors, [PINHIBIT](const auto& other) { return other.get() == PINHIBIT; }); });
|
||||||
|
|
||||||
if (PWINDOW) {
|
|
||||||
PINHIBIT->pWindow = PWINDOW;
|
|
||||||
PINHIBIT->windowDestroyListener = PWINDOW->events.destroy.registerListener([PINHIBIT](std::any data) {
|
|
||||||
Debug::log(WARN, "Inhibitor got its window destroyed before its inhibitor resource.");
|
|
||||||
PINHIBIT->pWindow.reset();
|
|
||||||
});
|
|
||||||
} else
|
|
||||||
Debug::log(WARN, "Inhibitor is for no window?");
|
|
||||||
recheckIdleInhibitorStatus();
|
recheckIdleInhibitorStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInputManager::recheckIdleInhibitorStatus() {
|
void CInputManager::recheckIdleInhibitorStatus() {
|
||||||
|
|
||||||
for (auto& ii : m_vIdleInhibitors) {
|
for (auto& ii : m_vIdleInhibitors) {
|
||||||
if (ii->pWindow.expired())
|
if (ii->inert)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (g_pHyprRenderer->shouldRenderWindow(ii->pWindow.lock())) {
|
auto WLSurface = CWLSurface::surfaceFromWlr(ii->inhibitor->surface);
|
||||||
|
|
||||||
|
if (!WLSurface)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (WLSurface->visible()) {
|
||||||
PROTO::idle->setInhibit(true);
|
PROTO::idle->setInhibit(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -242,8 +242,8 @@ class CInputManager {
|
||||||
// idle inhibitors
|
// idle inhibitors
|
||||||
struct SIdleInhibitor {
|
struct SIdleInhibitor {
|
||||||
std::shared_ptr<CIdleInhibitor> inhibitor;
|
std::shared_ptr<CIdleInhibitor> inhibitor;
|
||||||
PHLWINDOWREF pWindow;
|
bool inert = false;
|
||||||
CHyprSignalListener windowDestroyListener;
|
CHyprSignalListener surfaceDestroyListener;
|
||||||
};
|
};
|
||||||
std::vector<std::unique_ptr<SIdleInhibitor>> m_vIdleInhibitors;
|
std::vector<std::unique_ptr<SIdleInhibitor>> m_vIdleInhibitors;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue