1 | // Copyright (C) 2021 LG Electronics Inc. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
3 | |
4 | #ifndef QWAYLANDPRESENTATIONTIME_P_P_H |
5 | #define QWAYLANDPRESENTATIONTIME_P_P_H |
6 | |
7 | // |
8 | // W A R N I N G |
9 | // ------------- |
10 | // |
11 | // This file is not part of the Qt API. It exists purely as an |
12 | // implementation detail. This header file may change from version to |
13 | // version without notice, or even be removed. |
14 | // |
15 | // We mean it. |
16 | // |
17 | |
18 | #include <QtWaylandCompositor/private/qwaylandcompositorextension_p.h> |
19 | #include <QtWaylandCompositor/private/qwayland-server-presentation-time.h> |
20 | |
21 | #include <QObject> |
22 | #include <QPointer> |
23 | #include <QMultiMap> |
24 | |
25 | QT_BEGIN_NAMESPACE |
26 | |
27 | |
28 | class QWaylandSurface; |
29 | class QWaylandView; |
30 | class QQuickWindow; |
31 | |
32 | class PresentationFeedback : public QObject, public QtWaylandServer::wp_presentation_feedback |
33 | { |
34 | Q_OBJECT |
35 | public: |
36 | PresentationFeedback(QWaylandPresentationTime *, QWaylandSurface *, struct ::wl_client *, uint32_t, int); |
37 | |
38 | void setSurface(QWaylandSurface *); |
39 | QWaylandSurface *surface() { return m_surface; } |
40 | |
41 | void destroy(); |
42 | void sendSyncOutput(); |
43 | |
44 | private Q_SLOTS: |
45 | void discard(); |
46 | void onSurfaceCommit(); |
47 | void onSurfaceMapped(); |
48 | void onWindowChanged(); |
49 | void onSync(); |
50 | void onSwapped(); |
51 | void sendPresented(quint64 sequence, quint64 tv_sec, quint32 tv_nsec, quint32 refresh_nsec); |
52 | |
53 | private: |
54 | QWaylandPresentationTime *presentationTime() { return m_presentationTime; } |
55 | void maybeConnectToWindow(QWaylandView *); |
56 | void connectToWindow(QQuickWindow *); |
57 | |
58 | void wp_presentation_feedback_destroy_resource(Resource *resource) override; |
59 | |
60 | public: |
61 | QWaylandPresentationTime *m_presentationTime = nullptr; |
62 | QWaylandSurface *m_surface = nullptr; |
63 | QQuickWindow *m_connectedWindow = nullptr; |
64 | |
65 | bool m_committed = false; |
66 | bool m_sync = false; |
67 | }; |
68 | |
69 | class QWaylandPresentationTimePrivate : public QWaylandCompositorExtensionPrivate, public QtWaylandServer::wp_presentation |
70 | { |
71 | Q_DECLARE_PUBLIC(QWaylandPresentationTime) |
72 | public: |
73 | QWaylandPresentationTimePrivate(); |
74 | |
75 | protected: |
76 | void wp_presentation_feedback(Resource *resource, struct ::wl_resource *surface, uint32_t callback) override; |
77 | void wp_presentation_bind_resource(Resource *resource) override; |
78 | }; |
79 | |
80 | QT_END_NAMESPACE |
81 | |
82 | #endif |
83 | |