Bugzilla – Attachment 73535 Details for
Bug 59772
LibreOffice Writer takes a long time to convert images on the clipboard to rich text (RTF) format
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
X11 clipboard test program
readclipboard.c (text/plain), 4.47 KB, created by
Esme Povirk
on 2013-01-23 17:22:42 UTC
(
hide
)
Description:
X11 clipboard test program
Filename:
MIME Type:
Creator:
Esme Povirk
Created:
2013-01-23 17:22:42 UTC
Size:
4.47 KB
patch
obsolete
>/* > >attempt to paste plain text to the clipboard and write it to the screen > >gcc -lX11 -Wall readclipboard.c -o readclipboard > >*/ > >#include <stdio.h> >#include <assert.h> >#include <string.h> >#include <unistd.h> > >#include <X11/Xlib.h> >#include <X11/Xatom.h> > >#define BUFFER_SIZE 2048 > >Atom SELECTION_DATA, CLIPBOARD, INCR; > >Bool is_selectionnotify_event(Display *display, XEvent *event, XPointer arg) >{ > return (event->type == SelectionNotify); >} > >Bool is_propertynotify_event(Display *display, XEvent *event, XPointer arg) >{ > return (event->type == PropertyNotify); >} > >int read_property(Display *display, Window window, int recursive) >{ > int i, j; > Atom actual_type; > int actual_format; > unsigned long nitems, bytes_after=1; > unsigned char *prop=NULL; > char* atom_names[BUFFER_SIZE/4]; > int got_data=0; > > for (i=0; bytes_after != 0; i++) > { > XGetWindowProperty( > display, /* display */ > window, /* window */ > SELECTION_DATA, /* property */ > i*BUFFER_SIZE/4, /* long_offset */ > BUFFER_SIZE/4, /* long_length */ > False, /* delete */ > AnyPropertyType, /* req_type */ > &actual_type, /* actual_type_return */ > &actual_format, /* actual_format_return */ > &nitems, /* nitems_return */ > &bytes_after, /* bytes_after_return */ > &prop /* prop_return */ > ); > > if (nitems) > got_data = 1; > > if (actual_type == XA_ATOM) > { > assert(actual_format == 32); > XGetAtomNames(display, (Atom*)prop, nitems, atom_names); > for (j=0; j<nitems; j++) > { > fprintf(stdout, "%s\n", atom_names[j]); > XFree(atom_names[j]); > } > } > else if (actual_type == INCR) > { > XEvent event; > int read_data = 1; > > assert(!recursive); > > /* Clear out any previous property notify events */ > while (XCheckIfEvent(display, &event, is_propertynotify_event, NULL)); > > XDeleteProperty(display, window, SELECTION_DATA); > > while (read_data) > { > /* wait for PropertyNotify with new value */ > while (1) > { > XIfEvent(display, &event, is_propertynotify_event, NULL); > > if (event.xproperty.window == window && event.xproperty.atom == SELECTION_DATA && > event.xproperty.state == PropertyNewValue) > break; > } > > read_data = read_property(display, window, 1); > > XDeleteProperty(display, window, SELECTION_DATA); > } > > return 0; > } > else if (actual_type == None && actual_format == 0) > assert(0); > else > { > fwrite(prop, actual_format/8, nitems, stdout); > } > > XFree(prop); > } > > return got_data; >} > >int main(int argc, char *argv[]) >{ > Display *display; > Window window; > XEvent event; > int result=0; > Atom target; > > display = XOpenDisplay(NULL); > if (!display) > { > fprintf(stderr, "Cannot open X display.\n"); > return 1; > } > > window = XCreateSimpleWindow( > display, > DefaultRootWindow(display), > 0, 0, 1, 1, /* xywh */ > 0, /* border_width */ > 0, /* border */ > 0 /* background */ > ); > > XSelectInput(display, window, PropertyChangeMask); > > SELECTION_DATA = XInternAtom(display, "SELECTION_DATA", False); > CLIPBOARD = XInternAtom(display, "CLIPBOARD", False); > INCR = XInternAtom(display, "INCR", False); > > if (argc == 1) > target = XA_STRING; > else > target = XInternAtom(display, argv[1], True); > > if (target == None) > { > fprintf(stderr, "No such atom exists.\n"); > result=1; > } > else > { > XConvertSelection( > display, > CLIPBOARD, > target, > SELECTION_DATA, > window, > CurrentTime > ); > > /* wait until we get a SelectionNotify event */ > XIfEvent(display, &event, is_selectionnotify_event, NULL); > > if (event.xselection.property == SELECTION_DATA) > { > read_property(display, window, 0); > } > else > { > fprintf(stderr, "Target not available.\n"); > result=1; > } > } > > XDestroyWindow(display, window); > > XCloseDisplay(display); > > return result; >} >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 59772
:
73534
| 73535