■ ■ ■ ■ ■ ■
alacritty/src/display/window.rs
| skipped 25 lines |
26 | 26 | | use std::sync::Arc; |
27 | 27 | | |
28 | 28 | | #[cfg(target_os = "macos")] |
29 | | - | use cocoa::base::{id, NO, YES}; |
30 | | - | #[cfg(target_os = "macos")] |
31 | | - | use objc::{msg_send, sel, sel_impl}; |
| 29 | + | use { |
| 30 | + | cocoa::appkit::NSColorSpace, |
| 31 | + | cocoa::base::{id, nil, NO, YES}, |
| 32 | + | objc::{msg_send, sel, sel_impl}, |
| 33 | + | winit::platform::macos::{WindowBuilderExtMacOS, WindowExtMacOS}, |
| 34 | + | }; |
| 35 | + | |
32 | 36 | | use raw_window_handle::{HasRawWindowHandle, RawWindowHandle}; |
33 | 37 | | |
34 | 38 | | use winit::dpi::{PhysicalPosition, PhysicalSize}; |
35 | 39 | | use winit::event_loop::EventLoopWindowTarget; |
36 | 40 | | use winit::monitor::MonitorHandle; |
37 | | - | #[cfg(target_os = "macos")] |
38 | | - | use winit::platform::macos::{WindowBuilderExtMacOS, WindowExtMacOS}; |
39 | 41 | | #[cfg(windows)] |
40 | 42 | | use winit::platform::windows::IconExtWindows; |
41 | 43 | | use winit::window::{ |
| skipped 121 lines |
163 | 165 | | |
164 | 166 | | // Enable IME. |
165 | 167 | | window.set_ime_allowed(true); |
| 168 | + | |
| 169 | + | #[cfg(target_os = "macos")] |
| 170 | + | use_srgb_color_space(&window); |
166 | 171 | | |
167 | 172 | | #[cfg(all(feature = "x11", not(any(target_os = "macos", windows))))] |
168 | 173 | | if !is_wayland { |
| skipped 288 lines |
457 | 462 | | // Drain errors and restore original error handler. |
458 | 463 | | (xlib.XSync)(xlib_display as _, 0); |
459 | 464 | | (xlib.XSetErrorHandler)(old_handler); |
| 465 | + | } |
| 466 | + | } |
| 467 | + | |
| 468 | + | #[cfg(target_os = "macos")] |
| 469 | + | fn use_srgb_color_space(window: &WinitWindow) { |
| 470 | + | let raw_window = match window.raw_window_handle() { |
| 471 | + | RawWindowHandle::AppKit(handle) => handle.ns_window as id, |
| 472 | + | _ => return, |
| 473 | + | }; |
| 474 | + | |
| 475 | + | unsafe { |
| 476 | + | let _: () = msg_send![raw_window, setColorSpace: NSColorSpace::sRGBColorSpace(nil)]; |
460 | 477 | | } |
461 | 478 | | } |
462 | 479 | | |
| skipped 6 lines |