KWin
Loading...
Searching...
No Matches
xdgshellwindow.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: 2015 Martin Gräßlin <mgraesslin@kde.org>
6 SPDX-FileCopyrightText: 2018 David Edmundson <davidedmundson@kde.org>
7 SPDX-FileCopyrightText: 2019 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
8
9 SPDX-License-Identifier: GPL-2.0-or-later
10*/
11
12#pragma once
13
14#include "wayland/xdgshell.h"
15#include "waylandwindow.h"
16
17#include <QQueue>
18#include <QTimer>
19
20#include <optional>
21
22namespace KWin
23{
24
25class AppMenuInterface;
26class KillPrompt;
27class PlasmaShellSurfaceInterface;
28class ServerSideDecorationInterface;
29class ServerSideDecorationPaletteInterface;
30class XdgToplevelDecorationV1Interface;
31class Output;
32
34{
35public:
37 {
38 }
39
43 Q_DECLARE_FLAGS(ConfigureFlags, ConfigureFlag)
44
45 QRectF bounds;
47 qreal serial;
48 ConfigureFlags flags;
49};
50
52{
53 Q_OBJECT
54
55public:
56 explicit XdgSurfaceWindow(XdgSurfaceInterface *shellSurface);
57 ~XdgSurfaceWindow() override;
58
59 NET::WindowType windowType() const override;
60 QRectF frameRectToBufferRect(const QRectF &rect) const override;
61 void destroyWindow() override;
62
63 void installPlasmaShellSurface(PlasmaShellSurfaceInterface *shellSurface);
64
65protected:
66 void moveResizeInternal(const QRectF &rect, MoveResizeMode mode) override;
67
69 virtual void handleRoleCommit();
70 virtual void handleRolePrecommit();
71 virtual void handleRoleDestroyed();
72
73 XdgSurfaceConfigure *lastAcknowledgedConfigure() const;
74 void scheduleConfigure();
75 void sendConfigure();
76
77 QPointer<PlasmaShellSurfaceInterface> m_plasmaShellSurface;
78
79 NET::WindowType m_windowType = NET::Normal;
80 Gravity m_nextGravity = Gravity::None;
81
82private:
83 void handleConfigureAcknowledged(quint32 serial);
84 void handleCommit();
85 void handleNextWindowGeometry();
86 bool haveNextWindowGeometry() const;
87 void setHaveNextWindowGeometry();
88 void resetHaveNextWindowGeometry();
89 void maybeUpdateMoveResizeGeometry(const QRectF &rect);
90
91 XdgSurfaceInterface *m_shellSurface;
92 QTimer *m_configureTimer;
93 XdgSurfaceConfigure::ConfigureFlags m_configureFlags;
94 QQueue<XdgSurfaceConfigure *> m_configureEvents;
95 std::unique_ptr<XdgSurfaceConfigure> m_lastAcknowledgedConfigure;
96 std::optional<quint32> m_lastAcknowledgedConfigureSerial;
97 QRectF m_windowGeometry;
98 bool m_haveNextWindowGeometry = false;
99};
100
102{
103public:
104 std::shared_ptr<KDecoration2::Decoration> decoration;
105 XdgToplevelInterface::States states;
106};
107
109{
110 Q_OBJECT
111
112 enum class PingReason {
113 CloseWindow,
114 FocusWindow,
115 };
116
117 enum class DecorationMode {
118 None,
119 Client,
120 Server,
121 };
122
123public:
124 explicit XdgToplevelWindow(XdgToplevelInterface *shellSurface);
125 ~XdgToplevelWindow() override;
126
127 XdgToplevelInterface *shellSurface() const;
128
129 MaximizeMode maximizeMode() const override;
130 MaximizeMode requestedMaximizeMode() const override;
131 QSizeF minSize() const override;
132 QSizeF maxSize() const override;
133 bool isFullScreen() const override;
134 bool isRequestedFullScreen() const override;
135 bool isMovableAcrossScreens() const override;
136 bool isMovable() const override;
137 bool isResizable() const override;
138 bool isCloseable() const override;
139 bool isFullScreenable() const override;
140 bool isMaximizable() const override;
141 bool isMinimizable() const override;
142 bool isPlaceable() const override;
143 bool isTransient() const override;
144 bool userCanSetNoBorder() const override;
145 bool noBorder() const override;
146 void setNoBorder(bool set) override;
147 void invalidateDecoration() override;
148 QString preferredColorScheme() const override;
149 bool supportsWindowRules() const override;
150 void applyWindowRules() override;
151 bool takeFocus() override;
152 bool wantsInput() const override;
153 bool dockWantsInput() const override;
154 void setFullScreen(bool set) override;
155 void closeWindow() override;
156 void maximize(MaximizeMode mode) override;
157
158 void installAppMenu(AppMenuInterface *appMenu);
159 void installServerDecoration(ServerSideDecorationInterface *decoration);
160 void installPalette(ServerSideDecorationPaletteInterface *palette);
161 void installXdgDecoration(XdgToplevelDecorationV1Interface *decoration);
162
163protected:
164 XdgSurfaceConfigure *sendRoleConfigure() const override;
165 void handleRoleCommit() override;
166 void handleRolePrecommit() override;
167 void handleRoleDestroyed() override;
168 void doMinimize() override;
169 void doInteractiveResizeSync(const QRectF &rect) override;
170 void doSetActive() override;
171 void doSetFullScreen();
172 void doSetMaximized();
173 bool doStartInteractiveMoveResize() override;
174 void doFinishInteractiveMoveResize() override;
175 bool acceptsFocus() const override;
176 void doSetQuickTileMode() override;
177 void doSetSuspended() override;
178
179private:
180 void handleWindowTitleChanged();
181 void handleWindowClassChanged();
182 void handleWindowMenuRequested(SeatInterface *seat,
183 const QPoint &surfacePos, quint32 serial);
184 void handleMoveRequested(SeatInterface *seat, quint32 serial);
185 void handleResizeRequested(SeatInterface *seat, XdgToplevelInterface::ResizeAnchor anchor, quint32 serial);
186 void handleStatesAcknowledged(const XdgToplevelInterface::States &states);
187 void handleMaximizeRequested();
188 void handleUnmaximizeRequested();
189 void handleFullscreenRequested(OutputInterface *output);
190 void handleUnfullscreenRequested();
191 void handleMinimizeRequested();
192 void handleTransientForChanged();
193 void handleForeignTransientForChanged(SurfaceInterface *child);
194 void handlePingTimeout(quint32 serial);
195 void handlePingDelayed(quint32 serial);
196 void handlePongReceived(quint32 serial);
197 void handleMaximumSizeChanged();
198 void handleMinimumSizeChanged();
199 void initialize();
200 void updateMaximizeMode(MaximizeMode maximizeMode);
201 void updateFullScreenMode(bool set);
202 void sendPing(PingReason reason);
203 MaximizeMode initialMaximizeMode() const;
204 bool initialFullScreenMode() const;
205 DecorationMode preferredDecorationMode() const;
206 void configureDecoration();
207 void configureXdgDecoration(DecorationMode decorationMode);
208 void configureServerDecoration(DecorationMode decorationMode);
209 void clearDecoration();
210 void updateCapabilities();
211
212 QPointer<AppMenuInterface> m_appMenuInterface;
213 QPointer<ServerSideDecorationPaletteInterface> m_paletteInterface;
214 QPointer<ServerSideDecorationInterface> m_serverDecoration;
215 QPointer<XdgToplevelDecorationV1Interface> m_xdgDecoration;
216 XdgToplevelInterface *m_shellSurface;
217 XdgToplevelInterface::States m_nextStates;
218 XdgToplevelInterface::States m_acknowledgedStates;
219 XdgToplevelInterface::States m_initialStates;
220 XdgToplevelInterface::Capabilities m_capabilities;
221 QMap<quint32, PingReason> m_pings;
222 MaximizeMode m_maximizeMode = MaximizeRestore;
223 MaximizeMode m_requestedMaximizeMode = MaximizeRestore;
224 bool m_isFullScreen = false;
225 bool m_isRequestedFullScreen = false;
226 bool m_isInitialized = false;
227 bool m_userNoBorder = false;
228 bool m_isTransient = false;
229 QPointer<Output> m_fullScreenRequestedOutput;
230 std::shared_ptr<KDecoration2::Decoration> m_nextDecoration;
231 std::unique_ptr<KillPrompt> m_killPrompt;
232};
233
235{
236 Q_OBJECT
237
238public:
239 explicit XdgPopupWindow(XdgPopupInterface *shellSurface);
240 ~XdgPopupWindow() override;
241
242 bool hasPopupGrab() const override;
243 void popupDone() override;
244 bool isPopupWindow() const override;
245 bool isTransient() const override;
246 bool isResizable() const override;
247 bool isMovable() const override;
248 bool isMovableAcrossScreens() const override;
249 bool hasTransientPlacementHint() const override;
250 QRectF transientPlacement() const override;
251 bool isCloseable() const override;
252 void closeWindow() override;
253 bool wantsInput() const override;
254 bool takeFocus() override;
255
256protected:
257 bool acceptsFocus() const override;
258 XdgSurfaceConfigure *sendRoleConfigure() const override;
259 void handleRoleDestroyed() override;
260
261private:
262 void handleGrabRequested(SeatInterface *seat, quint32 serial);
263 void handleRepositionRequested(quint32 token);
264 void initialize();
265 void updateRelativePlacement();
266 void relayout();
267
268 XdgPopupInterface *m_shellSurface;
269 bool m_haveExplicitGrab = false;
270 QRectF m_relativePlacement;
271};
272
273} // namespace KWin
274
275Q_DECLARE_OPERATORS_FOR_FLAGS(KWin::XdgSurfaceConfigure::ConfigureFlags)
The Client class encapsulates a window decoration frame.
Resource for the org_kde_plasma_shell_surface interface.
Definition plasmashell.h:60
Represents a Seat on the Wayland Display.
Definition seat.h:134
Representing how a SurfaceInterface should be decorated.
Resource representing a wl_surface.
Definition surface.h:80
virtual XdgSurfaceConfigure * sendRoleConfigure() const =0
QPointer< PlasmaShellSurfaceInterface > m_plasmaShellSurface
std::shared_ptr< KDecoration2::Decoration > decoration
XdgToplevelInterface::States states
Gravity
Definition globals.h:150
MaximizeMode
Definition common.h:74
@ MaximizeRestore
The window is not maximized in any direction.
Definition common.h:75