1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-22 22:42:48 +03:00

maybe fixup build for wgpu 0.19 on macos and windows

This commit is contained in:
Wez Furlong 2024-01-20 12:55:33 -07:00
parent 6938701cd3
commit 6fd45c1223
No known key found for this signature in database
GPG Key ID: 7A7F66A31EC9B387
2 changed files with 38 additions and 26 deletions

View File

@ -38,8 +38,8 @@ use objc::runtime::{Class, Object, Protocol, Sel};
use objc::*;
use promise::Future;
use raw_window_handle::{
AppKitDisplayHandle, AppKitWindowHandle, HasRawDisplayHandle, HasRawWindowHandle,
RawDisplayHandle, RawWindowHandle,
AppKitDisplayHandle, AppKitWindowHandle, DisplayHandle, HandleError, HasDisplayHandle,
HasWindowHandle, RawDisplayHandle, RawWindowHandle, WindowHandle,
};
use std::any::Any;
use std::cell::RefCell;
@ -649,18 +649,21 @@ impl Window {
}
}
unsafe impl HasRawDisplayHandle for Window {
fn raw_display_handle(&self) -> RawDisplayHandle {
RawDisplayHandle::AppKit(AppKitDisplayHandle::empty())
impl HasDisplayHandle for Window {
fn display_handle(&self) -> Result<DisplayHandle, HandleError> {
unsafe {
Ok(DisplayHandle::from_raw(RawDisplayHandle::AppKit(
AppKitDisplayHandle::new(),
)))
}
}
}
unsafe impl HasRawWindowHandle for Window {
fn raw_window_handle(&self) -> RawWindowHandle {
let mut handle = AppKitWindowHandle::empty();
handle.ns_window = self.ns_window as *mut _;
handle.ns_view = self.ns_view as *mut _;
RawWindowHandle::AppKit(handle)
impl HasWindowHandle for Window {
fn window_handle(&self) -> Result<WindowHandle, HandleError> {
let mut handle =
AppKitWindowHandle::new(NonNull::new(self.ns_view as *mut _).expect("non-null"));
unsafe { Ok(WindowHandle::from_raw(RawWindowHandle::AppKit(handle))) }
}
}

View File

@ -13,7 +13,7 @@ use config::{ConfigHandle, ImePreeditRendering, SystemBackdrop};
use lazy_static::lazy_static;
use promise::Future;
use raw_window_handle::{
HasRawDisplayHandle, HasRawWindowHandle, RawDisplayHandle, RawWindowHandle, Win32WindowHandle,
DisplayHandle, HandleError, RawDisplayHandle, RawWindowHandle, Win32WindowHandle, WindowHandle,
WindowsDisplayHandle,
};
use shared_library::shared_library;
@ -23,6 +23,7 @@ use std::collections::HashMap;
use std::convert::TryInto;
use std::ffi::OsString;
use std::io::{self, Error as IoError};
use std::num::NonZeroIsize;
use std::os::windows::ffi::OsStringExt;
use std::path::PathBuf;
use std::ptr::{null, null_mut};
@ -194,18 +195,22 @@ fn callback_behavior() -> glium::debug::DebugCallbackBehavior {
}
}
unsafe impl HasRawDisplayHandle for WindowInner {
fn raw_display_handle(&self) -> RawDisplayHandle {
RawDisplayHandle::Windows(WindowsDisplayHandle::empty())
impl HasDisplayHandle for WindowInner {
fn display_handle(&self) -> Result<DisplayHandle, HandleError> {
unsafe {
Ok(DisplayHandle::from_raw(RawDisplayHandle::Windows(
WindowsDisplayHandle::new(),
)))
}
}
}
unsafe impl HasRawWindowHandle for WindowInner {
fn raw_window_handle(&self) -> RawWindowHandle {
let mut handle = Win32WindowHandle::empty();
handle.hwnd = self.hwnd.0 as *mut _;
handle.hinstance = unsafe { GetModuleHandleW(null()) } as _;
RawWindowHandle::Win32(handle)
impl HasWindowHandle for WindowInner {
fn window_handle(&self) -> Result<WindowHandle, HandleError> {
let mut handle =
Win32WindowHandle::new(NonZeroIsize::new(self.hwnd.0 as _).expect("non-zero"));
handle.hinstance = NonZeroIsize::new(unsafe { GetModuleHandleW(null()) } as _);
unsafe { Ok(WindowHandle::from_raw(RawWindowHandle::Win32(handle))) }
}
}
@ -713,14 +718,18 @@ impl WindowInner {
}
}
unsafe impl HasRawDisplayHandle for Window {
fn raw_display_handle(&self) -> RawDisplayHandle {
RawDisplayHandle::Windows(WindowsDisplayHandle::empty())
impl HasDisplayHandle for Window {
fn display_handle(&self) -> Result<DisplayHandle, HandleError> {
unsafe {
Ok(DisplayHandle::from_raw(RawDisplayHandle::Windows(
WindowsDisplayHandle::new(),
)))
}
}
}
unsafe impl HasRawWindowHandle for Window {
fn raw_window_handle(&self) -> RawWindowHandle {
impl HasWindowHandle for Window {
fn window_handle(&self) -> Result<WindowHandle, HandleError> {
let conn = Connection::get().expect("raw_window_handle only callable on main thread");
let handle = conn.get_window(self.0).expect("window handle invalid!?");