1// Copyright (C) 2018 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 "qwaylandxdgdecorationv1_p.h"
5#include "qwaylandxdgshell_p.h"
6
7QT_BEGIN_NAMESPACE
8
9namespace QtWaylandClient {
10
11QWaylandXdgDecorationManagerV1::QWaylandXdgDecorationManagerV1(wl_registry *registry, uint32_t id, uint32_t availableVersion)
12 : QtWayland::zxdg_decoration_manager_v1(registry, id, qMin(availableVersion, 1u))
13{
14}
15
16QWaylandXdgDecorationManagerV1::~QWaylandXdgDecorationManagerV1()
17{
18 Q_ASSERT(isInitialized());
19 destroy();
20}
21
22QWaylandXdgToplevelDecorationV1 *QWaylandXdgDecorationManagerV1::createToplevelDecoration(::xdg_toplevel *toplevel)
23{
24 Q_ASSERT(toplevel);
25 return new QWaylandXdgToplevelDecorationV1(get_toplevel_decoration(toplevel));
26}
27
28QWaylandXdgToplevelDecorationV1::QWaylandXdgToplevelDecorationV1(::zxdg_toplevel_decoration_v1 *decoration)
29 : QtWayland::zxdg_toplevel_decoration_v1(decoration)
30{
31}
32
33QWaylandXdgToplevelDecorationV1::~QWaylandXdgToplevelDecorationV1()
34{
35 Q_ASSERT(isInitialized());
36 destroy();
37}
38
39void QWaylandXdgToplevelDecorationV1::requestMode(QtWayland::zxdg_toplevel_decoration_v1::mode mode)
40{
41 // According to the spec the client is responsible for not requesting a mode repeatedly.
42 if (m_modeSet && m_requested == mode)
43 return;
44
45 set_mode(mode);
46 m_requested = mode;
47 m_modeSet = true;
48}
49
50void QWaylandXdgToplevelDecorationV1::unsetMode()
51{
52 unset_mode();
53 m_modeSet = false;
54 m_requested = mode_client_side;
55}
56
57QWaylandXdgToplevelDecorationV1::mode QWaylandXdgToplevelDecorationV1::pending() const
58{
59 return m_pending;
60}
61
62bool QWaylandXdgToplevelDecorationV1::isConfigured() const
63{
64 return m_configured;
65}
66
67void QtWaylandClient::QWaylandXdgToplevelDecorationV1::zxdg_toplevel_decoration_v1_configure(uint32_t mode)
68{
69 m_pending = zxdg_toplevel_decoration_v1::mode(mode);
70 m_configured = true;
71}
72
73}
74
75QT_END_NAMESPACE
76

source code of qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgdecorationv1.cpp