mirror of
https://github.com/alacritty/alacritty.git
synced 2025-09-04 22:43:53 -04:00
Use sRGB color space for NSWindow on macOS
Co-authored-by: Christian Duerr <contact@christianduerr.com>
This commit is contained in:
parent
2bd26fbeb0
commit
bcd6d0d981
2 changed files with 23 additions and 5 deletions
|
@ -14,6 +14,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- `font.glyph_offset.y` is now applied to underline/strikeout
|
- `font.glyph_offset.y` is now applied to underline/strikeout
|
||||||
|
- Always use sRGB color space on macOS
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
|
|
@ -26,16 +26,18 @@ use std::sync::atomic::AtomicBool;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
use cocoa::base::{id, NO, YES};
|
use {
|
||||||
#[cfg(target_os = "macos")]
|
cocoa::appkit::NSColorSpace,
|
||||||
use objc::{msg_send, sel, sel_impl};
|
cocoa::base::{id, nil, NO, YES},
|
||||||
|
objc::{msg_send, sel, sel_impl},
|
||||||
|
winit::platform::macos::{WindowBuilderExtMacOS, WindowExtMacOS},
|
||||||
|
};
|
||||||
|
|
||||||
use raw_window_handle::{HasRawWindowHandle, RawWindowHandle};
|
use raw_window_handle::{HasRawWindowHandle, RawWindowHandle};
|
||||||
|
|
||||||
use winit::dpi::{PhysicalPosition, PhysicalSize};
|
use winit::dpi::{PhysicalPosition, PhysicalSize};
|
||||||
use winit::event_loop::EventLoopWindowTarget;
|
use winit::event_loop::EventLoopWindowTarget;
|
||||||
use winit::monitor::MonitorHandle;
|
use winit::monitor::MonitorHandle;
|
||||||
#[cfg(target_os = "macos")]
|
|
||||||
use winit::platform::macos::{WindowBuilderExtMacOS, WindowExtMacOS};
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
use winit::platform::windows::IconExtWindows;
|
use winit::platform::windows::IconExtWindows;
|
||||||
use winit::window::{
|
use winit::window::{
|
||||||
|
@ -164,6 +166,9 @@ impl Window {
|
||||||
// Enable IME.
|
// Enable IME.
|
||||||
window.set_ime_allowed(true);
|
window.set_ime_allowed(true);
|
||||||
|
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
use_srgb_color_space(&window);
|
||||||
|
|
||||||
#[cfg(all(feature = "x11", not(any(target_os = "macos", windows))))]
|
#[cfg(all(feature = "x11", not(any(target_os = "macos", windows))))]
|
||||||
if !is_wayland {
|
if !is_wayland {
|
||||||
// On X11, embed the window inside another if the parent ID has been set.
|
// 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))))]
|
#[cfg(all(feature = "x11", not(any(target_os = "macos", windows))))]
|
||||||
unsafe extern "C" fn xembed_error_handler(_: *mut XDisplay, _: *mut XErrorEvent) -> i32 {
|
unsafe extern "C" fn xembed_error_handler(_: *mut XDisplay, _: *mut XErrorEvent) -> i32 {
|
||||||
log::error!("Could not embed into specified window.");
|
log::error!("Could not embed into specified window.");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue