Skip to content

feat(window): expose monitor_position alongside monitor_size#3321

Open
wilsonglasser wants to merge 2 commits into
iced-rs:masterfrom
wilsonglasser:monitor-position
Open

feat(window): expose monitor_position alongside monitor_size#3321
wilsonglasser wants to merge 2 commits into
iced-rs:masterfrom
wilsonglasser:monitor-position

Conversation

@wilsonglasser
Copy link
Copy Markdown

Adds iced::window::monitor_position(id) -> Task<Option<Point>> and the matching Action::GetMonitorPosition / winit handler. Returns the top-left position of the monitor the window currently lives on, in logical coordinates.

Why

monitor_size alone isn't enough to align a window flush with its current monitor's edges in a multi-monitor setup, since (0, 0) lives on the primary. Reading monitor_position lets the caller compute the correct offset for "snap to monitor top" / "fill monitor height" gestures without jumping windows across monitors.

Implementation

  • New Action::GetMonitorPosition(Id, oneshot::Sender<Option<Point>>) in core::widget::operation — mirrors GetMonitorSize.
  • New pub fn monitor_position(id) -> Task<Option<Point>> in runtime::window.
  • winit handler reads window.raw.current_monitor().map(|m| m.position().to_logical(scale)) — same pattern as the size handler, just .position() instead of .size().

26 lines net, no behaviour change for existing call sites.

Adds runtime::window::monitor_position(id) -> Task<Option<Point>>
and the matching Action::GetMonitorPosition / winit handler that
returns monitor.position() in logical coordinates.

Pairs with the existing monitor_size to let an app align a window
flush with the current monitor's edges in a multi-monitor setup,
where (0, 0) lives on the primary monitor.
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.

1 participant