KWin
Loading...
Searching...
No Matches
surface.h
Go to the documentation of this file.
1/*
2 SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
3 SPDX-FileCopyrightText: 2020 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
4
5 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
6*/
7#pragma once
8
9#include "core/colorspace.h"
10#include "core/output.h"
11#include "core/renderbackend.h"
12
13#include <QObject>
14#include <QRegion>
15
16struct wl_resource;
17
18namespace KWin
19{
20
21class GraphicsBuffer;
22class BlurInterface;
23class ClientConnection;
24class ConfinedPointerV1Interface;
25class ContrastInterface;
26class CompositorInterface;
27class LinuxDmaBufV1Feedback;
28class LockedPointerV1Interface;
29class OutputInterface;
30class ShadowInterface;
31class SlideInterface;
32class SubSurfaceInterface;
33class SurfaceInterfacePrivate;
34class Transaction;
35
39class KWIN_EXPORT SurfaceRole
40{
41public:
42 explicit SurfaceRole(const QByteArray &name);
43
47 QByteArray name() const;
48
49private:
50 QByteArray m_name;
51};
52
79class KWIN_EXPORT SurfaceInterface : public QObject
80{
81 Q_OBJECT
85 Q_PROPERTY(QRegion opaque READ opaque NOTIFY opaqueChanged)
89 Q_PROPERTY(QRegion input READ input NOTIFY inputChanged)
90 Q_PROPERTY(QSizeF size READ size NOTIFY sizeChanged)
91public:
92 explicit SurfaceInterface(CompositorInterface *compositor, wl_resource *resource);
93 ~SurfaceInterface() override;
94
98 uint32_t id() const;
102 ClientConnection *client() const;
106 wl_resource *resource() const;
110 CompositorInterface *compositor() const;
111
117 SurfaceRole *role() const;
118 void setRole(SurfaceRole *role);
119
126 QPointF mapToChild(SurfaceInterface *child, const QPointF &point) const;
127
128 void frameRendered(quint32 msec);
129 bool hasFrameCallbacks() const;
130
131 std::unique_ptr<PresentationFeedback> takePresentationFeedback(Output *output);
132
133 QRegion opaque() const;
134 QRegion input() const;
135 QRegion bufferDamage() const;
136 QRectF bufferSourceBox() const;
144 OutputTransform bufferTransform() const;
148 GraphicsBuffer *buffer() const;
149 QPoint offset() const;
156 QSizeF size() const;
162 QRectF boundingRect() const;
168 QSize bufferSize() const;
169
173 SubSurfaceInterface *subSurface() const;
178 QList<SubSurfaceInterface *> below() const;
183 QList<SubSurfaceInterface *> above() const;
184
188 ShadowInterface *shadow() const;
189
193 BlurInterface *blur() const;
194
198 SlideInterface *slideOnShowHide() const;
199
203 ContrastInterface *contrast() const;
204
213 bool isMapped() const;
214
226 SurfaceInterface *surfaceAt(const QPointF &position);
227
240 SurfaceInterface *inputSurfaceAt(const QPointF &position);
241
250 void setOutputs(const QList<OutputInterface *> &outputs, OutputInterface *primaryOutput);
251
256 QList<OutputInterface *> outputs() const;
257
262 ConfinedPointerV1Interface *confinedPointer() const;
263
268 LockedPointerV1Interface *lockedPointer() const;
269
274 bool inhibitsIdle() const;
275
279 LinuxDmaBufV1Feedback *dmabufFeedbackV1() const;
280
284 ContentType contentType() const;
285
289 static SurfaceInterface *get(wl_resource *native);
293 static SurfaceInterface *get(quint32 id, const ClientConnection *client);
294
298 qreal scaleOverride() const;
303 QPoint toSurfaceLocal(const QPoint &point) const;
308 QPointF toSurfaceLocal(const QPointF &point) const;
309
313 PresentationModeHint presentationModeHint() const;
314
319 void setPreferredBufferScale(qreal scale);
320
327 void setPreferredBufferTransform(OutputTransform transform);
328
332 Transaction *firstTransaction() const;
333 void setFirstTransaction(Transaction *transaction);
334
338 Transaction *lastTransaction() const;
339 void setLastTransaction(Transaction *transaction);
340
341 const ColorDescription &colorDescription() const;
342
343 void setPreferredColorDescription(const ColorDescription &descr);
344
348 void traverseTree(std::function<void(SurfaceInterface *surface)> callback);
349
350Q_SIGNALS:
360 void aboutToBeDestroyed();
369 void damaged(const QRegion &);
370 void opaqueChanged(const QRegion &);
371 void inputChanged(const QRegion &);
375 void bufferTransformChanged(KWin::OutputTransform);
376 void bufferSourceBoxChanged();
380 void bufferSizeChanged();
384 void mapped();
388 void unmapped();
392 void sizeChanged();
393 void shadowChanged();
394 void blurChanged();
395 void slideOnShowHideChanged();
396 void contrastChanged();
400 void childSubSurfaceAdded(SubSurfaceInterface *subSurface);
404 void childSubSurfaceRemoved(SubSurfaceInterface *subSurface);
408 void childSubSurfacesChanged();
409
419 void pointerConstraintsChanged();
420
425 void inhibitsIdleChanged();
426
427 void colorDescriptionChanged();
428 void presentationModeHintChanged();
429
436 void committed();
437
442 void stateStashed(quint32 serial);
443
448 void stateApplied(quint32 serial);
449
450private:
451 std::unique_ptr<SurfaceInterfacePrivate> d;
453};
454
459template<typename Commit>
460class SurfaceExtension : public QObject
461{
462public:
464 {
465 connect(surface, &SurfaceInterface::stateStashed, this, &SurfaceExtension::stashState);
466 connect(surface, &SurfaceInterface::stateApplied, this, &SurfaceExtension::applyState);
467 }
468
469 virtual void apply(Commit *commit) = 0;
470
471 Commit pending;
472 QMap<quint32, Commit> stashed;
473
474private:
475 void stashState(quint32 serial)
476 {
477 Commit stash = std::exchange(pending, Commit{});
478 stashed.insert(serial, stash);
479 }
480
481 void applyState(quint32 serial)
482 {
483 if (!stashed.isEmpty()) {
484 if (stashed.firstKey() == serial) {
485 Commit stash = stashed.take(serial);
486 apply(&stash);
487 }
488 return;
489 }
490
491 apply(&pending);
492 pending = Commit{};
493 }
494};
495
496} // namespace KWin
497
Represents the Resource for the org_kde_kwin_blur interface.
Definition blur.h:59
Convenient Class which represents a wl_client.
Represents the Resource for the org_kde_kwin_contrast interface.
Definition contrast.h:60
SurfaceExtension(SurfaceInterface *surface)
Definition surface.h:463
virtual void apply(Commit *commit)=0
QMap< quint32, Commit > stashed
Definition surface.h:472
Resource representing a wl_surface.
Definition surface.h:80
Q_DECLARE_METATYPE(KWin::SwitchEvent::State)
PresentationModeHint
Definition globals.h:299
ContentType
Definition globals.h:284
#define private
#define explicit