summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog96
-rw-r--r--gnu/java/awt/peer/gtk/GdkGraphics.java10
-rw-r--r--gnu/java/awt/peer/gtk/GdkGraphics2D.java161
-rw-r--r--gnu/java/awt/peer/gtk/GdkPixbufDecoder.java4
-rw-r--r--gnu/java/awt/peer/gtk/GtkCheckboxPeer.java12
-rw-r--r--gnu/java/awt/peer/gtk/GtkFileDialogPeer.java27
-rw-r--r--gnu/java/awt/peer/gtk/GtkFramePeer.java20
-rw-r--r--gnu/java/awt/peer/gtk/GtkToolkit.java14
-rw-r--r--gnu/java/awt/peer/gtk/GtkWindowPeer.java35
-rw-r--r--include/gnu_java_awt_peer_gtk_GdkGraphics.h1
-rw-r--r--include/gnu_java_awt_peer_gtk_GdkGraphics2D.h11
-rw-r--r--include/gnu_java_awt_peer_gtk_GtkFramePeer.h1
-rw-r--r--include/gnu_java_awt_peer_gtk_GtkWindowPeer.h2
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c33
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c259
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c16
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkButtonPeer.c29
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c4
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkChoicePeer.c7
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkClipboard.c8
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c40
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFileDialogPeer.c96
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFramePeer.c16
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkListPeer.c8
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuItemPeer.c4
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextFieldPeer.c2
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c7
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c84
-rw-r--r--native/jni/gtk-peer/gtkpeer.h1
29 files changed, 678 insertions, 330 deletions
diff --git a/ChangeLog b/ChangeLog
index 624a675b2..c9c97e170 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,99 @@
+2005-08-17 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * gnu/java/awt/peer/gtk/GtkFramePeer.java,
+ gnu_java_awt_peer_gtk_GtkFramePeer.c (postConfigureEvent): Prevent
+ callback calling back into peers.
+ (setBounds): Likewise.
+ (setMenuBarWidthUnlocked): New method.
+ * native/jni/gtk-peer/gtkpeer.h (cp_gtk_filedialog_init_jni):
+ Declare function.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c
+ (gtkInit): Call cp_gtk_filedialog_init_jni.
+ (loadSystemColors): Work around deadlock.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextFieldPeer.c
+ (textcomponent_changed_cb): Don't release GDK lock.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuItemPeer.c
+ (item_activate_cb): Don't release GDK lock.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkListPeer.c
+ (item_highlighted_cb): Don't release GDK lock.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
+ (component_button_press_cb): Don't release GDK lock.
+ (component_button_release_cb): Likewise.
+ (component_motion_notify_cb): Likewise.
+ (component_enter_notify_cb): Likewise.
+ (component_leave_notify_cb): Likewise.
+ (component_expose_cb): Likewise.
+ (component_focus_in_cb): Likewise.
+ (component_focus_out_cb): Likewise.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkButtonPeer.c
+ (block_expose_event_cb): Remove callback.
+ * gnu/java/awt/peer/gtk/GtkWindowPeer.java,
+ gnu_java_awt_peer_gtk_GtkWindowPeer.c (postConfigureEvent):
+ Prevent callback calling back into peers.
+ (setBounds): Likewise.
+ (nativeSetBoundsUnlocked): New method.
+ (setBoundsUnlocked): Likewise.
+ (nativeSetVisibleUnlocked): Likewise.
+ (setVisibleUnlocked): Likewise.
+ (window_delete_cb): Don't release GDK lock.
+ (window_destroy_cb): Likewise.
+ (window_show_cb): Likewise.
+ (window_active_state_change_cb): Likewise.
+ (window_focus_state_change_cb): Likewise.
+ (window_focus_in_cb): Likewise.
+ (window_focus_out_cb): Likewise.
+ (window_window_state_cb): Likewise.
+ (window_property_changed_cb): Likewise.
+ (realize_cb): Likewise.
+ * gnu/java/awt/peer/gtk/GtkToolkit.java (mainThread): New
+ variable.
+ * gnu/java/awt/peer/gtk/GtkFileDialogPeer.java,
+ gnu_java_awt_peer_gtk_GtkFileDialogPeer.c (setVisible): Prevent
+ callback calling back into peers.
+ (filename_filter_cb): Don't release GDK lock.
+ (handle_response_cb): Likewise.
+ (cp_gtk_filedialog_init_jni): New function.
+ * gnu/java/awt/peer/gtk/GtkCheckboxPeer.java (setState): Prevent
+ callback from calling back into peers.
+ (item_toggled_cb): Don't release GDK lock.
+ * gnu/java/awt/peer/gtk/GdkPixbufDecoder.java,
+ gnu_java_awt_peer_gtk_GdkPixbufDecoder.c (area_prepared_cb): Don't
+ release GDK lock.
+ (area_updated_cb): Likewise.
+ * gnu/java/awt/peer/gtk/GdkGraphics2D.java,
+ gnu_java_awt_peer_gtk_GdkGraphics2D.c (initStateUnlocked): New
+ method.
+ (cairoSurfaceSetFilterUnlocked): Likewise.
+ (initComponentGraphics2DUnlocked): Likewise.
+ (setTexturePixelsUnlocked): Likewise.
+ (setGradientUnlocked): Likewise.
+ (cairoSetMatrixUnlocked): Likewise.
+ (cairoSetRGBAColorUnlocked): Likewise.
+ (cairoSetLineWidthUnlocked): Likewise.
+ (cairoSetLineCapUnlocked): Likewise.
+ (cairoSetLineJoinUnlocked): Likewise.
+ (cairoSetDashUnlocked): Likewise.
+ (cairoSetMiterLimitUnlocked): Likewise.
+ (setPaintUnlocked): Likewise.
+ (setTransformUnlocked): Likewise.
+ (setStrokeUnlocked): Likewise.
+ (setColorUnlocked): Likewise.
+ (setBackgroundUnlocked): Likewise.
+ (setRenderingHintsUnlocked): Likewise.
+ (setFontUnlocked): Likewise.
+ (realize_cb): Don't release GDK lock. Call
+ initComponentGraphics2DUnlocked.
+ * gnu/java/awt/peer/gtk/GdkGraphics.java,
+ gnu_java_awt_peer_gtk_GdkGraphics.c (initStateUnlocked): New
+ method.
+ (initComponentGraphicsUnlocked): New method.
+ (realize_cb): Don't release GDK lock. Call
+ initComponentGraphicsUnlocked.
+ * include/gnu_java_awt_peer_gtk_GdkGraphics.h: Regenerate.
+ * include/gnu_java_awt_peer_gtk_GdkGraphics2D.h: Likewise.
+ * include/gnu_java_awt_peer_gtk_GtkFramePeer.h: Likewise.
+ * include/gnu_java_awt_peer_gtk_GtkWindowPeer.h: Likewise.
+
2005-08-17 Tom Tromey <tromey@redhat.com>
* .project: Correctly omit jdwp from vm/reference.
diff --git a/gnu/java/awt/peer/gtk/GdkGraphics.java b/gnu/java/awt/peer/gtk/GdkGraphics.java
index 65c01b86e..9a5195629 100644
--- a/gnu/java/awt/peer/gtk/GdkGraphics.java
+++ b/gnu/java/awt/peer/gtk/GdkGraphics.java
@@ -78,6 +78,7 @@ public class GdkGraphics extends Graphics
static final int GDK_COPY = 0, GDK_XOR = 2;
native void initState (GtkComponentPeer component);
+ native void initStateUnlocked (GtkComponentPeer component);
native void initState (int width, int height);
native void initFromImage (GtkImage image);
native void copyState (GdkGraphics g);
@@ -131,6 +132,15 @@ public class GdkGraphics extends Graphics
clip = new Rectangle (0, 0, d.width, d.height);
}
+ // called back by native side: realize_cb
+ void initComponentGraphicsUnlocked ()
+ {
+ initStateUnlocked (component);
+ color = component.awtComponent.getForeground ();
+ Dimension d = component.awtComponent.getSize ();
+ clip = new Rectangle (0, 0, d.width, d.height);
+ }
+
native void connectSignals (GtkComponentPeer component);
public native void clearRect(int x, int y, int width, int height);
diff --git a/gnu/java/awt/peer/gtk/GdkGraphics2D.java b/gnu/java/awt/peer/gtk/GdkGraphics2D.java
index b8203179d..3563ca9dc 100644
--- a/gnu/java/awt/peer/gtk/GdkGraphics2D.java
+++ b/gnu/java/awt/peer/gtk/GdkGraphics2D.java
@@ -132,12 +132,14 @@ public class GdkGraphics2D extends Graphics2D
Composite comp;
private Stack stateStack;
+ private native void initStateUnlocked(GtkComponentPeer component);
private native void initState(GtkComponentPeer component);
private native void initState(int width, int height);
private native void initState(int[] pixes, int width, int height);
private native void copyState(GdkGraphics2D g);
public native void dispose();
private native void cairoSurfaceSetFilter(int filter);
+ private native void cairoSurfaceSetFilterUnlocked(int filter);
native void connectSignals(GtkComponentPeer component);
public void finalize()
@@ -236,6 +238,21 @@ public class GdkGraphics2D extends Graphics2D
stateStack = new Stack();
}
+ void initComponentGraphics2DUnlocked()
+ {
+ initStateUnlocked(component);
+
+ setColorUnlocked(component.awtComponent.getForeground());
+ setBackgroundUnlocked(component.awtComponent.getBackground());
+ setPaintUnlocked(getColorUnlocked());
+ setTransformUnlocked(new AffineTransform());
+ setStrokeUnlocked(new BasicStroke());
+ setRenderingHintsUnlocked(getDefaultHints());
+ setFontUnlocked(new Font("SansSerif", Font.PLAIN, 12));
+
+ stateStack = new Stack();
+ }
+
GdkGraphics2D(BufferedImage bimage)
{
this.bimage = bimage;
@@ -280,25 +297,37 @@ public class GdkGraphics2D extends Graphics2D
// drawing utility methods
private native void drawPixels(int[] pixels, int w, int h, int stride,
double[] i2u);
+ private native void setTexturePixelsUnlocked(int[] pixels, int w, int h, int stride);
private native void setTexturePixels(int[] pixels, int w, int h, int stride);
private native void setGradient(double x1, double y1, double x2, double y2,
int r1, int g1, int b1, int a1, int r2,
int g2, int b2, int a2, boolean cyclic);
+ private native void setGradientUnlocked(double x1, double y1, double x2, double y2,
+ int r1, int g1, int b1, int a1, int r2,
+ int g2, int b2, int a2, boolean cyclic);
// simple passthroughs to cairo
private native void cairoSave();
private native void cairoRestore();
private native void cairoSetMatrix(double[] m);
+ private native void cairoSetMatrixUnlocked(double[] m);
private native void cairoSetOperator(int cairoOperator);
private native void cairoSetRGBAColor(double red, double green,
double blue, double alpha);
+ private native void cairoSetRGBAColorUnlocked(double red, double green,
+ double blue, double alpha);
private native void cairoSetFillRule(int cairoFillRule);
private native void cairoSetLineWidth(double width);
+ private native void cairoSetLineWidthUnlocked(double width);
private native void cairoSetLineCap(int cairoLineCap);
+ private native void cairoSetLineCapUnlocked(int cairoLineCap);
private native void cairoSetLineJoin(int cairoLineJoin);
+ private native void cairoSetLineJoinUnlocked(int cairoLineJoin);
private native void cairoSetDash(double[] dashes, int ndash, double offset);
+ private native void cairoSetDashUnlocked(double[] dashes, int ndash, double offset);
private native void cairoSetMiterLimit(double limit);
+ private native void cairoSetMiterLimitUnlocked(double limit);
private native void cairoNewPath();
private native void cairoMoveTo(double x, double y);
private native void cairoLineTo(double x, double y);
@@ -689,6 +718,49 @@ public class GdkGraphics2D extends Graphics2D
throw new java.lang.UnsupportedOperationException();
}
+ public void setPaintUnlocked(Paint p)
+ {
+ if (paint == null)
+ return;
+
+ paint = p;
+ if (paint instanceof Color)
+ {
+ setColorUnlocked((Color) paint);
+ }
+ else if (paint instanceof TexturePaint)
+ {
+ TexturePaint tp = (TexturePaint) paint;
+ BufferedImage img = tp.getImage();
+
+ // map the image to the anchor rectangle
+ int width = (int) tp.getAnchorRect().getWidth();
+ int height = (int) tp.getAnchorRect().getHeight();
+
+ double scaleX = width / (double) img.getWidth();
+ double scaleY = width / (double) img.getHeight();
+
+ AffineTransform at = new AffineTransform(scaleX, 0, 0, scaleY, 0, 0);
+ AffineTransformOp op = new AffineTransformOp(at, getRenderingHints());
+ BufferedImage texture = op.filter(img, null);
+ int[] pixels = texture.getRGB(0, 0, width, height, null, 0, width);
+ setTexturePixelsUnlocked(pixels, width, height, width);
+ }
+ else if (paint instanceof GradientPaint)
+ {
+ GradientPaint gp = (GradientPaint) paint;
+ Point2D p1 = gp.getPoint1();
+ Point2D p2 = gp.getPoint2();
+ Color c1 = gp.getColor1();
+ Color c2 = gp.getColor2();
+ setGradientUnlocked(p1.getX(), p1.getY(), p2.getX(), p2.getY(), c1.getRed(),
+ c1.getGreen(), c1.getBlue(), c1.getAlpha(), c2.getRed(),
+ c2.getGreen(), c2.getBlue(), c2.getAlpha(), gp.isCyclic());
+ }
+ else
+ throw new java.lang.UnsupportedOperationException();
+ }
+
public void setTransform(AffineTransform tx)
{
transform = tx;
@@ -700,6 +772,17 @@ public class GdkGraphics2D extends Graphics2D
}
}
+ public void setTransformUnlocked(AffineTransform tx)
+ {
+ transform = tx;
+ if (transform != null)
+ {
+ double[] m = new double[6];
+ transform.getMatrix(m);
+ cairoSetMatrixUnlocked(m);
+ }
+ }
+
public void transform(AffineTransform tx)
{
if (transform == null)
@@ -787,6 +870,28 @@ public class GdkGraphics2D extends Graphics2D
}
}
+ public void setStrokeUnlocked(Stroke st)
+ {
+ stroke = st;
+ if (stroke instanceof BasicStroke)
+ {
+ BasicStroke bs = (BasicStroke) stroke;
+ cairoSetLineCapUnlocked(bs.getEndCap());
+ cairoSetLineWidthUnlocked(bs.getLineWidth());
+ cairoSetLineJoinUnlocked(bs.getLineJoin());
+ cairoSetMiterLimitUnlocked(bs.getMiterLimit());
+ float[] dashes = bs.getDashArray();
+ if (dashes != null)
+ {
+ double[] double_dashes = new double[dashes.length];
+ for (int i = 0; i < dashes.length; i++)
+ double_dashes[i] = dashes[i];
+ cairoSetDashUnlocked(double_dashes, double_dashes.length,
+ (double) bs.getDashPhase());
+ }
+ }
+ }
+
////////////////////////////////////////////////
////// Implementation of Graphics Methods //////
////////////////////////////////////////////////
@@ -812,11 +917,27 @@ public class GdkGraphics2D extends Graphics2D
fg.getBlue() / 255.0, fg.getAlpha() / 255.0);
}
+ public void setColorUnlocked(Color c)
+ {
+ if (c == null)
+ c = Color.BLACK;
+
+ fg = c;
+ paint = c;
+ cairoSetRGBAColorUnlocked(fg.getRed() / 255.0, fg.getGreen() / 255.0,
+ fg.getBlue() / 255.0, fg.getAlpha() / 255.0);
+ }
+
public Color getColor()
{
return fg;
}
+ public Color getColorUnlocked()
+ {
+ return getColor();
+ }
+
public void clipRect(int x, int y, int width, int height)
{
clip(new Rectangle(x, y, width, height));
@@ -929,6 +1050,11 @@ public class GdkGraphics2D extends Graphics2D
bg = c;
}
+ public void setBackgroundUnlocked(Color c)
+ {
+ setBackground(c);
+ }
+
public Color getBackground()
{
return bg;
@@ -1180,6 +1306,36 @@ public class GdkGraphics2D extends Graphics2D
|| hints.containsValue(RenderingHints.VALUE_STROKE_DEFAULT);
}
+ public void setRenderingHintsUnlocked(Map hints)
+ {
+ this.hints = new RenderingHints(getDefaultHints());
+ this.hints.add(new RenderingHints(hints));
+
+ if (hints.containsKey(RenderingHints.KEY_INTERPOLATION))
+ {
+ if (hints.containsValue(RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR))
+ cairoSurfaceSetFilterUnlocked(0);
+
+ else if (hints.containsValue(RenderingHints.VALUE_INTERPOLATION_BILINEAR))
+ cairoSurfaceSetFilterUnlocked(1);
+ }
+
+ if (hints.containsKey(RenderingHints.KEY_ALPHA_INTERPOLATION))
+ {
+ if (hints.containsValue(RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED))
+ cairoSurfaceSetFilterUnlocked(2);
+
+ else if (hints.containsValue(RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY))
+ cairoSurfaceSetFilterUnlocked(3);
+
+ else if (hints.containsValue(RenderingHints.VALUE_ALPHA_INTERPOLATION_DEFAULT))
+ cairoSurfaceSetFilterUnlocked(4);
+ }
+
+ shiftDrawCalls = hints.containsValue(RenderingHints.VALUE_STROKE_NORMALIZE)
+ || hints.containsValue(RenderingHints.VALUE_STROKE_DEFAULT);
+ }
+
public void addRenderingHints(Map hints)
{
this.hints.add(new RenderingHints(hints));
@@ -1443,6 +1599,11 @@ public class GdkGraphics2D extends Graphics2D
.getFont(f.getName(), f.getAttributes());
}
+ public void setFontUnlocked(Font f)
+ {
+ setFont (f);
+ }
+
public String toString()
{
return (getClass().getName()
diff --git a/gnu/java/awt/peer/gtk/GdkPixbufDecoder.java b/gnu/java/awt/peer/gtk/GdkPixbufDecoder.java
index 57d5a36da..90bef8495 100644
--- a/gnu/java/awt/peer/gtk/GdkPixbufDecoder.java
+++ b/gnu/java/awt/peer/gtk/GdkPixbufDecoder.java
@@ -122,7 +122,7 @@ public class GdkPixbufDecoder extends gnu.java.awt.image.ImageDecoder
super (imagedata, imageoffset, imagelength);
}
- // called back by native side
+ // called back by native side: area_prepared_cb
void areaPrepared (int width, int height)
{
@@ -138,7 +138,7 @@ public class GdkPixbufDecoder extends gnu.java.awt.image.ImageDecoder
}
}
- // called back by native side
+ // called back by native side: area_updated_cb
void areaUpdated (int x, int y, int width, int height,
int pixels[], int scansize)
{
diff --git a/gnu/java/awt/peer/gtk/GtkCheckboxPeer.java b/gnu/java/awt/peer/gtk/GtkCheckboxPeer.java
index 851757245..3e05cf8ab 100644
--- a/gnu/java/awt/peer/gtk/GtkCheckboxPeer.java
+++ b/gnu/java/awt/peer/gtk/GtkCheckboxPeer.java
@@ -49,6 +49,7 @@ public class GtkCheckboxPeer extends GtkComponentPeer
public GtkCheckboxGroupPeer old_group;
// The current state of the GTK checkbox.
private boolean currentState;
+ private boolean changing = false;
public native void create (GtkCheckboxGroupPeer group);
public native void nativeSetCheckboxGroup (GtkCheckboxGroupPeer group);
@@ -76,6 +77,15 @@ public class GtkCheckboxPeer extends GtkComponentPeer
public void setState (boolean state)
{
+ // prevent item_toggled_cb -> postItemEvent ->
+ // awtComponent.setState -> this.setState ->
+ // gtkToggleButtonSetActive self-deadlock on the GDK lock.
+ if (changing && Thread.currentThread() == GtkToolkit.mainThread)
+ {
+ changing = false;
+ return;
+ }
+
if (currentState != state)
gtkToggleButtonSetActive (state);
}
@@ -100,6 +110,7 @@ public class GtkCheckboxPeer extends GtkComponentPeer
// Override the superclass postItemEvent so that the peer doesn't
// need information that we have.
+ // called back by native side: item_toggled_cb
public void postItemEvent (Object item, int stateChange)
{
Checkbox currentCheckBox = ((Checkbox)awtComponent);
@@ -113,6 +124,7 @@ public class GtkCheckboxPeer extends GtkComponentPeer
{
super.postItemEvent (awtComponent, stateChange);
currentState = !currentCheckBox.getState();
+ changing = true;
currentCheckBox.setState(currentState);
}
}
diff --git a/gnu/java/awt/peer/gtk/GtkFileDialogPeer.java b/gnu/java/awt/peer/gtk/GtkFileDialogPeer.java
index a2bd609d4..7a6b94d90 100644
--- a/gnu/java/awt/peer/gtk/GtkFileDialogPeer.java
+++ b/gnu/java/awt/peer/gtk/GtkFileDialogPeer.java
@@ -62,6 +62,8 @@ public class GtkFileDialogPeer extends GtkDialogPeer implements FileDialogPeer
public native void nativeSetDirectory(String directory);
native void nativeSetFilenameFilter (FilenameFilter filter);
+ private boolean hiding = false;
+
public void create()
{
create((GtkContainerPeer) awtComponent.getParent().getPeer());
@@ -156,6 +158,7 @@ public class GtkFileDialogPeer extends GtkDialogPeer implements FileDialogPeer
GtkFileFilterInfo object and send it to this method, which will
in turn call the filter's accept() method and give back the return
value. */
+ // called back by native side: filename_filter_cb
boolean filenameFilterCallback (String fullname) {
String filename = fullname.substring(fullname.lastIndexOf(FS) + 1);
String dirname = fullname.substring(0, fullname.lastIndexOf(FS));
@@ -169,19 +172,37 @@ public class GtkFileDialogPeer extends GtkDialogPeer implements FileDialogPeer
return null;
}
+ public void setVisible (boolean b)
+ {
+ // prevent handle_response_cb -> postItemEvent -> awtComponent.setState -> this.setState
+ // -> gtkToggleButtonSetActive self-deadlock on the GDK lock.
+ if (hiding && Thread.currentThread() == GtkToolkit.mainThread)
+ {
+ setVisibleUnlocked (b);
+ hiding = false;
+ }
+ else
+ super.setVisible (b);
+ }
+
+ // called back by native side: handle_response_cb
void gtkHideFileDialog ()
{
+ // hide calls back the peer's setVisible method, so locking is a
+ // problem.
+ hiding = true;
((Dialog) awtComponent).hide();
}
+ // called back by native side: handle_response_cb
void gtkDisposeFileDialog ()
{
((Dialog) awtComponent).dispose();
}
- /* Callback to set the file and directory values when the user is finished
- * with the dialog.
- */
+ // Callback to set the file and directory values when the user is finished
+ // with the dialog.
+ // called back by native side: handle_response_cb
void gtkSetFilename (String fileName)
{
FileDialog fd = (FileDialog) awtWidget;
diff --git a/gnu/java/awt/peer/gtk/GtkFramePeer.java b/gnu/java/awt/peer/gtk/GtkFramePeer.java
index 8def405d2..c7f197405 100644
--- a/gnu/java/awt/peer/gtk/GtkFramePeer.java
+++ b/gnu/java/awt/peer/gtk/GtkFramePeer.java
@@ -56,11 +56,14 @@ public class GtkFramePeer extends GtkWindowPeer
private int menuBarHeight;
private MenuBarPeer menuBar;
native int getMenuBarHeight (MenuBarPeer bar);
+ native void setMenuBarWidthUnlocked (MenuBarPeer bar, int width);
native void setMenuBarWidth (MenuBarPeer bar, int width);
native void setMenuBarPeer (MenuBarPeer bar);
native void removeMenuBarPeer ();
native void gtkFixedSetVisible (boolean visible);
+ private boolean resizing = false;
+
int getMenuBarHeight ()
{
return menuBar == null ? 0 : getMenuBarHeight (menuBar);
@@ -118,6 +121,18 @@ public class GtkFramePeer extends GtkWindowPeer
public void setBounds (int x, int y, int width, int height)
{
+ // prevent window_configure_cb -> awtComponent.setSize ->
+ // peer.setBounds -> nativeSetBounds self-deadlock on GDK lock.
+ if (resizing && Thread.currentThread() == GtkToolkit.mainThread)
+ {
+ int menuBarWidth = width - insets.left - insets.right;
+ if (menuBar != null && menuBarWidth > 0)
+ setMenuBarWidthUnlocked (menuBar, menuBarWidth);
+
+ resizing = false;
+ return;
+ }
+
int menuBarWidth = width - insets.left - insets.right;
if (menuBar != null && menuBarWidth > 0)
setMenuBarWidth (menuBar, menuBarWidth);
@@ -200,7 +215,10 @@ public class GtkFramePeer extends GtkWindowPeer
if (frame_width != awtComponent.getWidth()
|| frame_height != awtComponent.getHeight())
- awtComponent.setSize(frame_width, frame_height);
+ {
+ resizing = true;
+ awtComponent.setSize(frame_width, frame_height);
+ }
int frame_x = x - insets.left;
// Likewise, since insets.top includes the MenuBar height, we need
diff --git a/gnu/java/awt/peer/gtk/GtkToolkit.java b/gnu/java/awt/peer/gtk/GtkToolkit.java
index ef97685a3..70957b9df 100644
--- a/gnu/java/awt/peer/gtk/GtkToolkit.java
+++ b/gnu/java/awt/peer/gtk/GtkToolkit.java
@@ -90,6 +90,7 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit
static EventQueue q;
static boolean useGraphics2dSet;
static boolean useGraphics2d;
+ static Thread mainThread;
public static boolean useGraphics2D()
{
@@ -124,13 +125,14 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit
// Register ImageIO SPIs
GdkPixbufDecoder.registerSpis( IIORegistry.getDefaultInstance() );
- new Thread ("GTK main thread")
- {
- public void run ()
+ mainThread = new Thread ("GTK main thread")
{
- gtkMain ();
- }
- }.start ();
+ public void run ()
+ {
+ gtkMain ();
+ }
+ };
+ mainThread.start ();
}
public GtkToolkit ()
diff --git a/gnu/java/awt/peer/gtk/GtkWindowPeer.java b/gnu/java/awt/peer/gtk/GtkWindowPeer.java
index 32e4cee44..518c52662 100644
--- a/gnu/java/awt/peer/gtk/GtkWindowPeer.java
+++ b/gnu/java/awt/peer/gtk/GtkWindowPeer.java
@@ -60,6 +60,8 @@ public class GtkWindowPeer extends GtkContainerPeer
private boolean hasBeenShown = false;
private int oldState = Frame.NORMAL;
+ private boolean resizing = false;
+
native void gtkWindowSetTitle (String title);
native void gtkWindowSetResizable (boolean resizable);
native void gtkWindowSetModal (boolean modal);
@@ -116,14 +118,29 @@ public class GtkWindowPeer extends GtkContainerPeer
public native void toFront();
native void nativeSetBounds (int x, int y, int width, int height);
+ native void nativeSetBoundsUnlocked (int x, int y, int width, int height);
public void setBounds (int x, int y, int width, int height)
{
+ // prevent window_configure_cb -> awtComponent.setSize ->
+ // peer.setBounds -> nativeSetBounds self-deadlock on GDK lock.
+ if (resizing && Thread.currentThread() == GtkToolkit.mainThread)
+ {
+ resizing = false;
+ return;
+ }
nativeSetBounds (x, y,
width - insets.left - insets.right,
height - insets.top - insets.bottom);
}
+ public void setBoundsUnlocked (int x, int y, int width, int height)
+ {
+ nativeSetBoundsUnlocked (x, y,
+ width - insets.left - insets.right,
+ height - insets.top - insets.bottom);
+ }
+
public void setTitle (String title)
{
gtkWindowSetTitle (title);
@@ -157,7 +174,10 @@ public class GtkWindowPeer extends GtkContainerPeer
if (frame_width != awtComponent.getWidth()
|| frame_height != awtComponent.getHeight())
- awtComponent.setSize(frame_width, frame_height);
+ {
+ resizing = true;
+ awtComponent.setSize(frame_width, frame_height);
+ }
int frame_x = x - insets.left;
int frame_y = y - insets.top;
@@ -182,6 +202,19 @@ public class GtkWindowPeer extends GtkContainerPeer
nativeSetVisible (b);
}
+ native void nativeSetVisibleUnlocked (boolean b);
+ public void setVisibleUnlocked (boolean b)
+ {
+ // Prevent the window manager from automatically placing this
+ // window when it is shown.
+ if (b)
+ setBoundsUnlocked (awtComponent.getX(),
+ awtComponent.getY(),
+ awtComponent.getWidth(),
+ awtComponent.getHeight());
+ nativeSetVisibleUnlocked (b);
+ }
+
void postWindowEvent (int id, Window opposite, int newState)
{
if (id == WindowEvent.WINDOW_OPENED)
diff --git a/include/gnu_java_awt_peer_gtk_GdkGraphics.h b/include/gnu_java_awt_peer_gtk_GdkGraphics.h
index 009fa3fc9..427f0916d 100644
--- a/include/gnu_java_awt_peer_gtk_GdkGraphics.h
+++ b/include/gnu_java_awt_peer_gtk_GdkGraphics.h
@@ -12,6 +12,7 @@ extern "C"
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_initStaticState (JNIEnv *env, jclass);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_initState__Lgnu_java_awt_peer_gtk_GtkComponentPeer_2 (JNIEnv *env, jobject, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_initStateUnlocked (JNIEnv *env, jobject, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_initState__II (JNIEnv *env, jobject, jint, jint);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_initFromImage (JNIEnv *env, jobject, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_copyState (JNIEnv *env, jobject, jobject);
diff --git a/include/gnu_java_awt_peer_gtk_GdkGraphics2D.h b/include/gnu_java_awt_peer_gtk_GdkGraphics2D.h
index 0f9d04fb7..2d29cfc73 100644
--- a/include/gnu_java_awt_peer_gtk_GdkGraphics2D.h
+++ b/include/gnu_java_awt_peer_gtk_GdkGraphics2D.h
@@ -11,28 +11,39 @@ extern "C"
#endif
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_initStaticState (JNIEnv *env, jclass);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_initStateUnlocked (JNIEnv *env, jobject, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_initState__Lgnu_java_awt_peer_gtk_GtkComponentPeer_2 (JNIEnv *env, jobject, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_initState__II (JNIEnv *env, jobject, jint, jint);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_initState___3III (JNIEnv *env, jobject, jintArray, jint, jint);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_copyState (JNIEnv *env, jobject, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_dispose (JNIEnv *env, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSurfaceSetFilter (JNIEnv *env, jobject, jint);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSurfaceSetFilterUnlocked (JNIEnv *env, jobject, jint);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_connectSignals (JNIEnv *env, jobject, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_gdkDrawDrawable (JNIEnv *env, jobject, jobject, jint, jint);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_drawPixels (JNIEnv *env, jobject, jintArray, jint, jint, jint, jdoubleArray);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setTexturePixelsUnlocked (JNIEnv *env, jobject, jintArray, jint, jint, jint);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setTexturePixels (JNIEnv *env, jobject, jintArray, jint, jint, jint);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setGradient (JNIEnv *env, jobject, jdouble, jdouble, jdouble, jdouble, jint, jint, jint, jint, jint, jint, jint, jint, jboolean);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setGradientUnlocked (JNIEnv *env, jobject, jdouble, jdouble, jdouble, jdouble, jint, jint, jint, jint, jint, jint, jint, jint, jboolean);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSave (JNIEnv *env, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoRestore (JNIEnv *env, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetMatrix (JNIEnv *env, jobject, jdoubleArray);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetMatrixUnlocked (JNIEnv *env, jobject, jdoubleArray);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetOperator (JNIEnv *env, jobject, jint);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetRGBAColor (JNIEnv *env, jobject, jdouble, jdouble, jdouble, jdouble);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetRGBAColorUnlocked (JNIEnv *env, jobject, jdouble, jdouble, jdouble, jdouble);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetFillRule (JNIEnv *env, jobject, jint);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineWidth (JNIEnv *env, jobject, jdouble);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineWidthUnlocked (JNIEnv *env, jobject, jdouble);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineCap (JNIEnv *env, jobject, jint);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineCapUnlocked (JNIEnv *env, jobject, jint);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineJoin (JNIEnv *env, jobject, jint);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineJoinUnlocked (JNIEnv *env, jobject, jint);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetDash (JNIEnv *env, jobject, jdoubleArray, jint, jdouble);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetDashUnlocked (JNIEnv *env, jobject, jdoubleArray, jint, jdouble);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetMiterLimit (JNIEnv *env, jobject, jdouble);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetMiterLimitUnlocked (JNIEnv *env, jobject, jdouble);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoNewPath (JNIEnv *env, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoMoveTo (JNIEnv *env, jobject, jdouble, jdouble);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoLineTo (JNIEnv *env, jobject, jdouble, jdouble);
diff --git a/include/gnu_java_awt_peer_gtk_GtkFramePeer.h b/include/gnu_java_awt_peer_gtk_GtkFramePeer.h
index f3831312a..2095d421c 100644
--- a/include/gnu_java_awt_peer_gtk_GtkFramePeer.h
+++ b/include/gnu_java_awt_peer_gtk_GtkFramePeer.h
@@ -11,6 +11,7 @@ extern "C"
#endif
JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_gtk_GtkFramePeer_getMenuBarHeight (JNIEnv *env, jobject, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkFramePeer_setMenuBarWidthUnlocked (JNIEnv *env, jobject, jobject, jint);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkFramePeer_setMenuBarWidth (JNIEnv *env, jobject, jobject, jint);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkFramePeer_setMenuBarPeer (JNIEnv *env, jobject, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkFramePeer_removeMenuBarPeer (JNIEnv *env, jobject);
diff --git a/include/gnu_java_awt_peer_gtk_GtkWindowPeer.h b/include/gnu_java_awt_peer_gtk_GtkWindowPeer.h
index 5d3f132ea..eb4ccaf0c 100644
--- a/include/gnu_java_awt_peer_gtk_GtkWindowPeer.h
+++ b/include/gnu_java_awt_peer_gtk_GtkWindowPeer.h
@@ -19,8 +19,10 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkWindowPeer_connectSignals (
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkWindowPeer_toBack (JNIEnv *env, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkWindowPeer_toFront (JNIEnv *env, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkWindowPeer_nativeSetBounds (JNIEnv *env, jobject, jint, jint, jint, jint);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkWindowPeer_nativeSetBoundsUnlocked (JNIEnv *env, jobject, jint, jint, jint, jint);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkWindowPeer_setSize (JNIEnv *env, jobject, jint, jint);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkWindowPeer_nativeSetVisible (JNIEnv *env, jobject, jboolean);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkWindowPeer_nativeSetVisibleUnlocked (JNIEnv *env, jobject, jboolean);
#undef gnu_java_awt_peer_gtk_GtkWindowPeer_GDK_WINDOW_TYPE_HINT_NORMAL
#define gnu_java_awt_peer_gtk_GtkWindowPeer_GDK_WINDOW_TYPE_HINT_NORMAL 0L
#undef gnu_java_awt_peer_gtk_GtkWindowPeer_GDK_WINDOW_TYPE_HINT_DIALOG
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c
index 4a87aa744..b122eb015 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c
@@ -41,7 +41,7 @@ exception statement from your version. */
#include <gdk/gdkprivate.h>
#include <gdk/gdkx.h>
-static jmethodID initComponentGraphicsID;
+static jmethodID initComponentGraphicsUnlockedID;
void
cp_gtk_graphics_init_jni (void)
@@ -51,9 +51,10 @@ cp_gtk_graphics_init_jni (void)
gdkgraphics = (*cp_gtk_gdk_env())->FindClass (cp_gtk_gdk_env(),
"gnu/java/awt/peer/gtk/GdkGraphics");
- initComponentGraphicsID = (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(), gdkgraphics,
- "initComponentGraphics",
- "()V");
+ initComponentGraphicsUnlockedID =
+ (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(), gdkgraphics,
+ "initComponentGraphicsUnlocked",
+ "()V");
}
struct state_table *cp_gtk_native_graphics_state_table;
@@ -175,10 +176,8 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_initFromImage
gdk_threads_leave ();
}
-/* copy the native state of the peer (GtkWidget *) to the native state
- of the graphics object */
JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics_initState__Lgnu_java_awt_peer_gtk_GtkComponentPeer_2
+Java_gnu_java_awt_peer_gtk_GdkGraphics_initStateUnlocked
(JNIEnv *env, jobject obj, jobject peer)
{
struct graphics *g = NULL;
@@ -186,8 +185,6 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_initState__Lgnu_java_awt_peer_gtk_GtkComp
GtkWidget *widget = NULL;
GdkColor color;
- gdk_threads_enter ();
-
g = (struct graphics *) g_malloc (sizeof (struct graphics));
ptr = NSA_GET_PTR (env, peer);
g->x_offset = 0;
@@ -204,7 +201,17 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_initState__Lgnu_java_awt_peer_gtk_GtkComp
color = widget->style->fg[GTK_STATE_NORMAL];
NSA_SET_G_PTR (env, obj, g);
+}
+/* copy the native state of the peer (GtkWidget *) to the native state
+ of the graphics object */
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GdkGraphics_initState__Lgnu_java_awt_peer_gtk_GtkComponentPeer_2
+ (JNIEnv *env, jobject obj, jobject peer)
+{
+ gdk_threads_enter ();
+ Java_gnu_java_awt_peer_gtk_GdkGraphics_initStateUnlocked
+ (env, obj, peer);
gdk_threads_leave ();
}
@@ -666,11 +673,9 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_setClipRectangle
static void
realize_cb (GtkWidget *widget __attribute__ ((unused)), jobject jgraphics)
{
- gdk_threads_leave ();
-
- (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), jgraphics, initComponentGraphicsID);
+ (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(),
+ jgraphics,
+ initComponentGraphicsUnlockedID);
NSA_DEL_GLOBAL_G_REF (cp_gtk_gdk_env(), jgraphics);
-
- gdk_threads_enter ();
}
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c
index b4bd676e7..fe9980ffd 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c
@@ -52,7 +52,7 @@
#include <stdio.h>
#include <stdlib.h>
-static jmethodID initComponentGraphics2DID;
+static jmethodID initComponentGraphics2DUnlockedID;
void
cp_gtk_graphics2d_init_jni (void)
@@ -62,8 +62,8 @@ cp_gtk_graphics2d_init_jni (void)
gdkgraphics2d = (*cp_gtk_gdk_env())->FindClass (cp_gtk_gdk_env(),
"gnu/java/awt/peer/gtk/GdkGraphics2D");
- initComponentGraphics2DID = (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(), gdkgraphics2d,
- "initComponentGraphics2D",
+ initComponentGraphics2DUnlockedID = (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(), gdkgraphics2d,
+ "initComponentGraphics2DUnlocked",
"()V");
}
@@ -369,11 +369,9 @@ check_for_debug (struct graphics2d *gr)
static void
realize_cb (GtkWidget *widget __attribute__ ((unused)), jobject peer)
{
- gdk_threads_leave ();
-
- (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer, initComponentGraphics2DID);
-
- gdk_threads_enter ();
+ (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(),
+ peer,
+ initComponentGraphics2DUnlockedID);
}
JNIEXPORT void JNICALL
@@ -593,6 +591,43 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_gdkDrawDrawable
}
JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GdkGraphics2D_initStateUnlocked
+ (JNIEnv *env, jobject obj, jobject peer)
+{
+ struct graphics2d *gr = NULL;
+ GtkWidget *widget = NULL;
+ void *ptr = NULL;
+
+ if (peer_is_disposed(env, obj))
+ return;
+
+ ptr = NSA_GET_PTR (env, peer);
+ g_assert (ptr != NULL);
+
+ gr = (struct graphics2d *) g_malloc (sizeof (struct graphics2d));
+ g_assert (gr != NULL);
+ memset (gr, 0, sizeof(struct graphics2d));
+
+ check_for_debug (gr);
+
+ widget = GTK_WIDGET (ptr);
+ g_assert (widget != NULL);
+
+ grab_current_drawable (widget, &(gr->drawable), &(gr->win));
+ g_assert (gr->drawable != NULL);
+
+ gr->width = widget->allocation.width;
+ gr->height = widget->allocation.height;
+
+ if (x_server_has_render_extension ())
+ init_graphics2d_as_renderable (gr);
+ else
+ init_graphics2d_as_pixbuf (gr);
+
+ NSA_SET_G2D_PTR (env, obj, gr);
+}
+
+JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkGraphics2D_initState__Lgnu_java_awt_peer_gtk_GtkComponentPeer_2
(JNIEnv *env, jobject obj, jobject peer)
{
@@ -711,21 +746,36 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setGradient
jint r2, jint g2, jint b2, jint a2,
jboolean cyclic)
{
+ gdk_threads_enter();
+ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setGradientUnlocked
+ (env, obj,
+ x1, y1, x2, y2,
+ r1, g1, b1, a1,
+ r2, g2, b2, a2,
+ cyclic);
+
+ gdk_threads_leave();
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setGradientUnlocked
+ (JNIEnv *env, jobject obj,
+ jdouble x1, jdouble y1,
+ jdouble x2, jdouble y2,
+ jint r1, jint g1, jint b1, jint a1,
+ jint r2, jint g2, jint b2, jint a2,
+ jboolean cyclic)
+{
struct graphics2d *gr = NULL;
cairo_surface_t *surf = NULL;
cairo_t *cr2 = NULL;
cairo_matrix_t mat;
- gdk_threads_enter();
-
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
if (peer_is_disposed(env, obj))
- {
- gdk_threads_leave ();
- return;
- }
+ return;
if (gr->debug) printf ("setGradient (%f,%f) -> (%f,%f); (%d,%d,%d,%d) -> (%d,%d,%d,%d)\n",
x1, y1,
@@ -826,24 +876,29 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setGradient
gr->pattern = cairo_pattern_create_for_surface(surf);
cairo_set_source (gr->cr, gr->pattern);
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setTexturePixels
+ (JNIEnv *env, jobject obj, jintArray jarr, jint w, jint h, jint stride)
+{
+ gdk_threads_enter();
+
+ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setTexturePixelsUnlocked
+ (env, obj, jarr, w, h, stride);
gdk_threads_leave();
}
JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setTexturePixels
+Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setTexturePixelsUnlocked
(JNIEnv *env, jobject obj, jintArray jarr, jint w, jint h, jint stride)
{
struct graphics2d *gr = NULL;
jint *jpixels = NULL;
- gdk_threads_enter();
-
if (peer_is_disposed(env, obj))
- {
- gdk_threads_leave ();
- return;
- }
+ return;
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
@@ -880,8 +935,6 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setTexturePixels
gr->pattern = cairo_pattern_create_for_surface (gr->pattern_surface);
g_assert (gr->pattern != NULL);
cairo_set_source (gr->cr, gr->pattern);
-
- gdk_threads_leave();
}
JNIEXPORT void JNICALL
@@ -996,26 +1049,30 @@ JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetMatrix
(JNIEnv *env, jobject obj, jdoubleArray java_matrix)
{
+ gdk_threads_enter();
+
+ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetMatrixUnlocked
+ (env, obj, java_matrix);
+
+ gdk_threads_leave();
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetMatrixUnlocked
+ (JNIEnv *env, jobject obj, jdoubleArray java_matrix)
+{
struct graphics2d *gr = NULL;
jdouble *native_matrix = NULL;
- gdk_threads_enter();
-
if (peer_is_disposed(env, obj))
- {
- gdk_threads_leave ();
- return;
- }
+ return;
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
/* cairoSetMatrix was called before this graphics object's component
was realized. */
if (gr == NULL)
- {
- gdk_threads_leave ();
- return;
- }
+ return;
native_matrix = (*env)->GetDoubleArrayElements (env, java_matrix, NULL);
g_assert (native_matrix != NULL);
@@ -1039,8 +1096,6 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetMatrix
(*env)->ReleaseDoubleArrayElements (env, java_matrix, native_matrix, 0);
update_pattern_transform (gr);
-
- gdk_threads_leave();
}
static void
@@ -1357,15 +1412,22 @@ JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetRGBAColor
(JNIEnv *env, jobject obj, jdouble r, jdouble g, jdouble b, jdouble a)
{
- struct graphics2d *gr = NULL;
-
gdk_threads_enter();
+ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetRGBAColorUnlocked
+ (env, obj, r, g, b, a);
+
+ gdk_threads_leave();
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetRGBAColorUnlocked
+ (JNIEnv *env, jobject obj, jdouble r, jdouble g, jdouble b, jdouble a)
+{
+ struct graphics2d *gr = NULL;
+
if (peer_is_disposed(env, obj))
- {
- gdk_threads_leave ();
- return;
- }
+ return;
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
@@ -1381,8 +1443,6 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetRGBAColor
cairo_set_source_rgba (gr->cr, b, g, r, a);
else
cairo_set_source_rgba (gr->cr, r, g, b, a);
-
- gdk_threads_leave();
}
JNIEXPORT void JNICALL
@@ -1419,10 +1479,20 @@ JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineWidth
(JNIEnv *env, jobject obj, jdouble width)
{
- struct graphics2d *gr = NULL;
-
gdk_threads_enter();
+ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineWidthUnlocked
+ (env, obj, width);
+
+ gdk_threads_leave();
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineWidthUnlocked
+ (JNIEnv *env, jobject obj, jdouble width)
+{
+ struct graphics2d *gr = NULL;
+
if (peer_is_disposed(env, obj))
return;
@@ -1430,23 +1500,28 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineWidth
g_assert (gr != NULL);
if (gr->debug) printf ("cairo_set_line_width %f\n", width);
cairo_set_line_width (gr->cr, width);
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineCap
+ (JNIEnv *env, jobject obj, jint cap)
+{
+ gdk_threads_enter();
+
+ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineCapUnlocked
+ (env, obj, cap);
gdk_threads_leave();
}
JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineCap
+Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineCapUnlocked
(JNIEnv *env, jobject obj, jint cap)
{
struct graphics2d *gr = NULL;
- gdk_threads_enter();
-
if (peer_is_disposed(env, obj))
- {
- gdk_threads_leave ();
- return;
- }
+ return;
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
@@ -1465,23 +1540,28 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineCap
cairo_set_line_cap (gr->cr, CAIRO_LINE_CAP_SQUARE);
break;
}
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineJoin
+ (JNIEnv *env, jobject obj, jint join)
+{
+ gdk_threads_enter();
+
+ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineJoinUnlocked
+ (env, obj, join);
gdk_threads_leave();
}
JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineJoin
+Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineJoinUnlocked
(JNIEnv *env, jobject obj, jint join)
{
struct graphics2d *gr = NULL;
- gdk_threads_enter();
-
if (peer_is_disposed(env, obj))
- {
- gdk_threads_leave ();
- return;
- }
+ return;
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
@@ -1500,24 +1580,29 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineJoin
cairo_set_line_join (gr->cr, CAIRO_LINE_JOIN_BEVEL);
break;
}
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetDash
+ (JNIEnv *env, jobject obj, jdoubleArray dashes, jint ndash, jdouble offset)
+{
+ gdk_threads_enter();
+
+ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetDashUnlocked
+ (env, obj, dashes, ndash, offset);
gdk_threads_leave();
}
JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetDash
+Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetDashUnlocked
(JNIEnv *env, jobject obj, jdoubleArray dashes, jint ndash, jdouble offset)
{
struct graphics2d *gr = NULL;
jdouble *dasharr = NULL;
- gdk_threads_enter();
-
if (peer_is_disposed(env, obj))
- {
- gdk_threads_leave ();
- return;
- }
+ return;
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
@@ -1526,30 +1611,33 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetDash
g_assert (dasharr != NULL);
cairo_set_dash (gr->cr, dasharr, ndash, offset);
(*env)->ReleaseDoubleArrayElements (env, dashes, dasharr, 0);
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetMiterLimit
+ (JNIEnv *env, jobject obj, jdouble miter)
+{
+ gdk_threads_enter();
+
+ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetMiterLimitUnlocked
+ (env, obj, miter);
gdk_threads_leave();
}
JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetMiterLimit
+Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetMiterLimitUnlocked
(JNIEnv *env, jobject obj, jdouble miter)
{
struct graphics2d *gr = NULL;
- gdk_threads_enter();
-
if (peer_is_disposed(env, obj))
- {
- gdk_threads_leave ();
- return;
- }
+ return;
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
if (gr->debug) printf ("cairo_set_miter_limit %f\n", miter);
cairo_set_miter_limit (gr->cr, miter);
-
- gdk_threads_leave();
}
JNIEXPORT void JNICALL
@@ -1845,15 +1933,22 @@ JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSurfaceSetFilter
(JNIEnv *env, jobject obj, jint filter)
{
- struct graphics2d *gr = NULL;
-
gdk_threads_enter();
+ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSurfaceSetFilterUnlocked
+ (env, obj, filter);
+
+ gdk_threads_leave();
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSurfaceSetFilterUnlocked
+ (JNIEnv *env, jobject obj, jint filter)
+{
+ struct graphics2d *gr = NULL;
+
if (peer_is_disposed(env, obj))
- {
- gdk_threads_leave ();
- return;
- }
+ return;
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
@@ -1876,6 +1971,4 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSurfaceSetFilter
cairo_pattern_set_filter (gr->pattern, CAIRO_FILTER_BEST);
break;
}
-
- gdk_threads_leave();
}
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c
index 648cd6603..74103b5da 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c
@@ -97,14 +97,10 @@ area_prepared_cb (GdkPixbufLoader *loader,
e.jni_env = &env;
(*vm)->GetEnv (vm, e.void_env, JNI_VERSION_1_1);
- gdk_threads_leave ();
-
(*env)->CallVoidMethod (env,
*decoder,
areaPreparedID,
width, height);
-
- gdk_threads_enter ();
}
static void
@@ -143,12 +139,8 @@ area_updated_cb (GdkPixbufLoader *loader,
e.jni_env = &env;
(*vm)->GetEnv (vm, e.void_env, JNI_VERSION_1_1);
- gdk_threads_leave ();
-
jpixels = (*env)->NewIntArray (env, n_pixels);
- gdk_threads_enter ();
-
java_pixels = (*env)->GetIntArrayElements (env, jpixels, NULL);
memcpy (java_pixels,
@@ -165,8 +157,6 @@ area_updated_cb (GdkPixbufLoader *loader,
g_object_unref (pixbuf);
- gdk_threads_leave ();
-
(*env)->ReleaseIntArrayElements (env, jpixels, java_pixels, 0);
(*env)->CallVoidMethod (env,
@@ -178,8 +168,6 @@ area_updated_cb (GdkPixbufLoader *loader,
stride_pixels);
(*env)->DeleteLocalRef(env, jpixels);
-
- gdk_threads_enter ();
}
static void
@@ -190,12 +178,8 @@ closed_cb (GdkPixbufLoader *loader __attribute__((unused)), jobject *decoder)
e.jni_env = &env;
(*vm)->GetEnv (vm, e.void_env, JNI_VERSION_1_1);
- gdk_threads_leave ();
-
(*env)->DeleteGlobalRef (env, *decoder);
g_free (decoder);
-
- gdk_threads_enter ();
}
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkButtonPeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkButtonPeer.c
index 4b5a4c270..1459c62b8 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkButtonPeer.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkButtonPeer.c
@@ -63,9 +63,6 @@ cp_gtk_button_init_jni (void)
"postActionEvent", "(I)V");
}
-static void block_expose_event_cb (GtkWidget *widget,
- jobject peer);
-
static void clicked_cb (GtkButton *button,
jobject peer);
@@ -160,12 +157,6 @@ Java_gnu_java_awt_peer_gtk_GtkButtonPeer_connectSignals
button = gtk_bin_get_child (GTK_BIN (ptr));
/* Button signals */
- g_signal_connect_after (G_OBJECT (button), "pressed",
- G_CALLBACK (block_expose_event_cb), *gref);
-
- g_signal_connect_after (G_OBJECT (button), "released",
- G_CALLBACK (block_expose_event_cb), *gref);
-
g_signal_connect (G_OBJECT (button), "clicked",
G_CALLBACK (clicked_cb), *gref);
@@ -379,26 +370,6 @@ Java_gnu_java_awt_peer_gtk_GtkButtonPeer_setNativeBounds
}
static void
-block_expose_event_cb (GtkWidget *widget, jobject peer)
-{
- gdk_threads_leave ();
-
- (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer,
- beginNativeRepaintID);
-
- gdk_threads_enter ();
-
- gdk_window_process_updates (widget->window, TRUE);
-
- gdk_threads_leave ();
-
- (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer,
- endNativeRepaintID);
-
- gdk_threads_enter ();
-}
-
-static void
clicked_cb (GtkButton* button __attribute__((unused)),
jobject peer)
{
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c
index cf883dd33..7012bd821 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c
@@ -227,14 +227,10 @@ Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_gtkButtonSetLabel
static void
item_toggled_cb (GtkToggleButton *item, jobject peer)
{
- gdk_threads_leave ();
-
(*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer,
postItemEventID,
peer,
item->active ?
(jint) AWT_ITEM_SELECTED :
(jint) AWT_ITEM_DESELECTED);
-
- gdk_threads_enter ();
}
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkChoicePeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkChoicePeer.c
index ed9df5433..b7fb53c07 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkChoicePeer.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkChoicePeer.c
@@ -219,7 +219,8 @@ Java_gnu_java_awt_peer_gtk_GtkChoicePeer_nativeGetSelected
return index;
}
-static void selection_changed_cb (GtkComboBox *combobox, jobject peer)
+static void
+selection_changed_cb (GtkComboBox *combobox, jobject peer)
{
jstring label;
GtkTreeModel *model;
@@ -236,13 +237,9 @@ static void selection_changed_cb (GtkComboBox *combobox, jobject peer)
gtk_tree_model_get (model, &iter, 0, &selected, -1);
label = (*cp_gtk_gdk_env())->NewStringUTF (cp_gtk_gdk_env(), selected);
- gdk_threads_leave ();
-
(*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer,
postChoiceItemEventID,
label,
(jint) AWT_ITEM_SELECTED);
-
- gdk_threads_enter ();
}
}
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkClipboard.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkClipboard.c
index d4d34227e..adcd0a2ff 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkClipboard.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkClipboard.c
@@ -68,9 +68,9 @@ static jstring imageTarget;
static jstring filesTarget;
static void
-cp_gtk_clipboard_owner_change (GtkClipboard *clipboard __attribute__((unused)),
- GdkEvent *event __attribute__((unused)),
- gpointer user_data __attribute__((unused)))
+cp_gtk_clipboard_owner_change_cb (GtkClipboard *clipboard __attribute__((unused)),
+ GdkEvent *event __attribute__((unused)),
+ gpointer user_data __attribute__((unused)))
{
/* These are only interesting when we are not the owner. Otherwise
we will have the set and clear functions doing the updating. */
@@ -108,7 +108,7 @@ Java_gnu_java_awt_peer_gtk_GtkClipboard_initNativeState (JNIEnv *env,
if (gdk_display_supports_selection_notification (display))
{
g_signal_connect (clipboard, "owner-change",
- G_CALLBACK (cp_gtk_clipboard_owner_change), NULL);
+ G_CALLBACK (cp_gtk_clipboard_owner_change_cb), NULL);
gdk_display_request_selection_notification (display,
GDK_SELECTION_CLIPBOARD);
can_cache = JNI_TRUE;
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 b5761873c..7dbfca827 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
@@ -940,8 +940,6 @@ component_button_press_cb (GtkWidget *widget __attribute__((unused)),
button_window = event->window;
button_number = event->button;
- gdk_threads_leave ();
-
(*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer,
postMouseEventID,
AWT_MOUSE_PRESSED,
@@ -954,8 +952,6 @@ component_button_press_cb (GtkWidget *widget __attribute__((unused)),
(event->button == 3) ? JNI_TRUE :
JNI_FALSE);
- gdk_threads_enter ();
-
hasBeenDragged = FALSE;
return FALSE;
@@ -968,8 +964,6 @@ component_button_release_cb (GtkWidget *widget __attribute__((unused)),
{
int width, height;
- gdk_threads_leave ();
-
(*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer,
postMouseEventID,
AWT_MOUSE_RELEASED,
@@ -981,8 +975,6 @@ component_button_release_cb (GtkWidget *widget __attribute__((unused)),
click_count,
JNI_FALSE);
- gdk_threads_enter ();
-
/* Generate an AWT click event only if the release occured in the
window it was pressed in, and the mouse has not been dragged since
the last time it was pressed. */
@@ -993,8 +985,6 @@ component_button_release_cb (GtkWidget *widget __attribute__((unused)),
&& event->x <= width
&& event->y <= height)
{
- gdk_threads_leave ();
-
(*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer,
postMouseEventID,
AWT_MOUSE_CLICKED,
@@ -1005,8 +995,6 @@ component_button_release_cb (GtkWidget *widget __attribute__((unused)),
(jint)event->y,
click_count,
JNI_FALSE);
-
- gdk_threads_enter ();
}
return FALSE;
}
@@ -1022,8 +1010,6 @@ component_motion_notify_cb (GtkWidget *widget __attribute__((unused)),
| GDK_BUTTON4_MASK
| GDK_BUTTON5_MASK))
{
- gdk_threads_leave ();
-
(*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer,
postMouseEventID,
AWT_MOUSE_DRAGGED,
@@ -1034,14 +1020,10 @@ component_motion_notify_cb (GtkWidget *widget __attribute__((unused)),
0,
JNI_FALSE);
- gdk_threads_enter ();
-
hasBeenDragged = TRUE;
}
else
{
- gdk_threads_leave ();
-
(*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer, postMouseEventID,
AWT_MOUSE_MOVED,
(jlong)event->time,
@@ -1050,8 +1032,6 @@ component_motion_notify_cb (GtkWidget *widget __attribute__((unused)),
(jint)event->y,
0,
JNI_FALSE);
-
- gdk_threads_enter ();
}
return FALSE;
}
@@ -1065,8 +1045,6 @@ component_enter_notify_cb (GtkWidget *widget __attribute__((unused)),
grab/ungrab and not to actually crossing boundaries */
if (event->mode == GDK_CROSSING_NORMAL)
{
- gdk_threads_leave ();
-
(*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer, postMouseEventID,
AWT_MOUSE_ENTERED,
(jlong)event->time,
@@ -1075,8 +1053,6 @@ component_enter_notify_cb (GtkWidget *widget __attribute__((unused)),
(jint)event->y,
0,
JNI_FALSE);
-
- gdk_threads_enter ();
}
return FALSE;
}
@@ -1090,8 +1066,6 @@ component_leave_notify_cb (GtkWidget *widget __attribute__((unused)),
grab/ungrab and not to actually crossing boundaries */
if (event->mode == GDK_CROSSING_NORMAL)
{
- gdk_threads_leave ();
-
(*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer,
postMouseEventID,
AWT_MOUSE_EXITED,
@@ -1101,8 +1075,6 @@ component_leave_notify_cb (GtkWidget *widget __attribute__((unused)),
(jint)event->y,
0,
JNI_FALSE);
-
- gdk_threads_enter ();
}
return FALSE;
}
@@ -1112,8 +1084,6 @@ component_expose_cb (GtkWidget *widget __attribute__((unused)),
GdkEventExpose *event,
jobject peer)
{
- gdk_threads_leave ();
-
(*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer,
postExposeEventID,
(jint)event->area.x,
@@ -1121,8 +1091,6 @@ component_expose_cb (GtkWidget *widget __attribute__((unused)),
(jint)event->area.width,
(jint)event->area.height);
- gdk_threads_enter ();
-
return FALSE;
}
@@ -1131,15 +1099,11 @@ component_focus_in_cb (GtkWidget *widget __attribute((unused)),
GdkEventFocus *event __attribute((unused)),
jobject peer)
{
- gdk_threads_leave ();
-
(*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer,
postFocusEventID,
AWT_FOCUS_GAINED,
JNI_FALSE);
- gdk_threads_enter ();
-
return FALSE;
}
@@ -1148,14 +1112,10 @@ component_focus_out_cb (GtkWidget *widget __attribute((unused)),
GdkEventFocus *event __attribute((unused)),
jobject peer)
{
- gdk_threads_leave ();
-
(*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer,
postFocusEventID,
AWT_FOCUS_LOST,
JNI_FALSE);
- gdk_threads_enter ();
-
return FALSE;
}
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFileDialogPeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFileDialogPeer.c
index 48478d3b9..626204363 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFileDialogPeer.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFileDialogPeer.c
@@ -44,6 +44,43 @@ static void handle_response_cb (GtkDialog *dialog,
gint responseId,
jobject peer_obj);
+static jmethodID gtkSetFilenameID;
+static jmethodID gtkHideFileDialogID;
+static jmethodID gtkDisposeFileDialogID;
+static jmethodID filenameFilterCallbackID;
+
+void
+cp_gtk_filedialog_init_jni (void)
+{
+ jclass gtkfiledialogpeer;
+
+ gtkfiledialogpeer =
+ (*cp_gtk_gdk_env())->FindClass (cp_gtk_gdk_env(),
+ "gnu/java/awt/peer/gtk/GtkFileDialogPeer");
+
+ gtkDisposeFileDialogID =
+ (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(),
+ gtkfiledialogpeer,
+ "gtkDisposeFileDialog", "()V");
+
+ gtkHideFileDialogID =
+ (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(),
+ gtkfiledialogpeer,
+ "gtkHideFileDialog", "()V");
+
+ gtkSetFilenameID =
+ (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(),
+ gtkfiledialogpeer,
+ "gtkSetFilename",
+ "(Ljava/lang/String;)V");
+
+ filenameFilterCallbackID =
+ (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(),
+ gtkfiledialogpeer,
+ "filenameFilterCallback",
+ "(Ljava/lang/String;)Z");
+}
+
/*
* Make a new file selection dialog
*/
@@ -132,25 +169,17 @@ Java_gnu_java_awt_peer_gtk_GtkFileDialogPeer_nativeGetDirectory
This function extracts the filename from the GtkFileFilterInfo object,
and passes it to the Java method. The Java method will call the filter's
accept() method and will give back the return value. */
-static gboolean filenameFilterCallback (const GtkFileFilterInfo *filter_info,
+static gboolean filename_filter_cb (const GtkFileFilterInfo *filter_info,
gpointer obj)
{
- jclass cx;
- jmethodID id;
jstring *filename;
gboolean accepted;
- cx = (*cp_gtk_gdk_env())->GetObjectClass (cp_gtk_gdk_env(), (jobject) obj);
- id = (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(), cx, "filenameFilterCallback",
- "(Ljava/lang/String;)Z");
-
filename = (*cp_gtk_gdk_env())->NewStringUTF(cp_gtk_gdk_env(), filter_info->filename);
- gdk_threads_leave();
-
- accepted = (*cp_gtk_gdk_env())->CallBooleanMethod(cp_gtk_gdk_env(), obj, id, filename);
-
- gdk_threads_enter();
+ accepted = (*cp_gtk_gdk_env())->CallBooleanMethod(cp_gtk_gdk_env(), obj,
+ filenameFilterCallbackID,
+ filename);
return accepted;
}
@@ -168,7 +197,7 @@ Java_gnu_java_awt_peer_gtk_GtkFileDialogPeer_nativeSetFilenameFilter
filter = gtk_file_filter_new();
gtk_file_filter_add_custom(filter, GTK_FILE_FILTER_FILENAME,
- filenameFilterCallback, obj, NULL);
+ filename_filter_cb, obj, NULL);
gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(ptr), filter);
@@ -220,11 +249,6 @@ handle_response_cb (GtkDialog *dialog __attribute__((unused)),
gint responseId,
jobject peer_obj)
{
- static int isDisposeIDSet = 0;
- static int isIDSet = 0;
- static jmethodID gtkSetFilenameID;
- static jmethodID hideID;
- static jmethodID disposeID;
void *ptr;
G_CONST_RETURN gchar *fileName;
jstring str_fileName = NULL;
@@ -240,42 +264,24 @@ handle_response_cb (GtkDialog *dialog __attribute__((unused)),
if (responseId == GTK_RESPONSE_DELETE_EVENT)
{
- if (!isDisposeIDSet)
- {
- jclass cx = (*cp_gtk_gdk_env())->GetObjectClass (cp_gtk_gdk_env(), peer_obj);
- disposeID = (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(), cx, "gtkDisposeFileDialog", "()V");
- isDisposeIDSet = 1;
- }
-
/* We can dispose of the dialog now (and unblock show) */
- gdk_threads_leave ();
- (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer_obj, disposeID);
- gdk_threads_enter ();
+ (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer_obj,
+ gtkDisposeFileDialogID);
return;
}
- if (responseId == GTK_RESPONSE_ACCEPT) {
- fileName = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (GTK_WIDGET (ptr)));
- str_fileName = (*cp_gtk_gdk_env())->NewStringUTF (cp_gtk_gdk_env(), fileName);
- }
-
- if (!isIDSet)
+ if (responseId == GTK_RESPONSE_ACCEPT)
{
- jclass cx = (*cp_gtk_gdk_env())->GetObjectClass (cp_gtk_gdk_env(), peer_obj);
- hideID = (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(), cx, "gtkHideFileDialog", "()V");
- gtkSetFilenameID = (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(), cx,
- "gtkSetFilename", "(Ljava/lang/String;)V");
- isIDSet = 1;
+ fileName = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (GTK_WIDGET (ptr)));
+ str_fileName = (*cp_gtk_gdk_env())->NewStringUTF (cp_gtk_gdk_env(), fileName);
}
/* Set the Java object field 'file' with this value. */
- gdk_threads_leave ();
- (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer_obj, gtkSetFilenameID, str_fileName);
+ (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer_obj,
+ gtkSetFilenameID, str_fileName);
/* We can hide the dialog now (and unblock show) */
- (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer_obj, hideID);
-
- gdk_threads_enter ();
+ (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer_obj,
+ gtkHideFileDialogID);
}
-
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFramePeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFramePeer.c
index 5b99598e5..c60f48f51 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFramePeer.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFramePeer.c
@@ -118,13 +118,23 @@ Java_gnu_java_awt_peer_gtk_GtkFramePeer_getMenuBarHeight
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkFramePeer_setMenuBarWidth
+ (JNIEnv *env, jobject obj, jobject menubar, jint width)
+{
+ gdk_threads_enter ();
+
+ Java_gnu_java_awt_peer_gtk_GtkFramePeer_setMenuBarWidthUnlocked
+ (env, obj, menubar, width);
+
+ gdk_threads_leave ();
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GtkFramePeer_setMenuBarWidthUnlocked
(JNIEnv *env, jobject obj __attribute__((unused)), jobject menubar, jint width)
{
GtkWidget *ptr;
GtkRequisition natural_req;
- gdk_threads_enter ();
-
if (menubar)
{
ptr = NSA_GET_PTR (env, menubar);
@@ -137,8 +147,6 @@ Java_gnu_java_awt_peer_gtk_GtkFramePeer_setMenuBarWidth
gtk_widget_set_size_request (GTK_WIDGET (ptr),
width, natural_req.height);
}
-
- gdk_threads_leave ();
}
JNIEXPORT void JNICALL
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkListPeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkListPeer.c
index d513176be..32579e058 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkListPeer.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkListPeer.c
@@ -513,25 +513,17 @@ item_highlighted_cb (GtkTreeSelection *selection __attribute__((unused)),
if (!path_currently_selected)
{
- gdk_threads_leave ();
-
(*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer,
postListItemEventID,
row,
(jint) AWT_ITEM_SELECTED);
-
- gdk_threads_enter ();
}
else
{
- gdk_threads_leave ();
-
(*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer,
postListItemEventID,
row,
(jint) AWT_ITEM_DESELECTED);
-
- gdk_threads_enter ();
}
}
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuItemPeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuItemPeer.c
index 2746f1e4a..d2ae148a9 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuItemPeer.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuItemPeer.c
@@ -186,8 +186,6 @@ Java_gnu_java_awt_peer_gtk_GtkMenuItemPeer_setLabel
static void
item_activate_cb (GtkMenuItem *item __attribute__((unused)), jobject peer_obj)
{
- gdk_threads_leave ();
(*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer_obj,
- postMenuActionEventID);
- gdk_threads_enter ();
+ postMenuActionEventID);
}
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextFieldPeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextFieldPeer.c
index eb658339d..0ddab05c3 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextFieldPeer.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextFieldPeer.c
@@ -417,7 +417,5 @@ static void
textcomponent_changed_cb (GtkEditable *editable __attribute__((unused)),
jobject peer)
{
- gdk_threads_leave ();
(*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer, postTextEventID);
- gdk_threads_enter ();
}
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c
index b9924c15c..17cf63fff 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c
@@ -188,6 +188,7 @@ Java_gnu_java_awt_peer_gtk_GtkToolkit_gtkInit (JNIEnv *env,
cp_gtk_checkbox_init_jni ();
cp_gtk_choice_init_jni ();
cp_gtk_component_init_jni ();
+ cp_gtk_filedialog_init_jni ();
cp_gtk_list_init_jni ();
cp_gtk_menuitem_init_jni ();
cp_gtk_scrollbar_init_jni ();
@@ -396,7 +397,11 @@ Java_gnu_java_awt_peer_gtk_GtkToolkit_loadSystemColors
jint *colors;
GtkStyle *style;
+ /* FIXME: this was deadlocking so assume it is thread-safe for now;
+ we need to replace this call with a .properties file anyway. */
+#if 0
gdk_threads_enter ();
+#endif
colors = (*env)->GetIntArrayElements (env, jcolors, 0);
@@ -431,7 +436,9 @@ Java_gnu_java_awt_peer_gtk_GtkToolkit_loadSystemColors
(*env)->ReleaseIntArrayElements(env, jcolors, colors, 0);
+#if 0
gdk_threads_leave ();
+#endif
}
#undef CONVERT
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
index 3f607edd6..d15cdc37a 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
@@ -1044,8 +1044,6 @@ window_configure_cb (GtkWidget *widget __attribute__((unused)),
GdkEventConfigure *event,
jobject peer)
{
- gdk_threads_leave ();
-
(*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer,
postConfigureEventID,
(jint) event->x,
@@ -1053,8 +1051,6 @@ window_configure_cb (GtkWidget *widget __attribute__((unused)),
(jint) event->width,
(jint) event->height);
- gdk_threads_enter ();
-
return FALSE;
}
@@ -1063,8 +1059,6 @@ key_press_cb (GtkWidget *widget __attribute__((unused)),
GdkEventKey *event,
jobject peer)
{
- gdk_threads_leave ();
-
(*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer,
postKeyEventID,
(jint) AWT_KEY_PRESSED,
@@ -1074,8 +1068,6 @@ key_press_cb (GtkWidget *widget __attribute__((unused)),
keyevent_to_awt_keychar (event),
keysym_to_awt_keylocation (event));
- gdk_threads_enter ();
-
/* FIXME: generation of key typed events needs to be moved
to GtkComponentPeer.postKeyEvent. If the key in a key
press event is not an "action" key
@@ -1090,8 +1082,6 @@ key_release_cb (GtkWidget *widget __attribute__((unused)),
GdkEventKey *event,
jobject peer)
{
- gdk_threads_leave ();
-
(*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer,
postKeyEventID,
(jint) AWT_KEY_RELEASED,
@@ -1101,8 +1091,6 @@ key_release_cb (GtkWidget *widget __attribute__((unused)),
keyevent_to_awt_keychar (event),
keysym_to_awt_keylocation (event));
- gdk_threads_enter ();
-
return TRUE;
}
@@ -1213,10 +1201,20 @@ JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkWindowPeer_nativeSetVisible
(JNIEnv *env, jobject obj, jboolean visible)
{
- void *ptr;
-
gdk_threads_enter ();
+ Java_gnu_java_awt_peer_gtk_GtkWindowPeer_nativeSetVisibleUnlocked
+ (env, obj, visible);
+
+ gdk_threads_leave ();
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GtkWindowPeer_nativeSetVisibleUnlocked
+ (JNIEnv *env, jobject obj, jboolean visible)
+{
+ void *ptr;
+
ptr = NSA_GET_PTR (env, obj);
if (visible)
@@ -1225,8 +1223,6 @@ Java_gnu_java_awt_peer_gtk_GtkWindowPeer_nativeSetVisible
gtk_widget_hide (GTK_WIDGET (ptr));
XFlush (GDK_DISPLAY ());
-
- gdk_threads_leave ();
}
JNIEXPORT void JNICALL
@@ -1363,10 +1359,20 @@ JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkWindowPeer_nativeSetBounds
(JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height)
{
- void *ptr;
-
gdk_threads_enter ();
+ Java_gnu_java_awt_peer_gtk_GtkWindowPeer_nativeSetBoundsUnlocked
+ (env, obj, x, y, width, height);
+
+ gdk_threads_leave ();
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GtkWindowPeer_nativeSetBoundsUnlocked
+ (JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height)
+{
+ void *ptr;
+
ptr = NSA_GET_PTR (env, obj);
/* Avoid GTK runtime assertion failures. */
@@ -1395,8 +1401,6 @@ Java_gnu_java_awt_peer_gtk_GtkWindowPeer_nativeSetBounds
by the program and the window's "resizable" property is true then
the size request will not be honoured. */
gtk_window_resize (GTK_WINDOW (ptr), width, height);
-
- gdk_threads_leave ();
}
static void
@@ -1512,15 +1516,11 @@ window_delete_cb (GtkWidget *widget __attribute__((unused)),
GdkEvent *event __attribute__((unused)),
jobject peer)
{
- gdk_threads_leave ();
-
(*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer,
postWindowEventID,
(jint) AWT_WINDOW_CLOSING,
(jobject) NULL, (jint) 0);
- gdk_threads_enter ();
-
/* Prevents that the Window dissappears ("destroy"
not being signalled). This is necessary because it
should be up to a WindowListener implementation
@@ -1533,28 +1533,20 @@ window_destroy_cb (GtkWidget *widget __attribute__((unused)),
GdkEvent *event __attribute__((unused)),
jobject peer)
{
- gdk_threads_leave ();
-
(*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer,
postWindowEventID,
(jint) AWT_WINDOW_CLOSED,
(jobject) NULL, (jint) 0);
-
- gdk_threads_enter ();
}
static void
window_show_cb (GtkWidget *widget __attribute__((unused)),
jobject peer)
{
- gdk_threads_leave ();
-
(*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer,
postWindowEventID,
(jint) AWT_WINDOW_OPENED,
(jobject) NULL, (jint) 0);
-
- gdk_threads_enter ();
}
static void
@@ -1587,8 +1579,6 @@ window_focus_state_change_cb (GtkWidget *widget,
GParamSpec *pspec __attribute__((unused)),
jobject peer)
{
- gdk_threads_leave ();
-
if (GTK_WINDOW (widget)->has_toplevel_focus)
(*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer,
postWindowEventID,
@@ -1599,8 +1589,6 @@ window_focus_state_change_cb (GtkWidget *widget,
postWindowEventID,
(jint) AWT_WINDOW_DEACTIVATED,
(jobject) NULL, (jint) 0);
-
- gdk_threads_enter ();
}
static gboolean
@@ -1608,15 +1596,11 @@ window_focus_in_cb (GtkWidget * widget __attribute__((unused)),
GdkEventFocus *event __attribute__((unused)),
jobject peer)
{
- gdk_threads_leave ();
-
(*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer,
postWindowEventID,
(jint) AWT_WINDOW_GAINED_FOCUS,
(jobject) NULL, (jint) 0);
- gdk_threads_enter ();
-
return FALSE;
}
@@ -1625,15 +1609,11 @@ window_focus_out_cb (GtkWidget * widget __attribute__((unused)),
GdkEventFocus *event __attribute__((unused)),
jobject peer)
{
- gdk_threads_leave ();
-
(*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer,
postWindowEventID,
(jint) AWT_WINDOW_LOST_FOCUS,
(jobject) NULL, (jint) 0);
- gdk_threads_enter ();
-
return FALSE;
}
@@ -1651,26 +1631,18 @@ window_window_state_cb (GtkWidget *widget,
if (event->window_state.new_window_state & GDK_WINDOW_STATE_ICONIFIED)
{
/* We've been iconified. */
- gdk_threads_leave ();
-
(*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer,
postWindowEventID,
(jint) AWT_WINDOW_ICONIFIED,
(jobject) NULL, (jint) 0);
-
- gdk_threads_enter ();
}
else
{
/* We've been deiconified. */
- gdk_threads_leave ();
-
(*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer,
postWindowEventID,
(jint) AWT_WINDOW_DEICONIFIED,
(jobject) NULL, (jint) 0);
-
- gdk_threads_enter ();
}
}
@@ -1683,15 +1655,11 @@ window_window_state_cb (GtkWidget *widget,
new_state |= window_get_new_state (widget);
- gdk_threads_leave ();
-
(*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer,
postWindowEventID,
(jint) AWT_WINDOW_STATE_CHANGED,
(jobject) NULL, new_state);
- gdk_threads_enter ();
-
return TRUE;
}
@@ -1757,16 +1725,12 @@ window_property_changed_cb (GtkWidget *widget __attribute__((unused)),
NULL,
gu_ex.gu_extents))
{
- gdk_threads_leave ();
-
(*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer,
postInsetsChangedEventID,
(jint) extents[2], /* top */
(jint) extents[0], /* left */
(jint) extents[3], /* bottom */
(jint) extents[1]); /* right */
-
- gdk_threads_enter ();
}
diff --git a/native/jni/gtk-peer/gtkpeer.h b/native/jni/gtk-peer/gtkpeer.h
index a7baafa40..203e836e8 100644
--- a/native/jni/gtk-peer/gtkpeer.h
+++ b/native/jni/gtk-peer/gtkpeer.h
@@ -181,6 +181,7 @@ void cp_gtk_button_init_jni (void);
void cp_gtk_checkbox_init_jni (void);
void cp_gtk_choice_init_jni (void);
void cp_gtk_component_init_jni (void);
+void cp_gtk_filedialog_init_jni (void);
void cp_gtk_list_init_jni (void);
void cp_gtk_menuitem_init_jni (void);
void cp_gtk_scrollbar_init_jni (void);