Skip to content

Commit eb8a0ac

Browse files
committed
cleanup
1 parent 7138ea7 commit eb8a0ac

4 files changed

Lines changed: 10 additions & 21 deletions

File tree

src/platform/macos/context.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use crate::gl::GlContext;
21
use crate::platform::macos::cursor::Cursor;
32
use crate::platform::macos::view::BaseviewView;
43
use crate::wrappers::appkit::{View, ViewRef};
@@ -65,15 +64,15 @@ impl WindowContext {
6564
}
6665

6766
#[cfg(feature = "opengl")]
68-
pub fn gl_context(&self) -> Option<GlContext> {
69-
Some(GlContext::new(self.view.load()?.inner().gl_context.get()?.clone()))
67+
pub fn gl_context(&self) -> Option<crate::gl::GlContext> {
68+
Some(crate::gl::GlContext::new(self.view.load()?.inner().gl_context.get()?.clone()))
7069
}
7170

72-
pub fn window_handle(&self) -> Option<raw_window_handle::WindowHandle> {
71+
pub fn window_handle(&self) -> Option<raw_window_handle::WindowHandle<'_>> {
7372
View::window_handle_from_weak(&self.view)
7473
}
7574

76-
pub fn display_handle(&self) -> DisplayHandle {
75+
pub fn display_handle(&self) -> DisplayHandle<'_> {
7776
DisplayHandle::appkit()
7877
}
7978
}

src/platform/macos/window.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,16 @@ use std::cell::{Cell, RefCell};
22
use std::rc::Rc;
33

44
use objc2::rc::{autoreleasepool, Weak};
5-
use objc2::runtime::NSObjectProtocol;
65
use objc2::MainThreadMarker;
76
use objc2_app_kit::{
87
NSApplication, NSApplicationActivationPolicy, NSPasteboard, NSPasteboardTypeString,
98
};
109
use objc2_foundation::NSString;
11-
use raw_window_handle::{
12-
AppKitDisplayHandle, AppKitWindowHandle, HasRawDisplayHandle, HasRawWindowHandle,
13-
HasWindowHandle, RawDisplayHandle, RawWindowHandle,
14-
};
15-
16-
use super::cursor::Cursor;
17-
use crate::{MouseCursor, Size, WindowContext, WindowHandler, WindowInfo, WindowOpenOptions};
10+
use raw_window_handle::HasWindowHandle;
1811

19-
#[cfg(feature = "opengl")]
20-
use crate::gl::GlContext;
2112
use crate::platform::macos::view::{BaseviewView, ViewParentingType};
22-
use crate::wrappers::appkit::{create_window, extract_raw_window_handle, View, ViewRef};
13+
use crate::wrappers::appkit::{create_window, extract_raw_window_handle, View};
14+
use crate::{WindowContext, WindowHandler, WindowInfo, WindowOpenOptions};
2315

2416
pub struct WindowHandle {
2517
view: RefCell<Option<Weak<View<BaseviewView>>>>,

src/wrappers/appkit.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,5 @@ pub fn extract_raw_window_handle(handle: WindowHandle) -> Option<Retained<NSView
3131
panic!("Not a macOS window");
3232
};
3333

34-
let parent_view = unsafe { Retained::retain(handle.ns_view.as_ptr() as *mut NSView) };
35-
36-
parent_view
34+
unsafe { Retained::retain(handle.ns_view.as_ptr() as *mut NSView) }
3735
}

src/wrappers/appkit/view.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ impl<V: ViewImpl> View<V> {
8686
ViewRef { view: self, inner: self.inner() }
8787
}
8888

89-
pub fn window_handle_from_weak(this: &Weak<Self>) -> Option<WindowHandle> {
89+
pub fn window_handle_from_weak(this: &Weak<Self>) -> Option<WindowHandle<'_>> {
9090
let view = this.load()?;
91-
let ns_view = NonNull::from_ref(&view.parent).cast();
91+
let ns_view = NonNull::from(&view.parent).cast();
9292
let handle = AppKitWindowHandle::new(ns_view);
9393

9494
Some(unsafe { WindowHandle::borrow_raw(handle.into()) })

0 commit comments

Comments
 (0)