From d453cf5437fbe11ecd8d5bdf8ed46b521a6689e4 Mon Sep 17 00:00:00 2001 From: Silenio Quarti Date: Sat, 23 Mar 2013 10:51:35 -0400 Subject: Bug 397107 - [GTK3] CTabFolder rendering hangs --- .../Eclipse SWT PI/gtk/library/os.c | 60 ++++++++++++++++++++++ .../Eclipse SWT PI/gtk/library/os_custom.c | 25 +++++++-- .../Eclipse SWT PI/gtk/library/os_custom.h | 3 ++ .../Eclipse SWT PI/gtk/library/os_stats.c | 3 ++ .../Eclipse SWT PI/gtk/library/os_stats.h | 3 ++ .../Eclipse SWT PI/gtk/library/os_structs.c | 2 +- .../gtk/org/eclipse/swt/internal/gtk/OS.java | 37 +++++++++++++ 7 files changed, 127 insertions(+), 6 deletions(-) (limited to 'bundles/org.eclipse.swt/Eclipse SWT PI') 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 51ae3117bc..f9eb5cb146 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 @@ -18178,6 +18178,31 @@ JNIEXPORT jintLong JNICALL OS_NATIVE(_1gtk_1widget_1get_1parent_1window) } #endif +#ifndef NO__1gtk_1widget_1get_1preferred_1height_1for_1width +JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1widget_1get_1preferred_1height_1for_1width) + (JNIEnv *env, jclass that, jintLong arg0, jint arg1, jintArray arg2, jintArray arg3) +{ + jint *lparg2=NULL; + jint *lparg3=NULL; + OS_NATIVE_ENTER(env, that, _1gtk_1widget_1get_1preferred_1height_1for_1width_FUNC); + if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail; + if (arg3) if ((lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL)) == NULL) goto fail; +/* + gtk_widget_get_preferred_height_for_width(arg0, arg1, lparg2, lparg3); +*/ + { + OS_LOAD_FUNCTION(fp, gtk_widget_get_preferred_height_for_width) + if (fp) { + ((void (CALLING_CONVENTION*)(jintLong, jint, jint *, jint *))fp)(arg0, arg1, lparg2, lparg3); + } + } +fail: + if (arg3 && lparg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0); + if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0); + OS_NATIVE_EXIT(env, that, _1gtk_1widget_1get_1preferred_1height_1for_1width_FUNC); +} +#endif + #ifndef NO__1gtk_1widget_1get_1preferred_1size JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1widget_1get_1preferred_1size) (JNIEnv *env, jclass that, jintLong arg0, jobject arg1, jobject arg2) @@ -18203,6 +18228,31 @@ fail: } #endif +#ifndef NO__1gtk_1widget_1get_1preferred_1width_1for_1height +JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1widget_1get_1preferred_1width_1for_1height) + (JNIEnv *env, jclass that, jintLong arg0, jint arg1, jintArray arg2, jintArray arg3) +{ + jint *lparg2=NULL; + jint *lparg3=NULL; + OS_NATIVE_ENTER(env, that, _1gtk_1widget_1get_1preferred_1width_1for_1height_FUNC); + if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail; + if (arg3) if ((lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL)) == NULL) goto fail; +/* + gtk_widget_get_preferred_width_for_height(arg0, arg1, lparg2, lparg3); +*/ + { + OS_LOAD_FUNCTION(fp, gtk_widget_get_preferred_width_for_height) + if (fp) { + ((void (CALLING_CONVENTION*)(jintLong, jint, jint *, jint *))fp)(arg0, arg1, lparg2, lparg3); + } + } +fail: + if (arg3 && lparg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0); + if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0); + OS_NATIVE_EXIT(env, that, _1gtk_1widget_1get_1preferred_1width_1for_1height_FUNC); +} +#endif + #ifndef NO__1gtk_1widget_1get_1realized JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1widget_1get_1realized) (JNIEnv *env, jclass that, jintLong arg0) @@ -21015,6 +21065,16 @@ JNIEXPORT void JNICALL OS_NATIVE(_1swt_1fixed_1move) } #endif +#ifndef NO__1swt_1fixed_1resize +JNIEXPORT void JNICALL OS_NATIVE(_1swt_1fixed_1resize) + (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1, jint arg2, jint arg3) +{ + OS_NATIVE_ENTER(env, that, _1swt_1fixed_1resize_FUNC); + swt_fixed_resize((SwtFixed*)arg0, (GtkWidget*)arg1, arg2, arg3); + OS_NATIVE_EXIT(env, that, _1swt_1fixed_1resize_FUNC); +} +#endif + #ifndef NO__1swt_1fixed_1restack JNIEXPORT void JNICALL OS_NATIVE(_1swt_1fixed_1restack) (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1, jintLong arg2, jboolean arg3) diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.c index 8152b8c7a7..d6189fb0e8 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.c +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.c @@ -539,11 +539,8 @@ static void swt_fixed_size_allocate (GtkWidget *widget, GtkAllocation *allocatio child_allocation.y += allocation->y; } - /* - * Use the requested size if it is set. This is the GTK 2 behavior of - * gtk_widget_get_child_requisition(). - */ - gtk_widget_get_size_request (child, &w, &h); + w = child_data->width; + h = child_data->height; if (w == -1 || h == -1) { gtk_widget_get_preferred_size (child, &requisition, NULL); if (w == -1) w = requisition.width; @@ -573,6 +570,23 @@ void swt_fixed_move (SwtFixed *fixed, GtkWidget *widget, gint x, gint y) { } } +void swt_fixed_resize (SwtFixed *fixed, GtkWidget *widget, gint width, gint height) { + SwtFixedPrivate *priv = fixed->priv; + GList *list; + + list = priv->children; + while (list) { + SwtFixedChild *child_data = list->data; + GtkWidget *child = child_data->widget; + if (child == widget) { + child_data->width = width; + child_data->height = height; + break; + } + list = list->next; + } +} + static void swt_fixed_add (GtkContainer *container, GtkWidget *child) { GtkWidget *widget = GTK_WIDGET (container); SwtFixed *fixed = SWT_FIXED (container); @@ -582,6 +596,7 @@ static void swt_fixed_add (GtkContainer *container, GtkWidget *child) { child_data = g_new (SwtFixedChild, 1); child_data->widget = child; child_data->x = child_data->y = 0; + child_data->width = child_data->height = -1; priv->children = g_list_append (priv->children, child_data); gtk_widget_set_parent (child, widget); diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h index f1b60cd0a0..e31fe11b51 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h @@ -529,6 +529,8 @@ #define gtk_widget_override_color_LIB LIB_GTK #define gtk_widget_override_background_color_LIB LIB_GTK #define gtk_widget_override_font_LIB LIB_GTK +#define gtk_widget_get_preferred_height_for_width_LIB LIB_GTK +#define gtk_widget_get_preferred_width_for_height_LIB LIB_GTK #define gtk_style_context_get_font_LIB LIB_GTK #define gtk_style_context_get_color_LIB LIB_GTK #define gtk_style_context_get_background_color_LIB LIB_GTK @@ -737,6 +739,7 @@ GType swt_fixed_get_type (void) G_GNUC_CONST; void swt_fixed_restack(SwtFixed *fixed, GtkWidget *widget, GtkWidget *sibling, gboolean above); void swt_fixed_move(SwtFixed *fixed, GtkWidget *widget, gint x, gint y); +void swt_fixed_resize(SwtFixed *fixed, GtkWidget *widget, gint width, gint height); #endif 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 cf200b60b1..736669da93 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 @@ -1338,7 +1338,9 @@ char * OS_nativeFunctionNames[] = { "_1gtk_1widget_1get_1pango_1context", "_1gtk_1widget_1get_1parent", "_1gtk_1widget_1get_1parent_1window", + "_1gtk_1widget_1get_1preferred_1height_1for_1width", "_1gtk_1widget_1get_1preferred_1size", + "_1gtk_1widget_1get_1preferred_1width_1for_1height", "_1gtk_1widget_1get_1realized", "_1gtk_1widget_1get_1sensitive", "_1gtk_1widget_1get_1size_1request", @@ -1550,6 +1552,7 @@ char * OS_nativeFunctionNames[] = { "_1pango_1tab_1array_1set_1tab", "_1swt_1fixed_1get_1type", "_1swt_1fixed_1move", + "_1swt_1fixed_1resize", "_1swt_1fixed_1restack", "_1ubuntu_1menu_1proxy_1get", "g_1main_1context_1wakeup", 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 2153d5c936..5ceb219a25 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 @@ -1348,7 +1348,9 @@ typedef enum { _1gtk_1widget_1get_1pango_1context_FUNC, _1gtk_1widget_1get_1parent_FUNC, _1gtk_1widget_1get_1parent_1window_FUNC, + _1gtk_1widget_1get_1preferred_1height_1for_1width_FUNC, _1gtk_1widget_1get_1preferred_1size_FUNC, + _1gtk_1widget_1get_1preferred_1width_1for_1height_FUNC, _1gtk_1widget_1get_1realized_FUNC, _1gtk_1widget_1get_1sensitive_FUNC, _1gtk_1widget_1get_1size_1request_FUNC, @@ -1560,6 +1562,7 @@ typedef enum { _1pango_1tab_1array_1set_1tab_FUNC, _1swt_1fixed_1get_1type_FUNC, _1swt_1fixed_1move_FUNC, + _1swt_1fixed_1resize_FUNC, _1swt_1fixed_1restack_FUNC, _1ubuntu_1menu_1proxy_1get_FUNC, g_1main_1context_1wakeup_FUNC, diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_structs.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_structs.c index 25256f9a26..1fa8f1d9c1 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_structs.c +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_structs.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2012 IBM Corporation and others. All rights reserved. + * Copyright (c) 2000, 2013 IBM Corporation and others. All rights reserved. * The contents of this file are made available under the terms * of the GNU Lesser General Public License (LGPL) Version 2.1 that * accompanies this distribution (lgpl-v21.txt). The LGPL is also diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java index df440a752f..901d98e0ce 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java @@ -6352,6 +6352,30 @@ public static final void gtk_widget_get_preferred_size(long /*int*/ widget, GtkR lock.unlock(); } } +/** + * @method flags=dynamic + */ +public static final native void _gtk_widget_get_preferred_height_for_width(long /*int*/ widget, int width, int[] minimum_size, int[] natural_size); +public static final void gtk_widget_get_preferred_height_for_width(long /*int*/ widget, int width, int[] minimum_size, int[] natural_size) { + lock.lock(); + try { + _gtk_widget_get_preferred_height_for_width(widget, width, minimum_size, natural_size); + } finally { + lock.unlock(); + } +} +/** + * @method flags=dynamic + */ +public static final native void _gtk_widget_get_preferred_width_for_height(long /*int*/ widget, int height, int[] minimum_size, int[] natural_size); +public static final void gtk_widget_get_preferred_width_for_height(long /*int*/ widget, int height, int[] minimum_size, int[] natural_size) { + lock.lock(); + try { + _gtk_widget_get_preferred_width_for_height(widget, height, minimum_size, natural_size); + } finally { + lock.unlock(); + } +} public static final native long /*int*/ _gtk_cell_renderer_pixbuf_new(); public static final long /*int*/ gtk_cell_renderer_pixbuf_new() { lock.lock(); @@ -16160,4 +16184,17 @@ public static final void swt_fixed_move(long /*int*/ fixed, long /*int*/ widget, lock.unlock(); } } +/** + * @param fixed cast=(SwtFixed*) + * @param widget cast=(GtkWidget*) + */ +public static final native void _swt_fixed_resize(long /*int*/ fixed, long /*int*/ widget, int width, int height); +public static final void swt_fixed_resize(long /*int*/ fixed, long /*int*/ widget, int width, int height) { + lock.lock(); + try { + _swt_fixed_resize(fixed, widget, width, height); + } finally { + lock.unlock(); + } +} } -- cgit