Bug 449099 - Hot-plugging Primary Monitor not handled correctly for XWayland
Summary: Hot-plugging Primary Monitor not handled correctly for XWayland
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: wayland-generic (show other bugs)
Version: git-stable-Plasma/5.24
Platform: Manjaro Linux
: NOR normal (vote)
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-01-24 21:00 UTC by Aleksey Zagorodnikov
Modified: 2022-01-28 00:41 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.24


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Aleksey Zagorodnikov 2022-01-24 21:00:54 UTC
SUMMARY
If I unplug and plug again primary monitor it was incorrectly showed in xrandr' output as not primary, and Xwayland apps starts on wrong monitor.

STEPS TO REPRODUCE
1. Login in wayland session
2. Run xrandr
3. Unplug Primary monitor
4. Plug Primary monitor again
5. Run xrandr again and compare output

OBSERVED RESULT
Xrandr output in 5th step:
XWAYLAND1 connected primary 1280x1024+2560+208 (normal left inverted right x axis y axis) 380mm x 300mm
XWAYLAND2 connected 2560x1440+0+0 (normal left inverted right x axis y axis) 600mm x 340mm

EXPECTED RESULT
Xrandr output in 5th step should be the same as in 2nd step:
XWAYLAND0 connected primary 2560x1440+0+0 (normal left inverted right x axis y axis) 600mm x 340mm
XWAYLAND1 connected 1280x1024+2560+208 (normal left inverted right x axis y axis) 380mm x 300mm

SOFTWARE/OS VERSIONS
Operating System: Manjaro Linux
KDE Plasma Version: 5.24.80
KDE Frameworks Version: 5.91.0
Qt Version: 5.15.2
Kernel Version: 5.16.2-1-MANJARO (64-bit)
Graphics Platform: Wayland
Processors: 12 × Genuine Intel® CPU 0000 @ 3.20GHz
Memory: 31,0 GiB of RAM
Graphics Processor: Mesa Intel® UHD Graphics 630

ADDITIONAL INFORMATION
My primary 2560*1440 monitor is connected via DP, and secondary 1280*1024 monitor connected via HDMI and placed on right-hand side.

After login in logs:

kwin_wayland_drm: Reading output configuration for  KWin::DrmOutput(0x564ced0892c0, name="DP-1", geometry=QRect(0,0 2560x1440), scale=1)
kwin_wayland_drm: Reading output configuration for  KWin::DrmOutput(0x564cecf318c0, name="HDMI-A-2", geometry=QRect(0,0 1280x1024), scale=1)
kwin_xwl: Setting primary KWin::DrmOutput(0x564ced0892c0, name="DP-1", geometry=QRect(0,0 2560x1440), scale=1) 33

After unplug monitor:

kwin_wayland_drm: Removing output KWin::DrmOutput(0x564ced0892c0, name="DP-1", geometry=QRect(0,0 2560x1440), scale=1)
kwin_xwl: Setting primary KWin::DrmOutput(0x564cecf318c0, name="HDMI-A-2", geometry=QRect(2560,208 1280x1024), scale=1) 35
kwin_wayland_drm: Reading output configuration for  KWin::DrmOutput(0x564cecf318c0, name="HDMI-A-2", geometry=QRect(2560,208 1280x1024), scale=1)

After plug monitor again:

kwin_wayland_drm: Reading output configuration for  KWin::DrmOutput(0x564cedebd5e0, name="DP-1", geometry=QRect(0,0 2560x1440), scale=1)
kwin_wayland_drm: Reading output configuration for  KWin::DrmOutput(0x564cecf318c0, name="HDMI-A-2", geometry=QRect(0,0 1280x1024), scale=1)
kwin_xwl: Setting primary KWin::DrmOutput(0x564cedebd5e0, name="DP-1", geometry=QRect(0,0 2560x1440), scale=1) 35

Aside from this issue I've also experiencing #371717 after reconnect primary monitor.
Comment 1 Aleix Pol 2022-01-25 01:21:10 UTC
Can reproduce.

As discussed https://invent.kde.org/plasma/kwin/-/commit/f91ae3e97584767d273479c4013a43e279d77f40
Comment 2 Bug Janitor Service 2022-01-25 14:18:16 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/1945
Comment 3 Aleix Pol 2022-01-27 13:45:23 UTC
Git commit d1698e12706baedc054e1dea78960cf31a63dddc by Aleix Pol Gonzalez, on behalf of Aleix Pol.
Committed on 27/01/2022 at 11:31.
Pushed by apol into branch 'master'.

Fix xrandr primary when the new screen is the connected one

We'd trigger updatePrimary before Xwayland had reacted to the new output
so we wouldn't end up calling xcb_randr_set_output_primary() as
necessary.

M  +1    -0    src/utils/xcbutils.cpp
M  +32   -0    src/xwl/xwayland.cpp
M  +4    -0    src/xwl/xwayland.h

https://invent.kde.org/plasma/kwin/commit/d1698e12706baedc054e1dea78960cf31a63dddc
Comment 4 Aleix Pol 2022-01-27 14:19:06 UTC
Git commit 27254f61ff57f38ce95d28f1110e0159ef6e9ae4 by Aleix Pol Gonzalez, on behalf of Aleix Pol.
Committed on 27/01/2022 at 14:19.
Pushed by apol into branch 'Plasma/5.24'.

Fix xrandr primary when the new screen is the connected one

We'd trigger updatePrimary before Xwayland had reacted to the new output
so we wouldn't end up calling xcb_randr_set_output_primary() as
necessary.


(cherry picked from commit d1698e12706baedc054e1dea78960cf31a63dddc)

M  +1    -0    src/utils/xcbutils.cpp
M  +32   -0    src/xwl/xwayland.cpp
M  +4    -0    src/xwl/xwayland.h

https://invent.kde.org/plasma/kwin/commit/27254f61ff57f38ce95d28f1110e0159ef6e9ae4