Skip to content

[Feature] Desktop windows that let the pointer through: the whole window, or where it draws nothing #568

Closed

Description

@houko

Context

Line numbers are at 4aea100 (main).

  • No public API lets a desktop window ignore the pointer. WindowOptions (core/window.go:34-54) and PanelOptions (core/window.go:58-68) have no such field, and the desktop package has no setter. mobile.OverlayOptions.Passive (core/overlay.go:71) does it for Android overlays only.
  • The macOS backend already uses setIgnoresMouseEvents: internally, for the permission guide panel while it is dragged (internal/platform/macos/permissionguide.go:627, :689), so the mechanism is there but not exposed.
  • Windows sets no WS_EX_TRANSPARENT / WS_EX_LAYERED on any app window (internal/platform/windows/windows.go:631-637), and nothing answers WM_NCHITTEST with HTTRANSPARENT for empty areas.
  • NSH has a window-wide switch: WindowAttributes.pointer_events with WindowPointerEvents::None ("Presses and the pointer go through it to what is below. Needs the windows capability's overlay", crates/nsh-core/src/desktop/window.rs:109-118), implemented on Windows with WS_EX_LAYERED | WS_EX_TRANSPARENT (crates/nsh-platform-windows/src/shell.rs:235-238).

Why it matters

With a transparent window (the companion issue on transparent windows), the window's rectangle is still a dead zone for the user: clicks on the empty corners around a desktop pet, a HUD or a screen annotation layer hit the app instead of the window below. Two behaviours are needed:

  1. Whole window: a passive overlay (a HUD, a "do not disturb" pet, an annotation layer while not editing) takes no pointer at all.
  2. Where nothing is drawn: a desktop pet must still take presses, drags and right clicks on the character, while presses on the transparent area around it reach the window below. A window-wide switch alone cannot do this: once the window takes no pointer the app never hears that the pointer came back over the character, so it cannot switch itself back on.

Proposal

type WindowPointerEvents uint8

const (
	// WindowPointerAuto: the window takes the pointer (default).
	WindowPointerAuto WindowPointerEvents = iota
	// WindowPointerNone: every press and the pointer go through to what is below.
	WindowPointerNone
	// WindowPointerPainted: the window takes the pointer only over views that draw something or have handlers; elsewhere it goes through.
	WindowPointerPainted
)

func SetWindowPointerEvents(cx *core.Scope, p WindowPointerEvents)

plus a WindowOptions / PanelOptions field for the initial value, gated by Access as NSH gates it.

  • macOS: setIgnoresMouseEvents: for None; for Painted, toggling ignoresMouseEvents from a hit test of the pointer location (a global mouse-moved monitor, or a tracking area).
  • Windows: WS_EX_LAYERED | WS_EX_TRANSPARENT for None; WM_NCHITTEST returning HTTRANSPARENT over the empty areas for Painted (or toggling WS_EX_TRANSPARENT from the same hit test, since HTTRANSPARENT only passes to windows of the same thread).
  • Linux: an empty input region (gdk_surface_set_input_region) for None, and the input region set to the painted views' bounds for Painted.

Acceptance

  • With WindowPointerNone, presses, scrolls and hovering over the window reach the window below on macOS, Windows and Linux.
  • With WindowPointerPainted on a transparent window holding one 200x200 view in a 600x400 window, a press on the view reaches the app (including WindowDrag and OnContextMenu), and a press on the empty area reaches the window below.
  • Switching modes at run time takes effect without reopening the window.
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