1// Copyright (C) 2017-2016 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
2// Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB).
3// Copyright (C) 2017 The Qt Company Ltd.
4// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
5
6#ifndef QWAYLANDOUTPUT_P_H
7#define QWAYLANDOUTPUT_P_H
8
9//
10// W A R N I N G
11// -------------
12//
13// This file is not part of the Qt API. It exists purely as an
14// implementation detail. This header file may change from version to
15// version without notice, or even be removed.
16//
17// We mean it.
18//
19
20#include <QtWaylandCompositor/qtwaylandcompositorglobal.h>
21#include <QtWaylandCompositor/QWaylandOutput>
22#include <QtWaylandCompositor/QWaylandClient>
23#include <QtWaylandCompositor/QWaylandSurface>
24#include <QtWaylandCompositor/QWaylandXdgOutputV1>
25
26#include <QtWaylandCompositor/private/qwayland-server-wayland.h>
27
28#include <QtCore/QList>
29#include <QtCore/QRect>
30
31#include <QtCore/private/qobject_p.h>
32#include <QtCore/qpointer.h>
33
34QT_BEGIN_NAMESPACE
35
36struct QWaylandSurfaceViewMapper
37{
38 QWaylandSurfaceViewMapper()
39 {}
40
41 QWaylandSurfaceViewMapper(QWaylandSurface *s, QWaylandView *v)
42 : surface(s)
43 , views(1, v)
44 {}
45
46 QWaylandView *maybePrimaryView() const
47 {
48 for (int i = 0; i < views.size(); i++) {
49 if (surface && surface->primaryView() == views.at(i))
50 return views.at(i);
51 }
52 return nullptr;
53 }
54
55 QWaylandSurface *surface = nullptr;
56 QList<QWaylandView *> views;
57 bool has_entered = false;
58};
59
60class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandOutputPrivate : public QObjectPrivate, public QtWaylandServer::wl_output
61{
62public:
63 Q_DECLARE_PUBLIC(QWaylandOutput)
64
65 QWaylandOutputPrivate();
66
67 ~QWaylandOutputPrivate() override;
68 static QWaylandOutputPrivate *get(QWaylandOutput *output) { return output->d_func(); }
69
70 void addView(QWaylandView *view, QWaylandSurface *surface);
71 void removeView(QWaylandView *view, QWaylandSurface *surface);
72
73 void sendGeometry(const Resource *resource);
74 void sendGeometryInfo();
75
76 void sendMode(const Resource *resource, const QWaylandOutputMode &mode);
77 void sendModesInfo();
78
79 void handleWindowPixelSizeChanged();
80
81 QPointer<QWaylandXdgOutputV1> xdgOutput;
82
83protected:
84 void output_bind_resource(Resource *resource) override;
85
86private:
87 void _q_handleMaybeWindowPixelSizeChanged();
88 void _q_handleWindowDestroyed();
89
90 QWaylandCompositor *compositor = nullptr;
91 QWindow *window = nullptr;
92 QString manufacturer;
93 QString model;
94 QPoint position;
95 QList<QWaylandOutputMode> modes;
96 int currentMode = -1;
97 int preferredMode = -1;
98 QRect availableGeometry;
99 QList<QWaylandSurfaceViewMapper> surfaceViews;
100 QSize physicalSize;
101 QWaylandOutput::Subpixel subpixel = QWaylandOutput::SubpixelUnknown;
102 QWaylandOutput::Transform transform = QWaylandOutput::TransformNormal;
103 int scaleFactor = 1;
104 bool sizeFollowsWindow = false;
105 bool initialized = false;
106 QSize windowPixelSize;
107
108 Q_DISABLE_COPY(QWaylandOutputPrivate)
109
110 friend class QWaylandXdgOutputManagerV1Private;
111};
112
113
114QT_END_NAMESPACE
115
116#endif /*QWAYLANDOUTPUT_P_H*/
117

Provided by KDAB

Privacy Policy
Learn Advanced QML with KDAB
Find out more

source code of qtwayland/src/compositor/compositor_api/qwaylandoutput_p.h