Phosphor
Qt6 / Wayland library suite for window-management tools
Loading...
Searching...
No Matches
ContextResolveKey.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 fuddlesworth
2// SPDX-License-Identifier: LGPL-2.1-or-later
3
4#pragma once
5
6#include <QHash>
7#include <QString>
8
9namespace PhosphorZones {
10
17{
18 QString screenId;
20 QString activity;
21 // A free-form fourth key dimension, used by the context resolvers that
22 // share the ContextResolveKey type but never the same cache container. It
23 // folds in every non-rule-set input the resolved value depends on, so a
24 // change in one yields a fresh entry rather than a stale hit:
25 // - gap cascade: contextCacheKeyToken(mode, activeLayout, shape, scheme) —
26 // the SAME (screen, desktop, activity) resolves DIFFERENT gaps per
27 // placement mode, active layout, screen shape (orientation and
28 // device-pixel size) and colour scheme.
29 // - lock / default-assignment / OSD / drag-selector / overlay:
30 // contextCacheKeyToken with an empty mode (they are mode-agnostic) plus
31 // activeLayout (except default-assignment, which omits it to avoid
32 // recursion), the screen shape and the colour scheme.
33 // - assignment resolver: "twc:N|or:<token>|sz:WxH|cs:<token>" — the
34 // tiled-window count, the screen shape and the colour scheme (it does
35 // not read the active layout).
36 // Each resolver owns its own cache hash, so the token vocabularies never
37 // collide.
38 QString mode;
39 bool operator==(const ContextResolveKey& other) const noexcept
40 {
41 return virtualDesktop == other.virtualDesktop && screenId == other.screenId && activity == other.activity
42 && mode == other.mode;
43 }
44};
45
46inline size_t qHash(const ContextResolveKey& key, size_t seed = 0) noexcept
47{
48 // ::qHash routes to the global Qt qHash overloads. The qualifier is
49 // required because of SELF-HIDING: unqualified lookup inside this very
50 // qHash overload finds the PhosphorZones::qHash being defined, stops
51 // there, and never reaches the global QString/int overloads. Mirrors
52 // the same pattern LayoutAssignmentKey uses.
53 size_t h = seed;
54 h = ::qHash(key.screenId, h);
55 h = ::qHash(key.virtualDesktop, h);
56 h = ::qHash(key.activity, h);
57 h = ::qHash(key.mode, h);
58 return h;
59}
60
61} // namespace PhosphorZones
Definition IWindowTrackingService.h:24
size_t qHash(const LayoutAssignmentKey &key, size_t seed=0)
Definition AssignmentEntry.h:87
Lookup key for the LayoutRegistry context-resolver caches.
Definition ContextResolveKey.h:17
QString mode
Definition ContextResolveKey.h:38
bool operator==(const ContextResolveKey &other) const noexcept
Definition ContextResolveKey.h:39
int virtualDesktop
Definition ContextResolveKey.h:19
QString screenId
Definition ContextResolveKey.h:18
QString activity
Definition ContextResolveKey.h:20