1// Copyright (C) 2017 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#include "qwlqtkey_p.h"
5#include <QtWaylandCompositor/QWaylandSurface>
6#include <QKeyEvent>
7#include <QWindow>
8
9QT_BEGIN_NAMESPACE
10
11namespace QtWayland {
12
13QtKeyExtensionGlobal::QtKeyExtensionGlobal(QWaylandCompositor *compositor)
14 : QWaylandCompositorExtensionTemplate(compositor)
15 , QtWaylandServer::zqt_key_v1(compositor->display(), 1)
16 , m_compositor(compositor)
17{
18}
19
20bool QtKeyExtensionGlobal::postQtKeyEvent(QKeyEvent *event, QWaylandSurface *surface)
21{
22 uint32_t time = m_compositor->currentTimeMsecs();
23
24 Resource *target = surface ? resourceMap().value(surface->waylandClient()) : 0;
25
26 if (target) {
27 send_key(target->handle,
28 surface ? surface->resource() : nullptr,
29 time, event->type(), event->key(), event->modifiers(),
30 event->nativeScanCode(),
31 event->nativeVirtualKey(),
32 event->nativeModifiers(),
33 event->text(),
34 event->isAutoRepeat(),
35 event->count());
36
37 return true;
38 }
39
40 return false;
41}
42
43}
44
45QT_END_NAMESPACE
46
47#include "moc_qwlqtkey_p.cpp"
48

source code of qtwayland/src/compositor/extensions/qwlqtkey.cpp