From b7a7f592989092974bd4135f1154ae5d6d875b0b Mon Sep 17 00:00:00 2001 From: daxpedda Date: Mon, 5 Aug 2024 12:01:31 +0200 Subject: [PATCH] Remove `DeviceEvent::Added` and `Removed` This had no real use because we don't expose any information on `DeviceId` except on Windows. But there we only expose the name. The assumption is that this was originally added for gamepad support, which never made it into Winit. --- src/changelog/unreleased.md | 1 + src/event.rs | 5 --- .../linux/x11/event_processor.rs | 15 +------ src/platform_impl/windows/event_loop.rs | 45 +++++++------------ 4 files changed, 18 insertions(+), 48 deletions(-) diff --git a/src/changelog/unreleased.md b/src/changelog/unreleased.md index d987a4d8c2..2d920426fc 100644 --- a/src/changelog/unreleased.md +++ b/src/changelog/unreleased.md @@ -104,6 +104,7 @@ changelog entry. - On Web, remove unused `platform::web::CustomCursorError::Animation`. - Remove the `rwh_04` and `rwh_05` cargo feature and the corresponding `raw-window-handle` v0.4 and v0.5 support. v0.6 remains in place and is enabled by default. +- Remove `DeviceEvent::Added` and `DeviceEvent::Removed`. ### Fixed diff --git a/src/event.rs b/src/event.rs index 38eec58a1c..79c91a56cc 100644 --- a/src/event.rs +++ b/src/event.rs @@ -460,9 +460,6 @@ impl DeviceId { /// Note that these events are delivered regardless of input focus. #[derive(Clone, Debug, PartialEq)] pub enum DeviceEvent { - Added, - Removed, - /// Change in physical position of a pointing device. /// /// This represents raw, unfiltered physical motion. Not to be confused with @@ -1104,8 +1101,6 @@ mod tests { let with_device_event = |dev_ev| x(event::Event::DeviceEvent { device_id: did, event: dev_ev }); - with_device_event(Added); - with_device_event(Removed); with_device_event(MouseMotion { delta: (0.0, 0.0).into() }); with_device_event(MouseWheel { delta: event::MouseScrollDelta::LineDelta(0.0, 0.0), diff --git a/src/platform_impl/linux/x11/event_processor.rs b/src/platform_impl/linux/x11/event_processor.rs index b0aadc3596..eb098f5d75 100644 --- a/src/platform_impl/linux/x11/event_processor.rs +++ b/src/platform_impl/linux/x11/event_processor.rs @@ -280,7 +280,7 @@ impl EventProcessor { xinput2::XI_HierarchyChanged => { let xev: &XIHierarchyEvent = unsafe { xev.as_event() }; - self.xinput2_hierarchy_changed(xev, &mut callback); + self.xinput2_hierarchy_changed(xev); }, _ => {}, } @@ -1496,10 +1496,7 @@ impl EventProcessor { }); } - fn xinput2_hierarchy_changed(&mut self, xev: &XIHierarchyEvent, mut callback: F) - where - F: FnMut(&RootAEL, Event), - { + fn xinput2_hierarchy_changed(&mut self, xev: &XIHierarchyEvent) { let wt = Self::window_target(&self.target); // Set the timestamp. @@ -1508,15 +1505,7 @@ impl EventProcessor { for info in infos { if 0 != info.flags & (xinput2::XISlaveAdded | xinput2::XIMasterAdded) { self.init_device(info.deviceid as xinput::DeviceId); - callback(&self.target, Event::DeviceEvent { - device_id: mkdid(info.deviceid as xinput::DeviceId), - event: DeviceEvent::Added, - }); } else if 0 != info.flags & (xinput2::XISlaveRemoved | xinput2::XIMasterRemoved) { - callback(&self.target, Event::DeviceEvent { - device_id: mkdid(info.deviceid as xinput::DeviceId), - event: DeviceEvent::Removed, - }); let mut devices = self.devices.borrow_mut(); devices.remove(&DeviceId(info.deviceid as xinput::DeviceId)); } diff --git a/src/platform_impl/windows/event_loop.rs b/src/platform_impl/windows/event_loop.rs index c151bc04b1..41dc13e35b 100644 --- a/src/platform_impl/windows/event_loop.rs +++ b/src/platform_impl/windows/event_loop.rs @@ -38,21 +38,20 @@ use windows_sys::Win32::UI::WindowsAndMessaging::{ CreateWindowExW, DefWindowProcW, DestroyWindow, DispatchMessageW, GetClientRect, GetCursorPos, GetMenu, GetMessageW, KillTimer, LoadCursorW, PeekMessageW, PostMessageW, RegisterClassExW, RegisterWindowMessageA, SetCursor, SetTimer, SetWindowPos, TranslateMessage, CREATESTRUCTW, - GIDC_ARRIVAL, GIDC_REMOVAL, GWL_STYLE, GWL_USERDATA, HTCAPTION, HTCLIENT, MINMAXINFO, - MNC_CLOSE, MSG, NCCALCSIZE_PARAMS, PM_REMOVE, PT_PEN, PT_TOUCH, RI_MOUSE_HWHEEL, - RI_MOUSE_WHEEL, SC_MINIMIZE, SC_RESTORE, SIZE_MAXIMIZED, SWP_NOACTIVATE, SWP_NOMOVE, - SWP_NOSIZE, SWP_NOZORDER, WHEEL_DELTA, WINDOWPOS, WMSZ_BOTTOM, WMSZ_BOTTOMLEFT, - WMSZ_BOTTOMRIGHT, WMSZ_LEFT, WMSZ_RIGHT, WMSZ_TOP, WMSZ_TOPLEFT, WMSZ_TOPRIGHT, - WM_CAPTURECHANGED, WM_CLOSE, WM_CREATE, WM_DESTROY, WM_DPICHANGED, WM_ENTERSIZEMOVE, - WM_EXITSIZEMOVE, WM_GETMINMAXINFO, WM_IME_COMPOSITION, WM_IME_ENDCOMPOSITION, - WM_IME_SETCONTEXT, WM_IME_STARTCOMPOSITION, WM_INPUT, WM_INPUT_DEVICE_CHANGE, WM_KEYDOWN, - WM_KEYUP, WM_KILLFOCUS, WM_LBUTTONDOWN, WM_LBUTTONUP, WM_MBUTTONDOWN, WM_MBUTTONUP, - WM_MENUCHAR, WM_MOUSEHWHEEL, WM_MOUSEMOVE, WM_MOUSEWHEEL, WM_NCACTIVATE, WM_NCCALCSIZE, - WM_NCCREATE, WM_NCDESTROY, WM_NCLBUTTONDOWN, WM_PAINT, WM_POINTERDOWN, WM_POINTERUP, - WM_POINTERUPDATE, WM_RBUTTONDOWN, WM_RBUTTONUP, WM_SETCURSOR, WM_SETFOCUS, WM_SETTINGCHANGE, - WM_SIZE, WM_SIZING, WM_SYSCOMMAND, WM_SYSKEYDOWN, WM_SYSKEYUP, WM_TOUCH, WM_WINDOWPOSCHANGED, - WM_WINDOWPOSCHANGING, WM_XBUTTONDOWN, WM_XBUTTONUP, WNDCLASSEXW, WS_EX_LAYERED, - WS_EX_NOACTIVATE, WS_EX_TOOLWINDOW, WS_EX_TRANSPARENT, WS_OVERLAPPED, WS_POPUP, WS_VISIBLE, + GWL_STYLE, GWL_USERDATA, HTCAPTION, HTCLIENT, MINMAXINFO, MNC_CLOSE, MSG, NCCALCSIZE_PARAMS, + PM_REMOVE, PT_PEN, PT_TOUCH, RI_MOUSE_HWHEEL, RI_MOUSE_WHEEL, SC_MINIMIZE, SC_RESTORE, + SIZE_MAXIMIZED, SWP_NOACTIVATE, SWP_NOMOVE, SWP_NOSIZE, SWP_NOZORDER, WHEEL_DELTA, WINDOWPOS, + WMSZ_BOTTOM, WMSZ_BOTTOMLEFT, WMSZ_BOTTOMRIGHT, WMSZ_LEFT, WMSZ_RIGHT, WMSZ_TOP, WMSZ_TOPLEFT, + WMSZ_TOPRIGHT, WM_CAPTURECHANGED, WM_CLOSE, WM_CREATE, WM_DESTROY, WM_DPICHANGED, + WM_ENTERSIZEMOVE, WM_EXITSIZEMOVE, WM_GETMINMAXINFO, WM_IME_COMPOSITION, WM_IME_ENDCOMPOSITION, + WM_IME_SETCONTEXT, WM_IME_STARTCOMPOSITION, WM_INPUT, WM_KEYDOWN, WM_KEYUP, WM_KILLFOCUS, + WM_LBUTTONDOWN, WM_LBUTTONUP, WM_MBUTTONDOWN, WM_MBUTTONUP, WM_MENUCHAR, WM_MOUSEHWHEEL, + WM_MOUSEMOVE, WM_MOUSEWHEEL, WM_NCACTIVATE, WM_NCCALCSIZE, WM_NCCREATE, WM_NCDESTROY, + WM_NCLBUTTONDOWN, WM_PAINT, WM_POINTERDOWN, WM_POINTERUP, WM_POINTERUPDATE, WM_RBUTTONDOWN, + WM_RBUTTONUP, WM_SETCURSOR, WM_SETFOCUS, WM_SETTINGCHANGE, WM_SIZE, WM_SIZING, WM_SYSCOMMAND, + WM_SYSKEYDOWN, WM_SYSKEYUP, WM_TOUCH, WM_WINDOWPOSCHANGED, WM_WINDOWPOSCHANGING, + WM_XBUTTONDOWN, WM_XBUTTONUP, WNDCLASSEXW, WS_EX_LAYERED, WS_EX_NOACTIVATE, WS_EX_TOOLWINDOW, + WS_EX_TRANSPARENT, WS_OVERLAPPED, WS_POPUP, WS_VISIBLE, }; use super::window::set_skip_taskbar; @@ -61,7 +60,7 @@ use crate::application::ApplicationHandler; use crate::dpi::{PhysicalPosition, PhysicalSize}; use crate::error::EventLoopError; use crate::event::{ - DeviceEvent, Event, Force, Ime, InnerSizeWriter, RawKeyEvent, Touch, TouchPhase, WindowEvent, + Event, Force, Ime, InnerSizeWriter, RawKeyEvent, Touch, TouchPhase, WindowEvent, }; use crate::event_loop::{ActiveEventLoop as RootAEL, ControlFlow, DeviceEvents}; use crate::keyboard::ModifiersState; @@ -2348,20 +2347,6 @@ unsafe extern "system" fn thread_event_target_callback( // when opening them. DefWindowProcW(window, msg, wparam, lparam) }, - - WM_INPUT_DEVICE_CHANGE => { - let event = match wparam as u32 { - GIDC_ARRIVAL => DeviceEvent::Added, - GIDC_REMOVAL => DeviceEvent::Removed, - _ => unreachable!(), - }; - - userdata - .send_event(Event::DeviceEvent { device_id: wrap_device_id(lparam as u32), event }); - - 0 - }, - WM_INPUT => { if let Some(data) = raw_input::get_raw_input_data(lparam as _) { unsafe { handle_raw_input(&userdata, data) };