diff options
author | graydon <graydon@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-03-17 21:29:02 +0000 |
---|---|---|
committer | graydon <graydon@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-03-17 21:29:02 +0000 |
commit | 26e56d50901d27a67646c97e14b3e71cec89ec68 (patch) | |
tree | 02790a2b250b62643a1de68b63bd078238bfaf46 /libjava/jni | |
parent | f28cd43a6ebd2e92792019fc84a5ac1c42c8fd09 (diff) | |
download | gcc-26e56d50901d27a67646c97e14b3e71cec89ec68.tar.gz |
2004-03-12 Graydon Hoare <graydon@redhat.com>
* gnu/java/awt/peer/gtk/GdkGraphics2D.java: Clipping fixes.
* javax/swing/JComponent.java (paint): Use persistent double buffer.
* javax/swing/JList.java (ListListener): Revalidate on changes.
* javax/swing/JScrollPane.java: Reimplement.
* javax/swing/JViewport.java: Reimplement.
* javax/swing/ScrollPaneLayout.java: Reimplement.
* javax/swing/ViewportLayout.java: Tidy up.
* javax/swing/plaf/basic/BasicButtonListener.java: Remove printlns.
* javax/swing/plaf/basic/BasicScrollPaneUI.java: Reimplement.
* javax/swing/plaf/basic/BasicSliderUI.java: Handle missing labels.
* javax/swing/plaf/basic/BasicViewportUI.java: Implement in terms of
backing store only.
2004-03-11 Thomas Fitzsimmons <fitzsim@redhat.com>
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
(window_wm_protocols_filter): New function.
(window_focus_in_cb): Remove function.
(window_focus_out_cb): Likewise.
(window_focus_or_active_state_change_cb): New function.
(create): Add filter that removes WM_TAKE_FOCUS client messages.
(connectSignals): Don't attach handlers to focus-in-event or
focus-out-event signals. Handle notify signal.
2004-03-11 David Jee <djee@redhat.com>
* gnu/java/awt/peer/gtk/GtkCheckboxPeer.java
(gtkSetLabel): New native method declaration.
(setLabel): Use gtkSetLabel.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c
(Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_gtkSetLabel): New method.
2004-03-10 Thomas Fitzsimmons <fitzsim@redhat.com>
* gnu/java/awt/peer/gtk/GdkGraphics.java (setColor): Default to
black when color argument is null.
2004-03-10 Kim Ho <kho@redhat.com>
* java/awt/Container.java: Remove check
for drag events.
2004-03-10 Kim Ho <kho@redhat.com>
* java/awt/Container.java: (visitChild):
Remove candidate clip. Use the component
clip to intersect.
* gnu/java/awt/peer/gtk/GtkComponentPeer.java:
(handleEvent): Use the PaintEvent's clip.
2004-03-10 Kim Ho <kho@redhat.com>
* gnu/java/awt/peer/gtk/GtkComponentPeer.java:
(handleEvent): Don't set the clip for the
Graphics object.
2004-03-09 Graydon Hoare <graydon@redhat.com>
* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGlyphVector.c:
Fix double <-> fixed macros, reset font transform.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkClasspathFontPeerMetrics.c:
Likewise.
2004-03-09�� Kim Ho <kho@redhat.com>
* java/awt/Container.java: (visitChild): Move
the x and y coordinate of the component rectangle
to correct position.
(handleEvent): Forward drag events to the pressed
component.
* javax/swing/plaf/basic/BasicScrollBarUI.java:
Fix comments.
(ArrowButtonListener::mousePressed): Stop the
existing timer.
(mouseDragged): Implement.
(TrackListener::mousePressed): Only react if
the press doesn't occur on the thumb, otherwise
just set the offset.
(TrackListener::mouseReleased): Unset the isAdjusting
value.
(createIncreaseIcon): Switch icon.
(createDecreaseIcon): Switch icon.
(calculatePreferredSize): Use width.
(getThumbBounds): Use the top as the lower value.
(layoutVScrollBar): Switch the button locations.
(paintIncreaseHighlight): Paint correct side of thumb.
(paintDecreaseHighlight): ditto.
(valueForYPosition): Use top as the lower value.
* javax/swing/plaf/basic/BasicSliderUI.java:
Fix comments.
(mouseDragged): Implement.
(mousePressed): Only react when the thumb isn't
pressed, otherwise just set offset.
(mouseReleased): Handle a release of the thumb.
(scrollDueToClickInTrack): Stop the timer first.
* javax/swing/JProgressBar.java:
(setString): Fix change condition.
* javax/swing/JSeparator.java:
Remove println's.
2004-03-08 David Jee <djee@redhat.com>
* java/awt/image/AffineTransformOp.java:
(filter): Use Graphics2D interface instead of directly using the
GdkGraphics2D peer.
2004-03-05 David Jee <djee@redhat.com>
* gnu/java/awt/peer/gtk/GtkButtonPeer.java
(handleEvent): Action events are generated upon MOUSE_RELEASED.
* java/awt/Container.java
(acquireComponentForMouseEvent): Fixed.
(handleEvent): Fixed.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c
(state_to_awt_mods_with_button_states): New method.
(pre_event_handler): Fixed mouse event generation.
2004-03-05 Olga Rodimina <rodimina@redhat.com>
gnu/java/awt/peer/gtk/GdkGraphics2D.java
(GdkGraphics2D (BufferedImage)): Initialize
pixmap associated with specified BufferedImage.
(setPaint): Changed implementation of Texture
Paint to use AffineTransformOp.
* java/awt/image/AffineTransformOp.java
(createCompatibleDestRaster): Throw RasterFormatException
if resulting width or height of raster is 0.
2004-03-04 Olga Rodimina <rodimina@redhat.com>
* java/awt/image/AffineTransformOp.java:
Removed unnecessary field interpolationType.
Formatted some of the lines to be consistent with
the GNU style.
(AffineTransformOp): Create new RenderingHints
containing specified interpolation type.
(createCompatibleDestImage): Implemented.
(createCompatibleDestRaster): Implemented.
(filter): Implemented.
(getBounds2D(BufferedImage)): Implemented.
(getBounds2D(Raster)): Implemented.
(getInterpolationType): Get interpolation value from
rendering hints.
2004-03-04 David Jee <djee@redhat.com>
* gnu/java/awt/peer/gtk/GtkContainerPeer.java
(setFont): Check if child peers are null.
2004-03-04 Graydon Hoare <graydon@redhat.com>
* testsuite/lib/libjava.exp (libjava_find_lib): Don't include
.libs in -L option.
(libjava_arguments): Add new libraries to argument list.
2004-03-04 Tom Tromey <tromey@redhat.com>
* Makefile.in: Rebuilt.
* Makefile.am (toolexeclib_LTLIBRARIES): Added lib-java-awt.la,
lib-javax-swing.la, lib-java-applet.la, lib-java-beans.la.
(misc_java_source_files): New macro.
(swing_java_source_files): Likewise.
(awt_java_source_files): Pruned.
(applet_java_source_files): New macro.
(beans_java_source_files): Likewise.
(lib_java_applet_la_SOURCES): Likewise.
(lib_java_awt_la_SOURCES): Likewise.
(lib_javax_swing_la_SOURCES): Likewise.
(lib_java_beans_la_SOURCES): Likewise.
(all_java_object_files): Likewise.
(%.lo: %.java): Use all_java_object_files.
(all_java_source_files): Added new _SOURCES.
(ordinary_java_source_files): Removed awt_java_source_files.
2004-03-02 Olga Rodimina <rodimina@redhat.com>
* Makefile.am: Added java/awt/image/AffineTransformOp.java
* Makefile.in: Re-generated.
* java/awt/image/AffineTransformOp.java: New Class.
2004-03-01 Olga Rodimina <rodimina@redhat.com>
* gnu/java/awt/peer/gtk/GdkGraphics2D.java
(setPaint): Interpret correctly TexturePaint's
anchor rectangle.
(drawImage): Fixed scale factors of the affine
transform.
2004-02-27 David Jee <djee@redhat.com>
* gnu/java/awt/peer/gtk/GdkGraphics.java
(GdkGraphics(Component)): Inherit font from component.
(drawString): Use font style.
* gnu/java/awt/peer/gtk/GtkCheckboxPeer.java
(gtkSetFont): New native method declaration.
(setFont): New method.
* gnu/java/awt/peer/gtk/GtkComponentPeer.java
(gtkSetFont): New native method declaration.
(setFont): Call new native method gtkSetFont.
* gnu/java/awt/peer/gtk/GtkContainerPeer.java
(setFont): For all child components who do not their fonts set,
set their peers' fonts with this container's font.
* gnu/java/awt/peer/gtk/GtkLabelPeer.java:
Move all native method declarations to the top for readability.
(gtkSetFont): New native method declaration.
(setFont): New method.
* java/awt/Component.java
(setFont): Invalidate after setting the font.
* java/awt/Container.java
(invalidateTree): New method.
(setFont): Invalidate the container tree after setting the font.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c
(Java_gnu_java_awt_peer_gtk_GdkGraphics_drawString): Use font style.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c
(Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_gtkSetFont): New method.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
(Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkSetFont): New method.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkLabelPeer.c
(Java_gnu_java_awt_peer_gtk_GtkLabelPeer_gtkSetFont): New method.
2004-02-27 Olga Rodimina <rodimina@redhat.com>
* gnu/java/awt/peer/gtk/GdkGraphics2D.java
(updateBufferedImage): New helper function.
Updates BufferedImage in memory if it was changed.
(draw): changed to update BufferedImage in memory after
this drawing operation
(fill): Ditto.
(draw3DRect): Ditto.
(fill3DRect): Ditto.
(clearRect): Ditto.
(drawRaster): Ditto.
(drawImage) : Ditto. Update only in case of GtkOffScreenImage with
no affine transformation.
(drawGlyphVector): Ditto.
2004-02-26 Olga Rodimina <rodimina@redhat.com>
* gnu/java/awt/peer/gtk/GdkGraphics2D.java
(isBufferedImageGraphics): New Helper function.
Returns true if this graphics2d can be used to draw
into buffered image and false otherwise.
(updateImagePixels): New Helper function.
Updates pixels in the BufferedImage.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c
(getImagePixels): New function. Returns pixels
of the buffered image associated with
this Graphics2D.
2004-02-26 David Jee <djee@redhat.com>
* java/awt/BorderLayout.java
(layoutContainer): Fix width and height calculations to ensure
that they're non-negative.
* java/awt/Component.java
(setBackground): If c is null, inherit from closest ancestor whose
background color is set.
2004-02-26�� Kim Ho�� <kho@redhat.com>
* Makefile.am: Add new files.
* Makefile.in: Re-generate.
* javax/swing/JProgressBar.java:
(JProgressBar(int, int int)): Throw
IllegalArgumentException if orientation is
invalid.
(JProgressBar(BoundedRangeModel)): Create
ChangeListener and register it. UpdateUI.
(getChangeListeners): Implement.
(setModel): Reset ChangeListener.
* javax/swing/JScrollBar.java: Implement.
* javax/swing/JSeparator.java: Implement.
* javax/swing/JSlider.java:
(JSlider(int, int, int, int)): Throw
IllegalArgumentException if orientation
is invalid.
(getChangeListeners): Fix method name.
* javax/swing/SwingUtilities.java:
(layoutCompoundLabel): If there is no text,
set the text rectangle dimensions to 0.
* javax/swing/plaf/basic/BasicButtonUI.java:
(paint): If there is no text, don't paint it.
* javax/swing/plaf/basic/BasicScrollBarUI.java:
Implement.
* javax/swing/plaf/basic/BasicSeparatorUI.java:
Implement.
* javax/swing/plaf/basic/BasicSliderUI.java:
(propertyChange): If the model changes, change
the listeners accordingly.
2004-02-25 Graydon Hoare <graydon@redhat.com>
* javax/swing/AbstractButton.java: Add "final" qualifiers.
* javax/swing/JList.java: Reimplement.
* javax/swing/DefaultListSelectionModel.java: Reimplement.
* javax/swing/plaf/basic/BasicListUI.java: Reimplement.
* javax/swing/plaf/basic/BasicLookAndFeel.java: Add "purple" values.
* javax/swing/ListModel.java: Javadoc.
* javax/swing/ListSelectionModel.java: Add missing methods.
* javax/swing/AbstractListModel.java: Javadoc and corrections.
* javax/swing/DefaultListModel.java: Javadoc and corrections.
* javax/swing/ListModel.java: Javadoc and corrections.
* javax/swing/DefaultListCellRenderer.java: Minor tidying.
2004-02-25 David Jee <djee@redhat.com>
* gnu/java/awt/peer/gtk/GtkFontPeer.java
(GtkFontPeer): Change default size to 12.
* gnu/java/awt/peer/gtk/GtkToolkit.java
(getFontPeer): Change default size to 12.
(getClasspathFontPeer): Likewise. Set default name to "Default".
* java/awt/Font.java
(Font(Map)): Call Font(String,Map).
(Font(String,Map)): If attrs is null, initialize it as an empty
HashMap, which will ensure that the Font will get default attributes.
2004-02-25 David Jee <djee@redhat.com>
* gnu/java/awt/peer/gtk/GtkFontPeer.java
(GtkFontPeer(String,int)): Call the new constructor with size 1.
(GtkFontPeer(String,int,int)): New constructor with size attribute.
* gnu/java/awt/peer/gtk/GtkToolkit.java
(getFontPeer(String,int)): Call the new overload method with size 1.
(getFontPeer(String,int,int)): New method. Overloaded with size
attribute.
(getClasspathFontPeer): Set the size of the font.
2004-02-24 Olga Rodimina <rodimina@redhat.com>
* gnu/java/awt/peer/gtk/GdkGraphics2D.java
(bimage): New field.
(GdkGraphics2D): New Constructor. Constructs Graphics
object that can be used to draw into the Buffered Image.
* gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java:
(GdkGraphicsEnvironment): Fixed to include public
keyword.
(createGraphics): Implemented.
* gnu/java/awt/peer/gtk/GtkToolkit.java
(getLocalGraphicsEnvironment): Implemented.
* java/awt/GraphicsEnvironment.java:
(getLocalGraphicsEnvironment): Implemented.
* java/awt/image/BufferedImage.java:
(createGraphics): Implemented.
2004-02-24 David Jee <djee@redhat.com>
* java/awt/Component.java
(eventTypeEnabled): Add MOUSE_MOVED and MOUSE_DRAGGED event types.
* java/awt/Container.java
(addNotifyContainerChildren): Fix event enabling.
2004-02-23 Olga Rodimina <rodimina@redhat.com>
* Makefile.am: Added
gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java
* Makefile.in: Re-generated.
* gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java:
New Class.
2004-02-19 Kim Ho <kho@redhat.com>
* Makefile.am: Add BasicProgressBarUI
* Makefile.in: Regenerate.
* javax/swing/JProgressBar.java:
Re-implement.
* javax/swing/plaf/basic/BasicLookAndFeel.java
Add constants for JProgressBar.
* javax/swing/plaf/basic/BasicProgressBarUI.java
Implement.
* javax/swing/plaf/basic/BasicSliderUI.java
Change comments.
(calculateGeometry): New method
(paint): Remove unnecessary size calculations.
2004-02-18 Olga Rodimina <rodimina@redhat.com>
* gnu/java/awt/peer/gtk/GdkGraphics2D.java
(drawRaster): Fixed small error that caused
imageToUser transformation to be set incorrectly.
(toString): Implemented.
2004-02-18 David Jee <djee@redhat.com>
* java/awt/CardLayout.java
(addLayoutComponent): Show the first component added as the default.
(removeLayoutComponent): After removing, show the next component.
(gotoComponent): If there is only one component, show it and return.
2004-02-18 Kim Ho <kho@redhat.com>
* javax/swing/JSlider.java: Re-order
modifiers.
* javax/swing/JLabel.java: Re-order
modifiers.
* javax/swing/JComponent.java:
(addPropertyChangeListener):
Implement.
(removePropertyChangeListener):
ditto.
(firePropertyChangeEvent):
ditto.
2004-02-17 David Jee <djee@redhat.com>
* java/awt/Component.java
(show): Dispatch ComponentEvent via system event queue.
(hide): Likewise.
(move): Likewise.
(resize): Likewise.
(reshape): Likewise.
* java/awt/Window.java
(setBoundsCallback): Likewise.
2004-02-17 David Jee <djee@redhat.com>
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
(Java_gnu_java_awt_peer_gtk_GtkComponentPeer_setNativeBounds):
Use gtk_widget_set_size_request() instead of the deprecated
gtk_widget_set_usize().
2004-02-17 Kim Ho <kho@redhat.com>
* javax/swing/JSlider.java: Fix comments and
make property strings constants.
(createStandardLabels): Use the labels
preferred size as bounds.
* javax/swing/plaf/basic/BasicSliderUI.java
Fix comments.
(ScrollHandler::actionPerformed): Don't
calculate the timer stop value. Let the
MouseListeners find the stop location.
(getPreferredHorizontalSize): Re-implement.
(getPreferredVerticalSize): ditto.
(getMinimumHorizontalSize): ditto.
(getMinimumVerticalSize): ditto.
(getPreferredSize): ditto.
(getMinimumSize): ditto.
(getMaximumSize): ditto.
(paintTicks): Use doubles to find the
tick location.
(paintHorizontalLabel):�� Use preferredSize
as initial width and height.
(paintVerticalLabel): ditto.
2004-02-17 Kim Ho <kho@redhat.com>
* javax/swing/JLabel.java: Changed
property strings to constants.
(DISPLAYED_MNEMONIC_INDEX_CHANGED_PROPERTY):
New property.
(setText): Change mnemonic index if
text is too short.
(setDisplayedMnemonicIndex): Fire property
change event.
(getDisplayedMnemonicIndex): Remove check
against short text.
2004-02-17 Olga Rodimina <rodimina@redhat.com>
* gnu/java/awt/peer/gtk/GdkGraphics2D.java:
(drawImage(img,xform,obs)): Invert xform before
passing the xform to cairo.
(drawImage(img,x,y,bgcolor,obs)): Implemented.
(drawImage (img,x,y,w,h,bgcolor,obs)): Partly
implemented.
(drawImage (img,x,y,w,h,obs)): Implemented.
(drawImage (img,dx1,dy1,dx2,dy2,sx1,sy1,sx2,sy2,
bgcolor,obs)): Partly implemented.
(drawImage (img,dx1,dy1,dx2,dy2,sx1,sy1,sx2,sy2,obs)):
Implemented.
* java/awt/image/BufferedImage.java:
(copyData): if dest is null, create raster with same
dimensions as the current image.
2004-02-16 Graydon Hoare <graydon@redhat.com>
* javax/swing/plaf/basic/BasicLabelUI.java
(getPreferredSize): Use layoutCL.
* javax/swing/plaf/basic/BasicGraphicsUtils.java
(getPreferredButtonSize): Start with empty view rect, layout using
component's preferred alignment.
* javax/swing/plaf/basic/BasicLookAndFeel.java: Add some Label and
List defaults.
2004-02-16 David Jee <djee@redhat.com>
* java/awt/Component.java
(show): Dispatch COMPONENT_SHOWN ComponentEvent.
(hide): Dispatch COMPONENT_HIDDEN ComponentEvent.
(move): Erase old bounds and repaint new bounds. Dispatch
COMPONENT_MOVED ComponentEvent.
(resize): Erase old bounds and repaint new bounds. Dispatch
COMPONENT_RESIZED ComponentEvent.
(reshape): Dispatch COMPONENT_RESIZED and COMPONENT_MOVED
ComponentEvents.
* java/awt/Window.java
(setBoundsCallback): Dispatch COMPONENT_RESIZED and COMPONENT_MOVED
ComponentEvents.
2004-02-16 Olga Rodimina <rodimina@redhat.com>
* gnu/java/awt/peer/gtk/GdkGraphics2D.java:
(setRenderingHint): Added implementation of
Interpolation rendering hints.
(setRenderingHints): Ditto.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c:
(drawPixels): fixed to allow user to choose type
of filtering that should be used when displaying images.
(cairoSurfaceSetFilter): New method. Sets filter type for
interpolation of pixel values.
2004-02-16 David Jee <djee@redhat.com>
* java/awt/GridBagLayout.java
(calcCellSizes): Rows or columns with zero sizes should still be
considered for extra space distribution.
2004-02-16 Kim Ho <kho@redhat.com>
* javax/swing/JLabel.java: Re-implement.
* javax/swing/plaf/basic/BasicLabelUI.java
Re-implement.
* javax/swing/plaf/basic/BasicLookAndFeel.java:
Added constant.
2004-02-16�� Kim Ho�� <kho@redhat.com>
* javax/swing/JSlider.java: Fix indentation and comments.
(setModel): Remove null check to conform with Sun's.
(setOrientation): Throw exception if not
HORIZONTAL or VERTICAL.
(getInverted): Use private variable instead of
ComponentOrientation.
(setInverted): ditto.
* javax/swing/plaf/basic/BasicSliderUI.java:
Fix indentation and comments.
(propertyChange): Remove check for inverted slider, handle
in main paint.
(getMinimumSize): Return preferred size.
(getMaximumSize): ditto.
(calculateFocusRect): Don't relocate rectangle.
(drawInverted): Return XOR of the slider's inversion and
the component's orientation.
(paint): Update leftToRightCache
2004-02-13 David Jee <djee@redhat.com>
* java/awt/GridBagLayout.java
(GetLayoutInfo): Fix weight and size distribution. Relocate repeated
code to helper methods.
(sortBySpan): New helper method.
(distributeSizeAndWeight): Likewise.
(calcCellWeights): Likewise.
(calcCellSizes): Add comments.
2004-02-13 David Jee <djee@redhat.com>
* java/awt/Component.java
(show): Only do something if component is invisible at the moment.
(hide): Only do something if component is visible at the moment.
(reshape): If lightweight, erase old bounds and repaint new bounds.
2004-02-13�� Kim Ho�� <kho@redhat.com>
* Makefile.am: Updated for new file.
* Makefile.in: Regenerated.
* javax/swing/JSlider.java: Reimplement.
* javax/swing/SwingUtilities.java
(layoutCompoundLabel): Use icon height
instead of width.
(paintComponent): Implement.
* javax/swing/plaf/basic/BasicLookAndFeel.java:
Add JSlider defaults.
* javax/swing/plaf/basic/BasicSliderUI.java:
Implement. New file.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@79607 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/jni')
9 files changed, 392 insertions, 100 deletions
diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkClasspathFontPeerMetrics.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkClasspathFontPeerMetrics.c index 86139db52e6..cc09102debd 100644 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkClasspathFontPeerMetrics.c +++ b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkClasspathFontPeerMetrics.c @@ -53,6 +53,7 @@ JNIEXPORT jintArray JNICALL Java_gnu_java_awt_peer_gtk_GdkClasspathFontPeerMetri jintArray array; jint *metrics; struct peerfont *pf = NULL; + FT_Matrix mat; pf = NSA_GET_FONT_PTR(env, font); g_assert (pf != NULL); @@ -62,14 +63,21 @@ JNIEXPORT jintArray JNICALL Java_gnu_java_awt_peer_gtk_GdkClasspathFontPeerMetri gdk_threads_enter (); -#define DOUBLE_TO_26_6(d) ((FT_F26Dot6)((d) * 63.0)) -#define DOUBLE_FROM_26_6(t) (((double)((t) >> 6)) \ - + ((double)((t) & 0x3F) / 63.0)) +#define DOUBLE_TO_26_6(d) ((FT_F26Dot6)((d) * 64.0)) +#define DOUBLE_FROM_26_6(t) ((double)(t) / 64.0) +#define DOUBLE_TO_16_16(d) ((FT_Fixed)((d) * 65536.0)) +#define DOUBLE_FROM_16_16(t) ((double)(t) / 65536.0) double pointsize = pango_font_description_get_size (pf->desc); pointsize /= (double) PANGO_SCALE; + mat.xx = DOUBLE_TO_16_16(1); + mat.xy = DOUBLE_TO_16_16(0); + mat.yx = DOUBLE_TO_16_16(0); + mat.yy = DOUBLE_TO_16_16(1); + FT_Face face = pango_ft2_font_get_face (pf->font); + FT_Set_Transform(face, &mat, NULL); FT_Set_Char_Size( face, DOUBLE_TO_26_6 (pointsize), DOUBLE_TO_26_6 (pointsize), diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGlyphVector.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGlyphVector.c index 29616c738ed..b05d76ecb53 100644 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGlyphVector.c +++ b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGlyphVector.c @@ -47,10 +47,11 @@ typedef struct { double height; } rect_t; -#define DOUBLE_TO_26_6(d) ((FT_F26Dot6)((d) * 63.0)) -#define DOUBLE_FROM_26_6(t) (((double)((t) >> 6)) \ - + ((double)((t) & 0x3F) / 63.0)) - +#define DOUBLE_TO_26_6(d) ((FT_F26Dot6)((d) * 64.0)) +#define DOUBLE_FROM_26_6(t) ((double)(t) / 64.0) +#define DOUBLE_TO_16_16(d) ((FT_Fixed)((d) * 65536.0)) +#define DOUBLE_FROM_16_16(t) ((double)(t) / 65536.0) + JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGlyphVector_initStaticState (JNIEnv *env, jclass clazz) { @@ -401,6 +402,21 @@ JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_gtk_GdkGlyphVector_glyphCharIndex return idx; } +static void +assume_pointsize_and_identity_transform(double pointsize, + FT_Face face) +{ + FT_Matrix mat; + mat.xx = DOUBLE_TO_16_16(1); + mat.xy = DOUBLE_TO_16_16(0); + mat.yx = DOUBLE_TO_16_16(0); + mat.yy = DOUBLE_TO_16_16(1); + FT_Set_Transform(face, &mat, NULL); + FT_Set_Char_Size( face, + DOUBLE_TO_26_6 (pointsize), + DOUBLE_TO_26_6 (pointsize), + 0, 0); +} JNIEXPORT jdoubleArray JNICALL Java_gnu_java_awt_peer_gtk_GdkGlyphVector_allInkExtents (JNIEnv *env, jobject self) @@ -432,10 +448,7 @@ JNIEXPORT jdoubleArray JNICALL Java_gnu_java_awt_peer_gtk_GdkGlyphVector_allInkE g_assert (gi->glyphs != NULL); face = pango_ft2_font_get_face (gi->item->analysis.font); - FT_Set_Char_Size( face, - DOUBLE_TO_26_6 (pointsize), - DOUBLE_TO_26_6 (pointsize), - 0, 0); + assume_pointsize_and_identity_transform (pointsize, face); for (j = 0; j < gi->glyphs->num_glyphs; ++j) { @@ -487,10 +500,7 @@ JNIEXPORT jdoubleArray JNICALL Java_gnu_java_awt_peer_gtk_GdkGlyphVector_allLogi g_assert (gi->glyphs != NULL); face = pango_ft2_font_get_face (gi->item->analysis.font); - FT_Set_Char_Size( face, - DOUBLE_TO_26_6 (pointsize), - DOUBLE_TO_26_6 (pointsize), - 0, 0); + assume_pointsize_and_identity_transform (pointsize, face); for (j = 0; j < gi->glyphs->num_glyphs; ++j) { @@ -541,11 +551,9 @@ JNIEXPORT jdoubleArray JNICALL Java_gnu_java_awt_peer_gtk_GdkGlyphVector_glyphLo pointsize = pango_font_description_get_size (vec->desc); pointsize /= (double) PANGO_SCALE; face = pango_ft2_font_get_face (font); - FT_Set_Char_Size( face, - DOUBLE_TO_26_6 (pointsize), - DOUBLE_TO_26_6 (pointsize), - 0, 0); - + + assume_pointsize_and_identity_transform (pointsize, face); + FT_Load_Glyph (face, gi->glyph, FT_LOAD_DEFAULT); /* FIXME: this is probably not the correct set of metrics; @@ -588,10 +596,8 @@ JNIEXPORT jdoubleArray JNICALL Java_gnu_java_awt_peer_gtk_GdkGlyphVector_glyphIn pointsize = pango_font_description_get_size (vec->desc); pointsize /= (double) PANGO_SCALE; face = pango_ft2_font_get_face (font); - FT_Set_Char_Size( face, - DOUBLE_TO_26_6 (pointsize), - DOUBLE_TO_26_6 (pointsize), - 0, 0); + + assume_pointsize_and_identity_transform (pointsize, face); FT_Load_Glyph (face, gi->glyph, FT_LOAD_DEFAULT); /* FIXME: this needs to change for vertical layouts */ diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c index d53a69ac8d4..9c370e936cc 100644 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c +++ b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c @@ -188,7 +188,7 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_translateNative JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_drawString (JNIEnv *env, jobject obj, jstring str, jint x, jint y, - jstring fname, jint size) + jstring fname, jint style, jint size) { struct graphics *g; const char *cstr; @@ -209,6 +209,12 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_drawString font_desc = pango_font_description_from_string (font_name); pango_font_description_set_size (font_desc, size * PANGO_SCALE); + if (style & AWT_STYLE_BOLD) + pango_font_description_set_weight (font_desc, PANGO_WEIGHT_BOLD); + + if (style & AWT_STYLE_ITALIC) + pango_font_description_set_style (font_desc, PANGO_STYLE_OBLIQUE); + context = gdk_pango_context_get(); pango_context_set_font_description (context, font_desc); diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c index 581cb82cf75..f8ee342a033 100644 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c +++ b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c @@ -114,6 +114,15 @@ enum java_awt_geom_path_iterator_winding_rule java_awt_geom_path_iterator_WIND_NON_ZERO = 1 }; +enum java_awt_rendering_hints_filter + { + java_awt_rendering_hints_VALUE_INTERPOLATION_NEAREST_NEIGHBOR = 0, + java_awt_rendering_hints_VALUE_INTERPOLATION_BILINEAR = 1, + java_awt_rendering_hints_VALUE_ALPHA_INTERPOLATION_SPEED = 2, + java_awt_rendering_hints_VALUE_ALPHA_INTERPOLATION_QUALITY = 3, + java_awt_rendering_hints_VALUE_ALPHA_INTERPOLATION_DEFAULT = 4 + + }; static void grab_current_drawable (GtkWidget *widget, GdkDrawable **draw, GdkWindow **win) @@ -683,21 +692,8 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_drawPixels native_matrix[2], native_matrix[3], native_matrix[4], native_matrix[5]); cairo_surface_set_matrix (surf, mat); - if (native_matrix[0] != 1. - || native_matrix[1] != 0. - || native_matrix[2] != 0. - || native_matrix[3] != 1.) - { - cairo_surface_set_filter (surf, CAIRO_FILTER_BILINEAR); - cairo_surface_set_filter (gr->surface, CAIRO_FILTER_BILINEAR); - } - else - { - cairo_surface_set_filter (surf, CAIRO_FILTER_FAST); - cairo_surface_set_filter (gr->surface, CAIRO_FILTER_FAST); - } + cairo_surface_set_filter (surf, cairo_surface_get_filter(gr->surface)); cairo_show_surface (gr->cr, surf, w, h); - cairo_surface_set_filter (gr->surface, CAIRO_FILTER_FAST); cairo_matrix_destroy (mat); cairo_surface_destroy (surf); } @@ -709,6 +705,71 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_drawPixels } +JNIEXPORT jintArray JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_getImagePixels + (JNIEnv *env, jobject obj) +{ + struct graphics2d *gr = NULL; + jintArray java_pixels; + jint* native_pixels; + GdkPixbuf *buf = NULL; + gint width, height; + gint bits_per_sample = 8; + gboolean has_alpha = TRUE; + gint total_channels = 4; + jint i, px; + + gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj); + g_assert (gr != NULL); + + if (gr->debug) printf ("getImagePixels\n"); + + gdk_drawable_get_size (gr->drawable, &width, &height); + + buf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, has_alpha, + bits_per_sample, + width, height); + g_assert (buf != NULL); + g_assert (gdk_pixbuf_get_bits_per_sample (buf) == bits_per_sample); + g_assert (gdk_pixbuf_get_n_channels (buf) == total_channels); + + + /* copy pixels from drawable to pixbuf */ + + gdk_pixbuf_get_from_drawable (buf, gr->drawable, + NULL, + 0, 0, 0, 0, + width, height); + + native_pixels= gdk_pixbuf_get_pixels (buf); + + + /* NOTE: The pixels we got in the pixbuf are stored + in reversed order. i.e 0xBBGGRRAA. + We need to convert them to 0xAARRGGBB. */ + + for (i=0; i<width * height; i++) + { + + /* convert pixels from 0xBBGGRRAA to 0xAARRGGBB */ + + px = native_pixels[i]; + px = ((px >> 24) & 0xff) | ((px << 8) & 0xffffff00); + px = ((px >> 8) & 0x00ff00ff) | ((px << 8) & 0xff00ff00); + px = ((px >> 16) & 0x0000ffff) | ((px << 16) & 0xffff0000); + native_pixels[i] = px; + + } + + java_pixels = (*env) -> NewIntArray (env, width * height); + + (*env)->SetIntArrayRegion(env, java_pixels, + (jsize)0, (jsize) width*height, + (jint*) native_pixels); + + return java_pixels; + +} + /* passthrough methods to cairo */ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSave @@ -1157,3 +1218,30 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoClip cairo_clip (gr->cr); } +JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSurfaceSetFilter + (JNIEnv *env, jobject obj, jint filter) +{ + + struct graphics2d *gr = NULL; + gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj); + g_assert (gr != NULL); + if (gr->debug) printf ("cairo_surface_set_filter %d\n", filter); + switch ((enum java_awt_rendering_hints_filter) filter) + { + case java_awt_rendering_hints_VALUE_INTERPOLATION_NEAREST_NEIGHBOR: + cairo_surface_set_filter (gr->surface, CAIRO_FILTER_NEAREST); + break; + case java_awt_rendering_hints_VALUE_INTERPOLATION_BILINEAR: + cairo_surface_set_filter (gr->surface, CAIRO_FILTER_BILINEAR); + break; + case java_awt_rendering_hints_VALUE_ALPHA_INTERPOLATION_SPEED: + cairo_surface_set_filter (gr->surface, CAIRO_FILTER_FAST); + break; + case java_awt_rendering_hints_VALUE_ALPHA_INTERPOLATION_DEFAULT: + cairo_surface_set_filter (gr->surface, CAIRO_FILTER_NEAREST); + break; + case java_awt_rendering_hints_VALUE_ALPHA_INTERPOLATION_QUALITY: + cairo_surface_set_filter (gr->surface, CAIRO_FILTER_BEST); + break; + } +} diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c index b6b329d41d9..b0582cbe57b 100644 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c +++ b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c @@ -164,6 +164,69 @@ Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_nativeSetCheckboxGroup NSA_SET_PTR (env, group, native_group); } +JNIEXPORT void JNICALL +Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_gtkSetFont + (JNIEnv *env, jobject obj, jstring name, jint style, jint size) +{ + const char *font_name; + void *ptr; + GtkWidget *button; + GtkWidget *label; + PangoFontDescription *font_desc; + + ptr = NSA_GET_PTR (env, obj); + + button = GTK_WIDGET (ptr); + label = gtk_bin_get_child (GTK_BIN(button)); + + if (!label) + return; + + font_name = (*env)->GetStringUTFChars (env, name, NULL); + + gdk_threads_enter(); + + font_desc = pango_font_description_from_string (font_name); + pango_font_description_set_size (font_desc, size * PANGO_SCALE); + + if (style & AWT_STYLE_BOLD) + pango_font_description_set_weight (font_desc, PANGO_WEIGHT_BOLD); + + if (style & AWT_STYLE_ITALIC) + pango_font_description_set_style (font_desc, PANGO_STYLE_OBLIQUE); + + gtk_widget_modify_font (GTK_WIDGET(label), font_desc); + + pango_font_description_free (font_desc); + + gdk_threads_leave(); + + (*env)->ReleaseStringUTFChars (env, name, font_name); +} + +JNIEXPORT void JNICALL +Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_gtkSetLabel + (JNIEnv *env, jobject obj, jstring label) +{ + const char *str; + void *ptr; + GtkWidget *label_widget; + + ptr = NSA_GET_PTR (env, obj); + + label_widget = gtk_bin_get_child (GTK_BIN(ptr)); + + str = (*env)->GetStringUTFChars (env, label, 0); + + gdk_threads_enter (); + + gtk_label_set_label (GTK_LABEL (label_widget), str); + + gdk_threads_leave (); + + (*env)->ReleaseStringUTFChars (env, label, str); +} + static void item_toggled (GtkToggleButton *item, jobject peer) { diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c index 62a97e255d0..3bb957c92ac 100644 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c +++ b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c @@ -260,11 +260,11 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_setNativeBoun widget = GTK_WIDGET (ptr); if (GTK_IS_VIEWPORT (widget->parent)) { - gtk_widget_set_usize (widget, width, height); + gtk_widget_set_size_request (widget, width, height); } else { - gtk_widget_set_usize (widget, width, height); + gtk_widget_set_size_request (widget, width, height); gtk_layout_move (GTK_LAYOUT (widget->parent), widget, x, y); } @@ -380,6 +380,39 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetForeground gdk_threads_leave (); } +JNIEXPORT void JNICALL +Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkSetFont + (JNIEnv *env, jobject obj, jstring name, jint style, jint size) +{ + const char *font_name; + void *ptr; + GtkWidget *label; + PangoFontDescription *font_desc; + + ptr = NSA_GET_PTR (env, obj); + + font_name = (*env)->GetStringUTFChars (env, name, NULL); + + gdk_threads_enter(); + + font_desc = pango_font_description_from_string (font_name); + pango_font_description_set_size (font_desc, size * PANGO_SCALE); + + if (style & AWT_STYLE_BOLD) + pango_font_description_set_weight (font_desc, PANGO_WEIGHT_BOLD); + + if (style & AWT_STYLE_ITALIC) + pango_font_description_set_style (font_desc, PANGO_STYLE_OBLIQUE); + + gtk_widget_modify_font (GTK_WIDGET(ptr), font_desc); + + pango_font_description_free (font_desc); + + gdk_threads_leave(); + + (*env)->ReleaseStringUTFChars (env, name, font_name); +} + void set_visible (GtkWidget *widget, jboolean visible) { diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c index 64b2995ffbc..95f73011186 100644 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c +++ b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c @@ -83,6 +83,27 @@ state_to_awt_mods (guint state) return result; } +static jint +state_to_awt_mods_with_button_states (guint state) +{ + jint result = 0; + + if (state & GDK_SHIFT_MASK) + result |= AWT_SHIFT_MASK; + if (state & GDK_CONTROL_MASK) + result |= AWT_CTRL_MASK; + if (state & GDK_MOD1_MASK) + result |= AWT_ALT_MASK; + if (state & GDK_BUTTON1_MASK) + result |= AWT_BUTTON1_MASK; + if (state & GDK_BUTTON2_MASK) + result |= AWT_BUTTON2_MASK; + if (state & GDK_BUTTON3_MASK) + result |= AWT_BUTTON3_MASK; + + return result; +} + /* Modifier key events need special treatment. In Sun's peer implementation, when a modifier key is pressed, the KEY_PRESSED event has that modifier in its modifiers list. The corresponding @@ -830,6 +851,7 @@ pre_event_handler (GtkWidget *widget, GdkEvent *event, jobject peer) static GdkWindow *button_window = NULL; static guint button_number = -1; static jint click_count = 1; + static int hasBeenDragged; /* If it is not a focus change event, the widget must be realized already. If not, ignore the event (Gtk+ will do the same). */ @@ -895,6 +917,7 @@ pre_event_handler (GtkWidget *widget, GdkEvent *event, jobject peer) click_count, (event->button.button == 3) ? JNI_TRUE : JNI_FALSE); + hasBeenDragged = FALSE; break; case GDK_BUTTON_RELEASE: { @@ -911,10 +934,12 @@ pre_event_handler (GtkWidget *widget, GdkEvent *event, jobject peer) click_count, JNI_FALSE); - /* check to see if the release occured in the window it was pressed - in, and if so, generate an AWT click event */ + // 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. gdk_window_get_size (event->any.window, &width, &height); - if (event->button.x >= 0 + if (! hasBeenDragged + && event->button.x >= 0 && event->button.y >= 0 && event->button.x <= width && event->button.y <= height) @@ -933,15 +958,6 @@ pre_event_handler (GtkWidget *widget, GdkEvent *event, jobject peer) } break; case GDK_MOTION_NOTIFY: - (*gdk_env)->CallVoidMethod (gdk_env, peer, postMouseEventID, - AWT_MOUSE_MOVED, - (jlong)event->motion.time, - state_to_awt_mods (event->motion.state), - (jint)event->motion.x, - (jint)event->motion.y, - 0, - JNI_FALSE); - if (event->motion.state & (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK @@ -952,12 +968,22 @@ pre_event_handler (GtkWidget *widget, GdkEvent *event, jobject peer) postMouseEventID, AWT_MOUSE_DRAGGED, (jlong)event->motion.time, - state_to_awt_mods (event->motion.state), + state_to_awt_mods_with_button_states (event->motion.state), (jint)event->motion.x, (jint)event->motion.y, 0, JNI_FALSE); + hasBeenDragged = TRUE; } + else + (*gdk_env)->CallVoidMethod (gdk_env, peer, postMouseEventID, + AWT_MOUSE_MOVED, + (jlong)event->motion.time, + state_to_awt_mods (event->motion.state), + (jint)event->motion.x, + (jint)event->motion.y, + 0, + JNI_FALSE); break; case GDK_ENTER_NOTIFY: /* We are not interested in enter events that are due to @@ -966,7 +992,7 @@ pre_event_handler (GtkWidget *widget, GdkEvent *event, jobject peer) (*gdk_env)->CallVoidMethod (gdk_env, peer, postMouseEventID, AWT_MOUSE_ENTERED, (jlong)event->crossing.time, - state_to_awt_mods (event->crossing.state), + state_to_awt_mods_with_button_states (event->crossing.state), (jint)event->crossing.x, (jint)event->crossing.y, 0, @@ -980,7 +1006,7 @@ pre_event_handler (GtkWidget *widget, GdkEvent *event, jobject peer) postMouseEventID, AWT_MOUSE_EXITED, (jlong)event->crossing.time, - state_to_awt_mods (event->crossing.state), + state_to_awt_mods_with_button_states (event->crossing.state), (jint)event->crossing.x, (jint)event->crossing.y, 0, diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkLabelPeer.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkLabelPeer.c index 0865f63160b..c5848baa130 100644 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkLabelPeer.c +++ b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkLabelPeer.c @@ -70,6 +70,44 @@ Java_gnu_java_awt_peer_gtk_GtkLabelPeer_create } JNIEXPORT void JNICALL +Java_gnu_java_awt_peer_gtk_GtkLabelPeer_gtkSetFont + (JNIEnv *env, jobject obj, jstring name, jint style, jint size) +{ + const char *font_name; + void *ptr; + GtkWidget *label; + PangoFontDescription *font_desc; + + ptr = NSA_GET_PTR (env, obj); + + label = gtk_bin_get_child (GTK_BIN(ptr)); + + if (!label) + return; + + font_name = (*env)->GetStringUTFChars (env, name, NULL); + + gdk_threads_enter(); + + font_desc = pango_font_description_from_string (font_name); + pango_font_description_set_size (font_desc, size * PANGO_SCALE); + + if (style & AWT_STYLE_BOLD) + pango_font_description_set_weight (font_desc, PANGO_WEIGHT_BOLD); + + if (style & AWT_STYLE_ITALIC) + pango_font_description_set_style (font_desc, PANGO_STYLE_OBLIQUE); + + gtk_widget_modify_font (GTK_WIDGET(label), font_desc); + + pango_font_description_free (font_desc); + + gdk_threads_leave(); + + (*env)->ReleaseStringUTFChars (env, name, font_name); +} + +JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkLabelPeer_setText (JNIEnv *env, jobject obj, jstring text) { diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c index da1550fa8c7..80d9d5bfb1b 100644 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c +++ b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c @@ -44,6 +44,12 @@ exception statement from your version. */ #include <gdk/gdkx.h> #include <X11/Xatom.h> +static int filter_added = 0; + +static GdkFilterReturn window_wm_protocols_filter (GdkXEvent *xev, + GdkEvent *event, + gpointer data); + static void window_get_frame_extents (GtkWidget *window, int *top, int *left, int *bottom, int *right); @@ -59,12 +65,9 @@ static void window_delete_cb (GtkWidget *widget, GdkEvent *event, static void window_destroy_cb (GtkWidget *widget, GdkEvent *event, jobject peer); static void window_show_cb (GtkWidget *widget, jobject peer); -static gboolean window_focus_in_cb (GtkWidget * widget, - GdkEventFocus *event, - jobject peer); -static gboolean window_focus_out_cb (GtkWidget * widget, - GdkEventFocus *event, - jobject peer); +static void window_focus_or_active_state_change_cb (GtkWidget *widget, + GParamSpec *pspec, + jobject peer); static gboolean window_window_state_cb (GtkWidget *widget, GdkEvent *event, jobject peer); @@ -147,6 +150,20 @@ Java_gnu_java_awt_peer_gtk_GtkWindowPeer_create insets[2] = bottom; insets[3] = right; + /* We must filter out WM_TAKE_FOCUS messages. Otherwise we get two + focus in events when a window becomes active and two focus out + events when a window becomes inactive. */ + if (!filter_added) + { + GdkAtom wm_protocols_atom = + gdk_x11_xatom_to_atom (gdk_x11_get_xatom_by_name ("WM_PROTOCOLS")); + + gdk_add_client_message_filter (wm_protocols_atom, + window_wm_protocols_filter, + NULL); + filter_added = 1; + } + gdk_threads_leave (); (*env)->ReleaseIntArrayElements (env, jinsets, insets, 0); @@ -251,11 +268,8 @@ Java_gnu_java_awt_peer_gtk_GtkWindowPeer_connectSignals g_signal_connect (G_OBJECT (ptr), "show", G_CALLBACK (window_show_cb), *gref); - g_signal_connect (G_OBJECT (ptr), "focus-in-event", - G_CALLBACK (window_focus_in_cb), *gref); - - g_signal_connect (G_OBJECT (ptr), "focus-out-event", - G_CALLBACK (window_focus_out_cb), *gref); + g_signal_connect (G_OBJECT (ptr), "notify", + G_CALLBACK (window_focus_or_active_state_change_cb), *gref); g_signal_connect (G_OBJECT (ptr), "window-state-event", G_CALLBACK (window_window_state_cb), *gref); @@ -661,40 +675,37 @@ window_show_cb (GtkWidget *widget __attribute__((unused)), (jobject) NULL, (jint) 0); } -static gboolean -window_focus_in_cb (GtkWidget * widget __attribute__((unused)), - GdkEventFocus *event __attribute__((unused)), - jobject peer) -{ - /* FIXME: when hiding then showing, we get two sets of - (LOST_FOCUS/DEACTIVATED, ACTIVATED/GAINED_FOCUS) events. */ - (*gdk_env)->CallVoidMethod (gdk_env, peer, - postWindowEventID, - (jint) AWT_WINDOW_ACTIVATED, - (jobject) NULL, (jint) 0); - - (*gdk_env)->CallVoidMethod (gdk_env, peer, - postWindowEventID, - (jint) AWT_WINDOW_GAINED_FOCUS, - (jobject) NULL, (jint) 0); - return TRUE; -} - -static gboolean -window_focus_out_cb (GtkWidget * widget __attribute__((unused)), - GdkEventFocus *event __attribute__((unused)), - jobject peer) +static void +window_focus_or_active_state_change_cb (GtkWidget *widget, + GParamSpec *pspec, + jobject peer) { - (*gdk_env)->CallVoidMethod (gdk_env, peer, - postWindowEventID, - (jint) AWT_WINDOW_LOST_FOCUS, - (jobject) NULL, (jint) 0); - - (*gdk_env)->CallVoidMethod (gdk_env, peer, - postWindowEventID, - (jint) AWT_WINDOW_DEACTIVATED, - (jobject) NULL, (jint) 0); - return TRUE; + if (!strcmp (g_param_spec_get_name (pspec), "is-active")) + { + if (GTK_WINDOW (widget)->is_active) + (*gdk_env)->CallVoidMethod (gdk_env, peer, + postWindowEventID, + (jint) AWT_WINDOW_GAINED_FOCUS, + (jobject) NULL, (jint) 0); + else + (*gdk_env)->CallVoidMethod (gdk_env, peer, + postWindowEventID, + (jint) AWT_WINDOW_DEACTIVATED, + (jobject) NULL, (jint) 0); + } + else if (!strcmp (g_param_spec_get_name (pspec), "has-toplevel-focus")) + { + if (GTK_WINDOW (widget)->has_toplevel_focus) + (*gdk_env)->CallVoidMethod (gdk_env, peer, + postWindowEventID, + (jint) AWT_WINDOW_ACTIVATED, + (jobject) NULL, (jint) 0); + else + (*gdk_env)->CallVoidMethod (gdk_env, peer, + postWindowEventID, + (jint) AWT_WINDOW_LOST_FOCUS, + (jobject) NULL, (jint) 0); + } } static gboolean @@ -821,3 +832,16 @@ window_property_changed_cb (GtkWidget *widget __attribute__((unused)), return FALSE; } + +static GdkFilterReturn +window_wm_protocols_filter (GdkXEvent *xev, + GdkEvent *event __attribute__((unused)), + gpointer data __attribute__((unused))) +{ + XEvent *xevent = (XEvent *)xev; + + if ((Atom) xevent->xclient.data.l[0] == gdk_x11_get_xatom_by_name ("WM_TAKE_FOCUS")) + return GDK_FILTER_REMOVE; + + return GDK_FILTER_CONTINUE; +} |