fix: 修复wayland下设置智能隐藏失败的问题
1、wayland环境下根据窗口Id获取当前激活窗口错误,导致无法获取激活窗口 2、释放鼠标的时候没有触发激活窗口的判断函数,导致任务栏在拖动过程中释放鼠标后,没有发送是否隐藏信号 Log: 修复wayland下设置智能隐藏失败的问题 Influence: 进入wayland环境,任务栏设置智能隐藏,窗口拖动到任务栏下方,观察窗口是否隐藏,窗口移出任务栏,观察任务栏是否显示 Bug: https://pms.uniontech.com/bug-view-154513.html Change-Id: I4de3b4db019a664f184b0676bb8ce2a77d1d66a9
This commit is contained in:
@ -33,6 +33,7 @@ DBusHandler::DBusHandler(Dock *_dock, QObject *parent)
|
||||
, m_wm(new com::deepin::WM("com.deepin.wm", "/com/deepin/wm", m_session, this))
|
||||
, m_wmSwitcher(new com::deepin::WMSwitcher("com.deepin.wmWMSwitcher", "/com/deepin/WMSwitcher", m_session, this))
|
||||
, m_kwaylandManager(nullptr)
|
||||
, m_xEventMonitor(nullptr)
|
||||
{
|
||||
// 关联org.deepin.dde.daemon.Launcher1事件 ItemChanged
|
||||
connect(m_launcherEnd, &LauncherBackEnd::ItemChanged, this, &DBusHandler::handleLauncherItemChanged);
|
||||
@ -45,6 +46,14 @@ DBusHandler::DBusHandler(Dock *_dock, QObject *parent)
|
||||
|
||||
// 关联com.deepin.WMSwitcher事件 WMChanged
|
||||
connect(m_wmSwitcher, &__WMSwitcher::WMChanged, this, [&](QString name) {m_dock->setWMName(name);});
|
||||
|
||||
if (QString(getenv("XDG_SESSION_TYPE")).contains("wayland")) {
|
||||
m_xEventMonitor = new org::deepin::api::XEventMonitor1("org.deepin.api.XEventMonitor1", "/org/deepin/api/XEventMonitor1", m_session, this);
|
||||
// 注册XEventMonitor区域为整个屏幕的区域
|
||||
m_activeWindowMonitorKey = m_xEventMonitor->RegisterFullScreen();
|
||||
// 关联XEventMonitor的ButtonRelease事件
|
||||
connect(m_xEventMonitor, &org::deepin::api::XEventMonitor1::ButtonRelease, this, &DBusHandler::onActiveWindowButtonRelease);
|
||||
}
|
||||
}
|
||||
|
||||
// 关联com.deepin.daemon.KWayland.WindowManager事件
|
||||
@ -138,15 +147,34 @@ void DBusHandler::handleWlActiveWindowChange()
|
||||
|
||||
WindowInfoK *info = m_dock->handleActiveWindowChangedK(activeWinInternalId);
|
||||
if (info && info->getXid() != 0) {
|
||||
WindowInfoBase *base = static_cast<WindowInfoBase *>(info);
|
||||
if (base) {
|
||||
m_dock->handleActiveWindowChanged(base);
|
||||
}
|
||||
m_dock->handleActiveWindowChanged(info);
|
||||
} else {
|
||||
m_dock->updateHideState(false);
|
||||
}
|
||||
}
|
||||
|
||||
void DBusHandler::onActiveWindowButtonRelease(int type, int x, int y, const QString &key)
|
||||
{
|
||||
// 当鼠标松开区域事件的时候,取消注册,同时调用激活窗口的方法来触发智能隐藏的相关信号
|
||||
if (key != m_activeWindowMonitorKey)
|
||||
return;
|
||||
|
||||
uint activeWinInternalId = wlActiveWindow();
|
||||
if (activeWinInternalId == 0)
|
||||
return;
|
||||
|
||||
WindowInfoK *info = m_dock->handleActiveWindowChangedK(activeWinInternalId);
|
||||
if (!info)
|
||||
return;
|
||||
|
||||
// 如果是在当前激活窗口区域内释放的,则触发检测智能隐藏的方法
|
||||
DockRect dockRect = info->getGeometry();
|
||||
if (dockRect.X <= x && x <= dockRect.X + dockRect.Width && dockRect.Y <= y && y <= dockRect.Y + dockRect.Height) {
|
||||
// 取消智能隐藏
|
||||
m_dock->updateHideState(false);
|
||||
}
|
||||
}
|
||||
|
||||
void DBusHandler::listenKWindowSignals(WindowInfoK *windowInfo)
|
||||
{
|
||||
PlasmaWindow *window = windowInfo->getPlasmaWindow();
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "dbuskwaylandwindowmanager.h"
|
||||
#include "windowinfok.h"
|
||||
#include "dbusplasmawindow.h"
|
||||
#include "dbusxeventmonitor.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QDBusConnection>
|
||||
@ -76,6 +77,7 @@ public:
|
||||
|
||||
private Q_SLOTS:
|
||||
void handleWlActiveWindowChange();
|
||||
void onActiveWindowButtonRelease(int type, int x, int y, const QString &key);
|
||||
|
||||
private:
|
||||
Dock *m_dock;
|
||||
@ -86,6 +88,9 @@ private:
|
||||
com::deepin::WM *m_wm;
|
||||
com::deepin::WMSwitcher *m_wmSwitcher;
|
||||
com::deepin::daemon::kwayland::WindowManager *m_kwaylandManager;
|
||||
|
||||
org::deepin::api::XEventMonitor1 *m_xEventMonitor;
|
||||
QString m_activeWindowMonitorKey;
|
||||
};
|
||||
|
||||
#endif // DBUSHANDLER_H
|
||||
|
@ -896,13 +896,13 @@ bool Dock::hasInterSectionK(const DockRect &windowRect, QRect dockRect)
|
||||
int rbX = MIN(windowRect.X + windowRect.Width, dockRect.x() + dockRect.width());
|
||||
int rbY = MIN(windowRect.Y + windowRect.Height, dockRect.y() + dockRect.height());
|
||||
|
||||
if (position == int(PositionMode::Left) || position == int(PositionMode::Right)) {
|
||||
if (position == int(PositionMode::Left) || position == int(PositionMode::Right))
|
||||
return ltX <= rbX && ltY < rbY;
|
||||
} else if (position == int(PositionMode::Top) || position == int(PositionMode::Bottom)) {
|
||||
|
||||
if (position == int(PositionMode::Top) || position == int(PositionMode::Bottom))
|
||||
return ltX < rbX && ltY <= rbY;
|
||||
} else {
|
||||
return ltX < rbX && ltY < rbY;
|
||||
}
|
||||
|
||||
return ltX < rbX && ltY < rbY;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1213,7 +1213,7 @@ bool Dock::isWaylandEnv()
|
||||
*/
|
||||
WindowInfoK *Dock::handleActiveWindowChangedK(uint activeWin)
|
||||
{
|
||||
return m_waylandManager->handleActiveWindowChangedK(activeWin);
|
||||
return m_waylandManager->findWindowById(activeWin);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -82,18 +82,16 @@ void WaylandManager::unRegisterWindow(const QString &objPath)
|
||||
deleteWindow(objPath);
|
||||
}
|
||||
|
||||
WindowInfoK *WaylandManager::handleActiveWindowChangedK(uint activeWin)
|
||||
WindowInfoK *WaylandManager::findWindowById(uint activeWin)
|
||||
{
|
||||
WindowInfoK *winInfo = nullptr;
|
||||
QMutexLocker locker(&m_mutex);
|
||||
for (auto iter = m_kWinInfos.begin(); iter != m_kWinInfos.end(); iter++) {
|
||||
if (iter.value()->getInnerId() == activeWin) {
|
||||
winInfo = iter.value();
|
||||
break;
|
||||
if (iter.value()->getInnerId() == QString::number(activeWin)) {
|
||||
return iter.value();
|
||||
}
|
||||
}
|
||||
|
||||
return winInfo;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
WindowInfoK *WaylandManager::findWindowByXid(XWindow xid)
|
||||
|
@ -40,7 +40,7 @@ public:
|
||||
void registerWindow(const QString &objPath);
|
||||
void unRegisterWindow(const QString &objPath);
|
||||
|
||||
WindowInfoK *handleActiveWindowChangedK(uint activeWin);
|
||||
WindowInfoK *findWindowById(uint activeWin);
|
||||
WindowInfoK *findWindowByXid(XWindow xid);
|
||||
WindowInfoK *findWindowByObjPath(QString objPath);
|
||||
void insertWindow(QString objPath, WindowInfoK *windowInfo);
|
||||
|
@ -30,6 +30,7 @@
|
||||
class Entry;
|
||||
class AppInfo;
|
||||
class ProcessInfo;
|
||||
|
||||
class WindowInfoBase
|
||||
{
|
||||
public:
|
||||
@ -56,17 +57,17 @@ public:
|
||||
virtual void update() = 0;
|
||||
virtual void killClient() = 0;
|
||||
virtual QString uuid() = 0;
|
||||
virtual QString getInnerId() { return innerId; }
|
||||
|
||||
XWindow getXid() {return xid;}
|
||||
void setEntry(Entry *value) {entry = value;}
|
||||
Entry *getEntry() {return entry;}
|
||||
QString getEntryInnerId() {return entryInnerId;}
|
||||
QString getInnerId() {return innerId;}
|
||||
void setEntryInnerId(QString value) {entryInnerId = value;}
|
||||
AppInfo *getAppInfo() {return app;}
|
||||
void setAppInfo(AppInfo *value) {app = value;}
|
||||
int getPid() {return pid;}
|
||||
ProcessInfo *getProcess() {return processInfo;}
|
||||
void setEntry(Entry *value) { entry = value; }
|
||||
Entry *getEntry() { return entry; }
|
||||
QString getEntryInnerId() { return entryInnerId; }
|
||||
void setEntryInnerId(QString value) { entryInnerId = value; }
|
||||
AppInfo *getAppInfo() { return app; }
|
||||
void setAppInfo(AppInfo *value) { app = value; }
|
||||
int getPid() { return pid; }
|
||||
ProcessInfo *getProcess() { return processInfo; }
|
||||
bool containAtom(QVector<XCBAtom> supports, XCBAtom ty) {return supports.indexOf(ty) != -1;}
|
||||
|
||||
protected:
|
||||
|
@ -222,3 +222,8 @@ QString WindowInfoK::uuid()
|
||||
return QString(m_plasmaWindow->Uuid());
|
||||
}
|
||||
|
||||
QString WindowInfoK::getInnerId()
|
||||
{
|
||||
return QString::number(m_internalId);
|
||||
}
|
||||
|
||||
|
@ -52,6 +52,7 @@ public:
|
||||
virtual void update() override;
|
||||
virtual void killClient() override;
|
||||
virtual QString uuid() override;
|
||||
QString getInnerId() override;
|
||||
|
||||
QString getAppId();
|
||||
void setAppId(QString _appId);
|
||||
|
Reference in New Issue
Block a user