windowrules: rewrite completely (#12269)

Reworks the window rule syntax completely

---------

Co-authored-by: Mihai Fufezan <mihai@fufexan.net>
This commit is contained in:
Vaxry 2025-11-17 18:34:02 +00:00 committed by GitHub
parent 95ee08b340
commit c2670e9ab9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
93 changed files with 3574 additions and 2255 deletions

View file

@ -230,7 +230,7 @@ void CScreencopyFrame::renderMon() {
};
for (auto const& l : g_pCompositor->m_layers) {
if (!l->m_noScreenShare)
if (!l->m_ruleApplicator->noScreenShare().valueOrDefault())
continue;
if UNLIKELY ((!l->m_mapped && !l->m_fadingOut) || l->m_alpha->value() == 0.f)
@ -251,7 +251,7 @@ void CScreencopyFrame::renderMon() {
}
for (auto const& w : g_pCompositor->m_windows) {
if (!w->m_windowData.noScreenShare.valueOrDefault())
if (!w->m_ruleApplicator->noScreenShare().valueOrDefault())
continue;
if (!g_pHyprRenderer->shouldRenderWindow(w, m_monitor.lock()))
@ -272,7 +272,7 @@ void CScreencopyFrame::renderMon() {
.scale(m_monitor->m_scale)
.translate(-m_box.pos());
const auto dontRound = w->isEffectiveInternalFSMode(FSMODE_FULLSCREEN) || w->m_windowData.noRounding.valueOrDefault();
const auto dontRound = w->isEffectiveInternalFSMode(FSMODE_FULLSCREEN);
const auto rounding = dontRound ? 0 : w->rounding() * m_monitor->m_scale;
const auto roundingPower = dontRound ? 2.0f : w->roundingPower();

View file

@ -70,7 +70,7 @@ bool CKeyboardShortcutsInhibitProtocol::isInhibited() {
if (!g_pCompositor->m_lastFocus)
return false;
if (const auto PWINDOW = g_pCompositor->getWindowFromSurface(g_pCompositor->m_lastFocus.lock()); PWINDOW && PWINDOW->m_windowData.noShortcutsInhibit.valueOrDefault())
if (const auto PWINDOW = g_pCompositor->getWindowFromSurface(g_pCompositor->m_lastFocus.lock()); PWINDOW && PWINDOW->m_ruleApplicator->noShortcutsInhibit().valueOrDefault())
return false;
for (auto const& in : m_inhibitors) {

View file

@ -257,7 +257,7 @@ bool CToplevelExportFrame::copyShm(const Time::steady_tp& now) {
// render client at 0,0
if (PERM == PERMISSION_RULE_ALLOW_MODE_ALLOW) {
if (!m_window->m_windowData.noScreenShare.valueOrDefault()) {
if (!m_window->m_ruleApplicator->noScreenShare().valueOrDefault()) {
g_pHyprRenderer->m_bBlockSurfaceFeedback = g_pHyprRenderer->shouldRenderWindow(m_window); // block the feedback to avoid spamming the surface if it's visible
g_pHyprRenderer->renderWindow(m_window, PMONITOR, now, false, RENDER_PASS_ALL, true, true);
g_pHyprRenderer->m_bBlockSurfaceFeedback = false;
@ -339,7 +339,7 @@ bool CToplevelExportFrame::copyDmabuf(const Time::steady_tp& now) {
g_pHyprOpenGL->clear(CHyprColor(0, 0, 0, 1.0));
if (PERM == PERMISSION_RULE_ALLOW_MODE_ALLOW) {
if (!m_window->m_windowData.noScreenShare.valueOrDefault()) {
if (!m_window->m_ruleApplicator->noScreenShare().valueOrDefault()) {
g_pHyprRenderer->m_bBlockSurfaceFeedback = g_pHyprRenderer->shouldRenderWindow(m_window); // block the feedback to avoid spamming the surface if it's visible
g_pHyprRenderer->renderWindow(m_window, PMONITOR, now, false, RENDER_PASS_ALL, true, true);
g_pHyprRenderer->m_bBlockSurfaceFeedback = false;

View file

@ -30,7 +30,7 @@ void CXDGDialogV1Resource::updateWindow() {
if UNLIKELY (!HLSurface || !HLSurface->getWindow())
return;
g_pCompositor->updateWindowAnimatedDecorationValues(HLSurface->getWindow());
HLSurface->getWindow()->m_ruleApplicator->propertiesChanged(Desktop::Rule::RULE_PROP_MODAL);
}
bool CXDGDialogV1Resource::good() {

View file

@ -1,5 +1,6 @@
#include "XDGTag.hpp"
#include "XDGShell.hpp"
#include "../desktop/Window.hpp"
CXDGToplevelTagManagerResource::CXDGToplevelTagManagerResource(UP<CXdgToplevelTagManagerV1>&& resource) : m_resource(std::move(resource)) {
if UNLIKELY (!good())
@ -17,6 +18,8 @@ CXDGToplevelTagManagerResource::CXDGToplevelTagManagerResource(UP<CXdgToplevelTa
}
TOPLEVEL->m_toplevelTag = tag;
if (TOPLEVEL->m_window)
TOPLEVEL->m_window->m_ruleApplicator->propertiesChanged(Desktop::Rule::RULE_PROP_XDG_TAG);
});
m_resource->setSetToplevelDescription([](CXdgToplevelTagManagerV1* r, wl_resource* toplevel, const char* description) {

View file

@ -12,7 +12,15 @@ namespace NContentType {
if (it != table.end())
return it->second;
else
throw std::invalid_argument(std::format("Unknown content type {}", name));
return CONTENT_TYPE_NONE;
}
std::string toString(eContentType type) {
for (const auto& [k, v] : table) {
if (v == type)
return k;
}
return "";
}
eContentType fromWP(wpContentTypeV1Type contentType) {

View file

@ -13,6 +13,7 @@ namespace NContentType {
};
eContentType fromString(const std::string name);
std::string toString(eContentType);
eContentType fromWP(wpContentTypeV1Type contentType);
uint16_t toDRM(eContentType contentType);
}