You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
allocate transparent {WrapperWidget / JavaWidget} 0x0 and draw children in overflow area
This prevents overlay widgets from blocking touch events. Androids ViewGroup.dispatchTouchEvent() loops over all children and only breaks if an eventhandler returns true. Gtk on the other hand stops at the first sensitive child. Even if the eventhandler returned false.
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include "../generated_headers/android_view_View.h"
|
||||
|
||||
#include "WrapperWidget.h"
|
||||
#include "src/api-impl-jni/views/AndroidLayout.h"
|
||||
|
||||
G_DEFINE_TYPE(WrapperWidget, wrapper_widget, GTK_TYPE_WIDGET)
|
||||
|
||||
@@ -68,6 +69,10 @@ void wrapper_widget_measure(GtkWidget *widget, GtkOrientation orientation, int f
|
||||
void wrapper_widget_allocate(GtkWidget *widget, int width, int height, int baseline)
|
||||
{
|
||||
WrapperWidget *wrapper = WRAPPER_WIDGET(widget);
|
||||
if (!width && !height) {
|
||||
width = wrapper->real_width;
|
||||
height = wrapper->real_height;
|
||||
}
|
||||
GtkAllocation allocation = {
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
@@ -89,7 +94,21 @@ void wrapper_widget_allocate(GtkWidget *widget, int width, int height, int basel
|
||||
allocation.y = -(*env)->CallIntMethod(env, wrapper->jobj, handle_cache.view.getScrollY);
|
||||
}
|
||||
|
||||
gtk_widget_size_allocate(wrapper->child, &allocation, baseline);
|
||||
if (ATL_IS_ANDROID_LAYOUT(gtk_widget_get_layout_manager(wrapper->child))) {
|
||||
AndroidLayout *layout = ATL_ANDROID_LAYOUT(gtk_widget_get_layout_manager(wrapper->child));
|
||||
if (layout->real_width != width || layout->real_height != height) {
|
||||
layout->real_width = width;
|
||||
layout->real_height = height;
|
||||
if (!layout->needs_allocation)
|
||||
gtk_widget_queue_allocate(wrapper->child);
|
||||
}
|
||||
if (layout->needs_allocation)
|
||||
gtk_widget_size_allocate(wrapper->child, &allocation, baseline);
|
||||
else
|
||||
gtk_widget_size_allocate(wrapper->child, &(GtkAllocation){.x = allocation.x, .y = allocation.y}, baseline);
|
||||
} else {
|
||||
gtk_widget_size_allocate(wrapper->child, &allocation, baseline);
|
||||
}
|
||||
if (wrapper->sk_area)
|
||||
gtk_widget_size_allocate(wrapper->sk_area, &allocation, baseline);
|
||||
if (wrapper->background)
|
||||
@@ -184,6 +203,7 @@ void wrapper_widget_set_jobject(WrapperWidget *wrapper, JNIEnv *env, jobject job
|
||||
|
||||
g_signal_connect(controller, "released", G_CALLBACK(on_click), _REF(jobj));
|
||||
gtk_widget_add_controller(wrapper->child, controller);
|
||||
widget_set_needs_allocation(wrapper->child);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,9 @@ struct _WrapperWidget
|
||||
jmethodID computeScroll_method;
|
||||
int layout_width;
|
||||
int layout_height;
|
||||
int real_width;
|
||||
int real_height;
|
||||
gboolean needs_allocation;
|
||||
};
|
||||
|
||||
struct _WrapperWidgetClass
|
||||
|
||||
Reference in New Issue
Block a user