Compare commits

...

7 Commits

Author SHA1 Message Date
Kirill Chibisov
8f08fbae89 Winit version 0.29.15 2024-03-13 14:09:30 +04:00
Kirill Chibisov
10a492b5bc bugfix(x11): crash when querying xsettings prop fails
Don't crash when xsettings query fails with _present_ xsettings.

Closes: https://github.com/rust-windowing/winit/issues/3573
2024-03-13 14:09:30 +04:00
Kirill Chibisov
aaaf08972d Winit version 0.29.14 2024-03-06 13:12:25 +04:00
Kirill Chibisov
ba4660dade fix(xkb): text not being None when composing
When composing the text was not reset to `None` leading to input in
some applications e.g. alacritty.

Links: https://github.com/alacritty/alacritty/issues/7806
2024-03-06 13:12:25 +04:00
daxpedda
090800e6a6 Bump x11-dl to v2.19.1 2024-03-06 13:12:25 +04:00
Kirill Chibisov
70fc8f66e9 chore(wayland): don't reapply same cursor grab
Some compositors break when re-taking the same grab.

Closes: https://github.com/rust-windowing/winit/issues/3566
2024-03-06 13:12:25 +04:00
John Nunley
7601a1506d bugfix(x11): fix incorrect delta filtering
Invert the mouse delta filter, so it aligns with the intention of
filtering values lower than epsilon.

Signed-off-by: John Nunley <dev@notgull.net>
Closes: https://github.com/rust-windowing/winit/issues/3558
2024-03-06 13:12:25 +04:00
10 changed files with 74 additions and 28 deletions

View File

