Phosphor
Qt6 / Wayland library suite for window-management tools
Loading...
Searching...
No Matches
ContextRuleBridge.h File Reference

Header-only bridge: zone Assignments / per-mode disable entries → context-only Rules. More...

#include <QJsonObject>
#include <QList>
#include <QLoggingCategory>
#include <QSet>
#include <QString>
#include <QUuid>
#include <algorithm>
#include <functional>
#include <iterator>
#include <optional>
#include "IdentityKey.h"
#include "MatchExpression.h"
#include "MatchTypes.h"
#include "RuleAction.h"
#include "Rule.h"
#include "RuleLogging.h"
#include "phosphorrules_export.h"

Go to the source code of this file.

Classes

struct  PhosphorRules::ContextRuleBridge::ContextRemap
 How the desktops and activities a rule set names have moved. More...

Namespaces

namespace  PhosphorRules
namespace  PhosphorRules::ContextRuleBridge
namespace  PhosphorRules::ContextRuleBridge::detail

Enumerations

enum class  PhosphorRules::ContextRuleBridge::ContextAxis {
  PhosphorRules::ContextRuleBridge::CatchAll , PhosphorRules::ContextRuleBridge::Monitor , PhosphorRules::ContextRuleBridge::Desktop , PhosphorRules::ContextRuleBridge::Activity ,
  PhosphorRules::ContextRuleBridge::Combined
}
 The cascade axis a context tuple resolves to. More...

Functions

ContextAxis PhosphorRules::ContextRuleBridge::contextAxisOf (const QString &screenId, int virtualDesktop, const QString &activity)
 Classify a (screen, desktop, activity) tuple into its cascade axis.
QString PhosphorRules::ContextRuleBridge::contextRuleName (const QString &screenId, int virtualDesktop, const QString &activity)
 Human-readable label for a context rule's tuple.
const QUuid & PhosphorRules::ContextRuleBridge::detail::namespaceUuid ()
 Fixed v5-UUID namespace for context-rule identities.
QString PhosphorRules::ContextRuleBridge::detail::contextIdentityKey (QLatin1StringView family, const QString &screenId, int virtualDesktop, const QString &activity)
 Stable per-rule key for the v5-UUID derivation.
QUuid PhosphorRules::ContextRuleBridge::assignmentRuleIdFor (const QString &screenId, int virtualDesktop, const QString &activity)
 The deterministic v5 rule id makeAssignmentRule would assign for a given (screen, desktop, activity) tuple.
QUuid PhosphorRules::ContextRuleBridge::disableRuleIdFor (const QString &screenId, int virtualDesktop, const QString &activity, const QString &modeToken)
 The deterministic v5 rule id makeDisableRule would assign for a given (screen, desktop, activity, modeToken) tuple.
MatchExpression PhosphorRules::ContextRuleBridge::makeContextMatch (const QString &screenId, int virtualDesktop, const QString &activity)
 Build the context-only MatchExpression for a (screen, desktop, activity) tuple.
QList< RuleAction > PhosphorRules::ContextRuleBridge::makeAssignmentActions (const QString &modeToken, const QString &snappingLayout, const QString &tilingAlgorithm, const QString &scrollingTemplate)
 Build the lossless action list for a migrated zone Assignment.
Rule PhosphorRules::ContextRuleBridge::makeAssignmentRule (const QString &name, const QString &screenId, int virtualDesktop, const QString &activity, const QString &modeToken, const QString &snappingLayout, const QString &tilingAlgorithm, int priority, const QString &scrollingTemplate)
 Build a complete migrated zone-Assignment Rule.
Rule PhosphorRules::ContextRuleBridge::makeDisableRule (const QString &name, const QString &screenId, int virtualDesktop, const QString &activity, const QString &modeToken, int priority)
 Build a DisableEngine context rule for a per-mode disable entry.
bool PhosphorRules::ContextRuleBridge::isContextEqualsLeaf (const MatchExpression &expr, Field field)
 True if expr is an exact Field == value equality leaf for field.
bool PhosphorRules::ContextRuleBridge::contextDimsOf (const MatchExpression &match, QString &screenId, int &virtualDesktop, QString &activity)
 Decompose a context rule's match into its pinned dimensions.
