Skip to content

XWayland overlays never update their input shape on a drawn frame, so a redrawing overlay takes no clicks #276

Closed

Description

@pkkid

Summary

An overlay on the XWayland backing (GNOME Wayland, no layer-shell, OverlayOptions::xwayland_input) never updates its input shape on a drawn frame. An overlay that keeps redrawing therefore keeps the empty input shape it was created with and takes no clicks. This is the last piece of #85.

Hex hit it in anomalyco/hex#1526: Annotate's recording capsule redraws every second for its clock, and on GNOME none of its buttons responded. The full-screen ink overlay got its regions only after an unchanged frame, so the pen needed one click before it drew.

Cause

In crates/rune/src/overlay/draw.rs, the drawn-frame path publishes hit regions for macOS (panel), Windows (native), X11 (x11) and layer-shell (Backing::Layer), but not for Backing::Xwayland:

// Publish the geometry just rendered, never a layout cached from the preceding frame.
#[cfg(target_os = "macos")]
if let Some(panel) = &self.panel { panel.set_regions(self.rt.hit_regions()); }
#[cfg(target_os = "windows")]
if let Some(native) = &self.native { native.set_regions(self.rt.hit_regions(), live.scale); }
#[cfg(...)]
if self.options.input == OverlayInput::Regions && let Some(x11) = &mut self.x11 { x11.regions(self.rt.hit_regions(), live.scale); }
#[cfg(...)]
if let Backing::Layer(layer) = &live.backing { layer.input_regions(self.rt.hit_regions(), self.interactive); }

Backing::Xwayland gets its regions only through publish_regions (from apply_input, unchanged_frame and warm_frame), so a continuously drawn overlay never gets them.

Fix

One statement beside the layer-shell line, at 53c7f60f (the same issue is on dev at ba32e19f):

         if let Backing::Layer(layer) = &live.backing { layer.input_regions(self.rt.hit_regions(), self.interactive); }
+        // An XWayland window's input shape follows the frame just laid out too; without it a
+        // redrawing overlay kept the empty shape it was made with and took no clicks.
+        #[cfg(all(unix, not(target_os = "macos"), not(target_os = "ios"), not(target_os = "android")))]
+        if let Backing::Xwayland(surface) = &mut live.backing { surface.regions(self.rt.hit_regions()); }
         let target_format = ...

XwaylandSurface::regions already returns early when the shape hasn't changed, so running it every frame is cheap.

Evidence

Fedora 45, GNOME Shell 51.1, one 3440x1440 monitor at Xft scale 1. I listed the overlays' X windows and their ShapeInput rectangles during a capture:

Before the fix, capsule shown, pen off:
  'Hex capture' 640x424+1400+14  input shape: 0 rects
  'Hex ink'     3440x1440+0+0    input shape: 0 rects
Pen on:
  'Hex capture' 640x424+1400+14  input shape: 0 rects
  'Hex ink'     3440x1440+0+0    input shape: 4 rects [0,0 3440x36] [0,36 1626x40] [1814,36 1626x40] [0,76 3440x1364]

With the line added (Rune patched locally into Hex through cargo --config patch), the capsule's buttons take clicks and the pen draws on the first drag.

The opt-in meeting capsules on GNOME (Hex's Labs › Floating meeting capsules on GNOME) probably hit this too, since they also redraw, but I haven't checked that.

Related

🤖 Generated with Claude Code

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions