Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
YaLTeR committed Feb 26, 2025
1 parent 83cbc1e commit 18e0554
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 44 deletions.
73 changes: 34 additions & 39 deletions src/input/pick_window_grab.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
use smithay::backend::input::ButtonState;
use smithay::input::pointer::{
CursorImageStatus, GrabStartData as PointerGrabStartData, PointerGrab,
AxisFrame, ButtonEvent, CursorImageStatus, GestureHoldBeginEvent, GestureHoldEndEvent,
GesturePinchBeginEvent, GesturePinchEndEvent, GesturePinchUpdateEvent, GestureSwipeBeginEvent,
GestureSwipeEndEvent, GestureSwipeUpdateEvent, GrabStartData as PointerGrabStartData,
MotionEvent, PointerGrab, PointerInnerHandle, RelativeMotionEvent,
};
use smithay::input::SeatHandler;
use smithay::utils::{Logical, Point};

use crate::niri::State;
use crate::window::Mapped;
Expand Down Expand Up @@ -32,34 +37,28 @@ impl PointerGrab<State> for PickWindowGrab {
fn motion(
&mut self,
data: &mut State,
handle: &mut smithay::input::pointer::PointerInnerHandle<'_, State>,
_focus: Option<(
<State as smithay::input::SeatHandler>::PointerFocus,
smithay::utils::Point<f64, smithay::utils::Logical>,
)>,
event: &smithay::input::pointer::MotionEvent,
handle: &mut PointerInnerHandle<'_, State>,
_focus: Option<(<State as SeatHandler>::PointerFocus, Point<f64, Logical>)>,
event: &MotionEvent,
) {
handle.motion(data, None, event);
}

fn relative_motion(
&mut self,
data: &mut State,
handle: &mut smithay::input::pointer::PointerInnerHandle<'_, State>,
_focus: Option<(
<State as smithay::input::SeatHandler>::PointerFocus,
smithay::utils::Point<f64, smithay::utils::Logical>,
)>,
event: &smithay::input::pointer::RelativeMotionEvent,
handle: &mut PointerInnerHandle<'_, State>,
_focus: Option<(<State as SeatHandler>::PointerFocus, Point<f64, Logical>)>,
event: &RelativeMotionEvent,
) {
handle.relative_motion(data, None, event);
}

fn button(
&mut self,
data: &mut State,
handle: &mut smithay::input::pointer::PointerInnerHandle<'_, State>,
event: &smithay::input::pointer::ButtonEvent,
handle: &mut PointerInnerHandle<'_, State>,
event: &ButtonEvent,
) {
if event.state == ButtonState::Pressed {
if let Some(tx) = data.niri.pick_window.take() {
Expand All @@ -76,93 +75,89 @@ impl PointerGrab<State> for PickWindowGrab {
fn axis(
&mut self,
data: &mut State,
handle: &mut smithay::input::pointer::PointerInnerHandle<'_, State>,
details: smithay::input::pointer::AxisFrame,
handle: &mut PointerInnerHandle<'_, State>,
details: AxisFrame,
) {
handle.axis(data, details);
}

fn frame(
&mut self,
data: &mut State,
handle: &mut smithay::input::pointer::PointerInnerHandle<'_, State>,
) {
fn frame(&mut self, data: &mut State, handle: &mut PointerInnerHandle<'_, State>) {
handle.frame(data);
}

fn gesture_swipe_begin(
&mut self,
data: &mut State,
handle: &mut smithay::input::pointer::PointerInnerHandle<'_, State>,
event: &smithay::input::pointer::GestureSwipeBeginEvent,
handle: &mut PointerInnerHandle<'_, State>,
event: &GestureSwipeBeginEvent,
) {
handle.gesture_swipe_begin(data, event);
}

fn gesture_swipe_update(
&mut self,
data: &mut State,
handle: &mut smithay::input::pointer::PointerInnerHandle<'_, State>,
event: &smithay::input::pointer::GestureSwipeUpdateEvent,
handle: &mut PointerInnerHandle<'_, State>,
event: &GestureSwipeUpdateEvent,
) {
handle.gesture_swipe_update(data, event);
}

fn gesture_swipe_end(
&mut self,
data: &mut State,
handle: &mut smithay::input::pointer::PointerInnerHandle<'_, State>,
event: &smithay::input::pointer::GestureSwipeEndEvent,
handle: &mut PointerInnerHandle<'_, State>,
event: &GestureSwipeEndEvent,
) {
handle.gesture_swipe_end(data, event);
}

fn gesture_pinch_begin(
&mut self,
data: &mut State,
handle: &mut smithay::input::pointer::PointerInnerHandle<'_, State>,
event: &smithay::input::pointer::GesturePinchBeginEvent,
handle: &mut PointerInnerHandle<'_, State>,
event: &GesturePinchBeginEvent,
) {
handle.gesture_pinch_begin(data, event);
}

fn gesture_pinch_update(
&mut self,
data: &mut State,
handle: &mut smithay::input::pointer::PointerInnerHandle<'_, State>,
event: &smithay::input::pointer::GesturePinchUpdateEvent,
handle: &mut PointerInnerHandle<'_, State>,
event: &GesturePinchUpdateEvent,
) {
handle.gesture_pinch_update(data, event);
}

fn gesture_pinch_end(
&mut self,
data: &mut State,
handle: &mut smithay::input::pointer::PointerInnerHandle<'_, State>,
event: &smithay::input::pointer::GesturePinchEndEvent,
handle: &mut PointerInnerHandle<'_, State>,
event: &GesturePinchEndEvent,
) {
handle.gesture_pinch_end(data, event);
}

fn gesture_hold_begin(
&mut self,
data: &mut State,
handle: &mut smithay::input::pointer::PointerInnerHandle<'_, State>,
event: &smithay::input::pointer::GestureHoldBeginEvent,
handle: &mut PointerInnerHandle<'_, State>,
event: &GestureHoldBeginEvent,
) {
handle.gesture_hold_begin(data, event);
}

fn gesture_hold_end(
&mut self,
data: &mut State,
handle: &mut smithay::input::pointer::PointerInnerHandle<'_, State>,
event: &smithay::input::pointer::GestureHoldEndEvent,
handle: &mut PointerInnerHandle<'_, State>,
event: &GestureHoldEndEvent,
) {
handle.gesture_hold_end(data, event);
}

fn start_data(&self) -> &smithay::input::pointer::GrabStartData<State> {
fn start_data(&self) -> &PointerGrabStartData<State> {
&self.start_data
}

Expand Down
7 changes: 2 additions & 5 deletions src/ipc/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,10 +330,7 @@ async fn process(ctx: &ClientCtx, request: Request) -> Reply {
Request::PickWindow => {
let (tx, rx) = async_channel::bounded(1);
ctx.event_loop.insert_idle(move |state| {
let Some(pointer) = state.niri.seat.get_pointer() else {
let _ = tx.send_blocking(None);
return;
};
let pointer = state.niri.seat.get_pointer().unwrap();
let start_data = PointerGrabStartData {
focus: None,
button: 0,
Expand All @@ -342,7 +339,7 @@ async fn process(ctx: &ClientCtx, request: Request) -> Reply {
let grab = PickWindowGrab::new(start_data);
// The `WindowPickGrab` ungrab handler will cancel the previous ongoing pick, if
// any.
pointer.set_grab(state, grab, SERIAL_COUNTER.next_serial(), Focus::Keep);
pointer.set_grab(state, grab, SERIAL_COUNTER.next_serial(), Focus::Clear);
state.niri.pick_window = Some(tx);
state
.niri
Expand Down

0 comments on commit 18e0554

Please sign in to comment.