mirror of https://github.com/fltk/fltk
While looking at Xdnd I discoverd that jx (or at least their demo program)
cannot paste from fltk programs. This appears to be because JX barfs if the pasting program does not respond correctly to the TARGETS XConvertSelection. I added a response that fltk only can do text and this seems to make it work. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.0@1253 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
ba1d83cf47
commit
97a234ff4a
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// "$Id: Fl_cutpaste.cxx,v 1.6.2.2 2000/06/05 21:21:00 mike Exp $"
|
||||
// "$Id: Fl_cutpaste.cxx,v 1.6.2.3 2000/07/13 08:51:22 spitzak Exp $"
|
||||
//
|
||||
// Cut/paste code for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
|
@ -42,6 +42,7 @@ static char *selection_buffer;
|
|||
static int selection_length;
|
||||
static int selection_buffer_length;
|
||||
static char beenhere;
|
||||
static Atom TARGETS;
|
||||
|
||||
extern Fl_Widget *fl_selection_requestor; // widget doing request_paste()
|
||||
|
||||
|
@ -79,15 +80,21 @@ static int selection_xevent_handler(int) {
|
|||
e.selection = fl_xevent->xselectionrequest.selection;
|
||||
e.target = fl_xevent->xselectionrequest.target;
|
||||
e.time = fl_xevent->xselectionrequest.time;
|
||||
if (fl_xevent->xselectionrequest.target != XA_STRING || !selection_length) {
|
||||
e.property = 0;
|
||||
} else {
|
||||
e.property = fl_xevent->xselectionrequest.property;
|
||||
}
|
||||
if (e.property) {
|
||||
e.property = fl_xevent->xselectionrequest.property;
|
||||
if (e.target == TARGETS) {
|
||||
Atom a = XA_STRING;
|
||||
XChangeProperty(fl_display, e.requestor, e.property,
|
||||
XA_ATOM, sizeof(Atom)*8, 0, (unsigned char*)&a,
|
||||
sizeof(Atom));
|
||||
} else if (e.target == XA_STRING && selection_length) {
|
||||
XChangeProperty(fl_display, e.requestor, e.property,
|
||||
XA_STRING, 8, 0, (unsigned char *)selection_buffer,
|
||||
selection_length);
|
||||
} else {
|
||||
// char* x = XGetAtomName(fl_display,e.target);
|
||||
// fprintf(stderr,"selection request of %s\n",x);
|
||||
// XFree(x);
|
||||
e.property = 0;
|
||||
}
|
||||
XSendEvent(fl_display, e.requestor, 0, 0, (XEvent *)&e);}
|
||||
return 1;
|
||||
|
@ -99,6 +106,14 @@ static int selection_xevent_handler(int) {
|
|||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
static void setup_crap() {
|
||||
if (!beenhere) {
|
||||
beenhere = 1;
|
||||
TARGETS = XInternAtom(fl_display, "TARGETS", 0);
|
||||
Fl::add_handler(selection_xevent_handler);
|
||||
}
|
||||
}
|
||||
|
||||
// Call this when a "paste" operation happens:
|
||||
void Fl::paste(Fl_Widget &receiver) {
|
||||
if (selection_owner()) {
|
||||
|
@ -114,10 +129,7 @@ void Fl::paste(Fl_Widget &receiver) {
|
|||
fl_selection_requestor = &receiver;
|
||||
XConvertSelection(fl_display, XA_PRIMARY, XA_STRING, XA_PRIMARY,
|
||||
fl_xid(Fl::first_window()), fl_event_time);
|
||||
if (!beenhere) {
|
||||
Fl::add_handler(selection_xevent_handler);
|
||||
beenhere = 1;
|
||||
}
|
||||
setup_crap();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
@ -140,14 +152,11 @@ void Fl::selection(Fl_Widget &owner, const char *stuff, int len) {
|
|||
RootWindow(fl_display, fl_screen),
|
||||
0,0,1,1,0,0,0);
|
||||
XSetSelectionOwner(fl_display, XA_PRIMARY, selxid, fl_event_time);
|
||||
if (!beenhere) {
|
||||
Fl::add_handler(selection_xevent_handler);
|
||||
beenhere = 1;
|
||||
}
|
||||
setup_crap();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id: Fl_cutpaste.cxx,v 1.6.2.2 2000/06/05 21:21:00 mike Exp $".
|
||||
// End of "$Id: Fl_cutpaste.cxx,v 1.6.2.3 2000/07/13 08:51:22 spitzak Exp $".
|
||||
//
|
||||
|
|
Loading…
Reference in New Issue