Changeset View
Changeset View
Standalone View
Standalone View
plugins/platforms/wayland/wayland_output.h
- This file was added.
1 | /******************************************************************** | ||||
---|---|---|---|---|---|
2 | KWin - the KDE window manager | ||||
3 | This file is part of the KDE project. | ||||
4 | | ||||
5 | Copyright 2019 Roman Gilg <subdiff@gmail.com> | ||||
6 | | ||||
7 | This program is free software; you can redistribute it and/or modify | ||||
8 | it under the terms of the GNU General Public License as published by | ||||
9 | the Free Software Foundation; either version 2 of the License, or | ||||
10 | (at your option) any later version. | ||||
11 | | ||||
12 | This program is distributed in the hope that it will be useful, | ||||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
15 | GNU General Public License for more details. | ||||
16 | | ||||
17 | You should have received a copy of the GNU General Public License | ||||
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
19 | *********************************************************************/ | ||||
20 | #ifndef KWIN_WAYLAND_OUTPUT_H | ||||
21 | #define KWIN_WAYLAND_OUTPUT_H | ||||
22 | | ||||
23 | #include "abstract_output.h" | ||||
24 | | ||||
25 | #include <KWayland/Client/xdgshell.h> | ||||
26 | | ||||
27 | #include <QObject> | ||||
28 | | ||||
29 | namespace KWayland | ||||
30 | { | ||||
31 | namespace Client | ||||
32 | { | ||||
33 | class Surface; | ||||
34 | | ||||
35 | class Shell; | ||||
36 | class ShellSurface; | ||||
37 | | ||||
38 | class Pointer; | ||||
39 | class LockedPointer; | ||||
40 | } | ||||
41 | } | ||||
42 | | ||||
43 | namespace KWin | ||||
44 | { | ||||
45 | namespace Wayland | ||||
46 | { | ||||
47 | class WaylandBackend; | ||||
48 | | ||||
49 | class WaylandOutput : public AbstractOutput | ||||
50 | { | ||||
51 | Q_OBJECT | ||||
52 | public: | ||||
53 | explicit WaylandOutput(KWayland::Client::Surface *surface, QObject *parent = nullptr); | ||||
54 | ~WaylandOutput(); | ||||
55 | | ||||
56 | virtual void lockPointer(KWayland::Client::Pointer *pointer, bool lock) { | ||||
57 | Q_UNUSED(pointer) | ||||
58 | Q_UNUSED(lock) | ||||
59 | } | ||||
60 | | ||||
61 | virtual bool pointerIsLocked() { return false; } | ||||
62 | | ||||
63 | QSize pixelSize() const override; | ||||
64 | | ||||
65 | /** | ||||
66 | * @brief defines the geometry of the output | ||||
67 | * @param logicalPosition top left position of the output in compositor space | ||||
68 | * @param pixelSize output size as seen from the outside | ||||
69 | */ | ||||
70 | void setGeometry(const QPoint &logicalPosition, const QSize &pixelSize); | ||||
71 | | ||||
72 | KWayland::Client::Surface* surface() const { | ||||
73 | return m_surface; | ||||
74 | } | ||||
75 | | ||||
76 | bool rendered() const { | ||||
77 | return m_rendered; | ||||
78 | } | ||||
79 | void resetRendered() { | ||||
80 | m_rendered = false; | ||||
81 | } | ||||
82 | | ||||
83 | Q_SIGNALS: | ||||
84 | void sizeChanged(const QSize &size); | ||||
85 | void frameRendered(); | ||||
86 | | ||||
87 | private: | ||||
88 | KWayland::Client::Surface *m_surface; | ||||
89 | | ||||
90 | QSize m_pixelSize; | ||||
91 | bool m_rendered = false; | ||||
92 | }; | ||||
93 | | ||||
94 | class ShellOutput : public WaylandOutput | ||||
95 | { | ||||
96 | public: | ||||
97 | ShellOutput(KWayland::Client::Surface *surface, | ||||
98 | KWayland::Client::Shell *shell, | ||||
99 | WaylandBackend *backend); | ||||
100 | ~ShellOutput(); | ||||
101 | | ||||
102 | private: | ||||
103 | KWayland::Client::ShellSurface *m_shellSurface = nullptr; | ||||
104 | }; | ||||
105 | | ||||
106 | class XdgShellOutput : public WaylandOutput | ||||
107 | { | ||||
108 | public: | ||||
109 | XdgShellOutput(KWayland::Client::Surface *surface, | ||||
110 | KWayland::Client::XdgShell *xdgShell, | ||||
111 | WaylandBackend *backend, int number); | ||||
112 | ~XdgShellOutput(); | ||||
113 | | ||||
114 | void lockPointer(KWayland::Client::Pointer *pointer, bool lock) override; | ||||
115 | | ||||
116 | private: | ||||
117 | void handleConfigure(const QSize &size, KWayland::Client::XdgShellSurface::States states, quint32 serial); | ||||
118 | void updateWindowTitle(); | ||||
119 | | ||||
120 | KWayland::Client::XdgShellSurface *m_xdgShellSurface = nullptr; | ||||
121 | WaylandBackend *m_backend; | ||||
122 | int m_number; | ||||
123 | KWayland::Client::LockedPointer *m_pointerLock = nullptr; | ||||
124 | bool m_hasPointerLock = false; | ||||
125 | }; | ||||
126 | | ||||
127 | } | ||||
128 | } | ||||
129 | | ||||
130 | #endif |