Skip to content

Commit

Permalink
Add explicit window positioning for MacOS
Browse files Browse the repository at this point in the history
  • Loading branch information
mteit committed Mar 25, 2024
1 parent 74b2d12 commit 50d438d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
8 changes: 7 additions & 1 deletion alacritty/src/display/mod.rs
Expand Up @@ -16,7 +16,7 @@ use log::{debug, info};
use parking_lot::MutexGuard;
use raw_window_handle::RawWindowHandle;
use serde::{Deserialize, Serialize};
use winit::dpi::PhysicalSize;
use winit::dpi::{PhysicalSize, PhysicalPosition};
use winit::keyboard::ModifiersState;
use winit::window::CursorIcon;

Expand Down Expand Up @@ -422,6 +422,12 @@ impl Display {
window.request_inner_size(size);
}

// Set the window position to account for the user configured position.
#[cfg(target_os = "macos")]
if let Some(position) = config.window.position {
window.set_outer_position(PhysicalPosition::new(position.x as u32, position.y as u32));
}

// Create the GL surface to draw into.
let surface = renderer::platform::create_gl_surface(
&gl_context,
Expand Down
5 changes: 5 additions & 0 deletions alacritty/src/display/window.rs
Expand Up @@ -213,6 +213,11 @@ impl Window {
let _ = self.window.request_inner_size(size);
}

#[inline]
pub fn set_outer_position(&self, position: PhysicalPosition<u32>) {
self.window.set_outer_position(position);
}

#[inline]
pub fn inner_size(&self) -> PhysicalSize<u32> {
self.window.inner_size()
Expand Down

0 comments on commit 50d438d

Please sign in to comment.