mirror of
https://github.com/rust-windowing/winit.git
synced 2026-08-29 04:40:04 -04:00
wayland: Update sctk to 0.21
This uses `Dispatch2`, which will be how `Dispatch` is defined in the upcoming wayland-rs release.
This commit is contained in:
committed by
Kirill Chibisov
parent
0e7ed677f1
commit
a9e7bef8ff
@@ -35,10 +35,10 @@ foldhash.workspace = true
|
||||
libc.workspace = true
|
||||
memmap2.workspace = true
|
||||
rustix = { workspace = true, features = ["std", "system", "thread", "process", "event", "pipe"] }
|
||||
sctk = { package = "smithay-client-toolkit", version = "0.20.0", default-features = false, features = [
|
||||
sctk = { package = "smithay-client-toolkit", version = "0.21.0", default-features = false, features = [
|
||||
"calloop",
|
||||
] }
|
||||
sctk-adwaita = { version = "0.11.0", default-features = false, optional = true }
|
||||
sctk-adwaita = { version = "0.12.0", default-features = false, optional = true }
|
||||
wayland-backend = { version = "0.3.10", default-features = false, features = ["client_system"] }
|
||||
wayland-client = "0.31.10"
|
||||
wayland-protocols = { version = "0.32.12", features = ["staging", "unstable"] }
|
||||
|
||||
@@ -801,5 +801,3 @@ impl DataDeviceHandler for WinitState {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sctk::delegate_data_device!(WinitState);
|
||||
|
||||
@@ -878,7 +878,8 @@ impl RootActiveEventLoop for ActiveEventLoop {
|
||||
let serial = seat
|
||||
.pointer_data()
|
||||
.ok_or(NotSupportedError::new(NO_POINTER_CAP_ERROR_MSG))?
|
||||
.latest_button_serial();
|
||||
.latest_button_serial()
|
||||
.unwrap_or_default();
|
||||
|
||||
data_source.start_drag(data_device, source_surface, icon_surface.as_ref(), serial);
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ use sctk::reexports::client::protocol::wl_touch::WlTouch;
|
||||
use sctk::reexports::client::{Connection, Proxy, QueueHandle};
|
||||
use sctk::reexports::protocols::wp::relative_pointer::zv1::client::zwp_relative_pointer_v1::ZwpRelativePointerV1;
|
||||
use sctk::reexports::protocols::wp::text_input::zv3::client::zwp_text_input_v3::ZwpTextInputV3;
|
||||
use sctk::seat::pointer::{ThemeSpec, ThemedPointer};
|
||||
use sctk::seat::pointer::{PointerData, ThemeSpec, ThemedPointer};
|
||||
use sctk::seat::{Capability as SeatCapability, SeatHandler, SeatState};
|
||||
use tracing::warn;
|
||||
use wayland_protocols::wp::pointer_gestures::zv1::client::zwp_pointer_gesture_hold_v1::ZwpPointerGestureHoldV1;
|
||||
@@ -87,7 +87,7 @@ impl WinitSeatState {
|
||||
self.data_device.as_ref()
|
||||
}
|
||||
|
||||
pub(crate) fn pointer_data(&self) -> Option<&WinitPointerData> {
|
||||
pub(crate) fn pointer_data(&self) -> Option<&PointerData<WinitPointerData>> {
|
||||
self.pointer.as_ref().and_then(|pointer| pointer.pointer().data())
|
||||
}
|
||||
}
|
||||
@@ -128,7 +128,7 @@ impl SeatHandler for WinitState {
|
||||
.as_ref()
|
||||
.map(|state| state.get_viewport(&surface, queue_handle));
|
||||
let surface_id = surface.id();
|
||||
let pointer_data = WinitPointerData::new(seat.clone(), viewport);
|
||||
let pointer_data = WinitPointerData::new(viewport);
|
||||
let themed_pointer = self
|
||||
.seat_state
|
||||
.get_pointer_with_theme_and_data(
|
||||
@@ -252,8 +252,8 @@ impl SeatHandler for WinitState {
|
||||
let _ = self.pointer_surfaces.remove(&surface_id);
|
||||
|
||||
// Remove the inner locks/confines before dropping the pointer.
|
||||
pointer_data.unlock_pointer();
|
||||
pointer_data.unconfine_pointer();
|
||||
pointer_data.data().unlock_pointer();
|
||||
pointer_data.data().unconfine_pointer();
|
||||
|
||||
if pointer.pointer().version() >= 3 {
|
||||
pointer.pointer().release();
|
||||
@@ -300,5 +300,3 @@ impl WinitState {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sctk::delegate_seat!(WinitState);
|
||||
|
||||
@@ -8,13 +8,10 @@ use tracing::warn;
|
||||
|
||||
use sctk::reexports::client::delegate_dispatch;
|
||||
use sctk::reexports::client::protocol::wl_pointer::WlPointer;
|
||||
use sctk::reexports::client::protocol::wl_seat::WlSeat;
|
||||
use sctk::reexports::client::protocol::wl_surface::WlSurface;
|
||||
use sctk::reexports::client::{Connection, Proxy, QueueHandle, Dispatch};
|
||||
use sctk::reexports::protocols::wp::pointer_constraints::zv1::client::zwp_confined_pointer_v1::ZwpConfinedPointerV1;
|
||||
use sctk::reexports::protocols::wp::pointer_constraints::zv1::client::zwp_locked_pointer_v1::ZwpLockedPointerV1;
|
||||
use sctk::reexports::protocols::wp::cursor_shape::v1::client::wp_cursor_shape_device_v1::WpCursorShapeDeviceV1;
|
||||
use sctk::reexports::protocols::wp::cursor_shape::v1::client::wp_cursor_shape_manager_v1::WpCursorShapeManagerV1;
|
||||
use sctk::reexports::protocols::wp::pointer_constraints::zv1::client::zwp_pointer_constraints_v1::{Lifetime, ZwpPointerConstraintsV1};
|
||||
use sctk::reexports::client::globals::{BindError, GlobalList};
|
||||
use sctk::reexports::csd_frame::FrameClick;
|
||||
@@ -22,10 +19,7 @@ use sctk::reexports::protocols::wp::viewporter::client::wp_viewport::WpViewport;
|
||||
|
||||
use sctk::compositor::SurfaceData;
|
||||
use sctk::globals::GlobalData;
|
||||
use sctk::seat::SeatState;
|
||||
use sctk::seat::pointer::{
|
||||
PointerData, PointerDataExt, PointerEvent, PointerEventKind, PointerHandler,
|
||||
};
|
||||
use sctk::seat::pointer::{PointerData, PointerEvent, PointerEventKind, PointerHandler};
|
||||
|
||||
use dpi::{LogicalPosition, PhysicalPosition};
|
||||
use winit_core::event::{
|
||||
@@ -68,7 +62,7 @@ impl PointerHandler for WinitState {
|
||||
let surface = &event.surface;
|
||||
|
||||
// The parent surface.
|
||||
let parent_surface = match event.surface.data::<SurfaceData>() {
|
||||
let parent_surface = match event.surface.data::<SurfaceData<()>>() {
|
||||
Some(data) => data.parent_surface().unwrap_or(surface),
|
||||
None => continue,
|
||||
};
|
||||
@@ -140,13 +134,13 @@ impl PointerHandler for WinitState {
|
||||
window.pointer_entered(Arc::downgrade(themed_pointer));
|
||||
|
||||
// Set the currently focused surface.
|
||||
pointer.winit_data().inner.lock().unwrap().surface = Some(window_id);
|
||||
pointer.winit_data().data().inner.lock().unwrap().surface = Some(window_id);
|
||||
},
|
||||
PointerEventKind::Leave { .. } => {
|
||||
window.pointer_left(Arc::downgrade(themed_pointer));
|
||||
|
||||
// Remove the active surface.
|
||||
pointer.winit_data().inner.lock().unwrap().surface = None;
|
||||
pointer.winit_data().data().inner.lock().unwrap().surface = None;
|
||||
|
||||
self.events_sink.push_window_event(
|
||||
WindowEvent::PointerLeft {
|
||||
@@ -172,7 +166,7 @@ impl PointerHandler for WinitState {
|
||||
ref kind @ PointerEventKind::Press { button, serial, .. }
|
||||
| ref kind @ PointerEventKind::Release { button, serial, .. } => {
|
||||
// Update the last button serial.
|
||||
pointer.winit_data().inner.lock().unwrap().latest_button_serial = serial;
|
||||
pointer.winit_data().data().inner.lock().unwrap().latest_button_serial = serial;
|
||||
|
||||
let button = wayland_button_to_winit(button);
|
||||
let state = if matches!(kind, PointerEventKind::Press { .. }) {
|
||||
@@ -193,7 +187,7 @@ impl PointerHandler for WinitState {
|
||||
},
|
||||
PointerEventKind::Axis { horizontal, vertical, .. } => {
|
||||
// Get the current phase.
|
||||
let mut pointer_data = pointer.winit_data().inner.lock().unwrap();
|
||||
let mut pointer_data = pointer.winit_data().data().inner.lock().unwrap();
|
||||
|
||||
let has_value120_scroll = horizontal.value120 != 0 || vertical.value120 != 0;
|
||||
let has_discrete_scroll = horizontal.discrete != 0 || vertical.discrete != 0;
|
||||
@@ -253,20 +247,13 @@ pub struct WinitPointerData {
|
||||
/// The inner winit data associated with the pointer.
|
||||
inner: Mutex<WinitPointerDataInner>,
|
||||
|
||||
/// The data required by the sctk.
|
||||
sctk_data: PointerData,
|
||||
|
||||
/// Viewport for fractional cursor.
|
||||
viewport: Option<WpViewport>,
|
||||
}
|
||||
|
||||
impl WinitPointerData {
|
||||
pub fn new(seat: WlSeat, viewport: Option<WpViewport>) -> Self {
|
||||
Self {
|
||||
inner: Mutex::new(WinitPointerDataInner::default()),
|
||||
sctk_data: PointerData::new(seat),
|
||||
viewport,
|
||||
}
|
||||
pub fn new(viewport: Option<WpViewport>) -> Self {
|
||||
Self { inner: Mutex::new(WinitPointerDataInner::default()), viewport }
|
||||
}
|
||||
|
||||
pub fn lock_pointer(
|
||||
@@ -320,26 +307,11 @@ impl WinitPointerData {
|
||||
}
|
||||
}
|
||||
|
||||
/// Seat associated with this pointer.
|
||||
pub fn seat(&self) -> &WlSeat {
|
||||
self.sctk_data.seat()
|
||||
}
|
||||
|
||||
/// Active window.
|
||||
pub fn focused_window(&self) -> Option<WindowId> {
|
||||
self.inner.lock().unwrap().surface
|
||||
}
|
||||
|
||||
/// Last button serial.
|
||||
pub fn latest_button_serial(&self) -> u32 {
|
||||
self.sctk_data.latest_button_serial().unwrap_or_default()
|
||||
}
|
||||
|
||||
/// Last enter serial.
|
||||
pub fn latest_enter_serial(&self) -> u32 {
|
||||
self.sctk_data.latest_enter_serial().unwrap_or_default()
|
||||
}
|
||||
|
||||
pub fn set_locked_cursor_position(&self, surface_x: f64, surface_y: f64) {
|
||||
let inner = self.inner.lock().unwrap();
|
||||
if let Some(locked_pointer) = inner.locked_pointer.as_ref() {
|
||||
@@ -360,12 +332,6 @@ impl Drop for WinitPointerData {
|
||||
}
|
||||
}
|
||||
|
||||
impl PointerDataExt for WinitPointerData {
|
||||
fn pointer_data(&self) -> &PointerData {
|
||||
&self.sctk_data
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct WinitPointerDataInner {
|
||||
/// The associated locked pointer.
|
||||
@@ -423,12 +389,12 @@ fn wayland_button_to_winit(button: u32) -> ButtonSource {
|
||||
}
|
||||
|
||||
pub trait WinitPointerDataExt {
|
||||
fn winit_data(&self) -> &WinitPointerData;
|
||||
fn winit_data(&self) -> &PointerData<WinitPointerData>;
|
||||
}
|
||||
|
||||
impl WinitPointerDataExt for WlPointer {
|
||||
fn winit_data(&self) -> &WinitPointerData {
|
||||
self.data::<WinitPointerData>().expect("failed to get pointer data.")
|
||||
fn winit_data(&self) -> &PointerData<WinitPointerData> {
|
||||
self.data::<PointerData<WinitPointerData>>().expect("failed to get pointer data.")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -491,35 +457,6 @@ impl Dispatch<ZwpConfinedPointerV1, GlobalData, WinitState> for PointerConstrain
|
||||
}
|
||||
}
|
||||
|
||||
impl Dispatch<WpCursorShapeDeviceV1, GlobalData, WinitState> for SeatState {
|
||||
fn event(
|
||||
_: &mut WinitState,
|
||||
_: &WpCursorShapeDeviceV1,
|
||||
_: <WpCursorShapeDeviceV1 as Proxy>::Event,
|
||||
_: &GlobalData,
|
||||
_: &Connection,
|
||||
_: &QueueHandle<WinitState>,
|
||||
) {
|
||||
unreachable!("wp_cursor_shape_manager has no events")
|
||||
}
|
||||
}
|
||||
|
||||
impl Dispatch<WpCursorShapeManagerV1, GlobalData, WinitState> for SeatState {
|
||||
fn event(
|
||||
_: &mut WinitState,
|
||||
_: &WpCursorShapeManagerV1,
|
||||
_: <WpCursorShapeManagerV1 as Proxy>::Event,
|
||||
_: &GlobalData,
|
||||
_: &Connection,
|
||||
_: &QueueHandle<WinitState>,
|
||||
) {
|
||||
unreachable!("wp_cursor_device_manager has no events")
|
||||
}
|
||||
}
|
||||
|
||||
delegate_dispatch!(WinitState: [ WlPointer: WinitPointerData] => SeatState);
|
||||
delegate_dispatch!(WinitState: [ WpCursorShapeManagerV1: GlobalData] => SeatState);
|
||||
delegate_dispatch!(WinitState: [ WpCursorShapeDeviceV1: GlobalData] => SeatState);
|
||||
delegate_dispatch!(WinitState: [ZwpPointerConstraintsV1: GlobalData] => PointerConstraintsState);
|
||||
delegate_dispatch!(WinitState: [ZwpLockedPointerV1: GlobalData] => PointerConstraintsState);
|
||||
delegate_dispatch!(WinitState: [ZwpConfinedPointerV1: GlobalData] => PointerConstraintsState);
|
||||
|
||||
@@ -134,7 +134,9 @@ impl Dispatch<ZwpPointerGesturePinchV1, PointerGestureData, WinitState> for Poin
|
||||
}
|
||||
|
||||
// Don't handle events from a subsurface.
|
||||
if surface.data::<SurfaceData>().is_none_or(|data| data.parent_surface().is_some())
|
||||
if surface
|
||||
.data::<SurfaceData<()>>()
|
||||
.is_none_or(|data| data.parent_surface().is_some())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -247,8 +247,6 @@ pub trait TouchDataExt {
|
||||
|
||||
impl TouchDataExt for WlTouch {
|
||||
fn seat(&self) -> &WlSeat {
|
||||
self.data::<TouchData>().expect("failed to get touch data.").seat()
|
||||
self.data::<TouchData<()>>().expect("failed to get touch data.").seat()
|
||||
}
|
||||
}
|
||||
|
||||
sctk::delegate_touch!(WinitState);
|
||||
|
||||
@@ -268,7 +268,7 @@ impl WinitState {
|
||||
self.window_compositor_updates[pos].scale_changed = true;
|
||||
} else if let Some(pointer) = self.pointer_surfaces.get(&surface.id()) {
|
||||
// Get the window, where the pointer resides right now.
|
||||
let focused_window = match pointer.pointer().winit_data().focused_window() {
|
||||
let focused_window = match pointer.pointer().winit_data().data().focused_window() {
|
||||
Some(focused_window) => focused_window,
|
||||
None => return,
|
||||
};
|
||||
@@ -467,10 +467,5 @@ impl WindowCompositorUpdate {
|
||||
}
|
||||
}
|
||||
|
||||
sctk::delegate_subcompositor!(WinitState);
|
||||
sctk::delegate_compositor!(WinitState);
|
||||
sctk::delegate_output!(WinitState);
|
||||
sctk::delegate_dispatch2!(WinitState);
|
||||
sctk::delegate_registry!(WinitState);
|
||||
sctk::delegate_shm!(WinitState);
|
||||
sctk::delegate_xdg_shell!(WinitState);
|
||||
sctk::delegate_xdg_window!(WinitState);
|
||||
|
||||
@@ -4,14 +4,12 @@ use std::sync::Mutex;
|
||||
|
||||
use dpi::LogicalPosition;
|
||||
use sctk::compositor::SurfaceData;
|
||||
use sctk::globals::GlobalData;
|
||||
use sctk::dispatch2::Dispatch2;
|
||||
use sctk::reexports::client::backend::smallvec::SmallVec;
|
||||
use sctk::reexports::client::globals::{BindError, GlobalList};
|
||||
use sctk::reexports::client::protocol::wl_seat::WlSeat;
|
||||
use sctk::reexports::client::protocol::wl_surface::WlSurface;
|
||||
use sctk::reexports::client::{
|
||||
Connection, Dispatch, Proxy, QueueHandle, WEnum, delegate_dispatch, event_created_child,
|
||||
};
|
||||
use sctk::reexports::client::{Connection, Proxy, QueueHandle, WEnum, event_created_child};
|
||||
use sctk::reexports::protocols::wp::tablet::zv2::client::zwp_tablet_manager_v2::ZwpTabletManagerV2;
|
||||
use sctk::reexports::protocols::wp::tablet::zv2::client::zwp_tablet_pad_v2::ZwpTabletPadV2;
|
||||
use sctk::reexports::protocols::wp::tablet::zv2::client::zwp_tablet_seat_v2::{
|
||||
@@ -47,7 +45,7 @@ impl TabletManager {
|
||||
queue_handle: &QueueHandle<WinitState>,
|
||||
) -> Result<Self, BindError> {
|
||||
// Ignore v2 since we are not interested in its events.
|
||||
let manager = globals.bind(queue_handle, 1..=1, GlobalData)?;
|
||||
let manager = globals.bind(queue_handle, 1..=1, ())?;
|
||||
Ok(Self { manager })
|
||||
}
|
||||
|
||||
@@ -59,12 +57,12 @@ impl TabletManager {
|
||||
self.manager.get_tablet_seat(seat, queue_handle, ())
|
||||
}
|
||||
}
|
||||
impl Dispatch<ZwpTabletManagerV2, GlobalData, WinitState> for TabletManager {
|
||||
impl Dispatch2<ZwpTabletManagerV2, WinitState> for () {
|
||||
fn event(
|
||||
&self,
|
||||
_: &mut WinitState,
|
||||
_: &ZwpTabletManagerV2,
|
||||
_: <ZwpTabletManagerV2 as Proxy>::Event,
|
||||
_: &GlobalData,
|
||||
_: &Connection,
|
||||
_: &QueueHandle<WinitState>,
|
||||
) {
|
||||
@@ -72,47 +70,34 @@ impl Dispatch<ZwpTabletManagerV2, GlobalData, WinitState> for TabletManager {
|
||||
}
|
||||
}
|
||||
|
||||
impl Dispatch<ZwpTabletManagerV2, (), WinitState> for TabletManager {
|
||||
fn event(
|
||||
_: &mut WinitState,
|
||||
_: &ZwpTabletManagerV2,
|
||||
_: <ZwpTabletManagerV2 as Proxy>::Event,
|
||||
_: &(),
|
||||
_: &Connection,
|
||||
_: &QueueHandle<WinitState>,
|
||||
) {
|
||||
unreachable!("no events defined for zwp_tablet_manager_v2");
|
||||
}
|
||||
}
|
||||
|
||||
impl Dispatch<ZwpTabletSeatV2, (), WinitState> for TabletManager {
|
||||
impl Dispatch2<ZwpTabletSeatV2, WinitState> for () {
|
||||
event_created_child!(WinitState, ZwpTabletSeatV2, [
|
||||
zwp_tablet_seat_v2::EVT_TABLET_ADDED_OPCODE => (ZwpTabletV2, Default::default()),
|
||||
zwp_tablet_seat_v2::EVT_TOOL_ADDED_OPCODE => (ZwpTabletToolV2, Default::default()),
|
||||
zwp_tablet_seat_v2::EVT_PAD_ADDED_OPCODE => (ZwpTabletPadV2, Default::default())
|
||||
zwp_tablet_seat_v2::EVT_TABLET_ADDED_OPCODE => (ZwpTabletV2, ()),
|
||||
zwp_tablet_seat_v2::EVT_TOOL_ADDED_OPCODE => (ZwpTabletToolV2, TabletToolData::default()),
|
||||
zwp_tablet_seat_v2::EVT_PAD_ADDED_OPCODE => (ZwpTabletPadV2, ())
|
||||
]);
|
||||
|
||||
fn event(
|
||||
&self,
|
||||
_: &mut WinitState,
|
||||
_: &ZwpTabletSeatV2,
|
||||
_: <ZwpTabletSeatV2 as Proxy>::Event,
|
||||
_: &(),
|
||||
_: &Connection,
|
||||
_: &QueueHandle<WinitState>,
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
||||
impl Dispatch<ZwpTabletToolV2, TabletToolData, WinitState> for TabletManager {
|
||||
impl Dispatch2<ZwpTabletToolV2, WinitState> for TabletToolData {
|
||||
fn event(
|
||||
&self,
|
||||
state: &mut WinitState,
|
||||
_: &ZwpTabletToolV2,
|
||||
event: <ZwpTabletToolV2 as Proxy>::Event,
|
||||
data: &TabletToolData,
|
||||
_: &Connection,
|
||||
_: &QueueHandle<WinitState>,
|
||||
) {
|
||||
let mut data = data.inner.lock().unwrap();
|
||||
let mut data = self.inner.lock().unwrap();
|
||||
|
||||
match event {
|
||||
ToolEvent::Type { tool_type: WEnum::Value(tool_type) } => {
|
||||
@@ -198,7 +183,7 @@ impl Dispatch<ZwpTabletToolV2, TabletToolData, WinitState> for TabletManager {
|
||||
let surface = match data
|
||||
.surface
|
||||
.as_ref()
|
||||
.map(|surface| (surface, surface.data::<SurfaceData>()))
|
||||
.map(|surface| (surface, surface.data::<SurfaceData<()>>()))
|
||||
{
|
||||
Some((surface, Some(surface_data)))
|
||||
if surface_data.parent_surface().is_none() =>
|
||||
@@ -318,95 +303,84 @@ pub(crate) enum TabletEvent {
|
||||
Button { button: TabletToolButton, state: ElementState, serial: Option<u32> },
|
||||
}
|
||||
|
||||
impl Dispatch<ZwpTabletV2, (), WinitState> for TabletManager {
|
||||
impl Dispatch2<ZwpTabletV2, WinitState> for () {
|
||||
fn event(
|
||||
&self,
|
||||
_: &mut WinitState,
|
||||
_: &ZwpTabletV2,
|
||||
_: <ZwpTabletV2 as Proxy>::Event,
|
||||
_: &(),
|
||||
_: &Connection,
|
||||
_: &QueueHandle<WinitState>,
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
||||
impl Dispatch<ZwpTabletPadV2, (), WinitState> for TabletManager {
|
||||
impl Dispatch2<ZwpTabletPadV2, WinitState> for () {
|
||||
event_created_child!(WinitState, ZwpTabletPadV2, [
|
||||
zwp_tablet_pad_v2::EVT_GROUP_OPCODE => (ZwpTabletPadGroupV2, Default::default()),
|
||||
zwp_tablet_pad_v2::EVT_GROUP_OPCODE => (ZwpTabletPadGroupV2, ()),
|
||||
]);
|
||||
|
||||
fn event(
|
||||
&self,
|
||||
_: &mut WinitState,
|
||||
_: &ZwpTabletPadV2,
|
||||
_: <ZwpTabletPadV2 as Proxy>::Event,
|
||||
_: &(),
|
||||
_: &Connection,
|
||||
_: &QueueHandle<WinitState>,
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
||||
impl Dispatch<ZwpTabletPadGroupV2, (), WinitState> for TabletManager {
|
||||
impl Dispatch2<ZwpTabletPadGroupV2, WinitState> for () {
|
||||
event_created_child!(WinitState, ZwpTabletPadGroupV2, [
|
||||
zwp_tablet_pad_group_v2::EVT_RING_OPCODE => (ZwpTabletPadRingV2, Default::default()),
|
||||
zwp_tablet_pad_group_v2::EVT_STRIP_OPCODE => (ZwpTabletPadStripV2, Default::default()),
|
||||
zwp_tablet_pad_group_v2::EVT_DIAL_OPCODE => (ZwpTabletPadDialV2, Default::default()),
|
||||
zwp_tablet_pad_group_v2::EVT_RING_OPCODE => (ZwpTabletPadRingV2, ()),
|
||||
zwp_tablet_pad_group_v2::EVT_STRIP_OPCODE => (ZwpTabletPadStripV2, ()),
|
||||
zwp_tablet_pad_group_v2::EVT_DIAL_OPCODE => (ZwpTabletPadDialV2, ()),
|
||||
]);
|
||||
|
||||
fn event(
|
||||
&self,
|
||||
_: &mut WinitState,
|
||||
_: &ZwpTabletPadGroupV2,
|
||||
_: <ZwpTabletPadGroupV2 as Proxy>::Event,
|
||||
_: &(),
|
||||
_: &Connection,
|
||||
_: &QueueHandle<WinitState>,
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
||||
impl Dispatch<ZwpTabletPadRingV2, (), WinitState> for TabletManager {
|
||||
impl Dispatch2<ZwpTabletPadRingV2, WinitState> for () {
|
||||
fn event(
|
||||
&self,
|
||||
_: &mut WinitState,
|
||||
_: &ZwpTabletPadRingV2,
|
||||
_: <ZwpTabletPadRingV2 as Proxy>::Event,
|
||||
_: &(),
|
||||
_: &Connection,
|
||||
_: &QueueHandle<WinitState>,
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
||||
impl Dispatch<ZwpTabletPadStripV2, (), WinitState> for TabletManager {
|
||||
impl Dispatch2<ZwpTabletPadStripV2, WinitState> for () {
|
||||
fn event(
|
||||
&self,
|
||||
_: &mut WinitState,
|
||||
_: &ZwpTabletPadStripV2,
|
||||
_: <ZwpTabletPadStripV2 as Proxy>::Event,
|
||||
_: &(),
|
||||
_: &Connection,
|
||||
_: &QueueHandle<WinitState>,
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
||||
impl Dispatch<ZwpTabletPadDialV2, (), WinitState> for TabletManager {
|
||||
impl Dispatch2<ZwpTabletPadDialV2, WinitState> for () {
|
||||
fn event(
|
||||
&self,
|
||||
_: &mut WinitState,
|
||||
_: &ZwpTabletPadDialV2,
|
||||
_: <ZwpTabletPadDialV2 as Proxy>::Event,
|
||||
_: &(),
|
||||
_: &Connection,
|
||||
_: &QueueHandle<WinitState>,
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
||||
delegate_dispatch!(WinitState: [ZwpTabletManagerV2: GlobalData] => TabletManager);
|
||||
delegate_dispatch!(WinitState: [ZwpTabletManagerV2: ()] => TabletManager);
|
||||
delegate_dispatch!(WinitState: [ZwpTabletSeatV2: ()] => TabletManager);
|
||||
delegate_dispatch!(WinitState: [ZwpTabletV2: ()] => TabletManager);
|
||||
delegate_dispatch!(WinitState: [ZwpTabletToolV2: TabletToolData] => TabletManager);
|
||||
delegate_dispatch!(WinitState: [ZwpTabletPadV2: ()] => TabletManager);
|
||||
delegate_dispatch!(WinitState: [ZwpTabletPadGroupV2: ()] => TabletManager);
|
||||
delegate_dispatch!(WinitState: [ZwpTabletPadRingV2: ()] => TabletManager);
|
||||
delegate_dispatch!(WinitState: [ZwpTabletPadStripV2: ()] => TabletManager);
|
||||
delegate_dispatch!(WinitState: [ZwpTabletPadDialV2: ()] => TabletManager);
|
||||
|
||||
@@ -637,7 +637,7 @@ impl CoreWindow for Window {
|
||||
}
|
||||
|
||||
fn current_monitor(&self) -> Option<CoreMonitorHandle> {
|
||||
let data = self.window.wl_surface().data::<SurfaceData>()?;
|
||||
let data = self.window.wl_surface().data::<SurfaceData<()>>()?;
|
||||
data.outputs()
|
||||
.next()
|
||||
.map(MonitorHandle::new)
|
||||
|
||||
@@ -6,7 +6,7 @@ use std::time::Duration;
|
||||
|
||||
use dpi::{LogicalPosition, LogicalSize, PhysicalPosition, PhysicalSize, Size};
|
||||
use foldhash::HashSet;
|
||||
use sctk::compositor::{CompositorState, Region, SurfaceData, SurfaceDataExt};
|
||||
use sctk::compositor::{CompositorState, FrameCallbackData, Region, SurfaceData};
|
||||
use sctk::globals::GlobalData;
|
||||
use sctk::reexports::client::backend::ObjectId;
|
||||
use sctk::reexports::client::protocol::wl_seat::WlSeat;
|
||||
@@ -20,7 +20,7 @@ use sctk::reexports::protocols::wp::fractional_scale::v1::client::wp_fractional_
|
||||
use sctk::reexports::protocols::wp::text_input::zv3::client::zwp_text_input_v3::ZwpTextInputV3;
|
||||
use sctk::reexports::protocols::wp::viewporter::client::wp_viewport::WpViewport;
|
||||
use sctk::reexports::protocols::xdg::shell::client::xdg_toplevel::ResizeEdge as XdgResizeEdge;
|
||||
use sctk::seat::pointer::{PointerDataExt, ThemedPointer};
|
||||
use sctk::seat::pointer::{PointerData, ThemedPointer};
|
||||
use sctk::shell::WaylandSurface;
|
||||
use sctk::shell::xdg::XdgSurface;
|
||||
use sctk::shell::xdg::window::{DecorationMode, Window, WindowConfigure};
|
||||
@@ -250,7 +250,9 @@ impl WindowState {
|
||||
}
|
||||
|
||||
/// Apply closure on the given pointer.
|
||||
fn apply_on_pointer<F: FnMut(&ThemedPointer<WinitPointerData>, &WinitPointerData)>(
|
||||
fn apply_on_pointer<
|
||||
F: FnMut(&ThemedPointer<WinitPointerData>, &PointerData<WinitPointerData>),
|
||||
>(
|
||||
&self,
|
||||
mut callback: F,
|
||||
) {
|
||||
@@ -281,7 +283,7 @@ impl WindowState {
|
||||
match self.frame_callback_state {
|
||||
FrameCallbackState::None | FrameCallbackState::Received => {
|
||||
self.frame_callback_state = FrameCallbackState::Requested;
|
||||
surface.frame(&self.queue_handle, surface.clone());
|
||||
surface.frame(&self.queue_handle, FrameCallbackData(surface.clone()));
|
||||
},
|
||||
FrameCallbackState::Requested => (),
|
||||
}
|
||||
@@ -460,9 +462,10 @@ impl WindowState {
|
||||
|
||||
// TODO(kchibisov) handle touch serials.
|
||||
self.apply_on_pointer(|_, data| {
|
||||
let serial = data.latest_button_serial();
|
||||
let seat = data.seat();
|
||||
xdg_toplevel.resize(seat, serial, resize_direction_to_xdg(direction));
|
||||
if let Some(serial) = data.latest_button_serial() {
|
||||
let seat = data.seat();
|
||||
xdg_toplevel.resize(seat, serial, resize_direction_to_xdg(direction));
|
||||
}
|
||||
});
|
||||
|
||||
Ok(())
|
||||
@@ -473,9 +476,10 @@ impl WindowState {
|
||||
let xdg_toplevel = self.window.xdg_toplevel();
|
||||
// TODO(kchibisov) handle touch serials.
|
||||
self.apply_on_pointer(|_, data| {
|
||||
let serial = data.latest_button_serial();
|
||||
let seat = data.seat();
|
||||
xdg_toplevel._move(seat, serial);
|
||||
if let Some(serial) = data.latest_button_serial() {
|
||||
let seat = data.seat();
|
||||
xdg_toplevel._move(seat, serial);
|
||||
}
|
||||
});
|
||||
|
||||
Ok(())
|
||||
@@ -815,13 +819,13 @@ impl WindowState {
|
||||
self.apply_on_pointer(|pointer, data| {
|
||||
let surface = pointer.surface();
|
||||
|
||||
let scale = if let Some(viewport) = data.viewport() {
|
||||
let scale = if let Some(viewport) = data.data().viewport() {
|
||||
let scale = self.scale_factor();
|
||||
let size = PhysicalSize::new(cursor.w, cursor.h).to_logical(scale);
|
||||
viewport.set_destination(size.width, size.height);
|
||||
scale
|
||||
} else if surface.version() >= 3 {
|
||||
let scale = surface.data::<SurfaceData>().unwrap().surface_data().scale_factor();
|
||||
let scale = surface.data::<SurfaceData<()>>().unwrap().scale_factor();
|
||||
surface.set_buffer_scale(scale);
|
||||
scale as f64
|
||||
} else {
|
||||
@@ -839,8 +843,8 @@ impl WindowState {
|
||||
|
||||
let serial = pointer
|
||||
.pointer()
|
||||
.data::<WinitPointerData>()
|
||||
.and_then(|data| data.pointer_data().latest_enter_serial())
|
||||
.data::<PointerData<WinitPointerData>>()
|
||||
.and_then(|data| data.latest_enter_serial())
|
||||
.unwrap();
|
||||
|
||||
let hotspot =
|
||||
@@ -929,12 +933,12 @@ impl WindowState {
|
||||
match self.cursor_grab_mode.current_grab_mode {
|
||||
CursorGrabMode::None => unset_old = true,
|
||||
CursorGrabMode::Confined => self.apply_on_pointer(|_, data| {
|
||||
data.unconfine_pointer();
|
||||
data.data().unconfine_pointer();
|
||||
unset_old = true;
|
||||
}),
|
||||
CursorGrabMode::Locked => {
|
||||
self.apply_on_pointer(|_, data| {
|
||||
data.unlock_pointer();
|
||||
data.data().unlock_pointer();
|
||||
unset_old = true;
|
||||
});
|
||||
},
|
||||
@@ -951,12 +955,17 @@ impl WindowState {
|
||||
match mode {
|
||||
CursorGrabMode::Locked => self.apply_on_pointer(|pointer, data| {
|
||||
let pointer = pointer.pointer();
|
||||
data.lock_pointer(pointer_constraints, surface, pointer, &self.queue_handle);
|
||||
data.data().lock_pointer(pointer_constraints, surface, pointer, &self.queue_handle);
|
||||
set_mode = true;
|
||||
}),
|
||||
CursorGrabMode::Confined => self.apply_on_pointer(|pointer, data| {
|
||||
let pointer = pointer.pointer();
|
||||
data.confine_pointer(pointer_constraints, surface, pointer, &self.queue_handle);
|
||||
data.data().confine_pointer(
|
||||
pointer_constraints,
|
||||
surface,
|
||||
pointer,
|
||||
&self.queue_handle,
|
||||
);
|
||||
set_mode = true;
|
||||
}),
|
||||
CursorGrabMode::None => {
|
||||
@@ -976,9 +985,10 @@ impl WindowState {
|
||||
pub fn show_window_menu(&self, position: LogicalPosition<u32>) {
|
||||
// TODO(kchibisov) handle touch serials.
|
||||
self.apply_on_pointer(|_, data| {
|
||||
let serial = data.latest_button_serial();
|
||||
let seat = data.seat();
|
||||
self.window.show_window_menu(seat, serial, position.into());
|
||||
if let Some(serial) = data.latest_button_serial() {
|
||||
let seat = data.seat();
|
||||
self.window.show_window_menu(seat, serial, position.into());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -997,7 +1007,7 @@ impl WindowState {
|
||||
}
|
||||
|
||||
self.apply_on_pointer(|_, data| {
|
||||
data.set_locked_cursor_position(position.x, position.y);
|
||||
data.data().set_locked_cursor_position(position.x, position.y);
|
||||
});
|
||||
|
||||
Ok(())
|
||||
@@ -1014,9 +1024,11 @@ impl WindowState {
|
||||
}
|
||||
} else {
|
||||
for pointer in self.pointers.iter().filter_map(|pointer| pointer.upgrade()) {
|
||||
let latest_enter_serial = pointer.pointer().winit_data().latest_enter_serial();
|
||||
|
||||
pointer.pointer().set_cursor(latest_enter_serial, None, 0, 0);
|
||||
if let Some(latest_enter_serial) =
|
||||
pointer.pointer().winit_data().latest_enter_serial()
|
||||
{
|
||||
pointer.pointer().set_cursor(latest_enter_serial, None, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user