commit e7927fc52f89ffd5c8207ee5c61b59e6d47e09f4
Author: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
AuthorDate: Mon Oct 5 14:34:41 2026 +0200
Commit: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
CommitDate: Mon Oct 5 14:34:41 2026 +0200
Wayland: Implement 'Primary selection' protocol - cont'd (#1621)
FL/Fl.H | 4 ++--
src/drivers/Wayland/fl_wayland_clipboard_dnd.cxx | 13 ++++++-------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git FL/Fl.H FL/Fl.H
index 558a5ac..d080646 100644
--- FL/Fl.H
+++ FL/Fl.H
@@ -396,10 +396,10 @@ FL_EXPORT extern void grab(Fl_Window*); // platform dependent
- 1: clipboard
- 2: both
- The selection buffer exists only on the X11 platform and is used for middle-mouse
+ The selection buffer exists only on the Linux/Unix platform (X11 or Wayland) and is used for middle-mouse
pastes and for drag-and-drop selections. The clipboard is used for traditional
copy/cut/paste operations. On all other platforms the selection buffer
- (\p destination = 0) is mapped to the clipboard, i.e. on platforms other than X11
+ (\p destination = 0) is mapped to the clipboard, i.e. on platforms other than X11 or Wayland
all \p destinations are equivalent and the data is always copied to the clipboard.
\note Please see Fl::selection_to_clipboard() to enable duplication of the
diff --git src/drivers/Wayland/fl_wayland_clipboard_dnd.cxx src/drivers/Wayland/fl_wayland_clipboard_dnd.cxx
index 2247044..2fecdca 100644
--- src/drivers/Wayland/fl_wayland_clipboard_dnd.cxx
+++ src/drivers/Wayland/fl_wayland_clipboard_dnd.cxx
@@ -735,15 +735,14 @@ void Fl_Wayland_Screen_Driver::paste(Fl_Widget &receiver, int clipboard, const c
void Fl_Wayland_Screen_Driver::copy(const char *stuff, int len, int clipboard,
const char *type) {
-#if HAVE_PRIMARY_SELECTION
- if (seat->primary_selection_device_manager && clipboard == 0 && (!stuff || len <= 0)) {
- zwp_primary_selection_device_v1_set_selection(seat->primary_selection_device, NULL, seat->serial);
- }
-#endif
if (!stuff || len < 0) return;
+ if (clipboard == 0 && Fl::selection_to_clipboard())
+ clipboard = 2;
+ if (clipboard >= 2) {
+ copy(stuff, len, 1, type); // copy to clipboard first (this is a recursion!)
+ clipboard = 0; // ... and then to selection buffer: fall through
+ }
- if (clipboard >= 2)
- clipboard = 1; // Only on X11 do multiple clipboards make sense.
selection_string[clipboard].clear();
selection_string[clipboard].insert(selection_string[clipboard].begin(), stuff, stuff + len);
fl_i_own_selection[clipboard] = 1;
Comments are owned by the poster. All other content is copyright 1998-2026 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.