Phosphor
Qt6 / Wayland library suite for window-management tools
 
Loading...
Searching...
No Matches
NoOpPanelSource.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 "IPanelSource.h"
7#include "phosphorscreenscore_export.h"
8
9#include <QGuiApplication>
10#include <QScreen>
11#include <QTimer>
12
13namespace Phosphor::Screens {
14
26class PHOSPHORSCREENSCORE_EXPORT NoOpPanelSource final : public IPanelSource
27{
28 Q_OBJECT
29public:
30 explicit NoOpPanelSource(QObject* parent = nullptr)
31 : IPanelSource(parent)
32 {
33 }
34
35 void start() override
36 {
37 // Synthetic per-screen fan-out mirrors PlasmaPanelSource's first-ready
38 // behaviour so consumers wired only to panelOffsetsChanged (rather
39 // than ScreenManager::panelGeometryReady) still get a recompute kick
40 // on non-KDE hosts. Zero offsets are reported via currentOffsets().
41 if (qGuiApp) {
42 const auto screens = QGuiApplication::screens();
43 for (auto* s : screens) {
44 Q_EMIT panelOffsetsChanged(s);
45 }
46 }
47 Q_EMIT requeryCompleted();
48 }
49 void stop() override
50 {
51 }
52 Offsets currentOffsets(QScreen*) const override
53 {
54 return {};
55 }
56 bool ready() const override
57 {
58 return true;
59 }
60 void requestRequery(int delayMs = 0) override
61 {
62 // Honour the caller's delay so "wait for panel editor to settle"
63 // timing is consistent across IPanelSource implementations —
64 // PlasmaPanelSource's timer-path delays its completion signal, and
65 // callers that pass a positive delayMs expect that behaviour
66 // regardless of host desktop. 0/negative stays synchronous
67 // (matches the IPanelSource::requestRequery contract).
68 if (delayMs <= 0) {
69 Q_EMIT requeryCompleted();
70 return;
71 }
72 QTimer::singleShot(delayMs, this, [this]() {
73 Q_EMIT requeryCompleted();
74 });
75 }
76};
77
78} // namespace Phosphor::Screens
Pluggable producer of panel-reservation offsets per screen.
Definition IPanelSource.h:33
Trivial IPanelSource that reports zero offsets and ready=true.
Definition NoOpPanelSource.h:27
bool ready() const override
Has any successful query landed? Drives ScreenManager's panelGeometryReady one-shot signal — consumer...
Definition NoOpPanelSource.h:56
void start() override
Begin watching.
Definition NoOpPanelSource.h:35
NoOpPanelSource(QObject *parent=nullptr)
Definition NoOpPanelSource.h:30
Offsets currentOffsets(QScreen *) const override
Snapshot for a given screen.
Definition NoOpPanelSource.h:52
void requestRequery(int delayMs=0) override
Best-effort: ask the backend to re-query immediately, optionally after a short delay (e....
Definition NoOpPanelSource.h:60
void stop() override
Stop watching.
Definition NoOpPanelSource.h:49
Definition IWindowTrackingService.h:26
Per-edge reserved geometry, in physical pixels relative to the screen's top-left.
Definition IPanelSource.h:40