From 618eb8f105e131052c2ed206bf4f271f2f9acf45 Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Thu, 17 Mar 2022 11:08:02 +0100 Subject: Improve handling of custom cursor by Wayland platform. --- src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx | 33 +++++++++++------------- 1 file changed, 15 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx index f4ba06d56..458435756 100644 --- a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx +++ b/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx @@ -242,29 +242,25 @@ static void pointer_enter(void *data, wl_fixed_t surface_x, wl_fixed_t surface_y) { - struct seat *seat = (struct seat*)data; Fl_Window *win = Fl_Wayland_Screen_Driver::surface_to_window(surface); - struct wl_cursor *cursor = NULL; - if (win) { // use custom cursor if present - Fl_Wayland_Window_Driver *driver = Fl_Wayland_Window_Driver::driver(win); + if (!win) return; + Fl_Wayland_Window_Driver *driver = Fl_Wayland_Window_Driver::driver(win); + struct wl_cursor *cursor = driver->cursor(); // use custom cursor if present + if (win->parent() && !cursor) { + driver = Fl_Wayland_Window_Driver::driver(win->top_window()); cursor = driver->cursor(); - if (win->parent() && !cursor) { - driver = Fl_Wayland_Window_Driver::driver(win->top_window()); - cursor = driver->cursor(); - } } + struct seat *seat = (struct seat*)data; do_set_cursor(seat, cursor); seat->serial = serial; - if (win) { - float f = Fl::screen_scale(win->screen_num()); - Fl::e_x = wl_fixed_to_int(surface_x) / f; - Fl::e_x_root = Fl::e_x + win->x(); - Fl::e_y = wl_fixed_to_int(surface_y) / f; - Fl::e_y_root = Fl::e_y + win->y(); - set_event_xy(win); - Fl::handle(FL_ENTER, win); -//fprintf(stderr, "pointer_enter window=%p\n", win); - } + float f = Fl::screen_scale(win->screen_num()); + Fl::e_x = wl_fixed_to_int(surface_x) / f; + Fl::e_x_root = Fl::e_x + win->x(); + Fl::e_y = wl_fixed_to_int(surface_y) / f; + Fl::e_y_root = Fl::e_y + win->y(); + set_event_xy(win); + Fl::handle(FL_ENTER, win); + //fprintf(stderr, "pointer_enter window=%p\n", win); seat->pointer_focus = surface; } @@ -1391,6 +1387,7 @@ struct wl_cursor *Fl_Wayland_Screen_Driver::default_cursor() { void Fl_Wayland_Screen_Driver::default_cursor(struct wl_cursor *cursor) { seat->default_cursor = cursor; + do_set_cursor(seat); } struct wl_cursor *Fl_Wayland_Screen_Driver::cache_cursor(const char *cursor_name) { -- cgit v1.2.3