https://bugs.kde.org/show_bug.cgi?id=526303
Bug ID: 526303
Summary: Stored output mode is kept by size/refresh fallback
even when it was the preferred mode, which breaks VM
display auto-resize (VirtualBox VMSVGA / vmwgfx)
Classification: Plasma
Product: kwin
Version First 6.7.5
Reported In:
Platform: Arch Linux
OS: Linux
Status: REPORTED
Severity: normal
Priority: NOR
Component: output configuration
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected]
Target Milestone: ---
In a VirtualBox guest using VMSVGA (`vmwgfx`), guest display auto-resize in a
Plasma Wayland session works or fails depending only on which resolution is
stored in `~/.config/kwinoutputconfig.json`.
`vmwgfx` exposes the preferred mode (the current host window size, updated by
`VBoxDRMClient` through the vmwgfx layout ioctl, followed by a hotplug uevent)
plus a fixed list of 34 standard modes: 4096x2160, 2560x1600, 1920x1200,
1920x1080, 1600x900, and so on.
In `OutputConfigurationStore::setupToConfig()`
(src/outputconfigurationstore.cpp:394-420 in v6.7.5) and
`OutputConfigurationStore::generateConfig()` (:624-650), the stored mode is
resolved in three steps:
1. Exact match (size, refresh and flags) against `output->modes()`.
2. Otherwise, the fallback "for output configs prior to 6.6.5, which didn't
have flags": the first non-removed mode with the same size and refresh, flags
ignored.
3. Only then `chooseMode()`, which picks the preferred mode.
When the stored mode's size is one of `vmwgfx`'s fixed modes, step 2 always
finds it. KWin then keeps that resolution forever and never follows the new
preferred mode. When the stored size is not in the fixed list, it disappears
once the preferred mode changes, and step 3 picks the new preferred mode, so
auto-resize works.
This also happens when the stored mode has `flags: 1` (Preferred). If it was
saved while the window was exactly 1920x1080, the next resize makes the exact
match fail, and step 2 then settles on the static 1920x1080 mode. So the
Preferred flag KWin saves (since 6.6.5) never gets the chance to mean "follow
the preferred mode".
The mode KWin chooses automatically in step 3 isn't written back to
`kwinoutputconfig.json` either. The file keeps the old stored mode while the
output runs at the new preferred mode.
**Steps to reproduce:**
1. VirtualBox 7.2.20 with a Linux guest, Graphics Controller set to VMSVGA and
guest additions running (`VBoxService`, `VBoxDRMClient`, `VBoxClient
--vmsvga-session`). Plasma Wayland session.
2. Resize the VM window to some non-standard size and apply the preferred mode:
`kscreen-doctor output.Virtual-1.mode.1`. Resizing the window now resizes the
guest display correctly.
3. Apply a fixed standard mode, for example `kscreen-doctor
output.Virtual-1.mode.<id of 1920x1080@60>`. The stored mode becomes
`{"width":1920,"height":1080,"refreshRate":60000,"flags":0}`.
4. Resize the VM window.
**Observed result** (step 4):
```
$ head -1 /sys/class/drm/card0-Virtual-1/modes
2108x1200
$ kscreen-doctor -o
1:[email protected]! 12:[email protected]*
Geometry: 0,0 1920x1080
```
The connector's preferred mode changed to 2108x1200, but KWin stays at
1920x1080.
**Expected result:** when the preferred mode of an output changes (for example
on a hotplug/change uevent), KWin follows it if the stored mode was the
preferred mode. Ideally it also does so for virtual connectors
(`DRM_MODE_CONNECTOR_VIRTUAL`), where the preferred mode is the host window
size and the standard modes are synthetic.
Possible fixes:
- Skip the size/refresh fallback when the stored mode carries the `Preferred`
flag, and resolve to the output's current preferred mode instead.
- Restrict the fallback to entries saved without a `flags` key (pre-6.6.5
configs), instead of applying it to every mode that fails the exact match.
**Workaround:** re-select the preferred mode (`kscreen-doctor
output.Virtual-1.mode.<id marked with !>`) while the window is at a
non-standard size.
**Software:**
- Arch Linux, kernel 6.18.54-1-lts
- KWin 6.7.5, libkscreen 6.7.5, Qt 6.11.2
- Mesa 26.2.3, `vmwgfx` driver, OpenGL renderer SVGA3D
- VirtualBox 7.2.20 on the host, virtualbox-guest-utils 7.2.20 in the guest
--
You are receiving this mail because:
You are watching all bug changes.