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);
|
||||
|
||||
// ActiveWindowchanged
|
||||
connect(kwaylandManager, &__KwaylandManager::ActiveWindowChanged, this, &DBusHandler::handleWlActiveWindowchange);
|
||||
connect(kwaylandManager, &__KwaylandManager::ActiveWindowChanged, this, &DBusHandler::handleWlActiveWindowChange);
|
||||
// WindowCreated
|
||||
connect(kwaylandManager, &__KwaylandManager::WindowCreated, this, [&] (const QString &ObjPath) {
|
||||
dock->registerWindowWayland(ObjPath);
|
||||
@ -118,7 +118,7 @@ uint DBusHandler::wlActiveWindow()
|
||||
return ret;
|
||||
}
|
||||
|
||||
void DBusHandler::handleWlActiveWindowchange()
|
||||
void DBusHandler::handleWlActiveWindowChange()
|
||||
{
|
||||
uint activeWinInternalId = wlActiveWindow();
|
||||
if (activeWinInternalId == 0)
|
||||
@ -126,7 +126,10 @@ void DBusHandler::handleWlActiveWindowchange()
|
||||
|
||||
WindowInfoK *info = dock->handleActiveWindowChangedK(activeWinInternalId);
|
||||
if (info->getXid() != 0) {
|
||||
dock->handleActiveWindowChanged(info);
|
||||
WindowInfoBase *base = static_cast<WindowInfoBase *>(info);
|
||||
if (base) {
|
||||
dock->handleActiveWindowChanged(base);
|
||||
}
|
||||
} else {
|
||||
dock->updateHideState(false);
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ public:
|
||||
QString getDesktopFromWindowByBamf(XWindow windowId);
|
||||
|
||||
private Q_SLOTS:
|
||||
void handleWlActiveWindowchange();
|
||||
void handleWlActiveWindowChange();
|
||||
|
||||
private:
|
||||
Dock *dock;
|
||||
|
@ -44,7 +44,7 @@ Dock::Dock(QObject *parent)
|
||||
, entriesSum(0)
|
||||
, windowIdentify(new WindowIdentify(this))
|
||||
, entries(new Entries(this))
|
||||
, ddeLauncherVisible(true)
|
||||
, ddeLauncherVisible(false)
|
||||
, hideState(HideState::Unknown)
|
||||
, activeWindow(nullptr)
|
||||
, activeWindowOld(nullptr)
|
||||
@ -71,9 +71,8 @@ Dock::Dock(QObject *parent)
|
||||
|
||||
// 初始化智能隐藏定时器
|
||||
smartHideTimer = new QTimer(this);
|
||||
smartHideTimer->setInterval(10 * 1000);
|
||||
connect(smartHideTimer, SIGNAL(timeout()), this, SLOT(smartHideModeTimerExpired)); // 增加开始判断
|
||||
smartHideTimer->stop();
|
||||
smartHideTimer->setSingleShot(true);
|
||||
connect(smartHideTimer, &QTimer::timeout, this, &Dock::smartHideModeTimerExpired);
|
||||
|
||||
if (!isWayland) {
|
||||
std::thread thread([&] {
|
||||
@ -85,6 +84,7 @@ Dock::Dock(QObject *parent)
|
||||
thread.detach();
|
||||
x11Manager->listenRootWindowXEvent();
|
||||
connect(x11Manager, &X11Manager::requestUpdateHideState, this, &Dock::updateHideState);
|
||||
connect(x11Manager, &X11Manager::requestHandleActiveWindowChange, this, &Dock::handleActiveWindowChanged);
|
||||
connect(x11Manager, &X11Manager::requestAttachOrDetachWindow, this, &Dock::attachOrDetachWindow);
|
||||
}
|
||||
|
||||
@ -628,7 +628,7 @@ void Dock::removePluginSettings(QString pluginName, QStringList settingkeys)
|
||||
void Dock::smartHideModeTimerExpired()
|
||||
{
|
||||
HideState state = shouldHideOnSmartHideMode() ? HideState::Hide : HideState::Show;
|
||||
qInfo() << "smartHideModeTimerExpired, is Hide? " << int(state);
|
||||
qInfo() << "smartHideModeTimerExpired, should hide ? " << int(state);
|
||||
setPropHideState(state);
|
||||
}
|
||||
|
||||
@ -886,8 +886,10 @@ bool Dock::shouldHideOnSmartHideMode()
|
||||
|
||||
QVector<XWindow> list = getActiveWinGroup(activeWinId);
|
||||
for (XWindow xid : list) {
|
||||
if (isWindowDockOverlapX(xid))
|
||||
if (isWindowDockOverlapX(xid)) {
|
||||
qInfo() << "shouldHideOnSmartHideMode: window has overlap";
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
|
@ -69,7 +69,6 @@ public:
|
||||
bool is3DWM();
|
||||
bool isWaylandEnv();
|
||||
WindowInfoK *handleActiveWindowChangedK(uint activeWin);
|
||||
void handleActiveWindowChanged(WindowInfoBase *info);
|
||||
void saveDockedApps();
|
||||
void removeAppEntry(Entry *entry);
|
||||
void handleWindowGeometryChanged();
|
||||
@ -144,8 +143,6 @@ public:
|
||||
void mergePluginSettings(QString jsonStr);
|
||||
void removePluginSettings(QString pluginName, QStringList settingkeys);
|
||||
|
||||
void updateHideState(bool delay);
|
||||
|
||||
Q_SIGNALS:
|
||||
void serviceRestarted();
|
||||
void entryAdded(QDBusObjectPath entryObjPath, int index);
|
||||
@ -154,6 +151,8 @@ Q_SIGNALS:
|
||||
void frontendWindowRectChanged();
|
||||
|
||||
public Q_SLOTS:
|
||||
void updateHideState(bool delay);
|
||||
void handleActiveWindowChanged(WindowInfoBase *info);
|
||||
void smartHideModeTimerExpired();
|
||||
void attachOrDetachWindow(WindowInfoBase *info);
|
||||
|
||||
|
@ -599,7 +599,7 @@ void Entry::active(uint32_t timestamp)
|
||||
{
|
||||
if (dock->getHideMode() == HideMode::SmartHide) {
|
||||
dock->setPropHideState(HideState::Show);
|
||||
dock->updateHideState(true);
|
||||
dock->updateHideState(false);
|
||||
}
|
||||
|
||||
// 无窗口则直接启动
|
||||
|
@ -249,7 +249,10 @@ void X11Manager::handleActiveWindowChangedX()
|
||||
{
|
||||
XWindow active = XCB->getActiveWindow();
|
||||
WindowInfoX *info = findWindowByXid(active);
|
||||
dock->handleActiveWindowChanged(info);
|
||||
WindowInfoBase *base = static_cast<WindowInfoBase *>(info);
|
||||
if (base) {
|
||||
Q_EMIT requestHandleActiveWindowChange(base);
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
WindowInfoX *winInfo = findWindowByXid(xid);
|
||||
|
@ -60,6 +60,7 @@ public:
|
||||
|
||||
Q_SIGNALS:
|
||||
void requestUpdateHideState(bool delay);
|
||||
void requestHandleActiveWindowChange(WindowInfoBase *info);
|
||||
void requestAttachOrDetachWindow(WindowInfoBase *info);
|
||||
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user