Refine function names and type signatures (#886)

* First name consistency pass. More to come!

* Remove multitouch variable (hopefully this compiles!)

* Remove CreationError::NotSupported

* Add new error handling types

* Remove `get_` prefix from getters.

This is as per the Rust naming conventions recommended in
https://rust-lang-nursery.github.io/api-guidelines/naming.html#getter-names-follow-rust-convention-c-getter

* Make changes to Window position and size function signatures

* Remove CreationError in favor of OsError

* Begin updating iOS backend

* Change MonitorHandle::outer_position to just position

* Fix build on Windows and Linux

* Add Display and Error implementations to Error types

* Attempt to fix iOS build.

I can't actually check that this works since I can't cross-compile to
iOS on a Windows machine (thanks apple :/) but this should be one of
several commits to get it working.

* Attempt to fix iOS errors, and muck up Travis to make debugging easier

* More iOS fixins

* Add Debug and Display impls to OsError

* Fix Display impl

* Fix unused code warnings and travis

* Rename set_ime_spot to set_ime_position

* Add CHANGELOG entry

* Rename set_cursor to set_cursor_icon and MouseCursor to CursorIcon

* Organize Window functions into multiple, categorized impls

* Improve clarity of function ordering and docs in EventLoop
This commit is contained in:
Osspial 2019-05-29 21:29:54 -04:00 committed by GitHub
parent ae63fbdbbb
commit 0df436901a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
53 changed files with 1249 additions and 1250 deletions

View file

@ -61,13 +61,13 @@ impl<T> EventLoop<T> {
}
#[inline]
pub fn get_available_monitors(&self) -> VecDeque<MonitorHandle> {
monitor::get_available_monitors()
pub fn available_monitors(&self) -> VecDeque<MonitorHandle> {
monitor::available_monitors()
}
#[inline]
pub fn get_primary_monitor(&self) -> MonitorHandle {
monitor::get_primary_monitor()
pub fn primary_monitor(&self) -> MonitorHandle {
monitor::primary_monitor()
}
pub fn window_target(&self) -> &RootWindowTarget<T> {

View file

@ -13,10 +13,11 @@ mod view;
mod window;
mod window_delegate;
use std::{ops::Deref, sync::Arc};
use std::{fmt, ops::Deref, sync::Arc};
use {
event::DeviceId as RootDeviceId, window::{CreationError, WindowAttributes},
event::DeviceId as RootDeviceId, window::WindowAttributes,
error::OsError as RootOsError,
};
pub use self::{
event_loop::{EventLoop, EventLoopWindowTarget, Proxy as EventLoopProxy},
@ -44,6 +45,12 @@ pub struct Window {
_delegate: util::IdRef,
}
#[derive(Debug)]
pub enum OsError {
CGError(core_graphics::base::CGError),
CreationError(&'static str)
}
unsafe impl Send for Window {}
unsafe impl Sync for Window {}
@ -60,8 +67,17 @@ impl Window {
_window_target: &EventLoopWindowTarget<T>,
attributes: WindowAttributes,
pl_attribs: PlatformSpecificWindowBuilderAttributes,
) -> Result<Self, CreationError> {
) -> Result<Self, RootOsError> {
let (window, _delegate) = UnownedWindow::new(attributes, pl_attribs)?;
Ok(Window { window, _delegate })
}
}
impl fmt::Display for OsError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
OsError::CGError(e) => f.pad(&format!("CGError {}", e)),
OsError::CreationError(e) => f.pad(e),
}
}
}

View file

@ -9,7 +9,7 @@ use platform_impl::platform::util::IdRef;
#[derive(Clone, PartialEq)]
pub struct MonitorHandle(CGDirectDisplayID);
pub fn get_available_monitors() -> VecDeque<MonitorHandle> {
pub fn available_monitors() -> VecDeque<MonitorHandle> {
if let Ok(displays) = CGDisplay::active_displays() {
let mut monitors = VecDeque::with_capacity(displays.len());
for display in displays {
@ -21,7 +21,7 @@ pub fn get_available_monitors() -> VecDeque<MonitorHandle> {
}
}
pub fn get_primary_monitor() -> MonitorHandle {
pub fn primary_monitor() -> MonitorHandle {
MonitorHandle(CGDisplay::main().id)
}
@ -38,11 +38,11 @@ impl fmt::Debug for MonitorHandle {
}
let monitor_id_proxy = MonitorHandle {
name: self.get_name(),
native_identifier: self.get_native_identifier(),
dimensions: self.get_dimensions(),
position: self.get_position(),
hidpi_factor: self.get_hidpi_factor(),
name: self.name(),
native_identifier: self.native_identifier(),
dimensions: self.dimensions(),
position: self.position(),
hidpi_factor: self.hidpi_factor(),
};
monitor_id_proxy.fmt(f)
@ -54,48 +54,48 @@ impl MonitorHandle {
MonitorHandle(id)
}
pub fn get_name(&self) -> Option<String> {
pub fn name(&self) -> Option<String> {
let MonitorHandle(display_id) = *self;
let screen_num = CGDisplay::new(display_id).model_number();
Some(format!("Monitor #{}", screen_num))
}
#[inline]
pub fn get_native_identifier(&self) -> u32 {
pub fn native_identifier(&self) -> u32 {
self.0
}
pub fn get_dimensions(&self) -> PhysicalSize {
pub fn dimensions(&self) -> PhysicalSize {
let MonitorHandle(display_id) = *self;
let display = CGDisplay::new(display_id);
let height = display.pixels_high();
let width = display.pixels_wide();
PhysicalSize::from_logical(
(width as f64, height as f64),
self.get_hidpi_factor(),
self.hidpi_factor(),
)
}
#[inline]
pub fn get_position(&self) -> PhysicalPosition {
let bounds = unsafe { CGDisplayBounds(self.get_native_identifier()) };
pub fn position(&self) -> PhysicalPosition {
let bounds = unsafe { CGDisplayBounds(self.native_identifier()) };
PhysicalPosition::from_logical(
(bounds.origin.x as f64, bounds.origin.y as f64),
self.get_hidpi_factor(),
self.hidpi_factor(),
)
}
pub fn get_hidpi_factor(&self) -> f64 {
let screen = match self.get_nsscreen() {
pub fn hidpi_factor(&self) -> f64 {
let screen = match self.nsscreen() {
Some(screen) => screen,
None => return 1.0, // default to 1.0 when we can't find the screen
};
unsafe { NSScreen::backingScaleFactor(screen) as f64 }
}
pub(crate) fn get_nsscreen(&self) -> Option<id> {
pub(crate) fn nsscreen(&self) -> Option<id> {
unsafe {
let native_id = self.get_native_identifier();
let native_id = self.native_identifier();
let screens = NSScreen::screens(nil);
let count: NSUInteger = msg_send![screens, count];
let key = IdRef::new(NSString::alloc(nil).init_str("NSScreenNumber"));

View file

@ -4,7 +4,7 @@ use cocoa::{
};
use objc::runtime::Sel;
use window::MouseCursor;
use window::CursorIcon;
pub enum Cursor {
Native(&'static str),
@ -12,54 +12,54 @@ pub enum Cursor {
WebKit(&'static str),
}
impl From<MouseCursor> for Cursor {
fn from(cursor: MouseCursor) -> Self {
impl From<CursorIcon> for Cursor {
fn from(cursor: CursorIcon) -> Self {
match cursor {
MouseCursor::Arrow | MouseCursor::Default => Cursor::Native("arrowCursor"),
MouseCursor::Hand => Cursor::Native("pointingHandCursor"),
MouseCursor::Grabbing | MouseCursor::Grab => Cursor::Native("closedHandCursor"),
MouseCursor::Text => Cursor::Native("IBeamCursor"),
MouseCursor::VerticalText => Cursor::Native("IBeamCursorForVerticalLayout"),
MouseCursor::Copy => Cursor::Native("dragCopyCursor"),
MouseCursor::Alias => Cursor::Native("dragLinkCursor"),
MouseCursor::NotAllowed | MouseCursor::NoDrop => Cursor::Native("operationNotAllowedCursor"),
MouseCursor::ContextMenu => Cursor::Native("contextualMenuCursor"),
MouseCursor::Crosshair => Cursor::Native("crosshairCursor"),
MouseCursor::EResize => Cursor::Native("resizeRightCursor"),
MouseCursor::NResize => Cursor::Native("resizeUpCursor"),
MouseCursor::WResize => Cursor::Native("resizeLeftCursor"),
MouseCursor::SResize => Cursor::Native("resizeDownCursor"),
MouseCursor::EwResize | MouseCursor::ColResize => Cursor::Native("resizeLeftRightCursor"),
MouseCursor::NsResize | MouseCursor::RowResize => Cursor::Native("resizeUpDownCursor"),
CursorIcon::Arrow | CursorIcon::Default => Cursor::Native("arrowCursor"),
CursorIcon::Hand => Cursor::Native("pointingHandCursor"),
CursorIcon::Grabbing | CursorIcon::Grab => Cursor::Native("closedHandCursor"),
CursorIcon::Text => Cursor::Native("IBeamCursor"),
CursorIcon::VerticalText => Cursor::Native("IBeamCursorForVerticalLayout"),
CursorIcon::Copy => Cursor::Native("dragCopyCursor"),
CursorIcon::Alias => Cursor::Native("dragLinkCursor"),
CursorIcon::NotAllowed | CursorIcon::NoDrop => Cursor::Native("operationNotAllowedCursor"),
CursorIcon::ContextMenu => Cursor::Native("contextualMenuCursor"),
CursorIcon::Crosshair => Cursor::Native("crosshairCursor"),
CursorIcon::EResize => Cursor::Native("resizeRightCursor"),
CursorIcon::NResize => Cursor::Native("resizeUpCursor"),
CursorIcon::WResize => Cursor::Native("resizeLeftCursor"),
CursorIcon::SResize => Cursor::Native("resizeDownCursor"),
CursorIcon::EwResize | CursorIcon::ColResize => Cursor::Native("resizeLeftRightCursor"),
CursorIcon::NsResize | CursorIcon::RowResize => Cursor::Native("resizeUpDownCursor"),
// Undocumented cursors: https://stackoverflow.com/a/46635398/5435443
MouseCursor::Help => Cursor::Undocumented("_helpCursor"),
MouseCursor::ZoomIn => Cursor::Undocumented("_zoomInCursor"),
MouseCursor::ZoomOut => Cursor::Undocumented("_zoomOutCursor"),
MouseCursor::NeResize => Cursor::Undocumented("_windowResizeNorthEastCursor"),
MouseCursor::NwResize => Cursor::Undocumented("_windowResizeNorthWestCursor"),
MouseCursor::SeResize => Cursor::Undocumented("_windowResizeSouthEastCursor"),
MouseCursor::SwResize => Cursor::Undocumented("_windowResizeSouthWestCursor"),
MouseCursor::NeswResize => Cursor::Undocumented("_windowResizeNorthEastSouthWestCursor"),
MouseCursor::NwseResize => Cursor::Undocumented("_windowResizeNorthWestSouthEastCursor"),
CursorIcon::Help => Cursor::Undocumented("_helpCursor"),
CursorIcon::ZoomIn => Cursor::Undocumented("_zoomInCursor"),
CursorIcon::ZoomOut => Cursor::Undocumented("_zoomOutCursor"),
CursorIcon::NeResize => Cursor::Undocumented("_windowResizeNorthEastCursor"),
CursorIcon::NwResize => Cursor::Undocumented("_windowResizeNorthWestCursor"),
CursorIcon::SeResize => Cursor::Undocumented("_windowResizeSouthEastCursor"),
CursorIcon::SwResize => Cursor::Undocumented("_windowResizeSouthWestCursor"),
CursorIcon::NeswResize => Cursor::Undocumented("_windowResizeNorthEastSouthWestCursor"),
CursorIcon::NwseResize => Cursor::Undocumented("_windowResizeNorthWestSouthEastCursor"),
// While these are available, the former just loads a white arrow,
// and the latter loads an ugly deflated beachball!
// MouseCursor::Move => Cursor::Undocumented("_moveCursor"),
// MouseCursor::Wait => Cursor::Undocumented("_waitCursor"),
// CursorIcon::Move => Cursor::Undocumented("_moveCursor"),
// CursorIcon::Wait => Cursor::Undocumented("_waitCursor"),
// An even more undocumented cursor...
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=522349
// This is the wrong semantics for `Wait`, but it's the same as
// what's used in Safari and Chrome.
MouseCursor::Wait | MouseCursor::Progress => Cursor::Undocumented("busyButClickableCursor"),
CursorIcon::Wait | CursorIcon::Progress => Cursor::Undocumented("busyButClickableCursor"),
// For the rest, we can just snatch the cursors from WebKit...
// They fit the style of the native cursors, and will seem
// completely standard to macOS users.
// https://stackoverflow.com/a/21786835/5435443
MouseCursor::Move | MouseCursor::AllScroll => Cursor::WebKit("move"),
MouseCursor::Cell => Cursor::WebKit("cell"),
CursorIcon::Move | CursorIcon::AllScroll => Cursor::WebKit("move"),
CursorIcon::Cell => Cursor::WebKit("cell"),
}
}
}

View file

@ -58,7 +58,7 @@ pub fn new_view(nswindow: id) -> (IdRef, Weak<Mutex<util::Cursor>>) {
}
}
pub unsafe fn set_ime_spot(nsview: id, input_context: id, x: f64, y: f64) {
pub unsafe fn set_ime_position(nsview: id, input_context: id, x: f64, y: f64) {
let state_ptr: *mut c_void = *(*nsview).get_mut_ivar("winitState");
let state = &mut *(state_ptr as *mut ViewState);
let content_rect = NSWindow::contentRectForFrameRect_(

View file

@ -17,13 +17,15 @@ use objc::{runtime::{Class, Object, Sel, BOOL, YES, NO}, declare::ClassDecl};
use {
dpi::{LogicalPosition, LogicalSize}, icon::Icon,
error::{ExternalError, NotSupportedError, OsError as RootOsError},
monitor::MonitorHandle as RootMonitorHandle,
window::{
CreationError, MouseCursor, WindowAttributes, WindowId as RootWindowId,
CursorIcon, WindowAttributes, WindowId as RootWindowId,
},
};
use platform::macos::{ActivationPolicy, WindowExtMacOS};
use platform_impl::platform::{
OsError,
app_state::AppState, ffi, monitor::{self, MonitorHandle},
util::{self, IdRef}, view::{self, new_view},
window_delegate::new_delegate,
@ -102,7 +104,7 @@ fn create_window(
let pool = NSAutoreleasePool::new(nil);
let screen = match attrs.fullscreen {
Some(ref monitor_id) => {
let monitor_screen = monitor_id.inner.get_nsscreen();
let monitor_screen = monitor_id.inner.nsscreen();
Some(monitor_screen.unwrap_or(appkit::NSScreen::mainScreen(nil)))
},
_ => None,
@ -110,7 +112,7 @@ fn create_window(
let frame = match screen {
Some(screen) => appkit::NSScreen::frame(screen),
None => {
let (width, height) = attrs.dimensions
let (width, height) = attrs.inner_size
.map(|logical| (logical.width, logical.height))
.unwrap_or_else(|| (800.0, 600.0));
NSRect::new(NSPoint::new(0.0, 0.0), NSSize::new(width, height))
@ -245,7 +247,7 @@ pub struct UnownedWindow {
pub shared_state: Arc<Mutex<SharedState>>,
decorations: AtomicBool,
cursor: Weak<Mutex<util::Cursor>>,
cursor_hidden: AtomicBool,
cursor_visible: AtomicBool,
}
unsafe impl Send for UnownedWindow {}
@ -255,7 +257,7 @@ impl UnownedWindow {
pub fn new(
mut win_attribs: WindowAttributes,
pl_attribs: PlatformSpecificWindowBuilderAttributes,
) -> Result<(Arc<Self>, IdRef), CreationError> {
) -> Result<(Arc<Self>, IdRef), RootOsError> {
unsafe {
if !msg_send![class!(NSThread), isMainThread] {
panic!("Windows can only be created on the main thread on macOS");
@ -266,17 +268,17 @@ impl UnownedWindow {
let nsapp = create_app(pl_attribs.activation_policy).ok_or_else(|| {
unsafe { pool.drain() };
CreationError::OsError(format!("Couldn't create `NSApplication`"))
os_error!(OsError::CreationError("Couldn't create `NSApplication`"))
})?;
let nswindow = create_window(&win_attribs, &pl_attribs).ok_or_else(|| {
unsafe { pool.drain() };
CreationError::OsError(format!("Couldn't create `NSWindow`"))
os_error!(OsError::CreationError("Couldn't create `NSWindow`"))
})?;
let (nsview, cursor) = unsafe { create_view(*nswindow) }.ok_or_else(|| {
unsafe { pool.drain() };
CreationError::OsError(format!("Couldn't create `NSView`"))
os_error!(OsError::CreationError("Couldn't create `NSView`"))
})?;
let input_context = unsafe { util::create_input_context(*nsview) };
@ -289,8 +291,8 @@ impl UnownedWindow {
nsapp.activateIgnoringOtherApps_(YES);
win_attribs.min_dimensions.map(|dim| set_min_dimensions(*nswindow, dim));
win_attribs.max_dimensions.map(|dim| set_max_dimensions(*nswindow, dim));
win_attribs.min_inner_size.map(|dim| set_min_inner_size(*nswindow, dim));
win_attribs.max_inner_size.map(|dim| set_max_inner_size(*nswindow, dim));
use cocoa::foundation::NSArray;
// register for drag and drop operations.
@ -317,14 +319,14 @@ impl UnownedWindow {
shared_state: Arc::new(Mutex::new(win_attribs.into())),
decorations: AtomicBool::new(decorations),
cursor,
cursor_hidden: Default::default(),
cursor_visible: AtomicBool::new(true),
});
let delegate = new_delegate(&window, fullscreen.is_some());
// Set fullscreen mode after we setup everything
if let Some(monitor) = fullscreen {
if monitor.inner != window.get_current_monitor().inner {
if monitor.inner != window.current_monitor().inner {
// To do this with native fullscreen, we probably need to
// warp the window... while we could use
// `enterFullScreenMode`, they're idiomatically different
@ -381,42 +383,39 @@ impl UnownedWindow {
}
}
#[inline]
pub fn show(&self) {
unsafe { util::make_key_and_order_front_async(*self.nswindow) };
}
#[inline]
pub fn hide(&self) {
unsafe { util::order_out_async(*self.nswindow) };
pub fn set_visible(&self, visible: bool) {
match visible {
true => unsafe { util::make_key_and_order_front_async(*self.nswindow) },
false => unsafe { util::order_out_async(*self.nswindow) },
}
}
pub fn request_redraw(&self) {
AppState::queue_redraw(RootWindowId(self.id()));
}
pub fn get_position(&self) -> Option<LogicalPosition> {
pub fn outer_position(&self) -> Result<LogicalPosition, NotSupportedError> {
let frame_rect = unsafe { NSWindow::frame(*self.nswindow) };
Some((
Ok((
frame_rect.origin.x as f64,
util::bottom_left_to_top_left(frame_rect),
).into())
}
pub fn get_inner_position(&self) -> Option<LogicalPosition> {
pub fn inner_position(&self) -> Result<LogicalPosition, NotSupportedError> {
let content_rect = unsafe {
NSWindow::contentRectForFrameRect_(
*self.nswindow,
NSWindow::frame(*self.nswindow),
)
};
Some((
Ok((
content_rect.origin.x as f64,
util::bottom_left_to_top_left(content_rect),
).into())
}
pub fn set_position(&self, position: LogicalPosition) {
pub fn set_outer_position(&self, position: LogicalPosition) {
let dummy = NSRect::new(
NSPoint::new(
position.x,
@ -432,15 +431,15 @@ impl UnownedWindow {
}
#[inline]
pub fn get_inner_size(&self) -> Option<LogicalSize> {
pub fn inner_size(&self) -> LogicalSize {
let view_frame = unsafe { NSView::frame(*self.nsview) };
Some((view_frame.size.width as f64, view_frame.size.height as f64).into())
(view_frame.size.width as f64, view_frame.size.height as f64).into()
}
#[inline]
pub fn get_outer_size(&self) -> Option<LogicalSize> {
pub fn outer_size(&self) -> LogicalSize {
let view_frame = unsafe { NSWindow::frame(*self.nswindow) };
Some((view_frame.size.width as f64, view_frame.size.height as f64).into())
(view_frame.size.width as f64, view_frame.size.height as f64).into()
}
#[inline]
@ -450,17 +449,17 @@ impl UnownedWindow {
}
}
pub fn set_min_dimensions(&self, dimensions: Option<LogicalSize>) {
pub fn set_min_inner_size(&self, dimensions: Option<LogicalSize>) {
unsafe {
let dimensions = dimensions.unwrap_or_else(|| (0, 0).into());
set_min_dimensions(*self.nswindow, dimensions);
set_min_inner_size(*self.nswindow, dimensions);
}
}
pub fn set_max_dimensions(&self, dimensions: Option<LogicalSize>) {
pub fn set_max_inner_size(&self, dimensions: Option<LogicalSize>) {
unsafe {
let dimensions = dimensions.unwrap_or_else(|| (!0, !0).into());
set_max_dimensions(*self.nswindow, dimensions);
set_max_inner_size(*self.nswindow, dimensions);
}
}
@ -484,7 +483,7 @@ impl UnownedWindow {
} // Otherwise, we don't change the mask until we exit fullscreen.
}
pub fn set_cursor(&self, cursor: MouseCursor) {
pub fn set_cursor_icon(&self, cursor: CursorIcon) {
let cursor = util::Cursor::from(cursor);
if let Some(cursor_access) = self.cursor.upgrade() {
*cursor_access.lock().unwrap() = cursor;
@ -497,44 +496,43 @@ impl UnownedWindow {
}
#[inline]
pub fn grab_cursor(&self, grab: bool) -> Result<(), String> {
pub fn set_cursor_grab(&self, grab: bool) -> Result<(), ExternalError> {
// TODO: Do this for real https://stackoverflow.com/a/40922095/5435443
CGDisplay::associate_mouse_and_mouse_cursor_position(!grab)
.map_err(|status| format!("Failed to grab cursor: `CGError` {:?}", status))
.map_err(|status| ExternalError::Os(os_error!(OsError::CGError(status))))
}
#[inline]
pub fn hide_cursor(&self, hide: bool) {
pub fn set_cursor_visible(&self, visible: bool) {
let cursor_class = class!(NSCursor);
// macOS uses a "hide counter" like Windows does, so we avoid incrementing it more than once.
// (otherwise, `hide_cursor(false)` would need to be called n times!)
if hide != self.cursor_hidden.load(Ordering::Acquire) {
if hide {
let _: () = unsafe { msg_send![cursor_class, hide] };
} else {
if visible != self.cursor_visible.load(Ordering::Acquire) {
if visible {
let _: () = unsafe { msg_send![cursor_class, unhide] };
} else {
let _: () = unsafe { msg_send![cursor_class, hide] };
}
self.cursor_hidden.store(hide, Ordering::Release);
self.cursor_visible.store(visible, Ordering::Release);
}
}
#[inline]
pub fn get_hidpi_factor(&self) -> f64 {
pub fn hidpi_factor(&self) -> f64 {
unsafe { NSWindow::backingScaleFactor(*self.nswindow) as _ }
}
#[inline]
pub fn set_cursor_position(&self, cursor_position: LogicalPosition) -> Result<(), String> {
let window_position = self.get_inner_position()
.ok_or("`get_inner_position` failed".to_owned())?;
pub fn set_cursor_position(&self, cursor_position: LogicalPosition) -> Result<(), ExternalError> {
let window_position = self.inner_position().unwrap();
let point = appkit::CGPoint {
x: (cursor_position.x + window_position.x) as CGFloat,
y: (cursor_position.y + window_position.y) as CGFloat,
};
CGDisplay::warp_mouse_cursor_position(point)
.map_err(|e| format!("`CGWarpMouseCursorPosition` failed: {:?}", e))?;
.map_err(|e| ExternalError::Os(os_error!(OsError::CGError(e))))?;
CGDisplay::associate_mouse_and_mouse_cursor_position(true)
.map_err(|e| format!("`CGAssociateMouseAndMouseCursorPosition` failed: {:?}", e))?;
.map_err(|e| ExternalError::Os(os_error!(OsError::CGError(e))))?;
Ok(())
}
@ -637,7 +635,7 @@ impl UnownedWindow {
}
#[inline]
pub fn get_fullscreen(&self) -> Option<RootMonitorHandle> {
pub fn fullscreen(&self) -> Option<RootMonitorHandle> {
let shared_state_lock = self.shared_state.lock().unwrap();
shared_state_lock.fullscreen.clone()
}
@ -736,9 +734,9 @@ impl UnownedWindow {
}
#[inline]
pub fn set_ime_spot(&self, logical_spot: LogicalPosition) {
pub fn set_ime_position(&self, logical_spot: LogicalPosition) {
unsafe {
view::set_ime_spot(
view::set_ime_position(
*self.nsview,
*self.input_context,
logical_spot.x,
@ -748,7 +746,7 @@ impl UnownedWindow {
}
#[inline]
pub fn get_current_monitor(&self) -> RootMonitorHandle {
pub fn current_monitor(&self) -> RootMonitorHandle {
unsafe {
let screen: id = msg_send![*self.nswindow, screen];
let desc = NSScreen::deviceDescription(screen);
@ -760,24 +758,24 @@ impl UnownedWindow {
}
#[inline]
pub fn get_available_monitors(&self) -> VecDeque<MonitorHandle> {
monitor::get_available_monitors()
pub fn available_monitors(&self) -> VecDeque<MonitorHandle> {
monitor::available_monitors()
}
#[inline]
pub fn get_primary_monitor(&self) -> MonitorHandle {
monitor::get_primary_monitor()
pub fn primary_monitor(&self) -> MonitorHandle {
monitor::primary_monitor()
}
}
impl WindowExtMacOS for UnownedWindow {
#[inline]
fn get_nswindow(&self) -> *mut c_void {
fn nswindow(&self) -> *mut c_void {
*self.nswindow as *mut _
}
#[inline]
fn get_nsview(&self) -> *mut c_void {
fn nsview(&self) -> *mut c_void {
*self.nsview as *mut _
}
@ -792,7 +790,7 @@ impl WindowExtMacOS for UnownedWindow {
}
#[inline]
fn get_simple_fullscreen(&self) -> bool {
fn simple_fullscreen(&self) -> bool {
let shared_state_lock = self.shared_state.lock().unwrap();
shared_state_lock.is_simple_fullscreen
}
@ -869,7 +867,7 @@ impl Drop for UnownedWindow {
}
}
unsafe fn set_min_dimensions<V: NSWindow + Copy>(window: V, mut min_size: LogicalSize) {
unsafe fn set_min_inner_size<V: NSWindow + Copy>(window: V, mut min_size: LogicalSize) {
let mut current_rect = NSWindow::frame(window);
let content_rect = NSWindow::contentRectForFrameRect_(window, NSWindow::frame(window));
// Convert from client area size to window size
@ -893,7 +891,7 @@ unsafe fn set_min_dimensions<V: NSWindow + Copy>(window: V, mut min_size: Logica
}
}
unsafe fn set_max_dimensions<V: NSWindow + Copy>(window: V, mut max_size: LogicalSize) {
unsafe fn set_max_inner_size<V: NSWindow + Copy>(window: V, mut max_size: LogicalSize) {
let mut current_rect = NSWindow::frame(window);
let content_rect = NSWindow::contentRectForFrameRect_(window, NSWindow::frame(window));
// Convert from client area size to window size

View file

@ -37,7 +37,7 @@ impl WindowDelegateState {
window: &Arc<UnownedWindow>,
initial_fullscreen: bool,
) -> Self {
let dpi_factor = window.get_hidpi_factor();
let dpi_factor = window.hidpi_factor();
let mut delegate_state = WindowDelegateState {
nswindow: window.nswindow.clone(),
@ -408,7 +408,7 @@ extern fn window_did_enter_fullscreen(this: &Object, _: Sel, _: id) {
trace!("Triggered `windowDidEnterFullscreen:`");
with_state(this, |state| {
state.with_window(|window| {
let monitor = window.get_current_monitor();
let monitor = window.current_monitor();
trace!("Locked shared state in `window_did_enter_fullscreen`");
window.shared_state.lock().unwrap().fullscreen = Some(monitor);
trace!("Unlocked shared state in `window_will_enter_fullscreen`");