Phosphor
Qt6 / Wayland library suite for window-management tools
Loading...
Searching...
No Matches
MatchTypes.h File Reference
#include <QLatin1StringView>
#include <QSet>
#include <QString>
#include <QStringView>
#include <cmath>
#include <optional>

Go to the source code of this file.

Classes

struct  PhosphorRules::AspectRatioToken
 One entry of the Field::ScreenAspectRatio vocabulary: the token a rule compares against and the width-over-height ratio it stands for. More...
struct  PhosphorRules::FieldDescriptor
 Compile-time descriptor for one Field. More...

Namespaces

namespace  PhosphorRules
namespace  PhosphorRules::ModeToken
 The closed wire vocabulary of Field::Mode — the placement mode a window is in, or that a context resolves to.

Enumerations

enum class  PhosphorRules::Field : int {
  PhosphorRules::AppId = 0 , PhosphorRules::WindowClass = 1 , PhosphorRules::DesktopFile = 2 , PhosphorRules::WindowRole = 3 ,
  PhosphorRules::Pid = 4 , PhosphorRules::Title = 5 , PhosphorRules::WindowType = 6 , PhosphorRules::IsSticky = 7 ,
  PhosphorRules::IsFullscreen = 8 , PhosphorRules::IsMinimized = 9 , PhosphorRules::ScreenId = 10 , PhosphorRules::VirtualDesktop = 11 ,
  PhosphorRules::Activity = 12 , PhosphorRules::IsMaximized = 13 , PhosphorRules::IsFocused = 14 , PhosphorRules::IsTransient = 15 ,
  PhosphorRules::IsNotification = 16 , PhosphorRules::Width = 17 , PhosphorRules::Height = 18 , PhosphorRules::KeepAbove = 19 ,
  PhosphorRules::KeepBelow = 20 , PhosphorRules::SkipTaskbar = 21 , PhosphorRules::SkipPager = 22 , PhosphorRules::SkipSwitcher = 23 ,
  PhosphorRules::IsModal = 24 , PhosphorRules::HasDecoration = 25 , PhosphorRules::IsResizable = 26 , PhosphorRules::PositionX = 27 ,
  PhosphorRules::PositionY = 28 , PhosphorRules::CaptionNormal = 29 , PhosphorRules::IsFloating = 30 , PhosphorRules::IsSnapped = 31 ,
  PhosphorRules::Zone = 32 , PhosphorRules::IsTiled = 33 , PhosphorRules::Mode = 34 , PhosphorRules::TiledWindowCount = 35 ,
  PhosphorRules::IsMovable = 36 , PhosphorRules::IsMaximizable = 37 , PhosphorRules::ScreenOrientation = 38 , PhosphorRules::ActiveLayout = 39 ,
  PhosphorRules::ColorScheme = 40 , PhosphorRules::ScreenWidth = 41 , PhosphorRules::ScreenHeight = 42 , PhosphorRules::ScreenAspectRatio = 43
}
 Match fields. More...
enum class  PhosphorRules::FieldType : int { PhosphorRules::String , PhosphorRules::Bool , PhosphorRules::Int , PhosphorRules::Enum }
 Value-kind of a field's payload in a WindowQuery. More...
enum class  PhosphorRules::FieldSource : int { PhosphorRules::Window , PhosphorRules::Context }
 Whether a field is a window property or a context attribute. More...
enum class  PhosphorRules::Operator : int {
  PhosphorRules::Equals = 0 , PhosphorRules::Contains = 1 , PhosphorRules::StartsWith = 2 , PhosphorRules::EndsWith = 3 ,
  PhosphorRules::Regex = 4 , PhosphorRules::AppIdMatches = 5 , PhosphorRules::GreaterThan = 6 , PhosphorRules::LessThan = 7
}
 Match operators. More...

Functions

QString PhosphorRules::aspectRatioTokenFor (int width, int height)
 The Field::ScreenAspectRatio token for a width x height screen: the vocabulary entry whose ratio is nearest, measured on a log scale so a portrait screen and its landscape twin sit the same distance from their tokens.
QString PhosphorRules::orientationTokenFor (int width, int height)
 The Field::ScreenOrientation token for a width x height screen: "portrait" when it is taller than wide and "landscape" otherwise, so a square screen is landscape.
const QSet< Field > & PhosphorRules::windowSourcedFields ()
 Every Window-sourced field, derived from the table so a new field can never silently miss it.
consteval bool PhosphorRules::verifyFieldTableOrder ()
QString PhosphorRules::fieldToString (Field field)
 Canonical lowercase wire string for a Field.
std::optional< Field > PhosphorRules::fieldFromString (QStringView s)
 Strict parse: an unknown token returns nullopt so the loader can drop the malformed predicate rather than silently coercing typos to a default.
bool PhosphorRules::fieldIsString (Field field)
 True if field carries a string value (the four string operators and Regex apply to these; numeric/bool fields do not).
bool PhosphorRules::fieldIsNumeric (Field field)
 True if field carries a numeric value.
bool PhosphorRules::fieldIsBool (Field field)
 True if field carries a boolean value (window-state flags).
bool PhosphorRules::fieldIsContext (Field field)
 True if field describes the context a window appears in (screen / virtual desktop / activity / placement mode / tiled-window count / screen orientation / active layout / colour scheme / screen width, height and aspect ratio) rather than a property of the window itself.
QString PhosphorRules::operatorToString (Operator op)
 Canonical lowercase wire string for an Operator.
std::optional< Operator > PhosphorRules::operatorFromString (QStringView s)
 Strict parse: an unknown token returns nullopt.

Variables

constexpr int PhosphorRules::FieldCount = static_cast<int>(Field::ScreenAspectRatio) + 1
 The number of distinct Field enumerators.
constexpr QLatin1StringView PhosphorRules::ModeToken::Snapping {"snapping"}
constexpr QLatin1StringView PhosphorRules::ModeToken::Tiling {"tiling"}
 autotile OR scrolling-engine tiling
constexpr QLatin1StringView PhosphorRules::ModeToken::Scrolling {"scrolling"}
constexpr QLatin1StringView PhosphorRules::kModeTokens []
 The complete Field::Mode vocabulary, for callers that validate or enumerate it (a settings picker, a boundary check on a hand-edited value).
constexpr AspectRatioToken PhosphorRules::kAspectRatioTokens []
 The complete Field::ScreenAspectRatio vocabulary, landscape first and then the portrait forms a rotated monitor reports.
constexpr FieldDescriptor PhosphorRules::kFieldTable []
 The master field table — indexed by static_cast<int>(field).
constexpr int PhosphorRules::OperatorCount = static_cast<int>(Operator::LessThan) + 1
 The number of distinct Operator enumerators.