From 70c5d7782f63fa87966c9fe1dc797e9f4e06f993 Mon Sep 17 00:00:00 2001 From: IoI_xD Date: Thu, 23 Apr 2026 13:32:05 -0700 Subject: [PATCH] wayland now changes the cursor properly --- src/backend/wayland.c | 30 +++++++++++++++++++----------- src/widget/entry.c | 1 - 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/backend/wayland.c b/src/backend/wayland.c index fcfc309..13162a0 100644 --- a/src/backend/wayland.c +++ b/src/backend/wayland.c @@ -476,15 +476,20 @@ static struct wl_surface* curSurface = NULL; static void pointer_enter(void* data, struct wl_pointer* wl_pointer, MwU32 serial, struct wl_surface* surface, wl_fixed_t surface_x, wl_fixed_t surface_y) { - MwLL self = data; + MwLL self = data; + MwLL topmost_parent = self; + (void)surface_x; (void)surface_y; WAYLAND_EVENT_OP_START(self); + while(topmost_parent->wayland.parent) topmost_parent = topmost_parent->wayland.parent; + curSurface = surface; self->wayland.pointer_serial = serial; - wl_pointer_set_cursor(self->wayland.pointer, self->wayland.pointer_serial, self->wayland.cursor.surface, 0, 0); + + wl_pointer_set_cursor(self->wayland.pointer, self->wayland.pointer_serial, topmost_parent->wayland.cursor.surface, 0, 0); WAYLAND_EVENT_OP_END(self); }; @@ -576,6 +581,8 @@ static void pointer_motion(void* data, struct wl_pointer* wl_pointer, MwU32 time MwLL self = data; MwLL topmost_parent = self; MwMouse p; + MwBool inArea = MwFALSE; + (void)time; (void)wl_pointer; @@ -591,6 +598,16 @@ static void pointer_motion(void* data, struct wl_pointer* wl_pointer, MwU32 time MwLLDispatch(currentlyHeldWidget, down, &p); } + if(self->wayland.framebuffer.surface) { + inArea |= self->wayland.framebuffer.surface == curSurface; + } + + if(self->wayland.backbuffer.surface) { + inArea |= self->wayland.backbuffer.surface == curSurface; + } + if(inArea) { + wl_pointer_set_cursor(self->wayland.pointer, self->wayland.pointer_serial, self->wayland.cursor.surface, 0, 0); + } WAYLAND_EVENT_OP_END(self); }; @@ -2497,10 +2514,6 @@ static void MwLLSetCursorImpl(MwLL handle, MwCursor* image, MwCursor* mask) { WIDGET_CHECK(handle); - if(handle->wayland.parent) { - return; - } - if(handle->wayland.cursor.setup) { buffer_destroy(&handle->wayland.cursor); wl_surface_destroy(handle->wayland.cursor.surface); @@ -2546,11 +2559,6 @@ static void MwLLSetCursorImpl(MwLL handle, MwCursor* image, MwCursor* mask) { wl_surface_attach(handle->wayland.cursor.surface, handle->wayland.cursor.shm_buffer, 0, 0); wl_surface_commit(handle->wayland.cursor.surface); update_buffer(handle, &handle->wayland.cursor); - - /* If there's currently a pointer, set it up. (Otherwise, it'll be setup during the pointer enter event) */ - if(handle->wayland.pointer != NULL) { - wl_pointer_set_cursor(handle->wayland.pointer, handle->wayland.pointer_serial, handle->wayland.cursor.surface, 0, 0); - } } static void MwLLDetachImpl(MwLL handle, MwPoint* point) { diff --git a/src/widget/entry.c b/src/widget/entry.c index 2d4f12f..eed193f 100644 --- a/src/widget/entry.c +++ b/src/widget/entry.c @@ -11,7 +11,6 @@ static int wcreate(MwWidget handle) { MwSetDefault(handle); MwLLSetCursor(handle->lowlevel, &MwCursorText, &MwCursorTextMask); - MwSetInteger(handle, MwNroundness, 5); return 0; }