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 void sendDone();
79
80 void handleWindowPixelSizeChanged();
81
82protected:
83 void output_bind_resource(Resource *resource) override;
84
85private:
86 void _q_handleMaybeWindowPixelSizeChanged();
87 void _q_handleWindowDestroyed();
88
89 QWaylandCompositor *compositor = nullptr;
90 QWindow *window = nullptr;
91 QString manufacturer;
92 QString model;
93 QPoint position;
94 QList<QWaylandOutputMode> modes;
95 int currentMode = -1;
96 int preferredMode = -1;
97 QRect availableGeometry;
98 QList<QWaylandSurfaceViewMapper> surfaceViews;
99 QSize physicalSize;
100 QWaylandOutput::Subpixel subpixel = QWaylandOutput::SubpixelUnknown;
101 QWaylandOutput::Transform transform = QWaylandOutput::TransformNormal;
102 int scaleFactor = 1;
103 bool sizeFollowsWindow = false;
104 bool initialized = false;
105 QSize windowPixelSize;
106
107 Q_DISABLE_COPY(QWaylandOutputPrivate)
108
109 friend class QWaylandXdgOutputManagerV1Private;
110};
111
112
113QT_END_NAMESPACE
114
115#endif /*QWAYLANDOUTPUT_P_H*/
116

Provided by KDAB

Privacy Policy
Start learning QML with our Intro Training
Find out more

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