解决openkylin上打开应用会出现第二个图标问题
This commit is contained in:
parent
4134d4f6bd
commit
c9f9826858
|
@ -25,9 +25,9 @@ find_package(KF5WindowSystem REQUIRED)
|
|||
pkg_check_modules(GLIB2 REQUIRED glib-2.0 gio-2.0 udisks2)
|
||||
pkg_check_modules(QGS REQUIRED gsettings-qt)
|
||||
|
||||
|
||||
include_directories(${GLIB2_INCLUDE_DIRS})
|
||||
include_directories(${QGS_INCLUDE_DIRS})
|
||||
|
||||
add_executable(panel-daemon
|
||||
jsonwathcer/jsonwacther.cpp
|
||||
jsonwathcer/jsonwacther.h
|
||||
|
@ -53,7 +53,20 @@ add_executable(panel-daemon
|
|||
|
||||
add_definitions(-DQT_MESSAGELOGCONTEXT)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} Qt5::Widgets Qt5::DBus Qt5::Network ${GLIB2_LIBRARIES} ${QGS_LIBRARIES} KF5::WindowSystem)
|
||||
pkg_check_modules(KYSDKWAYLANDHELPER_PKG kysdk-waylandhelper)
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE ${KYSDKWAYLANDHELPER_PKG_INCLUDE_DIRS})
|
||||
target_link_directories(${PROJECT_NAME} PRIVATE ${KYSDKWAYLANDHELPER_PKG_LIBRARY_DIRS} KF5::WindowSystem)
|
||||
target_link_libraries(${PROJECT_NAME} ${KYSDKWAYLANDHELPER_PKG_LIBRARIES})
|
||||
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
Qt5::Widgets
|
||||
Qt5::DBus
|
||||
Qt5::Network
|
||||
${GLIB2_LIBRARIES}
|
||||
${QGS_LIBRARIES}
|
||||
KF5::WindowSystem
|
||||
)
|
||||
|
||||
|
||||
install(TARGETS panel-daemon DESTINATION bin)
|
||||
|
||||
|
|
|
@ -20,23 +20,35 @@
|
|||
#include <QFile>
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
|
||||
#include "kysdk/applications/windowmanager/windowmanager.h"
|
||||
|
||||
ConvertDesktopToWinId::ConvertDesktopToWinId()
|
||||
{
|
||||
//connect(KWindowSystem::self(), &KWindowSystem::windowAdded, this, &ConvertDesktopToWinId::tranIdToDesktop);
|
||||
}
|
||||
|
||||
QString ConvertDesktopToWinId::tranIdToDesktop(WId id)
|
||||
QString ConvertDesktopToWinId::tranIdToDesktop(int id)
|
||||
{
|
||||
QString desktopName = confirmDesktopFile(id);
|
||||
qDebug() << "desktopName is :" << desktopName;
|
||||
return desktopName;
|
||||
}
|
||||
|
||||
QString ConvertDesktopToWinId::confirmDesktopFile(WId id)
|
||||
int ConvertDesktopToWinId::getPidFromInfo(int id)
|
||||
{
|
||||
//x环境下输入wid转成pid, wayland下windowId转pid
|
||||
KWindowInfo info(id, 0, NET::WM2AllProperties);
|
||||
if (info.valid()) {
|
||||
m_pid = info.pid();
|
||||
} else {
|
||||
m_pid = kdk::WindowManager::getPid(id);
|
||||
}
|
||||
return m_pid;
|
||||
}
|
||||
|
||||
QString ConvertDesktopToWinId::confirmDesktopFile(int id)
|
||||
{
|
||||
m_pid = getPidFromInfo(id);
|
||||
m_desktopfilePath = "";
|
||||
QDir infoDir(DEKSTOP_FILE_PATH);
|
||||
m_list = infoDir.entryInfoList();
|
||||
|
@ -52,12 +64,11 @@ QString ConvertDesktopToWinId::confirmDesktopFile(WId id)
|
|||
|
||||
//第一种方法:比较名字一致性
|
||||
if (m_desktopfilePath.isEmpty()) {
|
||||
m_classClass = info.windowClassClass().toLower();
|
||||
m_className = info.windowClassName();
|
||||
m_className = kdk::WindowManager::getWindowGroup(id);
|
||||
|
||||
//匹配安卓兼容
|
||||
if (m_className == "kylin-kmre-window") {
|
||||
searchAndroidApp(info);
|
||||
searchAndroidApp(id);
|
||||
return m_desktopfilePath;
|
||||
}
|
||||
|
||||
|
@ -67,7 +78,7 @@ QString ConvertDesktopToWinId::confirmDesktopFile(WId id)
|
|||
return m_desktopfilePath;
|
||||
}
|
||||
|
||||
QFile file(QString("/proc/%1/status").arg(info.pid()));
|
||||
QFile file(QString("/proc/%1/status").arg(m_pid));
|
||||
if (file.open(QIODevice::ReadOnly)) {
|
||||
char buf[1024];
|
||||
qint64 len=file.readLine(buf,sizeof(buf));
|
||||
|
@ -77,15 +88,14 @@ QString ConvertDesktopToWinId::confirmDesktopFile(WId id)
|
|||
}
|
||||
compareClassName();
|
||||
}
|
||||
|
||||
//第二种方法:获取点击应用时大部分desktop文件名
|
||||
if (m_desktopfilePath.isEmpty()) {
|
||||
searchFromEnviron(info);
|
||||
searchFromEnviron(id);
|
||||
}
|
||||
|
||||
//第三种方法:比较cmd命令行操作一致性
|
||||
if (m_desktopfilePath.isEmpty()) {
|
||||
QFile file(QString("/proc/%1/cmdline").arg(info.pid()));
|
||||
QFile file(QString("/proc/%1/cmdline").arg(m_pid));
|
||||
if (file.open(QIODevice::ReadOnly)) {
|
||||
char buf[1024];
|
||||
qint64 len=file.readLine(buf,sizeof(buf));
|
||||
|
@ -103,14 +113,14 @@ QString ConvertDesktopToWinId::confirmDesktopFile(WId id)
|
|||
return m_desktopfilePath;
|
||||
}
|
||||
|
||||
void ConvertDesktopToWinId::searchAndroidApp(KWindowInfo info)
|
||||
void ConvertDesktopToWinId::searchAndroidApp(int id)
|
||||
{
|
||||
QDir androidDir(QString(QDir::homePath() + ANDROID_FILE_PATH));
|
||||
m_androidList = androidDir.entryInfoList();
|
||||
m_androidList.removeAll(QDir::homePath() + ANDROID_APP_CURRENT);
|
||||
m_androidList.removeAll(QDir::homePath() + ANDROID_APP_UPER);
|
||||
|
||||
QFile file(QString("/proc/%1/cmdline").arg(info.pid()));
|
||||
QFile file(QString("/proc/%1/cmdline").arg(m_pid));
|
||||
file.open(QIODevice::ReadOnly);
|
||||
QByteArray cmd = file.readAll();
|
||||
file.close();
|
||||
|
@ -150,9 +160,9 @@ void ConvertDesktopToWinId::searchTXeduApp(WId id)
|
|||
}
|
||||
}
|
||||
|
||||
void ConvertDesktopToWinId::searchFromEnviron(KWindowInfo info)
|
||||
void ConvertDesktopToWinId::searchFromEnviron(int id)
|
||||
{
|
||||
QFile file("/proc/" + QString::number(info.pid()) + "/environ");
|
||||
QFile file("/proc/" + QString::number(m_pid) + "/environ");
|
||||
file.open(QIODevice::ReadOnly);
|
||||
QByteArray BA = file.readAll();
|
||||
file.close();
|
||||
|
@ -189,7 +199,7 @@ void ConvertDesktopToWinId::compareClassName()
|
|||
}
|
||||
path_desktop_name = path_desktop_name.mid(path_desktop_name.lastIndexOf("/") + 1);
|
||||
path_desktop_name = path_desktop_name.left(path_desktop_name.lastIndexOf("."));
|
||||
if (path_desktop_name == m_classClass || path_desktop_name == m_className || path_desktop_name == m_statusName) {
|
||||
if (path_desktop_name == m_className || path_desktop_name == m_statusName) {
|
||||
m_desktopfilePath = fileInfo.filePath();
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#ifndef CONVERTDESKTOPTOWINID_H
|
||||
#define CONVERTDESKTOPTOWINID_H
|
||||
|
||||
#include "convertdesktoptowinid.h"
|
||||
#include <QObject>
|
||||
#include <KWindowSystem>
|
||||
#include <QDir>
|
||||
|
@ -57,7 +56,6 @@ public:
|
|||
~ConvertDesktopToWinId();
|
||||
//QList<int> InfoPidList;
|
||||
QString m_desktopfilePath = nullptr;
|
||||
QString m_classClass = nullptr;
|
||||
QString m_className = nullptr;
|
||||
QString m_statusName = nullptr;
|
||||
QString m_cmdLine = nullptr;
|
||||
|
@ -67,12 +65,13 @@ public:
|
|||
QFileInfoList m_list;
|
||||
QFileInfoList m_androidList;
|
||||
|
||||
QString tranIdToDesktop(WId id);
|
||||
QString tranIdToDesktop(int id);
|
||||
int getPidFromInfo(int id);
|
||||
|
||||
private:
|
||||
QString confirmDesktopFile(WId id);
|
||||
void searchFromEnviron(KWindowInfo info);
|
||||
void searchAndroidApp(KWindowInfo info);
|
||||
QString confirmDesktopFile(int id);
|
||||
void searchFromEnviron(int id);
|
||||
void searchAndroidApp(int id);
|
||||
void searchTXeduApp(WId id);
|
||||
void compareClassName();
|
||||
void compareCmdExec();
|
||||
|
@ -81,6 +80,8 @@ private:
|
|||
void compareDesktopClass();
|
||||
void containsName();
|
||||
QString getDesktopFileName(QString cmd);
|
||||
|
||||
int m_pid;
|
||||
};
|
||||
|
||||
#endif // CONVERTDESKTOPTOWINID_H
|
||||
|
|
|
@ -30,7 +30,6 @@ add_executable(sni-xembed-proxy
|
|||
sniproxy.cpp
|
||||
snidbus.cpp
|
||||
statusnotifierwatcher_interface.cpp
|
||||
../panel-daemon/convert-desktop-windowid/convertdesktoptowinid.cpp
|
||||
xtestsender.cpp
|
||||
|
||||
snixembedproxy.h
|
||||
|
@ -39,7 +38,6 @@ add_executable(sni-xembed-proxy
|
|||
statusnotifierwatcher_interface.h
|
||||
systemtraytypedefs.h
|
||||
xcbutilss.h
|
||||
../panel-daemon/convert-desktop-windowid/convertdesktoptowinid.h
|
||||
xtestsender.h
|
||||
)
|
||||
|
||||
|
|
|
@ -57,6 +57,11 @@
|
|||
#define SNI_WATCHER_SERVICE_NAME "org.kde.StatusNotifierWatcher"
|
||||
#define SNI_WATCHER_PATH "/StatusNotifierWatcher"
|
||||
|
||||
#define UKUI_PANEL_DAEMON "org.ukui.panel.daemon"
|
||||
#define UKUI_PANEL_DAEMON_PATH "/convert/desktopwid"
|
||||
#define UKUI_PANEL_DAEMON_INTERFACE "org.ukui.panel.daemon"
|
||||
#define UKUI_PANEL_DAEMON_METHOD "WIDToDesktop"
|
||||
|
||||
static uint16_t s_embedSize = 32; //max size of window to embed. We no longer resize the embedded window as Chromium acts stupidly.
|
||||
static unsigned int XEMBED_VERSION = 0;
|
||||
|
||||
|
@ -456,6 +461,21 @@ void SNIProxy::stackContainerWindow(const uint32_t stackMode) const
|
|||
xcb_configure_window(c, m_containerWid, XCB_CONFIG_WINDOW_STACK_MODE, stackData);
|
||||
}
|
||||
|
||||
QString SNIProxy::winidtoDesktopFileName(const WId& wid) const
|
||||
{
|
||||
QDBusInterface iface(UKUI_PANEL_DAEMON,
|
||||
UKUI_PANEL_DAEMON_PATH,
|
||||
UKUI_PANEL_DAEMON_INTERFACE,
|
||||
QDBusConnection::sessionBus());
|
||||
if(iface.isValid()) {
|
||||
QDBusReply<QString> reply = iface.call(UKUI_PANEL_DAEMON_METHOD, int(wid));
|
||||
QString processExeName = reply.value();
|
||||
return processExeName;
|
||||
} else {
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
//____________properties__________
|
||||
|
||||
QString SNIProxy::Category() const
|
||||
|
@ -496,9 +516,7 @@ QString SNIProxy::Title() const
|
|||
KWindowInfo window (m_windowId, NET::WMName,NET::WM2WindowClass);
|
||||
//根据应用的dekstop文件查找中文名
|
||||
QString toolTip;
|
||||
ConvertDesktopToWinId *getDesktop = new ConvertDesktopToWinId();
|
||||
QString appDesktopPath = getDesktop->tranIdToDesktop(window.win());
|
||||
delete getDesktop;
|
||||
QString appDesktopPath = winidtoDesktopFileName(window.win());
|
||||
if(QFile::exists(appDesktopPath)){
|
||||
XdgDesktopFile xdg;
|
||||
xdg.load(appDesktopPath);
|
||||
|
|
|
@ -33,7 +33,6 @@
|
|||
#include <xcb/xcb_image.h>
|
||||
|
||||
#include "snidbus.h"
|
||||
#include "../panel-daemon/convert-desktop-windowid/convertdesktoptowinid.h"
|
||||
|
||||
class SNIProxy : public QObject
|
||||
{
|
||||
|
@ -158,6 +157,7 @@ private:
|
|||
QImage convertFromNative(xcb_image_t *xcbImage) const;
|
||||
QPoint calculateClickPoint() const;
|
||||
void stackContainerWindow(const uint32_t stackMode) const;
|
||||
QString winidtoDesktopFileName(const WId& wid) const;
|
||||
|
||||
QDBusConnection m_dbus;
|
||||
xcb_window_t m_windowId;
|
||||
|
|
Loading…
Reference in New Issue