Add NewClaimWithTimestamp

Remedy #4
This commit is contained in:
Sasha Koshka 2024-07-06 22:31:49 -04:00
parent d1ba6eac9a
commit dab360de75

View File

@ -16,8 +16,18 @@ type Claim struct {
}
// NewClaim claims ownership of a specified selection, and allows using data
// passed to it to fulfill requests for the selection's contents.
// passed to it to fulfill requests for the selection's contents. If the claim
// happens because of a user input event, use NewClaimWithTimestamp instead of
// this function. See the documentation of NewClaimWithTimestamp for details.
func NewClaim (window *xwindow.Window, selection xproto.Atom, data Data) *Claim {
return NewClaimWithTimestamp(window, selection, data, 0)
}
// NewClaimWithTimestamp claims ownership of a specified selection, and allows
// using data passed to it to fulfill requests for the selection's contents. The
// timestamp should be set to that of the event that triggered the claim, such
// as a Ctrl+C event, or a mouse motion that led to text being selected.
func NewClaimWithTimestamp (window *xwindow.Window, selection xproto.Atom, data Data, timestamp xproto.Timestamp) *Claim {
// Follow:
// https://tronche.com/gui/x/icccm/sec-2.html#s-2.1
@ -35,7 +45,7 @@ func NewClaim (window *xwindow.Window, selection xproto.Atom, data Data) *Claim
// owner of the selection.
err := xproto.SetSelectionOwnerChecked (
window.X.Conn(),
window.Id, selection, 0).Check() // FIXME: should not be zero
window.Id, selection, timestamp).Check()
if err != nil { return nil }
ownerReply, err := xproto.GetSelectionOwner (