|
39 | 39 | #include "xdg-shell-client-protocol.h" |
40 | 40 | #include "xdg-decoration-client-protocol.h" |
41 | 41 | #include "viewporter-client-protocol.h" |
| 42 | +#include "cursor-shape-client-protocol.h" |
42 | 43 | #include <xkbcommon/xkbcommon.h> |
43 | 44 | #include <linux/input-event-codes.h> |
44 | 45 |
|
@@ -157,6 +158,13 @@ int32_t GPUDisplayFrontendWayland::FrontendMain() |
157 | 158 | } |
158 | 159 |
|
159 | 160 | auto pointer_enter = [](void* data, wl_pointer* wl_pointer, uint32_t serial, wl_surface* surface, wl_fixed_t surface_x, wl_fixed_t surface_y) { |
| 161 | + GPUDisplayFrontendWayland* me = (GPUDisplayFrontendWayland*)data; |
| 162 | + if (!me->mCursorShapeDevice && me->mCursorShapeManager) { |
| 163 | + me->mCursorShapeDevice = wp_cursor_shape_manager_v1_get_pointer(me->mCursorShapeManager, wl_pointer); |
| 164 | + } |
| 165 | + if (me->mCursorShapeDevice) { |
| 166 | + wp_cursor_shape_device_v1_set_shape(me->mCursorShapeDevice, serial, WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_DEFAULT); |
| 167 | + } |
160 | 168 | }; |
161 | 169 | auto pointer_leave = [](void* data, wl_pointer* wl_pointer, uint32_t serial, wl_surface* wl_surface) { |
162 | 170 | GPUDisplayFrontendWayland* me = (GPUDisplayFrontendWayland*)data; |
@@ -355,6 +363,8 @@ int32_t GPUDisplayFrontendWayland::FrontendMain() |
355 | 363 | wl_seat_add_listener(me->mSeat, &me->mSeatListener, me); |
356 | 364 | } else if (strcmp(interface, zxdg_decoration_manager_v1_interface.name) == 0) { |
357 | 365 | me->mDecManager = (zxdg_decoration_manager_v1*)wl_registry_bind(registry, name, &zxdg_decoration_manager_v1_interface, 1); |
| 366 | + } else if (strcmp(interface, wp_cursor_shape_manager_v1_interface.name) == 0) { |
| 367 | + me->mCursorShapeManager = (wp_cursor_shape_manager_v1*)wl_registry_bind(registry, name, &wp_cursor_shape_manager_v1_interface, 1); |
358 | 368 | } else if (strcmp(interface, wp_viewporter_interface.name) == 0) { |
359 | 369 | me->mViewporter = (wp_viewporter*)wl_registry_bind(registry, name, &wp_viewporter_interface, 1); |
360 | 370 | } else if (strcmp(interface, wp_fractional_scale_manager_v1_interface.name) == 0) { |
@@ -600,6 +610,14 @@ int32_t GPUDisplayFrontendWayland::FrontendMain() |
600 | 610 | mDisplayRunning = false; |
601 | 611 | pthread_mutex_unlock(&mSemLockExit); |
602 | 612 |
|
| 613 | + if (mCursorShapeDevice) { |
| 614 | + wp_cursor_shape_device_v1_destroy(mCursorShapeDevice); |
| 615 | + mCursorShapeDevice = nullptr; |
| 616 | + } |
| 617 | + if (mCursorShapeManager) { |
| 618 | + wp_cursor_shape_manager_v1_destroy(mCursorShapeManager); |
| 619 | + mCursorShapeManager = nullptr; |
| 620 | + } |
603 | 621 | if (mPointer) { |
604 | 622 | mSeatVersion >= WL_POINTER_RELEASE_SINCE_VERSION ? wl_pointer_release(mPointer) : wl_pointer_destroy(mPointer); |
605 | 623 | mPointer = nullptr; |
|
0 commit comments