Collapse the claim constructors

This commit is contained in:
Sasha Koshka 2024-07-11 02:07:55 -04:00
parent d9d84ddada
commit 36b3e4f0ed
2 changed files with 6 additions and 13 deletions

View File

@ -16,18 +16,11 @@ type Claim struct {
} }
// NewClaim claims ownership of a specified selection, and allows using data // NewClaim claims ownership of a specified selection, and allows using data
// passed to it to fulfill requests for the selection's contents. If the claim // passed to it to fulfill requests for the selection's contents. The timestamp
// happens because of a user input event, use NewClaimWithTimestamp instead of // should be set to that of the event that triggered the claim, such as a Ctrl+C
// this function. See the documentation of NewClaimWithTimestamp for details. // event, or a mouse motion that led to text being selected. If the claim was
func NewClaim (window *xwindow.Window, selection xproto.Atom, data Data) *Claim { // not triggered by an event, specify xproto.TimeCurrentTime.
return NewClaimWithTimestamp(window, selection, data, 0) func NewClaim (window *xwindow.Window, selection xproto.Atom, data Data, timestamp xproto.Timestamp) *Claim {
}
// 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: // Follow:
// https://tronche.com/gui/x/icccm/sec-2.html#s-2.1 // https://tronche.com/gui/x/icccm/sec-2.html#s-2.1

View File

@ -62,7 +62,7 @@ func main () {
// obtain claim on CLIPBOARD // obtain claim on CLIPBOARD
log.Println("obtaining claim") log.Println("obtaining claim")
clipboard, _ := xprop.Atm(X, "CLIPBOARD") clipboard, _ := xprop.Atm(X, "CLIPBOARD")
claim := xgbsel.NewClaim(window, clipboard, data) claim := xgbsel.NewClaim(window, clipboard, data, xproto.TimeCurrentTime)
// listen for events // listen for events
window.Listen(xproto.EventMaskPropertyChange) window.Listen(xproto.EventMaskPropertyChange)