Use Serial type for all serials
This commit is contained in:
parent
0a0399a339
commit
2a351d0879
|
@ -29,6 +29,7 @@ use smithay::{
|
|||
XdgSurfacePendingState, XdgSurfaceRole,
|
||||
},
|
||||
},
|
||||
Serial,
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -61,7 +62,7 @@ impl PointerGrab for MoveSurfaceGrab {
|
|||
_handle: &mut PointerInnerHandle<'_>,
|
||||
location: (f64, f64),
|
||||
_focus: Option<(wl_surface::WlSurface, (f64, f64))>,
|
||||
_serial: u32,
|
||||
_serial: Serial,
|
||||
_time: u32,
|
||||
) {
|
||||
let dx = location.0 - self.start_data.location.0;
|
||||
|
@ -79,7 +80,7 @@ impl PointerGrab for MoveSurfaceGrab {
|
|||
handle: &mut PointerInnerHandle<'_>,
|
||||
button: u32,
|
||||
state: ButtonState,
|
||||
serial: u32,
|
||||
serial: Serial,
|
||||
time: u32,
|
||||
) {
|
||||
handle.button(button, state, serial, time);
|
||||
|
@ -155,7 +156,7 @@ impl PointerGrab for ResizeSurfaceGrab {
|
|||
_handle: &mut PointerInnerHandle<'_>,
|
||||
location: (f64, f64),
|
||||
_focus: Option<(wl_surface::WlSurface, (f64, f64))>,
|
||||
serial: u32,
|
||||
serial: Serial,
|
||||
_time: u32,
|
||||
) {
|
||||
let mut dx = location.0 - self.start_data.location.0;
|
||||
|
@ -226,7 +227,7 @@ impl PointerGrab for ResizeSurfaceGrab {
|
|||
handle: &mut PointerInnerHandle<'_>,
|
||||
button: u32,
|
||||
state: ButtonState,
|
||||
serial: u32,
|
||||
serial: Serial,
|
||||
time: u32,
|
||||
) {
|
||||
handle.button(button, state, serial, time);
|
||||
|
@ -328,7 +329,7 @@ pub fn init_shell(display: &mut Display, buffer_utils: BufferUtils, log: ::slog:
|
|||
surface.send_configure(ToplevelConfigure {
|
||||
size: None,
|
||||
states: vec![],
|
||||
serial: 42,
|
||||
serial: Serial::from(42),
|
||||
});
|
||||
xdg_window_map
|
||||
.borrow_mut()
|
||||
|
@ -337,7 +338,7 @@ pub fn init_shell(display: &mut Display, buffer_utils: BufferUtils, log: ::slog:
|
|||
XdgRequest::NewPopup { surface } => surface.send_configure(PopupConfigure {
|
||||
size: (10, 10),
|
||||
position: (10, 10),
|
||||
serial: 42,
|
||||
serial: Serial::from(42),
|
||||
}),
|
||||
XdgRequest::Move {
|
||||
surface,
|
||||
|
@ -453,7 +454,7 @@ pub fn init_shell(display: &mut Display, buffer_utils: BufferUtils, log: ::slog:
|
|||
if let Some(serial) = waiting_for_serial {
|
||||
let acked = compositor_token
|
||||
.with_role_data(&surface, |role: &mut XdgSurfaceRole| {
|
||||
!role.pending_configures.contains(&serial)
|
||||
!role.pending_configures.contains(&serial.into())
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
|
@ -632,7 +633,7 @@ pub enum ResizeState {
|
|||
/// The surface is currently being resized.
|
||||
Resizing(ResizeData),
|
||||
/// The resize has finished, and the surface needs to ack the final configure.
|
||||
WaitingForFinalAck(ResizeData, u32),
|
||||
WaitingForFinalAck(ResizeData, Serial),
|
||||
/// The resize has finished, and the surface needs to commit its final state.
|
||||
WaitingForCommit(ResizeData),
|
||||
}
|
||||
|
@ -754,9 +755,9 @@ impl SurfaceData {
|
|||
}
|
||||
|
||||
/// Send the frame callback if it had been requested
|
||||
pub fn send_frame(&mut self, serial: u32) {
|
||||
pub fn send_frame(&mut self, serial: Serial) {
|
||||
if let Some(callback) = self.current_state.frame_callback.take() {
|
||||
callback.done(serial);
|
||||
callback.done(serial.into());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ use smithay::{
|
|||
legacy::{ShellSurface, ShellSurfaceRole},
|
||||
xdg::{ToplevelSurface, XdgSurfaceRole},
|
||||
},
|
||||
Serial,
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -172,7 +173,7 @@ where
|
|||
|
||||
/// Sends the frame callback to all the subsurfaces in this
|
||||
/// window that requested it
|
||||
pub fn send_frame(&self, serial: u32, ctoken: CompositorToken<R>) {
|
||||
pub fn send_frame(&self, serial: Serial, ctoken: CompositorToken<R>) {
|
||||
if let Some(wl_surface) = self.toplevel.get_surface() {
|
||||
ctoken.with_surface_tree_downward(
|
||||
wl_surface,
|
||||
|
@ -312,7 +313,7 @@ where
|
|||
.map(|w| w.geometry(self.ctoken))
|
||||
}
|
||||
|
||||
pub fn send_frames(&self, serial: u32) {
|
||||
pub fn send_frames(&self, serial: Serial) {
|
||||
for window in &self.windows {
|
||||
window.send_frame(serial, self.ctoken);
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ use wayland_server::{
|
|||
use crate::wayland::{
|
||||
compositor::{roles::Role, CompositorToken},
|
||||
seat::{AxisFrame, GrabStartData, PointerGrab, PointerInnerHandle, Seat},
|
||||
Serial,
|
||||
};
|
||||
|
||||
use super::{with_source_metadata, DataDeviceData, DnDIconRole, SeatData};
|
||||
|
@ -56,7 +57,7 @@ impl<R: Role<DnDIconRole> + 'static> PointerGrab for DnDGrab<R> {
|
|||
_handle: &mut PointerInnerHandle<'_>,
|
||||
location: (f64, f64),
|
||||
focus: Option<(wl_surface::WlSurface, (f64, f64))>,
|
||||
serial: u32,
|
||||
serial: Serial,
|
||||
time: u32,
|
||||
) {
|
||||
let (x, y) = location;
|
||||
|
@ -132,7 +133,7 @@ impl<R: Role<DnDIconRole> + 'static> PointerGrab for DnDGrab<R> {
|
|||
offer.source_actions(meta.dnd_action.to_raw());
|
||||
})
|
||||
.unwrap();
|
||||
device.enter(serial, &surface, x - sx, y - sy, Some(&offer));
|
||||
device.enter(serial.into(), &surface, x - sx, y - sy, Some(&offer));
|
||||
self.pending_offers.push(offer);
|
||||
}
|
||||
self.offer_data = Some(offer_data);
|
||||
|
@ -141,7 +142,7 @@ impl<R: Role<DnDIconRole> + 'static> PointerGrab for DnDGrab<R> {
|
|||
if self.origin.as_ref().same_client_as(&surface.as_ref()) {
|
||||
for device in &seat_data.known_devices {
|
||||
if device.as_ref().same_client_as(&surface.as_ref()) {
|
||||
device.enter(serial, &surface, x - sx, y - sy, None);
|
||||
device.enter(serial.into(), &surface, x - sx, y - sy, None);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -165,7 +166,7 @@ impl<R: Role<DnDIconRole> + 'static> PointerGrab for DnDGrab<R> {
|
|||
handle: &mut PointerInnerHandle<'_>,
|
||||
_button: u32,
|
||||
_state: wl_pointer::ButtonState,
|
||||
serial: u32,
|
||||
serial: Serial,
|
||||
time: u32,
|
||||
) {
|
||||
if handle.current_pressed().is_empty() {
|
||||
|
|
|
@ -67,6 +67,7 @@ use wayland_server::{
|
|||
use crate::wayland::{
|
||||
compositor::{roles::Role, CompositorToken},
|
||||
seat::{GrabStartData, Seat},
|
||||
Serial,
|
||||
};
|
||||
|
||||
mod data_source;
|
||||
|
@ -342,7 +343,7 @@ pub fn set_data_device_selection(seat: &Seat, mime_types: Vec<String>) {
|
|||
/// which events can be generated and what response is expected from you to them.
|
||||
pub fn start_dnd<C>(
|
||||
seat: &Seat,
|
||||
serial: u32,
|
||||
serial: Serial,
|
||||
start_data: GrabStartData,
|
||||
metadata: SourceMetadata,
|
||||
callback: C,
|
||||
|
@ -443,6 +444,7 @@ where
|
|||
serial,
|
||||
} => {
|
||||
/* TODO: handle the icon */
|
||||
let serial = Serial::from(serial);
|
||||
if let Some(pointer) = seat.get_pointer() {
|
||||
if pointer.has_grab(serial) {
|
||||
if let Some(ref icon) = icon {
|
||||
|
|
|
@ -6,6 +6,7 @@ use wayland_server::{
|
|||
};
|
||||
|
||||
use crate::wayland::seat::{AxisFrame, GrabStartData, PointerGrab, PointerInnerHandle, Seat};
|
||||
use crate::wayland::Serial;
|
||||
|
||||
use super::{DataDeviceData, SeatData};
|
||||
|
||||
|
@ -72,7 +73,7 @@ where
|
|||
_handle: &mut PointerInnerHandle<'_>,
|
||||
location: (f64, f64),
|
||||
focus: Option<(wl_surface::WlSurface, (f64, f64))>,
|
||||
serial: u32,
|
||||
serial: Serial,
|
||||
time: u32,
|
||||
) {
|
||||
let (x, y) = location;
|
||||
|
@ -142,7 +143,7 @@ where
|
|||
offer.offer(mime_type);
|
||||
}
|
||||
offer.source_actions(self.metadata.dnd_action.to_raw());
|
||||
device.enter(serial, &surface, x - sx, y - sy, Some(&offer));
|
||||
device.enter(serial.into(), &surface, x - sx, y - sy, Some(&offer));
|
||||
self.pending_offers.push(offer);
|
||||
}
|
||||
self.offer_data = Some(offer_data);
|
||||
|
@ -163,7 +164,7 @@ where
|
|||
handle: &mut PointerInnerHandle<'_>,
|
||||
_button: u32,
|
||||
_state: wl_pointer::ButtonState,
|
||||
serial: u32,
|
||||
serial: Serial,
|
||||
time: u32,
|
||||
) {
|
||||
if handle.current_pressed().is_empty() {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use crate::backend::input::KeyState;
|
||||
use crate::wayland::Serial;
|
||||
use std::{
|
||||
cell::RefCell,
|
||||
default::Default,
|
||||
|
@ -301,7 +302,7 @@ impl KeyboardHandle {
|
|||
///
|
||||
/// The module [`wayland::seat::keysyms`](::wayland::seat::keysyms) exposes definitions of all possible keysyms
|
||||
/// to be compared against. This includes non-character keysyms, such as XF86 special keys.
|
||||
pub fn input<F>(&self, keycode: u32, state: KeyState, serial: u32, time: u32, filter: F)
|
||||
pub fn input<F>(&self, keycode: u32, state: KeyState, serial: Serial, time: u32, filter: F)
|
||||
where
|
||||
F: FnOnce(&ModifiersState, Keysym) -> bool,
|
||||
{
|
||||
|
@ -337,9 +338,9 @@ impl KeyboardHandle {
|
|||
guard.with_focused_kbds(|kbd, _| {
|
||||
// key event must be sent before modifers event for libxkbcommon
|
||||
// to process them correctly
|
||||
kbd.key(serial, time, keycode, wl_state);
|
||||
kbd.key(serial.into(), time, keycode, wl_state);
|
||||
if let Some((dep, la, lo, gr)) = modifiers {
|
||||
kbd.modifiers(serial, dep, la, lo, gr);
|
||||
kbd.modifiers(serial.into(), dep, la, lo, gr);
|
||||
}
|
||||
});
|
||||
if guard.focus.is_some() {
|
||||
|
@ -355,7 +356,7 @@ impl KeyboardHandle {
|
|||
/// will be sent a [`wl_keyboard::Event::Leave`](wayland_server::protocol::wl_keyboard::Event::Leave)
|
||||
/// event, and if the new focus is not `None`,
|
||||
/// a [`wl_keyboard::Event::Enter`](wayland_server::protocol::wl_keyboard::Event::Enter) event will be sent.
|
||||
pub fn set_focus(&self, focus: Option<&WlSurface>, serial: u32) {
|
||||
pub fn set_focus(&self, focus: Option<&WlSurface>, serial: Serial) {
|
||||
let mut guard = self.arc.internal.borrow_mut();
|
||||
|
||||
let same = guard
|
||||
|
@ -367,7 +368,7 @@ impl KeyboardHandle {
|
|||
if !same {
|
||||
// unset old focus
|
||||
guard.with_focused_kbds(|kbd, s| {
|
||||
kbd.leave(serial, &s);
|
||||
kbd.leave(serial.into(), &s);
|
||||
});
|
||||
|
||||
// set new focus
|
||||
|
@ -375,9 +376,9 @@ impl KeyboardHandle {
|
|||
let (dep, la, lo, gr) = guard.serialize_modifiers();
|
||||
let keys = guard.serialize_pressed_keys();
|
||||
guard.with_focused_kbds(|kbd, surface| {
|
||||
kbd.enter(serial, &surface, keys.clone());
|
||||
kbd.enter(serial.into(), &surface, keys.clone());
|
||||
// Modifiers must be send after enter event.
|
||||
kbd.modifiers(serial, dep, la, lo, gr);
|
||||
kbd.modifiers(serial.into(), dep, la, lo, gr);
|
||||
});
|
||||
{
|
||||
let KbdInternal {
|
||||
|
|
|
@ -9,6 +9,7 @@ use wayland_server::{
|
|||
};
|
||||
|
||||
use crate::wayland::compositor::{roles::Role, CompositorToken};
|
||||
use crate::wayland::Serial;
|
||||
|
||||
/// The role representing a surface set as the pointer cursor
|
||||
#[derive(Default, Copy, Clone)]
|
||||
|
@ -30,7 +31,7 @@ pub enum CursorImageStatus {
|
|||
|
||||
enum GrabStatus {
|
||||
None,
|
||||
Active(u32, Box<dyn PointerGrab>),
|
||||
Active(Serial, Box<dyn PointerGrab>),
|
||||
Borrowed,
|
||||
}
|
||||
|
||||
|
@ -138,7 +139,7 @@ impl PointerHandle {
|
|||
/// Change the current grab on this pointer to the provided grab
|
||||
///
|
||||
/// Overwrites any current grab.
|
||||
pub fn set_grab<G: PointerGrab + 'static>(&self, grab: G, serial: u32) {
|
||||
pub fn set_grab<G: PointerGrab + 'static>(&self, grab: G, serial: Serial) {
|
||||
self.inner.borrow_mut().grab = GrabStatus::Active(serial, Box::new(grab));
|
||||
}
|
||||
|
||||
|
@ -148,7 +149,7 @@ impl PointerHandle {
|
|||
}
|
||||
|
||||
/// Check if this pointer is currently grabbed with this serial
|
||||
pub fn has_grab(&self, serial: u32) -> bool {
|
||||
pub fn has_grab(&self, serial: Serial) -> bool {
|
||||
let guard = self.inner.borrow_mut();
|
||||
match guard.grab {
|
||||
GrabStatus::Active(s, _) => s == serial,
|
||||
|
@ -189,7 +190,7 @@ impl PointerHandle {
|
|||
&self,
|
||||
location: (f64, f64),
|
||||
focus: Option<(WlSurface, (f64, f64))>,
|
||||
serial: u32,
|
||||
serial: Serial,
|
||||
time: u32,
|
||||
) {
|
||||
let mut inner = self.inner.borrow_mut();
|
||||
|
@ -203,7 +204,7 @@ impl PointerHandle {
|
|||
///
|
||||
/// This will internally send the appropriate button event to the client
|
||||
/// objects matching with the currently focused surface.
|
||||
pub fn button(&self, button: u32, state: ButtonState, serial: u32, time: u32) {
|
||||
pub fn button(&self, button: u32, state: ButtonState, serial: Serial, time: u32) {
|
||||
let mut inner = self.inner.borrow_mut();
|
||||
match state {
|
||||
ButtonState::Pressed => {
|
||||
|
@ -269,7 +270,7 @@ pub trait PointerGrab {
|
|||
handle: &mut PointerInnerHandle<'_>,
|
||||
location: (f64, f64),
|
||||
focus: Option<(WlSurface, (f64, f64))>,
|
||||
serial: u32,
|
||||
serial: Serial,
|
||||
time: u32,
|
||||
);
|
||||
/// A button press was reported
|
||||
|
@ -278,7 +279,7 @@ pub trait PointerGrab {
|
|||
handle: &mut PointerInnerHandle<'_>,
|
||||
button: u32,
|
||||
state: ButtonState,
|
||||
serial: u32,
|
||||
serial: Serial,
|
||||
time: u32,
|
||||
);
|
||||
/// An axis scroll was reported
|
||||
|
@ -297,14 +298,14 @@ impl<'a> PointerInnerHandle<'a> {
|
|||
/// Change the current grab on this pointer to the provided grab
|
||||
///
|
||||
/// Overwrites any current grab.
|
||||
pub fn set_grab<G: PointerGrab + 'static>(&mut self, serial: u32, grab: G) {
|
||||
pub fn set_grab<G: PointerGrab + 'static>(&mut self, serial: Serial, grab: G) {
|
||||
self.inner.grab = GrabStatus::Active(serial, Box::new(grab));
|
||||
}
|
||||
|
||||
/// Remove any current grab on this pointer, resetting it to the default behavior
|
||||
///
|
||||
/// This will also restore the focus of the underlying pointer
|
||||
pub fn unset_grab(&mut self, serial: u32, time: u32) {
|
||||
pub fn unset_grab(&mut self, serial: Serial, time: u32) {
|
||||
self.inner.grab = GrabStatus::None;
|
||||
// restore the focus
|
||||
let location = self.current_location();
|
||||
|
@ -345,7 +346,7 @@ impl<'a> PointerInnerHandle<'a> {
|
|||
&mut self,
|
||||
(x, y): (f64, f64),
|
||||
focus: Option<(WlSurface, (f64, f64))>,
|
||||
serial: u32,
|
||||
serial: Serial,
|
||||
time: u32,
|
||||
) {
|
||||
// do we leave a surface ?
|
||||
|
@ -360,7 +361,7 @@ impl<'a> PointerInnerHandle<'a> {
|
|||
}
|
||||
if leave {
|
||||
self.inner.with_focused_pointers(|pointer, surface| {
|
||||
pointer.leave(serial, &surface);
|
||||
pointer.leave(serial.into(), &surface);
|
||||
if pointer.as_ref().version() >= 5 {
|
||||
pointer.frame();
|
||||
}
|
||||
|
@ -377,7 +378,7 @@ impl<'a> PointerInnerHandle<'a> {
|
|||
self.inner.focus = Some((surface, (sx, sy)));
|
||||
if entered {
|
||||
self.inner.with_focused_pointers(|pointer, surface| {
|
||||
pointer.enter(serial, &surface, x - sx, y - sy);
|
||||
pointer.enter(serial.into(), &surface, x - sx, y - sy);
|
||||
if pointer.as_ref().version() >= 5 {
|
||||
pointer.frame();
|
||||
}
|
||||
|
@ -398,9 +399,9 @@ impl<'a> PointerInnerHandle<'a> {
|
|||
///
|
||||
/// This will internally send the appropriate button event to the client
|
||||
/// objects matching with the currently focused surface.
|
||||
pub fn button(&self, button: u32, state: ButtonState, serial: u32, time: u32) {
|
||||
pub fn button(&self, button: u32, state: ButtonState, serial: Serial, time: u32) {
|
||||
self.inner.with_focused_pointers(|pointer, _| {
|
||||
pointer.button(serial, time, button, state);
|
||||
pointer.button(serial.into(), time, button, state);
|
||||
if pointer.as_ref().version() >= 5 {
|
||||
pointer.frame();
|
||||
}
|
||||
|
@ -639,7 +640,7 @@ impl PointerGrab for DefaultGrab {
|
|||
handle: &mut PointerInnerHandle<'_>,
|
||||
location: (f64, f64),
|
||||
focus: Option<(WlSurface, (f64, f64))>,
|
||||
serial: u32,
|
||||
serial: Serial,
|
||||
time: u32,
|
||||
) {
|
||||
handle.motion(location, focus, serial, time);
|
||||
|
@ -649,7 +650,7 @@ impl PointerGrab for DefaultGrab {
|
|||
handle: &mut PointerInnerHandle<'_>,
|
||||
button: u32,
|
||||
state: ButtonState,
|
||||
serial: u32,
|
||||
serial: Serial,
|
||||
time: u32,
|
||||
) {
|
||||
handle.button(button, state, serial, time);
|
||||
|
@ -687,7 +688,7 @@ impl PointerGrab for ClickGrab {
|
|||
handle: &mut PointerInnerHandle<'_>,
|
||||
location: (f64, f64),
|
||||
_focus: Option<(WlSurface, (f64, f64))>,
|
||||
serial: u32,
|
||||
serial: Serial,
|
||||
time: u32,
|
||||
) {
|
||||
handle.motion(location, self.start_data.focus.clone(), serial, time);
|
||||
|
@ -697,7 +698,7 @@ impl PointerGrab for ClickGrab {
|
|||
handle: &mut PointerInnerHandle<'_>,
|
||||
button: u32,
|
||||
state: ButtonState,
|
||||
serial: u32,
|
||||
serial: Serial,
|
||||
time: u32,
|
||||
) {
|
||||
handle.button(button, state, serial, time);
|
||||
|
|
|
@ -67,6 +67,7 @@ use std::{
|
|||
};
|
||||
|
||||
use crate::wayland::compositor::{roles::Role, CompositorToken};
|
||||
use crate::wayland::Serial;
|
||||
|
||||
use wayland_server::{
|
||||
protocol::{wl_output, wl_seat, wl_shell, wl_shell_surface, wl_surface},
|
||||
|
@ -81,7 +82,7 @@ pub struct ShellSurfaceRole {
|
|||
pub title: String,
|
||||
/// Class of the surface
|
||||
pub class: String,
|
||||
pending_ping: u32,
|
||||
pending_ping: Serial,
|
||||
}
|
||||
|
||||
/// A handle to a shell surface
|
||||
|
@ -136,12 +137,12 @@ where
|
|||
/// down to 0 before a pong is received, mark the client as unresponsive.
|
||||
///
|
||||
/// Fails if this shell client already has a pending ping or is already dead.
|
||||
pub fn send_ping(&self, serial: u32) -> Result<(), ()> {
|
||||
pub fn send_ping(&self, serial: Serial) -> Result<(), ()> {
|
||||
if !self.alive() {
|
||||
return Err(());
|
||||
}
|
||||
let ret = self.token.with_role_data(&self.wl_surface, |data| {
|
||||
if data.pending_ping == 0 {
|
||||
if data.pending_ping == Serial::from(0) {
|
||||
data.pending_ping = serial;
|
||||
true
|
||||
} else {
|
||||
|
@ -149,7 +150,7 @@ where
|
|||
}
|
||||
});
|
||||
if let Ok(true) = ret {
|
||||
self.shell_surface.ping(serial);
|
||||
self.shell_surface.ping(serial.into());
|
||||
Ok(())
|
||||
} else {
|
||||
Err(())
|
||||
|
@ -201,7 +202,7 @@ pub enum ShellSurfaceKind {
|
|||
parent: wl_surface::WlSurface,
|
||||
/// The serial of the input event triggering the creation of this
|
||||
/// popup
|
||||
serial: u32,
|
||||
serial: Serial,
|
||||
/// Wether this popup should be marked as inactive
|
||||
inactive: bool,
|
||||
/// Location of the popup relative to its parent
|
||||
|
@ -244,7 +245,7 @@ pub enum ShellRequest<R> {
|
|||
/// The surface requesting the move
|
||||
surface: ShellSurface<R>,
|
||||
/// Serial of the implicit grab that initiated the move
|
||||
serial: u32,
|
||||
serial: Serial,
|
||||
/// Seat associated with the move
|
||||
seat: wl_seat::WlSeat,
|
||||
},
|
||||
|
@ -255,7 +256,7 @@ pub enum ShellRequest<R> {
|
|||
/// The surface requesting the resize
|
||||
surface: ShellSurface<R>,
|
||||
/// Serial of the implicit grab that initiated the resize
|
||||
serial: u32,
|
||||
serial: Serial,
|
||||
/// Seat associated with the resize
|
||||
seat: wl_seat::WlSeat,
|
||||
/// Direction of the resize
|
||||
|
|
|
@ -11,6 +11,7 @@ use wayland_server::{
|
|||
};
|
||||
|
||||
use crate::wayland::compositor::{roles::Role, CompositorToken};
|
||||
use crate::wayland::Serial;
|
||||
|
||||
use super::{ShellRequest, ShellState, ShellSurface, ShellSurfaceKind, ShellSurfaceRole};
|
||||
|
||||
|
@ -31,7 +32,7 @@ pub(crate) fn implement_shell<R, Impl>(
|
|||
let role_data = ShellSurfaceRole {
|
||||
title: "".into(),
|
||||
class: "".into(),
|
||||
pending_ping: 0,
|
||||
pending_ping: Serial::from(0),
|
||||
};
|
||||
if ctoken.give_role_with(&surface, role_data).is_err() {
|
||||
shell
|
||||
|
@ -98,10 +99,11 @@ where
|
|||
let mut user_impl = implementation.borrow_mut();
|
||||
match req {
|
||||
Request::Pong { serial } => {
|
||||
let serial = Serial::from(serial);
|
||||
let valid = ctoken
|
||||
.with_role_data(&data.surface, |data| {
|
||||
if data.pending_ping == serial {
|
||||
data.pending_ping = 0;
|
||||
data.pending_ping = Serial::from(0);
|
||||
true
|
||||
} else {
|
||||
false
|
||||
|
@ -114,17 +116,23 @@ where
|
|||
});
|
||||
}
|
||||
}
|
||||
Request::Move { seat, serial } => (&mut *user_impl)(ShellRequest::Move {
|
||||
surface: make_handle(&shell_surface, ctoken),
|
||||
serial,
|
||||
seat,
|
||||
}),
|
||||
Request::Resize { seat, serial, edges } => (&mut *user_impl)(ShellRequest::Resize {
|
||||
surface: make_handle(&shell_surface, ctoken),
|
||||
serial,
|
||||
seat,
|
||||
edges,
|
||||
}),
|
||||
Request::Move { seat, serial } => {
|
||||
let serial = Serial::from(serial);
|
||||
(&mut *user_impl)(ShellRequest::Move {
|
||||
surface: make_handle(&shell_surface, ctoken),
|
||||
serial,
|
||||
seat,
|
||||
})
|
||||
}
|
||||
Request::Resize { seat, serial, edges } => {
|
||||
let serial = Serial::from(serial);
|
||||
(&mut *user_impl)(ShellRequest::Resize {
|
||||
surface: make_handle(&shell_surface, ctoken),
|
||||
serial,
|
||||
seat,
|
||||
edges,
|
||||
})
|
||||
}
|
||||
Request::SetToplevel => (&mut *user_impl)(ShellRequest::SetKind {
|
||||
surface: make_handle(&shell_surface, ctoken),
|
||||
kind: ShellSurfaceKind::Toplevel,
|
||||
|
@ -156,16 +164,19 @@ where
|
|||
x,
|
||||
y,
|
||||
flags,
|
||||
} => (&mut *user_impl)(ShellRequest::SetKind {
|
||||
surface: make_handle(&shell_surface, ctoken),
|
||||
kind: ShellSurfaceKind::Popup {
|
||||
parent,
|
||||
serial,
|
||||
seat,
|
||||
location: (x, y),
|
||||
inactive: flags.contains(wl_shell_surface::Transient::Inactive),
|
||||
},
|
||||
}),
|
||||
} => {
|
||||
let serial = Serial::from(serial);
|
||||
(&mut *user_impl)(ShellRequest::SetKind {
|
||||
surface: make_handle(&shell_surface, ctoken),
|
||||
kind: ShellSurfaceKind::Popup {
|
||||
parent,
|
||||
serial,
|
||||
seat,
|
||||
location: (x, y),
|
||||
inactive: flags.contains(wl_shell_surface::Transient::Inactive),
|
||||
},
|
||||
})
|
||||
}
|
||||
Request::SetMaximized { output } => (&mut *user_impl)(ShellRequest::SetKind {
|
||||
surface: make_handle(&shell_surface, ctoken),
|
||||
kind: ShellSurfaceKind::Maximized { output },
|
||||
|
|
|
@ -88,6 +88,7 @@
|
|||
|
||||
use crate::utils::Rectangle;
|
||||
use crate::wayland::compositor::{roles::Role, CompositorToken};
|
||||
use crate::wayland::Serial;
|
||||
use std::{
|
||||
cell::RefCell,
|
||||
rc::Rc,
|
||||
|
@ -355,13 +356,13 @@ enum ShellClientKind {
|
|||
}
|
||||
|
||||
pub(crate) struct ShellClientData {
|
||||
pending_ping: u32,
|
||||
pending_ping: Serial,
|
||||
data: UserDataMap,
|
||||
}
|
||||
|
||||
fn make_shell_client_data() -> ShellClientData {
|
||||
ShellClientData {
|
||||
pending_ping: 0,
|
||||
pending_ping: Serial::from(0),
|
||||
data: UserDataMap::new(),
|
||||
}
|
||||
}
|
||||
|
@ -414,7 +415,7 @@ where
|
|||
/// down to 0 before a pong is received, mark the client as unresponsive.
|
||||
///
|
||||
/// Fails if this shell client already has a pending ping or is already dead.
|
||||
pub fn send_ping(&self, serial: u32) -> Result<(), ()> {
|
||||
pub fn send_ping(&self, serial: Serial) -> Result<(), ()> {
|
||||
if !self.alive() {
|
||||
return Err(());
|
||||
}
|
||||
|
@ -426,11 +427,11 @@ where
|
|||
.get::<self::xdg_handlers::ShellUserData<R>>()
|
||||
.unwrap();
|
||||
let mut guard = user_data.client_data.lock().unwrap();
|
||||
if guard.pending_ping == 0 {
|
||||
if guard.pending_ping == Serial::from(0) {
|
||||
return Err(());
|
||||
}
|
||||
guard.pending_ping = serial;
|
||||
shell.ping(serial);
|
||||
shell.ping(serial.into());
|
||||
}
|
||||
ShellClientKind::ZxdgV6(ref shell) => {
|
||||
let user_data = shell
|
||||
|
@ -439,11 +440,11 @@ where
|
|||
.get::<self::zxdgv6_handlers::ShellUserData<R>>()
|
||||
.unwrap();
|
||||
let mut guard = user_data.client_data.lock().unwrap();
|
||||
if guard.pending_ping == 0 {
|
||||
if guard.pending_ping == Serial::from(0) {
|
||||
return Err(());
|
||||
}
|
||||
guard.pending_ping = serial;
|
||||
shell.ping(serial);
|
||||
shell.ping(serial.into());
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
@ -830,7 +831,7 @@ pub struct ToplevelConfigure {
|
|||
/// This should be an ever increasing number, as the ACK-ing
|
||||
/// from a client for a serial will validate all pending lower
|
||||
/// serials.
|
||||
pub serial: u32,
|
||||
pub serial: Serial,
|
||||
}
|
||||
|
||||
/// A configure message for popup surface
|
||||
|
@ -845,7 +846,7 @@ pub struct PopupConfigure {
|
|||
/// This should be an ever increasing number, as the ACK-ing
|
||||
/// from a client for a serial will validate all pending lower
|
||||
/// serials.
|
||||
pub serial: u32,
|
||||
pub serial: Serial,
|
||||
}
|
||||
|
||||
/// Events generated by xdg shell surfaces
|
||||
|
@ -891,7 +892,7 @@ pub enum XdgRequest<R> {
|
|||
/// the seat associated to this move
|
||||
seat: wl_seat::WlSeat,
|
||||
/// the grab serial
|
||||
serial: u32,
|
||||
serial: Serial,
|
||||
},
|
||||
/// The client requested the start of an interactive resize for this surface
|
||||
Resize {
|
||||
|
@ -900,7 +901,7 @@ pub enum XdgRequest<R> {
|
|||
/// The seat associated with this resize
|
||||
seat: wl_seat::WlSeat,
|
||||
/// The grab serial
|
||||
serial: u32,
|
||||
serial: Serial,
|
||||
/// Specification of which part of the window's border is being dragged
|
||||
edges: xdg_toplevel::ResizeEdge,
|
||||
},
|
||||
|
@ -914,7 +915,7 @@ pub enum XdgRequest<R> {
|
|||
/// The seat to grab
|
||||
seat: wl_seat::WlSeat,
|
||||
/// The grab serial
|
||||
serial: u32,
|
||||
serial: Serial,
|
||||
},
|
||||
/// A toplevel surface requested to be maximized
|
||||
Maximize {
|
||||
|
@ -953,7 +954,7 @@ pub enum XdgRequest<R> {
|
|||
/// The seat associated with this input grab
|
||||
seat: wl_seat::WlSeat,
|
||||
/// the grab serial
|
||||
serial: u32,
|
||||
serial: Serial,
|
||||
/// location of the menu request
|
||||
location: (i32, i32),
|
||||
},
|
||||
|
@ -962,6 +963,6 @@ pub enum XdgRequest<R> {
|
|||
/// The surface.
|
||||
surface: wl_surface::WlSurface,
|
||||
/// The configure serial.
|
||||
serial: u32,
|
||||
serial: Serial,
|
||||
},
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use std::{cell::RefCell, ops::Deref as _, sync::Mutex};
|
||||
|
||||
use crate::wayland::compositor::{roles::*, CompositorToken};
|
||||
use crate::wayland::Serial;
|
||||
use wayland_protocols::xdg_shell::server::{
|
||||
xdg_popup, xdg_positioner, xdg_surface, xdg_toplevel, xdg_wm_base,
|
||||
};
|
||||
|
@ -94,10 +95,11 @@ where
|
|||
});
|
||||
}
|
||||
xdg_wm_base::Request::Pong { serial } => {
|
||||
let serial = Serial::from(serial);
|
||||
let valid = {
|
||||
let mut guard = data.client_data.lock().unwrap();
|
||||
if guard.pending_ping == serial {
|
||||
guard.pending_ping = 0;
|
||||
guard.pending_ping = Serial::from(0);
|
||||
true
|
||||
} else {
|
||||
false
|
||||
|
@ -344,6 +346,7 @@ where
|
|||
.expect("xdg_surface exists but surface has not shell_surface role?!");
|
||||
|
||||
let mut user_impl = data.shell_data.user_impl.borrow_mut();
|
||||
let serial = Serial::from(serial);
|
||||
(&mut *user_impl)(XdgRequest::AckConfigure {
|
||||
surface: data.wl_surface.clone(),
|
||||
serial,
|
||||
|
@ -405,11 +408,13 @@ where
|
|||
};
|
||||
let serial = configure.serial;
|
||||
resource.configure(width, height, states);
|
||||
data.xdg_surface.configure(serial);
|
||||
data.xdg_surface.configure(serial.into());
|
||||
// Add the configure as pending
|
||||
data.shell_data
|
||||
.compositor_token
|
||||
.with_role_data::<XdgSurfaceRole, _, _>(&data.wl_surface, |data| data.pending_configures.push(serial))
|
||||
.with_role_data::<XdgSurfaceRole, _, _>(&data.wl_surface, |data| {
|
||||
data.pending_configures.push(serial.into())
|
||||
})
|
||||
.expect("xdg_toplevel exists but surface has not shell_surface role?!");
|
||||
}
|
||||
|
||||
|
@ -464,6 +469,7 @@ where
|
|||
}
|
||||
xdg_toplevel::Request::ShowWindowMenu { seat, serial, x, y } => {
|
||||
let handle = make_toplevel_handle(&toplevel);
|
||||
let serial = Serial::from(serial);
|
||||
let mut user_impl = data.shell_data.user_impl.borrow_mut();
|
||||
(&mut *user_impl)(XdgRequest::ShowWindowMenu {
|
||||
surface: handle,
|
||||
|
@ -474,6 +480,7 @@ where
|
|||
}
|
||||
xdg_toplevel::Request::Move { seat, serial } => {
|
||||
let handle = make_toplevel_handle(&toplevel);
|
||||
let serial = Serial::from(serial);
|
||||
let mut user_impl = data.shell_data.user_impl.borrow_mut();
|
||||
(&mut *user_impl)(XdgRequest::Move {
|
||||
surface: handle,
|
||||
|
@ -484,6 +491,7 @@ where
|
|||
xdg_toplevel::Request::Resize { seat, serial, edges } => {
|
||||
let handle = make_toplevel_handle(&toplevel);
|
||||
let mut user_impl = data.shell_data.user_impl.borrow_mut();
|
||||
let serial = Serial::from(serial);
|
||||
(&mut *user_impl)(XdgRequest::Resize {
|
||||
surface: handle,
|
||||
seat,
|
||||
|
@ -581,11 +589,13 @@ where
|
|||
let (width, height) = configure.size;
|
||||
let serial = configure.serial;
|
||||
resource.configure(x, y, width, height);
|
||||
data.xdg_surface.configure(serial);
|
||||
data.xdg_surface.configure(serial.into());
|
||||
// Add the configure as pending
|
||||
data.shell_data
|
||||
.compositor_token
|
||||
.with_role_data::<XdgSurfaceRole, _, _>(&data.wl_surface, |data| data.pending_configures.push(serial))
|
||||
.with_role_data::<XdgSurfaceRole, _, _>(&data.wl_surface, |data| {
|
||||
data.pending_configures.push(serial.into())
|
||||
})
|
||||
.expect("xdg_toplevel exists but surface has not shell_surface role?!");
|
||||
}
|
||||
|
||||
|
@ -618,6 +628,7 @@ where
|
|||
xdg_popup::Request::Grab { seat, serial } => {
|
||||
let handle = make_popup_handle(&popup);
|
||||
let mut user_impl = data.shell_data.user_impl.borrow_mut();
|
||||
let serial = Serial::from(serial);
|
||||
(&mut *user_impl)(XdgRequest::Grab {
|
||||
surface: handle,
|
||||
seat,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use std::{cell::RefCell, ops::Deref as _, sync::Mutex};
|
||||
|
||||
use crate::wayland::compositor::{roles::*, CompositorToken};
|
||||
use crate::wayland::Serial;
|
||||
use wayland_protocols::{
|
||||
unstable::xdg_shell::v6::server::{
|
||||
zxdg_popup_v6, zxdg_positioner_v6, zxdg_shell_v6, zxdg_surface_v6, zxdg_toplevel_v6,
|
||||
|
@ -99,8 +100,8 @@ where
|
|||
zxdg_shell_v6::Request::Pong { serial } => {
|
||||
let valid = {
|
||||
let mut guard = data.client_data.lock().unwrap();
|
||||
if guard.pending_ping == serial {
|
||||
guard.pending_ping = 0;
|
||||
if guard.pending_ping == Serial::from(serial) {
|
||||
guard.pending_ping = Serial::from(0);
|
||||
true
|
||||
} else {
|
||||
false
|
||||
|
@ -362,6 +363,7 @@ fn xdg_surface_implementation<R>(
|
|||
.expect("xdg_surface exists but surface has not shell_surface role?!");
|
||||
|
||||
let mut user_impl = data.shell_data.user_impl.borrow_mut();
|
||||
let serial = Serial::from(serial);
|
||||
(&mut *user_impl)(XdgRequest::AckConfigure {
|
||||
surface: data.wl_surface.clone(),
|
||||
serial,
|
||||
|
@ -423,11 +425,13 @@ where
|
|||
};
|
||||
let serial = configure.serial;
|
||||
resource.configure(width, height, states);
|
||||
data.xdg_surface.configure(serial);
|
||||
data.xdg_surface.configure(serial.into());
|
||||
// Add the configure as pending
|
||||
data.shell_data
|
||||
.compositor_token
|
||||
.with_role_data::<XdgSurfaceRole, _, _>(&data.wl_surface, |data| data.pending_configures.push(serial))
|
||||
.with_role_data::<XdgSurfaceRole, _, _>(&data.wl_surface, |data| {
|
||||
data.pending_configures.push(serial.into())
|
||||
})
|
||||
.expect("xdg_toplevel exists but surface has not shell_surface role?!");
|
||||
}
|
||||
|
||||
|
@ -484,6 +488,7 @@ where
|
|||
zxdg_toplevel_v6::Request::ShowWindowMenu { seat, serial, x, y } => {
|
||||
let handle = make_toplevel_handle(&toplevel);
|
||||
let mut user_impl = data.shell_data.user_impl.borrow_mut();
|
||||
let serial = Serial::from(serial);
|
||||
(&mut *user_impl)(XdgRequest::ShowWindowMenu {
|
||||
surface: handle,
|
||||
seat,
|
||||
|
@ -494,6 +499,7 @@ where
|
|||
zxdg_toplevel_v6::Request::Move { seat, serial } => {
|
||||
let handle = make_toplevel_handle(&toplevel);
|
||||
let mut user_impl = data.shell_data.user_impl.borrow_mut();
|
||||
let serial = Serial::from(serial);
|
||||
(&mut *user_impl)(XdgRequest::Move {
|
||||
surface: handle,
|
||||
seat,
|
||||
|
@ -505,6 +511,7 @@ where
|
|||
zxdg_toplevel_v6::ResizeEdge::from_raw(edges).unwrap_or(zxdg_toplevel_v6::ResizeEdge::None);
|
||||
let handle = make_toplevel_handle(&toplevel);
|
||||
let mut user_impl = data.shell_data.user_impl.borrow_mut();
|
||||
let serial = Serial::from(serial);
|
||||
(&mut *user_impl)(XdgRequest::Resize {
|
||||
surface: handle,
|
||||
seat,
|
||||
|
@ -602,11 +609,13 @@ where
|
|||
let (width, height) = configure.size;
|
||||
let serial = configure.serial;
|
||||
resource.configure(x, y, width, height);
|
||||
data.xdg_surface.configure(serial);
|
||||
data.xdg_surface.configure(serial.into());
|
||||
// Add the configure as pending
|
||||
data.shell_data
|
||||
.compositor_token
|
||||
.with_role_data::<XdgSurfaceRole, _, _>(&data.wl_surface, |data| data.pending_configures.push(serial))
|
||||
.with_role_data::<XdgSurfaceRole, _, _>(&data.wl_surface, |data| {
|
||||
data.pending_configures.push(serial.into())
|
||||
})
|
||||
.expect("xdg_toplevel exists but surface has not shell_surface role?!");
|
||||
}
|
||||
|
||||
|
@ -639,6 +648,7 @@ where
|
|||
zxdg_popup_v6::Request::Grab { seat, serial } => {
|
||||
let handle = make_popup_handle(&popup);
|
||||
let mut user_impl = data.shell_data.user_impl.borrow_mut();
|
||||
let serial = Serial::from(serial);
|
||||
(&mut *user_impl)(XdgRequest::Grab {
|
||||
surface: handle,
|
||||
seat,
|
||||
|
|
Loading…
Reference in New Issue