Wayland: improve support for FL_CURSOR_{NONE, HELP}

This commit is contained in:
ManoloFLTK 2023-02-11 14:36:58 +01:00
parent d9b519f969
commit 740c56ce15
2 changed files with 23 additions and 2 deletions

View File

@ -2,7 +2,7 @@
// Definition of X11 Screen interface
// for the Fast Light Tool Kit (FLTK).
//
// Copyright 2010-2022 by Bill Spitzak and others.
// Copyright 2010-2023 by Bill Spitzak and others.
//
// This library is free software. Distribution and use rights are outlined in
// the file "COPYING" which should have been included with this file. If this
@ -91,6 +91,7 @@ public:
struct wl_cursor *xc_se;
struct wl_cursor *xc_ne;
struct wl_cursor *xc_nw;
struct wl_cursor *xc_none;
static const struct wl_data_device_listener *p_data_device_listener;
public:

View File

@ -22,6 +22,8 @@
#include <FL/filename.H>
#include <wayland-cursor.h>
#include "../../../libdecor/src/libdecor.h"
#include "../../fl_cursor_none.xpm"
#include "../../fl_cursor_help.xpm"
#include "xdg-shell-client-protocol.h"
#include <pango/pangocairo.h>
#include <FL/Fl_Overlay_Window.H>
@ -1337,7 +1339,14 @@ int Fl_Wayland_Window_Driver::set_cursor(Fl_Cursor c) {
break;
case FL_CURSOR_HELP:
if (!scr_driver->xc_help) scr_driver->xc_help = scr_driver->cache_cursor("help");
if (!scr_driver->xc_help) return 0;
if (!scr_driver->xc_help) {
const char **xpm = (const char**)fl_cursor_help_xpm;
Fl_Pixmap pxm(xpm);
Fl_RGB_Image image(&pxm);
this->set_cursor(&image, 1, 3);
scr_driver->xc_help = this->cursor_;
this->cursor_ = NULL;
}
scr_driver->default_cursor(scr_driver->xc_help);
break;
case FL_CURSOR_MOVE:
@ -1400,6 +1409,17 @@ int Fl_Wayland_Window_Driver::set_cursor(Fl_Cursor c) {
if (!scr_driver->xc_nw) return 0;
scr_driver->default_cursor(scr_driver->xc_nw);
break;
case FL_CURSOR_NONE:
if (!scr_driver->xc_none) {
const char **xpm = (const char**)fl_cursor_none_xpm;
Fl_Pixmap pxm(xpm);
Fl_RGB_Image image(&pxm);
this->set_cursor(&image, 0, 0);
scr_driver->xc_none = this->cursor_;
this->cursor_ = NULL;
}
scr_driver->default_cursor(scr_driver->xc_none);
break;
default:
return 0;