Compare commits

..

4 Commits

Author SHA1 Message Date
b7bcf428ee sync back changes from dde-tray-loader 2025-12-29 18:09:38 +08:00
cb3830e6c7 move some files around 2025-12-25 16:36:41 +08:00
16c90b6d25 reduce ecm usage 2025-12-25 15:28:30 +08:00
93daa1af0f no longer require xcbthread 2025-12-25 15:17:13 +08:00
14 changed files with 34 additions and 213 deletions

View File

@@ -11,10 +11,8 @@ find_package(ECM REQUIRED NO_MODULE)
find_package(PkgConfig REQUIRED) find_package(PkgConfig REQUIRED)
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
include(KDEInstallDirs) include(KDEInstallDirs)
include(ECMConfiguredInstall)
find_package(KF6 6.6 REQUIRED COMPONENTS find_package(KF6WindowSystem 6.6 REQUIRED)
WindowSystem)
pkg_check_modules(X11 REQUIRED IMPORTED_TARGET x11 xcb xcb-image xcb-damage xcb-composite xcb-xfixes xcb-util xcb-shape xtst xcb-xtest xcb-res xcb-ewmh) pkg_check_modules(X11 REQUIRED IMPORTED_TARGET x11 xcb xcb-image xcb-damage xcb-composite xcb-xfixes xcb-util xcb-shape xtst xcb-xtest xcb-res xcb-ewmh)
@@ -23,16 +21,15 @@ set(XEMBED_SNI_PROXY_SOURCES
fdoselectionmanager.cpp fdoselectionmanager.h fdoselectionmanager.cpp fdoselectionmanager.h
traymanager1.cpp traymanager1.h traymanager1.cpp traymanager1.h
util.cpp util.h util.cpp util.h
xcbthread.cpp xcbthread.h
) )
set_source_files_properties( set_source_files_properties(
${CMAKE_CURRENT_SOURCE_DIR}/org.deepin.dde.TrayManager1.xml ${CMAKE_CURRENT_SOURCE_DIR}/api/dbus/org.deepin.dde.TrayManager1.xml
PROPERTIES INCLUDE traylist.h PROPERTIES INCLUDE api/types/traylist.h
CLASSNAME TrayManager CLASSNAME TrayManager
) )
qt_add_dbus_adaptor(XEMBED_SNI_PROXY_SOURCES org.deepin.dde.TrayManager1.xml traymanager1.h TrayManager1) qt_add_dbus_adaptor(XEMBED_SNI_PROXY_SOURCES api/dbus/org.deepin.dde.TrayManager1.xml traymanager1.h TrayManager1)
add_executable(xembed-traymanager-proxy ${XEMBED_SNI_PROXY_SOURCES}) add_executable(xembed-traymanager-proxy ${XEMBED_SNI_PROXY_SOURCES})
set_property(TARGET xembed-traymanager-proxy PROPERTY AUTOMOC ON) set_property(TARGET xembed-traymanager-proxy PROPERTY AUTOMOC ON)
@@ -50,5 +47,3 @@ target_link_libraries(xembed-traymanager-proxy
install(TARGETS xembed-traymanager-proxy ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) install(TARGETS xembed-traymanager-proxy ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
install(FILES xembedsniproxy.desktop DESTINATION ${KDE_INSTALL_AUTOSTARTDIR}) install(FILES xembedsniproxy.desktop DESTINATION ${KDE_INSTALL_AUTOSTARTDIR})
ecm_install_configured_files(INPUT plasma-xembedsniproxy.service.in @ONLY DESTINATION ${KDE_INSTALL_SYSTEMDUSERUNITDIR})

View File

@@ -2,6 +2,7 @@
Registers as a embed container Registers as a embed container
SPDX-FileCopyrightText: 2015 David Edmundson <davidedmundson@kde.org> SPDX-FileCopyrightText: 2015 David Edmundson <davidedmundson@kde.org>
SPDX-FileCopyrightText: 2019 Konrad Materka <materka@gmail.com> SPDX-FileCopyrightText: 2019 Konrad Materka <materka@gmail.com>
SPDX-FileCopyrightText: 2025 Wang Zichong <wangzichong@deepin.org>
SPDX-License-Identifier: LGPL-2.1-or-later SPDX-License-Identifier: LGPL-2.1-or-later
*/ */
@@ -30,11 +31,11 @@ using Util = tray::Util;
Q_LOGGING_CATEGORY(SELECTIONMGR, "org.deepin.dde.trayloader.selectionmgr") Q_LOGGING_CATEGORY(SELECTIONMGR, "org.deepin.dde.trayloader.selectionmgr")
FdoSelectionManager::FdoSelectionManager() FdoSelectionManager::FdoSelectionManager(QObject *parent)
: QObject() : QObject(parent)
, m_selectionOwner(new KSelectionOwner(UTIL->getAtomFromDisplay("_NET_SYSTEM_TRAY"), UTIL->getX11Connection(), UTIL->getRootWindow(), this)) , 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 // 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); QTimer::singleShot(0, this, &FdoSelectionManager::init);
@@ -66,7 +67,11 @@ void FdoSelectionManager::init()
connect(m_selectionOwner, &KSelectionOwner::claimedOwnership, this, &FdoSelectionManager::onClaimedOwnership); connect(m_selectionOwner, &KSelectionOwner::claimedOwnership, this, &FdoSelectionManager::onClaimedOwnership);
connect(m_selectionOwner, &KSelectionOwner::failedToClaimOwnership, this, &FdoSelectionManager::onFailedToClaimOwnership); connect(m_selectionOwner, &KSelectionOwner::failedToClaimOwnership, this, &FdoSelectionManager::onFailedToClaimOwnership);
connect(m_selectionOwner, &KSelectionOwner::lostOwnership, this, &FdoSelectionManager::onLostOwnership); 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) bool FdoSelectionManager::addDamageWatch(xcb_window_t client)
@@ -170,7 +175,8 @@ void FdoSelectionManager::undock(xcb_window_t winId)
Q_CHECK_PTR(m_trayManager); Q_CHECK_PTR(m_trayManager);
qCDebug(SELECTIONMGR) << "trying to undock window " << winId; 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; return;
} }
@@ -192,13 +198,11 @@ void FdoSelectionManager::onClaimedOwnership()
void FdoSelectionManager::onFailedToClaimOwnership() void FdoSelectionManager::onFailedToClaimOwnership()
{ {
qCWarning(SELECTIONMGR) << "failed to claim ownership of Systray Manager"; qCWarning(SELECTIONMGR) << "failed to claim ownership of Systray Manager";
qApp->exit(-1);
} }
void FdoSelectionManager::onLostOwnership() void FdoSelectionManager::onLostOwnership()
{ {
qCWarning(SELECTIONMGR) << "lost ownership of Systray Manager"; qCWarning(SELECTIONMGR) << "lost ownership of Systray Manager";
qApp->exit(-1);
} }
void FdoSelectionManager::setSystemTrayVisual() void FdoSelectionManager::setSystemTrayVisual()

