Skip to content

Wayland: auto-select monitor under cursor and compact picker on every screen - #4875

Open
DIOR27 wants to merge 5 commits into
flameshot-org:masterfrom
DIOR27:feat/monitor-picker-autoselect
Open

DIOR27 wants to merge 5 commits into
flameshot-org:masterfrom
DIOR27:feat/monitor-picker-autoselect

Conversation

@DIOR27

@DIOR27 DIOR27 commented Aug 14, 2026

Copy link
Copy Markdown

Summary

Improves the Wayland monitor picker: it auto-selects the monitor under the cursor (matching the X11 "capture active monitor" behavior) and renders compactly on every screen so multi-monitor setups stay readable.

Changes

  • Auto-select: the picker now pre-selects the monitor under the cursor instead of always the first one. On Wayland the cursor position is not exposed to clients, so the selection is derived from the portal monitor descriptions introduced in the base PR.
  • Compact picker: preview boxes, margins and fonts scale down so the picker fits comfortably on each screen.
  • Click-only picker: keyboard-based monitor selection (number keys, arrows, Enter) is removed. On Wayland the picker surfaces never receive keyboard focus, so those shortcuts were dead weight; selection is mouse-only, Escape still cancels.
File Change
src/utils/monitorpreview.cpp / .h compact mode with smaller layout and fonts, click-only hint, no number key labels
src/utils/screengrabber.cpp / .h Monitor-under-cursor selection, compact picker layout across screens, click-only input handling
src/widgets/capture/capturewidget.cpp Picker sizing / auto-selection wiring

Test plan

  • cmake --build build-codebuff --target flameshot passes
  • Manual, Wayland multi-monitor: picker opens compact on every screen and pre-selects the monitor under the cursor
  • Manual, Wayland multi-monitor: click selects the monitor, Escape cancels, number keys no longer shown

Chain context

Second PR of a stacked chain (3 PRs):

  1. fix/wayland-monitor-placement (Fix Wayland multi-monitor: show capture UI on the correct monitor #4874) — base: fix Wayland monitor placement
  2. 📍 This PR — auto-select monitor under cursor + compact picker on every screen
  3. feat/hybrid-monitor-switching — "Capture this monitor" strips + reuse stored screenshots

Out of scope: capture-time monitor switching — that lands in the next PR.

On GNOME Wayland the capture window and the monitor selection dialog
were always mapped on the built-in panel instead of the monitor the
user configured as primary. Two root causes:

- Qt's wayland plugin does not implement the wp_primary_output
  protocol, so QGuiApplication::primaryScreen() reports the first
  wl_output instead of the real primary. The actual primary is now
  queried from mutter (org.gnome.Mutter.DisplayConfig) on GNOME
  Wayland.
- windowHandle()->setScreen() was a silent no-op because the native
  window does not exist before the widget is shown, and Wayland
  ignores move() entirely. winId() is now called before setScreen()
  so the fullscreen capture window and the monitor picker are
  recreated on the target QScreen, which is the only reliable way to
  choose the output on Wayland.

Verified end-to-end on a GNOME Wayland session: the monitor selection
dialog appears on the real primary (external) monitor and the capture
overlay follows the selected monitor.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
Diego Orellana Ávila and others added 4 commits August 14, 2026 12:16
… screen

On Wayland regular windows are placed on the monitor containing the
pointer (move()/setScreen() are ignored), so the previous capture-UI
placement relied on the pointer coincidentally matching the selected
screen. Fullscreen is the only window state where the requested output
is honored, so the capture widget now requests fullscreen after
setScreen() on Wayland.

The monitor under the cursor is recovered by mapping a tiny probe
window (compositors place new windows on the pointer's monitor) and the
selection dialog is skipped whenever it is known. When the fallback
compact picker is needed, each monitor gets a fullscreen opaque window
painted with its frozen desktop (fullscreen windows cannot be
translucent on GNOME Wayland) and a compact strip at the bottom; a
click anywhere on a monitor selects it. X11 keeps the small translucent
window moved to the bottom-center.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
@DIOR27
DIOR27 force-pushed the feat/monitor-picker-autoselect branch from bb8b9d3 to 007597a Compare August 14, 2026 19:16
@borgmanJeremy

Copy link
Copy Markdown
Collaborator

Im leaning towards not merging this but want to hear from @mmahmoudian my main concern is it seems like the kind of hack that will come around and bite us later.

On tiling DE's like cosmic the window also disrupts the windows as everything resizes.

@borgmanJeremy

Copy link
Copy Markdown
Collaborator

I thought about this more and i'm conceptually okay with it as long as its gated behind the same setting as X11 and windows rather than always capturing the active screen. I'm still skeptical it will work on every DE but I think enough users will be interested that its worth a try.

I still need to review the code.

@mmahmoudian

Copy link
Copy Markdown
Member

My main concern is reverting #4811.

@borgmanJeremy

Copy link
Copy Markdown
Collaborator

This should not revert #4811 once its behind the "Capture Active Monitor (skip monitor selection)" right?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants