diff --git a/glutin/Cargo.toml b/glutin/Cargo.toml index 6be4f390ee..8706df188c 100644 --- a/glutin/Cargo.toml +++ b/glutin/Cargo.toml @@ -52,20 +52,24 @@ x11-dl = { version = "2.20.0", optional = true } [target.'cfg(any(target_os = "macos"))'.dependencies] cgl = "0.3.2" core-foundation = "0.9.3" -# Enable `relax-void-encoding` until https://github.com/madsmtm/objc2/pull/526 is resolved -objc2 = { version = "0.4.1", features = ["relax-void-encoding"] } +objc2 = "0.5.1" dispatch = "0.2.0" -[target.'cfg(any(target_os = "macos"))'.dependencies.icrate] -version = "0.0.4" +[target.'cfg(any(target_os = "macos"))'.dependencies.objc2-foundation] +version = "0.2.0" features = [ "dispatch", - "Foundation", - "Foundation_NSArray", - "Foundation_NSThread", - "AppKit", - "AppKit_NSView", - "AppKit_NSWindow", + "NSArray", + "NSThread", +] + +[target.'cfg(any(target_os = "macos"))'.dependencies.objc2-app-kit] +version = "0.2.0" +features = [ + "NSResponder", + "NSView", + "NSWindow", + "NSOpenGL", ] [build-dependencies] diff --git a/glutin/src/api/cgl/appkit.rs b/glutin/src/api/cgl/appkit.rs index 325f28c99d..5f4fbc99d6 100644 --- a/glutin/src/api/cgl/appkit.rs +++ b/glutin/src/api/cgl/appkit.rs @@ -1,13 +1,13 @@ -//! Parts of AppKit related to OpenGL that is not yet in `icrate`. +//! Parts of AppKit related to OpenGL that is not yet in `objc2-app-kit`. #![allow(dead_code)] #![allow(non_snake_case)] -#[allow(deprecated)] -use icrate::AppKit::{NSOpenGLContextParameter, NSOpenGLPixelFormatAttribute, NSView}; -use icrate::Foundation::{MainThreadMarker, NSObject}; use objc2::encode::{Encoding, RefEncode}; use objc2::rc::{Allocated, Id}; use objc2::{extern_class, extern_methods, mutability, ClassType}; +#[allow(deprecated)] +use objc2_app_kit::{NSOpenGLContextParameter, NSOpenGLPixelFormatAttribute, NSView}; +use objc2_foundation::{MainThreadMarker, NSObject}; pub type GLint = i32; @@ -42,7 +42,7 @@ extern_methods!( #[method_id(initWithFormat:shareContext:)] pub(crate) fn initWithFormat_shareContext( - this: Option>, + this: Allocated, format: &NSOpenGLPixelFormat, share: Option<&NSOpenGLContext>, ) -> Option>; @@ -97,7 +97,7 @@ extern_methods!( unsafe impl NSOpenGLPixelFormat { #[method_id(initWithAttributes:)] unsafe fn initWithAttributes( - this: Option>, + this: Allocated, attrs: *const NSOpenGLPixelFormatAttribute, ) -> Option>; diff --git a/glutin/src/api/cgl/config.rs b/glutin/src/api/cgl/config.rs index f1377039fa..08426def3c 100644 --- a/glutin/src/api/cgl/config.rs +++ b/glutin/src/api/cgl/config.rs @@ -3,8 +3,9 @@ use std::sync::Arc; use std::{fmt, iter}; +use objc2::rc::Id; #[allow(deprecated)] -use icrate::AppKit::{ +use objc2_app_kit::{ NSOpenGLPFAAccelerated, NSOpenGLPFAAllowOfflineRenderers, NSOpenGLPFAAlphaSize, NSOpenGLPFAColorFloat, NSOpenGLPFAColorSize, NSOpenGLPFADepthSize, NSOpenGLPFADoubleBuffer, NSOpenGLPFAMinimumPolicy, NSOpenGLPFAMultisample, NSOpenGLPFAOpenGLProfile, @@ -12,7 +13,6 @@ use icrate::AppKit::{ NSOpenGLPFATripleBuffer, NSOpenGLPixelFormatAttribute, NSOpenGLProfileVersion3_2Core, NSOpenGLProfileVersion4_1Core, NSOpenGLProfileVersionLegacy, }; -use objc2::rc::Id; use crate::config::{ Api, AsRawConfig, ColorBufferType, ConfigSurfaceTypes, ConfigTemplate, GlConfig, RawConfig, diff --git a/glutin/src/api/cgl/context.rs b/glutin/src/api/cgl/context.rs index 301ea00d8c..d5b16a9e5d 100644 --- a/glutin/src/api/cgl/context.rs +++ b/glutin/src/api/cgl/context.rs @@ -4,10 +4,10 @@ use std::fmt; use std::marker::PhantomData; use cgl::CGLSetParameter; -use icrate::AppKit::{NSOpenGLCPSwapInterval, NSView}; -use icrate::Foundation::{MainThreadBound, MainThreadMarker}; use objc2::rc::{autoreleasepool, Id}; use objc2::ClassType; +use objc2_app_kit::{NSOpenGLCPSwapInterval, NSView}; +use objc2_foundation::{run_on_main, MainThreadBound}; use crate::config::GetGlConfig; use crate::context::{AsRawContext, ContextApi, ContextAttributes, RawContext, Robustness}; @@ -224,7 +224,7 @@ impl ContextInner { self.raw.makeCurrentContext(); let view = &surface.ns_view; - MainThreadMarker::run_on_main(|mtm| unsafe { + run_on_main(|mtm| unsafe { self.raw.setView(Some(view.get(mtm))); }); @@ -248,7 +248,7 @@ impl ContextInner { } pub(crate) fn update(&self) { - MainThreadMarker::run_on_main(|_| self.raw.update()); + run_on_main(|_| self.raw.update()); } pub(crate) fn flush_buffer(&self) -> Result<()> { @@ -259,7 +259,7 @@ impl ContextInner { } pub(crate) fn is_view_current(&self, view: &MainThreadBound>) -> bool { - MainThreadMarker::run_on_main(|mtm| { + run_on_main(|mtm| { self.raw.view(mtm).expect("context to have a current view") == *view.get(mtm) }) } diff --git a/glutin/src/api/cgl/surface.rs b/glutin/src/api/cgl/surface.rs index 64d30d470d..39e90e8fe0 100644 --- a/glutin/src/api/cgl/surface.rs +++ b/glutin/src/api/cgl/surface.rs @@ -4,9 +4,9 @@ use std::fmt; use std::marker::PhantomData; use std::num::NonZeroU32; -use icrate::AppKit::{NSView, NSWindow}; -use icrate::Foundation::{MainThreadBound, MainThreadMarker}; use objc2::rc::Id; +use objc2_app_kit::{NSView, NSWindow}; +use objc2_foundation::{run_on_main, MainThreadBound, MainThreadMarker}; use raw_window_handle::RawWindowHandle; use crate::config::GetGlConfig; @@ -112,7 +112,7 @@ impl GlSurface for Surface { fn width(&self) -> Option { let window = &self.ns_window; let view = &self.ns_view; - MainThreadMarker::run_on_main(|mtm| unsafe { + run_on_main(|mtm| { let scale_factor = window.get(mtm).backingScaleFactor(); let frame = view.get(mtm).frame(); Some((frame.size.width * scale_factor) as u32) @@ -122,7 +122,7 @@ impl GlSurface for Surface { fn height(&self) -> Option { let window = &self.ns_window; let view = &self.ns_view; - MainThreadMarker::run_on_main(|mtm| unsafe { + run_on_main(|mtm| { let scale_factor = window.get(mtm).backingScaleFactor(); let frame = view.get(mtm).frame(); Some((frame.size.height * scale_factor) as u32)