ltk/platform/wayland/
cursor.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// SPDX-License-Identifier: LGPL-2.1-only
// Copyright (C) 2026 Liberux Labs, S. L. <info@liberux.net>

use smithay_client_toolkit::reexports::protocols::wp::cursor_shape::v1::client::wp_cursor_shape_device_v1::Shape;

use crate::app::App;
use crate::types::CursorShape;

use super::WaylandPlatform;

pub( super ) fn set_shape<A: App>( platform: &WaylandPlatform<A>, shape: CursorShape ) -> bool
{
	let Some( device ) = platform.cursor_shape_device.as_ref() else { return false };
	device.set_shape( platform.last_pointer_enter_serial, wp_shape( shape ) );
	true
}

fn wp_shape( shape: CursorShape ) -> Shape
{
	use CursorShape as C;
	match shape
	{
		C::Default      => Shape::Default,
		C::ContextMenu  => Shape::ContextMenu,
		C::Help         => Shape::Help,
		C::Pointer      => Shape::Pointer,
		C::Progress     => Shape::Progress,
		C::Wait         => Shape::Wait,
		C::Cell         => Shape::Cell,
		C::Crosshair    => Shape::Crosshair,
		C::Text         => Shape::Text,
		C::VerticalText => Shape::VerticalText,
		C::Alias        => Shape::Alias,
		C::Copy         => Shape::Copy,
		C::Move         => Shape::Move,
		C::NoDrop       => Shape::NoDrop,
		C::NotAllowed   => Shape::NotAllowed,
		C::Grab         => Shape::Grab,
		C::Grabbing     => Shape::Grabbing,
		C::EResize      => Shape::EResize,
		C::NResize      => Shape::NResize,
		C::NeResize     => Shape::NeResize,
		C::NwResize     => Shape::NwResize,
		C::SResize      => Shape::SResize,
		C::SeResize     => Shape::SeResize,
		C::SwResize     => Shape::SwResize,
		C::WResize      => Shape::WResize,
		C::EwResize     => Shape::EwResize,
		C::NsResize     => Shape::NsResize,
		C::NeswResize   => Shape::NeswResize,
		C::NwseResize   => Shape::NwseResize,
		C::ColResize    => Shape::ColResize,
		C::RowResize    => Shape::RowResize,
		C::AllScroll    => Shape::AllScroll,
		C::ZoomIn       => Shape::ZoomIn,
		C::ZoomOut      => Shape::ZoomOut,
	}
}