mirror of
https://github.com/rust-windowing/winit.git
synced 2026-06-26 14:49:07 -04:00
Bump MSRV to 1.85 and edition to 2024
This commit is contained in:
@@ -14,7 +14,7 @@ use std::{fmt, mem, ptr, slice, str};
|
||||
use calloop::generic::Generic;
|
||||
use calloop::ping::Ping;
|
||||
use calloop::{EventLoop as Loop, Readiness};
|
||||
use libc::{setlocale, LC_CTYPE};
|
||||
use libc::{LC_CTYPE, setlocale};
|
||||
use tracing::warn;
|
||||
use winit_common::xkb::Context;
|
||||
use winit_core::application::ApplicationHandler;
|
||||
@@ -43,7 +43,7 @@ use crate::ime::{self, Ime, ImeCreationError, ImeSender};
|
||||
use crate::util::{self, CustomCursor};
|
||||
use crate::window::{UnownedWindow, Window};
|
||||
use crate::xdisplay::{XConnection, XError, XNotSupported};
|
||||
use crate::{ffi, xsettings, XlibErrorHook};
|
||||
use crate::{XlibErrorHook, ffi, xsettings};
|
||||
|
||||
// Xinput constants not defined in x11rb
|
||||
pub(crate) const ALL_DEVICES: u16 = 0;
|
||||
|
||||
@@ -33,8 +33,8 @@ use xkbcommon_dl::xkb_mod_mask_t;
|
||||
use crate::atoms::*;
|
||||
use crate::dnd::{Dnd, DndState};
|
||||
use crate::event_loop::{
|
||||
mkdid, mkwid, ActiveEventLoop, CookieResultExt, Device, DeviceInfo, DeviceType,
|
||||
ScrollOrientation, ALL_DEVICES,
|
||||
ALL_DEVICES, ActiveEventLoop, CookieResultExt, Device, DeviceInfo, DeviceType,
|
||||
ScrollOrientation, mkdid, mkwid,
|
||||
};
|
||||
use crate::ime::{ImeEvent, ImeEventReceiver, ImeReceiver, ImeRequest};
|
||||
use crate::util;
|
||||
|
||||
@@ -5,7 +5,7 @@ use std::sync::Arc;
|
||||
|
||||
use super::context::{ImeContext, ImeContextCreationError};
|
||||
use super::ffi;
|
||||
use super::inner::{close_im, ImeInner};
|
||||
use super::inner::{ImeInner, close_im};
|
||||
use super::input_method::PotentialInputMethods;
|
||||
use crate::xdisplay::{XConnection, XError};
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ use std::{fmt, mem, ptr};
|
||||
use x11_dl::xlib::{XIMCallback, XIMPreeditCaretCallbackStruct, XIMPreeditDrawCallbackStruct};
|
||||
|
||||
use super::input_method::{InputMethod, Style, XIMStyle};
|
||||
use super::{ffi, util, ImeEvent, ImeEventSender};
|
||||
use super::{ImeEvent, ImeEventSender, ffi, util};
|
||||
use crate::xdisplay::{XConnection, XError};
|
||||
|
||||
/// IME creation error.
|
||||
|
||||
@@ -4,7 +4,7 @@ use std::sync::Arc;
|
||||
|
||||
use super::context::ImeContext;
|
||||
use super::input_method::{InputMethod, PotentialInputMethods};
|
||||
use super::{ffi, ImeEventSender};
|
||||
use super::{ImeEventSender, ffi};
|
||||
use crate::xdisplay::{XConnection, XError};
|
||||
|
||||
pub(crate) unsafe fn close_im(xconn: &Arc<XConnection>, im: ffi::XIM) -> Result<(), XError> {
|
||||
|
||||
@@ -25,11 +25,7 @@ unsafe fn open_im(xconn: &Arc<XConnection>, locale_modifiers: &CStr) -> Option<f
|
||||
(xconn.xlib.XOpenIM)(xconn.display, ptr::null_mut(), ptr::null_mut(), ptr::null_mut())
|
||||
};
|
||||
|
||||
if im.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(im)
|
||||
}
|
||||
if im.is_null() { None } else { Some(im) }
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
||||
@@ -6,8 +6,8 @@ mod inner;
|
||||
mod input_method;
|
||||
|
||||
use std::fmt;
|
||||
use std::sync::mpsc::{Receiver, Sender};
|
||||
use std::sync::Arc;
|
||||
use std::sync::mpsc::{Receiver, Sender};
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -15,7 +15,7 @@ use serde::{Deserialize, Serialize};
|
||||
use self::callbacks::*;
|
||||
use self::context::ImeContext;
|
||||
pub use self::context::ImeContextCreationError;
|
||||
use self::inner::{close_im, ImeInner};
|
||||
use self::inner::{ImeInner, close_im};
|
||||
use self::input_method::PotentialInputMethods;
|
||||
use crate::xdisplay::{XConnection, XError};
|
||||
use crate::{ffi, util};
|
||||
|
||||
@@ -10,9 +10,7 @@ pub use crate::event_loop::{ActiveEventLoop, EventLoop};
|
||||
pub use crate::window::Window;
|
||||
|
||||
macro_rules! os_error {
|
||||
($error:expr) => {{
|
||||
winit_core::error::OsError::new(line!(), file!(), $error)
|
||||
}};
|
||||
($error:expr) => {{ winit_core::error::OsError::new(line!(), file!(), $error) }};
|
||||
}
|
||||
|
||||
mod activation;
|
||||
|
||||
@@ -97,9 +97,7 @@ impl XConnection {
|
||||
/// Find the render format that corresponds to ARGB32.
|
||||
fn find_argb32_format(&self) -> Result<render::Pictformat, X11Error> {
|
||||
macro_rules! direct {
|
||||
($format:expr, $shift_name:ident, $mask_name:ident, $shift:expr) => {{
|
||||
($format).direct.$shift_name == $shift && ($format).direct.$mask_name == 0xff
|
||||
}};
|
||||
($format:expr, $shift_name:ident, $mask_name:ident, $shift:expr) => {{ ($format).direct.$shift_name == $shift && ($format).direct.$mask_name == 0xff }};
|
||||
}
|
||||
|
||||
self.render_formats()
|
||||
@@ -202,7 +200,7 @@ impl CustomCursor {
|
||||
let mut cursor = match cursor {
|
||||
CustomCursorSource::Image(cursor_image) => cursor_image,
|
||||
CustomCursorSource::Animation { .. } | CustomCursorSource::Url { .. } => {
|
||||
return Err(NotSupportedError::new("unsupported cursor kind").into())
|
||||
return Err(NotSupportedError::new("unsupported cursor kind").into());
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -13,11 +13,7 @@ pub enum StateOperation {
|
||||
|
||||
impl From<bool> for StateOperation {
|
||||
fn from(op: bool) -> Self {
|
||||
if op {
|
||||
StateOperation::Add
|
||||
} else {
|
||||
StateOperation::Remove
|
||||
}
|
||||
if op { StateOperation::Add } else { StateOperation::Remove }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,11 +9,7 @@ impl<'a, T> XSmartPointer<'a, T> {
|
||||
// You're responsible for only passing things to this that should be XFree'd.
|
||||
// Returns None if ptr is null.
|
||||
pub fn new(xconn: &'a XConnection, ptr: *mut T) -> Option<Self> {
|
||||
if !ptr.is_null() {
|
||||
Some(XSmartPointer { xconn, ptr })
|
||||
} else {
|
||||
None
|
||||
}
|
||||
if !ptr.is_null() { Some(XSmartPointer { xconn, ptr }) } else { None }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,11 +31,7 @@ pub fn calc_dpi_factor(
|
||||
// Quantize 1/12 step size
|
||||
let dpi_factor = ((ppmm * (12.0 * 25.4 / 96.0)).round() / 12.0).max(1.0);
|
||||
assert!(validate_scale_factor(dpi_factor));
|
||||
if dpi_factor <= 20. {
|
||||
dpi_factor
|
||||
} else {
|
||||
1.
|
||||
}
|
||||
if dpi_factor <= 20. { dpi_factor } else { 1. }
|
||||
}
|
||||
|
||||
impl XConnection {
|
||||
|
||||
@@ -34,14 +34,14 @@ use x11rb::protocol::{randr, xinput};
|
||||
|
||||
use crate::atoms::*;
|
||||
use crate::event_loop::{
|
||||
xinput_fp1616_to_float, ActivationItem, ActiveEventLoop, CookieResultExt, VoidCookie,
|
||||
WakeSender, X11Error, ALL_MASTER_DEVICES, ICONIC_STATE,
|
||||
ALL_MASTER_DEVICES, ActivationItem, ActiveEventLoop, CookieResultExt, ICONIC_STATE, VoidCookie,
|
||||
WakeSender, X11Error, xinput_fp1616_to_float,
|
||||
};
|
||||
use crate::ime::{ImeRequest, ImeSender};
|
||||
use crate::monitor::MonitorHandle as X11MonitorHandle;
|
||||
use crate::util::{self, rgba_to_cardinals, CustomCursor, SelectedCursor};
|
||||
use crate::util::{self, CustomCursor, SelectedCursor, rgba_to_cardinals};
|
||||
use crate::xdisplay::XConnection;
|
||||
use crate::{ffi, WindowAttributesX11, WindowType};
|
||||
use crate::{WindowAttributesX11, WindowType, ffi};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Window(Arc<UnownedWindow>);
|
||||
@@ -632,10 +632,10 @@ impl UnownedWindow {
|
||||
// the visual from the parent window, thus we have to query the visual
|
||||
// we've got when we built the window above.
|
||||
if visual == x11rb::COPY_FROM_PARENT {
|
||||
visual = leap!(leap!(xconn
|
||||
.xcb_connection()
|
||||
.get_window_attributes(xwindow as xproto::Window))
|
||||
.reply())
|
||||
visual = leap!(
|
||||
leap!(xconn.xcb_connection().get_window_attributes(xwindow as xproto::Window))
|
||||
.reply()
|
||||
)
|
||||
.visual;
|
||||
}
|
||||
|
||||
@@ -762,12 +762,14 @@ impl UnownedWindow {
|
||||
aspect: None,
|
||||
win_gravity: None,
|
||||
};
|
||||
leap!(leap!(normal_hints.set(
|
||||
xconn.xcb_connection(),
|
||||
window.xwindow as xproto::Window,
|
||||
xproto::AtomEnum::WM_NORMAL_HINTS,
|
||||
))
|
||||
.check());
|
||||
leap!(
|
||||
leap!(normal_hints.set(
|
||||
xconn.xcb_connection(),
|
||||
window.xwindow as xproto::Window,
|
||||
xproto::AtomEnum::WM_NORMAL_HINTS,
|
||||
))
|
||||
.check()
|
||||
);
|
||||
|
||||
// Set window icons
|
||||
if let Some(icon) =
|
||||
@@ -797,9 +799,9 @@ impl UnownedWindow {
|
||||
let sync_counter_id = leap!(xconn.xcb_connection().generate_id());
|
||||
window.sync_counter_id = NonZeroU32::new(sync_counter_id);
|
||||
|
||||
leap!(xconn
|
||||
.xcb_connection()
|
||||
.sync_create_counter(sync_counter_id, Int64::default()))
|
||||
leap!(
|
||||
xconn.xcb_connection().sync_create_counter(sync_counter_id, Int64::default())
|
||||
)
|
||||
.ignore_error();
|
||||
|
||||
let result = xconn.xcb_connection().change_property(
|
||||
@@ -896,14 +898,16 @@ impl UnownedWindow {
|
||||
/// Embed this window into a parent window.
|
||||
pub(super) fn embed_window(&self) -> Result<(), RequestError> {
|
||||
let atoms = self.xconn.atoms();
|
||||
leap!(leap!(self.xconn.change_property(
|
||||
self.xwindow,
|
||||
atoms[_XEMBED],
|
||||
atoms[_XEMBED],
|
||||
xproto::PropMode::REPLACE,
|
||||
&[0u32, 1u32],
|
||||
))
|
||||
.check());
|
||||
leap!(
|
||||
leap!(self.xconn.change_property(
|
||||
self.xwindow,
|
||||
atoms[_XEMBED],
|
||||
atoms[_XEMBED],
|
||||
xproto::PropMode::REPLACE,
|
||||
&[0u32, 1u32],
|
||||
))
|
||||
.check()
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -1094,11 +1098,7 @@ impl UnownedWindow {
|
||||
|
||||
if let Some(native_mode) = video_mode.and_then(|requested| {
|
||||
monitor.video_modes.iter().find_map(|mode| {
|
||||
if &mode.mode == requested {
|
||||
Some(mode.native_mode)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
if &mode.mode == requested { Some(mode.native_mode) } else { None }
|
||||
})
|
||||
}) {
|
||||
// FIXME: this is actually not correct if we're setting the
|
||||
@@ -1454,7 +1454,7 @@ impl UnownedWindow {
|
||||
|
||||
match (visible, shared_state.visibility) {
|
||||
(true, Visibility::Yes) | (true, Visibility::YesWait) | (false, Visibility::No) => {
|
||||
return
|
||||
return;
|
||||
},
|
||||
_ => (),
|
||||
}
|
||||
|
||||
@@ -192,11 +192,7 @@ impl XConnection {
|
||||
#[inline]
|
||||
pub fn check_errors(&self) -> Result<(), XError> {
|
||||
let error = self.latest_error.lock().unwrap().take();
|
||||
if let Some(error) = error {
|
||||
Err(error)
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
if let Some(error) = error { Err(error) } else { Ok(()) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
||||
@@ -43,10 +43,10 @@ impl XConnection {
|
||||
let base_dpi = match dpi_setting.data {
|
||||
SettingData::Integer(dpi) => dpi as f64,
|
||||
SettingData::String(_) => {
|
||||
return Err(ParserError::BadType(SettingType::String).into())
|
||||
return Err(ParserError::BadType(SettingType::String).into());
|
||||
},
|
||||
SettingData::Color(_) => {
|
||||
return Err(ParserError::BadType(SettingType::Color).into())
|
||||
return Err(ParserError::BadType(SettingType::Color).into());
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user