android_layout_measure: reuse old MeasureSpec for missing dimension

This should fix the SurfaceView in NewPipe not resizing automatically
This commit is contained in:
Julian Winkler
2023-11-03 18:06:30 +01:00
parent 837ad31c3f
commit 385f6dcf0b
2 changed files with 12 additions and 3 deletions

View File

@@ -1,6 +1,7 @@
#include <gtk/gtk.h>
#include "../util.h"
#include "../defines.h"
#include "AndroidLayout.h"
static int make_measure_spec(int layout_size, int for_size)
@@ -26,6 +27,11 @@ static void android_layout_measure(GtkLayoutManager *layout_manager, GtkWidget *
int widthMeasureSpec = make_measure_spec(layout->width, orientation == GTK_ORIENTATION_VERTICAL ? for_size : -1);
int heightMeasureSpec = make_measure_spec(layout->height, orientation == GTK_ORIENTATION_HORIZONTAL ? for_size : -1);
// if layout params say match_parent, but GTK doesnt specify the dimension, fallback to old specification if available
if (widthMeasureSpec == -1)
widthMeasureSpec = _GET_INT_FIELD(layout->view, "oldWidthMeasureSpec");
if (heightMeasureSpec == -1)
heightMeasureSpec = _GET_INT_FIELD(layout->view, "oldHeightMeasureSpec");
if (widthMeasureSpec != -1 && heightMeasureSpec != -1) {
(*env)->CallVoidMethod(env, layout->view, handle_cache.view.measure, widthMeasureSpec, heightMeasureSpec);
if((*env)->ExceptionCheck(env))

View File

@@ -807,8 +807,8 @@ public class View extends Object {
public static HashMap<Integer, View> view_by_id = new HashMap<Integer, View>();
private int oldWidthMeasureSpec;
private int oldHeightMeasureSpec;
private int oldWidthMeasureSpec = -1;
private int oldHeightMeasureSpec = -1;
private boolean layoutRequested = true;
private int oldWidth;
private int oldHeight;
@@ -1237,6 +1237,9 @@ public class View extends Object {
public void requestLayout() {
layoutRequested = true;
if (parent != null && !parent.isLayoutRequested()) {
parent.requestLayout();
}
native_requestLayout(widget);
};
@@ -1302,7 +1305,7 @@ public class View extends Object {
public boolean isEnabled() {return true;}
public boolean hasFocus() {return false;}
public boolean isLayoutRequested() {return true;}
public boolean isLayoutRequested() {return layoutRequested;}
public int getBaseline() {return -1;}
public boolean hasFocusable() {return false;}
public boolean isFocused() {return false;}