bool PhosphorRules::ContextRuleBridge::pinsNonDimensionContextField (const MatchExpression &match)
 True if match pins a context field that is NOT one of the three cascade dimensions — any context field outside kContextDimensionFields (Mode, TiledWindowCount, the screen orientation, width, height and aspect ratio, ActiveLayout, ColorScheme).
ContextAxis PhosphorRules::ContextRuleBridge::contextAxisFor (const MatchExpression &match)
 Classify match's pinned-dimension shape as a ContextAxis.
bool PhosphorRules::ContextRuleBridge::matchIsExactContextBase (const MatchExpression &match)
 True if match is a context-only "screen-only" pin — screen present, no desktop, no activity.
bool PhosphorRules::ContextRuleBridge::matchIsExactContextDesktop (const MatchExpression &match)
 True if match is a context-only "screen + desktop" pin (no activity).
bool PhosphorRules::ContextRuleBridge::matchIsExactContextActivity (const MatchExpression &match)
 BROAD per-activity family classifier — true if match is a context-only rule pinning an activity (with screen), whether or not it ALSO pins a desktop.
bool PhosphorRules::ContextRuleBridge::matchIsExactContextActivityStrict (const MatchExpression &match)
 STRICT per-activity classifier — screen+activity ONLY, no desktop pin.
bool PhosphorRules::ContextRuleBridge::matchIsExactContextCombined (const MatchExpression &match)
 STRICT Combined classifier — screen + desktop + activity all pinned.
bool PhosphorRules::ContextRuleBridge::matchIsExactContext (const MatchExpression &match, const QString &screenId, int virtualDesktop, const QString &activity)
 True if match is the exact-shape context for screenId / virtualDesktop / activity — i.e.
std::optional< QString > PhosphorRules::ContextRuleBridge::disableRuleMode (const Rule &rule)
 If rule is a per-mode disable rule, return its mode wire token verbatim; otherwise nullopt.
MatchExpression PhosphorRules::ContextRuleBridge::detail::remapDesktopLeaves (const MatchExpression &match, const std::function< int(int)> &desktop, bool &namedGone)
 match with every VirtualDesktop Equals leaf, at any depth, moved through desktop.
bool PhosphorRules::ContextRuleBridge::detail::remapRuleDesktops (Rule &rule, const std::function< int(int)> &desktop)
 A rule that is not one context's own setting follows its desktops: its VirtualDesktop Equals leaves and its RouteToDesktop target move through desktop, and when one of them named a desktop that is gone the rule is switched off, not deleted, so it stays in the rule editor to be fixed.
bool PhosphorRules::ContextRuleBridge::detail::isContextSetting (const Rule &rule, const QString &screenId, int virtualDesktop, const QString &activity)
 Whether rule, whose match is the exact context shape decoded into the tuple, is that context's own setting: this bridge minted it for the tuple, or every action it carries is a context-domain one.
std::optional< QList< Rule > > PhosphorRules::ContextRuleBridge::remapContextRules (const QList< Rule > &rules, const ContextRemap &remap)
 rules with the desktops and activities they name moved by remap.
QString PhosphorRules::ContextRuleBridge::detail::encodeSegment (const QString &segment)
 Length-prefix a segment so concatenated identity keys are unambiguous: a screenId / activity may itself contain a |, so a plain |-joined key could collide for two distinct tuples.

Variables

constexpr int PhosphorRules::ContextRuleBridge::kContextBandBase = 300
 Default precedence band base for context rules (zone assignments and per-mode disables).
constexpr Field PhosphorRules::ContextRuleBridge::kContextDimensionFields [] = {Field::ScreenId, Field::VirtualDesktop, Field::Activity}
 The three cascade dimensions makeContextMatch can emit — the only context fields contextDimsOf decodes back out of a match.

Detailed Description

Header-only bridge: zone Assignments / per-mode disable entries → context-only Rules.

Zone Assignments and per-mode disable lists carry no window-property fields — they answer "what does this screen/desktop/activity context use?". They become context-only Rules whose match expression references only ScreenId / VirtualDesktop / Activity.

Precedence is plain priority: the highest-priority matching rule wins per action slot, ties broken by list order. There is no specificity formula and no provider-default rule. The caller supplies each rule's priority explicitly — context rules seed in the kContextBandBase band and the Settings list-order renormalizer / runtime upsert derive the rest.

Header-only: a consumer that includes this bridge takes only an include-time dependency; there is no link edge and no dependency cycle.