From 34858d2fa68a6d5a63279f293cfc9c0183efa6a9 Mon Sep 17 00:00:00 2001 From: Mis012 Date: Mon, 9 Jan 2023 14:50:17 +0100 Subject: [PATCH] remove incorrect offset correction from GLSurfaceView; handle ATL_DISABLE_WINDOW_DECORATIONS env --- .../widgets/android_opengl_GLSurfaceView.c | 28 +++++++++---------- src/main-executable/main.c | 3 ++ 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/api-impl-jni/widgets/android_opengl_GLSurfaceView.c b/src/api-impl-jni/widgets/android_opengl_GLSurfaceView.c index a0058840..2c2d5fd4 100644 --- a/src/api-impl-jni/widgets/android_opengl_GLSurfaceView.c +++ b/src/api-impl-jni/widgets/android_opengl_GLSurfaceView.c @@ -164,6 +164,20 @@ static void check_program_link_error(GLuint program) struct jni_gl_callback_data { JavaVM *jvm; jobject this; jobject renderer; bool first_time;}; static void on_realize(GtkGLArea *gl_area, struct jni_gl_callback_data *d) { +// --- + // compensate for offset between the widget coordinates and the surface coordinates + double off_x; + double off_y; + + GtkWidget *window = GTK_WIDGET(gtk_widget_get_native(gl_area)); + gtk_native_get_surface_transform(GTK_NATIVE(window), &off_x, &off_y); + + FIXME__WIDTH -= off_x; + FIXME__HEIGHT -= off_y; +// --- + + + gtk_gl_area_make_current(gl_area); struct render_priv *render_priv = g_object_get_data(G_OBJECT(gl_area), "render_priv"); @@ -435,20 +449,6 @@ static void call_ontouch_callback(GtkEventControllerLegacy* event_controller, in JNIEnv *env; (*d->jvm)->GetEnv(d->jvm, (void**)&env, JNI_VERSION_1_6); - // translate to the GLSurfaceArea widget's coordinates, since that's what the app expects - - double off_x; - double off_y; - - GtkWidget *gl_area = gtk_event_controller_get_widget(event_controller); - GtkWidget *window = GTK_WIDGET(gtk_widget_get_native(gl_area)); - - // compensate for offset between the widget coordinates and the surface coordinates - gtk_native_get_surface_transform(GTK_NATIVE(window), &off_x, &off_y); - x -= off_x; - y -= off_y; - gtk_widget_translate_coordinates(window, gl_area, x, y, &x, &y); - // execute the Java callback function jobject motion_event = (*env)->NewObject(env, handle_cache.motion_event.class, handle_cache.motion_event.constructor, action, (float)x, (float)y); diff --git a/src/main-executable/main.c b/src/main-executable/main.c index 9509c1d4..9c6f8cb7 100644 --- a/src/main-executable/main.c +++ b/src/main-executable/main.c @@ -310,6 +310,9 @@ static void open(GtkApplication *app, GFile** files, gint nfiles, const gchar* h // TODO: set icon according to how android gets it for the purposes of displaying it in the launcher // gtk_window_set_icon_name(window, "weather-clear"); + if(getenv("ATL_DISABLE_WINDOW_DECORATIONS")) + gtk_window_set_decorated(GTK_WINDOW(window), 0); + gtk_widget_show(window); /* -- register our JNI library under the appropriate classloader -- */