diff --git a/CMakeLists.txt b/CMakeLists.txt index 790c3a6..da3ff84 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,6 @@ find_package(Qt6 6.8 CONFIG REQUIRED COMPONENTS DBus) find_package(ECM REQUIRED NO_MODULE) find_package(PkgConfig REQUIRED) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) -include(ECMQtDeclareLoggingCategory) include(KDEInstallDirs) include(ECMConfiguredInstall) @@ -35,14 +34,6 @@ set_source_files_properties( qt_add_dbus_adaptor(XEMBED_SNI_PROXY_SOURCES org.deepin.dde.TrayManager1.xml traymanager1.h TrayManager1) -ecm_qt_declare_logging_category(XEMBED_SNI_PROXY_SOURCES HEADER debug.h - IDENTIFIER SNIPROXY - CATEGORY_NAME dde.xembedsniproxy - DEFAULT_SEVERITY Info - DESCRIPTION "xembed sni proxy" - EXPORT PLASMAWORKSPACE - ) - add_executable(xembed-traymanager-proxy ${XEMBED_SNI_PROXY_SOURCES}) set_property(TARGET xembed-traymanager-proxy PROPERTY AUTOMOC ON) diff --git a/Readme.md b/Readme.md index a2a0911..b1ca20d 100644 --- a/Readme.md +++ b/Readme.md @@ -9,6 +9,8 @@ This is to allow legacy apps (xchat, pidgin, tuxguitar) etc. system trays[1] ava > Currently this project is a standalone project that provides Xembed tray information on TrayManager1 D-Bus, so `dde-tray-loader` could consume it and provide Xembed tray icons. > This project will be integrated into `dde-tray-loader` project. +This tool can be used on a Wayland session with `wayland` QPA, `xcb` QPA can also be used but it's not mandatory, but either way it's required to have a X connection (via X11 or Xwayland). + ## Build instructions ```shell diff --git a/fdoselectionmanager.cpp b/fdoselectionmanager.cpp index 0294123..6448711 100644 --- a/fdoselectionmanager.cpp +++ b/fdoselectionmanager.cpp @@ -7,14 +7,12 @@ */ #include "fdoselectionmanager.h" -#include "debug.h" - #include #include +#include #include -#include #include #include #include @@ -30,11 +28,13 @@ using Util = tray::Util; #define SYSTEM_TRAY_BEGIN_MESSAGE 1 #define SYSTEM_TRAY_CANCEL_MESSAGE 2 +Q_LOGGING_CATEGORY(SELECTIONMGR, "org.deepin.dde.trayloader.selectionmgr") + FdoSelectionManager::FdoSelectionManager() : QObject() , m_selectionOwner(new KSelectionOwner(UTIL->getAtomFromDisplay("_NET_SYSTEM_TRAY"), UTIL->getX11Connection(), UTIL->getRootWindow(), this)) { - qDebug(SNIPROXY) << "starting"; + qDebug(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); @@ -42,7 +42,7 @@ FdoSelectionManager::FdoSelectionManager() FdoSelectionManager::~FdoSelectionManager() { - qCDebug(SNIPROXY) << "closing"; + qCDebug(SELECTIONMGR) << "closing"; m_selectionOwner->release(); } @@ -57,7 +57,7 @@ void FdoSelectionManager::init() xcb_damage_query_version_unchecked(c, XCB_DAMAGE_MAJOR_VERSION, XCB_DAMAGE_MINOR_VERSION); } else { // no XDamage means - qCCritical(SNIPROXY) << "could not load damage extension. Quitting"; + qCCritical(SELECTIONMGR) << "could not load damage extension. Quitting"; qApp->exit(-1); } @@ -71,7 +71,7 @@ void FdoSelectionManager::init() bool FdoSelectionManager::addDamageWatch(xcb_window_t client) { - qCDebug(SNIPROXY) << "adding damage watch for " << client; + qCDebug(SELECTIONMGR) << "adding damage watch for " << client; xcb_connection_t *c = Util::instance()->getX11Connection(); const auto attribsCookie = xcb_get_window_attributes_unchecked(c, client); @@ -153,16 +153,13 @@ bool FdoSelectionManager::nativeEventFilter(const QByteArray &eventType, void *m void FdoSelectionManager::dock(xcb_window_t winId) { Q_CHECK_PTR(m_trayManager); - qCDebug(SNIPROXY) << "trying to dock window " << winId; + qCDebug(SELECTIONMGR) << "trying to dock window " << winId; if (m_trayManager->haveIcon(winId)) { return; } if (addDamageWatch(winId)) { - // auto proxy = new TrayManagerProxy(winId, this); - // m_proxies[winId] = proxy; - // Register with TrayManager1 if available m_trayManager->registerIcon(winId); } @@ -171,7 +168,7 @@ void FdoSelectionManager::dock(xcb_window_t winId) void FdoSelectionManager::undock(xcb_window_t winId) { Q_CHECK_PTR(m_trayManager); - qCDebug(SNIPROXY) << "trying to undock window " << winId; + qCDebug(SELECTIONMGR) << "trying to undock window " << winId; if (m_trayManager->haveIcon(winId)) { return; @@ -186,7 +183,7 @@ void FdoSelectionManager::undock(xcb_window_t winId) void FdoSelectionManager::onClaimedOwnership() { - qCDebug(SNIPROXY) << "Manager selection claimed"; + qCDebug(SELECTIONMGR) << "Manager selection claimed"; initTrayManager(); setSystemTrayVisual(); @@ -194,13 +191,13 @@ void FdoSelectionManager::onClaimedOwnership() void FdoSelectionManager::onFailedToClaimOwnership() { - qCWarning(SNIPROXY) << "failed to claim ownership of Systray Manager"; + qCWarning(SELECTIONMGR) << "failed to claim ownership of Systray Manager"; qApp->exit(-1); } void FdoSelectionManager::onLostOwnership() { - qCWarning(SNIPROXY) << "lost ownership of Systray Manager"; + qCWarning(SELECTIONMGR) << "lost ownership of Systray Manager"; qApp->exit(-1); } @@ -253,7 +250,7 @@ void FdoSelectionManager::initTrayManager() QStringLiteral("org.deepin.dde.TrayManager1") ); - qCDebug(SNIPROXY) << "TrayManager1 DBus interface registered"; + qCDebug(SELECTIONMGR) << "TrayManager1 DBus interface registered"; } } diff --git a/main.cpp b/main.cpp index 88e7e30..289f440 100644 --- a/main.cpp +++ b/main.cpp @@ -9,7 +9,6 @@ #include "fdoselectionmanager.h" -#include "debug.h" #include "util.h" #ifdef None @@ -30,11 +29,14 @@ using Util = tray::Util; int main(int argc, char **argv) { - // the whole point of this is to interact with X, if we are in any other session, force trying to connect to X - // if the QPA can't load xcb, this app is useless anyway. + // We will use the X connection managed by UTIL, we don't really care if the tool itself is + // running with xcb or wayland QPA. + // We'll use wayland QPA for testing on DDE, the following code uses dde-tray-loader's wayland + // display, thus we can ensure our X events are not from QPA. qputenv("QT_QPA_PLATFORM", "wayland"); qputenv("WAYLAND_DISPLAY", "dockplugin"); qputenv("QT_WAYLAND_SHELL_INTEGRATION", "plugin-shell"); + // qputenv("QT_QPA_PLATFORM", "xcb"); QGuiApplication::setDesktopSettingsAware(false); QCoreApplication::setAttribute(Qt::AA_DisableSessionManager); diff --git a/traymanager1.cpp b/traymanager1.cpp index a65f2c4..18a934c 100644 --- a/traymanager1.cpp +++ b/traymanager1.cpp @@ -4,32 +4,35 @@ */ #include "traymanager1.h" -#include "debug.h" #include "traymanager1adaptor.h" #include #include +#include + +Q_LOGGING_CATEGORY(TRAYMGR, "org.deepin.dde.trayloader.traymgr") + TrayManager1::TrayManager1(QObject *parent) : QObject(parent) , m_adaptor(new TrayManager1Adaptor(this)) { - qCDebug(SNIPROXY) << "TrayManager1 created"; + qCDebug(TRAYMGR) << "TrayManager1 created"; } TrayManager1::~TrayManager1() { - qCDebug(SNIPROXY) << "TrayManager1 destroyed"; + qCDebug(TRAYMGR) << "TrayManager1 destroyed"; } void TrayManager1::registerIcon(xcb_window_t win) { if (m_icons.contains(win)) { - qCWarning(SNIPROXY) << "Icon already registered:" << win; + qCWarning(TRAYMGR) << "Icon already registered:" << win; return; } m_icons[win] = true; - qCDebug(SNIPROXY) << "Icon registered:" << win ;//<< "name:" << proxy->name(); + qCDebug(TRAYMGR) << "Icon registered:" << win ;//<< "name:" << proxy->name(); Q_EMIT Added(static_cast(win)); } @@ -37,12 +40,12 @@ void TrayManager1::registerIcon(xcb_window_t win) void TrayManager1::unregisterIcon(xcb_window_t win) { if (!m_icons.contains(win)) { - qCWarning(SNIPROXY) << "Icon not found for removal:" << win; + qCWarning(TRAYMGR) << "Icon not found for removal:" << win; return; } m_icons.remove(win); - qCDebug(SNIPROXY) << "Icon unregistered:" << win; + qCDebug(TRAYMGR) << "Icon unregistered:" << win; Q_EMIT Removed(static_cast(win)); } @@ -54,11 +57,11 @@ void TrayManager1::notifyIconChanged(xcb_window_t win) } if (!m_icons[win]) { - qCDebug(SNIPROXY) << "EnableNotification is false, not sending changed signal for:" << win; + qCDebug(TRAYMGR) << "EnableNotification is false, not sending changed signal for:" << win; return; } - qCDebug(SNIPROXY) << "Icon changed:" << win; + qCDebug(TRAYMGR) << "Icon changed:" << win; Q_EMIT Changed(static_cast(win)); } @@ -80,7 +83,7 @@ bool TrayManager1::haveIcon(xcb_window_t win) const // DBus method implementations bool TrayManager1::Manage() { - qCDebug(SNIPROXY) << "Manage() called via DBus"; + qCDebug(TRAYMGR) << "Manage() called via DBus"; return true; } @@ -99,5 +102,5 @@ void TrayManager1::EnableNotification(uint32_t win, bool enabled) m_icons[win] = enabled; - qCDebug(SNIPROXY) << "EnableNotification for" << win << "=" << enabled; + qCDebug(TRAYMGR) << "EnableNotification for" << win << "=" << enabled; } diff --git a/util.cpp b/util.cpp index 95a4353..fe8b0ed 100644 --- a/util.cpp +++ b/util.cpp @@ -2,9 +2,7 @@ // // SPDX-License-Identifier: GPL-3.0-or-later -#include - -#include "debug.h" +#include #include "util.h" #include "xcbthread.h" @@ -28,6 +26,8 @@ #include #include +Q_LOGGING_CATEGORY(TRAYUTIL, "org.deepin.dde.trayloader.util") + namespace tray { void clean_xcb_image(void *data) { @@ -46,7 +46,7 @@ void Util::dispatchEvents(DispatchEventsMode mode) { xcb_connection_t *connection = m_x11connection; if (!connection) { - qCWarning(SNIPROXY, "Attempting to dispatch X11 events with no connection"); + qCWarning(TRAYUTIL, "Attempting to dispatch X11 events with no connection"); return; }