Skip to content

Commit 70415b5

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

4 files changed

Lines changed: 72 additions & 2 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: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,29 @@
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="plugin_manager_callback_v1"/>
122+
</request>
123+
</interface>
124+
<interface name="plugin_manager_callback_v1" version="1">
125+
<description summary="callback for plugin manager operations">
126+
This interface is used for receiving completion notifications for asynchronous operations.
127+
</description>
128+
<request name="destroy" type="destructor">
129+
</request>
130+
<event name="done">
131+
<description summary="operation completed">
132+
This event indicates that the requested operation has been completed by the compositor.
133+
</description>
134+
</event>
112135
</interface>
113136
<interface name="plugin_popup" version="1">
114137
<request name="destroy" type="destructor">

src/tray-wayland-integration/pluginmanagerintegration.cpp

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

51+
PluginManagerCallback *PluginManagerIntegration::moveXembedWindow(uint32_t xembedWinId, const QString &pluginId, const QString &itemKey)
52+
{
53+
auto callback = new PluginManagerCallback();
54+
move_xembed_window(xembedWinId, pluginId, itemKey);
55+
return callback;
56+
}
57+
5158
void PluginManagerIntegration::plugin_manager_v1_position_changed(uint32_t dock_position)
5259
{
5360
if (dock_position != m_dockPosition) {
@@ -122,4 +129,18 @@ bool PluginManagerIntegration::tryCreatePopupForSubWindow(QWindow *window)
122129

123130
return false;
124131
}
132+
133+
PluginManagerCallback::PluginManagerCallback()
134+
{
135+
}
136+
137+
PluginManagerCallback::~PluginManagerCallback()
138+
{
139+
}
140+
141+
void PluginManagerCallback::plugin_manager_callback_v1_done()
142+
{
143+
Q_EMIT done();
144+
}
145+
125146
}

src/tray-wayland-integration/pluginmanagerintegration_p.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <QtWaylandClient/private/qwaylandshellintegration_p.h>
1010

1111
namespace Plugin {
12+
class PluginManagerCallback;
1213
class PluginManagerIntegration : public QtWaylandClient::QWaylandShellIntegrationTemplate<PluginManagerIntegration>, public QtWayland::plugin_manager_v1
1314
{
1415
Q_OBJECT
@@ -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+
PluginManagerCallback *moveXembedWindow(uint32_t xembedWinId, const QString &pluginId, const QString &itemKey);
2325

2426
Q_SIGNALS:
2527
void eventMessage(const QString &msg);
@@ -40,5 +42,21 @@ class PluginManagerIntegration : public QtWaylandClient::QWaylandShellIntegratio
4042
private:
4143
uint32_t m_dockPosition;
4244
uint32_t m_dockColorType;
45+
static PluginManagerIntegration *s_instance;
4346
};
47+
48+
class PluginManagerCallback : public QObject, public QtWayland::plugin_manager_callback_v1
49+
{
50+
Q_OBJECT
51+
public:
52+
PluginManagerCallback();
53+
~PluginManagerCallback();
54+
55+
Q_SIGNALS:
56+
void done();
57+
58+
protected:
59+
void plugin_manager_callback_v1_done() override;
60+
};
61+
4462
}

0 commit comments

Comments
 (0)