fix: 修复任务栏智能隐藏失败的问题
修复任务栏智能隐藏失败的问题,其它线程调用主线程定时器没有生效,使用信号槽进行关联 Log: Task: https://pms.uniontech.com/task-view-141249.html Influence: 任务栏智能隐藏功能正常 Change-Id: I6c2fc5f0550c94f5309012d4b1861efe35618fce
This commit is contained in:
parent
d2b5e1b33b
commit
be4580d3ca
@ -53,7 +53,7 @@ void DBusHandler::listenWaylandWMSignals()
|
|||||||
kwaylandManager = new com::deepin::daemon::kwayland::WindowManager("com.deepin.daemon.KWayland", "/com/deepin/daemon/KWayland/WindowManager", session, this);
|
kwaylandManager = new com::deepin::daemon::kwayland::WindowManager("com.deepin.daemon.KWayland", "/com/deepin/daemon/KWayland/WindowManager", session, this);
|
||||||
|
|
||||||
// ActiveWindowchanged
|
// ActiveWindowchanged
|
||||||
connect(kwaylandManager, &__KwaylandManager::ActiveWindowChanged, this, &DBusHandler::handleWlActiveWindowchange);
|
connect(kwaylandManager, &__KwaylandManager::ActiveWindowChanged, this, &DBusHandler::handleWlActiveWindowChange);
|
||||||
// WindowCreated
|
// WindowCreated
|
||||||
connect(kwaylandManager, &__KwaylandManager::WindowCreated, this, [&] (const QString &ObjPath) {
|
connect(kwaylandManager, &__KwaylandManager::WindowCreated, this, [&] (const QString &ObjPath) {
|
||||||
dock->registerWindowWayland(ObjPath);
|
dock->registerWindowWayland(ObjPath);
|
||||||
@ -118,7 +118,7 @@ uint DBusHandler::wlActiveWindow()
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DBusHandler::handleWlActiveWindowchange()
|
void DBusHandler::handleWlActiveWindowChange()
|
||||||
{
|
{
|
||||||
uint activeWinInternalId = wlActiveWindow();
|
uint activeWinInternalId = wlActiveWindow();
|
||||||
if (activeWinInternalId == 0)
|
if (activeWinInternalId == 0)
|
||||||
@ -126,7 +126,10 @@ void DBusHandler::handleWlActiveWindowchange()
|
|||||||
|
|
||||||
WindowInfoK *info = dock->handleActiveWindowChangedK(activeWinInternalId);
|
WindowInfoK *info = dock->handleActiveWindowChangedK(activeWinInternalId);
|
||||||
if (info->getXid() != 0) {
|
if (info->getXid() != 0) {
|
||||||
dock->handleActiveWindowChanged(info);
|
WindowInfoBase *base = static_cast<WindowInfoBase *>(info);
|
||||||
|
if (base) {
|
||||||
|
dock->handleActiveWindowChanged(base);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
dock->updateHideState(false);
|
dock->updateHideState(false);
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ public:
|
|||||||
QString getDesktopFromWindowByBamf(XWindow windowId);
|
QString getDesktopFromWindowByBamf(XWindow windowId);
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void handleWlActiveWindowchange();
|
void handleWlActiveWindowChange();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Dock *dock;
|
Dock *dock;
|
||||||
|
@ -44,7 +44,7 @@ Dock::Dock(QObject *parent)
|
|||||||
, entriesSum(0)
|
, entriesSum(0)
|
||||||
, windowIdentify(new WindowIdentify(this))
|
, windowIdentify(new WindowIdentify(this))
|
||||||
, entries(new Entries(this))
|
, entries(new Entries(this))
|
||||||
, ddeLauncherVisible(true)
|
, ddeLauncherVisible(false)
|
||||||
, hideState(HideState::Unknown)
|
, hideState(HideState::Unknown)
|
||||||
, activeWindow(nullptr)
|
, activeWindow(nullptr)
|
||||||
, activeWindowOld(nullptr)
|
, activeWindowOld(nullptr)
|
||||||
@ -71,9 +71,8 @@ Dock::Dock(QObject *parent)
|
|||||||
|
|
||||||
// 初始化智能隐藏定时器
|
// 初始化智能隐藏定时器
|
||||||
smartHideTimer = new QTimer(this);
|
smartHideTimer = new QTimer(this);
|
||||||
smartHideTimer->setInterval(10 * 1000);
|
smartHideTimer->setSingleShot(true);
|
||||||
connect(smartHideTimer, SIGNAL(timeout()), this, SLOT(smartHideModeTimerExpired)); // 增加开始判断
|
connect(smartHideTimer, &QTimer::timeout, this, &Dock::smartHideModeTimerExpired);
|
||||||
smartHideTimer->stop();
|
|
||||||
|
|
||||||
if (!isWayland) {
|
if (!isWayland) {
|
||||||
std::thread thread([&] {
|
std::thread thread([&] {
|
||||||
@ -85,6 +84,7 @@ Dock::Dock(QObject *parent)
|
|||||||
thread.detach();
|
thread.detach();
|
||||||
x11Manager->listenRootWindowXEvent();
|
x11Manager->listenRootWindowXEvent();
|
||||||
connect(x11Manager, &X11Manager::requestUpdateHideState, this, &Dock::updateHideState);
|
connect(x11Manager, &X11Manager::requestUpdateHideState, this, &Dock::updateHideState);
|
||||||
|
connect(x11Manager, &X11Manager::requestHandleActiveWindowChange, this, &Dock::handleActiveWindowChanged);
|
||||||
connect(x11Manager, &X11Manager::requestAttachOrDetachWindow, this, &Dock::attachOrDetachWindow);
|
connect(x11Manager, &X11Manager::requestAttachOrDetachWindow, this, &Dock::attachOrDetachWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -628,7 +628,7 @@ void Dock::removePluginSettings(QString pluginName, QStringList settingkeys)
|
|||||||
void Dock::smartHideModeTimerExpired()
|
void Dock::smartHideModeTimerExpired()
|
||||||
{
|
{
|
||||||
HideState state = shouldHideOnSmartHideMode() ? HideState::Hide : HideState::Show;
|
HideState state = shouldHideOnSmartHideMode() ? HideState::Hide : HideState::Show;
|
||||||
qInfo() << "smartHideModeTimerExpired, is Hide? " << int(state);
|
qInfo() << "smartHideModeTimerExpired, should hide ? " << int(state);
|
||||||
setPropHideState(state);
|
setPropHideState(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -886,9 +886,11 @@ bool Dock::shouldHideOnSmartHideMode()
|
|||||||
|
|
||||||
QVector<XWindow> list = getActiveWinGroup(activeWinId);
|
QVector<XWindow> list = getActiveWinGroup(activeWinId);
|
||||||
for (XWindow xid : list) {
|
for (XWindow xid : list) {
|
||||||
if (isWindowDockOverlapX(xid))
|
if (isWindowDockOverlapX(xid)) {
|
||||||
|
qInfo() << "shouldHideOnSmartHideMode: window has overlap";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return isWindowDockOverlapK(activeWindow);
|
return isWindowDockOverlapK(activeWindow);
|
||||||
|
@ -69,7 +69,6 @@ public:
|
|||||||
bool is3DWM();
|
bool is3DWM();
|
||||||
bool isWaylandEnv();
|
bool isWaylandEnv();
|
||||||
WindowInfoK *handleActiveWindowChangedK(uint activeWin);
|
WindowInfoK *handleActiveWindowChangedK(uint activeWin);
|
||||||
void handleActiveWindowChanged(WindowInfoBase *info);
|
|
||||||
void saveDockedApps();
|
void saveDockedApps();
|
||||||
void removeAppEntry(Entry *entry);
|
void removeAppEntry(Entry *entry);
|
||||||
void handleWindowGeometryChanged();
|
void handleWindowGeometryChanged();
|
||||||
@ -144,8 +143,6 @@ public:
|
|||||||
void mergePluginSettings(QString jsonStr);
|
void mergePluginSettings(QString jsonStr);
|
||||||
void removePluginSettings(QString pluginName, QStringList settingkeys);
|
void removePluginSettings(QString pluginName, QStringList settingkeys);
|
||||||
|
|
||||||
void updateHideState(bool delay);
|
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void serviceRestarted();
|
void serviceRestarted();
|
||||||
void entryAdded(QDBusObjectPath entryObjPath, int index);
|
void entryAdded(QDBusObjectPath entryObjPath, int index);
|
||||||
@ -154,6 +151,8 @@ Q_SIGNALS:
|
|||||||
void frontendWindowRectChanged();
|
void frontendWindowRectChanged();
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
|
void updateHideState(bool delay);
|
||||||
|
void handleActiveWindowChanged(WindowInfoBase *info);
|
||||||
void smartHideModeTimerExpired();
|
void smartHideModeTimerExpired();
|
||||||
void attachOrDetachWindow(WindowInfoBase *info);
|
void attachOrDetachWindow(WindowInfoBase *info);
|
||||||
|
|
||||||
|
@ -599,7 +599,7 @@ void Entry::active(uint32_t timestamp)
|
|||||||
{
|
{
|
||||||
if (dock->getHideMode() == HideMode::SmartHide) {
|
if (dock->getHideMode() == HideMode::SmartHide) {
|
||||||
dock->setPropHideState(HideState::Show);
|
dock->setPropHideState(HideState::Show);
|
||||||
dock->updateHideState(true);
|
dock->updateHideState(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 无窗口则直接启动
|
// 无窗口则直接启动
|
||||||
|
@ -249,7 +249,10 @@ void X11Manager::handleActiveWindowChangedX()
|
|||||||
{
|
{
|
||||||
XWindow active = XCB->getActiveWindow();
|
XWindow active = XCB->getActiveWindow();
|
||||||
WindowInfoX *info = findWindowByXid(active);
|
WindowInfoX *info = findWindowByXid(active);
|
||||||
dock->handleActiveWindowChanged(info);
|
WindowInfoBase *base = static_cast<WindowInfoBase *>(info);
|
||||||
|
if (base) {
|
||||||
|
Q_EMIT requestHandleActiveWindowChange(base);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void X11Manager::listenRootWindowXEvent()
|
void X11Manager::listenRootWindowXEvent()
|
||||||
@ -311,7 +314,7 @@ void X11Manager::handleMapNotifyEvent(XWindow xid)
|
|||||||
//});
|
//});
|
||||||
}
|
}
|
||||||
|
|
||||||
// config changed event 检测窗口大小调整和重绘应用
|
// config changed event 检测窗口大小调整和重绘应用,触发智能隐藏更新
|
||||||
void X11Manager::handleConfigureNotifyEvent(XWindow xid, int x, int y, int width, int height)
|
void X11Manager::handleConfigureNotifyEvent(XWindow xid, int x, int y, int width, int height)
|
||||||
{
|
{
|
||||||
WindowInfoX *winInfo = findWindowByXid(xid);
|
WindowInfoX *winInfo = findWindowByXid(xid);
|
||||||
|
@ -60,6 +60,7 @@ public:
|
|||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void requestUpdateHideState(bool delay);
|
void requestUpdateHideState(bool delay);
|
||||||
|
void requestHandleActiveWindowChange(WindowInfoBase *info);
|
||||||
void requestAttachOrDetachWindow(WindowInfoBase *info);
|
void requestAttachOrDetachWindow(WindowInfoBase *info);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
Reference in New Issue
Block a user