@@ -28,6 +28,14 @@ WaylandDockHelper::WaylandDockHelper(DockPanel *panel)
2828 if (auto applet = bridge.applet ()) {
2929 connect (applet, SIGNAL (windowFullscreenChanged (bool )), this , SLOT (setCurrentActiveWindowFullscreened (bool )));
3030 }
31+
32+ // Store dock window's wl_surface for XEmbed window positioning
33+ if (m_panel->window ()) {
34+ auto waylandWindow = dynamic_cast <QtWaylandClient::QWaylandWindow*>(m_panel->window ()->handle ());
35+ if (waylandWindow) {
36+ m_dockWlSurface = waylandWindow->waylandSurface ()->object ();
37+ }
38+ }
3139
3240 connect (m_panel, &DockPanel::rootObjectChanged, this , [this ]() {
3341 m_wallpaperColorManager->watchScreen (dockScreenName ());
@@ -144,6 +152,35 @@ void WaylandDockHelper::setDockColorTheme(const ColorTheme &theme)
144152 m_panel->setColorTheme (theme);
145153}
146154
155+ bool WaylandDockHelper::moveXEmbedWindow (uint32_t wid, const QString &pluginId, const QString &itemKey)
156+ {
157+ // Update dock wl_surface if needed
158+ if (!m_dockWlSurface && m_panel->window ()) {
159+ auto waylandWindow = dynamic_cast <QtWaylandClient::QWaylandWindow*>(m_panel->window ()->handle ());
160+ if (waylandWindow && waylandWindow->waylandSurface ()) {
161+ m_dockWlSurface = waylandWindow->waylandSurface ()->object ();
162+ }
163+ }
164+
165+ if (!m_ddeShellManager || !m_ddeShellManager->isActive () || !m_dockWlSurface) {
166+ qWarning () << " WaylandDockHelper::moveXEmbedWindow: not ready, manager active:"
167+ << (m_ddeShellManager && m_ddeShellManager->isActive ())
168+ << " surface:" << (m_dockWlSurface != nullptr );
169+ return false ;
170+ }
171+
172+ // The XEmbed window position is relative to the plugin item's position in the dock
173+ // For now, we use (0, 0) as the offset since the actual position calculation
174+ // should be done by the treeland compositor based on the anchor surface
175+ // The (dx, dy) offset will be calculated based on the plugin item's position
176+ //
177+ // TODO: We may need to get the actual plugin item position from the QML side
178+ // and pass it as the offset. For now, using (0, 0) as the window will be
179+ // positioned at the dock surface's top-left corner.
180+ m_ddeShellManager->setXWindowPositionRelative (wid, m_dockWlSurface, 0.0 , 0.0 );
181+ return true ;
182+ }
183+
147184WallpaperColorManager::WallpaperColorManager (WaylandDockHelper *helper)
148185 : QWaylandClientExtensionTemplate<WallpaperColorManager>(treeland_wallpaper_color_manager_v1_interface.version)
149186 , m_helper(helper)
@@ -169,6 +206,14 @@ TreeLandDDEShellManager::TreeLandDDEShellManager()
169206{
170207}
171208
209+ struct ::wl_callback *TreeLandDDEShellManager::setXWindowPositionRelative (uint32_t wid, struct ::wl_surface *anchor, double dx, double dy)
210+ {
211+ if (!isActive ()) {
212+ return nullptr ;
213+ }
214+ return QtWayland::treeland_dde_shell_manager_v1::set_xwindow_position_relative (wid, anchor, wl_fixed_from_double (dx), wl_fixed_from_double (dy));
215+ }
216+
172217TreeLandWindowOverlapChecker::TreeLandWindowOverlapChecker (WaylandDockHelper *helper, struct ::treeland_window_overlap_checker *checker)
173218 : QWaylandClientExtensionTemplate<TreeLandWindowOverlapChecker>(treeland_dde_shell_manager_v1_interface.version)
174219 , m_helper(helper)
0 commit comments