no longer rely on ecm_qt_declare_logging_category
This commit is contained in:
@@ -10,7 +10,6 @@ find_package(Qt6 6.8 CONFIG REQUIRED COMPONENTS DBus)
|
|||||||
find_package(ECM REQUIRED NO_MODULE)
|
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(ECMQtDeclareLoggingCategory)
|
|
||||||
include(KDEInstallDirs)
|
include(KDEInstallDirs)
|
||||||
include(ECMConfiguredInstall)
|
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)
|
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})
|
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)
|
||||||
|
|
||||||
|
|||||||
@@ -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.
|
> 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 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
|
## Build instructions
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
|
|||||||
@@ -7,14 +7,12 @@
|
|||||||
*/
|
*/
|
||||||
#include "fdoselectionmanager.h"
|
#include "fdoselectionmanager.h"
|
||||||
|
|
||||||
#include "debug.h"
|
|
||||||
|
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QDBusConnection>
|
#include <QDBusConnection>
|
||||||
|
#include <QLoggingCategory>
|
||||||
|
|
||||||
#include <KSelectionOwner>
|
#include <KSelectionOwner>
|
||||||
|
|
||||||
#include <qassert.h>
|
|
||||||
#include <xcb/composite.h>
|
#include <xcb/composite.h>
|
||||||
#include <xcb/damage.h>
|
#include <xcb/damage.h>
|
||||||
#include <xcb/xcb_atom.h>
|
#include <xcb/xcb_atom.h>
|
||||||
@@ -30,11 +28,13 @@ using Util = tray::Util;
|
|||||||
#define SYSTEM_TRAY_BEGIN_MESSAGE 1
|
#define SYSTEM_TRAY_BEGIN_MESSAGE 1
|
||||||
#define SYSTEM_TRAY_CANCEL_MESSAGE 2
|
#define SYSTEM_TRAY_CANCEL_MESSAGE 2
|
||||||
|
|
||||||
|
Q_LOGGING_CATEGORY(SELECTIONMGR, "org.deepin.dde.trayloader.selectionmgr")
|
||||||
|
|
||||||
FdoSelectionManager::FdoSelectionManager()
|
FdoSelectionManager::FdoSelectionManager()
|
||||||
: QObject()
|
: QObject()
|
||||||
, 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(SNIPROXY) << "starting";
|
qDebug(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);
|
||||||
@@ -42,7 +42,7 @@ FdoSelectionManager::FdoSelectionManager()
|
|||||||
|
|
||||||
FdoSelectionManager::~FdoSelectionManager()
|
FdoSelectionManager::~FdoSelectionManager()
|
||||||
{
|
{
|
||||||
qCDebug(SNIPROXY) << "closing";
|
qCDebug(SELECTIONMGR) << "closing";
|
||||||
m_selectionOwner->release();
|
m_selectionOwner->release();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@ void FdoSelectionManager::init()
|
|||||||
xcb_damage_query_version_unchecked(c, XCB_DAMAGE_MAJOR_VERSION, XCB_DAMAGE_MINOR_VERSION);
|
xcb_damage_query_version_unchecked(c, XCB_DAMAGE_MAJOR_VERSION, XCB_DAMAGE_MINOR_VERSION);
|
||||||
} else {
|
} else {
|
||||||
// no XDamage means
|
// no XDamage means
|
||||||
qCCritical(SNIPROXY) << "could not load damage extension. Quitting";
|
qCCritical(SELECTIONMGR) << "could not load damage extension. Quitting";
|
||||||
qApp->exit(-1);
|
qApp->exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,7 +71,7 @@ void FdoSelectionManager::init()
|
|||||||
|
|
||||||
bool FdoSelectionManager::addDamageWatch(xcb_window_t client)
|
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();
|
xcb_connection_t *c = Util::instance()->getX11Connection();
|
||||||
const auto attribsCookie = xcb_get_window_attributes_unchecked(c, client);
|
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)
|
void FdoSelectionManager::dock(xcb_window_t winId)
|
||||||
{
|
{
|
||||||
Q_CHECK_PTR(m_trayManager);
|
Q_CHECK_PTR(m_trayManager);
|
||||||
qCDebug(SNIPROXY) << "trying to dock window " << winId;
|
qCDebug(SELECTIONMGR) << "trying to dock window " << winId;
|
||||||
|
|
||||||
if (m_trayManager->haveIcon(winId)) {
|
if (m_trayManager->haveIcon(winId)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (addDamageWatch(winId)) {
|
if (addDamageWatch(winId)) {
|
||||||
// auto proxy = new TrayManagerProxy(winId, this);
|
|
||||||
// m_proxies[winId] = proxy;
|
|
||||||
|
|
||||||
// Register with TrayManager1 if available
|
// Register with TrayManager1 if available
|
||||||
m_trayManager->registerIcon(winId);
|
m_trayManager->registerIcon(winId);
|
||||||
}
|
}
|
||||||
@@ -171,7 +168,7 @@ void FdoSelectionManager::dock(xcb_window_t winId)
|
|||||||
void FdoSelectionManager::undock(xcb_window_t winId)
|
void FdoSelectionManager::undock(xcb_window_t winId)
|
||||||
{
|
{
|
||||||
Q_CHECK_PTR(m_trayManager);
|
Q_CHECK_PTR(m_trayManager);
|
||||||
qCDebug(SNIPROXY) << "trying to undock window " << winId;
|
qCDebug(SELECTIONMGR) << "trying to undock window " << winId;
|
||||||
|
|
||||||
if (m_trayManager->haveIcon(winId)) {
|
if (m_trayManager->haveIcon(winId)) {
|
||||||
return;
|
return;
|
||||||
@@ -186,7 +183,7 @@ void FdoSelectionManager::undock(xcb_window_t winId)
|
|||||||
|
|
||||||
void FdoSelectionManager::onClaimedOwnership()
|
void FdoSelectionManager::onClaimedOwnership()
|
||||||
{
|
{
|
||||||
qCDebug(SNIPROXY) << "Manager selection claimed";
|
qCDebug(SELECTIONMGR) << "Manager selection claimed";
|
||||||
|
|
||||||
initTrayManager();
|
initTrayManager();
|
||||||
setSystemTrayVisual();
|
setSystemTrayVisual();
|
||||||
@@ -194,13 +191,13 @@ void FdoSelectionManager::onClaimedOwnership()
|
|||||||
|
|
||||||
void FdoSelectionManager::onFailedToClaimOwnership()
|
void FdoSelectionManager::onFailedToClaimOwnership()
|
||||||
{
|
{
|
||||||
qCWarning(SNIPROXY) << "failed to claim ownership of Systray Manager";
|
qCWarning(SELECTIONMGR) << "failed to claim ownership of Systray Manager";
|
||||||
qApp->exit(-1);
|
qApp->exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FdoSelectionManager::onLostOwnership()
|
void FdoSelectionManager::onLostOwnership()
|
||||||
{
|
{
|
||||||
qCWarning(SNIPROXY) << "lost ownership of Systray Manager";
|
qCWarning(SELECTIONMGR) << "lost ownership of Systray Manager";
|
||||||
qApp->exit(-1);
|
qApp->exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -253,7 +250,7 @@ void FdoSelectionManager::initTrayManager()
|
|||||||
QStringLiteral("org.deepin.dde.TrayManager1")
|
QStringLiteral("org.deepin.dde.TrayManager1")
|
||||||
);
|
);
|
||||||
|
|
||||||
qCDebug(SNIPROXY) << "TrayManager1 DBus interface registered";
|
qCDebug(SELECTIONMGR) << "TrayManager1 DBus interface registered";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
8
main.cpp
8
main.cpp
@@ -9,7 +9,6 @@
|
|||||||
|
|
||||||
#include "fdoselectionmanager.h"
|
#include "fdoselectionmanager.h"
|
||||||
|
|
||||||
#include "debug.h"
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
#ifdef None
|
#ifdef None
|
||||||
@@ -30,11 +29,14 @@ using Util = tray::Util;
|
|||||||
|
|
||||||
int main(int argc, char **argv)
|
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
|
// We will use the X connection managed by UTIL, we don't really care if the tool itself is
|
||||||
// if the QPA can't load xcb, this app is useless anyway.
|
// 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("QT_QPA_PLATFORM", "wayland");
|
||||||
qputenv("WAYLAND_DISPLAY", "dockplugin");
|
qputenv("WAYLAND_DISPLAY", "dockplugin");
|
||||||
qputenv("QT_WAYLAND_SHELL_INTEGRATION", "plugin-shell");
|
qputenv("QT_WAYLAND_SHELL_INTEGRATION", "plugin-shell");
|
||||||
|
// qputenv("QT_QPA_PLATFORM", "xcb");
|
||||||
|
|
||||||
QGuiApplication::setDesktopSettingsAware(false);
|
QGuiApplication::setDesktopSettingsAware(false);
|
||||||
QCoreApplication::setAttribute(Qt::AA_DisableSessionManager);
|
QCoreApplication::setAttribute(Qt::AA_DisableSessionManager);
|
||||||
|
|||||||
@@ -4,32 +4,35 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "traymanager1.h"
|
#include "traymanager1.h"
|
||||||
#include "debug.h"
|
|
||||||
#include "traymanager1adaptor.h"
|
#include "traymanager1adaptor.h"
|
||||||
|
|
||||||
#include <KWindowInfo>
|
#include <KWindowInfo>
|
||||||
#include <QGuiApplication>
|
#include <QGuiApplication>
|
||||||
|
#include <QLoggingCategory>
|
||||||
|
|
||||||
|
Q_LOGGING_CATEGORY(TRAYMGR, "org.deepin.dde.trayloader.traymgr")
|
||||||
|
|
||||||
TrayManager1::TrayManager1(QObject *parent)
|
TrayManager1::TrayManager1(QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
, m_adaptor(new TrayManager1Adaptor(this))
|
, m_adaptor(new TrayManager1Adaptor(this))
|
||||||
{
|
{
|
||||||
qCDebug(SNIPROXY) << "TrayManager1 created";
|
qCDebug(TRAYMGR) << "TrayManager1 created";
|
||||||
}
|
}
|
||||||
|
|
||||||
TrayManager1::~TrayManager1()
|
TrayManager1::~TrayManager1()
|
||||||
{
|
{
|
||||||
qCDebug(SNIPROXY) << "TrayManager1 destroyed";
|
qCDebug(TRAYMGR) << "TrayManager1 destroyed";
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrayManager1::registerIcon(xcb_window_t win)
|
void TrayManager1::registerIcon(xcb_window_t win)
|
||||||
{
|
{
|
||||||
if (m_icons.contains(win)) {
|
if (m_icons.contains(win)) {
|
||||||
qCWarning(SNIPROXY) << "Icon already registered:" << win;
|
qCWarning(TRAYMGR) << "Icon already registered:" << win;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_icons[win] = true;
|
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<uint32_t>(win));
|
Q_EMIT Added(static_cast<uint32_t>(win));
|
||||||
}
|
}
|
||||||
@@ -37,12 +40,12 @@ void TrayManager1::registerIcon(xcb_window_t win)
|
|||||||
void TrayManager1::unregisterIcon(xcb_window_t win)
|
void TrayManager1::unregisterIcon(xcb_window_t win)
|
||||||
{
|
{
|
||||||
if (!m_icons.contains(win)) {
|
if (!m_icons.contains(win)) {
|
||||||
qCWarning(SNIPROXY) << "Icon not found for removal:" << win;
|
qCWarning(TRAYMGR) << "Icon not found for removal:" << win;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_icons.remove(win);
|
m_icons.remove(win);
|
||||||
qCDebug(SNIPROXY) << "Icon unregistered:" << win;
|
qCDebug(TRAYMGR) << "Icon unregistered:" << win;
|
||||||
|
|
||||||
Q_EMIT Removed(static_cast<uint32_t>(win));
|
Q_EMIT Removed(static_cast<uint32_t>(win));
|
||||||
}
|
}
|
||||||
@@ -54,11 +57,11 @@ void TrayManager1::notifyIconChanged(xcb_window_t win)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!m_icons[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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
qCDebug(SNIPROXY) << "Icon changed:" << win;
|
qCDebug(TRAYMGR) << "Icon changed:" << win;
|
||||||
Q_EMIT Changed(static_cast<uint32_t>(win));
|
Q_EMIT Changed(static_cast<uint32_t>(win));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,7 +83,7 @@ bool TrayManager1::haveIcon(xcb_window_t win) const
|
|||||||
// DBus method implementations
|
// DBus method implementations
|
||||||
bool TrayManager1::Manage()
|
bool TrayManager1::Manage()
|
||||||
{
|
{
|
||||||
qCDebug(SNIPROXY) << "Manage() called via DBus";
|
qCDebug(TRAYMGR) << "Manage() called via DBus";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,5 +102,5 @@ void TrayManager1::EnableNotification(uint32_t win, bool enabled)
|
|||||||
|
|
||||||
m_icons[win] = enabled;
|
m_icons[win] = enabled;
|
||||||
|
|
||||||
qCDebug(SNIPROXY) << "EnableNotification for" << win << "=" << enabled;
|
qCDebug(TRAYMGR) << "EnableNotification for" << win << "=" << enabled;
|
||||||
}
|
}
|
||||||
|
|||||||
8
util.cpp
8
util.cpp
@@ -2,9 +2,7 @@
|
|||||||
//
|
//
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QLoggingCategory>
|
||||||
|
|
||||||
#include "debug.h"
|
|
||||||
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "xcbthread.h"
|
#include "xcbthread.h"
|
||||||
@@ -28,6 +26,8 @@
|
|||||||
#include <xcb/xproto.h>
|
#include <xcb/xproto.h>
|
||||||
#include <xcb/composite.h>
|
#include <xcb/composite.h>
|
||||||
|
|
||||||
|
Q_LOGGING_CATEGORY(TRAYUTIL, "org.deepin.dde.trayloader.util")
|
||||||
|
|
||||||
namespace tray {
|
namespace tray {
|
||||||
void clean_xcb_image(void *data)
|
void clean_xcb_image(void *data)
|
||||||
{
|
{
|
||||||
@@ -46,7 +46,7 @@ void Util::dispatchEvents(DispatchEventsMode mode)
|
|||||||
{
|
{
|
||||||
xcb_connection_t *connection = m_x11connection;
|
xcb_connection_t *connection = m_x11connection;
|
||||||
if (!connection) {
|
if (!connection) {
|
||||||
qCWarning(SNIPROXY, "Attempting to dispatch X11 events with no connection");
|
qCWarning(TRAYUTIL, "Attempting to dispatch X11 events with no connection");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user