summaryrefslogtreecommitdiff
path: root/src/fl_dnd_x.cxx
diff options
context:
space:
mode:
authorAlbrecht Schlosser <albrechts.fltk@online.de>2021-01-29 00:06:34 +0100
committerAlbrecht Schlosser <albrechts.fltk@online.de>2021-02-11 15:51:37 +0100
commitff0543524b7b2df4931aaa4e81bdfa9fe82b76f0 (patch)
tree250c94a0f226eb2139d9bc3e0ec9f32e708410d9 /src/fl_dnd_x.cxx
parented5854d65a0b1da14eecf382e46512fbb9b94f02 (diff)
Fix X11 copy-paste and drag-and-drop target selection (#182)
Select the "best" target rather than a random one out of a list of suitable targets. The old target selection algorithm would sometimes select the wrong target and hence retrieve unexpected data. This could happen in both copy-paste and drag-and-drop operations. Note: backported to 1.3.6 (git current) as well (commit 7ce6d2cf5dfc0488ec30d9f9f1709be73353479c). Closes #182.
Diffstat (limited to 'src/fl_dnd_x.cxx')
-rw-r--r--src/fl_dnd_x.cxx13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/fl_dnd_x.cxx b/src/fl_dnd_x.cxx
index d8911c000..6ec34d286 100644
--- a/src/fl_dnd_x.cxx
+++ b/src/fl_dnd_x.cxx
@@ -1,7 +1,7 @@
//
// Drag & Drop code for the Fast Light Tool Kit (FLTK).
//
-// Copyright 1998-2018 by Bill Spitzak and others.
+// Copyright 1998-2021 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
@@ -21,7 +21,6 @@
#include "drivers/X11/Fl_X11_Screen_Driver.H"
#include "Fl_Window_Driver.H"
-
extern Atom fl_XdndAware;
extern Atom fl_XdndSelection;
extern Atom fl_XdndEnter;
@@ -32,7 +31,6 @@ extern Atom fl_XdndDrop;
extern Atom fl_XdndStatus;
extern Atom fl_XdndActionCopy;
extern Atom fl_XdndFinished;
-//extern Atom fl_XdndProxy;
extern Atom fl_XdndURIList;
extern Atom fl_XaUtf8String;
@@ -90,7 +88,6 @@ int Fl_X11_Screen_Driver::dnd(int unused) {
XSetSelectionOwner(fl_display, fl_XdndSelection, fl_message_window, fl_event_time);
while (Fl::pushed()) {
-
// figure out what window we are pointing at:
Window new_window = 0; int new_version = 0;
Fl_Window* new_local_window = 0;
@@ -145,12 +142,12 @@ int Fl_X11_Screen_Driver::dnd(int unused) {
!strchr(fl_selection_buffer[0], ' ') &&
strstr(fl_selection_buffer[0], "\r\n")) {
// Send file/URI list...
- fl_sendClientMessage(target_window, fl_XdndEnter, source_window,
- dndversion<<24, fl_XdndURIList, XA_STRING, 0);
+ fl_sendClientMessage(target_window, fl_XdndEnter, source_window, dndversion<<24,
+ fl_XdndURIList, fl_XaUtf8String, XA_STRING);
} else {
// Send plain text...
- fl_sendClientMessage(target_window, fl_XdndEnter, source_window,
- dndversion<<24, fl_XaUtf8String, 0, 0);
+ fl_sendClientMessage(target_window, fl_XdndEnter, source_window, dndversion<<24,
+ fl_XaUtf8String, XA_STRING, 0);
}
}
}