41 if (instanceId.isEmpty()) {
42 return appId.toString();
45 out.reserve(appId.size() + 1 + instanceId.size());
47 out.append(QLatin1Char(
'|'));
48 out.append(instanceId);
58 if (windowId.isEmpty()) {
61 int sep = windowId.indexOf(QLatin1Char(
'|'));
62 return (sep >= 0) ? windowId.left(sep) : windowId;
77 if (windowId.isEmpty()) {
80 int sep = windowId.indexOf(QLatin1Char(
'|'));
81 return (sep >= 0) ? windowId.mid(sep + 1) : windowId;
100inline QString
normalizeAppId(
const QString& desktopFileName,
const QString& windowClass)
102 QString appId = desktopFileName.trimmed();
103 if (appId.isEmpty()) {
108 const QString trimmedClass = windowClass.trimmed();
109 const int sep = trimmedClass.lastIndexOf(QLatin1Char(
' '));
110 appId = (sep >= 0 ? trimmedClass.mid(sep + 1) : trimmedClass);
112 return appId.toLower();
127 if (appId.isEmpty()) {
130 for (
const QChar c : appId) {
150 if (windowClass.isEmpty()) {
156 QStringView trimmed(windowClass);
157 while (!trimmed.isEmpty() && trimmed.back() == QLatin1Char(
'.')) {
160 if (trimmed.isEmpty()) {
163 const int dotIdx = trimmed.lastIndexOf(QLatin1Char(
'.'));
164 if (dotIdx >= 0 && dotIdx < trimmed.length() - 1) {
165 return trimmed.mid(dotIdx + 1).toString();
167 return trimmed.toString();
187 if (appId.isEmpty() || pattern.isEmpty()) {
190 if (appId.compare(pattern, Qt::CaseInsensitive) == 0) {
194 if (appId.length() > pattern.length() + 1 && appId[appId.length() - pattern.length() - 1] == QLatin1Char(
'.')
195 && appId.endsWith(pattern, Qt::CaseInsensitive)) {
199 if (pattern.length() > appId.length() + 1 && pattern[pattern.length() - appId.length() - 1] == QLatin1Char(
'.')
200 && pattern.endsWith(appId, Qt::CaseInsensitive)) {
206 if (pattern.length() >= 5) {
207 const int lastDot = appId.lastIndexOf(QLatin1Char(
'.'));
209 QStringView lastSeg = QStringView(appId).mid(lastDot + 1);
210 if (lastSeg.startsWith(pattern, Qt::CaseInsensitive) && lastSeg.length() != pattern.length()) {
217 if (appId.length() >= 5) {
218 const int lastDot = pattern.lastIndexOf(QLatin1Char(
'.'));
220 QStringView lastSeg = QStringView(pattern).mid(lastDot + 1);
221 if (lastSeg.startsWith(appId, Qt::CaseInsensitive) && lastSeg.length() != appId.length()) {
QString deriveShortName(const QString &windowClass)
Derive short name from app ID for icon/app display Reverse-DNS: "org.kde.dolphin" → last dot-segment ...
Definition WindowId.h:148
QString buildCompositeId(QStringView appId, QStringView instanceId)
Build a composite window id from its appId + instance parts.
Definition WindowId.h:39
bool appIdMatches(const QString &appId, const QString &pattern)
Segment-aware app ID matching for exclusion lists.
Definition WindowId.h:185
QString normalizeAppId(const QString &desktopFileName, const QString &windowClass)
Derive a canonical appId from a window's desktop-file name and class.
Definition WindowId.h:100
QString extractInstanceId(const QString &windowId)
Extract the stable KWin instance identifier (UUID) from a full window ID.
Definition WindowId.h:75
bool isValidAppId(const QString &appId)
Whether appId is a well-formed canonical app identifier.
Definition WindowId.h:125
QString extractAppId(const QString &windowId)
Extract app identity from window ID (portion before the '|' separator) Format: "appId|internalUuid" →...
Definition WindowId.h:56