diff options
Diffstat (limited to 'alacritty/src/display/window.rs')
-rw-r--r-- | alacritty/src/display/window.rs | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/alacritty/src/display/window.rs b/alacritty/src/display/window.rs index 97329d70..6f9e908a 100644 --- a/alacritty/src/display/window.rs +++ b/alacritty/src/display/window.rs @@ -26,16 +26,18 @@ use std::sync::atomic::AtomicBool; use std::sync::Arc; #[cfg(target_os = "macos")] -use cocoa::base::{id, NO, YES}; -#[cfg(target_os = "macos")] -use objc::{msg_send, sel, sel_impl}; +use { + cocoa::appkit::NSColorSpace, + cocoa::base::{id, nil, NO, YES}, + objc::{msg_send, sel, sel_impl}, + winit::platform::macos::{WindowBuilderExtMacOS, WindowExtMacOS}, +}; + use raw_window_handle::{HasRawWindowHandle, RawWindowHandle}; use winit::dpi::{PhysicalPosition, PhysicalSize}; use winit::event_loop::EventLoopWindowTarget; use winit::monitor::MonitorHandle; -#[cfg(target_os = "macos")] -use winit::platform::macos::{WindowBuilderExtMacOS, WindowExtMacOS}; #[cfg(windows)] use winit::platform::windows::IconExtWindows; use winit::window::{ @@ -164,6 +166,9 @@ impl Window { // Enable IME. window.set_ime_allowed(true); + #[cfg(target_os = "macos")] + use_srgb_color_space(&window); + #[cfg(all(feature = "x11", not(any(target_os = "macos", windows))))] if !is_wayland { // On X11, embed the window inside another if the parent ID has been set. @@ -460,6 +465,18 @@ fn x_embed_window(window: &WinitWindow, parent_id: std::os::raw::c_ulong) { } } +#[cfg(target_os = "macos")] +fn use_srgb_color_space(window: &WinitWindow) { + let raw_window = match window.raw_window_handle() { + RawWindowHandle::AppKit(handle) => handle.ns_window as id, + _ => return, + }; + + unsafe { + let _: () = msg_send![raw_window, setColorSpace: NSColorSpace::sRGBColorSpace(nil)]; + } +} + #[cfg(all(feature = "x11", not(any(target_os = "macos", windows))))] unsafe extern "C" fn xembed_error_handler(_: *mut XDisplay, _: *mut XErrorEvent) -> i32 { log::error!("Could not embed into specified window."); |