From 08e59d25cf08f4808b87bb569bbbdc98748dad58 Mon Sep 17 00:00:00 2001 From: MatejMagat305 <61238240+MatejMagat305@users.noreply.github.com> Date: Sat, 1 Jul 2023 18:52:27 +0200 Subject: [PATCH 01/23] Update android.go --- internal/driver/mobile/app/android.go | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/internal/driver/mobile/app/android.go b/internal/driver/mobile/app/android.go index fdc09b8597..6786310fa7 100644 --- a/internal/driver/mobile/app/android.go +++ b/internal/driver/mobile/app/android.go @@ -555,21 +555,30 @@ func runInputQueue(vm, jniEnv, ctx uintptr) error { } } + func processEvents(env *C.JNIEnv, q *C.AInputQueue) { var e *C.AInputEvent for C.AInputQueue_getEvent(q, &e) >= 0 { if C.AInputQueue_preDispatchEvent(q, e) != 0 { continue } - processEvent(env, e) - C.AInputQueue_finishEvent(q, e, 0) + handle := processEvent(env, e) + C.AInputQueue_finishEvent(q, e, C.int(handle)) } } -func processEvent(env *C.JNIEnv, e *C.AInputEvent) { +func processEvent(env *C.JNIEnv, e *C.AInputEvent) int { switch C.AInputEvent_getType(e) { case C.AINPUT_EVENT_TYPE_KEY: - processKey(env, e) + keyCode := C.AKeyEvent_getKeyCode(e) + if (keyCode == AKEYCODE_BACK) { + // Handle back button press + return 1 + } else if (keyCode == AKEYCODE_MENU) { + // Handle menu button press + return 1 + } + processKey(env, e) case C.AINPUT_EVENT_TYPE_MOTION: // At most one of the events in this batch is an up or down event; get its index and change. upDownIndex := C.size_t(C.AMotionEvent_getAction(e)&C.AMOTION_EVENT_ACTION_POINTER_INDEX_MASK) >> C.AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT @@ -596,6 +605,7 @@ func processEvent(env *C.JNIEnv, e *C.AInputEvent) { default: log.Printf("unknown input event, type=%d", C.AInputEvent_getType(e)) } + return 0 } func processKey(env *C.JNIEnv, e *C.AInputEvent) { From fc057e72e0d8bc8df7f5f5c5a951df1be04ac951 Mon Sep 17 00:00:00 2001 From: MatejMagat305 <61238240+MatejMagat305@users.noreply.github.com> Date: Sat, 1 Jul 2023 19:40:16 +0200 Subject: [PATCH 02/23] Update android.go --- internal/driver/mobile/app/android.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/internal/driver/mobile/app/android.go b/internal/driver/mobile/app/android.go index 6786310fa7..68b3f20052 100644 --- a/internal/driver/mobile/app/android.go +++ b/internal/driver/mobile/app/android.go @@ -555,7 +555,6 @@ func runInputQueue(vm, jniEnv, ctx uintptr) error { } } - func processEvents(env *C.JNIEnv, q *C.AInputQueue) { var e *C.AInputEvent for C.AInputQueue_getEvent(q, &e) >= 0 { @@ -572,7 +571,7 @@ func processEvent(env *C.JNIEnv, e *C.AInputEvent) int { case C.AINPUT_EVENT_TYPE_KEY: keyCode := C.AKeyEvent_getKeyCode(e) if (keyCode == AKEYCODE_BACK) { - // Handle back button press + // Handle back button press and return handle return 1 } else if (keyCode == AKEYCODE_MENU) { // Handle menu button press From 1a09e2a8a0f04da3c0fbafd3e8669f124a0bc1e9 Mon Sep 17 00:00:00 2001 From: MatejMagat305 <61238240+MatejMagat305@users.noreply.github.com> Date: Sat, 1 Jul 2023 20:57:40 +0200 Subject: [PATCH 03/23] move keyCode to processKey() --- internal/driver/mobile/app/android.go | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/internal/driver/mobile/app/android.go b/internal/driver/mobile/app/android.go index 68b3f20052..63a3a3797f 100644 --- a/internal/driver/mobile/app/android.go +++ b/internal/driver/mobile/app/android.go @@ -569,15 +569,7 @@ func processEvents(env *C.JNIEnv, q *C.AInputQueue) { func processEvent(env *C.JNIEnv, e *C.AInputEvent) int { switch C.AInputEvent_getType(e) { case C.AINPUT_EVENT_TYPE_KEY: - keyCode := C.AKeyEvent_getKeyCode(e) - if (keyCode == AKEYCODE_BACK) { - // Handle back button press and return handle - return 1 - } else if (keyCode == AKEYCODE_MENU) { - // Handle menu button press - return 1 - } - processKey(env, e) + return processKey(env, e) case C.AINPUT_EVENT_TYPE_MOTION: // At most one of the events in this batch is an up or down event; get its index and change. upDownIndex := C.size_t(C.AMotionEvent_getAction(e)&C.AMOTION_EVENT_ACTION_POINTER_INDEX_MASK) >> C.AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT @@ -611,15 +603,20 @@ func processKey(env *C.JNIEnv, e *C.AInputEvent) { deviceID := C.AInputEvent_getDeviceId(e) if deviceID == 0 { // Software keyboard input, leaving for scribe/IME. - return + return 0 } - + keyCode := C.AKeyEvent_getKeyCode(e) + if (keyCode == C.AKEYCODE_BACK) { + return 1 // Handle back button press and return handle + } else if (keyCode == C.AKEYCODE_MENU) { + return 1 // Handle menu button press + } k := key.Event{ Rune: rune(C.getKeyRune(env, e)), - Code: convAndroidKeyCode(int32(C.AKeyEvent_getKeyCode(e))), + Code: convAndroidKeyCode(int32(keyCode)), } if k.Rune >= '0' && k.Rune <= '9' { // GBoard generates key events for numbers, but we see them in textChanged - return + return 0 } switch C.AKeyEvent_getAction(e) { case C.AKEY_STATE_DOWN: @@ -630,7 +627,8 @@ func processKey(env *C.JNIEnv, e *C.AInputEvent) { k.Direction = key.DirNone } // TODO(crawshaw): set Modifiers. - theApp.events.In() <- k + go func() {theApp.events.In() <- k}() + return 0 } func eglGetError() string { From 8d70fe5d1be94040e1a5633f910e5753b18d3ae9 Mon Sep 17 00:00:00 2001 From: MatejMagat305 <61238240+MatejMagat305@users.noreply.github.com> Date: Sat, 1 Jul 2023 21:00:42 +0200 Subject: [PATCH 04/23] fix func type --- internal/driver/mobile/app/android.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/driver/mobile/app/android.go b/internal/driver/mobile/app/android.go index 63a3a3797f..fa818fa1e0 100644 --- a/internal/driver/mobile/app/android.go +++ b/internal/driver/mobile/app/android.go @@ -569,7 +569,7 @@ func processEvents(env *C.JNIEnv, q *C.AInputQueue) { func processEvent(env *C.JNIEnv, e *C.AInputEvent) int { switch C.AInputEvent_getType(e) { case C.AINPUT_EVENT_TYPE_KEY: - return processKey(env, e) + return processKey(env, e) case C.AINPUT_EVENT_TYPE_MOTION: // At most one of the events in this batch is an up or down event; get its index and change. upDownIndex := C.size_t(C.AMotionEvent_getAction(e)&C.AMOTION_EVENT_ACTION_POINTER_INDEX_MASK) >> C.AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT @@ -599,7 +599,7 @@ func processEvent(env *C.JNIEnv, e *C.AInputEvent) int { return 0 } -func processKey(env *C.JNIEnv, e *C.AInputEvent) { +func processKey(env *C.JNIEnv, e *C.AInputEvent) int { deviceID := C.AInputEvent_getDeviceId(e) if deviceID == 0 { // Software keyboard input, leaving for scribe/IME. From ce6241cc66d7e89b2819788510fb998437583a67 Mon Sep 17 00:00:00 2001 From: MatejMagat305 <61238240+MatejMagat305@users.noreply.github.com> Date: Fri, 21 Jul 2023 16:20:25 +0200 Subject: [PATCH 05/23] finish and reload ctx --- internal/driver/mobile/app/android.c | 45 +++++++++--------- internal/driver/mobile/app/android.go | 50 ++++++++------------ internal/driver/mobile/app/darwin_desktop.go | 6 +-- internal/driver/mobile/app/darwin_ios.go | 6 +-- internal/driver/mobile/app/x11.go | 9 ++-- 5 files changed, 49 insertions(+), 67 deletions(-) diff --git a/internal/driver/mobile/app/android.c b/internal/driver/mobile/app/android.c index 0d73683f4b..a8d37358d6 100644 --- a/internal/driver/mobile/app/android.c +++ b/internal/driver/mobile/app/android.c @@ -66,6 +66,21 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved) { static int main_running = 0; +void set_global(ANativeActivity *activity){ + JNIEnv* env = activity->env; + // Note that activity->clazz is mis-named. + current_class = (*env)->GetObjectClass(env, activity->clazz); + current_class = (*env)->NewGlobalRef(env, current_class); + key_rune_method = find_static_method(env, current_class, "getRune", "(III)I"); + show_keyboard_method = find_static_method(env, current_class, "showKeyboard", "(I)V"); + hide_keyboard_method = find_static_method(env, current_class, "hideKeyboard", "()V"); + show_file_open_method = find_static_method(env, current_class, "showFileOpen", "(Ljava/lang/String;)V"); + show_file_save_method = find_static_method(env, current_class, "showFileSave", "(Ljava/lang/String;Ljava/lang/String;)V"); + finish_method = find_method(env, current_class, "finish", "()V"); + + setCurrentContext(activity->vm, (*env)->NewGlobalRef(env, activity->clazz)); +} + // Entry point from our subclassed NativeActivity. // // By here, the Go runtime has been initialized (as we are running in @@ -78,17 +93,7 @@ void ANativeActivity_onCreate(ANativeActivity *activity, void* savedState, size_ if (!main_running) { JNIEnv* env = activity->env; - // Note that activity->clazz is mis-named. - current_class = (*env)->GetObjectClass(env, activity->clazz); - current_class = (*env)->NewGlobalRef(env, current_class); - key_rune_method = find_static_method(env, current_class, "getRune", "(III)I"); - show_keyboard_method = find_static_method(env, current_class, "showKeyboard", "(I)V"); - hide_keyboard_method = find_static_method(env, current_class, "hideKeyboard", "()V"); - show_file_open_method = find_static_method(env, current_class, "showFileOpen", "(Ljava/lang/String;)V"); - show_file_save_method = find_static_method(env, current_class, "showFileSave", "(Ljava/lang/String;Ljava/lang/String;)V"); - finish_method = find_method(env, current_class, "finishActivity", "()V"); - - setCurrentContext(activity->vm, (*env)->NewGlobalRef(env, activity->clazz)); + set_global(activity); // Set FILESDIR if (setenv("FILESDIR", activity->internalDataPath, 1) != 0) { @@ -160,6 +165,13 @@ static char* initEGLDisplay() { return NULL; } +void finish(JNIEnv* env, jobject ctx) { + (*env)->CallVoidMethod( + env, + ctx, + finish_method); +} + char* createEGLSurface(ANativeWindow* window) { char* err; EGLint numConfigs, format; @@ -206,13 +218,6 @@ char* destroyEGLSurface() { return NULL; } -void finish(JNIEnv* env, jobject ctx) { - (*env)->CallVoidMethod( - env, - ctx, - finish_method); -} - int32_t getKeyRune(JNIEnv* env, AInputEvent* e) { return (int32_t)(*env)->CallStaticIntMethod( env, @@ -281,10 +286,6 @@ void Java_org_golang_app_GoNativeActivity_keyboardDelete(JNIEnv *env, jclass cla keyboardDelete(); } -void Java_org_golang_app_GoNativeActivity_backPressed(JNIEnv *env, jclass clazz) { - onBackPressed(); -} - void Java_org_golang_app_GoNativeActivity_setDarkMode(JNIEnv *env, jclass clazz, jboolean dark) { setDarkMode((bool)dark); } diff --git a/internal/driver/mobile/app/android.go b/internal/driver/mobile/app/android.go index fa818fa1e0..e1ae5d0a97 100644 --- a/internal/driver/mobile/app/android.go +++ b/internal/driver/mobile/app/android.go @@ -49,6 +49,7 @@ void hideKeyboard(JNIEnv* env); void showFileOpen(JNIEnv* env, char* mimes); void showFileSave(JNIEnv* env, char* mimes, char* filename); void finish(JNIEnv* env, jobject ctx); +void set_global(ANativeActivity *activity); void Java_org_golang_app_GoNativeActivity_filePickerReturned(JNIEnv *env, jclass clazz, jstring str); */ @@ -78,18 +79,6 @@ var mimeMap = map[string]string{ ".txt": "text/plain", } -// GoBack asks the OS to go to the previous app / activity -func GoBack() { - err := RunOnJVM(func(_, jniEnv, ctx uintptr) error { - env := (*C.JNIEnv)(unsafe.Pointer(jniEnv)) - C.finish(env, C.jobject(ctx)) - return nil - }) - if err != nil { - log.Fatalf("app: %v", err) - } -} - // RunOnJVM runs fn on a new goroutine locked to an OS thread with a JNIEnv. // // RunOnJVM blocks until the call to fn is complete. Any Java @@ -133,10 +122,12 @@ func callMain(mainPC uintptr) { //export onStart func onStart(activity *C.ANativeActivity) { + C.set_global(activity) } //export onResume func onResume(activity *C.ANativeActivity) { + C.set_global(activity) } //export onSaveInstanceState @@ -152,19 +143,6 @@ func onPause(activity *C.ANativeActivity) { func onStop(activity *C.ANativeActivity) { } -//export onBackPressed -func onBackPressed() { - k := key.Event{ - Code: key.CodeBackButton, - Direction: key.DirPress, - } - log.Println("Logging key event back") - theApp.events.In() <- k - - k.Direction = key.DirRelease - theApp.events.In() <- k -} - //export onCreate func onCreate(activity *C.ANativeActivity) { // Set the initial configuration. @@ -230,6 +208,14 @@ type windowConfig struct { pixelsPerPt float32 } +func Finish() { + RunOnJVM(func(vm, jniEnv, ctx uintptr) error { + println("finish") + env := (*C.JNIEnv)(unsafe.Pointer(jniEnv)) // not a Go heap pointer + C.finish(env, C.jobject(ctx)) + return nil + }) +} func windowConfigRead(activity *C.ANativeActivity) windowConfig { aconfig := C.AConfiguration_new() C.AConfiguration_fromAssetManager(aconfig, activity.assetManager) @@ -555,6 +541,7 @@ func runInputQueue(vm, jniEnv, ctx uintptr) error { } } + func processEvents(env *C.JNIEnv, q *C.AInputQueue) { var e *C.AInputEvent for C.AInputQueue_getEvent(q, &e) >= 0 { @@ -605,12 +592,13 @@ func processKey(env *C.JNIEnv, e *C.AInputEvent) int { // Software keyboard input, leaving for scribe/IME. return 0 } - keyCode := C.AKeyEvent_getKeyCode(e) - if (keyCode == C.AKEYCODE_BACK) { - return 1 // Handle back button press and return handle - } else if (keyCode == C.AKEYCODE_MENU) { - return 1 // Handle menu button press - } + keyCode := C.AKeyEvent_getKeyCode(e) + if (keyCode == C.AKEYCODE_BACK) { + println("back ok") + return 0 // Handle back button press and return handle + } else if (keyCode == C.AKEYCODE_MENU) { + return 1 // Handle menu button press + } k := key.Event{ Rune: rune(C.getKeyRune(env, e)), Code: convAndroidKeyCode(int32(keyCode)), diff --git a/internal/driver/mobile/app/darwin_desktop.go b/internal/driver/mobile/app/darwin_desktop.go index 5b7041f465..35ac0ea571 100644 --- a/internal/driver/mobile/app/darwin_desktop.go +++ b/internal/driver/mobile/app/darwin_desktop.go @@ -63,10 +63,6 @@ func main(f func(App)) { C.runApp() } -func GoBack() { - // When simulating mobile there are no other activities open (and we can't just force background) -} - // loop is the primary drawing loop. // // After Cocoa has captured the initial OS thread for processing Cocoa @@ -107,7 +103,9 @@ func (a *app) loop(ctx C.GLintptr) { } } } +func Finish() { +} var drawDone = make(chan struct{}) // drawgl is used by Cocoa to occasionally request screen updates. diff --git a/internal/driver/mobile/app/darwin_ios.go b/internal/driver/mobile/app/darwin_ios.go index d40ec5a29e..f59547b084 100644 --- a/internal/driver/mobile/app/darwin_ios.go +++ b/internal/driver/mobile/app/darwin_ios.go @@ -82,10 +82,6 @@ var DisplayMetrics struct { HeightPx int } -func GoBack() { - // Apple do not permit apps to exit in any way other than user pressing home button / gesture -} - //export setDisplayMetrics func setDisplayMetrics(width, height int, scale int) { DisplayMetrics.WidthPx = width @@ -150,7 +146,9 @@ func updateConfig(width, height, orientation int32) { } theApp.events.In() <- paint.Event{External: true} } +func Finish() { +} // touchIDs is the current active touches. The position in the array // is the ID, the value is the UITouch* pointer value. // diff --git a/internal/driver/mobile/app/x11.go b/internal/driver/mobile/app/x11.go index 300297c3b1..816ea0a17b 100644 --- a/internal/driver/mobile/app/x11.go +++ b/internal/driver/mobile/app/x11.go @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build (linux && !android) || freebsd -// +build linux,!android freebsd +//go:build linux && !android +// +build linux,!android package app @@ -15,7 +15,6 @@ than screens with touch panels. /* #cgo LDFLAGS: -lEGL -lGLESv2 -lX11 -#cgo freebsd CFLAGS: -I/usr/local/include/ void createWindow(void); void processEvents(void); @@ -79,11 +78,9 @@ func main(f func(App)) { } } } +func Finish() { -func GoBack() { - // When simulating mobile there are no other activities open (and we can't just force background) } - //export onResize func onResize(w, h int) { // TODO(nigeltao): don't assume 72 DPI. DisplayWidth and DisplayWidthMM From 41610bf2fd7ca5f054b17ceb36b900ab86ec6958 Mon Sep 17 00:00:00 2001 From: MatejMagat305 <61238240+MatejMagat305@users.noreply.github.com> Date: Fri, 21 Jul 2023 16:22:10 +0200 Subject: [PATCH 06/23] delete old ctx --- internal/driver/mobile/mobileinit/ctx_android.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/internal/driver/mobile/mobileinit/ctx_android.go b/internal/driver/mobile/mobileinit/ctx_android.go index b58881a26d..8a109ee29b 100644 --- a/internal/driver/mobile/mobileinit/ctx_android.go +++ b/internal/driver/mobile/mobileinit/ctx_android.go @@ -55,6 +55,13 @@ static char* checkException(uintptr_t jnienv) { static void unlockJNI(JavaVM *vm) { (*vm)->DetachCurrentThread(vm); } +static void deletePrevCtx(JNIEnv* env,jobject ctx){ + (*env)->DeleteGlobalRef(env, ctx); +} +static int is_null(jobject ctx){ + if (ctx == NULL) return 1; + return 0; +} */ import "C" @@ -80,6 +87,13 @@ var currentCtx C.jobject // The android.context.Context object must be a global reference. func SetCurrentContext(vm unsafe.Pointer, ctx uintptr) { currentVM = (*C.JavaVM)(vm) + if int(C.is_null(currentCtx)) == 1 { + RunOnJVM(func(vm, jniEnv, ctx uintptr) error { + env := (*C.JNIEnv)(unsafe.Pointer(jniEnv)) // not a Go heap pointer + C.deletePrevCtx(env, C.jobject(ctx)) + return nil + }) + } currentCtx = (C.jobject)(ctx) } From 500568ffaa9218362137b7f935510fcb9e46b0ee Mon Sep 17 00:00:00 2001 From: MatejMagat305 <61238240+MatejMagat305@users.noreply.github.com> Date: Fri, 21 Jul 2023 16:45:11 +0200 Subject: [PATCH 07/23] quit --- internal/driver/mobile/driver.go | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/internal/driver/mobile/driver.go b/internal/driver/mobile/driver.go index 32ef317b54..77b0e725f6 100644 --- a/internal/driver/mobile/driver.go +++ b/internal/driver/mobile/driver.go @@ -7,7 +7,6 @@ import ( "fyne.io/fyne/v2" "fyne.io/fyne/v2/canvas" - "fyne.io/fyne/v2/driver/mobile" "fyne.io/fyne/v2/internal" "fyne.io/fyne/v2/internal/animation" intapp "fyne.io/fyne/v2/internal/app" @@ -23,7 +22,6 @@ import ( "fyne.io/fyne/v2/internal/driver/mobile/gl" "fyne.io/fyne/v2/internal/painter" pgl "fyne.io/fyne/v2/internal/painter/gl" - "fyne.io/fyne/v2/internal/scale" "fyne.io/fyne/v2/theme" ) @@ -128,11 +126,8 @@ func (d *mobileDriver) AbsolutePositionForObject(co fyne.CanvasObject) fyne.Posi return pos.Subtract(inset) } -func (d *mobileDriver) GoBack() { - app.GoBack() -} - func (d *mobileDriver) Quit() { + app.Finish() // Android and iOS guidelines say this should not be allowed! } @@ -294,9 +289,13 @@ func (d *mobileDriver) paintWindow(window fyne.Window, size fyne.Size) { inner := clips.Push(pos, obj.Size()) c.Painter().StartClipping(inner.Rect()) } + + if size.Width <= 0 || size.Height <= 0 { // iconifying on Windows can do bad things + return + } c.Painter().Paint(obj, pos, size) } - afterDraw := func(node *common.RenderCacheNode, pos fyne.Position) { + afterDraw := func(node *common.RenderCacheNode) { if _, ok := node.Obj().(fyne.Scrollable); ok { c.Painter().StopClipping() clips.Pop() @@ -304,10 +303,6 @@ func (d *mobileDriver) paintWindow(window fyne.Window, size fyne.Size) { c.Painter().StartClipping(top.Rect()) } } - - if c.debug { - c.DrawDebugOverlay(node.Obj(), pos, size) - } } c.WalkTrees(draw, afterDraw) @@ -336,16 +331,16 @@ func (d *mobileDriver) setTheme(dark bool) { } func (d *mobileDriver) tapDownCanvas(w *window, x, y float32, tapID touch.Sequence) { - tapX := scale.ToFyneCoordinate(w.canvas, int(x)) - tapY := scale.ToFyneCoordinate(w.canvas, int(y)) + tapX := internal.UnscaleInt(w.canvas, int(x)) + tapY := internal.UnscaleInt(w.canvas, int(y)) pos := fyne.NewPos(tapX, tapY+tapYOffset) w.canvas.tapDown(pos, int(tapID)) } func (d *mobileDriver) tapMoveCanvas(w *window, x, y float32, tapID touch.Sequence) { - tapX := scale.ToFyneCoordinate(w.canvas, int(x)) - tapY := scale.ToFyneCoordinate(w.canvas, int(y)) + tapX := internal.UnscaleInt(w.canvas, int(x)) + tapY := internal.UnscaleInt(w.canvas, int(y)) pos := fyne.NewPos(tapX, tapY+tapYOffset) w.canvas.tapMove(pos, int(tapID), func(wid fyne.Draggable, ev *fyne.DragEvent) { @@ -354,8 +349,8 @@ func (d *mobileDriver) tapMoveCanvas(w *window, x, y float32, tapID touch.Sequen } func (d *mobileDriver) tapUpCanvas(w *window, x, y float32, tapID touch.Sequence) { - tapX := scale.ToFyneCoordinate(w.canvas, int(x)) - tapY := scale.ToFyneCoordinate(w.canvas, int(y)) + tapX := internal.UnscaleInt(w.canvas, int(x)) + tapY := internal.UnscaleInt(w.canvas, int(y)) pos := fyne.NewPos(tapX, tapY+tapYOffset) w.canvas.tapUp(pos, int(tapID), func(wid fyne.Tappable, ev *fyne.PointEvent) { @@ -459,8 +454,6 @@ var keyCodeMap = map[key.Code]fyne.KeyName{ key.CodeBackslash: fyne.KeyBackslash, key.CodeRightSquareBracket: fyne.KeyRightBracket, key.CodeGraveAccent: fyne.KeyBackTick, - - key.CodeBackButton: mobile.KeyBack, } func keyToName(code key.Code) fyne.KeyName { From a1620c5dd5a62209de17591c1e71a35bf481cab6 Mon Sep 17 00:00:00 2001 From: MatejMagat305 <61238240+MatejMagat305@users.noreply.github.com> Date: Fri, 21 Jul 2023 17:22:50 +0200 Subject: [PATCH 08/23] delete global --- internal/driver/mobile/app/android.c | 4 ++++ internal/driver/mobile/app/android.go | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/internal/driver/mobile/app/android.c b/internal/driver/mobile/app/android.c index a8d37358d6..c369082a7e 100644 --- a/internal/driver/mobile/app/android.c +++ b/internal/driver/mobile/app/android.c @@ -81,6 +81,10 @@ void set_global(ANativeActivity *activity){ setCurrentContext(activity->vm, (*env)->NewGlobalRef(env, activity->clazz)); } +void delete_ref(ANativeActivity *activity){ + (*env)->DeleteGlobalRef(activity->env, current_class); +} + // Entry point from our subclassed NativeActivity. // // By here, the Go runtime has been initialized (as we are running in diff --git a/internal/driver/mobile/app/android.go b/internal/driver/mobile/app/android.go index e1ae5d0a97..86172a8ba7 100644 --- a/internal/driver/mobile/app/android.go +++ b/internal/driver/mobile/app/android.go @@ -50,6 +50,7 @@ void showFileOpen(JNIEnv* env, char* mimes); void showFileSave(JNIEnv* env, char* mimes, char* filename); void finish(JNIEnv* env, jobject ctx); void set_global(ANativeActivity *activity); +void delete_ref(ANativeActivity *activity); void Java_org_golang_app_GoNativeActivity_filePickerReturned(JNIEnv *env, jclass clazz, jstring str); */ @@ -137,10 +138,12 @@ func onSaveInstanceState(activity *C.ANativeActivity, outSize *C.size_t) unsafe. //export onPause func onPause(activity *C.ANativeActivity) { + C.delete_ref(activity) } //export onStop func onStop(activity *C.ANativeActivity) { + C.delete_ref(activity) } //export onCreate @@ -155,6 +158,7 @@ func onCreate(activity *C.ANativeActivity) { //export onDestroy func onDestroy(activity *C.ANativeActivity) { + C.delete_ref(activity) activityDestroyed <- struct{}{} } @@ -595,7 +599,7 @@ func processKey(env *C.JNIEnv, e *C.AInputEvent) int { keyCode := C.AKeyEvent_getKeyCode(e) if (keyCode == C.AKEYCODE_BACK) { println("back ok") - return 0 // Handle back button press and return handle + return 1 // Handle back button press and return handle } else if (keyCode == C.AKEYCODE_MENU) { return 1 // Handle menu button press } From 141a9e427f3e69d19606f17160f446d0ead46da6 Mon Sep 17 00:00:00 2001 From: MatejMagat305 <61238240+MatejMagat305@users.noreply.github.com> Date: Fri, 21 Jul 2023 17:41:03 +0200 Subject: [PATCH 09/23] fix careless --- internal/driver/mobile/app/android.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/driver/mobile/app/android.c b/internal/driver/mobile/app/android.c index c369082a7e..5e417114b8 100644 --- a/internal/driver/mobile/app/android.c +++ b/internal/driver/mobile/app/android.c @@ -82,7 +82,9 @@ void set_global(ANativeActivity *activity){ } void delete_ref(ANativeActivity *activity){ - (*env)->DeleteGlobalRef(activity->env, current_class); + if (current_class != NULL) + (*env)->DeleteGlobalRef(activity->env, current_class); + current_class = NULL; } // Entry point from our subclassed NativeActivity. From e7d986557e58395c89b3f93f62cb8736bdca2c69 Mon Sep 17 00:00:00 2001 From: MatejMagat305 <61238240+MatejMagat305@users.noreply.github.com> Date: Fri, 21 Jul 2023 17:43:51 +0200 Subject: [PATCH 10/23] Add files via upload --- internal/driver/mobile/app/android.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/driver/mobile/app/android.c b/internal/driver/mobile/app/android.c index 5e417114b8..5ee5ba76f2 100644 --- a/internal/driver/mobile/app/android.c +++ b/internal/driver/mobile/app/android.c @@ -82,8 +82,10 @@ void set_global(ANativeActivity *activity){ } void delete_ref(ANativeActivity *activity){ - if (current_class != NULL) + if (current_class != NULL){ + JNIEnv* env = activity->env; (*env)->DeleteGlobalRef(activity->env, current_class); + } current_class = NULL; } From e5699680f45009d628673004b4e907294b32930d Mon Sep 17 00:00:00 2001 From: MatejMagat305 <61238240+MatejMagat305@users.noreply.github.com> Date: Fri, 21 Jul 2023 17:52:27 +0200 Subject: [PATCH 11/23] global ref set only on begin --- internal/driver/mobile/app/android.c | 13 +++++-------- internal/driver/mobile/app/android.go | 6 ------ 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/internal/driver/mobile/app/android.c b/internal/driver/mobile/app/android.c index 5ee5ba76f2..77e956cc1c 100644 --- a/internal/driver/mobile/app/android.c +++ b/internal/driver/mobile/app/android.c @@ -69,6 +69,11 @@ static int main_running = 0; void set_global(ANativeActivity *activity){ JNIEnv* env = activity->env; // Note that activity->clazz is mis-named. + + if (current_class != NULL){ + JNIEnv* env = activity->env; + (*env)->DeleteGlobalRef(activity->env, current_class); + } current_class = (*env)->GetObjectClass(env, activity->clazz); current_class = (*env)->NewGlobalRef(env, current_class); key_rune_method = find_static_method(env, current_class, "getRune", "(III)I"); @@ -81,14 +86,6 @@ void set_global(ANativeActivity *activity){ setCurrentContext(activity->vm, (*env)->NewGlobalRef(env, activity->clazz)); } -void delete_ref(ANativeActivity *activity){ - if (current_class != NULL){ - JNIEnv* env = activity->env; - (*env)->DeleteGlobalRef(activity->env, current_class); - } - current_class = NULL; -} - // Entry point from our subclassed NativeActivity. // // By here, the Go runtime has been initialized (as we are running in diff --git a/internal/driver/mobile/app/android.go b/internal/driver/mobile/app/android.go index 86172a8ba7..e0f69a192e 100644 --- a/internal/driver/mobile/app/android.go +++ b/internal/driver/mobile/app/android.go @@ -50,7 +50,6 @@ void showFileOpen(JNIEnv* env, char* mimes); void showFileSave(JNIEnv* env, char* mimes, char* filename); void finish(JNIEnv* env, jobject ctx); void set_global(ANativeActivity *activity); -void delete_ref(ANativeActivity *activity); void Java_org_golang_app_GoNativeActivity_filePickerReturned(JNIEnv *env, jclass clazz, jstring str); */ @@ -123,12 +122,10 @@ func callMain(mainPC uintptr) { //export onStart func onStart(activity *C.ANativeActivity) { - C.set_global(activity) } //export onResume func onResume(activity *C.ANativeActivity) { - C.set_global(activity) } //export onSaveInstanceState @@ -138,12 +135,10 @@ func onSaveInstanceState(activity *C.ANativeActivity, outSize *C.size_t) unsafe. //export onPause func onPause(activity *C.ANativeActivity) { - C.delete_ref(activity) } //export onStop func onStop(activity *C.ANativeActivity) { - C.delete_ref(activity) } //export onCreate @@ -158,7 +153,6 @@ func onCreate(activity *C.ANativeActivity) { //export onDestroy func onDestroy(activity *C.ANativeActivity) { - C.delete_ref(activity) activityDestroyed <- struct{}{} } From c4d193150f349b4b592660acd061723819f04a89 Mon Sep 17 00:00:00 2001 From: MatejMagat305 <61238240+MatejMagat305@users.noreply.github.com> Date: Fri, 21 Jul 2023 18:02:34 +0200 Subject: [PATCH 12/23] fix mistakes ... From ebab39e2a057c3aa92ba0823efdfb552ef31e4e0 Mon Sep 17 00:00:00 2001 From: MatejMagat305 <61238240+MatejMagat305@users.noreply.github.com> Date: Fri, 21 Jul 2023 18:06:28 +0200 Subject: [PATCH 13/23] reset ctx when start and resume --- internal/driver/mobile/app/android.c | 12 ++++-------- internal/driver/mobile/app/android.go | 3 +++ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/internal/driver/mobile/app/android.c b/internal/driver/mobile/app/android.c index 77e956cc1c..645909b7ee 100644 --- a/internal/driver/mobile/app/android.c +++ b/internal/driver/mobile/app/android.c @@ -68,12 +68,10 @@ static int main_running = 0; void set_global(ANativeActivity *activity){ JNIEnv* env = activity->env; - // Note that activity->clazz is mis-named. - if (current_class != NULL){ - JNIEnv* env = activity->env; - (*env)->DeleteGlobalRef(activity->env, current_class); - } + (*env)->DeleteGlobalRef(activity->env, current_class); + } + // Note that activity->clazz is mis-named. current_class = (*env)->GetObjectClass(env, activity->clazz); current_class = (*env)->NewGlobalRef(env, current_class); key_rune_method = find_static_method(env, current_class, "getRune", "(III)I"); @@ -82,7 +80,6 @@ void set_global(ANativeActivity *activity){ show_file_open_method = find_static_method(env, current_class, "showFileOpen", "(Ljava/lang/String;)V"); show_file_save_method = find_static_method(env, current_class, "showFileSave", "(Ljava/lang/String;Ljava/lang/String;)V"); finish_method = find_method(env, current_class, "finish", "()V"); - setCurrentContext(activity->vm, (*env)->NewGlobalRef(env, activity->clazz)); } @@ -97,8 +94,7 @@ void set_global(ANativeActivity *activity){ void ANativeActivity_onCreate(ANativeActivity *activity, void* savedState, size_t savedStateSize) { if (!main_running) { JNIEnv* env = activity->env; - - set_global(activity); + set_global(activity); // useless? OnStart? // Set FILESDIR if (setenv("FILESDIR", activity->internalDataPath, 1) != 0) { diff --git a/internal/driver/mobile/app/android.go b/internal/driver/mobile/app/android.go index e0f69a192e..6bbdcf2e18 100644 --- a/internal/driver/mobile/app/android.go +++ b/internal/driver/mobile/app/android.go @@ -122,10 +122,12 @@ func callMain(mainPC uintptr) { //export onStart func onStart(activity *C.ANativeActivity) { + C.set_global(activity) } //export onResume func onResume(activity *C.ANativeActivity) { + C.set_global(activity) } //export onSaveInstanceState @@ -214,6 +216,7 @@ func Finish() { return nil }) } + func windowConfigRead(activity *C.ANativeActivity) windowConfig { aconfig := C.AConfiguration_new() C.AConfiguration_fromAssetManager(aconfig, activity.assetManager) From 3f35008e8ed4d77061bd5666a2c5dc2a3ad27864 Mon Sep 17 00:00:00 2001 From: MatejMagat305 <61238240+MatejMagat305@users.noreply.github.com> Date: Sat, 22 Jul 2023 19:15:43 +0200 Subject: [PATCH 14/23] fix unwanted change --- internal/driver/mobile/driver.go | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/internal/driver/mobile/driver.go b/internal/driver/mobile/driver.go index 77b0e725f6..3fae9b7390 100644 --- a/internal/driver/mobile/driver.go +++ b/internal/driver/mobile/driver.go @@ -7,6 +7,7 @@ import ( "fyne.io/fyne/v2" "fyne.io/fyne/v2/canvas" + "fyne.io/fyne/v2/driver/mobile" "fyne.io/fyne/v2/internal" "fyne.io/fyne/v2/internal/animation" intapp "fyne.io/fyne/v2/internal/app" @@ -22,6 +23,7 @@ import ( "fyne.io/fyne/v2/internal/driver/mobile/gl" "fyne.io/fyne/v2/internal/painter" pgl "fyne.io/fyne/v2/internal/painter/gl" + "fyne.io/fyne/v2/internal/scale" "fyne.io/fyne/v2/theme" ) @@ -289,13 +291,9 @@ func (d *mobileDriver) paintWindow(window fyne.Window, size fyne.Size) { inner := clips.Push(pos, obj.Size()) c.Painter().StartClipping(inner.Rect()) } - - if size.Width <= 0 || size.Height <= 0 { // iconifying on Windows can do bad things - return - } c.Painter().Paint(obj, pos, size) } - afterDraw := func(node *common.RenderCacheNode) { + afterDraw := func(node *common.RenderCacheNode, pos fyne.Position) { if _, ok := node.Obj().(fyne.Scrollable); ok { c.Painter().StopClipping() clips.Pop() @@ -303,6 +301,10 @@ func (d *mobileDriver) paintWindow(window fyne.Window, size fyne.Size) { c.Painter().StartClipping(top.Rect()) } } + + if c.debug { + c.DrawDebugOverlay(node.Obj(), pos, size) + } } c.WalkTrees(draw, afterDraw) @@ -331,16 +333,16 @@ func (d *mobileDriver) setTheme(dark bool) { } func (d *mobileDriver) tapDownCanvas(w *window, x, y float32, tapID touch.Sequence) { - tapX := internal.UnscaleInt(w.canvas, int(x)) - tapY := internal.UnscaleInt(w.canvas, int(y)) + tapX := scale.ToFyneCoordinate(w.canvas, int(x)) + tapY := scale.ToFyneCoordinate(w.canvas, int(y)) pos := fyne.NewPos(tapX, tapY+tapYOffset) w.canvas.tapDown(pos, int(tapID)) } func (d *mobileDriver) tapMoveCanvas(w *window, x, y float32, tapID touch.Sequence) { - tapX := internal.UnscaleInt(w.canvas, int(x)) - tapY := internal.UnscaleInt(w.canvas, int(y)) + tapX := scale.ToFyneCoordinate(w.canvas, int(x)) + tapY := scale.ToFyneCoordinate(w.canvas, int(y)) pos := fyne.NewPos(tapX, tapY+tapYOffset) w.canvas.tapMove(pos, int(tapID), func(wid fyne.Draggable, ev *fyne.DragEvent) { @@ -349,8 +351,8 @@ func (d *mobileDriver) tapMoveCanvas(w *window, x, y float32, tapID touch.Sequen } func (d *mobileDriver) tapUpCanvas(w *window, x, y float32, tapID touch.Sequence) { - tapX := internal.UnscaleInt(w.canvas, int(x)) - tapY := internal.UnscaleInt(w.canvas, int(y)) + tapX := scale.ToFyneCoordinate(w.canvas, int(x)) + tapY := scale.ToFyneCoordinate(w.canvas, int(y)) pos := fyne.NewPos(tapX, tapY+tapYOffset) w.canvas.tapUp(pos, int(tapID), func(wid fyne.Tappable, ev *fyne.PointEvent) { @@ -454,6 +456,8 @@ var keyCodeMap = map[key.Code]fyne.KeyName{ key.CodeBackslash: fyne.KeyBackslash, key.CodeRightSquareBracket: fyne.KeyRightBracket, key.CodeGraveAccent: fyne.KeyBackTick, + + key.CodeBackButton: mobile.KeyBack, } func keyToName(code key.Code) fyne.KeyName { From 403f8d7a36f6920ab476c3c43f4d28c0646aa2da Mon Sep 17 00:00:00 2001 From: MatejMagat305 <61238240+MatejMagat305@users.noreply.github.com> Date: Sat, 22 Jul 2023 19:19:34 +0200 Subject: [PATCH 15/23] Update x11.go --- internal/driver/mobile/app/x11.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/driver/mobile/app/x11.go b/internal/driver/mobile/app/x11.go index 816ea0a17b..ebaec6a56a 100644 --- a/internal/driver/mobile/app/x11.go +++ b/internal/driver/mobile/app/x11.go @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build linux && !android -// +build linux,!android +//go:build (linux && !android) || freebsd +// +build linux,!android freebsd package app From 01ca68b4ad9af64ade47f1782ff9056231dd354b Mon Sep 17 00:00:00 2001 From: MatejMagat305 <61238240+MatejMagat305@users.noreply.github.com> Date: Sat, 22 Jul 2023 19:23:28 +0200 Subject: [PATCH 16/23] Update android.c --- internal/driver/mobile/app/android.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/internal/driver/mobile/app/android.c b/internal/driver/mobile/app/android.c index 645909b7ee..a0c5d2efba 100644 --- a/internal/driver/mobile/app/android.c +++ b/internal/driver/mobile/app/android.c @@ -95,7 +95,6 @@ void ANativeActivity_onCreate(ANativeActivity *activity, void* savedState, size_ if (!main_running) { JNIEnv* env = activity->env; set_global(activity); // useless? OnStart? - // Set FILESDIR if (setenv("FILESDIR", activity->internalDataPath, 1) != 0) { LOG_INFO("setenv(\"FILESDIR\", \"%s\", 1) failed: %d", activity->internalDataPath, errno); @@ -166,13 +165,6 @@ static char* initEGLDisplay() { return NULL; } -void finish(JNIEnv* env, jobject ctx) { - (*env)->CallVoidMethod( - env, - ctx, - finish_method); -} - char* createEGLSurface(ANativeWindow* window) { char* err; EGLint numConfigs, format; @@ -219,6 +211,13 @@ char* destroyEGLSurface() { return NULL; } +void finish(JNIEnv* env, jobject ctx) { + (*env)->CallVoidMethod( + env, + ctx, + finish_method); +} + int32_t getKeyRune(JNIEnv* env, AInputEvent* e) { return (int32_t)(*env)->CallStaticIntMethod( env, From c3ed183e870297bdec2c689f54837e5fac58e5b1 Mon Sep 17 00:00:00 2001 From: MatejMagat305 <61238240+MatejMagat305@users.noreply.github.com> Date: Sat, 22 Jul 2023 19:26:08 +0200 Subject: [PATCH 17/23] Update x11.go --- internal/driver/mobile/app/x11.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/driver/mobile/app/x11.go b/internal/driver/mobile/app/x11.go index ebaec6a56a..c86f48bdec 100644 --- a/internal/driver/mobile/app/x11.go +++ b/internal/driver/mobile/app/x11.go @@ -78,9 +78,9 @@ func main(f func(App)) { } } } -func Finish() { -} +func Finish() {} + //export onResize func onResize(w, h int) { // TODO(nigeltao): don't assume 72 DPI. DisplayWidth and DisplayWidthMM From 181dd7a7ac448dfd177ab7cbe070b386b9a4f734 Mon Sep 17 00:00:00 2001 From: MatejMagat305 <61238240+MatejMagat305@users.noreply.github.com> Date: Sat, 22 Jul 2023 19:28:03 +0200 Subject: [PATCH 18/23] Update shiny.go --- internal/driver/mobile/app/shiny.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/internal/driver/mobile/app/shiny.go b/internal/driver/mobile/app/shiny.go index 8784215080..3012b07255 100644 --- a/internal/driver/mobile/app/shiny.go +++ b/internal/driver/mobile/app/shiny.go @@ -15,8 +15,7 @@ func main(f func(a App)) { fmt.Errorf("Running mobile simulation mode does not currently work on Windows.") } -func GoBack() { - // When simulating mobile there are no other activities open (and we can't just force background) +func Finish() { // When simulating mobile there are no other activities open (and we can't just force background) } // driverShowVirtualKeyboard does nothing on desktop From 92511ae90eb9d701b6d0d3eef333ae2c4ccef4d1 Mon Sep 17 00:00:00 2001 From: MatejMagat305 <61238240+MatejMagat305@users.noreply.github.com> Date: Sat, 22 Jul 2023 19:29:14 +0200 Subject: [PATCH 19/23] Update darwin_ios.go --- internal/driver/mobile/app/darwin_ios.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/driver/mobile/app/darwin_ios.go b/internal/driver/mobile/app/darwin_ios.go index f59547b084..dd5860d67e 100644 --- a/internal/driver/mobile/app/darwin_ios.go +++ b/internal/driver/mobile/app/darwin_ios.go @@ -146,9 +146,9 @@ func updateConfig(width, height, orientation int32) { } theApp.events.In() <- paint.Event{External: true} } -func Finish() { -} +func Finish() {} + // touchIDs is the current active touches. The position in the array // is the ID, the value is the UITouch* pointer value. // From c0382f059ee4b03c44f0da1a1dfec562b7ce9934 Mon Sep 17 00:00:00 2001 From: MatejMagat305 <61238240+MatejMagat305@users.noreply.github.com> Date: Sat, 22 Jul 2023 19:30:04 +0200 Subject: [PATCH 20/23] Update darwin_desktop.go --- internal/driver/mobile/app/darwin_desktop.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/driver/mobile/app/darwin_desktop.go b/internal/driver/mobile/app/darwin_desktop.go index 35ac0ea571..d34a522a3e 100644 --- a/internal/driver/mobile/app/darwin_desktop.go +++ b/internal/driver/mobile/app/darwin_desktop.go @@ -103,9 +103,9 @@ func (a *app) loop(ctx C.GLintptr) { } } } -func Finish() { -} +func Finish() {} + var drawDone = make(chan struct{}) // drawgl is used by Cocoa to occasionally request screen updates. From 30c10c58d5e8cee637e944edb97c7a92cc5f086c Mon Sep 17 00:00:00 2001 From: MatejMagat305 <61238240+MatejMagat305@users.noreply.github.com> Date: Sat, 22 Jul 2023 20:07:57 +0200 Subject: [PATCH 21/23] Update android.go --- internal/driver/mobile/app/android.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/internal/driver/mobile/app/android.go b/internal/driver/mobile/app/android.go index 6bbdcf2e18..d7f1707631 100644 --- a/internal/driver/mobile/app/android.go +++ b/internal/driver/mobile/app/android.go @@ -143,6 +143,18 @@ func onPause(activity *C.ANativeActivity) { func onStop(activity *C.ANativeActivity) { } +func onBackPressed() { + k := key.Event{ + Code: key.CodeBackButton, + Direction: key.DirPress, + } + log.Println("Logging key event back") + theApp.events.In() <- k + + k.Direction = key.DirRelease + theApp.events.In() <- k +} + //export onCreate func onCreate(activity *C.ANativeActivity) { // Set the initial configuration. @@ -596,6 +608,7 @@ func processKey(env *C.JNIEnv, e *C.AInputEvent) int { keyCode := C.AKeyEvent_getKeyCode(e) if (keyCode == C.AKEYCODE_BACK) { println("back ok") + go onBackPressed() return 1 // Handle back button press and return handle } else if (keyCode == C.AKEYCODE_MENU) { return 1 // Handle menu button press From dafa6aa59ba0fa348e221d01f339f770b87c278f Mon Sep 17 00:00:00 2001 From: MatejMagat305 <61238240+MatejMagat305@users.noreply.github.com> Date: Sat, 22 Jul 2023 20:10:26 +0200 Subject: [PATCH 22/23] Update GoNativeActivity.java --- internal/driver/mobile/app/GoNativeActivity.java | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/internal/driver/mobile/app/GoNativeActivity.java b/internal/driver/mobile/app/GoNativeActivity.java index 866f3246bd..06f6442533 100644 --- a/internal/driver/mobile/app/GoNativeActivity.java +++ b/internal/driver/mobile/app/GoNativeActivity.java @@ -43,7 +43,6 @@ public class GoNativeActivity extends NativeActivity { private native void insetsChanged(int top, int bottom, int left, int right); private native void keyboardTyped(String str); private native void keyboardDelete(); - private native void backPressed(); private native void setDarkMode(boolean dark); private EditText mTextEdit; @@ -314,21 +313,6 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) { filePickerReturned(uri.toString()); } - @Override - public void onBackPressed() { - // skip the default behaviour - we can call finishActivity if we want to go back - backPressed(); - } - - public void finishActivity() { - runOnUiThread(new Runnable() { - @Override - public void run() { - GoNativeActivity.super.onBackPressed(); - } - }); - } - @Override public void onConfigurationChanged(Configuration config) { super.onConfigurationChanged(config); From 94ec8cbf88d980023573ad189f1026b59a0047b9 Mon Sep 17 00:00:00 2001 From: MatejMagat305 <61238240+MatejMagat305@users.noreply.github.com> Date: Sat, 22 Jul 2023 20:17:06 +0200 Subject: [PATCH 23/23] Update x11.go --- internal/driver/mobile/app/x11.go | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/driver/mobile/app/x11.go b/internal/driver/mobile/app/x11.go index c86f48bdec..27ccf342fb 100644 --- a/internal/driver/mobile/app/x11.go +++ b/internal/driver/mobile/app/x11.go @@ -15,6 +15,7 @@ than screens with touch panels. /* #cgo LDFLAGS: -lEGL -lGLESv2 -lX11 +#cgo freebsd CFLAGS: -I/usr/local/include/ void createWindow(void); void processEvents(void);