Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions misc/dconfig/org.deepin.dde.treeland.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,17 @@
"description[zh_CN]": "闪屏使用亮色主题时的背景色",
"permissions": "readwrite",
"visibility": "public"
},
"splashMismatchCount": {
"value": 0,
"serial": 0,
"flags": [],
"name": "Splash Mismatch Count",
"name[zh_CN]": "闪屏不匹配次数",
"description": "Consecutive splash match failure count; reset to 0 on success",
"description[zh_CN]": "连续闪屏匹配失败次数,匹配成功后重置为0",
"permissions": "readwrite",
"visibility": "public"
}
}
}
11 changes: 11 additions & 0 deletions misc/dconfig/org.deepin.dde.treeland.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,17 @@
"description[zh_CN]": "复制模式输出 ID 的 JSON 字符串数组。第一个元素是被复制屏,后续元素镜像它。",
"permissions": "readwrite",
"visibility": "public"
},
"prelaunchSplashMaxMismatchCount": {
"value": 4,
"serial": 0,
"flags": [],
"name": "Prelaunch Splash Max Mismatch Count",
"name[zh_CN]": "预启动闪屏最大不匹配次数",
"description": "Maximum consecutive splash match failures before disabling splash for an app. 0 means never auto-disable.",
"description[zh_CN]": "连续闪屏匹配失败达到此次数后禁用该应用的闪屏功能。0 表示永不自动禁用。",
"permissions": "readwrite",
"visibility": "public"
}
}
}
24 changes: 24 additions & 0 deletions src/core/shellhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,13 @@ void ShellHandler::createPrelaunchSplash(const QString &appId,

// Destroy the splash wrapper
m_rootSurfaceContainer->destroyForSurface(wrapper);

// Splash closed without matching a real window — record mismatch
if (m_windowConfigStore) {
const int maxMismatch = static_cast<int>(
Helper::instance()->globalConfig()->prelaunchSplashMaxMismatchCount());
m_windowConfigStore->recordSplashMismatch(appId, maxMismatch);
}
});

if (timeoutMs > 0) {
Expand All @@ -366,7 +373,13 @@ void ShellHandler::createPrelaunchSplash(const QString &appId,
<< "Prelaunch splash timeout, destroy wrapper appId="
<< wrapper->appId();
m_prelaunchWrappers.removeAt(idx);
const QString mismatchAppId = wrapper->appId();
m_rootSurfaceContainer->destroyForSurface(wrapper);
if (m_windowConfigStore) {
const int maxMismatch = static_cast<int>(
Helper::instance()->globalConfig()->prelaunchSplashMaxMismatchCount());
m_windowConfigStore->recordSplashMismatch(mismatchAppId, maxMismatch);
}
});
}
}
Expand All @@ -386,6 +399,11 @@ void ShellHandler::handlePrelaunchSplashClosed(const QString &appId, const QStri
<< "Client requested close_splash, destroy wrapper appId=" << appId;
m_prelaunchWrappers.removeAt(i);
m_rootSurfaceContainer->destroyForSurface(wrapper);
if (m_windowConfigStore) {
const int maxMismatch = static_cast<int>(
Helper::instance()->globalConfig()->prelaunchSplashMaxMismatchCount());
m_windowConfigStore->recordSplashMismatch(appId, maxMismatch);
}
return;
}
}
Expand Down Expand Up @@ -594,6 +612,9 @@ void ShellHandler::ensureXdgWrapper(WXdgToplevelSurface *surface, const QString
candidate->convertToNormalSurface(surface, SurfaceWrapper::Type::XdgToplevel);
wrapper = candidate;
isNewWrapper = false; // matched from prelaunch, not newly created
if (m_windowConfigStore) {
m_windowConfigStore->resetSplashMismatchCount(targetAppId);
}
break;
}
}
Expand Down Expand Up @@ -912,6 +933,9 @@ void ShellHandler::ensureXwaylandWrapper(WXWaylandSurface *surface, const QStrin
candidate->convertToNormalSurface(surface, SurfaceWrapper::Type::XWayland);
wrapper = candidate;
isNewWrapper = false; // matched from prelaunch, not newly created
if (m_windowConfigStore) {
m_windowConfigStore->resetSplashMismatchCount(targetAppId);
}
break;
}
}
Expand Down
40 changes: 40 additions & 0 deletions src/core/windowconfigstore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,43 @@ void WindowConfigStore::withSplashConfigFor(const QString &appId,
},
Qt::SingleShotConnection);
}

void WindowConfigStore::recordSplashMismatch(const QString &appId, int maxMismatchCount)
{
if (appId.isEmpty() || maxMismatchCount <= 0) {
return;
}

auto *config = configForApp(appId);
if (!config) {
return;
}

int count = static_cast<int>(config->splashMismatchCount()) + 1;
config->setSplashMismatchCount(count);
qCInfo(lcTlCore) << "WindowConfigStore: splash mismatch count for" << appId << "is now"
<< count;
if (count >= maxMismatchCount) {
config->setEnablePrelaunchSplash(false);
config->setSplashMismatchCount(0);
qCInfo(lcTlCore) << "WindowConfigStore: auto-disabled prelaunch splash for" << appId
<< "after" << count << "consecutive mismatches";
}
}

void WindowConfigStore::resetSplashMismatchCount(const QString &appId)
{
if (appId.isEmpty()) {
return;
}

auto *config = configForApp(appId);
if (!config) {
return;
}

if (config->splashMismatchCount() != 0) {
config->setSplashMismatchCount(0);
qCDebug(lcTlCore) << "WindowConfigStore: reset splash mismatch count for" << appId;
}
}
3 changes: 3 additions & 0 deletions src/core/windowconfigstore.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ class WindowConfigStore : public QObject
qlonglong splashThemeType)> callback,
std::function<void()> skipCallback) const;

void recordSplashMismatch(const QString &appId, int maxMismatchCount);
void resetSplashMismatchCount(const QString &appId);

private:
AppConfig *configForApp(const QString &appId) const;

Expand Down
Loading