mirror of
https://github.com/italicsjenga/rust_minifb.git
synced 2025-01-11 03:21:32 +11:00
Restructure Unix implementation in preparation for Wayland support
* Wayland implementation restructuration * Moved previous X11 code into own module * Moved some data into a common struct between wayland and x11 * Added glue * Moved common unix functions into module * Revert commits * Update x11.rs * Update x11.rs * Cargo fmt * Cargo fmt
This commit is contained in:
parent
703477f742
commit
0a72653310
21
Cargo.toml
21
Cargo.toml
|
@ -41,24 +41,45 @@ features = [
|
||||||
|
|
||||||
[target.i686-unknown-linux-gnu.dependencies]
|
[target.i686-unknown-linux-gnu.dependencies]
|
||||||
x11-dl = "2.18.3"
|
x11-dl = "2.18.3"
|
||||||
|
wayland-client = "0.24"
|
||||||
|
wayland-protocols = { version = "0.24", features = ["client"] }
|
||||||
|
tempfile = "3.1.0"
|
||||||
|
|
||||||
[target.x86_64-unknown-linux-gnu.dependencies]
|
[target.x86_64-unknown-linux-gnu.dependencies]
|
||||||
x11-dl = "2.18.3"
|
x11-dl = "2.18.3"
|
||||||
|
wayland-client = "0.24"
|
||||||
|
wayland-protocols = { version = "0.24", features = ["client"] }
|
||||||
|
tempfile = "3.1.0"
|
||||||
|
|
||||||
[target.arm-unknown-linux-gnueabihf.dependencies]
|
[target.arm-unknown-linux-gnueabihf.dependencies]
|
||||||
x11-dl = "2.18.3"
|
x11-dl = "2.18.3"
|
||||||
|
wayland-client = "0.24"
|
||||||
|
wayland-protocols = { version = "0.24", features = ["client"] }
|
||||||
|
tempfile = "3.1.0"
|
||||||
|
|
||||||
[target.armv7-unknown-linux-gnueabihf.dependencies]
|
[target.armv7-unknown-linux-gnueabihf.dependencies]
|
||||||
x11-dl = "2.18.3"
|
x11-dl = "2.18.3"
|
||||||
|
wayland-client = "0.24"
|
||||||
|
wayland-protocols = { version = "0.24", features = ["client"] }
|
||||||
|
tempfile = "3.1.0"
|
||||||
|
|
||||||
[target.aarch64-unknown-linux-gnu.dependencies]
|
[target.aarch64-unknown-linux-gnu.dependencies]
|
||||||
x11-dl = "2.18.3"
|
x11-dl = "2.18.3"
|
||||||
|
wayland-client = "0.24"
|
||||||
|
wayland-protocols = { version = "0.24", features = ["client"] }
|
||||||
|
tempfile = "3.1.0"
|
||||||
|
|
||||||
[target.x86_64-unknown-dragonfly.dependencies]
|
[target.x86_64-unknown-dragonfly.dependencies]
|
||||||
x11-dl = "2.18.3"
|
x11-dl = "2.18.3"
|
||||||
|
wayland-client = "0.24"
|
||||||
|
wayland-protocols = { version = "0.24", features = ["client"] }
|
||||||
|
tempfile = "3.1.0"
|
||||||
|
|
||||||
[target.x86_64-unknown-freebsd.dependencies]
|
[target.x86_64-unknown-freebsd.dependencies]
|
||||||
x11-dl = "2.18.3"
|
x11-dl = "2.18.3"
|
||||||
|
wayland-client = "0.24"
|
||||||
|
wayland-protocols = { version = "0.24", features = ["client"] }
|
||||||
|
tempfile = "3.1.0"
|
||||||
|
|
||||||
[target.x86_64-unknown-redox.dependencies]
|
[target.x86_64-unknown-redox.dependencies]
|
||||||
orbclient = "0.3.20"
|
orbclient = "0.3.20"
|
||||||
|
|
13
src/lib.rs
13
src/lib.rs
|
@ -828,7 +828,7 @@ impl Menu {
|
||||||
/// ```
|
/// ```
|
||||||
pub fn add_item(&mut self, name: &str, id: usize) -> MenuItem {
|
pub fn add_item(&mut self, name: &str, id: usize) -> MenuItem {
|
||||||
MenuItem {
|
MenuItem {
|
||||||
id: id,
|
id,
|
||||||
label: name.to_owned(),
|
label: name.to_owned(),
|
||||||
menu: Some(self),
|
menu: Some(self),
|
||||||
..MenuItem::default()
|
..MenuItem::default()
|
||||||
|
@ -886,7 +886,7 @@ impl<'a> MenuItem<'a> {
|
||||||
/// Creates a new menu item
|
/// Creates a new menu item
|
||||||
pub fn new(name: &str, id: usize) -> MenuItem {
|
pub fn new(name: &str, id: usize) -> MenuItem {
|
||||||
MenuItem {
|
MenuItem {
|
||||||
id: id,
|
id,
|
||||||
label: name.to_owned(),
|
label: name.to_owned(),
|
||||||
..MenuItem::default()
|
..MenuItem::default()
|
||||||
}
|
}
|
||||||
|
@ -904,8 +904,8 @@ impl<'a> MenuItem<'a> {
|
||||||
/// ```
|
/// ```
|
||||||
pub fn shortcut(self, key: Key, modifier: usize) -> Self {
|
pub fn shortcut(self, key: Key, modifier: usize) -> Self {
|
||||||
MenuItem {
|
MenuItem {
|
||||||
key: key,
|
key,
|
||||||
modifier: modifier,
|
modifier,
|
||||||
..self
|
..self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -939,10 +939,7 @@ impl<'a> MenuItem<'a> {
|
||||||
/// # ;
|
/// # ;
|
||||||
/// ```
|
/// ```
|
||||||
pub fn enabled(self, enabled: bool) -> Self {
|
pub fn enabled(self, enabled: bool) -> Self {
|
||||||
MenuItem {
|
MenuItem { enabled, ..self }
|
||||||
enabled: enabled,
|
|
||||||
..self
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
/// Must be called to finalize building of a menu item when started with ```menu.add_item()```
|
/// Must be called to finalize building of a menu item when started with ```menu.add_item()```
|
||||||
|
|
|
@ -290,7 +290,7 @@ impl Window {
|
||||||
|
|
||||||
Ok(Window {
|
Ok(Window {
|
||||||
window_handle: handle,
|
window_handle: handle,
|
||||||
scale_factor: scale_factor,
|
scale_factor,
|
||||||
shared_data: SharedData {
|
shared_data: SharedData {
|
||||||
bg_color: 0,
|
bg_color: 0,
|
||||||
scale_mode: opts.scale_mode as u32,
|
scale_mode: opts.scale_mode as u32,
|
||||||
|
|
|
@ -79,8 +79,8 @@ impl Window {
|
||||||
is_active: true,
|
is_active: true,
|
||||||
buffer_width: width,
|
buffer_width: width,
|
||||||
buffer_height: height,
|
buffer_height: height,
|
||||||
window: window,
|
window,
|
||||||
window_scale: window_scale,
|
window_scale,
|
||||||
key_handler: KeyHandler::new(),
|
key_handler: KeyHandler::new(),
|
||||||
menu_counter: MenuHandle(0),
|
menu_counter: MenuHandle(0),
|
||||||
menus: Vec::new(),
|
menus: Vec::new(),
|
||||||
|
@ -415,7 +415,7 @@ impl Menu {
|
||||||
let handle = self.next_item_handle();
|
let handle = self.next_item_handle();
|
||||||
self.internal.items.push(UnixMenuItem {
|
self.internal.items.push(UnixMenuItem {
|
||||||
label: name.to_owned(),
|
label: name.to_owned(),
|
||||||
handle: handle,
|
handle,
|
||||||
sub_menu: Some(Box::new(sub_menu.internal.clone())),
|
sub_menu: Some(Box::new(sub_menu.internal.clone())),
|
||||||
id: 0,
|
id: 0,
|
||||||
enabled: true,
|
enabled: true,
|
||||||
|
|
1248
src/os/unix/mod.rs
1248
src/os/unix/mod.rs
File diff suppressed because it is too large
Load diff
1156
src/os/unix/x11.rs
Normal file
1156
src/os/unix/x11.rs
Normal file
File diff suppressed because it is too large
Load diff
|
@ -580,7 +580,7 @@ impl Window {
|
||||||
key_handler: KeyHandler::new(),
|
key_handler: KeyHandler::new(),
|
||||||
update_rate: UpdateRate::new(),
|
update_rate: UpdateRate::new(),
|
||||||
is_open: true,
|
is_open: true,
|
||||||
scale_factor: scale_factor,
|
scale_factor,
|
||||||
width: (width * scale_factor as usize) as i32,
|
width: (width * scale_factor as usize) as i32,
|
||||||
height: (height * scale_factor as usize) as i32,
|
height: (height * scale_factor as usize) as i32,
|
||||||
menus: Vec::new(),
|
menus: Vec::new(),
|
||||||
|
|
Loading…
Reference in a new issue