[kaffe] CVS kaffe (robilad): Resyynced with GNU Classpath: various small AWT fixes

Kaffe CVS cvs-commits at kaffe.org
Sat Dec 11 15:15:27 PST 2004


PatchSet 5614 
Date: 2004/12/11 23:08:35
Author: robilad
Branch: HEAD
Tag: (none) 
Log:
Resyynced with GNU Classpath: various small AWT fixes

2004-12-11  Dalibor Topic  <robilad at kaffe.org>

        * libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c,
        libraries/javalib/gnu/java/awt/peer/gtk/GdkGraphics.java,
        libraries/javalib/gnu/java/awt/peer/gtk/GtkFramePeer.java,
        libraries/javalib/gnu/java/awt/peer/gtk/GtkWindowPeer.java,
        libraries/javalib/java/awt/Component.java,
        libraries/javalib/java/awt/Container.java,
        libraries/javalib/java/awt/Window.java:
        Resynced with GNU Classpath.

        2004-12-11  Thomas Fitzsimmons  <fitzsim at redhat.com>

        * gnu/java/awt/peer/gtk/GdkGraphics.java (setClip): Protect
        against null clip region.
        * gnu/java/awt/peer/gtk/GtkFramePeer.java (create): Call
        gtkWindowSetResizable.
        (postConfigureEvent): Only revalidate if frame size has changed.
        * gnu/java/awt/peer/gtk/GtkWindowPeer.java (postConfigureEvent):
        Only revalidate if frame size has changed.
        * java/awt/Component.java (reshape): Only repaint and post
        component events if component is showing.
        * java/awt/Container.java (addImpl): Only post container event if
        container is showing.
        (remove): Likewise.
        * java/awt/Window.java (setLocationRelativeTo): Implement.
        (setBoundsCallback): Only post component events if component is
        showing.
        * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c (clearRect):
        Protect against null graphics structure.  Flush gdk event queue.

Members: 
	ChangeLog:1.3159->1.3160 
	libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c:1.8->1.9 
	libraries/javalib/gnu/java/awt/peer/gtk/GdkGraphics.java:1.7->1.8 
	libraries/javalib/gnu/java/awt/peer/gtk/GtkFramePeer.java:1.6->1.7 
	libraries/javalib/gnu/java/awt/peer/gtk/GtkWindowPeer.java:1.4->1.5 
	libraries/javalib/java/awt/Component.java:1.45->1.46 
	libraries/javalib/java/awt/Container.java:1.27->1.28 
	libraries/javalib/java/awt/Window.java:1.24->1.25 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.3159 kaffe/ChangeLog:1.3160
--- kaffe/ChangeLog:1.3159	Sat Dec 11 20:49:36 2004
+++ kaffe/ChangeLog	Sat Dec 11 23:08:35 2004
@@ -1,3 +1,34 @@
+2004-12-11  Dalibor Topic  <robilad at kaffe.org>
+
+	* libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c,
+	libraries/javalib/gnu/java/awt/peer/gtk/GdkGraphics.java,
+	libraries/javalib/gnu/java/awt/peer/gtk/GtkFramePeer.java,
+	libraries/javalib/gnu/java/awt/peer/gtk/GtkWindowPeer.java,
+	libraries/javalib/java/awt/Component.java,
+	libraries/javalib/java/awt/Container.java,
+	libraries/javalib/java/awt/Window.java:
+	Resynced with GNU Classpath.
+
+	2004-12-11  Thomas Fitzsimmons  <fitzsim at redhat.com>
+
+	* gnu/java/awt/peer/gtk/GdkGraphics.java (setClip): Protect
+	against null clip region.
+	* gnu/java/awt/peer/gtk/GtkFramePeer.java (create): Call
+	gtkWindowSetResizable.
+	(postConfigureEvent): Only revalidate if frame size has changed.
+	* gnu/java/awt/peer/gtk/GtkWindowPeer.java (postConfigureEvent):
+	Only revalidate if frame size has changed.
+	* java/awt/Component.java (reshape): Only repaint and post
+	component events if component is showing.
+	* java/awt/Container.java (addImpl): Only post container event if
+	container is showing.
+	(remove): Likewise.
+	* java/awt/Window.java (setLocationRelativeTo): Implement.
+	(setBoundsCallback): Only post component events if component is
+	showing.
+	* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c (clearRect):
+	Protect against null graphics structure.  Flush gdk event queue.
+	
 2004-12-11  Adam Heath  <doogie at brainfood.com>
 
 	* include/Arrays.h, include/native.h, kaffe/kaffevm/object.c,
