Skip to content
Closed
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
4 changes: 2 additions & 2 deletions frame/qml/PanelMenu.qml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Item {
property bool readyBinding: false
// WM_NAME, used for kwin.
property string windowTitle: "dde-shell/panelmenu"
property bool autoCloseOnDeactivate: true
width: menu.childrenRect.width
height: menu.childrenRect.height

Expand Down Expand Up @@ -83,8 +84,7 @@ Item {
{
if (!menuWindow)
return
// TODO why activeChanged is not emit.
if (menuWindow && !menuWindow.active) {
if (autoCloseOnDeactivate && menuWindow && !menuWindow.active) {
control.close()
}
}
Expand Down
4 changes: 3 additions & 1 deletion panels/dock/MenuHelper.qml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2023-2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

Expand All @@ -8,12 +8,14 @@ import Qt.labs.platform

Item {
property Menu activeMenu: null
property bool hasTrayMenuOpen: false

signal menuClosed()
Connections {
target: activeMenu
function onAboutToHide() {
activeMenu = null
hasTrayMenuOpen = false
menuClosed()
}
}
Expand Down
4 changes: 4 additions & 0 deletions panels/dock/taskmanager/package/AppItem.qml
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,10 @@ Item {
function requestAppItemMenu() {
contextMenuLoader.trashEmpty = TaskManager.isTrashEmpty()
contextMenuLoader.active = true
let notifyPanel = DS.applet("org.deepin.ds.notificationcenter")
if (notifyPanel && notifyPanel.visible) {
notifyPanel.close()
}
MenuHelper.openMenu(contextMenuLoader.item)
}

Expand Down
61 changes: 59 additions & 2 deletions panels/dock/tray/SurfacePopup.qml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2024-2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

Expand All @@ -16,6 +16,52 @@ Item {
}
property int toolTipVOffset: 0
signal popupCreated(var surfaceId)
property var pendingTrayMenu: null
Timer {
id: trayMenuOpenTimer
interval: 150
repeat: false
onTriggered: {
if (pendingTrayMenu) {
Copy link

Choose a reason for hiding this comment

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

issue (bug_risk): autoCloseOnDeactivate is never restored because pendingTrayMenu is nulled before the restore timer runs

Because pendingTrayMenu is set to null immediately after open(), restoreAutoCloseTimer’s if (pendingTrayMenu) check always fails and autoCloseOnDeactivate is never reset for that menu. As a result, later menuWindow.active changes won’t auto-close the tray menu. You’ll need to either keep a separate reference for the restore timer, delay nulling pendingTrayMenu until after the restore runs, or restore autoCloseOnDeactivate in a way that doesn’t depend on pendingTrayMenu being non-null.

pendingTrayMenu.open()
pendingTrayMenu = null
}
}
}
Timer {
id: restoreAutoCloseTimer
interval: 200
repeat: false
onTriggered: {
if (pendingTrayMenu) {
pendingTrayMenu.autoCloseOnDeactivate = true
}
}
}
Connections {
target: menu
function onMenuVisibleChanged() {
if (!menu.menuVisible) {
MenuHelper.hasTrayMenuOpen = false
let notifyPanel = DS.applet("org.deepin.ds.notificationcenter")
if (notifyPanel) {
notifyPanel.hasTrayMenuOpen = false
}
}
}
}
Connections {
target: menu.menuWindow
function onActiveChanged() {
if (menu.menuWindow && !menu.menuWindow.active && !menu.menuVisible) {
MenuHelper.hasTrayMenuOpen = false
let notifyPanel = DS.applet("org.deepin.ds.notificationcenter")
if (notifyPanel) {
notifyPanel.hasTrayMenuOpen = false
}
}
}
}

PanelToolTipWindow {
id: toolTipWindow
Expand Down Expand Up @@ -144,7 +190,18 @@ Item {
menu.menuY = Qt.binding(function () {
return menu.shellSurface.y
})
menu.open()
let notifyPanel = DS.applet("org.deepin.ds.notificationcenter")
if (notifyPanel && notifyPanel.visible) {
notifyPanel.close()
}
menu.autoCloseOnDeactivate = false
MenuHelper.hasTrayMenuOpen = true
if (notifyPanel) {
notifyPanel.hasTrayMenuOpen = true
}
root.pendingTrayMenu = menu
trayMenuOpenTimer.restart()
restoreAutoCloseTimer.restart()
}
}
}
Expand Down
61 changes: 59 additions & 2 deletions panels/dock/tray/TrayItemSurfacePopup.qml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2024-2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

Expand All @@ -20,6 +20,52 @@ Item {
return false
}
readonly property bool isOpened: popup.popupVisible
property var pendingTrayMenu: null
Timer {
id: trayMenuOpenTimer
interval: 150
repeat: false
onTriggered: {
if (pendingTrayMenu) {
Copy link

Choose a reason for hiding this comment

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

issue (bug_risk): Same autoCloseOnDeactivate restoration issue as in SurfacePopup.qml

Here too, trayMenuOpenTimer clears pendingTrayMenu after opening, so when restoreAutoCloseTimer fires, pendingTrayMenu is null and autoCloseOnDeactivate is never restored. This leaves popupMenu.autoCloseOnDeactivate stuck at false, so deactivation won’t close the menu. Please adjust the logic (as in SurfacePopup.qml) so the flag is always restored after the first open.

pendingTrayMenu.open()
pendingTrayMenu = null
}
}
}
Timer {
id: restoreAutoCloseTimer
interval: 200
repeat: false
onTriggered: {
if (pendingTrayMenu) {
pendingTrayMenu.autoCloseOnDeactivate = true
}
}
}
Connections {
target: popupMenu
function onMenuVisibleChanged() {
if (!popupMenu.menuVisible) {
MenuHelper.hasTrayMenuOpen = false
let notifyPanel = DS.applet("org.deepin.ds.notificationcenter")
if (notifyPanel) {
notifyPanel.hasTrayMenuOpen = false
}
}
}
}
Connections {
target: popupMenu.menuWindow
function onActiveChanged() {
if (popupMenu.menuWindow && !popupMenu.menuWindow.active && !popupMenu.menuVisible) {
MenuHelper.hasTrayMenuOpen = false
let notifyPanel = DS.applet("org.deepin.ds.notificationcenter")
if (notifyPanel) {
notifyPanel.hasTrayMenuOpen = false
}
}
}
}
function closeTooltip() {
if (toolTip.toolTipVisible) {
toolTip.close()
Expand Down Expand Up @@ -161,7 +207,18 @@ Item {
var point = Qt.point(popupMenu.shellSurface.x, popupMenu.shellSurface.y)
return Qt.rect(point.x, point.y, popupMenu.width, popupMenu.height)
})
popupMenu.open()
let notifyPanel = DS.applet("org.deepin.ds.notificationcenter")
if (notifyPanel && notifyPanel.visible) {
notifyPanel.close()
}
popupMenu.autoCloseOnDeactivate = false
MenuHelper.hasTrayMenuOpen = true
if (notifyPanel) {
notifyPanel.hasTrayMenuOpen = true
}
root.pendingTrayMenu = popupMenu
trayMenuOpenTimer.restart()
restoreAutoCloseTimer.restart()
}
}
}
Expand Down
35 changes: 27 additions & 8 deletions panels/notification/center/notificationcenterpanel.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2024-2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

Expand All @@ -9,24 +9,26 @@
#include "notificationcenterproxy.h"
#include "notifyaccessor.h"

#include <pluginfactory.h>
#include <pluginloader.h>
#include <applet.h>

Check warning on line 12 in panels/notification/center/notificationcenterpanel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <applet.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <containment.h>
#include <appletbridge.h>

Check warning on line 13 in panels/notification/center/notificationcenterpanel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 14 in panels/notification/center/notificationcenterpanel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 15 in panels/notification/center/notificationcenterpanel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 16 in panels/notification/center/notificationcenterpanel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

#include <QQueue>
#include <QDBusConnection>

Check warning on line 18 in panels/notification/center/notificationcenterpanel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 19 in panels/notification/center/notificationcenterpanel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 20 in panels/notification/center/notificationcenterpanel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 21 in panels/notification/center/notificationcenterpanel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 22 in panels/notification/center/notificationcenterpanel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

DS_USE_NAMESPACE

namespace notification {
namespace notification
{
Q_DECLARE_LOGGING_CATEGORY(notifyLog)
}
namespace notification {
namespace notification
{

static const QString DDENotifyDBusServer = "org.deepin.dde.Notification1";
static const QString DDENotifyDBusInterface = "org.deepin.dde.Notification1";
Expand Down Expand Up @@ -99,6 +101,10 @@

void NotificationCenterPanel::setVisible(bool newVisible)
{
if (m_hasTrayMenuOpen) {
qDebug(notifyLog) << "Blocked: tray menu is open";
return;
}
if (m_visible == newVisible)
return;
m_visible = newVisible;
Expand Down Expand Up @@ -128,6 +134,19 @@
QMetaObject::invokeMethod(applet, "setEnabled", Qt::DirectConnection, Q_ARG(bool, enabled));
}

bool NotificationCenterPanel::hasTrayMenuOpen() const
{
return m_hasTrayMenuOpen;
}

void NotificationCenterPanel::setHasTrayMenuOpen(bool hasOpen)
{
if (m_hasTrayMenuOpen == hasOpen)
return;
m_hasTrayMenuOpen = hasOpen;
emit hasTrayMenuOpenChanged();
}

D_APPLET_CLASS(NotificationCenterPanel)
}

Expand Down
11 changes: 9 additions & 2 deletions panels/notification/center/notificationcenterpanel.h
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2024-2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

#pragma once

#include "panel.h"

namespace notification {
namespace notification
{

class NotificationCenterProxy;
class NotificationCenterPanel : public DS_NAMESPACE::DPanel
{
Q_OBJECT
Q_PROPERTY(bool visible READ visible NOTIFY visibleChanged FINAL)
Q_PROPERTY(bool hasTrayMenuOpen READ hasTrayMenuOpen WRITE setHasTrayMenuOpen NOTIFY hasTrayMenuOpenChanged FINAL)
public:
explicit NotificationCenterPanel(QObject *parent = nullptr);
~NotificationCenterPanel();
Expand All @@ -24,14 +26,19 @@ class NotificationCenterPanel : public DS_NAMESPACE::DPanel
void setVisible(bool newVisible);
Q_INVOKABLE void close();

bool hasTrayMenuOpen() const;
void setHasTrayMenuOpen(bool hasOpen);

Q_SIGNALS:
void visibleChanged();
void hasTrayMenuOpenChanged();

private slots:
void setBubblePanelEnabled(bool enabled);

private:
bool m_visible = false;
bool m_hasTrayMenuOpen = false;
NotificationCenterProxy *m_proxy = nullptr;
};
}
2 changes: 1 addition & 1 deletion panels/notification/center/package/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Window {
}

// visible: true
visible: Panel.visible
visible: Panel.visible && !Panel.hasTrayMenuOpen
flags: Qt.Tool

property int contentPadding: 20
Expand Down
Loading