app: [API] make ViewEvent an interface on all platforms

A uniform type allows convenient nil checks and for future window
backends on platforms other than Linux (which already had ViewEvent
as an interface).

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2023-12-15 16:52:38 -06:00
parent 5e5d164929
commit f3fc0d62b8
7 changed files with 34 additions and 29 deletions
+7 -6
View File
@@ -297,9 +297,9 @@ func init() {
runtime.LockOSThread()
}
// ViewEvent notifies the client of changes to the window AppKit handles.
// The handles are retained until another ViewEvent is sent.
type ViewEvent struct {
// AppKitViewEvent notifies the client of changes to the window AppKit handles.
// The handles are retained until another AppKitViewEvent is sent.
type AppKitViewEvent struct {
// View is a CFTypeRef for the NSView for the window.
View uintptr
// Layer is a CFTypeRef of the CALayer of View.
@@ -862,9 +862,9 @@ func gio_onAttached(h C.uintptr_t, attached C.int) {
w := windowFor(h)
if attached != 0 {
layer := C.layerForView(w.view)
w.ProcessEvent(ViewEvent{View: uintptr(w.view), Layer: uintptr(layer)})
w.ProcessEvent(AppKitViewEvent{View: uintptr(w.view), Layer: uintptr(layer)})
} else {
w.ProcessEvent(ViewEvent{})
w.ProcessEvent(AppKitViewEvent{})
w.setStage(StagePaused)
}
}
@@ -1057,4 +1057,5 @@ func convertMods(mods C.NSUInteger) key.Modifiers {
return kmods
}
func (_ ViewEvent) ImplementsEvent() {}
func (AppKitViewEvent) implementsViewEvent() {}
func (AppKitViewEvent) ImplementsEvent() {}