Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qwaylandview.cpp
Go to the documentation of this file.
1// Copyright (C) 2017 Jolla Ltd, author: <giulio.camuffo@jollamobile.com>
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#include "qwaylandview.h"
5#include "qwaylandview_p.h"
6#include "qwaylandsurface.h"
7#include <QtWaylandCompositor/QWaylandSeat>
8#include <QtWaylandCompositor/QWaylandCompositor>
9
10#include <QtWaylandCompositor/private/qwaylandsurface_p.h>
11#include <QtWaylandCompositor/private/qwaylandoutput_p.h>
12
13#include <QtCore/QMutex>
14
16
18{
19 Q_Q(QWaylandView);
20 Q_ASSERT(surface == this->surface);
21
22 setSurface(nullptr);
23 QPointer<QWaylandView> deleteGuard(q);
24 emit q->surfaceDestroyed();
25 if (!deleteGuard.isNull())
27}
28
57{
58 d_func()->renderObject = renderObject;
59}
60
65{
66 Q_D(QWaylandView);
67 if (d->surface) {
68 if (d->output)
69 QWaylandOutputPrivate::get(d->output)->removeView(this, d->surface);
70
72 }
73
74}
75
81{
82 Q_D(const QWaylandView);
83 return d->renderObject;
84}
85
98{
99 Q_D(const QWaylandView);
100 return d->surface;
101}
102
103
105{
106 Q_Q(QWaylandView);
107 if (surface) {
109 if (output)
111 }
112
113 surface = newSurface;
114
116 nextBufferCommitted = false;
118
119 if (surface) {
121 if (output)
123 }
124}
125
127{
128 if (!bufferLocked) {
131 }
132}
133
135{
136 Q_D(QWaylandView);
137 if (d->surface == newSurface)
138 return;
139
140 d->setSurface(newSurface);
141 d->clearFrontBuffer();
143}
144
157{
158 Q_D(const QWaylandView);
159 return d->output;
160}
161
163{
164 Q_D(QWaylandView);
165 if (d->output == newOutput)
166 return;
167
168 if (d->output && d->surface)
169 QWaylandOutputPrivate::get(d->output)->removeView(this, d->surface);
170
171 d->output = newOutput;
172
173 if (d->output && d->surface)
174 QWaylandOutputPrivate::get(d->output)->addView(this, d->surface);
175
177}
178
188{
189 Q_D(QWaylandView);
190 QMutexLocker locker(&d->bufferMutex);
191 d->nextBuffer = buffer;
192 d->nextDamage = damage;
193 d->nextBufferCommitted = true;
194}
195
204{
205 Q_D(QWaylandView);
206
207 if (!d->nextBufferCommitted && !d->forceAdvanceSucceed)
208 return false;
209
210 if (d->bufferLocked)
211 return false;
212
213 if (d->surface && d->surface->primaryView() == this) {
214 const auto views = d->surface->views();
215 for (QWaylandView *view : views) {
216 if (view != this && view->allowDiscardFrontBuffer() && view->d_func()->currentBuffer == d->currentBuffer)
217 view->discardCurrentBuffer();
218 }
219 }
220
221 QMutexLocker locker(&d->bufferMutex);
222 d->forceAdvanceSucceed = false;
223 d->nextBufferCommitted = false;
224 d->currentBuffer = d->nextBuffer;
225 d->currentDamage = d->nextDamage;
226 return true;
227}
228
233{
234 Q_D(QWaylandView);
235 QMutexLocker locker(&d->bufferMutex);
236 d->currentBuffer = QWaylandBufferRef();
237 d->forceAdvanceSucceed = true;
238}
239
244{
245 Q_D(QWaylandView);
246 QMutexLocker locker(&d->bufferMutex);
247 return d->currentBuffer;
248}
249
254{
255 Q_D(QWaylandView);
256 QMutexLocker locker(&d->bufferMutex);
257 return d->currentDamage;
258}
259
280{
281 Q_D(const QWaylandView);
282 return d->bufferLocked;
283}
284
286{
287 Q_D(QWaylandView);
288 if (d->bufferLocked == locked)
289 return;
290 d->bufferLocked = locked;
292}
313{
314 Q_D(const QWaylandView);
315 return d->allowDiscardFrontBuffer;
316}
317
319{
320 Q_D(QWaylandView);
321 if (d->allowDiscardFrontBuffer == discard)
322 return;
323 d->allowDiscardFrontBuffer = discard;
325}
326
335{
336 Q_D(QWaylandView);
337 if (d->surface)
338 d->surface->setPrimaryView(this);
339 else
340 qWarning("Calling setPrimary() on a QWaylandView without a surface has no effect.");
341}
342
349{
350 Q_D(const QWaylandView);
351 return d->surface && d->surface->primaryView() == this;
352}
353
357struct wl_resource *QWaylandView::surfaceResource() const
358{
359 Q_D(const QWaylandView);
360 if (!d->surface)
361 return nullptr;
362 return d->surface->resource();
363}
364
366
367#include "moc_qwaylandview.cpp"
\inmodule QtCore
Definition qmutex.h:317
\inmodule QtCore
Definition qobject.h:90
\inmodule QtCore
Definition qpointer.h:18
bool isNull() const
Returns true if the referenced object has been destroyed or if there is no referenced object; otherwi...
Definition qpointer.h:67
The QRegion class specifies a clip region for a painter.
Definition qregion.h:27
\inmodule QtWaylandCompositor
void removeView(QWaylandView *view, QWaylandSurface *surface)
void addView(QWaylandView *view, QWaylandSurface *surface)
static QWaylandOutputPrivate * get(QWaylandOutput *output)
\qmltype WaylandOutput \instantiates QWaylandOutput \inqmlmodule QtWayland.Compositor
static QWaylandSurfacePrivate * get(QWaylandSurface *surface)
void refView(QWaylandView *view)
void derefView(QWaylandView *view)
\qmltype WaylandSurface \instantiates QWaylandSurface \inqmlmodule QtWayland.Compositor
void setSurface(QWaylandSurface *newSurface)
QWaylandOutput * output
QWaylandSurface * surface
QWaylandBufferRef nextBuffer
QWaylandBufferRef currentBuffer
void markSurfaceAsDestroyed(QWaylandSurface *surface)
\qmltype WaylandView \instantiates QWaylandView \inqmlmodule QtWayland.Compositor
virtual bool advance()
Updates the current buffer and damage region to the latest version committed by the client.
virtual void discardCurrentBuffer()
Force the view to discard its current buffer, to allow it to be reused on the client side.
virtual QRegion currentDamage()
Returns the current damage region of this view.
bool isBufferLocked() const
struct wl_resource * surfaceResource() const
Returns the Wayland surface resource for this QWaylandView.
void allowDiscardFrontBufferChanged()
bool isPrimary() const
Returns true if this QWaylandView is the primary view for the QWaylandSurface.
QObject * renderObject
QWaylandOutput * output
\qmlproperty WaylandOutput QtWayland.Compositor::WaylandView::output
void setSurface(QWaylandSurface *surface)
QWaylandView(QObject *renderObject=nullptr, QObject *parent=nullptr)
Constructs a QWaylandView with the given renderObject and parent.
bool allowDiscardFrontBuffer
\qmlproperty bool QtWayland.Compositor::WaylandView::allowDiscardFrontBuffer
virtual QWaylandBufferRef currentBuffer()
Returns a reference to this view's current buffer.
void setOutput(QWaylandOutput *output)
QWaylandSurface * surface
\qmlproperty WaylandSurface QtWayland.Compositor::WaylandView::surface
void bufferLockedChanged()
~QWaylandView() override
Destroys the QWaylandView.
virtual void bufferCommitted(const QWaylandBufferRef &buffer, const QRegion &damage)
This function is called when a new buffer is committed to this view's surface.
void outputChanged()
void setPrimary()
Makes this QWaylandView the primary view for the surface.
void setAllowDiscardFrontBuffer(bool discard)
void setBufferLocked(bool locked)
void surfaceChanged()
Combined button and popup list for selecting options.
#define qWarning
Definition qlogging.h:162
GLenum GLuint buffer
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
#define emit
QQuickView * view
[0]
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent