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;
102 if (!lhs.contains(QLatin1Char(
'|')) || !rhs.contains(QLatin1Char(
'|'))) {
125inline QString
normalizeAppId(
const QString& desktopFileName,
const QString& windowClass)
127 QString appId = desktopFileName.trimmed();
128 if (appId.isEmpty()) {
133 const QString trimmedClass = windowClass.trimmed();
134 const int sep = trimmedClass.lastIndexOf(QLatin1Char(
' '));
135 appId = (sep >= 0 ? trimmedClass.mid(sep + 1) : trimmedClass);
137 return appId.toLower();
152 if (appId.isEmpty()) {
155 for (
const QChar c : appId) {
175 if (windowClass.isEmpty()) {
181 QStringView trimmed(windowClass);
182 while (!trimmed.isEmpty() && trimmed.back() == QLatin1Char(
'.')) {
185 if (trimmed.isEmpty()) {
188 const int dotIdx = trimmed.lastIndexOf(QLatin1Char(
'.'));
189 if (dotIdx >= 0 && dotIdx < trimmed.length() - 1) {
190 return trimmed.mid(dotIdx + 1).toString();
192 return trimmed.toString();
212 if (appId.isEmpty() || pattern.isEmpty()) {
215 if (appId.compare(pattern, Qt::CaseInsensitive) == 0) {
219 if (appId.length() > pattern.length() + 1 && appId[appId.length() - pattern.length() - 1] == QLatin1Char(
'.')
220 && appId.endsWith(pattern, Qt::CaseInsensitive)) {
224 if (pattern.length() > appId.length() + 1 && pattern[pattern.length() - appId.length() - 1] == QLatin1Char(
'.')
225 && pattern.endsWith(appId, Qt::CaseInsensitive)) {
231 if (pattern.length() >= 5) {
232 const int lastDot = appId.lastIndexOf(QLatin1Char(
'.'));
234 QStringView lastSeg = QStringView(appId).mid(lastDot + 1);
235 if (lastSeg.startsWith(pattern, Qt::CaseInsensitive) && lastSeg.length() != pattern.length()) {
242 if (appId.length() >= 5) {
243 const int lastDot = pattern.lastIndexOf(QLatin1Char(
'.'));
245 QStringView lastSeg = QStringView(pattern).mid(lastDot + 1);
246 if (lastSeg.startsWith(appId, Qt::CaseInsensitive) && lastSeg.length() != appId.length()) {
Compositor-agnostic window-identity utilities.
Definition WindowId.h:23
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:173
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:210
QString normalizeAppId(const QString &desktopFileName, const QString &windowClass)
Derive a canonical appId from a window's desktop-file name and class.
Definition WindowId.h:125
QString extractInstanceId(const QString &windowId)
Extract the stable KWin instance identifier (UUID) from a full window ID.
Definition WindowId.h:75
bool sameWindowInstance(const QString &lhs, const QString &rhs)
Do two window ids name the same live window instance?
Definition WindowId.h:97
bool isValidAppId(const QString &appId)
Whether appId is a well-formed canonical app identifier.
Definition WindowId.h:150
QString extractAppId(const QString &windowId)
Extract app identity from window ID (portion before the '|' separator) Format: "appId|internalUuid" →...
Definition WindowId.h:56