Skip to content

Commit

Permalink
Use with_position instead of set_outer_position
Browse files Browse the repository at this point in the history
This uses `with_position` method on a `WindowBuilder` instead of setting
window position on the created window later on.
  • Loading branch information
kchibisov authored Jan 11, 2022
1 parent a8c8c57 commit 01c1cc1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
10 changes: 1 addition & 9 deletions alacritty/src/display/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::sync::atomic::Ordering;
use std::time::Instant;
use std::{f64, mem};

use glutin::dpi::{PhysicalPosition, PhysicalSize};
use glutin::dpi::PhysicalSize;
use glutin::event::ModifiersState;
use glutin::event_loop::EventLoopWindowTarget;
#[cfg(not(any(target_os = "macos", windows)))]
Expand Down Expand Up @@ -308,14 +308,6 @@ impl Display {

window.set_visible(true);

// Set window position.
//
// TODO: replace `set_position` with `with_position` once available.
// Upstream issue: https://github.com/rust-windowing/winit/issues/806.
if let Some(position) = config.window.position {
window.set_outer_position(PhysicalPosition::from((position.x, position.y)));
}

#[allow(clippy::single_match)]
#[cfg(not(windows))]
match config.window.startup_mode {
Expand Down
11 changes: 6 additions & 5 deletions alacritty/src/display/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,12 @@ impl Window {
wayland_event_queue: Option<&EventQueue>,
) -> Result<Window> {
let identity = identity.clone();
let window_builder = Window::get_platform_window(&identity, &config.window);
let mut window_builder = Window::get_platform_window(&identity, &config.window);

if let Some(position) = config.window.position {
window_builder = window_builder
.with_position(PhysicalPosition::<i32>::from((position.x, position.y)));
}

// Check if we're running Wayland to disable vsync.
#[cfg(all(feature = "wayland", not(any(target_os = "macos", windows))))]
Expand Down Expand Up @@ -360,10 +365,6 @@ impl Window {
self.window().request_user_attention(attention);
}

pub fn set_outer_position(&self, pos: PhysicalPosition<i32>) {
self.window().set_outer_position(pos);
}

#[cfg(all(feature = "x11", not(any(target_os = "macos", windows))))]
pub fn x11_window_id(&self) -> Option<usize> {
self.window().xlib_window().map(|xlib_window| xlib_window as usize)
Expand Down

0 comments on commit 01c1cc1

Please sign in to comment.