Skip to content

Commit 883253d

Browse files
committed
fix: adapt control center activation for Wayland
1. Replace D-Bus direct calls with XdgActivation token-based activation 2. Use dde-application-manager (dde-am) as intermediary for Wayland protocol 3. Pass XDG_ACTIVATION_TOKEN environment variable when token is available 4. Update dependency to dde-application-manager >> 1.2.54 for required features 5. Simplify notification settings opening by removing DBus async call watcher 6. Add proper logging categories for quick panel and docking panel Log: Activated control center in Wayland via dde-am and XdgActivation protocol Influence: 1. Test opening dock settings in both X11 and Wayland sessions 2. Verify notification settings opening in both display servers 3. Check quick panel system settings entry works correctly 4. Ensure activation token is properly passed when available 5. Test backward compatibility with X11 sessions (no Wayland protocol) 6. Verify dde-am is invoked with correct arguments and environment 7. Check that token cleanup (deleteLater) works properly fix: 适配 Wayland 下激活控制中心 1. 使用 XdgActivation token 替代直接的 D-Bus 调用 2. 通过 dde-application-manager (dde-am) 作为 Wayland 协议中介 3. 在 token 可用时传递 XDG_ACTIVATION_TOKEN 环境变量 4. 更新依赖至 dde-application-manager >> 1.2.54 以支持新功能 5. 简化通知设置打开流程,移除 D-Bus 异步调用监听器 6. 为快捷面板和停靠面板添加正确的日志分类 Log: 通过 dde-am 和 XdgActivation 协议在 Wayland 下激活控制中心 Influence: 1. 在 X11 和 Wayland 会话中测试打开停靠设置 2. 验证两种显示服务器下的通知设置打开功能 3. 检查快捷面板系统设置入口是否正常工作 4. 确保 token 可用时正确传递激活令牌 5. 测试与 X11 会话的向后兼容性(无 Wayland 协议) 6. 验证 dde-am 使用正确的参数和环境变量调用 7. 检查 token 清理(deleteLater)是否正确执行 PMS: BUG-295555
1 parent 273db49 commit 883253d

6 files changed

Lines changed: 61 additions & 40 deletions

File tree

debian/control

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ Depends:
8282
qml6-module-qtquick-layouts,
8383
qml6-module-qtquick-window,
8484
qt6-wayland (>= 6.8),
85-
dde-application-manager (>> 1.2.51),
85+
dde-application-manager (>> 1.2.54),
8686
${misc:Depends},
8787
${shlibs:Depends},
8888
Breaks:

panels/dock/dockpanel.cpp

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@
1717
#include "dockdaemonadaptor.h"
1818
#include "loadtrayplugins.h"
1919

20-
#include <DDBusSender>
21-
#include <QQuickWindow>
22-
#include <QLoggingCategory>
20+
#include <DGuiApplicationHelper>
2321
#include <QGuiApplication>
22+
#include <QLoggingCategory>
23+
#include <QProcess>
2424
#include <QQuickItem>
25-
#include <DGuiApplicationHelper>
25+
#include <QQuickWindow>
26+
27+
#include <wayland/xdgactivation.h>
2628

2729
#ifdef HAVE_DDE_API_EVENTLOGGER
2830
#include <dde-api/eventlogger.hpp>
@@ -356,15 +358,23 @@ bool DockPanel::debugMode() const
356358
#endif
357359
}
358360

359-
void DockPanel::openDockSettings() const
361+
void DockPanel::openDockSettings()
360362
{
361-
DDBusSender()
362-
.service(QStringLiteral("org.deepin.dde.ControlCenter1"))
363-
.path(QStringLiteral("/org/deepin/dde/ControlCenter1"))
364-
.interface(QStringLiteral("org.deepin.dde.ControlCenter1"))
365-
.method(QStringLiteral("ShowPage"))
366-
.arg(QStringLiteral("personalization/dock"))
367-
.call();
363+
qCDebug(dockLog) << "openDockSettings";
364+
auto *activation = new ds::XdgActivation(this);
365+
connect(activation, &ds::XdgActivation::tokenReady, this, [activation](const QString &token) {
366+
QStringList args = {"--by-user", "org.deepin.dde.control-center"};
367+
if (!token.isEmpty()) {
368+
qCDebug(dockLog) << "Passing XDG_ACTIVATION_TOKEN to dde-am";
369+
args << "-e" << QStringLiteral("XDG_ACTIVATION_TOKEN=") + token;
370+
}
371+
args << "--"
372+
<< "-p"
373+
<< "personalization/dock";
374+
QProcess::startDetached("dde-am", args);
375+
activation->deleteLater();
376+
});
377+
activation->requestToken();
368378
}
369379

370380
void DockPanel::notifyDockPositionChanged(int offsetX, int offsetY)

panels/dock/dockpanel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class DockPanel : public DS_NAMESPACE::DPanel, public QDBusContext
8080

8181
bool debugMode() const;
8282

83-
Q_INVOKABLE void openDockSettings() const;
83+
Q_INVOKABLE void openDockSettings();
8484

8585
Q_INVOKABLE void notifyDockPositionChanged(int offsetX, int offsetY);
8686

