winit/src/platform_impl/linux/wayland/seat/touch/mod.rs

79 lines
1.7 KiB
Rust
Raw Normal View History

Update SCTK to 0.11.0 * Update SCTK to 0.11.0 Updates smithay-client-toolkit to 0.11.0. The major highlight of that updated, is update of wayland-rs to 0.27.0. Switching to wayland-cursor, instead of using libwayland-cursor. It also fixes the following bugs: - Disabled repeat rate not being handled. - Decoration buttons not working after tty switch. - Scaling not being applied on output reenable. - Crash when `XCURSOR_SIZE` is `0`. - Pointer getting created in some cases without pointer capability. - On kwin, fix space between window and decorations on startup. - Incorrect size event when entering fullscreen when using client side decorations. - Client side decorations not being hided properly in fullscreen. - Size tracking between fullscreen/tiled state changes. - Repeat rate triggering multiple times from slow callback handler. - Resizable attribute not being applied properly on startup. - Not working IME Besides those fixes it also adds a bunch of missing virtual key codes, implements proper cursor grabbing, adds right click on decorations to open application menu, disabled maximize button for non-resizeable window, and fall back for cursor icon to similar ones, if the requested is missing. It also adds new methods to a `Theme` trait, such as: - `title_font(&self) -> Option<(String, f32)>` - The font for a title. - `title_color(&self, window_active: bool) -> [u8; 4]` - The color of the text in the title. Fixes #1680. Fixes #1678. Fixes #1676. Fixes #1646. Fixes #1614. Fixes #1601. Fixes #1533. Fixes #1509. Fixes #952. Fixes #947.
2020-09-29 00:11:43 +03:00
//! Touch handling.
use sctk::reexports::client::protocol::wl_seat::WlSeat;
use sctk::reexports::client::protocol::wl_surface::WlSurface;
use sctk::reexports::client::protocol::wl_touch::WlTouch;
use sctk::reexports::client::Attached;
use crate::dpi::LogicalPosition;
use crate::platform_impl::wayland::event_loop::WinitState;
mod handlers;
/// Wrapper around touch to handle release.
pub struct Touch {
/// Proxy to touch.
touch: WlTouch,
}
impl Touch {
pub fn new(seat: &Attached<WlSeat>) -> Self {
let touch = seat.get_touch();
let mut inner = TouchInner::new();
touch.quick_assign(move |_, event, mut dispatch_data| {
let winit_state = dispatch_data.get::<WinitState>().unwrap();
handlers::handle_touch(event, &mut inner, winit_state);
});
Self {
touch: touch.detach(),
}
}
}
impl Drop for Touch {
fn drop(&mut self) {
if self.touch.as_ref().version() >= 3 {
self.touch.release();
}
}
}
/// The data used by touch handlers.
pub(super) struct TouchInner {
/// Current touch points.
touch_points: Vec<TouchPoint>,
}
impl TouchInner {
fn new() -> Self {
Self {
touch_points: Vec::new(),
}
}
}
/// Location of touch press.
pub(super) struct TouchPoint {
/// A surface where the touch point is located.
surface: WlSurface,
/// Location of the touch point.
position: LogicalPosition<f64>,
/// Id.
id: i32,
}
impl TouchPoint {
pub fn new(surface: WlSurface, position: LogicalPosition<f64>, id: i32) -> Self {
Self {
surface,
position,
id,
}
}
}