diff options
| -rw-r--r-- | documentation/src/wayland.dox | 8 | ||||
| -rw-r--r-- | src/drivers/Wayland/Fl_Wayland_Window_Driver.H | 14 | ||||
| -rw-r--r-- | src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx | 58 |
3 files changed, 40 insertions, 40 deletions
diff --git a/documentation/src/wayland.dox b/documentation/src/wayland.dox index 4836f9c1f..56f47c208 100644 --- a/documentation/src/wayland.dox +++ b/documentation/src/wayland.dox @@ -996,16 +996,16 @@ struct wl_cursor { \endcode Function \c Fl_Wayland_Window_Driver::set_cursor_4args() also creates a <tt>struct wl_cursor</tt> object containing a single \c wl_cursor_image, which is in fact the \c cursor_image. -Finally, a <tt>struct custom_cursor_</tt> (see \ref wld_window) is allocated and used to memorize +Finally, a <tt>struct Fl_Wayland_Window_Driver::custom_cursor</tt> (see \ref wld_window) is allocated and used to memorize the <tt>struct wl_cursor</tt> and the cursor's image and hotspot. -A pointer to this <tt>struct custom_cursor_</tt> object is stored in member \c custom_cursor of the +A pointer to this <tt>struct Fl_Wayland_Window_Driver::custom_cursor</tt> object is stored in member \c custom_cursor of the window's \ref wld_window. Function \c Fl_Wayland_Window_Driver::set_cursor_4args() is also called when a window with a custom cursor is moved between distinct displays or when a display is rescaled to adapt the cursor size to the new display's scale factor. -Member function \c Fl_Wayland_Window_Driver::delete_cursor_() is used to delete any custom cursor +Static member function \c Fl_Wayland_Window_Driver::delete_cursor() is used to delete any custom cursor shape. This occurs when a window associated to a custom cursor is un-mapped and when such a window gets associated to a standard cursor or to a new custom cursor. @@ -1273,7 +1273,7 @@ struct wld_window { struct xdg_popup *xdg_popup; // for POPUP windows struct xdg_toplevel *xdg_toplevel; // for UNFRAMED windows }; - struct custom_cursor_ { + struct Fl_Wayland_Window_Driver::custom_cursor { struct wl_cursor *wl_cursor; const Fl_RGB_Image *rgb; int hotx, hoty; diff --git a/src/drivers/Wayland/Fl_Wayland_Window_Driver.H b/src/drivers/Wayland/Fl_Wayland_Window_Driver.H index e0eca821e..192d82f5a 100644 --- a/src/drivers/Wayland/Fl_Wayland_Window_Driver.H +++ b/src/drivers/Wayland/Fl_Wayland_Window_Driver.H @@ -59,7 +59,6 @@ private: cairo_rectangle_int_t *subRect_; // makes sure subwindow remains inside its parent window static bool in_flush_; // useful for progressive window drawing Fl_Cursor standard_cursor_; // window's standard custom kind - void delete_cursor_(bool delete_rgb = true); struct gl_start_support *gl_start_support_; // for support of gl_start/gl_finish bool is_popup_window_; public: @@ -74,6 +73,12 @@ public: struct Fl_Wayland_Screen_Driver::output *output; struct wl_list link; }; + struct custom_cursor { + struct wl_cursor *wl_cursor; + const Fl_RGB_Image *rgb; + int hotx, hoty; + }; + static void delete_cursor(struct custom_cursor *custom, bool delete_rgb = true); static type_for_resize_window_between_screens data_for_resize_window_between_screens_; void decorated_win_size(int &w, int &h); void shape_bitmap_(Fl_Image* b); @@ -155,11 +160,8 @@ struct wld_window { struct xdg_popup *xdg_popup; struct xdg_toplevel *xdg_toplevel; }; - struct custom_cursor_ { - struct wl_cursor *wl_cursor; - const Fl_RGB_Image *rgb; - int hotx, hoty; - } *custom_cursor; // non-null when using custom cursor + // non-null when using custom cursor + struct Fl_Wayland_Window_Driver::custom_cursor *custom_cursor; int configured_width; int configured_height; int floating_width; diff --git a/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx index 055802192..44ffe3037 100644 --- a/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx +++ b/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx @@ -72,31 +72,27 @@ Fl_Wayland_Window_Driver::Fl_Wayland_Window_Driver(Fl_Window *win) : Fl_Window_D } -void Fl_Wayland_Window_Driver::delete_cursor_(bool delete_rgb) { - struct wld_window *xid = (struct wld_window *)Fl_Window_Driver::xid(pWindow); - struct wld_window::custom_cursor_ *custom = xid->custom_cursor; - if (custom) { - struct wl_cursor *wl_cursor = custom->wl_cursor; - struct cursor_image *new_image = (struct cursor_image*)wl_cursor->images[0]; - struct Fl_Wayland_Graphics_Driver::wld_buffer *offscreen = - (struct Fl_Wayland_Graphics_Driver::wld_buffer *) - wl_buffer_get_user_data(new_image->buffer); - struct wld_window fake_xid; - memset(&fake_xid, 0, sizeof(fake_xid)); - fake_xid.buffer = offscreen; - Fl_Wayland_Graphics_Driver::buffer_release(&fake_xid); - free(new_image); - free(wl_cursor->images); - free(wl_cursor->name); - free(wl_cursor); - Fl_Wayland_Screen_Driver *scr_driver = (Fl_Wayland_Screen_Driver*)Fl::screen_driver(); - if (scr_driver->default_cursor() == wl_cursor) { - scr_driver->default_cursor(scr_driver->xc_arrow); - } - if (delete_rgb) delete custom->rgb; - delete custom; - xid->custom_cursor = NULL; +void Fl_Wayland_Window_Driver::delete_cursor( + struct Fl_Wayland_Window_Driver::custom_cursor *custom, bool delete_rgb) { + struct wl_cursor *wl_cursor = custom->wl_cursor; + struct cursor_image *new_image = (struct cursor_image*)wl_cursor->images[0]; + struct Fl_Wayland_Graphics_Driver::wld_buffer *offscreen = + (struct Fl_Wayland_Graphics_Driver::wld_buffer *) + wl_buffer_get_user_data(new_image->buffer); + struct wld_window fake_xid; + memset(&fake_xid, 0, sizeof(fake_xid)); + fake_xid.buffer = offscreen; + Fl_Wayland_Graphics_Driver::buffer_release(&fake_xid); + free(new_image); + free(wl_cursor->images); + free(wl_cursor->name); + free(wl_cursor); + Fl_Wayland_Screen_Driver *scr_driver = (Fl_Wayland_Screen_Driver*)Fl::screen_driver(); + if (scr_driver->default_cursor() == wl_cursor) { + scr_driver->default_cursor(scr_driver->xc_arrow); } + if (delete_rgb) delete custom->rgb; + delete custom; } @@ -453,15 +449,13 @@ void Fl_Wayland_Window_Driver::hide() { Fl_Screen_Driver::del_transient_window(NULL); } Fl_X* ip = Fl_X::flx(pWindow); - if (!ip) return; - struct wld_window *wld_win = (struct wld_window*)ip->xid; - if (wld_win->custom_cursor) delete_cursor_(); if (hide_common()) return; if (ip->region) { Fl_Graphics_Driver::default_driver().XDestroyRegion(ip->region); ip->region = 0; } screen_num_ = -1; + struct wld_window *wld_win = (struct wld_window*)ip->xid; if (wld_win) { // this test makes sure ip->xid has not been destroyed already Fl_Wayland_Graphics_Driver::buffer_release(wld_win); if (wld_win->kind == SUBWINDOW && wld_win->subsurface) { @@ -486,6 +480,7 @@ void Fl_Wayland_Window_Driver::hide() { wld_win->xdg_surface = NULL; } } + if (wld_win->custom_cursor) delete_cursor(wld_win->custom_cursor); if (wld_win->wl_surface) { Fl_Wayland_Screen_Driver *scr_driver = (Fl_Wayland_Screen_Driver*)Fl::screen_driver(); destroy_surface_caution_pointer_focus(wld_win->wl_surface, scr_driver->seat); @@ -1679,7 +1674,10 @@ int Fl_Wayland_Window_Driver::set_cursor(Fl_Cursor c) { default: return 0; } - if (xid->custom_cursor) delete_cursor_(); + if (xid->custom_cursor) { + delete_cursor(xid->custom_cursor); + xid->custom_cursor = NULL; + } standard_cursor_ = c; scr_driver->set_cursor(); return 1; @@ -1799,9 +1797,9 @@ int Fl_Wayland_Window_Driver::set_cursor_4args(const Fl_RGB_Image *rgb, int hotx memcpy(offscreen->data, offscreen->draw_buffer.buffer, offscreen->draw_buffer.data_size); // delete the previous custom cursor, if there was one, // and keep its Fl_RGB_Image if appropriate - delete_cursor_(keep_copy); + if (xid->custom_cursor) delete_cursor(xid->custom_cursor, keep_copy); //have this new cursor used - xid->custom_cursor = new wld_window::custom_cursor_; + xid->custom_cursor = new custom_cursor; xid->custom_cursor->wl_cursor = new_cursor; xid->custom_cursor->rgb = rgb; xid->custom_cursor->hotx = hotx; |
