I was trying to read the paths of the files on the clipboard (if there are any).
So I noticed people are reading from clipboard when a copy event happens like this:
https://github.com/awesomeWM/awesome/blob/master/selection.c#L84 http://www.cyberforum.ru/cpp-linux/thread220845.html
I don't need to wait for the copy event, i just need to check if its blank or has something. I don't care for future events. So I was trying to figure out what to pass to xcb_get_property_unchecked
in the call:
xcb_get_property_unchecked(connect, 0, event_notify->requestor, event_notify->property,utf8_string, 0, UINT32_MAX);
These codes that wait for the event are passing in event_notify->requestor
and event_notify->property
I'm guessing for event_notify->requestor
I should pass in the selection owner like this:
xcb_get_selection_owner_cookie_t cookie_primary, cookie_clipboard;
cookie_primary = xcb_get_selection_owner(connect, PRIMARY);//XCB_ATOM_PRIMARY
cookie_clipboard = xcb_get_selection_owner(connect, CLIPBOARD);
xcb_get_selection_owner_reply_t *reply_primary = xcb_get_selection_owner_reply( connect, cookie_primary, NULL );
xcb_get_selection_owner_reply_t *reply_clipboard = xcb_get_selection_owner_reply( connect, cookie_clipboard, NULL );
xcb_window_t win_owner_primary = reply_primary->owner;
xcb_window_t win_owner_clipboard = reply_clipboard->owner;
So I'm thinking pass it win_owner_primary
or win_owner_clipboard
. However i cannot figure out what to pass as property
. I tried an experiment to redirect events from root to my poll to see what the value of property
is but im not getting any events - https://gist.github.com/Noitidart/9026d03b83a4cf493c1744e46884a139
Does anyone know what I shuould pass for property
? So the possible values of property
when it is a selection event?
Thanks
This is really just about how selections work. What you need to do is ask the server to convert the selection and the server will then give you this event. AFAIK there's no »direct« way to query it (but I've never really worked with selections).
The wikipedia article on this is pretty well-written, though:
In particular, the destination client begins by asking the server which window owns the selection. Then the two clients transfer the selection via the server. This exchange involves a property of a window, and an arbitrary piece of data attached to the window. If the content of the selection is considered small enough to be transferred all at once, the steps that take place are:
- the recipient of the selection requests the selection to be converted, specifying a property of a window (this may be the window where the text has to be pasted)
- in response, the server sends to the current owner of the selection a SelectionRequest event;
- the owner places the selected text in the property of the window that the requestor has specified by sending a ChangeProperty; request to the server
- the owner sends a request to the server to send the requester a SelectionNotify to notify that the selection has been transferred
- the requester can now read the selection in the property of the window by sending one or more GetProperty requests to the server;
- the requester destroys the property; if the owner has requested to be informed of this, it is sent a PropertyNotify event.