97 lines
2.2 KiB
C++
97 lines
2.2 KiB
C++
/*
|
|
Deepin DDE TrayManager1 implementation
|
|
SPDX-License-Identifier: LGPL-2.1-or-later
|
|
*/
|
|
|
|
#include "traymanager1.h"
|
|
#include "traymanagerproxy.h"
|
|
#include "debug.h"
|
|
#include "traymanager1adaptor.h"
|
|
|
|
TrayManager1::TrayManager1(QObject *parent)
|
|
: QObject(parent)
|
|
, m_adaptor(new TrayManager1Adaptor(this))
|
|
{
|
|
qCDebug(SNIPROXY) << "TrayManager1 created";
|
|
}
|
|
|
|
TrayManager1::~TrayManager1()
|
|
{
|
|
qCDebug(SNIPROXY) << "TrayManager1 destroyed";
|
|
}
|
|
|
|
void TrayManager1::registerIcon(xcb_window_t win, TrayManagerProxy *proxy)
|
|
{
|
|
if (m_icons.contains(win)) {
|
|
qCWarning(SNIPROXY) << "Icon already registered:" << win;
|
|
return;
|
|
}
|
|
|
|
m_icons[win] = proxy;
|
|
qCDebug(SNIPROXY) << "Icon registered:" << win << "name:" << proxy->name();
|
|
|
|
Q_EMIT Added(static_cast<uint32_t>(win));
|
|
}
|
|
|
|
void TrayManager1::unregisterIcon(xcb_window_t win)
|
|
{
|
|
if (!m_icons.contains(win)) {
|
|
qCWarning(SNIPROXY) << "Icon not found for removal:" << win;
|
|
return;
|
|
}
|
|
|
|
m_icons.remove(win);
|
|
qCDebug(SNIPROXY) << "Icon unregistered:" << win;
|
|
|
|
Q_EMIT Removed(static_cast<uint32_t>(win));
|
|
}
|
|
|
|
void TrayManager1::notifyIconChanged(xcb_window_t win)
|
|
{
|
|
if (!m_icons.contains(win)) {
|
|
return;
|
|
}
|
|
|
|
qCDebug(SNIPROXY) << "Icon changed:" << win;
|
|
Q_EMIT Changed(static_cast<uint32_t>(win));
|
|
}
|
|
|
|
TrayList TrayManager1::trayIcons() const
|
|
{
|
|
qDebug() << "trayIcons:" << m_icons.keys();
|
|
TrayList result;
|
|
for (xcb_window_t win : m_icons.keys()) {
|
|
result << static_cast<uint>(win);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
TrayManagerProxy *TrayManager1::iconProxy(xcb_window_t win) const
|
|
{
|
|
return m_icons.value(win, nullptr);
|
|
}
|
|
|
|
// DBus method implementations
|
|
bool TrayManager1::Manage()
|
|
{
|
|
qCDebug(SNIPROXY) << "Manage() called via DBus";
|
|
return true;
|
|
}
|
|
|
|
QString TrayManager1::GetName(uint32_t win)
|
|
{
|
|
auto proxy = m_icons.value(static_cast<xcb_window_t>(win), nullptr);
|
|
if (proxy) {
|
|
return proxy->name();
|
|
}
|
|
return QString();
|
|
}
|
|
|
|
void TrayManager1::EnableNotification(uint32_t win, bool enabled)
|
|
{
|
|
auto proxy = m_icons.value(static_cast<xcb_window_t>(win), nullptr);
|
|
if (proxy) {
|
|
qCDebug(SNIPROXY) << "EnableNotification for" << win << "=" << enabled;
|
|
}
|
|
}
|