Bug 476592 - Incorrect output for the color-scheme portal
Summary: Incorrect output for the color-scheme portal
Status: RESOLVED FIXED
Alias: None
Product: xdg-desktop-portal-kde
Classification: Plasma
Component: general (other bugs)
Version First Reported In: git-master
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Plasma Bugs List
URL:
Keywords: qt6
Depends on:
Blocks:
 
Reported: 2023-11-05 16:05 UTC by Prajna Sariputra
Modified: 2023-11-25 06:43 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Prajna Sariputra 2023-11-05 16:05:20 UTC
SUMMARY
In Plasma 6, the color scheme portal outputs its result in a slightly different format, which at minimum stops libadwaita apps (for example Epiphany/GNOME Web, Flatseal and so on) from switching to dark mode automatically following the rest of the system. The same apps work fine in a Plasma 5 session.

The libadwaita apps show this error message in the terminal: "Invalid type for org.freedesktop.appearance.color-scheme: expected u, got v".


STEPS TO REPRODUCE
1. Run a Plasma 6 session
2. Use a dark color scheme
3. Open GNOME Web or Flatseal (or any libadwaita app that follows the color scheme preference) 

OBSERVED RESULT
The opened app stays in light mode.

EXPECTED RESULT
The opened app should be in dark mode.

SOFTWARE/OS VERSIONS
Operating System: Arch Linux 
KDE Plasma Version: 5.27.80
KDE Frameworks Version: 5.240.0
Qt Version: 6.6.0
Kernel Version: 6.5.9-arch2-1 (64-bit)
Graphics Platform: Wayland
Processors: 16 × AMD Ryzen 7 6800H with Radeon Graphics
Memory: 30.6 GiB of RAM
Graphics Processor: AMD Radeon Graphics

ADDITIONAL INFORMATION
xdg-desktop-portal-kde is at commit 3dc22a2c75d5533ab518b03b9201052c59e842ab when I compiled it.

Also, here is the difference between the portal output for Plasma 5 and 6 respectively:

Plasma 5 (working):
➜  ~ dbus-send  --print-reply=literal --dest=org.freedesktop.portal.Desktop /org/freedesktop/portal/desktop org.freedesktop.portal.Settings.Read string:org.freedesktop.appearance string:color-scheme                                                                  
   variant       variant          uint32 1
➜  ~ dbus-send  --print-reply=literal --dest=org.freedesktop.impl.portal.desktop.kde /org/freedesktop/portal/desktop org.freedesktop.impl.portal.Settings.Read string:org.freedesktop.appearance string:color-scheme
   variant       uint32 1

Plasma 6 (not working):
➜  ~ dbus-send  --print-reply=literal --dest=org.freedesktop.portal.Desktop /org/freedesktop/portal/desktop org.freedesktop.portal.Settings.Read string:org.freedesktop.appearance string:color-scheme                                                                  
   variant       variant          variant             uint32 1
➜  ~ dbus-send  --print-reply=literal --dest=org.freedesktop.impl.portal.desktop.kde /org/freedesktop/portal/desktop org.freedesktop.impl.portal.Settings.Read string:org.freedesktop.appearance string:color-scheme                                                    
   variant       variant          uint32 1
Comment 1 Bug Janitor Service 2023-11-07 18:12:30 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/xdg-desktop-portal-kde/-/merge_requests/244
Comment 2 Nicolas Fella 2023-11-08 10:13:29 UTC
Git commit bb974d5c052557a5aca4c3c16606bbb4c24b5e2d by Nicolas Fella, on behalf of Bharadwaj Raju.
Committed on 08/11/2023 at 11:13.
Pushed by nicolasfella into branch 'master'.

Use QDBusVariant::variant() instead of QVariant::fromValue()

The former produces a QVariant of the type that QDBusVariant held, while
the latter produces a QVariant of type QDBusVariant itself. This affects
our return type according to DBus.

Simple test:

```cpp
auto x = QVariant::fromValue(readFdoColorScheme());
auto y = readFdoColorScheme().variant();
qDebug() << x.typeName() << y.typeName();
```

M  +2    -2    src/settings.cpp

https://invent.kde.org/plasma/xdg-desktop-portal-kde/-/commit/bb974d5c052557a5aca4c3c16606bbb4c24b5e2d
Comment 3 Bug Janitor Service 2023-11-19 02:43:59 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/xdg-desktop-portal-kde/-/merge_requests/249
Comment 4 Fushan Wen 2023-11-25 06:43:18 UTC
Git commit 9122e408acdd7382c8183a3977b7e28b450b1b2c by Fushan Wen.
Committed on 25/11/2023 at 07:39.
Pushed by fusionfuture into branch 'master'.

Make sure replies from org.freedesktop.appearance have correct signatures

M  +6    -0    autotests/CMakeLists.txt
A  +82   -0    autotests/colorschemetest.py

https://invent.kde.org/plasma/xdg-desktop-portal-kde/-/commit/9122e408acdd7382c8183a3977b7e28b450b1b2c