moved backend trait to own file
This commit is contained in:
parent
a85d8d0df5
commit
d3afc30ceb
|
@ -1,35 +1,6 @@
|
||||||
use self::window_event::KeyBind;
|
|
||||||
|
|
||||||
pub mod keycodes;
|
pub mod keycodes;
|
||||||
|
pub mod traits;
|
||||||
pub mod window_event;
|
pub mod window_event;
|
||||||
pub mod xlib;
|
pub mod xlib;
|
||||||
|
|
||||||
pub trait WindowServerBackend {
|
pub use traits::*;
|
||||||
type Window;
|
|
||||||
|
|
||||||
fn new() -> Self;
|
|
||||||
|
|
||||||
fn next_event(&mut self) -> window_event::WindowEvent<Self::Window>;
|
|
||||||
fn add_keybind(&mut self, keybind: KeyBind, window: Option<Self::Window>);
|
|
||||||
fn remove_keybind(
|
|
||||||
&mut self,
|
|
||||||
keybind: KeyBind,
|
|
||||||
window: Option<Self::Window>,
|
|
||||||
);
|
|
||||||
fn add_mousebind(&mut self, keybind: KeyBind, window: Option<Self::Window>);
|
|
||||||
fn remove_mousebind(
|
|
||||||
&mut self,
|
|
||||||
keybind: KeyBind,
|
|
||||||
window: Option<Self::Window>,
|
|
||||||
);
|
|
||||||
fn focus_window(&self, window: Self::Window);
|
|
||||||
fn unfocus_window(&self, window: Self::Window);
|
|
||||||
fn move_window(&self, window: Self::Window, new_pos: (i32, i32));
|
|
||||||
fn resize_window(&self, window: Self::Window, new_size: (i32, i32));
|
|
||||||
fn raise_window(&self, window: Self::Window);
|
|
||||||
fn get_parent_window(&self, window: Self::Window) -> Option<Self::Window>;
|
|
||||||
fn hide_window(&self, window: Self::Window);
|
|
||||||
fn screen_size(&self) -> (i32, i32);
|
|
||||||
fn kill_window(&self, window: Self::Window);
|
|
||||||
fn get_window_size(&self, window: Self::Window) -> Option<(i32, i32)>;
|
|
||||||
}
|
|
||||||
|
|
51
src/backends/traits.rs
Normal file
51
src/backends/traits.rs
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
use super::{
|
||||||
|
window_event,
|
||||||
|
window_event::{KeyBind, Point},
|
||||||
|
};
|
||||||
|
|
||||||
|
pub trait WindowServerBackend {
|
||||||
|
type Window;
|
||||||
|
|
||||||
|
fn new() -> Self;
|
||||||
|
|
||||||
|
fn next_event(&mut self) -> window_event::WindowEvent<Self::Window>;
|
||||||
|
fn handle_event(&mut self, event: window_event::WindowEvent<Self::Window>);
|
||||||
|
|
||||||
|
fn add_keybind(&mut self, keybind: KeyBind, window: Option<Self::Window>);
|
||||||
|
fn remove_keybind(
|
||||||
|
&mut self,
|
||||||
|
keybind: KeyBind,
|
||||||
|
window: Option<Self::Window>,
|
||||||
|
);
|
||||||
|
|
||||||
|
fn add_mousebind(&mut self, keybind: KeyBind, window: Option<Self::Window>);
|
||||||
|
fn remove_mousebind(
|
||||||
|
&mut self,
|
||||||
|
keybind: KeyBind,
|
||||||
|
window: Option<Self::Window>,
|
||||||
|
);
|
||||||
|
|
||||||
|
fn focus_window(&self, window: Self::Window);
|
||||||
|
fn unfocus_window(&self, window: Self::Window);
|
||||||
|
fn raise_window(&self, window: Self::Window);
|
||||||
|
fn hide_window(&self, window: Self::Window);
|
||||||
|
fn kill_window(&self, window: Self::Window);
|
||||||
|
fn get_parent_window(&self, window: Self::Window) -> Option<Self::Window>;
|
||||||
|
fn configure_window(
|
||||||
|
&self,
|
||||||
|
window: Self::Window,
|
||||||
|
new_size: Option<Point<i32>>,
|
||||||
|
new_pos: Option<Point<i32>>,
|
||||||
|
);
|
||||||
|
|
||||||
|
fn screen_size(&self) -> Point<i32>;
|
||||||
|
fn get_window_size(&self, window: Self::Window) -> Option<Point<i32>>;
|
||||||
|
|
||||||
|
fn resize_window(&self, window: Self::Window, new_size: Point<i32>) {
|
||||||
|
self.configure_window(window, Some(new_size), None);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn move_window(&self, window: Self::Window, new_pos: Point<i32>) {
|
||||||
|
self.configure_window(window, None, Some(new_pos));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue