Bugzilla – Attachment 1265 Details for
Bug 8427
Some apps in session can hang when copying images in client side
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
Put Latin-1 string into PRIMARY clipboard
latin1.c (text/x-csrc), 2.40 KB, created by
Adam Halim
on 2025-02-25 12:22:09 CET
(
hide
)
Description:
Put Latin-1 string into PRIMARY clipboard
Filename:
MIME Type:
Creator:
Adam Halim
Created:
2025-02-25 12:22:09 CET
Size:
2.40 KB
patch
obsolete
>#include <X11/Xlib.h> >#include <X11/Xatom.h> >#include <stdio.h> >#include <string.h> >#include <stdlib.h> > >// Function to set the clipboard text >void setClipboard(Display* display, Window window, const char* text) { >// Atom clipboard = XInternAtom(display, "CLIPBOARD", False); > Atom clipboard = XInternAtom(display, "PRIMARY", False); > Atom string = XInternAtom(display, "STRING", False); > Atom textAtom = XInternAtom(display, "TEXT", False); > Atom targets = XInternAtom(display, "TARGETS", False); > > XSetSelectionOwner(display, clipboard, window, CurrentTime); > if (XGetSelectionOwner(display, clipboard) != window) { > fprintf(stderr, "Failed to set clipboard owner\n"); > return; > } > > XEvent event; > while (1) { > XNextEvent(display, &event); > if (event.type == SelectionRequest) { > XSelectionRequestEvent* req = &event.xselectionrequest; > XSelectionEvent ev = {0}; > ev.type = SelectionNotify; > ev.display = req->display; > ev.requestor = req->requestor; > ev.selection = req->selection; > ev.time = req->time; > ev.target = req->target; > ev.property = req->property; > > if (req->target == targets) { > Atom typeList[] = { string, textAtom }; > XChangeProperty(display, req->requestor, req->property, XA_ATOM, 32, PropModeReplace, (unsigned char*)typeList, 2); > } else if (req->target == string || req->target == textAtom) { > XChangeProperty(display, req->requestor, req->property, req->target, 8, PropModeReplace, (unsigned char*)text, strlen(text)); > } else { > ev.property = None; > } > > XSendEvent(display, req->requestor, 0, 0, (XEvent*)&ev); > XFlush(display); > } > } >} > >int main() { > Display* display = XOpenDisplay(NULL); > if (!display) { > fprintf(stderr, "Unable to open X display\n"); > return 1; > } > > int screen = DefaultScreen(display); > Window window = XCreateSimpleWindow( > display, RootWindow(display, screen), 10, 10, 100, 100, 1, > BlackPixel(display, screen), WhitePixel(display, screen)); > XStoreName(display, window, "Clipboard Example"); > > char text[] = {0xe5, 0xe4, 0xf6, 0}; // åäö > > setClipboard(display, window, text); > > XDestroyWindow(display, window); > XCloseDisplay(display); > > return 0; >}
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 8427
: 1265