@@ -11,6 +11,16 @@ Unreleased` header.
# Unreleased
# 0.29.15
- On X11, fix crash due to xsettings query on systems with incomplete xsettings.
# 0.29.14
- On X11/Wayland, fix `text` and `text_with_all_modifiers` not being `None` during compose.
- On Wayland, don't reapply cursor grab when unchanged.
- On X11, fix a bug where some mouse events would be unexpectedly filtered out.
# 0.29.13
- On Web, fix possible crash with `ControlFlow::Wait` and `ControlFlow::WaitUntil`.

View File

@@ -1,6 +1,6 @@
[package]
name = "winit"
version = "0.29.13"
version = "0.29.15"
authors = ["The winit contributors", "Pierre Krieger <pierre.krieger1708@gmail.com>"]
description = "Cross-platform window creation library."
edition = "2021"
@@ -165,7 +165,7 @@ wayland-backend = { version = "0.3.0", default_features = false, features = ["cl
wayland-client = { version = "0.31.1", optional = true }
wayland-protocols = { version = "0.31.0", features = [ "staging"], optional = true }
wayland-protocols-plasma = { version = "0.2.0", features = [ "client" ], optional = true }
x11-dl = { version = "2.18.5", optional = true }
x11-dl = { version = "2.19.1", optional = true }
x11rb = { version = "0.13.0", default-features = false, features = ["allow-unsafe-code", "dl-libxcb", "randr", "resource_manager", "xinput", "xkb"], optional = true }
xkbcommon-dl = "0.4.2"

View File

@@ -6,7 +6,7 @@
```toml
[dependencies]
winit = "0.29.13"
winit = "0.29.15"
```
## [Documentation](https://docs.rs/winit)
@@ -156,7 +156,7 @@ For more details, refer to these `android-activity` [example applications](https
If your application is currently based on `NativeActivity` via the `ndk-glue` crate and building with `cargo apk`, then the minimal changes would be:
1. Remove `ndk-glue` from your `Cargo.toml`
2. Enable the `"android-native-activity"` feature for Winit: `winit = { version = "0.29.13", features = [ "android-native-activity" ] }`
2. Enable the `"android-native-activity"` feature for Winit: `winit = { version = "0.29.15", features = [ "android-native-activity" ] }`
3. Add an `android_main` entrypoint (as above), instead of using the '`[ndk_glue::main]` proc macro from `ndk-macros` (optionally add a dependency on `android_logger` and initialize logging as above).
4. Pass a clone of the `AndroidApp` that your application receives to Winit when building your event loop (as shown above).

View File

@@ -373,10 +373,15 @@ impl<'a, 'b> KeyEventResults<'a, 'b> {
fn composed_text(&mut self) -> Result<Option<SmolStr>, ()> {
match self.compose {
ComposeStatus::Accepted(xkb_compose_status::XKB_COMPOSE_COMPOSED) => {
let state = self.context.compose_state1.as_mut().unwrap();
Ok(state.get_string(self.context.scratch_buffer))
}
ComposeStatus::Accepted(status) => match status {
xkb_compose_status::XKB_COMPOSE_COMPOSED => {
let state = self.context.compose_state1.as_mut().unwrap();
Ok(state.get_string(self.context.scratch_buffer))
}
xkb_compose_status::XKB_COMPOSE_COMPOSING
| xkb_compose_status::XKB_COMPOSE_CANCELLED => Ok(None),
xkb_compose_status::XKB_COMPOSE_NOTHING => Err(()),
},
_ => Err(()),
}
}

View File

@@ -758,9 +758,14 @@ impl WindowState {
/// Set the cursor grabbing state on the top-level.
pub fn set_cursor_grab(&mut self, mode: CursorGrabMode) -> Result<(), ExternalError> {
// Replace the user grabbing mode.
if self.cursor_grab_mode.user_grab_mode == mode {
return Ok(());
}
self.set_cursor_grab_inner(mode)?;
// Update user grab on success.
self.cursor_grab_mode.user_grab_mode = mode;
self.set_cursor_grab_inner(mode)
Ok(())
}
/// Reload the hints for minimum and maximum sizes.

View File

@@ -891,6 +891,9 @@ pub enum X11Error {
/// Unable to parse xsettings.
XsettingsParse(xsettings::ParserError),
/// Failed to get property.
GetProperty(util::GetPropertyError),
}
impl fmt::Display for X11Error {
@@ -900,6 +903,7 @@ impl fmt::Display for X11Error {
X11Error::Connect(e) => write!(f, "X11 connection error: {}", e),
X11Error::Connection(e) => write!(f, "X11 connection error: {}", e),
X11Error::XidsExhausted(e) => write!(f, "XID range exhausted: {}", e),
X11Error::GetProperty(e) => write!(f, "Failed to get X property {}", e),
X11Error::X11(e) => write!(f, "X11 error: {:?}", e),
X11Error::UnexpectedNull(s) => write!(f, "Xlib function returned null: {}", s),
X11Error::InvalidActivationToken(s) => write!(
@@ -992,6 +996,12 @@ impl From<xsettings::ParserError> for X11Error {
}
}
impl From<util::GetPropertyError> for X11Error {
fn from(value: util::GetPropertyError) -> Self {
Self::GetProperty(value)
}
}
/// Type alias for a void cookie.
type VoidCookie<'a> = x11rb::cookie::VoidCookie<'a, X11rbConnection>;

View File

@@ -30,8 +30,8 @@ macro_rules! consume {
let this = $this;
let (x, y) = match (this.x.abs() < <$ty>::EPSILON, this.y.abs() < <$ty>::EPSILON) {
(true, true) => return None,
(true, false) => (this.x, 0.0),
(false, true) => (0.0, this.y),
(false, true) => (this.x, 0.0),
(true, false) => (0.0, this.y),
(false, false) => (this.x, this.y),
};

View File

@@ -52,6 +52,7 @@ impl XConnection {
.get_string("Xft.dpi", "")
.and_then(|s| f64::from_str(s).ok())
}
pub fn get_output_info(
&self,
resources: &monitor::ScreenResources,

View File

@@ -1,13 +1,18 @@
use super::*;
use bytemuck::{NoUninit, Pod};
use std::error::Error;
use std::fmt;
use std::sync::Arc;
use bytemuck::{NoUninit, Pod};
use x11rb::connection::Connection;
use x11rb::errors::ReplyError;
pub type Cardinal = u32;
use super::*;
pub const CARDINAL_SIZE: usize = mem::size_of::<u32>();
pub type Cardinal = u32;
#[derive(Debug, Clone)]
pub enum GetPropertyError {
X11rbError(Arc<ReplyError>),
@@ -15,12 +20,6 @@ pub enum GetPropertyError {
FormatMismatch(c_int),
}
impl<T: Into<ReplyError>> From<T> for GetPropertyError {
fn from(e: T) -> Self {
Self::X11rbError(Arc::new(e.into()))
}
}
impl GetPropertyError {
pub fn is_actual_property_type(&self, t: xproto::Atom) -> bool {
if let GetPropertyError::TypeMismatch(actual_type) = *self {
@@ -31,6 +30,24 @@ impl GetPropertyError {
}
}
impl<T: Into<ReplyError>> From<T> for GetPropertyError {
fn from(e: T) -> Self {
Self::X11rbError(Arc::new(e.into()))
}
}
impl fmt::Display for GetPropertyError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
GetPropertyError::X11rbError(err) => err.fmt(f),
GetPropertyError::TypeMismatch(err) => write!(f, "type mismatch: {err}"),
GetPropertyError::FormatMismatch(err) => write!(f, "format mismatch: {err}"),
}
}
}
impl Error for GetPropertyError {}
// Number of 32-bit chunks to retrieve per iteration of get_property's inner loop.
// To test if `get_property` works correctly, set this to 1.
const PROPERTY_BUFFER_SIZE: u32 = 1024; // 4k of RAM ought to be enough for anyone!

View File

@@ -33,13 +33,11 @@ impl XConnection {
.reply()?;
// Read the _XSETTINGS_SETTINGS property.
let data: Vec<u8> = self
.get_property(
owner.owner,
atoms[_XSETTINGS_SETTINGS],
atoms[_XSETTINGS_SETTINGS],
)
.unwrap();
let data: Vec<u8> = self.get_property(
owner.owner,
atoms[_XSETTINGS_SETTINGS],
atoms[_XSETTINGS_SETTINGS],
)?;
// Parse the property.
let dpi_setting = read_settings(&data)?