Save the window: no more segfault + wgpu works too

This commit is contained in:
Timmy Xiao authored and Wez Furlong committed 2024-02-03 14:54:44 -07:00
1 parent 0071064e79
commit 4170f238bd
2 files changed
+9 -22

No files matched your search

-9
View File
@@ -122,15 +122,6 @@ impl WaylandConnection {
bail!("polling for events: {:?}", err);
}
{
// TODO: remove me
log::trace!("WINDOWS");
for (k, v) in self.windows.borrow().iter() {
let obj_id = wayland_client::Proxy::id(&v.borrow().surface).as_ptr();
log::trace!("{k} := inner <{:?}>", obj_id);
}
}
for event in &events {
if event.token() != tok_wl {
continue;
+9 -13
View File
@@ -21,6 +21,7 @@ use raw_window_handle::WaylandWindowHandle;
use smithay_client_toolkit::compositor::CompositorState;
use smithay_client_toolkit::registry::ProvidesRegistryState;
use smithay_client_toolkit::shell::xdg::window::DecorationMode;
use smithay_client_toolkit::shell::xdg::window::Window as XdgWindow;
use smithay_client_toolkit::shell::xdg::window::WindowDecorations as Decorations;
use smithay_client_toolkit::shell::xdg::XdgShell;
use smithay_client_toolkit::shell::WaylandSurface;
@@ -84,7 +85,6 @@ impl WaylandWindow {
let compositor = CompositorState::bind(&globals, &qh)?;
let surface = compositor.create_surface(&qh);
log::trace!("SURFACE: {:?} - {:?} - {:?}", surface, surface.id(), surface.id().as_ptr());
let xdg_shell = XdgShell::bind(&globals, &qh)?;
let window = xdg_shell.create_window(surface.clone(), Decorations::RequestServer, &qh);
@@ -109,6 +109,7 @@ impl WaylandWindow {
window.set_min_size(Some((32, 32)));
window.commit();
//
// TODO:
// let copy_and_paste = CopyAndPaste::create();
@@ -119,7 +120,7 @@ impl WaylandWindow {
// TODO: WindowInner
let inner = Rc::new(RefCell::new(WaylandWindowInner {
events: WindowEventSender::new(event_handler),
surface: surface.clone(),
window,
wegl_surface: None,
gl_state: None,
@@ -145,9 +146,6 @@ impl WaylandWindow {
// });
conn.windows.borrow_mut().insert(window_id, inner.clone());
log::trace!("About to commit window");
window.commit();
Ok(window_handle)
}
}
@@ -256,7 +254,8 @@ pub struct WaylandWindowInner {
// window_id: usize,
pub(crate) events: WindowEventSender,
// TODO: remove pub(crate) surface
pub(crate) surface: WlSurface,
pub (crate) window: XdgWindow,
// pub(crate) surface: WlSurface,
// surface_factor: f64,
// copy_and_paste: Arc<Mutex<CopyAndPaste>>,
// window: Option<toolkit::window::Window<ConceptFrame>>,
@@ -297,17 +296,14 @@ impl WaylandWindowInner {
let gl_state = if !egl_is_available() {
Err(anyhow!("!egl_is_available"))
} else {
let object_id = self.surface.id();
log::trace!("EGL SURFACE: {:?} - {:?} - {:?}", self.surface, object_id, object_id.as_ptr());
let ptr = object_id.as_ptr();
// IMPORTANT!!!! - TODO: the wl_surface is null
let object_id = self.window.wl_surface().id();
wegl_surface = Some(WlEglSurface::new(
self.surface.id(),
object_id,
// TODO: remove the hardcoded stuff
100,
100,
)?);
log::trace!("EGL SURFACE AFTER");
match wayland_conn.gl_connection.borrow().as_ref() {
Some(glconn) => crate::egl::GlState::create_wayland_with_existing_connection(
@@ -356,7 +352,7 @@ unsafe impl HasRawDisplayHandle for WaylandWindowInner {
unsafe impl HasRawWindowHandle for WaylandWindowInner {
fn raw_window_handle(&self) -> RawWindowHandle {
let mut handle = WaylandWindowHandle::empty();
handle.surface = self.surface.id().as_ptr() as *mut _;
handle.surface = self.window.wl_surface().id().as_ptr() as *mut _;
RawWindowHandle::Wayland(handle)
}
}