Skip to content

Commit

Permalink
Update wayland-rs to 0.30.0
Browse files Browse the repository at this point in the history
This update rewrites the winit's Wayland backend using new wayland-rs
0.30 API. This fixes long standing issue with the forward compatibility
of the wayland backend, meaning that future updates to the wayland
protocol won't break rust code anymore. like it was before when adding
new shm/enum variants into the protocol.

Fixes rust-windowing#2560.
Fixes rust-windowing#2128.
  • Loading branch information
kchibisov committed Feb 4, 2023
1 parent 69d6076 commit b9364f2
Show file tree
Hide file tree
Showing 26 changed files with 2,296 additions and 3,283 deletions.
22 changes: 11 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ targets = [
rustdoc-args = ["--cfg", "docsrs"]

[features]
default = ["x11", "wayland", "wayland-dlopen", "wayland-csd-adwaita"]
default = ["x11", "wayland", "wayland-dlopen"]
x11 = ["x11-dl", "mio", "percent-encoding"]
wayland = ["wayland-client", "wayland-protocols", "sctk", "wayland-commons"]
wayland-dlopen = ["sctk/dlopen", "wayland-client/dlopen"]
wayland-csd-adwaita = ["sctk-adwaita", "sctk-adwaita/ab_glyph"]
wayland-csd-adwaita-crossfont = ["sctk-adwaita", "sctk-adwaita/crossfont"]
wayland-csd-adwaita-notitle = ["sctk-adwaita"]
wayland = ["wayland-client", "wayland-backend", "wayland-protocols", "sctk"]
wayland-dlopen = ["wayland-backend/dlopen"]
# wayland-csd-adwaita = ["sctk-adwaita", "sctk-adwaita/ab_glyph"]
# wayland-csd-adwaita-crossfont = ["sctk-adwaita", "sctk-adwaita/crossfont"]
# wayland-csd-adwaita-notitle = ["sctk-adwaita"]
android-native-activity = [ "android-activity/native-activity" ]
android-game-activity = [ "android-activity/game-activity" ]

Expand Down Expand Up @@ -107,11 +107,11 @@ features = [
libc = "0.2.64"
mio = { version = "0.8", features = ["os-ext"], optional = true }
percent-encoding = { version = "2.0", optional = true }
sctk = { package = "smithay-client-toolkit", version = "0.16.0", default_features = false, features = ["calloop"], optional = true }
sctk-adwaita = { version = "0.5.1", default_features = false, optional = true }
wayland-client = { version = "0.29.5", default_features = false, features = ["use_system_lib"], optional = true }
wayland-protocols = { version = "0.29.5", features = [ "staging_protocols"], optional = true }
wayland-commons = { version = "0.29.5", optional = true }
sctk = { package = "smithay-client-toolkit", git = "https://github.com/kchibisov/client-toolkit", branch = "winit-update", optional = true }
wayland-client = { version = "0.30.0", optional = true }
wayland-backend = { version = "0.1.0", default_features = false, features = ["client_system"], optional = true }
wayland-protocols = { version = "0.30.0", features = [ "staging"], optional = true }
calloop = "0.10.5"
x11-dl = { version = "2.18.5", optional = true }

[target.'cfg(target_os = "redox")'.dependencies]
Expand Down
74 changes: 38 additions & 36 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,35 +1,37 @@
use cfg_aliases::cfg_aliases;

#[cfg(all(
any(
target_os = "linux",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "openbsd",
target_os = "netbsd",
),
feature = "wayland",
))]
mod wayland {
use std::env;
use std::path::PathBuf;
use wayland_scanner::Side;
// #[cfg(all(
// any(
// target_os = "linux",
// target_os = "dragonfly",
// target_os = "freebsd",
// target_os = "openbsd",
// target_os = "netbsd",
// ),
// feature = "wayland",
// ))]
// mod wayland {
// use std::env;
// use std::path::PathBuf;
// use wayland_scanner::Side;

pub fn main() {
let mut path = PathBuf::from(env::var("OUT_DIR").unwrap());
path.push("fractional_scale_v1.rs");
wayland_scanner::generate_code(
"wayland_protocols/fractional-scale-v1.xml",
&path,
Side::Client,
);
}
}
// pub fn main() {
// let mut path = PathBuf::from(env::var("OUT_DIR").unwrap());
// path.push("fractional_scale_v1.rs");
// wayland_scanner::generate_code(
// "wayland_protocols/fractional-scale-v1.xml",
// &path,
// Side::Client,
// );
// }
// }

fn main() {
// The script doesn't depend on our code
println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-changed=wayland_protocols");
// println!("cargo:rerun-if-changed=wayland_protocols");

// TODO

// Setup cfg aliases
cfg_aliases! {
Expand All @@ -50,15 +52,15 @@ fn main() {
}

// XXX aliases are not available for the build script itself.
#[cfg(all(
any(
target_os = "linux",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "openbsd",
target_os = "netbsd",
),
feature = "wayland",
))]
wayland::main();
// #[cfg(all(
// any(
// target_os = "linux",
// target_os = "dragonfly",
// target_os = "freebsd",
// target_os = "openbsd",
// target_os = "netbsd",
// ),
// feature = "wayland",
// ))]
// wayland::main();
}
8 changes: 5 additions & 3 deletions src/platform/wayland.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use std::os::raw;

use sctk::reexports::client::Proxy;

use crate::{
event_loop::{EventLoopBuilder, EventLoopWindowTarget},
monitor::MonitorHandle,
Expand Down Expand Up @@ -39,7 +41,7 @@ impl<T> EventLoopWindowTargetExtWayland for EventLoopWindowTarget<T> {
fn wayland_display(&self) -> Option<*mut raw::c_void> {
match self.p {
LinuxEventLoopWindowTarget::Wayland(ref p) => {
Some(p.display().get_display_ptr() as *mut _)
Some(p.connection.display().id().as_ptr() as *mut _)
}
#[cfg(x11_platform)]
_ => None,
Expand Down Expand Up @@ -94,7 +96,7 @@ impl WindowExtWayland for Window {
#[inline]
fn wayland_surface(&self) -> Option<*mut raw::c_void> {
match self.window {
LinuxWindow::Wayland(ref w) => Some(w.surface().as_ref().c_ptr() as *mut _),
LinuxWindow::Wayland(ref w) => Some(w.surface().id().as_ptr() as *mut _),
#[cfg(x11_platform)]
_ => None,
}
Expand All @@ -103,7 +105,7 @@ impl WindowExtWayland for Window {
#[inline]
fn wayland_display(&self) -> Option<*mut raw::c_void> {
match self.window {
LinuxWindow::Wayland(ref w) => Some(w.display().get_display_ptr() as *mut _),
LinuxWindow::Wayland(ref w) => Some(w.display().id().as_ptr() as *mut _),
#[cfg(x11_platform)]
_ => None,
}
Expand Down
183 changes: 0 additions & 183 deletions src/platform_impl/linux/wayland/env.rs

This file was deleted.

Loading

0 comments on commit b9364f2

Please sign in to comment.