From 69b8a07ae01d8debeea710addf8c4a57b1833e2d Mon Sep 17 00:00:00 2001 From: SuchAFuriousDeath <48620541+SuchAFuriousDeath@users.noreply.github.com> Date: Tue, 24 Feb 2026 15:15:49 +0100 Subject: [PATCH] winit-x11: fix debug mode overflow panic in `set_timestamp` Fixes #4484 --- src/changelog/unreleased.md | 1 + src/platform_impl/linux/x11/xdisplay.rs | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/changelog/unreleased.md b/src/changelog/unreleased.md index 58f0de13d..7cfbe9145 100644 --- a/src/changelog/unreleased.md +++ b/src/changelog/unreleased.md @@ -44,3 +44,4 @@ changelog entry. - On macOS, fixed crash when dragging non-file content onto window. - On X11, fix `set_hittest` not working on some window managers. +- On X11, fix debug mode overflow panic in `set_timestamp`. diff --git a/src/platform_impl/linux/x11/xdisplay.rs b/src/platform_impl/linux/x11/xdisplay.rs index 902d0ce4c..79da0d1fa 100644 --- a/src/platform_impl/linux/x11/xdisplay.rs +++ b/src/platform_impl/linux/x11/xdisplay.rs @@ -234,9 +234,7 @@ impl XConnection { // Store the timestamp in the slot if it's greater than the last one. let mut last_timestamp = self.timestamp.load(Ordering::Relaxed); loop { - let wrapping_sub = |a: xproto::Timestamp, b: xproto::Timestamp| (a as i32) - (b as i32); - - if wrapping_sub(timestamp, last_timestamp) <= 0 { + if (timestamp as i32).wrapping_sub(last_timestamp as i32) <= 0 { break; }