impl raw window handle on Window
This commit is contained in:
1 parent
c4e1f2434a
commit
f4939c510b
5 files changed
+57
No files matched your search
@@ -495,6 +495,16 @@ impl Window {
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl HasRawWindowHandle for WindowInner {
|
||||
fn raw_window_handle(&self) -> RawWindowHandle {
|
||||
let conn = Connection::get().expect("raw_window_handle only callable on main thread");
|
||||
let handle = conn.window_by_id(self.0).expect("window handle invalid!?");
|
||||
|
||||
let inner = handle.borrow();
|
||||
inner.raw_window_handle()
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait(?Send)]
|
||||
impl WindowOps for Window {
|
||||
async fn enable_opengl(&self) -> anyhow::Result<Rc<glium::backend::Context>> {
|
||||
|
||||
@@ -601,6 +601,19 @@ impl WaylandWindowInner {
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl HasRawWindowHandle for WaylandWindow {
|
||||
fn raw_window_handle(&self) -> RawWindowHandle {
|
||||
let conn = Connection::get().expect("raw_window_handle only callable on main thread");
|
||||
let handle = conn
|
||||
.wayland()
|
||||
.window_by_id(self.0)
|
||||
.expect("window handle invalid!?");
|
||||
|
||||
let inner = handle.borrow();
|
||||
inner.raw_window_handle()
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait(?Send)]
|
||||
impl WindowOps for WaylandWindow {
|
||||
async fn enable_opengl(&self) -> anyhow::Result<Rc<glium::backend::Context>> {
|
||||
|
||||
@@ -549,6 +549,16 @@ impl WindowInner {
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl HasRawWindowHandle for WindowInner {
|
||||
fn raw_window_handle(&self) -> RawWindowHandle {
|
||||
let conn = Connection::get().expect("raw_window_handle only callable on main thread");
|
||||
let handle = conn.get_window(self.0).expect("window handle invalid!?");
|
||||
|
||||
let inner = handle.borrow();
|
||||
inner.raw_window_handle()
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait(?Send)]
|
||||
impl WindowOps for Window {
|
||||
async fn enable_opengl(&self) -> anyhow::Result<Rc<glium::backend::Context>> {
|
||||
|
||||
@@ -898,6 +898,19 @@ impl XWindowInner {
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl HasRawWindowHandle for XWindow {
|
||||
fn raw_window_handle(&self) -> RawWindowHandle {
|
||||
let conn = Connection::get().expect("raw_window_handle only callable on main thread");
|
||||
let handle = conn
|
||||
.x11()
|
||||
.window_by_id(self.0)
|
||||
.expect("window handle invalid!?");
|
||||
|
||||
let inner = handle.lock().unwrap();
|
||||
inner.raw_window_handle()
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait(?Send)]
|
||||
impl WindowOps for XWindow {
|
||||
async fn enable_opengl(&self) -> anyhow::Result<Rc<glium::backend::Context>> {
|
||||
|
||||
@@ -11,6 +11,7 @@ use crate::{Clipboard, Dimensions, MouseCursor, ScreenPoint, WindowEventReceiver
|
||||
use async_trait::async_trait;
|
||||
use config::ConfigHandle;
|
||||
use promise::*;
|
||||
use raw_window_handle::{HasRawWindowHandle, RawWindowHandle};
|
||||
use std::any::Any;
|
||||
use std::rc::Rc;
|
||||
|
||||
@@ -120,6 +121,16 @@ impl Window {
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl HasRawWindowHandle for Window {
|
||||
fn raw_window_handle(&self) -> RawWindowHandle {
|
||||
match self {
|
||||
Self::X11(x) => x.raw_window_handle(),
|
||||
#[cfg(feature = "wayland")]
|
||||
Self::Wayland(w) => w.raw_window_handle(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait(?Send)]
|
||||
impl WindowOps for Window {
|
||||
async fn enable_opengl(&self) -> anyhow::Result<Rc<glium::backend::Context>> {
|
||||
|
||||
Reference in new issue
Block a user