diff options
| author | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2023-03-05 11:54:55 +0100 |
|---|---|---|
| committer | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2023-03-05 11:54:55 +0100 |
| commit | a52811567ebcd8c9ad96aded3c7581b9cfd78caa (patch) | |
| tree | b4d9b90c003bc43b76b56fe90d0cdb544678e8c9 | |
| parent | 5ae92f034ac8688bda0d905964eb281f764bf351 (diff) | |
Wayland: improve DnD of filenames to allow space-containing names
| -rw-r--r-- | documentation/src/events.dox | 2 | ||||
| -rw-r--r-- | documentation/src/wayland.dox | 5 | ||||
| -rw-r--r-- | src/drivers/Wayland/fl_wayland_clipboard_dnd.cxx | 8 |
3 files changed, 10 insertions, 5 deletions
diff --git a/documentation/src/events.dox b/documentation/src/events.dox index 7657ce933..26a3cda83 100644 --- a/documentation/src/events.dox +++ b/documentation/src/events.dox @@ -271,7 +271,7 @@ application on the desktop to an FLTK widget. Text is transferred using UTF-8 encoding. Files are received as a list of full path and file names, separated by newline. -On some X11 platforms, files are received as a URL-encoded UTF-8 string, +On some X11 platforms and with Wayland, files are received as a URL-encoded UTF-8 string, that is, non-ASCII bytes (and a few others such as space and %) are replaced by the 3 bytes "%XY" where XY are the byte's hexadecimal value. The \ref fl_decode_uri() function can be used to transform in-place diff --git a/documentation/src/wayland.dox b/documentation/src/wayland.dox index 9ab7583f6..3dfa4d733 100644 --- a/documentation/src/wayland.dox +++ b/documentation/src/wayland.dox @@ -761,9 +761,10 @@ operations: FLTK can copy or paste plain UTF-8 text or image data to/from the clipboard. Images are copied to the clipboard as \c image/bmp mime type. Images in \c image/bmp or \c image/png mime types from the -clipboard can be pasted to FLTK apps. Files dropped are received as a string with ' ' between -successive filenames. +clipboard can be pasted to FLTK apps. +Files dropped are received one per line with URL-encoded UTF-8 names prepended by +<tt>file://</tt> (see \ref events_dnd). \section wayland-egl EGL as support for OpenGL diff --git a/src/drivers/Wayland/fl_wayland_clipboard_dnd.cxx b/src/drivers/Wayland/fl_wayland_clipboard_dnd.cxx index 0c802dd0a..15a79663c 100644 --- a/src/drivers/Wayland/fl_wayland_clipboard_dnd.cxx +++ b/src/drivers/Wayland/fl_wayland_clipboard_dnd.cxx @@ -270,8 +270,12 @@ static void data_offer_handle_offer(void *data, struct wl_data_offer *offer, con } else if (strcmp(mime_type, "image/bmp") == 0 && (!fl_selection_offer_type || strcmp(fl_selection_offer_type, "image/png"))) { fl_selection_type[1] = Fl::clipboard_image; fl_selection_offer_type = "image/bmp"; + } else if (strcmp(mime_type, "text/uri-list") == 0 && !fl_selection_type[1]) { + fl_selection_type[1] = Fl::clipboard_plain_text; + fl_selection_offer_type = "text/uri-list"; } else if (strcmp(mime_type, wld_plain_text_clipboard) == 0 && !fl_selection_type[1]) { fl_selection_type[1] = Fl::clipboard_plain_text; + fl_selection_offer_type = wld_plain_text_clipboard; } } @@ -325,7 +329,7 @@ static void data_device_handle_selection(void *data, struct wl_data_device *data static void get_clipboard_or_dragged_text(struct wl_data_offer *offer) { int fds[2]; if (pipe(fds)) return; - wl_data_offer_receive(offer, wld_plain_text_clipboard, fds[1]); + wl_data_offer_receive(offer, fl_selection_offer_type, fds[1]); close(fds[1]); wl_display_flush(Fl_Wayland_Screen_Driver::wl_display); // read in fl_selection_buffer @@ -357,7 +361,7 @@ static void get_clipboard_or_dragged_text(struct wl_data_offer *offer) { //fprintf(stderr, "get_clipboard_or_dragged_text: size=%ld\n", rest); // read full clipboard data if (pipe(fds)) return; - wl_data_offer_receive(offer, wld_plain_text_clipboard, fds[1]); + wl_data_offer_receive(offer, fl_selection_offer_type, fds[1]); close(fds[1]); wl_display_flush(Fl_Wayland_Screen_Driver::wl_display); if (rest+1 > fl_selection_buffer_length[1]) { |