panels/dock/tray/quickpanel/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
1+
# SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd.
22
#
33
# SPDX-License-Identifier: GPL-3.0-or-later
44

@@ -24,6 +24,8 @@ qt_add_qml_module(tray-quickpanel
2424

2525
target_link_libraries(tray-quickpanel PRIVATE
2626
Dtk${DTK_VERSION_MAJOR}::Core
27+
Qt${QT_VERSION_MAJOR}::Gui
28+
dde-shell-frame
2729
)
2830

2931
install(TARGETS tray-quickpanel DESTINATION "${QML_INSTALL_DIR}/org/deepin/ds/dock/tray/quickpanel/")

panels/dock/tray/quickpanel/quickpanelproxymodel.cpp

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
1-
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
1+
// SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd.
22
//
33
// SPDX-License-Identifier: GPL-3.0-or-later
44

55
#include "quickpanelproxymodel.h"
66

7-
#include <QDebug>
87
#include <DConfig>
9-
#include <DDBusSender>
8+
#include <QDebug>
9+
#include <QLoggingCategory>
10+
#include <QProcess>
11+
12+
#include <wayland/xdgactivation.h>
1013
DCORE_USE_NAMESPACE
1114

15+
Q_LOGGING_CATEGORY(quickpanelLog, "org.deepin.dde.shell.dock.quickpanel")
16+
1217
namespace dock {
1318
namespace {
1419
enum {
@@ -46,12 +51,18 @@ bool QuickPanelProxyModel::isQuickPanelPopup(const QString &pluginId, const QStr
4651

4752
void QuickPanelProxyModel::openSystemSettings()
4853
{
49-
DDBusSender()
50-
.service("org.deepin.dde.ControlCenter1")
51-
.interface("org.deepin.dde.ControlCenter1")
52-
.path("/org/deepin/dde/ControlCenter1")
53-
.method(QString("Show"))
54-
.call();
54+
qCDebug(quickpanelLog) << "openSystemSettings";
55+
auto *activation = new ds::XdgActivation(this);
56+
connect(activation, &ds::XdgActivation::tokenReady, this, [activation](const QString &token) {
57+
QStringList args = {"--by-user", "org.deepin.dde.control-center"};
58+
if (!token.isEmpty()) {
59+
qCDebug(quickpanelLog) << "Passing XDG_ACTIVATION_TOKEN to dde-am";
60+
args << "-e" << QStringLiteral("XDG_ACTIVATION_TOKEN=") + token;
61+
}
62+
QProcess::startDetached("dde-am", args);
63+
activation->deleteLater();
64+
});
65+
activation->requestToken();
5566
}
5667

5768
QVariant QuickPanelProxyModel::data(const QModelIndex &index, int role) const

panels/notification/center/notifyaccessor.cpp

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,12 @@
77
#include <QQmlEngine>
88
#include <QGuiApplication>
99
#include <QLoggingCategory>
10-
#include <QDBusInterface>
11-
#include <QDBusPendingReply>
1210
#include <QProcess>
13-
#include <QDBusReply>
1411

1512
#include <DConfig>
1613

1714
#include "dataaccessor.h"
15+
#include <wayland/xdgactivation.h>
1816

1917
DCORE_USE_NAMESPACE
2018

@@ -210,21 +208,21 @@ bool NotifyAccessor::applicationPin(const QString &appId) const
210208

211209
void NotifyAccessor::openNotificationSetting()
212210
{
213-
qDebug(notifyLog) << "Open notification setting";
214-
QDBusMessage msg = QDBusMessage::createMethodCall("org.deepin.dde.ControlCenter1",
215-
"/org/deepin/dde/ControlCenter1",
216-
"org.deepin.dde.ControlCenter1",
217-
"ShowPage");
218-
msg << "notification";
219-
QDBusPendingCall call = QDBusConnection::sessionBus().asyncCall(msg);
220-
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this);
221-
connect(watcher, &QDBusPendingCallWatcher::finished, this, [this](QDBusPendingCallWatcher *self) {
222-
QDBusReply<void> reply = *self;
223-
if (!reply.isValid()) {
224-
qWarning(notifyLog) << "Failed to open notification setting:" << reply.error().message();
211+
qDebug(notifyLog) << "openNotificationSetting";
212+
auto *activation = new ds::XdgActivation(this);
213+
connect(activation, &ds::XdgActivation::tokenReady, this, [activation](const QString &token) {
214+
QStringList args = {"--by-user", "org.deepin.dde.control-center"};
215+
if (!token.isEmpty()) {
216+
qDebug(notifyLog) << "Passing XDG_ACTIVATION_TOKEN to dde-am";
217+
args << "-e" << QStringLiteral("XDG_ACTIVATION_TOKEN=") + token;
225218
}
226-
self->deleteLater();
219+
args << "--"
220+
<< "-p"
221+
<< "notification";
222+
QProcess::startDetached("dde-am", args);
223+
activation->deleteLater();
227224
});
225+
activation->requestToken();
228226
}
229227

230228
void NotifyAccessor::onNotificationStateChanged(qint64 id, int processedType)

0 commit comments

Comments
 (0)