From 749c0ae11b93548ab57e7f7151c53d023ecbb423 Mon Sep 17 00:00:00 2001 From: Adrien Prokopowicz Date: Mon, 25 Mar 2024 18:58:04 +0100 Subject: [PATCH] Minor fixes --- src/x11/event_loop.rs | 8 +++++--- src/x11/window.rs | 6 +++--- src/x11/x11_window.rs | 6 +++--- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/x11/event_loop.rs b/src/x11/event_loop.rs index a98e0b0..c8ad9cc 100644 --- a/src/x11/event_loop.rs +++ b/src/x11/event_loop.rs @@ -49,7 +49,7 @@ impl EventLoop { // the same. // NOTE: x11rb uses calloop under the hood, so that won't be an issue anymore once we switch to // it - pub fn run(&mut self) { + pub fn run(&mut self) -> Result<(), Box> { use nix::poll::*; let xcb_fd = self.window.xcb_connection.file_descriptor(); @@ -74,7 +74,7 @@ impl EventLoop { // Check for any events in the internal buffers // before going to sleep: - self.drain_xcb_events(); + self.drain_xcb_events()?; // FIXME: handle errors poll(&mut fds, next_frame.duration_since(Instant::now()).subsec_millis() as i32) @@ -86,7 +86,7 @@ impl EventLoop { } if revents.contains(PollFlags::POLLIN) { - self.drain_xcb_events(); + self.drain_xcb_events()?; } } @@ -107,6 +107,8 @@ impl EventLoop { self.handle_must_close(); } } + + Ok(()) } fn handle_close_requested(&mut self) { diff --git a/src/x11/window.rs b/src/x11/window.rs index faade13..bc48a4b 100644 --- a/src/x11/window.rs +++ b/src/x11/window.rs @@ -2,7 +2,7 @@ use std::cell::Cell; use std::error::Error; -use std::rc::{Rc, Weak}; +use std::rc::Rc; use std::sync::mpsc; use std::thread; @@ -100,7 +100,7 @@ impl Window { window_shared.x11_window.show(&window_shared.xcb_connection)?; - EventLoop::new(window_shared, handler, handle_receiver).run(); + EventLoop::new(window_shared, handler, handle_receiver).run()?; Ok(()) } @@ -131,7 +131,7 @@ impl Window { } #[cfg(feature = "opengl")] - pub fn gl_context(&self) -> Option> { + pub fn gl_context(&self) -> Option> { self.x11_window.gl_context() } diff --git a/src/x11/x11_window.rs b/src/x11/x11_window.rs index c8a2703..0095581 100644 --- a/src/x11/x11_window.rs +++ b/src/x11/x11_window.rs @@ -3,7 +3,6 @@ use crate::x11::xcb_connection::XcbConnection; use crate::{MouseCursor, Size, WindowInfo, WindowOpenOptions, WindowScalePolicy}; use raw_window_handle::XcbWindowHandle; use std::error::Error; -use std::rc::{Rc, Weak}; use x11rb::connection::Connection; use x11rb::protocol::xproto::{ AtomEnum, ChangeWindowAttributesAux, ConfigureWindowAux, ConnectionExt, CreateGCAux, @@ -20,7 +19,7 @@ pub(crate) struct X11Window { _graphics_context: Gcontext, #[cfg(feature = "opengl")] - gl_context: Option>, + gl_context: Option>, } impl X11Window { @@ -86,7 +85,7 @@ impl X11Window { gl_context: None, }; - created_window.set_title(connection, &options.title); + created_window.set_title(connection, &options.title)?; // Register protocols connection.conn2.change_property32( @@ -180,6 +179,7 @@ fn create_graphics_context( #[cfg(feature = "opengl")] const _: () = { use crate::gl::platform::GlContext; + use std::rc::{Rc, Weak}; use std::ffi::c_ulong;