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
ignore deprecation warnings for per-widget css, switch gtk_widget_translate_coordinates to gtk_widget_compute_point
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
#include <assert.h>
|
||||
#include <fcntl.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
@@ -173,8 +174,15 @@ static inline void make_touch_event(GdkEvent* event, GtkEventControllerLegacy* e
|
||||
// apps expect it to start at the top left of the area where child widgets get placed, so that
|
||||
// the top left of the window is the same as the top left of a single widget filling the entire window
|
||||
// while it's quite hacky, the following should realistically work for most if not all cases
|
||||
if(child = gtk_window_get_child(GTK_WINDOW(window)))
|
||||
gtk_widget_translate_coordinates(window, child, ainput_event->x, ainput_event->y, &ainput_event->x, &ainput_event->y);
|
||||
if((child = gtk_window_get_child(GTK_WINDOW(window)))) {
|
||||
int ret;
|
||||
graphene_point_t p;
|
||||
ret = gtk_widget_compute_point(window, child, &GRAPHENE_POINT_INIT(ainput_event->x, ainput_event->y), &p);
|
||||
assert(ret);
|
||||
|
||||
ainput_event->x = p.x;
|
||||
ainput_event->y = p.y;
|
||||
}
|
||||
|
||||
switch(gdk_event_get_event_type(event)) {
|
||||
case GDK_BUTTON_PRESS:
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
#define XR_USE_PLATFORM_EGL
|
||||
#include <openxr/openxr_platform.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
#include <jni.h>
|
||||
@@ -251,8 +252,9 @@ ANativeWindow * ANativeWindow_fromSurface(JNIEnv* env, jobject surface)
|
||||
int width;
|
||||
int height;
|
||||
|
||||
double pos_x;
|
||||
double pos_y;
|
||||
int ret;
|
||||
|
||||
graphene_point_t pos;
|
||||
double off_x;
|
||||
double off_y;
|
||||
|
||||
@@ -273,14 +275,15 @@ ANativeWindow * ANativeWindow_fromSurface(JNIEnv* env, jobject surface)
|
||||
|
||||
|
||||
// get position of the SurfaceView widget wrt the toplevel window
|
||||
gtk_widget_translate_coordinates(surface_view_widget, window, 0, 0, &pos_x, &pos_y);
|
||||
ret = gtk_widget_compute_point(surface_view_widget, window, &GRAPHENE_POINT_INIT(0, 0), &pos);
|
||||
assert(ret);
|
||||
// compensate for offset between the widget coordinates and the surface coordinates
|
||||
gtk_native_get_surface_transform(GTK_NATIVE(window), &off_x, &off_y);
|
||||
pos_x += off_x;
|
||||
pos_y += off_y;
|
||||
pos.x += off_x;
|
||||
pos.y += off_y;
|
||||
|
||||
printf("XXXXX: SurfaceView widget: %p (%s), width: %d, height: %d\n", surface_view_widget, gtk_widget_get_name(surface_view_widget), width, height);
|
||||
printf("XXXXX: SurfaceView widget: x: %lf, y: %lf\n", pos_x, pos_y);
|
||||
printf("XXXXX: SurfaceView widget: x: %lf, y: %lf\n", pos.x, pos.y);
|
||||
printf("XXXXX: native offset: x: %lf, y: %lf\n", off_x, off_y);
|
||||
|
||||
struct ANativeWindow *native_window = calloc(1, sizeof(struct ANativeWindow));
|
||||
@@ -306,7 +309,7 @@ ANativeWindow * ANativeWindow_fromSurface(JNIEnv* env, jobject surface)
|
||||
|
||||
struct wl_subsurface *subsurface = wl_subcompositor_get_subsurface(wl_subcompositor, wayland_surface, toplevel_surface);
|
||||
wl_subsurface_set_desync(subsurface);
|
||||
wl_subsurface_set_position(subsurface, pos_x, pos_y);
|
||||
wl_subsurface_set_position(subsurface, pos.x, pos.y);
|
||||
|
||||
struct wl_region *empty_region = wl_compositor_create_region(wl_compositor);
|
||||
wl_surface_set_input_region(wayland_surface, empty_region);
|
||||
|
||||
Reference in New Issue
Block a user