mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-25 06:41:31 +11:00
Merge pull request #23 from ozkriff/port_glutin_to_winit
Prepared winit for glutin porting
This commit is contained in:
commit
81e2037745
9
src/api/cocoa/mod.rs
Normal file → Executable file
9
src/api/cocoa/mod.rs
Normal file → Executable file
|
@ -11,22 +11,15 @@ use os::macos::ActivationPolicy;
|
||||||
use objc::runtime::{Class, Object, Sel, BOOL, YES, NO};
|
use objc::runtime::{Class, Object, Sel, BOOL, YES, NO};
|
||||||
use objc::declare::ClassDecl;
|
use objc::declare::ClassDecl;
|
||||||
|
|
||||||
use cgl::{CGLEnable, kCGLCECrashOnRemovedFunctions, CGLSetParameter, kCGLCPSurfaceOpacity};
|
|
||||||
|
|
||||||
use cocoa::base::{id, nil};
|
use cocoa::base::{id, nil};
|
||||||
use cocoa::foundation::{NSAutoreleasePool, NSDate, NSDefaultRunLoopMode, NSPoint, NSRect, NSSize,
|
use cocoa::foundation::{NSAutoreleasePool, NSDate, NSDefaultRunLoopMode, NSPoint, NSRect, NSSize,
|
||||||
NSString, NSUInteger};
|
NSString, NSUInteger};
|
||||||
use cocoa::appkit::{self, NSApplication, NSEvent, NSOpenGLContext, NSOpenGLPixelFormat, NSView, NSWindow};
|
use cocoa::appkit::{self, NSApplication, NSEvent, NSView, NSWindow};
|
||||||
|
|
||||||
use core_foundation::base::TCFType;
|
|
||||||
use core_foundation::string::CFString;
|
|
||||||
use core_foundation::bundle::{CFBundleGetBundleWithIdentifier, CFBundleGetFunctionPointerForName};
|
|
||||||
|
|
||||||
use core_graphics::display::{CGAssociateMouseAndMouseCursorPosition, CGMainDisplayID, CGDisplayPixelsHigh, CGWarpMouseCursorPosition};
|
use core_graphics::display::{CGAssociateMouseAndMouseCursorPosition, CGMainDisplayID, CGDisplayPixelsHigh, CGWarpMouseCursorPosition};
|
||||||
|
|
||||||
use std::ffi::CStr;
|
use std::ffi::CStr;
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
use std::str::FromStr;
|
|
||||||
use std::str::from_utf8;
|
use std::str::from_utf8;
|
||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
|
|
|
@ -717,6 +717,16 @@ impl Window {
|
||||||
self.x.display.display as *mut libc::c_void
|
self.x.display.display as *mut libc::c_void
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn get_xlib_screen_id(&self) -> *mut libc::c_void {
|
||||||
|
self.x.screen_id as *mut libc::c_void
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn get_xlib_xconnection(&self) -> Arc<XConnection> {
|
||||||
|
self.x.display.clone()
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn platform_display(&self) -> *mut libc::c_void {
|
pub fn platform_display(&self) -> *mut libc::c_void {
|
||||||
self.x.display.display as *mut libc::c_void
|
self.x.display.display as *mut libc::c_void
|
||||||
|
|
0
src/os/macos.rs
Normal file → Executable file
0
src/os/macos.rs
Normal file → Executable file
|
@ -1,13 +1,17 @@
|
||||||
#![cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "openbsd"))]
|
#![cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "openbsd"))]
|
||||||
|
|
||||||
|
use std::sync::Arc;
|
||||||
use libc;
|
use libc;
|
||||||
use Window;
|
use Window;
|
||||||
use platform::Window as LinuxWindow;
|
use platform::Window as LinuxWindow;
|
||||||
use WindowBuilder;
|
use WindowBuilder;
|
||||||
|
use api::x11::XConnection;
|
||||||
|
|
||||||
use wayland_client::protocol::wl_display::WlDisplay;
|
use wayland_client::protocol::wl_display::WlDisplay;
|
||||||
use wayland_client::protocol::wl_surface::WlSurface;
|
use wayland_client::protocol::wl_surface::WlSurface;
|
||||||
|
|
||||||
|
pub use api::x11;
|
||||||
|
|
||||||
/// Additional methods on `Window` that are specific to Unix.
|
/// Additional methods on `Window` that are specific to Unix.
|
||||||
pub trait WindowExt {
|
pub trait WindowExt {
|
||||||
/// Returns a pointer to the `Window` object of xlib that is used by this window.
|
/// Returns a pointer to the `Window` object of xlib that is used by this window.
|
||||||
|
@ -24,7 +28,10 @@ pub trait WindowExt {
|
||||||
/// The pointer will become invalid when the glutin `Window` is destroyed.
|
/// The pointer will become invalid when the glutin `Window` is destroyed.
|
||||||
fn get_xlib_display(&self) -> Option<*mut libc::c_void>;
|
fn get_xlib_display(&self) -> Option<*mut libc::c_void>;
|
||||||
|
|
||||||
///
|
fn get_xlib_screen_id(&self) -> Option<*mut libc::c_void>;
|
||||||
|
|
||||||
|
fn get_xlib_xconnection(&self) -> Option<Arc<XConnection>>;
|
||||||
|
|
||||||
/// This function returns the underlying `xcb_connection_t` of an xlib `Display`.
|
/// This function returns the underlying `xcb_connection_t` of an xlib `Display`.
|
||||||
///
|
///
|
||||||
/// Returns `None` if the window doesn't use xlib (if it uses wayland for example).
|
/// Returns `None` if the window doesn't use xlib (if it uses wayland for example).
|
||||||
|
@ -82,6 +89,20 @@ impl WindowExt for Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn get_xlib_screen_id(&self) -> Option<*mut libc::c_void> {
|
||||||
|
match self.window {
|
||||||
|
LinuxWindow::X(ref w) => Some(w.get_xlib_screen_id()),
|
||||||
|
_ => None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_xlib_xconnection(&self) -> Option<Arc<XConnection>> {
|
||||||
|
match self.window {
|
||||||
|
LinuxWindow::X(ref w) => Some(w.get_xlib_xconnection()),
|
||||||
|
_ => None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn get_xcb_connection(&self) -> Option<*mut libc::c_void> {
|
fn get_xcb_connection(&self) -> Option<*mut libc::c_void> {
|
||||||
match self.window {
|
match self.window {
|
||||||
LinuxWindow::X(ref w) => Some(w.get_xcb_connection()),
|
LinuxWindow::X(ref w) => Some(w.get_xcb_connection()),
|
||||||
|
|
Loading…
Reference in a new issue