Phosphor
Qt6 / Wayland library suite for window-management tools
 
Loading...
Searching...
No Matches
PhosphorAnimationShaders::AnimationAppRule Struct Reference

One per-window animation override entry. More...

#include <phosphor-animation/include/PhosphorAnimation/AnimationAppRule.h>

Public Types

enum class  Kind { Shader , Timing }
 

Public Member Functions

bool operator== (const AnimationAppRule &other) const noexcept
 
bool operator!= (const AnimationAppRule &other) const noexcept
 
QJsonObject toJson () const
 

Static Public Member Functions

static std::optional< AnimationAppRulefromJson (const QJsonObject &obj)
 Strict rule-level loader.
 

Public Attributes

QString classPattern
 Substring matched case-insensitively against EffectWindow::windowClass() (or the equivalent in the daemon path).
 
QString eventPath
 Animation event path from PhosphorAnimation::ProfilePaths::Window* (e.g.
 
Kind kind = Kind::Shader
 
QString effectId
 Shader effect id from the registry.
 
QVariantMap shaderParams
 Per-effect parameter map (same shape as the per-event tree).
 
QString curve
 Easing curve string in Profile's wire format ("x1,y1,x2,y2", "elastic-out:amp,per", "spring:omega,zeta", etc.).
 
int durationMs = 0
 Duration override in milliseconds.
 

Detailed Description

One per-window animation override entry.

Sits alongside the per-event ShaderProfileTree in the same org.plasmazones.settings config namespace. Where the tree provides a global default per event path (e.g. "every window-open uses pop-in"), an AnimationAppRule overrides that default for a specific window-class pattern (e.g. "firefox uses dissolve, but everything else stays pop-in").

Schema decisions (settled)

  • Per-event scope: each rule names one eventPath only. To override the same pattern across multiple events, write a separate rule per event.
  • Single-axis: each rule carries EITHER a Shader override OR a Timing override, not both. Override both for the same (pattern, eventPath) by writing two rules.
  • Substring, case-insensitive matching (mirrors snap App Rules).
  • First-match per axis (the resolver walks the list and returns the first matching rule whose kind matches the requested axis).
  • Empty effectId in a Shader rule = engaged-blocking sentinel: "no animation for this app on this event," winning over the per-event default.

Cascade

Resolution at window-event time is:

  1. AnimationAppRuleList::resolve{Shader,Timing}(windowClass, eventPath) — first matching rule of that axis. If hit, done.
  2. Settings::shaderProfileTree.resolve(eventPath) — the user's per-event override, if engaged.
  3. The library default (empty ShaderProfile).

The rule layer wins over the per-event override. If a user has configured both, they intended the per-app rule to take precedence on matching windows.

Member Enumeration Documentation

◆ Kind

Enumerator
Shader 

Override the shader effect (effectId + shaderParams)

Timing 

Override the motion curve (curve + durationMs)

Member Function Documentation

◆ fromJson()

static std::optional< AnimationAppRule > PhosphorAnimationShaders::AnimationAppRule::fromJson ( const QJsonObject &  obj)
static

Strict rule-level loader.

Returns nullopt when the JSON is missing required fields, names an unknown kind, or carries an empty classPattern / eventPath — none of which can produce a valid rule. Direct callers (tests, ad-hoc round-trips, future scripting hooks) get the same drop-on-malformed contract the list-level loader already applies, so a typo in kind can't silently materialise as an engaged-empty-effectId Shader rule that would block animations for matching windows.

The kind field is parsed case-insensitively on read (so "Shader", "shader", "SHADER" all map to Kind::Shader) and emitted lowercase via toJson — direct round-trip is stable for the canonical form, but hand-edited capitalised values normalise on first save.

The durationMs Timing-kind sentinel covers <= 0 — negative values are accepted on read but emit as the absent-key form via toJson, so a negative in-memory value will round-trip through disk as 0. Callers should normalise to 0 if they want strict equality across a save/load cycle.

◆ operator!=()

bool PhosphorAnimationShaders::AnimationAppRule::operator!= ( const AnimationAppRule other) const
inlinenoexcept

◆ operator==()

bool PhosphorAnimationShaders::AnimationAppRule::operator== ( const AnimationAppRule other) const
noexcept

◆ toJson()

QJsonObject PhosphorAnimationShaders::AnimationAppRule::toJson ( ) const

Member Data Documentation

◆ classPattern

QString PhosphorAnimationShaders::AnimationAppRule::classPattern

Substring matched case-insensitively against EffectWindow::windowClass() (or the equivalent in the daemon path).

Empty pattern matches nothing — the resolver short-circuits, so an accidentally-empty pattern can't accidentally swallow every window.

◆ curve

QString PhosphorAnimationShaders::AnimationAppRule::curve

Easing curve string in Profile's wire format ("x1,y1,x2,y2", "elastic-out:amp,per", "spring:omega,zeta", etc.).

Empty string means "use per-event default."

◆ durationMs

int PhosphorAnimationShaders::AnimationAppRule::durationMs = 0

Duration override in milliseconds.

Zero (or negative) means "use per-event default."

◆ effectId

QString PhosphorAnimationShaders::AnimationAppRule::effectId

Shader effect id from the registry.

Empty string means "engaged- blocking sentinel" — the rule disables the per-event default shader for matching windows without falling through to it.

◆ eventPath

QString PhosphorAnimationShaders::AnimationAppRule::eventPath

Animation event path from PhosphorAnimation::ProfilePaths::Window* (e.g.

"window.open", "window.close"). Exact equality match — rule only applies to the named event.

◆ kind

Kind PhosphorAnimationShaders::AnimationAppRule::kind = Kind::Shader

◆ shaderParams

QVariantMap PhosphorAnimationShaders::AnimationAppRule::shaderParams

Per-effect parameter map (same shape as the per-event tree).

Stored as QVariantMap so the JSON round-trip is straightforward; consumers translate via AnimationShaderRegistry::translateAnimationParams at resolution time.


The documentation for this struct was generated from the following file: