Skip to content

Commit

Permalink
wayland/seat: with_ -> _for_each
Browse files Browse the repository at this point in the history
  • Loading branch information
Drakulix committed Aug 24, 2022
1 parent d496fe6 commit 9806c31
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions src/wayland/seat/keyboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ where
}
}

fn with_focused_kbds<D: SeatHandler + 'static>(
fn for_each_focused_kbds<D: SeatHandler + 'static>(
seat: &Seat<D>,
surface: &WlSurface,
mut f: impl FnMut(WlKeyboard),
Expand All @@ -135,7 +135,7 @@ fn serialize_pressed_keys(keys: Vec<u32>) -> Vec<u8> {

impl<D: SeatHandler + 'static> KeyboardTarget<D> for WlSurface {
fn enter(&self, seat: &Seat<D>, _data: &mut D, keys: Vec<KeysymHandle<'_>>, serial: Serial) {
with_focused_kbds(seat, self, |kbd| {
for_each_focused_kbds(seat, self, |kbd| {
kbd.enter(
serial.into(),
self,
Expand All @@ -145,7 +145,7 @@ impl<D: SeatHandler + 'static> KeyboardTarget<D> for WlSurface {
}

fn leave(&self, seat: &Seat<D>, _data: &mut D, serial: Serial) {
with_focused_kbds(seat, self, |kbd| kbd.leave(serial.into(), self))
for_each_focused_kbds(seat, self, |kbd| kbd.leave(serial.into(), self))
}

fn key(
Expand All @@ -157,13 +157,13 @@ impl<D: SeatHandler + 'static> KeyboardTarget<D> for WlSurface {
serial: Serial,
time: u32,
) {
with_focused_kbds(seat, self, |kbd| {
for_each_focused_kbds(seat, self, |kbd| {
kbd.key(serial.into(), time, key.raw_code() - 8, state.into())
})
}

fn modifiers(&self, seat: &Seat<D>, _data: &mut D, modifiers: ModifiersState, serial: Serial) {
with_focused_kbds(seat, self, |kbd| {
for_each_focused_kbds(seat, self, |kbd| {
let modifiers = modifiers.serialized;
kbd.modifiers(
serial.into(),
Expand Down
12 changes: 6 additions & 6 deletions src/wayland/seat/pointer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl<D: SeatHandler> PointerHandle<D> {
/// WlSurface role of a cursor image icon
pub const CURSOR_IMAGE_ROLE: &str = "cursor_image";

fn with_focused_pointers<D: SeatHandler + 'static>(
fn for_each_focused_pointers<D: SeatHandler + 'static>(
seat: &Seat<D>,
surface: &WlSurface,
mut f: impl FnMut(WlPointer),
Expand All @@ -58,39 +58,39 @@ where
D: SeatHandler + 'static,
{
fn enter(&self, seat: &Seat<D>, _data: &mut D, event: &MotionEvent) {
with_focused_pointers(seat, self, |ptr| {
for_each_focused_pointers(seat, self, |ptr| {
ptr.enter(event.serial.into(), self, event.location.x, event.location.y);
if ptr.version() >= 5 {
ptr.frame();
}
})
}
fn leave(&self, seat: &Seat<D>, _data: &mut D, serial: Serial, _time: u32) {
with_focused_pointers(seat, self, |ptr| {
for_each_focused_pointers(seat, self, |ptr| {
ptr.leave(serial.into(), self);
if ptr.version() >= 5 {
ptr.frame();
}
})
}
fn motion(&self, seat: &Seat<D>, _data: &mut D, event: &MotionEvent) {
with_focused_pointers(seat, self, |ptr| {
for_each_focused_pointers(seat, self, |ptr| {
ptr.motion(event.time, event.location.x, event.location.y);
if ptr.version() >= 5 {
ptr.frame();
}
})
}
fn button(&self, seat: &Seat<D>, _data: &mut D, event: &ButtonEvent) {
with_focused_pointers(seat, self, |ptr| {
for_each_focused_pointers(seat, self, |ptr| {
ptr.button(event.serial.into(), event.time, event.button, event.state.into());
if ptr.version() >= 5 {
ptr.frame();
}
})
}
fn axis(&self, seat: &Seat<D>, _data: &mut D, details: AxisFrame) {
with_focused_pointers(seat, self, |ptr| {
for_each_focused_pointers(seat, self, |ptr| {
// axis
if details.axis.0 != 0.0 {
ptr.axis(details.time, WlAxis::HorizontalScroll, details.axis.0);
Expand Down

0 comments on commit 9806c31

Please sign in to comment.