From 21db472f8bdd39bc28410e22f2f93a8ee3d1d043 Mon Sep 17 00:00:00 2001 From: Victoria Brekenfeld Date: Mon, 30 Jan 2023 23:19:36 +0100 Subject: [PATCH] deps: Update smithay & relative motion events --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/input/mod.rs | 27 ++++++++++++++++------- src/shell/element/mod.rs | 9 +++++++- src/shell/element/stack.rs | 11 ++++++++- src/shell/element/surface.rs | 17 ++++++++++++++ src/shell/element/window.rs | 10 ++++++++- src/shell/focus/target.rs | 21 ++++++++++++++++-- src/shell/grabs.rs | 15 ++++++++++++- src/shell/layout/floating/grabs/moving.rs | 13 ++++++++++- src/shell/layout/floating/grabs/resize.rs | 13 ++++++++++- src/shell/layout/tiling/grabs.rs | 13 ++++++++++- src/utils/iced.rs | 10 ++++++++- 13 files changed, 143 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 78bf6d65..75fd4abb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3282,7 +3282,7 @@ checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" [[package]] name = "smithay" version = "0.3.0" -source = "git+https://github.com/pop-os/smithay?rev=406a40d6ec#406a40d6ec09723d8f1c73f3b7c9d62494cdbd13" +source = "git+https://github.com/pop-os/smithay?rev=139c6e6079#139c6e6079da3624f58edf5c59bd7f264aede985" dependencies = [ "appendlist", "bitflags", diff --git a/Cargo.toml b/Cargo.toml index 0659c7ee..3e260f9c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -70,4 +70,4 @@ debug = true lto = "fat" [patch."https://github.com/Smithay/smithay.git"] -smithay = { git = "https://github.com/pop-os/smithay", rev = "406a40d6ec" } +smithay = { git = "https://github.com/pop-os/smithay", rev = "139c6e6079" } diff --git a/src/input/mod.rs b/src/input/mod.rs index 5b29bdfe..23c05aa8 100644 --- a/src/input/mod.rs +++ b/src/input/mod.rs @@ -23,7 +23,7 @@ use smithay::{ desktop::{layer_map_for_output, space::SpaceElement, WindowSurfaceType}, input::{ keyboard::{keysyms, FilterResult, KeysymHandle, XkbConfig}, - pointer::{AxisFrame, ButtonEvent, CursorImageStatus, MotionEvent}, + pointer::{AxisFrame, ButtonEvent, CursorImageStatus, MotionEvent, RelativeMotionEvent}, Seat, SeatState, }, output::Output, @@ -207,7 +207,7 @@ impl State { slog_scope::trace!("key"; "keycode" => keycode, "state" => format!("{:?}", state)); let serial = SERIAL_COUNTER.next_serial(); - let time = Event::time(&event); + let time = Event::time_msec(&event); if let Some(action) = seat .get_keyboard() .unwrap() @@ -337,13 +337,23 @@ impl State { session.cursor_info(seat, InputType::Pointer, geometry, offset); } } - seat.get_pointer().unwrap().motion( + let ptr = seat.get_pointer().unwrap(); + ptr.motion( self, - under, + under.clone(), &MotionEvent { location: position, serial, - time: event.time(), + time: event.time_msec(), + }, + ); + ptr.relative_motion( + self, + under, + &RelativeMotionEvent { + delta: event.delta(), + delta_unaccel: event.delta_unaccel(), + utime: event.time(), }, ); break; @@ -393,7 +403,7 @@ impl State { &MotionEvent { location: position, serial, - time: event.time(), + time: event.time_msec(), }, ); @@ -492,7 +502,7 @@ impl State { button, state: event.state(), serial, - time: event.time(), + time: event.time_msec(), }, ); break; @@ -516,7 +526,8 @@ impl State { let vertical_amount_discrete = event.amount_discrete(Axis::Vertical); { - let mut frame = AxisFrame::new(event.time()).source(event.source()); + let mut frame = + AxisFrame::new(event.time_msec()).source(event.source()); if horizontal_amount != 0.0 { frame = frame.value(Axis::Horizontal, horizontal_amount); if let Some(discrete) = horizontal_amount_discrete { diff --git a/src/shell/element/mod.rs b/src/shell/element/mod.rs index 615e8b9c..8b29f4df 100644 --- a/src/shell/element/mod.rs +++ b/src/shell/element/mod.rs @@ -16,7 +16,7 @@ use smithay::{ desktop::{space::SpaceElement, PopupManager, WindowSurfaceType}, input::{ keyboard::{KeyboardTarget, KeysymHandle, ModifiersState}, - pointer::{AxisFrame, ButtonEvent, MotionEvent, PointerTarget}, + pointer::{AxisFrame, ButtonEvent, MotionEvent, PointerTarget, RelativeMotionEvent}, Seat, }, output::Output, @@ -573,6 +573,13 @@ impl PointerTarget for CosmicMapped { _ => {} } } + fn relative_motion(&self, seat: &Seat, data: &mut State, event: &RelativeMotionEvent) { + match &self.element { + CosmicMappedInternal::Stack(s) => PointerTarget::relative_motion(s, seat, data, event), + CosmicMappedInternal::Window(w) => PointerTarget::relative_motion(w, seat, data, event), + _ => {} + } + } fn button(&self, seat: &Seat, data: &mut State, event: &ButtonEvent) { match &self.element { CosmicMappedInternal::Stack(s) => PointerTarget::button(s, seat, data, event), diff --git a/src/shell/element/stack.rs b/src/shell/element/stack.rs index f2489a3e..724f88ef 100644 --- a/src/shell/element/stack.rs +++ b/src/shell/element/stack.rs @@ -21,7 +21,7 @@ use smithay::{ desktop::space::SpaceElement, input::{ keyboard::{KeyboardTarget, KeysymHandle, ModifiersState}, - pointer::{AxisFrame, ButtonEvent, MotionEvent, PointerTarget}, + pointer::{AxisFrame, ButtonEvent, MotionEvent, PointerTarget, RelativeMotionEvent}, Seat, }, output::Output, @@ -491,6 +491,15 @@ impl PointerTarget for CosmicStack { } } + fn relative_motion(&self, seat: &Seat, data: &mut State, event: &RelativeMotionEvent) { + self.0.with_program(|p| { + if p.current_focus() == Focus::Window { + let window = &p.windows.lock().unwrap()[p.active.load(Ordering::SeqCst)]; + window.relative_motion(seat, data, event) + } + }) + } + fn button(&self, seat: &Seat, data: &mut State, event: &ButtonEvent) { if let Some((location, _serial, _time)) = self .0 diff --git a/src/shell/element/surface.rs b/src/shell/element/surface.rs index 172d85cb..9ea91eaa 100644 --- a/src/shell/element/surface.rs +++ b/src/shell/element/surface.rs @@ -537,6 +537,23 @@ impl PointerTarget for CosmicSurface { } } + fn relative_motion( + &self, + seat: &smithay::input::Seat, + data: &mut crate::state::State, + event: &smithay::input::pointer::RelativeMotionEvent, + ) { + match self { + CosmicSurface::Wayland(window) => { + PointerTarget::relative_motion(window, seat, data, event) + } + CosmicSurface::X11(surface) => { + PointerTarget::relative_motion(surface, seat, data, event) + } + _ => unreachable!(), + } + } + fn button( &self, seat: &smithay::input::Seat, diff --git a/src/shell/element/window.rs b/src/shell/element/window.rs index a4ce5548..90623643 100644 --- a/src/shell/element/window.rs +++ b/src/shell/element/window.rs @@ -25,7 +25,7 @@ use smithay::{ desktop::space::SpaceElement, input::{ keyboard::{KeyboardTarget, KeysymHandle, ModifiersState}, - pointer::{AxisFrame, ButtonEvent, MotionEvent, PointerTarget}, + pointer::{AxisFrame, ButtonEvent, MotionEvent, PointerTarget, RelativeMotionEvent}, Seat, }, output::Output, @@ -468,6 +468,14 @@ impl PointerTarget for CosmicWindow { } } + fn relative_motion(&self, seat: &Seat, data: &mut State, event: &RelativeMotionEvent) { + self.0.with_program(|p| { + if !p.has_ssd() || p.current_focus() == Focus::Window { + PointerTarget::relative_motion(&p.window, seat, data, event) + } + }) + } + fn button(&self, seat: &Seat, data: &mut State, event: &ButtonEvent) { match self.0.with_program(|p| p.current_focus()) { Focus::Header => { diff --git a/src/shell/focus/target.rs b/src/shell/focus/target.rs index d686c8d2..39d6481b 100644 --- a/src/shell/focus/target.rs +++ b/src/shell/focus/target.rs @@ -10,7 +10,7 @@ use smithay::{ desktop::{LayerSurface, PopupKind}, input::{ keyboard::{KeyboardTarget, KeysymHandle, ModifiersState}, - pointer::{AxisFrame, ButtonEvent, MotionEvent, PointerTarget}, + pointer::{AxisFrame, ButtonEvent, MotionEvent, PointerTarget, RelativeMotionEvent}, Seat, }, output::WeakOutput, @@ -107,7 +107,24 @@ impl PointerTarget for PointerFocusTarget { PointerFocusTarget::Popup(p) => { PointerTarget::motion(p.wl_surface(), seat, data, event) } - PointerFocusTarget::OverrideRedirect(s) => PointerTarget::enter(s, seat, data, event), + PointerFocusTarget::OverrideRedirect(s) => PointerTarget::motion(s, seat, data, event), + } + } + fn relative_motion(&self, seat: &Seat, data: &mut State, event: &RelativeMotionEvent) { + match self { + PointerFocusTarget::Element(w) => PointerTarget::relative_motion(w, seat, data, event), + PointerFocusTarget::Fullscreen(w) => { + PointerTarget::relative_motion(w, seat, data, event) + } + PointerFocusTarget::LayerSurface(l) => { + PointerTarget::relative_motion(l, seat, data, event) + } + PointerFocusTarget::Popup(p) => { + PointerTarget::relative_motion(p.wl_surface(), seat, data, event) + } + PointerFocusTarget::OverrideRedirect(s) => { + PointerTarget::relative_motion(s, seat, data, event) + } } } fn button(&self, seat: &Seat, data: &mut State, event: &ButtonEvent) { diff --git a/src/shell/grabs.rs b/src/shell/grabs.rs index 6531bc0c..60541ac5 100644 --- a/src/shell/grabs.rs +++ b/src/shell/grabs.rs @@ -1,7 +1,7 @@ use smithay::{ input::pointer::{ AxisFrame, ButtonEvent, GrabStartData as PointerGrabStartData, MotionEvent, PointerGrab, - PointerInnerHandle, + PointerInnerHandle, RelativeMotionEvent, }, reexports::wayland_protocols::xdg::shell::server::xdg_toplevel, utils::{Logical, Point}, @@ -91,6 +91,19 @@ impl PointerGrab for ResizeGrab { } } + fn relative_motion( + &mut self, + data: &mut State, + handle: &mut PointerInnerHandle<'_, State>, + focus: Option<(PointerFocusTarget, Point)>, + event: &RelativeMotionEvent, + ) { + match self { + ResizeGrab::Floating(grab) => grab.relative_motion(data, handle, focus, event), + ResizeGrab::Tiling(grab) => grab.relative_motion(data, handle, focus, event), + } + } + fn button( &mut self, data: &mut State, diff --git a/src/shell/layout/floating/grabs/moving.rs b/src/shell/layout/floating/grabs/moving.rs index cd022183..aa846250 100644 --- a/src/shell/layout/floating/grabs/moving.rs +++ b/src/shell/layout/floating/grabs/moving.rs @@ -18,7 +18,7 @@ use smithay::{ input::{ pointer::{ AxisFrame, ButtonEvent, GrabStartData as PointerGrabStartData, MotionEvent, - PointerGrab, PointerInnerHandle, + PointerGrab, PointerInnerHandle, RelativeMotionEvent, }, Seat, }, @@ -85,6 +85,17 @@ impl PointerGrab for MoveSurfaceGrab { } } + fn relative_motion( + &mut self, + state: &mut State, + handle: &mut PointerInnerHandle<'_, State>, + _focus: Option<(PointerFocusTarget, Point)>, + event: &RelativeMotionEvent, + ) { + // While the grab is active, no client has pointer focus + handle.relative_motion(state, None, event); + } + fn button( &mut self, state: &mut State, diff --git a/src/shell/layout/floating/grabs/resize.rs b/src/shell/layout/floating/grabs/resize.rs index 621e3174..9654f173 100644 --- a/src/shell/layout/floating/grabs/resize.rs +++ b/src/shell/layout/floating/grabs/resize.rs @@ -10,7 +10,7 @@ use smithay::{ desktop::space::SpaceElement, input::pointer::{ AxisFrame, ButtonEvent, GrabStartData as PointerGrabStartData, MotionEvent, PointerGrab, - PointerInnerHandle, + PointerInnerHandle, RelativeMotionEvent, }, utils::{IsAlive, Logical, Point, Rectangle, Size}, }; @@ -107,6 +107,17 @@ impl PointerGrab for ResizeSurfaceGrab { self.window.configure(); } + fn relative_motion( + &mut self, + state: &mut State, + handle: &mut PointerInnerHandle<'_, State>, + _focus: Option<(PointerFocusTarget, Point)>, + event: &RelativeMotionEvent, + ) { + // While the grab is active, no client has pointer focus + handle.relative_motion(state, None, event); + } + fn button( &mut self, data: &mut State, diff --git a/src/shell/layout/tiling/grabs.rs b/src/shell/layout/tiling/grabs.rs index b23c4965..d12c0450 100644 --- a/src/shell/layout/tiling/grabs.rs +++ b/src/shell/layout/tiling/grabs.rs @@ -8,7 +8,7 @@ use id_tree::NodeId; use smithay::{ input::pointer::{ AxisFrame, ButtonEvent, GrabStartData as PointerGrabStartData, MotionEvent, PointerGrab, - PointerInnerHandle, + PointerInnerHandle, RelativeMotionEvent, }, output::{Output, WeakOutput}, utils::{Logical, Point}, @@ -189,6 +189,17 @@ impl PointerGrab for ResizeForkGrab { } } + fn relative_motion( + &mut self, + state: &mut State, + handle: &mut PointerInnerHandle<'_, State>, + _focus: Option<(PointerFocusTarget, Point)>, + event: &RelativeMotionEvent, + ) { + // While the grab is active, no client has pointer focus + handle.relative_motion(state, None, event); + } + fn button( &mut self, data: &mut State, diff --git a/src/utils/iced.rs b/src/utils/iced.rs index 7bea2043..4930099b 100644 --- a/src/utils/iced.rs +++ b/src/utils/iced.rs @@ -40,7 +40,7 @@ use smithay::{ desktop::space::{RenderZindex, SpaceElement}, input::{ keyboard::{KeyboardTarget, KeysymHandle, ModifiersState}, - pointer::{AxisFrame, ButtonEvent, MotionEvent, PointerTarget}, + pointer::{AxisFrame, ButtonEvent, MotionEvent, PointerTarget, RelativeMotionEvent}, Seat, }, output::Output, @@ -308,6 +308,14 @@ impl PointerTarget for IcedEle let _ = internal.update(true); // TODO } + fn relative_motion( + &self, + _seat: &Seat, + _data: &mut crate::state::State, + _event: &RelativeMotionEvent, + ) { + } + fn button( &self, _seat: &Seat,