Skip to content

Commit 613a1ba

Browse files
committed
fix: dock will not hide on hideModeChanged by dbus
1. when hideModeChanged to start show/hide timer 2. make the dock's rect is the original size so that the window rect obtained by xcb can correctly calculate whether it overlaps log: as title pms: BUG-293825
1 parent 6798319 commit 613a1ba

File tree

3 files changed

+27
-7
lines changed

3 files changed

+27
-7
lines changed

panels/dock/dockhelper.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ DockHelper::DockHelper(DockPanel *parent)
2727
connect(parent, &DockPanel::rootObjectChanged, this, &DockHelper::initAreas);
2828
connect(parent, &DockPanel::showInPrimaryChanged, this, &DockHelper::updateAllDockWakeArea);
2929
connect(parent, &DockPanel::hideStateChanged, this, &DockHelper::updateAllDockWakeArea);
30+
connect(parent, &DockPanel::hideModeChanged, m_hideTimer, static_cast<void (QTimer::*)()>(&QTimer::start));
31+
connect(parent, &DockPanel::hideModeChanged, m_showTimer, static_cast<void (QTimer::*)()>(&QTimer::start));
3032
connect(parent, &DockPanel::positionChanged, this, [this](Position pos) {
3133
std::for_each(m_areas.begin(), m_areas.end(), [pos](const auto &area) {
3234
if (!area)

panels/dock/x11dockhelper.cpp

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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) {

panels/dock/x11dockhelper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ private Q_SLOTS:
8888
QRect m_dockArea;
8989
QHash<xcb_window_t, WindowData*> m_windows;
9090
XcbEventFilter *m_xcbHelper;
91+
QTimer *m_updateDockAreaTimer;
9192
};
9293

9394
class X11DockWakeUpArea : public QObject, public DockWakeUpArea

0 commit comments

Comments
 (0)