Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXi Yan2019-01-25 10:39:49 -0500
committerXi Yan2019-01-25 10:39:49 -0500
commitd120090e99d9a3249fdca7227321d867b1995b65 (patch)
treeca1f48b6425bdf2c3f8370bec0c89702045ce224
parentb039f55b1d5df8a3d866ae1233c543dd6ade1788 (diff)
downloadeclipse.platform.swt-d120090e99d9a3249fdca7227321d867b1995b65.tar.gz
eclipse.platform.swt-d120090e99d9a3249fdca7227321d867b1995b65.tar.xz
eclipse.platform.swt-d120090e99d9a3249fdca7227321d867b1995b65.zip
Bug 540675 - [GTK4] Adapt to sizing machinery changes
Replace gtK_widget_get_preferred_height_for_width/width_for_height with gtk_widget_measure for GTK4. Change-Id: If5133b5a17200d3e3f9b7f8bf234dfdbc3d0f21a Signed-off-by: Xi Yan <xixiyan@redhat.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c23
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java11
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java12
5 files changed, 46 insertions, 2 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c
index 0a79e11d58..753a70a0ae 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c
@@ -12676,6 +12676,29 @@ JNIEXPORT void JNICALL GTK_NATIVE(_1gtk_1widget_1map)
}
#endif
+#ifndef NO__1gtk_1widget_1measure
+JNIEXPORT void JNICALL GTK_NATIVE(_1gtk_1widget_1measure)
+ (JNIEnv *env, jclass that, jintLong arg0, jint arg1, jint arg2, jintArray arg3, jintArray arg4, jintArray arg5, jintArray arg6)
+{
+ jint *lparg3=NULL;
+ jint *lparg4=NULL;
+ jint *lparg5=NULL;
+ jint *lparg6=NULL;
+ GTK_NATIVE_ENTER(env, that, _1gtk_1widget_1measure_FUNC);
+ if (arg3) if ((lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL)) == NULL) goto fail;
+ if (arg4) if ((lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL)) == NULL) goto fail;
+ if (arg5) if ((lparg5 = (*env)->GetIntArrayElements(env, arg5, NULL)) == NULL) goto fail;
+ if (arg6) if ((lparg6 = (*env)->GetIntArrayElements(env, arg6, NULL)) == NULL) goto fail;
+ gtk_widget_measure((GtkWidget *)arg0, arg1, arg2, lparg3, lparg4, lparg5, lparg6);
+fail:
+ if (arg6 && lparg6) (*env)->ReleaseIntArrayElements(env, arg6, lparg6, 0);
+ if (arg5 && lparg5) (*env)->ReleaseIntArrayElements(env, arg5, lparg5, 0);
+ if (arg4 && lparg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0);
+ if (arg3 && lparg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
+ GTK_NATIVE_EXIT(env, that, _1gtk_1widget_1measure_FUNC);
+}
+#endif
+
#ifndef NO__1gtk_1widget_1mnemonic_1activate
JNIEXPORT jboolean JNICALL GTK_NATIVE(_1gtk_1widget_1mnemonic_1activate)
(JNIEnv *env, jclass that, jintLong arg0, jboolean arg1)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c
index cc4f8e54ea..0a29907f25 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c
@@ -1142,6 +1142,7 @@ char * GTK_nativeFunctionNames[] = {
"_1gtk_1widget_1input_1shape_1combine_1region",
"_1gtk_1widget_1is_1focus",
"_1gtk_1widget_1map",
+ "_1gtk_1widget_1measure",
"_1gtk_1widget_1mnemonic_1activate",
"_1gtk_1widget_1override_1background_1color",
"_1gtk_1widget_1override_1color",
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h
index 365dad3bfe..55b2013aed 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h
@@ -1140,6 +1140,7 @@ typedef enum {
_1gtk_1widget_1input_1shape_1combine_1region_FUNC,
_1gtk_1widget_1is_1focus_FUNC,
_1gtk_1widget_1map_FUNC,
+ _1gtk_1widget_1measure_FUNC,
_1gtk_1widget_1mnemonic_1activate_FUNC,
_1gtk_1widget_1override_1background_1color_FUNC,
_1gtk_1widget_1override_1color_FUNC,
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java
index 85c7601e21..04acb3d06f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java
@@ -8709,6 +8709,17 @@ public class GTK extends OS {
lock.unlock();
}
}
+ /** @param widget cast=(GtkWidget *) */
+ public static final native void _gtk_widget_measure(long /*int*/ widget, int orientation, int for_size, int[] minimum, int[] natural, int[] minimum_baseline, int[] natural_baseline);
+ /** [GTK4 only, if-def'd in os.h] */
+ public static final void gtk_widget_measure(long /*int*/ widget, int orientation, int for_size, int[] minimum, int[] natural, int[] minimum_baseline, int[] natural_baseline) {
+ lock.lock();
+ try {
+ _gtk_widget_measure(widget, orientation, for_size, minimum, natural, minimum_baseline, natural_baseline);
+ } finally {
+ lock.unlock();
+ }
+ }
/**
* @param widget cast=(GtkWidget *)
* @param group_cycling cast=(gboolean)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
index 9f3924b7c3..86e3fcbb9b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
@@ -835,10 +835,18 @@ Point computeNativeSize (long /*int*/ h, int wHint, int hHint, boolean changed)
} else if (wHint == SWT.DEFAULT || hHint == SWT.DEFAULT) {
int [] natural_size = new int [1];
if (wHint == SWT.DEFAULT) {
- GTK.gtk_widget_get_preferred_width_for_height (h, height, null, natural_size);
+ if (GTK.GTK4) {
+ GTK.gtk_widget_measure(h, GTK.GTK_ORIENTATION_HORIZONTAL, height, null, natural_size, null, null);
+ } else {
+ GTK.gtk_widget_get_preferred_width_for_height (h, height, null, natural_size);
+ }
width = natural_size [0];
} else {
- GTK.gtk_widget_get_preferred_height_for_width (h, width, null, natural_size);
+ if (GTK.GTK4) {
+ GTK.gtk_widget_measure(h, GTK.GTK_ORIENTATION_VERTICAL, width, null, natural_size, null, null);
+ } else {
+ GTK.gtk_widget_get_preferred_height_for_width (h, width, null, natural_size);
+ }
height = natural_size [0];
}
}

Back to the top