sync back changes from dde-tray-loader

This commit is contained in:
2025-12-29 18:09:38 +08:00
parent cb3830e6c7
commit b7bcf428ee
4 changed files with 29 additions and 20 deletions

View File

@@ -31,11 +31,11 @@ using Util = tray::Util;
Q_LOGGING_CATEGORY(SELECTIONMGR, "org.deepin.dde.trayloader.selectionmgr")
FdoSelectionManager::FdoSelectionManager()
: QObject()
FdoSelectionManager::FdoSelectionManager(QObject *parent)
: QObject(parent)
, m_selectionOwner(new KSelectionOwner(UTIL->getAtomFromDisplay("_NET_SYSTEM_TRAY"), UTIL->getX11Connection(), UTIL->getRootWindow(), this))
{
qDebug(SELECTIONMGR) << "starting";
qCDebug(SELECTIONMGR) << "starting";
// we may end up calling QCoreApplication::quit() in this method, at which point we need the event loop running
QTimer::singleShot(0, this, &FdoSelectionManager::init);
@@ -67,7 +67,11 @@ void FdoSelectionManager::init()
connect(m_selectionOwner, &KSelectionOwner::claimedOwnership, this, &FdoSelectionManager::onClaimedOwnership);
connect(m_selectionOwner, &KSelectionOwner::failedToClaimOwnership, this, &FdoSelectionManager::onFailedToClaimOwnership);
connect(m_selectionOwner, &KSelectionOwner::lostOwnership, this, &FdoSelectionManager::onLostOwnership);
m_selectionOwner->claim(false);
m_selectionOwner->claim(true);
connect(m_trayManager, &TrayManager1::reclainRequested, this, [this](){
m_selectionOwner->claim(true);
});
}
bool FdoSelectionManager::addDamageWatch(xcb_window_t client)
@@ -171,10 +175,11 @@ void FdoSelectionManager::undock(xcb_window_t winId)
Q_CHECK_PTR(m_trayManager);
qCDebug(SELECTIONMGR) << "trying to undock window " << winId;
if (m_trayManager->haveIcon(winId)) {
if (!m_trayManager->haveIcon(winId)) {
qCDebug(SELECTIONMGR) << "failed to find winId to undock:" << winId;
return;
}
// Unregister from TrayManager1 if available
m_trayManager->unregisterIcon(winId);
@@ -193,13 +198,11 @@ void FdoSelectionManager::onClaimedOwnership()
void FdoSelectionManager::onFailedToClaimOwnership()
{
qCWarning(SELECTIONMGR) << "failed to claim ownership of Systray Manager";
qApp->exit(-1);
}
void FdoSelectionManager::onLostOwnership()
{
qCWarning(SELECTIONMGR) << "lost ownership of Systray Manager";
qApp->exit(-1);
}
void FdoSelectionManager::setSystemTrayVisual()

View File

@@ -23,7 +23,7 @@ class FdoSelectionManager : public QObject, public QAbstractNativeEventFilter
Q_OBJECT
public:
FdoSelectionManager();
FdoSelectionManager(QObject *parent = nullptr);
~FdoSelectionManager() override;
protected:

View File

@@ -1,11 +1,14 @@
/*
Deepin DDE TrayManager1 implementation
SPDX-License-Identifier: LGPL-2.1-or-later
*/
// Deepin DDE TrayManager1 implementation
//
// SPDX-FileCopyrightText: 2025 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#include "traymanager1.h"
#include "traymanager1adaptor.h"
#include "util.h"
#include <KWindowInfo>
#include <QGuiApplication>
#include <QLoggingCategory>
@@ -84,14 +87,14 @@ bool TrayManager1::haveIcon(xcb_window_t win) const
bool TrayManager1::Manage()
{
qCDebug(TRAYMGR) << "Manage() called via DBus";
emit reclainRequested();
return true;
}
QString TrayManager1::GetName(uint32_t win)
{
auto connection = qGuiApp->nativeInterface<QNativeInterface::QX11Application>()->connection();
KWindowInfo info(win, NET::WMName | NET::WMIconName);
return info.name();
using Util = tray::Util;
return UTIL->getX11WindowName(win);
}
void TrayManager1::EnableNotification(uint32_t win, bool enabled)

View File

@@ -1,7 +1,8 @@
/*
Deepin DDE TrayManager1 implementation
SPDX-License-Identifier: LGPL-2.1-or-later
*/
// Deepin DDE TrayManager1 implementation
//
// SPDX-FileCopyrightText: 2025 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
@@ -74,6 +75,8 @@ Q_SIGNALS:
void Changed(uint32_t id);
void Inited();
void reclainRequested();
private:
TrayManager1Adaptor * m_adaptor;
QHash<xcb_window_t, bool> m_icons; // <winid, enableNotify>