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
|
|
|
//! All pointer related handling.
|
|
|
|
|
|
|
|
|
|
use std::cell::{Cell, RefCell};
|
|
|
|
|
use std::rc::{Rc, Weak};
|
|
|
|
|
|
|
|
|
|
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::Attached;
|
|
|
|
|
use sctk::reexports::protocols::unstable::relative_pointer::v1::client::zwp_relative_pointer_manager_v1::ZwpRelativePointerManagerV1;
|
|
|
|
|
use sctk::reexports::protocols::unstable::relative_pointer::v1::client::zwp_relative_pointer_v1::ZwpRelativePointerV1;
|
|
|
|
|
use sctk::reexports::protocols::unstable::pointer_constraints::v1::client::zwp_pointer_constraints_v1::{ZwpPointerConstraintsV1, Lifetime};
|
|
|
|
|
use sctk::reexports::protocols::unstable::pointer_constraints::v1::client::zwp_confined_pointer_v1::ZwpConfinedPointerV1;
|
|
|
|
|
|
|
|
|
|
use sctk::seat::pointer::{ThemeManager, ThemedPointer};
|
2021-08-15 22:31:59 +03:00
|
|
|
use sctk::window::{FallbackFrame, Window};
|
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 crate::event::ModifiersState;
|
|
|
|
|
use crate::platform_impl::wayland::event_loop::WinitState;
|
|
|
|
|
use crate::window::CursorIcon;
|
|
|
|
|
|
|
|
|
|
mod data;
|
|
|
|
|
mod handlers;
|
|
|
|
|
|
|
|
|
|
use data::PointerData;
|
|
|
|
|
|
|
|
|
|
/// A proxy to Wayland pointer, which serves requests from a `WindowHandle`.
|
|
|
|
|
pub struct WinitPointer {
|
|
|
|
|
pointer: ThemedPointer,
|
|
|
|
|
|
|
|
|
|
/// Create confined pointers.
|
|
|
|
|
pointer_constraints: Option<Attached<ZwpPointerConstraintsV1>>,
|
|
|
|
|
|
|
|
|
|
/// Cursor to handle confine requests.
|
|
|
|
|
confined_pointer: Weak<RefCell<Option<ZwpConfinedPointerV1>>>,
|
|
|
|
|
|
|
|
|
|
/// Latest observed serial in pointer events.
|
2022-05-01 15:21:34 +02:00
|
|
|
/// used by Window::start_interactive_move()
|
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
|
|
|
latest_serial: Rc<Cell<u32>>,
|
2022-05-01 15:21:34 +02:00
|
|
|
/// Latest observed serial in pointer enter events.
|
|
|
|
|
/// used by Window::set_cursor()
|
|
|
|
|
latest_enter_serial: Rc<Cell<u32>>,
|
2021-03-07 10:43:23 +01:00
|
|
|
|
|
|
|
|
/// Seat.
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl PartialEq for WinitPointer {
|
|
|
|
|
fn eq(&self, other: &Self) -> bool {
|
|
|
|
|
*self.pointer == *other.pointer
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Eq for WinitPointer {}
|
|
|
|
|
|
|
|
|
|
impl WinitPointer {
|
|
|
|
|
/// Set the cursor icon.
|
|
|
|
|
///
|
|
|
|
|
/// Providing `None` will hide the cursor.
|
|
|
|
|
pub fn set_cursor(&self, cursor_icon: Option<CursorIcon>) {
|
|
|
|
|
let cursor_icon = match cursor_icon {
|
|
|
|
|
Some(cursor_icon) => cursor_icon,
|
|
|
|
|
None => {
|
|
|
|
|
// Hide the cursor.
|
2022-05-01 15:21:34 +02:00
|
|
|
// WlPointer::set_cursor() expects the serial of the last *enter*
|
|
|
|
|
// event (compare to to start_interactive_move()).
|
|
|
|
|
(*self.pointer).set_cursor(self.latest_enter_serial.get(), None, 0, 0);
|
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
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
let cursors: &[&str] = match cursor_icon {
|
|
|
|
|
CursorIcon::Alias => &["link"],
|
|
|
|
|
CursorIcon::Arrow => &["arrow"],
|
|
|
|
|
CursorIcon::Cell => &["plus"],
|
|
|
|
|
CursorIcon::Copy => &["copy"],
|
|
|
|
|
CursorIcon::Crosshair => &["crosshair"],
|
|
|
|
|
CursorIcon::Default => &["left_ptr"],
|
2021-08-01 08:16:02 +00:00
|
|
|
CursorIcon::Hand => &["hand2", "hand1"],
|
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
|
|
|
CursorIcon::Help => &["question_arrow"],
|
|
|
|
|
CursorIcon::Move => &["move"],
|
|
|
|
|
CursorIcon::Grab => &["openhand", "grab"],
|
|
|
|
|
CursorIcon::Grabbing => &["closedhand", "grabbing"],
|
|
|
|
|
CursorIcon::Progress => &["progress"],
|
|
|
|
|
CursorIcon::AllScroll => &["all-scroll"],
|
|
|
|
|
CursorIcon::ContextMenu => &["context-menu"],
|
|
|
|
|
|
|
|
|
|
CursorIcon::NoDrop => &["no-drop", "circle"],
|
|
|
|
|
CursorIcon::NotAllowed => &["crossed_circle"],
|
|
|
|
|
|
|
|
|
|
// Resize cursors
|
|
|
|
|
CursorIcon::EResize => &["right_side"],
|
|
|
|
|
CursorIcon::NResize => &["top_side"],
|
|
|
|
|
CursorIcon::NeResize => &["top_right_corner"],
|
|
|
|
|
CursorIcon::NwResize => &["top_left_corner"],
|
|
|
|
|
CursorIcon::SResize => &["bottom_side"],
|
|
|
|
|
CursorIcon::SeResize => &["bottom_right_corner"],
|
|
|
|
|
CursorIcon::SwResize => &["bottom_left_corner"],
|
|
|
|
|
CursorIcon::WResize => &["left_side"],
|
|
|
|
|
CursorIcon::EwResize => &["h_double_arrow"],
|
|
|
|
|
CursorIcon::NsResize => &["v_double_arrow"],
|
2021-08-01 10:19:00 +02:00
|
|
|
CursorIcon::NwseResize => &["bd_double_arrow", "size_fdiag"],
|
|
|
|
|
CursorIcon::NeswResize => &["fd_double_arrow", "size_bdiag"],
|
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
|
|
|
CursorIcon::ColResize => &["split_h", "h_double_arrow"],
|
|
|
|
|
CursorIcon::RowResize => &["split_v", "v_double_arrow"],
|
|
|
|
|
CursorIcon::Text => &["text", "xterm"],
|
|
|
|
|
CursorIcon::VerticalText => &["vertical-text"],
|
|
|
|
|
|
|
|
|
|
CursorIcon::Wait => &["watch"],
|
|
|
|
|
|
|
|
|
|
CursorIcon::ZoomIn => &["zoom-in"],
|
|
|
|
|
CursorIcon::ZoomOut => &["zoom-out"],
|
|
|
|
|
};
|
|
|
|
|
|
2022-05-01 15:21:34 +02:00
|
|
|
let serial = Some(self.latest_enter_serial.get());
|
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
|
|
|
for cursor in cursors {
|
|
|
|
|
if self.pointer.set_cursor(cursor, serial).is_ok() {
|
2021-08-15 15:05:14 -04:00
|
|
|
return;
|
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
|
|
|
}
|
|
|
|
|
}
|
2021-08-15 15:05:14 -04:00
|
|
|
warn!("Failed to set cursor to {:?}", cursor_icon);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Confine the pointer to a surface.
|
|
|
|
|
pub fn confine(&self, surface: &WlSurface) {
|
|
|
|
|
let pointer_constraints = match &self.pointer_constraints {
|
|
|
|
|
Some(pointer_constraints) => pointer_constraints,
|
|
|
|
|
None => return,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
let confined_pointer = match self.confined_pointer.upgrade() {
|
|
|
|
|
Some(confined_pointer) => confined_pointer,
|
|
|
|
|
// A pointer is gone.
|
|
|
|
|
None => return,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
*confined_pointer.borrow_mut() = Some(init_confined_pointer(
|
2021-08-15 22:31:59 +03:00
|
|
|
pointer_constraints,
|
|
|
|
|
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
|
|
|
&*self.pointer,
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Tries to unconfine the pointer if the current pointer is confined.
|
|
|
|
|
pub fn unconfine(&self) {
|
|
|
|
|
let confined_pointer = match self.confined_pointer.upgrade() {
|
|
|
|
|
Some(confined_pointer) => confined_pointer,
|
|
|
|
|
// A pointer is gone.
|
|
|
|
|
None => return,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
let mut confined_pointer = confined_pointer.borrow_mut();
|
|
|
|
|
|
|
|
|
|
if let Some(confined_pointer) = confined_pointer.take() {
|
|
|
|
|
confined_pointer.destroy();
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-03-07 10:43:23 +01:00
|
|
|
|
2021-08-15 22:31:59 +03:00
|
|
|
pub fn drag_window(&self, window: &Window<FallbackFrame>) {
|
2022-05-01 15:21:34 +02:00
|
|
|
// WlPointer::setart_interactive_move() expects the last serial of *any*
|
|
|
|
|
// pointer event (compare to set_cursor()).
|
2021-03-07 10:43:23 +01:00
|
|
|
window.start_interactive_move(&self.seat, self.latest_serial.get());
|
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// A pointer wrapper for easy releasing and managing pointers.
|
|
|
|
|
pub(super) struct Pointers {
|
|
|
|
|
/// A pointer itself.
|
|
|
|
|
pointer: ThemedPointer,
|
|
|
|
|
|
|
|
|
|
/// A relative pointer handler.
|
|
|
|
|
relative_pointer: Option<ZwpRelativePointerV1>,
|
|
|
|
|
|
|
|
|
|
/// Confined pointer.
|
|
|
|
|
confined_pointer: Rc<RefCell<Option<ZwpConfinedPointerV1>>>,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Pointers {
|
|
|
|
|
pub(super) fn new(
|
|
|
|
|
seat: &Attached<WlSeat>,
|
|
|
|
|
theme_manager: &ThemeManager,
|
|
|
|
|
relative_pointer_manager: &Option<Attached<ZwpRelativePointerManagerV1>>,
|
|
|
|
|
pointer_constraints: &Option<Attached<ZwpPointerConstraintsV1>>,
|
|
|
|
|
modifiers_state: Rc<RefCell<ModifiersState>>,
|
|
|
|
|
) -> Self {
|
|
|
|
|
let confined_pointer = Rc::new(RefCell::new(None));
|
|
|
|
|
let pointer_data = Rc::new(RefCell::new(PointerData::new(
|
|
|
|
|
confined_pointer.clone(),
|
|
|
|
|
pointer_constraints.clone(),
|
|
|
|
|
modifiers_state,
|
|
|
|
|
)));
|
2021-03-07 10:43:23 +01:00
|
|
|
let pointer_seat = seat.detach();
|
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 pointer = theme_manager.theme_pointer_with_impl(
|
|
|
|
|
seat,
|
|
|
|
|
move |event, pointer, mut dispatch_data| {
|
|
|
|
|
let winit_state = dispatch_data.get::<WinitState>().unwrap();
|
2021-03-07 10:43:23 +01:00
|
|
|
handlers::handle_pointer(
|
|
|
|
|
pointer,
|
|
|
|
|
event,
|
|
|
|
|
&pointer_data,
|
|
|
|
|
winit_state,
|
|
|
|
|
pointer_seat.clone(),
|
|
|
|
|
);
|
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
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Setup relative_pointer if it's available.
|
2021-08-15 22:31:59 +03:00
|
|
|
let relative_pointer = relative_pointer_manager
|
|
|
|
|
.as_ref()
|
|
|
|
|
.map(|relative_pointer_manager| {
|
|
|
|
|
init_relative_pointer(relative_pointer_manager, &*pointer)
|
|
|
|
|
});
|
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
|
|
|
|
|
|
|
|
Self {
|
|
|
|
|
pointer,
|
|
|
|
|
relative_pointer,
|
|
|
|
|
confined_pointer,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Drop for Pointers {
|
|
|
|
|
fn drop(&mut self) {
|
|
|
|
|
// Drop relative pointer.
|
|
|
|
|
if let Some(relative_pointer) = self.relative_pointer.take() {
|
|
|
|
|
relative_pointer.destroy();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Drop confined pointer.
|
|
|
|
|
if let Some(confined_pointer) = self.confined_pointer.borrow_mut().take() {
|
|
|
|
|
confined_pointer.destroy();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Drop the pointer itself in case it's possible.
|
|
|
|
|
if self.pointer.as_ref().version() >= 3 {
|
|
|
|
|
self.pointer.release();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub(super) fn init_relative_pointer(
|
|
|
|
|
relative_pointer_manager: &ZwpRelativePointerManagerV1,
|
|
|
|
|
pointer: &WlPointer,
|
|
|
|
|
) -> ZwpRelativePointerV1 {
|
|
|
|
|
let relative_pointer = relative_pointer_manager.get_relative_pointer(&*pointer);
|
|
|
|
|
relative_pointer.quick_assign(move |_, event, mut dispatch_data| {
|
|
|
|
|
let winit_state = dispatch_data.get::<WinitState>().unwrap();
|
|
|
|
|
handlers::handle_relative_pointer(event, winit_state);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
relative_pointer.detach()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub(super) fn init_confined_pointer(
|
|
|
|
|
pointer_constraints: &Attached<ZwpPointerConstraintsV1>,
|
|
|
|
|
surface: &WlSurface,
|
|
|
|
|
pointer: &WlPointer,
|
|
|
|
|
) -> ZwpConfinedPointerV1 {
|
|
|
|
|
let confined_pointer =
|
2021-08-15 22:31:59 +03:00
|
|
|
pointer_constraints.confine_pointer(surface, pointer, None, Lifetime::Persistent);
|
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
|
|
|
|
|
|
|
|
confined_pointer.quick_assign(move |_, _, _| {});
|
|
|
|
|
|
|
|
|
|
confined_pointer.detach()
|
|
|
|
|
}
|