Skip to content

Commit 058940d

Browse files
committed
feat: add move_xembed_window protocol for later use
Log:
1 parent a671a09 commit 058940d

5 files changed

Lines changed: 34 additions & 3 deletions

File tree

plugins/application-tray/xembedprotocolhandler.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "fdoselectionmanager.h"
99

1010
#include "util.h"
11+
#include "plugin.h"
1112

1213
#include <QBitmap>
1314
#include <QWindow>
@@ -300,8 +301,15 @@ QPixmap XembedProtocolHandler::getPixmapFromWidnow()
300301
QPoint XembedProtocolHandler::updateEmbedWindowPosForGetInputEvent()
301302
{
302303
// update pos
303-
QPoint p = UTIL->getMousePos();
304-
UTIL->moveX11Window(m_containerWid, p.x(), p.y());
304+
if (qgetenv("XDG_SESSION_TYPE") == "wayland") {
305+
// Get `plugin_id` and `item_key` from EmbedPlugin.
306+
auto plugin = Plugin::EmbedPlugin::get(window()->windowHandle());
307+
// use move_xembed_window to move m_containerWid to plugin_id.
308+
// TODO: ...?
309+
} else {
310+
QPoint p = UTIL->getMousePos();
311+
UTIL->moveX11Window(m_containerWid, p.x(), p.y());
312+
}
305313

306314
// make window normal and above for get input
307315
UTIL->setX11WindowInputShape(m_containerWid, QSize(1, 1));

src/protocol/plugin-manager-v1.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,17 @@
109109
<arg name="surface" type="object" interface="wl_surface"/>
110110
<arg name="id" type="new_id" interface="plugin"/>
111111
</request>
112+
113+
<request name="move_xembed_window">
114+
<description summary="request move xembed window to position">
115+
This requests dde-shell to forward a request to the compositor (treeland) to move a xembed window to position.
116+
dde-shell knows the xembed window's relative position, and then can request treeland to move the window to an absolute position based on a relative position.
117+
</description>
118+
<arg name="xembed_winid" type="int"/>
119+
<arg name="plugin_id" type="string"/>
120+
<arg name="item_key" type="string"/>
121+
<arg name="callback" type="new_id" interface="wl_callback"/>
122+
</request>
112123
</interface>
113124
<interface name="plugin_popup" version="1">
114125
<request name="destroy" type="destructor">

src/tray-wayland-integration/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ add_library(dockpluginmanager SHARED
3939
)
4040

4141
qt_generate_wayland_protocol_client_sources(dockpluginmanager
42-
FILES
42+
NO_INCLUDE_CORE_ONLY
43+
FILES
4344
${CMAKE_CURRENT_SOURCE_DIR}/../protocol/plugin-manager-v1.xml
4445
)
4546

src/tray-wayland-integration/pluginmanagerintegration.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ void PluginManagerIntegration::requestMessage(const QString &plugin_id, const QS
4848
request_message(plugin_id, item_key, msg);
4949
}
5050

51+
struct ::wl_callback *PluginManagerIntegration::moveXembedWindow(uint32_t xembedWinId, const QString &pluginId, const QString &itemKey)
52+
{
53+
auto callback = move_xembed_window(xembedWinId, pluginId, itemKey);
54+
return callback;
55+
}
56+
5157
void PluginManagerIntegration::plugin_manager_v1_position_changed(uint32_t dock_position)
5258
{
5359
if (dock_position != m_dockPosition) {
@@ -122,4 +128,5 @@ bool PluginManagerIntegration::tryCreatePopupForSubWindow(QWindow *window)
122128

123129
return false;
124130
}
131+
125132
}

src/tray-wayland-integration/pluginmanagerintegration_p.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#pragma once
66

77
#include "qwayland-plugin-manager-v1.h"
8+
#include <wayland-client-protocol.h>
89

910
#include <QtWaylandClient/private/qwaylandshellintegration_p.h>
1011

@@ -20,6 +21,7 @@ class PluginManagerIntegration : public QtWaylandClient::QWaylandShellIntegratio
2021

2122
public:
2223
void requestMessage(const QString &plugin_id, const QString &item_key, const QString &msg);
24+
struct ::wl_callback *moveXembedWindow(uint32_t xembedWinId, const QString &pluginId, const QString &itemKey);
2325

2426
Q_SIGNALS:
2527
void eventMessage(const QString &msg);
@@ -40,5 +42,7 @@ class PluginManagerIntegration : public QtWaylandClient::QWaylandShellIntegratio
4042
private:
4143
uint32_t m_dockPosition;
4244
uint32_t m_dockColorType;
45+
static PluginManagerIntegration *s_instance;
4346
};
47+
4448
}

0 commit comments

Comments
 (0)