|
1 | 1 | pub mod error; |
2 | 2 | pub mod render; |
3 | 3 |
|
4 | | -use std::{cell::RefCell, num::NonZero, sync::OnceLock}; |
| 4 | +use std::{cell::RefCell, ffi::c_void, num::NonZero, ptr::NonNull, sync::OnceLock}; |
5 | 5 |
|
6 | 6 | use bevy::{ |
7 | 7 | app::{App, AppExit}, |
@@ -95,6 +95,7 @@ impl HasDisplayHandle for GlfwWindow { |
95 | 95 | /// actually create the surface. |
96 | 96 | pub fn create_surface( |
97 | 97 | window_handle: u64, |
| 98 | + display_handle: u64, |
98 | 99 | width: u32, |
99 | 100 | height: u32, |
100 | 101 | scale_factor: f32, |
@@ -132,7 +133,7 @@ pub fn create_surface( |
132 | 133 | } |
133 | 134 | }; |
134 | 135 |
|
135 | | - let window = AppKitWindowHandle::new(std::ptr::NonNull::new(ns_view_ptr).unwrap()); |
| 136 | + let window = AppKitWindowHandle::new(NonNull::new(ns_view_ptr).unwrap()); |
136 | 137 | let display = AppKitDisplayHandle::new(); |
137 | 138 | ( |
138 | 139 | RawWindowHandle::AppKit(window), |
@@ -178,8 +179,30 @@ pub fn create_surface( |
178 | 179 | }; |
179 | 180 |
|
180 | 181 | #[cfg(target_os = "linux")] |
181 | | - let (raw_window_handle, raw_display_handle) = |
182 | | - { todo!("implement linux raw window handle conversion") }; |
| 182 | + let (raw_window_handle, raw_display_handle) = { |
| 183 | + use raw_window_handle::{WaylandDisplayHandle, WaylandWindowHandle}; |
| 184 | + |
| 185 | + if window_handle == 0 { |
| 186 | + return Err(error::ProcessingError::HandleError( |
| 187 | + HandleError::Unavailable, |
| 188 | + )); |
| 189 | + } |
| 190 | + let window_handle_ptr = NonNull::new(window_handle as *mut c_void).unwrap(); |
| 191 | + let window = WaylandWindowHandle::new(window_handle_ptr); |
| 192 | + |
| 193 | + if display_handle == 0 { |
| 194 | + return Err(error::ProcessingError::HandleError( |
| 195 | + HandleError::Unavailable, |
| 196 | + )); |
| 197 | + } |
| 198 | + let display_handle_ptr = NonNull::new(display_handle as *mut c_void).unwrap(); |
| 199 | + let display = WaylandDisplayHandle::new(display_handle_ptr); |
| 200 | + |
| 201 | + ( |
| 202 | + RawWindowHandle::Wayland(window), |
| 203 | + RawDisplayHandle::Wayland(display), |
| 204 | + ) |
| 205 | + }; |
183 | 206 |
|
184 | 207 | let glfw_window = GlfwWindow { |
185 | 208 | window_handle: raw_window_handle, |
|
0 commit comments