From 7669785e29b0e39c9bebf42af45663b5c2824a63 Mon Sep 17 00:00:00 2001 From: Anatoly Spektor Date: Wed, 17 Oct 2012 14:27:54 -0400 Subject: Use gdk_window* instead of gdk_drawable_get_visible_region() --- .../Eclipse SWT PI/gtk/library/os.c | 30 +++++++++++++++++++++- .../Eclipse SWT PI/gtk/library/os_custom.h | 2 ++ .../Eclipse SWT PI/gtk/library/os_stats.c | 1 + .../Eclipse SWT PI/gtk/library/os_stats.h | 1 + .../gtk/org/eclipse/swt/internal/gtk/OS.java | 15 ++++++++++- .../gtk/org/eclipse/swt/graphics/GC.java | 4 ++- .../gtk/org/eclipse/swt/widgets/Canvas.java | 4 ++- 7 files changed, 53 insertions(+), 4 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 4ca1b92987..f0400130ac 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 @@ -5405,7 +5405,15 @@ JNIEXPORT jintLong JNICALL OS_NATIVE(_1gdk_1drawable_1get_1visible_1region) { jintLong rc = 0; OS_NATIVE_ENTER(env, that, _1gdk_1drawable_1get_1visible_1region_FUNC); - rc = (jintLong)gdk_drawable_get_visible_region((GdkDrawable *)arg0); +/* + rc = (jintLong)gdk_drawable_get_visible_region(arg0); +*/ + { + OS_LOAD_FUNCTION(fp, gdk_drawable_get_visible_region) + if (fp) { + rc = (jintLong)((jintLong (CALLING_CONVENTION*)(jintLong))fp)(arg0); + } + } OS_NATIVE_EXIT(env, that, _1gdk_1drawable_1get_1visible_1region_FUNC); return rc; } @@ -7293,6 +7301,26 @@ fail: } #endif +#ifndef NO__1gdk_1window_1get_1visible_1region +JNIEXPORT jintLong JNICALL OS_NATIVE(_1gdk_1window_1get_1visible_1region) + (JNIEnv *env, jclass that, jintLong arg0) +{ + jintLong rc = 0; + OS_NATIVE_ENTER(env, that, _1gdk_1window_1get_1visible_1region_FUNC); +/* + rc = (jintLong)gdk_window_get_visible_region((GdkWindow *)arg0); +*/ + { + OS_LOAD_FUNCTION(fp, gdk_window_get_visible_region) + if (fp) { + rc = (jintLong)((jintLong (CALLING_CONVENTION*)(GdkWindow *))fp)((GdkWindow *)arg0); + } + } + OS_NATIVE_EXIT(env, that, _1gdk_1window_1get_1visible_1region_FUNC); + return rc; +} +#endif + #ifndef NO__1gdk_1window_1get_1width JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1window_1get_1width) (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 9ac3a4734f..32943e64b3 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 @@ -197,6 +197,7 @@ #define gdk_draw_polygon_LIB LIB_GDK #define gdk_draw_image_LIB LIB_GDK #define gdk_drawable_get_size_LIB LIB_GDK +#define gdk_drawable_get_visible_region_LIB LIB_GDK #define gdk_gc_set_background_LIB LIB_GDK #define gdk_gc_set_stipple_LIB LIB_GDK #define gdk_gc_set_clip_mask_LIB LIB_GDK @@ -268,6 +269,7 @@ #define gdk_window_get_width_LIB LIB_GDK #define gdk_pixmap_get_size_LIB LIB_GDK #define gdk_window_get_display_LIB LIB_GDK +#define gdk_window_get_visible_region_LIB LIB_GDK #define gdk_window_set_keep_above_LIB LIB_GDK #define gdk_window_set_accept_focus_LIB LIB_GDK #define gtk_window_set_opacity_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 32b9b0cb91..0eab77a90d 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 @@ -555,6 +555,7 @@ char * OS_nativeFunctionNames[] = { "_1gdk_1window_1get_1pointer", "_1gdk_1window_1get_1position", "_1gdk_1window_1get_1user_1data", + "_1gdk_1window_1get_1visible_1region", "_1gdk_1window_1get_1width", "_1gdk_1window_1hide", "_1gdk_1window_1invalidate_1rect", 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 5bcc0ee129..f2b2cf6333 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 @@ -565,6 +565,7 @@ typedef enum { _1gdk_1window_1get_1pointer_FUNC, _1gdk_1window_1get_1position_FUNC, _1gdk_1window_1get_1user_1data_FUNC, + _1gdk_1window_1get_1visible_1region_FUNC, _1gdk_1window_1get_1width_FUNC, _1gdk_1window_1hide_FUNC, _1gdk_1window_1invalidate_1rect_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 db9af0212b..ea27101484 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 @@ -3506,6 +3506,19 @@ public static final int gdk_window_get_width(long /*int*/ window) { lock.unlock(); } } +/** + * @param window cast=(GdkWindow *) + * @method flags=dynamic + */ +public static final native long /*int*/ _gdk_window_get_visible_region(long /*int*/ window); +public static final long /*int*/ gdk_window_get_visible_region(long /*int*/ window) { + lock.lock(); + try { + return _gdk_window_get_visible_region(window); + } finally { + lock.unlock(); + } +} /** * @param window cast=(GdkWindow *) * @method flags=dynamic @@ -4036,7 +4049,7 @@ public static final void gdk_drawable_get_size(long /*int*/ drawable, int[] widt lock.unlock(); } } -/** @param drawable cast=(GdkDrawable *) */ +/** @method flags=dynamic */ public static final native long /*int*/ _gdk_drawable_get_visible_region(long /*int*/ drawable); public static final long /*int*/ gdk_drawable_get_visible_region(long /*int*/ drawable) { lock.lock(); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java index 3fcaeeddcc..5de2642596 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java @@ -598,8 +598,9 @@ public void copyArea(int srcX, int srcY, int width, int height, int destX, int d Cairo.cairo_paint(handle); Cairo.cairo_restore(handle); if (paint) { - long /*int*/ visibleRegion = OS.gdk_drawable_get_visible_region (drawable); + long /*int*/ visibleRegion = 0; if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + visibleRegion = OS.gdk_window_get_visible_region (drawable); cairo_rectangle_int_t srcRect = new cairo_rectangle_int_t (); srcRect.x = srcX; srcRect.y = srcY; @@ -615,6 +616,7 @@ public void copyArea(int srcX, int srcY, int width, int height, int destX, int d Cairo.cairo_region_destroy (copyRegion); Cairo.cairo_region_destroy (invalidateRegion); } else { + visibleRegion = OS.gdk_drawable_get_visible_region (drawable); GdkRectangle srcRect = new GdkRectangle (); srcRect.x = srcX; srcRect.y = srcY; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Canvas.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Canvas.java index 3537f46bda..be7fa652aa 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Canvas.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Canvas.java @@ -252,8 +252,9 @@ public void scroll (int destX, int destY, int x, int y, int width, int height, b boolean isFocus = caret != null && caret.isFocusCaret (); if (isFocus) caret.killFocus (); long /*int*/ window = paintWindow (); - long /*int*/ visibleRegion = OS.gdk_drawable_get_visible_region (window); + long /*int*/ visibleRegion = 0; if(OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + visibleRegion = OS.gdk_window_get_visible_region (window); cairo_rectangle_int_t srcRect = new cairo_rectangle_int_t(); srcRect.x = x; srcRect.y = y; @@ -325,6 +326,7 @@ public void scroll (int destX, int destY, int x, int y, int width, int height, b Cairo.cairo_region_destroy (invalidateRegion); } } else { + visibleRegion = OS.gdk_drawable_get_visible_region (window); GdkRectangle srcRect = new GdkRectangle (); srcRect.x = x; srcRect.y = y; -- cgit