diff --git a/app/app.go b/app/app.go index 69b3042e..ef4a0fe2 100644 --- a/app/app.go +++ b/app/app.go @@ -56,6 +56,13 @@ type FrameEvent struct { Source input.Source } +// ViewEvent provides handles to the underlying window objects for the +// current display protocol. +type ViewEvent interface { + implementsViewEvent() + ImplementsEvent() +} + // Insets is the space taken up by // system decoration such as translucent // system bars and software keyboards. diff --git a/app/os_android.go b/app/os_android.go index 1a2c3034..3819d2f8 100644 --- a/app/os_android.go +++ b/app/os_android.go @@ -205,9 +205,9 @@ type pixelInsets struct { top, bottom, left, right int } -// ViewEvent is sent whenever the Window's underlying Android view +// AndroidViewEvent is sent whenever the Window's underlying Android view // changes. -type ViewEvent struct { +type AndroidViewEvent struct { // View is a JNI global reference to the android.view.View // instance backing the Window. The reference is valid until // the next ViewEvent is received. @@ -514,7 +514,7 @@ func Java_org_gioui_GioView_onCreateView(env *C.JNIEnv, class C.jclass, view C.j w.setConfig(env, cnf) w.SetInputHint(w.inputHint) w.setStage(StagePaused) - w.processEvent(ViewEvent{View: uintptr(view)}) + w.processEvent(AndroidViewEvent{View: uintptr(view)}) return C.jlong(w.handle) } @@ -805,7 +805,7 @@ func (w *window) semIDFor(virtID C.jint) input.SemanticID { func (w *window) detach(env *C.JNIEnv) { callVoidMethod(env, w.view, gioView.unregister) - w.processEvent(ViewEvent{}) + w.processEvent(AndroidViewEvent{}) w.handle.Delete() C.jni_DeleteGlobalRef(env, w.view) w.view = 0 @@ -1504,4 +1504,5 @@ func Java_org_gioui_Gio_scheduleMainFuncs(env *C.JNIEnv, cls C.jclass) { } } -func (_ ViewEvent) ImplementsEvent() {} +func (AndroidViewEvent) implementsViewEvent() {} +func (AndroidViewEvent) ImplementsEvent() {} diff --git a/app/os_ios.go b/app/os_ios.go index b2f9fabd..8df0dfd9 100644 --- a/app/os_ios.go +++ b/app/os_ios.go @@ -93,7 +93,7 @@ import ( "gioui.org/unit" ) -type ViewEvent struct { +type UIKitViewEvent struct { // ViewController is a CFTypeRef for the UIViewController backing a Window. ViewController uintptr } @@ -139,7 +139,7 @@ func onCreate(view, controller C.CFTypeRef) { C.gio_viewSetHandle(view, C.uintptr_t(cgo.NewHandle(w))) w.Configure(wopts.options) w.ProcessEvent(StageEvent{Stage: StageRunning}) - w.ProcessEvent(ViewEvent{ViewController: uintptr(controller)}) + w.ProcessEvent(UIKitViewEvent{ViewController: uintptr(controller)}) } func viewFor(h C.uintptr_t) *window { @@ -203,7 +203,7 @@ func onStart(h C.uintptr_t) { //export onDestroy func onDestroy(h C.uintptr_t) { w := viewFor(h) - w.ProcessEvent(ViewEvent{}) + w.ProcessEvent(UIKitViewEvent{}) w.ProcessEvent(DestroyEvent{}) w.displayLink.Close() w.displayLink = nil @@ -398,4 +398,5 @@ func gio_runMain() { runMain() } -func (_ ViewEvent) ImplementsEvent() {} +func (UIKitViewEvent) implementsViewEvent() {} +func (UIKitViewEvent) ImplementsEvent() {} diff --git a/app/os_js.go b/app/os_js.go index 7e1aace0..352b8413 100644 --- a/app/os_js.go +++ b/app/os_js.go @@ -25,7 +25,7 @@ import ( "gioui.org/unit" ) -type ViewEvent struct { +type JSViewEvent struct { Element js.Value } @@ -114,7 +114,7 @@ func newWindow(win *callbacks, options []Option) { w.Configure(options) w.blur() - w.processEvent(ViewEvent{Element: cont}) + w.processEvent(JSViewEvent{Element: cont}) w.processEvent(StageEvent{Stage: StageRunning}) w.resize() w.draw(true) @@ -830,4 +830,5 @@ func translateKey(k string) (key.Name, bool) { return n, true } -func (_ ViewEvent) ImplementsEvent() {} +func (JSViewEvent) implementsViewEvent() {} +func (JSViewEvent) ImplementsEvent() {} diff --git a/app/os_macos.go b/app/os_macos.go index c1305d10..f743980d 100644 --- a/app/os_macos.go +++ b/app/os_macos.go @@ -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() {} diff --git a/app/os_unix.go b/app/os_unix.go index 492a38cc..b91cf89a 100644 --- a/app/os_unix.go +++ b/app/os_unix.go @@ -13,13 +13,6 @@ import ( "gioui.org/io/pointer" ) -// ViewEvent provides handles to the underlying window objects for the -// current display protocol. -type ViewEvent interface { - implementsViewEvent() - ImplementsEvent() -} - type X11ViewEvent struct { // Display is a pointer to the X11 Display created by XOpenDisplay. Display unsafe.Pointer diff --git a/app/os_windows.go b/app/os_windows.go index 680b3e8f..c73793bc 100644 --- a/app/os_windows.go +++ b/app/os_windows.go @@ -31,7 +31,7 @@ import ( "gioui.org/io/transfer" ) -type ViewEvent struct { +type Win32ViewEvent struct { HWND uintptr } @@ -113,7 +113,7 @@ func newWindow(win *callbacks, options []Option) { } winMap.Store(w.hwnd, w) defer winMap.Delete(w.hwnd) - w.ProcessEvent(ViewEvent{HWND: uintptr(w.hwnd)}) + w.ProcessEvent(Win32ViewEvent{HWND: uintptr(w.hwnd)}) w.Configure(options) windows.SetForegroundWindow(w.hwnd) windows.SetFocus(w.hwnd) @@ -308,7 +308,7 @@ func windowProc(hwnd syscall.Handle, msg uint32, wParam, lParam uintptr) uintptr case windows.WM_MOUSEHWHEEL: w.scrollEvent(wParam, lParam, true, getModifiers()) case windows.WM_DESTROY: - w.ProcessEvent(ViewEvent{}) + w.ProcessEvent(Win32ViewEvent{}) w.ProcessEvent(DestroyEvent{}) if w.hdc != 0 { windows.ReleaseDC(w.hdc) @@ -1011,4 +1011,5 @@ func configForDPI(dpi int) unit.Metric { } } -func (_ ViewEvent) ImplementsEvent() {} +func (Win32ViewEvent) implementsViewEvent() {} +func (Win32ViewEvent) ImplementsEvent() {}