Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
prokopyl committed Mar 25, 2024
1 parent 814493f commit 749c0ae
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
8 changes: 5 additions & 3 deletions src/x11/event_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<dyn Error>> {
use nix::poll::*;

let xcb_fd = self.window.xcb_connection.file_descriptor();
Expand All @@ -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)
Expand All @@ -86,7 +86,7 @@ impl EventLoop {
}

if revents.contains(PollFlags::POLLIN) {
self.drain_xcb_events();
self.drain_xcb_events()?;
}
}

Expand All @@ -107,6 +107,8 @@ impl EventLoop {
self.handle_must_close();
}
}

Ok(())
}

fn handle_close_requested(&mut self) {
Expand Down
6 changes: 3 additions & 3 deletions src/x11/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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(())
}

Expand Down Expand Up @@ -131,7 +131,7 @@ impl Window {
}

#[cfg(feature = "opengl")]
pub fn gl_context(&self) -> Option<Weak<crate::gl::platform::GlContext>> {
pub fn gl_context(&self) -> Option<std::rc::Weak<crate::gl::platform::GlContext>> {
self.x11_window.gl_context()
}

Expand Down
6 changes: 3 additions & 3 deletions src/x11/x11_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -20,7 +19,7 @@ pub(crate) struct X11Window {
_graphics_context: Gcontext,

#[cfg(feature = "opengl")]
gl_context: Option<Rc<crate::gl::x11::GlContext>>,
gl_context: Option<std::rc::Rc<crate::gl::x11::GlContext>>,
}

impl X11Window {
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 749c0ae

Please sign in to comment.