This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] enable double buffering on GtkCanvasPeer


hi,

this patch enables GDK's double buffering on the canvas peer, so that
it behaves like a "normal" flicker-less GTK widget when you paint into
it.

ok?

-graydon

Index: gnu/java/awt/peer/gtk/GtkCanvasPeer.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/java/awt/peer/gtk/GtkCanvasPeer.java,v
retrieving revision 1.2
diff -u -r1.2 GtkCanvasPeer.java
--- gnu/java/awt/peer/gtk/GtkCanvasPeer.java	13 Jul 2003 15:09:20 -0000	1.2
+++ gnu/java/awt/peer/gtk/GtkCanvasPeer.java	18 Jul 2003 15:16:30 -0000
@@ -48,6 +48,8 @@
 public class GtkCanvasPeer extends GtkComponentPeer implements CanvasPeer
 {
   native void create ();
+  native void beginDraw ();
+  native void endDraw ();
 
   public GtkCanvasPeer (Canvas c)
   {
@@ -68,6 +70,7 @@
       case PaintEvent.PAINT:
       case PaintEvent.UPDATE:
 	{
+    beginDraw ();
 	  try 
 	    {
 	      Graphics g = getGraphics ();
@@ -84,6 +87,7 @@
 	    { 
 	      System.err.println (e);
 	    }
+    endDraw ();
 	}
 	break;
       }
Index: jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCanvasPeer.c
===================================================================
RCS file: /cvs/gcc/gcc/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCanvasPeer.c,v
retrieving revision 1.1
diff -u -r1.1 gnu_java_awt_peer_gtk_GtkCanvasPeer.c
--- jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCanvasPeer.c	31 Jan 2003 17:54:14 -0000	1.1
+++ jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCanvasPeer.c	18 Jul 2003 15:16:32 -0000
@@ -38,6 +38,7 @@
 
 #include "gtkpeer.h"
 #include "gnu_java_awt_peer_gtk_GtkCanvasPeer.h"
+#include <assert.h>
 
 JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkCanvasPeer_create
   (JNIEnv *env, jobject obj)
@@ -52,3 +53,42 @@
 }
 
 
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkCanvasPeer_beginDraw
+  (JNIEnv *env, jobject obj)
+{
+  GtkWidget *w;
+  GdkDrawable *d;
+  GdkRectangle rect;
+
+  gdk_threads_enter ();
+
+  w = GTK_WIDGET (NSA_GET_PTR (env, obj));
+  assert (w);
+
+  d = GDK_DRAWABLE (w->window);
+  assert (d);
+
+  rect.x = 0;
+  rect.y = 0;
+  gdk_drawable_get_size (d, &(rect.width), &(rect.height));
+  gdk_window_begin_paint_rect (GDK_WINDOW (d), &rect); 
+  gdk_threads_leave ();    
+}
+
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkCanvasPeer_endDraw
+  (JNIEnv *env, jobject obj)
+{
+  GtkWidget *w;
+  GdkDrawable *d;
+
+  gdk_threads_enter ();
+
+  w = GTK_WIDGET (NSA_GET_PTR (env, obj));
+  assert (w);
+
+  d = GDK_DRAWABLE (w->window);
+  assert (d);
+
+  gdk_window_end_paint (GDK_WINDOW (d)); 
+  gdk_threads_leave ();
+}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]