8#include <QtWaylandCompositor/QWaylandCompositor>
9#include <QtWaylandCompositor/QWaylandView>
11#include <QtWaylandCompositor/private/qwaylandsurface_p.h>
12#include <QtWaylandCompositor/private/qwaylandcompositor_p.h>
13#include <QtWaylandCompositor/private/qwaylandview_p.h>
14#include <QtWaylandCompositor/private/qwaylandutils_p.h>
15#include <QtWaylandCompositor/private/qwaylandxdgoutputv1_p.h>
17#include <QtCore/QCoreApplication>
18#include <QtCore/QtMath>
19#include <QtGui/QWindow>
20#include <QtGui/QExposeEvent>
21#include <QtGui/QScreen>
22#include <private/qobject_p.h>
30 return QtWaylandServer::wl_output::subpixel_unknown;
32 return QtWaylandServer::wl_output::subpixel_none;
34 return QtWaylandServer::wl_output::subpixel_horizontal_rgb;
36 return QtWaylandServer::wl_output::subpixel_horizontal_bgr;
38 return QtWaylandServer::wl_output::subpixel_vertical_rgb;
40 return QtWaylandServer::wl_output::subpixel_vertical_bgr;
45 return QtWaylandServer::wl_output::subpixel_unknown;
52 return QtWaylandServer::wl_output::transform_90;
54 return QtWaylandServer::wl_output::transform_180;
56 return QtWaylandServer::wl_output::transform_270;
58 return QtWaylandServer::wl_output::transform_flipped;
60 return QtWaylandServer::wl_output::transform_flipped_90;
62 return QtWaylandServer::wl_output::transform_flipped_180;
64 return QtWaylandServer::wl_output::transform_flipped_270;
69 return QtWaylandServer::wl_output::transform_normal;
87 if (resource->version() >= 2) {
88 send_scale(resource->handle, scaleFactor);
89 send_done(resource->handle);
93void QWaylandOutputPrivate::_q_handleMaybeWindowPixelSizeChanged()
98 const QSize pixelSize = window->
size() * window->devicePixelRatio();
100 if (pixelSize != windowPixelSize) {
101 windowPixelSize = pixelSize;
106void QWaylandOutputPrivate::_q_handleWindowDestroyed()
110 emit q->windowChanged();
111 emit q->windowDestroyed();
116 send_geometry(resource->handle,
117 position.
x(), position.
y(),
125 for (
const Resource *resource : resourceMap().values()) {
127 if (resource->version() >= 2)
128 send_done(resource->handle);
139 flags |= QtWaylandServer::wl_output::mode_current;
141 flags |= QtWaylandServer::wl_output::mode_preferred;
143 send_mode(resource->handle,
flags,
144 mode.size().width(),
mode.size().height(),
150 for (
const Resource *resource : resourceMap().values()) {
153 if (resource->version() >= 2)
154 send_done(resource->handle);
165 if (sizeFollowsWindow && currentMode <= modes.
size() - 1) {
166 if (currentMode >= 0) {
168 mode.setSize(windowPixelSize);
170 emit q->geometryChanged();
171 if (!availableGeometry.
isValid())
172 emit q->availableGeometryChanged();
179 if (
mode.isValid()) {
181 q->addMode(
mode,
true);
182 q->setCurrentMode(
mode);
190 for (
int i = 0;
i < surfaceViews.
size();
i++) {
205 for (
int i = 0;
i < surfaceViews.
size();
i++) {
210 q->surfaceLeave(surface);
216 qWarning(
"%s Could not find view %p for surface %p to remove. Possible invalid state",
Q_FUNC_INFO,
view, surface);
294 if (!
d->window &&
d->sizeFollowsWindow) {
295 qWarning(
"Setting QWaylandOutput::sizeFollowsWindow without a window has no effect");
300 if (
d->window &&
d->sizeFollowsWindow) {
302 qFloor(
d->window->screen()->refreshRate() * 1000));
303 if (
mode.isValid()) {
319 d->init(
d->compositor->display(), 2);
321 d->initialized =
true;
329 if (
auto p = QtWayland::fromResource<QWaylandOutputPrivate *>(resource))
340 QWaylandOutputPrivate::Resource *
r =
d->resourceMap().value(client->
client());
357 d->window->requestUpdate();
374 return d_func()->compositor;
387 if (
d->initialized) {
388 qWarning(
"Setting QWaylandCompositor %p on QWaylandOutput %p is not supported after QWaylandOutput has been initialized\n",
compositor,
this);
392 qWarning(
"Possible initialization error. Moving QWaylandOutput %p between compositor instances.\n",
this);
413 return d_func()->manufacturer;
424 d->sendGeometryInfo();
441 return d_func()->model;
452 d->sendGeometryInfo();
469 return d_func()->position;
475 if (
d->position == pt)
480 d->sendGeometryInfo();
492 return d->modes.toList();
504 if (!
mode.isValid()) {
505 qWarning(
"Cannot add an invalid mode");
509 if (
d->modes.indexOf(
mode) < 0)
510 d->modes.append(
mode);
513 d->preferredMode =
d->modes.indexOf(
mode);
529 if (
d->currentMode >= 0 &&
d->currentMode <=
d->modes.size() - 1)
530 return d->modes.at(
d->currentMode);
547 qWarning(
"Cannot set an unknown QWaylandOutput mode as current");
555 if (!
d->availableGeometry.isValid())
603 if (!
d->availableGeometry.isValid())
606 return d->availableGeometry;
616 qWarning(
"Available geometry should be a portion of the output");
640 return d_func()->physicalSize;
646 if (
d->physicalSize ==
size)
649 d->physicalSize =
size;
651 d->sendGeometryInfo();
696 return d_func()->subpixel;
707 d->sendGeometryInfo();
758 return d_func()->transform;
769 d->sendGeometryInfo();
799 return d_func()->scaleFactor;
805 if (
d->scaleFactor ==
scale)
810 const auto resMap =
d->resourceMap();
811 for (QWaylandOutputPrivate::Resource *resource : resMap) {
812 if (resource->version() >= 2) {
813 d->send_scale(resource->handle,
scale);
814 d->send_done(resource->handle);
849 return d_func()->sizeFollowsWindow;
856 if (follow !=
d->sizeFollowsWindow) {
857 d->sizeFollowsWindow = follow;
878 return d_func()->window;
886 if (
d->initialized) {
887 qWarning(
"Setting QWindow %p on QWaylandOutput %p is not supported after QWaylandOutput has been initialized\n",
window,
this);
900 for (
int i = 0;
i <
d->surfaceViews.size();
i++) {
913 for (
int i = 0;
i <
d->surfaceViews.size();
i++) {
918 d->surfaceViews[
i].has_entered =
true;
926 wl_display_flush_clients(
d->compositor->display());
947 if (!surface || !surface->
client())
967#include "moc_qwaylandoutput.cpp"
qsizetype size() const noexcept
bool isEmpty() const noexcept
bool removeOne(const AT &t)
const_reference at(qsizetype i) const noexcept
void remove(qsizetype i, qsizetype n=1)
void replace(qsizetype i, parameter_type t)
void append(parameter_type t)
static QMetaObject::Connection connect(const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiverPrivate, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection)
virtual bool event(QEvent *event)
This virtual function receives events to an object and should return true if the event e was recogniz...
void destroyed(QObject *=nullptr)
This signal is emitted immediately before the object obj is destroyed, after any instances of QPointe...
\inmodule QtCore\reentrant
constexpr int x() const noexcept
Returns the x coordinate of this point.
constexpr int y() const noexcept
Returns the y coordinate of this point.
\inmodule QtCore\reentrant
constexpr bool isValid() const noexcept
Returns true if the rectangle is valid, otherwise returns false.
constexpr QPoint topLeft() const noexcept
Returns the position of the rectangle's top-left corner.
qreal refreshRate
the approximate vertical refresh rate of the screen in Hz
constexpr int height() const noexcept
Returns the height.
constexpr int width() const noexcept
Returns the width.
\macro QT_RESTRICTED_CAST_FROM_ASCII
\qmltype WaylandClient \instantiates QWaylandClient \inqmlmodule QtWayland.Compositor
wl_client * client() const
Returns the Wayland client of this QWaylandClient.
void removeOutput(QWaylandOutput *output)
void addPolishObject(QObject *object)
void addOutput(QWaylandOutput *output)
static QWaylandCompositorPrivate * get(QWaylandCompositor *compositor)
\qmltype WaylandCompositor \instantiates QWaylandCompositor \inqmlmodule QtWayland....
\inmodule QtWaylandCompositor
\inmodule QtWaylandCompositor
void removeView(QWaylandView *view, QWaylandSurface *surface)
void addView(QWaylandView *view, QWaylandSurface *surface)
~QWaylandOutputPrivate() override
void sendMode(const Resource *resource, const QWaylandOutputMode &mode)
void handleWindowPixelSizeChanged()
void output_bind_resource(Resource *resource) override
QPointer< QWaylandXdgOutputV1 > xdgOutput
void sendGeometry(const Resource *resource)
\qmltype WaylandOutput \instantiates QWaylandOutput \inqmlmodule QtWayland.Compositor
QWaylandOutput::Subpixel subpixel
\qmlproperty enum QtWayland.Compositor::WaylandOutput::subpixel
void availableGeometryChanged()
void scaleFactorChanged()
bool sizeFollowsWindow
\qmlproperty bool QtWayland.Compositor::WaylandOutput::sizeFollowsWindow
void setSizeFollowsWindow(bool follow)
void setScaleFactor(int scale)
void setAvailableGeometry(const QRect &availableGeometry)
static QWaylandOutput * fromResource(wl_resource *resource)
Returns the QWaylandOutput corresponding to resource.
QString manufacturer
\qmlproperty string QtWayland.Compositor::WaylandOutput::manufacturer
QPoint position
\qmlproperty point QtWayland.Compositor::WaylandOutput::position
void setCurrentMode(const QWaylandOutputMode &mode)
Sets the current mode.
struct::wl_resource * resourceForClient(QWaylandClient *client) const
QSize physicalSize
\qmlproperty size QtWayland.Compositor::WaylandOutput::physicalSize
void setPosition(const QPoint &pt)
void surfaceLeave(QWaylandSurface *surface)
QRect availableGeometry
\qmlproperty rect QtWayland.Compositor::WaylandOutput::availableGeometry
void frameStarted()
Informs QWaylandOutput that a frame has started.
virtual void initialize()
virtual void update()
Schedules a QEvent::UpdateRequest to be delivered to the QWaylandOutput's \l{window()}{window}.
QRect geometry
\qmlproperty rect QtWayland.Compositor::WaylandOutput::geometry
void setTransform(const Transform &transform)
bool event(QEvent *event) override
~QWaylandOutput() override
Destroys the QWaylandOutput.
void setModel(const QString &model)
void setCompositor(QWaylandCompositor *compositor)
void addMode(const QWaylandOutputMode &mode, bool preferred=false)
Adds the mode mode to the output and mark it as preferred if preferred is true.
QList< QWaylandOutputMode > modes() const
Returns the list of modes.
Subpixel
This enum type is used to specify the subpixel arrangement of a QWaylandOutput.
void setPhysicalSize(const QSize &size)
void surfaceEnter(QWaylandSurface *surface)
Transform
This enum type is used to specify the orientation of a QWaylandOutput.
void sendFrameCallbacks()
Sends pending frame callbacks.
QWindow * window
\qmlproperty Window QtWayland.Compositor::WaylandOutput::window
void sizeFollowsWindowChanged()
void currentModeChanged()
QWaylandOutputMode currentMode() const
Returns the output's size in pixels and refresh rate in mHz.
QString model
\qmlproperty string QtWayland.Compositor::WaylandOutput::model
void physicalSizeChanged()
void setSubpixel(const Subpixel &subpixel)
void setManufacturer(const QString &manufacturer)
void manufacturerChanged()
int scaleFactor
\qmlproperty int QtWayland.Compositor::WaylandOutput::scaleFactor
QWaylandOutput::Transform transform
\qmlproperty enum QtWayland.Compositor::WaylandOutput::transform
QWaylandCompositor * compositor
void setWindow(QWindow *window)
static QWaylandSurfacePrivate * get(QWaylandSurface *surface)
\qmltype WaylandSurface \instantiates QWaylandSurface \inqmlmodule QtWayland.Compositor
Q_INVOKABLE void frameStarted()
Prepares all frame callbacks for sending.
Q_INVOKABLE void sendFrameCallbacks()
Sends pending frame callbacks.
bool hasContent
\qmlproperty bool QtWayland.Compositor::WaylandSurface::hasContent
QWaylandClient * client
\qmlproperty WaylandClient QtWayland.Compositor::WaylandSurface::client
static QWaylandViewPrivate * get(QWaylandView *view)
\qmltype WaylandView \instantiates QWaylandView \inqmlmodule QtWayland.Compositor
static QWaylandXdgOutputV1Private * get(QWaylandXdgOutputV1 *xdgOutput)
void heightChanged(int arg)
QSize size() const override
Returns the size of the window excluding any window frame.
void widthChanged(int arg)
void screenChanged(QScreen *screen)
This signal is emitted when a window's screen changes, either by being set explicitly with setScreen(...
Combined button and popup list for selecting options.
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
static QOpenGLCompositor * compositor
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint GLenum GLenum transform
GLdouble GLdouble GLdouble GLdouble q
GLenum GLenum GLenum GLenum GLenum scale
static QtWaylandServer::wl_output::transform toWlTransform(const QWaylandOutput::Transform &value)
static QT_BEGIN_NAMESPACE QtWaylandServer::wl_output::subpixel toWlSubpixel(const QWaylandOutput::Subpixel &value)
QSqlQueryModel * model
[16]
qsizetype indexOf(const AT &t, qsizetype from=0) const noexcept
bool contains(const AT &t) const noexcept
QWaylandView * maybePrimaryView() const
QList< QWaylandView * > views
QWaylandSurface * surface