Skip to content

Commit

Permalink
Revert "Merge pull request #2280 from n1ght-hunter/add-action-fetch-l…
Browse files Browse the repository at this point in the history
…ocation"

This reverts commit a27267b, reversing
changes made to ce4eef6.
  • Loading branch information
hecrj committed Feb 22, 2024
1 parent 4e8883b commit c1f41a4
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 55 deletions.
11 changes: 0 additions & 11 deletions runtime/src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,6 @@ pub fn minimize<Message>(id: Id, minimized: bool) -> Command<Message> {
Command::single(command::Action::Window(Action::Minimize(id, minimized)))
}

/// Fetches the current window position in logical coordinates.
pub fn fetch_position<Message>(
id: Id,
f: impl FnOnce(Option<Point>) -> Message + 'static,
) -> Command<Message> {
Command::single(command::Action::Window(Action::FetchPosition(
id,
Box::new(f),
)))
}

/// Moves the window to the given logical coordinates.
pub fn move_to<Message>(id: Id, position: Point) -> Command<Message> {
Command::single(command::Action::Window(Action::Move(id, position)))
Expand Down
8 changes: 0 additions & 8 deletions runtime/src/window/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ pub enum Action<T> {
FetchMinimized(Id, Box<dyn FnOnce(Option<bool>) -> T + 'static>),
/// Set the window to minimized or back
Minimize(Id, bool),
/// Fetch the current logical coordinates of the window.
FetchPosition(Id, Box<dyn FnOnce(Option<Point>) -> T + 'static>),
/// Move the window to the given logical coordinates.
///
/// Unsupported on Wayland.
Expand Down Expand Up @@ -136,9 +134,6 @@ impl<T> Action<T> {
Action::FetchMinimized(id, Box::new(move |s| f(o(s))))
}
Self::Minimize(id, minimized) => Action::Minimize(id, minimized),
Self::FetchPosition(id, o) => {
Action::FetchPosition(id, Box::new(move |s| f(o(s))))
}
Self::Move(id, position) => Action::Move(id, position),
Self::ChangeMode(id, mode) => Action::ChangeMode(id, mode),
Self::FetchMode(id, o) => {
Expand Down Expand Up @@ -191,9 +186,6 @@ impl<T> fmt::Debug for Action<T> {
Self::Minimize(id, minimized) => {
write!(f, "Action::Minimize({id:?}, {minimized}")
}
Self::FetchPosition(id, _) => {
write!(f, "Action::FetchPosition({id:?})")
}
Self::Move(id, position) => {
write!(f, "Action::Move({id:?}, {position})")
}
Expand Down
17 changes: 1 addition & 16 deletions winit/src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::core::renderer;
use crate::core::time::Instant;
use crate::core::widget::operation;
use crate::core::window;
use crate::core::{Event, Point, Size};
use crate::core::{Event, Size};
use crate::futures::futures;
use crate::futures::{Executor, Runtime, Subscription};
use crate::graphics::compositor::{self, Compositor};
Expand Down Expand Up @@ -756,21 +756,6 @@ pub fn run_command<A, C, E>(
window::Action::Minimize(_id, minimized) => {
window.set_minimized(minimized);
}
window::Action::FetchPosition(_id, callback) => {
let position = window
.inner_position()
.map(|position| {
let position = position
.to_logical::<f32>(window.scale_factor());

Point::new(position.x, position.y)
})
.ok();

proxy
.send_event(callback(position))
.expect("Send message to event loop");
}
window::Action::Move(_id, position) => {
window.set_outer_position(winit::dpi::LogicalPosition {
x: position.x,
Expand Down
21 changes: 1 addition & 20 deletions winit/src/multi_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::core::mouse;
use crate::core::renderer;
use crate::core::widget::operation;
use crate::core::window;
use crate::core::{Point, Size};
use crate::core::Size;
use crate::futures::futures::channel::mpsc;
use crate::futures::futures::{task, Future, StreamExt};
use crate::futures::{Executor, Runtime, Subscription};
Expand Down Expand Up @@ -977,25 +977,6 @@ fn run_command<A, C, E>(
window.raw.set_minimized(minimized);
}
}
window::Action::FetchPosition(id, callback) => {
if let Some(window) = window_manager.get_mut(id) {
let position = window
.raw
.inner_position()
.map(|position| {
let position = position.to_logical::<f32>(
window.raw.scale_factor(),
);

Point::new(position.x, position.y)
})
.ok();

proxy
.send_event(callback(position))
.expect("Send message to event loop");
}
}
window::Action::Move(id, position) => {
if let Some(window) = window_manager.get_mut(id) {
window.raw.set_outer_position(
Expand Down

0 comments on commit c1f41a4

Please sign in to comment.