Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates for next release #732

Merged
merged 3 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions wayland-backend/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

## Unreleased

### Additions

- Add `rwh_06` feature for `raw-window-handle` 0.6

#### Bugfixes
- backend/rs: `WAYLAND_DEBUG` now displays `fixed` as decimal, not integer.
* Matches libwayland

## 0.3.3 -- 2024-01-29

### Additions
Expand Down
1 change: 1 addition & 0 deletions wayland-backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ log = { version = "0.4", optional = true }
scoped-tls = "1.0"
downcast-rs = "1.2"
raw-window-handle = { version = "0.5.0", optional = true }
rwh_06 = { package = "raw-window-handle", version = "0.6.0", optional = true }

[dependencies.smallvec]
version = "1.9"
Expand Down
8 changes: 6 additions & 2 deletions wayland-backend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,12 @@
//!
//! ## raw-window-handle integration
//!
//! This crate can implement [`HasRawDisplayHandle`][raw_window_handle::HasRawDisplayHandle] for the client
//! module [`Backend`][client::Backend] type if you activate the `raw-window-handle` feature.
//! The `rwh_06` feature activates the [`HasDisplayHandle`][raw_window_handle::HasDisplayHandle] implementation
//! for the client module [`Backend`][client::Backend].
//!
//! ### Deprecated raw-window-handle versions
//!
//! While raw-window-handle 0.5 is supported via the `raw-window-handle` feature, it is deprecated and will be removed in the future.
//!
//! Note that the `client_system` feature must also be enabled for the implementation to be activated.

Expand Down
2 changes: 1 addition & 1 deletion wayland-backend/src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ impl<Id: std::fmt::Display, Fd: AsRawFd> std::fmt::Display for Argument<Id, Fd>
match self {
Self::Int(value) => write!(f, "{}", value),
Self::Uint(value) => write!(f, "{}", value),
Self::Fixed(value) => write!(f, "{}", value),
Self::Fixed(value) => write!(f, "{:.4}", *value as f64 / 256.0),
Self::Str(value) => write!(f, "{:?}", value),
Self::Object(value) => write!(f, "{}", value),
Self::NewId(value) => write!(f, "{}", value),
Expand Down
22 changes: 22 additions & 0 deletions wayland-backend/src/sys/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,28 @@ unsafe impl raw_window_handle::HasRawDisplayHandle for client::Backend {
}
}

#[cfg(all(feature = "rwh_06", feature = "client_system"))]
impl rwh_06::HasDisplayHandle for client::Backend {
fn display_handle(&self) -> Result<rwh_06::DisplayHandle<'_>, rwh_06::HandleError> {
use std::ptr::NonNull;

// SAFETY:
// - The display_ptr will be valid, either because we have created the pointer or the caller which created the
// backend has ensured the pointer is valid when `Backend::from_foreign_display` was called.
let ptr = unsafe { NonNull::new_unchecked(self.display_ptr().cast()) };
let handle = rwh_06::WaylandDisplayHandle::new(ptr);
let raw = rwh_06::RawDisplayHandle::Wayland(handle);

// SAFETY:
// - The display_ptr will be valid, either because we have created the pointer or the caller which created the
// backend has ensured the pointer is valid when `Backend::from_foreign_display` was called.
// - The lifetime assigned to the DisplayHandle borrows the Backend, ensuring the display pointer
// is valid..
// - The display_ptr will not change for the lifetime of the backend.
Ok(unsafe { rwh_06::DisplayHandle::borrow_raw(raw) })
}
}

/// Server-side implementation of a Wayland protocol backend using `libwayland`
///
/// The main entrypoint is the [`Backend::new()`][server::Backend::new()] method.
Expand Down
Loading