** Description changed:

  [ Impact ]
  
   * With displays rotated to portrait (Transform 90), the mouse pointer
     moves in the wrong direction for a few seconds after the displays wake
     from power save (screen lock, DPMS off or resume): moving the mouse
     right moves the pointer down, and on adjacent monitors the pointer can
     appear on the wrong monitor at the same time. It recovers only when the
     cursor shape changes. This affects every Wayland user with rotated
     monitors on every power-save wake, resume or modeset - a common laptop
     dock and portrait-display workflow.
   * The cause is in mutter's native KMS cursor manager: when the CRTC
     layout is updated (e.g. when leaving power save mode),
     update_viewports_in_impl() recreates the per-CRTC cursor state keeping
     only the cursor buffer, dropping the transform, hotspot and sprite size
     that describe the buffer, and whether the cursor plane was assigned.
     calculate_cursor_buffer_rect() then maps the pointer position into CRTC
     coordinates as if the output were unrotated, until the sprite is
     realized again on the next cursor change - which is why the effect is
     transient.
-  * The fix preserves the sprite state across the layout update. It is 14
-    lines, upstream as mutter merge request !5494, written by this bug's
-    reporter. The regression test added upstream is not carried in the SRU
-    patch, to keep the stable-release change minimal.
+  * The fix preserves the transform, hotspot and plane assignment across
+    the layout update. Upstream (mutter merge request !5494, written by
+    this bug's reporter) additionally preserves the sprite size; that part
+    does not apply to mutter 50.x/51.x, whose per-CRTC state does not
+    track the sprite size (buffer dimensions are used directly instead),
+    so the backport is 12 lines. The regression test added upstream is
+    not carried in the SRU patch, to keep the stable-release change
+    minimal.
  
  [ Test Plan ]
  
   * Requires rotated displays on a Wayland session (real hardware or a VM
     with virtual displays that support rotation). Reproduce on the
     unpatched package first to confirm the environment:
     1. Rotate the display(s) to portrait (Settings - Displays, or
        "gdctl set" on newer mutter).
     2. Trigger a power-save cycle:
          busctl --user set-property org.gnome.Mutter.DisplayConfig \
            /org/gnome/Mutter/DisplayConfig org.gnome.Mutter.DisplayConfig \
            PowerSaveMode i 3
          sleep 5
          busctl --user set-property org.gnome.Mutter.DisplayConfig \
            /org/gnome/Mutter/DisplayConfig org.gnome.Mutter.DisplayConfig \
            PowerSaveMode i 0
     3. Immediately move the pointer. Without the fix, movement is rotated
        (right becomes down) and the pointer can appear near the top of an
        adjacent monitor; it clears up after a few seconds or a cursor
        shape change. Repeat ~10 times and note the reproduction rate as
        the baseline.
     4. Install the fixed package and repeat the same cycles: the pointer
        must track correctly after every wake.
   * Regression checks (the change only touches the KMS cursor state
     update on CRTC layout changes, native Wayland sessions):
     - cursor behaviour across monitor configuration changes: hotplug,
       rotation changes, scale changes (the sprite is re-realized there)
     - cursor tracking across monitor boundaries, including a sprite
       partially outside a CRTC, and the cursor plane being released when
       the cursor leaves a CRTC
     - power save enter/exit, suspend/resume, lock screen, cursor shape
       changes
     - X11 sessions are unaffected (they do not use mutter's native KMS
       cursor manager)
   * autopkgtests for mutter run automatically against the upload in
     -proposed. The upstream regression test (vkms
     backends/native/kms/device/cursor-layout-update) is not carried in
     the SRU patch but is expected to be merged upstream.
  
  [ Where problems could occur ]
  
   * The change makes the cursor manager keep the transform, hotspot and
-    sprite size (and the plane assignment, when the plane is unchanged)
-    across a CRTC layout update instead of resetting them. If that kept
+    plane assignment (when the plane is unchanged) across a CRTC layout
+    update instead of resetting them. If that kept
     state were stale for the new layout, the cursor would be placed
     incorrectly - but the kept state describes the cursor sprite, which a
     layout update does not change, and for monitor configuration changes
     (hotplug, rotation, scale) the stage views are rebuilt and the sprite
     is re-realized anyway, so the kept state is not used there.
   * Keeping has_cursor means a cursor plane assigned before the layout
     update is now unassigned when the cursor is no longer visible on that
     CRTC; previously it stayed on screen until the next mode set. A wrong
     unassignment would show as a missing hardware cursor until the next
     cursor update; the cursor-movement checks above cover this.
   * The ordering of cursor sprite updates after the layout update is
     unchanged (impl tasks are processed in order).
  
  [ Other Info ]
  
   * Standard bug-fix SRU; mutter is not covered by the GNOME micro
     release exception.
-  * The fix is applied to tenacious (devel, mutter 51.0-1ubuntu5,
+  * The fix is applied to tenacious (devel, mutter 51.0-1ubuntu6,
     development release fixed first per SRU policy), stonking
-    (51.0-1ubuntu3.2) and resolute (50.1-0ubuntu2.8).
+    (51.0-1ubuntu3.3) and resolute (50.1-0ubuntu2.9).
   * This upload also fixes LP: #2013042 (lock screen wallpaper turning
     black when a second monitor is plugged in/out), which carries its own
     SRU documentation on that bug. Both fixes are by the same author.
   * Upstream merge request !5494 is open and under review; the Ubuntu
-    uploads use the exact same commit (minus the upstream test). If
-    upstream lands an amended version, the Ubuntu patch will be updated
-    to match in a follow-up SRU.
+    uploads use an adapted backport of the upstream commit (minus the
+    upstream test and the sprite-size preservation, which only applies to
+    newer mutter). If upstream lands an amended version, the Ubuntu patch
+    will be updated to match in a follow-up SRU.
  
  ---- Original description ----
  With the displays rotated to portrait, the mouse pointer moves in the wrong 
direction for a few seconds after the displays wake from power save (screen 
lock, DPMS off or resume).
  
  Environment:
  - Ubuntu 26.04.1 LTS
  - mutter 50.1-0ubuntu2.7, GNOME/Wayland
  - AMD Strix Halo (amdgpu), three monitors, each rotated right (Transform 90),
    laid out left/centre/right
  
  Symptoms:
  - After locking the screen, waiting for the displays to power off and then
    waking them, pointer motion is rotated: moving the mouse right moves the
    pointer down, moving it down moves the pointer left.
  - On the left monitor the pointer can also appear near the top of the centre
    monitor at the same time.
  - The rotation itself is correct: gdctl show reports Transform 90 for all
    three logical monitors throughout, and the wallpaper, clock and lock screen
    text stay upright. The cursor image is upright; only its position and
    movement are wrong.
  - It clears up after a few seconds, or as soon as the cursor shape changes.
  
  Reproducer (does not need the lock screen, run in the desktop session):
  
      busctl --user set-property org.gnome.Mutter.DisplayConfig \
        /org/gnome/Mutter/DisplayConfig org.gnome.Mutter.DisplayConfig \
        PowerSaveMode i 3
  
      sleep 5
  
      busctl --user set-property org.gnome.Mutter.DisplayConfig \
        /org/gnome/Mutter/DisplayConfig org.gnome.Mutter.DisplayConfig \
        PowerSaveMode i 0
  
  Then move the pointer immediately. The wrong mapping is intermittent, but
  this reproduces it reliably on this machine.
  
  Cause:
  meta_renderer_native_queue_modes_reset() ->
  meta_kms_cursor_manager_update_crtc_layout() ->
  update_viewports_in_impl() recreates the per-CRTC cursor state from the stage
  view layouts and preserves only the cursor buffer. It drops the transform,
  hotspot and sprite size that describe the buffer, and whether the cursor plane
  was assigned. calculate_cursor_buffer_rect() then maps the pointer position to
  CRTC coordinates as if the output were not rotated. The state is only restored
  when the cursor sprite is realized again after a cursor change, which is why
  the effect is transient.
  
  Fix:
  Upstream merge request:
  https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/5494
  
  Commit 62cfc12322f87167c6fdd0152dd210b755c95bbd preserves the sprite state
  across the layout update and adds a vkms regression test
  (/backends/native/kms/device/cursor-layout-update) that fails without the
  change and passes with it. The test covers the transform, hotspot and sprite
  size; the has_cursor/plane assignment guard is not covered by the test.
  
  I reproduced the problem on this host with the stock package. I also built
  the upstream fix on top of mutter 50.1 and ran 10 power-save on/off cycles
  without a recurrence. Once the fix is accepted upstream I intend to propose
  it for 26.04.

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2175469

Title:
  Mouse pointer movement is rotated after displays wake on portrait
  monitors

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/mutter/+bug/2175469/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to