diff options
| author | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2026-01-22 14:27:13 +0100 |
|---|---|---|
| committer | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2026-01-22 14:27:13 +0100 |
| commit | 05a3f82a5c385e7f00aa2bb8c1971e1cc99225a3 (patch) | |
| tree | 6d9a37921c572d108b9ff75f5728e9a1654b1306 /src/drivers | |
| parent | 14a5f705c8e3385a637be3377f0800b30c38e589 (diff) | |
Fix "Setting window custom cursor from SVG image crashes" (#1363)
Diffstat (limited to 'src/drivers')
| -rw-r--r-- | src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx index 1c42da2a1..0495fb7bc 100644 --- a/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx +++ b/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx @@ -1824,13 +1824,21 @@ int Fl_Wayland_Window_Driver::set_cursor(const Fl_RGB_Image *rgb, int hotx, int int Fl_Wayland_Window_Driver::set_cursor_4args(const Fl_RGB_Image *rgb, int hotx, int hoty, bool keep_copy) { if (keep_copy) { - int ld = rgb->ld() ? rgb->ld() : rgb->data_w() * rgb->d(); - uchar *data = new uchar[ld * rgb->data_h()]; - memcpy(data, rgb->array, ld * rgb->data_h()); - Fl_RGB_Image *rgb2 = new Fl_RGB_Image(data, rgb->data_w(), rgb->data_h(), rgb->d(), rgb->ld()); - rgb2->alloc_array = 1; - rgb2->scale(rgb->w(), rgb->h(), 0, 1); - rgb = rgb2; + if (rgb->as_svg_image()) { + int scale = wld_scale(); + Fl_RGB_Image *svg = (Fl_RGB_Image*)rgb->copy(rgb->w() * scale, rgb->h() * scale); + svg->normalize(); + svg->scale(rgb->w(), rgb->h(), 0, 1); + rgb = svg; + } else { + int ld = rgb->ld() ? rgb->ld() : rgb->data_w() * rgb->d(); + uchar *data = new uchar[ld * rgb->data_h()]; + memcpy(data, rgb->array, ld * rgb->data_h()); + Fl_RGB_Image *rgb2 = new Fl_RGB_Image(data, rgb->data_w(), rgb->data_h(), rgb->d(), rgb->ld()); + rgb2->alloc_array = 1; + rgb2->scale(rgb->w(), rgb->h(), 0, 1); + rgb = rgb2; + } } // build a new wl_cursor and its image struct wld_window *xid = (struct wld_window *)Fl_Window_Driver::xid(pWindow); |
