From 15b0c2e857b009ab5b5958acdd5db22c6cb28008 Mon Sep 17 00:00:00 2001 From: Billy Messenger Date: Sat, 5 Sep 2020 14:41:26 -0500 Subject: [PATCH] Replace RenderExpose event with draw method --- examples/open_window.rs | 3 ++- src/event.rs | 1 - src/lib.rs | 1 + src/x11/window.rs | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/open_window.rs b/examples/open_window.rs index b195499..745fec7 100644 --- a/examples/open_window.rs +++ b/examples/open_window.rs @@ -30,9 +30,10 @@ impl baseview::AppWindow for MyProgram { ) { } + fn draw(&mut self) {} + fn on_event(&mut self, event: Event) { match event { - Event::RenderExpose => {} Event::CursorMotion(x, y) => { println!("Cursor moved, x: {}, y: {}", x, y); } diff --git a/src/event.rs b/src/event.rs index 7f429c7..b78e27b 100644 --- a/src/event.rs +++ b/src/event.rs @@ -38,7 +38,6 @@ pub struct WindowInfo { #[derive(Debug)] pub enum Event { - RenderExpose, CursorMotion(i32, i32), // new (x, y) relative to window MouseDown(MouseButtonID), MouseUp(MouseButtonID), diff --git a/src/lib.rs b/src/lib.rs index ce63188..5ed9f41 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -41,6 +41,7 @@ pub trait AppWindow { window: raw_window_handle::RawWindowHandle, window_info: &WindowInfo, ); + fn draw(&mut self); fn on_event(&mut self, event: Event); fn on_app_message(&mut self, message: Self::AppMessage); } diff --git a/src/x11/window.rs b/src/x11/window.rs index b71e101..fd4682b 100644 --- a/src/x11/window.rs +++ b/src/x11/window.rs @@ -189,7 +189,7 @@ impl Window { match event_type { xcb::EXPOSE => { - self.app_window.on_event(Event::RenderExpose); + self.app_window.draw(); } xcb::MOTION_NOTIFY => { let event = unsafe { xcb::cast_event::(&event) };