More work on dnd kitten

This commit is contained in:
Kovid Goyal
2026-04-19 10:21:01 +05:30
parent 8e76a62815
commit 36171d1233
4 changed files with 249 additions and 4 deletions

View File

@@ -720,3 +720,17 @@ func (self *Loop) StartAcceptingDrops(mime_types ...string) {
func (self *Loop) StopAcceptingDrops() {
self.QueueDnDData(map[string]string{"t": "A"}, "", false)
}
func (self *Loop) StartOfferingDrags() {
payload := ""
if ans, err := machine_id.MachineId(); err == nil {
mac := hmac.New(sha256.New, []byte("tty-dnd-protocol-machine-id"))
mac.Write(utils.UnsafeStringToBytes(ans))
payload = "1:" + hex.EncodeToString(mac.Sum(nil))
}
self.QueueDnDData(map[string]string{"t": "o", "x": "1"}, payload, false)
}
func (self *Loop) StopOfferingDrags() {
self.QueueDnDData(map[string]string{"t": "o", "x": "2"}, "", false)
}