mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-05 17:35:36 +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"
|
"errors"
|
||||||
"image"
|
"image"
|
||||||
"runtime"
|
"runtime"
|
||||||
"sync"
|
|
||||||
"time"
|
"time"
|
||||||
"unicode"
|
"unicode"
|
||||||
"unicode/utf16"
|
"unicode/utf16"
|
||||||
@@ -57,7 +56,7 @@ type window struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// viewMap is the mapping from Cocoa NSViews to Go windows.
|
// viewMap is the mapping from Cocoa NSViews to Go windows.
|
||||||
var viewMap sync.Map
|
var viewMap = make(map[C.CFTypeRef]*window)
|
||||||
|
|
||||||
var mainWindow = newWindowRendezvous()
|
var mainWindow = newWindowRendezvous()
|
||||||
|
|
||||||
@@ -74,19 +73,19 @@ func mustView(view C.CFTypeRef) *window {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func lookupView(view C.CFTypeRef) (*window, bool) {
|
func lookupView(view C.CFTypeRef) (*window, bool) {
|
||||||
w, exists := viewMap.Load(view)
|
w, exists := viewMap[view]
|
||||||
if !exists {
|
if !exists {
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
return w.(*window), true
|
return w, true
|
||||||
}
|
}
|
||||||
|
|
||||||
func deleteView(view C.CFTypeRef) {
|
func deleteView(view C.CFTypeRef) {
|
||||||
viewMap.Delete(view)
|
delete(viewMap, view)
|
||||||
}
|
}
|
||||||
|
|
||||||
func insertView(view C.CFTypeRef, w *window) {
|
func insertView(view C.CFTypeRef, w *window) {
|
||||||
viewMap.Store(view, w)
|
viewMap[view] = w
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *window) contextView() C.CFTypeRef {
|
func (w *window) contextView() C.CFTypeRef {
|
||||||
|
|||||||
Reference in New Issue
Block a user