Skip to content
Open
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 panels/dock/dockdbusproxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ QRect DockDBusProxy::geometry()
void DockDBusProxy::updateDockPluginsVisible(const QVariantMap &pluginsVisible)
{
for (auto *dockApplet : dockApplets(parent())) {
if (!dockApplet->isSupported()) {
continue;
}
DockItemInfo itemInfo = dockApplet->dockItemInfo();
QString itemKey = itemInfo.itemKey;
if (pluginsVisible.contains(itemKey)) {
Expand Down Expand Up @@ -235,6 +238,9 @@ DockItemInfos DockDBusProxy::plugins()
}

for (auto *dockApplet : dockApplets(parent())) {
if (!dockApplet->isSupported()) {
continue;
}
iteminfos.append(dockApplet->dockItemInfo());
}

Expand Down
27 changes: 26 additions & 1 deletion panels/dock/frame/dappletdock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
~DAppletDockPrivate() override = default;

bool m_visible = true;
bool m_isSupported = true;

D_DECLARE_PUBLIC(DAppletDock)
};
Expand All @@ -34,20 +35,44 @@
bool DAppletDock::visible() const
{
D_DC(DAppletDock);
return d->m_visible;
return d->m_visible && d->m_isSupported;
}

void DAppletDock::setVisible(bool visible)

Check warning on line 41 in panels/dock/frame/dappletdock.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'setVisible' is never used.
{
D_D(DAppletDock);
if (d->m_visible == visible)
return;

bool oldEffectiveVisible = this->visible();

Check warning on line 47 in panels/dock/frame/dappletdock.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Finding the same expression on both sides of an operator is suspicious and might indicate a cut and paste or logic error. Please examine this code carefully to determine if it is correct.
d->m_visible = visible;
if (oldEffectiveVisible != this->visible()) {
Q_EMIT visibleChanged();
}
}

bool DAppletDock::isSupported() const

Check warning on line 54 in panels/dock/frame/dappletdock.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'isSupported' is never used.
{
D_DC(DAppletDock);
return d->m_isSupported;
}

void DAppletDock::setSupported(bool supported)

Check warning on line 60 in panels/dock/frame/dappletdock.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'setSupported' is never used.
{
D_D(DAppletDock);
if (d->m_isSupported == supported)
return;

bool oldEffectiveVisible = this->visible();

Check warning on line 66 in panels/dock/frame/dappletdock.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Finding the same expression on both sides of an operator is suspicious and might indicate a cut and paste or logic error. Please examine this code carefully to determine if it is correct.
d->m_isSupported = supported;
Q_EMIT supportedChanged();

if (oldEffectiveVisible != this->visible()) {
Q_EMIT visibleChanged();
}
}

DockItemInfo DAppletDock::dockItemInfo()

Check warning on line 75 in panels/dock/frame/dappletdock.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'dockItemInfo' is never used.
{
return {};
}
Expand Down
5 changes: 5 additions & 0 deletions panels/dock/frame/dappletdock.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class DS_SHARE DAppletDock : public DApplet
{
Q_OBJECT
Q_PROPERTY(bool visible READ visible WRITE setVisible NOTIFY visibleChanged)
Q_PROPERTY(bool supported READ isSupported WRITE setSupported NOTIFY supportedChanged)
D_DECLARE_PRIVATE(DAppletDock)

public:
Expand All @@ -27,8 +28,12 @@ class DS_SHARE DAppletDock : public DApplet
bool visible() const;
void setVisible(bool visible);

bool isSupported() const;
void setSupported(bool supported);

Q_SIGNALS:
void visibleChanged();
void supportedChanged();

protected:
explicit DAppletDock(DAppletDockPrivate &dd, QObject *parent = nullptr);
Expand Down
10 changes: 8 additions & 2 deletions panels/dock/multitaskview/multitaskview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ MultiTaskView::MultiTaskView(QObject *parent)
: DAppletDock(parent)
, m_iconName("deepin-multitasking-view")
{
connect(DWindowManagerHelper::instance(), &DWindowManagerHelper::hasCompositeChanged, this, &MultiTaskView::visibleChanged);
connect(DWindowManagerHelper::instance(), &DWindowManagerHelper::hasCompositeChanged, this, [this]() {
Q_EMIT visibleChanged();
setSupported(m_kWinEffect && DWindowManagerHelper::instance()->hasComposite());
Comment on lines +28 to +30
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): Avoid potentially emitting visibleChanged twice on compositor changes.

Because the lambda always emits visibleChanged(), and setSupported() can emit it again when the effective visibility changes, a single compositor change may trigger duplicate notifications. Either rely on setSupported() alone to emit visibleChanged() when needed, or emit visibleChanged() here only when supported actually changes (e.g. compute the new supported state, compare to isSupported(), then call setSupported() without the unconditional Q_EMIT visibleChanged()).

});
auto platformName = QGuiApplication::platformName();
if (QStringLiteral("wayland") == platformName) {
m_multitaskview.reset(new TreeLandMultitaskview);
Expand All @@ -39,6 +42,7 @@ MultiTaskView::MultiTaskView(QObject *parent)
if (kWinEffect != m_kWinEffect) {
m_kWinEffect = kWinEffect;
Q_EMIT visibleChanged();
setSupported(m_kWinEffect && DWindowManagerHelper::instance()->hasComposite());
}
}
});
Expand All @@ -47,6 +51,8 @@ MultiTaskView::MultiTaskView(QObject *parent)

bool MultiTaskView::init()
{
setSupported(m_kWinEffect && DWindowManagerHelper::instance()->hasComposite());
setVisible(m_kWinEffect && DWindowManagerHelper::instance()->hasComposite());
DAppletDock::init();
return true;
}
Expand Down Expand Up @@ -86,7 +92,7 @@ DockItemInfo MultiTaskView::dockItemInfo()
info.displayName = tr("Multitasking View");
info.itemKey = "multitasking-view";
info.settingKey = "multitasking-view";
info.visible = m_kWinEffect && DWindowManagerHelper::instance()->hasComposite();
info.visible = visible();
info.dccIcon = DCCIconPath + "multitasking-view.svg";
return info;
}
Expand Down
Loading