Index: kaffe/libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c
diff -u kaffe/libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c:1.8 kaffe/libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c:1.9
--- kaffe/libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c:1.8	Fri Dec  3 23:21:55 2004
+++ kaffe/libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c	Sat Dec 11 23:08:37 2004
@@ -438,6 +438,12 @@
   g = (struct graphics *) NSA_GET_PTR (env, obj);
 
   gdk_threads_enter ();
+
+  if (!g)
+    {
+      gdk_threads_leave ();
+      return;
+    }
   if (GDK_IS_WINDOW (g->drawable))
     {
       w.widget = &widget;
@@ -455,6 +461,8 @@
 			  x + g->x_offset, y + g->y_offset, width, height);
       gdk_gc_set_foreground (g->gc, &(saved.foreground));
     }
+
+  gdk_flush ();
   gdk_threads_leave ();
 }
 
Index: kaffe/libraries/javalib/gnu/java/awt/peer/gtk/GdkGraphics.java
diff -u kaffe/libraries/javalib/gnu/java/awt/peer/gtk/GdkGraphics.java:1.7 kaffe/libraries/javalib/gnu/java/awt/peer/gtk/GdkGraphics.java:1.8
--- kaffe/libraries/javalib/gnu/java/awt/peer/gtk/GdkGraphics.java:1.7	Fri Dec  3 23:21:55 2004
+++ kaffe/libraries/javalib/gnu/java/awt/peer/gtk/GdkGraphics.java	Sat Dec 11 23:08:38 2004
@@ -418,7 +418,8 @@
 
   public void setClip (int x, int y, int width, int height)
   {
-    if (component != null && ! component.isRealized ())
+    if ((component != null && ! component.isRealized ())
+        || clip == null)
       return;
 
     clip.x = x;
Index: kaffe/libraries/javalib/gnu/java/awt/peer/gtk/GtkFramePeer.java
diff -u kaffe/libraries/javalib/gnu/java/awt/peer/gtk/GtkFramePeer.java:1.6 kaffe/libraries/javalib/gnu/java/awt/peer/gtk/GtkFramePeer.java:1.7
--- kaffe/libraries/javalib/gnu/java/awt/peer/gtk/GtkFramePeer.java:1.6	Fri Dec  3 23:21:56 2004
+++ kaffe/libraries/javalib/gnu/java/awt/peer/gtk/GtkFramePeer.java	Sat Dec 11 23:08:38 2004
@@ -165,7 +165,7 @@
     setMenuBar (frame.getMenuBar ());
 
     setTitle (frame.getTitle ());
-    setResizable (frame.isResizable ());
+    gtkWindowSetResizable (frame.isResizable ());
     setIconImage(frame.getIconImage());
   }
 
@@ -237,9 +237,9 @@
                            frame_y,
                            frame_width,
                            frame_height);
-      }
 
-    awtComponent.validate();
+        awtComponent.validate();
+      }
   }
 
   protected void postMouseEvent(int id, long when, int mods, int x, int y, 
Index: kaffe/libraries/javalib/gnu/java/awt/peer/gtk/GtkWindowPeer.java
diff -u kaffe/libraries/javalib/gnu/java/awt/peer/gtk/GtkWindowPeer.java:1.4 kaffe/libraries/javalib/gnu/java/awt/peer/gtk/GtkWindowPeer.java:1.5
--- kaffe/libraries/javalib/gnu/java/awt/peer/gtk/GtkWindowPeer.java:1.4	Sat Oct  9 22:18:51 2004
+++ kaffe/libraries/javalib/gnu/java/awt/peer/gtk/GtkWindowPeer.java	Sat Dec 11 23:08:38 2004
@@ -166,10 +166,12 @@
 	|| frame_y != awtComponent.getY()
 	|| frame_width != awtComponent.getWidth()
 	|| frame_height != awtComponent.getHeight())
-      setBoundsCallback ((Window) awtComponent,
-			 frame_x, frame_y, frame_width, frame_height);
+      {
+        setBoundsCallback ((Window) awtComponent,
+                           frame_x, frame_y, frame_width, frame_height);
 
-    awtComponent.validate();
+        awtComponent.validate();
+      }
   }
 
   native void nativeSetVisible (boolean b);
