侦听XSetSelectionOwner

时间:2014-10-02 13:27:15

标签: xlib

是否可以通知新选择所有者? XSetSelectionOwner方法会导致任何事件广播吗?我想知道x2x是如何工作的。如果没有任何方式可以通知有新的选择所有者,则x2x必须询问循环中的X服务器谁是选择所有者。

我怀疑: x2x使用XGetSelectionOwner向两个显示器询问当前所有者。如果在Display 1上更改了所有者,则x2x会使用XSetSelectionOwner成为Display 2上的选择所有者。如果用户希望在展示广告2上粘贴数据,display 2上的x2x将作为中间版,并将所有收到的请求发送到Display 1中的原始客户端。我是对的吗?

1 个答案:

答案 0 :(得分:3)

是的,当您获得选择所有权时,之前的所有者会收到SelectionClear事件:

  

SelectionClear

     

所有者:WINDOW

     

选择:ATOM

     

时间:TIMESTAMP

     

此事件将报告给选择的当前所有者,并且是   通过以下方式定义新所有者时生成的   SetSelectionOwner。时间戳是记录的最后更改时间   选择。 owner参数是由指定的窗口   SetSelectionOwner请求中的当前所有者。

更新:如果您没有自己的选择,则可以使用XFixes extension获取有关选择更改的通知:

6. Selection Tracking

Applications wishing to monitor the contents of current selections must
poll for selection changes.  XFIXES improves this by providing an event
delivered whenever the selection ownership changes.

6.2 Requests

SelectSelectionInput

        window:             Window
        selection:          Atom
        event-mask:         SETofSELECTIONEVENT

    Selects for events to be delivered to window when various causes of
    ownership of selection occur.  Subtype indicates the cause of the
    selection ownership change.  Owner is set to the current selection
    owner, or None.  Timestamp indicates the time the event was
    generated while selection-timestamp indicates the timestamp used to
    own the selection.