Cursor shape
此全局对象提供了一种可选的光标图像设置替代方法。这种新方法使用枚举光标,而不是像 wl_pointer.set_cursor 那样使用 wl_surface。
警告!此文件中描述的协议目前处于测试阶段。向后兼容的更改可能会与相应的接口版本提升一起添加。向后不兼容的更改只能通过创建扩展的新主版本来完成。
get_pointer(cursor_shape_device: new_id<wp_cursor_shape_device_v1>, pointer: object<wl_pointer>)
参数 | 类型 | 描述 |
|---|---|---|
| cursor_shape_device | new_id<wp_cursor_shape_device_v1> | |
| pointer | object<wl_pointer> |
获取 wl_pointer 对象的 wp_cursor_shape_device_v1。
当指针功能从 wl_seat 中移除时,wp_cursor_shape_device_v1 对象将变得无效(inert)。
get_tablet_tool_v2(cursor_shape_device: new_id<wp_cursor_shape_device_v1>, tablet_tool: object<zwp_tablet_tool_v2>)
参数 | 类型 | 描述 |
|---|---|---|
| cursor_shape_device | new_id<wp_cursor_shape_device_v1> | |
| tablet_tool | object<zwp_tablet_tool_v2> |
获取 zwp_tablet_tool_v2 对象的 wp_cursor_shape_device_v1。
当 zwp_tablet_tool_v2 被移除时,wp_cursor_shape_device_v1 对象将变得无效(inert)。
此接口允许客户端设置光标形状。
set_shape(serial: uint, shape: uint<wp_cursor_shape_device_v1.shape>)
参数 | 类型 | 描述 |
|---|---|---|
| serial | uint | serial number of the enter event |
| shape | uint<wp_cursor_shape_device_v1.shape> |
将设备光标设置为指定的形状。合成器(compositor)将根据指定的形状更改光标图像。
仅当输入设备焦点位于请求客户端的 surface 之一时,光标才会真正发生变化。如果有的话,之前的光标图像(surface 或形状)将被替换。
"shape" 参数必须是有效的枚举条目,否则会引发 invalid_shape 协议错误。
这类似于 wl_pointer.set_cursor 和 zwp_tablet_tool_v2.set_cursor 请求,但是此请求接受的是一个形状,而不是表面(surface)形式的内容。客户端可以混合使用 set_cursor 和 set_shape 请求。
serial 参数必须与发送到客户端的最新 wl_pointer.enter 或 zwp_tablet_tool_v2.proximity_in 序列号匹配。否则,该请求将被忽略。
shape { default, context_menu, help, pointer, progress, wait, cell, crosshair, text, vertical_text, alias, copy, move, no_drop, not_allowed, grab, grabbing, e_resize, n_resize, ne_resize, nw_resize, s_resize, se_resize, sw_resize, w_resize, ew_resize, ns_resize, nesw_resize, nwse_resize, col_resize, row_resize, all_scroll, zoom_in, zoom_out, dnd_ask, all_resize }
参数 | 值 | 描述 |
|---|---|---|
| default | 1 | 默认光标 |
| context_menu | 2 | 光标下的对象有可用的上下文菜单 |
| help | 3 | 光标下的对象有可用的帮助 |
| pointer | 4 | 指示链接或其他交互元素的指针 |
| progress | 5 | 进度指示器 |
| wait | 6 | 程序正忙,用户应等待 |
| cell | 7 | 可以选择一个单元格或一组单元格 |
| crosshair | 8 | 简单的十字准星 |
| text | 9 | 文本可以被选择 |
| vertical_text | 10 | 垂直文本可以被选择 |
| alias | 11 | 拖放:将要创建某物的别名/快捷方式 |
| copy | 12 | 拖放:将要复制某物 |
| move | 13 | 拖放:将要移动某物 |
| no_drop | 14 | 拖放:拖动的项目不能在当前光标位置放下 |
| not_allowed | 15 | 拖放:请求的动作将不会被执行 |
| grab | 16 | 拖放:可以抓取某物 |
| grabbing | 17 | 拖放:某物正在被抓取 |
| e_resize | 18 | 调整大小:将要移动东边框 |
| n_resize | 19 | 调整大小:将要移动北边框 |
| ne_resize | 20 | 调整大小:将要移动东北角 |
| nw_resize | 21 | 调整大小:将要移动西北角 |
| s_resize | 22 | 调整大小:将要移动南边框 |
| se_resize | 23 | 调整大小:将要移动东南角 |
| sw_resize | 24 | 调整大小:将要移动西南角 |
| w_resize | 25 | 调整大小:将要移动西边框 |
| ew_resize | 26 | 调整大小:将要移动东西边框 |
| ns_resize | 27 | 调整大小:将要移动南北边框 |
| nesw_resize | 28 | 调整大小:将要移动东北和西南角 |
| nwse_resize | 29 | 调整大小:将要移动西北和东南角 |
| col_resize | 30 | 调整大小:项目/列可以水平调整大小 |
| row_resize | 31 | 调整大小:项目/行可以垂直调整大小 |
| all_scroll | 32 | 某物可以在任何方向滚动 |
| zoom_in | 33 | 可以放大某物 |
| zoom_out | 34 | 可以缩小某物 |
| dnd_ask起始版本 2 | 35 | 拖放:用户将选择要执行哪个动作(非 CSS 值) |
| all_resize起始版本 2 | 36 | 调整大小:某物可以在任何方向上移动或调整大小(非 CSS 值) |
此枚举描述了光标形状。
名称取自 CSS W3C 规范: https://w3c.github.io/csswg-drafts/css-ui/#cursor 并做了一些补充。
请注意,某些光标形状组是相关的: 第一组是拖放(drag-and-drop)光标,用于指示 dnd 操作期间选择的动作。第二组是调整大小的光标,用于指示窗口边框上的调整大小和移动可能性。建议这些组中的形状使用视觉上兼容的图像和隐喻。
合成器支持
Cage | COSMIC | GameScope | Hyprland | Jay | KWin | Labwc | Louvre | Mir | Muffin | Mutter | niri | phoc | river | Sway | Treeland | Wayfire | Weston | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| wp_cursor_shape_manager_v1 | x | 2 | x | 1 | 2 | 2 | 1 | x | x | x | 2 | 2 | 1 | 1 | 1 | 1 | x | x |
Copyright
Copyright 2018 The Chromium Authors Copyright 2023 Simon Ser
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.