mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-24 06:11:30 +11:00
add macos with_disallow_hidpi (#1073)
* add macos with_disallow_hidpi add CHANGELOG * Always use stable rustfmt for CI. (#1074) Signed-off-by: Hal Gentz <zegentzy@protonmail.com> * add macos with_disallow_hidpi add CHANGELOG
This commit is contained in:
parent
03f9e8fce0
commit
f4e9bf51db
|
@ -2,6 +2,7 @@
|
||||||
- On macOS, drop the run closure on exit.
|
- On macOS, drop the run closure on exit.
|
||||||
- On Windows, location of `WindowEvent::Touch` are window client coordinates instead of screen coordinates.
|
- On Windows, location of `WindowEvent::Touch` are window client coordinates instead of screen coordinates.
|
||||||
- On X11, fix delayed events after window redraw.
|
- On X11, fix delayed events after window redraw.
|
||||||
|
- On macOS, add `WindowBuilderExt::with_disallow_hidpi` to have the option to turn off best resolution openGL surface.
|
||||||
|
|
||||||
# 0.20.0 Alpha 2 (2019-07-09)
|
# 0.20.0 Alpha 2 (2019-07-09)
|
||||||
|
|
||||||
|
|
|
@ -129,6 +129,7 @@ pub trait WindowBuilderExtMacOS {
|
||||||
fn with_fullsize_content_view(self, fullsize_content_view: bool) -> WindowBuilder;
|
fn with_fullsize_content_view(self, fullsize_content_view: bool) -> WindowBuilder;
|
||||||
/// Build window with `resizeIncrements` property. Values must not be 0.
|
/// Build window with `resizeIncrements` property. Values must not be 0.
|
||||||
fn with_resize_increments(self, increments: LogicalSize) -> WindowBuilder;
|
fn with_resize_increments(self, increments: LogicalSize) -> WindowBuilder;
|
||||||
|
fn with_disallow_hidpi(self, disallow_hidpi: bool) -> WindowBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WindowBuilderExtMacOS for WindowBuilder {
|
impl WindowBuilderExtMacOS for WindowBuilder {
|
||||||
|
@ -182,6 +183,12 @@ impl WindowBuilderExtMacOS for WindowBuilder {
|
||||||
self.platform_specific.resize_increments = Some(increments.into());
|
self.platform_specific.resize_increments = Some(increments.into());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn with_disallow_hidpi(mut self, disallow_hidpi: bool) -> WindowBuilder {
|
||||||
|
self.platform_specific.disallow_hidpi = disallow_hidpi;
|
||||||
|
self
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Additional methods on `MonitorHandle` that are specific to MacOS.
|
/// Additional methods on `MonitorHandle` that are specific to MacOS.
|
||||||
|
|
|
@ -66,6 +66,7 @@ pub struct PlatformSpecificWindowBuilderAttributes {
|
||||||
pub titlebar_buttons_hidden: bool,
|
pub titlebar_buttons_hidden: bool,
|
||||||
pub fullsize_content_view: bool,
|
pub fullsize_content_view: bool,
|
||||||
pub resize_increments: Option<LogicalSize>,
|
pub resize_increments: Option<LogicalSize>,
|
||||||
|
pub disallow_hidpi: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_app(activation_policy: ActivationPolicy) -> Option<id> {
|
fn create_app(activation_policy: ActivationPolicy) -> Option<id> {
|
||||||
|
@ -86,10 +87,15 @@ fn create_app(activation_policy: ActivationPolicy) -> Option<id> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn create_view(ns_window: id) -> Option<(IdRef, Weak<Mutex<util::Cursor>>)> {
|
unsafe fn create_view(
|
||||||
|
ns_window: id,
|
||||||
|
pl_attribs: &PlatformSpecificWindowBuilderAttributes,
|
||||||
|
) -> Option<(IdRef, Weak<Mutex<util::Cursor>>)> {
|
||||||
let (ns_view, cursor) = new_view(ns_window);
|
let (ns_view, cursor) = new_view(ns_window);
|
||||||
ns_view.non_nil().map(|ns_view| {
|
ns_view.non_nil().map(|ns_view| {
|
||||||
ns_view.setWantsBestResolutionOpenGLSurface_(YES);
|
if !pl_attribs.disallow_hidpi {
|
||||||
|
ns_view.setWantsBestResolutionOpenGLSurface_(YES);
|
||||||
|
}
|
||||||
|
|
||||||
// On Mojave, views automatically become layer-backed shortly after being added to
|
// On Mojave, views automatically become layer-backed shortly after being added to
|
||||||
// a window. Changing the layer-backedness of a view breaks the association between
|
// a window. Changing the layer-backedness of a view breaks the association between
|
||||||
|
@ -301,10 +307,11 @@ impl UnownedWindow {
|
||||||
os_error!(OsError::CreationError("Couldn't create `NSWindow`"))
|
os_error!(OsError::CreationError("Couldn't create `NSWindow`"))
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let (ns_view, cursor) = unsafe { create_view(*ns_window) }.ok_or_else(|| {
|
let (ns_view, cursor) =
|
||||||
unsafe { pool.drain() };
|
unsafe { create_view(*ns_window, &pl_attribs) }.ok_or_else(|| {
|
||||||
os_error!(OsError::CreationError("Couldn't create `NSView`"))
|
unsafe { pool.drain() };
|
||||||
})?;
|
os_error!(OsError::CreationError("Couldn't create `NSView`"))
|
||||||
|
})?;
|
||||||
|
|
||||||
let input_context = unsafe { util::create_input_context(*ns_view) };
|
let input_context = unsafe { util::create_input_context(*ns_view) };
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue