mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-29 07:52:50 -05:00
clipboard: fix hash duplication check, set isOwner for CopyFile
This commit is contained in:
@@ -505,10 +505,10 @@ func computeHash(data []byte) uint64 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func extractHash(data []byte) uint64 {
|
func extractHash(data []byte) uint64 {
|
||||||
if len(data) < 8 {
|
if len(data) < 9 {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
return binary.BigEndian.Uint64(data[len(data)-8:])
|
return binary.BigEndian.Uint64(data[len(data)-9 : len(data)-1])
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Manager) hasSensitiveMimeType(mimes []string) bool {
|
func (m *Manager) hasSensitiveMimeType(mimes []string) bool {
|
||||||
@@ -960,11 +960,21 @@ func (m *Manager) SetClipboard(data []byte, mimeType string) error {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
source.SetCancelledHandler(func(e ext_data_control.ExtDataControlSourceV1CancelledEvent) {
|
||||||
|
m.ownerLock.Lock()
|
||||||
|
m.isOwner = false
|
||||||
|
m.ownerLock.Unlock()
|
||||||
|
})
|
||||||
|
|
||||||
m.currentSource = source
|
m.currentSource = source
|
||||||
m.sourceMutex.Lock()
|
m.sourceMutex.Lock()
|
||||||
m.sourceMimeTypes = []string{mimeType}
|
m.sourceMimeTypes = []string{mimeType}
|
||||||
m.sourceMutex.Unlock()
|
m.sourceMutex.Unlock()
|
||||||
|
|
||||||
|
m.ownerLock.Lock()
|
||||||
|
m.isOwner = true
|
||||||
|
m.ownerLock.Unlock()
|
||||||
|
|
||||||
device := m.dataDevice.(*ext_data_control.ExtDataControlDeviceV1)
|
device := m.dataDevice.(*ext_data_control.ExtDataControlDeviceV1)
|
||||||
if err := device.SetSelection(source); err != nil {
|
if err := device.SetSelection(source); err != nil {
|
||||||
log.Errorf("Failed to set selection: %v", err)
|
log.Errorf("Failed to set selection: %v", err)
|
||||||
@@ -1585,7 +1595,18 @@ func (m *Manager) CopyFile(filePath string) error {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
source.SetCancelledHandler(func(e ext_data_control.ExtDataControlSourceV1CancelledEvent) {
|
||||||
|
m.ownerLock.Lock()
|
||||||
|
m.isOwner = false
|
||||||
|
m.ownerLock.Unlock()
|
||||||
|
})
|
||||||
|
|
||||||
m.currentSource = source
|
m.currentSource = source
|
||||||
|
|
||||||
|
m.ownerLock.Lock()
|
||||||
|
m.isOwner = true
|
||||||
|
m.ownerLock.Unlock()
|
||||||
|
|
||||||
device := m.dataDevice.(*ext_data_control.ExtDataControlDeviceV1)
|
device := m.dataDevice.(*ext_data_control.ExtDataControlDeviceV1)
|
||||||
if err := device.SetSelection(source); err != nil {
|
if err := device.SetSelection(source); err != nil {
|
||||||
log.Errorf("Failed to set selection: %v", err)
|
log.Errorf("Failed to set selection: %v", err)
|
||||||
|
|||||||
Reference in New Issue
Block a user