Skip to content

Commit 4cf62c1

Browse files
authored
layerrules: add abovelock to render above lockscreen (#9793)
1 parent 41f5f67 commit 4cf62c1

File tree

9 files changed

+71
-24
lines changed

9 files changed

+71
-24
lines changed

src/Compositor.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,9 +1286,12 @@ SP<CWLSurfaceResource> CCompositor::vectorToLayerPopupSurface(const Vector2D& po
12861286
return nullptr;
12871287
}
12881288

1289-
SP<CWLSurfaceResource> CCompositor::vectorToLayerSurface(const Vector2D& pos, std::vector<PHLLSREF>* layerSurfaces, Vector2D* sCoords, PHLLS* ppLayerSurfaceFound) {
1289+
SP<CWLSurfaceResource> CCompositor::vectorToLayerSurface(const Vector2D& pos, std::vector<PHLLSREF>* layerSurfaces, Vector2D* sCoords, PHLLS* ppLayerSurfaceFound,
1290+
bool aboveLockscreen) {
1291+
12901292
for (auto const& ls : *layerSurfaces | std::views::reverse) {
1291-
if (!ls->m_mapped || ls->m_fadingOut || !ls->m_layerSurface || (ls->m_layerSurface && !ls->m_layerSurface->surface->mapped) || ls->m_alpha->value() == 0.f)
1293+
if (!ls->m_mapped || ls->m_fadingOut || !ls->m_layerSurface || (ls->m_layerSurface && !ls->m_layerSurface->surface->mapped) || ls->m_alpha->value() == 0.f ||
1294+
(aboveLockscreen && (!ls->m_aboveLockscreen || !ls->m_aboveLockscreenInteractable)))
12921295
continue;
12931296

12941297
auto [surf, local] = ls->m_layerSurface->surface->at(pos - ls->m_geometry.pos(), true);

src/Compositor.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class CCompositor {
8585
void focusSurface(SP<CWLSurfaceResource>, PHLWINDOW pWindowOwner = nullptr);
8686
bool monitorExists(PHLMONITOR);
8787
PHLWINDOW vectorToWindowUnified(const Vector2D&, uint8_t properties, PHLWINDOW pIgnoreWindow = nullptr);
88-
SP<CWLSurfaceResource> vectorToLayerSurface(const Vector2D&, std::vector<PHLLSREF>*, Vector2D*, PHLLS*);
88+
SP<CWLSurfaceResource> vectorToLayerSurface(const Vector2D&, std::vector<PHLLSREF>*, Vector2D*, PHLLS*, bool aboveLockscreen = false);
8989
SP<CWLSurfaceResource> vectorToLayerPopupSurface(const Vector2D&, PHLMONITOR monitor, Vector2D*, PHLLS*);
9090
SP<CWLSurfaceResource> vectorWindowToSurface(const Vector2D&, PHLWINDOW, Vector2D& sl);
9191
Vector2D vectorToSurfaceLocal(const Vector2D&, PHLWINDOW, SP<CWLSurfaceResource>);

src/desktop/LayerRule.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include "../debug/Log.hpp"
66

77
static const auto RULES = std::unordered_set<std::string>{"noanim", "blur", "blurpopups", "dimaround"};
8-
static const auto RULES_PREFIX = std::unordered_set<std::string>{"ignorealpha", "ignorezero", "xray", "animation", "order"};
8+
static const auto RULES_PREFIX = std::unordered_set<std::string>{"ignorealpha", "ignorezero", "xray", "animation", "order", "abovelock"};
99

1010
CLayerRule::CLayerRule(const std::string& rule_, const std::string& ns_) : m_targetNamespace(ns_), m_rule(rule_) {
1111
const bool VALID = RULES.contains(m_rule) || std::any_of(RULES_PREFIX.begin(), RULES_PREFIX.end(), [&rule_](const auto& prefix) { return rule_.starts_with(prefix); });
@@ -31,8 +31,10 @@ CLayerRule::CLayerRule(const std::string& rule_, const std::string& ns_) : m_tar
3131
m_ruleType = RULE_ANIMATION;
3232
else if (m_rule.starts_with("order"))
3333
m_ruleType = RULE_ORDER;
34+
else if (m_rule.starts_with("abovelock"))
35+
m_ruleType = RULE_ABOVELOCK;
3436
else {
3537
Debug::log(ERR, "CLayerRule: didn't match a rule that was found valid?!");
3638
m_ruleType = RULE_INVALID;
3739
}
38-
}
40+
}

src/desktop/LayerRule.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class CLayerRule {
1414
RULE_BLUR,
1515
RULE_BLURPOPUPS,
1616
RULE_DIMAROUND,
17+
RULE_ABOVELOCK,
1718
RULE_IGNOREALPHA,
1819
RULE_IGNOREZERO,
1920
RULE_XRAY,
@@ -28,4 +29,4 @@ class CLayerRule {
2829
const std::string m_rule;
2930

3031
CRuleRegexContainer m_targetNamespaceRegex;
31-
};
32+
};

src/desktop/LayerSurface.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -421,9 +421,8 @@ void CLayerSurface::applyRules() {
421421
}
422422
case CLayerRule::RULE_XRAY: {
423423
CVarList vars{rule->m_rule, 0, ' '};
424-
try {
425-
m_xray = configStringToInt(vars[1]).value_or(false);
426-
} catch (...) {}
424+
m_xray = configStringToInt(vars[1]).value_or(false);
425+
427426
break;
428427
}
429428
case CLayerRule::RULE_ANIMATION: {
@@ -438,6 +437,14 @@ void CLayerSurface::applyRules() {
438437
} catch (...) { Debug::log(ERR, "Invalid value passed to order"); }
439438
break;
440439
}
440+
case CLayerRule::RULE_ABOVELOCK: {
441+
m_aboveLockscreen = true;
442+
443+
CVarList vars{rule->m_rule, 0, ' '};
444+
m_aboveLockscreenInteractable = configStringToInt(vars[1]).value_or(false);
445+
446+
break;
447+
}
441448
default: break;
442449
}
443450
}

src/desktop/LayerSurface.hpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,15 @@ class CLayerSurface {
4343
bool m_noProcess = false;
4444
bool m_noAnimations = false;
4545

46-
bool m_forceBlur = false;
47-
bool m_forceBlurPopups = false;
48-
int64_t m_xray = -1;
49-
bool m_ignoreAlpha = false;
50-
float m_ignoreAlphaValue = 0.f;
51-
bool m_dimAround = false;
52-
int64_t m_order = 0;
46+
bool m_forceBlur = false;
47+
bool m_forceBlurPopups = false;
48+
int64_t m_xray = -1;
49+
bool m_ignoreAlpha = false;
50+
float m_ignoreAlphaValue = 0.f;
51+
bool m_dimAround = false;
52+
int64_t m_order = 0;
53+
bool m_aboveLockscreen = false;
54+
bool m_aboveLockscreenInteractable = false;
5355

5456
std::optional<std::string> m_animationStyle;
5557

src/managers/input/InputManager.cpp

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "../../Compositor.hpp"
33
#include <aquamarine/output/Output.hpp>
44
#include <cstdint>
5+
#include <hyprutils/math/Vector2D.hpp>
56
#include <ranges>
67
#include "../../config/ConfigValue.hpp"
78
#include "../../config/ConfigManager.hpp"
@@ -249,15 +250,29 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse) {
249250
g_pCompositor->setActiveMonitor(PMONITOR);
250251

251252
if (g_pSessionLockManager->isSessionLocked()) {
253+
254+
// set keyboard focus on session lock surface regardless of layers
252255
const auto PSESSIONLOCKSURFACE = g_pSessionLockManager->getSessionLockSurfaceForMonitor(PMONITOR->ID);
253-
surfacePos = PMONITOR->vecPosition;
256+
const auto foundLockSurface = PSESSIONLOCKSURFACE ? PSESSIONLOCKSURFACE->surface->surface() : nullptr;
257+
258+
g_pCompositor->focusSurface(foundLockSurface);
259+
260+
// search for interactable abovelock surfaces for pointer focus, or use session lock surface if not found
261+
for (auto& lsl : PMONITOR->m_aLayerSurfaceLayers | std::views::reverse) {
262+
foundSurface = g_pCompositor->vectorToLayerSurface(mouseCoords, &lsl, &surfaceCoords, &pFoundLayerSurface, true);
263+
264+
if (foundSurface)
265+
break;
266+
}
267+
268+
if (!foundSurface) {
269+
surfaceCoords = mouseCoords - PMONITOR->vecPosition;
270+
foundSurface = foundLockSurface;
271+
}
254272

255-
foundSurface = PSESSIONLOCKSURFACE ? PSESSIONLOCKSURFACE->surface->surface() : nullptr;
256-
g_pCompositor->focusSurface(foundSurface);
273+
g_pSeatManager->setPointerFocus(foundSurface, surfaceCoords);
274+
g_pSeatManager->sendPointerMotion(time, surfaceCoords);
257275

258-
const auto SURFACELOCAL = mouseCoords - surfacePos;
259-
g_pSeatManager->setPointerFocus(foundSurface, SURFACELOCAL);
260-
g_pSeatManager->sendPointerMotion(time, SURFACELOCAL);
261276
return;
262277
}
263278

src/render/Renderer.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -690,10 +690,14 @@ void CHyprRenderer::renderWindow(PHLWINDOW pWindow, PHLMONITOR pMonitor, const T
690690
g_pHyprOpenGL->m_RenderData.currentWindow.reset();
691691
}
692692

693-
void CHyprRenderer::renderLayer(PHLLS pLayer, PHLMONITOR pMonitor, const Time::steady_tp& time, bool popups) {
693+
void CHyprRenderer::renderLayer(PHLLS pLayer, PHLMONITOR pMonitor, const Time::steady_tp& time, bool popups, bool lockscreen) {
694694
if (!pLayer)
695695
return;
696696

697+
// skip rendering based on abovelock rule and make sure to not render abovelock layers twice
698+
if ((pLayer->m_aboveLockscreen && !lockscreen && g_pSessionLockManager->isSessionLocked()) || (lockscreen && !pLayer->m_aboveLockscreen))
699+
return;
700+
697701
static auto PDIMAROUND = CConfigValue<Hyprlang::FLOAT>("decoration:dim_around");
698702

699703
if (*PDIMAROUND && pLayer->m_dimAround && !m_bRenderingSnapshot && !popups) {
@@ -998,6 +1002,19 @@ void CHyprRenderer::renderLockscreen(PHLMONITOR pMonitor, const Time::steady_tp&
9981002
renderSessionLockMissing(pMonitor);
9991003
} else {
10001004
renderSessionLockSurface(PSLS, pMonitor, now);
1005+
1006+
// render layers and then their popups for abovelock rule
1007+
for (auto const& lsl : pMonitor->m_aLayerSurfaceLayers) {
1008+
for (auto const& ls : lsl) {
1009+
renderLayer(ls.lock(), pMonitor, now, false, true);
1010+
}
1011+
}
1012+
for (auto const& lsl : pMonitor->m_aLayerSurfaceLayers) {
1013+
for (auto const& ls : lsl) {
1014+
renderLayer(ls.lock(), pMonitor, now, true, true);
1015+
}
1016+
}
1017+
10011018
g_pSessionLockManager->onLockscreenRenderedOnMonitor(pMonitor->ID);
10021019
}
10031020
}

src/render/Renderer.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class CHyprRenderer {
120120
void renderWorkspaceWindowsFullscreen(PHLMONITOR, PHLWORKSPACE, const Time::steady_tp&); // renders workspace windows (fullscreen) (tiled, floating, pinned, but no special)
121121
void renderWorkspaceWindows(PHLMONITOR, PHLWORKSPACE, const Time::steady_tp&); // renders workspace windows (no fullscreen) (tiled, floating, pinned, but no special)
122122
void renderWindow(PHLWINDOW, PHLMONITOR, const Time::steady_tp&, bool, eRenderPassMode, bool ignorePosition = false, bool standalone = false);
123-
void renderLayer(PHLLS, PHLMONITOR, const Time::steady_tp&, bool popups = false);
123+
void renderLayer(PHLLS, PHLMONITOR, const Time::steady_tp&, bool popups = false, bool lockscreen = false);
124124
void renderSessionLockSurface(WP<SSessionLockSurface>, PHLMONITOR, const Time::steady_tp&);
125125
void renderDragIcon(PHLMONITOR, const Time::steady_tp&);
126126
void renderIMEPopup(CInputPopup*, PHLMONITOR, const Time::steady_tp&);

0 commit comments

Comments
 (0)