Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions panels/dock/dockhelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ DockHelper::DockHelper(DockPanel *parent)
connect(parent, &DockPanel::rootObjectChanged, this, &DockHelper::initAreas);
connect(parent, &DockPanel::showInPrimaryChanged, this, &DockHelper::updateAllDockWakeArea);
connect(parent, &DockPanel::hideStateChanged, this, &DockHelper::updateAllDockWakeArea);
connect(parent, &DockPanel::hideModeChanged, m_hideTimer, static_cast<void (QTimer::*)()>(&QTimer::start));
connect(parent, &DockPanel::hideModeChanged, m_showTimer, static_cast<void (QTimer::*)()>(&QTimer::start));
connect(parent, &DockPanel::positionChanged, this, [this](Position pos) {
std::for_each(m_areas.begin(), m_areas.end(), [pos](const auto &area) {
if (!area)
Expand Down
31 changes: 24 additions & 7 deletions panels/dock/x11dockhelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,17 +315,22 @@ void XcbEventFilter::setWindowState(const xcb_window_t& window, uint32_t list_le
xcb_ewmh_set_wm_state(&m_ewmh, window, list_len, state);
}

X11DockHelper::X11DockHelper(DockPanel* panel)
X11DockHelper::X11DockHelper(DockPanel *panel)
: DockHelper(panel)
, m_xcbHelper(new XcbEventFilter(this))
, m_updateDockAreaTimer(new QTimer(this))
{
m_updateDockAreaTimer->setSingleShot(true);
m_updateDockAreaTimer->setInterval(100);

connect(m_updateDockAreaTimer, &QTimer::timeout, this, &X11DockHelper::updateDockArea);
connect(panel, &DockPanel::hideModeChanged, this, &X11DockHelper::onHideModeChanged);
connect(panel, &DockPanel::rootObjectChanged, this, &X11DockHelper::updateDockArea);
connect(panel, &DockPanel::positionChanged, this, &X11DockHelper::updateDockArea);
connect(panel, &DockPanel::dockSizeChanged, this, &X11DockHelper::updateDockArea);
connect(panel, &DockPanel::geometryChanged, this, &X11DockHelper::updateDockArea);
connect(panel, &DockPanel::showInPrimaryChanged, this, &X11DockHelper::updateDockArea);
connect(panel, &DockPanel::dockScreenChanged, this, &X11DockHelper::updateDockArea);
connect(panel, &DockPanel::rootObjectChanged, m_updateDockAreaTimer, static_cast<void (QTimer::*)()>(&QTimer::start));
connect(panel, &DockPanel::positionChanged, m_updateDockAreaTimer, static_cast<void (QTimer::*)()>(&QTimer::start));
connect(panel, &DockPanel::dockSizeChanged, m_updateDockAreaTimer, static_cast<void (QTimer::*)()>(&QTimer::start));
connect(panel, &DockPanel::geometryChanged, m_updateDockAreaTimer, static_cast<void (QTimer::*)()>(&QTimer::start));
connect(panel, &DockPanel::showInPrimaryChanged, m_updateDockAreaTimer, static_cast<void (QTimer::*)()>(&QTimer::start));
connect(panel, &DockPanel::dockScreenChanged, m_updateDockAreaTimer, static_cast<void (QTimer::*)()>(&QTimer::start));

qGuiApp->installNativeEventFilter(m_xcbHelper);
onHideModeChanged(panel->hideMode());
Expand Down Expand Up @@ -485,6 +490,18 @@ void X11DockHelper::updateDockArea()
default:
break;
}

// Since the position of other windows are obtained through the xcb interface without scaling
// the rect of the dock needs to be changed to the original size of the original xcb.
QScreen *screen = parent()->dockScreen();
if (screen != nullptr) {
auto screenRect = screen->geometry();
rect.setSize(rect.size() * parent()->devicePixelRatio());
auto x = (rect.x() - screenRect.x()) * parent()->devicePixelRatio() + screenRect.x();
auto y = (rect.y() - screenRect.y()) * parent()->devicePixelRatio() + screenRect.y();
rect.moveTo(x, y);
}

if (m_dockArea != rect) {
m_dockArea = rect;
for (auto it = m_windows.cbegin(); it != m_windows.cend(); ++it) {
Expand Down
1 change: 1 addition & 0 deletions panels/dock/x11dockhelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ private Q_SLOTS:
QRect m_dockArea;
QHash<xcb_window_t, WindowData*> m_windows;
XcbEventFilter *m_xcbHelper;
QTimer *m_updateDockAreaTimer;
};

class X11DockWakeUpArea : public QObject, public DockWakeUpArea
Expand Down
Loading