feat(window): expose monitor_position alongside monitor_size#3321
Open
wilsonglasser wants to merge 2 commits into
Open
feat(window): expose monitor_position alongside monitor_size#3321wilsonglasser wants to merge 2 commits into
wilsonglasser wants to merge 2 commits into
Conversation
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.
c2ef23a to
c6ebd9e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
iced::window::monitor_position(id) -> Task<Option<Point>>and the matchingAction::GetMonitorPosition/ winit handler. Returns the top-left position of the monitor the window currently lives on, in logical coordinates.Why
monitor_sizealone 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. Readingmonitor_positionlets the caller compute the correct offset for "snap to monitor top" / "fill monitor height" gestures without jumping windows across monitors.Implementation
Action::GetMonitorPosition(Id, oneshot::Sender<Option<Point>>)incore::widget::operation— mirrorsGetMonitorSize.pub fn monitor_position(id) -> Task<Option<Point>>inruntime::window.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.