client: Switch qt-toplevel-drag to xdg-toplevel-drag
While no released compositor implemented qt-toplevel-drag it was a valuable to step to prove the protocol and the Qt implementation together with development pre-release versions of KWin. Now that the protocol is standardized we can switch to that version which is functionally identical. Pick-to: 6.6 6.7 Change-Id: I3beefe542cbabeddba4468b5d1fa24fcb05a2e5a Reviewed-by: David Edmundson <davidedmundson@kde.org>
This commit is contained in:
parent
9becad7b64
commit
91d9156e7b
@ -1,83 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<protocol name="qt_toplevel_drag_v1">
|
||||
|
||||
<copyright>
|
||||
Copyright 2022 David Redondo <kde@david-redondo.de>
|
||||
|
||||
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.
|
||||
</copyright>
|
||||
|
||||
<interface name="qt_toplevel_drag_manager_v1" version="1">
|
||||
<description summary="Move a window during a drag">
|
||||
This protocol enhances normal drag and drop with the ability to move a
|
||||
window at the same time. This allows having detachable windows that
|
||||
can also be reattached when dragged back to another window or some special
|
||||
zone.
|
||||
|
||||
Warning! The protocol described in this file is currently in the testing
|
||||
phase. Backward compatible changes may be added together with the
|
||||
corresponding interface version bump. Backward incompatible changes can
|
||||
only be done by creating a new major version of the extension.
|
||||
</description>
|
||||
|
||||
<request name="get_qt_toplevel_drag">
|
||||
<description summary="get an qt_toplevel_drag for a wl_data_source">
|
||||
Create an qt_toplevel_drag for a drag and drop operation that is going
|
||||
to be started with data_source.
|
||||
This request can only be made on sources used in drag-and-drop, so it
|
||||
must be performed before wl_data_device.start_drag. Attempting to use
|
||||
the source other than for drag-and-drop will raise an invalid_source error.
|
||||
</description>
|
||||
<arg name="id" type="new_id" interface="qt_toplevel_drag_v1"/>
|
||||
<arg name="data_source" type="object" interface="wl_data_source"/>
|
||||
</request>
|
||||
|
||||
<request name="release" type="destructor" />
|
||||
|
||||
<enum name="error">
|
||||
<entry name="invalid_source" value="0" summary="data_source already used for toplevel drag"/>
|
||||
</enum>
|
||||
</interface>
|
||||
|
||||
<interface name="qt_toplevel_drag_v1" version="1">
|
||||
<description summary="Object representing a toplevel move during a drag">
|
||||
</description>
|
||||
|
||||
<request name="attach">
|
||||
<description summary="Move a toplevel with the drag operation">
|
||||
Request that the window will be moved with the cursor during the drag operation. The offset
|
||||
describes how the toplevel will be positioned relative to the cursor hotspot
|
||||
in surface local coordinates.
|
||||
Issuing this request after the drag has ended will result in a drag_ended protocol error.
|
||||
</description>
|
||||
<arg name="toplevel" type="object" interface="xdg_toplevel" />
|
||||
<arg name="x_offset" type="int" summary="dragged surface x offset"/>
|
||||
<arg name="y_offset" type="int" summary="dragged surface y offset"/>
|
||||
</request>
|
||||
|
||||
<request name="destroy" type="destructor">
|
||||
<description summary="destroy an qt_toplevel_drag object" />
|
||||
</request>
|
||||
|
||||
<enum name="error">
|
||||
<entry name="drag_ended" value="0" summary="corresponding drag has ended" />
|
||||
</enum>
|
||||
</interface>
|
||||
</protocol>
|
141
src/3rdparty/wayland/protocols/xdg-toplevel-drag-v1.xml
vendored
Normal file
141
src/3rdparty/wayland/protocols/xdg-toplevel-drag-v1.xml
vendored
Normal file
@ -0,0 +1,141 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<protocol name="xdg_toplevel_drag_v1">
|
||||
|
||||
<copyright>
|
||||
Copyright 2023 David Redondo
|
||||
|
||||
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.
|
||||
</copyright>
|
||||
|
||||
<interface name="xdg_toplevel_drag_manager_v1" version="1">
|
||||
<description summary="Move a window during a drag">
|
||||
This protocol enhances normal drag and drop with the ability to move a
|
||||
window at the same time. This allows having detachable parts of a window
|
||||
that when dragged out of it become a new window and can be dragged over
|
||||
an existing window to be reattached.
|
||||
|
||||
A typical workflow would be when the user starts dragging on top of a
|
||||
detachable part of a window, the client would create a wl_data_source and
|
||||
a xdg_toplevel_drag_v1 object and start the drag as normal via
|
||||
wl_data_device.start_drag. Once the client determines that the detachable
|
||||
window contents should be detached from the originating window, it creates
|
||||
a new xdg_toplevel with these contents and issues a
|
||||
xdg_toplevel_drag_v1.attach request before mapping it. From now on the new
|
||||
window is moved by the compositor during the drag as if the client called
|
||||
xdg_toplevel.move.
|
||||
|
||||
Dragging an existing window is similar. The client creates a
|
||||
xdg_toplevel_drag_v1 object and attaches the existing toplevel before
|
||||
starting the drag.
|
||||
|
||||
Clients use the existing drag and drop mechanism to detect when a window
|
||||
can be docked or undocked. If the client wants to snap a window into a
|
||||
parent window it should delete or unmap the dragged top-level. If the
|
||||
contents should be detached again it attaches a new toplevel as described
|
||||
above. If a drag operation is cancelled without being dropped, clients
|
||||
should revert to the previous state, deleting any newly created windows
|
||||
as appropriate. When a drag operation ends as indicated by
|
||||
wl_data_source.dnd_drop_performed the dragged toplevel window's final
|
||||
position is determined as if a xdg_toplevel_move operation ended.
|
||||
|
||||
Warning! The protocol described in this file is currently in the testing
|
||||
phase. Backward compatible changes may be added together with the
|
||||
corresponding interface version bump. Backward incompatible changes can
|
||||
only be done by creating a new major version of the extension.
|
||||
</description>
|
||||
|
||||
<enum name="error">
|
||||
<entry name="invalid_source" value="0"
|
||||
summary="data_source already used for toplevel drag"/>
|
||||
</enum>
|
||||
|
||||
<request name="destroy" type="destructor">
|
||||
<description summary="destroy the xdg_toplevel_drag_manager_v1 object">
|
||||
Destroy this xdg_toplevel_drag_manager_v1 object. Other objects,
|
||||
including xdg_toplevel_drag_v1 objects created by this factory, are not
|
||||
affected by this request.
|
||||
</description>
|
||||
</request>
|
||||
|
||||
<request name="get_xdg_toplevel_drag">
|
||||
<description summary="get an xdg_toplevel_drag for a wl_data_source">
|
||||
Create an xdg_toplevel_drag for a drag and drop operation that is going
|
||||
to be started with data_source.
|
||||
|
||||
This request can only be made on sources used in drag-and-drop, so it
|
||||
must be performed before wl_data_device.start_drag. Attempting to use
|
||||
the source other than for drag-and-drop such as in
|
||||
wl_data_device.set_selection will raise an invalid_source error.
|
||||
|
||||
Destroying data_source while a toplevel is attached to the
|
||||
xdg_toplevel_drag is undefined.
|
||||
</description>
|
||||
|
||||
<arg name="id" type="new_id" interface="xdg_toplevel_drag_v1"/>
|
||||
<arg name="data_source" type="object" interface="wl_data_source"/>
|
||||
</request>
|
||||
</interface>
|
||||
|
||||
<interface name="xdg_toplevel_drag_v1" version="1">
|
||||
<description summary="Object representing a toplevel move during a drag">
|
||||
</description>
|
||||
|
||||
<enum name="error">
|
||||
<entry name="toplevel_attached" value="0"
|
||||
summary="valid toplevel already attached"/>
|
||||
<entry name="ongoing_drag" value="1"
|
||||
summary="drag has not ended" />
|
||||
</enum>
|
||||
|
||||
<request name="destroy" type="destructor">
|
||||
<description summary="destroy an xdg_toplevel_drag_v1 object">
|
||||
Destroy this xdg_toplevel_drag_v1 object. This request must only be
|
||||
called after the underlying wl_data_source drag has ended, as indicated
|
||||
by the dnd_drop_performed or cancelled events. In any other case an
|
||||
ongoing_drag error is raised.
|
||||
</description>
|
||||
</request>
|
||||
|
||||
<request name="attach">
|
||||
<description summary="Move a toplevel with the drag operation">
|
||||
Request that the window will be moved with the cursor during the drag
|
||||
operation. The offset is a hint to the compositor how the toplevel
|
||||
should be positioned relative to the cursor hotspot in surface local
|
||||
coordinates. For example it might only be used when an unmapped window
|
||||
is attached. The attached window does not participate in the selection
|
||||
of the drag target.
|
||||
|
||||
If the toplevel is unmapped while it is attached, it is automatically
|
||||
detached from the drag. In this case this request has to be called again
|
||||
if the window should be attached after it is remapped.
|
||||
|
||||
This request can be called multiple times but issuing it while a
|
||||
toplevel with an active role is attached raises a toplevel_attached
|
||||
error.
|
||||
</description>
|
||||
|
||||
<arg name="toplevel" type="object" interface="xdg_toplevel"/>
|
||||
<arg name="x_offset" type="int" summary="dragged surface x offset"/>
|
||||
<arg name="y_offset" type="int" summary="dragged surface y offset"/>
|
||||
</request>
|
||||
|
||||
</interface>
|
||||
</protocol>
|
||||
|
@ -94,8 +94,8 @@ qt6_generate_wayland_protocol_client_sources(WaylandClient
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/protocol/xdg-output-unstable-v1.xml
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/protocol/fractional-scale-v1.xml
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/protocol/viewporter.xml
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/protocol/qt-toplevel-drag-v1.xml
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/protocol/xdg-shell.xml
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/protocol/xdg-toplevel-drag-v1.xml
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../extensions/qt-key-unstable-v1.xml
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../extensions/qt-text-input-method-unstable-v1.xml
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../extensions/qt-windowmanager.xml
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include "qwaylandabstractdecoration_p.h"
|
||||
#include "qwaylandsurface_p.h"
|
||||
|
||||
#include <QtWaylandClient/private/qwayland-qt-toplevel-drag-v1.h>
|
||||
#include <QtWaylandClient/private/qwayland-xdg-toplevel-drag-v1.h>
|
||||
|
||||
#include <QtCore/QMimeData>
|
||||
#include <QtGui/QGuiApplication>
|
||||
@ -153,8 +153,8 @@ bool QWaylandDataDevice::startDrag(QMimeData *mimeData, Qt::DropActions supporte
|
||||
offsetStream >> offset;
|
||||
if (auto waylandWindow = static_cast<QWaylandWindow *>(dockWindow->handle())) {
|
||||
if (auto toplevel = waylandWindow->surfaceRole<xdg_toplevel>()) {
|
||||
m_toplevelDrag = new QtWayland::qt_toplevel_drag_v1(
|
||||
m_display->xdgToplevelDragManager()->get_qt_toplevel_drag(
|
||||
m_toplevelDrag = new QtWayland::xdg_toplevel_drag_v1(
|
||||
m_display->xdgToplevelDragManager()->get_xdg_toplevel_drag(
|
||||
m_dragSource->object()));
|
||||
m_toplevelDrag->attach(toplevel, offset.x(), offset.y());
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ class QPlatformDragQtResponse;
|
||||
class QWindow;
|
||||
|
||||
namespace QtWayland {
|
||||
class qt_toplevel_drag_v1;
|
||||
class xdg_toplevel_drag_v1;
|
||||
}
|
||||
|
||||
namespace QtWaylandClient {
|
||||
@ -98,7 +98,7 @@ private:
|
||||
QScopedPointer<QWaylandDataOffer> m_selectionOffer;
|
||||
QScopedPointer<QWaylandDataSource> m_selectionSource;
|
||||
QScopedPointer<QWaylandDataSource> m_dragSource;
|
||||
QtWayland::qt_toplevel_drag_v1 *m_toplevelDrag = nullptr;
|
||||
QtWayland::xdg_toplevel_drag_v1 *m_toplevelDrag = nullptr;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -51,7 +51,7 @@
|
||||
#include <QtWaylandClient/private/qwayland-fractional-scale-v1.h>
|
||||
#include <QtWaylandClient/private/qwayland-viewporter.h>
|
||||
#include <QtWaylandClient/private/qwayland-cursor-shape-v1.h>
|
||||
#include <QtWaylandClient/private/qwayland-qt-toplevel-drag-v1.h>
|
||||
#include <QtWaylandClient/private/qwayland-xdg-toplevel-drag-v1.h>
|
||||
|
||||
#include <QtCore/private/qcore_unix_p.h>
|
||||
|
||||
@ -773,10 +773,10 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
|
||||
wp_cursor_shape_manager_v1_destroy>(
|
||||
registry, id, std::min(1u, version)));
|
||||
} else if (
|
||||
interface == QLatin1String(QtWayland::qt_toplevel_drag_manager_v1::interface()->name)) {
|
||||
interface == QLatin1String(QtWayland::xdg_toplevel_drag_manager_v1::interface()->name)) {
|
||||
mGlobals.xdgToplevelDragManager.reset(
|
||||
new WithDestructor<QtWayland::qt_toplevel_drag_manager_v1,
|
||||
qt_toplevel_drag_manager_v1_destroy>(registry, id, 1));
|
||||
new WithDestructor<QtWayland::xdg_toplevel_drag_manager_v1,
|
||||
xdg_toplevel_drag_manager_v1_destroy>(registry, id, 1));
|
||||
}
|
||||
|
||||
mRegistryGlobals.append(RegistryGlobal(id, interface, version, registry));
|
||||
|
@ -54,7 +54,7 @@ namespace QtWayland {
|
||||
class wp_cursor_shape_manager_v1;
|
||||
class wp_fractional_scale_manager_v1;
|
||||
class wp_viewporter;
|
||||
class qt_toplevel_drag_manager_v1;
|
||||
class xdg_toplevel_drag_manager_v1;
|
||||
}
|
||||
|
||||
namespace QtWaylandClient {
|
||||
@ -125,7 +125,10 @@ public:
|
||||
QWaylandCursor *waylandCursor();
|
||||
QWaylandCursorTheme *loadCursorTheme(const QString &name, int pixelSize);
|
||||
#endif
|
||||
struct wl_display *wl_display() const { return mDisplay; }
|
||||
struct wl_display *wl_display() const
|
||||
{
|
||||
return mDisplay;
|
||||
}
|
||||
struct ::wl_registry *wl_registry() { return object(); }
|
||||
|
||||
QtWayland::wl_compositor *compositor()
|
||||
@ -202,7 +205,7 @@ public:
|
||||
{
|
||||
return mGlobals.cursorShapeManager.get();
|
||||
}
|
||||
QtWayland::qt_toplevel_drag_manager_v1 *xdgToplevelDragManager() const
|
||||
QtWayland::xdg_toplevel_drag_manager_v1 *xdgToplevelDragManager() const
|
||||
{
|
||||
return mGlobals.xdgToplevelDragManager.get();
|
||||
}
|
||||
@ -281,7 +284,6 @@ private:
|
||||
RegistryListener listener = nullptr;
|
||||
void *data = nullptr;
|
||||
};
|
||||
|
||||
struct wl_display *mDisplay = nullptr;
|
||||
std::unique_ptr<EventThread> m_eventThread;
|
||||
wl_event_queue *m_frameEventQueue = nullptr;
|
||||
@ -341,7 +343,7 @@ private:
|
||||
std::unique_ptr<QtWayland::wp_viewporter> viewporter;
|
||||
std::unique_ptr<QtWayland::wp_fractional_scale_manager_v1> fractionalScaleManager;
|
||||
std::unique_ptr<QtWayland::wp_cursor_shape_manager_v1> cursorShapeManager;
|
||||
std::unique_ptr<QtWayland::qt_toplevel_drag_manager_v1> xdgToplevelDragManager;
|
||||
std::unique_ptr<QtWayland::xdg_toplevel_drag_manager_v1> xdgToplevelDragManager;
|
||||
} mGlobals;
|
||||
int mFd = -1;
|
||||
int mWritableNotificationFd = -1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user