diff options
author | Anatoly Spektor <aspektor@redhat.com> | 2012-08-24 09:47:21 -0400 |
---|---|---|
committer | Anatoly Spektor <aspektor@redhat.com> | 2012-08-24 09:47:21 -0400 |
commit | 23fa2e067c12ec923c7abd19afd1709d47ad0ac4 (patch) | |
tree | 305cedef4f2231f3088450d9fec3b18dc8ee09a0 | |
parent | 994916062ac21984d9d9928e629166d25c9002ba (diff) | |
download | eclipse.platform.swt-gdk_region.tar.gz eclipse.platform.swt-gdk_region.tar.xz eclipse.platform.swt-gdk_region.zip |
Omit use of deprecated gdk_region_polygon in Tooltip widgetgdk_region
6 files changed, 92 insertions, 6 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 12cff6d853..720cbeeda6 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 @@ -4655,6 +4655,26 @@ JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1cairo_1region) } #endif +#ifndef NO__1gdk_1cairo_1region_1create_1from_1surface +JNIEXPORT jintLong JNICALL OS_NATIVE(_1gdk_1cairo_1region_1create_1from_1surface) + (JNIEnv *env, jclass that, jintLong arg0) +{ + jintLong rc = 0; + OS_NATIVE_ENTER(env, that, _1gdk_1cairo_1region_1create_1from_1surface_FUNC); +/* + rc = (jintLong)gdk_cairo_region_create_from_surface(arg0); +*/ + { + OS_LOAD_FUNCTION(fp, gdk_cairo_region_create_from_surface) + if (fp) { + rc = (jintLong)((jintLong (CALLING_CONVENTION*)(jintLong))fp)(arg0); + } + } + OS_NATIVE_EXIT(env, that, _1gdk_1cairo_1region_1create_1from_1surface_FUNC); + return rc; +} +#endif + #ifndef NO__1gdk_1cairo_1reset_1clip JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1cairo_1reset_1clip) (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1) @@ -16267,6 +16287,24 @@ JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1widget_1set_1visible) } #endif +#ifndef NO__1gtk_1widget_1shape_1combine_1region +JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1widget_1shape_1combine_1region) + (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1) +{ + OS_NATIVE_ENTER(env, that, _1gtk_1widget_1shape_1combine_1region_FUNC); +/* + gtk_widget_shape_combine_region(arg0, arg1); +*/ + { + OS_LOAD_FUNCTION(fp, gtk_widget_shape_combine_region) + if (fp) { + ((void (CALLING_CONVENTION*)(jintLong, jintLong))fp)(arg0, arg1); + } + } + OS_NATIVE_EXIT(env, that, _1gtk_1widget_1shape_1combine_1region_FUNC); +} +#endif + #ifndef NO__1gtk_1widget_1show JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1widget_1show) (JNIEnv *env, jclass that, jintLong arg0) 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 69b44542ef..cbf8e488c5 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 @@ -210,6 +210,7 @@ #define gtk_widget_get_allocation_LIB LIB_GTK #define gtk_widget_get_tooltip_text_LIB LIB_GTK #define gtk_widget_get_visible_LIB LIB_GTK +#define gtk_widget_shape_combine_region_LIB LIB_GTK #define gtk_widget_has_focus_LIB LIB_GTK #define gtk_widget_has_default_LIB LIB_GTK #define gtk_widget_set_tooltip_text_LIB LIB_GTK @@ -259,6 +260,7 @@ #define gdk_cairo_set_source_window_LIB LIB_GDK #define gdk_cairo_region_LIB LIB_GDK #define gdk_cairo_create_LIB LIB_GDK +#define gdk_cairo_region_create_from_surface_LIB LIB_GDK #define gtk_enumerate_printers_LIB LIB_GTK #define gtk_object_sink_LIB LIB_GTK #define gtk_orientable_set_orientation_LIB LIB_GTK 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 657e02529d..ba9e00f37f 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 = 1333; -int OS_nativeFunctionCallCount[1333]; +int OS_nativeFunctionCount = 1335; +int OS_nativeFunctionCallCount[1335]; char * OS_nativeFunctionNames[] = { #ifndef JNI64 "Call__IIII", @@ -406,6 +406,7 @@ char * OS_nativeFunctionNames[] = { "_1gdk_1bitmap_1create_1from_1data", "_1gdk_1cairo_1create", "_1gdk_1cairo_1region", + "_1gdk_1cairo_1region_1create_1from_1surface", "_1gdk_1cairo_1reset_1clip", "_1gdk_1cairo_1set_1source_1color", "_1gdk_1cairo_1set_1source_1pixbuf", @@ -1276,6 +1277,7 @@ char * OS_nativeFunctionNames[] = { "_1gtk_1widget_1set_1state", "_1gtk_1widget_1set_1tooltip_1text", "_1gtk_1widget_1set_1visible", + "_1gtk_1widget_1shape_1combine_1region", "_1gtk_1widget_1show", "_1gtk_1widget_1size_1allocate", "_1gtk_1widget_1size_1request", 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 e97f22092c..72c7052092 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 @@ -414,6 +414,7 @@ typedef enum { _1gdk_1bitmap_1create_1from_1data_FUNC, _1gdk_1cairo_1create_FUNC, _1gdk_1cairo_1region_FUNC, + _1gdk_1cairo_1region_1create_1from_1surface_FUNC, _1gdk_1cairo_1reset_1clip_FUNC, _1gdk_1cairo_1set_1source_1color_FUNC, _1gdk_1cairo_1set_1source_1pixbuf_FUNC, @@ -1284,6 +1285,7 @@ typedef enum { _1gtk_1widget_1set_1state_FUNC, _1gtk_1widget_1set_1tooltip_1text_FUNC, _1gtk_1widget_1set_1visible_FUNC, + _1gtk_1widget_1shape_1combine_1region_FUNC, _1gtk_1widget_1show_FUNC, _1gtk_1widget_1size_1allocate_FUNC, _1gtk_1widget_1size_1request_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 312603a2b1..4ea2f165d7 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 @@ -3454,6 +3454,16 @@ public static final void gdk_cairo_region(int /*long*/ cairo, int /*long*/ regio } } /** @method flags=dynamic */ +public static final native int /*long*/ _gdk_cairo_region_create_from_surface(int /*long*/ surface); +public static final int /*long*/ gdk_cairo_region_create_from_surface(int /*long*/ surface) { + lock.lock(); + try { + return _gdk_cairo_region_create_from_surface(surface); + } finally { + lock.unlock(); + } +} +/** @method flags=dynamic */ public static final native void _gdk_cairo_reset_clip(int /*long*/ cairo, int /*long*/ drawable); public static final void gdk_cairo_reset_clip(int /*long*/ cairo, int /*long*/ drawable) { lock.lock(); @@ -5423,6 +5433,16 @@ public static final void gdk_window_shape_combine_region (int /*long*/ window, i lock.unlock(); } } +/** @method flags=dynamic */ +public static final native void _gtk_widget_shape_combine_region(int /*long*/ widget, int /*long*/ region); +public static final void gtk_widget_shape_combine_region(int /*long*/ widget, int /*long*/ region) { + lock.lock(); + try { + _gtk_widget_shape_combine_region(widget,region); + } finally { + lock.unlock(); + } +} /** @param window cast=(GdkWindow *) */ public static final native void _gdk_window_show(int /*long*/ window); public static final void gdk_window_show(int /*long*/ window) { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java index 13425ad071..d4d9ddab67 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java @@ -249,11 +249,33 @@ void configure () { OS.gtk_window_move (handle, Math.min(dest.width - w, x - w + 17), y - h - TIP_HEIGHT); } } - int /*long*/ rgn = OS.gdk_region_polygon (polyline, polyline.length / 2, OS.GDK_EVEN_ODD_RULE); - OS.gtk_widget_realize (handle); + OS.gtk_widget_realize(handle); int /*long*/ window = gtk_widget_get_window (handle); - OS.gdk_window_shape_combine_region (window, rgn, 0, 0); - OS.gdk_region_destroy (rgn); + /* + As methods required to replicate gdk_window_shape_combine_region () + are available starting from GTK+ 3, Cairo implementation that replicates + gdk_region_polygon () should be also available to GTK+ 3.0 and higher. + */ + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + int /*long*/ cairo = OS.gdk_cairo_create(window); + int count = polyline.length / 2; + if (count == 0) return; + Cairo.cairo_move_to(cairo, polyline[0], polyline[1]); + for (int i=1,j=2; i<count; i++,j+=2) { + Cairo.cairo_move_to(cairo, polyline[j]+0.5, polyline[j+1]+0.5); + } + Cairo.cairo_close_path(cairo); + Cairo.cairo_set_fill_rule(cairo, Cairo.CAIRO_FILL_RULE_EVEN_ODD); + Cairo.cairo_fill(cairo); + int /*long*/ surface = Cairo.cairo_get_target(cairo); + int /*long*/ region = OS.gdk_cairo_region_create_from_surface(surface); + OS.gtk_widget_shape_combine_region (window, region); + Cairo.cairo_destroy(cairo); + } else { + int /*long*/ rgn = OS.gdk_region_polygon (polyline, polyline.length / 2, OS.GDK_EVEN_ODD_RULE); + OS.gdk_window_shape_combine_region (window, rgn, 0, 0); + OS.gdk_region_destroy (rgn); + } } void createHandle (int index) { |