mysql80: fix darwin and LLVM 19 build (#374591)
[NixPkgs.git] / pkgs / development / libraries / qt-5 / modules / qtwayland-app_id.patch
blob24d081aa602be23c424b7fde987183e3ed82cdb8
1 Ensure that the correct `app_id` for Wayland is set. The upstream implementation
2 uses `QFileInfo::baseName()`[1] which strips everything away after the first dot.
3 This means that `.foo-wrapped` has an empty `app_id` because `baseName` returns
4 an empty string in this case.
6 The patch basically checks whether the program has the form `.foo-wrapped` (i.e. got
7 wrapped by `makeWrapper`) and if that's the case, `foo` will be the correct `app_id`.
9 [1] https://doc.qt.io/qt-5/qfileinfo.html#baseName
11 diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp
12 index ba881cb..b3fd031 100644
13 --- a/src/client/qwaylandwindow.cpp
14 +++ b/src/client/qwaylandwindow.cpp
15 @@ -167,7 +167,20 @@ void QWaylandWindow::initWindow()
16 Qt::SkipEmptyParts);
18 if (domainName.isEmpty()) {
19 - mShellSurface->setAppId(fi.baseName());
20 + auto baseName = fi.baseName();
21 + if (baseName.isEmpty()) {
22 + auto fileName = fi.fileName();
23 + if (fileName.endsWith("-wrapped") && fileName.startsWith(".")) {
24 + do {
25 + auto len = fileName.length();
26 + fileName = fileName.right(len - 1);
27 + fileName = fileName.left(len - 9);
28 + } while (fileName.endsWith("-wrapped") && fileName.startsWith("."));
29 + mShellSurface->setAppId(fileName);
30 + }
31 + } else {
32 + mShellSurface->setAppId(baseName);
33 + }
34 } else {
35 QString appId;
36 for (int i = 0; i < domainName.count(); ++i)