@@ -315,17 +315,22 @@ void XcbEventFilter::setWindowState(const xcb_window_t& window, uint32_t list_le
315315 xcb_ewmh_set_wm_state (&m_ewmh, window, list_len, state);
316316}
317317
318- X11DockHelper::X11DockHelper (DockPanel* panel)
318+ X11DockHelper::X11DockHelper (DockPanel * panel)
319319 : DockHelper(panel)
320320 , m_xcbHelper(new XcbEventFilter(this ))
321+ , m_updateDockAreaTimer(new QTimer(this ))
321322{
323+ m_updateDockAreaTimer->setSingleShot (true );
324+ m_updateDockAreaTimer->setInterval (100 );
325+
326+ connect (m_updateDockAreaTimer, &QTimer::timeout, this , &X11DockHelper::updateDockArea);
322327 connect (panel, &DockPanel::hideModeChanged, this , &X11DockHelper::onHideModeChanged);
323- connect (panel, &DockPanel::rootObjectChanged, this , &X11DockHelper::updateDockArea );
324- connect (panel, &DockPanel::positionChanged, this , &X11DockHelper::updateDockArea );
325- connect (panel, &DockPanel::dockSizeChanged, this , &X11DockHelper::updateDockArea );
326- connect (panel, &DockPanel::geometryChanged, this , &X11DockHelper::updateDockArea );
327- connect (panel, &DockPanel::showInPrimaryChanged, this , &X11DockHelper::updateDockArea );
328- connect (panel, &DockPanel::dockScreenChanged, this , &X11DockHelper::updateDockArea );
328+ connect (panel, &DockPanel::rootObjectChanged, m_updateDockAreaTimer, static_cast < void (QTimer::*)()>(&QTimer::start) );
329+ connect (panel, &DockPanel::positionChanged, m_updateDockAreaTimer, static_cast < void (QTimer::*)()>(&QTimer::start) );
330+ connect (panel, &DockPanel::dockSizeChanged, m_updateDockAreaTimer, static_cast < void (QTimer::*)()>(&QTimer::start) );
331+ connect (panel, &DockPanel::geometryChanged, m_updateDockAreaTimer, static_cast < void (QTimer::*)()>(&QTimer::start) );
332+ connect (panel, &DockPanel::showInPrimaryChanged, m_updateDockAreaTimer, static_cast < void (QTimer::*)()>(&QTimer::start) );
333+ connect (panel, &DockPanel::dockScreenChanged, m_updateDockAreaTimer, static_cast < void (QTimer::*)()>(&QTimer::start) );
329334
330335 qGuiApp->installNativeEventFilter (m_xcbHelper);
331336 onHideModeChanged (panel->hideMode ());
@@ -485,6 +490,18 @@ void X11DockHelper::updateDockArea()
485490 default :
486491 break ;
487492 }
493+
494+ // Since the position of other windows are obtained through the xcb interface without scaling
495+ // the rect of the dock needs to be changed to the original size of the original xcb.
496+ QScreen *screen = parent ()->dockScreen ();
497+ if (screen != nullptr ) {
498+ auto screenRect = screen->geometry ();
499+ rect.setSize (rect.size () * parent ()->devicePixelRatio ());
500+ auto x = (rect.x () - screenRect.x ()) * parent ()->devicePixelRatio () + screenRect.x ();
501+ auto y = (rect.y () - screenRect.y ()) * parent ()->devicePixelRatio () + screenRect.y ();
502+ rect.moveTo (x, y);
503+ }
504+
488505 if (m_dockArea != rect) {
489506 m_dockArea = rect;
490507 for (auto it = m_windows.cbegin (); it != m_windows.cend (); ++it) {
0 commit comments