From 534a8fd0ad0e43bc6aaa019e83eb94c14b3df765 Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Thu, 11 Jul 2024 17:21:59 -0400 Subject: [PATCH] Added a Prune method to Claim --- v2/claim.go | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/v2/claim.go b/v2/claim.go index 66c26d4..8f1442b 100644 --- a/v2/claim.go +++ b/v2/claim.go @@ -21,6 +21,12 @@ type claimRequest struct { event xevent.SelectionRequestEvent } +// Close closes the request's reader and does other cleanup. It does not remove +// the request from the claim. +func (this *claimRequest) Close () error { + return this.reader.Close() +} + type claimRequestKey struct { property xproto.Atom requestor xproto.Window @@ -73,7 +79,7 @@ func NewClaim (window *xwindow.Window, selection xproto.Atom, data Data, timesta return &Claim { open: true, - incr: false, // TODO change to enable INCR + incr: false, // TODO change to enable INCR once its done window: window, data: data, selection: selection, @@ -281,7 +287,7 @@ func (claim *Claim) HandlePropertyNotify ( if !ok { return } done := func () { - request.reader.Close() + request.Close() delete(claim.requests, key) } @@ -344,6 +350,15 @@ func (claim *Claim) HandleSelectionClear ( claim.open = false } +// Prune checks for requests that cannot continue and removes them. If this +// claim is to be held for an extended period of time, this method should be +// called every so often. +func (claim *Claim) Prune () { + // TODO + // check all active requests to see if anyone's window has closed, and + // if it has, close the request +} + // Open returns false if the claim has been relinquished, either from recieving // a SelectionClear event or with the Close method. func (claim *Claim) Open () bool {