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 88cb039
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions alacritty/src/display/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ use log::{debug, info};
use parking_lot::MutexGuard;
use raw_window_handle::RawWindowHandle;
use serde::{Deserialize, Serialize};
#[cfg(target_os = "macos")]
use winit::dpi::PhysicalPosition;
use winit::dpi::PhysicalSize;
use winit::keyboard::ModifiersState;
use winit::window::CursorIcon;
Expand Down Expand Up @@ -422,6 +424,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
6 changes: 6 additions & 0 deletions alacritty/src/display/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,12 @@ impl Window {
let _ = self.window.request_inner_size(size);
}

#[inline]
#[cfg(target_os = "macos")]
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 88cb039

Please sign in to comment.