-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clipboard support in X11 #79
Comments
Confirmed also in linux Mint (mate/gnome2). I can see the buffer in xcb, but it is not connected with buffer used by the GUI. |
I've managed to trace the clipboard calls to traits xlib display storeToClipboard: aString, which is basically wrapper over traits xlib display xStoreBytes: t0, which itself is just wrapper over C++ code defined in xlib_glue.cpp / XStoreBytes_wrap as: void XStoreBytes_wrap(Display* display, char* buffer, void *FH) {
if (!XStoreBytes(display, buffer, strlen(buffer))) {
failure(FH, "xStoreBytes failed");
}
} That is clearly just another wrapper over I am no C++ programmer and definitlely no Unix / X11 expert, but from the description it looks to me like this is not a standard clipboard solution, but just some kind of X11 buffer. |
You want to use this: https://tronche.com/gui/x/xlib/window-information/selection.html Store the text in a special buffer, then set some X11 window (doesn't Self always have one?) as the owner of the current X11 selection, and handle this event: https://tronche.com/gui/x/xlib/events/client-communication/selection-request.html by sending this back to the requesting window: https://tronche.com/gui/x/xlib/events/client-communication/selection.html |
Just found that autocutsel can be used to temporarily bypass this problem, which will sync cut buffer and selection automatically. For a complete solution, we need to update to mechanism mentioned by @pjanouch. |
I've did some research and I've found, that the @pjanouch is right, BUT the xlib code for main window is handled from the Self code*. So you have to do selection request, but somewhere from Self ( *There is |
I am not able to find where in the Self code is the event loop for the xlib. There seems to be too much objects and abstraction and generated code. |
I may be wrong but I think it's done by
The |
Does this mean, that you can't modify the behavior while using Self, because the process is already launched? I've played with |
I suspect you need to find the actual instance of |
Maybe I'm looking in the wrong place. |
It looks like the The
|
Thanks, I will look at that. |
And
|
@Bystroushaak What do you think is a good place to document this sort of thing? The wiki? |
The wiki needs refactoring, but I suppose it is the only place where we can collect documentation. |
An alternative option is that I could move the handbook to its own repo and give you all write access. |
I think that handbook should be more formal and definitive. For me, wiki is more experimental and temporary, better for collaboration. |
I added some notes to the wiki. |
I've patched the void XStoreBytes_wrap(Display* display, char* buffer, void *FH) {
if (!XStoreBytes(display, buffer, strlen(buffer))) {
failure(FH, "xStoreBytes failed");
}
# ifdef XLIB
// X11 clipboard support
int revert_to;
Window active_win;
XGetInputFocus(display, &active_win, &revert_to); // get active window
XSetSelectionOwner(display, XA_PRIMARY, active_win, CurrentTime);
# endif // XLIB
} Which should tell X11 to mark Self window as selection owner, and when other applications requests the selection (user press ctrl+v), it should send selection request event to Self as described in https://web.archive.org/web/20120125071034/http://michael.toren.net/mirrors/doc/X-copy+paste.txt The problem is, that selection request doesn't ever appear. But it is defined in
All xEvents are generated by primitive maker, which is another confusing thing for me (where is the definition?). So, I think the required steps are:
Off course, there is also strong probability, that I don't understand what I am doing deep enough and this is all nonsense :) |
That looks right to me. See the For the primitiveMaker stuff you'll need to add the entry for the event,following the examples that are there, in
This generates the xlib glue code and you can rebuild the image. |
Hah. Yeah, I just discovered same thing. I am trying to generate the |
Can I request that anything you put anything you learn about primitive maker onto the wiki? :) |
I'll do a stub based on what I learned doing the font primitives. |
See primitiveMaker in the wiki. |
Currently, Self use cut buffers to support copy&paste in X11, but KDE (maybe other some other WMs) do not support it.
I have to use
xcutsel
to manually transfer contents between cut buffers and selections.P.S.
xcb
can be used to monitor cut buffers.See https://en.wikipedia.org/wiki/X_Window_selection for more details about clipboards in X11.
The text was updated successfully, but these errors were encountered: