1// Copyright (C) 2020 Aleix Pol Gonzalez <aleixpol@kde.org>
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 "qwaylandxdgactivationv1_p.h"
5#include <QtWaylandClient/private/qwaylanddisplay_p.h>
6#include <QtWaylandClient/private/qwaylandinputdevice_p.h>
7
8QT_BEGIN_NAMESPACE
9
10namespace QtWaylandClient {
11
12QWaylandXdgActivationV1::QWaylandXdgActivationV1(wl_registry *registry, uint32_t id,
13 uint32_t availableVersion)
14 : QtWayland::xdg_activation_v1(registry, id, qMin(availableVersion, 1u))
15{
16}
17
18QWaylandXdgActivationV1::~QWaylandXdgActivationV1()
19{
20 Q_ASSERT(isInitialized());
21 destroy();
22}
23
24QWaylandXdgActivationTokenV1 *
25QWaylandXdgActivationV1::requestXdgActivationToken(QWaylandDisplay *display,
26 struct ::wl_surface *surface,
27 std::optional<uint32_t> serial,
28 const QString &app_id)
29{
30 auto wl = get_activation_token();
31 auto provider = new QWaylandXdgActivationTokenV1;
32 provider->init(wl);
33
34 if (surface)
35 provider->set_surface(surface);
36
37 if (!app_id.isEmpty())
38 provider->set_app_id(app_id);
39
40 if (serial && display->lastInputDevice())
41 provider->set_serial(*serial, display->lastInputDevice()->wl_seat());
42 provider->commit();
43 return provider;
44}
45
46}
47
48QT_END_NAMESPACE
49
50#include "moc_qwaylandxdgactivationv1_p.cpp"
51

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