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
48 changes: 26 additions & 22 deletions frame/layershell/x11dlayershellemulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,33 +30,37 @@ LayerShellEmulation::LayerShellEmulation(QWindow* window, QObject *parent)
connect(m_dlayerShellWindow, &DLayerShellWindow::layerChanged, this, &LayerShellEmulation::onLayerChanged);

onPositionChanged();
connect(m_dlayerShellWindow, &DLayerShellWindow::anchorsChanged, this, &LayerShellEmulation::onPositionChanged);
connect(m_dlayerShellWindow, &DLayerShellWindow::marginsChanged, this, &LayerShellEmulation::onPositionChanged);
m_positionChangedTimer.setSingleShot(true);
m_positionChangedTimer.setInterval(100);
connect(&m_positionChangedTimer, &QTimer::timeout, this, &LayerShellEmulation::onPositionChanged);
connect(m_dlayerShellWindow, &DLayerShellWindow::anchorsChanged, &m_positionChangedTimer, static_cast<void (QTimer::*)()>(&QTimer::start));
connect(m_dlayerShellWindow, &DLayerShellWindow::marginsChanged, &m_positionChangedTimer, static_cast<void (QTimer::*)()>(&QTimer::start));

onExclusionZoneChanged();
connect(m_dlayerShellWindow, &DLayerShellWindow::anchorsChanged, this, &LayerShellEmulation::onExclusionZoneChanged);
connect(m_dlayerShellWindow, &DLayerShellWindow::exclusionZoneChanged, this, &LayerShellEmulation::onExclusionZoneChanged);
m_exclusionZoneChangedTimer.setSingleShot(true);
m_exclusionZoneChangedTimer.setInterval(100);
connect(&m_exclusionZoneChangedTimer, &QTimer::timeout, this, &LayerShellEmulation::onExclusionZoneChanged);
connect(m_dlayerShellWindow, &DLayerShellWindow::anchorsChanged, &m_exclusionZoneChangedTimer, static_cast<void (QTimer::*)()>(&QTimer::start));
connect(m_dlayerShellWindow, &DLayerShellWindow::exclusionZoneChanged, &m_exclusionZoneChangedTimer, static_cast<void (QTimer::*)()>(&QTimer::start));

// qml height or width may update later, need to update anchor postion and exclusion zone
connect(m_window, &QWindow::widthChanged, this, &LayerShellEmulation::onExclusionZoneChanged);
connect(m_window, &QWindow::widthChanged, this, &LayerShellEmulation::onPositionChanged);

connect(m_window, &QWindow::heightChanged, this, &LayerShellEmulation::onExclusionZoneChanged);
connect(m_window, &QWindow::heightChanged, this, &LayerShellEmulation::onPositionChanged);

auto screen = m_window->screen();
connect(screen, &QScreen::geometryChanged, this, &LayerShellEmulation::onPositionChanged);
connect(screen, &QScreen::geometryChanged, this, &LayerShellEmulation::onExclusionZoneChanged);
connect(qApp, &QGuiApplication::primaryScreenChanged, this, &LayerShellEmulation::onExclusionZoneChanged);
connect(m_window, &QWindow::widthChanged, &m_exclusionZoneChangedTimer, static_cast<void (QTimer::*)()>(&QTimer::start));
connect(m_window, &QWindow::widthChanged, &m_positionChangedTimer, static_cast<void (QTimer::*)()>(&QTimer::start));
connect(m_window, &QWindow::heightChanged, &m_exclusionZoneChangedTimer, static_cast<void (QTimer::*)()>(&QTimer::start));
connect(m_window, &QWindow::heightChanged, &m_positionChangedTimer, static_cast<void (QTimer::*)()>(&QTimer::start));

for (auto screen : qApp->screens()) {
connect(screen, &QScreen::geometryChanged, &m_positionChangedTimer, static_cast<void (QTimer::*)()>(&QTimer::start));
connect(screen, &QScreen::geometryChanged, &m_exclusionZoneChangedTimer, static_cast<void (QTimer::*)()>(&QTimer::start));
}
connect(qApp, &QGuiApplication::screenAdded, this, [this] (const QScreen *newScreen) {
connect(newScreen, &QScreen::geometryChanged, &m_positionChangedTimer, static_cast<void (QTimer::*)()>(&QTimer::start));
connect(newScreen, &QScreen::geometryChanged, &m_exclusionZoneChangedTimer, static_cast<void (QTimer::*)()>(&QTimer::start));
});
connect(qApp, &QGuiApplication::primaryScreenChanged, &m_exclusionZoneChangedTimer, static_cast<void (QTimer::*)()>(&QTimer::start));
connect(m_window, &QWindow::screenChanged, this, [this](QScreen *nowScreen){
for (auto screen : qApp->screens()) {
screen->disconnect(this);
}

connect(nowScreen, &QScreen::geometryChanged, this, &LayerShellEmulation::onPositionChanged);
connect(nowScreen, &QScreen::geometryChanged, this, &LayerShellEmulation::onExclusionZoneChanged);
onPositionChanged();
QMetaObject::invokeMethod(this, &LayerShellEmulation::onExclusionZoneChanged, Qt::QueuedConnection);
m_positionChangedTimer.start();
m_exclusionZoneChangedTimer.start();
});

// connect(m_dlayerShellWindow, &DS_NAMESPACE::DLayerShellWindow::keyboardInteractivityChanged, this, &LayerShellEmulation::onKeyboardInteractivityChanged);
Expand Down
3 changes: 3 additions & 0 deletions frame/layershell/x11dlayershellemulation.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
#include "dsglobal.h"
#include "dlayershellwindow.h"

#include <QObject>

Check warning on line 10 in frame/layershell/x11dlayershellemulation.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QObject> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QWindow>

Check warning on line 11 in frame/layershell/x11dlayershellemulation.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QWindow> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QTimer>

Check warning on line 12 in frame/layershell/x11dlayershellemulation.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QTimer> not found. Please note: Cppcheck does not need standard library headers to get proper results.

#include <xcb/xcb.h>

Check warning on line 14 in frame/layershell/x11dlayershellemulation.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <xcb/xcb.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <xcb/xproto.h>

Check warning on line 15 in frame/layershell/x11dlayershellemulation.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <xcb/xproto.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.

class xcb_connection_t;
DS_BEGIN_NAMESPACE
Expand All @@ -31,5 +32,7 @@
private:
QWindow* m_window;
DLayerShellWindow* m_dlayerShellWindow;
QTimer m_positionChangedTimer;
QTimer m_exclusionZoneChangedTimer;
};
DS_END_NAMESPACE
Loading