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
|
|
|
//! Handlers for the pointers we're using.
|
|
|
|
|
|
|
|
|
|
use std::cell::RefCell;
|
|
|
|
|
use std::rc::Rc;
|
|
|
|
|
|
|
|
|
|
use sctk::reexports::client::protocol::wl_pointer::{self, Event as PointerEvent};
|
2021-03-07 10:43:23 +01:00
|
|
|
use sctk::reexports::client::protocol::wl_seat::WlSeat;
|
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
|
|
|
use sctk::reexports::protocols::unstable::relative_pointer::v1::client::zwp_relative_pointer_v1::Event as RelativePointerEvent;
|
|
|
|
|
|
|
|
|
|
use sctk::seat::pointer::ThemedPointer;
|
|
|
|
|
|
|
|
|
|
use crate::dpi::LogicalPosition;
|
|
|
|
|
use crate::event::{
|
|
|
|
|
DeviceEvent, ElementState, MouseButton, MouseScrollDelta, TouchPhase, WindowEvent,
|
|
|
|
|
};
|
|
|
|
|
use crate::platform_impl::wayland::event_loop::WinitState;
|
|
|
|
|
use crate::platform_impl::wayland::{self, DeviceId};
|
|
|
|
|
|
|
|
|
|
use super::{PointerData, WinitPointer};
|
|
|
|
|
|
2020-12-09 23:11:25 +03:00
|
|
|
// These values are comming from <linux/input-event-codes.h>.
|
|
|
|
|
const BTN_LEFT: u32 = 0x110;
|
|
|
|
|
const BTN_RIGHT: u32 = 0x111;
|
|
|
|
|
const BTN_MIDDLE: u32 = 0x112;
|
|
|
|
|
|
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
|
|
|
#[inline]
|
|
|
|
|
pub(super) fn handle_pointer(
|
|
|
|
|
pointer: ThemedPointer,
|
|
|
|
|
event: PointerEvent,
|
|
|
|
|
pointer_data: &Rc<RefCell<PointerData>>,
|
|
|
|
|
winit_state: &mut WinitState,
|
2021-03-07 10:43:23 +01:00
|
|
|
seat: WlSeat,
|
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
|
|
|
) {
|
|
|
|
|
let event_sink = &mut winit_state.event_sink;
|
|
|
|
|
let mut pointer_data = pointer_data.borrow_mut();
|
|
|
|
|
match event {
|
|
|
|
|
PointerEvent::Enter {
|
|
|
|
|
surface,
|
|
|
|
|
surface_x,
|
|
|
|
|
surface_y,
|
|
|
|
|
serial,
|
|
|
|
|
..
|
|
|
|
|
} => {
|
|
|
|
|
pointer_data.latest_serial.replace(serial);
|
|
|
|
|
|
|
|
|
|
let window_id = wayland::make_wid(&surface);
|
|
|
|
|
if !winit_state.window_map.contains_key(&window_id) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
let window_handle = match winit_state.window_map.get_mut(&window_id) {
|
|
|
|
|
Some(window_handle) => window_handle,
|
|
|
|
|
None => return,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
let scale_factor = sctk::get_surface_scale_factor(&surface) as f64;
|
|
|
|
|
pointer_data.surface = Some(surface);
|
|
|
|
|
|
|
|
|
|
// Notify window that pointer entered the surface.
|
|
|
|
|
let winit_pointer = WinitPointer {
|
|
|
|
|
pointer,
|
|
|
|
|
confined_pointer: Rc::downgrade(&pointer_data.confined_pointer),
|
|
|
|
|
pointer_constraints: pointer_data.pointer_constraints.clone(),
|
|
|
|
|
latest_serial: pointer_data.latest_serial.clone(),
|
2021-03-07 10:43:23 +01:00
|
|
|
seat,
|
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
|
|
|
};
|
|
|
|
|
window_handle.pointer_entered(winit_pointer);
|
|
|
|
|
|
|
|
|
|
event_sink.push_window_event(
|
|
|
|
|
WindowEvent::CursorEntered {
|
|
|
|
|
device_id: crate::event::DeviceId(crate::platform_impl::DeviceId::Wayland(
|
|
|
|
|
DeviceId,
|
|
|
|
|
)),
|
|
|
|
|
},
|
|
|
|
|
window_id,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
let position = LogicalPosition::new(surface_x, surface_y).to_physical(scale_factor);
|
|
|
|
|
|
|
|
|
|
event_sink.push_window_event(
|
|
|
|
|
WindowEvent::CursorMoved {
|
|
|
|
|
device_id: crate::event::DeviceId(crate::platform_impl::DeviceId::Wayland(
|
|
|
|
|
DeviceId,
|
|
|
|
|
)),
|
|
|
|
|
position,
|
|
|
|
|
modifiers: *pointer_data.modifiers_state.borrow(),
|
|
|
|
|
},
|
|
|
|
|
window_id,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
PointerEvent::Leave { surface, serial } => {
|
|
|
|
|
pointer_data.surface = None;
|
|
|
|
|
pointer_data.latest_serial.replace(serial);
|
|
|
|
|
|
|
|
|
|
let window_id = wayland::make_wid(&surface);
|
|
|
|
|
|
|
|
|
|
let window_handle = match winit_state.window_map.get_mut(&window_id) {
|
|
|
|
|
Some(window_handle) => window_handle,
|
|
|
|
|
None => return,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Notify a window that pointer is no longer observing it.
|
|
|
|
|
let winit_pointer = WinitPointer {
|
|
|
|
|
pointer,
|
|
|
|
|
confined_pointer: Rc::downgrade(&pointer_data.confined_pointer),
|
|
|
|
|
pointer_constraints: pointer_data.pointer_constraints.clone(),
|
|
|
|
|
latest_serial: pointer_data.latest_serial.clone(),
|
2021-03-07 10:43:23 +01:00
|
|
|
seat,
|
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
|
|
|
};
|
|
|
|
|
window_handle.pointer_left(winit_pointer);
|
|
|
|
|
|
|
|
|
|
event_sink.push_window_event(
|
|
|
|
|
WindowEvent::CursorLeft {
|
|
|
|
|
device_id: crate::event::DeviceId(crate::platform_impl::DeviceId::Wayland(
|
|
|
|
|
DeviceId,
|
|
|
|
|
)),
|
|
|
|
|
},
|
|
|
|
|
window_id,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
PointerEvent::Motion {
|
|
|
|
|
surface_x,
|
|
|
|
|
surface_y,
|
|
|
|
|
..
|
|
|
|
|
} => {
|
|
|
|
|
let surface = match pointer_data.surface.as_ref() {
|
|
|
|
|
Some(surface) => surface,
|
|
|
|
|
None => return,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
let window_id = wayland::make_wid(surface);
|
|
|
|
|
|
2021-08-15 22:31:59 +03:00
|
|
|
let scale_factor = sctk::get_surface_scale_factor(surface) as f64;
|
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
|
|
|
let position = LogicalPosition::new(surface_x, surface_y).to_physical(scale_factor);
|
|
|
|
|
|
|
|
|
|
event_sink.push_window_event(
|
|
|
|
|
WindowEvent::CursorMoved {
|
|
|
|
|
device_id: crate::event::DeviceId(crate::platform_impl::DeviceId::Wayland(
|
|
|
|
|
DeviceId,
|
|
|
|
|
)),
|
|
|
|
|
position,
|
|
|
|
|
modifiers: *pointer_data.modifiers_state.borrow(),
|
|
|
|
|
},
|
|
|
|
|
window_id,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
PointerEvent::Button {
|
|
|
|
|
button,
|
|
|
|
|
state,
|
|
|
|
|
serial,
|
|
|
|
|
..
|
|
|
|
|
} => {
|
|
|
|
|
pointer_data.latest_serial.replace(serial);
|
|
|
|
|
let window_id = match pointer_data.surface.as_ref().map(wayland::make_wid) {
|
|
|
|
|
Some(window_id) => window_id,
|
|
|
|
|
None => return,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
let state = match state {
|
|
|
|
|
wl_pointer::ButtonState::Pressed => ElementState::Pressed,
|
|
|
|
|
wl_pointer::ButtonState::Released => ElementState::Released,
|
|
|
|
|
_ => unreachable!(),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
let button = match button {
|
2020-12-09 23:11:25 +03:00
|
|
|
BTN_LEFT => MouseButton::Left,
|
|
|
|
|
BTN_RIGHT => MouseButton::Right,
|
|
|
|
|
BTN_MIDDLE => MouseButton::Middle,
|
|
|
|
|
button => MouseButton::Other(button as u16),
|
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
|
|
|
};
|
|
|
|
|
|
|
|
|
|
event_sink.push_window_event(
|
|
|
|
|
WindowEvent::MouseInput {
|
|
|
|
|
device_id: crate::event::DeviceId(crate::platform_impl::DeviceId::Wayland(
|
|
|
|
|
DeviceId,
|
|
|
|
|
)),
|
|
|
|
|
state,
|
|
|
|
|
button,
|
|
|
|
|
modifiers: *pointer_data.modifiers_state.borrow(),
|
|
|
|
|
},
|
|
|
|
|
window_id,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
PointerEvent::Axis { axis, value, .. } => {
|
|
|
|
|
let surface = match pointer_data.surface.as_ref() {
|
|
|
|
|
Some(surface) => surface,
|
|
|
|
|
None => return,
|
|
|
|
|
};
|
|
|
|
|
|
2021-08-15 22:31:59 +03:00
|
|
|
let window_id = wayland::make_wid(surface);
|
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
|
|
|
|
|
|
|
|
if pointer.as_ref().version() < 5 {
|
|
|
|
|
let (mut x, mut y) = (0.0, 0.0);
|
|
|
|
|
|
|
|
|
|
// Old seat compatibility.
|
|
|
|
|
match axis {
|
|
|
|
|
// Wayland vertical sign convention is the inverse of winit.
|
|
|
|
|
wl_pointer::Axis::VerticalScroll => y -= value as f32,
|
|
|
|
|
wl_pointer::Axis::HorizontalScroll => x += value as f32,
|
|
|
|
|
_ => unreachable!(),
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-15 22:31:59 +03:00
|
|
|
let scale_factor = sctk::get_surface_scale_factor(surface) as f64;
|
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
|
|
|
let delta = LogicalPosition::new(x as f64, y as f64).to_physical(scale_factor);
|
|
|
|
|
|
|
|
|
|
event_sink.push_window_event(
|
|
|
|
|
WindowEvent::MouseWheel {
|
|
|
|
|
device_id: crate::event::DeviceId(crate::platform_impl::DeviceId::Wayland(
|
|
|
|
|
DeviceId,
|
|
|
|
|
)),
|
|
|
|
|
delta: MouseScrollDelta::PixelDelta(delta),
|
|
|
|
|
phase: TouchPhase::Moved,
|
|
|
|
|
modifiers: *pointer_data.modifiers_state.borrow(),
|
|
|
|
|
},
|
|
|
|
|
window_id,
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
let (mut x, mut y) = pointer_data.axis_data.axis_buffer.unwrap_or((0.0, 0.0));
|
|
|
|
|
match axis {
|
|
|
|
|
// Wayland vertical sign convention is the inverse of winit.
|
|
|
|
|
wl_pointer::Axis::VerticalScroll => y -= value as f32,
|
|
|
|
|
wl_pointer::Axis::HorizontalScroll => x += value as f32,
|
|
|
|
|
_ => unreachable!(),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pointer_data.axis_data.axis_buffer = Some((x, y));
|
|
|
|
|
|
|
|
|
|
pointer_data.axis_data.axis_state = match pointer_data.axis_data.axis_state {
|
|
|
|
|
TouchPhase::Started | TouchPhase::Moved => TouchPhase::Moved,
|
|
|
|
|
_ => TouchPhase::Started,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
PointerEvent::AxisDiscrete { axis, discrete } => {
|
|
|
|
|
let (mut x, mut y) = pointer_data
|
|
|
|
|
.axis_data
|
|
|
|
|
.axis_discrete_buffer
|
|
|
|
|
.unwrap_or((0., 0.));
|
|
|
|
|
|
|
|
|
|
match axis {
|
|
|
|
|
// Wayland vertical sign convention is the inverse of winit.
|
|
|
|
|
wl_pointer::Axis::VerticalScroll => y -= discrete as f32,
|
|
|
|
|
wl_pointer::Axis::HorizontalScroll => x += discrete as f32,
|
|
|
|
|
_ => unreachable!(),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pointer_data.axis_data.axis_discrete_buffer = Some((x, y));
|
|
|
|
|
|
|
|
|
|
pointer_data.axis_data.axis_state = match pointer_data.axis_data.axis_state {
|
|
|
|
|
TouchPhase::Started | TouchPhase::Moved => TouchPhase::Moved,
|
|
|
|
|
_ => TouchPhase::Started,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
PointerEvent::AxisSource { .. } => (),
|
|
|
|
|
PointerEvent::AxisStop { .. } => {
|
|
|
|
|
pointer_data.axis_data.axis_state = TouchPhase::Ended;
|
|
|
|
|
}
|
|
|
|
|
PointerEvent::Frame => {
|
|
|
|
|
let axis_buffer = pointer_data.axis_data.axis_buffer.take();
|
|
|
|
|
let axis_discrete_buffer = pointer_data.axis_data.axis_discrete_buffer.take();
|
|
|
|
|
|
|
|
|
|
let surface = match pointer_data.surface.as_ref() {
|
|
|
|
|
Some(surface) => surface,
|
|
|
|
|
None => return,
|
|
|
|
|
};
|
2021-08-15 22:31:59 +03:00
|
|
|
let window_id = wayland::make_wid(surface);
|
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
|
|
|
|
|
|
|
|
let window_event = if let Some((x, y)) = axis_discrete_buffer {
|
|
|
|
|
WindowEvent::MouseWheel {
|
|
|
|
|
device_id: crate::event::DeviceId(crate::platform_impl::DeviceId::Wayland(
|
|
|
|
|
DeviceId,
|
|
|
|
|
)),
|
|
|
|
|
delta: MouseScrollDelta::LineDelta(x, y),
|
|
|
|
|
phase: pointer_data.axis_data.axis_state,
|
|
|
|
|
modifiers: *pointer_data.modifiers_state.borrow(),
|
|
|
|
|
}
|
|
|
|
|
} else if let Some((x, y)) = axis_buffer {
|
2021-08-15 22:31:59 +03:00
|
|
|
let scale_factor = sctk::get_surface_scale_factor(surface) as f64;
|
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
|
|
|
let delta = LogicalPosition::new(x, y).to_physical(scale_factor);
|
|
|
|
|
|
|
|
|
|
WindowEvent::MouseWheel {
|
|
|
|
|
device_id: crate::event::DeviceId(crate::platform_impl::DeviceId::Wayland(
|
|
|
|
|
DeviceId,
|
|
|
|
|
)),
|
|
|
|
|
delta: MouseScrollDelta::PixelDelta(delta),
|
|
|
|
|
phase: pointer_data.axis_data.axis_state,
|
|
|
|
|
modifiers: *pointer_data.modifiers_state.borrow(),
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
return;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
event_sink.push_window_event(window_event, window_id);
|
|
|
|
|
}
|
|
|
|
|
_ => (),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[inline]
|
|
|
|
|
pub(super) fn handle_relative_pointer(event: RelativePointerEvent, winit_state: &mut WinitState) {
|
2022-02-03 12:46:29 +02:00
|
|
|
match event {
|
|
|
|
|
RelativePointerEvent::RelativeMotion {
|
|
|
|
|
dx_unaccel,
|
|
|
|
|
dy_unaccel,
|
|
|
|
|
..
|
|
|
|
|
} => winit_state.event_sink.push_device_event(
|
|
|
|
|
DeviceEvent::MouseMotion {
|
|
|
|
|
delta: (dx_unaccel, dy_unaccel),
|
|
|
|
|
},
|
|
|
|
|
DeviceId,
|
|
|
|
|
),
|
|
|
|
|
_ => (),
|
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
|
|
|
}
|
|
|
|
|
}
|