View File

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

View File

@@ -1,63 +0,0 @@
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
<!-- This is a minimally cut down version of the interface only implementing the
methods and properties used by xembedsniproxy -->
<interface name="org.kde.StatusNotifierItem">
<property name="Category" type="s" access="read"/>
<property name="Id" type="s" access="read"/>
<property name="Title" type="s" access="read"/>
<property name="Status" type="s" access="read"/>
<property name="WindowId" type="i" access="read"/>
<property name="ItemIsMenu" type="b" access="read"/>
<property name="IconPixmap" type="(iiay)" access="read">
<annotation name="org.qtproject.QtDBus.QtTypeName" value="KDbusImageVector"/>
</property>
<!-- interaction: the systemtray wants the application to do something -->
<method name="ContextMenu">
<!-- we're passing the coordinates of the icon, so the app knows where to put the popup window -->
<arg name="x" type="i" direction="in"/>
<arg name="y" type="i" direction="in"/>
</method>
<method name="Activate">
<arg name="x" type="i" direction="in"/>
<arg name="y" type="i" direction="in"/>
</method>
<method name="SecondaryActivate">
<arg name="x" type="i" direction="in"/>
<arg name="y" type="i" direction="in"/>
</method>
<method name="Scroll">
<arg name="delta" type="i" direction="in"/>
<arg name="orientation" type="s" direction="in"/>
</method>
<!-- Signals: the client wants to change something in the status-->
<signal name="NewTitle">
</signal>
<signal name="NewIcon">
</signal>
<signal name="NewAttentionIcon">
</signal>
<signal name="NewOverlayIcon">
</signal>
<signal name="NewToolTip">
</signal>
<signal name="NewStatus">
<arg name="status" type="s"/>
</signal>
</interface>
</node>

View File

@@ -1,42 +0,0 @@
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
<interface name="org.kde.StatusNotifierWatcher">
<!-- methods -->
<method name="RegisterStatusNotifierItem">
<arg name="service" type="s" direction="in"/>
</method>
<method name="RegisterStatusNotifierHost">
<arg name="service" type="s" direction="in"/>
</method>
<!-- properties -->
<property name="RegisteredStatusNotifierItems" type="as" access="read">
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QStringList"/>
</property>
<property name="IsStatusNotifierHostRegistered" type="b" access="read"/>
<property name="ProtocolVersion" type="i" access="read"/>
<!-- signals -->
<signal name="StatusNotifierItemRegistered">
<arg type="s"/>
</signal>
<signal name="StatusNotifierItemUnregistered">
<arg type="s"/>
</signal>
<signal name="StatusNotifierHostRegistered">
</signal>
<signal name="StatusNotifierHostUnregistered">
</signal>
</interface>
</node>

View File

@@ -1,11 +0,0 @@
[Unit]
Description=Handle legacy xembed system tray icons
PartOf=graphical-session.target
After=plasma-core.target
[Service]
ExecStart=@CMAKE_INSTALL_FULL_BINDIR@/xembedsniproxy
Restart=on-failure
Type=simple
Slice=background.slice
TimeoutSec=5sec

View File

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

View File

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

View File

@@ -5,7 +5,6 @@
#include <QLoggingCategory> #include <QLoggingCategory>
#include "util.h" #include "util.h"
#include "xcbthread.h"
#include <QSize> #include <QSize>
#include <QPixmap> #include <QPixmap>

3
util.h
View File

@@ -21,7 +21,6 @@ struct _XDisplay;
namespace tray { namespace tray {
#define UTIL Util::instance() #define UTIL Util::instance()
class XcbThread;
class Util : public QObject class Util : public QObject
{ {
@@ -79,8 +78,6 @@ private:
_XDisplay *m_display; _XDisplay *m_display;
QSet<QString> m_currentIds; QSet<QString> m_currentIds;
XcbThread *m_xcbThread;
}; };
} }

View File

@@ -1,42 +0,0 @@
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#include "xcbthread.h"
#include "util.h"
namespace tray {
XcbThread::XcbThread(xcb_connection_t *connection, QObject *parent)
: QThread(parent)
, m_connection(connection)
{
}
XcbThread::~XcbThread()
{
}
void XcbThread::run()
{
if (!m_connection) {
return;
}
// The Xembed type tray needs to reset the xwindow state of the receiving event to the state of not receiving events after the mouse
// leaves. This thread is used to receive the leave event and apply the operation.
QScopedPointer<xcb_generic_event_t> event;
while (!isInterruptionRequested()) {
event.reset(xcb_wait_for_event(m_connection));
if (event) {
uint8_t responseType = event->response_type & ~0x80;
switch (responseType) {
case XCB_LEAVE_NOTIFY: {
xcb_leave_notify_event_t *lE = (xcb_leave_notify_event_t *)event.data();
UTIL->setX11WindowInputShape(lE->event, QSize(0, 0));
break;
}
}
}
}
}
}

View File

@@ -1,22 +0,0 @@
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
#include <QThread>
#include <xcb/xcb.h>
namespace tray {
class XcbThread : public QThread {
Q_OBJECT
public:
XcbThread(xcb_connection_t *connection, QObject *parent = nullptr);
~XcbThread();
void run() override;
private:
xcb_connection_t *m_connection;
};
}