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:
Antonino Siena 2020-01-18 09:15:15 +01:00 committed by Daniel Collin
parent 703477f742
commit 0a72653310
7 changed files with 1352 additions and 1096 deletions

View file

@ -41,24 +41,45 @@ features = [
[target.i686-unknown-linux-gnu.dependencies]
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]
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]
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]
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]
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]
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]
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]
orbclient = "0.3.20"

View file

@ -828,7 +828,7 @@ impl Menu {
/// ```
pub fn add_item(&mut self, name: &str, id: usize) -> MenuItem {
MenuItem {
id: id,
id,
label: name.to_owned(),
menu: Some(self),
..MenuItem::default()
@ -886,7 +886,7 @@ impl<'a> MenuItem<'a> {
/// Creates a new menu item
pub fn new(name: &str, id: usize) -> MenuItem {
MenuItem {
id: id,
id,
label: name.to_owned(),
..MenuItem::default()
}
@ -904,8 +904,8 @@ impl<'a> MenuItem<'a> {
/// ```
pub fn shortcut(self, key: Key, modifier: usize) -> Self {
MenuItem {
key: key,
modifier: modifier,
key,
modifier,
..self
}
}
@ -939,10 +939,7 @@ impl<'a> MenuItem<'a> {
/// # ;
/// ```
pub fn enabled(self, enabled: bool) -> Self {
MenuItem {
enabled: enabled,
..self
}
MenuItem { enabled, ..self }
}
#[inline]
/// Must be called to finalize building of a menu item when started with ```menu.add_item()```

View file

@ -290,7 +290,7 @@ impl Window {
Ok(Window {
window_handle: handle,
scale_factor: scale_factor,
scale_factor,
shared_data: SharedData {
bg_color: 0,
scale_mode: opts.scale_mode as u32,

View file

@ -79,8 +79,8 @@ impl Window {
is_active: true,
buffer_width: width,
buffer_height: height,
window: window,
window_scale: window_scale,
window,
window_scale,
key_handler: KeyHandler::new(),
menu_counter: MenuHandle(0),
menus: Vec::new(),
@ -415,7 +415,7 @@ impl Menu {
let handle = self.next_item_handle();
self.internal.items.push(UnixMenuItem {
label: name.to_owned(),
handle: handle,
handle,
sub_menu: Some(Box::new(sub_menu.internal.clone())),
id: 0,
enabled: true,

File diff suppressed because it is too large Load diff

1156
src/os/unix/x11.rs Normal file

File diff suppressed because it is too large Load diff

View file

@ -580,7 +580,7 @@ impl Window {
key_handler: KeyHandler::new(),
update_rate: UpdateRate::new(),
is_open: true,
scale_factor: scale_factor,
scale_factor,
width: (width * scale_factor as usize) as i32,
height: (height * scale_factor as usize) as i32,
menus: Vec::new(),