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, orientation) —
26 // the SAME (screen, desktop, activity) resolves DIFFERENT gaps per
27 // placement mode, active layout, and screen orientation.
28 // - lock / default-assignment / overlay: contextCacheKeyToken with an
29 // empty mode (they are mode-agnostic) plus activeLayout (except
30 // default-assignment, which omits it to avoid recursion) and orientation.
31 // - assignment resolver: "twc:N|or:<token>" — the tiled-window-count and
32 // the screen orientation (it does not read the active layout).
33 // Each resolver owns its own cache hash, so the token vocabularies never
34 // collide.
35 QString mode;
36 bool operator==(const ContextResolveKey& other) const noexcept
37 {
38 return virtualDesktop == other.virtualDesktop && screenId == other.screenId && activity == other.activity
39 && mode == other.mode;
40 }
41};
42
43inline size_t qHash(const ContextResolveKey& key, size_t seed = 0) noexcept
44{
45 // ::qHash routes to the global Qt qHash overloads. The qualifier is
46 // required because of SELF-HIDING: unqualified lookup inside this very
47 // qHash overload finds the PhosphorZones::qHash being defined, stops
48 // there, and never reaches the global QString/int overloads. Mirrors
49 // the same pattern LayoutAssignmentKey uses.
50 size_t h = seed;
51 h = ::qHash(key.screenId, h);
52 h = ::qHash(key.virtualDesktop, h);
53 h = ::qHash(key.activity, h);
54 h = ::qHash(key.mode, h);
55 return h;
56}
57
58} // namespace PhosphorZones
Definition IWindowTrackingService.h:23
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:35
bool operator==(const ContextResolveKey &other) const noexcept
Definition ContextResolveKey.h:36
int virtualDesktop
Definition ContextResolveKey.h:19
QString screenId
Definition ContextResolveKey.h:18
QString activity
Definition ContextResolveKey.h:20