diff options
author | Anatoly Spektor <aspektor@redhat.com> | 2013-04-19 11:05:18 -0400 |
---|---|---|
committer | Anatoly Spektor <aspektor@redhat.com> | 2013-04-22 10:52:16 -0400 |
commit | b2687091b20430a0683c4d5f89a04ed5e3873360 (patch) | |
tree | fb9179c86a6368f174c085175a4565c87868ea13 | |
parent | 975e98f6ef680ed917c7d22fde80e918d5bef60e (diff) | |
download | eclipse.platform.swt-b2687091b20430a0683c4d5f89a04ed5e3873360.tar.gz eclipse.platform.swt-b2687091b20430a0683c4d5f89a04ed5e3873360.tar.xz eclipse.platform.swt-b2687091b20430a0683c4d5f89a04ed5e3873360.zip |
[GTK3] Fixes Drag and Drop bug for single line for Tree and Table392774
7 files changed, 76 insertions, 10 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TableDragSourceEffect.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TableDragSourceEffect.java index aee782f2bd..f056e23edf 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TableDragSourceEffect.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TableDragSourceEffect.java @@ -83,8 +83,6 @@ public class TableDragSourceEffect extends DragSourceEffect { //TEMPORARY CODE if (table.isListening(SWT.EraseItem) || table.isListening (SWT.PaintItem)) return null; - if (OS.GTK3) return null; - /* * Bug in GTK. gtk_tree_selection_get_selected_rows() segmentation faults * in versions smaller than 2.2.4 if the model is NULL. The fix is @@ -104,6 +102,7 @@ public class TableDragSourceEffect extends DragSourceEffect { dragSourceImage = Image.gtk_new(display, SWT.ICON, pixmap, 0); OS.gtk_tree_path_free (path); } else { + if (OS.GTK3) return null; int width = 0, height = 0; int[] w = new int[1], h = new int[1]; int[] yy = new int[count], hh = new int[count]; diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TreeDragSourceEffect.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TreeDragSourceEffect.java index d7a7f544bb..b5b705ac82 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TreeDragSourceEffect.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TreeDragSourceEffect.java @@ -82,8 +82,6 @@ public class TreeDragSourceEffect extends DragSourceEffect { //TEMPORARY CODE if (tree.isListening(SWT.EraseItem) || tree.isListening (SWT.PaintItem)) return null; - if (OS.GTK3) return null; - /* * Bug in GTK. gtk_tree_selection_get_selected_rows() segmentation faults * in versions smaller than 2.2.4 if the model is NULL. The fix is @@ -103,6 +101,7 @@ public class TreeDragSourceEffect extends DragSourceEffect { dragSourceImage = Image.gtk_new(display, SWT.ICON, pixmap, 0); OS.gtk_tree_path_free (path); } else { + if (OS.GTK3) return null; int width = 0, height = 0; int[] w = new int[1], h = new int[1]; int[] yy = new int[count], hh = new int[count]; diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo.c b/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo.c index 8c2052bcaa..42bb4267b4 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo.c +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo.c @@ -15,7 +15,7 @@ * * IBM * - Binding to permit interfacing between Cairo and SWT - * - Copyright (C) 2005, 2012 IBM Corp. All Rights Reserved. + * - Copyright (C) 2005, 2013 IBM Corp. All Rights Reserved. * * ***** END LICENSE BLOCK ***** */ @@ -79,6 +79,29 @@ JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1clip) } #endif +#ifndef NO__1cairo_1clip_1extents +JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1clip_1extents) + (JNIEnv *env, jclass that, jintLong arg0, jdoubleArray arg1, jdoubleArray arg2, jdoubleArray arg3, jdoubleArray arg4) +{ + jdouble *lparg1=NULL; + jdouble *lparg2=NULL; + jdouble *lparg3=NULL; + jdouble *lparg4=NULL; + Cairo_NATIVE_ENTER(env, that, _1cairo_1clip_1extents_FUNC); + if (arg1) if ((lparg1 = (*env)->GetDoubleArrayElements(env, arg1, NULL)) == NULL) goto fail; + if (arg2) if ((lparg2 = (*env)->GetDoubleArrayElements(env, arg2, NULL)) == NULL) goto fail; + if (arg3) if ((lparg3 = (*env)->GetDoubleArrayElements(env, arg3, NULL)) == NULL) goto fail; + if (arg4) if ((lparg4 = (*env)->GetDoubleArrayElements(env, arg4, NULL)) == NULL) goto fail; + cairo_clip_extents((cairo_t *)arg0, (double *)lparg1, (double *)lparg2, (double *)lparg3, (double *)lparg4); +fail: + if (arg4 && lparg4) (*env)->ReleaseDoubleArrayElements(env, arg4, lparg4, 0); + if (arg3 && lparg3) (*env)->ReleaseDoubleArrayElements(env, arg3, lparg3, 0); + if (arg2 && lparg2) (*env)->ReleaseDoubleArrayElements(env, arg2, lparg2, 0); + if (arg1 && lparg1) (*env)->ReleaseDoubleArrayElements(env, arg1, lparg1, 0); + Cairo_NATIVE_EXIT(env, that, _1cairo_1clip_1extents_FUNC); +} +#endif + #ifndef NO__1cairo_1clip_1preserve JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1clip_1preserve) (JNIEnv *env, jclass that, jintLong arg0) diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_stats.c b/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_stats.c index 5cdb9a0ddf..7052261323 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_stats.c +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_stats.c @@ -15,7 +15,7 @@ * * IBM * - Binding to permit interfacing between Cairo and SWT - * - Copyright (C) 2005, 2012 IBM Corp. All Rights Reserved. + * - Copyright (C) 2005, 2013 IBM Corp. All Rights Reserved. * * ***** END LICENSE BLOCK ***** */ @@ -30,6 +30,7 @@ char * Cairo_nativeFunctionNames[] = { "_1cairo_1arc", "_1cairo_1arc_1negative", "_1cairo_1clip", + "_1cairo_1clip_1extents", "_1cairo_1clip_1preserve", "_1cairo_1close_1path", "_1cairo_1copy_1page", diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_stats.h index 79bfc95f83..cbbafd80df 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_stats.h +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_stats.h @@ -15,7 +15,7 @@ * * IBM * - Binding to permit interfacing between Cairo and SWT - * - Copyright (C) 2005, 2012 IBM Corp. All Rights Reserved. + * - Copyright (C) 2005, 2013 IBM Corp. All Rights Reserved. * * ***** END LICENSE BLOCK ***** */ @@ -40,6 +40,7 @@ typedef enum { _1cairo_1arc_FUNC, _1cairo_1arc_1negative_FUNC, _1cairo_1clip_FUNC, + _1cairo_1clip_1extents_FUNC, _1cairo_1clip_1preserve_FUNC, _1cairo_1close_1path_FUNC, _1cairo_1copy_1page_FUNC, diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/org/eclipse/swt/internal/cairo/Cairo.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/org/eclipse/swt/internal/cairo/Cairo.java index 896e139138..608bdd7ecd 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/org/eclipse/swt/internal/cairo/Cairo.java +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/org/eclipse/swt/internal/cairo/Cairo.java @@ -150,6 +150,22 @@ public static final void cairo_clip_preserve(long /*int*/ cr) { lock.unlock(); } } +/** + * @param cr cast=(cairo_t *) + * @param x1 cast=(double *) + * @param y1 cast=(double *) + * @param x2 cast=(double *) + * @param y2 cast=(double *) + */ +public static final native void _cairo_clip_extents(long /*int*/ cr, double[] x1, double[] y1, double[] x2, double[] y2); +public static final void cairo_clip_extents(long /*int*/ cr, double[] x1, double[] y1, double[] x2, double[] y2) { + lock.lock(); + try { + _cairo_clip_extents(cr,x1,y1,x2,y2); + } finally { + lock.unlock(); + } +} /** @param cr cast=(cairo_t *) */ public static final native void _cairo_close_path(long /*int*/ cr); public static final void cairo_close_path(long /*int*/ cr) { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java index b8ec1055d2..00683d77f9 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java @@ -99,6 +99,12 @@ public final class Image extends Resource implements Drawable { public long /*int*/ pixmap; /** + * Cairo surface for GTK 3 + */ + public static long /*int*/ cairo_surface = 0; + + + /** * The handle to the OS mask resource. * (Warning: This field is platform dependent) * <p> @@ -871,7 +877,24 @@ long /*int*/ createMask(ImageData image, boolean copy) { void createSurface() { if (surface != 0) return; /* There is no pixmaps in GTK 3. */ - if (OS.GTK3) return; + if (OS.GTK3) { + /*Getting size of cairo_surface */ + double [] x1 = new double[1]; + double [] x2 = new double[1]; + double [] y1 = new double[1]; + double [] y2 = new double[1]; + long /*int*/ cairo = Cairo.cairo_create(cairo_surface); + Cairo.cairo_clip_extents(cairo, x1, y1, x2, y2); + this.width = (int) (x2[0] - x1[0]); + this.height = (int) (y2[0] - y1[0]); + + long /*int*/ xDisplay = OS.gdk_x11_display_get_xdisplay(OS.gdk_display_get_default()); + long /*int*/ xDrawable = Cairo.cairo_xlib_surface_get_drawable(cairo_surface) ; + long /*int*/ xVisual = OS.gdk_x11_visual_get_xvisual(OS.gdk_visual_get_system()); + surface = Cairo.cairo_xlib_surface_create(xDisplay, xDrawable, xVisual, width, height); + Cairo.cairo_destroy(cairo); + return; + } /* Generate the mask if necessary. */ if (transparentPixel != -1) createMask(); int[] w = new int[1], h = new int[1]; @@ -1235,9 +1258,13 @@ public ImageData getImageData() { public static Image gtk_new(Device device, int type, long /*int*/ pixmap, long /*int*/ mask) { Image image = new Image(device); image.type = type; - image.pixmap = pixmap; + if(OS.GTK3){ + cairo_surface = pixmap; + } else { + image.pixmap = pixmap; + } image.mask = mask; - if (OS.USE_CAIRO) image.createSurface(); + image.createSurface(); return image; } |