summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Wielaard <mark@klomp.org>2006-03-22 23:28:32 +0000
committerMark Wielaard <mark@klomp.org>2006-03-22 23:28:32 +0000
commite7e6d564de59d101178ca787281d7aa01b8f5a57 (patch)
tree8f85de8d41e4f67235bf7230a2fd4752c9d1a7a9
parent139208ba6b19cbf99b4a1ef860e4105f5c5e53a3 (diff)
downloadclasspath-e7e6d564de59d101178ca787281d7aa01b8f5a57.tar.gz
Fixes bug #26301
* gnu/java/awt/peer/gtk/GtkComponentPeer.java (gtkWidgetSetCursor): Takes GtkImage, x and y coordinates. (gtkWidgetSetCursorUnlocked): Likewise. (GtkComponentPeer): Set cursor when set. (setCursor): Handle GtkCursor. * gnu/java/awt/peer/gtk/GtkToolkit.java (createCustomCursor): New method. * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c (gtkWidgetSetCursor): Takes GtkImage, x and y coordinates. (gtkWidgetSetCursorUnlocked): Likewise. Handle custom image. * include/gnu_java_awt_peer_gtk_GtkComponentPeer.h: Regenerated.
-rw-r--r--ChangeLog15
-rw-r--r--gnu/java/awt/peer/gtk/GtkComponentPeer.java30
-rw-r--r--gnu/java/awt/peer/gtk/GtkToolkit.java5
-rw-r--r--include/gnu_java_awt_peer_gtk_GtkComponentPeer.h4
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c15
5 files changed, 59 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index 98462168c..afd3a0f76 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2006-03-22 Mark Wielaard <mark@klomp.org>
+
+ Fixes bug #26301
+ * gnu/java/awt/peer/gtk/GtkComponentPeer.java (gtkWidgetSetCursor):
+ Takes GtkImage, x and y coordinates.
+ (gtkWidgetSetCursorUnlocked): Likewise.
+ (GtkComponentPeer): Set cursor when set.
+ (setCursor): Handle GtkCursor.
+ * gnu/java/awt/peer/gtk/GtkToolkit.java (createCustomCursor):
+ New method.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
+ (gtkWidgetSetCursor): Takes GtkImage, x and y coordinates.
+ (gtkWidgetSetCursorUnlocked): Likewise. Handle custom image.
+ * include/gnu_java_awt_peer_gtk_GtkComponentPeer.h: Regenerated.
+
2006-03-23 Roman Kennke <kennke@aicas.com>
PR 26805
diff --git a/gnu/java/awt/peer/gtk/GtkComponentPeer.java b/gnu/java/awt/peer/gtk/GtkComponentPeer.java
index ed0380172..1a4aa0afb 100644
--- a/gnu/java/awt/peer/gtk/GtkComponentPeer.java
+++ b/gnu/java/awt/peer/gtk/GtkComponentPeer.java
@@ -99,8 +99,9 @@ public class GtkComponentPeer extends GtkGenericPeer
native void gtkWidgetGetPreferredDimensions (int[] dim);
native void gtkWindowGetLocationOnScreen (int[] point);
native void gtkWidgetGetLocationOnScreen (int[] point);
- native void gtkWidgetSetCursor (int type);
- native void gtkWidgetSetCursorUnlocked (int type);
+ native void gtkWidgetSetCursor (int type, GtkImage image, int x, int y);
+ native void gtkWidgetSetCursorUnlocked (int type, GtkImage image,
+ int x, int y);
native void gtkWidgetSetBackground (int red, int green, int blue);
native void gtkWidgetSetForeground (int red, int green, int blue);
native void gtkWidgetSetSensitive (boolean sensitive);
@@ -149,6 +150,9 @@ public class GtkComponentPeer extends GtkGenericPeer
setNativeEventMask ();
realize ();
+
+ if (awtComponent.isCursorSet())
+ setCursor ();
}
void setParentAndBounds ()
@@ -503,10 +507,28 @@ public class GtkComponentPeer extends GtkGenericPeer
public void setCursor (Cursor cursor)
{
+ int x, y;
+ GtkImage image;
+ int type = cursor.getType();
+ if (cursor instanceof GtkCursor)
+ {
+ GtkCursor gtkCursor = (GtkCursor) cursor;
+ image = gtkCursor.getGtkImage();
+ Point hotspot = gtkCursor.getHotspot();
+ x = hotspot.x;
+ y = hotspot.y;
+ }
+ else
+ {
+ image = null;
+ x = 0;
+ y = 0;
+ }
+
if (Thread.currentThread() == GtkToolkit.mainThread)
- gtkWidgetSetCursorUnlocked (cursor.getType ());
+ gtkWidgetSetCursorUnlocked(cursor.getType(), image, x, y);
else
- gtkWidgetSetCursor (cursor.getType ());
+ gtkWidgetSetCursor(cursor.getType(), image, x, y);
}
public void setEnabled (boolean b)
diff --git a/gnu/java/awt/peer/gtk/GtkToolkit.java b/gnu/java/awt/peer/gtk/GtkToolkit.java
index 084bdd3f2..7757db0c5 100644
--- a/gnu/java/awt/peer/gtk/GtkToolkit.java
+++ b/gnu/java/awt/peer/gtk/GtkToolkit.java
@@ -579,6 +579,11 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit
return q;
}
+ public Cursor createCustomCursor(Image image, Point hotspot, String name)
+ {
+ return new GtkCursor(image, hotspot, name);
+ }
+
protected native void loadSystemColors (int[] systemColors);
public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent e)
diff --git a/include/gnu_java_awt_peer_gtk_GtkComponentPeer.h b/include/gnu_java_awt_peer_gtk_GtkComponentPeer.h
index da86e23a8..207e08d05 100644
--- a/include/gnu_java_awt_peer_gtk_GtkComponentPeer.h
+++ b/include/gnu_java_awt_peer_gtk_GtkComponentPeer.h
@@ -18,8 +18,8 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetGetD
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetGetPreferredDimensions (JNIEnv *env, jobject, jintArray);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWindowGetLocationOnScreen (JNIEnv *env, jobject, jintArray);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetGetLocationOnScreen (JNIEnv *env, jobject, jintArray);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetCursor (JNIEnv *env, jobject, jint);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetCursorUnlocked (JNIEnv *env, jobject, jint);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetCursor (JNIEnv *env, jobject, jint, jobject, jint, jint);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetCursorUnlocked (JNIEnv *env, jobject, jint, jobject, jint, jint);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetBackground (JNIEnv *env, jobject, jint, jint, jint);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetForeground (JNIEnv *env, jobject, jint, jint, jint);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetSensitive (JNIEnv *env, jobject, jboolean);
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
index 6805ae690..fc6002255 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
@@ -192,19 +192,19 @@ state_to_awt_mods_with_button_states (guint state)
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetCursor
- (JNIEnv *env, jobject obj, jint type)
+ (JNIEnv *env, jobject obj, jint type, jobject image, jint x, jint y)
{
gdk_threads_enter ();
Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetCursorUnlocked
- (env, obj, type);
+ (env, obj, type, image, x, y);
gdk_threads_leave ();
}
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetCursorUnlocked
- (JNIEnv *env, jobject obj, jint type)
+ (JNIEnv *env, jobject obj, jint type, jobject image, jint x, jint y)
{
void *ptr;
GtkWidget *widget;
@@ -260,7 +260,14 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetCursorUnlocked
widget = get_widget(GTK_WIDGET(ptr));
- gdk_cursor = gdk_cursor_new (gdk_cursor_type);
+ if (image == NULL)
+ gdk_cursor = gdk_cursor_new (gdk_cursor_type);
+ else
+ gdk_cursor
+ = gdk_cursor_new_from_pixbuf (gdk_drawable_get_display (widget->window),
+ cp_gtk_image_get_pixbuf (env, image),
+ x, y);
+
gdk_window_set_cursor (widget->window, gdk_cursor);
gdk_cursor_unref (gdk_cursor);
}