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