diff --git a/src/main-executable/main.c b/src/main-executable/main.c index ec36b370..7cad57fe 100644 --- a/src/main-executable/main.c +++ b/src/main-executable/main.c @@ -554,6 +554,15 @@ static void open(GtkApplication *app, GFile **files, gint nfiles, const gchar *h if (GDK_IS_WAYLAND_TOPLEVEL(toplevel)) { gdk_wayland_toplevel_set_application_id(GDK_WAYLAND_TOPLEVEL(toplevel), package_name); } + GdkMonitor *monitor = gdk_display_get_monitor_at_surface(gdk_display_get_default(), GDK_SURFACE(toplevel)); + GdkRectangle monitor_geometry; + gdk_monitor_get_geometry(monitor, &monitor_geometry); + jobject resources = _GET_STATIC_OBJ_FIELD(handle_cache.context.class, "r", "Landroid/content/res/Resources;"); + jobject configuration = _GET_OBJ_FIELD(resources, "mConfiguration", "Landroid/content/res/Configuration;"); + if (monitor_geometry.width >= 800 && monitor_geometry.height >= 800) + _SET_INT_FIELD(configuration, "screenLayout", /*SCREENLAYOUT_SIZE_LARGE*/ 0x03); + else + _SET_INT_FIELD(configuration, "screenLayout", /*SCREENLAYOUT_SIZE_NORMAL*/ 0x02); if (app_icon_path) { char *app_icon_path_full = malloc(strlen(app_data_dir) + 1 + strlen(app_icon_path) + 1); // +1 for /, +1 for NULL