add raw-window-handle impls

This commit is contained in:
Wez Furlong committed 2021-05-08 09:36:19 -07:00
1 parent 3d760653b4
commit c4e1f2434a
6 files changed
+63 -1

No files matched your search

Generated
+10
View File
@@ -3055,6 +3055,15 @@ dependencies = [
"parking_lot 0.9.0",
]
[[package]]
name = "raw-window-handle"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0a441a7a6c80ad6473bd4b74ec1c9a4c951794285bf941c2126f607c72e48211"
dependencies = [
"libc",
]
[[package]]
name = "rayon"
version = "1.5.0"
@@ -4686,6 +4695,7 @@ dependencies = [
"objc",
"pretty_env_logger",
"promise",
"raw-window-handle",
"resize",
"serde",
"shared_library",
+1
View File
@@ -30,6 +30,7 @@ line_drawing = "0.8"
log = "0.4"
metrics = { version="0.14", features=["std"]}
promise = { path = "../promise" }
raw-window-handle = "0.3"
resize = "0.5"
serde = {version="1.0", features = ["rc", "derive"]}
glium = { version = "0.28", default-features = false}
+15 -1
View File
@@ -30,6 +30,8 @@ use objc::rc::{StrongPtr, WeakPtr};
use objc::runtime::{Class, Object, Protocol, Sel};
use objc::*;
use promise::Future;
use raw_window_handle::macos::MacOSHandle;
use raw_window_handle::{HasRawWindowHandle, RawWindowHandle};
use std::any::Any;
use std::cell::RefCell;
use std::ffi::c_void;
@@ -416,7 +418,7 @@ impl Window {
// Prevent Cocoa native tabs from being used
let _: () = msg_send![*window, setTabbingMode:2 /* NSWindowTabbingModeDisallowed */];
let _: () = msg_send![*window, setRestorable:NO];
let _: () = msg_send![*window, setRestorable: NO];
window.setReleasedWhenClosed_(NO);
let ns_color: id = msg_send![Class::get("NSColor").unwrap(), alloc];
@@ -970,6 +972,18 @@ struct Inner {
config: ConfigHandle,
}
unsafe impl HasRawWindowHandle for Inner {
fn raw_window_handle(&self) -> RawWindowHandle {
let ns_window = self.window.as_ref().unwrap().load();
let ns_view = self.view_id.as_ref().unwrap().load();
RawWindowHandle::MacOS(MacOSHandle {
ns_window: *ns_window as *mut _,
ns_view: *ns_view as *mut _,
..MacOSHandle::empty()
})
}
}
#[repr(C)]
pub struct __InputSource {
_dummy: i32,
+14
View File
@@ -13,6 +13,8 @@ use async_trait::async_trait;
use config::ConfigHandle;
use filedescriptor::FileDescriptor;
use promise::{Future, Promise};
use raw_window_handle::unix::WaylandHandle;
use raw_window_handle::{HasRawWindowHandle, RawWindowHandle};
use smithay_client_toolkit as toolkit;
use std::any::Any;
use std::cell::RefCell;
@@ -274,6 +276,18 @@ impl WaylandWindow {
}
}
unsafe impl HasRawWindowHandle for WaylandWindowInner {
fn raw_window_handle(&self) -> RawWindowHandle {
let conn = WaylandConnection::get().unwrap().wayland();
let display = conn.display.borrow();
RawWindowHandle::Wayland(WaylandHandle {
surface: self.surface.as_ref().c_ptr() as *mut _,
display: display.c_ptr() as *mut _,
..WaylandHandle::empty()
})
}
}
impl WaylandWindowInner {
pub(crate) fn handle_keyboard_event(&mut self, evt: KeyboardEvent) {
match evt {
+11
View File
@@ -10,6 +10,8 @@ use async_trait::async_trait;
use config::ConfigHandle;
use lazy_static::lazy_static;
use promise::{Future, Promise};
use raw_window_handle::windows::WindowsHandle;
use raw_window_handle::{HasRawWindowHandle, RawWindowHandle};
use shared_library::shared_library;
use std::any::Any;
use std::cell::RefCell;
@@ -120,6 +122,15 @@ fn callback_behavior() -> glium::debug::DebugCallbackBehavior {
}
}
unsafe impl HasRawWindowHandle for WindowInner {
fn raw_window_handle(&self) -> RawWindowHandle {
RawWindowHandle::Windows(WindowsHandle {
hwnd: self.hwnd.0 as *mut _,
..WindowsHandle::empty()
})
}
}
impl WindowInner {
fn enable_opengl(&mut self) -> anyhow::Result<Rc<glium::backend::Context>> {
let conn = Connection::get().unwrap();
+12
View File
@@ -12,6 +12,8 @@ use anyhow::{anyhow, Context as _};
use async_trait::async_trait;
use config::ConfigHandle;
use promise::{Future, Promise};
use raw_window_handle::unix::XcbHandle;
use raw_window_handle::{HasRawWindowHandle, RawWindowHandle};
use std::any::Any;
use std::collections::VecDeque;
use std::convert::TryInto;
@@ -84,6 +86,16 @@ impl Drop for XWindowInner {
}
}
unsafe impl HasRawWindowHandle for XWindowInner {
fn raw_window_handle(&self) -> RawWindowHandle {
RawWindowHandle::Xcb(XcbHandle {
window: self.window_id,
connection: self.conn.upgrade().unwrap().get_raw_conn() as *mut _,
..XcbHandle::empty()
})
}
}
impl XWindowInner {
fn enable_opengl(&mut self) -> anyhow::Result<Rc<glium::backend::Context>> {
let conn = self.conn();