1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qwaylandextendedsurface_p.h"
5
6#include "qwaylandwindow_p.h"
7
8#include "qwaylanddisplay_p.h"
9
10#include "qwaylandnativeinterface_p.h"
11
12#include <QtGui/QGuiApplication>
13#include <qpa/qplatformnativeinterface.h>
14#include <qpa/qwindowsysteminterface.h>
15
16QT_BEGIN_NAMESPACE
17
18namespace QtWaylandClient {
19
20QWaylandExtendedSurface::QWaylandExtendedSurface(QWaylandWindow *window)
21 : QtWayland::qt_extended_surface(window->display()->windowExtension()->get_extended_surface(window->wlSurface()))
22 , m_window(window)
23{
24}
25
26QWaylandExtendedSurface::~QWaylandExtendedSurface()
27{
28 qt_extended_surface_destroy(object());
29}
30
31void QWaylandExtendedSurface::updateGenericProperty(const QString &name, const QVariant &value)
32{
33 QByteArray byteValue;
34 QDataStream ds(&byteValue, QIODevice::WriteOnly);
35 ds << value;
36
37 update_generic_property(name, value: byteValue);
38}
39
40void QWaylandExtendedSurface::setContentOrientationMask(Qt::ScreenOrientations mask)
41{
42 int32_t wlmask = 0;
43 if (mask & Qt::PrimaryOrientation)
44 wlmask |= QT_EXTENDED_SURFACE_ORIENTATION_PRIMARYORIENTATION;
45 if (mask & Qt::PortraitOrientation)
46 wlmask |= QT_EXTENDED_SURFACE_ORIENTATION_PORTRAITORIENTATION;
47 if (mask & Qt::LandscapeOrientation)
48 wlmask |= QT_EXTENDED_SURFACE_ORIENTATION_LANDSCAPEORIENTATION;
49 if (mask & Qt::InvertedPortraitOrientation)
50 wlmask |= QT_EXTENDED_SURFACE_ORIENTATION_INVERTEDPORTRAITORIENTATION;
51 if (mask & Qt::InvertedLandscapeOrientation)
52 wlmask |= QT_EXTENDED_SURFACE_ORIENTATION_INVERTEDLANDSCAPEORIENTATION;
53 set_content_orientation_mask(wlmask);
54}
55
56void QWaylandExtendedSurface::extended_surface_onscreen_visibility(int32_t visibility)
57{
58 m_window->window()->setVisibility(static_cast<QWindow::Visibility>(visibility));
59}
60
61void QWaylandExtendedSurface::extended_surface_set_generic_property(const QString &name, wl_array *value)
62{
63 QByteArray data = QByteArray::fromRawData(data: static_cast<char *>(value->data), size: value->size);
64
65 QVariant variantValue;
66 QDataStream ds(data);
67 ds >> variantValue;
68
69 m_window->setProperty(name, value: variantValue);
70}
71
72void QWaylandExtendedSurface::extended_surface_close()
73{
74 QWindowSystemInterface::handleCloseEvent(m_window->window());
75}
76
77Qt::WindowFlags QWaylandExtendedSurface::setWindowFlags(Qt::WindowFlags flags)
78{
79 uint wlFlags = 0;
80
81 if (flags & Qt::WindowStaysOnTopHint) wlFlags |= QT_EXTENDED_SURFACE_WINDOWFLAG_STAYSONTOP;
82 if (flags & Qt::WindowOverridesSystemGestures) wlFlags |= QT_EXTENDED_SURFACE_WINDOWFLAG_OVERRIDESSYSTEMGESTURES;
83 if (flags & Qt::BypassWindowManagerHint) wlFlags |= QT_EXTENDED_SURFACE_WINDOWFLAG_BYPASSWINDOWMANAGER;
84
85 set_window_flags(wlFlags);
86
87 return flags & (Qt::WindowStaysOnTopHint | Qt::WindowOverridesSystemGestures | Qt::BypassWindowManagerHint);
88}
89
90}
91
92QT_END_NAMESPACE
93

source code of qtwayland/src/client/qwaylandextendedsurface.cpp