KWin
Loading...
Searching...
No Matches
wayland_output.h
Go to the documentation of this file.
1/*
2 KWin - the KDE window manager
3 This file is part of the KDE project.
4
5 SPDX-FileCopyrightText: 2019 Roman Gilg <subdiff@gmail.com>
6
7 SPDX-License-Identifier: GPL-2.0-or-later
8*/
9#pragma once
10
11#include "core/output.h"
12
13#include <KWayland/Client/xdgshell.h>
14
15#include <QObject>
16#include <QTimer>
17
18namespace KWayland
19{
20namespace Client
21{
22class Surface;
23class Pointer;
24class LockedPointer;
25class XdgDecoration;
26}
27}
28
29struct wl_buffer;
30
31namespace KWin
32{
33class OutputFrame;
34
35namespace Wayland
36{
37class WaylandBackend;
38
40{
41public:
42 explicit WaylandCursor(WaylandBackend *backend);
44
45 KWayland::Client::Pointer *pointer() const;
46 void setPointer(KWayland::Client::Pointer *pointer);
47
48 void setEnabled(bool enable);
49 void update(wl_buffer *buffer, qreal scale, const QPoint &hotspot);
50
51private:
52 void sync();
53
54 KWayland::Client::Pointer *m_pointer = nullptr;
55 std::unique_ptr<KWayland::Client::Surface> m_surface;
56 wl_buffer *m_buffer = nullptr;
57 QPoint m_hotspot;
58 qreal m_scale = 1;
59 bool m_enabled = true;
60};
61
62class WaylandOutput : public Output
63{
64 Q_OBJECT
65public:
66 WaylandOutput(const QString &name, WaylandBackend *backend);
67 ~WaylandOutput() override;
68
69 RenderLoop *renderLoop() const override;
70 bool updateCursorLayer() override;
71
72 void init(const QSize &pixelSize, qreal scale);
73
74 bool isReady() const;
75 KWayland::Client::Surface *surface() const;
76 WaylandCursor *cursor() const;
77 WaylandBackend *backend() const;
78
79 void lockPointer(KWayland::Client::Pointer *pointer, bool lock);
80 void resize(const QSize &pixelSize);
81 void setDpmsMode(DpmsMode mode) override;
83 void updateEnabled(bool enabled);
84
85 void framePending(const std::shared_ptr<OutputFrame> &frame);
86
87private:
88 void handleConfigure(const QSize &size, KWayland::Client::XdgShellSurface::States states, quint32 serial);
89 void updateWindowTitle();
90 void applyConfigure(const QSize &size, quint32 serial);
91
92 std::unique_ptr<RenderLoop> m_renderLoop;
93 std::unique_ptr<KWayland::Client::Surface> m_surface;
94 std::unique_ptr<KWayland::Client::XdgShellSurface> m_xdgShellSurface;
95 std::unique_ptr<KWayland::Client::LockedPointer> m_pointerLock;
96 std::unique_ptr<KWayland::Client::XdgDecoration> m_xdgDecoration;
97 WaylandBackend *const m_backend;
98 std::unique_ptr<WaylandCursor> m_cursor;
99 QTimer m_turnOffTimer;
100 bool m_hasPointerLock = false;
101 bool m_ready = false;
102 std::shared_ptr<OutputFrame> m_frame;
103 quint32 m_pendingConfigureSerial = 0;
104 QSize m_pendingConfigureSize;
105 QTimer m_configureThrottleTimer;
106};
107
108} // namespace Wayland
109} // namespace KWin
The Client class encapsulates a window decoration frame.
qreal scale() const
Definition output.cpp:455
QString name
Definition output.h:136
QSize pixelSize() const
Definition output.cpp:485
DpmsMode dpmsMode() const
Definition output.cpp:647
Class encapsulating all Wayland data structures needed by the Egl backend.
KWayland::Client::Pointer * pointer() const
WaylandCursor(WaylandBackend *backend)
void update(wl_buffer *buffer, qreal scale, const QPoint &hotspot)
void setPointer(KWayland::Client::Pointer *pointer)
void lockPointer(KWayland::Client::Pointer *pointer, bool lock)
void init(const QSize &pixelSize, qreal scale)
WaylandCursor * cursor() const
void resize(const QSize &pixelSize)
void framePending(const std::shared_ptr< OutputFrame > &frame)
WaylandBackend * backend() const
void updateDpmsMode(DpmsMode dpmsMode)
void setDpmsMode(DpmsMode mode) override
WaylandOutput(const QString &name, WaylandBackend *backend)
RenderLoop * renderLoop() const override
KWayland::Client::Surface * surface() const