Index: kaffe/libraries/javalib/java/awt/Component.java
diff -u kaffe/libraries/javalib/java/awt/Component.java:1.45 kaffe/libraries/javalib/java/awt/Component.java:1.46
--- kaffe/libraries/javalib/java/awt/Component.java:1.45	Mon Dec  6 19:02:13 2004
+++ kaffe/libraries/javalib/java/awt/Component.java	Sat Dec 11 23:08:40 2004
@@ -1362,7 +1362,7 @@
       peer.setBounds (x, y, width, height);
 
     // Erase old bounds and repaint new bounds for lightweights.
-    if (isLightweight())
+    if (isLightweight() && isShowing ())
       {
         boolean shouldRepaintParent = false;
         boolean shouldRepaintSelf = false;
@@ -1386,13 +1386,16 @@
           repaint();
       }
 
-    if (oldx != x || oldy != y)
+    // Only post event if this component is visible and has changed size.
+    if (isShowing ()
+        && (oldx != x || oldy != y))
       {
         ComponentEvent ce = new ComponentEvent(this,
                                                ComponentEvent.COMPONENT_MOVED);
         getToolkit().getSystemEventQueue().postEvent(ce);
       }
-    if (oldwidth != width || oldheight != height)
+    if (isShowing ()
+        && (oldwidth != width || oldheight != height))
       {
         ComponentEvent ce = new ComponentEvent(this,
                                                ComponentEvent.COMPONENT_RESIZED);
Index: kaffe/libraries/javalib/java/awt/Container.java
diff -u kaffe/libraries/javalib/java/awt/Container.java:1.27 kaffe/libraries/javalib/java/awt/Container.java:1.28
--- kaffe/libraries/javalib/java/awt/Container.java:1.27	Wed Nov 24 21:49:17 2004
+++ kaffe/libraries/javalib/java/awt/Container.java	Sat Dec 11 23:08:40 2004
@@ -387,11 +387,14 @@
               layoutMgr.addLayoutComponent(null, comp);
           }
 
-        // Post event to notify of adding the container.
-        ContainerEvent ce = new ContainerEvent(this,
-                                               ContainerEvent.COMPONENT_ADDED,
-                                               comp);
-        getToolkit().getSystemEventQueue().postEvent(ce);
+        if (isShowing ())
+          {
+            // Post event to notify of adding the component.
+            ContainerEvent ce = new ContainerEvent(this,
+                                                   ContainerEvent.COMPONENT_ADDED,
+                                                   comp);
+            getToolkit().getSystemEventQueue().postEvent(ce);
+          }
       }
   }
 
@@ -419,11 +422,14 @@
 
         r.parent = null;
 
-        // Post event to notify of adding the container.
-        ContainerEvent ce = new ContainerEvent(this,
-                                               ContainerEvent.COMPONENT_REMOVED,
-                                               r);
-        getToolkit().getSystemEventQueue().postEvent(ce);
+        if (isShowing ())
+          {
+            // Post event to notify of removing the component.
+            ContainerEvent ce = new ContainerEvent(this,
+                                                   ContainerEvent.COMPONENT_REMOVED,
+                                                   r);
+            getToolkit().getSystemEventQueue().postEvent(ce);
+          }
       }
   }
 
Index: kaffe/libraries/javalib/java/awt/Window.java
diff -u kaffe/libraries/javalib/java/awt/Window.java:1.24 kaffe/libraries/javalib/java/awt/Window.java:1.25
--- kaffe/libraries/javalib/java/awt/Window.java:1.24	Wed Nov 24 21:49:19 2004
+++ kaffe/libraries/javalib/java/awt/Window.java	Sat Dec 11 23:08:40 2004
@@ -731,6 +731,22 @@
     return super.isShowing();
   }
 
+  public void setLocationRelativeTo (Component c)
+  {
+    if (c == null || !c.isShowing ())
+      {
+        int x = 0;
+        int y = 0;
+
+        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment ();
+        Point center = ge.getCenterPoint ();
+        x = center.x - (width / 2);
+        y = center.y - (height / 2);
+        setLocation (x, y);
+      }
+    // FIXME: handle case where component is non-null.
+  }
+
   /**
    * @since 1.2
    *
@@ -866,13 +882,13 @@
     this.y = y;
     width = w;
     height = h;
-    if (resized)
+    if (resized && isShowing ())
       {
         ComponentEvent ce =
           new ComponentEvent(this, ComponentEvent.COMPONENT_RESIZED);
         getToolkit().getSystemEventQueue().postEvent(ce);
       }
-    if (moved)
+    if (moved && isShowing ())
       {
         ComponentEvent ce =
           new ComponentEvent(this, ComponentEvent.COMPONENT_MOVED);




More information about the kaffe mailing list