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.
This commit is contained in:
parent
471b1e003a
commit
3d85af04be
31 changed files with 3791 additions and 2630 deletions
122
src/platform_impl/linux/wayland/seat/touch/handlers.rs
Normal file
122
src/platform_impl/linux/wayland/seat/touch/handlers.rs
Normal file
|
|
@ -0,0 +1,122 @@
|
|||
//! Various handlers for touch events.
|
||||
|
||||
use sctk::reexports::client::protocol::wl_touch::Event as TouchEvent;
|
||||
|
||||
use crate::dpi::LogicalPosition;
|
||||
use crate::event::{TouchPhase, WindowEvent};
|
||||
|
||||
use crate::platform_impl::wayland::event_loop::WinitState;
|
||||
use crate::platform_impl::wayland::{self, DeviceId};
|
||||
|
||||
use super::{TouchInner, TouchPoint};
|
||||
|
||||
/// Handle WlTouch events.
|
||||
#[inline]
|
||||
pub(super) fn handle_touch(
|
||||
event: TouchEvent,
|
||||
inner: &mut TouchInner,
|
||||
winit_state: &mut WinitState,
|
||||
) {
|
||||
let event_sink = &mut winit_state.event_sink;
|
||||
|
||||
match event {
|
||||
TouchEvent::Down {
|
||||
surface, id, x, y, ..
|
||||
} => {
|
||||
let window_id = wayland::make_wid(&surface);
|
||||
if !winit_state.window_map.contains_key(&window_id) {
|
||||
return;
|
||||
}
|
||||
|
||||
let scale_factor = sctk::get_surface_scale_factor(&surface) as f64;
|
||||
let position = LogicalPosition::new(x, y);
|
||||
|
||||
event_sink.push_window_event(
|
||||
WindowEvent::Touch(crate::event::Touch {
|
||||
device_id: crate::event::DeviceId(crate::platform_impl::DeviceId::Wayland(
|
||||
DeviceId,
|
||||
)),
|
||||
phase: TouchPhase::Started,
|
||||
location: position.to_physical(scale_factor),
|
||||
force: None, // TODO
|
||||
id: id as u64,
|
||||
}),
|
||||
window_id,
|
||||
);
|
||||
|
||||
inner
|
||||
.touch_points
|
||||
.push(TouchPoint::new(surface, position, id));
|
||||
}
|
||||
TouchEvent::Up { id, .. } => {
|
||||
let touch_point = match inner.touch_points.iter().find(|p| p.id == id) {
|
||||
Some(touch_point) => touch_point,
|
||||
None => return,
|
||||
};
|
||||
|
||||
let scale_factor = sctk::get_surface_scale_factor(&touch_point.surface) as f64;
|
||||
let location = touch_point.position.to_physical(scale_factor);
|
||||
let window_id = wayland::make_wid(&touch_point.surface);
|
||||
|
||||
event_sink.push_window_event(
|
||||
WindowEvent::Touch(crate::event::Touch {
|
||||
device_id: crate::event::DeviceId(crate::platform_impl::DeviceId::Wayland(
|
||||
DeviceId,
|
||||
)),
|
||||
phase: TouchPhase::Ended,
|
||||
location,
|
||||
force: None, // TODO
|
||||
id: id as u64,
|
||||
}),
|
||||
window_id,
|
||||
);
|
||||
}
|
||||
TouchEvent::Motion { id, x, y, .. } => {
|
||||
let touch_point = match inner.touch_points.iter_mut().find(|p| p.id == id) {
|
||||
Some(touch_point) => touch_point,
|
||||
None => return,
|
||||
};
|
||||
|
||||
touch_point.position = LogicalPosition::new(x, y);
|
||||
|
||||
let scale_factor = sctk::get_surface_scale_factor(&touch_point.surface) as f64;
|
||||
let location = touch_point.position.to_physical(scale_factor);
|
||||
let window_id = wayland::make_wid(&touch_point.surface);
|
||||
|
||||
event_sink.push_window_event(
|
||||
WindowEvent::Touch(crate::event::Touch {
|
||||
device_id: crate::event::DeviceId(crate::platform_impl::DeviceId::Wayland(
|
||||
DeviceId,
|
||||
)),
|
||||
phase: TouchPhase::Moved,
|
||||
location,
|
||||
force: None, // TODO
|
||||
id: id as u64,
|
||||
}),
|
||||
window_id,
|
||||
);
|
||||
}
|
||||
TouchEvent::Frame => (),
|
||||
TouchEvent::Cancel => {
|
||||
for touch_point in inner.touch_points.drain(..) {
|
||||
let scale_factor = sctk::get_surface_scale_factor(&touch_point.surface) as f64;
|
||||
let location = touch_point.position.to_physical(scale_factor);
|
||||
let window_id = wayland::make_wid(&touch_point.surface);
|
||||
|
||||
event_sink.push_window_event(
|
||||
WindowEvent::Touch(crate::event::Touch {
|
||||
device_id: crate::event::DeviceId(crate::platform_impl::DeviceId::Wayland(
|
||||
DeviceId,
|
||||
)),
|
||||
phase: TouchPhase::Cancelled,
|
||||
location,
|
||||
force: None, // TODO
|
||||
id: touch_point.id as u64,
|
||||
}),
|
||||
window_id,
|
||||
);
|
||||
}
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
78
src/platform_impl/linux/wayland/seat/touch/mod.rs
Normal file
78
src/platform_impl/linux/wayland/seat/touch/mod.rs
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
//! 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,
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue