Make all platforms get same kind of Fl_Image object when pasting an image from clipboard.
Previously the X11 platform got an Fl_Shared_Image whereas other got an Fl_RGB_Image, which made image deletion difficult. Now all platforms get an Fl_RGB_Image object. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@11712 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
eda47df063
commit
8feb1bda5f
@ -161,9 +161,7 @@ int main(int argc, char **argv)
|
||||
win->end();
|
||||
win->resizable(tabs);
|
||||
win->show(argc,argv);
|
||||
#if defined(__APPLE__) || defined(WIN32)
|
||||
clip_callback(1, tabs); // use clipboard content at start
|
||||
#endif
|
||||
Fl::add_clipboard_notify(clip_callback, tabs); // will update with new clipboard content immediately or at application activation
|
||||
|
||||
Fl_Image::RGB_scaling(FL_RGB_SCALING_BILINEAR); // set bilinear image scaling method
|
||||
|
||||
21
src/Fl_x.cxx
21
src/Fl_x.cxx
@ -893,8 +893,8 @@ int Fl::clipboard_contains(const char *type)
|
||||
if (event.type == SelectionNotify && event.xselection.property == None) return 0;
|
||||
i++;
|
||||
}
|
||||
while (i < 10 && event.type != SelectionNotify);
|
||||
if (i >= 10) return 0;
|
||||
while (i < 50 && event.type != SelectionNotify);
|
||||
if (i >= 50) return 0;
|
||||
XGetWindowProperty(fl_display,
|
||||
event.xselection.requestor,
|
||||
event.xselection.property,
|
||||
@ -1478,9 +1478,9 @@ fprintf(stderr,"\n");*/
|
||||
sn_buffer[bytesread] = 0;
|
||||
convert_crlf(sn_buffer, bytesread);
|
||||
}
|
||||
if (!fl_selection_requestor) return 0;
|
||||
if (Fl::e_clipboard_type == Fl::clipboard_image) {
|
||||
if (bytesread == 0) return 0;
|
||||
Fl_Image *image = 0;
|
||||
static char tmp_fname[21];
|
||||
static Fl_Shared_Image *shared = 0;
|
||||
strcpy(tmp_fname, "/tmp/clipboardXXXXXX");
|
||||
@ -1496,18 +1496,23 @@ fprintf(stderr,"\n");*/
|
||||
shared = Fl_Shared_Image::get(tmp_fname);
|
||||
unlink(tmp_fname);
|
||||
if (!shared) return 0;
|
||||
image = shared->copy();
|
||||
uchar *rgb = new uchar[shared->w() * shared->h() * shared->d()];
|
||||
memcpy(rgb, shared->data()[0], shared->w() * shared->h() * shared->d());
|
||||
Fl_RGB_Image *image = new Fl_RGB_Image(rgb, shared->w(), shared->h(), shared->d());
|
||||
shared->release();
|
||||
image->alloc_array = 1;
|
||||
Fl::e_clipboard_data = (void*)image;
|
||||
}
|
||||
if (!fl_selection_requestor) return 0;
|
||||
|
||||
if (Fl::e_clipboard_type == Fl::clipboard_plain_text) {
|
||||
else if (Fl::e_clipboard_type == Fl::clipboard_plain_text) {
|
||||
Fl::e_text = sn_buffer ? (char*)sn_buffer : (char *)"";
|
||||
Fl::e_length = bytesread;
|
||||
}
|
||||
int old_event = Fl::e_number;
|
||||
fl_selection_requestor->handle(Fl::e_number = FL_PASTE);
|
||||
int retval = fl_selection_requestor->handle(Fl::e_number = FL_PASTE);
|
||||
if (!retval && Fl::e_clipboard_type == Fl::clipboard_image) {
|
||||
delete (Fl_RGB_Image*)Fl::e_clipboard_data;
|
||||
Fl::e_clipboard_data = NULL;
|
||||
}
|
||||
Fl::e_number = old_event;
|
||||
// Detect if this paste is due to Xdnd by the property name (I use
|
||||
// XA_SECONDARY for that) and send an XdndFinished message. It is not
|
||||
|
||||
Loading…
Reference in New Issue
Block a user