1
0
Fork 0
forked from wry/wry

all: track serials as u64 internally

This commit is contained in:
Julian Orth 2024-10-17 15:20:46 +02:00
parent 437c6b0596
commit c987fdb58d
28 changed files with 123 additions and 119 deletions

View file

@ -1137,7 +1137,7 @@ impl WlSeatGlobal {
time_usec: u64,
button: u32,
state: KeyState,
serial: u32,
serial: u64,
) {
let (state, pressed) = match state {
KeyState::Released => (wl_pointer::RELEASED, false),
@ -1250,7 +1250,7 @@ impl WlSeatGlobal {
pub fn enter_surface(&self, n: &WlSurface, x: Fixed, y: Fixed) {
let serial = n.client.next_serial();
n.client.last_enter_serial.set(serial);
n.client.last_enter_serial.set(Some(serial));
self.surface_pointer_event(Version::ALL, n, |p| p.send_enter(serial, n.id, x, y));
self.surface_pointer_frame(n);
for (_, constraint) in &n.constraints {
@ -1428,7 +1428,7 @@ impl WlSeatGlobal {
dnd: &Dnd,
x: Fixed,
y: Fixed,
serial: u32,
serial: u64,
) {
if let Some(src) = &dnd.src {
if !surface.client.is_xwayland {

View file

@ -128,7 +128,7 @@ impl PointerOwnerHolder {
origin: &Rc<WlSurface>,
source: Option<Rc<WlDataSource>>,
icon: Option<Rc<DndIcon>>,
serial: u32,
serial: u64,
) -> Result<(), WlSeatError> {
self.owner
.get()
@ -230,7 +230,7 @@ trait PointerOwner {
origin: &Rc<WlSurface>,
source: Option<Rc<WlDataSource>>,
icon: Option<Rc<DndIcon>>,
serial: u32,
serial: u64,
) -> Result<(), WlSeatError> {
let _ = origin;
let _ = icon;
@ -284,7 +284,7 @@ struct SimpleGrabPointerOwner<T> {
usecase: T,
buttons: SmallMap<u32, (), 1>,
node: Rc<dyn Node>,
serial: u32,
serial: u64,
}
struct DndPointerOwner {
@ -473,7 +473,7 @@ impl<T: SimplePointerOwnerUsecase> PointerOwner for SimpleGrabPointerOwner<T> {
origin: &Rc<WlSurface>,
src: Option<Rc<WlDataSource>>,
icon: Option<Rc<DndIcon>>,
serial: u32,
serial: u64,
) -> Result<(), WlSeatError> {
self.usecase
.start_drag(self, seat, origin, src, icon, serial)
@ -627,7 +627,7 @@ trait SimplePointerOwnerUsecase: Sized + Clone + 'static {
origin: &Rc<WlSurface>,
src: Option<Rc<WlDataSource>>,
icon: Option<Rc<DndIcon>>,
serial: u32,
serial: u64,
) -> Result<(), WlSeatError> {
let _ = grab;
let _ = origin;
@ -720,7 +720,7 @@ impl SimplePointerOwnerUsecase for DefaultPointerUsecase {
origin: &Rc<WlSurface>,
src: Option<Rc<WlDataSource>>,
icon: Option<Rc<DndIcon>>,
serial: u32,
serial: u64,
) -> Result<(), WlSeatError> {
let button = match grab.buttons.iter().next() {
Some((b, _)) => b,

View file

@ -60,11 +60,11 @@ impl ZwpTabletPadGroupV2 {
self.client.event(Done { self_id: self.id });
}
pub fn send_mode_switch(&self, time: u32, serial: u32, mode: u32) {
pub fn send_mode_switch(&self, time: u32, serial: u64, mode: u32) {
self.client.event(ModeSwitch {
self_id: self.id,
time,
serial,
serial: serial as _,
mode,
});
}

View file

@ -68,21 +68,21 @@ impl ZwpTabletPadV2 {
});
}
pub fn send_enter(&self, serial: u32, tablet: &ZwpTabletV2, surface: &WlSurface) {
pub fn send_enter(&self, serial: u64, tablet: &ZwpTabletV2, surface: &WlSurface) {
self.entered.set(true);
self.client.event(Enter {
self_id: self.id,
serial,
serial: serial as _,
tablet: tablet.id,
surface: surface.id,
});
}
pub fn send_leave(&self, serial: u32, surface: &WlSurface) {
pub fn send_leave(&self, serial: u64, surface: &WlSurface) {
self.entered.set(false);
self.client.event(Leave {
self_id: self.id,
serial,
serial: serial as _,
surface: surface.id,
});
}

View file

@ -98,11 +98,11 @@ impl ZwpTabletToolV2 {
self.client.event(Removed { self_id: self.id });
}
pub fn send_proximity_in(&self, serial: u32, tablet: &ZwpTabletV2, surface: &WlSurface) {
pub fn send_proximity_in(&self, serial: u64, tablet: &ZwpTabletV2, surface: &WlSurface) {
self.entered.set(true);
self.client.event(ProximityIn {
self_id: self.id,
serial,
serial: serial as _,
tablet: tablet.id,
surface: surface.id,
});
@ -113,10 +113,10 @@ impl ZwpTabletToolV2 {
self.client.event(ProximityOut { self_id: self.id });
}
pub fn send_down(&self, serial: u32) {
pub fn send_down(&self, serial: u64) {
self.client.event(Down {
self_id: self.id,
serial,
serial: serial as _,
});
}
@ -177,10 +177,10 @@ impl ZwpTabletToolV2 {
});
}
pub fn send_button(&self, serial: u32, button: u32, state: ToolButtonState) {
pub fn send_button(&self, serial: u64, button: u32, state: ToolButtonState) {
self.client.event(Button {
self_id: self.id,
serial,
serial: serial as _,
button,
state: match state {
ToolButtonState::Released => 0,
@ -204,7 +204,7 @@ impl ZwpTabletToolV2RequestHandler for ZwpTabletToolV2 {
let Some(tool) = self.tool.get() else {
return Ok(());
};
if !self.seat.client.valid_serial(req.serial) {
if self.seat.client.map_serial(req.serial).is_none() {
log::warn!("Client tried to set_cursor with an invalid serial");
return Ok(());
}

View file

@ -42,7 +42,7 @@ impl ZwpInputMethodKeyboardGrabV2 {
});
}
fn update_state(&self, serial: u32, kb_state: &KeyboardState) {
fn update_state(&self, serial: u64, kb_state: &KeyboardState) {
self.send_keymap(kb_state);
self.send_modifiers(serial, kb_state);
self.kb_state_id.set(kb_state.id);
@ -56,10 +56,10 @@ impl ZwpInputMethodKeyboardGrabV2 {
self.send_key(serial, time_usec, key, state);
}
fn send_key(&self, serial: u32, time_usec: u64, key: u32, state: u32) {
fn send_key(&self, serial: u64, time_usec: u64, key: u32, state: u32) {
self.client.event(Key {
self_id: self.id,
serial,
serial: serial as _,
time: (time_usec / 1000) as _,
key,
state,
@ -74,10 +74,10 @@ impl ZwpInputMethodKeyboardGrabV2 {
self.send_modifiers(serial, kb_state);
}
fn send_modifiers(&self, serial: u32, kb_state: &KeyboardState) {
fn send_modifiers(&self, serial: u64, kb_state: &KeyboardState) {
self.client.event(Modifiers {
self_id: self.id,
serial,
serial: serial as _,
mods_depressed: kb_state.mods.mods_depressed,
mods_latched: kb_state.mods.mods_latched,
mods_locked: kb_state.mods.mods_locked,

View file

@ -44,7 +44,7 @@ impl WlKeyboard {
fn send_kb_state(
&self,
serial: u32,
serial: u64,
kb_state: &KeyboardState,
surface_id: WlSurfaceId,
send_leave: bool,
@ -78,7 +78,7 @@ impl WlKeyboard {
});
}
pub fn enter(&self, serial: u32, surface: WlSurfaceId, kb_state: &KeyboardState) {
pub fn enter(&self, serial: u64, surface: WlSurfaceId, kb_state: &KeyboardState) {
if kb_state.id != self.kb_state_id.get() {
self.send_kb_state(serial, kb_state, surface, false);
} else {
@ -87,26 +87,26 @@ impl WlKeyboard {
}
}
fn send_enter(&self, serial: u32, surface: WlSurfaceId, keys: &[u32]) {
fn send_enter(&self, serial: u64, surface: WlSurfaceId, keys: &[u32]) {
self.seat.client.event(Enter {
self_id: self.id,
serial,
serial: serial as _,
surface,
keys,
})
}
pub fn send_leave(&self, serial: u32, surface: WlSurfaceId) {
pub fn send_leave(&self, serial: u64, surface: WlSurfaceId) {
self.seat.client.event(Leave {
self_id: self.id,
serial,
serial: serial as _,
surface,
})
}
pub fn on_key(
&self,
serial: u32,
serial: u64,
time: u32,
key: u32,
state: u32,
@ -119,17 +119,17 @@ impl WlKeyboard {
self.send_key(serial, time, key, state);
}
fn send_key(&self, serial: u32, time: u32, key: u32, state: u32) {
fn send_key(&self, serial: u64, time: u32, key: u32, state: u32) {
self.seat.client.event(Key {
self_id: self.id,
serial,
serial: serial as _,
time,
key,
state,
})
}
pub fn on_mods_changed(&self, serial: u32, surface: WlSurfaceId, kb_state: &KeyboardState) {
pub fn on_mods_changed(&self, serial: u64, surface: WlSurfaceId, kb_state: &KeyboardState) {
if self.kb_state_id.get() != kb_state.id {
self.send_kb_state(serial, kb_state, surface, true);
} else {
@ -137,10 +137,10 @@ impl WlKeyboard {
}
}
fn send_modifiers(&self, serial: u32, mods: &ModifierState) {
fn send_modifiers(&self, serial: u64, mods: &ModifierState) {
self.seat.client.event(Modifiers {
self_id: self.id,
serial,
serial: serial as _,
mods_depressed: mods.mods_depressed,
mods_latched: mods.mods_latched,
mods_locked: mods.mods_locked,

View file

@ -86,22 +86,22 @@ impl WlPointer {
}
}
pub fn send_enter(&self, serial: u32, surface: WlSurfaceId, mut x: Fixed, mut y: Fixed) {
pub fn send_enter(&self, serial: u64, surface: WlSurfaceId, mut x: Fixed, mut y: Fixed) {
self.last_motion.set((x, y));
logical_to_client_wire_scale!(self.seat.client, x, y);
self.seat.client.event(Enter {
self_id: self.id,
serial,
serial: serial as u32,
surface,
surface_x: x,
surface_y: y,
})
}
pub fn send_leave(&self, serial: u32, surface: WlSurfaceId) {
pub fn send_leave(&self, serial: u64, surface: WlSurfaceId) {
self.seat.client.event(Leave {
self_id: self.id,
serial,
serial: serial as u32,
surface,
})
}
@ -119,10 +119,10 @@ impl WlPointer {
})
}
pub fn send_button(&self, serial: u32, time: u32, button: u32, state: u32) {
pub fn send_button(&self, serial: u64, time: u32, button: u32, state: u32) {
self.seat.client.event(Button {
self_id: self.id,
serial,
serial: serial as u32,
time,
button,
state,
@ -187,7 +187,7 @@ impl WlPointerRequestHandler for WlPointer {
type Error = WlPointerError;
fn set_cursor(&self, mut req: SetCursor, _slf: &Rc<Self>) -> Result<(), Self::Error> {
if !self.seat.client.valid_serial(req.serial) {
if self.seat.client.map_serial(req.serial).is_none() {
log::warn!("Client tried to set_cursor with an invalid serial");
return Ok(());
}

View file

@ -33,7 +33,7 @@ impl WlTouch {
pub fn send_down(
&self,
serial: u32,
serial: u64,
time: u32,
surface: WlSurfaceId,
id: i32,
@ -43,7 +43,7 @@ impl WlTouch {
logical_to_client_wire_scale!(self.seat.client, x, y);
self.seat.client.event(Down {
self_id: self.id,
serial,
serial: serial as _,
time,
surface,
id,
@ -52,10 +52,10 @@ impl WlTouch {
})
}
pub fn send_up(&self, serial: u32, time: u32, id: i32) {
pub fn send_up(&self, serial: u64, time: u32, id: i32) {
self.seat.client.event(Up {
self_id: self.id,
serial,
serial: serial as _,
time,
id,
})

View file

@ -23,20 +23,20 @@ impl ZwpPointerGestureHoldV1 {
self.seat.hold_bindings.remove(&self.client, self);
}
pub fn send_hold_begin(&self, n: &WlSurface, serial: u32, time_usec: u64, finger_count: u32) {
pub fn send_hold_begin(&self, n: &WlSurface, serial: u64, time_usec: u64, finger_count: u32) {
self.client.event(Begin {
self_id: self.id,
serial,
serial: serial as _,
time: (time_usec / 1000) as u32,
surface: n.id,
fingers: finger_count,
});
}
pub fn send_hold_end(&self, serial: u32, time_usec: u64, cancelled: bool) {
pub fn send_hold_end(&self, serial: u64, time_usec: u64, cancelled: bool) {
self.client.event(End {
self_id: self.id,
serial,
serial: serial as _,
time: (time_usec / 1000) as u32,
cancelled: cancelled as _,
});

View file

@ -24,10 +24,10 @@ impl ZwpPointerGesturePinchV1 {
self.seat.pinch_bindings.remove(&self.client, self);
}
pub fn send_pinch_begin(&self, n: &WlSurface, serial: u32, time_usec: u64, finger_count: u32) {
pub fn send_pinch_begin(&self, n: &WlSurface, serial: u64, time_usec: u64, finger_count: u32) {
self.client.event(Begin {
self_id: self.id,
serial,
serial: serial as _,
time: (time_usec / 1000) as u32,
surface: n.id,
fingers: finger_count,
@ -52,10 +52,10 @@ impl ZwpPointerGesturePinchV1 {
});
}
pub fn send_pinch_end(&self, serial: u32, time_usec: u64, cancelled: bool) {
pub fn send_pinch_end(&self, serial: u64, time_usec: u64, cancelled: bool) {
self.client.event(End {
self_id: self.id,
serial,
serial: serial as _,
time: (time_usec / 1000) as u32,
cancelled: cancelled as _,
});

View file

@ -24,10 +24,10 @@ impl ZwpPointerGestureSwipeV1 {
self.seat.swipe_bindings.remove(&self.client, self);
}
pub fn send_swipe_begin(&self, n: &WlSurface, serial: u32, time_usec: u64, finger_count: u32) {
pub fn send_swipe_begin(&self, n: &WlSurface, serial: u64, time_usec: u64, finger_count: u32) {
self.client.event(Begin {
self_id: self.id,
serial,
serial: serial as _,
time: (time_usec / 1000) as u32,
surface: n.id,
fingers: finger_count,
@ -43,10 +43,10 @@ impl ZwpPointerGestureSwipeV1 {
});
}
pub fn send_swipe_end(&self, serial: u32, time_usec: u64, cancelled: bool) {
pub fn send_swipe_end(&self, serial: u64, time_usec: u64, cancelled: bool) {
self.client.event(End {
self_id: self.id,
serial,
serial: serial as _,
time: (time_usec / 1000) as u32,
cancelled: cancelled as _,
});

View file

@ -30,7 +30,7 @@ pub struct ZwpVirtualKeyboardV1 {
impl ZwpVirtualKeyboardV1 {
fn for_each_kb<F>(&self, mut f: F)
where
F: FnMut(u32, &WlSurface, &WlKeyboard),
F: FnMut(u64, &WlSurface, &WlKeyboard),
{
let Some(surface) = self.seat.keyboard_node.get().node_into_surface() else {
return;