diff options
Diffstat (limited to 'src/compositor/extensions')
94 files changed, 3165 insertions, 10250 deletions
diff --git a/src/compositor/extensions/extensions.pri b/src/compositor/extensions/extensions.pri index 61ab043ea..a3d329b8f 100644 --- a/src/compositor/extensions/extensions.pri +++ b/src/compositor/extensions/extensions.pri @@ -8,15 +8,17 @@ WAYLANDSERVERSOURCES += \ ../extensions/touch-extension.xml \ ../extensions/qt-key-unstable-v1.xml \ ../extensions/qt-windowmanager.xml \ + ../extensions/qt-text-input-method-unstable-v1.xml \ ../3rdparty/protocol/text-input-unstable-v2.xml \ ../3rdparty/protocol/viewporter.xml \ ../3rdparty/protocol/scaler.xml \ - ../3rdparty/protocol/xdg-shell-unstable-v6.xml \ ../3rdparty/protocol/xdg-shell.xml \ ../3rdparty/protocol/xdg-decoration-unstable-v1.xml \ ../3rdparty/protocol/xdg-output-unstable-v1.xml \ ../3rdparty/protocol/ivi-application.xml \ ../3rdparty/protocol/idle-inhibit-unstable-v1.xml \ + ../extensions/qt-texture-sharing-unstable-v1.xml \ + ../3rdparty/protocol/presentation-time.xml \ HEADERS += \ extensions/qwlqttouch_p.h \ @@ -29,16 +31,14 @@ HEADERS += \ extensions/qwaylandtextinput_p.h \ extensions/qwaylandtextinputmanager.h \ extensions/qwaylandtextinputmanager_p.h \ + extensions/qwaylandqttextinputmethodmanager.h \ + extensions/qwaylandqttextinputmethodmanager_p.h \ + extensions/qwaylandqttextinputmethod.h \ + extensions/qwaylandqttextinputmethod_p.h \ extensions/qwaylandqtwindowmanager.h \ extensions/qwaylandqtwindowmanager_p.h \ extensions/qwaylandviewporter.h \ extensions/qwaylandviewporter_p.h \ - extensions/qwaylandwlscaler.h \ - extensions/qwaylandwlscaler_p.h \ - extensions/qwaylandxdgshellv5.h \ - extensions/qwaylandxdgshellv5_p.h \ - extensions/qwaylandxdgshellv6.h \ - extensions/qwaylandxdgshellv6_p.h \ extensions/qwaylandxdgshell.h \ extensions/qwaylandxdgshell_p.h \ extensions/qwaylandxdgdecorationv1.h \ @@ -60,11 +60,10 @@ SOURCES += \ extensions/qwaylandwlshell.cpp \ extensions/qwaylandtextinput.cpp \ extensions/qwaylandtextinputmanager.cpp \ + extensions/qwaylandqttextinputmethodmanager.cpp \ + extensions/qwaylandqttextinputmethod.cpp \ extensions/qwaylandqtwindowmanager.cpp \ extensions/qwaylandviewporter.cpp \ - extensions/qwaylandwlscaler.cpp \ - extensions/qwaylandxdgshellv5.cpp \ - extensions/qwaylandxdgshellv6.cpp \ extensions/qwaylandxdgshell.cpp \ extensions/qwaylandxdgdecorationv1.cpp \ extensions/qwaylandxdgoutputv1.cpp \ @@ -73,7 +72,9 @@ SOURCES += \ extensions/qwaylandiviapplication.cpp \ extensions/qwaylandivisurface.cpp \ -qtHaveModule(quick) { +qtConfig(wayland-compositor-quick) { + QT += quick quick-private + HEADERS += \ extensions/qwaylandquickshellintegration.h \ extensions/qwaylandquickshellsurfaceitem.h \ @@ -81,9 +82,9 @@ qtHaveModule(quick) { extensions/qwaylandivisurfaceintegration_p.h \ extensions/qwaylandwlshellintegration_p.h \ extensions/qwaylandquickxdgoutputv1.h \ - extensions/qwaylandxdgshellv5integration_p.h \ - extensions/qwaylandxdgshellv6integration_p.h \ extensions/qwaylandxdgshellintegration_p.h \ + extensions/qwaylandpresentationtime_p.h \ + extensions/qwaylandpresentationtime_p_p.h \ SOURCES += \ extensions/qwaylandquickshellintegration.cpp \ @@ -91,14 +92,10 @@ qtHaveModule(quick) { extensions/qwaylandivisurfaceintegration.cpp \ extensions/qwaylandwlshellintegration.cpp \ extensions/qwaylandquickxdgoutputv1.cpp \ - extensions/qwaylandxdgshellv5integration.cpp \ - extensions/qwaylandxdgshellv6integration.cpp \ extensions/qwaylandxdgshellintegration.cpp \ + extensions/qwaylandpresentationtime.cpp \ qtConfig(opengl) { - WAYLANDSERVERSOURCES += \ - ../extensions/qt-texture-sharing-unstable-v1.xml - HEADERS += \ extensions/qwltexturesharingextension_p.h @@ -107,6 +104,4 @@ qtHaveModule(quick) { } } -include ($$PWD/pregenerated/xdg-shell-v5.pri) - INCLUDEPATH += extensions diff --git a/src/compositor/extensions/pregenerated/3rdparty/qwayland-server-xdg-shell-unstable-v5.cpp b/src/compositor/extensions/pregenerated/3rdparty/qwayland-server-xdg-shell-unstable-v5.cpp deleted file mode 100644 index 78877171b..000000000 --- a/src/compositor/extensions/pregenerated/3rdparty/qwayland-server-xdg-shell-unstable-v5.cpp +++ /dev/null @@ -1,890 +0,0 @@ -/* - * Copyright © 2008-2013 Kristian Høgsberg - * Copyright © 2013 Rafael Antognolli - * Copyright © 2013 Jasper St. Pierre - * Copyright © 2010-2013 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#include <QtWaylandCompositor/private/qwayland-server-xdg-shell-unstable-v5_p.h> - -QT_BEGIN_NAMESPACE -QT_WARNING_PUSH -QT_WARNING_DISABLE_GCC("-Wmissing-field-initializers") - -namespace QtWaylandServer { - xdg_shell_v5::xdg_shell_v5(struct ::wl_client *client, int id, int version) - : m_resource_map() - , m_resource(nullptr) - , m_global(nullptr) - { - init(client, id, version); - } - - xdg_shell_v5::xdg_shell_v5(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(nullptr) - , m_global(nullptr) - { - init(display, version); - } - - xdg_shell_v5::xdg_shell_v5(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(nullptr) - , m_global(nullptr) - { - init(resource); - } - - xdg_shell_v5::xdg_shell_v5() - : m_resource_map() - , m_resource(nullptr) - , m_global(nullptr) - { - } - - xdg_shell_v5::~xdg_shell_v5() - { - for (auto resource : qAsConst(m_resource_map)) - wl_resource_set_implementation(resource->handle, nullptr, nullptr, nullptr); - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void xdg_shell_v5::init(struct ::wl_client *client, int id, int version) - { - m_resource = bind(client, id, version); - } - - void xdg_shell_v5::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - xdg_shell_v5::Resource *xdg_shell_v5::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(client, resource); - return resource; - } - - xdg_shell_v5::Resource *xdg_shell_v5::add(struct ::wl_client *client, int id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(client, resource); - return resource; - } - - void xdg_shell_v5::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::xdg_shell_v5_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = xdg_shell_v5::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *xdg_shell_v5::interface() - { - return &::xdg_shell_v5_interface; - } - - xdg_shell_v5::Resource *xdg_shell_v5::xdg_shell_allocate() - { - return new Resource; - } - - void xdg_shell_v5::xdg_shell_bind_resource(Resource *) - { - } - - void xdg_shell_v5::xdg_shell_destroy_resource(Resource *) - { - } - - void xdg_shell_v5::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - xdg_shell_v5 *that = static_cast<xdg_shell_v5 *>(data); - that->add(client, id, qMin(that->m_globalVersion, version)); - } - - void xdg_shell_v5::display_destroy_func(struct ::wl_listener *listener, void *data) - { - Q_UNUSED(data); - xdg_shell_v5 *that = static_cast<xdg_shell_v5::DisplayDestroyedListener *>(listener)->parent; - that->m_global = nullptr; - } - - void xdg_shell_v5::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - xdg_shell_v5 *that = resource->xdg_shell_object; - that->m_resource_map.remove(resource->client(), resource); - that->xdg_shell_destroy_resource(resource); - delete resource; - } - - xdg_shell_v5::Resource *xdg_shell_v5::bind(struct ::wl_client *client, uint32_t id, int version) - { - Q_ASSERT_X(!wl_client_get_object(client, id), "QWaylandObject bind", QStringLiteral("binding to object %1 more than once").arg(id).toLocal8Bit().constData()); - struct ::wl_resource *handle = wl_resource_create(client, &::xdg_shell_v5_interface, version, id); - return bind(handle); - } - - xdg_shell_v5::Resource *xdg_shell_v5::bind(struct ::wl_resource *handle) - { - Resource *resource = xdg_shell_allocate(); - resource->xdg_shell_object = this; - - wl_resource_set_implementation(handle, &m_xdg_shell_interface, resource, destroy_func); - resource->handle = handle; - xdg_shell_bind_resource(resource); - return resource; - } - xdg_shell_v5::Resource *xdg_shell_v5::Resource::fromResource(struct ::wl_resource *resource) - { - if (wl_resource_instance_of(resource, &::xdg_shell_v5_interface, &m_xdg_shell_interface)) - return static_cast<Resource *>(resource->data); - return nullptr; - } - - const struct ::xdg_shell_v5_interface xdg_shell_v5::m_xdg_shell_interface = { - xdg_shell_v5::handle_destroy, - xdg_shell_v5::handle_use_unstable_version, - xdg_shell_v5::handle_get_xdg_surface, - xdg_shell_v5::handle_get_xdg_popup, - xdg_shell_v5::handle_pong - }; - - void xdg_shell_v5::xdg_shell_destroy(Resource *) - { - } - - void xdg_shell_v5::xdg_shell_use_unstable_version(Resource *, int32_t ) - { - } - - void xdg_shell_v5::xdg_shell_get_xdg_surface(Resource *, uint32_t, struct ::wl_resource *) - { - } - - void xdg_shell_v5::xdg_shell_get_xdg_popup(Resource *, uint32_t, struct ::wl_resource *, struct ::wl_resource *, struct ::wl_resource *, uint32_t , int32_t , int32_t ) - { - } - - void xdg_shell_v5::xdg_shell_pong(Resource *, uint32_t ) - { - } - - - void xdg_shell_v5::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - Q_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast<xdg_shell_v5 *>(r->xdg_shell_object)->xdg_shell_destroy( - r); - } - - void xdg_shell_v5::handle_use_unstable_version( - ::wl_client *client, - struct wl_resource *resource, - int32_t version) - { - Q_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast<xdg_shell_v5 *>(r->xdg_shell_object)->xdg_shell_use_unstable_version( - r, - version); - } - - void xdg_shell_v5::handle_get_xdg_surface( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct ::wl_resource *surface) - { - Q_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast<xdg_shell_v5 *>(r->xdg_shell_object)->xdg_shell_get_xdg_surface( - r, - id, - surface); - } - - void xdg_shell_v5::handle_get_xdg_popup( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct ::wl_resource *surface, - struct ::wl_resource *parent, - struct ::wl_resource *seat, - uint32_t serial, - int32_t x, - int32_t y) - { - Q_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast<xdg_shell_v5 *>(r->xdg_shell_object)->xdg_shell_get_xdg_popup( - r, - id, - surface, - parent, - seat, - serial, - x, - y); - } - - void xdg_shell_v5::handle_pong( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial) - { - Q_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast<xdg_shell_v5 *>(r->xdg_shell_object)->xdg_shell_pong( - r, - serial); - } - - void xdg_shell_v5::send_ping(uint32_t serial) - { - send_ping( - m_resource->handle, - serial); - } - - void xdg_shell_v5::send_ping(struct ::wl_resource *resource, uint32_t serial) - { - xdg_shell_send_ping( - resource, - serial); - } - - - xdg_surface_v5::xdg_surface_v5(struct ::wl_client *client, int id, int version) - : m_resource_map() - , m_resource(nullptr) - , m_global(nullptr) - { - init(client, id, version); - } - - xdg_surface_v5::xdg_surface_v5(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(nullptr) - , m_global(nullptr) - { - init(display, version); - } - - xdg_surface_v5::xdg_surface_v5(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(nullptr) - , m_global(nullptr) - { - init(resource); - } - - xdg_surface_v5::xdg_surface_v5() - : m_resource_map() - , m_resource(nullptr) - , m_global(nullptr) - { - } - - xdg_surface_v5::~xdg_surface_v5() - { - for (auto resource : qAsConst(m_resource_map)) - wl_resource_set_implementation(resource->handle, nullptr, nullptr, nullptr); - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void xdg_surface_v5::init(struct ::wl_client *client, int id, int version) - { - m_resource = bind(client, id, version); - } - - void xdg_surface_v5::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - xdg_surface_v5::Resource *xdg_surface_v5::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(client, resource); - return resource; - } - - xdg_surface_v5::Resource *xdg_surface_v5::add(struct ::wl_client *client, int id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(client, resource); - return resource; - } - - void xdg_surface_v5::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::xdg_surface_v5_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = xdg_surface_v5::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *xdg_surface_v5::interface() - { - return &::xdg_surface_v5_interface; - } - - xdg_surface_v5::Resource *xdg_surface_v5::xdg_surface_allocate() - { - return new Resource; - } - - void xdg_surface_v5::xdg_surface_bind_resource(Resource *) - { - } - - void xdg_surface_v5::xdg_surface_destroy_resource(Resource *) - { - } - - void xdg_surface_v5::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - xdg_surface_v5 *that = static_cast<xdg_surface_v5 *>(data); - that->add(client, id, qMin(that->m_globalVersion, version)); - } - - void xdg_surface_v5::display_destroy_func(struct ::wl_listener *listener, void *data) - { - Q_UNUSED(data); - xdg_surface_v5 *that = static_cast<xdg_surface_v5::DisplayDestroyedListener *>(listener)->parent; - that->m_global = nullptr; - } - - void xdg_surface_v5::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - xdg_surface_v5 *that = resource->xdg_surface_object; - that->m_resource_map.remove(resource->client(), resource); - that->xdg_surface_destroy_resource(resource); - delete resource; - } - - xdg_surface_v5::Resource *xdg_surface_v5::bind(struct ::wl_client *client, uint32_t id, int version) - { - Q_ASSERT_X(!wl_client_get_object(client, id), "QWaylandObject bind", QStringLiteral("binding to object %1 more than once").arg(id).toLocal8Bit().constData()); - struct ::wl_resource *handle = wl_resource_create(client, &::xdg_surface_v5_interface, version, id); - return bind(handle); - } - - xdg_surface_v5::Resource *xdg_surface_v5::bind(struct ::wl_resource *handle) - { - Resource *resource = xdg_surface_allocate(); - resource->xdg_surface_object = this; - - wl_resource_set_implementation(handle, &m_xdg_surface_interface, resource, destroy_func); - resource->handle = handle; - xdg_surface_bind_resource(resource); - return resource; - } - xdg_surface_v5::Resource *xdg_surface_v5::Resource::fromResource(struct ::wl_resource *resource) - { - if (wl_resource_instance_of(resource, &::xdg_surface_v5_interface, &m_xdg_surface_interface)) - return static_cast<Resource *>(resource->data); - return nullptr; - } - - const struct ::xdg_surface_v5_interface xdg_surface_v5::m_xdg_surface_interface = { - xdg_surface_v5::handle_destroy, - xdg_surface_v5::handle_set_parent, - xdg_surface_v5::handle_set_title, - xdg_surface_v5::handle_set_app_id, - xdg_surface_v5::handle_show_window_menu, - xdg_surface_v5::handle_move, - xdg_surface_v5::handle_resize, - xdg_surface_v5::handle_ack_configure, - xdg_surface_v5::handle_set_window_geometry, - xdg_surface_v5::handle_set_maximized, - xdg_surface_v5::handle_unset_maximized, - xdg_surface_v5::handle_set_fullscreen, - xdg_surface_v5::handle_unset_fullscreen, - xdg_surface_v5::handle_set_minimized - }; - - void xdg_surface_v5::xdg_surface_destroy(Resource *) - { - } - - void xdg_surface_v5::xdg_surface_set_parent(Resource *, struct ::wl_resource *) - { - } - - void xdg_surface_v5::xdg_surface_set_title(Resource *, const QString &) - { - } - - void xdg_surface_v5::xdg_surface_set_app_id(Resource *, const QString &) - { - } - - void xdg_surface_v5::xdg_surface_show_window_menu(Resource *, struct ::wl_resource *, uint32_t , int32_t , int32_t ) - { - } - - void xdg_surface_v5::xdg_surface_move(Resource *, struct ::wl_resource *, uint32_t ) - { - } - - void xdg_surface_v5::xdg_surface_resize(Resource *, struct ::wl_resource *, uint32_t , uint32_t ) - { - } - - void xdg_surface_v5::xdg_surface_ack_configure(Resource *, uint32_t ) - { - } - - void xdg_surface_v5::xdg_surface_set_window_geometry(Resource *, int32_t , int32_t , int32_t , int32_t ) - { - } - - void xdg_surface_v5::xdg_surface_set_maximized(Resource *) - { - } - - void xdg_surface_v5::xdg_surface_unset_maximized(Resource *) - { - } - - void xdg_surface_v5::xdg_surface_set_fullscreen(Resource *, struct ::wl_resource *) - { - } - - void xdg_surface_v5::xdg_surface_unset_fullscreen(Resource *) - { - } - - void xdg_surface_v5::xdg_surface_set_minimized(Resource *) - { - } - - - void xdg_surface_v5::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - Q_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast<xdg_surface_v5 *>(r->xdg_surface_object)->xdg_surface_destroy( - r); - } - - void xdg_surface_v5::handle_set_parent( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *parent) - { - Q_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast<xdg_surface_v5 *>(r->xdg_surface_object)->xdg_surface_set_parent( - r, - parent); - } - - void xdg_surface_v5::handle_set_title( - ::wl_client *client, - struct wl_resource *resource, - const char *title) - { - Q_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast<xdg_surface_v5 *>(r->xdg_surface_object)->xdg_surface_set_title( - r, - QString::fromUtf8(title)); - } - - void xdg_surface_v5::handle_set_app_id( - ::wl_client *client, - struct wl_resource *resource, - const char *app_id) - { - Q_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast<xdg_surface_v5 *>(r->xdg_surface_object)->xdg_surface_set_app_id( - r, - QString::fromUtf8(app_id)); - } - - void xdg_surface_v5::handle_show_window_menu( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *seat, - uint32_t serial, - int32_t x, - int32_t y) - { - Q_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast<xdg_surface_v5 *>(r->xdg_surface_object)->xdg_surface_show_window_menu( - r, - seat, - serial, - x, - y); - } - - void xdg_surface_v5::handle_move( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *seat, - uint32_t serial) - { - Q_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast<xdg_surface_v5 *>(r->xdg_surface_object)->xdg_surface_move( - r, - seat, - serial); - } - - void xdg_surface_v5::handle_resize( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *seat, - uint32_t serial, - uint32_t edges) - { - Q_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast<xdg_surface_v5 *>(r->xdg_surface_object)->xdg_surface_resize( - r, - seat, - serial, - edges); - } - - void xdg_surface_v5::handle_ack_configure( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial) - { - Q_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast<xdg_surface_v5 *>(r->xdg_surface_object)->xdg_surface_ack_configure( - r, - serial); - } - - void xdg_surface_v5::handle_set_window_geometry( - ::wl_client *client, - struct wl_resource *resource, - int32_t x, - int32_t y, - int32_t width, - int32_t height) - { - Q_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast<xdg_surface_v5 *>(r->xdg_surface_object)->xdg_surface_set_window_geometry( - r, - x, - y, - width, - height); - } - - void xdg_surface_v5::handle_set_maximized( - ::wl_client *client, - struct wl_resource *resource) - { - Q_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast<xdg_surface_v5 *>(r->xdg_surface_object)->xdg_surface_set_maximized( - r); - } - - void xdg_surface_v5::handle_unset_maximized( - ::wl_client *client, - struct wl_resource *resource) - { - Q_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast<xdg_surface_v5 *>(r->xdg_surface_object)->xdg_surface_unset_maximized( - r); - } - - void xdg_surface_v5::handle_set_fullscreen( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *output) - { - Q_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast<xdg_surface_v5 *>(r->xdg_surface_object)->xdg_surface_set_fullscreen( - r, - output); - } - - void xdg_surface_v5::handle_unset_fullscreen( - ::wl_client *client, - struct wl_resource *resource) - { - Q_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast<xdg_surface_v5 *>(r->xdg_surface_object)->xdg_surface_unset_fullscreen( - r); - } - - void xdg_surface_v5::handle_set_minimized( - ::wl_client *client, - struct wl_resource *resource) - { - Q_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast<xdg_surface_v5 *>(r->xdg_surface_object)->xdg_surface_set_minimized( - r); - } - - void xdg_surface_v5::send_configure(int32_t width, int32_t height, const QByteArray &states, uint32_t serial) - { - send_configure( - m_resource->handle, - width, - height, - states, - serial); - } - - void xdg_surface_v5::send_configure(struct ::wl_resource *resource, int32_t width, int32_t height, const QByteArray &states, uint32_t serial) - { - struct wl_array states_data; - states_data.size = states.size(); - states_data.data = static_cast<void *>(const_cast<char *>(states.constData())); - states_data.alloc = 0; - - xdg_surface_send_configure( - resource, - width, - height, - &states_data, - serial); - } - - - void xdg_surface_v5::send_close() - { - send_close( - m_resource->handle); - } - - void xdg_surface_v5::send_close(struct ::wl_resource *resource) - { - xdg_surface_send_close( - resource); - } - - - xdg_popup_v5::xdg_popup_v5(struct ::wl_client *client, int id, int version) - : m_resource_map() - , m_resource(nullptr) - , m_global(nullptr) - { - init(client, id, version); - } - - xdg_popup_v5::xdg_popup_v5(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(nullptr) - , m_global(nullptr) - { - init(display, version); - } - - xdg_popup_v5::xdg_popup_v5(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(nullptr) - , m_global(nullptr) - { - init(resource); - } - - xdg_popup_v5::xdg_popup_v5() - : m_resource_map() - , m_resource(nullptr) - , m_global(nullptr) - { - } - - xdg_popup_v5::~xdg_popup_v5() - { - for (auto resource : qAsConst(m_resource_map)) - wl_resource_set_implementation(resource->handle, nullptr, nullptr, nullptr); - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void xdg_popup_v5::init(struct ::wl_client *client, int id, int version) - { - m_resource = bind(client, id, version); - } - - void xdg_popup_v5::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - xdg_popup_v5::Resource *xdg_popup_v5::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(client, resource); - return resource; - } - - xdg_popup_v5::Resource *xdg_popup_v5::add(struct ::wl_client *client, int id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(client, resource); - return resource; - } - - void xdg_popup_v5::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::xdg_popup_v5_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = xdg_popup_v5::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *xdg_popup_v5::interface() - { - return &::xdg_popup_v5_interface; - } - - xdg_popup_v5::Resource *xdg_popup_v5::xdg_popup_allocate() - { - return new Resource; - } - - void xdg_popup_v5::xdg_popup_bind_resource(Resource *) - { - } - - void xdg_popup_v5::xdg_popup_destroy_resource(Resource *) - { - } - - void xdg_popup_v5::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - xdg_popup_v5 *that = static_cast<xdg_popup_v5 *>(data); - that->add(client, id, qMin(that->m_globalVersion, version)); - } - - void xdg_popup_v5::display_destroy_func(struct ::wl_listener *listener, void *data) - { - Q_UNUSED(data); - xdg_popup_v5 *that = static_cast<xdg_popup_v5::DisplayDestroyedListener *>(listener)->parent; - that->m_global = nullptr; - } - - void xdg_popup_v5::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - xdg_popup_v5 *that = resource->xdg_popup_object; - that->m_resource_map.remove(resource->client(), resource); - that->xdg_popup_destroy_resource(resource); - delete resource; - } - - xdg_popup_v5::Resource *xdg_popup_v5::bind(struct ::wl_client *client, uint32_t id, int version) - { - Q_ASSERT_X(!wl_client_get_object(client, id), "QWaylandObject bind", QStringLiteral("binding to object %1 more than once").arg(id).toLocal8Bit().constData()); - struct ::wl_resource *handle = wl_resource_create(client, &::xdg_popup_v5_interface, version, id); - return bind(handle); - } - - xdg_popup_v5::Resource *xdg_popup_v5::bind(struct ::wl_resource *handle) - { - Resource *resource = xdg_popup_allocate(); - resource->xdg_popup_object = this; - - wl_resource_set_implementation(handle, &m_xdg_popup_interface, resource, destroy_func); - resource->handle = handle; - xdg_popup_bind_resource(resource); - return resource; - } - xdg_popup_v5::Resource *xdg_popup_v5::Resource::fromResource(struct ::wl_resource *resource) - { - if (wl_resource_instance_of(resource, &::xdg_popup_v5_interface, &m_xdg_popup_interface)) - return static_cast<Resource *>(resource->data); - return nullptr; - } - - const struct ::xdg_popup_v5_interface xdg_popup_v5::m_xdg_popup_interface = { - xdg_popup_v5::handle_destroy - }; - - void xdg_popup_v5::xdg_popup_destroy(Resource *) - { - } - - - void xdg_popup_v5::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - Q_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast<xdg_popup_v5 *>(r->xdg_popup_object)->xdg_popup_destroy( - r); - } - - void xdg_popup_v5::send_popup_done() - { - send_popup_done( - m_resource->handle); - } - - void xdg_popup_v5::send_popup_done(struct ::wl_resource *resource) - { - xdg_popup_send_popup_done( - resource); - } - -} - -QT_WARNING_POP -QT_END_NAMESPACE diff --git a/src/compositor/extensions/pregenerated/3rdparty/qwayland-server-xdg-shell-unstable-v5_p.h b/src/compositor/extensions/pregenerated/3rdparty/qwayland-server-xdg-shell-unstable-v5_p.h deleted file mode 100644 index 8124860b9..000000000 --- a/src/compositor/extensions/pregenerated/3rdparty/qwayland-server-xdg-shell-unstable-v5_p.h +++ /dev/null @@ -1,439 +0,0 @@ -/* - * Copyright © 2008-2013 Kristian Høgsberg - * Copyright © 2013 Rafael Antognolli - * Copyright © 2013 Jasper St. Pierre - * Copyright © 2010-2013 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#ifndef QT_WAYLAND_SERVER_XDG_SHELL_UNSTABLE_V5 -#define QT_WAYLAND_SERVER_XDG_SHELL_UNSTABLE_V5 - -#include "wayland-server.h" -#include <QtWaylandCompositor/private/wayland-xdg-shell-unstable-v5-server-protocol_p.h> -#include <QByteArray> -#include <QMultiMap> -#include <QString> - -#ifndef WAYLAND_VERSION_CHECK -#define WAYLAND_VERSION_CHECK(major, minor, micro) \ - ((WAYLAND_VERSION_MAJOR > (major)) || \ - (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR > (minor)) || \ - (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR == (minor) && WAYLAND_VERSION_MICRO >= (micro))) -#endif - -QT_BEGIN_NAMESPACE -QT_WARNING_PUSH -QT_WARNING_DISABLE_GCC("-Wmissing-field-initializers") -QT_WARNING_DISABLE_CLANG("-Wmissing-field-initializers") - -#if !defined(Q_WAYLAND_SERVER_XDG_SHELL_UNSTABLE_V5_EXPORT) -# if defined(QT_SHARED) -# define Q_WAYLAND_SERVER_XDG_SHELL_UNSTABLE_V5_EXPORT Q_DECL_EXPORT -# else -# define Q_WAYLAND_SERVER_XDG_SHELL_UNSTABLE_V5_EXPORT -# endif -#endif - -namespace QtWaylandServer { - class Q_WAYLAND_SERVER_XDG_SHELL_UNSTABLE_V5_EXPORT xdg_shell_v5 - { - public: - xdg_shell_v5(struct ::wl_client *client, int id, int version); - xdg_shell_v5(struct ::wl_display *display, int version); - xdg_shell_v5(struct ::wl_resource *resource); - xdg_shell_v5(); - - virtual ~xdg_shell_v5(); - - class Resource - { - public: - Resource() : xdg_shell_object(nullptr), handle(nullptr) {} - virtual ~Resource() {} - - xdg_shell_v5 *xdg_shell_object; - xdg_shell_v5 *object() { return xdg_shell_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, int id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, int id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, int id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - QMultiMap<struct ::wl_client*, Resource*> resourceMap() { return m_resource_map; } - const QMultiMap<struct ::wl_client*, Resource*> resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != nullptr; } - bool isResource() const { return m_resource != nullptr; } - - static const struct ::wl_interface *interface(); - static QByteArray interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum version { - version_current = 5 // Always the latest version - }; - - enum error { - error_role = 0, // given wl_surface has another role - error_defunct_surfaces = 1, // xdg_shell was destroyed before children - error_not_the_topmost_popup = 2, // the client tried to map or destroy a non-topmost popup - error_invalid_popup_parent = 3 // the client specified an invalid popup parent surface - }; - - void send_ping(uint32_t serial); - void send_ping(struct ::wl_resource *resource, uint32_t serial); - - protected: - virtual Resource *xdg_shell_allocate(); - - virtual void xdg_shell_bind_resource(Resource *resource); - virtual void xdg_shell_destroy_resource(Resource *resource); - - virtual void xdg_shell_destroy(Resource *resource); - virtual void xdg_shell_use_unstable_version(Resource *resource, int32_t version); - virtual void xdg_shell_get_xdg_surface(Resource *resource, uint32_t id, struct ::wl_resource *surface); - virtual void xdg_shell_get_xdg_popup(Resource *resource, uint32_t id, struct ::wl_resource *surface, struct ::wl_resource *parent, struct ::wl_resource *seat, uint32_t serial, int32_t x, int32_t y); - virtual void xdg_shell_pong(Resource *resource, uint32_t serial); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::xdg_shell_v5_interface m_xdg_shell_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - static void handle_use_unstable_version( - ::wl_client *client, - struct wl_resource *resource, - int32_t version); - static void handle_get_xdg_surface( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct ::wl_resource *surface); - static void handle_get_xdg_popup( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct ::wl_resource *surface, - struct ::wl_resource *parent, - struct ::wl_resource *seat, - uint32_t serial, - int32_t x, - int32_t y); - static void handle_pong( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial); - - QMultiMap<struct ::wl_client*, Resource*> m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - xdg_shell_v5 *parent; - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class Q_WAYLAND_SERVER_XDG_SHELL_UNSTABLE_V5_EXPORT xdg_surface_v5 - { - public: - xdg_surface_v5(struct ::wl_client *client, int id, int version); - xdg_surface_v5(struct ::wl_display *display, int version); - xdg_surface_v5(struct ::wl_resource *resource); - xdg_surface_v5(); - - virtual ~xdg_surface_v5(); - - class Resource - { - public: - Resource() : xdg_surface_object(nullptr), handle(nullptr) {} - virtual ~Resource() {} - - xdg_surface_v5 *xdg_surface_object; - xdg_surface_v5 *object() { return xdg_surface_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, int id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, int id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, int id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - QMultiMap<struct ::wl_client*, Resource*> resourceMap() { return m_resource_map; } - const QMultiMap<struct ::wl_client*, Resource*> resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != nullptr; } - bool isResource() const { return m_resource != nullptr; } - - static const struct ::wl_interface *interface(); - static QByteArray interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum resize_edge { - resize_edge_none = 0, - resize_edge_top = 1, - resize_edge_bottom = 2, - resize_edge_left = 4, - resize_edge_top_left = 5, - resize_edge_bottom_left = 6, - resize_edge_right = 8, - resize_edge_top_right = 9, - resize_edge_bottom_right = 10 - }; - - enum state { - state_maximized = 1, // the surface is maximized - state_fullscreen = 2, // the surface is fullscreen - state_resizing = 3, - state_activated = 4 - }; - - void send_configure(int32_t width, int32_t height, const QByteArray &states, uint32_t serial); - void send_configure(struct ::wl_resource *resource, int32_t width, int32_t height, const QByteArray &states, uint32_t serial); - void send_close(); - void send_close(struct ::wl_resource *resource); - - protected: - virtual Resource *xdg_surface_allocate(); - - virtual void xdg_surface_bind_resource(Resource *resource); - virtual void xdg_surface_destroy_resource(Resource *resource); - - virtual void xdg_surface_destroy(Resource *resource); - virtual void xdg_surface_set_parent(Resource *resource, struct ::wl_resource *parent); - virtual void xdg_surface_set_title(Resource *resource, const QString &title); - virtual void xdg_surface_set_app_id(Resource *resource, const QString &app_id); - virtual void xdg_surface_show_window_menu(Resource *resource, struct ::wl_resource *seat, uint32_t serial, int32_t x, int32_t y); - virtual void xdg_surface_move(Resource *resource, struct ::wl_resource *seat, uint32_t serial); - virtual void xdg_surface_resize(Resource *resource, struct ::wl_resource *seat, uint32_t serial, uint32_t edges); - virtual void xdg_surface_ack_configure(Resource *resource, uint32_t serial); - virtual void xdg_surface_set_window_geometry(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height); - virtual void xdg_surface_set_maximized(Resource *resource); - virtual void xdg_surface_unset_maximized(Resource *resource); - virtual void xdg_surface_set_fullscreen(Resource *resource, struct ::wl_resource *output); - virtual void xdg_surface_unset_fullscreen(Resource *resource); - virtual void xdg_surface_set_minimized(Resource *resource); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::xdg_surface_v5_interface m_xdg_surface_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - static void handle_set_parent( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *parent); - static void handle_set_title( - ::wl_client *client, - struct wl_resource *resource, - const char *title); - static void handle_set_app_id( - ::wl_client *client, - struct wl_resource *resource, - const char *app_id); - static void handle_show_window_menu( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *seat, - uint32_t serial, - int32_t x, - int32_t y); - static void handle_move( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *seat, - uint32_t serial); - static void handle_resize( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *seat, - uint32_t serial, - uint32_t edges); - static void handle_ack_configure( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial); - static void handle_set_window_geometry( - ::wl_client *client, - struct wl_resource *resource, - int32_t x, - int32_t y, - int32_t width, - int32_t height); - static void handle_set_maximized( - ::wl_client *client, - struct wl_resource *resource); - static void handle_unset_maximized( - ::wl_client *client, - struct wl_resource *resource); - static void handle_set_fullscreen( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *output); - static void handle_unset_fullscreen( - ::wl_client *client, - struct wl_resource *resource); - static void handle_set_minimized( - ::wl_client *client, - struct wl_resource *resource); - - QMultiMap<struct ::wl_client*, Resource*> m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - xdg_surface_v5 *parent; - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class Q_WAYLAND_SERVER_XDG_SHELL_UNSTABLE_V5_EXPORT xdg_popup_v5 - { - public: - xdg_popup_v5(struct ::wl_client *client, int id, int version); - xdg_popup_v5(struct ::wl_display *display, int version); - xdg_popup_v5(struct ::wl_resource *resource); - xdg_popup_v5(); - - virtual ~xdg_popup_v5(); - - class Resource - { - public: - Resource() : xdg_popup_object(nullptr), handle(nullptr) {} - virtual ~Resource() {} - - xdg_popup_v5 *xdg_popup_object; - xdg_popup_v5 *object() { return xdg_popup_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, int id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, int id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, int id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - QMultiMap<struct ::wl_client*, Resource*> resourceMap() { return m_resource_map; } - const QMultiMap<struct ::wl_client*, Resource*> resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != nullptr; } - bool isResource() const { return m_resource != nullptr; } - - static const struct ::wl_interface *interface(); - static QByteArray interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - void send_popup_done(); - void send_popup_done(struct ::wl_resource *resource); - - protected: - virtual Resource *xdg_popup_allocate(); - - virtual void xdg_popup_bind_resource(Resource *resource); - virtual void xdg_popup_destroy_resource(Resource *resource); - - virtual void xdg_popup_destroy(Resource *resource); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::xdg_popup_v5_interface m_xdg_popup_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - - QMultiMap<struct ::wl_client*, Resource*> m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - xdg_popup_v5 *parent; - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; -} - -QT_WARNING_POP -QT_END_NAMESPACE - -#endif diff --git a/src/compositor/extensions/pregenerated/3rdparty/wayland-xdg-shell-unstable-v5-protocol.c b/src/compositor/extensions/pregenerated/3rdparty/wayland-xdg-shell-unstable-v5-protocol.c deleted file mode 100644 index e2781c994..000000000 --- a/src/compositor/extensions/pregenerated/3rdparty/wayland-xdg-shell-unstable-v5-protocol.c +++ /dev/null @@ -1,126 +0,0 @@ -/* Generated by wayland-scanner 1.15.92 */ -// Hand edited to resolve conflicts with xdg-shell stable - -/* - * Copyright © 2008-2013 Kristian Høgsberg - * Copyright © 2013 Rafael Antognolli - * Copyright © 2013 Jasper St. Pierre - * Copyright © 2010-2013 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#include <stdlib.h> -#include <stdint.h> -#include "wayland-util.h" - -extern const struct wl_interface wl_output_interface; -extern const struct wl_interface wl_seat_interface; -extern const struct wl_interface wl_surface_interface; -extern const struct wl_interface xdg_popup_v5_interface; -extern const struct wl_interface xdg_surface_v5_interface; - -static const struct wl_interface *types[] = { - NULL, - NULL, - NULL, - NULL, - &xdg_surface_v5_interface, - &wl_surface_interface, - &xdg_popup_v5_interface, - &wl_surface_interface, - &wl_surface_interface, - &wl_seat_interface, - NULL, - NULL, - NULL, - &xdg_surface_v5_interface, - &wl_seat_interface, - NULL, - NULL, - NULL, - &wl_seat_interface, - NULL, - &wl_seat_interface, - NULL, - NULL, - &wl_output_interface, -}; - -static const struct wl_message xdg_shell_requests[] = { - { "destroy", "", types + 0 }, - { "use_unstable_version", "i", types + 0 }, - { "get_xdg_surface", "no", types + 4 }, - { "get_xdg_popup", "nooouii", types + 6 }, - { "pong", "u", types + 0 }, -}; - -static const struct wl_message xdg_shell_events[] = { - { "ping", "u", types + 0 }, -}; - -WL_EXPORT const struct wl_interface xdg_shell_v5_interface = { - "xdg_shell", 1, - 5, xdg_shell_requests, - 1, xdg_shell_events, -}; - -static const struct wl_message xdg_surface_requests[] = { - { "destroy", "", types + 0 }, - { "set_parent", "?o", types + 13 }, - { "set_title", "s", types + 0 }, - { "set_app_id", "s", types + 0 }, - { "show_window_menu", "ouii", types + 14 }, - { "move", "ou", types + 18 }, - { "resize", "ouu", types + 20 }, - { "ack_configure", "u", types + 0 }, - { "set_window_geometry", "iiii", types + 0 }, - { "set_maximized", "", types + 0 }, - { "unset_maximized", "", types + 0 }, - { "set_fullscreen", "?o", types + 23 }, - { "unset_fullscreen", "", types + 0 }, - { "set_minimized", "", types + 0 }, -}; - -static const struct wl_message xdg_surface_events[] = { - { "configure", "iiau", types + 0 }, - { "close", "", types + 0 }, -}; - -WL_EXPORT const struct wl_interface xdg_surface_v5_interface = { - "xdg_surface", 1, - 14, xdg_surface_requests, - 2, xdg_surface_events, -}; - -static const struct wl_message xdg_popup_requests[] = { - { "destroy", "", types + 0 }, -}; - -static const struct wl_message xdg_popup_events[] = { - { "popup_done", "", types + 0 }, -}; - -WL_EXPORT const struct wl_interface xdg_popup_v5_interface = { - "xdg_popup", 1, - 1, xdg_popup_requests, - 1, xdg_popup_events, -}; - diff --git a/src/compositor/extensions/pregenerated/3rdparty/wayland-xdg-shell-unstable-v5-server-protocol_p.h b/src/compositor/extensions/pregenerated/3rdparty/wayland-xdg-shell-unstable-v5-server-protocol_p.h deleted file mode 100644 index 493fd52d4..000000000 --- a/src/compositor/extensions/pregenerated/3rdparty/wayland-xdg-shell-unstable-v5-server-protocol_p.h +++ /dev/null @@ -1,905 +0,0 @@ -/* Generated by wayland-scanner 1.15.92 */ -// Hand edited to resolve conflicts with xdg-shell stable - -#ifndef XDG_SHELL_UNSTABLE_V5_SERVER_PROTOCOL_H -#define XDG_SHELL_UNSTABLE_V5_SERVER_PROTOCOL_H - -#include <stdint.h> -#include <stddef.h> -#include "wayland-server-core.h" - -#ifdef __cplusplus -extern "C" { -#endif - -struct wl_client; -struct wl_resource; - -/** - * @page page_xdg_shell_unstable_v5 The xdg_shell_unstable_v5 protocol - * @section page_ifaces_xdg_shell_unstable_v5 Interfaces - * - @subpage page_iface_xdg_shell - create desktop-style surfaces - * - @subpage page_iface_xdg_surface - A desktop window - * - @subpage page_iface_xdg_popup - short-lived, popup surfaces for menus - * @section page_copyright_xdg_shell_unstable_v5 Copyright - * <pre> - * - * Copyright © 2008-2013 Kristian Høgsberg - * Copyright © 2013 Rafael Antognolli - * Copyright © 2013 Jasper St. Pierre - * Copyright © 2010-2013 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * </pre> - */ -struct wl_output; -struct wl_seat; -struct wl_surface; -struct xdg_popup; -struct xdg_shell; -struct xdg_surface; - -/** - * @page page_iface_xdg_shell xdg_shell - * @section page_iface_xdg_shell_desc Description - * - * xdg_shell allows clients to turn a wl_surface into a "real window" - * which can be dragged, resized, stacked, and moved around by the - * user. Everything about this interface is suited towards traditional - * desktop environments. - * @section page_iface_xdg_shell_api API - * See @ref iface_xdg_shell. - */ -/** - * @defgroup iface_xdg_shell The xdg_shell interface - * - * xdg_shell allows clients to turn a wl_surface into a "real window" - * which can be dragged, resized, stacked, and moved around by the - * user. Everything about this interface is suited towards traditional - * desktop environments. - */ -extern const struct wl_interface xdg_shell_v5_interface; -/** - * @page page_iface_xdg_surface xdg_surface - * @section page_iface_xdg_surface_desc Description - * - * An interface that may be implemented by a wl_surface, for - * implementations that provide a desktop-style user interface. - * - * It provides requests to treat surfaces like windows, allowing to set - * properties like maximized, fullscreen, minimized, and to move and resize - * them, and associate metadata like title and app id. - * - * The client must call wl_surface.commit on the corresponding wl_surface - * for the xdg_surface state to take effect. Prior to committing the new - * state, it can set up initial configuration, such as maximizing or setting - * a window geometry. - * - * Even without attaching a buffer the compositor must respond to initial - * committed configuration, for instance sending a configure event with - * expected window geometry if the client maximized its surface during - * initialization. - * - * For a surface to be mapped by the compositor the client must have - * committed both an xdg_surface state and a buffer. - * @section page_iface_xdg_surface_api API - * See @ref iface_xdg_surface. - */ -/** - * @defgroup iface_xdg_surface The xdg_surface interface - * - * An interface that may be implemented by a wl_surface, for - * implementations that provide a desktop-style user interface. - * - * It provides requests to treat surfaces like windows, allowing to set - * properties like maximized, fullscreen, minimized, and to move and resize - * them, and associate metadata like title and app id. - * - * The client must call wl_surface.commit on the corresponding wl_surface - * for the xdg_surface state to take effect. Prior to committing the new - * state, it can set up initial configuration, such as maximizing or setting - * a window geometry. - * - * Even without attaching a buffer the compositor must respond to initial - * committed configuration, for instance sending a configure event with - * expected window geometry if the client maximized its surface during - * initialization. - * - * For a surface to be mapped by the compositor the client must have - * committed both an xdg_surface state and a buffer. - */ -extern const struct wl_interface xdg_surface_v5_interface; -/** - * @page page_iface_xdg_popup xdg_popup - * @section page_iface_xdg_popup_desc Description - * - * A popup surface is a short-lived, temporary surface that can be - * used to implement menus. It takes an explicit grab on the surface - * that will be dismissed when the user dismisses the popup. This can - * be done by the user clicking outside the surface, using the keyboard, - * or even locking the screen through closing the lid or a timeout. - * - * When the popup is dismissed, a popup_done event will be sent out, - * and at the same time the surface will be unmapped. The xdg_popup - * object is now inert and cannot be reactivated, so clients should - * destroy it. Explicitly destroying the xdg_popup object will also - * dismiss the popup and unmap the surface. - * - * Clients will receive events for all their surfaces during this - * grab (which is an "owner-events" grab in X11 parlance). This is - * done so that users can navigate through submenus and other - * "nested" popup windows without having to dismiss the topmost - * popup. - * - * Clients that want to dismiss the popup when another surface of - * their own is clicked should dismiss the popup using the destroy - * request. - * - * The parent surface must have either an xdg_surface or xdg_popup - * role. - * - * Specifying an xdg_popup for the parent means that the popups are - * nested, with this popup now being the topmost popup. Nested - * popups must be destroyed in the reverse order they were created - * in, e.g. the only popup you are allowed to destroy at all times - * is the topmost one. - * - * If there is an existing popup when creating a new popup, the - * parent must be the current topmost popup. - * - * A parent surface must be mapped before the new popup is mapped. - * - * When compositors choose to dismiss a popup, they will likely - * dismiss every nested popup as well. When a compositor dismisses - * popups, it will follow the same dismissing order as required - * from the client. - * - * The x and y arguments passed when creating the popup object specify - * where the top left of the popup should be placed, relative to the - * local surface coordinates of the parent surface. See - * xdg_shell.get_xdg_popup. - * - * The client must call wl_surface.commit on the corresponding wl_surface - * for the xdg_popup state to take effect. - * - * For a surface to be mapped by the compositor the client must have - * committed both the xdg_popup state and a buffer. - * @section page_iface_xdg_popup_api API - * See @ref iface_xdg_popup. - */ -/** - * @defgroup iface_xdg_popup The xdg_popup interface - * - * A popup surface is a short-lived, temporary surface that can be - * used to implement menus. It takes an explicit grab on the surface - * that will be dismissed when the user dismisses the popup. This can - * be done by the user clicking outside the surface, using the keyboard, - * or even locking the screen through closing the lid or a timeout. - * - * When the popup is dismissed, a popup_done event will be sent out, - * and at the same time the surface will be unmapped. The xdg_popup - * object is now inert and cannot be reactivated, so clients should - * destroy it. Explicitly destroying the xdg_popup object will also - * dismiss the popup and unmap the surface. - * - * Clients will receive events for all their surfaces during this - * grab (which is an "owner-events" grab in X11 parlance). This is - * done so that users can navigate through submenus and other - * "nested" popup windows without having to dismiss the topmost - * popup. - * - * Clients that want to dismiss the popup when another surface of - * their own is clicked should dismiss the popup using the destroy - * request. - * - * The parent surface must have either an xdg_surface or xdg_popup - * role. - * - * Specifying an xdg_popup for the parent means that the popups are - * nested, with this popup now being the topmost popup. Nested - * popups must be destroyed in the reverse order they were created - * in, e.g. the only popup you are allowed to destroy at all times - * is the topmost one. - * - * If there is an existing popup when creating a new popup, the - * parent must be the current topmost popup. - * - * A parent surface must be mapped before the new popup is mapped. - * - * When compositors choose to dismiss a popup, they will likely - * dismiss every nested popup as well. When a compositor dismisses - * popups, it will follow the same dismissing order as required - * from the client. - * - * The x and y arguments passed when creating the popup object specify - * where the top left of the popup should be placed, relative to the - * local surface coordinates of the parent surface. See - * xdg_shell.get_xdg_popup. - * - * The client must call wl_surface.commit on the corresponding wl_surface - * for the xdg_popup state to take effect. - * - * For a surface to be mapped by the compositor the client must have - * committed both the xdg_popup state and a buffer. - */ -extern const struct wl_interface xdg_popup_v5_interface; - -#ifndef XDG_SHELL_VERSION_ENUM -#define XDG_SHELL_VERSION_ENUM -/** - * @ingroup iface_xdg_shell - * latest protocol version - * - * The 'current' member of this enum gives the version of the - * protocol. Implementations can compare this to the version - * they implement using static_assert to ensure the protocol and - * implementation versions match. - */ -enum xdg_shell_version { - /** - * Always the latest version - */ - XDG_SHELL_VERSION_CURRENT = 5, -}; -#endif /* XDG_SHELL_VERSION_ENUM */ - -#ifndef XDG_SHELL_ERROR_ENUM -#define XDG_SHELL_ERROR_ENUM -enum xdg_shell_error { - /** - * given wl_surface has another role - */ - XDG_SHELL_ERROR_ROLE = 0, - /** - * xdg_shell was destroyed before children - */ - XDG_SHELL_ERROR_DEFUNCT_SURFACES = 1, - /** - * the client tried to map or destroy a non-topmost popup - */ - XDG_SHELL_ERROR_NOT_THE_TOPMOST_POPUP = 2, - /** - * the client specified an invalid popup parent surface - */ - XDG_SHELL_ERROR_INVALID_POPUP_PARENT = 3, -}; -#endif /* XDG_SHELL_ERROR_ENUM */ - -/** - * @ingroup iface_xdg_shell - * @struct xdg_shell_v5_interface - */ -struct xdg_shell_v5_interface { - /** - * destroy xdg_shell - * - * Destroy this xdg_shell object. - * - * Destroying a bound xdg_shell object while there are surfaces - * still alive created by this xdg_shell object instance is illegal - * and will result in a protocol error. - */ - void (*destroy)(struct wl_client *client, - struct wl_resource *resource); - /** - * enable use of this unstable version - * - * Negotiate the unstable version of the interface. This - * mechanism is in place to ensure client and server agree on the - * unstable versions of the protocol that they speak or exit - * cleanly if they don't agree. This request will go away once the - * xdg-shell protocol is stable. - */ - void (*use_unstable_version)(struct wl_client *client, - struct wl_resource *resource, - int32_t version); - /** - * create a shell surface from a surface - * - * This creates an xdg_surface for the given surface and gives it - * the xdg_surface role. A wl_surface can only be given an - * xdg_surface role once. If get_xdg_surface is called with a - * wl_surface that already has an active xdg_surface associated - * with it, or if it had any other role, an error is raised. - * - * See the documentation of xdg_surface for more details about what - * an xdg_surface is and how it is used. - */ - void (*get_xdg_surface)(struct wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct wl_resource *surface); - /** - * create a popup for a surface - * - * This creates an xdg_popup for the given surface and gives it - * the xdg_popup role. A wl_surface can only be given an xdg_popup - * role once. If get_xdg_popup is called with a wl_surface that - * already has an active xdg_popup associated with it, or if it had - * any other role, an error is raised. - * - * This request must be used in response to some sort of user - * action like a button press, key press, or touch down event. - * - * See the documentation of xdg_popup for more details about what - * an xdg_popup is and how it is used. - * @param seat the wl_seat of the user event - * @param serial the serial of the user event - */ - void (*get_xdg_popup)(struct wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct wl_resource *surface, - struct wl_resource *parent, - struct wl_resource *seat, - uint32_t serial, - int32_t x, - int32_t y); - /** - * respond to a ping event - * - * A client must respond to a ping event with a pong request or - * the client may be deemed unresponsive. - * @param serial serial of the ping event - */ - void (*pong)(struct wl_client *client, - struct wl_resource *resource, - uint32_t serial); -}; - -#define XDG_SHELL_PING 0 - -/** - * @ingroup iface_xdg_shell - */ -#define XDG_SHELL_PING_SINCE_VERSION 1 - -/** - * @ingroup iface_xdg_shell - */ -#define XDG_SHELL_DESTROY_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_shell - */ -#define XDG_SHELL_USE_UNSTABLE_VERSION_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_shell - */ -#define XDG_SHELL_GET_XDG_SURFACE_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_shell - */ -#define XDG_SHELL_GET_XDG_POPUP_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_shell - */ -#define XDG_SHELL_PONG_SINCE_VERSION 1 - -/** - * @ingroup iface_xdg_shell - * Sends an ping event to the client owning the resource. - * @param resource_ The client's resource - * @param serial pass this to the pong request - */ -static inline void -xdg_shell_send_ping(struct wl_resource *resource_, uint32_t serial) -{ - wl_resource_post_event(resource_, XDG_SHELL_PING, serial); -} - -#ifndef XDG_SURFACE_RESIZE_EDGE_ENUM -#define XDG_SURFACE_RESIZE_EDGE_ENUM -/** - * @ingroup iface_xdg_surface - * edge values for resizing - * - * These values are used to indicate which edge of a surface - * is being dragged in a resize operation. - */ -enum xdg_surface_resize_edge { - XDG_SURFACE_RESIZE_EDGE_NONE = 0, - XDG_SURFACE_RESIZE_EDGE_TOP = 1, - XDG_SURFACE_RESIZE_EDGE_BOTTOM = 2, - XDG_SURFACE_RESIZE_EDGE_LEFT = 4, - XDG_SURFACE_RESIZE_EDGE_TOP_LEFT = 5, - XDG_SURFACE_RESIZE_EDGE_BOTTOM_LEFT = 6, - XDG_SURFACE_RESIZE_EDGE_RIGHT = 8, - XDG_SURFACE_RESIZE_EDGE_TOP_RIGHT = 9, - XDG_SURFACE_RESIZE_EDGE_BOTTOM_RIGHT = 10, -}; -#endif /* XDG_SURFACE_RESIZE_EDGE_ENUM */ - -#ifndef XDG_SURFACE_STATE_ENUM -#define XDG_SURFACE_STATE_ENUM -/** - * @ingroup iface_xdg_surface - * types of state on the surface - * - * The different state values used on the surface. This is designed for - * state values like maximized, fullscreen. It is paired with the - * configure event to ensure that both the client and the compositor - * setting the state can be synchronized. - * - * States set in this way are double-buffered. They will get applied on - * the next commit. - * - * Desktop environments may extend this enum by taking up a range of - * values and documenting the range they chose in this description. - * They are not required to document the values for the range that they - * chose. Ideally, any good extensions from a desktop environment should - * make its way into standardization into this enum. - * - * The current reserved ranges are: - * - * 0x0000 - 0x0FFF: xdg-shell core values, documented below. - * 0x1000 - 0x1FFF: GNOME - */ -enum xdg_surface_state { - /** - * the surface is maximized - */ - XDG_SURFACE_STATE_MAXIMIZED = 1, - /** - * the surface is fullscreen - */ - XDG_SURFACE_STATE_FULLSCREEN = 2, - XDG_SURFACE_STATE_RESIZING = 3, - XDG_SURFACE_STATE_ACTIVATED = 4, -}; -#endif /* XDG_SURFACE_STATE_ENUM */ - -/** - * @ingroup iface_xdg_surface - * @struct xdg_surface_v5_interface - */ -struct xdg_surface_v5_interface { - /** - * Destroy the xdg_surface - * - * Unmap and destroy the window. The window will be effectively - * hidden from the user's point of view, and all state like - * maximization, fullscreen, and so on, will be lost. - */ - void (*destroy)(struct wl_client *client, - struct wl_resource *resource); - /** - * set the parent of this surface - * - * Set the "parent" of this surface. This window should be - * stacked above a parent. The parent surface must be mapped as - * long as this surface is mapped. - * - * Parent windows should be set on dialogs, toolboxes, or other - * "auxiliary" surfaces, so that the parent is raised when the - * dialog is raised. - */ - void (*set_parent)(struct wl_client *client, - struct wl_resource *resource, - struct wl_resource *parent); - /** - * set surface title - * - * Set a short title for the surface. - * - * This string may be used to identify the surface in a task bar, - * window list, or other user interface elements provided by the - * compositor. - * - * The string must be encoded in UTF-8. - */ - void (*set_title)(struct wl_client *client, - struct wl_resource *resource, - const char *title); - /** - * set application ID - * - * Set an application identifier for the surface. - * - * The app ID identifies the general class of applications to which - * the surface belongs. The compositor can use this to group - * multiple surfaces together, or to determine how to launch a new - * application. - * - * For D-Bus activatable applications, the app ID is used as the - * D-Bus service name. - * - * The compositor shell will try to group application surfaces - * together by their app ID. As a best practice, it is suggested to - * select app ID's that match the basename of the application's - * .desktop file. For example, "org.freedesktop.FooViewer" where - * the .desktop file is "org.freedesktop.FooViewer.desktop". - * - * See the desktop-entry specification [0] for more details on - * application identifiers and how they relate to well-known D-Bus - * names and .desktop files. - * - * [0] http://standards.freedesktop.org/desktop-entry-spec/ - */ - void (*set_app_id)(struct wl_client *client, - struct wl_resource *resource, - const char *app_id); - /** - * show the window menu - * - * Clients implementing client-side decorations might want to - * show a context menu when right-clicking on the decorations, - * giving the user a menu that they can use to maximize or minimize - * the window. - * - * This request asks the compositor to pop up such a window menu at - * the given position, relative to the local surface coordinates of - * the parent surface. There are no guarantees as to what menu - * items the window menu contains. - * - * This request must be used in response to some sort of user - * action like a button press, key press, or touch down event. - * @param seat the wl_seat of the user event - * @param serial the serial of the user event - * @param x the x position to pop up the window menu at - * @param y the y position to pop up the window menu at - */ - void (*show_window_menu)(struct wl_client *client, - struct wl_resource *resource, - struct wl_resource *seat, - uint32_t serial, - int32_t x, - int32_t y); - /** - * start an interactive move - * - * Start an interactive, user-driven move of the surface. - * - * This request must be used in response to some sort of user - * action like a button press, key press, or touch down event. The - * passed serial is used to determine the type of interactive move - * (touch, pointer, etc). - * - * The server may ignore move requests depending on the state of - * the surface (e.g. fullscreen or maximized), or if the passed - * serial is no longer valid. - * - * If triggered, the surface will lose the focus of the device - * (wl_pointer, wl_touch, etc) used for the move. It is up to the - * compositor to visually indicate that the move is taking place, - * such as updating a pointer cursor, during the move. There is no - * guarantee that the device focus will return when the move is - * completed. - * @param seat the wl_seat of the user event - * @param serial the serial of the user event - */ - void (*move)(struct wl_client *client, - struct wl_resource *resource, - struct wl_resource *seat, - uint32_t serial); - /** - * start an interactive resize - * - * Start a user-driven, interactive resize of the surface. - * - * This request must be used in response to some sort of user - * action like a button press, key press, or touch down event. The - * passed serial is used to determine the type of interactive - * resize (touch, pointer, etc). - * - * The server may ignore resize requests depending on the state of - * the surface (e.g. fullscreen or maximized). - * - * If triggered, the client will receive configure events with the - * "resize" state enum value and the expected sizes. See the - * "resize" enum value for more details about what is required. The - * client must also acknowledge configure events using - * "ack_configure". After the resize is completed, the client will - * receive another "configure" event without the resize state. - * - * If triggered, the surface also will lose the focus of the device - * (wl_pointer, wl_touch, etc) used for the resize. It is up to the - * compositor to visually indicate that the resize is taking place, - * such as updating a pointer cursor, during the resize. There is - * no guarantee that the device focus will return when the resize - * is completed. - * - * The edges parameter specifies how the surface should be resized, - * and is one of the values of the resize_edge enum. The compositor - * may use this information to update the surface position for - * example when dragging the top left corner. The compositor may - * also use this information to adapt its behavior, e.g. choose an - * appropriate cursor image. - * @param seat the wl_seat of the user event - * @param serial the serial of the user event - * @param edges which edge or corner is being dragged - */ - void (*resize)(struct wl_client *client, - struct wl_resource *resource, - struct wl_resource *seat, - uint32_t serial, - uint32_t edges); - /** - * ack a configure event - * - * When a configure event is received, if a client commits the - * surface in response to the configure event, then the client must - * make a ack_configure request before the commit request, passing - * along the serial of the configure event. - * - * For instance, the compositor might use this information to move - * a surface to the top left only when the client has drawn itself - * for the maximized or fullscreen state. - * - * If the client receives multiple configure events before it can - * respond to one, it only has to ack the last configure event. - * @param serial the serial from the configure event - */ - void (*ack_configure)(struct wl_client *client, - struct wl_resource *resource, - uint32_t serial); - /** - * set the new window geometry - * - * The window geometry of a window is its "visible bounds" from - * the user's perspective. Client-side decorations often have - * invisible portions like drop-shadows which should be ignored for - * the purposes of aligning, placing and constraining windows. - * - * The window geometry is double buffered, and will be applied at - * the time wl_surface.commit of the corresponding wl_surface is - * called. - * - * Once the window geometry of the surface is set once, it is not - * possible to unset it, and it will remain the same until - * set_window_geometry is called again, even if a new subsurface or - * buffer is attached. - * - * If never set, the value is the full bounds of the surface, - * including any subsurfaces. This updates dynamically on every - * commit. This unset mode is meant for extremely simple clients. - * - * If responding to a configure event, the window geometry in here - * must respect the sizing negotiations specified by the states in - * the configure event. - * - * The arguments are given in the surface local coordinate space of - * the wl_surface associated with this xdg_surface. - * - * The width and height must be greater than zero. - */ - void (*set_window_geometry)(struct wl_client *client, - struct wl_resource *resource, - int32_t x, - int32_t y, - int32_t width, - int32_t height); - /** - * maximize the window - * - * Maximize the surface. - * - * After requesting that the surface should be maximized, the - * compositor will respond by emitting a configure event with the - * "maximized" state and the required window geometry. The client - * should then update its content, drawing it in a maximized state, - * i.e. without shadow or other decoration outside of the window - * geometry. The client must also acknowledge the configure when - * committing the new content (see ack_configure). - * - * It is up to the compositor to decide how and where to maximize - * the surface, for example which output and what region of the - * screen should be used. - * - * If the surface was already maximized, the compositor will still - * emit a configure event with the "maximized" state. - */ - void (*set_maximized)(struct wl_client *client, - struct wl_resource *resource); - /** - * unmaximize the window - * - * Unmaximize the surface. - * - * After requesting that the surface should be unmaximized, the - * compositor will respond by emitting a configure event without - * the "maximized" state. If available, the compositor will include - * the window geometry dimensions the window had prior to being - * maximized in the configure request. The client must then update - * its content, drawing it in a regular state, i.e. potentially - * with shadow, etc. The client must also acknowledge the configure - * when committing the new content (see ack_configure). - * - * It is up to the compositor to position the surface after it was - * unmaximized; usually the position the surface had before - * maximizing, if applicable. - * - * If the surface was already not maximized, the compositor will - * still emit a configure event without the "maximized" state. - */ - void (*unset_maximized)(struct wl_client *client, - struct wl_resource *resource); - /** - * set the window as fullscreen on a monitor - * - * Make the surface fullscreen. - * - * You can specify an output that you would prefer to be - * fullscreen. If this value is NULL, it's up to the compositor to - * choose which display will be used to map this surface. - * - * If the surface doesn't cover the whole output, the compositor - * will position the surface in the center of the output and - * compensate with black borders filling the rest of the output. - */ - void (*set_fullscreen)(struct wl_client *client, - struct wl_resource *resource, - struct wl_resource *output); - /** - */ - void (*unset_fullscreen)(struct wl_client *client, - struct wl_resource *resource); - /** - * set the window as minimized - * - * Request that the compositor minimize your surface. There is no - * way to know if the surface is currently minimized, nor is there - * any way to unset minimization on this surface. - * - * If you are looking to throttle redrawing when minimized, please - * instead use the wl_surface.frame event for this, as this will - * also work with live previews on windows in Alt-Tab, Expose or - * similar compositor features. - */ - void (*set_minimized)(struct wl_client *client, - struct wl_resource *resource); -}; - -#define XDG_SURFACE_CONFIGURE 0 -#define XDG_SURFACE_CLOSE 1 - -/** - * @ingroup iface_xdg_surface - */ -#define XDG_SURFACE_CONFIGURE_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_surface - */ -#define XDG_SURFACE_CLOSE_SINCE_VERSION 1 - -/** - * @ingroup iface_xdg_surface - */ -#define XDG_SURFACE_DESTROY_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_surface - */ -#define XDG_SURFACE_SET_PARENT_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_surface - */ -#define XDG_SURFACE_SET_TITLE_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_surface - */ -#define XDG_SURFACE_SET_APP_ID_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_surface - */ -#define XDG_SURFACE_SHOW_WINDOW_MENU_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_surface - */ -#define XDG_SURFACE_MOVE_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_surface - */ -#define XDG_SURFACE_RESIZE_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_surface - */ -#define XDG_SURFACE_ACK_CONFIGURE_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_surface - */ -#define XDG_SURFACE_SET_WINDOW_GEOMETRY_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_surface - */ -#define XDG_SURFACE_SET_MAXIMIZED_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_surface - */ -#define XDG_SURFACE_UNSET_MAXIMIZED_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_surface - */ -#define XDG_SURFACE_SET_FULLSCREEN_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_surface - */ -#define XDG_SURFACE_UNSET_FULLSCREEN_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_surface - */ -#define XDG_SURFACE_SET_MINIMIZED_SINCE_VERSION 1 - -/** - * @ingroup iface_xdg_surface - * Sends an configure event to the client owning the resource. - * @param resource_ The client's resource - */ -static inline void -xdg_surface_send_configure(struct wl_resource *resource_, int32_t width, int32_t height, struct wl_array *states, uint32_t serial) -{ - wl_resource_post_event(resource_, XDG_SURFACE_CONFIGURE, width, height, states, serial); -} - -/** - * @ingroup iface_xdg_surface - * Sends an close event to the client owning the resource. - * @param resource_ The client's resource - */ -static inline void -xdg_surface_send_close(struct wl_resource *resource_) -{ - wl_resource_post_event(resource_, XDG_SURFACE_CLOSE); -} - -/** - * @ingroup iface_xdg_popup - * @struct xdg_popup_v5_interface - */ -struct xdg_popup_v5_interface { - /** - * remove xdg_popup interface - * - * This destroys the popup. Explicitly destroying the xdg_popup - * object will also dismiss the popup, and unmap the surface. - * - * If this xdg_popup is not the "topmost" popup, a protocol error - * will be sent. - */ - void (*destroy)(struct wl_client *client, - struct wl_resource *resource); -}; - -#define XDG_POPUP_POPUP_DONE 0 - -/** - * @ingroup iface_xdg_popup - */ -#define XDG_POPUP_POPUP_DONE_SINCE_VERSION 1 - -/** - * @ingroup iface_xdg_popup - */ -#define XDG_POPUP_DESTROY_SINCE_VERSION 1 - -/** - * @ingroup iface_xdg_popup - * Sends an popup_done event to the client owning the resource. - * @param resource_ The client's resource - */ -static inline void -xdg_popup_send_popup_done(struct wl_resource *resource_) -{ - wl_resource_post_event(resource_, XDG_POPUP_POPUP_DONE); -} - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/compositor/extensions/pregenerated/xdg-shell-v5.pri b/src/compositor/extensions/pregenerated/xdg-shell-v5.pri deleted file mode 100644 index 48d163f17..000000000 --- a/src/compositor/extensions/pregenerated/xdg-shell-v5.pri +++ /dev/null @@ -1,10 +0,0 @@ -# Putting pregenerated files in a 3rdparty directory to avoid -# qtqa's license checking failing. - -HEADERS += \ - $$PWD/3rdparty/qwayland-server-xdg-shell-unstable-v5_p.h \ - $$PWD/3rdparty/wayland-xdg-shell-unstable-v5-server-protocol_p.h - -SOURCES += \ - $$PWD/3rdparty/qwayland-server-xdg-shell-unstable-v5.cpp \ - $$PWD/3rdparty/wayland-xdg-shell-unstable-v5-protocol.c diff --git a/src/compositor/extensions/qwaylandidleinhibitv1.cpp b/src/compositor/extensions/qwaylandidleinhibitv1.cpp index b97f58130..dc90fb637 100644 --- a/src/compositor/extensions/qwaylandidleinhibitv1.cpp +++ b/src/compositor/extensions/qwaylandidleinhibitv1.cpp @@ -1,38 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 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$ -** -****************************************************************************/ +// Copyright (C) 2019 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QtWaylandCompositor/QWaylandCompositor> #include <QtWaylandCompositor/private/qwaylandsurface_p.h> @@ -45,7 +12,7 @@ QT_BEGIN_NAMESPACE \class QWaylandIdleInhibitManagerV1 \inmodule QtWaylandCompositor \since 5.14 - \brief Provides an extension that allows to inhibit the idle behavior of the compositor + \brief Provides an extension that allows to inhibit the idle behavior of the compositor. \sa QWaylandSurface::inhibitsIdle The QWaylandIdleInhibitV1 extension provides a way for a client to inhibit the idle behavior of @@ -58,9 +25,10 @@ QT_BEGIN_NAMESPACE /*! \qmltype IdleInhibitManagerV1 + \instantiates QWaylandIdleInhibitManagerV1 \inqmlmodule QtWayland.Compositor \since 5.14 - \brief Provides an extension that allows to inhibit the idle behavior of the compositor + \brief Provides an extension that allows to inhibit the idle behavior of the compositor. \sa WaylandSurface::inhibitsIdle The IdleInhibitManagerV1 extension provides a way for a client to inhibit the idle behavior of @@ -71,8 +39,8 @@ QT_BEGIN_NAMESPACE To provide the functionality of the extension in a compositor, create an instance of the IdleInhibitManagerV1 component and add it to the list of extensions supported by the compositor: - \qml \QtMinorVersion - import QtWayland.Compositor 1.\1 + \qml + import QtWayland.Compositor WaylandCompositor { IdleInhibitManagerV1 { @@ -188,3 +156,5 @@ void QWaylandIdleInhibitManagerV1Private::Inhibitor::zwp_idle_inhibitor_v1_destr } QT_END_NAMESPACE + +#include "moc_qwaylandidleinhibitv1.cpp" diff --git a/src/compositor/extensions/qwaylandidleinhibitv1.h b/src/compositor/extensions/qwaylandidleinhibitv1.h index 53c09d084..5d3dc3eca 100644 --- a/src/compositor/extensions/qwaylandidleinhibitv1.h +++ b/src/compositor/extensions/qwaylandidleinhibitv1.h @@ -1,38 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 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$ -** -****************************************************************************/ +// Copyright (C) 2019 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDIDLEINHIBITV1_H #define QWAYLANDIDLEINHIBITV1_H @@ -43,7 +10,7 @@ QT_BEGIN_NAMESPACE class QWaylandIdleInhibitManagerV1Private; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandIdleInhibitManagerV1 : public QWaylandCompositorExtensionTemplate<QWaylandIdleInhibitManagerV1> +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandIdleInhibitManagerV1 : public QWaylandCompositorExtensionTemplate<QWaylandIdleInhibitManagerV1> { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandIdleInhibitManagerV1) diff --git a/src/compositor/extensions/qwaylandidleinhibitv1_p.h b/src/compositor/extensions/qwaylandidleinhibitv1_p.h index 380551804..1899c109e 100644 --- a/src/compositor/extensions/qwaylandidleinhibitv1_p.h +++ b/src/compositor/extensions/qwaylandidleinhibitv1_p.h @@ -1,38 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 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$ -** -****************************************************************************/ +// Copyright (C) 2019 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDIDLEINHIBITV1_P_H #define QWAYLANDIDLEINHIBITV1_P_H @@ -42,6 +9,8 @@ #include <QtWaylandCompositor/private/qwaylandcompositorextension_p.h> #include <QtWaylandCompositor/private/qwayland-server-idle-inhibit-unstable-v1.h> +#include <QtCore/qpointer.h> + // // W A R N I N G // ------------- @@ -55,7 +24,7 @@ QT_BEGIN_NAMESPACE -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandIdleInhibitManagerV1Private +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandIdleInhibitManagerV1Private : public QWaylandCompositorExtensionPrivate , public QtWaylandServer::zwp_idle_inhibit_manager_v1 { @@ -63,7 +32,7 @@ class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandIdleInhibitManagerV1Private public: explicit QWaylandIdleInhibitManagerV1Private() = default; - class Q_WAYLAND_COMPOSITOR_EXPORT Inhibitor + class Q_WAYLANDCOMPOSITOR_EXPORT Inhibitor : public QtWaylandServer::zwp_idle_inhibitor_v1 { public: diff --git a/src/compositor/extensions/qwaylandiviapplication.cpp b/src/compositor/extensions/qwaylandiviapplication.cpp index d0422a052..db9130829 100644 --- a/src/compositor/extensions/qwaylandiviapplication.cpp +++ b/src/compositor/extensions/qwaylandiviapplication.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwaylandiviapplication.h" #include "qwaylandiviapplication_p.h" @@ -39,7 +13,8 @@ QT_BEGIN_NAMESPACE /*! * \qmltype IviApplication - * \inqmlmodule QtWayland.Compositor + * \instantiates QWaylandIviApplication + * \inqmlmodule QtWayland.Compositor.IviApplication * \since 5.8 * \brief Provides a shell extension for embedded-style user interfaces. * @@ -53,8 +28,8 @@ QT_BEGIN_NAMESPACE * an instance of the IviApplication component and add it to the list of extensions * supported by the compositor: * - * \qml \QtMinorVersion - * import QtWayland.Compositor 1.\1 + * \qml + * import QtWayland.Compositor.IviApplication * * WaylandCompositor { * IviApplication { @@ -131,7 +106,7 @@ QByteArray QWaylandIviApplication::interfaceName() } /*! - * \qmlsignal void QtWaylandCompositor::IviApplication::iviSurfaceRequested(WaylandSurface surface, int iviId, WaylandResource resource) + * \qmlsignal void IviApplication::iviSurfaceRequested(WaylandSurface surface, int iviId, WaylandResource resource) * * This signal is emitted when the client has requested an \c ivi_surface to be associated * with \a surface, which is identified by \a iviId. The handler for this signal is @@ -145,12 +120,12 @@ QByteArray QWaylandIviApplication::interfaceName() * * This signal is emitted when the client has requested an \c ivi_surface to be associated * with \a surface, which is identified by \a iviId. The handler for this signal is - * expected to create the ivi surface and initialize it within the scope of the + * expected to create the ivi surface for \a resource and initialize it within the scope of the * signal emission. If no ivi surface is created, a default one will be created instead. */ /*! - * \qmlsignal void QtWaylandCompositor::IviApplication::iviSurfaceCreated(IviSurface *iviSurface) + * \qmlsignal void IviApplication::iviSurfaceCreated(IviSurface *iviSurface) * * This signal is emitted when an IviSurface has been created. The supplied \a iviSurface is * most commonly used to instantiate a ShellSurfaceItem. @@ -203,3 +178,5 @@ void QWaylandIviApplicationPrivate::ivi_application_surface_create(QtWaylandServ } QT_END_NAMESPACE + +#include "moc_qwaylandiviapplication.cpp" diff --git a/src/compositor/extensions/qwaylandiviapplication.h b/src/compositor/extensions/qwaylandiviapplication.h index d9756811c..5472ff05a 100644 --- a/src/compositor/extensions/qwaylandiviapplication.h +++ b/src/compositor/extensions/qwaylandiviapplication.h @@ -1,46 +1,20 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDIVIAPPLICATION_H #define QWAYLANDIVIAPPLICATION_H #include <QtWaylandCompositor/QWaylandCompositorExtension> +#include <QtWaylandCompositor/QWaylandSurface> +#include <QtWaylandCompositor/QWaylandResource> +#include <QtWaylandCompositor/QWaylandIviSurface> #include <QtCore/QSize> QT_BEGIN_NAMESPACE -class QWaylandIviSurface; -class QWaylandSurface; -class QWaylandResource; class QWaylandIviApplicationPrivate; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandIviApplication : public QWaylandCompositorExtensionTemplate<QWaylandIviApplication> +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandIviApplication : public QWaylandCompositorExtensionTemplate<QWaylandIviApplication> { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandIviApplication) diff --git a/src/compositor/extensions/qwaylandiviapplication_p.h b/src/compositor/extensions/qwaylandiviapplication_p.h index f08f05345..1a2988245 100644 --- a/src/compositor/extensions/qwaylandiviapplication_p.h +++ b/src/compositor/extensions/qwaylandiviapplication_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDIVIAPPLICATION_P_H #define QWAYLANDIVIAPPLICATION_P_H @@ -50,7 +24,7 @@ QT_BEGIN_NAMESPACE -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandIviApplicationPrivate +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandIviApplicationPrivate : public QWaylandCompositorExtensionPrivate , public QtWaylandServer::ivi_application { diff --git a/src/compositor/extensions/qwaylandivisurface.cpp b/src/compositor/extensions/qwaylandivisurface.cpp index 81a7da107..493416abf 100644 --- a/src/compositor/extensions/qwaylandivisurface.cpp +++ b/src/compositor/extensions/qwaylandivisurface.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwaylandivisurface.h" #include "qwaylandivisurface_p.h" @@ -45,7 +19,8 @@ QWaylandSurfaceRole QWaylandIviSurfacePrivate::s_role("ivi_surface"); /*! * \qmltype IviSurface - * \inqmlmodule QtWayland.Compositor + * \instantiates QWaylandIviSurface + * \inqmlmodule QtWayland.Compositor.IviApplication * \since 5.8 * \brief Provides a simple way to identify and resize a surface. * @@ -86,7 +61,7 @@ QWaylandIviSurface::QWaylandIviSurface(QWaylandIviApplication *application, QWay } /*! - * \qmlmethod void QtWaylandCompositor::IviSurface::initialize(IviApplication iviApplication, WaylandSurface surface, int iviId, WaylandResource resource) + * \qmlmethod void IviSurface::initialize(IviApplication iviApplication, WaylandSurface surface, int iviId, WaylandResource resource) * * Initializes the IviSurface, associating it with the given \a iviApplication, \a surface, * \a iviId, and \a resource. @@ -114,7 +89,7 @@ void QWaylandIviSurface::initialize(QWaylandIviApplication *iviApplication, QWay } /*! - * \qmlproperty WaylandSurface QtWaylandCompositor::IviSurface::surface + * \qmlproperty WaylandSurface IviSurface::surface * * This property holds the surface associated with this IviSurface. */ @@ -131,7 +106,7 @@ QWaylandSurface *QWaylandIviSurface::surface() const } /*! - * \qmlproperty int QtWaylandCompositor::IviSurface::iviId + * \qmlproperty int IviSurface::iviId * \readonly * * This property holds the ivi id id of this IviSurface. @@ -180,7 +155,7 @@ QWaylandIviSurface *QWaylandIviSurface::fromResource(wl_resource *resource) } /*! - * \qmlmethod int QtWaylandCompositor::IviSurface::sendConfigure(size size) + * \qmlmethod int IviSurface::sendConfigure(size size) * * Sends a configure event to the client, telling it to resize the surface to the given \a size. */ @@ -231,3 +206,5 @@ void QWaylandIviSurfacePrivate::ivi_surface_destroy(QtWaylandServer::ivi_surface } QT_END_NAMESPACE + +#include "moc_qwaylandivisurface.cpp" diff --git a/src/compositor/extensions/qwaylandivisurface.h b/src/compositor/extensions/qwaylandivisurface.h index fa5a7c7e0..09f18c3ed 100644 --- a/src/compositor/extensions/qwaylandivisurface.h +++ b/src/compositor/extensions/qwaylandivisurface.h @@ -1,37 +1,13 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDIVISURFACE_H #define QWAYLANDIVISURFACE_H #include <QtWaylandCompositor/QWaylandShellSurface> +#if QT_CONFIG(wayland_compositor_quick) #include <QtWaylandCompositor/qwaylandquickchildren.h> +#endif struct wl_resource; @@ -43,13 +19,16 @@ class QWaylandIviApplication; class QWaylandSurfaceRole; class QWaylandResource; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandIviSurface : public QWaylandShellSurfaceTemplate<QWaylandIviSurface> +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandIviSurface : public QWaylandShellSurfaceTemplate<QWaylandIviSurface> { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandIviSurface) +#if QT_CONFIG(wayland_compositor_quick) Q_WAYLAND_COMPOSITOR_DECLARE_QUICK_CHILDREN(QWaylandIviSurface) +#endif Q_PROPERTY(QWaylandSurface *surface READ surface NOTIFY surfaceChanged) Q_PROPERTY(uint iviId READ iviId NOTIFY iviIdChanged) + Q_MOC_INCLUDE("qwaylandsurface.h") public: QWaylandIviSurface(); diff --git a/src/compositor/extensions/qwaylandivisurface_p.h b/src/compositor/extensions/qwaylandivisurface_p.h index 2ef66b1ab..d721dff69 100644 --- a/src/compositor/extensions/qwaylandivisurface_p.h +++ b/src/compositor/extensions/qwaylandivisurface_p.h @@ -1,36 +1,10 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDIVISURFACE_P_H #define QWAYLANDIVISURFACE_P_H -#include <QtWaylandCompositor/private/qwaylandcompositorextension_p.h> +#include <QtWaylandCompositor/private/qwaylandshellsurface_p.h> #include <QtWaylandCompositor/private/qwayland-server-ivi-application.h> #include <QtWaylandCompositor/QWaylandIviSurface> @@ -50,8 +24,8 @@ QT_BEGIN_NAMESPACE -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandIviSurfacePrivate - : public QWaylandCompositorExtensionPrivate +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandIviSurfacePrivate + : public QWaylandShellSurfacePrivate , public QtWaylandServer::ivi_surface { Q_DECLARE_PUBLIC(QWaylandIviSurface) diff --git a/src/compositor/extensions/qwaylandivisurfaceintegration.cpp b/src/compositor/extensions/qwaylandivisurfaceintegration.cpp index f8cba9962..8449df684 100644 --- a/src/compositor/extensions/qwaylandivisurfaceintegration.cpp +++ b/src/compositor/extensions/qwaylandivisurfaceintegration.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwaylandivisurfaceintegration_p.h" @@ -60,3 +34,5 @@ void IviSurfaceIntegration::handleIviSurfaceDestroyed() } QT_END_NAMESPACE + +#include "moc_qwaylandivisurfaceintegration_p.cpp" diff --git a/src/compositor/extensions/qwaylandivisurfaceintegration_p.h b/src/compositor/extensions/qwaylandivisurfaceintegration_p.h index be56b4b8c..827d3e9d5 100644 --- a/src/compositor/extensions/qwaylandivisurfaceintegration_p.h +++ b/src/compositor/extensions/qwaylandivisurfaceintegration_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDIVISURFACEINTEGRATION_H #define QWAYLANDIVISURFACEINTEGRATION_H diff --git a/src/compositor/extensions/qwaylandpresentationtime.cpp b/src/compositor/extensions/qwaylandpresentationtime.cpp new file mode 100644 index 000000000..637fc5d68 --- /dev/null +++ b/src/compositor/extensions/qwaylandpresentationtime.cpp @@ -0,0 +1,340 @@ +// Copyright (C) 2021 LG Electronics Inc. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include "qwaylandpresentationtime_p.h" +#include "qwaylandpresentationtime_p_p.h" + +#include <time.h> +#include <QQuickWindow> +#include <QtWaylandCompositor/QWaylandView> +#include <QtWaylandCompositor/QWaylandQuickItem> + +QT_BEGIN_NAMESPACE + +/*! + * \qmltype PresentationTime + * \instantiates QWaylandPresentationTime + * \inqmlmodule QtWayland.Compositor.PresentationTime + * \since 6.3 + * \brief Provides tracking the timing when a frame is presented on screen. + * + * The PresentationTime extension provides a way to track rendering timing + * for a surface. Client can request feedbacks associated with a surface, + * then compositor send events for the feedback with the time when the surface + * is presented on-screen. + * + * PresentationTime corresponds to the Wayland \c wp_presentation interface. + * + * To provide the functionality of the presentationtime extension in a compositor, create + * an instance of the PresentationTime component and add it to the list of extensions + * supported by the compositor: + * + * Then, call sendFeedback() when a surface is presented on screen. + * Usually, the timing can be obtained from drm page flip event. + * + * \qml + * import QtWayland.Compositor.PresentationTime + * + * WaylandCompositor { + * PresentationTime { + * id: presentationTime + * } + * } + * \endqml + */ + +/*! + * \class QWaylandPresentationTime + * \inmodule QtWaylandCompositor + * \since 6.3 + * \brief The QWaylandPresentationTime class is an extension to get timing for on-screen presentation. + * + * The QWaylandPresentationTime extension provides a way to track rendering timing + * for a surface. Client can request feedbacks associated with a surface, + * then compositor send events for the feedback with the time when the surface + * is presented on-screen. + * + * QWaylandPresentationTime corresponds to the Wayland \c wp_presentation interface. + */ + + +/*! + * Constructs a QWaylandPresentationTime object for \a compositor. + */ +QWaylandPresentationTime::QWaylandPresentationTime(QWaylandCompositor *compositor) + : QWaylandCompositorExtensionTemplate(compositor, *new QWaylandPresentationTimePrivate) +{ + +} + +/*! + * Constructs an empty QWaylandPresentationTime object. + */ +QWaylandPresentationTime::QWaylandPresentationTime() + : QWaylandCompositorExtensionTemplate(*new QWaylandPresentationTimePrivate) +{ +} + +/*! + * Initializes the extension. + */ +void QWaylandPresentationTime::initialize() +{ + Q_D(QWaylandPresentationTime); + + if (isInitialized()) { + qWarning() << "QWaylandPresentationTime is already initialized"; + return; + } + + QWaylandCompositor *compositor = this->compositor(); + if (compositor == nullptr) { + qWarning() << "Failed to find QWaylandCompositor when initializing QWaylandPresentationTime"; + return; + } + + QWaylandCompositorExtensionTemplate::initialize(); + + d->init(compositor->display(), /* version */ 1); +} + +QWaylandCompositor *QWaylandPresentationTime::compositor() const +{ + return qobject_cast<QWaylandCompositor *>(extensionContainer()); +} + +/*! + * \qmlmethod void PresentationTime::sendFeedback(Window window, int sequence, int sec, int nsec) + * + * Interface to notify that a frame is presented on screen using \a window. + * If your platform supports DRM events, \c page_flip_handler is the proper timing to send it. + * The \a sequence is the refresh counter. \a sec and \a nsec hold the + * seconds and nanoseconds parts of the presentation timestamp, respectively. + */ + +/*! + * Interface to notify that a frame is presented on screen using \a window. + * If your platform supports DRM events, \c page_flip_handler is the proper timing to send it. + * The \a sequence is the refresh counter. \a tv_sec and \a tv_nsec hold the + * seconds and nanoseconds parts of the presentation timestamp, respectively. + */ +void QWaylandPresentationTime::sendFeedback(QQuickWindow *window, quint64 sequence, quint64 tv_sec, quint32 tv_nsec) +{ + if (!window) + return; + + quint32 refresh_nsec = window->screen()->refreshRate() != 0 ? 1000000000 / window->screen()->refreshRate() : 0; + + emit presented(sequence, tv_sec, tv_nsec, refresh_nsec); +} + +/*! + * Returns the Wayland interface for the QWaylandPresentationTime. + */ +const struct wl_interface *QWaylandPresentationTime::interface() +{ + return QWaylandPresentationTimePrivate::interface(); +} + +/*! + * \internal + */ +QByteArray QWaylandPresentationTime::interfaceName() +{ + return QWaylandPresentationTimePrivate::interfaceName(); +} + +PresentationFeedback::PresentationFeedback(QWaylandPresentationTime *pTime, QWaylandSurface *surface, struct ::wl_client *client, uint32_t id, int version) + : wp_presentation_feedback(client, id, version) + , m_presentationTime(pTime) +{ + setSurface(surface); +} + +void PresentationFeedback::setSurface(QWaylandSurface *qwls) +{ + if (!qwls) { + discard(); + return; + } + + m_surface = qwls; + + connect(qwls, &QWaylandSurface::damaged, this, &PresentationFeedback::onSurfaceCommit); + connect(qwls, &QWaylandSurface::destroyed, this, &PresentationFeedback::discard); + + QWaylandView *view = qwls ? qwls->primaryView() : nullptr; + //The surface has not committed yet. + if (!view) { + connect(qwls, &QWaylandSurface::hasContentChanged, this, &PresentationFeedback::onSurfaceMapped); + return; + } + + maybeConnectToWindow(view); +} + +void PresentationFeedback::onSurfaceCommit() +{ + // There is a new commit before sync so that discard this feedback. + if (m_committed) { + discard(); + return; + } + m_committed = true; +} + +void PresentationFeedback::onSurfaceMapped() +{ + QWaylandView *view = m_surface->primaryView(); + if (!view) { + qWarning() << "The mapped surface has no view"; + discard(); + return; + } + + maybeConnectToWindow(view); +} + +void PresentationFeedback::maybeConnectToWindow(QWaylandView *view) +{ + QWaylandQuickItem *item = view ? qobject_cast<QWaylandQuickItem *>(view->renderObject()) : nullptr; + if (!item) { + qWarning() << "QWaylandPresentationTime only works with QtQuick compositors" << view; + discard(); + return; + } + + connect(item, &QQuickItem::windowChanged, this, &PresentationFeedback::onWindowChanged); + // wait for having window + if (!item->window()) { + return; + } + + connectToWindow(item->window()); +} + +void PresentationFeedback::onWindowChanged() +{ + QWaylandQuickItem *item = qobject_cast<QWaylandQuickItem *>(sender()); + QQuickWindow *window = item ? item->window() : nullptr; + + if (!window) { + qWarning() << "QWaylandPresentationTime only works with QtQuick compositors" << item; + discard(); + /* Actually, the commit is not discarded yet. If the related item has new window, + the commit can be presented on screen. So we can choose not to discard the feedback + until item has new window or the surface is destroyed. */ + return; + } + + // Check if the connected window is changed + if (m_connectedWindow && m_connectedWindow != window) + m_connectedWindow->disconnect(this); + + connectToWindow(window); +} + +void PresentationFeedback::connectToWindow(QQuickWindow *window) +{ + if (!window) { + discard(); + return; + } + + m_connectedWindow = window; + + connect(window, &QQuickWindow::beforeSynchronizing, this, &PresentationFeedback::onSync); + connect(window, &QQuickWindow::afterFrameEnd, this, &PresentationFeedback::onSwapped); +} + +void PresentationFeedback::onSync() +{ + QQuickWindow *window = qobject_cast<QQuickWindow *>(sender()); + + if (m_committed) { + disconnect(m_surface, &QWaylandSurface::damaged, this, &PresentationFeedback::onSurfaceCommit); + disconnect(window, &QQuickWindow::beforeSynchronizing, this, &PresentationFeedback::onSync); + m_sync = true; + } +} + +void PresentationFeedback::onSwapped() +{ + QQuickWindow *window = qobject_cast<QQuickWindow *>(sender()); + + if (m_sync) { + disconnect(window, &QQuickWindow::afterFrameEnd, this, &PresentationFeedback::onSwapped); + connect(m_presentationTime, &QWaylandPresentationTime::presented, this, &PresentationFeedback::sendPresented); + } +} + +void PresentationFeedback::discard() +{ + send_discarded(); + destroy(); +} + +void PresentationFeedback::sendSyncOutput() +{ + QWaylandCompositor *compositor = presentationTime()->compositor(); + if (!compositor) { + qWarning() << "No compositor container to send sync_output"; + return; + } + + QWaylandView *view = surface()->primaryView(); + QWaylandOutput *output = view ? view->output() : nullptr; + struct ::wl_resource *r = output ? output->resourceForClient(QWaylandClient::fromWlClient(compositor, resource()->client())) : nullptr; + + if (r) + send_sync_output(r); +} + +void PresentationFeedback::sendPresented(quint64 sequence, quint64 tv_sec, quint32 tv_nsec, quint32 refresh_nsec) +{ + sendSyncOutput(); + + send_presented(tv_sec >> 32, tv_sec, tv_nsec, refresh_nsec, sequence >> 32, sequence, + QtWaylandServer::wp_presentation_feedback::kind_vsync + | QtWaylandServer::wp_presentation_feedback::kind_hw_clock + | QtWaylandServer::wp_presentation_feedback::kind_hw_completion); + + destroy(); +} + +void PresentationFeedback::destroy() +{ + wl_resource_destroy(resource()->handle); +} + +void PresentationFeedback::wp_presentation_feedback_destroy_resource(Resource *resource) +{ + Q_UNUSED(resource); + delete this; +} + +QWaylandPresentationTimePrivate::QWaylandPresentationTimePrivate() +{ +} + +void QWaylandPresentationTimePrivate::wp_presentation_bind_resource(Resource *resource) +{ + send_clock_id(resource->handle, CLOCK_MONOTONIC); +} + +void QWaylandPresentationTimePrivate::wp_presentation_feedback(Resource *resource, struct ::wl_resource *surface, uint32_t callback) +{ + Q_Q(QWaylandPresentationTime); + + QWaylandSurface *qwls = QWaylandSurface::fromResource(surface); + if (!qwls) + return; + + new PresentationFeedback(q, qwls, resource->client(), callback, /* version */ 1); +} + +QT_END_NAMESPACE + +#include "moc_qwaylandpresentationtime_p_p.cpp" + +#include "moc_qwaylandpresentationtime_p.cpp" diff --git a/src/compositor/extensions/qwaylandpresentationtime_p.h b/src/compositor/extensions/qwaylandpresentationtime_p.h new file mode 100644 index 000000000..c57cd91d2 --- /dev/null +++ b/src/compositor/extensions/qwaylandpresentationtime_p.h @@ -0,0 +1,49 @@ +// Copyright (C) 2021 LG Electronics Inc. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#ifndef QWAYLANDPRESENTATIONTIME_P_H +#define QWAYLANDPRESENTATIONTIME_P_H + +// +// 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. +// + +#include <QObject> +#include <QtWaylandCompositor/qwaylandcompositorextension.h> +#include <QtCore/private/qglobal_p.h> + +QT_BEGIN_NAMESPACE + +class QQuickWindow; +class QWaylandPresentationTimePrivate; + +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandPresentationTime : public QWaylandCompositorExtensionTemplate<QWaylandPresentationTime> +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QWaylandPresentationTime) +public: + QWaylandPresentationTime(); + QWaylandPresentationTime(QWaylandCompositor *compositor); + + QWaylandCompositor *compositor() const; + void initialize() override; + + Q_INVOKABLE void sendFeedback(QQuickWindow *window, quint64 sequence, quint64 tv_sec, quint32 tv_nsec); + + static const struct wl_interface *interface(); + static QByteArray interfaceName(); + +Q_SIGNALS: + void presented(quint64 sequence, quint64 tv_sec, quint32 tv_nsec, quint32 refresh_nsec); +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/compositor/extensions/qwaylandpresentationtime_p_p.h b/src/compositor/extensions/qwaylandpresentationtime_p_p.h new file mode 100644 index 000000000..8e0cf42af --- /dev/null +++ b/src/compositor/extensions/qwaylandpresentationtime_p_p.h @@ -0,0 +1,82 @@ +// Copyright (C) 2021 LG Electronics Inc. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#ifndef QWAYLANDPRESENTATIONTIME_P_P_H +#define QWAYLANDPRESENTATIONTIME_P_P_H + +// +// 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. +// + +#include <QtWaylandCompositor/private/qwaylandcompositorextension_p.h> +#include <QtWaylandCompositor/private/qwayland-server-presentation-time.h> + +#include <QObject> +#include <QPointer> +#include <QMultiMap> + +QT_BEGIN_NAMESPACE + + +class QWaylandSurface; +class QWaylandView; +class QQuickWindow; + +class PresentationFeedback : public QObject, public QtWaylandServer::wp_presentation_feedback +{ + Q_OBJECT +public: + PresentationFeedback(QWaylandPresentationTime *, QWaylandSurface *, struct ::wl_client *, uint32_t, int); + + void setSurface(QWaylandSurface *); + QWaylandSurface *surface() { return m_surface; } + + void destroy(); + void sendSyncOutput(); + +private Q_SLOTS: + void discard(); + void onSurfaceCommit(); + void onSurfaceMapped(); + void onWindowChanged(); + void onSync(); + void onSwapped(); + void sendPresented(quint64 sequence, quint64 tv_sec, quint32 tv_nsec, quint32 refresh_nsec); + +private: + QWaylandPresentationTime *presentationTime() { return m_presentationTime; } + void maybeConnectToWindow(QWaylandView *); + void connectToWindow(QQuickWindow *); + + void wp_presentation_feedback_destroy_resource(Resource *resource) override; + +public: + QWaylandPresentationTime *m_presentationTime = nullptr; + QWaylandSurface *m_surface = nullptr; + QQuickWindow *m_connectedWindow = nullptr; + + bool m_committed = false; + bool m_sync = false; +}; + +class QWaylandPresentationTimePrivate : public QWaylandCompositorExtensionPrivate, public QtWaylandServer::wp_presentation +{ + Q_DECLARE_PUBLIC(QWaylandPresentationTime) +public: + QWaylandPresentationTimePrivate(); + +protected: + void wp_presentation_feedback(Resource *resource, struct ::wl_resource *surface, uint32_t callback) override; + void wp_presentation_bind_resource(Resource *resource) override; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/compositor/extensions/qwaylandqttextinputmethod.cpp b/src/compositor/extensions/qwaylandqttextinputmethod.cpp new file mode 100644 index 000000000..edcf28d30 --- /dev/null +++ b/src/compositor/extensions/qwaylandqttextinputmethod.cpp @@ -0,0 +1,435 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include "qwaylandqttextinputmethod.h" +#include "qwaylandqttextinputmethod_p.h" + +#include <QtGui/qevent.h> +#include <QtGui/qguiapplication.h> +#include <QtGui/qinputmethod.h> +#include <QtGui/qcolor.h> +#include <QtGui/qtextformat.h> + +#include <QtWaylandCompositor/qwaylandcompositor.h> +#include <QtWaylandCompositor/qwaylandsurface.h> + +QT_BEGIN_NAMESPACE + +QWaylandQtTextInputMethodPrivate::QWaylandQtTextInputMethodPrivate(QWaylandCompositor *c) + : compositor(c) +{ +} + +void QWaylandQtTextInputMethodPrivate::text_input_method_v1_enable(Resource *resource, struct ::wl_resource *surface) +{ + Q_Q(QWaylandQtTextInputMethod); + if (this->resource == resource) { + QWaylandSurface *waylandSurface = QWaylandSurface::fromResource(surface); + if (surface != nullptr) { + enabledSurfaces[resource] = waylandSurface; + emit q->surfaceEnabled(waylandSurface); + } + } +} + +void QWaylandQtTextInputMethodPrivate::text_input_method_v1_disable(Resource *resource, struct ::wl_resource *surface) +{ + Q_Q(QWaylandQtTextInputMethod); + if (this->resource == resource) { + QWaylandSurface *waylandSurface = QWaylandSurface::fromResource(surface); + QWaylandSurface *enabledSurface = enabledSurfaces.take(resource); + + if (Q_UNLIKELY(enabledSurface != waylandSurface)) + qCWarning(qLcWaylandCompositorInputMethods) << "Disabled surface does not match the one currently enabled"; + + emit q->surfaceEnabled(waylandSurface); + } +} + +void QWaylandQtTextInputMethodPrivate::text_input_method_v1_destroy(Resource *resource) +{ + if (this->resource == resource) + wl_resource_destroy(resource->handle); +} + +void QWaylandQtTextInputMethodPrivate::text_input_method_v1_reset(Resource *resource) +{ + if (this->resource == resource) + qApp->inputMethod()->reset(); +} + +void QWaylandQtTextInputMethodPrivate::text_input_method_v1_commit(Resource *resource) +{ + if (this->resource == resource) + qApp->inputMethod()->commit(); +} + +void QWaylandQtTextInputMethodPrivate::text_input_method_v1_show_input_panel(Resource *resource) +{ + if (this->resource == resource) + qApp->inputMethod()->show(); +} + +void QWaylandQtTextInputMethodPrivate::text_input_method_v1_hide_input_panel(Resource *resource) +{ + if (this->resource == resource) + qApp->inputMethod()->hide(); +} + +void QWaylandQtTextInputMethodPrivate::text_input_method_v1_invoke_action(Resource *resource, int32_t type, int32_t cursorPosition) +{ + if (this->resource == resource) + qApp->inputMethod()->invokeAction(QInputMethod::Action(type), cursorPosition); +} + +void QWaylandQtTextInputMethodPrivate::text_input_method_v1_update_cursor_rectangle(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) +{ + if (this->resource == resource) + cursorRectangle = QRect(x, y, width, height); +} + +void QWaylandQtTextInputMethodPrivate::text_input_method_v1_start_update(Resource *resource, int32_t queries) +{ + if (this->resource == resource) + updatingQueries = Qt::InputMethodQueries(queries); +} + +void QWaylandQtTextInputMethodPrivate::text_input_method_v1_update_hints(Resource *resource, int32_t hints) +{ + if (this->resource == resource) + this->hints = Qt::InputMethodHints(hints); +} + +void QWaylandQtTextInputMethodPrivate::text_input_method_v1_update_anchor_position(Resource *resource, int32_t anchorPosition) +{ + if (this->resource == resource) + this->anchorPosition = anchorPosition; +} + +void QWaylandQtTextInputMethodPrivate::text_input_method_v1_update_cursor_position(Resource *resource, int32_t cursorPosition) +{ + if (this->resource == resource) + this->cursorPosition = cursorPosition; +} + +void QWaylandQtTextInputMethodPrivate::text_input_method_v1_update_surrounding_text(Resource *resource, const QString &surroundingText, int32_t surroundingTextOffset) +{ + if (this->resource == resource) { + this->surroundingText = surroundingText; + this->surroundingTextOffset = surroundingTextOffset; + } +} + +void QWaylandQtTextInputMethodPrivate::text_input_method_v1_update_absolute_position(Resource *resource, int32_t absolutePosition) +{ + if (this->resource == resource) + this->absolutePosition = absolutePosition; +} + +void QWaylandQtTextInputMethodPrivate::text_input_method_v1_update_preferred_language(Resource *resource, const QString &preferredLanguage) +{ + if (this->resource == resource) + this->preferredLanguage = preferredLanguage; +} + +void QWaylandQtTextInputMethodPrivate::text_input_method_v1_end_update(Resource *resource) +{ + Q_Q(QWaylandQtTextInputMethod); + if (this->resource == resource && updatingQueries != 0) { + Qt::InputMethodQueries queries = updatingQueries; + updatingQueries = Qt::InputMethodQueries(); + emit q->updateInputMethod(queries); + } +} + +void QWaylandQtTextInputMethodPrivate::text_input_method_v1_acknowledge_input_method(Resource *resource) +{ + if (this->resource == resource) + waitingForSync = false; +} + +QWaylandQtTextInputMethod::QWaylandQtTextInputMethod(QWaylandObject *container, QWaylandCompositor *compositor) + : QWaylandCompositorExtensionTemplate(container, *new QWaylandQtTextInputMethodPrivate(compositor)) +{ + connect(&d_func()->focusDestroyListener, &QWaylandDestroyListener::fired, + this, &QWaylandQtTextInputMethod::focusSurfaceDestroyed); + + connect(qGuiApp->inputMethod(), &QInputMethod::visibleChanged, this, &QWaylandQtTextInputMethod::sendVisibleChanged); + connect(qGuiApp->inputMethod(), &QInputMethod::keyboardRectangleChanged, this, &QWaylandQtTextInputMethod::sendKeyboardRectangleChanged); + connect(qGuiApp->inputMethod(), &QInputMethod::inputDirectionChanged, this, &QWaylandQtTextInputMethod::sendInputDirectionChanged); + connect(qGuiApp->inputMethod(), &QInputMethod::localeChanged, this, &QWaylandQtTextInputMethod::sendLocaleChanged); +} + + +QWaylandQtTextInputMethod::~QWaylandQtTextInputMethod() +{ +} + +void QWaylandQtTextInputMethod::focusSurfaceDestroyed() +{ + Q_D(QWaylandQtTextInputMethod); + d->focusDestroyListener.reset(); + d->waitingForSync = false; + d->resource = nullptr; + d->focusedSurface = nullptr; +} + +QWaylandSurface *QWaylandQtTextInputMethod::focusedSurface() const +{ + Q_D(const QWaylandQtTextInputMethod); + return d->focusedSurface; +} + +QVariant QWaylandQtTextInputMethod::inputMethodQuery(Qt::InputMethodQuery property, QVariant argument) const +{ + Q_D(const QWaylandQtTextInputMethod); + switch (property) { + case Qt::ImHints: + return int(d->hints); + case Qt::ImCursorRectangle: + return d->cursorRectangle; + case Qt::ImCursorPosition: + return d->cursorPosition; + case Qt::ImSurroundingText: + return d->surroundingText; + case Qt::ImAbsolutePosition: + return d->absolutePosition; + case Qt::ImCurrentSelection: + return d->surroundingText.mid(qMin(d->cursorPosition, d->anchorPosition), + qAbs(d->anchorPosition - d->cursorPosition)); + case Qt::ImAnchorPosition: + return d->anchorPosition; + case Qt::ImTextAfterCursor: + if (argument.isValid()) + return d->surroundingText.mid(d->cursorPosition, argument.toInt()); + return d->surroundingText.mid(d->cursorPosition); + case Qt::ImTextBeforeCursor: + if (argument.isValid()) + return d->surroundingText.left(d->cursorPosition).right(argument.toInt()); + return d->surroundingText.left(d->cursorPosition); + case Qt::ImPreferredLanguage: + return d->preferredLanguage; + + default: + return QVariant(); + } +} + +void QWaylandQtTextInputMethod::sendKeyEvent(QKeyEvent *event) +{ + Q_D(QWaylandQtTextInputMethod); + if (d->resource == nullptr || d->resource->handle == nullptr) + return; + + d->send_key(d->resource->handle, + int(event->type()), + event->key(), + event->modifiers(), + event->isAutoRepeat(), + event->count(), + event->nativeScanCode(), + event->nativeVirtualKey(), + event->nativeModifiers(), + event->text()); +} + +void QWaylandQtTextInputMethod::sendInputMethodEvent(QInputMethodEvent *event) +{ + Q_D(QWaylandQtTextInputMethod); + if (d->resource == nullptr || d->resource->handle == nullptr || d->compositor == nullptr) + return; + + if (d->updatingQueries != 0) { + qCWarning(qLcWaylandCompositorInputMethods) << "Input method event sent while client is updating. Ignored."; + return; + } + + Q_ASSERT(!d->waitingForSync); + + QString oldSurroundText = d->surroundingText; + int oldCursorPosition = d->cursorPosition; + int oldAnchorPosition = d->anchorPosition; + int oldAbsolutePosition = d->absolutePosition; + QRect oldCursorRectangle = d->cursorRectangle; + QString oldPreferredLanguage = d->preferredLanguage; + Qt::InputMethodHints oldHints = d->hints; + + uint serial = d->compositor->nextSerial(); // ### Not needed if we block on this? + d->send_start_input_method_event(d->resource->handle, serial, d->surroundingTextOffset); + for (const QInputMethodEvent::Attribute &attribute : event->attributes()) { + switch (attribute.type) { + case QInputMethodEvent::TextFormat: + { + auto properties = attribute.value.value<QTextFormat>().properties(); + if (properties.size() != 2 || properties.firstKey() != QTextFormat::FontUnderline || properties.lastKey() != QTextFormat::TextUnderlineStyle) { + qCWarning(qLcWaylandCompositorInputMethods()) << "Only underline text formats currently supported"; + } + + d->send_input_method_event_attribute(d->resource->handle, + serial, + attribute.type, + attribute.start, + attribute.length, + QString()); + break; + } + case QInputMethodEvent::Cursor: + d->cursorPosition = attribute.start; + d->send_input_method_event_attribute(d->resource->handle, + serial, + attribute.type, + attribute.start, + attribute.length, + attribute.value.typeId() == QMetaType::QColor ? attribute.value.value<QColor>().name() : QString()); + break; + case QInputMethodEvent::Language: // ### What is the type of value? Is it string? + Q_FALLTHROUGH(); + case QInputMethodEvent::Ruby: + d->send_input_method_event_attribute(d->resource->handle, + serial, + attribute.type, + attribute.start, + attribute.length, + attribute.value.toString()); + break; + case QInputMethodEvent::Selection: + d->send_input_method_event_attribute(d->resource->handle, + serial, + attribute.type, + attribute.start, + attribute.length, + QString()); + break; + } + } + + d->waitingForSync = true; + d->send_end_input_method_event(d->resource->handle, + serial, + event->commitString(), + event->preeditString(), + event->replacementStart(), + event->replacementLength()); + + while (d->waitingForSync) + d->compositor->processWaylandEvents(); + + Qt::InputMethodQueries queries; + if (d->surroundingText != oldSurroundText) + queries |= Qt::ImSurroundingText; + if (d->cursorPosition != oldCursorPosition) + queries |= Qt::ImCursorPosition; + if (d->anchorPosition != oldAnchorPosition) + queries |= Qt::ImAnchorPosition; + if (d->absolutePosition != oldAbsolutePosition) + queries |= Qt::ImAbsolutePosition; + if (d->cursorRectangle != oldCursorRectangle) + queries |= Qt::ImCursorRectangle; + if (d->preferredLanguage != oldPreferredLanguage) + queries |= Qt::ImPreferredLanguage; + if (d->hints != oldHints) + queries |= Qt::ImHints; + if (queries != 0) + emit updateInputMethod(queries); +} + +bool QWaylandQtTextInputMethod::isSurfaceEnabled(QWaylandSurface *surface) const +{ + Q_D(const QWaylandQtTextInputMethod); + return d->enabledSurfaces.values().contains(surface); +} + +void QWaylandQtTextInputMethod::setFocus(QWaylandSurface *surface) +{ + Q_D(QWaylandQtTextInputMethod); + + QWaylandQtTextInputMethodPrivate::Resource *resource = surface != nullptr ? d->resourceMap().value(surface->waylandClient()) : nullptr; + if (d->resource == resource) + return; + + if (d->resource != nullptr && d->focusedSurface != nullptr) { + d->send_leave(d->resource->handle, d->focusedSurface->resource()); + d->focusDestroyListener.reset(); + } + + d->resource = resource; + d->focusedSurface = surface; + + if (d->resource != nullptr && d->focusedSurface != nullptr) { + d->surroundingText.clear(); + d->cursorPosition = 0; + d->anchorPosition = 0; + d->absolutePosition = 0; + d->cursorRectangle = QRect(); + d->preferredLanguage.clear(); + d->hints = Qt::InputMethodHints(); + d->send_enter(d->resource->handle, d->focusedSurface->resource()); + sendInputDirectionChanged(); + sendLocaleChanged(); + sendInputDirectionChanged(); + d->focusDestroyListener.listenForDestruction(surface->resource()); + if (d->inputPanelVisible && d->enabledSurfaces.values().contains(surface)) + qGuiApp->inputMethod()->show(); + } +} + +void QWaylandQtTextInputMethod::sendLocaleChanged() +{ + Q_D(QWaylandQtTextInputMethod); + if (d->resource == nullptr || d->resource->handle == nullptr) + return; + + d->send_locale_changed(d->resource->handle, qGuiApp->inputMethod()->locale().bcp47Name()); +} + +void QWaylandQtTextInputMethod::sendInputDirectionChanged() +{ + Q_D(QWaylandQtTextInputMethod); + if (d->resource == nullptr || d->resource->handle == nullptr) + return; + + d->send_input_direction_changed(d->resource->handle, int(qGuiApp->inputMethod()->inputDirection())); +} + +void QWaylandQtTextInputMethod::sendKeyboardRectangleChanged() +{ + Q_D(QWaylandQtTextInputMethod); + if (d->resource == nullptr || d->resource->handle == nullptr) + return; + + QRectF keyboardRectangle = qGuiApp->inputMethod()->keyboardRectangle(); + d->send_keyboard_rectangle_changed(d->resource->handle, + wl_fixed_from_double(keyboardRectangle.x()), + wl_fixed_from_double(keyboardRectangle.y()), + wl_fixed_from_double(keyboardRectangle.width()), + wl_fixed_from_double(keyboardRectangle.height())); +} + +void QWaylandQtTextInputMethod::sendVisibleChanged() +{ + Q_D(QWaylandQtTextInputMethod); + if (d->resource == nullptr || d->resource->handle == nullptr) + return; + + d->send_visible_changed(d->resource->handle, int(qGuiApp->inputMethod()->isVisible())); +} + +void QWaylandQtTextInputMethod::add(::wl_client *client, uint32_t id, int version) +{ + Q_D(QWaylandQtTextInputMethod); + d->add(client, id, version); +} + +const struct wl_interface *QWaylandQtTextInputMethod::interface() +{ + return QWaylandQtTextInputMethodPrivate::interface(); +} + +QByteArray QWaylandQtTextInputMethod::interfaceName() +{ + return QWaylandQtTextInputMethodPrivate::interfaceName(); +} + +QT_END_NAMESPACE + +#include "moc_qwaylandqttextinputmethod.cpp" diff --git a/src/compositor/extensions/qwaylandqttextinputmethod.h b/src/compositor/extensions/qwaylandqttextinputmethod.h new file mode 100644 index 000000000..99f7cb4b2 --- /dev/null +++ b/src/compositor/extensions/qwaylandqttextinputmethod.h @@ -0,0 +1,55 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#ifndef QWAYLANDQTTEXTINPUTMETHOD_H +#define QWAYLANDQTTEXTINPUTMETHOD_H + +#include <QtWaylandCompositor/qwaylandcompositorextension.h> + +struct wl_client; + +QT_BEGIN_NAMESPACE + +class QWaylandSurface; +class QWaylandQtTextInputMethodPrivate; +class QInputMethodEvent; +class QKeyEvent; + +class QWaylandQtTextInputMethod : public QWaylandCompositorExtensionTemplate<QWaylandQtTextInputMethod> +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QWaylandQtTextInputMethod) +public: + explicit QWaylandQtTextInputMethod(QWaylandObject *container, QWaylandCompositor *compositor); + ~QWaylandQtTextInputMethod() override; + + QWaylandSurface *focusedSurface() const; + void setFocus(QWaylandSurface *surface); + + bool isSurfaceEnabled(QWaylandSurface *surface) const; + + void add(::wl_client *client, uint32_t id, int version); + + static const struct wl_interface *interface(); + static QByteArray interfaceName(); + + QVariant inputMethodQuery(Qt::InputMethodQuery property, QVariant argument) const; + void sendInputMethodEvent(QInputMethodEvent *event); + void sendKeyEvent(QKeyEvent *event); + +Q_SIGNALS: + void updateInputMethod(Qt::InputMethodQueries queries); + void surfaceEnabled(QWaylandSurface *surface); + void surfaceDisabled(QWaylandSurface *surface); + +private Q_SLOTS: + void sendVisibleChanged(); + void sendKeyboardRectangleChanged(); + void sendInputDirectionChanged(); + void sendLocaleChanged(); + void focusSurfaceDestroyed(); +}; + +QT_END_NAMESPACE + +#endif // QWAYLANDQTTEXTINPUTMETHOD_H diff --git a/src/compositor/extensions/qwaylandqttextinputmethod_p.h b/src/compositor/extensions/qwaylandqttextinputmethod_p.h new file mode 100644 index 000000000..2ca1e9213 --- /dev/null +++ b/src/compositor/extensions/qwaylandqttextinputmethod_p.h @@ -0,0 +1,80 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#ifndef QWAYLANDQTTEXTINPUTMETHOD_P_H +#define QWAYLANDQTTEXTINPUTMETHOD_P_H + + +#include "qwaylandqttextinputmethod.h" + +#include <QtWaylandCompositor/private/qwaylandcompositorextension_p.h> +#include <QtWaylandCompositor/private/qwayland-server-qt-text-input-method-unstable-v1.h> +#include <QtWaylandCompositor/qwaylanddestroylistener.h> + +#include <QtCore/qrect.h> +#include <QtCore/qhash.h> + +// +// 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 QWaylandCompositor; +class QWaylandSurface; + +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandQtTextInputMethodPrivate : public QWaylandCompositorExtensionPrivate, public QtWaylandServer::qt_text_input_method_v1 +{ + Q_DECLARE_PUBLIC(QWaylandQtTextInputMethod) +public: + explicit QWaylandQtTextInputMethodPrivate(QWaylandCompositor *compositor); + + QWaylandCompositor *compositor; + QWaylandSurface *focusedSurface = nullptr; + Resource *resource = nullptr; + QHash<Resource * , QWaylandSurface *> enabledSurfaces; + QWaylandDestroyListener focusDestroyListener; + bool inputPanelVisible = false; + bool waitingForSync = false; + + Qt::InputMethodQueries updatingQueries; + Qt::InputMethodHints hints; + QString surroundingText; + QString preferredLanguage; + QRect cursorRectangle; + int cursorPosition = 0; + int anchorPosition = 0; + int absolutePosition = 0; + int surroundingTextOffset = 0; + +private: + void text_input_method_v1_enable(Resource *resource, struct ::wl_resource *surface) override; + void text_input_method_v1_disable(Resource *resource, struct ::wl_resource *surface) override; + void text_input_method_v1_destroy(Resource *resource) override; + void text_input_method_v1_reset(Resource *resource) override; + void text_input_method_v1_commit(Resource *resource) override; + void text_input_method_v1_show_input_panel(Resource *resource) override; + void text_input_method_v1_hide_input_panel(Resource *resource) override; + void text_input_method_v1_update_hints(Resource *resource, int32_t hints) override; + void text_input_method_v1_update_surrounding_text(Resource *resource, const QString &surroundingText, int32_t surroundingTextOffset) override; + void text_input_method_v1_update_anchor_position(Resource *resource, int32_t anchorPosition) override; + void text_input_method_v1_update_cursor_position(Resource *resource, int32_t cursorPosition) override; + void text_input_method_v1_update_absolute_position(Resource *resource, int32_t absolutePosition) override; + void text_input_method_v1_invoke_action(Resource *resource, int32_t type, int32_t cursorPosition) override; + void text_input_method_v1_update_preferred_language(Resource *resource, const QString &preferredLanguage) override; + void text_input_method_v1_update_cursor_rectangle(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) override; + void text_input_method_v1_start_update(Resource *resource, int32_t queries) override; + void text_input_method_v1_end_update(Resource *resource) override; + void text_input_method_v1_acknowledge_input_method(Resource *resource) override; +}; + +QT_END_NAMESPACE + +#endif // QWAYLANDQTTEXTINPUTMETHOD_P_H diff --git a/src/compositor/extensions/qwaylandqttextinputmethodmanager.cpp b/src/compositor/extensions/qwaylandqttextinputmethodmanager.cpp new file mode 100644 index 000000000..355e77338 --- /dev/null +++ b/src/compositor/extensions/qwaylandqttextinputmethodmanager.cpp @@ -0,0 +1,102 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include "qwaylandqttextinputmethodmanager.h" +#include "qwaylandqttextinputmethodmanager_p.h" + +#include <QtWaylandCompositor/QWaylandCompositor> +#include <QtWaylandCompositor/QWaylandSeat> + +#include "qwaylandqttextinputmethod.h" + +QT_BEGIN_NAMESPACE + +QWaylandQtTextInputMethodManagerPrivate::QWaylandQtTextInputMethodManagerPrivate() +{ +} + +void QWaylandQtTextInputMethodManagerPrivate::text_input_method_manager_v1_get_text_input_method(Resource *resource, uint32_t id, struct ::wl_resource *seatResource) +{ + Q_Q(QWaylandQtTextInputMethodManager); + QWaylandCompositor *compositor = static_cast<QWaylandCompositor *>(q->extensionContainer()); + QWaylandSeat *seat = QWaylandSeat::fromSeatResource(seatResource); + QWaylandQtTextInputMethod *textInput = QWaylandQtTextInputMethod::findIn(seat); + if (textInput == nullptr) + textInput = new QWaylandQtTextInputMethod(seat, compositor); + textInput->add(resource->client(), id, wl_resource_get_version(resource->handle)); + QWaylandClient *client = QWaylandClient::fromWlClient(compositor, resource->client()); + QWaylandClient::TextInputProtocols p = client->textInputProtocols(); + client->setTextInputProtocols(p.setFlag(QWaylandClient::TextInputProtocol::QtTextInputMethodV1)); + + if (!textInput->isInitialized()) + textInput->initialize(); +} + +/*! + \qmltype QtTextInputMethodManager + \instantiates QWaylandQtTextInputMethodManager + \inqmlmodule QtWayland.Compositor + \since 6.0 + \brief Provides access to input methods in the compositor. + + The \c QtTextInputMethodManager corresponds to the \c qt-text-input-method-manager interface + in the \c qt-text-input-method-unstable-v1 extension protocol. It is specifically designed + to be used with a Qt-based input method, such as Qt Virtual Keyboard. + + Instantiating this as child of a \l WaylandCompositor adds it to the list of interfaces available + to the client. If a client binds to it, then it will be used to communciate text input to + that client. +*/ + +/*! + \class QWaylandQtTextInputMethodManager + \inmodule QtWaylandCompositor + \since 6.0 + \brief Provides access to input methods in the compositor. + + The \c QWaylandQtTextInputMethodManager class corresponds to the \c qt-text-input-method-manager interface + in the \c qt-text-input-method-unstable-v1 extension protocol. It is specifically designed + to be used with a Qt-based input method, such as Qt Virtual Keyboard. + + Instantiating this as child of a \l WaylandCompositor adds it to the list of interfaces available + to the client. If a client binds to it, then it will be used to communciate text input to + that client. +*/ + +QWaylandQtTextInputMethodManager::QWaylandQtTextInputMethodManager() + : QWaylandCompositorExtensionTemplate<QWaylandQtTextInputMethodManager>(*new QWaylandQtTextInputMethodManagerPrivate) +{ +} + +QWaylandQtTextInputMethodManager::QWaylandQtTextInputMethodManager(QWaylandCompositor *compositor) + : QWaylandCompositorExtensionTemplate<QWaylandQtTextInputMethodManager>(compositor, *new QWaylandQtTextInputMethodManagerPrivate) +{ +} + +void QWaylandQtTextInputMethodManager::initialize() +{ + Q_D(QWaylandQtTextInputMethodManager); + + QWaylandCompositorExtensionTemplate::initialize(); + QWaylandCompositor *compositor = static_cast<QWaylandCompositor *>(extensionContainer()); + if (compositor == nullptr) { + qWarning() << "Failed to find QWaylandCompositor when initializing QWaylandQtTextInputMethodManager"; + return; + } + + d->init(compositor->display(), 1); +} + +const wl_interface *QWaylandQtTextInputMethodManager::interface() +{ + return QWaylandQtTextInputMethodManagerPrivate::interface(); +} + +QByteArray QWaylandQtTextInputMethodManager::interfaceName() +{ + return QWaylandQtTextInputMethodManagerPrivate::interfaceName(); +} + +QT_END_NAMESPACE + +#include "moc_qwaylandqttextinputmethodmanager.cpp" diff --git a/src/compositor/extensions/qwaylandqttextinputmethodmanager.h b/src/compositor/extensions/qwaylandqttextinputmethodmanager.h new file mode 100644 index 000000000..ded6a3aae --- /dev/null +++ b/src/compositor/extensions/qwaylandqttextinputmethodmanager.h @@ -0,0 +1,31 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#ifndef QWAYLANDQTTEXTINPUTMETHODMANAGER_H +#define QWAYLANDQTTEXTINPUTMETHODMANAGER_H + +#include <QtWaylandCompositor/QWaylandCompositorExtension> + +#include <QtCore/QSize> + +QT_BEGIN_NAMESPACE + +class QWaylandQtTextInputMethodManagerPrivate; + +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandQtTextInputMethodManager : public QWaylandCompositorExtensionTemplate<QWaylandQtTextInputMethodManager> +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QWaylandQtTextInputMethodManager) +public: + QWaylandQtTextInputMethodManager(); + QWaylandQtTextInputMethodManager(QWaylandCompositor *compositor); + + void initialize() override; + + static const struct wl_interface *interface(); + static QByteArray interfaceName(); +}; + +QT_END_NAMESPACE + +#endif // QWAYLANDQTTEXTINPUTMETHODMANAGER_H diff --git a/src/compositor/extensions/qwaylandqttextinputmethodmanager_p.h b/src/compositor/extensions/qwaylandqttextinputmethodmanager_p.h new file mode 100644 index 000000000..71be87e85 --- /dev/null +++ b/src/compositor/extensions/qwaylandqttextinputmethodmanager_p.h @@ -0,0 +1,36 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#ifndef QWAYLANDQTTEXTINPUTMETHODMANAGER_P_H +#define QWAYLANDQTTEXTINPUTMETHODMANAGER_P_H + +#include <QtWaylandCompositor/private/qwaylandcompositorextension_p.h> + +#include <QtWaylandCompositor/private/qwayland-server-qt-text-input-method-unstable-v1.h> + +// +// 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_WAYLANDCOMPOSITOR_EXPORT QWaylandQtTextInputMethodManagerPrivate : public QWaylandCompositorExtensionPrivate, public QtWaylandServer::qt_text_input_method_manager_v1 +{ + Q_DECLARE_PUBLIC(QWaylandQtTextInputMethodManager) +public: + QWaylandQtTextInputMethodManagerPrivate(); + +protected: + void text_input_method_manager_v1_get_text_input_method(Resource *resource, uint32_t id, struct ::wl_resource *seat) override; +}; + +QT_END_NAMESPACE + +#endif // QWAYLANDQTTEXTINPUTMETHODMANAGER_P_H diff --git a/src/compositor/extensions/qwaylandqtwindowmanager.cpp b/src/compositor/extensions/qwaylandqtwindowmanager.cpp index d44dd456b..f33a83ac9 100644 --- a/src/compositor/extensions/qwaylandqtwindowmanager.cpp +++ b/src/compositor/extensions/qwaylandqtwindowmanager.cpp @@ -1,32 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QtCore/QObject> #include <QtCore/QUrl> @@ -139,3 +113,5 @@ QByteArray QWaylandQtWindowManager::interfaceName() } QT_END_NAMESPACE + +#include "moc_qwaylandqtwindowmanager.cpp" diff --git a/src/compositor/extensions/qwaylandqtwindowmanager.h b/src/compositor/extensions/qwaylandqtwindowmanager.h index d83508219..c1439cf46 100644 --- a/src/compositor/extensions/qwaylandqtwindowmanager.h +++ b/src/compositor/extensions/qwaylandqtwindowmanager.h @@ -1,32 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDQTWINDOWMANAGER_H #define QWAYLANDQTWINDOWMANAGER_H @@ -40,7 +14,7 @@ QT_BEGIN_NAMESPACE class QWaylandQtWindowManagerPrivate; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandQtWindowManager : public QWaylandCompositorExtensionTemplate<QWaylandQtWindowManager> +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandQtWindowManager : public QWaylandCompositorExtensionTemplate<QWaylandQtWindowManager> { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandQtWindowManager) diff --git a/src/compositor/extensions/qwaylandqtwindowmanager_p.h b/src/compositor/extensions/qwaylandqtwindowmanager_p.h index dc353e2c5..8c7e7e827 100644 --- a/src/compositor/extensions/qwaylandqtwindowmanager_p.h +++ b/src/compositor/extensions/qwaylandqtwindowmanager_p.h @@ -1,32 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDQTWINDOWMANAGER_P_H #define QWAYLANDQTWINDOWMANAGER_P_H @@ -50,7 +24,7 @@ QT_BEGIN_NAMESPACE -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandQtWindowManagerPrivate +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandQtWindowManagerPrivate : public QWaylandCompositorExtensionPrivate , public QtWaylandServer::qt_windowmanager { diff --git a/src/compositor/extensions/qwaylandquickshellintegration.cpp b/src/compositor/extensions/qwaylandquickshellintegration.cpp index 5d3d526f1..87762eae6 100644 --- a/src/compositor/extensions/qwaylandquickshellintegration.cpp +++ b/src/compositor/extensions/qwaylandquickshellintegration.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwaylandquickshellintegration.h" @@ -33,7 +7,7 @@ * \class QWaylandQuickShellIntegration * \inmodule QtWaylandCompositor * \since 5.14 - * \brief Provides support for shell surface integration with QtQuick + * \brief Provides support for shell surface integration with QtQuick. * * Shell surface implementations should inherit from this class in order to provide * an integration between the shell surface and QtQuick. @@ -80,6 +54,8 @@ * \sa QObject::eventFilter() */ +QT_BEGIN_NAMESPACE + QWaylandQuickShellIntegration::QWaylandQuickShellIntegration(QObject *parent) : QObject(parent) { @@ -88,3 +64,7 @@ QWaylandQuickShellIntegration::QWaylandQuickShellIntegration(QObject *parent) QWaylandQuickShellIntegration::~QWaylandQuickShellIntegration() { } + +QT_END_NAMESPACE + +#include "moc_qwaylandquickshellintegration.cpp" diff --git a/src/compositor/extensions/qwaylandquickshellintegration.h b/src/compositor/extensions/qwaylandquickshellintegration.h index cae11ee4f..574d3ea47 100644 --- a/src/compositor/extensions/qwaylandquickshellintegration.h +++ b/src/compositor/extensions/qwaylandquickshellintegration.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDQUICKSHELLINTEGRATION_H #define QWAYLANDQUICKSHELLINTEGRATION_H @@ -33,9 +7,11 @@ #include <QtCore/QObject> #include <QtWaylandCompositor/qtwaylandcompositorglobal.h> +QT_REQUIRE_CONFIG(wayland_compositor_quick); + QT_BEGIN_NAMESPACE -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandQuickShellIntegration : public QObject +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandQuickShellIntegration : public QObject { Q_OBJECT public: diff --git a/src/compositor/extensions/qwaylandquickshellsurfaceitem.cpp b/src/compositor/extensions/qwaylandquickshellsurfaceitem.cpp index 4952cef66..7eb1479f5 100644 --- a/src/compositor/extensions/qwaylandquickshellsurfaceitem.cpp +++ b/src/compositor/extensions/qwaylandquickshellsurfaceitem.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwaylandquickshellsurfaceitem.h" #include "qwaylandquickshellsurfaceitem_p.h" @@ -44,14 +18,14 @@ QWaylandQuickShellSurfaceItem *QWaylandQuickShellSurfaceItemPrivate::maybeCreate auto *popupItem = new QWaylandQuickShellSurfaceItem(q); popupItem->setShellSurface(shellSurface); popupItem->setAutoCreatePopupItems(true); - QObject::connect(popupItem, &QWaylandQuickShellSurfaceItem::surfaceDestroyed, [popupItem](){ - popupItem->deleteLater(); - }); + QObject::connect(popupItem, &QWaylandQuickShellSurfaceItem::surfaceDestroyed, + popupItem, &QObject::deleteLater); return popupItem; } /*! * \qmltype ShellSurfaceItem + * \instantiates QWaylandQuickShellSurfaceItem * \inherits WaylandQuickItem * \inqmlmodule QtWayland.Compositor * \since 5.8 @@ -60,7 +34,7 @@ QWaylandQuickShellSurfaceItem *QWaylandQuickShellSurfaceItemPrivate::maybeCreate * This type is used to render \c wl_shell, \c xdg_shell or \c ivi_application surfaces as part of * a Qt Quick scene. It handles moving and resizing triggered by clicking on the window decorations. * - * \sa WaylandQuickItem, WlShellSurface, XdgSurfaceV5, IviSurface + * \sa WaylandQuickItem, WlShellSurface, IviSurface */ /*! @@ -72,7 +46,7 @@ QWaylandQuickShellSurfaceItem *QWaylandQuickShellSurfaceItemPrivate::maybeCreate * This class is used to render \c wl_shell, \c xdg_shell or \c ivi_application surfaces as part of * a Qt Quick scene. It handles moving and resizing triggered by clicking on the window decorations. * - * \sa QWaylandQuickItem, QWaylandWlShellSurface, QWaylandXdgSurfaceV5, QWaylandIviSurface + * \sa QWaylandQuickItem, QWaylandWlShellSurface, QWaylandIviSurface */ /*! @@ -102,7 +76,7 @@ QWaylandQuickShellSurfaceItem::QWaylandQuickShellSurfaceItem(QWaylandQuickShellS } /*! - * \qmlproperty ShellSurface QtWaylandCompositor::ShellSurfaceItem::shellSurface + * \qmlproperty ShellSurface QtWayland.Compositor::ShellSurfaceItem::shellSurface * * This property holds the ShellSurface rendered by this ShellSurfaceItem. * It may either be an XdgSurfaceV5, WlShellSurface or IviSurface depending on which shell protocol @@ -128,6 +102,9 @@ void QWaylandQuickShellSurfaceItem::setShellSurface(QWaylandShellSurface *shellS if (d->m_shellSurface == shellSurface) return; + if (Q_UNLIKELY(d->m_shellSurface)) + disconnect(d->m_shellSurface, &QWaylandShellSurface::modalChanged, this, nullptr); + d->m_shellSurface = shellSurface; if (d->m_shellIntegration) { @@ -141,11 +118,14 @@ void QWaylandQuickShellSurfaceItem::setShellSurface(QWaylandShellSurface *shellS installEventFilter(d->m_shellIntegration); } + connect(shellSurface, &QWaylandShellSurface::modalChanged, this, + [d](){ if (d->m_shellSurface->modal()) d->raise(); }); + emit shellSurfaceChanged(); } /*! - * \qmlproperty Item QtWaylandCompositor::ShellSurfaceItem::moveItem + * \qmlproperty Item QtWayland.Compositor::ShellSurfaceItem::moveItem * * This property holds the move item for this ShellSurfaceItem. This is the item that will be moved * when the clients request the ShellSurface to be moved, maximized, resized etc. This property is @@ -176,7 +156,7 @@ void QWaylandQuickShellSurfaceItem::setMoveItem(QQuickItem *moveItem) } /*! - * \qmlproperty bool QtWaylandCompositor::ShellSurfaceItem::autoCreatePopupItems + * \qmlproperty bool QtWayland.Compositor::ShellSurfaceItem::autoCreatePopupItems * * This property holds whether ShellSurfaceItems for popups parented to the shell * surface managed by this item should automatically be created. @@ -312,4 +292,151 @@ void QWaylandQuickShellEventFilter::timerEvent(QTimerEvent *event) } } +static QWaylandQuickShellSurfaceItem *findSurfaceItemFromMoveItem(QQuickItem *moveItem) +{ + if (Q_UNLIKELY(!moveItem)) + return nullptr; + if (auto *surf = qobject_cast<QWaylandQuickShellSurfaceItem *>(moveItem)) + return surf; + for (auto *item : moveItem->childItems()) { + if (auto *surf = findSurfaceItemFromMoveItem(item)) + return surf; + } + return nullptr; +} + +static inline bool onTop(QWaylandQuickShellSurfaceItem *surf) +{ + return surf->staysOnTop() || surf->shellSurface()->modal(); +} + +static inline bool onBottom(QWaylandQuickShellSurfaceItem *surf) +{ + return surf->staysOnBottom() && !surf->shellSurface()->modal(); +} + +/* + To raise a surface, find the topmost suitable surface and place above that. + We start from the top and: + If we don't have staysOnTop, skip all surfaces with staysOnTop + If we have staysOnBottom, skip all surfaces that don't have staysOnBottom + A modal dialog is handled as if it had staysOnTop + */ +void QWaylandQuickShellSurfaceItemPrivate::raise() +{ + Q_Q(QWaylandQuickShellSurfaceItem); + auto *moveItem = q->moveItem(); + QQuickItem *parent = moveItem->parentItem(); + if (!parent) + return; + const bool putOnTop = staysOnTop || m_shellSurface->modal(); + const bool putOnBottom = staysOnBottom && !m_shellSurface->modal(); + + auto it = parent->childItems().crbegin(); + auto skip = [=](QQuickItem *item) { + if (auto *surf = findSurfaceItemFromMoveItem(item)) + return (!putOnTop && onTop(surf)) || (putOnBottom && !onBottom(surf)); + return true; // ignore any other Quick items that may be there + }; + auto end = parent->childItems().crend(); + while (it != end && skip(*it)) + ++it; + if (it != end) { + QQuickItem *top = *it; + if (moveItem != top) + moveItem->stackAfter(top); + } +} + +/* + To lower a surface, find the lowest suitable surface and place below that. + We start from the bottom and: + If we don't have staysOnBottom, skip all surfaces with staysOnBottom + If we have staysOnTop, skip all surfaces that don't have staysOnTop + A modal dialog is handled as if it had staysOnTop + */ +void QWaylandQuickShellSurfaceItemPrivate::lower() +{ + Q_Q(QWaylandQuickShellSurfaceItem); + auto *moveItem = q->moveItem(); + QQuickItem *parent = moveItem->parentItem(); + if (!parent) + return; + const bool putOnTop = staysOnTop || m_shellSurface->modal(); + const bool putOnBottom = staysOnBottom && !m_shellSurface->modal(); + + auto it = parent->childItems().cbegin(); + auto skip = [=](QQuickItem *item) { + if (auto *surf = findSurfaceItemFromMoveItem(item)) + return (!putOnBottom && onBottom(surf)) || (putOnTop && !onTop(surf)); + return true; // ignore any other Quick items that may be there + }; + while (skip(*it)) + ++it; + + QQuickItem *bottom = *it; + if (moveItem != bottom) + moveItem->stackBefore(bottom); +} + +/*! + * \property QWaylandQuickShellSurfaceItem::staysOnTop + * + * Keep this item above other Wayland surfaces + */ +bool QWaylandQuickShellSurfaceItem::staysOnTop() const +{ + Q_D(const QWaylandQuickShellSurfaceItem); + return d->staysOnTop; +} + +void QWaylandQuickShellSurfaceItem::setStaysOnTop(bool onTop) +{ + Q_D(QWaylandQuickShellSurfaceItem); + if (d->staysOnTop == onTop) + return; + d->staysOnTop = onTop; + if (d->staysOnBottom) { + d->staysOnBottom = false; + emit staysOnBottomChanged(); + } + // We need to call raise() even if onTop is false, since we need to stack under any other + // staysOnTop surfaces in that case + raise(); + emit staysOnTopChanged(); + Q_ASSERT(!(d->staysOnTop && d->staysOnBottom)); +} + +/*! + * \property QWaylandQuickShellSurfaceItem::staysOnBottom + * + * Keep this item above other Wayland surfaces + */ +bool QWaylandQuickShellSurfaceItem::staysOnBottom() const +{ + Q_D(const QWaylandQuickShellSurfaceItem); + return d->staysOnBottom; +} + +void QWaylandQuickShellSurfaceItem::setStaysOnBottom(bool onBottom) +{ + Q_D(QWaylandQuickShellSurfaceItem); + if (d->staysOnBottom == onBottom) + return; + d->staysOnBottom = onBottom; + if (d->staysOnTop) { + d->staysOnTop = false; + emit staysOnTopChanged(); + } + // We need to call lower() even if onBottom is false, since we need to stack over any other + // staysOnBottom surfaces in that case + lower(); + emit staysOnBottomChanged(); + Q_ASSERT(!(d->staysOnTop && d->staysOnBottom)); +} + QT_END_NAMESPACE + +#include "moc_qwaylandquickshellsurfaceitem_p.cpp" + +#include "moc_qwaylandquickshellsurfaceitem.cpp" diff --git a/src/compositor/extensions/qwaylandquickshellsurfaceitem.h b/src/compositor/extensions/qwaylandquickshellsurfaceitem.h index 39949a8fa..9d9610c70 100644 --- a/src/compositor/extensions/qwaylandquickshellsurfaceitem.h +++ b/src/compositor/extensions/qwaylandquickshellsurfaceitem.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDQUICKSHELLSURFACEITEM_H #define QWAYLANDQUICKSHELLSURFACEITEM_H @@ -33,18 +7,25 @@ #include <QtWaylandCompositor/QWaylandCompositorExtension> #include <QtWaylandCompositor/QWaylandQuickItem> +QT_REQUIRE_CONFIG(wayland_compositor_quick); + QT_BEGIN_NAMESPACE class QWaylandQuickShellSurfaceItemPrivate; class QWaylandShellSurface; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandQuickShellSurfaceItem : public QWaylandQuickItem +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandQuickShellSurfaceItem : public QWaylandQuickItem { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandQuickShellSurfaceItem) Q_PROPERTY(QWaylandShellSurface *shellSurface READ shellSurface WRITE setShellSurface NOTIFY shellSurfaceChanged) Q_PROPERTY(QQuickItem *moveItem READ moveItem WRITE setMoveItem NOTIFY moveItemChanged) Q_PROPERTY(bool autoCreatePopupItems READ autoCreatePopupItems WRITE setAutoCreatePopupItems NOTIFY autoCreatePopupItemsChanged) + Q_PROPERTY(bool staysOnTop READ staysOnTop WRITE setStaysOnTop NOTIFY staysOnTopChanged) + Q_PROPERTY(bool staysOnBottom READ staysOnBottom WRITE setStaysOnBottom NOTIFY staysOnBottomChanged) + Q_MOC_INCLUDE("qwaylandshellsurface.h") + QML_NAMED_ELEMENT(ShellSurfaceItem) + QML_ADDED_IN_VERSION(1, 0) public: QWaylandQuickShellSurfaceItem(QQuickItem *parent = nullptr); ~QWaylandQuickShellSurfaceItem() override; @@ -58,10 +39,17 @@ public: bool autoCreatePopupItems(); void setAutoCreatePopupItems(bool enabled); + bool staysOnTop() const; + void setStaysOnTop(bool on); + bool staysOnBottom() const; + void setStaysOnBottom(bool on); + Q_SIGNALS: void shellSurfaceChanged(); void moveItemChanged(); void autoCreatePopupItemsChanged(); + void staysOnTopChanged(); + void staysOnBottomChanged(); protected: QWaylandQuickShellSurfaceItem(QWaylandQuickShellSurfaceItemPrivate &dd, QQuickItem *parent); diff --git a/src/compositor/extensions/qwaylandquickshellsurfaceitem_p.h b/src/compositor/extensions/qwaylandquickshellsurfaceitem_p.h index 27163145e..46e5f65a5 100644 --- a/src/compositor/extensions/qwaylandquickshellsurfaceitem_p.h +++ b/src/compositor/extensions/qwaylandquickshellsurfaceitem_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDQUICKSHELLSURFACEITEM_P_H #define QWAYLANDQUICKSHELLSURFACEITEM_P_H @@ -33,7 +7,9 @@ #include <QtWaylandCompositor/QWaylandQuickShellSurfaceItem> #include <QtWaylandCompositor/QWaylandQuickShellIntegration> #include <QtWaylandCompositor/private/qwaylandquickitem_p.h> + #include <QtCore/QBasicTimer> +#include <QtCore/qpointer.h> #include <functional> @@ -53,7 +29,7 @@ QT_BEGIN_NAMESPACE class QWaylandShellSurface; class QWaylandQuickShellSurfaceItem; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandQuickShellSurfaceItemPrivate : public QWaylandQuickItemPrivate +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandQuickShellSurfaceItemPrivate : public QWaylandQuickItemPrivate { Q_DECLARE_PUBLIC(QWaylandQuickShellSurfaceItem) public: @@ -61,19 +37,18 @@ public: QWaylandQuickShellSurfaceItem *maybeCreateAutoPopup(QWaylandShellSurface* shellSurface); static QWaylandQuickShellSurfaceItemPrivate *get(QWaylandQuickShellSurfaceItem *item) { return item->d_func(); } + void raise() override; + void lower() override; + QWaylandQuickShellIntegration *m_shellIntegration = nullptr; QWaylandShellSurface *m_shellSurface = nullptr; QQuickItem *m_moveItem = nullptr; - bool m_autoCreatePopupItems = -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - true; -#else - false; -#endif - + bool m_autoCreatePopupItems = true; + bool staysOnTop = false; + bool staysOnBottom = false; }; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandQuickShellEventFilter : public QObject +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandQuickShellEventFilter : public QObject { Q_OBJECT public: diff --git a/src/compositor/extensions/qwaylandquickxdgoutputv1.cpp b/src/compositor/extensions/qwaylandquickxdgoutputv1.cpp index eb6717a78..c637280c1 100644 --- a/src/compositor/extensions/qwaylandquickxdgoutputv1.cpp +++ b/src/compositor/extensions/qwaylandquickxdgoutputv1.cpp @@ -1,38 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 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$ -** -****************************************************************************/ +// Copyright (C) 2019 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QWaylandCompositor> #include <QWaylandOutput> @@ -40,6 +7,8 @@ #include "qwaylandquickxdgoutputv1.h" #include "qwaylandxdgoutputv1_p.h" +QT_BEGIN_NAMESPACE + QWaylandQuickXdgOutputV1::QWaylandQuickXdgOutputV1() : QWaylandXdgOutputV1() { @@ -71,3 +40,7 @@ void QWaylandQuickXdgOutputV1::componentComplete() } } } + +QT_END_NAMESPACE + +#include "moc_qwaylandquickxdgoutputv1.cpp" diff --git a/src/compositor/extensions/qwaylandquickxdgoutputv1.h b/src/compositor/extensions/qwaylandquickxdgoutputv1.h index c8b16ab8e..c607cf649 100644 --- a/src/compositor/extensions/qwaylandquickxdgoutputv1.h +++ b/src/compositor/extensions/qwaylandquickxdgoutputv1.h @@ -1,38 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 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$ -** -****************************************************************************/ +// Copyright (C) 2019 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDQUICKXDGOUTPUT_V1 #define QWAYLANDQUICKXDGOUTPUT_V1 @@ -41,9 +8,11 @@ #include <QtQml/QQmlParserStatus> #include <QtWaylandCompositor/QWaylandXdgOutputV1> +QT_REQUIRE_CONFIG(wayland_compositor_quick); + QT_BEGIN_NAMESPACE -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandQuickXdgOutputV1 +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandQuickXdgOutputV1 : public QWaylandXdgOutputV1 , public QQmlParserStatus { diff --git a/src/compositor/extensions/qwaylandshell.cpp b/src/compositor/extensions/qwaylandshell.cpp index 45f80114e..68f9d839b 100644 --- a/src/compositor/extensions/qwaylandshell.cpp +++ b/src/compositor/extensions/qwaylandshell.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwaylandshell.h" #include "qwaylandshell_p.h" @@ -55,7 +29,7 @@ QWaylandShell::QWaylandShell(QWaylandObject *waylandObject) */ /*! - * \qmlproperty enumeration QtWaylandCompositor::Shell::focusPolicy + * \qmlproperty enumeration Shell::focusPolicy * * This property holds the focus policy of the Shell. */ @@ -92,14 +66,6 @@ QWaylandShell::QWaylandShell(QWaylandObject *container, QWaylandShellPrivate &dd { } -QWaylandShell::QWaylandShell(QWaylandCompositorExtensionPrivate &dd) - : QWaylandShell(static_cast<QWaylandShellPrivate &>(dd)) -{ -} - -QWaylandShell::QWaylandShell(QWaylandObject *container, QWaylandCompositorExtensionPrivate &dd) - : QWaylandShell(container, static_cast<QWaylandShellPrivate &>(dd)) -{ -} - QT_END_NAMESPACE + +#include "moc_qwaylandshell.cpp" diff --git a/src/compositor/extensions/qwaylandshell.h b/src/compositor/extensions/qwaylandshell.h index a572b3d6e..765d4f0eb 100644 --- a/src/compositor/extensions/qwaylandshell.h +++ b/src/compositor/extensions/qwaylandshell.h @@ -1,46 +1,25 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDSHELL_H #define QWAYLANDSHELL_H -#include <QtWaylandCompositor/QWaylandCompositorExtension> +#include <QtWaylandCompositor/qtwaylandqmlinclude.h> +#include <QtWaylandCompositor/qwaylandcompositorextension.h> QT_BEGIN_NAMESPACE class QWaylandShellPrivate; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandShell : public QWaylandCompositorExtension +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandShell : public QWaylandCompositorExtension { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandShell) Q_PROPERTY(FocusPolicy focusPolicy READ focusPolicy WRITE setFocusPolicy NOTIFY focusPolicyChanged) + + QML_NAMED_ELEMENT(Shell) + QML_UNCREATABLE("") + QML_ADDED_IN_VERSION(1, 0) public: enum FocusPolicy { AutomaticFocus, @@ -60,14 +39,10 @@ Q_SIGNALS: protected: explicit QWaylandShell(QWaylandShellPrivate &dd); explicit QWaylandShell(QWaylandObject *container, QWaylandShellPrivate &dd); - - //Qt 6: remove - Q_DECL_DEPRECATED QWaylandShell(QWaylandCompositorExtensionPrivate &dd); - Q_DECL_DEPRECATED QWaylandShell(QWaylandObject *container, QWaylandCompositorExtensionPrivate &dd); }; template <typename T> -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandShellTemplate : public QWaylandShell +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandShellTemplate : public QWaylandShell { public: QWaylandShellTemplate() diff --git a/src/compositor/extensions/qwaylandshell_p.h b/src/compositor/extensions/qwaylandshell_p.h index c3ca79338..ab7dc9a34 100644 --- a/src/compositor/extensions/qwaylandshell_p.h +++ b/src/compositor/extensions/qwaylandshell_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDSHELL_P_H #define QWAYLANDSHELL_P_H @@ -46,7 +20,7 @@ QT_BEGIN_NAMESPACE -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandShellPrivate : public QWaylandCompositorExtensionPrivate +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandShellPrivate : public QWaylandCompositorExtensionPrivate { Q_DECLARE_PUBLIC(QWaylandShell) public: diff --git a/src/compositor/extensions/qwaylandshellsurface.cpp b/src/compositor/extensions/qwaylandshellsurface.cpp index 6fda778f6..7e2fcee60 100644 --- a/src/compositor/extensions/qwaylandshellsurface.cpp +++ b/src/compositor/extensions/qwaylandshellsurface.cpp @@ -1,36 +1,46 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the config.tests of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtWaylandCompositor/QWaylandShellSurface> +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include "qwaylandshellsurface_p.h" + +/*! + * \class QWaylandShellSurfaceTemplate + * \inmodule QtWaylandCompositor + * \since 5.8 + * \brief QWaylandShellSurfaceTemplate is a convenience class for creating custom shell surface + * classes. + * + * QWaylandShellSurfaceTemplate is a template class which inherits from QWaylandShellSurface and + * is convenience for building custom shell extensions. + * + * It provides the connection between Qt Wayland Compositor and the class generated by + * \c qtwaylandscanner, based on the XML description of the extension protocol. + * + * It provides two specific pieces of convenience: + * \list + * \li A reimplementation of \l{QWaylandCompositorExtension::extensionInterface()} which returns + * the \c wl_interface pointer for the qtwaylandscanner-generated base class. + * \li A static \l{findIn()} function which searches for an instance of the extension in a + * provided container, and returns this if it is found. + * \endlist + * + * The same usage pattern applies as for QWaylandCompositorExtensionTemplate. + * + * \sa { Custom Shell} + */ + +/*! + * \fn template <typename T> T *QWaylandShellSurfaceTemplate<T>::findIn(QWaylandObject *container) + * + * If any instance of the interface has been registered with \a container, this is returned. + * Otherwise null is returned. The look-up is based on the generated \c interfaceName() which + * matches the interface name in the protocol description. + */ + /*! * \qmltype ShellSurface + * \instantiates QWaylandShellSurface * \inqmlmodule QtWayland.Compositor * \since 5.8 * \brief Provides a common interface for surface roles specified by shell extensions. @@ -38,13 +48,13 @@ * This interface represents a Wayland surface role given by a Wayland protocol extension that * defines how the WaylandSurface should map onto the screen. * - * Note: Even though this type contains a very limited API, the properties and signals of the + * \note Even though this type contains a very limited API, the properties and signals of the * implementations are named consistently. For example, if you're only using desktop shell * extensions in your compositor, it's safe to access properties such as title, maximized, etc. * directly on the ShellSurface. See the various implementations for additional properties and * signals. * - * \sa WaylandSurface, ShellSurfaceItem, WlShellSurface, XdgSurfaceV5, IviSurface + * \sa WaylandSurface, ShellSurfaceItem, WlShellSurface, IviSurface */ /*! @@ -56,7 +66,7 @@ * This interface represents a Wayland surface role given by a Wayland protocol extension that * defines how the QWaylandSurface should map onto the screen. * - * \sa QWaylandSurface, QWaylandWlShellSurface, QWaylandXdgSurfaceV5, QWaylandIviSurface + * \sa QWaylandSurface, QWaylandWlShellSurface, QWaylandIviSurface, QWaylandShellSurfaceTemplate */ #if QT_CONFIG(wayland_compositor_quick) @@ -64,14 +74,14 @@ * \fn QWaylandQuickShellIntegration *QWaylandShellSurface::createIntegration(QWaylandQuickShellSurfaceItem *item) * * Creates a QWaylandQuickShellIntegration for this QWaylandQuickShellSurface. It's called - * automatically when QWaylandQuickShellSurfaceItem::shellSurface is assigned. + * automatically when \a {item}'s \l {QWaylandQuickShellSurfaceItem::}{shellSurface} is assigned. * * \sa QWaylandQuickShellSurfaceItem */ #endif /*! - * \qmlproperty enum QtWaylandCompositor::ShellSurface::windowType + * \qmlproperty enum QtWayland.Compositor::ShellSurface::windowType * * This property holds the window type of the ShellSurface. */ @@ -81,3 +91,53 @@ * * This property holds the window type of the QWaylandShellSurface. */ + +/*! + * \qmlproperty bool QtWayland.Compositor::ShellSurface::modal + * + * This property is true if the ShellSurface represents a modal dialog. + * \since 6.8 + */ + +/*! + * \property QWaylandShellSurface::modal + * + * This property is true if the ShellSurface represents a modal dialog. + * \since 6.8 + */ + +QT_BEGIN_NAMESPACE + +QWaylandShellSurface::QWaylandShellSurface(QWaylandShellSurfacePrivate &dd) + : QWaylandCompositorExtension(dd) +{ +} + +QWaylandShellSurface::QWaylandShellSurface(QWaylandObject *container, QWaylandShellSurfacePrivate &dd) + : QWaylandCompositorExtension(container, dd) +{ +} + +QWaylandShellSurface::QWaylandShellSurface(QWaylandObject *waylandObject) + : QWaylandCompositorExtension(waylandObject, *new QWaylandShellSurfacePrivate) +{ +} + +bool QWaylandShellSurface::modal() const +{ + Q_D(const QWaylandShellSurface); + return d->modal; +} + +void QWaylandShellSurface::setModal(bool newModal) +{ + Q_D(QWaylandShellSurface); + if (d->modal == newModal) + return; + d->modal = newModal; + emit modalChanged(); +} + +QT_END_NAMESPACE + +#include "moc_qwaylandshellsurface.cpp" diff --git a/src/compositor/extensions/qwaylandshellsurface.h b/src/compositor/extensions/qwaylandshellsurface.h index bcc931228..96ef772ca 100644 --- a/src/compositor/extensions/qwaylandshellsurface.h +++ b/src/compositor/extensions/qwaylandshellsurface.h @@ -1,68 +1,52 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDSHELLSURFACE_H #define QWAYLANDSHELLSURFACE_H -#include <QtWaylandCompositor/QWaylandCompositorExtension> +#include <QtWaylandCompositor/qtwaylandqmlinclude.h> +#include <QtWaylandCompositor/qwaylandcompositorextension.h> QT_BEGIN_NAMESPACE class QWaylandQuickShellIntegration; class QWaylandQuickShellSurfaceItem; class QWaylandShellSurfacePrivate; -class QWaylandShellSurfaceTemplatePrivate; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandShellSurface : public QWaylandCompositorExtension +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandShellSurface : public QWaylandCompositorExtension { Q_OBJECT + Q_DECLARE_PRIVATE(QWaylandShellSurface) + Q_PROPERTY(Qt::WindowType windowType READ windowType NOTIFY windowTypeChanged) + Q_PROPERTY(bool modal READ modal NOTIFY modalChanged FINAL REVISION(6, 8)) + QML_NAMED_ELEMENT(ShellSurface) + QML_UNCREATABLE("") + QML_ADDED_IN_VERSION(1, 0) public: #if QT_CONFIG(wayland_compositor_quick) virtual QWaylandQuickShellIntegration *createIntegration(QWaylandQuickShellSurfaceItem *item) = 0; #endif - QWaylandShellSurface(QWaylandObject *waylandObject) : QWaylandCompositorExtension(waylandObject) {} + QWaylandShellSurface(QWaylandObject *waylandObject); virtual Qt::WindowType windowType() const { return Qt::WindowType::Window; } + bool modal() const; + protected: - QWaylandShellSurface(QWaylandCompositorExtensionPrivate &dd) : QWaylandCompositorExtension(dd){} - QWaylandShellSurface(QWaylandObject *container, QWaylandCompositorExtensionPrivate &dd) : QWaylandCompositorExtension(container, dd) {} + QWaylandShellSurface(QWaylandShellSurfacePrivate &dd); + QWaylandShellSurface(QWaylandObject *container, QWaylandShellSurfacePrivate &dd); + void setModal(bool newModal); Q_SIGNALS: void windowTypeChanged(); + Q_REVISION(6, 8) void modalChanged(); }; template <typename T> -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandShellSurfaceTemplate : public QWaylandShellSurface +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandShellSurfaceTemplate : public QWaylandShellSurface { public: - QWaylandShellSurfaceTemplate(QWaylandObject *container) + QWaylandShellSurfaceTemplate(QWaylandObject *container = nullptr) : QWaylandShellSurface(container) { } @@ -78,11 +62,11 @@ public: } protected: - QWaylandShellSurfaceTemplate(QWaylandCompositorExtensionPrivate &dd) + QWaylandShellSurfaceTemplate(QWaylandShellSurfacePrivate &dd) : QWaylandShellSurface(dd) { } - QWaylandShellSurfaceTemplate(QWaylandObject *container, QWaylandCompositorExtensionPrivate &dd) + QWaylandShellSurfaceTemplate(QWaylandObject *container, QWaylandShellSurfacePrivate &dd) : QWaylandShellSurface(container,dd) { } }; diff --git a/src/compositor/extensions/qwaylandshellsurface_p.h b/src/compositor/extensions/qwaylandshellsurface_p.h new file mode 100644 index 000000000..438571824 --- /dev/null +++ b/src/compositor/extensions/qwaylandshellsurface_p.h @@ -0,0 +1,32 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#ifndef QWAYLANDSHELLSURFACE_P_H +#define QWAYLANDSHELLSURFACE_P_H + +#include <QtWaylandCompositor/private/qwaylandcompositorextension_p.h> +#include "qwaylandshellsurface.h" + +// +// 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_WAYLANDCOMPOSITOR_EXPORT QWaylandShellSurfacePrivate : public QWaylandCompositorExtensionPrivate +{ + Q_DECLARE_PUBLIC(QWaylandShellSurface) +public: + bool modal = false; +}; + +QT_END_NAMESPACE + +#endif // QWAYLANDSHELLSURFACE_P_H diff --git a/src/compositor/extensions/qwaylandtextinput.cpp b/src/compositor/extensions/qwaylandtextinput.cpp index 5f6adac9d..933f31208 100644 --- a/src/compositor/extensions/qwaylandtextinput.cpp +++ b/src/compositor/extensions/qwaylandtextinput.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwaylandtextinput.h" #include "qwaylandtextinput_p.h" @@ -36,12 +10,13 @@ #include "qwaylandsurface.h" #include "qwaylandview.h" #include "qwaylandinputmethodeventbuilder_p.h" +#include "qwaylandinputmethodcontrol.h" #include <QGuiApplication> #include <QInputMethodEvent> #if QT_CONFIG(xkbcommon) -#include <QtXkbCommonSupport/private/qxkbcommon_p.h> +#include <QtGui/private/qxkbcommon_p.h> #endif QT_BEGIN_NAMESPACE @@ -130,10 +105,10 @@ void QWaylandTextInputPrivate::sendInputMethodEvent(QInputMethodEvent *event) if (event->replacementLength() > 0 || event->replacementStart() != 0) { // Remove replacement - afterCommit.cursorPosition = qBound(0, afterCommit.cursorPosition + event->replacementStart(), afterCommit.surroundingText.length()); + afterCommit.cursorPosition = qBound(0, afterCommit.cursorPosition + event->replacementStart(), afterCommit.surroundingText.size()); afterCommit.surroundingText.remove(afterCommit.cursorPosition, qMin(event->replacementLength(), - afterCommit.surroundingText.length() - afterCommit.cursorPosition)); + afterCommit.surroundingText.size() - afterCommit.cursorPosition)); if (event->replacementStart() <= 0 && (event->replacementLength() >= -event->replacementStart())) { const int selectionStart = qMin(currentState->cursorPosition, currentState->anchorPosition); @@ -149,7 +124,7 @@ void QWaylandTextInputPrivate::sendInputMethodEvent(QInputMethodEvent *event) // Insert commit string afterCommit.surroundingText.insert(afterCommit.cursorPosition, event->commitString()); - afterCommit.cursorPosition += event->commitString().length(); + afterCommit.cursorPosition += event->commitString().size(); afterCommit.anchorPosition = afterCommit.cursorPosition; for (const QInputMethodEvent::Attribute &attribute : event->attributes()) { @@ -194,13 +169,22 @@ void QWaylandTextInputPrivate::sendKeyEvent(QKeyEvent *event) if (!focusResource || !focusResource->handle) return; - // TODO add support for modifiers + uint mods = 0; + const auto &qtMods = event->modifiers(); + if (qtMods & Qt::ShiftModifier) + mods |= shiftModifierMask; + if (qtMods & Qt::ControlModifier) + mods |= controlModifierMask; + if (qtMods & Qt::AltModifier) + mods |= altModifierMask; + if (qtMods & Qt::MetaModifier) + mods |= metaModifierMask; #if QT_CONFIG(xkbcommon) for (xkb_keysym_t keysym : QXkbCommon::toKeysym(event)) { send_keysym(focusResource->handle, event->timestamp(), keysym, event->type() == QEvent::KeyPress ? WL_KEYBOARD_KEY_STATE_PRESSED : WL_KEYBOARD_KEY_STATE_RELEASED, - 0); + mods); } #else Q_UNUSED(event); @@ -313,9 +297,24 @@ void QWaylandTextInputPrivate::setFocus(QWaylandSurface *surface) focus = surface; } +void QWaylandTextInputPrivate::sendModifiersMap(const QByteArray &modifiersMap) +{ + send_modifiers_map(focusResource->handle, modifiersMap); +} + +#if !QT_CONFIG(xkbcommon) +#define XKB_MOD_NAME_SHIFT "Shift" +#define XKB_MOD_NAME_CTRL "Control" +#define XKB_MOD_NAME_ALT "Mod1" +#define XKB_MOD_NAME_LOGO "Mod4" +#endif void QWaylandTextInputPrivate::zwp_text_input_v2_bind_resource(Resource *resource) { - send_modifiers_map(resource->handle, QByteArray("")); + QByteArray modifiers = XKB_MOD_NAME_SHIFT + QByteArray(1, '\0'); + modifiers += XKB_MOD_NAME_CTRL + QByteArray(1, '\0'); + modifiers += XKB_MOD_NAME_ALT + QByteArray(1, '\0'); + modifiers += XKB_MOD_NAME_LOGO + QByteArray(1, '\0'); + send_modifiers_map(resource->handle, modifiers); } void QWaylandTextInputPrivate::zwp_text_input_v2_destroy_resource(Resource *resource) @@ -335,6 +334,11 @@ void QWaylandTextInputPrivate::zwp_text_input_v2_enable(Resource *resource, wl_r QWaylandSurface *s = QWaylandSurface::fromResource(surface); enabledSurfaces.insert(resource, s); + + QWaylandInputMethodControl *control = s->inputMethodControl(); + if (control) + control->updateTextInput(); + emit q->surfaceEnabled(s); } @@ -388,9 +392,9 @@ void QWaylandTextInputPrivate::zwp_text_input_v2_update_state(Resource *resource Qt::InputMethodQueries queries; if (flags == update_state_change) { - queries = currentState->mergeChanged(*pendingState.data()); + queries = currentState->mergeChanged(*pendingState); } else { - queries = pendingState->updatedQueries(*currentState.data()); + queries = pendingState->updatedQueries(*currentState); currentState.swap(pendingState); } @@ -601,4 +605,33 @@ QByteArray QWaylandTextInput::interfaceName() return QWaylandTextInputPrivate::interfaceName(); } + +void QWaylandTextInput::sendModifiersMap(const QByteArray &modifiersMap) +{ + Q_D(QWaylandTextInput); + + const QList<QByteArray> modifiers = modifiersMap.split('\0'); + + int numModifiers = modifiers.size(); + if (modifiers.last().isEmpty()) + numModifiers--; + + for (int i = 0; i < numModifiers; ++i) { + const auto modString = modifiers.at(i); + if (modString == XKB_MOD_NAME_SHIFT) + d->shiftModifierMask = 1 << i; + else if (modString == XKB_MOD_NAME_CTRL) + d->controlModifierMask = 1 << i; + else if (modString == XKB_MOD_NAME_ALT) + d->altModifierMask = 1 << i; + else if (modString == XKB_MOD_NAME_LOGO) + d->metaModifierMask = 1 << i; + else + qCDebug(qLcWaylandCompositorInputMethods) << "unsupported modifier name " << modString; + } + d->sendModifiersMap(modifiersMap); +} + QT_END_NAMESPACE + +#include "moc_qwaylandtextinput.cpp" diff --git a/src/compositor/extensions/qwaylandtextinput.h b/src/compositor/extensions/qwaylandtextinput.h index fc2918e29..0d7dcd2c7 100644 --- a/src/compositor/extensions/qwaylandtextinput.h +++ b/src/compositor/extensions/qwaylandtextinput.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDTEXTINPUT_H #define QWAYLANDTEXTINPUT_H @@ -64,6 +38,8 @@ public: static const struct wl_interface *interface(); static QByteArray interfaceName(); + void sendModifiersMap(const QByteArray &modifiersMap); + Q_SIGNALS: void updateInputMethod(Qt::InputMethodQueries queries); void surfaceEnabled(QWaylandSurface *surface); diff --git a/src/compositor/extensions/qwaylandtextinput_p.h b/src/compositor/extensions/qwaylandtextinput_p.h index dba0c2bf5..239bc9d5c 100644 --- a/src/compositor/extensions/qwaylandtextinput_p.h +++ b/src/compositor/extensions/qwaylandtextinput_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDTEXTINPUT_P_H #define QWAYLANDTEXTINPUT_P_H @@ -36,8 +10,8 @@ #include <QtCore/QObject> #include <QtCore/QMap> +#include <QtCore/QHash> #include <QtCore/QRect> -#include <QtCore/QVector> #include <QtGui/QInputMethod> #include <QtWaylandCompositor/QWaylandSurface> @@ -76,7 +50,7 @@ public: Qt::InputMethodQueries changedState; }; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandTextInputPrivate : public QWaylandCompositorExtensionPrivate, public QtWaylandServer::zwp_text_input_v2 +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandTextInputPrivate : public QWaylandCompositorExtensionPrivate, public QtWaylandServer::zwp_text_input_v2 { Q_DECLARE_PUBLIC(QWaylandTextInput) public: @@ -87,6 +61,7 @@ public: void sendInputPanelState(); void sendTextDirection(); void sendLocale(); + void sendModifiersMap(const QByteArray &modifiersMap); QVariant inputMethodQuery(Qt::InputMethodQuery property, QVariant argument) const; @@ -100,8 +75,8 @@ public: bool inputPanelVisible = false; - QScopedPointer<QWaylandTextInputClientState> currentState; - QScopedPointer<QWaylandTextInputClientState> pendingState; + std::unique_ptr<QWaylandTextInputClientState> currentState; + std::unique_ptr<QWaylandTextInputClientState> pendingState; uint32_t serial = 0; @@ -121,6 +96,12 @@ protected: void zwp_text_input_v2_set_cursor_rectangle(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) override; void zwp_text_input_v2_set_preferred_language(Resource *resource, const QString &language) override; void zwp_text_input_v2_update_state(Resource *resource, uint32_t serial, uint32_t flags) override; + +private: + quint32 shiftModifierMask = 1; + quint32 controlModifierMask = 2; + quint32 altModifierMask = 4; + quint32 metaModifierMask = 8; }; QT_END_NAMESPACE diff --git a/src/compositor/extensions/qwaylandtextinputmanager.cpp b/src/compositor/extensions/qwaylandtextinputmanager.cpp index 495ebae84..64f6ffdd7 100644 --- a/src/compositor/extensions/qwaylandtextinputmanager.cpp +++ b/src/compositor/extensions/qwaylandtextinputmanager.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwaylandtextinputmanager.h" #include "qwaylandtextinputmanager_p.h" @@ -47,12 +21,43 @@ void QWaylandTextInputManagerPrivate::zwp_text_input_manager_v2_get_text_input(R QWaylandCompositor *compositor = static_cast<QWaylandCompositor *>(q->extensionContainer()); QWaylandSeat *seat = QWaylandSeat::fromSeatResource(seatResource); QWaylandTextInput *textInput = QWaylandTextInput::findIn(seat); - if (!textInput) { + if (!textInput) textInput = new QWaylandTextInput(seat, compositor); - } textInput->add(resource->client(), id, wl_resource_get_version(resource->handle)); + QWaylandClient *client = QWaylandClient::fromWlClient(compositor, resource->client()); + QWaylandClient::TextInputProtocols p = client->textInputProtocols(); + client->setTextInputProtocols(p.setFlag(QWaylandClient::TextInputProtocol::TextInputV2)); + if (!textInput->isInitialized()) + textInput->initialize(); } +/*! + \qmltype TextInputManager + \instantiates QWaylandTextInputManager + \inqmlmodule QtWayland.Compositor + \brief Provides access to input methods in the compositor. + + The \c TextInputManager corresponds to the \c zwp_text_input_manager_v2 interface + in the \c text_input_unstable_v2 extension protocol. + + Instantiating this as child of a \l WaylandCompositor adds it to the list of interfaces available + to the client. If a client binds to it, then it will be used to communciate text input to + that client. +*/ + +/*! + \class QWaylandTextInputManager + \inmodule QtWaylandCompositor + \brief Provides access to input methods in the compositor. + + The \c QWaylandTextInputManager corresponds to the \c zwp_text_input_manager_v2 interface + in the \c text_input_unstable_v2 extension protocol. + + Instantiating this as child of a \l WaylandCompositor adds it to the list of interfaces available + to the client. If a client binds to it, then it will be used to communciate text input to + that client. +*/ + QWaylandTextInputManager::QWaylandTextInputManager() : QWaylandCompositorExtensionTemplate<QWaylandTextInputManager>(*new QWaylandTextInputManagerPrivate) { @@ -87,3 +92,5 @@ QByteArray QWaylandTextInputManager::interfaceName() } QT_END_NAMESPACE + +#include "moc_qwaylandtextinputmanager.cpp" diff --git a/src/compositor/extensions/qwaylandtextinputmanager.h b/src/compositor/extensions/qwaylandtextinputmanager.h index 90a8b3b14..cab75d8fa 100644 --- a/src/compositor/extensions/qwaylandtextinputmanager.h +++ b/src/compositor/extensions/qwaylandtextinputmanager.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDTEXTINPUTMANAGER_H #define QWAYLANDTEXTINPUTMANAGER_H @@ -38,7 +12,7 @@ QT_BEGIN_NAMESPACE class QWaylandTextInputManagerPrivate; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandTextInputManager : public QWaylandCompositorExtensionTemplate<QWaylandTextInputManager> +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandTextInputManager : public QWaylandCompositorExtensionTemplate<QWaylandTextInputManager> { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandTextInputManager) diff --git a/src/compositor/extensions/qwaylandtextinputmanager_p.h b/src/compositor/extensions/qwaylandtextinputmanager_p.h index 804930bcc..1e998fda4 100644 --- a/src/compositor/extensions/qwaylandtextinputmanager_p.h +++ b/src/compositor/extensions/qwaylandtextinputmanager_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDTEXTINPUTMANAGER_P_H #define QWAYLANDTEXTINPUTMANAGER_P_H @@ -47,7 +21,7 @@ QT_BEGIN_NAMESPACE -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandTextInputManagerPrivate : public QWaylandCompositorExtensionPrivate, public QtWaylandServer::zwp_text_input_manager_v2 +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandTextInputManagerPrivate : public QWaylandCompositorExtensionPrivate, public QtWaylandServer::zwp_text_input_manager_v2 { Q_DECLARE_PUBLIC(QWaylandTextInputManager) public: diff --git a/src/compositor/extensions/qwaylandtextinputmanagerv3.cpp b/src/compositor/extensions/qwaylandtextinputmanagerv3.cpp new file mode 100644 index 000000000..e9ad25bff --- /dev/null +++ b/src/compositor/extensions/qwaylandtextinputmanagerv3.cpp @@ -0,0 +1,111 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include "qwaylandtextinputmanagerv3.h" +#include "qwaylandtextinputmanagerv3_p.h" + +#include <QtWaylandCompositor/QWaylandCompositor> +#include <QtWaylandCompositor/QWaylandSeat> + +#include "qwaylandtextinputv3.h" + +QT_BEGIN_NAMESPACE + +QWaylandTextInputManagerV3Private::QWaylandTextInputManagerV3Private() +{ +} + +void QWaylandTextInputManagerV3Private::zwp_text_input_manager_v3_get_text_input(Resource *resource, uint32_t id, struct ::wl_resource *seatResource) +{ + qCDebug(qLcWaylandCompositorTextInput) << Q_FUNC_INFO; + + Q_Q(QWaylandTextInputManagerV3); + QWaylandCompositor *compositor = static_cast<QWaylandCompositor *>(q->extensionContainer()); + QWaylandSeat *seat = QWaylandSeat::fromSeatResource(seatResource); + QWaylandTextInputV3 *textInput = QWaylandTextInputV3::findIn(seat); + if (!textInput) { + textInput = new QWaylandTextInputV3(seat, compositor); + } + textInput->add(resource->client(), id, wl_resource_get_version(resource->handle)); + QWaylandClient *client = QWaylandClient::fromWlClient(compositor, resource->client()); + QWaylandClient::TextInputProtocols p = client->textInputProtocols(); + client->setTextInputProtocols(p.setFlag(QWaylandClient::TextInputProtocol::TextInputV3)); + if (!textInput->isInitialized()) + textInput->initialize(); +} + +/*! + \internal + \preliminary + + \qmltype TextInputManagerV3 + \instantiates QWaylandTextInputManagerV3 + \inqmlmodule QtWayland.Compositor + \brief Provides access to input methods in the compositor. + + The \c TextInputManagerV3 corresponds to the \c zwp_text_input_manager_v3 interface + in the \c text_input_unstable_v3 extension protocol. + + Instantiating this as child of a \l WaylandCompositor adds it to the list of interfaces available + to the client. If a client binds to it, then it will be used to communciate text input to + that client. + + \note This protocol is currently a work-in-progress and only exists in Qt for validation purposes. It may change at any time. +*/ + +/*! + \internal + \preliminary + \class QWaylandTextInputManagerV3 + \inmodule QtWaylandCompositor + \brief Provides access to input methods in the compositor. + + The \c QWaylandTextInputManagerV3 corresponds to the \c zwp_text_input_manager_v3 interface + in the \c text_input_unstable_v3 extension protocol. + + Instantiating this as child of a \l WaylandCompositor adds it to the list of interfaces available + to the client. If a client binds to it, then it will be used to communciate text input to + that client. + \note This protocol is currently a work-in-progress and only exists in Qt for validation purposes. It may change at any time. +*/ + +QWaylandTextInputManagerV3::QWaylandTextInputManagerV3() + : QWaylandCompositorExtensionTemplate<QWaylandTextInputManagerV3>(*new QWaylandTextInputManagerV3Private) +{ +} + +QWaylandTextInputManagerV3::QWaylandTextInputManagerV3(QWaylandCompositor *compositor) + : QWaylandCompositorExtensionTemplate<QWaylandTextInputManagerV3>(compositor, *new QWaylandTextInputManagerV3Private) +{ +} + +QWaylandTextInputManagerV3::~QWaylandTextInputManagerV3() +{ +} + +void QWaylandTextInputManagerV3::initialize() +{ + qCDebug(qLcWaylandCompositorTextInput) << Q_FUNC_INFO; + + Q_D(QWaylandTextInputManagerV3); + + QWaylandCompositorExtensionTemplate::initialize(); + QWaylandCompositor *compositor = static_cast<QWaylandCompositor *>(extensionContainer()); + if (!compositor) { + qWarning() << "Failed to find QWaylandCompositor when initializing QWaylandTextInputManagerV3"; + return; + } + d->init(compositor->display(), 1); +} + +const wl_interface *QWaylandTextInputManagerV3::interface() +{ + return QWaylandTextInputManagerV3Private::interface(); +} + +QByteArray QWaylandTextInputManagerV3::interfaceName() +{ + return QWaylandTextInputManagerV3Private::interfaceName(); +} + +QT_END_NAMESPACE diff --git a/src/compositor/extensions/qwaylandtextinputmanagerv3.h b/src/compositor/extensions/qwaylandtextinputmanagerv3.h new file mode 100644 index 000000000..a71fdcbaa --- /dev/null +++ b/src/compositor/extensions/qwaylandtextinputmanagerv3.h @@ -0,0 +1,32 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#ifndef QWAYLANDTEXTINPUTMANAGERV3_H +#define QWAYLANDTEXTINPUTMANAGERV3_H + +#include <QtWaylandCompositor/QWaylandCompositorExtension> + +#include <QtCore/QSize> + +QT_BEGIN_NAMESPACE + +class QWaylandTextInputManagerV3Private; + +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandTextInputManagerV3 : public QWaylandCompositorExtensionTemplate<QWaylandTextInputManagerV3> +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QWaylandTextInputManagerV3) +public: + QWaylandTextInputManagerV3(); + explicit QWaylandTextInputManagerV3(QWaylandCompositor *compositor); + ~QWaylandTextInputManagerV3() override; + + void initialize() override; + + static const struct wl_interface *interface(); + static QByteArray interfaceName(); +}; + +QT_END_NAMESPACE + +#endif // QWAYLANDTEXTINPUTMANAGERV3_H diff --git a/src/compositor/extensions/qwaylandtextinputmanagerv3_p.h b/src/compositor/extensions/qwaylandtextinputmanagerv3_p.h new file mode 100644 index 000000000..5559a4418 --- /dev/null +++ b/src/compositor/extensions/qwaylandtextinputmanagerv3_p.h @@ -0,0 +1,36 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#ifndef QWAYLANDTEXTINPUTMANAGERV3_P_H +#define QWAYLANDTEXTINPUTMANAGERV3_P_H + +#include <QtWaylandCompositor/private/qwaylandcompositorextension_p.h> + +#include <QtWaylandCompositor/private/qwayland-server-text-input-unstable-v3.h> + +// +// 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_WAYLANDCOMPOSITOR_EXPORT QWaylandTextInputManagerV3Private : public QWaylandCompositorExtensionPrivate, public QtWaylandServer::zwp_text_input_manager_v3 +{ + Q_DECLARE_PUBLIC(QWaylandTextInputManagerV3) +public: + QWaylandTextInputManagerV3Private(); + +protected: + void zwp_text_input_manager_v3_get_text_input(Resource *resource, uint32_t id, struct ::wl_resource *seatResource) override; +}; + +QT_END_NAMESPACE + +#endif // QWAYLANDTEXTINPUTMANAGERV3_P_H diff --git a/src/compositor/extensions/qwaylandtextinputv3.cpp b/src/compositor/extensions/qwaylandtextinputv3.cpp new file mode 100644 index 000000000..7a0abd5dd --- /dev/null +++ b/src/compositor/extensions/qwaylandtextinputv3.cpp @@ -0,0 +1,523 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include "qwaylandtextinputv3.h" +#include "qwaylandtextinputv3_p.h" + +#include <QtWaylandCompositor/QWaylandCompositor> +#include <QtWaylandCompositor/private/qwaylandseat_p.h> + +#include "qwaylandsurface.h" +#include "qwaylandview.h" +#include "qwaylandinputmethodeventbuilder_p.h" + +#include <QGuiApplication> +#include <QInputMethodEvent> +#include <qpa/qwindowsysteminterface.h> + +#if QT_CONFIG(xkbcommon) +#include <QtGui/private/qxkbcommon_p.h> +#endif + +QT_BEGIN_NAMESPACE + +Q_DECLARE_LOGGING_CATEGORY(qLcWaylandCompositorTextInput) + +QWaylandTextInputV3ClientState::QWaylandTextInputV3ClientState() +{ +} + +Qt::InputMethodQueries QWaylandTextInputV3ClientState::updatedQueries(const QWaylandTextInputV3ClientState &other) const +{ + qCDebug(qLcWaylandCompositorTextInput) << Q_FUNC_INFO; + + Qt::InputMethodQueries queries; + + if (hints != other.hints) + queries |= Qt::ImHints; + if (cursorRectangle != other.cursorRectangle) + queries |= Qt::ImCursorRectangle; + if (surroundingText != other.surroundingText) + queries |= Qt::ImSurroundingText | Qt::ImCurrentSelection; + if (cursorPosition != other.cursorPosition) + queries |= Qt::ImCursorPosition | Qt::ImCurrentSelection; + if (anchorPosition != other.anchorPosition) + queries |= Qt::ImAnchorPosition | Qt::ImCurrentSelection; + + return queries; +} + +Qt::InputMethodQueries QWaylandTextInputV3ClientState::mergeChanged(const QWaylandTextInputV3ClientState &other) { + + Qt::InputMethodQueries queries; + + if ((other.changedState & Qt::ImHints) && hints != other.hints) { + hints = other.hints; + queries |= Qt::ImHints; + } + + if ((other.changedState & Qt::ImCursorRectangle) && cursorRectangle != other.cursorRectangle) { + cursorRectangle = other.cursorRectangle; + queries |= Qt::ImCursorRectangle; + } + + if ((other.changedState & Qt::ImSurroundingText) && surroundingText != other.surroundingText) { + surroundingText = other.surroundingText; + queries |= Qt::ImSurroundingText | Qt::ImCurrentSelection; + } + + if ((other.changedState & Qt::ImCursorPosition) && cursorPosition != other.cursorPosition) { + cursorPosition = other.cursorPosition; + queries |= Qt::ImCursorPosition | Qt::ImCurrentSelection; + } + + if ((other.changedState & Qt::ImAnchorPosition) && anchorPosition != other.anchorPosition) { + anchorPosition = other.anchorPosition; + queries |= Qt::ImAnchorPosition | Qt::ImCurrentSelection; + } + + return queries; +} + +QWaylandTextInputV3Private::QWaylandTextInputV3Private(QWaylandCompositor *compositor) + : compositor(compositor) + , currentState(new QWaylandTextInputV3ClientState) + , pendingState(new QWaylandTextInputV3ClientState) +{ +} + +void QWaylandTextInputV3Private::sendInputMethodEvent(QInputMethodEvent *event) +{ + qCDebug(qLcWaylandCompositorTextInput) << Q_FUNC_INFO; + + if (!focusResource || !focusResource->handle) + return; + + bool needsDone = false; + + const QString &newPreeditString = event->preeditString(); + + // Current cursor shape is only line. It means both cursorBegin + // and cursorEnd will be the same values. + int32_t preeditCursorPos = newPreeditString.toUtf8().size(); + + if (event->replacementLength() > 0) { + int replacementStart = event->replacementStart(); + int replacementLength = event->replacementLength(); + const int cursorPos = currentState->cursorPosition; + if (currentState->cursorPosition < -event->replacementStart()) { + qCWarning(qLcWaylandCompositorTextInput) + << Q_FUNC_INFO + << "Invalid replacementStart :" << replacementStart + << "on the cursorPosition :" << cursorPos; + replacementStart = -cursorPos; + } + auto targetText = QStringView{currentState->surroundingText}.sliced(cursorPos + replacementStart); + if (targetText.length() < replacementLength) { + qCWarning(qLcWaylandCompositorTextInput) + << Q_FUNC_INFO + << "Invalid replacementLength :" << replacementLength + << "for the surrounding text :" << targetText; + replacementLength = targetText.length(); + } + const int before = targetText.first(-replacementStart).toUtf8().size(); + const int after = targetText.first(replacementLength).toUtf8().size() - before; + + send_delete_surrounding_text(focusResource->handle, before, after); + needsDone = true; + + // The commit will also be applied here + currentState->surroundingText.replace(cursorPos + replacementStart, + replacementLength, + event->commitString()); + currentState->cursorPosition = cursorPos + replacementStart + event->commitString().length(); + currentState->anchorPosition = cursorPos + replacementStart + event->commitString().length(); + qApp->inputMethod()->update(Qt::ImSurroundingText | Qt::ImCursorPosition | Qt::ImAnchorPosition); + } + + if (currentPreeditString != newPreeditString) { + currentPreeditString = newPreeditString; + send_preedit_string(focusResource->handle, currentPreeditString, preeditCursorPos, preeditCursorPos); + needsDone = true; + } + if (!event->commitString().isEmpty()) { + send_commit_string(focusResource->handle, event->commitString()); + needsDone = true; + } + + if (needsDone) + send_done(focusResource->handle, serials[focusResource]); +} + + +void QWaylandTextInputV3Private::sendKeyEvent(QKeyEvent *event) +{ + qCDebug(qLcWaylandCompositorTextInput) << Q_FUNC_INFO; + + if (!focusResource || !focusResource->handle) + return; + + send_commit_string(focusResource->handle, event->text()); + + send_done(focusResource->handle, serials[focusResource]); +} + +QVariant QWaylandTextInputV3Private::inputMethodQuery(Qt::InputMethodQuery property, QVariant argument) const +{ + qCDebug(qLcWaylandCompositorTextInput) << Q_FUNC_INFO << property; + + switch (property) { + case Qt::ImHints: + return QVariant(static_cast<int>(currentState->hints)); + case Qt::ImCursorRectangle: + return currentState->cursorRectangle; + case Qt::ImFont: + // Not supported + return QVariant(); + case Qt::ImCursorPosition: + qCDebug(qLcWaylandCompositorTextInput) << currentState->cursorPosition; + return currentState->cursorPosition; + case Qt::ImSurroundingText: + qCDebug(qLcWaylandCompositorTextInput) << currentState->surroundingText; + return currentState->surroundingText; + case Qt::ImCurrentSelection: + return currentState->surroundingText.mid(qMin(currentState->cursorPosition, currentState->anchorPosition), + qAbs(currentState->anchorPosition - currentState->cursorPosition)); + case Qt::ImMaximumTextLength: + // Not supported + return QVariant(); + case Qt::ImAnchorPosition: + qCDebug(qLcWaylandCompositorTextInput) << currentState->anchorPosition; + return currentState->anchorPosition; + case Qt::ImAbsolutePosition: + // We assume the surrounding text is our whole document for now + return currentState->cursorPosition; + case Qt::ImTextAfterCursor: + if (argument.isValid()) + return currentState->surroundingText.mid(currentState->cursorPosition, argument.toInt()); + return currentState->surroundingText.mid(currentState->cursorPosition); + case Qt::ImTextBeforeCursor: + if (argument.isValid()) + return currentState->surroundingText.left(currentState->cursorPosition).right(argument.toInt()); + return currentState->surroundingText.left(currentState->cursorPosition); + + default: + return QVariant(); + } +} + +void QWaylandTextInputV3Private::setFocus(QWaylandSurface *surface) +{ + qCDebug(qLcWaylandCompositorTextInput) << Q_FUNC_INFO << surface; + + if (focusResource && focus) { + // sync before leave + // IBUS commits by itself but qtvirtualkeyboard doesn't + // And when handling chinese input, it is required to commit + // before leaving the focus. + if (qgetenv("QT_IM_MODULE") != QByteArrayLiteral("ibus") + || qApp->inputMethod()->locale().language() == QLocale::Chinese) { + qApp->inputMethod()->commit(); + } + + qApp->inputMethod()->hide(); + inputPanelVisible = false; + send_leave(focusResource->handle, focus->resource()); + currentPreeditString.clear(); + } + + if (focus != surface) + focusDestroyListener.reset(); + + Resource *resource = surface ? resourceMap().value(surface->waylandClient()) : 0; + if (resource && surface) { + send_enter(resource->handle, surface->resource()); + + if (focus != surface) + focusDestroyListener.listenForDestruction(surface->resource()); + } + + focus = surface; + focusResource = resource; +} + +void QWaylandTextInputV3Private::zwp_text_input_v3_bind_resource(Resource *resource) +{ + qCDebug(qLcWaylandCompositorTextInput) << Q_FUNC_INFO; + + serials.insert(resource, 0); +} + +void QWaylandTextInputV3Private::zwp_text_input_v3_destroy_resource(Resource *resource) +{ + qCDebug(qLcWaylandCompositorTextInput) << Q_FUNC_INFO; + + serials.remove(resource); + if (focusResource == resource) + focusResource = nullptr; +} + +void QWaylandTextInputV3Private::zwp_text_input_v3_destroy(Resource *resource) +{ + qCDebug(qLcWaylandCompositorTextInput) << Q_FUNC_INFO; + + wl_resource_destroy(resource->handle); +} + +void QWaylandTextInputV3Private::zwp_text_input_v3_enable(Resource *resource) +{ + qCDebug(qLcWaylandCompositorTextInput) << Q_FUNC_INFO; + + Q_Q(QWaylandTextInputV3); + + pendingState.reset(new QWaylandTextInputV3ClientState); + + enabledSurfaces.insert(resource, focus); + emit q->surfaceEnabled(focus); + + inputPanelVisible = true; + qApp->inputMethod()->show(); +} + +void QWaylandTextInputV3Private::zwp_text_input_v3_disable(QtWaylandServer::zwp_text_input_v3::Resource *resource) +{ + qCDebug(qLcWaylandCompositorTextInput) << Q_FUNC_INFO; + + Q_Q(QWaylandTextInputV3); + + QWaylandSurface *s = enabledSurfaces.take(resource); + emit q->surfaceDisabled(s); + + // When reselecting a word by setFocus + if (qgetenv("QT_IM_MODULE") != QByteArrayLiteral("ibus") + || qApp->inputMethod()->locale().language() == QLocale::Chinese) { + qApp->inputMethod()->commit(); + } + qApp->inputMethod()->reset(); + pendingState.reset(new QWaylandTextInputV3ClientState); +} + +void QWaylandTextInputV3Private::zwp_text_input_v3_set_cursor_rectangle(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) +{ + qCDebug(qLcWaylandCompositorTextInput) << Q_FUNC_INFO << x << y << width << height; + + if (resource != focusResource) + return; + + pendingState->cursorRectangle = QRect(x, y, width, height); + + pendingState->changedState |= Qt::ImCursorRectangle; +} + +void QWaylandTextInputV3Private::zwp_text_input_v3_commit(Resource *resource) +{ + qCDebug(qLcWaylandCompositorTextInput) << Q_FUNC_INFO; + + serials[resource] = serials[resource] < UINT_MAX ? serials[resource] + 1U : 0U; + + // Just increase serials and ignore empty commits + if (!pendingState->changedState) { + qCDebug(qLcWaylandCompositorTextInput) << Q_FUNC_INFO << "pendingState is not changed"; + return; + } + + // Selection starts. + // But since qtvirtualkeyboard with hunspell does not reset its preedit string, + // compositor forces to reset inputMethod. + if ((currentState->cursorPosition == currentState->anchorPosition) + && (pendingState->cursorPosition != pendingState->anchorPosition)) + qApp->inputMethod()->reset(); + + // Enable reselection + // This is a workaround to make qtvirtualkeyboad's state empty by clearing State::InputMethodClick. + if (currentState->surroundingText == pendingState->surroundingText && currentState->cursorPosition != pendingState->cursorPosition) + qApp->inputMethod()->invokeAction(QInputMethod::Click, pendingState->cursorPosition); + + Qt::InputMethodQueries queries = currentState->mergeChanged(*pendingState.data()); + pendingState.reset(new QWaylandTextInputV3ClientState); + + if (queries) { + qCDebug(qLcWaylandCompositorTextInput) << "QInputMethod::update() after commit with" << queries; + + qApp->inputMethod()->update(queries); + } +} + +void QWaylandTextInputV3Private::zwp_text_input_v3_set_content_type(Resource *resource, uint32_t hint, uint32_t purpose) +{ + qCDebug(qLcWaylandCompositorTextInput) << Q_FUNC_INFO << hint << purpose; + + if (resource != focusResource) + return; + + pendingState->hints = Qt::ImhNone; + + if ((hint & content_hint_completion) == 0) + pendingState->hints |= Qt::ImhNoPredictiveText; + if ((hint & content_hint_auto_capitalization) == 0) + pendingState->hints |= Qt::ImhNoAutoUppercase; + if ((hint & content_hint_lowercase) != 0) + pendingState->hints |= Qt::ImhPreferLowercase; + if ((hint & content_hint_uppercase) != 0) + pendingState->hints |= Qt::ImhPreferUppercase; + if ((hint & content_hint_hidden_text) != 0) + pendingState->hints |= Qt::ImhHiddenText; + if ((hint & content_hint_sensitive_data) != 0) + pendingState->hints |= Qt::ImhSensitiveData; + if ((hint & content_hint_latin) != 0) + pendingState->hints |= Qt::ImhLatinOnly; + if ((hint & content_hint_multiline) != 0) + pendingState->hints |= Qt::ImhMultiLine; + + switch (purpose) { + case content_purpose_normal: + break; + case content_purpose_alpha: + pendingState->hints |= Qt::ImhUppercaseOnly | Qt::ImhLowercaseOnly; + break; + case content_purpose_digits: + pendingState->hints |= Qt::ImhDigitsOnly; + break; + case content_purpose_number: + pendingState->hints |= Qt::ImhFormattedNumbersOnly; + break; + case content_purpose_phone: + pendingState->hints |= Qt::ImhDialableCharactersOnly; + break; + case content_purpose_url: + pendingState->hints |= Qt::ImhUrlCharactersOnly; + break; + case content_purpose_email: + pendingState->hints |= Qt::ImhEmailCharactersOnly; + break; + case content_purpose_name: + case content_purpose_password: + break; + case content_purpose_date: + pendingState->hints |= Qt::ImhDate; + break; + case content_purpose_time: + pendingState->hints |= Qt::ImhTime; + break; + case content_purpose_datetime: + pendingState->hints |= Qt::ImhDate | Qt::ImhTime; + break; + case content_purpose_terminal: + default: + break; + } + + qCDebug(qLcWaylandCompositorTextInput) << Q_FUNC_INFO << pendingState->hints; + + pendingState->changedState |= Qt::ImHints; +} + +void QWaylandTextInputV3Private::zwp_text_input_v3_set_surrounding_text(Resource *resource, const QString &text, int32_t cursor, int32_t anchor) +{ + qCDebug(qLcWaylandCompositorTextInput) << Q_FUNC_INFO << text << cursor << anchor; + + if (resource != focusResource) + return; + + pendingState->surroundingText = text; + pendingState->cursorPosition = QWaylandInputMethodEventBuilder::indexFromWayland(text, cursor); + pendingState->anchorPosition = QWaylandInputMethodEventBuilder::indexFromWayland(text, anchor); + + pendingState->changedState |= Qt::ImSurroundingText | Qt::ImCursorPosition | Qt::ImAnchorPosition; +} + +void QWaylandTextInputV3Private::zwp_text_input_v3_set_text_change_cause(Resource *resource, uint32_t cause) +{ + qCDebug(qLcWaylandCompositorTextInput) << Q_FUNC_INFO; + + Q_UNUSED(resource); + Q_UNUSED(cause); +} + +QWaylandTextInputV3::QWaylandTextInputV3(QWaylandObject *container, QWaylandCompositor *compositor) + : QWaylandCompositorExtensionTemplate(container, *new QWaylandTextInputV3Private(compositor)) +{ + connect(&d_func()->focusDestroyListener, &QWaylandDestroyListener::fired, + this, &QWaylandTextInputV3::focusSurfaceDestroyed); +} + +QWaylandTextInputV3::~QWaylandTextInputV3() +{ +} + +void QWaylandTextInputV3::sendInputMethodEvent(QInputMethodEvent *event) +{ + Q_D(QWaylandTextInputV3); + + d->sendInputMethodEvent(event); +} + +void QWaylandTextInputV3::sendKeyEvent(QKeyEvent *event) +{ + Q_D(QWaylandTextInputV3); + + d->sendKeyEvent(event); +} + +QVariant QWaylandTextInputV3::inputMethodQuery(Qt::InputMethodQuery property, QVariant argument) const +{ + const Q_D(QWaylandTextInputV3); + + return d->inputMethodQuery(property, argument); +} + +QWaylandSurface *QWaylandTextInputV3::focus() const +{ + const Q_D(QWaylandTextInputV3); + + return d->focus; +} + +void QWaylandTextInputV3::setFocus(QWaylandSurface *surface) +{ + Q_D(QWaylandTextInputV3); + + d->setFocus(surface); +} + +void QWaylandTextInputV3::focusSurfaceDestroyed(void *) +{ + qCDebug(qLcWaylandCompositorTextInput) << Q_FUNC_INFO; + + Q_D(QWaylandTextInputV3); + + d->focusDestroyListener.reset(); + + d->focus = nullptr; + d->focusResource = nullptr; +} + +bool QWaylandTextInputV3::isSurfaceEnabled(QWaylandSurface *surface) const +{ + qCDebug(qLcWaylandCompositorTextInput) << Q_FUNC_INFO; + + const Q_D(QWaylandTextInputV3); + + return d->enabledSurfaces.values().contains(surface); +} + +void QWaylandTextInputV3::add(::wl_client *client, uint32_t id, int version) +{ + qCDebug(qLcWaylandCompositorTextInput) << Q_FUNC_INFO << client << id << version; + + Q_D(QWaylandTextInputV3); + + d->add(client, id, version); +} + +const wl_interface *QWaylandTextInputV3::interface() +{ + return QWaylandTextInputV3Private::interface(); +} + +QByteArray QWaylandTextInputV3::interfaceName() +{ + return QWaylandTextInputV3Private::interfaceName(); +} + +QT_END_NAMESPACE diff --git a/src/compositor/extensions/qwaylandtextinputv3.h b/src/compositor/extensions/qwaylandtextinputv3.h new file mode 100644 index 000000000..869238631 --- /dev/null +++ b/src/compositor/extensions/qwaylandtextinputv3.h @@ -0,0 +1,52 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#ifndef QWAYLANDTEXTINPUTV3_H +#define QWAYLANDTEXTINPUTV3_H + +#include <QtWaylandCompositor/QWaylandCompositorExtension> + +struct wl_client; + +QT_BEGIN_NAMESPACE + +class QWaylandTextInputV3Private; + +class QInputMethodEvent; +class QKeyEvent; +class QWaylandSurface; + +class QWaylandTextInputV3 : public QWaylandCompositorExtensionTemplate<QWaylandTextInputV3> +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QWaylandTextInputV3) +public: + explicit QWaylandTextInputV3(QWaylandObject *container, QWaylandCompositor *compositor); + ~QWaylandTextInputV3() override; + + void sendInputMethodEvent(QInputMethodEvent *event); + void sendKeyEvent(QKeyEvent *event); + + QVariant inputMethodQuery(Qt::InputMethodQuery property, QVariant argument) const; + + QWaylandSurface *focus() const; + void setFocus(QWaylandSurface *surface); + + bool isSurfaceEnabled(QWaylandSurface *surface) const; + + void add(::wl_client *client, uint32_t id, int version); + static const struct wl_interface *interface(); + static QByteArray interfaceName(); + +Q_SIGNALS: + void updateInputMethod(Qt::InputMethodQueries queries); + void surfaceEnabled(QWaylandSurface *surface); + void surfaceDisabled(QWaylandSurface *surface); + +private: + void focusSurfaceDestroyed(void *); +}; + +QT_END_NAMESPACE + +#endif // QWAYLANDTEXTINPUTV3_H diff --git a/src/compositor/extensions/qwaylandtextinputv3_p.h b/src/compositor/extensions/qwaylandtextinputv3_p.h new file mode 100644 index 000000000..267d14125 --- /dev/null +++ b/src/compositor/extensions/qwaylandtextinputv3_p.h @@ -0,0 +1,95 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#ifndef QWAYLANDTEXTINPUTV3_P_H +#define QWAYLANDTEXTINPUTV3_P_H + +#include <QtWaylandCompositor/private/qwaylandcompositorextension_p.h> +#include <QtWaylandCompositor/private/qwayland-server-text-input-unstable-v3.h> +#include <QtWaylandCompositor/QWaylandDestroyListener> + +#include <QtCore/QObject> +#include <QtCore/QRect> +#include <QtGui/QInputMethod> +#include <QtWaylandCompositor/QWaylandSurface> + +// +// 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 QInputMethodEvent; +class QKeyEvent; +class QWaylandCompositor; +class QWaylandView; + +class QWaylandTextInputV3ClientState { +public: + QWaylandTextInputV3ClientState(); + + Qt::InputMethodQueries updatedQueries(const QWaylandTextInputV3ClientState &other) const; + Qt::InputMethodQueries mergeChanged(const QWaylandTextInputV3ClientState &other); + + Qt::InputMethodHints hints = Qt::ImhNone; + QRect cursorRectangle; + QString surroundingText; + int cursorPosition = 0; + int anchorPosition = 0; + + Qt::InputMethodQueries changedState; +}; + +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandTextInputV3Private : public QWaylandCompositorExtensionPrivate, public QtWaylandServer::zwp_text_input_v3 +{ + Q_DECLARE_PUBLIC(QWaylandTextInputV3) +public: + explicit QWaylandTextInputV3Private(QWaylandCompositor *compositor); + + void sendInputMethodEvent(QInputMethodEvent *event); + void sendKeyEvent(QKeyEvent *event); + + QVariant inputMethodQuery(Qt::InputMethodQuery property, QVariant argument) const; + + void setFocus(QWaylandSurface *surface); + + QWaylandCompositor *compositor = nullptr; + + QWaylandSurface *focus = nullptr; + Resource *focusResource = nullptr; + QWaylandDestroyListener focusDestroyListener; + + bool inputPanelVisible = false; + + QString currentPreeditString; + + QScopedPointer<QWaylandTextInputV3ClientState> currentState; + QScopedPointer<QWaylandTextInputV3ClientState> pendingState; + + QHash<Resource *, uint32_t> serials; + QHash<Resource *, QWaylandSurface *> enabledSurfaces; + +protected: + void zwp_text_input_v3_bind_resource(Resource *resource) override; + void zwp_text_input_v3_destroy_resource(Resource *resource) override; + + void zwp_text_input_v3_destroy(Resource *resource) override; + void zwp_text_input_v3_enable(Resource *resource) override; + void zwp_text_input_v3_disable(Resource *resource) override; + void zwp_text_input_v3_set_surrounding_text(Resource *resource, const QString &text, int32_t cursor, int32_t anchor) override; + void zwp_text_input_v3_set_text_change_cause(Resource *resource, uint32_t cause) override; + void zwp_text_input_v3_set_content_type(Resource *resource, uint32_t hint, uint32_t purpose) override; + void zwp_text_input_v3_set_cursor_rectangle(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) override; + void zwp_text_input_v3_commit(Resource *resource) override; +}; + +QT_END_NAMESPACE + +#endif // QWAYLANDTEXTINPUTV3_P_H diff --git a/src/compositor/extensions/qwaylandviewporter.cpp b/src/compositor/extensions/qwaylandviewporter.cpp index 3856c135d..c44bcca15 100644 --- a/src/compositor/extensions/qwaylandviewporter.cpp +++ b/src/compositor/extensions/qwaylandviewporter.cpp @@ -1,38 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** 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$ -** -****************************************************************************/ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwaylandviewporter_p.h" @@ -156,14 +123,16 @@ void QWaylandViewporterPrivate::Viewport::checkCommittedState() return; } - QRectF max = QRectF(QPointF(), m_surface->bufferSize() / m_surface->bufferScale()); - // We can't use QRectF.contains, because that would return false for values on the border - if (max.united(source) != max) { - wl_resource_post_error(resource()->handle, error_out_of_buffer, - "source %f,%f, %fx%f extends outside attached buffer %fx%f", - source.x(), source.y(), source.width(), source.height(), - max.width(), max.height()); - return; + if (m_surface->bufferSize().isValid()) { + QRectF max = QRectF(QPointF(), m_surface->bufferSize() / m_surface->bufferScale()); + // We can't use QRectF.contains, because that would return false for values on the border + if (max.united(source) != max) { + wl_resource_post_error(resource()->handle, error_out_of_buffer, + "source %f,%f, %fx%f extends outside attached buffer %fx%f", + source.x(), source.y(), source.width(), source.height(), + max.width(), max.height()); + return; + } } } @@ -241,3 +210,5 @@ void QWaylandViewporterPrivate::Viewport::wp_viewport_set_destination(QtWaylandS } QT_END_NAMESPACE + +#include "moc_qwaylandviewporter.cpp" diff --git a/src/compositor/extensions/qwaylandviewporter.h b/src/compositor/extensions/qwaylandviewporter.h index 811c74145..0c87a936d 100644 --- a/src/compositor/extensions/qwaylandviewporter.h +++ b/src/compositor/extensions/qwaylandviewporter.h @@ -1,38 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** 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$ -** -****************************************************************************/ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDVIEWPORTER_H #define QWAYLANDVIEWPORTER_H @@ -43,7 +10,7 @@ QT_BEGIN_NAMESPACE class QWaylandViewporterPrivate; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandViewporter +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandViewporter : public QWaylandCompositorExtensionTemplate<QWaylandViewporter> { Q_OBJECT diff --git a/src/compositor/extensions/qwaylandviewporter_p.h b/src/compositor/extensions/qwaylandviewporter_p.h index d22da6990..84e0c90fc 100644 --- a/src/compositor/extensions/qwaylandviewporter_p.h +++ b/src/compositor/extensions/qwaylandviewporter_p.h @@ -1,38 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** 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$ -** -****************************************************************************/ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDVIEWPORTER_P_H #define QWAYLANDVIEWPORTER_P_H @@ -42,6 +9,8 @@ #include <QtWaylandCompositor/private/qwaylandcompositorextension_p.h> #include <QtWaylandCompositor/private/qwayland-server-viewporter.h> +#include <QtCore/qpointer.h> + // // W A R N I N G // ------------- @@ -57,7 +26,7 @@ QT_BEGIN_NAMESPACE class QWaylandSurface; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandViewporterPrivate +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandViewporterPrivate : public QWaylandCompositorExtensionPrivate , public QtWaylandServer::wp_viewporter { @@ -65,7 +34,7 @@ class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandViewporterPrivate public: explicit QWaylandViewporterPrivate() = default; - class Q_WAYLAND_COMPOSITOR_EXPORT Viewport + class Q_WAYLANDCOMPOSITOR_EXPORT Viewport : public QtWaylandServer::wp_viewport { public: diff --git a/src/compositor/extensions/qwaylandwlscaler.cpp b/src/compositor/extensions/qwaylandwlscaler.cpp deleted file mode 100644 index 5c8e4b270..000000000 --- a/src/compositor/extensions/qwaylandwlscaler.cpp +++ /dev/null @@ -1,274 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** 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 "qwaylandwlscaler_p.h" - -#include <QtWaylandCompositor/QWaylandSurface> -#include <QtWaylandCompositor/QWaylandCompositor> - -#include <QtWaylandCompositor/private/qwaylandsurface_p.h> - -QT_BEGIN_NAMESPACE - -#if QT_DEPRECATED_SINCE(5, 13) -/*! - \qmltype WlScaler - \inqmlmodule QtWayland.Compositor - \since 5.13 - \brief Provides an extension for surface resizing and cropping. - - The WlScaler extension provides a way for clients to resize and crop surface contents. - - WlScaler corresponds to the Wayland interface, \c wl_scaler. - - \c wl_scaler is a non-standard and deprecated protocol that has largely been replaced by - \c wp_viewporter. I.e. This extensions is only useful for supporting legacy clients. - \c wp_viewporter support is enabled automatically for all Qml compositors. - - To provide the functionality of the extension in a compositor, create an instance of the - WlScaler component and add it to the list of extensions supported by the compositor: - - \qml \QtMinorVersion - import QtWayland.Compositor 1.\1 - - WaylandCompositor { - // ... - WlScaler {} - } - \endqml - - \deprecated -*/ - -/*! - \class QWaylandWlScaler - \inmodule QtWaylandCompositor - \since 5.13 - \brief Provides an extension for surface resizing and croping. - - The QWaylandWlScaler extension provides a way for clients to resize and crop surface - contents. - - QWaylandWlScaler corresponds to the Wayland interface, \c wl_scaler. - - \c wl_scaler is a non-standard and deprecated protocol that has largely been replaced by - \c wp_viewporter. I.e. This extensions is only useful for supporting legacy clients. - - \sa QWaylandViewporter - - \deprecated -*/ - -/*! - Constructs a QWaylandWlScaler object. -*/ -QWaylandWlScaler::QWaylandWlScaler() - : QWaylandCompositorExtensionTemplate<QWaylandWlScaler>(*new QWaylandWlScalerPrivate) -{ -} - -/*! - * Constructs a QWaylandWlScaler object for the provided \a compositor. - */ -QWaylandWlScaler::QWaylandWlScaler(QWaylandCompositor *compositor) - : QWaylandCompositorExtensionTemplate<QWaylandWlScaler>(compositor, *new QWaylandWlScalerPrivate()) -{ -} - -/*! - Initializes the extension. -*/ -void QWaylandWlScaler::initialize() -{ - Q_D(QWaylandWlScaler); - - QWaylandCompositorExtensionTemplate::initialize(); - auto *compositor = static_cast<QWaylandCompositor *>(extensionContainer()); - if (!compositor) { - qWarning() << "Failed to find QWaylandCompositor when initializing QWaylandWlScaler"; - return; - } - d->init(compositor->display(), 2); -} - -/*! - Returns the Wayland interface for the QWaylandWlScaler. -*/ -const wl_interface *QWaylandWlScaler::interface() -{ - return QWaylandWlScalerPrivate::interface(); -} - -void QWaylandWlScalerPrivate::scaler_destroy(Resource *resource) -{ - // Viewport objects are allowed ot outlive the scaler - wl_resource_destroy(resource->handle); -} - -void QWaylandWlScalerPrivate::scaler_get_viewport(Resource *resource, uint id, wl_resource *surfaceResource) -{ - auto *surface = QWaylandSurface::fromResource(surfaceResource); - if (!surface) { - qWarning() << "Couldn't find surface for viewporter"; - return; - } - - // Note: This will only protect us not creating scalers for surfaces with wp_viewport objects - auto *surfacePrivate = QWaylandSurfacePrivate::get(surface); - if (surfacePrivate->viewport) { - wl_resource_post_error(resource->handle, WL_SCALER_ERROR_VIEWPORT_EXISTS, - "viewport already exists for surface"); - return; - } - - // We can't set viewport here, since it's of the new type for wp_viewporter -// surfacePrivate->viewport = new Viewport(surface, resource->client(), id, resource->version()); - new Viewport(surface, resource->client(), id, resource->version()); -} - -QWaylandWlScalerPrivate::Viewport::Viewport(QWaylandSurface *surface, wl_client *client, int id, int version) - : QtWaylandServer::wl_viewport(client, id, version) - , m_surface(surface) -{ - Q_ASSERT(surface); -} - -//TODO: This isn't currently called -// This function has to be called immediately after a surface is committed, before no -// other client events have been dispatched, or we may incorrectly error out on an -// incomplete pending state. See comment below. -void QWaylandWlScalerPrivate::Viewport::checkCommittedState() -{ - auto *surfacePrivate = QWaylandSurfacePrivate::get(m_surface); - - // We can't use the current state for destination/source when checking, - // as that has fallbacks to the buffer size so we can't distinguish - // between the set/unset case. We use the pending state because no other - // requests has modified it yet. - QSize destination = surfacePrivate->pending.destinationSize; - QRectF source = surfacePrivate->pending.sourceGeometry; - - if (!destination.isValid() && source.size() != source.size().toSize()) { - //TODO: Do rounding to nearest integer - } - - QRectF max = QRectF(QPointF(), m_surface->bufferSize() / m_surface->bufferScale()); - // We can't use QRectF.contains, because that would return false for values on the border - if (max.united(source) != max) { - //TODO: surface contents are no undefined, surface size is still valid though - qCDebug(qLcWaylandCompositor) << "Source set outside buffer bounds (client error)"; - } -} - - -void QWaylandWlScalerPrivate::Viewport::viewport_destroy_resource(Resource *resource) -{ - Q_UNUSED(resource); - delete this; -} - -void QWaylandWlScalerPrivate::Viewport::viewport_destroy(Resource *resource) -{ - if (m_surface) { - auto *surfacePrivate = QWaylandSurfacePrivate::get(m_surface); - surfacePrivate->pending.destinationSize = QSize(); - surfacePrivate->pending.sourceGeometry = QRectF(); - } - wl_resource_destroy(resource->handle); -} - -void QWaylandWlScalerPrivate::Viewport::viewport_set(QtWaylandServer::wl_viewport::Resource *resource, wl_fixed_t src_x, wl_fixed_t src_y, wl_fixed_t src_width, wl_fixed_t src_height, int32_t dst_width, int32_t dst_height) -{ - viewport_set_source(resource, src_x, src_y, src_width, src_height); - viewport_set_destination(resource, dst_width, dst_height); -} - -void QWaylandWlScalerPrivate::Viewport::viewport_set_source(QtWaylandServer::wl_viewport::Resource *resource, wl_fixed_t x, wl_fixed_t y, wl_fixed_t width, wl_fixed_t height) -{ - Q_UNUSED(resource); - - if (!m_surface) { - qCDebug(qLcWaylandCompositor) << "set_source requested for destroyed surface"; - return; - } - - QPointF position(wl_fixed_to_double(x), wl_fixed_to_double(y)); - QSizeF size(wl_fixed_to_double(width), wl_fixed_to_double(height)); - QRectF sourceGeometry(position, size); - - if (sourceGeometry == QRectF(-1, -1, -1, -1)) { - auto *surfacePrivate = QWaylandSurfacePrivate::get(m_surface); - surfacePrivate->pending.sourceGeometry = QRectF(); - return; - } - - if (position.x() < 0 || position.y() < 0) { - wl_resource_post_error(resource->handle, error_bad_value, - "negative position in set_source"); - return; - } - - if (!size.isValid()) { - wl_resource_post_error(resource->handle, error_bad_value, - "negative size in set_source"); - return; - } - - auto *surfacePrivate = QWaylandSurfacePrivate::get(m_surface); - surfacePrivate->pending.sourceGeometry = sourceGeometry; -} - -void QWaylandWlScalerPrivate::Viewport::viewport_set_destination(QtWaylandServer::wl_viewport::Resource *resource, int32_t width, int32_t height) -{ - Q_UNUSED(resource); - - if (!m_surface) { - qCDebug(qLcWaylandCompositor) << "set_destination requested for destroyed surface"; - return; - } - - QSize destinationSize(width, height); - if (!destinationSize.isValid() && destinationSize != QSize(-1, -1)) { - wl_resource_post_error(resource->handle, error_bad_value, - "negative size in set_destination"); - return; - } - auto *surfacePrivate = QWaylandSurfacePrivate::get(m_surface); - surfacePrivate->pending.destinationSize = destinationSize; -} -#endif // QT_DEPRECATED_SINCE - -QT_END_NAMESPACE diff --git a/src/compositor/extensions/qwaylandwlscaler.h b/src/compositor/extensions/qwaylandwlscaler.h deleted file mode 100644 index 4ecdf3968..000000000 --- a/src/compositor/extensions/qwaylandwlscaler.h +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** 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 QWAYLANDWLSCALER_H -#define QWAYLANDWLSCALER_H - -#include <QtWaylandCompositor/QWaylandCompositorExtension> - -QT_BEGIN_NAMESPACE - -#if QT_DEPRECATED_SINCE(5, 13) -class QWaylandWlScalerPrivate; - -// TODO: We should have used the QT_DEPRECATED macro here, but for some reason -// header file generation stops working when that's added. -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandWlScaler - : public QWaylandCompositorExtensionTemplate<QWaylandWlScaler> -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QWaylandWlScaler) - -public: - explicit QWaylandWlScaler(); - explicit QWaylandWlScaler(QWaylandCompositor *compositor); - - void initialize() override; - - static const struct wl_interface *interface(); -}; -#endif - -QT_END_NAMESPACE - -#endif // QWAYLANDWLSCALER_H diff --git a/src/compositor/extensions/qwaylandwlscaler_p.h b/src/compositor/extensions/qwaylandwlscaler_p.h deleted file mode 100644 index 10a66f884..000000000 --- a/src/compositor/extensions/qwaylandwlscaler_p.h +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** 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 QWAYLANDWLSCALER_P_H -#define QWAYLANDWLSCALER_P_H - -#include "qwaylandwlscaler.h" - -#include <QtWaylandCompositor/private/qwaylandcompositorextension_p.h> -#include <QtWaylandCompositor/private/qwayland-server-scaler.h> - -// -// 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 - -#if QT_DEPRECATED_SINCE(5, 13) -class QWaylandSurface; - -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandWlScalerPrivate - : public QWaylandCompositorExtensionPrivate - , public QtWaylandServer::wl_scaler -{ - Q_DECLARE_PUBLIC(QWaylandWlScaler) -public: - explicit QWaylandWlScalerPrivate() = default; - -protected: - void scaler_destroy(Resource *resource) override; - void scaler_get_viewport(Resource *resource, uint32_t id, wl_resource *surface) override; - -private: - class Viewport : public QtWaylandServer::wl_viewport - { - public: - explicit Viewport(QWaylandSurface *surface, wl_client *client, int id, int version); - void checkCommittedState(); - - protected: - void viewport_destroy_resource(Resource *resource) override; - void viewport_destroy(Resource *resource) override; - void viewport_set(Resource *resource, wl_fixed_t src_x, wl_fixed_t src_y, wl_fixed_t src_width, wl_fixed_t src_height, int32_t dst_width, int32_t dst_height) override; - void viewport_set_source(Resource *resource, wl_fixed_t x, wl_fixed_t y, wl_fixed_t width, wl_fixed_t height) override; - void viewport_set_destination(Resource *resource, int32_t width, int32_t height) override; - - private: - QPointer<QWaylandSurface> m_surface = nullptr; - }; -}; -#endif - -QT_END_NAMESPACE - -#endif // QWAYLANDWLSCALER_P_H diff --git a/src/compositor/extensions/qwaylandwlshell.cpp b/src/compositor/extensions/qwaylandwlshell.cpp index 6eb1c06e4..c0e6119e1 100644 --- a/src/compositor/extensions/qwaylandwlshell.cpp +++ b/src/compositor/extensions/qwaylandwlshell.cpp @@ -1,32 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwaylandwlshell.h" #include "qwaylandwlshell_p.h" @@ -244,7 +218,8 @@ void QWaylandWlShellSurfacePrivate::shell_surface_set_class(Resource *resource, /*! * \qmltype WlShell - * \inqmlmodule QtWayland.Compositor + * \instantiates QWaylandWlShell + * \inqmlmodule QtWayland.Compositor.WlShell * \since 5.8 * \brief Provides an extension for desktop-style user interfaces. * @@ -258,8 +233,8 @@ void QWaylandWlShellSurfacePrivate::shell_surface_set_class(Resource *resource, * an instance of the WlShell component and add it to the list of extensions * supported by the compositor: * - * \qml \QtMinorVersion - * import QtWayland.Compositor 1.\1 + * \qml + * import QtWayland.Compositor.WlShell * * WaylandCompositor { * WlShell { @@ -370,7 +345,7 @@ const struct wl_interface *QWaylandWlShell::interface() } /*! - * \qmlsignal void QtWaylandCompositor::WlShell::wlShellSurfaceRequested(WaylandSurface surface, WaylandResource resource) + * \qmlsignal void WlShell::wlShellSurfaceRequested(WaylandSurface surface, WaylandResource resource) * * This signal is emitted when the client has requested a \c wl_shell_surface to be associated with * \a surface. The handler for this signal may create a shell surface for \a resource and initialize @@ -388,7 +363,7 @@ const struct wl_interface *QWaylandWlShell::interface() */ /*! - * \qmlsignal void QtWaylandCompositor::WlShell::wlShellSurfaceCreated(WlShellSurface shellSurface) + * \qmlsignal void WlShell::wlShellSurfaceCreated(WlShellSurface shellSurface) * * This signal is emitted when the client has created a \c wl_shell_surface. * A common use case is to let the handler of this signal instantiate a ShellSurfaceItem or @@ -413,7 +388,8 @@ QByteArray QWaylandWlShell::interfaceName() /*! * \qmltype WlShellSurface - * \inqmlmodule QtWayland.Compositor + * \instantiates QWaylandWlShellSurface + * \inqmlmodule QtWayland.Compositor.WlShell * \since 5.8 * \brief Provides a \c wl_shell_surface that offers desktop-style compositor-specific features to a surface. * @@ -462,7 +438,7 @@ QWaylandWlShellSurface::~QWaylandWlShellSurface() } /*! - * \qmlmethod void QtWaylandCompositor::WlShellSurface::initialize(WlShell shell, WaylandSurface surface, WaylandResource resource) + * \qmlmethod void WlShellSurface::initialize(WlShell shell, WaylandSurface surface, WaylandResource resource) * * Initializes the WlShellSurface and associates it with the given \a shell, \a surface, and \a resource. */ @@ -562,7 +538,7 @@ void QWaylandWlShellSurface::sendConfigure(const QSize &size, ResizeEdge edges) } /*! - * \qmlmethod void QtWaylandCompositor::WlShellSurface::sendPopupDone() + * \qmlmethod void WlShellSurface::sendPopupDone() * * Sends a popup_done event to the client to indicate that the user has clicked * somewhere outside the client's surfaces. @@ -586,7 +562,7 @@ QWaylandQuickShellIntegration *QWaylandWlShellSurface::createIntegration(QWaylan #endif /*! - * \qmlproperty WaylandSurface QtWaylandCompositor::WlShellSurface::surface + * \qmlproperty WaylandSurface WlShellSurface::surface * * This property holds the \c wl_surface associated with this WlShellSurface. */ @@ -603,7 +579,7 @@ QWaylandSurface *QWaylandWlShellSurface::surface() const } /*! - * \qmlproperty WlShell QtWaylandCompositor::WlShellSurface::shell + * \qmlproperty WlShell WlShellSurface::shell * * This property holds the shell associated with this WlShellSurface. */ @@ -620,7 +596,7 @@ QWaylandWlShell *QWaylandWlShellSurface::shell() const } /*! - * \qmlproperty enum QtWaylandCompositor::WlShellSurface::windowType + * \qmlproperty enum WlShellSurface::windowType * * This property holds the window type of the WlShellSurface. */ @@ -632,7 +608,7 @@ Qt::WindowType QWaylandWlShellSurface::windowType() const } /*! - * \qmlproperty string QtWaylandCompositor::WlShellSurface::title + * \qmlproperty string WlShellSurface::title * * This property holds the title of the WlShellSurface. */ @@ -649,7 +625,7 @@ QString QWaylandWlShellSurface::title() const } /*! - * \qmlproperty string QtWaylandCompositor::WlShellSurface::className + * \qmlproperty string WlShellSurface::className * * This property holds the class name of the WlShellSurface. */ @@ -671,7 +647,7 @@ QWaylandSurfaceRole *QWaylandWlShellSurface::role() } /*! - * \qmlmethod void QtWaylandCompositor::WlShellSurface::ping() + * \qmlmethod void WlShellSurface::ping() * * Sends a ping event to the client. If the client replies to the event the pong * signal will be emitted. @@ -699,3 +675,5 @@ QWaylandWlShellSurface *QWaylandWlShellSurface::fromResource(wl_resource *resour } QT_END_NAMESPACE + +#include "moc_qwaylandwlshell.cpp" diff --git a/src/compositor/extensions/qwaylandwlshell.h b/src/compositor/extensions/qwaylandwlshell.h index 117d24a23..250c78447 100644 --- a/src/compositor/extensions/qwaylandwlshell.h +++ b/src/compositor/extensions/qwaylandwlshell.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDWLSHELL_H #define QWAYLANDWLSHELL_H @@ -34,7 +8,9 @@ #include <QtWaylandCompositor/QWaylandResource> #include <QtWaylandCompositor/QWaylandShell> #include <QtWaylandCompositor/QWaylandShellSurface> +#if QT_CONFIG(wayland_compositor_quick) #include <QtWaylandCompositor/qwaylandquickchildren.h> +#endif #include <QtCore/QSize> @@ -49,7 +25,7 @@ class QWaylandOutput; class QWaylandSurfaceRole; class QWaylandWlShellSurface; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandWlShell : public QWaylandShellTemplate<QWaylandWlShell> +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandWlShell : public QWaylandShellTemplate<QWaylandWlShell> { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandWlShell) @@ -74,15 +50,18 @@ Q_SIGNALS: void wlShellSurfaceCreated(QWaylandWlShellSurface *shellSurface); }; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandWlShellSurface : public QWaylandShellSurfaceTemplate<QWaylandWlShellSurface> +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandWlShellSurface : public QWaylandShellSurfaceTemplate<QWaylandWlShellSurface> { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandWlShellSurface) +#if QT_CONFIG(wayland_compositor_quick) Q_WAYLAND_COMPOSITOR_DECLARE_QUICK_CHILDREN(QWaylandWlShellSurface) +#endif Q_PROPERTY(QWaylandSurface *surface READ surface NOTIFY surfaceChanged) 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_MOC_INCLUDE("qwaylandsurface.h") public: enum FullScreenMethod { diff --git a/src/compositor/extensions/qwaylandwlshell_p.h b/src/compositor/extensions/qwaylandwlshell_p.h index 3782f5164..4202a8aed 100644 --- a/src/compositor/extensions/qwaylandwlshell_p.h +++ b/src/compositor/extensions/qwaylandwlshell_p.h @@ -1,38 +1,12 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDWLSHELL_P_H #define QWAYLANDWLSHELL_P_H #include <QtWaylandCompositor/qtwaylandcompositorglobal.h> #include <QtWaylandCompositor/qwaylandsurface.h> -#include <QtWaylandCompositor/private/qwaylandcompositorextension_p.h> +#include <QtWaylandCompositor/private/qwaylandshellsurface_p.h> #include <QtWaylandCompositor/private/qwaylandshell_p.h> #include <QtWaylandCompositor/QWaylandWlShellSurface> #include <QtWaylandCompositor/QWaylandSeat> @@ -44,6 +18,8 @@ #include <QtWaylandCompositor/private/qwayland-server-wayland.h> +#include <QtCore/qpointer.h> + // // W A R N I N G // ------------- @@ -57,7 +33,7 @@ QT_BEGIN_NAMESPACE -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandWlShellPrivate +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandWlShellPrivate : public QWaylandShellPrivate , public QtWaylandServer::wl_shell { @@ -75,8 +51,8 @@ protected: QList<QWaylandWlShellSurface *> m_shellSurfaces; }; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandWlShellSurfacePrivate - : public QWaylandCompositorExtensionPrivate +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandWlShellSurfacePrivate + : public QWaylandShellSurfacePrivate , public QtWaylandServer::wl_shell_surface { Q_DECLARE_PUBLIC(QWaylandWlShellSurface) diff --git a/src/compositor/extensions/qwaylandwlshellintegration.cpp b/src/compositor/extensions/qwaylandwlshellintegration.cpp index 3853d7eec..b625d164f 100644 --- a/src/compositor/extensions/qwaylandwlshellintegration.cpp +++ b/src/compositor/extensions/qwaylandwlshellintegration.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwaylandwlshellintegration_p.h" @@ -98,8 +72,8 @@ void WlShellIntegration::handleSetDefaultTopLevel() void WlShellIntegration::handleSetTransient(QWaylandSurface *parentSurface, const QPoint &relativeToParent, bool inactive) { - Q_UNUSED(parentSurface) - Q_UNUSED(relativeToParent) + 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) @@ -296,25 +270,25 @@ bool WlShellIntegration::filterMouseMoveEvent(QMouseEvent *event) if (grabberState == GrabberState::Resize) { Q_ASSERT(resizeState.seat == m_item->compositor()->seatFor(event)); if (!resizeState.initialized) { - resizeState.initialMousePos = event->windowPos(); + resizeState.initialMousePos = event->scenePosition(); resizeState.initialized = true; return true; } float scaleFactor = m_item->view()->output()->scaleFactor(); - QPointF delta = (event->windowPos() - resizeState.initialMousePos) / scaleFactor * devicePixelRatio(); + QPointF delta = (event->scenePosition() - resizeState.initialMousePos) / scaleFactor * devicePixelRatio(); QSize newSize = m_shellSurface->sizeForResize(resizeState.initialSize, delta, resizeState.resizeEdges); m_shellSurface->sendConfigure(newSize, resizeState.resizeEdges); } else if (grabberState == GrabberState::Move) { Q_ASSERT(moveState.seat == m_item->compositor()->seatFor(event)); QQuickItem *moveItem = m_item->moveItem(); if (!moveState.initialized) { - moveState.initialOffset = moveItem->mapFromItem(nullptr, event->windowPos()); + moveState.initialOffset = moveItem->mapFromItem(nullptr, event->scenePosition()); moveState.initialized = true; return true; } if (!moveItem->parentItem()) return true; - QPointF parentPos = moveItem->parentItem()->mapFromItem(nullptr, event->windowPos()); + QPointF parentPos = moveItem->parentItem()->mapFromItem(nullptr, event->scenePosition()); moveItem->setPosition(parentPos - moveState.initialOffset); } return false; @@ -333,3 +307,5 @@ bool WlShellIntegration::filterMouseReleaseEvent(QMouseEvent *event) } QT_END_NAMESPACE + +#include "moc_qwaylandwlshellintegration_p.cpp" diff --git a/src/compositor/extensions/qwaylandwlshellintegration_p.h b/src/compositor/extensions/qwaylandwlshellintegration_p.h index 8fd4a2b89..1818e7b8f 100644 --- a/src/compositor/extensions/qwaylandwlshellintegration_p.h +++ b/src/compositor/extensions/qwaylandwlshellintegration_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDWLSHELLINTEGRATION_H #define QWAYLANDWLSHELLINTEGRATION_H @@ -34,6 +8,8 @@ #include <QtWaylandCompositor/QWaylandWlShellSurface> +#include <QtCore/qpointer.h> + QT_BEGIN_NAMESPACE // diff --git a/src/compositor/extensions/qwaylandxdgdecorationv1.cpp b/src/compositor/extensions/qwaylandxdgdecorationv1.cpp index a58601cd4..c7af0bca5 100644 --- a/src/compositor/extensions/qwaylandxdgdecorationv1.cpp +++ b/src/compositor/extensions/qwaylandxdgdecorationv1.cpp @@ -1,38 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** 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$ -** -****************************************************************************/ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwaylandxdgdecorationv1_p.h" @@ -46,7 +13,8 @@ QT_BEGIN_NAMESPACE /*! \qmltype XdgDecorationManagerV1 - \inqmlmodule QtWayland.Compositor + \instantiates QWaylandXdgDecorationManagerV1 + \inqmlmodule QtWayland.Compositor.XdgShell \since 5.12 \brief Provides an extension for negotiation of server-side and client-side window decorations. @@ -59,8 +27,8 @@ QT_BEGIN_NAMESPACE To provide the functionality of the extension in a compositor, create an instance of the XdgDecorationManagerV1 component and add it to the list of extensions supported by the compositor: - \qml \QtMinorVersion - import QtWayland.Compositor 1.\1 + \qml + import QtWayland.Compositor WaylandCompositor { // Xdg decoration manager assumes xdg-shell is being used @@ -75,7 +43,7 @@ QT_BEGIN_NAMESPACE } \endqml - \sa QWaylandXdgToplevel::decorationMode + \sa QWaylandXdgToplevel::decorationMode, {Server Side Decoration Compositor} */ /*! @@ -118,7 +86,7 @@ void QWaylandXdgDecorationManagerV1::initialize() } /*! - \qmlproperty string QtWaylandCompositor::XdgDecorationManagerV1::preferredMode + \qmlproperty string XdgDecorationManagerV1::preferredMode This property holds the decoration mode the compositor prefers. @@ -258,3 +226,5 @@ void QWaylandXdgToplevelDecorationV1::handleClientPreferredModeChanged() } QT_END_NAMESPACE + +#include "moc_qwaylandxdgdecorationv1.cpp" diff --git a/src/compositor/extensions/qwaylandxdgdecorationv1.h b/src/compositor/extensions/qwaylandxdgdecorationv1.h index 4390716e8..263504cf1 100644 --- a/src/compositor/extensions/qwaylandxdgdecorationv1.h +++ b/src/compositor/extensions/qwaylandxdgdecorationv1.h @@ -1,38 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** 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$ -** -****************************************************************************/ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDXDGDECORATIONV1_H #define QWAYLANDXDGDECORATIONV1_H @@ -44,7 +11,7 @@ QT_BEGIN_NAMESPACE class QWaylandXdgDecorationManagerV1Private; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgDecorationManagerV1 : public QWaylandCompositorExtensionTemplate<QWaylandXdgDecorationManagerV1> +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandXdgDecorationManagerV1 : public QWaylandCompositorExtensionTemplate<QWaylandXdgDecorationManagerV1> { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandXdgDecorationManagerV1) diff --git a/src/compositor/extensions/qwaylandxdgdecorationv1_p.h b/src/compositor/extensions/qwaylandxdgdecorationv1_p.h index fdd555abb..8d06f6a57 100644 --- a/src/compositor/extensions/qwaylandxdgdecorationv1_p.h +++ b/src/compositor/extensions/qwaylandxdgdecorationv1_p.h @@ -1,38 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** 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$ -** -****************************************************************************/ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDXDGDECORATIONV1_P_H #define QWAYLANDXDGDECORATIONV1_P_H @@ -59,7 +26,7 @@ QT_BEGIN_NAMESPACE class QWaylandXdgToplevel; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgDecorationManagerV1Private +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandXdgDecorationManagerV1Private : public QWaylandCompositorExtensionPrivate , public QtWaylandServer::zxdg_decoration_manager_v1 { @@ -75,7 +42,7 @@ private: DecorationMode m_preferredMode = DecorationMode::ClientSideDecoration; }; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgToplevelDecorationV1 +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandXdgToplevelDecorationV1 : public QtWaylandServer::zxdg_toplevel_decoration_v1 { public: diff --git a/src/compositor/extensions/qwaylandxdgdialogv1.cpp b/src/compositor/extensions/qwaylandxdgdialogv1.cpp new file mode 100644 index 000000000..102bfb1dd --- /dev/null +++ b/src/compositor/extensions/qwaylandxdgdialogv1.cpp @@ -0,0 +1,64 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include "qwaylandcompositor.h" +#include "qwaylandxdgdialogv1_p.h" + +#include <QWaylandXdgToplevel> +#include <wayland-server.h> + +QT_BEGIN_NAMESPACE + +QWaylandXdgDialogV1Global::QWaylandXdgDialogV1Global(QWaylandCompositor *parent) + : QWaylandCompositorExtensionTemplate<QWaylandXdgDialogV1Global>(parent) +{ +} + +void QWaylandXdgDialogV1Global::initialize() +{ + QWaylandCompositorExtensionTemplate::initialize(); + QWaylandCompositor *compositor = static_cast<QWaylandCompositor *>(extensionContainer()); + if (compositor) + init(compositor->display(), 1); +} + +void QWaylandXdgDialogV1Global::xdg_wm_dialog_v1_get_xdg_dialog(Resource *resource, uint32_t id, wl_resource *toplevelResource) +{ + auto *toplevel = QWaylandXdgToplevel::fromResource(toplevelResource); + (void)new QWaylandXdgDialogV1(toplevel, resource->client(), id); +} + +QWaylandXdgDialogV1::QWaylandXdgDialogV1(QWaylandXdgToplevel *toplevel, wl_client *client, int id) + : QtWaylandServer::xdg_dialog_v1(client, id, 1), m_topLevel(toplevel) +{ +} + +void QWaylandXdgDialogV1::xdg_dialog_v1_set_modal(Resource *resource) +{ + Q_UNUSED(resource); + if (m_topLevel) + m_topLevel->setModal(true); + +} + +void QWaylandXdgDialogV1::xdg_dialog_v1_unset_modal(Resource *resource) +{ + Q_UNUSED(resource); + if (m_topLevel) + m_topLevel->setModal(false); +} + +void QWaylandXdgDialogV1::xdg_dialog_v1_destroy_resource(Resource *resource) +{ + Q_UNUSED(resource); + delete this; +} + +void QWaylandXdgDialogV1::xdg_dialog_v1_destroy(Resource *resource) +{ + if (m_topLevel) + m_topLevel->setModal(false); + wl_resource_destroy(resource->handle); +} + +QT_END_NAMESPACE diff --git a/src/compositor/extensions/qwaylandxdgdialogv1_p.h b/src/compositor/extensions/qwaylandxdgdialogv1_p.h new file mode 100644 index 000000000..b6353c72f --- /dev/null +++ b/src/compositor/extensions/qwaylandxdgdialogv1_p.h @@ -0,0 +1,57 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#ifndef QWAYLANDXDGDIALOGV1_P_H +#define QWAYLANDXDGDIALOGV1_P_H +#include "qwaylandxdgshell.h" +#include <QtWaylandCompositor/QWaylandCompositorExtensionTemplate> +#include <QtWaylandCompositor/private/qwaylandcompositorextension_p.h> +#include <QtWaylandCompositor/private/qwayland-server-xdg-dialog-v1.h> + +// +// 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_WAYLANDCOMPOSITOR_EXPORT QWaylandXdgDialogV1Global + : public QWaylandCompositorExtensionTemplate<QWaylandXdgDialogV1Global> + , public QtWaylandServer::xdg_wm_dialog_v1 +{ + Q_OBJECT +public: + QWaylandXdgDialogV1Global(QWaylandCompositor *parent = nullptr); + + void initialize() override; + +protected: + void xdg_wm_dialog_v1_get_xdg_dialog(Resource *resource, uint32_t id, wl_resource *toplevelResource) override; +}; + +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandXdgDialogV1 + : public QtWaylandServer::xdg_dialog_v1 +{ +public: + QWaylandXdgDialogV1(QWaylandXdgToplevel *toplevel, wl_client *client, int id); + +protected: + void xdg_dialog_v1_destroy_resource(Resource *resource) override; + void xdg_dialog_v1_destroy(Resource *resource) override; + + void xdg_dialog_v1_set_modal(Resource *resource) override; + void xdg_dialog_v1_unset_modal(Resource *resource) override; + +private: + QPointer<QWaylandXdgToplevel> m_topLevel; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/compositor/extensions/qwaylandxdgoutputv1.cpp b/src/compositor/extensions/qwaylandxdgoutputv1.cpp index 2ab26c162..035d8dd3d 100644 --- a/src/compositor/extensions/qwaylandxdgoutputv1.cpp +++ b/src/compositor/extensions/qwaylandxdgoutputv1.cpp @@ -1,38 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 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$ -** -****************************************************************************/ +// Copyright (C) 2019 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QWaylandCompositor> @@ -45,9 +12,10 @@ QT_BEGIN_NAMESPACE /*! * \qmltype XdgOutputManagerV1 - * \inqmlmodule QtWayland.Compositor + * \instantiates QWaylandXdgOutputManagerV1 + * \inqmlmodule QtWayland.Compositor.XdgShell * \since 5.14 - * \brief Provides an extension for describing outputs in a desktop oriented fashion + * \brief Provides an extension for describing outputs in a desktop oriented fashion. * * The XdgOutputManagerV1 extension provides a way for a compositor to describe outputs in a way * that is more in line with the concept of an output on desktop oriented systems. @@ -63,8 +31,8 @@ QT_BEGIN_NAMESPACE * XdgOutputManagerV1 component and add it to the list of extensions supported by the compositor, * and associated each XdgOutputV1 with its WaylandOutput: * - * \qml \QtMinorVersion - * import QtWayland.Compositor 1.\1 + * \qml + * import QtWayland.Compositor * * WaylandCompositor { * XdgOutputManagerV1 { @@ -104,7 +72,7 @@ QT_BEGIN_NAMESPACE * \class QWaylandXdgOutputManagerV1 * \inmodule QtWaylandCompositor * \since 5.14 - * \brief Provides an extension for describing outputs in a desktop oriented fashion + * \brief Provides an extension for describing outputs in a desktop oriented fashion. * * The QWaylandXdgOutputManagerV1 extension provides a way for a compositor to describe outputs in a way * that is more in line with the concept of an output on desktop oriented systems. @@ -238,7 +206,7 @@ QWaylandXdgOutputV1::~QWaylandXdgOutputV1() } /*! - * \qmlproperty XdgOutputManagerV1 QtWaylandCompositor::XdgOutputV1::manager + * \qmlproperty XdgOutputManagerV1 XdgOutputV1::manager * \readonly * * This property holds the object that manages this XdgOutputV1. @@ -256,7 +224,7 @@ QWaylandXdgOutputManagerV1 *QWaylandXdgOutputV1::manager() const } /*! - * \qmlproperty WaylandOutput QtWaylandCompositor::XdgOutputV1::output + * \qmlproperty WaylandOutput XdgOutputV1::output * \readonly * * This property holds the WaylandOutput associated with this XdgOutputV1. @@ -274,7 +242,7 @@ QWaylandOutput *QWaylandXdgOutputV1::output() const } /*! - * \qmlproperty string QtWaylandCompositor::XdgOutputV1::name + * \qmlproperty string XdgOutputV1::name * * This property holds the name of this output. * @@ -325,7 +293,7 @@ void QWaylandXdgOutputV1::setName(const QString &name) } /*! - * \qmlproperty string QtWaylandCompositor::XdgOutputV1::description + * \qmlproperty string XdgOutputV1::description * * This property holds the description of this output. * @@ -366,7 +334,7 @@ void QWaylandXdgOutputV1::setDescription(const QString &description) } /*! - * \qmlproperty point QtWaylandCompositor::XdgOutputV1::logicalPosition + * \qmlproperty point XdgOutputV1::logicalPosition * * This property holds the coordinates of the output within the global compositor space. * @@ -402,7 +370,7 @@ void QWaylandXdgOutputV1::setLogicalPosition(const QPoint &position) } /*! - * \qmlproperty size QtWaylandCompositor::XdgOutputV1::logicalSize + * \qmlproperty size XdgOutputV1::logicalSize * * This property holds the size of the output in the global compositor space. * @@ -454,7 +422,7 @@ void QWaylandXdgOutputV1::setLogicalSize(const QSize &size) } /*! - * \qmlproperty rect QtWaylandCompositor::XdgOutputV1::logicalGeometry + * \qmlproperty rect XdgOutputV1::logicalGeometry * \readonly * * This property holds the position and size of the output in the global compositor space. @@ -593,3 +561,5 @@ void QWaylandXdgOutputV1Private::zxdg_output_v1_destroy(Resource *resource) } QT_END_NAMESPACE + +#include "moc_qwaylandxdgoutputv1.cpp" diff --git a/src/compositor/extensions/qwaylandxdgoutputv1.h b/src/compositor/extensions/qwaylandxdgoutputv1.h index 957ac3bed..79a6235c7 100644 --- a/src/compositor/extensions/qwaylandxdgoutputv1.h +++ b/src/compositor/extensions/qwaylandxdgoutputv1.h @@ -1,45 +1,14 @@ -/**************************************************************************** -** -** Copyright (C) 2019 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$ -** -****************************************************************************/ +// Copyright (C) 2019 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDXDGOUTPUTV1_H #define QWAYLANDXDGOUTPUTV1_H -#include <QRect> +#include <QtCore/QRect> #include <QtWaylandCompositor/QWaylandCompositorExtension> +#if QT_CONFIG(wayland_compositor_quick) #include <QtWaylandCompositor/qwaylandquickchildren.h> +#endif QT_BEGIN_NAMESPACE @@ -48,7 +17,7 @@ class QWaylandOutput; class QWaylandXdgOutputManagerV1Private; class QWaylandXdgOutputV1Private; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgOutputManagerV1 +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandXdgOutputManagerV1 : public QWaylandCompositorExtensionTemplate<QWaylandXdgOutputManagerV1> { Q_OBJECT @@ -62,11 +31,14 @@ public: static const wl_interface *interface(); }; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgOutputV1 : public QObject +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandXdgOutputV1 : public QObject { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandXdgOutputV1) +#if QT_CONFIG(wayland_compositor_quick) Q_WAYLAND_COMPOSITOR_DECLARE_QUICK_CHILDREN(QWaylandXdgOutputV1) +#endif + Q_PROPERTY(QWaylandXdgOutputManagerV1 *manager READ manager NOTIFY managerChanged) Q_PROPERTY(QWaylandOutput *output READ output NOTIFY outputChanged) Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) @@ -74,6 +46,7 @@ class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgOutputV1 : public QObject Q_PROPERTY(QPoint logicalPosition READ logicalPosition WRITE setLogicalPosition NOTIFY logicalPositionChanged) Q_PROPERTY(QSize logicalSize READ logicalSize WRITE setLogicalSize NOTIFY logicalSizeChanged) Q_PROPERTY(QRect logicalGeometry READ logicalGeometry NOTIFY logicalGeometryChanged) + Q_MOC_INCLUDE("qwaylandoutput.h") public: QWaylandXdgOutputV1(); QWaylandXdgOutputV1(QWaylandOutput *output, QWaylandXdgOutputManagerV1 *manager); diff --git a/src/compositor/extensions/qwaylandxdgoutputv1_p.h b/src/compositor/extensions/qwaylandxdgoutputv1_p.h index 2e8a6fff9..9db3703fc 100644 --- a/src/compositor/extensions/qwaylandxdgoutputv1_p.h +++ b/src/compositor/extensions/qwaylandxdgoutputv1_p.h @@ -1,42 +1,11 @@ -/**************************************************************************** -** -** Copyright (C) 2019 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$ -** -****************************************************************************/ +// Copyright (C) 2019 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDXDGOUTPUTV1_P_H #define QWAYLANDXDGOUTPUTV1_P_H +#include <QtCore/QHash> + #include <QWaylandOutput> #include <QWaylandXdgOutputV1> #include <QtWaylandCompositor/private/qwaylandcompositorextension_p.h> @@ -55,7 +24,7 @@ QT_BEGIN_NAMESPACE -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgOutputManagerV1Private +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandXdgOutputManagerV1Private : public QWaylandCompositorExtensionPrivate , public QtWaylandServer::zxdg_output_manager_v1 { @@ -76,7 +45,7 @@ private: QHash<QWaylandOutput *, QWaylandXdgOutputV1 *> xdgOutputs; }; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgOutputV1Private +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandXdgOutputV1Private : public QObjectPrivate , public QtWaylandServer::zxdg_output_v1 { diff --git a/src/compositor/extensions/qwaylandxdgshell.cpp b/src/compositor/extensions/qwaylandxdgshell.cpp index 1b8a3c2e2..7185d749e 100644 --- a/src/compositor/extensions/qwaylandxdgshell.cpp +++ b/src/compositor/extensions/qwaylandxdgshell.cpp @@ -1,38 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** 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$ -** -****************************************************************************/ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwaylandxdgshell.h" #include "qwaylandxdgshell_p.h" @@ -42,6 +9,8 @@ #endif #include <QtWaylandCompositor/private/qwaylandutils_p.h> +#include "qwaylandxdgdialogv1_p.h" + #include <QtWaylandCompositor/QWaylandCompositor> #include <QtWaylandCompositor/QWaylandSeat> #include <QtWaylandCompositor/QWaylandSurface> @@ -78,7 +47,7 @@ void QWaylandXdgShellPrivate::unregisterXdgSurface(QWaylandXdgSurface *xdgSurfac QWaylandXdgSurface *QWaylandXdgShellPrivate::xdgSurfaceFromSurface(QWaylandSurface *surface) { - for (QWaylandXdgSurface *xdgSurface : qAsConst(m_xdgSurfaces)) { + for (QWaylandXdgSurface *xdgSurface : std::as_const(m_xdgSurfaces)) { if (surface == xdgSurface->surface()) return xdgSurface; } @@ -141,7 +110,8 @@ void QWaylandXdgShellPrivate::xdg_wm_base_pong(Resource *resource, uint32_t seri /*! * \qmltype XdgShell - * \inqmlmodule QtWayland.Compositor + * \instantiates QWaylandXdgShell + * \inqmlmodule QtWayland.Compositor.XdgShell * \since 5.12 * \brief Provides an extension for desktop-style user interfaces. * @@ -155,8 +125,8 @@ void QWaylandXdgShellPrivate::xdg_wm_base_pong(Resource *resource, uint32_t seri * an instance of the XdgShell component and add it to the list of extensions * supported by the compositor: * - * \qml \QtMinorVersion - * import QtWayland.Compositor 1.\1 + * \qml + * import QtWayland.Compositor.XdgShell * * WaylandCompositor { * XdgShell { @@ -213,6 +183,10 @@ void QWaylandXdgShell::initialize() connect(compositor, &QWaylandCompositor::defaultSeatChanged, this, &QWaylandXdgShell::handleSeatChanged); + + // Support the dialog extension unconditionally. + QObject *dialogExtension = new QWaylandXdgDialogV1Global(compositor); + dialogExtension->setParent(this); } /*! @@ -229,7 +203,7 @@ QByteArray QWaylandXdgShell::interfaceName() } /*! - * \qmlmethod void QtWaylandCompositor::XdgShell::ping(WaylandClient client) + * \qmlmethod void XdgShell::ping(WaylandClient client) * * Sends a ping event to \a client. If the client replies to the event the * \l pong signal will be emitted. @@ -362,6 +336,9 @@ void QWaylandXdgSurfacePrivate::xdg_surface_get_toplevel(QtWaylandServer::xdg_su m_toplevel = new QWaylandXdgToplevel(q, topLevelResource); emit q->toplevelCreated(); emit m_xdgShell->toplevelCreated(m_toplevel, q); + q->connect(m_toplevel, &QWaylandXdgToplevel::modalChanged, q, [q, this](){ + q->setModal(m_toplevel->modal()); + }); } void QWaylandXdgSurfacePrivate::xdg_surface_get_popup(QtWaylandServer::xdg_surface::Resource *resource, uint32_t id, wl_resource *parentResource, wl_resource *positionerResource) @@ -461,7 +438,8 @@ void QWaylandXdgSurfacePrivate::xdg_surface_set_window_geometry(QtWaylandServer: /*! * \qmltype XdgSurface - * \inqmlmodule QtWayland.Compositor + * \instantiates QWaylandXdgSurface + * \inqmlmodule QtWayland.Compositor.XdgShell * \since 5.12 * \brief XdgSurface provides desktop-style compositor-specific features to an xdg surface. * @@ -506,7 +484,7 @@ QWaylandXdgSurface::QWaylandXdgSurface(QWaylandXdgShell *xdgShell, QWaylandSurfa } /*! - * \qmlmethod void QtWaylandCompositor::XdgSurface::initialize(object xdgShell, object surface, object client, int id) + * \qmlmethod void XdgSurface::initialize(object xdgShell, object surface, object client, int id) * * Initializes the XdgSurface, associating it with the given \a xdgShell, \a surface, * \a client, and \a id. @@ -532,7 +510,7 @@ void QWaylandXdgSurface::initialize(QWaylandXdgShell *xdgShell, QWaylandSurface } /*! - * \qmlproperty enum QtWaylandCompositor::XdgSurface::windowType + * \qmlproperty enum XdgSurface::windowType * * This property holds the window type of the XdgSurface. */ @@ -543,7 +521,7 @@ Qt::WindowType QWaylandXdgSurface::windowType() const } /*! - * \qmlproperty rect QtWaylandCompositor::XdgSurface::windowGeometry + * \qmlproperty rect XdgSurface::windowGeometry * * This property holds the window geometry of the QWaylandXdgSurface. The window * geometry describes the window's visible bounds from the user's perspective. @@ -588,7 +566,7 @@ void QWaylandXdgSurface::handleBufferScaleChanged() } /*! - * \qmlproperty XdgShell QtWaylandCompositor::XdgSurface::shell + * \qmlproperty XdgShell XdgSurface::shell * * This property holds the shell associated with this XdgSurface. */ @@ -605,7 +583,7 @@ QWaylandXdgShell *QWaylandXdgSurface::shell() const } /*! - * \qmlproperty WaylandSurface QtWaylandCompositor::XdgSurface::surface + * \qmlproperty WaylandSurface XdgSurface::surface * * This property holds the surface associated with this XdgSurface. */ @@ -622,7 +600,7 @@ QWaylandSurface *QWaylandXdgSurface::surface() const } /*! - * \qmlproperty XdgToplevel QtWaylandCompositor::XdgSurface::toplevel + * \qmlproperty XdgToplevel XdgSurface::toplevel * * This property holds the properties and methods that are specific to the * toplevel XdgSurface. @@ -645,7 +623,7 @@ QWaylandXdgToplevel *QWaylandXdgSurface::toplevel() const } /*! - * \qmlproperty XdgPopup QtWaylandCompositor::XdgSurface::popup + * \qmlproperty XdgPopup XdgSurface::popup * * This property holds the properties and methods that are specific to the * popup XdgSurface. @@ -710,7 +688,8 @@ QWaylandQuickShellIntegration *QWaylandXdgSurface::createIntegration(QWaylandQui /*! * \qmltype XdgToplevel - * \inqmlmodule QtWayland.Compositor + * \instantiates QWaylandXdgToplevel + * \inqmlmodule QtWayland.Compositor.XdgShell * \since 5.12 * \brief XdgToplevel represents the toplevel window specific parts of an xdg surface. * @@ -740,7 +719,7 @@ QWaylandQuickShellIntegration *QWaylandXdgSurface::createIntegration(QWaylandQui QWaylandXdgToplevel::QWaylandXdgToplevel(QWaylandXdgSurface *xdgSurface, QWaylandResource &resource) : QObject(*new QWaylandXdgToplevelPrivate(xdgSurface, resource)) { - QVector<QWaylandXdgToplevel::State> states; + QList<QWaylandXdgToplevel::State> states; sendConfigure({0, 0}, states); } @@ -755,7 +734,7 @@ QWaylandXdgToplevel::~QWaylandXdgToplevel() } /*! - * \qmlproperty XdgSurface QtWaylandCompositor::XdgToplevel::xdgSurface + * \qmlproperty XdgSurface XdgToplevel::xdgSurface * * This property holds the XdgSurface for this XdgToplevel. */ @@ -772,7 +751,7 @@ QWaylandXdgSurface *QWaylandXdgToplevel::xdgSurface() const } /*! - * \qmlproperty XdgToplevel QtWaylandCompositor::XdgToplevel::parentToplevel + * \qmlproperty XdgToplevel XdgToplevel::parentToplevel * * This property holds the XdgToplevel parent of this XdgToplevel. */ @@ -790,7 +769,7 @@ QWaylandXdgToplevel *QWaylandXdgToplevel::parentToplevel() const } /*! - * \qmlproperty string QtWaylandCompositor::XdgToplevel::title + * \qmlproperty string XdgToplevel::title * * This property holds the title of the XdgToplevel. */ @@ -807,7 +786,7 @@ QString QWaylandXdgToplevel::title() const } /*! - * \qmlproperty string QtWaylandCompositor::XdgToplevel::appId + * \qmlproperty string XdgToplevel::appId * * This property holds the app id of the XdgToplevel. */ @@ -824,7 +803,7 @@ QString QWaylandXdgToplevel::appId() const } /*! - * \qmlproperty size QtWaylandCompositor::XdgToplevel::maxSize + * \qmlproperty size XdgToplevel::maxSize * * This property holds the maximum size of the XdgToplevel as requested by the client. * @@ -845,7 +824,7 @@ QSize QWaylandXdgToplevel::maxSize() const } /*! - * \qmlproperty size QtWaylandCompositor::XdgToplevel::minSize + * \qmlproperty size XdgToplevel::minSize * * This property holds the minimum size of the XdgToplevel as requested by the client. * @@ -870,14 +849,14 @@ QSize QWaylandXdgToplevel::minSize() const * * This property holds the last states the client acknowledged for this QWaylandToplevel. */ -QVector<QWaylandXdgToplevel::State> QWaylandXdgToplevel::states() const +QList<QWaylandXdgToplevel::State> QWaylandXdgToplevel::states() const { Q_D(const QWaylandXdgToplevel); return d->m_lastAckedConfigure.states; } /*! - * \qmlproperty bool QtWaylandCompositor::XdgToplevel::maximized + * \qmlproperty bool XdgToplevel::maximized * * This property holds whether the client has acknowledged that it should be maximized. */ @@ -894,7 +873,7 @@ bool QWaylandXdgToplevel::maximized() const } /*! - * \qmlproperty bool QtWaylandCompositor::XdgToplevel::fullscreen + * \qmlproperty bool XdgToplevel::fullscreen * * This property holds whether the client has acknowledged that it should be fullscreen. */ @@ -911,7 +890,7 @@ bool QWaylandXdgToplevel::fullscreen() const } /*! - * \qmlproperty bool QtWaylandCompositor::XdgToplevel::resizing + * \qmlproperty bool XdgToplevel::resizing * * This property holds whether the client has acknowledged that it is being resized. */ @@ -928,7 +907,7 @@ bool QWaylandXdgToplevel::resizing() const } /*! - * \qmlproperty bool QtWaylandCompositor::XdgToplevel::activated + * \qmlproperty bool XdgToplevel::activated * * This property holds whether toplevel is drawing itself as having input focus. */ @@ -945,6 +924,34 @@ bool QWaylandXdgToplevel::activated() const } /*! + * \qmlproperty bool XdgToplevel::modal + * + * This property holds whether toplevel blocks other windows from receiving input. + * \since 6.8 + */ + +/*! + * \property QWaylandXdgToplevel::modal + * + * This property holds whether toplevel blocks other windows from receiving input. + * \since 6.8 + */ +bool QWaylandXdgToplevel::modal() const +{ + Q_D(const QWaylandXdgToplevel); + return d->m_modal; +} + +void QWaylandXdgToplevel::setModal(bool newModal) +{ + Q_D(QWaylandXdgToplevel); + if (d->m_modal == newModal) + return; + d->m_modal = newModal; + emit modalChanged(); +} + +/*! * \enum QWaylandXdgToplevel::DecorationMode * * This enum type is used to specify the window decoration mode for toplevel windows. @@ -954,7 +961,7 @@ bool QWaylandXdgToplevel::activated() const */ /*! - * \qmlproperty enumeration QtWaylandCompositor::XdgToplevel::decorationMode + * \qmlproperty enumeration XdgToplevel::decorationMode * * This property holds the current window decoration mode for this toplevel. * @@ -979,7 +986,7 @@ QWaylandXdgToplevel::DecorationMode QWaylandXdgToplevel::decorationMode() const } /*! - * \qmlmethod size QtWaylandCompositor::XdgToplevel::sizeForResize(size size, point delta, uint edges) + * \qmlmethod size XdgToplevel::sizeForResize(size size, point delta, uint edges) * * Convenience for computing the new size given the current \a size, a \a delta, and * the \a edges active in the drag. @@ -1018,7 +1025,7 @@ QSize QWaylandXdgToplevel::sizeForResize(const QSizeF &size, const QPointF &delt * of the surface. A size of zero means the client is free to decide the size. * Known \a states are enumerated in QWaylandXdgToplevel::State. */ -uint QWaylandXdgToplevel::sendConfigure(const QSize &size, const QVector<QWaylandXdgToplevel::State> &states) +uint QWaylandXdgToplevel::sendConfigure(const QSize &size, const QList<QWaylandXdgToplevel::State> &states) { if (!size.isValid()) { qWarning() << "Can't configure xdg_toplevel with an invalid size" << size; @@ -1035,22 +1042,22 @@ uint QWaylandXdgToplevel::sendConfigure(const QSize &size, const QVector<QWaylan } /*! - * \qmlmethod int QtWaylandCompositor::XdgToplevel::sendConfigure(size size, list<int> states) + * \qmlmethod int XdgToplevel::sendConfigure(size size, list<int> states) * * Sends a configure event to the client. \a size contains the pixel size of the surface. * A size of zero means the client is free to decide the size. * Known \a states are enumerated in XdgToplevel::State. */ -uint QWaylandXdgToplevel::sendConfigure(const QSize &size, const QVector<int> &states) +uint QWaylandXdgToplevel::sendConfigure(const QSize &size, const QList<int> &states) { - QVector<State> s; + QList<State> s; for (auto state : states) s << State(state); return sendConfigure(size, s); } /*! - * \qmlmethod void QtWaylandCompositor::XdgToplevel::sendClose() + * \qmlmethod void XdgToplevel::sendClose() * * Sends a close event to the client. The client may choose to ignore the event. */ @@ -1065,7 +1072,7 @@ void QWaylandXdgToplevel::sendClose() } /*! - * \qmlmethod void QtWaylandCompositor::XdgToplevel::sendMaximized(size size) + * \qmlmethod void XdgToplevel::sendMaximized(size size) * * Convenience for sending a configure event with the maximized state set, and * fullscreen and resizing removed. The activated state is left in its current state. @@ -1093,7 +1100,7 @@ uint QWaylandXdgToplevel::sendMaximized(const QSize &size) } /*! - * \qmlmethod void QtWaylandCompositor::XdgToplevel::sendUnmaximized(size size) + * \qmlmethod void XdgToplevel::sendUnmaximized(size size) * * Convenience for sending a configure event with the maximized, fullscreen and * resizing states removed, and fullscreen and resizing removed. The activated @@ -1123,7 +1130,7 @@ uint QWaylandXdgToplevel::sendUnmaximized(const QSize &size) } /*! - * \qmlmethod void QtWaylandCompositor::XdgToplevel::sendFullscreen(size size) + * \qmlmethod void XdgToplevel::sendFullscreen(size size) * * Convenience for sending a configure event with the fullscreen state set, and * maximized and resizing removed. The activated state is left in its current state. @@ -1155,7 +1162,7 @@ uint QWaylandXdgToplevel::sendFullscreen(const QSize &size) } /*! - * \qmlmethod void QtWaylandCompositor::XdgToplevel::sendResizing(size maxSize) + * \qmlmethod void XdgToplevel::sendResizing(size maxSize) * * Convenience for sending a configure event with the resizing state set, and * maximized and fullscreen removed. The activated state is left in its current state. @@ -1201,7 +1208,7 @@ QWaylandXdgToplevel *QWaylandXdgToplevel::fromResource(wl_resource *resource) } /*! - * \qmlsignal QtWaylandCompositor::XdgShell::xdgSurfaceCreated(XdgSurface xdgSurface) + * \qmlsignal XdgShell::xdgSurfaceCreated(XdgSurface xdgSurface) * * This signal is emitted when the client has created a \c xdg_surface. * Note that \a xdgSurface is not mapped, i.e. according to the \c xdg-shell @@ -1221,7 +1228,7 @@ QWaylandXdgToplevel *QWaylandXdgToplevel::fromResource(wl_resource *resource) */ /*! - * \qmlsignal QtWaylandCompositor::XdgShell::toplevelCreated(XdgToplevel toplevel, XdgSurface xdgSurface) + * \qmlsignal XdgShell::toplevelCreated(XdgToplevel toplevel, XdgSurface xdgSurface) * * This signal is emitted when the client has created a \c xdg_toplevel. * A common use case is to let the handler of this signal instantiate a ShellSurfaceItem or @@ -1241,7 +1248,7 @@ QWaylandXdgToplevel *QWaylandXdgToplevel::fromResource(wl_resource *resource) */ /*! - * \qmlsignal QtWaylandCompositor::XdgShell::popupCreated(XdgPopup popup, XdgSurface xdgSurface) + * \qmlsignal XdgShell::popupCreated(XdgPopup popup, XdgSurface xdgSurface) * * This signal is emitted when the client has created a \c xdg_popup. * A common use case is to let the handler of this signal instantiate a ShellSurfaceItem or @@ -1261,7 +1268,7 @@ QWaylandXdgToplevel *QWaylandXdgToplevel::fromResource(wl_resource *resource) */ /*! - * \qmlsignal QtWaylandCompositor::XdgShell::pong(int serial) + * \qmlsignal XdgShell::pong(int serial) * * This signal is emitted when the client has responded to a ping event with serial, \a serial. * @@ -1312,7 +1319,7 @@ void QWaylandXdgToplevelPrivate::handleAckConfigure(uint serial) break; } - QVector<uint> changedStates; + QList<uint> changedStates; std::set_symmetric_difference( m_lastAckedConfigure.states.begin(), m_lastAckedConfigure.states.end(), config.states.begin(), config.states.end(), @@ -1547,7 +1554,8 @@ void QWaylandXdgToplevelPrivate::xdg_toplevel_set_minimized(QtWaylandServer::xdg /*! * \qmltype XdgPopup - * \inqmlmodule QtWayland.Compositor + * \instantiates QWaylandXdgPopup + * \inqmlmodule QtWayland.Compositor.XdgShell * \since 5.12 * \brief XdgPopup represents the popup specific parts of and xdg surface. * @@ -1581,7 +1589,7 @@ QWaylandXdgPopup::QWaylandXdgPopup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSu } /*! - * \qmlproperty XdgSurface QtWaylandCompositor::XdgPopup::xdgSurface + * \qmlproperty XdgSurface XdgPopup::xdgSurface * * This property holds the XdgSurface associated with this XdgPopup. */ @@ -1598,7 +1606,7 @@ QWaylandXdgSurface *QWaylandXdgPopup::xdgSurface() const } /*! - * \qmlproperty XdgSurface QtWaylandCompositor::XdgPopup::parentXdgSurface + * \qmlproperty XdgSurface XdgPopup::parentXdgSurface * * This property holds the XdgSurface associated with the parent of this XdgPopup. */ @@ -1616,7 +1624,7 @@ QWaylandXdgSurface *QWaylandXdgPopup::parentXdgSurface() const } /*! - * \qmlproperty rect QtWaylandCompositor::XdgPopup::configuredGeometry + * \qmlproperty rect XdgPopup::configuredGeometry * * The window geometry the popup received in the configure event. Relative to the * upper left corner of the parent surface. @@ -1635,7 +1643,7 @@ QRect QWaylandXdgPopup::configuredGeometry() const } /*! - * \qmlproperty rect QtWaylandCompositor::XdgPopup::anchorRect + * \qmlproperty rect XdgPopup::anchorRect * * The anchor rectangle relative to the parent window geometry that the child * surface should be placed relative to. @@ -1654,7 +1662,7 @@ QRect QWaylandXdgPopup::anchorRect() const } /*! - * \qmlproperty enumeration QtWaylandCompositor::XdgPopup::anchorEdges + * \qmlproperty enumeration XdgPopup::anchorEdges * * This property holds the set of edges on the anchor rect that the child surface should be placed * relative to. If no edges are specified in a direction, the anchor point should be @@ -1681,7 +1689,7 @@ Qt::Edges QWaylandXdgPopup::anchorEdges() const } /*! - * \qmlproperty rect QtWaylandCompositor::XdgPopup::gravityEdges + * \qmlproperty rect XdgPopup::gravityEdges * * Specifies in what direction the surface should be positioned, relative to the anchor * point. @@ -1706,7 +1714,7 @@ Qt::Edges QWaylandXdgPopup::gravityEdges() const } /*! - * \qmlproperty enumeration QtWaylandCompositor::XdgPopup::slideConstraints + * \qmlproperty enumeration XdgPopup::slideConstraints * * This property holds the orientations in which the child should slide to fit within the screen. * @@ -1725,7 +1733,7 @@ Qt::Orientations QWaylandXdgPopup::slideConstraints() const Q_D(const QWaylandXdgPopup); const uint flags = d->m_positionerData.constraintAdjustments; - Qt::Orientations constraints = 0; + Qt::Orientations constraints = {}; if (flags & XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_X) constraints |= Qt::Horizontal; @@ -1736,7 +1744,7 @@ Qt::Orientations QWaylandXdgPopup::slideConstraints() const } /*! - * \qmlproperty enumeration QtWaylandCompositor::XdgPopup::flipConstraints + * \qmlproperty enumeration XdgPopup::flipConstraints * * This property holds the orientations in which the child should flip to fit within the screen. * @@ -1755,7 +1763,7 @@ Qt::Orientations QWaylandXdgPopup::flipConstraints() const Q_D(const QWaylandXdgPopup); const uint flags = d->m_positionerData.constraintAdjustments; - Qt::Orientations constraints = 0; + Qt::Orientations constraints = {}; if (flags & XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_FLIP_X) constraints |= Qt::Horizontal; @@ -1766,7 +1774,7 @@ Qt::Orientations QWaylandXdgPopup::flipConstraints() const } /*! - * \qmlproperty enumeration QtWaylandCompositor::XdgPopup::resizeConstraints + * \qmlproperty enumeration XdgPopup::resizeConstraints * * This property holds the orientations in which the child should resize to fit within the screen. * @@ -1785,7 +1793,7 @@ Qt::Orientations QWaylandXdgPopup::resizeConstraints() const Q_D(const QWaylandXdgPopup); const uint flags = d->m_positionerData.constraintAdjustments; - Qt::Orientations constraints = 0; + Qt::Orientations constraints = {}; if (flags & XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_RESIZE_X) constraints |= Qt::Horizontal; @@ -1796,7 +1804,7 @@ Qt::Orientations QWaylandXdgPopup::resizeConstraints() const } /*! - * \qmlproperty point QtWaylandCompositor::XdgPopup::offset + * \qmlproperty point XdgPopup::offset * * The position relative to the position of the anchor on the anchor rectangle and * the anchor on the surface. @@ -1815,7 +1823,7 @@ QPoint QWaylandXdgPopup::offset() const } /*! - * \qmlproperty size QtWaylandCompositor::XdgPopup::positionerSize + * \qmlproperty size XdgPopup::positionerSize * * The size requested for the window geometry by the positioner object. */ @@ -1832,7 +1840,7 @@ QSize QWaylandXdgPopup::positionerSize() const } /*! - * \qmlproperty point QtWaylandCompositor::XdgPopup::unconstrainedPosition + * \qmlproperty point XdgPopup::unconstrainedPosition * * The position of the surface relative to the parent window geometry if the surface * is not constrained. I.e. when not moved to fit inside the screen or similar. @@ -1851,7 +1859,7 @@ QPoint QWaylandXdgPopup::unconstrainedPosition() const } /*! - * \qmlmethod int QtWaylandCompositor::XdgPopup::sendConfigure(rect geometry) + * \qmlmethod int XdgPopup::sendConfigure(rect geometry) * * Sends a configure event to the client. \a geometry contains the window geometry * relative to the upper left corner of the window geometry of the parent surface. @@ -1873,7 +1881,7 @@ uint QWaylandXdgPopup::sendConfigure(const QRect &geometry) } /*! - * \qmlmethod void QtWaylandCompositor::XdgPopup::sendPopupDone() + * \qmlmethod void XdgPopup::sendPopupDone() * \since 5.14 * * Dismiss the popup. According to the \c xdg-shell protocol this should make the @@ -2133,3 +2141,5 @@ Qt::Edges QWaylandXdgPositioner::convertToEdges(QWaylandXdgPositioner::gravity g QT_END_NAMESPACE + +#include "moc_qwaylandxdgshell.cpp" diff --git a/src/compositor/extensions/qwaylandxdgshell.h b/src/compositor/extensions/qwaylandxdgshell.h index 2e3e28180..4c5a2fef7 100644 --- a/src/compositor/extensions/qwaylandxdgshell.h +++ b/src/compositor/extensions/qwaylandxdgshell.h @@ -1,38 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** 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$ -** -****************************************************************************/ + +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDXDGSHELL_H #define QWAYLANDXDGSHELL_H @@ -41,7 +9,9 @@ #include <QtWaylandCompositor/QWaylandResource> #include <QtWaylandCompositor/QWaylandShell> #include <QtWaylandCompositor/QWaylandShellSurface> +#if QT_CONFIG(wayland_compositor_quick) #include <QtWaylandCompositor/qwaylandquickchildren.h> +#endif #include <QtCore/QRect> @@ -63,7 +33,7 @@ class QWaylandXdgPopup; class QWaylandXdgPopupPrivate; class QWaylandXdgPositioner; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgShell : public QWaylandShellTemplate<QWaylandXdgShell> +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandXdgShell : public QWaylandShellTemplate<QWaylandXdgShell> { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandXdgShell) @@ -90,16 +60,19 @@ private Q_SLOTS: void handleFocusChanged(QWaylandSurface *newSurface, QWaylandSurface *oldSurface); }; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgSurface : public QWaylandShellSurfaceTemplate<QWaylandXdgSurface> +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandXdgSurface : public QWaylandShellSurfaceTemplate<QWaylandXdgSurface> { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandXdgSurface) +#if QT_CONFIG(wayland_compositor_quick) Q_WAYLAND_COMPOSITOR_DECLARE_QUICK_CHILDREN(QWaylandXdgSurface) +#endif Q_PROPERTY(QWaylandXdgShell *shell READ shell NOTIFY shellChanged) Q_PROPERTY(QWaylandSurface *surface READ surface NOTIFY surfaceChanged) Q_PROPERTY(QWaylandXdgToplevel *toplevel READ toplevel NOTIFY toplevelCreated) Q_PROPERTY(QWaylandXdgPopup *popup READ popup NOTIFY popupCreated) Q_PROPERTY(QRect windowGeometry READ windowGeometry NOTIFY windowGeometryChanged) + Q_MOC_INCLUDE("qwaylandsurface.h") public: explicit QWaylandXdgSurface(); @@ -138,7 +111,7 @@ private Q_SLOTS: void handleBufferScaleChanged(); }; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgToplevel : public QObject +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandXdgToplevel : public QObject { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandXdgToplevel) @@ -153,7 +126,9 @@ class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgToplevel : public QObject Q_PROPERTY(bool fullscreen READ fullscreen NOTIFY fullscreenChanged) Q_PROPERTY(bool resizing READ resizing NOTIFY resizingChanged) Q_PROPERTY(bool activated READ activated NOTIFY activatedChanged) + Q_PROPERTY(bool modal READ modal NOTIFY modalChanged FINAL REVISION(6,8)) Q_PROPERTY(enum DecorationMode decorationMode READ decorationMode NOTIFY decorationModeChanged) + public: enum State : uint { MaximizedState = 1, @@ -179,7 +154,7 @@ public: QString appId() const; QSize maxSize() const; QSize minSize() const; - QVector<QWaylandXdgToplevel::State> states() const; + QList<QWaylandXdgToplevel::State> states() const; bool maximized() const; bool fullscreen() const; bool resizing() const; @@ -187,8 +162,8 @@ public: DecorationMode decorationMode() const; Q_INVOKABLE QSize sizeForResize(const QSizeF &size, const QPointF &delta, Qt::Edges edges) const; - uint sendConfigure(const QSize &size, const QVector<State> &states); - Q_INVOKABLE uint sendConfigure(const QSize &size, const QVector<int> &states); + uint sendConfigure(const QSize &size, const QList<State> &states); + Q_INVOKABLE uint sendConfigure(const QSize &size, const QList<int> &states); Q_INVOKABLE void sendClose(); Q_INVOKABLE uint sendMaximized(const QSize &size); Q_INVOKABLE uint sendUnmaximized(const QSize &size = QSize(0, 0)); @@ -198,6 +173,8 @@ public: static QWaylandSurfaceRole *role(); static QWaylandXdgToplevel *fromResource(::wl_resource *resource); + bool modal() const; + Q_SIGNALS: void parentToplevelChanged(); void titleChanged(); @@ -221,16 +198,20 @@ Q_SIGNALS: void decorationModeChanged(); + Q_REVISION(6, 8) void modalChanged(); + private: QList<int> statesAsInts() const; + void setModal(bool newModal); + friend class QWaylandXdgDialogV1; }; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgPopup : public QObject +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandXdgPopup : public QObject { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandXdgPopup) - Q_PROPERTY(QWaylandXdgSurface *xdgSurface READ xdgSurface) - Q_PROPERTY(QWaylandXdgSurface *parentXdgSurface READ parentXdgSurface) + Q_PROPERTY(QWaylandXdgSurface *xdgSurface READ xdgSurface CONSTANT) + Q_PROPERTY(QWaylandXdgSurface *parentXdgSurface READ parentXdgSurface CONSTANT) Q_PROPERTY(QRect configuredGeometry READ configuredGeometry NOTIFY configuredGeometryChanged) // Positioner properties @@ -260,7 +241,7 @@ public: QPoint unconstrainedPosition() const; Q_INVOKABLE uint sendConfigure(const QRect &geometry); - Q_REVISION(14) Q_INVOKABLE void sendPopupDone(); + Q_REVISION(1, 14) Q_INVOKABLE void sendPopupDone(); static QWaylandSurfaceRole *role(); diff --git a/src/compositor/extensions/qwaylandxdgshell_p.h b/src/compositor/extensions/qwaylandxdgshell_p.h index 3223abf3a..9ab188a44 100644 --- a/src/compositor/extensions/qwaylandxdgshell_p.h +++ b/src/compositor/extensions/qwaylandxdgshell_p.h @@ -1,43 +1,10 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** 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$ -** -****************************************************************************/ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDXDGSHELL_P_H #define QWAYLANDXDGSHELL_P_H -#include <QtWaylandCompositor/private/qwaylandcompositorextension_p.h> +#include <QtWaylandCompositor/private/qwaylandshellsurface_p.h> #include <QtWaylandCompositor/private/qwaylandshell_p.h> #include <QtWaylandCompositor/private/qwayland-server-xdg-shell.h> @@ -60,11 +27,11 @@ QT_BEGIN_NAMESPACE -struct Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgPositionerData { +struct Q_WAYLANDCOMPOSITOR_EXPORT QWaylandXdgPositionerData { QSize size; QRect anchorRect; - Qt::Edges anchorEdges = 0; - Qt::Edges gravityEdges = 0; + Qt::Edges anchorEdges = {}; + Qt::Edges gravityEdges = {}; uint constraintAdjustments = XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_NONE; QPoint offset; QWaylandXdgPositionerData(); @@ -73,7 +40,7 @@ struct Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgPositionerData { QPoint unconstrainedPosition() const; }; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgShellPrivate +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandXdgShellPrivate : public QWaylandShellPrivate , public QtWaylandServer::xdg_wm_base { @@ -98,8 +65,8 @@ protected: void xdg_wm_base_pong(Resource *resource, uint32_t serial) override; }; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgSurfacePrivate - : public QWaylandCompositorExtensionPrivate +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandXdgSurfacePrivate + : public QWaylandShellSurfacePrivate , public QtWaylandServer::xdg_surface { Q_DECLARE_PUBLIC(QWaylandXdgSurface) @@ -132,18 +99,18 @@ private: void xdg_surface_set_window_geometry(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) override; }; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgToplevelPrivate : public QObjectPrivate, public QtWaylandServer::xdg_toplevel +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandXdgToplevelPrivate : public QObjectPrivate, public QtWaylandServer::xdg_toplevel { Q_DECLARE_PUBLIC(QWaylandXdgToplevel) public: struct ConfigureEvent { ConfigureEvent() = default; - ConfigureEvent(const QVector<QWaylandXdgToplevel::State> + ConfigureEvent(const QList<QWaylandXdgToplevel::State> &incomingStates, const QSize &incomingSize, uint incomingSerial) : states(incomingStates), size(incomingSize), serial(incomingSerial) { } - QVector<QWaylandXdgToplevel::State> states; + QList<QWaylandXdgToplevel::State> states; QSize size = {0, 0}; uint serial = 0; }; @@ -186,11 +153,12 @@ public: QSize m_maxSize; QSize m_minSize = {0, 0}; QWaylandXdgToplevelDecorationV1 *m_decoration = nullptr; + bool m_modal = false; static QWaylandSurfaceRole s_role; }; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgPopupPrivate : public QObjectPrivate, public QtWaylandServer::xdg_popup +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandXdgPopupPrivate : public QObjectPrivate, public QtWaylandServer::xdg_popup { Q_DECLARE_PUBLIC(QWaylandXdgPopup) public: @@ -223,7 +191,7 @@ private: QList<ConfigureEvent> m_pendingConfigures; }; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgPositioner : public QtWaylandServer::xdg_positioner +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandXdgPositioner : public QtWaylandServer::xdg_positioner { public: QWaylandXdgPositioner(const QWaylandResource& resource); diff --git a/src/compositor/extensions/qwaylandxdgshellintegration.cpp b/src/compositor/extensions/qwaylandxdgshellintegration.cpp index 0aa160544..643ad65ba 100644 --- a/src/compositor/extensions/qwaylandxdgshellintegration.cpp +++ b/src/compositor/extensions/qwaylandxdgshellintegration.cpp @@ -1,38 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** 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$ -** -****************************************************************************/ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwaylandxdgshellintegration_p.h" @@ -82,45 +49,63 @@ bool XdgToplevelIntegration::eventFilter(QObject *object, QEvent *event) if (event->type() == QEvent::MouseMove) { QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event); return filterMouseMoveEvent(mouseEvent); - } else if (event->type() == QEvent::MouseButtonRelease) { - QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event); - return filterMouseReleaseEvent(mouseEvent); + } else if (event->type() == QEvent::MouseButtonRelease || event->type() == QEvent::TouchEnd || event->type() == QEvent::TouchCancel) { + return filterPointerReleaseEvent(); + } else if (event->type() == QEvent::TouchUpdate) { + QTouchEvent *touchEvent = static_cast<QTouchEvent *>(event); + return filterTouchUpdateEvent(touchEvent); } return QWaylandQuickShellIntegration::eventFilter(object, event); } -bool XdgToplevelIntegration::filterMouseMoveEvent(QMouseEvent *event) +bool XdgToplevelIntegration::filterPointerMoveEvent(const QPointF &scenePosition) { if (grabberState == GrabberState::Resize) { - Q_ASSERT(resizeState.seat == m_item->compositor()->seatFor(event)); if (!resizeState.initialized) { - resizeState.initialMousePos = event->windowPos(); + resizeState.initialMousePos = scenePosition; resizeState.initialized = true; return true; } - QPointF delta = m_item->mapToSurface(event->windowPos() - resizeState.initialMousePos); + QPointF delta = m_item->mapToSurface(scenePosition - resizeState.initialMousePos); QSize newSize = m_toplevel->sizeForResize(resizeState.initialWindowSize, delta, resizeState.resizeEdges); m_toplevel->sendResizing(newSize); } else if (grabberState == GrabberState::Move) { - Q_ASSERT(moveState.seat == m_item->compositor()->seatFor(event)); QQuickItem *moveItem = m_item->moveItem(); if (!moveState.initialized) { - moveState.initialOffset = moveItem->mapFromItem(nullptr, event->windowPos()); + moveState.initialOffset = moveItem->mapFromItem(nullptr, scenePosition); moveState.initialized = true; return true; } if (!moveItem->parentItem()) return true; - QPointF parentPos = moveItem->parentItem()->mapFromItem(nullptr, event->windowPos()); + QPointF parentPos = moveItem->parentItem()->mapFromItem(nullptr, scenePosition); moveItem->setPosition(parentPos - moveState.initialOffset); } return false; } -bool XdgToplevelIntegration::filterMouseReleaseEvent(QMouseEvent *event) +bool XdgToplevelIntegration::filterTouchUpdateEvent(QTouchEvent *event) { - Q_UNUSED(event); + if (event->pointCount() == 0) + return false; + + Q_ASSERT(grabberState != GrabberState::Move || moveState.seat == m_item->compositor()->seatFor(event)); + Q_ASSERT(grabberState != GrabberState::Resize || resizeState.seat == m_item->compositor()->seatFor(event)); + QEventPoint point = event->points().first(); + return filterPointerMoveEvent(point.scenePosition()); + } + +bool XdgToplevelIntegration::filterMouseMoveEvent(QMouseEvent *event) +{ + Q_ASSERT(grabberState != GrabberState::Move || moveState.seat == m_item->compositor()->seatFor(event)); + Q_ASSERT(grabberState != GrabberState::Resize || resizeState.seat == m_item->compositor()->seatFor(event)); + + return filterPointerMoveEvent(event->scenePosition()); +} + +bool XdgToplevelIntegration::filterPointerReleaseEvent() +{ if (grabberState != GrabberState::Default) { grabberState = GrabberState::Default; return true; @@ -151,7 +136,7 @@ void XdgToplevelIntegration::handleSetMaximized() if (!m_item->view()->isPrimary()) return; - QVector<QWaylandXdgToplevel::State> states = m_toplevel->states(); + QList<QWaylandXdgToplevel::State> states = m_toplevel->states(); if (!states.contains(QWaylandXdgToplevel::State::FullscreenState) && !states.contains(QWaylandXdgToplevel::State::MaximizedState)) { windowedGeometry.initialWindowSize = m_xdgSurface->windowGeometry().size(); @@ -207,7 +192,7 @@ void XdgToplevelIntegration::handleSetFullscreen() if (!m_item->view()->isPrimary()) return; - QVector<QWaylandXdgToplevel::State> states = m_toplevel->states(); + QList<QWaylandXdgToplevel::State> states = m_toplevel->states(); if (!states.contains(QWaylandXdgToplevel::State::FullscreenState) && !states.contains(QWaylandXdgToplevel::State::MaximizedState)) { windowedGeometry.initialWindowSize = m_xdgSurface->windowGeometry().size(); @@ -318,3 +303,5 @@ void XdgPopupIntegration::handleGeometryChanged() } QT_END_NAMESPACE + +#include "moc_qwaylandxdgshellintegration_p.cpp" diff --git a/src/compositor/extensions/qwaylandxdgshellintegration_p.h b/src/compositor/extensions/qwaylandxdgshellintegration_p.h index cd6bad572..eba397678 100644 --- a/src/compositor/extensions/qwaylandxdgshellintegration_p.h +++ b/src/compositor/extensions/qwaylandxdgshellintegration_p.h @@ -1,38 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** 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$ -** -****************************************************************************/ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDXDGSHELLINTEGRATION_H #define QWAYLANDXDGSHELLINTEGRATION_H @@ -122,8 +89,10 @@ private: // geometry-changed. } nonwindowedState; + bool filterPointerMoveEvent(const QPointF &scenePosition); bool filterMouseMoveEvent(QMouseEvent *event); - bool filterMouseReleaseEvent(QMouseEvent *event); + bool filterPointerReleaseEvent(); + bool filterTouchUpdateEvent(QTouchEvent *event); }; class XdgPopupIntegration : public QWaylandQuickShellIntegration diff --git a/src/compositor/extensions/qwaylandxdgshellv5.cpp b/src/compositor/extensions/qwaylandxdgshellv5.cpp deleted file mode 100644 index fab3c841a..000000000 --- a/src/compositor/extensions/qwaylandxdgshellv5.cpp +++ /dev/null @@ -1,1517 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qwaylandxdgshellv5.h" -#include "qwaylandxdgshellv5_p.h" - -#if QT_CONFIG(wayland_compositor_quick) -#include "qwaylandxdgshellv5integration_p.h" -#endif -#include <QtWaylandCompositor/private/qwaylandutils_p.h> - -#include <QtWaylandCompositor/QWaylandCompositor> -#include <QtWaylandCompositor/QWaylandSurface> -#include <QtWaylandCompositor/QWaylandSurfaceRole> -#include <QtWaylandCompositor/QWaylandResource> -#include <QtWaylandCompositor/QWaylandSeat> - -#include <QtCore/QObject> - -#include <algorithm> - -QT_BEGIN_NAMESPACE - -QWaylandSurfaceRole QWaylandXdgSurfaceV5Private::s_role("xdg_surface"); -QWaylandSurfaceRole QWaylandXdgPopupV5Private::s_role("xdg_popup"); - -QWaylandXdgShellV5Private::QWaylandXdgShellV5Private() -{ -} - -void QWaylandXdgShellV5Private::ping(Resource *resource, uint32_t serial) -{ - m_pings.insert(serial); - send_ping(resource->handle, serial); -} - -void QWaylandXdgShellV5Private::registerSurface(QWaylandXdgSurfaceV5 *xdgSurface) -{ - m_xdgSurfaces.insert(xdgSurface->surface()->client()->client(), xdgSurface); -} - -void QWaylandXdgShellV5Private::unregisterXdgSurface(QWaylandXdgSurfaceV5 *xdgSurface) -{ - auto xdgSurfacePrivate = QWaylandXdgSurfaceV5Private::get(xdgSurface); - if (!m_xdgSurfaces.remove(xdgSurfacePrivate->resource()->client(), xdgSurface)) - qWarning("%s Unexpected state. Can't find registered xdg surface\n", Q_FUNC_INFO); -} - -void QWaylandXdgShellV5Private::registerXdgPopup(QWaylandXdgPopupV5 *xdgPopup) -{ - m_xdgPopups.insert(xdgPopup->surface()->client()->client(), xdgPopup); -} - -void QWaylandXdgShellV5Private::unregisterXdgPopup(QWaylandXdgPopupV5 *xdgPopup) -{ - auto xdgPopupPrivate = QWaylandXdgPopupV5Private::get(xdgPopup); - if (!m_xdgPopups.remove(xdgPopupPrivate->resource()->client(), xdgPopup)) - qWarning("%s Unexpected state. Can't find registered xdg popup\n", Q_FUNC_INFO); -} - -bool QWaylandXdgShellV5Private::isValidPopupParent(QWaylandSurface *parentSurface) const -{ - QWaylandXdgPopupV5 *topmostPopup = topmostPopupForClient(parentSurface->client()->client()); - if (topmostPopup && topmostPopup->surface() != parentSurface) { - return false; - } - - QWaylandSurfaceRole *parentRole = parentSurface->role(); - if (parentRole != QWaylandXdgSurfaceV5::role() && parentRole != QWaylandXdgPopupV5::role()) { - return false; - } - - return true; -} - -QWaylandXdgPopupV5 *QWaylandXdgShellV5Private::topmostPopupForClient(wl_client *client) const -{ - QList<QWaylandXdgPopupV5 *> clientPopups = m_xdgPopups.values(client); - return clientPopups.empty() ? nullptr : clientPopups.last(); -} - -QWaylandXdgSurfaceV5 *QWaylandXdgShellV5Private::xdgSurfaceFromSurface(QWaylandSurface *surface) const -{ - for (QWaylandXdgSurfaceV5 *xdgSurface : m_xdgSurfaces) { - if (surface == xdgSurface->surface()) - return xdgSurface; - } - return nullptr; -} - -void QWaylandXdgShellV5Private::xdg_shell_destroy(Resource *resource) -{ - if (!m_xdgSurfaces.values(resource->client()).empty()) - wl_resource_post_error(resource->handle, XDG_SHELL_ERROR_DEFUNCT_SURFACES, - "xdg_shell was destroyed before children"); - - wl_resource_destroy(resource->handle); -} - -void QWaylandXdgShellV5Private::xdg_shell_get_xdg_surface(Resource *resource, uint32_t id, - wl_resource *surface_res) -{ - Q_Q(QWaylandXdgShellV5); - QWaylandSurface *surface = QWaylandSurface::fromResource(surface_res); - - if (xdgSurfaceFromSurface(surface)) { - wl_resource_post_error(resource->handle, XDG_SHELL_ERROR_ROLE, - "An active xdg_surface already exists for wl_surface@%d", - wl_resource_get_id(surface->resource())); - return; - } - - if (!surface->setRole(QWaylandXdgSurfaceV5::role(), resource->handle, XDG_SHELL_ERROR_ROLE)) - return; - - QWaylandResource xdgSurfaceResource(wl_resource_create(resource->client(), &xdg_surface_v5_interface, - wl_resource_get_version(resource->handle), id)); - - emit q->xdgSurfaceRequested(surface, xdgSurfaceResource); - - QWaylandXdgSurfaceV5 *xdgSurface = QWaylandXdgSurfaceV5::fromResource(xdgSurfaceResource.resource()); - if (!xdgSurface) { - // A QWaylandXdgSurfaceV5 was not created in response to the xdgSurfaceRequested signal, so we - // create one as fallback here instead. - xdgSurface = new QWaylandXdgSurfaceV5(q, surface, xdgSurfaceResource); - } - - registerSurface(xdgSurface); - emit q->xdgSurfaceCreated(xdgSurface); -} - -void QWaylandXdgShellV5Private::xdg_shell_use_unstable_version(Resource *resource, int32_t version) -{ - if (xdg_shell_v5::version_current != version) { - wl_resource_post_error(resource->handle, WL_DISPLAY_ERROR_INVALID_OBJECT, - "incompatible version, server is %d, but client wants %d", - xdg_shell_v5::version_current, version); - } -} - -void QWaylandXdgShellV5Private::xdg_shell_get_xdg_popup(Resource *resource, uint32_t id, - wl_resource *surface_res, wl_resource *parent, - wl_resource *seatResource, uint32_t serial, - int32_t x, int32_t y) -{ - Q_UNUSED(serial); - Q_Q(QWaylandXdgShellV5); - QWaylandSurface *surface = QWaylandSurface::fromResource(surface_res); - QWaylandSurface *parentSurface = QWaylandSurface::fromResource(parent); - - if (!isValidPopupParent(parentSurface)) { - wl_resource_post_error(resource->handle, XDG_SHELL_ERROR_INVALID_POPUP_PARENT, - "the client specified an invalid popup parent surface"); - return; - } - - if (!surface->setRole(QWaylandXdgPopupV5::role(), resource->handle, XDG_SHELL_ERROR_ROLE)) { - return; - } - - QWaylandResource xdgPopupResource (wl_resource_create(resource->client(), &xdg_popup_v5_interface, - wl_resource_get_version(resource->handle), id)); - QWaylandSeat *seat = QWaylandSeat::fromSeatResource(seatResource); - QPoint position(x, y); - emit q->xdgPopupRequested(surface, parentSurface, seat, position, xdgPopupResource); - - QWaylandXdgPopupV5 *xdgPopup = QWaylandXdgPopupV5::fromResource(xdgPopupResource.resource()); - if (!xdgPopup) { - // A QWaylandXdgPopupV5 was not created in response to the xdgPopupRequested signal, so we - // create one as fallback here instead. - xdgPopup = new QWaylandXdgPopupV5(q, surface, parentSurface, position, xdgPopupResource); - } - - registerXdgPopup(xdgPopup); - emit q->xdgPopupCreated(xdgPopup); -} - -void QWaylandXdgShellV5Private::xdg_shell_pong(Resource *resource, uint32_t serial) -{ - Q_UNUSED(resource); - Q_Q(QWaylandXdgShellV5); - if (m_pings.remove(serial)) - emit q->pong(serial); - else - qWarning("Received an unexpected pong!"); -} - -QWaylandXdgSurfaceV5Private::QWaylandXdgSurfaceV5Private() - : m_lastAckedConfigure({{}, QSize(0, 0), 0}) -{ -} - -void QWaylandXdgSurfaceV5Private::handleFocusLost() -{ - Q_Q(QWaylandXdgSurfaceV5); - QWaylandXdgSurfaceV5Private::ConfigureEvent current = lastSentConfigure(); - current.states.removeOne(QWaylandXdgSurfaceV5::State::ActivatedState); - q->sendConfigure(current.size, current.states); -} - -void QWaylandXdgSurfaceV5Private::handleFocusReceived() -{ - Q_Q(QWaylandXdgSurfaceV5); - - QWaylandXdgSurfaceV5Private::ConfigureEvent current = lastSentConfigure(); - if (!current.states.contains(QWaylandXdgSurfaceV5::State::ActivatedState)) { - current.states.push_back(QWaylandXdgSurfaceV5::State::ActivatedState); - } - - q->sendConfigure(current.size, current.states); -} - -QRect QWaylandXdgSurfaceV5Private::calculateFallbackWindowGeometry() const -{ - // TODO: The unset window geometry should include subsurfaces as well, so this solution - // won't work too well on those kinds of clients. - return QRect(QPoint(), m_surface->destinationSize()); -} - -void QWaylandXdgSurfaceV5Private::updateFallbackWindowGeometry() -{ - Q_Q(QWaylandXdgSurfaceV5); - if (!m_unsetWindowGeometry) - return; - - const QRect unsetGeometry = calculateFallbackWindowGeometry(); - if (unsetGeometry == m_windowGeometry) - return; - - m_windowGeometry = unsetGeometry; - emit q->windowGeometryChanged(); -} - -void QWaylandXdgSurfaceV5Private::setWindowType(Qt::WindowType windowType) -{ - if (m_windowType == windowType) - return; - - m_windowType = windowType; - - Q_Q(QWaylandXdgSurfaceV5); - emit q->windowTypeChanged(); -} - -void QWaylandXdgSurfaceV5Private::xdg_surface_destroy_resource(Resource *resource) -{ - Q_UNUSED(resource); - Q_Q(QWaylandXdgSurfaceV5); - QWaylandXdgShellV5Private::get(m_xdgShell)->unregisterXdgSurface(q); - delete q; -} - -void QWaylandXdgSurfaceV5Private::xdg_surface_destroy(Resource *resource) -{ - wl_resource_destroy(resource->handle); -} - -void QWaylandXdgSurfaceV5Private::xdg_surface_move(Resource *resource, wl_resource *seat, uint32_t serial) -{ - Q_UNUSED(resource); - Q_UNUSED(serial); - - Q_Q(QWaylandXdgSurfaceV5); - QWaylandSeat *input_device = QWaylandSeat::fromSeatResource(seat); - emit q->startMove(input_device); -} - -void QWaylandXdgSurfaceV5Private::xdg_surface_resize(Resource *resource, wl_resource *seat, - uint32_t serial, uint32_t edges) -{ - Q_UNUSED(resource); - Q_UNUSED(serial); - - Q_Q(QWaylandXdgSurfaceV5); - QWaylandSeat *input_device = QWaylandSeat::fromSeatResource(seat); - emit q->startResize(input_device, QWaylandXdgSurfaceV5::ResizeEdge(edges)); -} - -void QWaylandXdgSurfaceV5Private::xdg_surface_set_maximized(Resource *resource) -{ - Q_UNUSED(resource); - Q_Q(QWaylandXdgSurfaceV5); - emit q->setMaximized(); -} - -void QWaylandXdgSurfaceV5Private::xdg_surface_unset_maximized(Resource *resource) -{ - Q_UNUSED(resource); - Q_Q(QWaylandXdgSurfaceV5); - emit q->unsetMaximized(); -} - -void QWaylandXdgSurfaceV5Private::xdg_surface_set_fullscreen(Resource *resource, wl_resource *output_res) -{ - Q_UNUSED(resource); - Q_Q(QWaylandXdgSurfaceV5); - QWaylandOutput *output = output_res ? QWaylandOutput::fromResource(output_res) : nullptr; - emit q->setFullscreen(output); -} - -void QWaylandXdgSurfaceV5Private::xdg_surface_unset_fullscreen(Resource *resource) -{ - Q_UNUSED(resource); - Q_Q(QWaylandXdgSurfaceV5); - emit q->unsetFullscreen(); -} - -void QWaylandXdgSurfaceV5Private::xdg_surface_set_minimized(Resource *resource) -{ - Q_UNUSED(resource); - Q_Q(QWaylandXdgSurfaceV5); - emit q->setMinimized(); -} - -void QWaylandXdgSurfaceV5Private::xdg_surface_set_parent(Resource *resource, wl_resource *parent) -{ - Q_UNUSED(resource); - QWaylandXdgSurfaceV5 *parentSurface = nullptr; - if (parent) { - parentSurface = static_cast<QWaylandXdgSurfaceV5Private *>( - QWaylandXdgSurfaceV5Private::Resource::fromResource(parent)->xdg_surface_object)->q_func(); - } - - Q_Q(QWaylandXdgSurfaceV5); - - if (m_parentSurface != parentSurface) { - m_parentSurface = parentSurface; - emit q->parentSurfaceChanged(); - } - - if (m_parentSurface && m_windowType != Qt::WindowType::SubWindow) { - // There's a parent now, which means the surface is transient - setWindowType(Qt::WindowType::SubWindow); - emit q->setTransient(); - } else if (!m_parentSurface && m_windowType != Qt::WindowType::Window) { - // When the surface has no parent it is toplevel - setWindowType(Qt::WindowType::Window); - emit q->setTopLevel(); - } -} - -void QWaylandXdgSurfaceV5Private::xdg_surface_set_app_id(Resource *resource, const QString &app_id) -{ - Q_UNUSED(resource); - if (app_id == m_appId) - return; - Q_Q(QWaylandXdgSurfaceV5); - m_appId = app_id; - emit q->appIdChanged(); -} - -void QWaylandXdgSurfaceV5Private::xdg_surface_show_window_menu(Resource *resource, wl_resource *seatResource, - uint32_t serial, int32_t x, int32_t y) -{ - Q_UNUSED(resource); - Q_UNUSED(serial); - QPoint position(x, y); - auto seat = QWaylandSeat::fromSeatResource(seatResource); - Q_Q(QWaylandXdgSurfaceV5); - emit q->showWindowMenu(seat, position); -} - -void QWaylandXdgSurfaceV5Private::xdg_surface_ack_configure(Resource *resource, uint32_t serial) -{ - Q_UNUSED(resource); - Q_Q(QWaylandXdgSurfaceV5); - - ConfigureEvent config; - Q_FOREVER { - if (m_pendingConfigures.empty()) { - qWarning("Received an unexpected ack_configure!"); - return; - } - - config = m_pendingConfigures.takeFirst(); - - if (config.serial == serial) - break; - } - - std::vector<uint> changedStates; - std::set_symmetric_difference( - m_lastAckedConfigure.states.begin(), m_lastAckedConfigure.states.end(), - config.states.begin(), config.states.end(), - std::back_inserter(changedStates)); - - m_lastAckedConfigure = config; - - if (!changedStates.empty()) { - for (uint state : changedStates) { - switch (state) { - case QWaylandXdgSurfaceV5::State::MaximizedState: - emit q->maximizedChanged(); - break; - case QWaylandXdgSurfaceV5::State::FullscreenState: - emit q->fullscreenChanged(); - break; - case QWaylandXdgSurfaceV5::State::ResizingState: - emit q->resizingChanged(); - break; - case QWaylandXdgSurfaceV5::State::ActivatedState: - emit q->activatedChanged(); - break; - } - } - emit q->statesChanged(); - } - - emit q->ackConfigure(serial); -} - -void QWaylandXdgSurfaceV5Private::xdg_surface_set_title(Resource *resource, const QString &title) -{ - Q_UNUSED(resource); - if (title == m_title) - return; - Q_Q(QWaylandXdgSurfaceV5); - m_title = title; - emit q->titleChanged(); -} - -void QWaylandXdgSurfaceV5Private::xdg_surface_set_window_geometry(Resource *resource, - int32_t x, int32_t y, - int32_t width, int32_t height) -{ - Q_UNUSED(resource); - - if (width <= 0 || height <= 0) { - qWarning() << "Invalid (non-positive) dimensions received in set_window_geometry"; - return; - } - - m_unsetWindowGeometry = false; - - QRect geometry(x, y, width, height); - - Q_Q(QWaylandXdgSurfaceV5); - if ((q->maximized() || q->fullscreen()) && m_lastAckedConfigure.size != geometry.size()) - qWarning() << "Client window geometry did not obey last acked configure"; - - if (geometry == m_windowGeometry) - return; - - m_windowGeometry = geometry; - emit q->windowGeometryChanged(); -} - -QWaylandXdgPopupV5Private::QWaylandXdgPopupV5Private() -{ -} - -void QWaylandXdgPopupV5Private::xdg_popup_destroy_resource(Resource *resource) -{ - Q_UNUSED(resource); - Q_Q(QWaylandXdgPopupV5); - QWaylandXdgShellV5Private::get(m_xdgShell)->unregisterXdgPopup(q); - delete q; -} - -void QWaylandXdgPopupV5Private::xdg_popup_destroy(Resource *resource) -{ - //TODO: post error if not topmost popup - wl_resource_destroy(resource->handle); -} - -/*! - * \qmltype XdgShellV5 - * \inqmlmodule QtWayland.Compositor - * \since 5.8 - * \brief Provides an extension for desktop-style user interfaces. - * - * The XdgShellV5 extension provides a way to associate an XdgSurfaceV5 - * with a regular Wayland surface. Using the xdg_surface interface, the client - * can request that the surface is resized, moved, and so on. - * - * XdgShellV5 corresponds to the Wayland interface \c xdg_shell. - * - * To provide the functionality of the shell extension in a compositor, create - * an instance of the XdgShellV5 component and add it as a child of the - * compositor: - * - * \qml \QtMinorVersion - * import QtWayland.Compositor 1.\1 - * - * WaylandCompositor { - * XdgShellV5 { - * // ... - * } - * } - * \endqml - * - * \deprecated - */ - -/*! - * \class QWaylandXdgShellV5 - * \inmodule QtWaylandCompositor - * \since 5.8 - * \brief The QWaylandXdgShellV5 class is an extension for desktop-style user interfaces. - * - * The QWaylandXdgShellV5 extension provides a way to associate a QWaylandXdgSurfaceV5 with - * a regular Wayland surface. Using the xdg_surface interface, the client - * can request that the surface is resized, moved, and so on. - * - * QWaylandXdgShellV5 corresponds to the Wayland interface \c xdg_shell. - * - * \deprecated - */ - -/*! - * Constructs a QWaylandXdgShellV5 object. - */ -QWaylandXdgShellV5::QWaylandXdgShellV5() - : QWaylandShellTemplate<QWaylandXdgShellV5>(*new QWaylandXdgShellV5Private()) -{ } - -/*! - * Constructs a QWaylandXdgShellV5 object for the provided \a compositor. - */ -QWaylandXdgShellV5::QWaylandXdgShellV5(QWaylandCompositor *compositor) - : QWaylandShellTemplate<QWaylandXdgShellV5>(compositor, *new QWaylandXdgShellV5Private()) -{ } - -/*! - * Initializes the shell extension. - */ -void QWaylandXdgShellV5::initialize() -{ - Q_D(QWaylandXdgShellV5); - QWaylandShellTemplate::initialize(); - QWaylandCompositor *compositor = static_cast<QWaylandCompositor *>(extensionContainer()); - if (!compositor) { - qWarning() << "Failed to find QWaylandCompositor when initializing QWaylandXdgShellV5"; - return; - } - d->init(compositor->display(), 1); - - handleSeatChanged(compositor->defaultSeat(), nullptr); - - connect(compositor, &QWaylandCompositor::defaultSeatChanged, - this, &QWaylandXdgShellV5::handleSeatChanged); -} - -QWaylandClient *QWaylandXdgShellV5::popupClient() const -{ - Q_D(const QWaylandXdgShellV5); - for (QWaylandXdgPopupV5 *popup : d->m_xdgPopups) { - if (popup->surface()->hasContent()) - return popup->surface()->client(); - } - return nullptr; -} - -/*! - * Returns the Wayland interface for the QWaylandXdgShellV5. - */ -const struct wl_interface *QWaylandXdgShellV5::interface() -{ - return QWaylandXdgShellV5Private::interface(); -} - -QByteArray QWaylandXdgShellV5::interfaceName() -{ - return QWaylandXdgShellV5Private::interfaceName(); -} - -/*! - * \qmlmethod void QtWaylandCompositor::XdgShellV5::ping() - * - * Sends a ping event to the \a client. If the client replies to the event, the - * pong signal will be emitted. - */ - -/*! - * Sends a ping event to the \a client. If the client replies to the event, the - * pong signal will be emitted. - */ -uint QWaylandXdgShellV5::ping(QWaylandClient *client) -{ - Q_D(QWaylandXdgShellV5); - - QWaylandCompositor *compositor = static_cast<QWaylandCompositor *>(extensionContainer()); - Q_ASSERT(compositor); - - uint32_t serial = compositor->nextSerial(); - - QWaylandXdgShellV5Private::Resource *clientResource = d->resourceMap().value(client->client(), nullptr); - Q_ASSERT(clientResource); - - d->ping(clientResource, serial); - return serial; -} - -// ### remove once QMap has rbegin()/rend() -template <typename Iterator> -std::reverse_iterator<Iterator> make_reverse(Iterator it) -{ - return std::reverse_iterator<Iterator>(std::move(it)); -} - -void QWaylandXdgShellV5::closeAllPopups() -{ - Q_D(QWaylandXdgShellV5); - // Close pop-ups from top-most to bottom-most, lest we get protocol errors: - for (auto rit = make_reverse(d->m_xdgPopups.end()), rend = make_reverse(d->m_xdgPopups.begin()); rit != rend; ++rit) { - (*rit)->sendPopupDone(); - } -} - -/*! - * \qmlsignal void QtWaylandCompositor::XdgShellV5::xdgSurfaceRequested(WaylandSurface surface, WaylandResource resource) - * - * This signal is emitted when the client has requested an \c xdg_surface to be associated - * with \a surface. The handler for this signal may create the shell surface for \a resource - * and initialize it within the scope of the signal emission. Otherwise an XdgSurfaceV5 will - * be created automatically. - */ - -/*! - * \fn void QWaylandXdgShellV5::xdgSurfaceRequested(QWaylandSurface *surface, const QWaylandResource &resource) - * - * This signal is emitted when the client has requested an \c xdg_surface to be associated - * with \a surface. The handler for this signal may create the shell surface for \a resource - * and initialize it within the scope of the signal emission. Otherwise a QWaylandXdgSurfaceV5 - * will be created automatically. - */ - -/*! - * \qmlsignal void QtWaylandCompositor::XdgShellV5::xdgSurfaceCreated(XdgSurfaceV5 xdgSurface) - * - * This signal is emitted when the client has created an \c xdg_surface. - * A common use case is to let the handler of this signal instantiate a ShellSurfaceItem or - * WaylandQuickItem for displaying \a xdgSurface in a QtQuick scene. - */ - -/*! - * \fn void QWaylandXdgShellV5::xdgSurfaceCreated(QWaylandXdgSurfaceV5 *xdgSurface) - * - * This signal is emitted when the client has created an \c xdg_surface. - * A common use case is to let the handler of this signal instantiate a QWaylandShellSurfaceItem or - * QWaylandQuickItem for displaying \a xdgSurface in a QtQuick scene. - */ - -/*! - * \qmlsignal void QtWaylandCompositor::XdgShellV5::xdgPopupRequested(WaylandSurface surface, WaylandSurface parent, WaylandSeat seat, point position, WaylandResource resource) - * - * This signal is emitted when the client has requested an \c xdg_popup to be associated - * with \a surface. The handler for this signal may create the xdg popup for \a resource and - * initialize it within the scope of the signal emission. Otherwise an XdgPopupV5 will be - * created automatically. - * - * The \a seat is the \c wl_seat that caused the popup to be opened. - * - * \a position is the desired position of the popup, relative to the \a parent. - */ - -/*! - * \fn void QWaylandXdgShellV5::xdgPopupRequested(QWaylandSurface *surface, QWaylandSurface *parent, QWaylandSeat *seat, const QPoint &position, const QWaylandResource &resource) - * - * This signal is emitted when the client has requested an \c xdg_surface to be associated - * with \a surface. The handler for this signal may create the xdg poup for \a resource and - * initialize it within the scope of the signal emission. Otherwise a QWaylandXdgPopupV5 will be - * created automatically. - * - * The \a seat is the \c wl_seat that caused the popup to be opened. - * - * \a position is the desired position of the popup, relative to the \a parent. - */ - -/*! - * \qmlsignal void QtWaylandCompositor::XdgShellV5::xdgPopupCreated(XdgPopupV5 xdgPopup) - * - * This signal is emitted when the client has created an \c xdg_popup. - * A common use case is to let the handler of this signal instantiate a ShellSurfaceItem or - * WaylandQuickItem for displaying \a xdgPopup in a QtQuick scene. - */ - -/*! - * \fn void QWaylandXdgShellV5::xdgPopupCreated(QWaylandXdgPopupV5 *xdgPopup) - * - * This signal is emitted when the client has created an \c xdg_popup. - * A common use case is to let the handler of this signal instantiate a QWaylandShellSurfaceItem or - * QWaylandQuickItem for displaying \a xdgPopup in a QtQuick scene. - */ - -/*! - * \qmlsignal void QtWaylandCompositor::XdgShellV5::pong(int serial) - * - * This signal is emitted when the client has responded to a ping event with serial \a serial. - * - * \sa QtWaylandCompositor::XdgShellV5::ping() - */ - -/*! - * \fn void QWaylandXdgShellV5::pong(uint serial) - * - * This signal is emitted when the client has responded to a ping event with serial \a serial. - * - * \sa QWaylandXdgShellV5::ping() - */ - -void QWaylandXdgShellV5::handleSeatChanged(QWaylandSeat *newSeat, QWaylandSeat *oldSeat) -{ - if (oldSeat != nullptr) { - disconnect(oldSeat, &QWaylandSeat::keyboardFocusChanged, - this, &QWaylandXdgShellV5::handleFocusChanged); - } - - if (newSeat != nullptr) { - connect(newSeat, &QWaylandSeat::keyboardFocusChanged, - this, &QWaylandXdgShellV5::handleFocusChanged); - } -} - -void QWaylandXdgShellV5::handleFocusChanged(QWaylandSurface *newSurface, QWaylandSurface *oldSurface) -{ - Q_D(QWaylandXdgShellV5); - - QWaylandXdgSurfaceV5 *newXdgSurface = d->xdgSurfaceFromSurface(newSurface); - QWaylandXdgSurfaceV5 *oldXdgSurface = d->xdgSurfaceFromSurface(oldSurface); - - if (newXdgSurface) - QWaylandXdgSurfaceV5Private::get(newXdgSurface)->handleFocusReceived(); - - if (oldXdgSurface) - QWaylandXdgSurfaceV5Private::get(oldXdgSurface)->handleFocusLost(); -} - -/*! - * \qmltype XdgSurfaceV5 - * \inqmlmodule QtWayland.Compositor - * \since 5.8 - * \brief Provides a \c xdg_surface that offers desktop-style compositor-specific features to a surface. - * - * This type is part of the \l{XdgShellV5} extension and provides a way to extend - * the functionality of an existing WaylandSurface with features specific to desktop-style - * compositors, such as resizing and moving the surface. - * - * It corresponds to the Wayland interface \c xdg_surface for the unstable xdg-shell protocol v5. - * - * \deprecated - */ - -/*! - * \class QWaylandXdgSurfaceV5 - * \inmodule QtWaylandCompositor - * \since 5.8 - * \brief The QWaylandXdgSurfaceV5 class provides desktop-style compositor-specific features to an xdg surface. - * - * This class is part of the QWaylandXdgShellV5 extension and provides a way to - * extend the functionality of an existing QWaylandSurface with features - * specific to desktop-style compositors, such as resizing and moving the - * surface. - * - * It corresponds to the Wayland interface xdg_surface. - * - * \deprecated - */ - -/*! - * \qmlsignal QtWaylandCompositor::XdgSurfaceV5::setTopLevel() - * - * This signal is emitted when the parent surface is unset, effectively - * making the window top level. - */ - -/*! - * \qmlsignal QtWaylandCompositor::XdgSurfaceV5::setTransient() - * - * This signal is emitted when the parent surface is set, effectively - * making the window transient. - */ - -/*! - * Constructs a QWaylandXdgSurfaceV5. - */ -QWaylandXdgSurfaceV5::QWaylandXdgSurfaceV5() - : QWaylandShellSurfaceTemplate<QWaylandXdgSurfaceV5>(*new QWaylandXdgSurfaceV5Private) -{ -} - -/*! - * Constructs a QWaylandXdgSurfaceV5 for \a surface and initializes it with the - * given \a xdgShell, \a surface, and resource \a res. - */ -QWaylandXdgSurfaceV5::QWaylandXdgSurfaceV5(QWaylandXdgShellV5 *xdgShell, QWaylandSurface *surface, const QWaylandResource &res) - : QWaylandShellSurfaceTemplate<QWaylandXdgSurfaceV5>(*new QWaylandXdgSurfaceV5Private) -{ - initialize(xdgShell, surface, res); -} - -/*! - * \qmlmethod void QtWaylandCompositor::XdgSurfaceV5::initialize(XdgShellV5 xdgShell, WaylandSurface surface, WaylandResource resource) - * - * Initializes the XdgSurfaceV5, associating it with the given \a xdgShell, \a surface, - * and \a resource. - */ - -/*! - * Initializes the QWaylandXdgSurfaceV5, associating it with the given \a xdgShell, \a surface - * and \a resource. - */ -void QWaylandXdgSurfaceV5::initialize(QWaylandXdgShellV5 *xdgShell, QWaylandSurface *surface, const QWaylandResource &resource) -{ - Q_D(QWaylandXdgSurfaceV5); - d->m_xdgShell = xdgShell; - d->m_surface = surface; - d->init(resource.resource()); - setExtensionContainer(surface); - d->m_windowGeometry = d->calculateFallbackWindowGeometry(); - connect(surface, &QWaylandSurface::destinationSizeChanged, this, &QWaylandXdgSurfaceV5::handleSurfaceSizeChanged); - connect(surface, &QWaylandSurface::bufferScaleChanged, this, &QWaylandXdgSurfaceV5::handleBufferScaleChanged); - emit shellChanged(); - emit surfaceChanged(); - emit windowGeometryChanged(); - QWaylandCompositorExtension::initialize(); -} - -/*! - * \qmlsignal void QtWaylandCompositor::XdgSurfaceV5::showWindowMenu(WaylandSeat seat, point localSurfacePosition) - * - * This signal is emitted when the client wants to show a context menu at \a localSurfacePosition, - * using the Wayland seat \a seat. It's typically emitted in response to the user right-clicking - * the window decorations. - */ - -/*! - * \fn void QWaylandXdgSurfaceV5::showWindowMenu(QWaylandSeat *seat, const QPoint &localSurfacePosition) - * - * This signal is emitted when the client wants to show a context menu at \a localSurfacePosition, - * using the Wayland seat \a seat. It's typically emitted in response to the user right-clicking - * the window decorations. - */ - -/*! - * \qmlsignal void QtWaylandCompositor::XdgSurfaceV5::startMove(WaylandSeat seat) - * - * This signal is emitted when the client wants to start an interactive move of the XdgSurfaceV5, - * typically in response to the window decorations being dragged by \a seat. - */ - -/*! - * \fn void QWaylandXdgSurfaceV5::startMove(QWaylandSeat *seat) - * - * This signal is emitted when the client wants to start an interactive move of the - * QWaylandXdgSurfaceV5, typically in response to the window decorations being dragged by \a seat. - */ - -/*! - * \qmlsignal void QtWaylandCompositor::XdgSurfaceV5::startResize(WaylandSeat seat, enumeration edges) - * - * This signal is emitted when the client wants to start an interactive resize of the XdgSurfaceV5, - * typically in response to the window decorations being dragged by \a seat on the window borders - * given by \a edges. - * - * \sa QWaylandXdgSurfaceV5::ResizeEdge - */ - -/*! - * \fn void QWaylandXdgSurfaceV5::startResize(QWaylandSeat *seat, ResizeEdge edges) - * - * This signal is emitted when the client wants to start an interactive resize of the - * QWaylandXdgSurfaceV5, typically in response to the window decorations being dragged by - * \a seat on the window borders given by \a edges. - */ - -/*! - * \qmlsignal void QtWaylandCompositor::XdgSurfaceV5::setMaximized() - * - * This signal is emitted when the client wants the \c xdg_surface to be maximized. - */ - -/*! - * \fn void QWaylandXdgSurfaceV5::setMaximized() - * - * This signal is emitted when the client wants the \c xdg_surface to be maximized. - */ - -/*! - * \qmlsignal void QtWaylandCompositor::XdgSurfaceV5::unsetMaximized() - * - * This signal is emitted when the client doesn't want the \c xdg_surface to be maximized anymore. - */ - -/*! - * \fn void QWaylandXdgSurfaceV5::unsetMaximized() - * - * This signal is emitted when the client doesn't want the \c xdg_surface to be maximized anymore. - */ - -/*! - * \qmlsignal void QtWaylandCompositor::XdgSurfaceV5::setFullscreen(WaylandOutput output) - * - * This signal is emitted when the client wants the \c xdg_surface to be in full screen mode. - * The client may specify an \a output it wishes the \c xdg_surface to be shown on. - */ - -/*! - * \fn void QWaylandXdgSurfaceV5::setFullscreen(QWaylandOutput *output) - * - * This signal is emitted when the client wants the \c xdg_surface to be in full screen mode. - * The client may specify an \a output it wishes the \c xdg_surface to be shown on. - */ - -/*! - * \qmlsignal void QtWaylandCompositor::XdgSurfaceV5::unsetFullscreen() - * - * This signal is emitted when the client doesn't want the \c xdg_surface to be in full screen mode - * anymore. - */ - -/*! - * \fn void QWaylandXdgSurfaceV5::unsetFullscreen() - * - * This signal is emitted when the client doesn't want the \c xdg_surface to be in full screen mode - * anymore. - */ - -/*! - * \qmlsignal void QtWaylandCompositor::XdgSurfaceV5::setMinimized() - * - * This signal is emitted when the client wants the \c xdg_surface to be minimized. - */ - -/*! - * \fn void QWaylandXdgSurfaceV5::setMinimized() - * - * This signal is emitted when the client wants the \c xdg_surface to be minimized. - */ - -/*! - * \qmlsignal void QtWaylandCompositor::XdgSurfaceV5::ackConfigure(int serial) - * - * This signal is emitted when the client has received configure events up to and including the - * configure event with serial \a serial and will draw its surface accordingly in the next committed - * buffer. - */ - -/*! - * \fn void QWaylandXdgSurfaceV5::ackConfigure(uint serial) - * - * This signal is emitted when the client has received configure events up to and including the - * configure event with serial \a serial and will draw its surface accordingly in the next committed - * buffer. - */ - -/*! - * \internal - */ -void QWaylandXdgSurfaceV5::initialize() -{ - QWaylandCompositorExtension::initialize(); -} - -QList<int> QWaylandXdgSurfaceV5::statesAsInts() const -{ - QList<int> list; - const auto s = states(); - list.reserve(s.size()); - for (auto state : s) { - list << static_cast<int>(state); - } - return list; -} - -void QWaylandXdgSurfaceV5::handleSurfaceSizeChanged() -{ - Q_D(QWaylandXdgSurfaceV5); - d->updateFallbackWindowGeometry(); -} - -void QWaylandXdgSurfaceV5::handleBufferScaleChanged() -{ - Q_D(QWaylandXdgSurfaceV5); - d->updateFallbackWindowGeometry(); -} - -/*! - * \qmlproperty XdgShellV5 QtWaylandCompositor::XdgSurfaceV5::shell - * - * This property holds the shell associated with this XdgSurfaceV5. - */ - -/*! - * \property QWaylandXdgSurfaceV5::shell - * - * This property holds the shell associated with this QWaylandXdgSurfaceV5. - */ -QWaylandXdgShellV5 *QWaylandXdgSurfaceV5::shell() const -{ - Q_D(const QWaylandXdgSurfaceV5); - return d->m_xdgShell; -} - -/*! - * \qmlproperty WaylandSurface QtWaylandCompositor::XdgSurfaceV5::surface - * - * This property holds the surface associated with this XdgSurfaceV5. - */ - -/*! - * \property QWaylandXdgSurfaceV5::surface - * - * This property holds the surface associated with this QWaylandXdgSurfaceV5. - */ -QWaylandSurface *QWaylandXdgSurfaceV5::surface() const -{ - Q_D(const QWaylandXdgSurfaceV5); - return d->m_surface; -} - -/*! - * \qmlproperty enumeration QtWaylandCompositor::XdgSurfaceV5::windowType - * - * This property holds the window type of the XdgSurfaceV5. - */ - -Qt::WindowType QWaylandXdgSurfaceV5::windowType() const -{ - Q_D(const QWaylandXdgSurfaceV5); - return d->m_windowType; -} - -/*! - * \qmlproperty XdgSurfaceV5 QtWaylandCompositor::XdgSurfaceV5::parentSurface - * - * This property holds the XdgSurfaceV5 parent of this XdgSurfaceV5. - * When a parent surface is set, the parentSurfaceChanged() signal - * is guaranteed to be emitted before setTopLevel() and setTransient(). - * - * \sa QtWaylandCompositor::XdgSurfaceV5::setTopLevel() - * \sa QtWaylandCompositor::XdgSurfaceV5::setTransient() - */ - -/*! - * \property QWaylandXdgSurfaceV5::parentSurface - * - * This property holds the XdgSurfaceV5 parent of this XdgSurfaceV5. - * When a parent surface is set, the parentSurfaceChanged() signal - * is guaranteed to be emitted before setTopLevel() and setTransient(). - * - * \sa QWaylandXdgSurfaceV5::setTopLevel() - * \sa QWaylandXdgSurfaceV5::setTransient() - */ -QWaylandXdgSurfaceV5 *QWaylandXdgSurfaceV5::parentSurface() const -{ - Q_D(const QWaylandXdgSurfaceV5); - return d->m_parentSurface; -} - -/*! - * \qmlproperty string QtWaylandCompositor::XdgSurfaceV5::title - * - * This property holds the title of the XdgSurfaceV5. - */ - -/*! - * \property QWaylandXdgSurfaceV5::title - * - * This property holds the title of the QWaylandXdgSurfaceV5. - */ -QString QWaylandXdgSurfaceV5::title() const -{ - Q_D(const QWaylandXdgSurfaceV5); - return d->m_title; -} - -/*! - * \property QWaylandXdgSurfaceV5::appId - * - * This property holds the app id of the QWaylandXdgSurfaceV5. - */ -QString QWaylandXdgSurfaceV5::appId() const -{ - Q_D(const QWaylandXdgSurfaceV5); - return d->m_appId; -} - -/*! - * \property QWaylandXdgSurfaceV5::windowGeometry - * - * This property holds the window geometry of the QWaylandXdgSurfaceV5. The window - * geometry describes the window's visible bounds from the user's perspective. - * The geometry includes title bars and borders if drawn by the client, but - * excludes drop shadows. It is meant to be used for aligning and tiling - * windows. - */ -QRect QWaylandXdgSurfaceV5::windowGeometry() const -{ - Q_D(const QWaylandXdgSurfaceV5); - return d->m_windowGeometry; -} - -/*! - * \property QWaylandXdgSurfaceV5::states - * - * This property holds the last states the client acknowledged for this QWaylandXdgSurfaceV5. - */ -QVector<uint> QWaylandXdgSurfaceV5::states() const -{ - Q_D(const QWaylandXdgSurfaceV5); - return d->m_lastAckedConfigure.states; -} - -bool QWaylandXdgSurfaceV5::maximized() const -{ - Q_D(const QWaylandXdgSurfaceV5); - return d->m_lastAckedConfigure.states.contains(QWaylandXdgSurfaceV5::State::MaximizedState); -} - -bool QWaylandXdgSurfaceV5::fullscreen() const -{ - Q_D(const QWaylandXdgSurfaceV5); - return d->m_lastAckedConfigure.states.contains(QWaylandXdgSurfaceV5::State::FullscreenState); -} - -bool QWaylandXdgSurfaceV5::resizing() const -{ - Q_D(const QWaylandXdgSurfaceV5); - return d->m_lastAckedConfigure.states.contains(QWaylandXdgSurfaceV5::State::ResizingState); -} - -bool QWaylandXdgSurfaceV5::activated() const -{ - Q_D(const QWaylandXdgSurfaceV5); - return d->m_lastAckedConfigure.states.contains(QWaylandXdgSurfaceV5::State::ActivatedState); -} - -/*! - * Returns the Wayland interface for the QWaylandXdgSurfaceV5. - */ -const wl_interface *QWaylandXdgSurfaceV5::interface() -{ - return QWaylandXdgSurfaceV5Private::interface(); -} - -QByteArray QWaylandXdgSurfaceV5::interfaceName() -{ - return QWaylandXdgSurfaceV5Private::interfaceName(); -} - -/*! - * Returns the surface role for the QWaylandXdgSurfaceV5. - */ -QWaylandSurfaceRole *QWaylandXdgSurfaceV5::role() -{ - return &QWaylandXdgSurfaceV5Private::s_role; -} - -/*! - * Returns the QWaylandXdgSurfaceV5 corresponding to the \a resource. - */ -QWaylandXdgSurfaceV5 *QWaylandXdgSurfaceV5::fromResource(wl_resource *resource) -{ - if (auto p = QtWayland::fromResource<QWaylandXdgSurfaceV5Private *>(resource)) - return p->q_func(); - return nullptr; -} - -QSize QWaylandXdgSurfaceV5::sizeForResize(const QSizeF &size, const QPointF &delta, - QWaylandXdgSurfaceV5::ResizeEdge edge) -{ - qreal width = size.width(); - qreal height = size.height(); - if (edge & LeftEdge) - width -= delta.x(); - else if (edge & RightEdge) - width += delta.x(); - - if (edge & TopEdge) - height -= delta.y(); - else if (edge & BottomEdge) - height += delta.y(); - - QSizeF newSize(qMax(width, 1.0), qMax(height, 1.0)); - return newSize.toSize(); -} - -/*! - * \qmlmethod int QtWaylandCompositor::XdgSurfaceV5::sendConfigure(size size, list<uint> states) - * - * Sends a configure event to the client. \a size contains the pixel size of the surface. - * Known \a states are enumerated in XdgSurfaceV5::State. - */ - -/*! - * Sends a configure event to the client. Parameter \a size contains the pixel size - * of the surface. Known \a states are enumerated in QWaylandXdgSurfaceV5::State. - */ -uint QWaylandXdgSurfaceV5::sendConfigure(const QSize &size, const QVector<uint> &states) -{ - if (!size.isValid()) { - qWarning() << "Can't configure xdg surface (v5) with an invalid size" << size; - return 0; - } - Q_D(QWaylandXdgSurfaceV5); - auto statesBytes = QByteArray::fromRawData((char *)states.data(), states.size() * sizeof(State)); - QWaylandSurface *surface = qobject_cast<QWaylandSurface *>(extensionContainer()); - Q_ASSERT(surface); - QWaylandCompositor *compositor = surface->compositor(); - Q_ASSERT(compositor); - uint32_t serial = compositor->nextSerial(); - d->m_pendingConfigures.append(QWaylandXdgSurfaceV5Private::ConfigureEvent{states, size, serial}); - d->send_configure(size.width(), size.height(), statesBytes, serial); - return serial; -} - -uint QWaylandXdgSurfaceV5::sendConfigure(const QSize &size, const QVector<QWaylandXdgSurfaceV5::State> &states) -{ - QVector<uint> asUints; - asUints.reserve(states.size()); - for (QWaylandXdgSurfaceV5::State state : states) { - asUints << state; - } - return sendConfigure(size, asUints); -} - -/*! - * \qmlmethod void QtWaylandCompositor::XdgSurfaceV5::sendClose() - * - * Sends a close event to the client. - */ - -/*! - * Sends a close event to the client. - */ -void QWaylandXdgSurfaceV5::sendClose() -{ - Q_D(QWaylandXdgSurfaceV5); - d->send_close(); -} - -uint QWaylandXdgSurfaceV5::sendMaximized(const QSize &size) -{ - Q_D(QWaylandXdgSurfaceV5); - QWaylandXdgSurfaceV5Private::ConfigureEvent conf = d->lastSentConfigure(); - - if (!conf.states.contains(QWaylandXdgSurfaceV5::State::MaximizedState)) - conf.states.append(QWaylandXdgSurfaceV5::State::MaximizedState); - conf.states.removeOne(QWaylandXdgSurfaceV5::State::FullscreenState); - conf.states.removeOne(QWaylandXdgSurfaceV5::State::ResizingState); - - return sendConfigure(size, conf.states); -} - -uint QWaylandXdgSurfaceV5::sendUnmaximized(const QSize &size) -{ - Q_D(QWaylandXdgSurfaceV5); - QWaylandXdgSurfaceV5Private::ConfigureEvent conf = d->lastSentConfigure(); - - conf.states.removeOne(QWaylandXdgSurfaceV5::State::MaximizedState); - conf.states.removeOne(QWaylandXdgSurfaceV5::State::FullscreenState); - conf.states.removeOne(QWaylandXdgSurfaceV5::State::ResizingState); - - return sendConfigure(size, conf.states); -} - -uint QWaylandXdgSurfaceV5::sendFullscreen(const QSize &size) -{ - Q_D(QWaylandXdgSurfaceV5); - QWaylandXdgSurfaceV5Private::ConfigureEvent conf = d->lastSentConfigure(); - - if (!conf.states.contains(QWaylandXdgSurfaceV5::State::FullscreenState)) - conf.states.append(QWaylandXdgSurfaceV5::State::FullscreenState); - conf.states.removeOne(QWaylandXdgSurfaceV5::State::MaximizedState); - conf.states.removeOne(QWaylandXdgSurfaceV5::State::ResizingState); - - return sendConfigure(size, conf.states); -} - -uint QWaylandXdgSurfaceV5::sendResizing(const QSize &maxSize) -{ - Q_D(QWaylandXdgSurfaceV5); - QWaylandXdgSurfaceV5Private::ConfigureEvent conf = d->lastSentConfigure(); - - if (!conf.states.contains(QWaylandXdgSurfaceV5::State::ResizingState)) - conf.states.append(QWaylandXdgSurfaceV5::State::ResizingState); - conf.states.removeOne(QWaylandXdgSurfaceV5::State::MaximizedState); - conf.states.removeOne(QWaylandXdgSurfaceV5::State::FullscreenState); - - return sendConfigure(maxSize, conf.states); -} - -#if QT_CONFIG(wayland_compositor_quick) -QWaylandQuickShellIntegration *QWaylandXdgSurfaceV5::createIntegration(QWaylandQuickShellSurfaceItem *item) -{ - return new QtWayland::XdgShellV5Integration(item); -} -#endif - -/*! - * \qmltype XdgPopupV5 - * \inqmlmodule QtWayland.Compositor - * \since 5.8 - * \brief Provides a \c xdg_popup interface that implements popup features for the xdg-shell protocol. - * - * This type is part of the \l{XdgShellV5} extension and provides a way to extend - * the functionality of an existing WaylandSurface for handling popup surfaces created by clients - * using xdg-shell. - * - * It corresponds to the Wayland interface \c xdg_popup for the unstable xdg-shell protocol v5. - * - * \deprecated - */ - -/*! - * \class QWaylandXdgPopupV5 - * \inmodule QtWaylandCompositor - * \since 5.8 - * \brief The QWaylandXdgPopupV5 class provides menus for an xdg surface. - * - * This class is part of the QWaylandXdgShellV5 extension and provides a way to - * extend the functionality of an existing QWaylandSurface with features - * specific to desktop-style menus for an xdg surface. - * - * It corresponds to the Wayland interface xdg_popup. - * - * \deprecated - */ - -/*! - * Constructs a QWaylandXdgPopupV5. - */ -QWaylandXdgPopupV5::QWaylandXdgPopupV5() - : QWaylandShellSurfaceTemplate<QWaylandXdgPopupV5>(*new QWaylandXdgPopupV5Private) -{ -} - -/*! - * Constructs a QWaylandXdgPopupV5, associating it with \a xdgShell at the specified \a position - * for \a surface, and initializes it with the given \a parentSurface and \a resource. - */ -QWaylandXdgPopupV5::QWaylandXdgPopupV5(QWaylandXdgShellV5 *xdgShell, QWaylandSurface *surface, - QWaylandSurface *parentSurface, const QPoint &position, const QWaylandResource &resource) - : QWaylandShellSurfaceTemplate<QWaylandXdgPopupV5>(*new QWaylandXdgPopupV5Private) -{ - initialize(xdgShell, surface, parentSurface, position, resource); -} - -/*! - * \qmlmethod void QtWaylandCompositor::XdgPopupV5::initialize(XdgShellV5 shell, WaylandSurface surface, WaylandSurface parentSurface, point position, WaylandResource resource) - * - * Initializes the xdg popup, associating it with the given \a shell, \a surface, - * \a parentSurface, \a position and \a resource. - */ - -/*! - * Initializes the QWaylandXdgPopupV5, associating it with the given \a shell, \a surface, - * \a parentSurface, \a position, and \a resource. - */ -void QWaylandXdgPopupV5::initialize(QWaylandXdgShellV5 *shell, QWaylandSurface *surface, QWaylandSurface *parentSurface, - const QPoint& position, const QWaylandResource &resource) -{ - Q_D(QWaylandXdgPopupV5); - d->m_surface = surface; - d->m_parentSurface = parentSurface; - d->m_xdgShell = shell; - d->m_position = position; - d->init(resource.resource()); - setExtensionContainer(surface); - emit shellChanged(); - emit surfaceChanged(); - emit parentSurfaceChanged(); - emit positionChanged(); - QWaylandCompositorExtension::initialize(); -} - -/*! - * \qmlproperty XdgShellV5 QtWaylandCompositor::XdgPopupV5::shell - * - * This property holds the shell associated with this XdgPopupV5. - */ - -/*! - * \property QWaylandXdgPopupV5::shell - * - * This property holds the shell associated with this QWaylandXdgPopupV5. - */ -QWaylandXdgShellV5 *QWaylandXdgPopupV5::shell() const -{ - Q_D(const QWaylandXdgPopupV5); - return d->m_xdgShell; -} - -/*! - * \qmlproperty WaylandSurface QtWaylandCompositor::XdgPopupV5::surface - * - * This property holds the surface associated with this XdgPopupV5. - */ - -/*! - * \property QWaylandXdgPopupV5::surface - * - * This property holds the surface associated with this QWaylandXdgPopupV5. - */ -QWaylandSurface *QWaylandXdgPopupV5::surface() const -{ - Q_D(const QWaylandXdgPopupV5); - return d->m_surface; -} - -/*! - * \qmlproperty WaylandSurface QtWaylandCompositor::XdgPopupV5::parentSurface - * - * This property holds the surface associated with the parent of this XdgPopupV5. - */ - -/*! - * \property QWaylandXdgPopupV5::parentSurface - * - * This property holds the surface associated with the parent of this - * QWaylandXdgPopupV5. - */ -QWaylandSurface *QWaylandXdgPopupV5::parentSurface() const -{ - Q_D(const QWaylandXdgPopupV5); - return d->m_parentSurface; -} - - -/*! - * \qmlproperty point QtWaylandCompositor::XdgPopupV5::position - * - * This property holds the location of the upper left corner of the surface - * relative to the upper left corner of the parent surface, in surface local - * coordinates. - */ - -/*! - * \property QWaylandXdgPopupV5::position - * - * This property holds the location of the upper left corner of the surface - * relative to the upper left corner of the parent surface, in surface local - * coordinates. - */ -QPoint QWaylandXdgPopupV5::position() const -{ - Q_D(const QWaylandXdgPopupV5); - return d->m_position; -} - -/*! - * \internal - */ -void QWaylandXdgPopupV5::initialize() -{ - QWaylandCompositorExtension::initialize(); -} - -/*! - * Returns the Wayland interface for the QWaylandXdgPopupV5. - */ -const wl_interface *QWaylandXdgPopupV5::interface() -{ - return QWaylandXdgPopupV5Private::interface(); -} - -QByteArray QWaylandXdgPopupV5::interfaceName() -{ - return QWaylandXdgPopupV5Private::interfaceName(); -} - -/*! - * Returns the surface role for the QWaylandXdgPopupV5. - */ -QWaylandSurfaceRole *QWaylandXdgPopupV5::role() -{ - return &QWaylandXdgPopupV5Private::s_role; -} - -QWaylandXdgPopupV5 *QWaylandXdgPopupV5::fromResource(wl_resource *resource) -{ - if (auto p = QtWayland::fromResource<QWaylandXdgPopupV5Private *>(resource)) - return p->q_func(); - return nullptr; -} - -void QWaylandXdgPopupV5::sendPopupDone() -{ - Q_D(QWaylandXdgPopupV5); - d->send_popup_done(); -} - -#if QT_CONFIG(wayland_compositor_quick) -QWaylandQuickShellIntegration *QWaylandXdgPopupV5::createIntegration(QWaylandQuickShellSurfaceItem *item) -{ - return new QtWayland::XdgPopupV5Integration(item); -} -#endif - -QT_END_NAMESPACE diff --git a/src/compositor/extensions/qwaylandxdgshellv5.h b/src/compositor/extensions/qwaylandxdgshellv5.h deleted file mode 100644 index d0fba5f69..000000000 --- a/src/compositor/extensions/qwaylandxdgshellv5.h +++ /dev/null @@ -1,252 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QWAYLANDXDGSHELLV5_H -#define QWAYLANDXDGSHELLV5_H - -#include <QtWaylandCompositor/QWaylandCompositorExtension> -#include <QtWaylandCompositor/QWaylandResource> -#include <QtWaylandCompositor/QWaylandShell> -#include <QtWaylandCompositor/QWaylandShellSurface> -#include <QtWaylandCompositor/qwaylandquickchildren.h> - -#include <QtCore/QRect> - -struct wl_resource; - -QT_BEGIN_NAMESPACE - -class QWaylandXdgShellV5Private; -class QWaylandXdgSurfaceV5; -class QWaylandXdgSurfaceV5Private; -class QWaylandXdgPopupV5; -class QWaylandXdgPopupV5Private; - -class QWaylandSurface; -class QWaylandSurfaceRole; -class QWaylandSeat; -class QWaylandOutput; -class QWaylandClient; - -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgShellV5 : public QWaylandShellTemplate<QWaylandXdgShellV5> -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QWaylandXdgShellV5) -public: - QWaylandXdgShellV5(); - QWaylandXdgShellV5(QWaylandCompositor *compositor); - - void initialize() override; - QWaylandClient *popupClient() const; - - static const struct wl_interface *interface(); - static QByteArray interfaceName(); - -public Q_SLOTS: - uint ping(QWaylandClient *client); - void closeAllPopups(); - -Q_SIGNALS: - void xdgSurfaceRequested(QWaylandSurface *surface, const QWaylandResource &resource); - void xdgSurfaceCreated(QWaylandXdgSurfaceV5 *xdgSurface); - void xdgPopupCreated(QWaylandXdgPopupV5 *xdgPopup); - void xdgPopupRequested(QWaylandSurface *surface, QWaylandSurface *parent, QWaylandSeat *seat, const QPoint &position, const QWaylandResource &resource); - void pong(uint serial); - -private Q_SLOTS: - void handleSeatChanged(QWaylandSeat *newSeat, QWaylandSeat *oldSeat); - void handleFocusChanged(QWaylandSurface *newSurface, QWaylandSurface *oldSurface); - -}; - -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgSurfaceV5 : public QWaylandShellSurfaceTemplate<QWaylandXdgSurfaceV5> -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QWaylandXdgSurfaceV5) - Q_WAYLAND_COMPOSITOR_DECLARE_QUICK_CHILDREN(QWaylandXdgSurfaceV5) - Q_PROPERTY(QWaylandXdgShellV5 *shell READ shell NOTIFY shellChanged) - Q_PROPERTY(QWaylandSurface *surface READ surface NOTIFY surfaceChanged) - Q_PROPERTY(QWaylandXdgSurfaceV5 *parentSurface READ parentSurface NOTIFY parentSurfaceChanged) - Q_PROPERTY(QString title READ title NOTIFY titleChanged) - Q_PROPERTY(QString appId READ appId NOTIFY appIdChanged) - Q_PROPERTY(QRect windowGeometry READ windowGeometry NOTIFY windowGeometryChanged) - - Q_PROPERTY(QList<int> states READ statesAsInts NOTIFY statesChanged) - Q_PROPERTY(bool maximized READ maximized NOTIFY maximizedChanged) - Q_PROPERTY(bool fullscreen READ fullscreen NOTIFY fullscreenChanged) - Q_PROPERTY(bool resizing READ resizing NOTIFY resizingChanged) - Q_PROPERTY(bool activated READ activated NOTIFY activatedChanged) - -public: - enum State : uint { - MaximizedState = 1, - FullscreenState = 2, - ResizingState = 3, - ActivatedState = 4 - }; - Q_ENUM(State) - - enum ResizeEdge : uint { - NoneEdge = 0, - TopEdge = 1, - BottomEdge = 2, - LeftEdge = 4, - TopLeftEdge = 5, - BottomLeftEdge = 6, - RightEdge = 8, - TopRightEdge = 9, - BottomRightEdge = 10 - }; - Q_ENUM(ResizeEdge) - - QWaylandXdgSurfaceV5(); - QWaylandXdgSurfaceV5(QWaylandXdgShellV5* xdgShell, QWaylandSurface *surface, const QWaylandResource &resource); - - Q_INVOKABLE void initialize(QWaylandXdgShellV5* xdgShell, QWaylandSurface *surface, const QWaylandResource &resource); - - Qt::WindowType windowType() const override; - - QString title() const; - QString appId() const; - QRect windowGeometry() const; - QVector<uint> states() const; - bool maximized() const; - bool fullscreen() const; - bool resizing() const; - bool activated() const; - - QWaylandXdgShellV5 *shell() const; - - QWaylandSurface *surface() const; - QWaylandXdgSurfaceV5 *parentSurface() const; - - static const struct wl_interface *interface(); - static QByteArray interfaceName(); - static QWaylandSurfaceRole *role(); - static QWaylandXdgSurfaceV5 *fromResource(::wl_resource *resource); - - Q_INVOKABLE QSize sizeForResize(const QSizeF &size, const QPointF &delta, ResizeEdge edge); - Q_INVOKABLE uint sendConfigure(const QSize &size, const QVector<uint> &states); - Q_INVOKABLE uint sendConfigure(const QSize &size, const QVector<State> &states); - Q_INVOKABLE void sendClose(); - - Q_INVOKABLE uint sendMaximized(const QSize &size); - Q_INVOKABLE uint sendUnmaximized(const QSize &size = QSize(0, 0)); - Q_INVOKABLE uint sendFullscreen(const QSize &size); - Q_INVOKABLE uint sendResizing(const QSize &maxSize); - -#if QT_CONFIG(wayland_compositor_quick) - QWaylandQuickShellIntegration *createIntegration(QWaylandQuickShellSurfaceItem *item) override; -#endif - -Q_SIGNALS: - void shellChanged(); - void surfaceChanged(); - void titleChanged(); - void windowGeometryChanged(); - void appIdChanged(); - void parentSurfaceChanged(); - - void statesChanged(); - void maximizedChanged(); - void fullscreenChanged(); - void resizingChanged(); - void activatedChanged(); - - void showWindowMenu(QWaylandSeat *seat, const QPoint &localSurfacePosition); - void startMove(QWaylandSeat *seat); - void startResize(QWaylandSeat *seat, ResizeEdge edges); - void setTopLevel(); - void setTransient(); - void setMaximized(); - void unsetMaximized(); - void setFullscreen(QWaylandOutput *output); - void unsetFullscreen(); - void setMinimized(); - void ackConfigure(uint serial); - -private: - void initialize() override; - QList<int> statesAsInts() const; - -private Q_SLOTS: - void handleSurfaceSizeChanged(); - void handleBufferScaleChanged(); -}; - -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgPopupV5 : public QWaylandShellSurfaceTemplate<QWaylandXdgPopupV5> -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QWaylandXdgPopupV5) - Q_WAYLAND_COMPOSITOR_DECLARE_QUICK_CHILDREN(QWaylandXdgPopupV5) - Q_PROPERTY(QWaylandXdgShellV5 *shell READ shell NOTIFY shellChanged) - Q_PROPERTY(QWaylandSurface *surface READ surface NOTIFY surfaceChanged) - Q_PROPERTY(QWaylandSurface *parentSurface READ parentSurface NOTIFY parentSurfaceChanged) - Q_PROPERTY(QPoint position READ position NOTIFY positionChanged) - -public: - QWaylandXdgPopupV5(); - QWaylandXdgPopupV5(QWaylandXdgShellV5 *xdgShell, QWaylandSurface *surface, QWaylandSurface *parentSurface, - const QPoint &position, const QWaylandResource &resource); - - Qt::WindowType windowType() const override { return Qt::WindowType::Popup; } - - Q_INVOKABLE void initialize(QWaylandXdgShellV5 *shell, QWaylandSurface *surface, - QWaylandSurface *parentSurface, const QPoint &position, const QWaylandResource &resource); - - QWaylandXdgShellV5 *shell() const; - - QWaylandSurface *surface() const; - QWaylandSurface *parentSurface() const; - QPoint position() const; - - static const struct wl_interface *interface(); - static QByteArray interfaceName(); - static QWaylandSurfaceRole *role(); - static QWaylandXdgPopupV5 *fromResource(::wl_resource *resource); - - Q_INVOKABLE void sendPopupDone(); - -#if QT_CONFIG(wayland_compositor_quick) - QWaylandQuickShellIntegration *createIntegration(QWaylandQuickShellSurfaceItem *item) override; -#endif - -Q_SIGNALS: - void shellChanged(); - void surfaceChanged(); - void parentSurfaceChanged(); - void positionChanged(); - -private: - void initialize() override; -}; - -QT_END_NAMESPACE - -#endif /*QWAYLANDXDGSHELLV5_H*/ diff --git a/src/compositor/extensions/qwaylandxdgshellv5_p.h b/src/compositor/extensions/qwaylandxdgshellv5_p.h deleted file mode 100644 index 9aaad65b5..000000000 --- a/src/compositor/extensions/qwaylandxdgshellv5_p.h +++ /dev/null @@ -1,173 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QWAYLANDXDGSHELLV5_P_H -#define QWAYLANDXDGSHELLV5_P_H - -#include <QtWaylandCompositor/private/qwaylandcompositorextension_p.h> -#include <QtWaylandCompositor/private/qwaylandshell_p.h> -#include <QtWaylandCompositor/private/qwayland-server-xdg-shell-unstable-v5_p.h> - -#include <QtWaylandCompositor/QWaylandXdgShellV5> - -#include <QtCore/QSet> - -// -// 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 QWaylandXdgShellV5Private - : public QWaylandShellPrivate - , public QtWaylandServer::xdg_shell_v5 -{ - Q_DECLARE_PUBLIC(QWaylandXdgShellV5) -public: - QWaylandXdgShellV5Private(); - void ping(Resource *resource, uint32_t serial); - void registerSurface(QWaylandXdgSurfaceV5 *xdgSurface); - void unregisterXdgSurface(QWaylandXdgSurfaceV5 *xdgSurface); - void registerXdgPopup(QWaylandXdgPopupV5 *xdgPopup); - void unregisterXdgPopup(QWaylandXdgPopupV5 *xdgPopup); - static QWaylandXdgShellV5Private *get(QWaylandXdgShellV5 *xdgShell) { return xdgShell->d_func(); } - bool isValidPopupParent(QWaylandSurface *parentSurface) const; - QWaylandXdgPopupV5 *topmostPopupForClient(struct wl_client* client) const; - - QSet<uint32_t> m_pings; - QMultiMap<struct wl_client *, QWaylandXdgSurfaceV5 *> m_xdgSurfaces; - QMultiMap<struct wl_client *, QWaylandXdgPopupV5 *> m_xdgPopups; - - QWaylandXdgSurfaceV5 *xdgSurfaceFromSurface(QWaylandSurface *surface) const; - -protected: - void xdg_shell_destroy(Resource *resource) override; - void xdg_shell_get_xdg_surface(Resource *resource, uint32_t id, - struct ::wl_resource *surface) override; - void xdg_shell_use_unstable_version(Resource *resource, int32_t version) override; - void xdg_shell_get_xdg_popup(Resource *resource, uint32_t id, struct ::wl_resource *surface, - struct ::wl_resource *parent, struct ::wl_resource *seatResource, - uint32_t serial, int32_t x, int32_t y) override; - void xdg_shell_pong(Resource *resource, uint32_t serial) override; -}; - -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgSurfaceV5Private - : public QWaylandCompositorExtensionPrivate - , public QtWaylandServer::xdg_surface_v5 -{ - Q_DECLARE_PUBLIC(QWaylandXdgSurfaceV5) -public: - QWaylandXdgSurfaceV5Private(); - static QWaylandXdgSurfaceV5Private *get(QWaylandXdgSurfaceV5 *xdgSurface) { return xdgSurface->d_func(); } - - struct ConfigureEvent { - QVector<uint> states; - QSize size; - uint serial; - }; - - void handleFocusLost(); - void handleFocusReceived(); - QRect calculateFallbackWindowGeometry() const; - void updateFallbackWindowGeometry(); - - void setWindowType(Qt::WindowType windowType); - -private: - QWaylandXdgShellV5 *m_xdgShell = nullptr; - QWaylandSurface *m_surface = nullptr; - QWaylandXdgSurfaceV5 *m_parentSurface = nullptr; - - Qt::WindowType m_windowType = Qt::WindowType::Window; - - QString m_title; - QString m_appId; - QRect m_windowGeometry; - bool m_unsetWindowGeometry = true; - - QList<ConfigureEvent> m_pendingConfigures; - ConfigureEvent m_lastAckedConfigure; - ConfigureEvent lastSentConfigure() const { return m_pendingConfigures.empty() ? m_lastAckedConfigure : m_pendingConfigures.first(); } - - void xdg_surface_destroy_resource(Resource *resource) override; - - void xdg_surface_destroy(Resource *resource) override; - void xdg_surface_move(Resource *resource, struct ::wl_resource *seat, - uint32_t serial) override; - void xdg_surface_resize(Resource *resource, struct ::wl_resource *seat, uint32_t serial, - uint32_t edges) override; - void xdg_surface_set_maximized(Resource *resource) override; - void xdg_surface_unset_maximized(Resource *resource) override; - void xdg_surface_set_fullscreen(Resource *resource, - struct ::wl_resource *output) override; - void xdg_surface_unset_fullscreen(Resource *resource) override; - void xdg_surface_set_minimized(Resource *resource) override; - void xdg_surface_set_parent(Resource *resource, struct ::wl_resource *parent) override; - void xdg_surface_set_app_id(Resource *resource, const QString &app_id) override; - void xdg_surface_show_window_menu(Resource *resource, struct ::wl_resource *seatResource, - uint32_t serial, int32_t x, int32_t y) override; - void xdg_surface_ack_configure(Resource *resource, uint32_t serial) override; - void xdg_surface_set_title(Resource *resource, const QString &title) override; - void xdg_surface_set_window_geometry(Resource *resource, int32_t x, int32_t y, - int32_t width, int32_t height) override; - - static QWaylandSurfaceRole s_role; -}; - -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgPopupV5Private - : public QWaylandCompositorExtensionPrivate - , public QtWaylandServer::xdg_popup_v5 -{ - Q_DECLARE_PUBLIC(QWaylandXdgPopupV5) - -public: - QWaylandXdgPopupV5Private(); - static QWaylandXdgPopupV5Private *get(QWaylandXdgPopupV5 *xdgPopup) { return xdgPopup->d_func(); } - - QWaylandSurface *m_surface = nullptr; - QWaylandSurface *m_parentSurface = nullptr; - QWaylandXdgShellV5 *m_xdgShell = nullptr; - QPoint m_position; - - void xdg_popup_destroy_resource(Resource *resource) override; - void xdg_popup_destroy(xdg_popup_v5::Resource *resource) override; - - static QWaylandSurfaceRole s_role; -}; - -QT_END_NAMESPACE - -#endif // QWAYLANDXDGSHELLV5_P_H diff --git a/src/compositor/extensions/qwaylandxdgshellv5integration.cpp b/src/compositor/extensions/qwaylandxdgshellv5integration.cpp deleted file mode 100644 index cbb61d3bd..000000000 --- a/src/compositor/extensions/qwaylandxdgshellv5integration.cpp +++ /dev/null @@ -1,249 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qwaylandxdgshellv5integration_p.h" - -#include <QtWaylandCompositor/QWaylandQuickShellSurfaceItem> -#include <QtWaylandCompositor/QWaylandCompositor> -#include <QtWaylandCompositor/QWaylandSeat> -#include <QtWaylandCompositor/private/qwaylandxdgshellv5_p.h> -#include <QMouseEvent> -#include <QGuiApplication> - -QT_BEGIN_NAMESPACE - -namespace QtWayland { - -static void handlePopupCreated(QWaylandQuickShellSurfaceItem *parentItem, QWaylandXdgPopupV5 *popup) -{ - if (parentItem->surface() == popup->parentSurface()) - QWaylandQuickShellSurfaceItemPrivate::get(parentItem)->maybeCreateAutoPopup(popup); -} - -XdgShellV5Integration::XdgShellV5Integration(QWaylandQuickShellSurfaceItem *item) - : QWaylandQuickShellIntegration(item) - , m_item(item) - , m_xdgSurface(qobject_cast<QWaylandXdgSurfaceV5 *>(item->shellSurface())) - , grabberState(GrabberState::Default) -{ - 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); - connect(m_xdgSurface, &QWaylandXdgSurfaceV5::activatedChanged, this, &XdgShellV5Integration::handleActivatedChanged); - connect(m_xdgSurface->surface(), &QWaylandSurface::destinationSizeChanged, this, &XdgShellV5Integration::handleSurfaceSizeChanged); - connect(m_xdgSurface->shell(), &QWaylandXdgShellV5::xdgPopupCreated, this, [item](QWaylandXdgPopupV5 *popup){ - handlePopupCreated(item, popup); - }); -} - -XdgShellV5Integration::~XdgShellV5Integration() -{ - m_item->setSurface(nullptr); -} - -bool XdgShellV5Integration::eventFilter(QObject *object, QEvent *event) -{ - if (event->type() == QEvent::MouseMove) { - QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event); - return filterMouseMoveEvent(mouseEvent); - } else if (event->type() == QEvent::MouseButtonRelease) { - QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event); - return filterMouseReleaseEvent(mouseEvent); - } - return QWaylandQuickShellIntegration::eventFilter(object, event); -} - -bool XdgShellV5Integration::filterMouseMoveEvent(QMouseEvent *event) -{ - if (grabberState == GrabberState::Resize) { - Q_ASSERT(resizeState.seat == m_item->compositor()->seatFor(event)); - if (!resizeState.initialized) { - resizeState.initialMousePos = event->windowPos(); - resizeState.initialized = true; - return true; - } - QPointF delta = m_item->mapToSurface(event->windowPos() - resizeState.initialMousePos); - QSize newSize = m_xdgSurface->sizeForResize(resizeState.initialWindowSize, delta, resizeState.resizeEdges); - m_xdgSurface->sendResizing(newSize); - } else if (grabberState == GrabberState::Move) { - Q_ASSERT(moveState.seat == m_item->compositor()->seatFor(event)); - QQuickItem *moveItem = m_item->moveItem(); - if (!moveState.initialized) { - moveState.initialOffset = moveItem->mapFromItem(nullptr, event->windowPos()); - moveState.initialized = true; - return true; - } - if (!moveItem->parentItem()) - return true; - QPointF parentPos = moveItem->parentItem()->mapFromItem(nullptr, event->windowPos()); - moveItem->setPosition(parentPos - moveState.initialOffset); - } - return false; -} - -bool XdgShellV5Integration::filterMouseReleaseEvent(QMouseEvent *event) -{ - Q_UNUSED(event); - - if (grabberState == GrabberState::Resize) { - m_xdgSurface->sendUnmaximized(); - grabberState = GrabberState::Default; - return true; - } else if (grabberState == GrabberState::Move) { - grabberState = GrabberState::Default; - return true; - } - return false; -} - -void XdgShellV5Integration::handleStartMove(QWaylandSeat *seat) -{ - grabberState = GrabberState::Move; - moveState.seat = seat; - moveState.initialized = false; -} - -void XdgShellV5Integration::handleStartResize(QWaylandSeat *seat, QWaylandXdgSurfaceV5::ResizeEdge edges) -{ - grabberState = GrabberState::Resize; - resizeState.seat = seat; - resizeState.resizeEdges = edges; - resizeState.initialWindowSize = m_xdgSurface->windowGeometry().size(); - resizeState.initialPosition = m_item->moveItem()->position(); - resizeState.initialSurfaceSize = m_item->surface()->destinationSize(); - 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() -{ - if (!m_item->view()->isPrimary()) - return; - - maximizeState.initialWindowSize = m_xdgSurface->windowGeometry().size(); - maximizeState.initialPosition = m_item->moveItem()->position(); - - QWaylandOutput *output = m_item->view()->output(); - m_xdgSurface->sendMaximized(output->availableGeometry().size() / output->scaleFactor()); -} - -void XdgShellV5Integration::handleUnsetMaximized() -{ - if (!m_item->view()->isPrimary()) - return; - - m_xdgSurface->sendUnmaximized(maximizeState.initialWindowSize); -} - -void XdgShellV5Integration::handleMaximizedChanged() -{ - if (m_xdgSurface->maximized()) { - QWaylandOutput *output = m_item->view()->output(); - m_item->moveItem()->setPosition(output->position() + output->availableGeometry().topLeft()); - } else { - m_item->moveItem()->setPosition(maximizeState.initialPosition); - } -} - -void XdgShellV5Integration::handleActivatedChanged() -{ - if (m_xdgSurface->activated()) - m_item->raise(); -} - -void XdgShellV5Integration::handleSurfaceSizeChanged() -{ - if (grabberState == GrabberState::Resize) { - qreal dx = 0; - qreal dy = 0; - if (resizeState.resizeEdges & QWaylandXdgSurfaceV5::ResizeEdge::TopEdge) - dy = resizeState.initialSurfaceSize.height() - m_item->surface()->destinationSize().height(); - if (resizeState.resizeEdges & QWaylandXdgSurfaceV5::ResizeEdge::LeftEdge) - dx = resizeState.initialSurfaceSize.width() - m_item->surface()->destinationSize().width(); - QPointF offset = m_item->mapFromSurface({dx, dy}); - m_item->moveItem()->setPosition(resizeState.initialPosition + offset); - } -} - -XdgPopupV5Integration::XdgPopupV5Integration(QWaylandQuickShellSurfaceItem *item) - : QWaylandQuickShellIntegration (item) - , m_item(item) - , m_xdgPopup(qobject_cast<QWaylandXdgPopupV5 *>(item->shellSurface())) - , m_xdgShell(QWaylandXdgPopupV5Private::get(m_xdgPopup)->m_xdgShell) -{ - item->setSurface(m_xdgPopup->surface()); - if (item->view()->output()) { - QPoint position = item->mapFromSurface(m_xdgPopup->position()).toPoint(); - item->moveItem()->setPosition(position); - } else { - qWarning() << "XdgPopupV5Integration popup item without output" << item; - } - - QWaylandClient *client = m_xdgPopup->surface()->client(); - auto shell = m_xdgShell; - QWaylandQuickShellEventFilter::startFilter(client, [shell]() { shell->closeAllPopups(); }); - - connect(m_xdgPopup, &QWaylandXdgPopupV5::destroyed, this, &XdgPopupV5Integration::handlePopupDestroyed); - connect(m_xdgPopup->shell(), &QWaylandXdgShellV5::xdgPopupCreated, this, [item](QWaylandXdgPopupV5 *popup) { - handlePopupCreated(item, popup); - }); -} - -XdgPopupV5Integration::~XdgPopupV5Integration() -{ - m_item->setSurface(nullptr); -} - -void XdgPopupV5Integration::handlePopupDestroyed() -{ - QWaylandXdgShellV5Private *shellPrivate = QWaylandXdgShellV5Private::get(m_xdgShell); - auto popups = shellPrivate->m_xdgPopups; - if (popups.isEmpty()) - QWaylandQuickShellEventFilter::cancelFilter(); -} - -} - -QT_END_NAMESPACE diff --git a/src/compositor/extensions/qwaylandxdgshellv5integration_p.h b/src/compositor/extensions/qwaylandxdgshellv5integration_p.h deleted file mode 100644 index ea4477ba0..000000000 --- a/src/compositor/extensions/qwaylandxdgshellv5integration_p.h +++ /dev/null @@ -1,127 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QWAYLANDXDGSHELLV5INTEGRATION_H -#define QWAYLANDXDGSHELLV5INTEGRATION_H - -#include <QtWaylandCompositor/private/qwaylandquickshellsurfaceitem_p.h> -#include <QtWaylandCompositor/QWaylandXdgSurfaceV5> - -QT_BEGIN_NAMESPACE - -// -// 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. -// - -namespace QtWayland { - -class XdgShellV5Integration : public QWaylandQuickShellIntegration -{ - Q_OBJECT -public: - XdgShellV5Integration(QWaylandQuickShellSurfaceItem *item); - ~XdgShellV5Integration() override; - -protected: - bool eventFilter(QObject *object, QEvent *event) override; - -private Q_SLOTS: - void handleStartMove(QWaylandSeat *seat); - void handleStartResize(QWaylandSeat *seat, QWaylandXdgSurfaceV5::ResizeEdge edges); - void handleSetTopLevel(); - void handleSetTransient(); - void handleSetMaximized(); - void handleUnsetMaximized(); - void handleMaximizedChanged(); - void handleActivatedChanged(); - void handleSurfaceSizeChanged(); - -private: - enum class GrabberState { - Default, - Resize, - Move - }; - QWaylandQuickShellSurfaceItem *m_item = nullptr; - QWaylandXdgSurfaceV5 *m_xdgSurface = nullptr; - - GrabberState grabberState; - struct { - QWaylandSeat *seat = nullptr; - QPointF initialOffset; - bool initialized = false; - } moveState; - - struct { - QWaylandSeat *seat = nullptr; - QWaylandXdgSurfaceV5::ResizeEdge resizeEdges; - QSizeF initialWindowSize; - QPointF initialMousePos; - QPointF initialPosition; - QSize initialSurfaceSize; - bool initialized = false; - } resizeState; - - struct { - QSize initialWindowSize; - QPointF initialPosition; - } maximizeState; - - bool filterMouseMoveEvent(QMouseEvent *event); - bool filterMouseReleaseEvent(QMouseEvent *event); -}; - -class XdgPopupV5Integration : public QWaylandQuickShellIntegration -{ - Q_OBJECT -public: - XdgPopupV5Integration(QWaylandQuickShellSurfaceItem *item); - ~XdgPopupV5Integration() override; - -private Q_SLOTS: - void handlePopupDestroyed(); - -private: - QWaylandQuickShellSurfaceItem *m_item = nullptr; - QWaylandXdgPopupV5 *m_xdgPopup = nullptr; - QWaylandXdgShellV5 *m_xdgShell = nullptr; -}; - -} - -QT_END_NAMESPACE - -#endif // QWAYLANDXDGSHELLV5INTEGRATION_H diff --git a/src/compositor/extensions/qwaylandxdgshellv6.cpp b/src/compositor/extensions/qwaylandxdgshellv6.cpp deleted file mode 100644 index 934dccb06..000000000 --- a/src/compositor/extensions/qwaylandxdgshellv6.cpp +++ /dev/null @@ -1,2033 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** 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 "qwaylandxdgshellv6.h" -#include "qwaylandxdgshellv6_p.h" - -#if QT_CONFIG(wayland_compositor_quick) -#include "qwaylandxdgshellv6integration_p.h" -#endif -#include <QtWaylandCompositor/private/qwaylandutils_p.h> - -#include <QtWaylandCompositor/QWaylandCompositor> -#include <QtWaylandCompositor/QWaylandSeat> -#include <QtWaylandCompositor/QWaylandSurface> -#include <QtWaylandCompositor/QWaylandSurfaceRole> -#include <QtWaylandCompositor/QWaylandResource> - -#include <QtCore/QObject> - -#include <algorithm> - -QT_BEGIN_NAMESPACE - -QWaylandXdgShellV6Private::QWaylandXdgShellV6Private() -{ -} - -void QWaylandXdgShellV6Private::ping(QtWaylandServer::zxdg_shell_v6::Resource *resource, uint32_t serial) -{ - m_pings.insert(serial); - send_ping(resource->handle, serial); -} - -void QWaylandXdgShellV6Private::registerXdgSurface(QWaylandXdgSurfaceV6 *xdgSurface) -{ - m_xdgSurfaces.insert(xdgSurface->surface()->client()->client(), xdgSurface); -} - -void QWaylandXdgShellV6Private::unregisterXdgSurface(QWaylandXdgSurfaceV6 *xdgSurface) -{ - auto xdgSurfacePrivate = QWaylandXdgSurfaceV6Private::get(xdgSurface); - if (!m_xdgSurfaces.remove(xdgSurfacePrivate->resource()->client(), xdgSurface)) - qWarning("%s Unexpected state. Can't find registered xdg surface\n", Q_FUNC_INFO); -} - -Qt::Edges QWaylandXdgShellV6Private::convertToEdges(uint xdgEdges) -{ - return Qt::Edges(((xdgEdges & 0b1100) >> 1) | ((xdgEdges & 0b0010) << 2) | (xdgEdges & 0b0001)); -} - -QWaylandXdgSurfaceV6 *QWaylandXdgShellV6Private::xdgSurfaceFromSurface(QWaylandSurface *surface) -{ - for (QWaylandXdgSurfaceV6 *xdgSurface : qAsConst(m_xdgSurfaces)) { - if (surface == xdgSurface->surface()) - return xdgSurface; - } - return nullptr; -} - -void QWaylandXdgShellV6Private::zxdg_shell_v6_destroy(Resource *resource) -{ - if (!m_xdgSurfaces.values(resource->client()).empty()) - wl_resource_post_error(resource->handle, ZXDG_SHELL_V6_ERROR_DEFUNCT_SURFACES, - "xdg_shell was destroyed before children"); - - wl_resource_destroy(resource->handle); -} - -void QWaylandXdgShellV6Private::zxdg_shell_v6_create_positioner(QtWaylandServer::zxdg_shell_v6::Resource *resource, uint32_t id) -{ - QWaylandResource positionerResource(wl_resource_create(resource->client(), &zxdg_positioner_v6_interface, - wl_resource_get_version(resource->handle), id)); - - new QWaylandXdgPositionerV6(positionerResource); -} - -void QWaylandXdgShellV6Private::zxdg_shell_v6_get_xdg_surface(Resource *resource, uint32_t id, wl_resource *surfaceResource) -{ - Q_Q(QWaylandXdgShellV6); - QWaylandSurface *surface = QWaylandSurface::fromResource(surfaceResource); - - if (surface->role() != nullptr) { - wl_resource_post_error(resource->handle, ZXDG_SHELL_V6_ERROR_ROLE, - "wl_surface@%d, already has role %s\n", - wl_resource_get_id(surface->resource()), - surface->role()->name().constData()); - return; - } - - if (surface->hasContent()) { - //TODO: According to the spec, this is a client error, but there's no appropriate error code - qWarning() << "get_xdg_surface requested on a zxdg_surface_v6 with content"; - } - - QWaylandResource xdgSurfaceResource(wl_resource_create(resource->client(), &zxdg_surface_v6_interface, - wl_resource_get_version(resource->handle), id)); - - QWaylandXdgSurfaceV6 *xdgSurface = new QWaylandXdgSurfaceV6(q, surface, xdgSurfaceResource); - - registerXdgSurface(xdgSurface); - emit q->xdgSurfaceCreated(xdgSurface); -} - -void QWaylandXdgShellV6Private::zxdg_shell_v6_pong(Resource *resource, uint32_t serial) -{ - Q_UNUSED(resource); - Q_Q(QWaylandXdgShellV6); - if (m_pings.remove(serial)) - emit q->pong(serial); - else - qWarning("Received an unexpected pong!"); -} - -/*! - * \qmltype XdgShellV6 - * \inqmlmodule QtWayland.Compositor - * \since 5.10 - * \brief Provides an extension for desktop-style user interfaces. - * - * The XdgShellV6 extension provides a way to associate a XdgToplevelV6 or XdgPopupV6 - * with a regular Wayland surface. Using the XdgToplevelV6 interface, the client - * can request that the surface is resized, moved, and so on. - * - * XdgShellV6 corresponds to the Wayland interface, \c zxdg_shell_v6. - * - * To provide the functionality of the shell extension in a compositor, create - * an instance of the XdgShellV6 component and add it to the list of extensions - * supported by the compositor: - * - * \qml \QtMinorVersion - * import QtWayland.Compositor 1.\1 - * - * WaylandCompositor { - * XdgShellV6 { - * // ... - * } - * } - * \endqml - */ - -/*! - * \class QWaylandXdgShellV6 - * \inmodule QtWaylandCompositor - * \since 5.10 - * \brief The QWaylandXdgShellV6 class is an extension for desktop-style user interfaces. - * - * The QWaylandXdgShellV6 extension provides a way to associate a QWaylandXdgToplevelV6 or - * QWaylandXdgPopupV6 with a regular Wayland surface. Using the QWaylandXdgToplevelV6 interface, - * the client can request that the surface is resized, moved, and so on. - * - * QWaylandXdgShellV6 corresponds to the Wayland interface, \c zxdg_shell_v6. - */ - -/*! - * Constructs a QWaylandXdgShellV6 object. - */ -QWaylandXdgShellV6::QWaylandXdgShellV6() - : QWaylandShellTemplate<QWaylandXdgShellV6>(*new QWaylandXdgShellV6Private()) -{ -} - -/*! - * Constructs a QWaylandXdgShellV6 object for the provided \a compositor. - */ -QWaylandXdgShellV6::QWaylandXdgShellV6(QWaylandCompositor *compositor) - : QWaylandShellTemplate<QWaylandXdgShellV6>(compositor, *new QWaylandXdgShellV6Private()) -{ -} - -/*! - * Initializes the shell extension. - */ -void QWaylandXdgShellV6::initialize() -{ - Q_D(QWaylandXdgShellV6); - QWaylandShellTemplate::initialize(); - QWaylandCompositor *compositor = static_cast<QWaylandCompositor *>(extensionContainer()); - if (!compositor) { - qWarning() << "Failed to find QWaylandCompositor when initializing QWaylandXdgShellV6"; - return; - } - d->init(compositor->display(), 1); - - handleSeatChanged(compositor->defaultSeat(), nullptr); - - connect(compositor, &QWaylandCompositor::defaultSeatChanged, - this, &QWaylandXdgShellV6::handleSeatChanged); -} - -/*! - * Returns the Wayland interface for the QWaylandXdgShellV6. - */ -const struct wl_interface *QWaylandXdgShellV6::interface() -{ - return QWaylandXdgShellV6Private::interface(); -} - -QByteArray QWaylandXdgShellV6::interfaceName() -{ - return QWaylandXdgShellV6Private::interfaceName(); -} - -/*! - * \qmlmethod void QtWaylandCompositor::XdgShellV6::ping(WaylandClient client) - * - * Sends a ping event to \a client. If the client replies to the event the - * \l pong signal will be emitted. - */ - -/*! - * Sends a ping event to \a client. If the client replies to the event the - * \l pong signal will be emitted. - */ -uint QWaylandXdgShellV6::ping(QWaylandClient *client) -{ - Q_D(QWaylandXdgShellV6); - - QWaylandCompositor *compositor = static_cast<QWaylandCompositor *>(extensionContainer()); - Q_ASSERT(compositor); - - uint32_t serial = compositor->nextSerial(); - - QWaylandXdgShellV6Private::Resource *clientResource = d->resourceMap().value(client->client(), nullptr); - Q_ASSERT(clientResource); - - d->ping(clientResource, serial); - return serial; -} - -void QWaylandXdgShellV6::handleSeatChanged(QWaylandSeat *newSeat, QWaylandSeat *oldSeat) -{ - if (oldSeat != nullptr) { - disconnect(oldSeat, &QWaylandSeat::keyboardFocusChanged, - this, &QWaylandXdgShellV6::handleFocusChanged); - } - - if (newSeat != nullptr) { - connect(newSeat, &QWaylandSeat::keyboardFocusChanged, - this, &QWaylandXdgShellV6::handleFocusChanged); - } -} - -void QWaylandXdgShellV6::handleFocusChanged(QWaylandSurface *newSurface, QWaylandSurface *oldSurface) -{ - Q_D(QWaylandXdgShellV6); - - QWaylandXdgSurfaceV6 *newXdgSurface = d->xdgSurfaceFromSurface(newSurface); - QWaylandXdgSurfaceV6 *oldXdgSurface = d->xdgSurfaceFromSurface(oldSurface); - - if (newXdgSurface) - QWaylandXdgSurfaceV6Private::get(newXdgSurface)->handleFocusReceived(); - - if (oldXdgSurface) - QWaylandXdgSurfaceV6Private::get(oldXdgSurface)->handleFocusLost(); -} - -QWaylandXdgSurfaceV6Private::QWaylandXdgSurfaceV6Private() -{ -} - -void QWaylandXdgSurfaceV6Private::setWindowType(Qt::WindowType windowType) -{ - if (m_windowType == windowType) - return; - - m_windowType = windowType; - - Q_Q(QWaylandXdgSurfaceV6); - emit q->windowTypeChanged(); -} - -void QWaylandXdgSurfaceV6Private::handleFocusLost() -{ - if (m_toplevel) - QWaylandXdgToplevelV6Private::get(m_toplevel)->handleFocusLost(); -} - -void QWaylandXdgSurfaceV6Private::handleFocusReceived() -{ - if (m_toplevel) - QWaylandXdgToplevelV6Private::get(m_toplevel)->handleFocusReceived(); -} - -QRect QWaylandXdgSurfaceV6Private::calculateFallbackWindowGeometry() const -{ - // TODO: The unset window geometry should include subsurfaces as well, so this solution - // won't work too well on those kinds of clients. - return QRect(QPoint(), m_surface->destinationSize()); -} - -void QWaylandXdgSurfaceV6Private::updateFallbackWindowGeometry() -{ - Q_Q(QWaylandXdgSurfaceV6); - if (!m_unsetWindowGeometry) - return; - - const QRect unsetGeometry = calculateFallbackWindowGeometry(); - if (unsetGeometry == m_windowGeometry) - return; - - m_windowGeometry = unsetGeometry; - emit q->windowGeometryChanged(); -} - -void QWaylandXdgSurfaceV6Private::zxdg_surface_v6_destroy_resource(QtWaylandServer::zxdg_surface_v6::Resource *resource) -{ - Q_UNUSED(resource); - Q_Q(QWaylandXdgSurfaceV6); - QWaylandXdgShellV6Private::get(m_xdgShell)->unregisterXdgSurface(q); - delete q; -} - -void QWaylandXdgSurfaceV6Private::zxdg_surface_v6_destroy(QtWaylandServer::zxdg_surface_v6::Resource *resource) -{ - wl_resource_destroy(resource->handle); -} - -void QWaylandXdgSurfaceV6Private::zxdg_surface_v6_get_toplevel(QtWaylandServer::zxdg_surface_v6::Resource *resource, uint32_t id) -{ - Q_Q(QWaylandXdgSurfaceV6); - - if (m_toplevel || m_popup) { - wl_resource_post_error(resource->handle, ZXDG_SURFACE_V6_ERROR_ALREADY_CONSTRUCTED, - "zxdg_surface_v6 already has a role object"); - return; - } - - if (!m_surface->setRole(QWaylandXdgToplevelV6::role(), resource->handle, ZXDG_SHELL_V6_ERROR_ROLE)) - return; - - QWaylandResource topLevelResource(wl_resource_create(resource->client(), &zxdg_toplevel_v6_interface, - wl_resource_get_version(resource->handle), id)); - - m_toplevel = new QWaylandXdgToplevelV6(q, topLevelResource); - emit q->toplevelCreated(); - emit m_xdgShell->toplevelCreated(m_toplevel, q); -} - -void QWaylandXdgSurfaceV6Private::zxdg_surface_v6_get_popup(QtWaylandServer::zxdg_surface_v6::Resource *resource, uint32_t id, wl_resource *parentResource, wl_resource *positionerResource) -{ - Q_Q(QWaylandXdgSurfaceV6); - - if (m_toplevel || m_popup) { - wl_resource_post_error(resource->handle, ZXDG_SURFACE_V6_ERROR_ALREADY_CONSTRUCTED, - "zxdg_surface_v6 already has a role object"); - return; - } - - QWaylandXdgSurfaceV6 *parent = QWaylandXdgSurfaceV6::fromResource(parentResource); - if (!parent) { - wl_resource_post_error(resource->handle, ZXDG_SHELL_V6_ERROR_INVALID_POPUP_PARENT, - "zxdg_surface_v6.get_popup with invalid popup parent"); - return; - } - - QWaylandXdgPositionerV6 *positioner = QWaylandXdgPositionerV6::fromResource(positionerResource); - if (!positioner) { - wl_resource_post_error(resource->handle, ZXDG_SHELL_V6_ERROR_INVALID_POSITIONER, - "zxdg_surface_v6.get_popup without positioner"); - return; - } - - if (!positioner->m_data.isComplete()) { - QWaylandXdgPositionerV6Data p = positioner->m_data; - wl_resource_post_error(resource->handle, ZXDG_SHELL_V6_ERROR_INVALID_POSITIONER, - "zxdg_surface_v6.get_popup with invalid positioner (size: %dx%d, anchorRect: %dx%d)", - p.size.width(), p.size.height(), p.anchorRect.width(), p.anchorRect.height()); - return; - } - - QRect anchorBounds(QPoint(0, 0), parent->windowGeometry().size()); - if (!anchorBounds.contains(positioner->m_data.anchorRect)) { - // TODO: this is a protocol error and should ideally be handled like this: - //wl_resource_post_error(resource->handle, ZXDG_SHELL_V6_ERROR_INVALID_POSITIONER, - // "zxdg_positioner_v6 anchor rect extends beyound its parent's window geometry"); - //return; - // However, our own clients currently do this, so we'll settle for a gentle warning instead. - qCWarning(qLcWaylandCompositor) << "Ignoring client protocol error: zxdg_positioner_v6 anchor" - << "rect extends beyond its parent's window geometry"; - } - - if (!m_surface->setRole(QWaylandXdgPopupV6::role(), resource->handle, ZXDG_SHELL_V6_ERROR_ROLE)) - return; - - QWaylandResource popupResource(wl_resource_create(resource->client(), &zxdg_popup_v6_interface, - wl_resource_get_version(resource->handle), id)); - - m_popup = new QWaylandXdgPopupV6(q, parent, positioner, popupResource); - emit q->popupCreated(); - emit m_xdgShell->popupCreated(m_popup, q); -} - -void QWaylandXdgSurfaceV6Private::zxdg_surface_v6_ack_configure(QtWaylandServer::zxdg_surface_v6::Resource *resource, uint32_t serial) -{ - if (m_toplevel) { - QWaylandXdgToplevelV6Private::get(m_toplevel)->handleAckConfigure(serial); - } else if (m_popup) { - QWaylandXdgPopupV6Private::get(m_popup)->handleAckConfigure(serial); - } else { - wl_resource_post_error(resource->handle, ZXDG_SURFACE_V6_ERROR_NOT_CONSTRUCTED, - "ack_configure requested on an unconstructed zxdg_surface_v6"); - } -} - -void QWaylandXdgSurfaceV6Private::zxdg_surface_v6_set_window_geometry(QtWaylandServer::zxdg_surface_v6::Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) -{ - Q_Q(QWaylandXdgSurfaceV6); - - if (!q->surface()->role()) { - wl_resource_post_error(resource->handle, ZXDG_SURFACE_V6_ERROR_NOT_CONSTRUCTED, - "set_window_geometry requested on an unconstructed zxdg_surface_v6"); - return; - } - - if (width <= 0 || height <= 0) { - // The protocol spec says "setting an invalid size will raise an error". But doesn't tell - // which error to raise, and there's no fitting error in the zxdg_surface_v6_error enum. - // So until this is fixed, just output a warning and return. - qWarning() << "Invalid (non-positive) dimensions received in set_window_geometry"; - return; - } - - m_unsetWindowGeometry = false; - - QRect geometry(x, y, width, height); - - if (m_windowGeometry == geometry) - return; - - m_windowGeometry = geometry; - emit q->windowGeometryChanged(); -} - -/*! - * \qmltype XdgSurfaceV6 - * \inqmlmodule QtWayland.Compositor - * \since 5.10 - * \brief XdgSurfaceV6 provides desktop-style compositor-specific features to an xdg surface. - * - * This type is part of the \l{XdgShellV6} extension and provides a way to - * extend the functionality of an existing \l{WaylandSurface} with features - * specific to desktop-style compositors, such as resizing and moving the - * surface. - * - * It corresponds to the Wayland interface \c zxdg_surface_v6. - */ - -/*! - * \class QWaylandXdgSurfaceV6 - * \inmodule QtWaylandCompositor - * \since 5.10 - * \brief The QWaylandXdgSurfaceV6 class provides desktop-style compositor-specific features to an xdg surface. - * - * This class is part of the QWaylandXdgShellV6 extension and provides a way to - * extend the functionality of an existing QWaylandSurface with features - * specific to desktop-style compositors, such as resizing and moving the - * surface. - * - * It corresponds to the Wayland interface \c zxdg_surface_v6. - */ - -/*! - * Constructs a QWaylandXdgSurfaceV6. - */ -QWaylandXdgSurfaceV6::QWaylandXdgSurfaceV6() - : QWaylandShellSurfaceTemplate<QWaylandXdgSurfaceV6>(*new QWaylandXdgSurfaceV6Private) -{ -} - -/*! - * Constructs a QWaylandXdgSurfaceV6 for \a surface and initializes it with the - * given \a xdgShell, \a surface, and resource \a res. - */ -QWaylandXdgSurfaceV6::QWaylandXdgSurfaceV6(QWaylandXdgShellV6 *xdgShell, QWaylandSurface *surface, const QWaylandResource &res) - : QWaylandShellSurfaceTemplate<QWaylandXdgSurfaceV6>(*new QWaylandXdgSurfaceV6Private) -{ - initialize(xdgShell, surface, res); -} - -/*! - * \qmlmethod void QtWaylandCompositor::XdgSurfaceV6::initialize(object xdgShell, object surface, object client, int id) - * - * Initializes the XdgSurface, associating it with the given \a xdgShell, \a surface, - * \a client, and \a id. - */ - -/*! - * Initializes the QWaylandXdgSurfaceV6, associating it with the given \a xdgShell, \a surface - * and \a resource. - */ -void QWaylandXdgSurfaceV6::initialize(QWaylandXdgShellV6 *xdgShell, QWaylandSurface *surface, const QWaylandResource &resource) -{ - Q_D(QWaylandXdgSurfaceV6); - d->m_xdgShell = xdgShell; - d->m_surface = surface; - d->init(resource.resource()); - setExtensionContainer(surface); - d->m_windowGeometry = d->calculateFallbackWindowGeometry(); - connect(surface, &QWaylandSurface::destinationSizeChanged, this, &QWaylandXdgSurfaceV6::handleSurfaceSizeChanged); - connect(surface, &QWaylandSurface::bufferScaleChanged, this, &QWaylandXdgSurfaceV6::handleBufferScaleChanged); - emit shellChanged(); - emit surfaceChanged(); - QWaylandCompositorExtension::initialize(); -} - -/*! - * \qmlproperty enum QtWaylandCompositor::XdgSurfaceV6::windowType - * - * This property holds the window type of the XdgSurfaceV6. - */ -Qt::WindowType QWaylandXdgSurfaceV6::windowType() const -{ - Q_D(const QWaylandXdgSurfaceV6); - return d->m_windowType; -} - -/*! - * \qmlproperty rect QtWaylandCompositor::XdgSurfaceV6::windowGeometry - * - * This property holds the window geometry of the QWaylandXdgSurfaceV6. The window - * geometry describes the window's visible bounds from the user's perspective. - * The geometry includes title bars and borders if drawn by the client, but - * excludes drop shadows. It is meant to be used for aligning and tiling - * windows. - */ - -/*! - * \property QWaylandXdgSurfaceV6::windowGeometry - * - * This property holds the window geometry of the QWaylandXdgSurfaceV6. The window - * geometry describes the window's visible bounds from the user's perspective. - * The geometry includes title bars and borders if drawn by the client, but - * excludes drop shadows. It is meant to be used for aligning and tiling - * windows. - */ -QRect QWaylandXdgSurfaceV6::windowGeometry() const -{ - Q_D(const QWaylandXdgSurfaceV6); - return d->m_windowGeometry; -} - -/*! - * \internal - */ -void QWaylandXdgSurfaceV6::initialize() -{ - QWaylandCompositorExtension::initialize(); -} - -void QWaylandXdgSurfaceV6::handleSurfaceSizeChanged() -{ - Q_D(QWaylandXdgSurfaceV6); - d->updateFallbackWindowGeometry(); -} - -void QWaylandXdgSurfaceV6::handleBufferScaleChanged() -{ - Q_D(QWaylandXdgSurfaceV6); - d->updateFallbackWindowGeometry(); -} - -/*! - * \qmlproperty XdgShellV6 QtWaylandCompositor::XdgSurfaceV6::shell - * - * This property holds the shell associated with this XdgSurface. - */ - -/*! - * \property QWaylandXdgSurfaceV6::shell - * - * This property holds the shell associated with this QWaylandXdgSurfaceV6. - */ -QWaylandXdgShellV6 *QWaylandXdgSurfaceV6::shell() const -{ - Q_D(const QWaylandXdgSurfaceV6); - return d->m_xdgShell; -} - -/*! - * \qmlproperty WaylandSurface QtWaylandCompositor::XdgSurfaceV6::surface - * - * This property holds the surface associated with this XdgSurfaceV6. - */ - -/*! - * \property QWaylandXdgSurfaceV6::surface - * - * This property holds the surface associated with this QWaylandXdgSurfaceV6. - */ -QWaylandSurface *QWaylandXdgSurfaceV6::surface() const -{ - Q_D(const QWaylandXdgSurfaceV6); - return d->m_surface; -} - -/*! - * \qmlproperty XdgToplevelV6 QtWaylandCompositor::XdgSurfaceV6::toplevel - * - * This property holds the properties and methods that are specific to the - * toplevel XdgSurfaceV6. - * - * \sa popup, XdgShellV6::toplevelCreated - */ - -/*! - * \property QWaylandXdgSurfaceV6::toplevel - * - * This property holds the properties and methods that are specific to the - * toplevel QWaylandXdgSurfaceV6. - * - * \sa QWaylandXdgSurfaceV6::popup, QWaylandXdgShellV6::toplevelCreated - */ -QWaylandXdgToplevelV6 *QWaylandXdgSurfaceV6::toplevel() const -{ - Q_D(const QWaylandXdgSurfaceV6); - return d->m_toplevel; -} - -/*! - * \qmlproperty XdgPopupV6 QtWaylandCompositor::XdgSurfaceV6::popup - * - * This property holds the properties and methods that are specific to the - * popup XdgSurfaceV6. - * - * \sa toplevel, XdgShellV6::popupCreated - */ - -/*! - * \property QWaylandXdgSurfaceV6::popup - * - * This property holds the properties and methods that are specific to the - * popup QWaylandXdgSurfaceV6. - * - * \sa QWaylandXdgSurfaceV6::toplevel, QWaylandXdgShellV6::popupCreated - */ -QWaylandXdgPopupV6 *QWaylandXdgSurfaceV6::popup() const -{ - Q_D(const QWaylandXdgSurfaceV6); - return d->m_popup; -} - -/*! - * Returns the Wayland interface for the QWaylandXdgSurfaceV6. - */ -const wl_interface *QWaylandXdgSurfaceV6::interface() -{ - return QWaylandXdgSurfaceV6Private::interface(); -} - -/*! - * \internal - */ -QByteArray QWaylandXdgSurfaceV6::interfaceName() -{ - return QWaylandXdgSurfaceV6Private::interfaceName(); -} - -/*! - * Returns the QWaylandXdgSurfaceV6 corresponding to the \a resource. - */ -QWaylandXdgSurfaceV6 *QWaylandXdgSurfaceV6::fromResource(wl_resource *resource) -{ - if (auto p = QtWayland::fromResource<QWaylandXdgSurfaceV6Private *>(resource)) - return p->q_func(); - return nullptr; -} - -#if QT_CONFIG(wayland_compositor_quick) -QWaylandQuickShellIntegration *QWaylandXdgSurfaceV6::createIntegration(QWaylandQuickShellSurfaceItem *item) -{ - Q_D(const QWaylandXdgSurfaceV6); - - if (d->m_toplevel) - return new QtWayland::XdgToplevelV6Integration(item); - - if (d->m_popup) - return new QtWayland::XdgPopupV6Integration(item); - - return nullptr; -} -#endif - -/*! - * \qmltype XdgToplevelV6 - * \inqmlmodule QtWayland.Compositor - * \since 5.10 - * \brief XdgToplevelV6 represents the toplevel window specific parts of an xdg surface. - * - * This type is part of the \l{XdgShellV6} extension and provides a way to - * extend the functionality of an XdgSurfaceV6 with features - * specific to desktop-style windows. - * - * It corresponds to the Wayland interface \c zxdg_toplevel_v6. - */ - -/*! - * \class QWaylandXdgToplevelV6 - * \inmodule QtWaylandCompositor - * \since 5.10 - * \brief The QWaylandXdgToplevelV6 class represents the toplevel window specific parts of an xdg surface. - * - * This class is part of the QWaylandXdgShellV6 extension and provides a way to - * extend the functionality of an QWaylandXdgSurfaceV6 with features - * specific to desktop-style windows. - * - * It corresponds to the Wayland interface \c zxdg_toplevel_v6. - */ - -/*! - * Constructs a QWaylandXdgToplevelV6 for the given \a xdgSurface and \a resource. - */ -QWaylandXdgToplevelV6::QWaylandXdgToplevelV6(QWaylandXdgSurfaceV6 *xdgSurface, QWaylandResource &resource) - : QObject(*new QWaylandXdgToplevelV6Private(xdgSurface, resource)) -{ - QVector<QWaylandXdgToplevelV6::State> states; - sendConfigure({0, 0}, states); -} - -/*! - * \qmlproperty XdgToplevelV6 QtWaylandCompositor::XdgToplevelV6::parentToplevel - * - * This property holds the XdgToplevelV6 parent of this XdgToplevelV6. - */ - -/*! - * \property QWaylandXdgToplevelV6::parentToplevel - * - * This property holds the XdgToplevelV6 parent of this XdgToplevelV6. - * - */ -QWaylandXdgToplevelV6 *QWaylandXdgToplevelV6::parentToplevel() const -{ - Q_D(const QWaylandXdgToplevelV6); - return d->m_parentToplevel; -} - -/*! - * \qmlproperty string QtWaylandCompositor::XdgToplevelV6::title - * - * This property holds the title of the XdgToplevelV6. - */ - -/*! - * \property QWaylandXdgToplevelV6::title - * - * This property holds the title of the QWaylandXdgToplevelV6. - */ -QString QWaylandXdgToplevelV6::title() const -{ - Q_D(const QWaylandXdgToplevelV6); - return d->m_title; -} - -/*! - * \qmlproperty string QtWaylandCompositor::XdgToplevelV6::appId - * - * This property holds the app id of the XdgToplevelV6. - */ - -/*! - * \property QWaylandXdgToplevelV6::appId - * - * This property holds the app id of the QWaylandXdgToplevelV6. - */ -QString QWaylandXdgToplevelV6::appId() const -{ - Q_D(const QWaylandXdgToplevelV6); - return d->m_appId; -} - -/*! - * \qmlproperty size QtWaylandCompositor::XdgToplevelV6::maxSize - * - * This property holds the maximum size of the XdgToplevelV6 as requested by the client. - * - * The compositor is free to ignore this value and request a larger size. - */ - -/*! - * \property QWaylandXdgToplevelV6::maxSize - * - * This property holds the maximum size of the QWaylandXdgToplevelV6. - * - * The compositor is free to ignore this value and request a larger size. - */ -QSize QWaylandXdgToplevelV6::maxSize() const -{ - Q_D(const QWaylandXdgToplevelV6); - return d->m_maxSize; -} - -/*! - * \qmlproperty size QtWaylandCompositor::XdgToplevelV6::minSize - * - * This property holds the minimum size of the XdgToplevelV6 as requested by the client. - * - * The compositor is free to ignore this value and request a smaller size. - */ - -/*! - * \property QWaylandXdgToplevelV6::minSize - * - * This property holds the minimum size of the QWaylandXdgToplevelV6. - * - * The compositor is free to ignore this value and request a smaller size. - */ -QSize QWaylandXdgToplevelV6::minSize() const -{ - Q_D(const QWaylandXdgToplevelV6); - return d->m_minSize; -} - -/*! - * \property QWaylandXdgToplevelV6::states - * - * This property holds the last states the client acknowledged for this QWaylandToplevelV6. - */ -QVector<QWaylandXdgToplevelV6::State> QWaylandXdgToplevelV6::states() const -{ - Q_D(const QWaylandXdgToplevelV6); - return d->m_lastAckedConfigure.states; -} - -/*! - * \qmlproperty bool QtWaylandCompositor::XdgToplevelV6::maximized - * - * This property holds whether the client has acknowledged that it should be maximized. - */ - -/*! - * \property QWaylandXdgToplevelV6::maximized - * - * This property holds whether the client has acknowledged that it should be maximized. - */ -bool QWaylandXdgToplevelV6::maximized() const -{ - Q_D(const QWaylandXdgToplevelV6); - return d->m_lastAckedConfigure.states.contains(QWaylandXdgToplevelV6::State::MaximizedState); -} - -/*! - * \qmlproperty bool QtWaylandCompositor::XdgToplevelV6::fullscreen - * - * This property holds whether the client has acknowledged that it should be fullscreen. - */ - -/*! - * \property QWaylandXdgToplevelV6::fullscreen - * - * This property holds whether the client has acknowledged that it should be fullscreen. - */ -bool QWaylandXdgToplevelV6::fullscreen() const -{ - Q_D(const QWaylandXdgToplevelV6); - return d->m_lastAckedConfigure.states.contains(QWaylandXdgToplevelV6::State::FullscreenState); -} - -/*! - * \qmlproperty bool QtWaylandCompositor::XdgToplevelV6::resizing - * - * This property holds whether the client has acknowledged that it is being resized. - */ - -/*! - * \property QWaylandXdgToplevelV6::resizing - * - * This property holds whether the client has acknowledged that it is being resized. - */ -bool QWaylandXdgToplevelV6::resizing() const -{ - Q_D(const QWaylandXdgToplevelV6); - return d->m_lastAckedConfigure.states.contains(QWaylandXdgToplevelV6::State::ResizingState); -} - -/*! - * \qmlproperty bool QtWaylandCompositor::XdgToplevelV6::activated - * - * This property holds whether toplevel is drawing itself as having input focus. - */ - -/*! - * \property QWaylandXdgToplevelV6::activated - * - * This property holds whether toplevel is drawing itself as having input focus. - */ -bool QWaylandXdgToplevelV6::activated() const -{ - Q_D(const QWaylandXdgToplevelV6); - return d->m_lastAckedConfigure.states.contains(QWaylandXdgToplevelV6::State::ActivatedState); -} - -/*! - * \qmlmethod size QtWaylandCompositor::XdgToplevelV6::sizeForResize(size size, point delta, uint edges) - * - * Convenience for computing the new size given the current \a size, a \a delta, and - * the \a edges active in the drag. - */ - -/*! - * Convenience for computing the new size given the current \a size, a \a delta, and - * the \a edges active in the drag. - */ -QSize QWaylandXdgToplevelV6::sizeForResize(const QSizeF &size, const QPointF &delta, Qt::Edges edges) const -{ - qreal width = size.width(); - qreal height = size.height(); - if (edges & Qt::LeftEdge) - width -= delta.x(); - else if (edges & Qt::RightEdge) - width += delta.x(); - - if (edges & Qt::TopEdge) - height -= delta.y(); - else if (edges & Qt::BottomEdge) - height += delta.y(); - - QSize newSize = QSize(width, height) - .expandedTo(minSize()) - .expandedTo({1, 1}); // We don't want to send a size of (0,0) as that means that the client decides - - if (maxSize().isValid()) - newSize = newSize.boundedTo(maxSize()); - - return newSize; -} - -/*! - * Sends a configure event to the client. Parameter \a size contains the pixel size - * of the surface. A size of zero means the client is free to decide the size. - * Known \a states are enumerated in QWaylandXdgToplevelV6::State. - */ -uint QWaylandXdgToplevelV6::sendConfigure(const QSize &size, const QVector<QWaylandXdgToplevelV6::State> &states) -{ - if (!size.isValid()) { - qWarning() << "Can't configure zxdg_toplevel_v6 with an invalid size" << size; - return 0; - } - Q_D(QWaylandXdgToplevelV6); - auto statesBytes = QByteArray::fromRawData(reinterpret_cast<const char *>(states.data()), - states.size() * static_cast<int>(sizeof(State))); - uint32_t serial = d->m_xdgSurface->surface()->compositor()->nextSerial(); - d->m_pendingConfigures.append(QWaylandXdgToplevelV6Private::ConfigureEvent{states, size, serial}); - d->send_configure(size.width(), size.height(), statesBytes); - QWaylandXdgSurfaceV6Private::get(d->m_xdgSurface)->send_configure(serial); - return serial; -} - -/*! - * \qmlmethod int QtWaylandCompositor::XdgToplevelV6::sendConfigure(size size, list<int> states) - * - * Sends a configure event to the client. \a size contains the pixel size of the surface. - * A size of zero means the client is free to decide the size. - * Known \a states are enumerated in XdgToplevelV6::State. - */ -uint QWaylandXdgToplevelV6::sendConfigure(const QSize &size, const QVector<int> &states) -{ - QVector<State> s; - for (auto state : states) - s << State(state); - return sendConfigure(size, s); -} - -/*! - * \qmlmethod void QtWaylandCompositor::XdgToplevelV6::sendClose() - * - * Sends a close event to the client. The client may choose to ignore the event. - */ - -/*! - * Sends a close event to the client. The client may choose to ignore the event. - */ -void QWaylandXdgToplevelV6::sendClose() -{ - Q_D(QWaylandXdgToplevelV6); - d->send_close(); -} - -/*! - * \qmlmethod void QtWaylandCompositor::XdgToplevelV6::sendMaximized(size size) - * - * Convenience for sending a configure event with the maximized state set, and - * fullscreen and resizing removed. The activated state is left in its current state. - * - * \a size is the new size of the window. - */ - -/*! - * Convenience for sending a configure event with the maximized state set, and - * fullscreen and resizing removed. The activated state is left in its current state. - * - * \a size is the new size of the window. - */ -uint QWaylandXdgToplevelV6::sendMaximized(const QSize &size) -{ - Q_D(QWaylandXdgToplevelV6); - QWaylandXdgToplevelV6Private::ConfigureEvent conf = d->lastSentConfigure(); - - if (!conf.states.contains(QWaylandXdgToplevelV6::State::MaximizedState)) - conf.states.append(QWaylandXdgToplevelV6::State::MaximizedState); - conf.states.removeOne(QWaylandXdgToplevelV6::State::FullscreenState); - conf.states.removeOne(QWaylandXdgToplevelV6::State::ResizingState); - - return sendConfigure(size, conf.states); -} - -/*! - * \qmlmethod void QtWaylandCompositor::XdgToplevelV6::sendUnmaximized(size size) - * - * Convenience for sending a configure event with the maximized, fullscreen and - * resizing states removed, and fullscreen and resizing removed. The activated - * state is left in its current state. - * - * \a size is the new size of the window. If \a size is zero, the client decides the size. - */ - -/*! - * Convenience for sending a configure event with the maximized, fullscreen and - * resizing states removed, and fullscreen and resizing removed. The activated - * state is left in its current state. - * - * \a size is the new size of the window. If \a size is zero, the client decides the size. - */ -uint QWaylandXdgToplevelV6::sendUnmaximized(const QSize &size) -{ - Q_D(QWaylandXdgToplevelV6); - QWaylandXdgToplevelV6Private::ConfigureEvent conf = d->lastSentConfigure(); - - conf.states.removeOne(QWaylandXdgToplevelV6::State::MaximizedState); - conf.states.removeOne(QWaylandXdgToplevelV6::State::FullscreenState); - conf.states.removeOne(QWaylandXdgToplevelV6::State::ResizingState); - - return sendConfigure(size, conf.states); - -} - -/*! - * \qmlmethod void QtWaylandCompositor::XdgToplevelV6::sendFullscreen(size size) - * - * Convenience for sending a configure event with the fullscreen state set, and - * maximized and resizing removed. The activated state is left in its current state. - * - * \sa sendUnmaximized - * - * \a size is the new size of the window. - */ - -/*! - * Convenience for sending a configure event with the fullscreen state set, and - * maximized and resizing removed. The activated state is left in its current state. - * - * \sa sendUnmaximized - * - * \a size is the new size of the window. - */ -uint QWaylandXdgToplevelV6::sendFullscreen(const QSize &size) -{ - Q_D(QWaylandXdgToplevelV6); - QWaylandXdgToplevelV6Private::ConfigureEvent conf = d->lastSentConfigure(); - - if (!conf.states.contains(QWaylandXdgToplevelV6::State::FullscreenState)) - conf.states.append(QWaylandXdgToplevelV6::State::FullscreenState); - conf.states.removeOne(QWaylandXdgToplevelV6::State::MaximizedState); - conf.states.removeOne(QWaylandXdgToplevelV6::State::ResizingState); - - return sendConfigure(size, conf.states); -} - -/*! - * \qmlmethod void QtWaylandCompositor::XdgToplevelV6::sendResizing(size maxSize) - * - * Convenience for sending a configure event with the resizing state set, and - * maximized and fullscreen removed. The activated state is left in its current state. - * - * \a maxSize is the new size of the window. - */ - -/*! - * Convenience for sending a configure event with the resizing state set, and - * maximized and fullscreen removed. The activated state is left in its current state. - * - * \a maxSize is the new size of the window. - */ -uint QWaylandXdgToplevelV6::sendResizing(const QSize &maxSize) -{ - Q_D(QWaylandXdgToplevelV6); - QWaylandXdgToplevelV6Private::ConfigureEvent conf = d->lastSentConfigure(); - - if (!conf.states.contains(QWaylandXdgToplevelV6::State::ResizingState)) - conf.states.append(QWaylandXdgToplevelV6::State::ResizingState); - conf.states.removeOne(QWaylandXdgToplevelV6::State::MaximizedState); - conf.states.removeOne(QWaylandXdgToplevelV6::State::FullscreenState); - - return sendConfigure(maxSize, conf.states); -} - -/*! - * Returns the surface role for the QWaylandToplevelV6. - */ -QWaylandSurfaceRole *QWaylandXdgToplevelV6::role() -{ - return &QWaylandXdgToplevelV6Private::s_role; -} - - -/*! - * \qmlsignal QtWaylandCompositor::XdgShellV6::xdgSurfaceCreated(XdgSurfaceV6 xdgSurface) - * - * This signal is emitted when the client has created a \c zxdg_surface_v6. - * Note that \a xdgSurface is not mapped, i.e. according to the \c xdg-shell - * protocol it should not be displayed, until it has received a role object. - * - * \sa toplevelCreated(), popupCreated() - */ - -/*! - * \fn void QWaylandXdgShellV6::xdgSurfaceCreated(QWaylandXdgSurfaceV6 *xdgSurface) - * - * This signal is emitted when the client has created a \c zxdg_surface_v6. - * Note that \a xdgSurface is not mapped, i.e. according to the \c xdg-shell - * protocol it should not be displayed, until it has received a role object. - * - * \sa toplevelCreated(), popupCreated() - */ - -/*! - * \qmlsignal QtWaylandCompositor::XdgShellV6::toplevelCreated(XdgToplevelV6 toplevel, XdgSurfaceV6 xdgSurface) - * - * This signal is emitted when the client has created a \c zxdg_toplevel_v6. - * A common use case is to let the handler of this signal instantiate a ShellSurfaceItem or - * WaylandQuickItem for displaying \a toplevel in a QtQuick scene. - * - * \a xdgSurface is the XdgSurfaceV6 \a toplevel is the role object for. - */ - -/*! - * \fn void QWaylandXdgShellV6::toplevelCreated(QWaylandXdgToplevelV6 *toplevel, QWaylandXdgSurfaceV6 *xdgSurface) - * - * This signal is emitted when the client has created a \c zxdg_toplevel_v6. - * A common use case is to let the handler of this signal instantiate a QWaylandShellSurfaceItem or - * QWaylandQuickItem for displaying \a toplevel in a QtQuick scene. - * - * \a xdgSurface is the XdgSurfaceV6 \a toplevel is the role object for. - */ - -/*! - * \qmlsignal QtWaylandCompositor::XdgShellV6::popupCreated(XdgPopupV6 popup, XdgSurfaceV6 xdgSurface) - * - * This signal is emitted when the client has created a \c zxdg_popup_v6. - * A common use case is to let the handler of this signal instantiate a ShellSurfaceItem or - * WaylandQuickItem for displaying \a popup in a QtQuick scene. - * - * \a xdgSurface is the XdgSurfaceV6 \a popup is the role object for. - */ - -/*! - * \fn void QWaylandXdgShellV6::popupCreated(QWaylandXdgPopupV6 *popup, QWaylandXdgSurfaceV6 *xdgSurface) - * - * This signal is emitted when the client has created a \c zxdg_popup_v6. - * A common use case is to let the handler of this signal instantiate a QWaylandShellSurfaceItem or - * QWaylandQuickItem for displaying \a popup in a QtQuick scene. - * - * \a xdgSurface is the XdgSurfaceV6 \a popup is the role object for. - */ - -/*! - * \qmlsignal QtWaylandCompositor::XdgShellV6::pong(int serial) - * - * This signal is emitted when the client has responded to a ping event with serial, \a serial. - * - * \sa ping() - */ - -/*! - * \fn void QWaylandXdgShellV6::pong(uint serial) - * - * This signal is emitted when the client has responded to a ping event with serial, \a serial. - * - * \sa QWaylandXdgShellV6::ping() - */ - -QList<int> QWaylandXdgToplevelV6::statesAsInts() const -{ - QList<int> list; - const auto s = states(); - list.reserve(s.size()); - for (auto state : s) { - list << static_cast<int>(state); - } - return list; -} - -QWaylandSurfaceRole QWaylandXdgToplevelV6Private::s_role("zxdg_toplevel_v6"); - -QWaylandXdgToplevelV6Private::QWaylandXdgToplevelV6Private(QWaylandXdgSurfaceV6 *xdgSurface, const QWaylandResource &resource) - : m_xdgSurface(xdgSurface) -{ - init(resource.resource()); -} - -void QWaylandXdgToplevelV6Private::handleAckConfigure(uint serial) -{ - Q_Q(QWaylandXdgToplevelV6); - ConfigureEvent config; - Q_FOREVER { - if (m_pendingConfigures.empty()) { - qWarning("Toplevel received an unexpected ack_configure!"); - return; - } - - // This won't work unless there always is a toplevel.configure for each xdgsurface.configure - config = m_pendingConfigures.takeFirst(); - - if (config.serial == serial) - break; - } - - QVector<uint> changedStates; - std::set_symmetric_difference( - m_lastAckedConfigure.states.begin(), m_lastAckedConfigure.states.end(), - config.states.begin(), config.states.end(), - std::back_inserter(changedStates)); - - m_lastAckedConfigure = config; - - for (uint state : changedStates) { - switch (state) { - case state_maximized: - emit q->maximizedChanged(); - break; - case state_fullscreen: - emit q->fullscreenChanged(); - break; - case state_resizing: - emit q->resizingChanged(); - break; - case state_activated: - emit q->activatedChanged(); - break; - } - } - - if (!changedStates.empty()) - emit q->statesChanged(); -} - -void QWaylandXdgToplevelV6Private::handleFocusLost() -{ - Q_Q(QWaylandXdgToplevelV6); - QWaylandXdgToplevelV6Private::ConfigureEvent current = lastSentConfigure(); - current.states.removeOne(QWaylandXdgToplevelV6::State::ActivatedState); - q->sendConfigure(current.size, current.states); -} - -void QWaylandXdgToplevelV6Private::handleFocusReceived() -{ - Q_Q(QWaylandXdgToplevelV6); - QWaylandXdgToplevelV6Private::ConfigureEvent current = lastSentConfigure(); - if (!current.states.contains(QWaylandXdgToplevelV6::State::ActivatedState)) { - current.states.push_back(QWaylandXdgToplevelV6::State::ActivatedState); - q->sendConfigure(current.size, current.states); - } -} - -void QWaylandXdgToplevelV6Private::zxdg_toplevel_v6_destroy_resource(QtWaylandServer::zxdg_toplevel_v6::Resource *resource) -{ - Q_UNUSED(resource); - Q_Q(QWaylandXdgToplevelV6); - delete q; -} - -void QWaylandXdgToplevelV6Private::zxdg_toplevel_v6_destroy(QtWaylandServer::zxdg_toplevel_v6::Resource *resource) -{ - wl_resource_destroy(resource->handle); - //TODO: Should the xdg surface be desroyed as well? Or is it allowed to recreate a new toplevel for it? -} - -void QWaylandXdgToplevelV6Private::zxdg_toplevel_v6_set_parent(QtWaylandServer::zxdg_toplevel_v6::Resource *resource, wl_resource *parent) -{ - Q_UNUSED(resource); - QWaylandXdgToplevelV6 *parentToplevel = nullptr; - if (parent) { - parentToplevel = static_cast<QWaylandXdgToplevelV6Private *>( - QWaylandXdgToplevelV6Private::Resource::fromResource(parent)->zxdg_toplevel_v6_object)->q_func(); - } - - Q_Q(QWaylandXdgToplevelV6); - - if (m_parentToplevel != parentToplevel) { - m_parentToplevel = parentToplevel; - emit q->parentToplevelChanged(); - } - - if (m_parentToplevel && m_xdgSurface->windowType() != Qt::WindowType::SubWindow) { - // There's a parent now, which means the surface is transient - QWaylandXdgSurfaceV6Private::get(m_xdgSurface)->setWindowType(Qt::WindowType::SubWindow); - } else if (!m_parentToplevel && m_xdgSurface->windowType() != Qt::WindowType::Window) { - // When the surface has no parent it is toplevel - QWaylandXdgSurfaceV6Private::get(m_xdgSurface)->setWindowType(Qt::WindowType::Window); - } -} - -void QWaylandXdgToplevelV6Private::zxdg_toplevel_v6_set_title(QtWaylandServer::zxdg_toplevel_v6::Resource *resource, const QString &title) -{ - Q_UNUSED(resource); - if (title == m_title) - return; - Q_Q(QWaylandXdgToplevelV6); - m_title = title; - emit q->titleChanged(); -} - -void QWaylandXdgToplevelV6Private::zxdg_toplevel_v6_set_app_id(QtWaylandServer::zxdg_toplevel_v6::Resource *resource, const QString &app_id) -{ - Q_UNUSED(resource); - if (app_id == m_appId) - return; - Q_Q(QWaylandXdgToplevelV6); - m_appId = app_id; - emit q->appIdChanged(); -} - -void QWaylandXdgToplevelV6Private::zxdg_toplevel_v6_show_window_menu(QtWaylandServer::zxdg_toplevel_v6::Resource *resource, wl_resource *seatResource, uint32_t serial, int32_t x, int32_t y) -{ - Q_UNUSED(resource); - Q_UNUSED(serial); - QPoint position(x, y); - auto seat = QWaylandSeat::fromSeatResource(seatResource); - Q_Q(QWaylandXdgToplevelV6); - emit q->showWindowMenu(seat, position); -} - -void QWaylandXdgToplevelV6Private::zxdg_toplevel_v6_move(Resource *resource, wl_resource *seatResource, uint32_t serial) -{ - Q_UNUSED(resource); - Q_UNUSED(serial); - Q_Q(QWaylandXdgToplevelV6); - QWaylandSeat *seat = QWaylandSeat::fromSeatResource(seatResource); - emit q->startMove(seat); -} - -void QWaylandXdgToplevelV6Private::zxdg_toplevel_v6_resize(QtWaylandServer::zxdg_toplevel_v6::Resource *resource, wl_resource *seatResource, uint32_t serial, uint32_t edges) -{ - Q_UNUSED(resource); - Q_UNUSED(serial); - Q_Q(QWaylandXdgToplevelV6); - QWaylandSeat *seat = QWaylandSeat::fromSeatResource(seatResource); - emit q->startResize(seat, QWaylandXdgShellV6Private::convertToEdges(edges)); -} - -void QWaylandXdgToplevelV6Private::zxdg_toplevel_v6_set_max_size(QtWaylandServer::zxdg_toplevel_v6::Resource *resource, int32_t width, int32_t height) -{ - Q_UNUSED(resource); - - QSize maxSize(width, height); - if (width == 0 && height == 0) - maxSize = QSize(); // Wayland size of zero means unspecified which best translates to invalid - - if (m_maxSize == maxSize) - return; - - if (width < 0 || height < 0) { - // The spec says raise a protocol error, but there's no matching error defined - qWarning() << "Received a zxdg_toplevel_v6.set_max_size request with a negative size"; - return; - } - - if (m_minSize.isValid() && maxSize.isValid() && - (maxSize.width() < m_minSize.width() || maxSize.height() < m_minSize.height())) { - // The spec says raise a protocol error, but there's no matching error defined - qWarning() << "Received a zxdg_toplevel_v6.set_max_size request with a size smaller than the minimium size"; - return; - } - - m_maxSize = maxSize; - - Q_Q(QWaylandXdgToplevelV6); - emit q->maxSizeChanged(); -} - -void QWaylandXdgToplevelV6Private::zxdg_toplevel_v6_set_min_size(QtWaylandServer::zxdg_toplevel_v6::Resource *resource, int32_t width, int32_t height) -{ - Q_UNUSED(resource); - - QSize minSize(width, height); - if (width == 0 && height == 0) - minSize = QSize(); // Wayland size of zero means unspecified - - if (m_minSize == minSize) - return; - - if (width < 0 || height < 0) { - // The spec says raise a protocol error, but there's no matching error defined - qWarning() << "Received a zxdg_toplevel_v6.set_min_size request with a negative size"; - return; - } - - if (m_maxSize.isValid() && minSize.isValid() && - (minSize.width() > m_maxSize.width() || minSize.height() > m_maxSize.height())) { - // The spec says raise a protocol error, but there's no matching error defined - qWarning() << "Received a zxdg_toplevel_v6.set_min_size request with a size larger than the maximum size"; - return; - } - - m_minSize = minSize; - - Q_Q(QWaylandXdgToplevelV6); - emit q->minSizeChanged(); -} - -void QWaylandXdgToplevelV6Private::zxdg_toplevel_v6_set_maximized(QtWaylandServer::zxdg_toplevel_v6::Resource *resource) -{ - Q_UNUSED(resource); - Q_Q(QWaylandXdgToplevelV6); - emit q->setMaximized(); -} - -void QWaylandXdgToplevelV6Private::zxdg_toplevel_v6_unset_maximized(QtWaylandServer::zxdg_toplevel_v6::Resource *resource) -{ - Q_UNUSED(resource); - Q_Q(QWaylandXdgToplevelV6); - emit q->unsetMaximized(); -} - -void QWaylandXdgToplevelV6Private::zxdg_toplevel_v6_set_fullscreen(QtWaylandServer::zxdg_toplevel_v6::Resource *resource, wl_resource *output_res) -{ - Q_UNUSED(resource); - Q_Q(QWaylandXdgToplevelV6); - QWaylandOutput *output = output_res ? QWaylandOutput::fromResource(output_res) : nullptr; - emit q->setFullscreen(output); -} - -void QWaylandXdgToplevelV6Private::zxdg_toplevel_v6_unset_fullscreen(QtWaylandServer::zxdg_toplevel_v6::Resource *resource) -{ - Q_UNUSED(resource); - Q_Q(QWaylandXdgToplevelV6); - emit q->unsetFullscreen(); -} - -void QWaylandXdgToplevelV6Private::zxdg_toplevel_v6_set_minimized(QtWaylandServer::zxdg_toplevel_v6::Resource *resource) -{ - Q_UNUSED(resource); - Q_Q(QWaylandXdgToplevelV6); - emit q->setMinimized(); -} - -/*! - * \qmltype XdgPopupV6 - * \inqmlmodule QtWayland.Compositor - * \since 5.10 - * \brief XdgPopupV6 represents the popup specific parts of and xdg surface. - * - * This type is part of the \l{XdgShellV6} extension and provides a way to extend - * extend the functionality of an \l{XdgSurfaceV6} with features - * specific to desktop-style menus for an xdg surface. - * - * It corresponds to the Wayland interface \c zxdg_popup_v6. - */ - -/*! - * \class QWaylandXdgPopupV6 - * \inmodule QtWaylandCompositor - * \since 5.10 - * \brief The QWaylandXdgPopupV6 class represents the popup specific parts of an xdg surface. - * - * This class is part of the QWaylandXdgShellV6 extension and provides a way to - * extend the functionality of a QWaylandXdgSurfaceV6 with features - * specific to desktop-style menus for an xdg surface. - * - * It corresponds to the Wayland interface \c zxdg_popup_v6. - */ - -/*! - * Constructs a QWaylandXdgPopupV6. - */ -QWaylandXdgPopupV6::QWaylandXdgPopupV6(QWaylandXdgSurfaceV6 *xdgSurface, QWaylandXdgSurfaceV6 *parentXdgSurface, - QWaylandXdgPositionerV6 *positioner, QWaylandResource &resource) - : QObject(*new QWaylandXdgPopupV6Private(xdgSurface, parentXdgSurface, positioner, resource)) -{ -} - -/*! - * \qmlproperty XdgSurfaceV6 QtWaylandCompositor::XdgPopupV6::xdgSurface - * - * This property holds the XdgSurfaceV6 associated with this XdgPopupV6. - */ - -/*! - * \property QWaylandXdgPopupV6::xdgSurface - * - * This property holds the QWaylandXdgSurfaceV6 associated with this QWaylandXdgPopupV6. - */ -QWaylandXdgSurfaceV6 *QWaylandXdgPopupV6::xdgSurface() const -{ - Q_D(const QWaylandXdgPopupV6); - return d->m_xdgSurface; -} - -/*! - * \qmlproperty XdgSurfaceV6 QtWaylandCompositor::XdgPopupV6::parentXdgSurface - * - * This property holds the XdgSurfaceV6 associated with the parent of this XdgPopupV6. - */ - -/*! - * \property QWaylandXdgPopupV6::parentXdgSurface - * - * This property holds the QWaylandXdgSurfaceV6 associated with the parent of this - * QWaylandXdgPopupV6. - */ -QWaylandXdgSurfaceV6 *QWaylandXdgPopupV6::parentXdgSurface() const -{ - Q_D(const QWaylandXdgPopupV6); - return d->m_parentXdgSurface; -} - -/*! - * \qmlproperty rect QtWaylandCompositor::XdgPopupV6::configuredGeometry - * - * The window geometry the popup received in the configure event. Relative to the - * upper left corner of the parent surface. - */ - -/*! - * \property QWaylandXdgPopupV6::configuredGeometry - * - * The window geometry the popup received in the configure event. Relative to the - * upper left corner of the parent surface. - */ -QRect QWaylandXdgPopupV6::configuredGeometry() const -{ - Q_D(const QWaylandXdgPopupV6); - return d->m_geometry; -} - -/*! - * \qmlproperty rect QtWaylandCompositor::XdgPopupV6::anchorRect - * - * The anchor rectangle relative to the parent window geometry that the child - * surface should be placed relative to. - */ - -/*! - * \property QWaylandXdgPopupV6::anchorRect - * - * Returns the anchor rectangle relative to the parent window geometry that the child - * surface should be placed relative to. - */ -QRect QWaylandXdgPopupV6::anchorRect() const -{ - Q_D(const QWaylandXdgPopupV6); - return d->m_positionerData.anchorRect; -} - -/*! - * \qmlproperty enumeration QtWaylandCompositor::XdgPopupV6::anchorEdges - * - * This property holds the set of edges on the anchor rect that the child surface should be placed - * relative to. If no edges are specified in a direction, the anchor point should be - * centered between the edges. - * - * The possible values are: - * \value Qt.TopEdge The top edge of the rectangle. - * \value Qt.LeftEdge The left edge of the rectangle. - * \value Qt.RightEdge The right edge of the rectangle. - * \value Qt.BottomEdge The bottom edge of the rectangle. - */ - -/*! - * \property QWaylandXdgPopupV6::anchorEdges - * - * Returns the set of edges on the anchor rect that the child surface should be placed - * relative to. If no edges are specified in a direction, the anchor point should be - * centered between the edges. - */ -Qt::Edges QWaylandXdgPopupV6::anchorEdges() const -{ - Q_D(const QWaylandXdgPopupV6); - return d->m_positionerData.anchorEdges; -} - -/*! - * \qmlproperty rect QtWaylandCompositor::XdgPopupV6::gravityEdges - * - * Specifies in what direction the surface should be positioned, relative to the anchor - * point. - * - * The possible values are: - * \value Qt.TopEdge The surface should slide towards the top of the screen. - * \value Qt.LeftEdge The surface should slide towards the left of the screen. - * \value Qt.RightEdge The surface should slide towards the right of the screen. - * \value Qt.BottomEdge The surface should slide towards the bottom of the screen. - */ - -/*! - * \property QWaylandXdgPopupV6::gravityEdges - * - * Specifies in what direction the surface should be positioned, relative to the anchor - * point. - */ -Qt::Edges QWaylandXdgPopupV6::gravityEdges() const -{ - Q_D(const QWaylandXdgPopupV6); - return d->m_positionerData.gravityEdges; -} - -/*! - * \qmlproperty enumeration QtWaylandCompositor::XdgPopupV6::slideConstraints - * - * This property holds the orientations in which the child should slide to fit within the screen. - * - * Possible values: - * \value Qt.Horizontal Horizontal - * \value Qt.Vertical Vertical - */ - -/*! - * \property QWaylandXdgPopupV6::slideConstraints - * - * This property holds the orientations in which the child should slide to fit within the screen. - */ -Qt::Orientations QWaylandXdgPopupV6::slideConstraints() const -{ - Q_D(const QWaylandXdgPopupV6); - const uint flags = d->m_positionerData.constraintAdjustments; - - Qt::Orientations constraints = 0; - - if (flags & ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_SLIDE_X) - constraints |= Qt::Horizontal; - if (flags & ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_SLIDE_Y) - constraints |= Qt::Vertical; - - return constraints; -} - -/*! - * \qmlproperty enumeration QtWaylandCompositor::XdgPopupV6::flipConstraints - * - * This property holds the orientations in which the child should flip to fit within the screen. - * - * Possible values: - * \value Qt.Horizontal Horizontal - * \value Qt.Vertical Vertical - */ - -/*! - * \property QWaylandXdgPopupV6::flipConstraints - * - * This property holds the orientations in which the child should flip to fit within the screen. - */ -Qt::Orientations QWaylandXdgPopupV6::flipConstraints() const -{ - Q_D(const QWaylandXdgPopupV6); - const uint flags = d->m_positionerData.constraintAdjustments; - - Qt::Orientations constraints = 0; - - if (flags & ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_FLIP_X) - constraints |= Qt::Horizontal; - if (flags & ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_FLIP_Y) - constraints |= Qt::Vertical; - - return constraints; -} - -/*! - * \qmlproperty enumeration QtWaylandCompositor::XdgPopupV6::resizeConstraints - * - * This property holds the orientations in which the child should resize to fit within the screen. - * - * Possible values: - * \value Qt.Horizontal Horizontal - * \value Qt.Vertical Vertical - */ - -/*! - * \property QWaylandXdgPopupV6::resizeConstraints - * - * This property holds the orientations in which the child should resize to fit within the screen. - */ -Qt::Orientations QWaylandXdgPopupV6::resizeConstraints() const -{ - Q_D(const QWaylandXdgPopupV6); - const uint flags = d->m_positionerData.constraintAdjustments; - - Qt::Orientations constraints = 0; - - if (flags & ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_RESIZE_X) - constraints |= Qt::Horizontal; - if (flags & ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_RESIZE_Y) - constraints |= Qt::Vertical; - - return constraints; -} - -/*! - * \qmlproperty point QtWaylandCompositor::XdgPopupV6::offset - * - * The position relative to the position of the anchor on the anchor rectangle and - * the anchor on the surface. - */ - -/*! - * \property QWaylandXdgPopupV6::offset - * - * Returns the surface position relative to the position of the anchor on the anchor - * rectangle and the anchor on the surface. - */ -QPoint QWaylandXdgPopupV6::offset() const -{ - Q_D(const QWaylandXdgPopupV6); - return d->m_positionerData.offset; -} - -/*! - * \qmlproperty size QtWaylandCompositor::XdgPopupV6::positionerSize - * - * The size requested for the window geometry by the positioner object. - */ - -/*! - * \property QWaylandXdgPopupV6::positionerSize - * - * Returns the size requested for the window geometry by the positioner object. - */ -QSize QWaylandXdgPopupV6::positionerSize() const -{ - Q_D(const QWaylandXdgPopupV6); - return d->m_positionerData.size; -} - -/*! - * \qmlproperty point QtWaylandCompositor::XdgPopupV6::unconstrainedPosition - * - * The position of the surface relative to the parent window geometry if the surface - * is not constrained. I.e. when not moved to fit inside the screen or similar. - */ - -/*! - * \property QWaylandXdgPopupV6::unconstrainedPosition - * - * The position of the surface relative to the parent window geometry if the surface - * is not constrained. I.e. when not moved to fit inside the screen or similar. - */ -QPoint QWaylandXdgPopupV6::unconstrainedPosition() const -{ - Q_D(const QWaylandXdgPopupV6); - return d->m_positionerData.unconstrainedPosition(); -} - -/*! - * \qmlmethod int QtWaylandCompositor::XdgPopupV6::sendConfigure(rect geometry) - * - * Sends a configure event to the client. \a geometry contains the window geometry - * relative to the upper left corner of the window geometry of the parent surface. - * - * This implicitly sends a configure event to the corresponding XdgSurfaceV6 as well. - */ - -/*! - * Sends a configure event to the client. \a geometry contains the window geometry - * relative to the upper left corner of the window geometry of the parent surface. - * - * This implicitly sends a configure event to the corresponding QWaylandXdgSurfaceV6 - * as well. - */ -uint QWaylandXdgPopupV6::sendConfigure(const QRect &geometry) -{ - Q_D(QWaylandXdgPopupV6); - return d->sendConfigure(geometry); -} - -/*! - * \qmlmethod void QtWaylandCompositor::XdgPopupV6::sendPopupDone() - * \since 5.14 - * - * Dismiss the popup. According to the \c xdg-shell-unstable-v6 protocol this should make the - * client destroy the popup. - */ - -/*! - * \since 5.14 - * - * Dismiss the popup. According to the \c xdg-shell-unstable-v6 protocol this should make the - * client destroy the popup. - */ -void QWaylandXdgPopupV6::sendPopupDone() -{ - Q_D(QWaylandXdgPopupV6); - d->send_popup_done(); -} - -/*! - * Returns the surface role for the QWaylandPopupV6. - */ -QWaylandSurfaceRole *QWaylandXdgPopupV6::role() -{ - return &QWaylandXdgPopupV6Private::s_role; -} - -QWaylandXdgPopupV6Private::QWaylandXdgPopupV6Private(QWaylandXdgSurfaceV6 *xdgSurface, QWaylandXdgSurfaceV6 *parentXdgSurface, - QWaylandXdgPositionerV6 *positioner, const QWaylandResource &resource) - : m_xdgSurface(xdgSurface) - , m_parentXdgSurface(parentXdgSurface) - , m_positionerData(positioner->m_data) -{ - Q_ASSERT(m_positionerData.isComplete()); - init(resource.resource()); - - QWaylandXdgSurfaceV6Private::get(m_xdgSurface)->setWindowType(Qt::WindowType::Popup); - - //TODO: Need an API for sending a different initial configure - sendConfigure(QRect(m_positionerData.unconstrainedPosition(), m_positionerData.size)); -} - -void QWaylandXdgPopupV6Private::handleAckConfigure(uint serial) -{ - Q_Q(QWaylandXdgPopupV6); - ConfigureEvent config; - Q_FOREVER { - if (m_pendingConfigures.empty()) { - qWarning("Popup received an unexpected ack_configure!"); - return; - } - - // This won't work unless there always is a popup.configure for each xdgsurface.configure - config = m_pendingConfigures.takeFirst(); - - if (config.serial == serial) - break; - } - - if (m_geometry == config.geometry) - return; - - m_geometry = config.geometry; - emit q->configuredGeometryChanged(); -} - -uint QWaylandXdgPopupV6Private::sendConfigure(const QRect &geometry) -{ - uint32_t serial = m_xdgSurface->surface()->compositor()->nextSerial(); - m_pendingConfigures.append(QWaylandXdgPopupV6Private::ConfigureEvent{geometry, serial}); - send_configure(geometry.x(), geometry.y(), geometry.width(), geometry.height()); - QWaylandXdgSurfaceV6Private::get(m_xdgSurface)->send_configure(serial); - return serial; -} - -void QWaylandXdgPopupV6Private::zxdg_popup_v6_destroy(QtWaylandServer::zxdg_popup_v6::Resource *resource) -{ - Q_UNUSED(resource); - qWarning() << Q_FUNC_INFO << "Not implemented"; //TODO -} - -void QWaylandXdgPopupV6Private::zxdg_popup_v6_grab(QtWaylandServer::zxdg_popup_v6::Resource *resource, wl_resource *seat, uint32_t serial) -{ - Q_UNUSED(resource); - Q_UNUSED(serial); - Q_UNUSED(seat); - qWarning() << Q_FUNC_INFO << "Not implemented"; //TODO - //switch keyboard focus - //eventually send configure with activated. -} - -QWaylandSurfaceRole QWaylandXdgPopupV6Private::s_role("zxdg_popup_v6"); - -QWaylandXdgPositionerV6Data::QWaylandXdgPositionerV6Data() - : offset(0, 0) -{} - -bool QWaylandXdgPositionerV6Data::isComplete() const -{ - return size.width() > 0 && size.height() > 0 && anchorRect.size().width() > 0 && anchorRect.size().height() > 0; -} - -QPoint QWaylandXdgPositionerV6Data::anchorPoint() const -{ - int yPosition = 0; - if (anchorEdges & Qt::TopEdge) - yPosition = anchorRect.top(); - else if (anchorEdges & Qt::BottomEdge) - yPosition = anchorRect.bottom() + 1; - else - yPosition = anchorRect.top() + anchorRect.height() / 2; - - int xPosition = 0; - if (anchorEdges & Qt::LeftEdge) - xPosition = anchorRect.left(); - else if (anchorEdges & Qt::RightEdge) - xPosition = anchorRect.right() + 1; - else - xPosition = anchorRect.left() + anchorRect.width() / 2; - - return QPoint(xPosition, yPosition); -} - -QPoint QWaylandXdgPositionerV6Data::unconstrainedPosition() const -{ - int gravityOffsetY = 0; - if (gravityEdges & Qt::TopEdge) - gravityOffsetY = -size.height(); - else if (!(gravityEdges & Qt::BottomEdge)) - gravityOffsetY = -size.height() / 2; - - int gravityOffsetX = 0; - if (gravityEdges & Qt::LeftEdge) - gravityOffsetX = -size.width(); - else if (!(gravityEdges & Qt::RightEdge)) - gravityOffsetX = -size.width() / 2; - - QPoint gravityOffset(gravityOffsetX, gravityOffsetY); - return anchorPoint() + gravityOffset + offset; -} - -QWaylandXdgPositionerV6::QWaylandXdgPositionerV6(const QWaylandResource &resource) -{ - init(resource.resource()); -} - -void QWaylandXdgPositionerV6::zxdg_positioner_v6_destroy_resource(QtWaylandServer::zxdg_positioner_v6::Resource *resource) -{ - Q_UNUSED(resource); - delete this; -} - -void QWaylandXdgPositionerV6::zxdg_positioner_v6_destroy(QtWaylandServer::zxdg_positioner_v6::Resource *resource) -{ - wl_resource_destroy(resource->handle); -} - -void QWaylandXdgPositionerV6::zxdg_positioner_v6_set_size(QtWaylandServer::zxdg_positioner_v6::Resource *resource, int32_t width, int32_t height) -{ - if (width <= 0 || height <= 0) { - wl_resource_post_error(resource->handle, ZXDG_POSITIONER_V6_ERROR_INVALID_INPUT, - "zxdg_positioner_v6.set_size requested with non-positive dimensions"); - return; - } - - QSize size(width, height); - m_data.size = size; -} - -void QWaylandXdgPositionerV6::zxdg_positioner_v6_set_anchor_rect(QtWaylandServer::zxdg_positioner_v6::Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) -{ - if (width <= 0 || height <= 0) { - wl_resource_post_error(resource->handle, ZXDG_POSITIONER_V6_ERROR_INVALID_INPUT, - "zxdg_positioner_v6.set_anchor_rect requested with non-positive dimensions"); - return; - } - - QRect anchorRect(x, y, width, height); - m_data.anchorRect = anchorRect; -} - -void QWaylandXdgPositionerV6::zxdg_positioner_v6_set_anchor(QtWaylandServer::zxdg_positioner_v6::Resource *resource, uint32_t anchor) -{ - Qt::Edges anchorEdges = QWaylandXdgShellV6Private::convertToEdges(anchor); - - if ((anchorEdges & Qt::BottomEdge && anchorEdges & Qt::TopEdge) || - (anchorEdges & Qt::LeftEdge && anchorEdges & Qt::RightEdge)) { - wl_resource_post_error(resource->handle, ZXDG_POSITIONER_V6_ERROR_INVALID_INPUT, - "zxdg_positioner_v6.set_anchor requested with parallel edges"); - return; - } - - m_data.anchorEdges = anchorEdges; -} - -void QWaylandXdgPositionerV6::zxdg_positioner_v6_set_gravity(QtWaylandServer::zxdg_positioner_v6::Resource *resource, uint32_t gravity) -{ - Qt::Edges gravityEdges = QWaylandXdgShellV6Private::convertToEdges(gravity); - - if ((gravityEdges & Qt::BottomEdge && gravityEdges & Qt::TopEdge) || - (gravityEdges & Qt::LeftEdge && gravityEdges & Qt::RightEdge)) { - wl_resource_post_error(resource->handle, ZXDG_POSITIONER_V6_ERROR_INVALID_INPUT, - "zxdg_positioner_v6.set_gravity requested with parallel edges"); - return; - } - - m_data.gravityEdges = gravityEdges; -} - -void QWaylandXdgPositionerV6::zxdg_positioner_v6_set_constraint_adjustment(QtWaylandServer::zxdg_positioner_v6::Resource *resource, uint32_t constraint_adjustment) -{ - Q_UNUSED(resource); - m_data.constraintAdjustments = constraint_adjustment; -} - -void QWaylandXdgPositionerV6::zxdg_positioner_v6_set_offset(QtWaylandServer::zxdg_positioner_v6::Resource *resource, int32_t x, int32_t y) -{ - Q_UNUSED(resource); - m_data.offset = QPoint(x, y); -} - -QWaylandXdgPositionerV6 *QWaylandXdgPositionerV6::fromResource(wl_resource *resource) -{ - return QtWayland::fromResource<QWaylandXdgPositionerV6 *>(resource); -} - -QT_END_NAMESPACE diff --git a/src/compositor/extensions/qwaylandxdgshellv6.h b/src/compositor/extensions/qwaylandxdgshellv6.h deleted file mode 100644 index 71f82521a..000000000 --- a/src/compositor/extensions/qwaylandxdgshellv6.h +++ /dev/null @@ -1,264 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** 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 QWAYLANDXDGSHELLV6_H -#define QWAYLANDXDGSHELLV6_H - -#include <QtWaylandCompositor/QWaylandCompositorExtension> -#include <QtWaylandCompositor/QWaylandResource> -#include <QtWaylandCompositor/QWaylandShell> -#include <QtWaylandCompositor/QWaylandShellSurface> -#include <QtWaylandCompositor/qwaylandquickchildren.h> - -#include <QtCore/QRect> - -struct wl_resource; - -QT_BEGIN_NAMESPACE - -class QWaylandClient; -class QWaylandOutput; -class QWaylandSeat; -class QWaylandSurface; -class QWaylandSurfaceRole; -class QWaylandXdgShellV6Private; -class QWaylandXdgSurfaceV6; -class QWaylandXdgSurfaceV6Private; -class QWaylandXdgToplevelV6; -class QWaylandXdgToplevelV6Private; -class QWaylandXdgPopupV6; -class QWaylandXdgPopupV6Private; -class QWaylandXdgPositionerV6; - -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgShellV6 : public QWaylandShellTemplate<QWaylandXdgShellV6> -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QWaylandXdgShellV6) -public: - QWaylandXdgShellV6(); - QWaylandXdgShellV6(QWaylandCompositor *compositor); - - void initialize() override; - - static const struct wl_interface *interface(); - static QByteArray interfaceName(); - -public Q_SLOTS: - uint ping(QWaylandClient *client); - -Q_SIGNALS: - void xdgSurfaceCreated(QWaylandXdgSurfaceV6 *xdgSurface); - void toplevelCreated(QWaylandXdgToplevelV6 *toplevel, QWaylandXdgSurfaceV6 *xdgSurface); - void popupCreated(QWaylandXdgPopupV6 *popup, QWaylandXdgSurfaceV6 *xdgSurface); - void pong(uint serial); - -private Q_SLOTS: - void handleSeatChanged(QWaylandSeat *newSeat, QWaylandSeat *oldSeat); - void handleFocusChanged(QWaylandSurface *newSurface, QWaylandSurface *oldSurface); -}; - -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgSurfaceV6 : public QWaylandShellSurfaceTemplate<QWaylandXdgSurfaceV6> -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QWaylandXdgSurfaceV6) - Q_WAYLAND_COMPOSITOR_DECLARE_QUICK_CHILDREN(QWaylandXdgSurfaceV6) - Q_PROPERTY(QWaylandXdgShellV6 *shell READ shell NOTIFY shellChanged) - Q_PROPERTY(QWaylandSurface *surface READ surface NOTIFY surfaceChanged) - Q_PROPERTY(QWaylandXdgToplevelV6 *toplevel READ toplevel NOTIFY toplevelCreated) - Q_PROPERTY(QWaylandXdgPopupV6 *popup READ popup NOTIFY popupCreated) - Q_PROPERTY(QRect windowGeometry READ windowGeometry NOTIFY windowGeometryChanged) - -public: - QWaylandXdgSurfaceV6(); - QWaylandXdgSurfaceV6(QWaylandXdgShellV6* xdgShell, QWaylandSurface *surface, const QWaylandResource &resource); - - Q_INVOKABLE void initialize(QWaylandXdgShellV6* xdgShell, QWaylandSurface *surface, const QWaylandResource &resource); - - Qt::WindowType windowType() const override; - - QWaylandXdgShellV6 *shell() const; - QWaylandSurface *surface() const; - QWaylandXdgToplevelV6 *toplevel() const; - QWaylandXdgPopupV6 *popup() const; - QRect windowGeometry() const; - - static const struct wl_interface *interface(); - static QByteArray interfaceName(); - static QWaylandXdgSurfaceV6 *fromResource(::wl_resource *resource); - -#if QT_CONFIG(wayland_compositor_quick) - QWaylandQuickShellIntegration *createIntegration(QWaylandQuickShellSurfaceItem *item) override; -#endif - -Q_SIGNALS: - void shellChanged(); - void surfaceChanged(); - void toplevelCreated(); - void popupCreated(); - void windowGeometryChanged(); - -private: - void initialize() override; - -private Q_SLOTS: - void handleSurfaceSizeChanged(); - void handleBufferScaleChanged(); -}; - -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgToplevelV6 : public QObject -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QWaylandXdgToplevelV6) - Q_PROPERTY(QWaylandXdgToplevelV6 *parentToplevel READ parentToplevel NOTIFY parentToplevelChanged) - Q_PROPERTY(QString title READ title NOTIFY titleChanged) - Q_PROPERTY(QString appId READ appId NOTIFY appIdChanged) - Q_PROPERTY(QSize maxSize READ maxSize NOTIFY maxSizeChanged) - Q_PROPERTY(QSize minSize READ minSize NOTIFY minSizeChanged) - Q_PROPERTY(QList<int> states READ statesAsInts NOTIFY statesChanged) - Q_PROPERTY(bool maximized READ maximized NOTIFY maximizedChanged) - Q_PROPERTY(bool fullscreen READ fullscreen NOTIFY fullscreenChanged) - Q_PROPERTY(bool resizing READ resizing NOTIFY resizingChanged) - Q_PROPERTY(bool activated READ activated NOTIFY activatedChanged) -public: - enum State : uint { - MaximizedState = 1, - FullscreenState = 2, - ResizingState = 3, - ActivatedState = 4 - }; - Q_ENUM(State) - - QWaylandXdgToplevelV6(QWaylandXdgSurfaceV6 *xdgSurface, QWaylandResource &resource); - - QWaylandXdgToplevelV6 *parentToplevel() const; - - QString title() const; - QString appId() const; - QSize maxSize() const; - QSize minSize() const; - QVector<QWaylandXdgToplevelV6::State> states() const; - bool maximized() const; - bool fullscreen() const; - bool resizing() const; - bool activated() const; - - Q_INVOKABLE QSize sizeForResize(const QSizeF &size, const QPointF &delta, Qt::Edges edges) const; - uint sendConfigure(const QSize &size, const QVector<State> &states); - Q_INVOKABLE uint sendConfigure(const QSize &size, const QVector<int> &states); - Q_INVOKABLE void sendClose(); - Q_INVOKABLE uint sendMaximized(const QSize &size); - Q_INVOKABLE uint sendUnmaximized(const QSize &size = QSize(0, 0)); - Q_INVOKABLE uint sendFullscreen(const QSize &size); - Q_INVOKABLE uint sendResizing(const QSize &maxSize); - - static QWaylandSurfaceRole *role(); - -Q_SIGNALS: - void parentToplevelChanged(); - void titleChanged(); - void appIdChanged(); - void maxSizeChanged(); - void minSizeChanged(); - void startMove(QWaylandSeat *seat); - void startResize(QWaylandSeat *seat, Qt::Edges edges); - void statesChanged(); - void maximizedChanged(); - void fullscreenChanged(); - void resizingChanged(); - void activatedChanged(); - - void showWindowMenu(QWaylandSeat *seat, const QPoint &localSurfacePosition); - void setMaximized(); - void unsetMaximized(); - void setFullscreen(QWaylandOutput *output); - void unsetFullscreen(); - void setMinimized(); - -private: - QList<int> statesAsInts() const; -}; - -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgPopupV6 : public QObject -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QWaylandXdgPopupV6) - Q_PROPERTY(QWaylandXdgSurfaceV6 *xdgSurface READ xdgSurface) - Q_PROPERTY(QWaylandXdgSurfaceV6 *parentXdgSurface READ parentXdgSurface) - Q_PROPERTY(QRect configuredGeometry READ configuredGeometry NOTIFY configuredGeometryChanged) - - // Positioner properties - Q_PROPERTY(QRect anchorRect READ anchorRect CONSTANT) - Q_PROPERTY(Qt::Edges anchorEdges READ anchorEdges CONSTANT) - Q_PROPERTY(Qt::Edges gravityEdges READ gravityEdges CONSTANT) - Q_PROPERTY(Qt::Orientations slideConstraints READ slideConstraints CONSTANT) - Q_PROPERTY(Qt::Orientations flipConstraints READ flipConstraints CONSTANT) - Q_PROPERTY(Qt::Orientations resizeConstraints READ resizeConstraints CONSTANT) - Q_PROPERTY(QPoint offset READ offset CONSTANT) - Q_PROPERTY(QSize positionerSize READ positionerSize CONSTANT) - Q_PROPERTY(QPoint unconstrainedPosition READ unconstrainedPosition CONSTANT) -public: - QWaylandXdgSurfaceV6 *xdgSurface() const; - QWaylandXdgSurfaceV6 *parentXdgSurface() const; - QRect configuredGeometry() const; - - // Positioner properties - QRect anchorRect() const; - Qt::Edges anchorEdges() const ; - Qt::Edges gravityEdges() const ; - Qt::Orientations slideConstraints() const; - Qt::Orientations flipConstraints() const; - Qt::Orientations resizeConstraints() const; - QPoint offset() const; - QSize positionerSize() const; - QPoint unconstrainedPosition() const; - - Q_INVOKABLE uint sendConfigure(const QRect &geometry); - Q_REVISION(14) Q_INVOKABLE void sendPopupDone(); - - static QWaylandSurfaceRole *role(); - -Q_SIGNALS: - void configuredGeometryChanged(); - -private: - QWaylandXdgPopupV6(QWaylandXdgSurfaceV6 *xdgSurface, QWaylandXdgSurfaceV6 *parentXdgSurface, - QWaylandXdgPositionerV6 *positioner, QWaylandResource &resource); - friend class QWaylandXdgSurfaceV6Private; -}; - -QT_END_NAMESPACE - -#endif // QWAYLANDXDGSHELLV6_H diff --git a/src/compositor/extensions/qwaylandxdgshellv6_p.h b/src/compositor/extensions/qwaylandxdgshellv6_p.h deleted file mode 100644 index 457bc2201..000000000 --- a/src/compositor/extensions/qwaylandxdgshellv6_p.h +++ /dev/null @@ -1,246 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** 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 QWAYLANDXDGSHELLV6_P_H -#define QWAYLANDXDGSHELLV6_P_H - -#include <QtWaylandCompositor/private/qwaylandcompositorextension_p.h> -#include <QtWaylandCompositor/private/qwaylandshell_p.h> -#include <QtWaylandCompositor/private/qwayland-server-xdg-shell-unstable-v6.h> - -#include <QtWaylandCompositor/QWaylandXdgShellV6> - -#include <QtCore/QSet> - -// -// 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 - -struct Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgPositionerV6Data { - QSize size; - QRect anchorRect; - Qt::Edges anchorEdges = 0; - Qt::Edges gravityEdges = 0; - uint constraintAdjustments = ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_NONE; - QPoint offset; - QWaylandXdgPositionerV6Data(); - bool isComplete() const; - QPoint anchorPoint() const; - QPoint unconstrainedPosition() const; -}; - -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgShellV6Private - : public QWaylandShellPrivate - , public QtWaylandServer::zxdg_shell_v6 -{ - Q_DECLARE_PUBLIC(QWaylandXdgShellV6) -public: - QWaylandXdgShellV6Private(); - void ping(Resource *resource, uint32_t serial); - void registerXdgSurface(QWaylandXdgSurfaceV6 *xdgSurface); - void unregisterXdgSurface(QWaylandXdgSurfaceV6 *xdgSurface); - static QWaylandXdgShellV6Private *get(QWaylandXdgShellV6 *xdgShell) { return xdgShell->d_func(); } - static Qt::Edges convertToEdges(uint xdgEdges); - - QSet<uint32_t> m_pings; - QMultiMap<struct wl_client *, QWaylandXdgSurfaceV6 *> m_xdgSurfaces; - - QWaylandXdgSurfaceV6 *xdgSurfaceFromSurface(QWaylandSurface *surface); - -protected: - void zxdg_shell_v6_destroy(Resource *resource) override; - void zxdg_shell_v6_create_positioner(Resource *resource, uint32_t id) override; - void zxdg_shell_v6_get_xdg_surface(Resource *resource, uint32_t id, - struct ::wl_resource *surface) override; - void zxdg_shell_v6_pong(Resource *resource, uint32_t serial) override; -}; - -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgSurfaceV6Private - : public QWaylandCompositorExtensionPrivate - , public QtWaylandServer::zxdg_surface_v6 -{ - Q_DECLARE_PUBLIC(QWaylandXdgSurfaceV6) -public: - QWaylandXdgSurfaceV6Private(); - void setWindowType(Qt::WindowType windowType); - void handleFocusLost(); - void handleFocusReceived(); - static QWaylandXdgSurfaceV6Private *get(QWaylandXdgSurfaceV6 *xdgSurface) { return xdgSurface->d_func(); } - - QRect calculateFallbackWindowGeometry() const; - void updateFallbackWindowGeometry(); - -private: - QWaylandXdgShellV6 *m_xdgShell = nullptr; - QWaylandSurface *m_surface = nullptr; - - QWaylandXdgToplevelV6 *m_toplevel = nullptr; - QWaylandXdgPopupV6 *m_popup = nullptr; - QRect m_windowGeometry; - bool m_unsetWindowGeometry = true; - QMargins m_windowMargins; - Qt::WindowType m_windowType = Qt::WindowType::Window; - - void zxdg_surface_v6_destroy_resource(Resource *resource) override; - void zxdg_surface_v6_destroy(Resource *resource) override; - void zxdg_surface_v6_get_toplevel(Resource *resource, uint32_t id) override; - void zxdg_surface_v6_get_popup(Resource *resource, uint32_t id, struct ::wl_resource *parent, struct ::wl_resource *positioner) override; - void zxdg_surface_v6_ack_configure(Resource *resource, uint32_t serial) override; - void zxdg_surface_v6_set_window_geometry(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) override; -}; - -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgToplevelV6Private : public QObjectPrivate, public QtWaylandServer::zxdg_toplevel_v6 -{ - Q_DECLARE_PUBLIC(QWaylandXdgToplevelV6) -public: - struct ConfigureEvent { - ConfigureEvent() = default; - ConfigureEvent(const QVector<QWaylandXdgToplevelV6::State> - &incomingStates, - const QSize &incomingSize, uint incomingSerial) - : states(incomingStates), size(incomingSize), serial(incomingSerial) - { } - QVector<QWaylandXdgToplevelV6::State> states; - QSize size = {0, 0}; - uint serial = 0; - }; - - QWaylandXdgToplevelV6Private(QWaylandXdgSurfaceV6 *xdgSurface, const QWaylandResource& resource); - ConfigureEvent lastSentConfigure() const { return m_pendingConfigures.empty() ? m_lastAckedConfigure : m_pendingConfigures.last(); } - void handleAckConfigure(uint serial); //TODO: move? - void handleFocusLost(); - void handleFocusReceived(); - - static QWaylandXdgToplevelV6Private *get(QWaylandXdgToplevelV6 *toplevel) { return toplevel->d_func(); } - -protected: - - void zxdg_toplevel_v6_destroy_resource(Resource *resource) override; - - void zxdg_toplevel_v6_destroy(Resource *resource) override; - void zxdg_toplevel_v6_set_parent(Resource *resource, struct ::wl_resource *parent) override; - void zxdg_toplevel_v6_set_title(Resource *resource, const QString &title) override; - void zxdg_toplevel_v6_set_app_id(Resource *resource, const QString &app_id) override; - void zxdg_toplevel_v6_show_window_menu(Resource *resource, struct ::wl_resource *seat, uint32_t serial, int32_t x, int32_t y) override; - void zxdg_toplevel_v6_move(Resource *resource, struct ::wl_resource *seatResource, uint32_t serial) override; - void zxdg_toplevel_v6_resize(Resource *resource, struct ::wl_resource *seat, uint32_t serial, uint32_t edges) override; - void zxdg_toplevel_v6_set_max_size(Resource *resource, int32_t width, int32_t height) override; - void zxdg_toplevel_v6_set_min_size(Resource *resource, int32_t width, int32_t height) override; - void zxdg_toplevel_v6_set_maximized(Resource *resource) override; - void zxdg_toplevel_v6_unset_maximized(Resource *resource) override; - void zxdg_toplevel_v6_set_fullscreen(Resource *resource, struct ::wl_resource *output) override; - void zxdg_toplevel_v6_unset_fullscreen(Resource *resource) override; - void zxdg_toplevel_v6_set_minimized(Resource *resource) override; - -public: - QWaylandXdgSurfaceV6 *m_xdgSurface = nullptr; - QWaylandXdgToplevelV6 *m_parentToplevel = nullptr; - QList<ConfigureEvent> m_pendingConfigures; - ConfigureEvent m_lastAckedConfigure; - QString m_title; - QString m_appId; - QSize m_maxSize; - QSize m_minSize; - - static QWaylandSurfaceRole s_role; -}; - -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgPopupV6Private : public QObjectPrivate, public QtWaylandServer::zxdg_popup_v6 -{ - Q_DECLARE_PUBLIC(QWaylandXdgPopupV6) -public: - struct ConfigureEvent { - QRect geometry; - uint serial; - }; - - QWaylandXdgPopupV6Private(QWaylandXdgSurfaceV6 *xdgSurface, QWaylandXdgSurfaceV6 *parentXdgSurface, - QWaylandXdgPositionerV6 *positioner, const QWaylandResource& resource); - - void handleAckConfigure(uint serial); - - static QWaylandXdgPopupV6Private *get(QWaylandXdgPopupV6 *popup) { return popup->d_func(); } - - static QWaylandSurfaceRole s_role; - -private: - uint sendConfigure(const QRect &geometry); - -protected: - void zxdg_popup_v6_destroy(Resource *resource) override; - void zxdg_popup_v6_grab(Resource *resource, struct ::wl_resource *seat, uint32_t serial) override; - -private: - QWaylandXdgSurfaceV6 *m_xdgSurface = nullptr; - QWaylandXdgSurfaceV6 *m_parentXdgSurface = nullptr; - QWaylandXdgPositionerV6Data m_positionerData; - QRect m_geometry; - QList<ConfigureEvent> m_pendingConfigures; -}; - -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgPositionerV6 : public QtWaylandServer::zxdg_positioner_v6 -{ -public: - QWaylandXdgPositionerV6(const QWaylandResource& resource); - static QWaylandXdgPositionerV6 *fromResource(wl_resource *resource); - -protected: - void zxdg_positioner_v6_destroy_resource(Resource *resource) override; //TODO: do something special here? - - void zxdg_positioner_v6_destroy(Resource *resource) override; - void zxdg_positioner_v6_set_size(Resource *resource, int32_t width, int32_t height) override; - void zxdg_positioner_v6_set_anchor_rect(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) override; - void zxdg_positioner_v6_set_anchor(Resource *resource, uint32_t anchor) override; - void zxdg_positioner_v6_set_gravity(Resource *resource, uint32_t gravity) override; - void zxdg_positioner_v6_set_constraint_adjustment(Resource *resource, uint32_t constraint_adjustment) override; - void zxdg_positioner_v6_set_offset(Resource *resource, int32_t x, int32_t y) override; - -public: - QWaylandXdgPositionerV6Data m_data; -}; - -QT_END_NAMESPACE - -#endif // QWAYLANDXDGSHELLV6_P_H diff --git a/src/compositor/extensions/qwaylandxdgshellv6integration.cpp b/src/compositor/extensions/qwaylandxdgshellv6integration.cpp deleted file mode 100644 index e424af193..000000000 --- a/src/compositor/extensions/qwaylandxdgshellv6integration.cpp +++ /dev/null @@ -1,312 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** 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 "qwaylandxdgshellv6integration_p.h" - -#include <QtWaylandCompositor/QWaylandXdgSurfaceV6> -#include <QtWaylandCompositor/QWaylandCompositor> -#include <QtWaylandCompositor/QWaylandSeat> - -QT_BEGIN_NAMESPACE - -namespace QtWayland { - -static void handlePopupCreated(QWaylandQuickShellSurfaceItem *parentItem, QWaylandXdgPopupV6 *popup) -{ - if (parentItem->shellSurface() == popup->parentXdgSurface()) - QWaylandQuickShellSurfaceItemPrivate::get(parentItem)->maybeCreateAutoPopup(popup->xdgSurface()); -} - -XdgToplevelV6Integration::XdgToplevelV6Integration(QWaylandQuickShellSurfaceItem *item) - : QWaylandQuickShellIntegration(item) - , m_item(item) - , m_xdgSurface(qobject_cast<QWaylandXdgSurfaceV6 *>(item->shellSurface())) - , m_toplevel(m_xdgSurface->toplevel()) - , grabberState(GrabberState::Default) -{ - Q_ASSERT(m_toplevel); - - m_item->setSurface(m_xdgSurface->surface()); - - connect(m_toplevel, &QWaylandXdgToplevelV6::startMove, this, &XdgToplevelV6Integration::handleStartMove); - connect(m_toplevel, &QWaylandXdgToplevelV6::startResize, this, &XdgToplevelV6Integration::handleStartResize); - connect(m_toplevel, &QWaylandXdgToplevelV6::setMaximized, this, &XdgToplevelV6Integration::handleSetMaximized); - connect(m_toplevel, &QWaylandXdgToplevelV6::unsetMaximized, this, &XdgToplevelV6Integration::handleUnsetMaximized); - connect(m_toplevel, &QWaylandXdgToplevelV6::maximizedChanged, this, &XdgToplevelV6Integration::handleMaximizedChanged); - connect(m_toplevel, &QWaylandXdgToplevelV6::setFullscreen, this, &XdgToplevelV6Integration::handleSetFullscreen); - connect(m_toplevel, &QWaylandXdgToplevelV6::unsetFullscreen, this, &XdgToplevelV6Integration::handleUnsetFullscreen); - connect(m_toplevel, &QWaylandXdgToplevelV6::fullscreenChanged, this, &XdgToplevelV6Integration::handleFullscreenChanged); - connect(m_toplevel, &QWaylandXdgToplevelV6::activatedChanged, this, &XdgToplevelV6Integration::handleActivatedChanged); - connect(m_xdgSurface->shell(), &QWaylandXdgShellV6::popupCreated, this, [item](QWaylandXdgPopupV6 *popup, QWaylandXdgSurfaceV6 *){ - handlePopupCreated(item, popup); - }); - connect(m_xdgSurface->surface(), &QWaylandSurface::destinationSizeChanged, this, &XdgToplevelV6Integration::handleSurfaceSizeChanged); - connect(m_toplevel, &QObject::destroyed, this, &XdgToplevelV6Integration::handleToplevelDestroyed); -} - -bool XdgToplevelV6Integration::eventFilter(QObject *object, QEvent *event) -{ - if (event->type() == QEvent::MouseMove) { - QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event); - return filterMouseMoveEvent(mouseEvent); - } else if (event->type() == QEvent::MouseButtonRelease) { - QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event); - return filterMouseReleaseEvent(mouseEvent); - } - return QWaylandQuickShellIntegration::eventFilter(object, event); -} - -bool XdgToplevelV6Integration::filterMouseMoveEvent(QMouseEvent *event) -{ - if (grabberState == GrabberState::Resize) { - Q_ASSERT(resizeState.seat == m_item->compositor()->seatFor(event)); - if (!resizeState.initialized) { - resizeState.initialMousePos = event->windowPos(); - resizeState.initialized = true; - return true; - } - QPointF delta = m_item->mapToSurface(event->windowPos() - resizeState.initialMousePos); - QSize newSize = m_toplevel->sizeForResize(resizeState.initialWindowSize, delta, resizeState.resizeEdges); - m_toplevel->sendResizing(newSize); - } else if (grabberState == GrabberState::Move) { - Q_ASSERT(moveState.seat == m_item->compositor()->seatFor(event)); - QQuickItem *moveItem = m_item->moveItem(); - if (!moveState.initialized) { - moveState.initialOffset = moveItem->mapFromItem(nullptr, event->windowPos()); - moveState.initialized = true; - return true; - } - if (!moveItem->parentItem()) - return true; - QPointF parentPos = moveItem->parentItem()->mapFromItem(nullptr, event->windowPos()); - moveItem->setPosition(parentPos - moveState.initialOffset); - } - return false; -} - -bool XdgToplevelV6Integration::filterMouseReleaseEvent(QMouseEvent *event) -{ - Q_UNUSED(event); - - if (grabberState != GrabberState::Default) { - grabberState = GrabberState::Default; - return true; - } - return false; -} - -void XdgToplevelV6Integration::handleStartMove(QWaylandSeat *seat) -{ - grabberState = GrabberState::Move; - moveState.seat = seat; - moveState.initialized = false; -} - -void XdgToplevelV6Integration::handleStartResize(QWaylandSeat *seat, Qt::Edges edges) -{ - grabberState = GrabberState::Resize; - resizeState.seat = seat; - resizeState.resizeEdges = edges; - resizeState.initialWindowSize = m_xdgSurface->windowGeometry().size(); - resizeState.initialPosition = m_item->moveItem()->position(); - resizeState.initialSurfaceSize = m_item->surface()->destinationSize(); - resizeState.initialized = false; -} - -void XdgToplevelV6Integration::handleSetMaximized() -{ - if (!m_item->view()->isPrimary()) - return; - - QVector<QWaylandXdgToplevelV6::State> states = m_toplevel->states(); - - if (!states.contains(QWaylandXdgToplevelV6::State::FullscreenState) && !states.contains(QWaylandXdgToplevelV6::State::MaximizedState)) { - windowedGeometry.initialWindowSize = m_xdgSurface->windowGeometry().size(); - windowedGeometry.initialPosition = m_item->moveItem()->position(); - } - - // Any prior output-resize handlers are irrelevant at this point. - disconnect(nonwindowedState.sizeChangedConnection); - nonwindowedState.output = m_item->view()->output(); - nonwindowedState.sizeChangedConnection = connect(nonwindowedState.output, &QWaylandOutput::availableGeometryChanged, this, &XdgToplevelV6Integration::handleMaximizedSizeChanged); - handleMaximizedSizeChanged(); -} - -void XdgToplevelV6Integration::handleMaximizedSizeChanged() -{ - // Insurance against handleToplevelDestroyed() not managing to disconnect this - // handler in time. - if (m_toplevel == nullptr) - return; - - m_toplevel->sendMaximized(nonwindowedState.output->availableGeometry().size() / nonwindowedState.output->scaleFactor()); -} - -void XdgToplevelV6Integration::handleUnsetMaximized() -{ - if (!m_item->view()->isPrimary()) - return; - - // If no prior windowed size was recorded, send a 0x0 configure event - // to allow the client to choose its preferred size. - if (windowedGeometry.initialWindowSize.isValid()) - m_toplevel->sendUnmaximized(windowedGeometry.initialWindowSize); - else - m_toplevel->sendUnmaximized(); -} - -void XdgToplevelV6Integration::handleMaximizedChanged() -{ - if (m_toplevel->maximized()) { - QWaylandOutput *output = m_item->view()->output(); - m_item->moveItem()->setPosition(output->position() + output->availableGeometry().topLeft()); - } else { - m_item->moveItem()->setPosition(windowedGeometry.initialPosition); - } -} - -void XdgToplevelV6Integration::handleSetFullscreen() -{ - if (!m_item->view()->isPrimary()) - return; - - QVector<QWaylandXdgToplevelV6::State> states = m_toplevel->states(); - - if (!states.contains(QWaylandXdgToplevelV6::State::FullscreenState) && !states.contains(QWaylandXdgToplevelV6::State::MaximizedState)) { - windowedGeometry.initialWindowSize = m_xdgSurface->windowGeometry().size(); - windowedGeometry.initialPosition = m_item->moveItem()->position(); - } - - // Any prior output-resize handlers are irrelevant at this point. - disconnect(nonwindowedState.sizeChangedConnection); - nonwindowedState.output = m_item->view()->output(); - nonwindowedState.sizeChangedConnection = connect(nonwindowedState.output, &QWaylandOutput::geometryChanged, this, &XdgToplevelV6Integration::handleFullscreenSizeChanged); - handleFullscreenSizeChanged(); -} - -void XdgToplevelV6Integration::handleFullscreenSizeChanged() -{ - // Insurance against handleToplevelDestroyed() not managing to disconnect this - // handler in time. - if (m_toplevel == nullptr) - return; - - m_toplevel->sendFullscreen(nonwindowedState.output->geometry().size() / nonwindowedState.output->scaleFactor()); -} - -void XdgToplevelV6Integration::handleUnsetFullscreen() -{ - if (!m_item->view()->isPrimary()) - return; - - // If no prior windowed size was recorded, send a 0x0 configure event - // to allow the client to choose its preferred size. - if (windowedGeometry.initialWindowSize.isValid()) - m_toplevel->sendUnmaximized(windowedGeometry.initialWindowSize); - else - m_toplevel->sendUnmaximized(); -} - -void XdgToplevelV6Integration::handleFullscreenChanged() -{ - if (m_toplevel->fullscreen()) { - QWaylandOutput *output = m_item->view()->output(); - m_item->moveItem()->setPosition(output->position() + output->geometry().topLeft()); - } else { - m_item->moveItem()->setPosition(windowedGeometry.initialPosition); - } -} - -void XdgToplevelV6Integration::handleActivatedChanged() -{ - if (m_toplevel->activated()) - m_item->raise(); -} - -void XdgToplevelV6Integration::handleSurfaceSizeChanged() -{ - if (grabberState == GrabberState::Resize) { - qreal dx = 0; - qreal dy = 0; - if (resizeState.resizeEdges & Qt::TopEdge) - dy = resizeState.initialSurfaceSize.height() - m_item->surface()->destinationSize().height(); - if (resizeState.resizeEdges & Qt::LeftEdge) - dx = resizeState.initialSurfaceSize.width() - m_item->surface()->destinationSize().width(); - QPointF offset = m_item->mapFromSurface({dx, dy}); - m_item->moveItem()->setPosition(resizeState.initialPosition + offset); - } -} - -void XdgToplevelV6Integration::handleToplevelDestroyed() -{ - // Disarm any handlers that might fire on the now-stale toplevel pointer - nonwindowedState.output = nullptr; - disconnect(nonwindowedState.sizeChangedConnection); -} - -XdgPopupV6Integration::XdgPopupV6Integration(QWaylandQuickShellSurfaceItem *item) - : m_item(item) - , m_xdgSurface(qobject_cast<QWaylandXdgSurfaceV6 *>(item->shellSurface())) - , m_popup(m_xdgSurface->popup()) -{ - Q_ASSERT(m_popup); - - m_item->setSurface(m_xdgSurface->surface()); - handleGeometryChanged(); - - connect(m_popup, &QWaylandXdgPopupV6::configuredGeometryChanged, this, &XdgPopupV6Integration::handleGeometryChanged); - connect(m_xdgSurface->shell(), &QWaylandXdgShellV6::popupCreated, this, [item](QWaylandXdgPopupV6 *popup, QWaylandXdgSurfaceV6 *){ - handlePopupCreated(item, popup); - }); -} - -void XdgPopupV6Integration::handleGeometryChanged() -{ - if (m_item->view()->output()) { - const QPoint windowOffset = m_popup->parentXdgSurface()->windowGeometry().topLeft(); - const QPoint surfacePosition = m_popup->unconstrainedPosition() + windowOffset; - const QPoint itemPosition = m_item->mapFromSurface(surfacePosition).toPoint(); - //TODO: positioner size or other size...? - //TODO check positioner constraints etc... sliding, flipping - m_item->moveItem()->setPosition(itemPosition); - } else { - qWarning() << "XdgPopupV6Integration popup item without output" << m_item; - } -} - -} - -QT_END_NAMESPACE diff --git a/src/compositor/extensions/qwaylandxdgshellv6integration_p.h b/src/compositor/extensions/qwaylandxdgshellv6integration_p.h deleted file mode 100644 index 9df2885f1..000000000 --- a/src/compositor/extensions/qwaylandxdgshellv6integration_p.h +++ /dev/null @@ -1,148 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** 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 QWAYLANDXDGSHELLV6INTEGRATION_H -#define QWAYLANDXDGSHELLV6INTEGRATION_H - -#include <QtWaylandCompositor/private/qwaylandquickshellsurfaceitem_p.h> -#include <QtWaylandCompositor/QWaylandQuickShellSurfaceItem> -#include <QtWaylandCompositor/QWaylandXdgToplevelV6> - -QT_BEGIN_NAMESPACE - -// -// 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. -// - -class QWaylandXdgSurfaceV6; - -namespace QtWayland { - -class XdgToplevelV6Integration : public QWaylandQuickShellIntegration -{ - Q_OBJECT -public: - XdgToplevelV6Integration(QWaylandQuickShellSurfaceItem *item); - -protected: - bool eventFilter(QObject *object, QEvent *event) override; - -private Q_SLOTS: - void handleStartMove(QWaylandSeat *seat); - void handleStartResize(QWaylandSeat *seat, Qt::Edges edges); - void handleSetMaximized(); - void handleUnsetMaximized(); - void handleMaximizedChanged(); - void handleSetFullscreen(); - void handleUnsetFullscreen(); - void handleFullscreenChanged(); - void handleActivatedChanged(); - void handleSurfaceSizeChanged(); - void handleToplevelDestroyed(); - void handleMaximizedSizeChanged(); - void handleFullscreenSizeChanged(); - -private: - QWaylandQuickShellSurfaceItem *m_item = nullptr; - QWaylandXdgSurfaceV6 *m_xdgSurface = nullptr; - QWaylandXdgToplevelV6 *m_toplevel = nullptr; - - enum class GrabberState { - Default, - Resize, - Move - }; - GrabberState grabberState; - - struct { - QWaylandSeat *seat = nullptr; - QPointF initialOffset; - bool initialized = false; - } moveState; - - struct { - QWaylandSeat *seat = nullptr; - Qt::Edges resizeEdges; - QSizeF initialWindowSize; - QPointF initialMousePos; - QPointF initialPosition; - QSize initialSurfaceSize; - bool initialized = false; - } resizeState; - - struct { - QSize initialWindowSize; - QPointF initialPosition; - } windowedGeometry; - - struct { - QWaylandOutput *output = nullptr; - QMetaObject::Connection sizeChangedConnection; // Depending on whether maximized or fullscreen, - // will be hooked to geometry-changed or available- - // geometry-changed. - } nonwindowedState; - - bool filterMouseMoveEvent(QMouseEvent *event); - bool filterMouseReleaseEvent(QMouseEvent *event); -}; - -class XdgPopupV6Integration : public QWaylandQuickShellIntegration -{ - Q_OBJECT -public: - XdgPopupV6Integration(QWaylandQuickShellSurfaceItem *item); - -private Q_SLOTS: - void handleGeometryChanged(); - -private: - QWaylandQuickShellSurfaceItem *m_item = nullptr; - QWaylandXdgSurfaceV6 *m_xdgSurface = nullptr; - QWaylandXdgPopupV6 *m_popup = nullptr; -}; - -} - -QT_END_NAMESPACE - -#endif // QWAYLANDXDGSHELLV6INTEGRATION_H diff --git a/src/compositor/extensions/qwlqtkey.cpp b/src/compositor/extensions/qwlqtkey.cpp index 03a97c7ee..fb0f760ba 100644 --- a/src/compositor/extensions/qwlqtkey.cpp +++ b/src/compositor/extensions/qwlqtkey.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwlqtkey_p.h" #include <QtWaylandCompositor/QWaylandSurface> @@ -69,3 +43,5 @@ bool QtKeyExtensionGlobal::postQtKeyEvent(QKeyEvent *event, QWaylandSurface *sur } QT_END_NAMESPACE + +#include "moc_qwlqtkey_p.cpp" diff --git a/src/compositor/extensions/qwlqtkey_p.h b/src/compositor/extensions/qwlqtkey_p.h index f0517e50f..e7cff9607 100644 --- a/src/compositor/extensions/qwlqtkey_p.h +++ b/src/compositor/extensions/qwlqtkey_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef WLQTKEY_H #define WLQTKEY_H @@ -44,6 +18,7 @@ #include <QtWaylandCompositor/QWaylandCompositorExtensionTemplate> #include <QtWaylandCompositor/QWaylandCompositor> #include <QtWaylandCompositor/private/qwayland-server-qt-key-unstable-v1.h> +#include <QtCore/private/qglobal_p.h> #include <wayland-util.h> diff --git a/src/compositor/extensions/qwlqttouch.cpp b/src/compositor/extensions/qwlqttouch.cpp index 1f92432fb..1435dde1e 100644 --- a/src/compositor/extensions/qwlqttouch.cpp +++ b/src/compositor/extensions/qwlqttouch.cpp @@ -1,34 +1,9 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwlqttouch_p.h" #include "qwaylandview.h" +#include <QPointingDevice> #include <QTouchEvent> #include <QWindow> @@ -57,14 +32,14 @@ static inline int toFixed(qreal f) bool TouchExtensionGlobal::postTouchEvent(QTouchEvent *event, QWaylandSurface *surface) { - const QList<QTouchEvent::TouchPoint> points = event->touchPoints(); - const int pointCount = points.count(); + const QList<QTouchEvent::TouchPoint> points = event->points(); + const int pointCount = points.size(); if (!pointCount) return false; wl_client *surfaceClient = surface->client()->client(); uint32_t time = m_compositor->currentTimeMsecs(); - const int rescount = m_resources.count(); + const int rescount = m_resources.size(); for (int res = 0; res < rescount; ++res) { Resource *target = m_resources.at(res); @@ -76,47 +51,31 @@ bool TouchExtensionGlobal::postTouchEvent(QTouchEvent *event, QWaylandSurface *s // included in the touch point events. int sentPointCount = 0; for (int i = 0; i < pointCount; ++i) { - if (points.at(i).state() != Qt::TouchPointStationary) + if (points.at(i).state() != QEventPoint::Stationary) ++sentPointCount; } for (int i = 0; i < pointCount; ++i) { const QTouchEvent::TouchPoint &tp(points.at(i)); // Stationary points are never sent. They are cached on client side. - if (tp.state() == Qt::TouchPointStationary) + if (tp.state() == QEventPoint::Stationary) continue; uint32_t id = tp.id(); uint32_t state = (tp.state() & 0xFFFF) | (sentPointCount << 16); - uint32_t flags = (tp.flags() & 0xFFFF) | (int(event->device()->capabilities()) << 16); - - int x = toFixed(tp.pos().x()); - int y = toFixed(tp.pos().y()); - int nx = toFixed(tp.normalizedPos().x()); - int ny = toFixed(tp.normalizedPos().y()); - int w = toFixed(tp.rect().width()); - int h = toFixed(tp.rect().height()); + uint32_t flags = (int(event->pointingDevice()->capabilities()) << 16); + + int x = toFixed(tp.position().x()); + int y = toFixed(tp.position().y()); + int nx = toFixed(tp.normalizedPosition().x()); + int ny = toFixed(tp.normalizedPosition().y()); + int w = toFixed(tp.ellipseDiameters().width()); + int h = toFixed(tp.ellipseDiameters().height()); int vx = toFixed(tp.velocity().x()); int vy = toFixed(tp.velocity().y()); uint32_t pressure = uint32_t(tp.pressure() * 255); QByteArray rawData; - QVector<QPointF> rawPosList = tp.rawScreenPositions(); - int rawPosCount = rawPosList.count(); - if (rawPosCount) { - rawPosCount = qMin(maxRawPos, rawPosCount); - QVector<float>::iterator iter = m_posData.begin(); - for (int rpi = 0; rpi < rawPosCount; ++rpi) { - const QPointF &rawPos(rawPosList.at(rpi)); - // This will stay in screen coordinates for performance - // reasons, clients using this data will presumably know - // what they are doing. - *iter++ = static_cast<float>(rawPos.x()); - *iter++ = static_cast<float>(rawPos.y()); - } - rawData = QByteArray::fromRawData(reinterpret_cast<const char*>(m_posData.constData()), sizeof(float) * rawPosCount * 2); - } - send_touch(target->handle, time, id, state, x, y, nx, ny, w, h, @@ -153,3 +112,5 @@ void TouchExtensionGlobal::touch_extension_destroy_resource(Resource *resource) } QT_END_NAMESPACE + +#include "moc_qwlqttouch_p.cpp" diff --git a/src/compositor/extensions/qwlqttouch_p.h b/src/compositor/extensions/qwlqttouch_p.h index 76087151c..2d96da7fc 100644 --- a/src/compositor/extensions/qwlqttouch_p.h +++ b/src/compositor/extensions/qwlqttouch_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef WLTOUCH_H #define WLTOUCH_H @@ -44,6 +18,7 @@ #include <QtWaylandCompositor/private/qwayland-server-touch-extension.h> #include <QtWaylandCompositor/QWaylandCompositor> #include <QtWaylandCompositor/QWaylandCompositorExtensionTemplate> +#include <QtCore/private/qglobal_p.h> #include <wayland-util.h> @@ -86,7 +61,7 @@ private: QWaylandCompositor *m_compositor = nullptr; BehaviorFlags m_flags = BehaviorFlag::None; QList<Resource *> m_resources; - QVector<float> m_posData; + QList<float> m_posData; }; Q_DECLARE_OPERATORS_FOR_FLAGS(TouchExtensionGlobal::BehaviorFlags) diff --git a/src/compositor/extensions/qwltexturesharingextension.cpp b/src/compositor/extensions/qwltexturesharingextension.cpp index 6f801e956..c474176d2 100644 --- a/src/compositor/extensions/qwltexturesharingextension.cpp +++ b/src/compositor/extensions/qwltexturesharingextension.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwltexturesharingextension_p.h" @@ -40,7 +14,8 @@ #include <QTimer> #include <QtGui/private/qtexturefilereader_p.h> -#include <QtGui/QOpenGLTexture> + +#include <QtOpenGL/QOpenGLTexture> #include <QtGui/QImageReader> #include <QtQuick/QSGTexture> @@ -49,66 +24,6 @@ QT_BEGIN_NAMESPACE -class SharedTexture : public QSGTexture -{ - Q_OBJECT -public: - SharedTexture(QtWayland::ServerBuffer *buffer); - - int textureId() const override; - QSize textureSize() const override; - bool hasAlphaChannel() const override; - bool hasMipmaps() const override; - - void bind() override; - -private: - void updateGLTexture() const; - QtWayland::ServerBuffer *m_buffer = nullptr; - mutable QOpenGLTexture *m_tex = nullptr; -}; - -SharedTexture::SharedTexture(QtWayland::ServerBuffer *buffer) - : m_buffer(buffer), m_tex(nullptr) -{ -} - -int SharedTexture::textureId() const -{ - updateGLTexture(); - return m_tex ? m_tex->textureId() : 0; -} - -QSize SharedTexture::textureSize() const -{ - updateGLTexture(); - return m_tex ? QSize(m_tex->width(), m_tex->height()) : QSize(); -} - -bool SharedTexture::hasAlphaChannel() const -{ - return true; -} - -bool SharedTexture::hasMipmaps() const -{ - updateGLTexture(); - return m_tex ? (m_tex->mipLevels() > 1) : false; -} - -void SharedTexture::bind() -{ - updateGLTexture(); - if (m_tex) - m_tex->bind(); -} - -inline void SharedTexture::updateGLTexture() const -{ - if (!m_tex && m_buffer) - m_tex = m_buffer->toOpenGlTexture(); -} - class SharedTextureFactory : public QQuickTextureFactory { public: @@ -133,9 +48,17 @@ public: return m_buffer ? (m_buffer->size().width() * m_buffer->size().height() * 4) : 0; } - QSGTexture *createTexture(QQuickWindow *) const override + QSGTexture *createTexture(QQuickWindow *window) const override { - return new SharedTexture(const_cast<QtWayland::ServerBuffer *>(m_buffer)); + if (m_buffer != nullptr) { + QOpenGLTexture *texture = const_cast<QtWayland::ServerBuffer *>(m_buffer)->toOpenGlTexture(); + return QNativeInterface::QSGOpenGLTexture::fromNative(texture->textureId(), + window, + m_buffer->size(), + QQuickWindow::TextureHasAlphaChannel); + } + + return nullptr; } private: @@ -176,7 +99,7 @@ public: return m_errorString; } -public slots: +public Q_SLOTS: void doResponse(const QString &key, QtWayland::ServerBuffer *buffer) { if (key != m_id) @@ -221,7 +144,7 @@ QQuickImageResponse *QWaylandSharedTextureProvider::requestImageResponse(const Q void QWaylandSharedTextureProvider::setExtensionReady(QWaylandTextureSharingExtension *extension) { - for (auto *response : qAsConst(m_pendingResponses)) + for (auto *response : std::as_const(m_pendingResponses)) response->doRequest(extension); m_pendingResponses.clear(); m_pendingResponses.squeeze(); @@ -276,7 +199,7 @@ void QWaylandTextureSharingExtension::initialize() auto suffixes = QTextureFileReader::supportedFileFormats(); suffixes.append(QImageReader::supportedImageFormats()); - for (auto ext : qAsConst(suffixes)) + for (auto ext : std::as_const(suffixes)) m_image_suffixes << QLatin1Char('.') + QString::fromLatin1(ext); //qDebug() << "m_image_suffixes" << m_image_suffixes << "m_image_dirs" << m_image_dirs; @@ -301,13 +224,13 @@ QString QWaylandTextureSharingExtension::getExistingFilePath(const QString &key) if (key.contains(QLatin1String("../"))) return QString(); - for (auto dir : m_image_dirs) { + for (auto dir : std::as_const(m_image_dirs)) { QString path = dir + key; if (QFileInfo::exists(path)) return path; } - for (auto dir : m_image_dirs) { + for (auto dir : std::as_const(m_image_dirs)) { for (auto ext : m_image_suffixes) { QString fp = dir + key + ext; //qDebug() << "trying" << fp; @@ -455,9 +378,8 @@ QtWayland::ServerBuffer *QWaylandTextureSharingExtension::getCompressedBuffer(co return nullptr; } - QByteArray pixelData = QByteArray::fromRawData(td.data().constData() + td.dataOffset(), td.dataLength()); - - return m_server_buffer_integration->createServerBufferFromData(pixelData, td.size(), td.glInternalFormat()); + return m_server_buffer_integration->createServerBufferFromData(td.getDataView(), td.size(), + td.glInternalFormat()); } void QWaylandTextureSharingExtension::cleanupBuffers() @@ -477,11 +399,13 @@ void QWaylandTextureSharingExtension::cleanupBuffers() void QWaylandTextureSharingExtension::dumpBufferInfo() { - qDebug() << "shared buffers:" << m_server_buffers.count(); + qDebug() << "shared buffers:" << m_server_buffers.size(); for (auto it = m_server_buffers.cbegin(); it != m_server_buffers.cend(); ++it) qDebug() << " " << it.key() << ":" << it.value().buffer << "in use" << it.value().buffer->bufferInUse() << "usedLocally" << it.value().usedLocally ; } QT_END_NAMESPACE +#include "moc_qwltexturesharingextension_p.cpp" + #include "qwltexturesharingextension.moc" diff --git a/src/compositor/extensions/qwltexturesharingextension_p.h b/src/compositor/extensions/qwltexturesharingextension_p.h index bd0cd66ba..92f9ee187 100644 --- a/src/compositor/extensions/qwltexturesharingextension_p.h +++ b/src/compositor/extensions/qwltexturesharingextension_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWLTEXTURESHARINGEXTENSION_P_H #define QWLTEXTURESHARINGEXTENSION_P_H @@ -67,7 +41,7 @@ namespace QtWayland class QWaylandTextureSharingExtension; class SharedTextureImageResponse; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandSharedTextureProvider : public QQuickAsyncImageProvider +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandSharedTextureProvider : public QQuickAsyncImageProvider { public: QWaylandSharedTextureProvider(); @@ -77,10 +51,10 @@ public: void setExtensionReady(QWaylandTextureSharingExtension *extension); private: - QVector<SharedTextureImageResponse*> m_pendingResponses; + QList<SharedTextureImageResponse*> m_pendingResponses; }; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandTextureSharingExtension +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandTextureSharingExtension : public QWaylandCompositorExtensionTemplate<QWaylandTextureSharingExtension> , public QtWaylandServer::zqt_texture_sharing_v1 { @@ -97,13 +71,13 @@ public: static QWaylandTextureSharingExtension *self() { return s_self; } -public slots: +public Q_SLOTS: void requestBuffer(const QString &key); -signals: +Q_SIGNALS: void bufferResult(const QString &key, QtWayland::ServerBuffer *buffer); -protected slots: +protected Q_SLOTS: void cleanupBuffers(); protected: |