mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 15:45:38 +00:00
app/internal/window: [macOS] use regular map for view-to-window lookups
All accesses to the view map now happens on the main thread, so there is no need for a sync.Map anymore. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -8,7 +8,6 @@ import (
|
||||
"errors"
|
||||
"image"
|
||||
"runtime"
|
||||
"sync"
|
||||
"time"
|
||||
"unicode"
|
||||
"unicode/utf16"
|
||||
@@ -57,7 +56,7 @@ type window struct {
|
||||
}
|
||||
|
||||
// viewMap is the mapping from Cocoa NSViews to Go windows.
|
||||
var viewMap sync.Map
|
||||
var viewMap = make(map[C.CFTypeRef]*window)
|
||||
|
||||
var mainWindow = newWindowRendezvous()
|
||||
|
||||
@@ -74,19 +73,19 @@ func mustView(view C.CFTypeRef) *window {
|
||||
}
|
||||
|
||||
func lookupView(view C.CFTypeRef) (*window, bool) {
|
||||
w, exists := viewMap.Load(view)
|
||||
w, exists := viewMap[view]
|
||||
if !exists {
|
||||
return nil, false
|
||||
}
|
||||
return w.(*window), true
|
||||
return w, true
|
||||
}
|
||||
|
||||
func deleteView(view C.CFTypeRef) {
|
||||
viewMap.Delete(view)
|
||||
delete(viewMap, view)
|
||||
}
|
||||
|
||||
func insertView(view C.CFTypeRef, w *window) {
|
||||
viewMap.Store(view, w)
|
||||
viewMap[view] = w
|
||||
}
|
||||
|
||||
func (w *window) contextView() C.CFTypeRef {
|
||||
|
||||
Reference in New Issue
Block a user