summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPier Luigi Fiorini <pierluigi.fiorini@gmail.com>2016-08-14 13:28:30 +0200
committerPier Luigi Fiorini <pierluigi.fiorini@hawaiios.org>2016-09-30 09:38:56 +0000
commit9e585fc849c80b04c02c671d908fb5ade6c441b0 (patch)
tree0eeb11777d59012f8298f1a5d05e0176fda48eb6
parent079b260e42cf394a8dbe823763ec455929fba091 (diff)
Compositor: Base shell class
Standard shell class with focus policy shared by all protocol implementations. The automatic focus policy gives focus to windows automatically as they are created, while the manual policy allows a compositor to decide what to do. Change-Id: Ica71271174b30e28217e31c53f1c8dd576752c5e Reviewed-by: Johan Helsing <johan.helsing@qt.io>
-rw-r--r--examples/wayland/qwindow-compositor/compositor.cpp5
-rw-r--r--examples/wayland/qwindow-compositor/compositor.h2
-rw-r--r--src/compositor/compositor_api/qwaylandseat.cpp5
-rw-r--r--src/compositor/extensions/extensions.pri3
-rw-r--r--src/compositor/extensions/qwaylandshell.cpp100
-rw-r--r--src/compositor/extensions/qwaylandshell.h107
-rw-r--r--src/compositor/extensions/qwaylandshell_p.h67
-rw-r--r--src/compositor/extensions/qwaylandwlshell.cpp43
-rw-r--r--src/compositor/extensions/qwaylandwlshell.h14
-rw-r--r--src/compositor/extensions/qwaylandwlshell_p.h10
-rw-r--r--src/compositor/extensions/qwaylandwlshellintegration.cpp19
-rw-r--r--src/compositor/extensions/qwaylandwlshellintegration_p.h2
-rw-r--r--src/compositor/extensions/qwaylandxdgshellv5.cpp6
-rw-r--r--src/compositor/extensions/qwaylandxdgshellv5.h3
-rw-r--r--src/compositor/extensions/qwaylandxdgshellv5integration.cpp14
-rw-r--r--src/compositor/extensions/qwaylandxdgshellv5integration_p.h2
-rw-r--r--src/imports/compositor/qwaylandquickcompositorplugin.cpp1
17 files changed, 331 insertions, 72 deletions
diff --git a/examples/wayland/qwindow-compositor/compositor.cpp b/examples/wayland/qwindow-compositor/compositor.cpp
index eed270cd6..e9231faf9 100644
--- a/examples/wayland/qwindow-compositor/compositor.cpp
+++ b/examples/wayland/qwindow-compositor/compositor.cpp
@@ -282,9 +282,10 @@ void Compositor::onXdgStartResize(QWaylandSeat *seat,
emit startResize(int(edges), true);
}
-void Compositor::onSetTransient(QWaylandSurface *parent, const QPoint &relativeToParent, QWaylandWlShellSurface::FocusPolicy focusPolicy)
+void Compositor::onSetTransient(QWaylandSurface *parent, const QPoint &relativeToParent, bool inactive)
{
- Q_UNUSED(focusPolicy);
+ Q_UNUSED(inactive);
+
QWaylandWlShellSurface *wlShellSurface = qobject_cast<QWaylandWlShellSurface*>(sender());
View *view = findView(wlShellSurface->surface());
diff --git a/examples/wayland/qwindow-compositor/compositor.h b/examples/wayland/qwindow-compositor/compositor.h
index 636def97e..b7569082f 100644
--- a/examples/wayland/qwindow-compositor/compositor.h
+++ b/examples/wayland/qwindow-compositor/compositor.h
@@ -135,7 +135,7 @@ private slots:
void onXdgSurfaceCreated(QWaylandXdgSurfaceV5 *xdgSurface);
void onXdgPopupRequested(QWaylandSurface *surface, QWaylandSurface *parent, QWaylandSeat *seat,
const QPoint &position, const QWaylandResource &resource);
- void onSetTransient(QWaylandSurface *parentSurface, const QPoint &relativeToParent, QWaylandWlShellSurface::FocusPolicy focusPolicy);
+ void onSetTransient(QWaylandSurface *parentSurface, const QPoint &relativeToParent, bool inactive);
void onSetPopup(QWaylandSeat *seat, QWaylandSurface *parent, const QPoint &relativeToParent);
void onSubsurfaceChanged(QWaylandSurface *child, QWaylandSurface *parent);
diff --git a/src/compositor/compositor_api/qwaylandseat.cpp b/src/compositor/compositor_api/qwaylandseat.cpp
index 145184c0e..182f95ca3 100644
--- a/src/compositor/compositor_api/qwaylandseat.cpp
+++ b/src/compositor/compositor_api/qwaylandseat.cpp
@@ -43,7 +43,6 @@
#include <QtWaylandCompositor/QWaylandDrag>
#include <QtWaylandCompositor/QWaylandTouch>
#include <QtWaylandCompositor/QWaylandPointer>
-#include <QtWaylandCompositor/QWaylandWlShellSurface>
#include <QtWaylandCompositor/private/qwaylandseat_p.h>
#include <QtWaylandCompositor/private/qwaylandcompositor_p.h>
#include <QtWaylandCompositor/private/qwldatadevice_p.h>
@@ -360,10 +359,6 @@ bool QWaylandSeat::setKeyboardFocus(QWaylandSurface *surface)
if (surface == oldSurface)
return true;
- QWaylandWlShellSurface *wlShellsurface = QWaylandWlShellSurface::findIn(surface);
- if (wlShellsurface && wlShellsurface->focusPolicy() == QWaylandWlShellSurface::NoKeyboardFocus)
- return false;
-
d->keyboardFocus = surface;
if (!d->keyboard.isNull())
d->keyboard->setFocus(surface);
diff --git a/src/compositor/extensions/extensions.pri b/src/compositor/extensions/extensions.pri
index d5a14f549..e139d9e8c 100644
--- a/src/compositor/extensions/extensions.pri
+++ b/src/compositor/extensions/extensions.pri
@@ -13,6 +13,8 @@ HEADERS += \
extensions/qwlextendedsurface_p.h \
extensions/qwlqttouch_p.h \
extensions/qwlqtkey_p.h \
+ extensions/qwaylandshell.h \
+ extensions/qwaylandshell_p.h \
extensions/qwaylandwlshell.h \
extensions/qwaylandwlshell_p.h \
extensions/qwaylandtextinput.h \
@@ -29,6 +31,7 @@ SOURCES += \
extensions/qwlextendedsurface.cpp \
extensions/qwlqttouch.cpp \
extensions/qwlqtkey.cpp \
+ extensions/qwaylandshell.cpp \
extensions/qwaylandwlshell.cpp \
extensions/qwaylandtextinput.cpp \
extensions/qwaylandtextinputmanager.cpp \
diff --git a/src/compositor/extensions/qwaylandshell.cpp b/src/compositor/extensions/qwaylandshell.cpp
new file mode 100644
index 000000000..7811a1c2a
--- /dev/null
+++ b/src/compositor/extensions/qwaylandshell.cpp
@@ -0,0 +1,100 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandshell.h"
+#include "qwaylandshell_p.h"
+
+QT_BEGIN_NAMESPACE
+
+QWaylandShellPrivate::QWaylandShellPrivate()
+ : focusPolicy(QWaylandShell::AutomaticFocus)
+{
+}
+
+QWaylandShell::QWaylandShell()
+ : QWaylandCompositorExtension()
+{
+}
+
+QWaylandShell::QWaylandShell(QWaylandObject *waylandObject)
+ : QWaylandCompositorExtension(waylandObject, *new QWaylandShellPrivate())
+{
+}
+
+/*!
+ * \qmlproperty enum QtWaylandCompositor::Shell::focusPolicy
+ *
+ * This property holds the focus policy of the Shell.
+ */
+
+/*!
+ * \enum QWaylandShell::FocusPolicy
+ *
+ * This enum type is used to specify the focus policy for shell surfaces.
+ *
+ * \value AutomaticFocus Shell surfaces will automatically get keyboard focus when they are created.
+ * \value ManualFocus The compositor will decide whether shell surfaces should get keyboard focus or not.
+ */
+
+/*!
+ * \qmlproperty object QtWaylandCompositor::Shell::focusPolicy
+ *
+ * This property holds the focus policy of the Shell.
+ */
+
+/*!
+ * \property QWaylandShell::focusPolicy
+ *
+ * This property holds the focus policy of the QWaylandShell.
+ */
+QWaylandShell::FocusPolicy QWaylandShell::focusPolicy() const
+{
+ Q_D(const QWaylandShell);
+ return d->focusPolicy;
+}
+
+void QWaylandShell::setFocusPolicy(QWaylandShell::FocusPolicy focusPolicy)
+{
+ Q_D(QWaylandShell);
+
+ if (d->focusPolicy == focusPolicy)
+ return;
+
+ d->focusPolicy = focusPolicy;
+ emit focusPolicyChanged();
+}
+
+QT_END_NAMESPACE
diff --git a/src/compositor/extensions/qwaylandshell.h b/src/compositor/extensions/qwaylandshell.h
new file mode 100644
index 000000000..997573c95
--- /dev/null
+++ b/src/compositor/extensions/qwaylandshell.h
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDSHELL_H
+#define QWAYLANDSHELL_H
+
+#include <QtWaylandCompositor/QWaylandCompositorExtension>
+
+QT_BEGIN_NAMESPACE
+
+class QWaylandShellPrivate;
+
+class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandShell : public QWaylandCompositorExtension
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QWaylandShell)
+ Q_PROPERTY(FocusPolicy focusPolicy READ focusPolicy WRITE setFocusPolicy NOTIFY focusPolicyChanged)
+public:
+ enum FocusPolicy {
+ AutomaticFocus,
+ ManualFocus
+ };
+ Q_ENUM(FocusPolicy)
+
+ QWaylandShell();
+ QWaylandShell(QWaylandObject *waylandObject);
+
+ FocusPolicy focusPolicy() const;
+ void setFocusPolicy(FocusPolicy focusPolicy);
+
+Q_SIGNALS:
+ void focusPolicyChanged();
+
+protected:
+ QWaylandShell(QWaylandCompositorExtensionPrivate &dd) : QWaylandCompositorExtension(dd) {}
+ QWaylandShell(QWaylandObject *container, QWaylandCompositorExtensionPrivate &dd) : QWaylandCompositorExtension(container, dd) {}
+};
+
+template <typename T>
+class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandShellTemplate : public QWaylandShell
+{
+public:
+ QWaylandShellTemplate()
+ : QWaylandShell()
+ { }
+
+ QWaylandShellTemplate(QWaylandObject *container)
+ : QWaylandShell(container)
+ { }
+
+ const struct wl_interface *extensionInterface() const Q_DECL_OVERRIDE
+ {
+ return T::interface();
+ }
+
+ static T *findIn(QWaylandObject *container)
+ {
+ if (!container) return nullptr;
+ return qobject_cast<T *>(container->extension(T::interfaceName()));
+ }
+
+protected:
+ QWaylandShellTemplate(QWaylandCompositorExtensionPrivate &dd)
+ : QWaylandShell(dd)
+ { }
+
+ QWaylandShellTemplate(QWaylandObject *container, QWaylandCompositorExtensionPrivate &dd)
+ : QWaylandShell(container,dd)
+ { }
+};
+
+QT_END_NAMESPACE
+
+#endif // QWAYLANDSHELL_H
diff --git a/src/compositor/extensions/qwaylandshell_p.h b/src/compositor/extensions/qwaylandshell_p.h
new file mode 100644
index 000000000..7f849c76d
--- /dev/null
+++ b/src/compositor/extensions/qwaylandshell_p.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDSHELL_P_H
+#define QWAYLANDSHELL_P_H
+
+#include <QtWaylandCompositor/private/qwaylandcompositorextension_p.h>
+#include <QtWaylandCompositor/QWaylandShell>
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+QT_BEGIN_NAMESPACE
+
+class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandShellPrivate : public QWaylandCompositorExtensionPrivate
+{
+ Q_DECLARE_PUBLIC(QWaylandShell)
+public:
+ QWaylandShellPrivate();
+
+ QWaylandShell::FocusPolicy focusPolicy;
+};
+
+QT_END_NAMESPACE
+
+#endif // QWAYLANDSHELL_P_H
diff --git a/src/compositor/extensions/qwaylandwlshell.cpp b/src/compositor/extensions/qwaylandwlshell.cpp
index 97d2b3958..f3af4d15f 100644
--- a/src/compositor/extensions/qwaylandwlshell.cpp
+++ b/src/compositor/extensions/qwaylandwlshell.cpp
@@ -103,7 +103,6 @@ QWaylandWlShellSurfacePrivate::QWaylandWlShellSurfacePrivate()
, wl_shell_surface()
, m_shell(Q_NULLPTR)
, m_surface(Q_NULLPTR)
- , m_focusPolicy(QWaylandWlShellSurface::DefaultFocus)
, m_windowType(Qt::WindowType::Window)
{
}
@@ -164,7 +163,6 @@ void QWaylandWlShellSurfacePrivate::shell_surface_set_toplevel(Resource *resourc
{
Q_UNUSED(resource);
Q_Q(QWaylandWlShellSurface);
- setFocusPolicy(QWaylandWlShellSurface::DefaultFocus);
setWindowType(Qt::WindowType::Window);
emit q->setDefaultToplevel();
}
@@ -179,12 +177,8 @@ void QWaylandWlShellSurfacePrivate::shell_surface_set_transient(Resource *resour
Q_UNUSED(resource);
Q_Q(QWaylandWlShellSurface);
QWaylandSurface *parent_surface = QWaylandSurface::fromResource(parent_surface_resource);
- QWaylandWlShellSurface::FocusPolicy focusPolicy =
- flags & WL_SHELL_SURFACE_TRANSIENT_INACTIVE ? QWaylandWlShellSurface::NoKeyboardFocus
- : QWaylandWlShellSurface::DefaultFocus;
- setFocusPolicy(focusPolicy);
setWindowType(Qt::WindowType::SubWindow);
- emit q->setTransient(parent_surface, QPoint(x,y), focusPolicy);
+ emit q->setTransient(parent_surface, QPoint(x,y), flags & WL_SHELL_SURFACE_TRANSIENT_INACTIVE);
}
void QWaylandWlShellSurfacePrivate::shell_surface_set_fullscreen(Resource *resource,
@@ -196,7 +190,6 @@ void QWaylandWlShellSurfacePrivate::shell_surface_set_fullscreen(Resource *resou
Q_UNUSED(method);
Q_UNUSED(framerate);
Q_Q(QWaylandWlShellSurface);
- setFocusPolicy(QWaylandWlShellSurface::DefaultFocus);
QWaylandOutput *output = output_resource
? QWaylandOutput::fromResource(output_resource)
: Q_NULLPTR;
@@ -210,7 +203,6 @@ void QWaylandWlShellSurfacePrivate::shell_surface_set_popup(Resource *resource,
Q_UNUSED(serial);
Q_UNUSED(flags);
Q_Q(QWaylandWlShellSurface);
- setFocusPolicy(QWaylandWlShellSurface::DefaultFocus);
QWaylandSeat *input = QWaylandSeat::fromSeatResource(input_device);
QWaylandSurface *parentSurface = QWaylandSurface::fromResource(parent);
setWindowType(Qt::WindowType::Popup);
@@ -223,7 +215,6 @@ void QWaylandWlShellSurfacePrivate::shell_surface_set_maximized(Resource *resour
{
Q_UNUSED(resource);
Q_Q(QWaylandWlShellSurface);
- setFocusPolicy(QWaylandWlShellSurface::DefaultFocus);
QWaylandOutput *output = output_resource
? QWaylandOutput::fromResource(output_resource)
: Q_NULLPTR;
@@ -307,14 +298,14 @@ void QWaylandWlShellSurfacePrivate::shell_surface_set_class(Resource *resource,
* Constructs a QWaylandWlShell object.
*/
QWaylandWlShell::QWaylandWlShell()
- : QWaylandCompositorExtensionTemplate<QWaylandWlShell>(*new QWaylandWlShellPrivate())
+ : QWaylandShellTemplate<QWaylandWlShell>(*new QWaylandWlShellPrivate())
{ }
/*!
* Constructs a QWaylandWlShell object for the provided \a compositor.
*/
QWaylandWlShell::QWaylandWlShell(QWaylandCompositor *compositor)
- : QWaylandCompositorExtensionTemplate<QWaylandWlShell>(compositor, *new QWaylandWlShellPrivate())
+ : QWaylandShellTemplate<QWaylandWlShell>(compositor, *new QWaylandWlShellPrivate())
{ }
@@ -324,7 +315,7 @@ QWaylandWlShell::QWaylandWlShell(QWaylandCompositor *compositor)
void QWaylandWlShell::initialize()
{
Q_D(QWaylandWlShell);
- QWaylandCompositorExtensionTemplate::initialize();
+ QWaylandShellTemplate::initialize();
QWaylandCompositor *compositor = static_cast<QWaylandCompositor *>(extensionContainer());
if (!compositor) {
qWarning() << "Failed to find QWaylandCompositor when initializing QWaylandWlShell";
@@ -615,32 +606,6 @@ QWaylandWlShell *QWaylandWlShellSurface::shell() const
}
/*!
- * \enum QWaylandWlShellSurface::FocusPolicy
- *
- * This enum type is used to specify the focus policy of a shell surface.
- *
- * \value DefaultFocus The default focus policy should be used.
- * \value NoKeyboardFocus The shell surface should not get keyboard focus.
- */
-
-/*!
- * \qmlproperty enum QtWaylandCompositor::WlShellSurface::focusPolicy
- *
- * This property holds the focus policy of the WlShellSurface.
- */
-
-/*!
- * \property QWaylandWlShellSurface::focusPolicy
- *
- * This property holds the focus policy of the QWaylandWlShellSurface.
- */
-QWaylandWlShellSurface::FocusPolicy QWaylandWlShellSurface::focusPolicy() const
-{
- Q_D(const QWaylandWlShellSurface);
- return d->m_focusPolicy;
-}
-
-/*!
* \qmlproperty enum QtWaylandCompositor::WlShellSurface::windowType
*
* This property holds the window type of the WlShellSurface.
diff --git a/src/compositor/extensions/qwaylandwlshell.h b/src/compositor/extensions/qwaylandwlshell.h
index e6cbf2268..7fe07e7a9 100644
--- a/src/compositor/extensions/qwaylandwlshell.h
+++ b/src/compositor/extensions/qwaylandwlshell.h
@@ -39,6 +39,7 @@
#include <QtWaylandCompositor/QWaylandCompositorExtension>
#include <QtWaylandCompositor/QWaylandResource>
+#include <QtWaylandCompositor/QWaylandShell>
#include <QtWaylandCompositor/QWaylandShellSurface>
#include <QtCore/QSize>
@@ -54,7 +55,7 @@ class QWaylandOutput;
class QWaylandSurfaceRole;
class QWaylandWlShellSurface;
-class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandWlShell : public QWaylandCompositorExtensionTemplate<QWaylandWlShell>
+class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandWlShell : public QWaylandShellTemplate<QWaylandWlShell>
{
Q_OBJECT
Q_DECLARE_PRIVATE(QWaylandWlShell)
@@ -87,7 +88,6 @@ class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandWlShellSurface : public QWaylandShellS
Q_PROPERTY(QWaylandWlShell *shell READ shell NOTIFY shellChanged)
Q_PROPERTY(QString title READ title NOTIFY titleChanged)
Q_PROPERTY(QString className READ className NOTIFY classNameChanged)
- Q_PROPERTY(FocusPolicy focusPolicy READ focusPolicy NOTIFY focusPolicyChanged)
public:
enum FullScreenMethod {
@@ -111,12 +111,6 @@ public:
};
Q_ENUM(ResizeEdge);
- enum FocusPolicy{
- DefaultFocus,
- NoKeyboardFocus
- };
- Q_ENUM(FocusPolicy)
-
QWaylandWlShellSurface();
QWaylandWlShellSurface(QWaylandWlShell *shell, QWaylandSurface *surface, const QWaylandResource &resource);
virtual ~QWaylandWlShellSurface();
@@ -129,7 +123,6 @@ public:
QWaylandSurface *surface() const;
QWaylandWlShell *shell() const;
- FocusPolicy focusPolicy() const;
Qt::WindowType windowType() const override;
static const struct wl_interface *interface();
@@ -154,13 +147,12 @@ Q_SIGNALS:
void shellChanged();
void titleChanged();
void classNameChanged();
- void focusPolicyChanged();
void pong();
void startMove(QWaylandSeat *seat);
void startResize(QWaylandSeat *seat, ResizeEdge edges);
void setDefaultToplevel();
- void setTransient(QWaylandSurface *parentSurface, const QPoint &relativeToParent, FocusPolicy focusPolicy);
+ void setTransient(QWaylandSurface *parentSurface, const QPoint &relativeToParent, bool inactive);
void setFullScreen(FullScreenMethod method, uint framerate, QWaylandOutput *output);
void setPopup(QWaylandSeat *seat, QWaylandSurface *parentSurface, const QPoint &relativeToParent);
void setMaximized(QWaylandOutput *output);
diff --git a/src/compositor/extensions/qwaylandwlshell_p.h b/src/compositor/extensions/qwaylandwlshell_p.h
index e840a01fe..5e8903090 100644
--- a/src/compositor/extensions/qwaylandwlshell_p.h
+++ b/src/compositor/extensions/qwaylandwlshell_p.h
@@ -94,15 +94,6 @@ public:
void ping(uint32_t serial);
- void setFocusPolicy(QWaylandWlShellSurface::FocusPolicy focusPolicy)
- {
- if (focusPolicy == m_focusPolicy)
- return;
- Q_Q(QWaylandWlShellSurface);
- m_focusPolicy = focusPolicy;
- emit q->focusPolicyChanged();
- }
-
void setWindowType(Qt::WindowType windowType);
private:
@@ -113,7 +104,6 @@ private:
QString m_title;
QString m_className;
- QWaylandWlShellSurface::FocusPolicy m_focusPolicy;
Qt::WindowType m_windowType;
void shell_surface_destroy_resource(Resource *resource) Q_DECL_OVERRIDE;
diff --git a/src/compositor/extensions/qwaylandwlshellintegration.cpp b/src/compositor/extensions/qwaylandwlshellintegration.cpp
index ba2fe5fb4..882db0d0d 100644
--- a/src/compositor/extensions/qwaylandwlshellintegration.cpp
+++ b/src/compositor/extensions/qwaylandwlshellintegration.cpp
@@ -57,6 +57,8 @@ WlShellIntegration::WlShellIntegration(QWaylandQuickShellSurfaceItem *item)
connect(m_shellSurface, &QWaylandWlShellSurface::startResize, this, &WlShellIntegration::handleStartResize);
connect(m_shellSurface->surface(), &QWaylandSurface::offsetForNextFrame, this, &WlShellIntegration::adjustOffsetForNextFrame);
connect(m_shellSurface->surface(), &QWaylandSurface::hasContentChanged, this, &WlShellIntegration::handleSurfaceHasContentChanged);
+ connect(m_shellSurface, &QWaylandWlShellSurface::setDefaultToplevel, this, &WlShellIntegration::handleSetDefaultTopLevel);
+ connect(m_shellSurface, &QWaylandWlShellSurface::setTransient, this, &WlShellIntegration::handleSetTransient);
connect(m_shellSurface, &QWaylandWlShellSurface::setPopup, this, &WlShellIntegration::handleSetPopup);
connect(m_shellSurface, &QWaylandWlShellSurface::destroyed, this, &WlShellIntegration::handleShellSurfaceDestroyed);
}
@@ -78,6 +80,23 @@ void WlShellIntegration::handleStartResize(QWaylandSeat *seat, QWaylandWlShellSu
resizeState.initialized = false;
}
+void WlShellIntegration::handleSetDefaultTopLevel()
+{
+ // Take focus if the policy allows
+ if (m_shellSurface->shell()->focusPolicy() == QWaylandShell::AutomaticFocus)
+ m_item->takeFocus();
+}
+
+void WlShellIntegration::handleSetTransient(QWaylandSurface *parentSurface, const QPoint &relativeToParent, bool inactive)
+{
+ Q_UNUSED(parentSurface)
+ Q_UNUSED(relativeToParent)
+
+ // Take focus if the policy allows and it's not inactive
+ if (m_shellSurface->shell()->focusPolicy() == QWaylandShell::AutomaticFocus && !inactive)
+ m_item->takeFocus();
+}
+
void WlShellIntegration::handleSetPopup(QWaylandSeat *seat, QWaylandSurface *parent, const QPoint &relativeToParent)
{
Q_UNUSED(seat);
diff --git a/src/compositor/extensions/qwaylandwlshellintegration_p.h b/src/compositor/extensions/qwaylandwlshellintegration_p.h
index 7d965ff07..7befe4bf9 100644
--- a/src/compositor/extensions/qwaylandwlshellintegration_p.h
+++ b/src/compositor/extensions/qwaylandwlshellintegration_p.h
@@ -67,6 +67,8 @@ public:
private Q_SLOTS:
void handleStartMove(QWaylandSeat *seat);
void handleStartResize(QWaylandSeat *seat, QWaylandWlShellSurface::ResizeEdge edges);
+ void handleSetDefaultTopLevel();
+ void handleSetTransient(QWaylandSurface *parentSurface, const QPoint &relativeToParent, bool inactive);
void handleSetPopup(QWaylandSeat *seat, QWaylandSurface *parent, const QPoint &relativeToParent);
void handleShellSurfaceDestroyed();
void handleSurfaceHasContentChanged();
diff --git a/src/compositor/extensions/qwaylandxdgshellv5.cpp b/src/compositor/extensions/qwaylandxdgshellv5.cpp
index a14f58e05..07453ffe5 100644
--- a/src/compositor/extensions/qwaylandxdgshellv5.cpp
+++ b/src/compositor/extensions/qwaylandxdgshellv5.cpp
@@ -501,14 +501,14 @@ void QWaylandXdgPopupV5Private::xdg_popup_destroy(Resource *resource)
* Constructs a QWaylandXdgShellV5 object.
*/
QWaylandXdgShellV5::QWaylandXdgShellV5()
- : QWaylandCompositorExtensionTemplate<QWaylandXdgShellV5>(*new QWaylandXdgShellV5Private())
+ : QWaylandShellTemplate<QWaylandXdgShellV5>(*new QWaylandXdgShellV5Private())
{ }
/*!
* Constructs a QWaylandXdgShellV5 object for the provided \a compositor.
*/
QWaylandXdgShellV5::QWaylandXdgShellV5(QWaylandCompositor *compositor)
- : QWaylandCompositorExtensionTemplate<QWaylandXdgShellV5>(compositor, *new QWaylandXdgShellV5Private())
+ : QWaylandShellTemplate<QWaylandXdgShellV5>(compositor, *new QWaylandXdgShellV5Private())
{ }
/*!
@@ -517,7 +517,7 @@ QWaylandXdgShellV5::QWaylandXdgShellV5(QWaylandCompositor *compositor)
void QWaylandXdgShellV5::initialize()
{
Q_D(QWaylandXdgShellV5);
- QWaylandCompositorExtensionTemplate::initialize();
+ QWaylandShellTemplate::initialize();
QWaylandCompositor *compositor = static_cast<QWaylandCompositor *>(extensionContainer());
if (!compositor) {
qWarning() << "Failed to find QWaylandCompositor when initializing QWaylandXdgShellV5";
diff --git a/src/compositor/extensions/qwaylandxdgshellv5.h b/src/compositor/extensions/qwaylandxdgshellv5.h
index 605701dd2..bcc740c7d 100644
--- a/src/compositor/extensions/qwaylandxdgshellv5.h
+++ b/src/compositor/extensions/qwaylandxdgshellv5.h
@@ -39,6 +39,7 @@
#include <QtWaylandCompositor/QWaylandCompositorExtension>
#include <QtWaylandCompositor/QWaylandResource>
+#include <QtWaylandCompositor/QWaylandShell>
#include <QtWaylandCompositor/QWaylandShellSurface>
#include <QtCore/QRect>
@@ -59,7 +60,7 @@ class QWaylandSeat;
class QWaylandOutput;
class QWaylandClient;
-class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgShellV5 : public QWaylandCompositorExtensionTemplate<QWaylandXdgShellV5>
+class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgShellV5 : public QWaylandShellTemplate<QWaylandXdgShellV5>
{
Q_OBJECT
Q_DECLARE_PRIVATE(QWaylandXdgShellV5)
diff --git a/src/compositor/extensions/qwaylandxdgshellv5integration.cpp b/src/compositor/extensions/qwaylandxdgshellv5integration.cpp
index 768747e44..f15b5c275 100644
--- a/src/compositor/extensions/qwaylandxdgshellv5integration.cpp
+++ b/src/compositor/extensions/qwaylandxdgshellv5integration.cpp
@@ -56,6 +56,8 @@ XdgShellV5Integration::XdgShellV5Integration(QWaylandQuickShellSurfaceItem *item
m_item->setSurface(m_xdgSurface->surface());
connect(m_xdgSurface, &QWaylandXdgSurfaceV5::startMove, this, &XdgShellV5Integration::handleStartMove);
connect(m_xdgSurface, &QWaylandXdgSurfaceV5::startResize, this, &XdgShellV5Integration::handleStartResize);
+ connect(m_xdgSurface, &QWaylandXdgSurfaceV5::setTopLevel, this, &XdgShellV5Integration::handleSetTopLevel);
+ connect(m_xdgSurface, &QWaylandXdgSurfaceV5::setTransient, this, &XdgShellV5Integration::handleSetTransient);
connect(m_xdgSurface, &QWaylandXdgSurfaceV5::setMaximized, this, &XdgShellV5Integration::handleSetMaximized);
connect(m_xdgSurface, &QWaylandXdgSurfaceV5::unsetMaximized, this, &XdgShellV5Integration::handleUnsetMaximized);
connect(m_xdgSurface, &QWaylandXdgSurfaceV5::maximizedChanged, this, &XdgShellV5Integration::handleMaximizedChanged);
@@ -124,6 +126,18 @@ void XdgShellV5Integration::handleStartResize(QWaylandSeat *seat, QWaylandXdgSur
resizeState.initialized = false;
}
+void XdgShellV5Integration::handleSetTopLevel()
+{
+ if (m_xdgSurface->shell()->focusPolicy() == QWaylandShell::AutomaticFocus)
+ m_item->takeFocus();
+}
+
+void XdgShellV5Integration::handleSetTransient()
+{
+ if (m_xdgSurface->shell()->focusPolicy() == QWaylandShell::AutomaticFocus)
+ m_item->takeFocus();
+}
+
void XdgShellV5Integration::handleSetMaximized()
{
maximizeState.initialWindowSize = m_xdgSurface->windowGeometry().size();
diff --git a/src/compositor/extensions/qwaylandxdgshellv5integration_p.h b/src/compositor/extensions/qwaylandxdgshellv5integration_p.h
index 61db435e5..da4573c76 100644
--- a/src/compositor/extensions/qwaylandxdgshellv5integration_p.h
+++ b/src/compositor/extensions/qwaylandxdgshellv5integration_p.h
@@ -66,6 +66,8 @@ public:
private Q_SLOTS:
void handleStartMove(QWaylandSeat *seat);
void handleStartResize(QWaylandSeat *seat, QWaylandXdgSurfaceV5::ResizeEdge edges);
+ void handleSetTopLevel();
+ void handleSetTransient();
void handleSetMaximized();
void handleUnsetMaximized();
void handleMaximizedChanged();
diff --git a/src/imports/compositor/qwaylandquickcompositorplugin.cpp b/src/imports/compositor/qwaylandquickcompositorplugin.cpp
index 45b46a811..037d9ccba 100644
--- a/src/imports/compositor/qwaylandquickcompositorplugin.cpp
+++ b/src/imports/compositor/qwaylandquickcompositorplugin.cpp
@@ -125,6 +125,7 @@ public:
qmlRegisterUncreatableType<QWaylandDrag>(uri, 1, 0, "WaylandDrag", QObject::tr("Cannot create instance of WaylandDrag"));
qmlRegisterUncreatableType<QWaylandCompositor>(uri, 1, 0, "WaylandCompositorBase", QObject::tr("Cannot create instance of WaylandCompositorBase, use WaylandCompositor instead"));
qmlRegisterUncreatableType<QWaylandSurface>(uri, 1, 0, "WaylandSurfaceBase", QObject::tr("Cannot create instance of WaylandSurfaceBase, use WaylandSurface instead"));
+ qmlRegisterUncreatableType<QWaylandShell>(uri, 1, 0, "Shell", QObject::tr("Cannot create instance of Shell"));
qmlRegisterUncreatableType<QWaylandShellSurface>(uri, 1, 0, "ShellSurface", QObject::tr("Cannot create instance of ShellSurface"));
qmlRegisterUncreatableType<QWaylandResource>(uri, 1, 0, "WaylandResource", QObject::tr("Cannot create instance of WaylandResource"));