From 6207053cbabec2bceac5c0fcadb16091fc8a4c80 Mon Sep 17 00:00:00 2001 From: Anatoly Spektor Date: Tue, 7 Aug 2012 15:26:07 -0400 Subject: Bug 386778 Omit use of GTK_WIDGET_SET_X and GTK_WIDGET_SET_Y in newer GTK+ --- .../org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c | 21 +++++++++++++++++++++ .../Eclipse SWT PI/gtk/library/os_custom.h | 9 +++++++++ .../Eclipse SWT PI/gtk/library/os_stats.c | 5 +++-- .../Eclipse SWT PI/gtk/library/os_stats.h | 1 + .../gtk/org/eclipse/swt/internal/gtk/OS.java | 13 +++++++++++++ .../gtk/org/eclipse/swt/widgets/Control.java | 20 +++++++++++++++++--- 6 files changed, 64 insertions(+), 5 deletions(-) (limited to 'bundles') 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 e48a8f9a76..b71852b2c0 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 @@ -16034,6 +16034,27 @@ JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1widget_1send_1expose) } #endif +#ifndef NO__1gtk_1widget_1set_1allocation +JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1widget_1set_1allocation) + (JNIEnv *env, jclass that, jintLong arg0, jobject arg1) +{ + GtkAllocation _arg1, *lparg1=NULL; + OS_NATIVE_ENTER(env, that, _1gtk_1widget_1set_1allocation_FUNC); + if (arg1) if ((lparg1 = getGtkAllocationFields(env, arg1, &_arg1)) == NULL) goto fail; +/* + gtk_widget_set_allocation(arg0, (GtkAllocation *)lparg1); +*/ + { + OS_LOAD_FUNCTION(fp, gtk_widget_set_allocation) + if (fp) { + ((void (CALLING_CONVENTION*)(jintLong, GtkAllocation *))fp)(arg0, (GtkAllocation *)lparg1); + } + } +fail: + OS_NATIVE_EXIT(env, that, _1gtk_1widget_1set_1allocation_FUNC); +} +#endif + #ifndef NO__1gtk_1widget_1set_1app_1paintable JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1widget_1set_1app_1paintable) (JNIEnv *env, jclass that, jintLong arg0, jboolean arg1) 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 050eae6ae7..2671afd6da 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 @@ -71,6 +71,7 @@ #define XRenderSetPictureClipRectangles_LIB LIB_XRENDER #define XRenderSetPictureTransform_LIB LIB_XRENDER #define g_filename_display_name_LIB LIB_GLIB +#define gtk_widget_set_allocation_LIB LIB_GTK #define gtk_calendar_display_options_LIB LIB_GTK #define gtk_calendar_get_date_LIB LIB_GTK #define gtk_calendar_new_LIB LIB_GTK @@ -437,7 +438,11 @@ #else #define GTK_WIDGET_X(arg0) (arg0)->allocation.x #endif +#if GTK_CHECK_VERSION(2,18,0) +#define GTK_WIDGET_SET_X(arg0, arg1) +#else #define GTK_WIDGET_SET_X(arg0, arg1) (arg0)->allocation.x = arg1 +#endif #define GTK_ENTRY_IM_CONTEXT(arg0) (arg0)->im_context #define GTK_TEXTVIEW_IM_CONTEXT(arg0) (arg0)->im_context #if GTK_CHECK_VERSION(2,12,0) @@ -454,7 +459,11 @@ #else #define GTK_WIDGET_Y(arg0) ((GtkWidget *)arg0)->allocation.y #endif +#if GTK_CHECK_VERSION(2,18,0) +#define GTK_WIDGET_SET_Y(arg0, arg1) +#else #define GTK_WIDGET_SET_Y(arg0, arg1) (arg0)->allocation.y = arg1 +#endif #define GTK_WIDGET_REQUISITION_WIDTH(arg0) (arg0)->requisition.width #define GTK_WIDGET_REQUISITION_HEIGHT(arg0) (arg0)->requisition.height #define GDK_EVENT_TYPE(arg0) (arg0)->type 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 aa5d1eab09..aeb340c4a1 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 @@ -18,8 +18,8 @@ #ifdef NATIVE_STATS -int OS_nativeFunctionCount = 1336; -int OS_nativeFunctionCallCount[1336]; +int OS_nativeFunctionCount = 1337; +int OS_nativeFunctionCallCount[1337]; char * OS_nativeFunctionNames[] = { #ifndef JNI64 "Call__IIII", @@ -1262,6 +1262,7 @@ char * OS_nativeFunctionNames[] = { "_1gtk_1widget_1remove_1accelerator", "_1gtk_1widget_1reparent", "_1gtk_1widget_1send_1expose", + "_1gtk_1widget_1set_1allocation", "_1gtk_1widget_1set_1app_1paintable", "_1gtk_1widget_1set_1can_1default", "_1gtk_1widget_1set_1can_1focus", 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 34e4638271..6b46369112 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 @@ -1270,6 +1270,7 @@ typedef enum { _1gtk_1widget_1remove_1accelerator_FUNC, _1gtk_1widget_1reparent_FUNC, _1gtk_1widget_1send_1expose_FUNC, + _1gtk_1widget_1set_1allocation_FUNC, _1gtk_1widget_1set_1app_1paintable_FUNC, _1gtk_1widget_1set_1can_1default_FUNC, _1gtk_1widget_1set_1can_1focus_FUNC, 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 d79646c18a..d221129a8e 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 @@ -12738,6 +12738,19 @@ public static final void gtk_widget_size_request(int /*long*/ widget, GtkRequisi lock.unlock(); } } +/** + * @method flags=dynamic + * @param allocation cast=(GtkAllocation *),flags=no_out + */ +public static final native void _gtk_widget_set_allocation(int /*long*/ widget, GtkAllocation allocation); +public static final void gtk_widget_set_allocation(int /*long*/ widget, GtkAllocation allocation) { + lock.lock(); + try { + _gtk_widget_set_allocation(widget, allocation); + } finally { + lock.unlock(); + } +} /** * @param widget cast=(GtkWidget *) * @param property_name cast=(const gchar *) 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 83d1920130..209fadab90 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 @@ -4190,12 +4190,26 @@ void setInitialBounds () { * expected by SWT. */ int /*long*/ topHandle = topHandle (); + GtkAllocation allocation = new GtkAllocation(); if ((parent.style & SWT.MIRRORED) != 0) { - OS.GTK_WIDGET_SET_X (topHandle, parent.getClientWidth ()); + if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) { + allocation.x = parent.getClientWidth (); + } else { + OS.GTK_WIDGET_SET_X (topHandle, parent.getClientWidth ()); + } + } else { + if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) { + allocation.x = 0; + } else { + OS.GTK_WIDGET_SET_X (topHandle, 0); + } + } + if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) { + allocation.y = 0; + OS.gtk_widget_set_allocation(topHandle, allocation); } else { - OS.GTK_WIDGET_SET_X (topHandle, 0); + OS.GTK_WIDGET_SET_Y (topHandle, 0); } - OS.GTK_WIDGET_SET_Y (topHandle, 0); } else { resizeHandle (1, 1); forceResize (); -- cgit