Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: position jitter between two presentations #50

Merged
merged 1 commit into from
Jan 12, 2024
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
6 changes: 6 additions & 0 deletions desktopintegration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,12 @@
return m_dockIntegration->geometry();
}

uint DesktopIntegration::dockSpacing() const

Check warning on line 88 in desktopintegration.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'dockSpacing' is never used.
{
return m_dockIntegration->windowMargin();
}

QString DesktopIntegration::backgroundUrl() const

Check warning on line 93 in desktopintegration.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'backgroundUrl' is never used.
{
return QString("image://blurhash/%1").arg(m_appearanceIntegration->wallpaperBlurhash());
}
Expand Down Expand Up @@ -219,5 +224,6 @@
{
connect(m_dockIntegration, &DdeDock::directionChanged, this, &DesktopIntegration::dockPositionChanged);
connect(m_dockIntegration, &DdeDock::geometryChanged, this, &DesktopIntegration::dockGeometryChanged);
connect(m_dockIntegration, &DdeDock::windowMarginChanged, this, &DesktopIntegration::dockSpacingChanged);
connect(m_appearanceIntegration, &Appearance::wallpaperBlurhashChanged, this, &DesktopIntegration::backgroundUrlChanged);
}
3 changes: 3 additions & 0 deletions desktopintegration.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class DesktopIntegration : public QObject

Q_PROPERTY(Qt::ArrowType dockPosition READ dockPosition NOTIFY dockPositionChanged)
Q_PROPERTY(QRect dockGeometry READ dockGeometry NOTIFY dockGeometryChanged)
Q_PROPERTY(uint dockSpacing READ dockSpacing NOTIFY dockSpacingChanged)
Q_PROPERTY(QString backgroundUrl READ backgroundUrl NOTIFY backgroundUrlChanged)

public:
Expand All @@ -34,6 +35,7 @@ class DesktopIntegration : public QObject

Qt::ArrowType dockPosition() const;
QRect dockGeometry() const;
uint dockSpacing() const;
QString backgroundUrl() const;

Q_INVOKABLE bool isDockedApp(const QString & desktopId) const;
Expand All @@ -49,6 +51,7 @@ class DesktopIntegration : public QObject
signals:
void dockPositionChanged();
void dockGeometryChanged();
void dockSpacingChanged();
void backgroundUrlChanged();

private:
Expand Down
8 changes: 4 additions & 4 deletions qml/Main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,18 @@ QtObject {
switch (DesktopIntegration.dockPosition) {
case Qt.DownArrow:
x = dockGeometry.left
y = (dockGeometry.top >= 0 ? dockGeometry.top : (Screen.height - dockGeometry.height)) - height
y = (dockGeometry.top >= 0 ? dockGeometry.top : (Screen.height - dockGeometry.height)) - height - DesktopIntegration.dockSpacing
break
case Qt.LeftArrow:
x = dockGeometry.width
x = dockGeometry.right + DesktopIntegration.dockSpacing
y = (dockGeometry.top >= 0 ? dockGeometry.top : 0)
break
case Qt.UpArrow:
x = dockGeometry.left
y = dockGeometry.height
y = dockGeometry.bottom + DesktopIntegration.dockSpacing
break
case Qt.RightArrow:
x = (dockGeometry.left >= 0 ? dockGeometry.left : (Screen.width - dockGeometry.width)) - width
x = (dockGeometry.left >= 0 ? dockGeometry.left : (Screen.width - dockGeometry.width)) - width - DesktopIntegration.dockSpacing
y = dockGeometry.top
break
}
Expand Down
14 changes: 14 additions & 0 deletions src/ddeintegration/ddedock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@ DdeDock::DdeDock(QObject *parent)
QDBusConnection::sessionBus(), this))
, m_direction(Qt::DownArrow)
, m_rect(QRect(-1, -1, 0, 0))
, m_windowMargin(0)
{
QTimer::singleShot(0, this, &DdeDock::updateDockRectAndPositionFromDBus);
QMetaObject::invokeMethod(this, &DdeDock::updateDockWindowMarginFromDBus, Qt::QueuedConnection);

// Due to current dde-dock bug, we need to do both since position changed signal might not got emit in some case.
connect(m_dbusDaemonDockIface, &Dock1::PositionChanged, this, &DdeDock::updateDockRectAndPositionFromDBus);
connect(m_dbusDaemonDockIface, &Dock1::FrontendWindowRectChanged, this, &DdeDock::updateDockRectAndPositionFromDBus);
connect(m_dbusDaemonDockIface, &Dock1::WindowMarginChanged, this, &DdeDock::updateDockWindowMarginFromDBus);
}

DdeDock::~DdeDock()
Expand All @@ -39,6 +42,11 @@ QRect DdeDock::geometry() const
return m_rect;
}

uint DdeDock::windowMargin() const
{
return m_windowMargin;
}

bool DdeDock::isDocked(const QString &desktop) const
{
QDBusPendingReply<bool> reply(m_dbusDaemonDockIface->IsDocked(desktop));
Expand Down Expand Up @@ -99,6 +107,12 @@ void DdeDock::updateDockPositionFromDBus()
}
}

void DdeDock::updateDockWindowMarginFromDBus()
{
m_windowMargin = m_dbusDaemonDockIface->windowMargin();
emit windowMarginChanged();
}

void DdeDock::updateDockRectFromDBus()
{
m_rect = m_dbusDaemonDockIface->frontendWindowRect();
Expand Down
5 changes: 5 additions & 0 deletions src/ddeintegration/ddedock.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ class DdeDock : public QObject

Q_PROPERTY(Qt::ArrowType direction READ direction NOTIFY directionChanged)
Q_PROPERTY(QRect geometry READ geometry NOTIFY geometryChanged)
Q_PROPERTY(uint windowMargin READ windowMargin NOTIFY windowMarginChanged)

public:
explicit DdeDock(QObject *parent = nullptr);
~DdeDock();

Qt::ArrowType direction() const;
QRect geometry() const;
uint windowMargin() const;

bool isDocked(const QString & desktop) const;
void sendToDock(const QString & desktop, int idx = -1);
Expand All @@ -29,14 +31,17 @@ class DdeDock : public QObject
signals:
void directionChanged();
void geometryChanged();
void windowMarginChanged();

private:
void updateDockRectAndPositionFromDBus();
void updateDockPositionFromDBus();
void updateDockWindowMarginFromDBus();
void updateDockRectFromDBus();

__Dock1 * m_dbusDaemonDockIface;

Qt::ArrowType m_direction;
QRect m_rect;
uint m_windowMargin;
};
1 change: 1 addition & 0 deletions src/ddeintegration/xml/org.deepin.dde.daemon.Dock1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
<property name="WindowSize" type="u" access="readwrite"/>
<property name="WindowSizeEfficient" type="u" access="readwrite"/>
<property name="WindowSizeFashion" type="u" access="readwrite"/>
<property name="WindowMargin" type="u" access="read"/>
<property name="ShowTimeout" type="u" access="readwrite"/>
<property name="HideTimeout" type="u" access="readwrite"/>
<property name="DockedApps" type="as" access="read"/>
Expand Down