XCB_SELECTION_NOTIFY_EVENT 中请求者和 属性 的值

Values of requetor and property in XCB_SELECTION_NOTIFY_EVENT

我试图读取剪贴板上文件的路径(如果有的话)。

所以我注意到当发生这样的复制事件时,人们正在从剪贴板读取内容:

https://github.com/awesomeWM/awesome/blob/master/selection.c#L84 http://www.cyberforum.ru/cpp-linux/thread220845.html

我不需要等待复制事件,我只需要检查它是否为空白或有东西。我不关心未来的事件。所以我试图找出在调用中传递给 xcb_get_property_unchecked 的内容:

 xcb_get_property_unchecked(connect, 0, event_notify->requestor, event_notify->property,utf8_string, 0, UINT32_MAX);

这些等待事件的代码正在传入event_notify->requestorevent_notify->property

我猜 event_notify->requestor 我应该像这样传递选择所有者:

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;

所以我想通过它 win_owner_primarywin_owner_clipboard。但是我不知道要传递什么 property。我尝试了一个实验,将事件从根目录重定向到我的民意调查,以查看 property 的值是什么,但我没有收到任何事件 - https://gist.github.com/Noitidart/9026d03b83a4cf493c1744e46884a139

有人知道我应该为 property 传递什么吗?那么当是选择事件时property的可能取值是多少?

谢谢

这实际上只是关于选择的工作原理。你需要做的是要求服务器转换选择,然后服务器会给你这个事件。据我所知,没有 »direct« 查询方式(但我从未真正使用过选择)。

wikipedia article 写得很好,不过:

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:

  1. 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)
  2. in response, the server sends to the current owner of the selection a SelectionRequest event;
  3. 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
  4. the owner sends a request to the server to send the requester a SelectionNotify to notify that the selection has been transferred
  5. the requester can now read the selection in the property of the window by sending one or more GetProperty requests to the server;
  6. the requester destroys the property; if the owner has requested to be informed of this, it is sent a PropertyNotify event.