1// Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef QWAYLANDSHELL_H
5#define QWAYLANDSHELL_H
6
7#include <QtWaylandCompositor/qtwaylandqmlinclude.h>
8#include <QtWaylandCompositor/qwaylandcompositorextension.h>
9
10QT_BEGIN_NAMESPACE
11
12class QWaylandShellPrivate;
13
14class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandShell : public QWaylandCompositorExtension
15{
16 Q_OBJECT
17 Q_DECLARE_PRIVATE(QWaylandShell)
18 Q_PROPERTY(FocusPolicy focusPolicy READ focusPolicy WRITE setFocusPolicy NOTIFY focusPolicyChanged)
19
20 QML_NAMED_ELEMENT(Shell)
21 QML_UNCREATABLE("")
22 QML_ADDED_IN_VERSION(1, 0)
23public:
24 enum FocusPolicy {
25 AutomaticFocus,
26 ManualFocus
27 };
28 Q_ENUM(FocusPolicy)
29
30 QWaylandShell();
31 QWaylandShell(QWaylandObject *waylandObject);
32
33 FocusPolicy focusPolicy() const;
34 void setFocusPolicy(FocusPolicy focusPolicy);
35
36Q_SIGNALS:
37 void focusPolicyChanged();
38
39protected:
40 explicit QWaylandShell(QWaylandShellPrivate &dd);
41 explicit QWaylandShell(QWaylandObject *container, QWaylandShellPrivate &dd);
42};
43
44template <typename T>
45class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandShellTemplate : public QWaylandShell
46{
47public:
48 QWaylandShellTemplate()
49 : QWaylandShell()
50 { }
51
52 QWaylandShellTemplate(QWaylandObject *container)
53 : QWaylandShell(container)
54 { }
55
56 const struct wl_interface *extensionInterface() const override
57 {
58 return T::interface();
59 }
60
61 static T *findIn(QWaylandObject *container)
62 {
63 if (!container) return nullptr;
64 return qobject_cast<T *>(container->extension(T::interfaceName()));
65 }
66
67protected:
68 QWaylandShellTemplate(QWaylandShellPrivate &dd)
69 : QWaylandShell(dd)
70 { }
71
72 QWaylandShellTemplate(QWaylandObject *container, QWaylandShellPrivate &dd)
73 : QWaylandShell(container,dd)
74 { }
75};
76
77QT_END_NAMESPACE
78
79#endif // QWAYLANDSHELL_H
80

source code of qtwayland/src/compositor/extensions/qwaylandshell.h