From 0524e01a3c57214408ed96fe136c899819d21ae9 Mon Sep 17 00:00:00 2001 From: Julian Orth Date: Wed, 14 May 2025 14:07:25 +0200 Subject: [PATCH] metal: sort InputDevice functions --- src/backends/metal.rs | 108 +++++++++++++++++++++--------------------- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/src/backends/metal.rs b/src/backends/metal.rs index 2ab08d57..9e893a3b 100644 --- a/src/backends/metal.rs +++ b/src/backends/metal.rs @@ -559,6 +559,10 @@ impl InputDevice for MetalInputDevice { } } + fn left_handed(&self) -> Option { + self.effective.left_handed.get() + } + fn set_left_handed(&self, left_handed: bool) { self.desired.left_handed.set(Some(left_handed)); if let Some(dev) = self.inputdev.get() { @@ -571,6 +575,16 @@ impl InputDevice for MetalInputDevice { } } + fn accel_profile(&self) -> Option { + let p = self.effective.accel_profile.get()?; + let p = match p { + LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT => InputDeviceAccelProfile::Flat, + LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE => InputDeviceAccelProfile::Adaptive, + _ => return None, + }; + Some(p) + } + fn set_accel_profile(&self, profile: InputDeviceAccelProfile) { let profile = match profile { InputDeviceAccelProfile::Flat => LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT, @@ -579,6 +593,10 @@ impl InputDevice for MetalInputDevice { self.set_accel_profile_(profile); } + fn accel_speed(&self) -> Option { + self.effective.accel_speed.get() + } + fn set_accel_speed(&self, speed: f64) { self.desired.accel_speed.set(Some(speed)); if let Some(dev) = self.inputdev.get() { @@ -591,10 +609,30 @@ impl InputDevice for MetalInputDevice { } } + fn transform_matrix(&self) -> Option { + self.transform_matrix.get() + } + fn set_transform_matrix(&self, matrix: TransformMatrix) { self.transform_matrix.set(Some(matrix)); } + fn calibration_matrix(&self) -> Option<[[f32; 3]; 2]> { + self.effective.calibration_matrix.get() + } + + fn set_calibration_matrix(&self, m: [[f32; 3]; 2]) { + self.desired.calibration_matrix.set(Some(m)); + if let Some(dev) = self.inputdev.get() { + if dev.device().has_calibration_matrix() { + dev.device().set_calibration_matrix(m); + self.effective + .calibration_matrix + .set(Some(dev.device().get_calibration_matrix())); + } + } + } + fn name(&self) -> Rc { self.name.get() } @@ -603,6 +641,10 @@ impl InputDevice for MetalInputDevice { Some(self.devnum) } + fn tap_enabled(&self) -> Option { + self.effective.tap_enabled.get() + } + fn set_tap_enabled(&self, enabled: bool) { self.desired.tap_enabled.set(Some(enabled)); if let Some(dev) = self.inputdev.get() { @@ -615,6 +657,10 @@ impl InputDevice for MetalInputDevice { } } + fn drag_enabled(&self) -> Option { + self.effective.drag_enabled.get() + } + fn set_drag_enabled(&self, enabled: bool) { self.desired.drag_enabled.set(Some(enabled)); if let Some(dev) = self.inputdev.get() { @@ -627,6 +673,10 @@ impl InputDevice for MetalInputDevice { } } + fn drag_lock_enabled(&self) -> Option { + self.effective.drag_lock_enabled.get() + } + fn set_drag_lock_enabled(&self, enabled: bool) { self.desired.drag_lock_enabled.set(Some(enabled)); if let Some(dev) = self.inputdev.get() { @@ -639,6 +689,10 @@ impl InputDevice for MetalInputDevice { } } + fn natural_scrolling_enabled(&self) -> Option { + self.effective.natural_scrolling_enabled.get() + } + fn set_natural_scrolling_enabled(&self, enabled: bool) { self.desired.natural_scrolling_enabled.set(Some(enabled)); if let Some(dev) = self.inputdev.get() { @@ -651,44 +705,6 @@ impl InputDevice for MetalInputDevice { } } - fn left_handed(&self) -> Option { - self.effective.left_handed.get() - } - - fn accel_profile(&self) -> Option { - let p = self.effective.accel_profile.get()?; - let p = match p { - LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT => InputDeviceAccelProfile::Flat, - LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE => InputDeviceAccelProfile::Adaptive, - _ => return None, - }; - Some(p) - } - - fn accel_speed(&self) -> Option { - self.effective.accel_speed.get() - } - - fn transform_matrix(&self) -> Option { - self.transform_matrix.get() - } - - fn tap_enabled(&self) -> Option { - self.effective.tap_enabled.get() - } - - fn drag_enabled(&self) -> Option { - self.effective.drag_enabled.get() - } - - fn drag_lock_enabled(&self) -> Option { - self.effective.drag_lock_enabled.get() - } - - fn natural_scrolling_enabled(&self) -> Option { - self.effective.natural_scrolling_enabled.get() - } - fn tablet_info(&self) -> Option> { let dev = self.inputdev.get()?; let dev = dev.device(); @@ -757,22 +773,6 @@ impl InputDevice for MetalInputDevice { groups, })) } - - fn calibration_matrix(&self) -> Option<[[f32; 3]; 2]> { - self.effective.calibration_matrix.get() - } - - fn set_calibration_matrix(&self, m: [[f32; 3]; 2]) { - self.desired.calibration_matrix.set(Some(m)); - if let Some(dev) = self.inputdev.get() { - if dev.device().has_calibration_matrix() { - dev.device().set_calibration_matrix(m); - self.effective - .calibration_matrix - .set(Some(dev.device().get_calibration_matrix())); - } - } - } } impl MetalInputDevice {