Hi,

This patch changes the GTK peers, so that they can be compiled and used
on systems without X, for example on GTK for embedded or Windows
systems. In many places this only removes imports that are unused, there
are only two notable changes:
- The GdkRobotPeer now has #ifdef HAVE_XTEST for all operations and does
nothing if XTest is not present on compile time.
- The code for fetching the frame extents now uses the (new?) GDK
function gdk_window_get_frame_extents() rather than pulling the frame
extents using the extended window property _NET_FRAME_EXTENTS.

2007-09-11  Roman Kennke  <[EMAIL PROTECTED]>

        * native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c
        Removed unused includes.
        * native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoSurface.c
        Removed unused includes.
        * native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c
        Removed unusued excludes. Put Xrender includes in HAVE_XRENDER
        conditional.
        (flush): Use gdk_display_flush() instead of XFlush().
        (initState): Use GDK/Cairo functions to get cairo_t object.
        (initFromVolatile): Likewise.
        *
native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphicsCopy.c
        Removed unused includes.
        * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkRobotPeer.c
        Use HAVE_XTEST conditionals for code that uses XTest.
        * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c
        Removed unused includes.
        * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c
        Removed unused includes.
        * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkVolatileImage.c
        Removed unused includes.
        * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
        Removed unused includes. Rewrote frame-extents code to use
        gdk_window_get_frame_extents() rather than the X window
properties
        directly.
        * include/gnu_java_awt_peer_gtk_ComponentGraphics.h
        (initFromVolatile): Removed width and height parameters.
        * gnu/java/awt/peer/gtk/ComponentGraphics.java
        (initFromVolatile): Remove width and height parameters.
        * gnu/java/awt/peer/gtk/VolatileImageGraphics.java
        (VolatileImageGraphics): Use initFromVolatile without width and
        height.
        * configure.ac: Check for presence of XTest, and define
HAVE_XTEST
        accordingly.

/Roman

-- 
Dipl.-Inform. (FH) Roman Kennke, Software Engineer, http://kennke.org
aicas Allerton Interworks Computer Automated Systems GmbH
Haid-und-Neu-Straße 18 * D-76131 Karlsruhe * Germany
http://www.aicas.com   * Tel: +49-721-663 968-0
USt-Id: DE216375633, Handelsregister HRB 109481, AG Karlsruhe
Geschäftsführer: Dr. James J. Hunt
Index: include/gnu_java_awt_peer_gtk_ComponentGraphics.h
===================================================================
RCS file: /cvsroot/classpath/classpath/include/gnu_java_awt_peer_gtk_ComponentGraphics.h,v
retrieving revision 1.11
diff -u -1 -0 -r1.11 gnu_java_awt_peer_gtk_ComponentGraphics.h
--- include/gnu_java_awt_peer_gtk_ComponentGraphics.h	9 Apr 2007 21:34:27 -0000	1.11
+++ include/gnu_java_awt_peer_gtk_ComponentGraphics.h	11 Sep 2007 09:44:10 -0000
@@ -4,21 +4,21 @@
 #define __gnu_java_awt_peer_gtk_ComponentGraphics__
 
 #include <jni.h>
 
 #ifdef __cplusplus
 extern "C"
 {
 #endif
 
 JNIEXPORT jlong JNICALL Java_gnu_java_awt_peer_gtk_ComponentGraphics_initState (JNIEnv *env, jobject, jobject);
-JNIEXPORT jlong JNICALL Java_gnu_java_awt_peer_gtk_ComponentGraphics_initFromVolatile (JNIEnv *env, jobject, jlong, jint, jint);
+JNIEXPORT jlong JNICALL Java_gnu_java_awt_peer_gtk_ComponentGraphics_initFromVolatile (JNIEnv *env, jobject, jlong);
 JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_ComponentGraphics_start_1gdk_1drawing (JNIEnv *env, jobject);
 JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_ComponentGraphics_end_1gdk_1drawing (JNIEnv *env, jobject);
 JNIEXPORT jboolean JNICALL Java_gnu_java_awt_peer_gtk_ComponentGraphics_hasXRender (JNIEnv *env, jclass);
 JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_gtk_ComponentGraphics_nativeGrab (JNIEnv *env, jclass, jobject);
 JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_ComponentGraphics_copyAreaNative (JNIEnv *env, jobject, jobject, jint, jint, jint, jint, jint, jint);
 JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_ComponentGraphics_drawVolatile (JNIEnv *env, jobject, jobject, jlong, jint, jint, jint, jint, jint, jint, jint, jint);
 
 #ifdef __cplusplus
 }
 #endif
Index: configure.ac
===================================================================
RCS file: /cvsroot/classpath/classpath/configure.ac,v
retrieving revision 1.212
diff -u -1 -0 -r1.212 configure.ac
--- configure.ac	9 Jul 2007 16:32:20 -0000	1.212
+++ configure.ac	11 Sep 2007 09:44:10 -0000
@@ -478,25 +478,27 @@
     AC_SUBST(XSLT_LIBS)
     AC_SUBST(XSLT_CFLAGS)
   fi
 
   dnl Check for AWT related gthread/gtk
   if test "x${COMPILE_GTK_PEER}" = xyes; then
     AC_PATH_XTRA
     if test "$no_x" = yes; then
         AC_MSG_ERROR([GTK+ peers requested but no X library available])
     fi
-    dnl We explicitly want the XTest Extension for Robot support.
+    dnl Check if we can link against the XTest library and set
+    dnl HAVE_XTEST accordingly.
     AC_CHECK_LIB([Xtst], [XTestQueryExtension],
-    		 [XTEST_LIBS="$XTEST_LIBS -lX11 -lXtst"],
-		 [AC_MSG_ERROR([libXtst NOT found, required for GdkRobot])],
-		 [${X_LIBS}])
+                 [AC_DEFINE(HAVE_XTEST, 1, [Define to 1 if you have libXtst.])[XTEST_LIBS="$XTEST_LIBS -X11 -lXtst"]],
+                 [true],
+                 [${X_LIBS}])
+
 
     PKG_CHECK_MODULES(GTK, gtk+-2.0 >= 2.8 gthread-2.0 >= 2.2 gdk-pixbuf-2.0)
     PKG_CHECK_MODULES(FREETYPE2, freetype2)
     PKG_CHECK_MODULES(PANGOFT2, pangoft2)
     PKG_CHECK_MODULES(CAIRO, cairo >= 1.1.8)
     dnl Check if we can link against the XRender library and set
     dnl HAVE_XRENDER accordingly.
     AC_CHECK_LIB([Xrender], [XRenderQueryExtension],
 		 [AC_DEFINE(HAVE_XRENDER, 1, [Define to 1 if you have libXrender.])[X_EXTRA_LIBS="$X_EXTRA_LIBS -lXrender"]],
 		 [true],
Index: native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c
===================================================================
RCS file: /cvsroot/classpath/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c,v
retrieving revision 1.25
diff -u -1 -0 -r1.25 gnu_java_awt_peer_gtk_CairoGraphics2D.c
--- native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c	21 Jun 2007 14:07:01 -0000	1.25
+++ native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c	11 Sep 2007 09:44:10 -0000
@@ -34,24 +34,22 @@
 this exception to your version of the library, but you are not
 obligated to do so.  If you do not wish to do so, delete this
 exception statement from your version. */
 
 #include "jcl.h"
 #include "gdkfont.h"
 #include "cairographics2d.h"
 #include "gnu_java_awt_peer_gtk_CairoGraphics2D.h"
 #include <gdk/gdktypes.h>
 #include <gdk/gdkprivate.h>
-#include <gdk/gdkx.h>
 
 #include <cairo-ft.h>
-#include <cairo-xlib.h>
 
 #include <stdio.h>
 #include <stdlib.h>
 
 static void update_pattern_transform (struct cairographics2d *gr);
 
 /**
  * Allocates the cairographics2d structure.
  */
 JNIEXPORT jlong JNICALL
Index: native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoSurface.c
===================================================================
RCS file: /cvsroot/classpath/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoSurface.c,v
retrieving revision 1.24
diff -u -1 -0 -r1.24 gnu_java_awt_peer_gtk_CairoSurface.c
--- native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoSurface.c	23 Feb 2007 15:44:14 -0000	1.24
+++ native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoSurface.c	11 Sep 2007 09:44:11 -0000
@@ -30,22 +30,20 @@
 terms of your choice, provided that you also meet, for each linked
 independent module, the terms and conditions of the license of that
 module.  An independent module is a module which is not derived from
 or based on this library.  If you modify this library, you may extend
 this exception to your version of the library, but you are not
 obligated to do so.  If you do not wish to do so, delete this
 exception statement from your version. */
 
 #include "jcl.h"
 #include "gtkpeer.h"
-#include <cairo-xlib.h>
-#include <gdk/gdkx.h>
 
 #include "gnu_java_awt_peer_gtk_CairoSurface.h"
 #include "cairographics2d.h"
 
 /**
  * Field names in CairoSurface.java
  */
 #define SURFACE "surfacePointer"
 #define SHARED "sharedBuffer"
 
Index: native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c
===================================================================
RCS file: /cvsroot/classpath/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c,v
retrieving revision 1.21
diff -u -1 -0 -r1.21 gnu_java_awt_peer_gtk_ComponentGraphics.c
--- native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c	25 Apr 2007 14:53:03 -0000	1.21
+++ native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c	11 Sep 2007 09:44:11 -0000
@@ -30,46 +30,47 @@
 terms of your choice, provided that you also meet, for each linked
 independent module, the terms and conditions of the license of that
 module.  An independent module is a module which is not derived from
 or based on this library.  If you modify this library, you may extend
 this exception to your version of the library, but you are not
 obligated to do so.  If you do not wish to do so, delete this
 exception statement from your version. */
 
 #include "jcl.h"
 #include "gtkpeer.h"
-#include <cairo-xlib.h>
 #include <gdk/gdktypes.h>
 #include <gdk/gdkprivate.h>
-#include <gdk/gdkx.h>
-#include <X11/extensions/Xrender.h>
 
 #include <gdk-pixbuf/gdk-pixbuf.h>
 #include <gdk-pixbuf/gdk-pixdata.h>
 
 #include <cairo-ft.h>
-#include <cairo-xlib.h>
 
 #include <stdio.h>
 #include <stdlib.h>
 
+#if HAVE_XRENDER
+#include <gdk/gdkx.h>
+#include <X11/extensions/Xrender.h>
+#endif
+
 #include "gnu_java_awt_peer_gtk_ComponentGraphics.h"
 
 #include "cairographics2d.h"
 
 static short flush_scheduled = 0;
 
 static gboolean flush (gpointer data __attribute__((unused)))
 {
   gdk_threads_enter ();
 
-  XFlush (GDK_DISPLAY ());
+  gdk_display_flush (gdk_display_get_default ());
   flush_scheduled = 0;
 
   gdk_threads_leave ();
 
   return FALSE;
 }
 
 /* The minimum time period between calls to XFlush, in
    milliseconds. */
 #define MINIMUM_FLUSH_PERIOD 20
@@ -100,111 +101,75 @@
 
 /**
  * Returns whether the XRender extension is supported
  */
 JNIEXPORT jboolean JNICALL 
 Java_gnu_java_awt_peer_gtk_ComponentGraphics_hasXRender
   (JNIEnv *env __attribute__ ((unused)), jclass cls __attribute__ ((unused)))
 {
 #if HAVE_XRENDER
   int ev = 0, err = 0; 
-  if( XRenderQueryExtension (GDK_DISPLAY (), &ev, &err) )
+  if( XRenderQueryExtension (GDK_DISPLAY(), &ev, &err) )
     return JNI_TRUE;
 #endif
   return JNI_FALSE;
 }
 
 
 JNIEXPORT jlong JNICALL 
 Java_gnu_java_awt_peer_gtk_ComponentGraphics_initState
   (JNIEnv *env, jobject obj __attribute__ ((unused)), jobject peer)
 {
-  Drawable draw;
-  Display * dpy;
-  Visual * vis;
   GdkDrawable *drawable;
-  cairo_surface_t *surface;
-  GdkWindow *win;
-  GtkWidget *widget = NULL;
+  GtkWidget *widget;
   int width, height;
   cairo_t *cr;
   void *ptr;
 
   gdk_threads_enter();
 
   ptr = gtkpeer_get_widget (env, peer);
   g_assert (ptr != NULL);
 
   widget = GTK_WIDGET (ptr);
   g_assert (widget != NULL);
 
-  cp_gtk_grab_current_drawable (widget, &drawable, &win);
+  drawable = widget->window;
   g_assert (drawable != NULL);
 
   width = widget->allocation.width;
   height = widget->allocation.height;
 
-  g_assert (drawable != NULL);
-
-  draw = gdk_x11_drawable_get_xid(drawable);
-  g_assert (draw != (XID) 0);
-  
-  dpy = gdk_x11_drawable_get_xdisplay(drawable);
-  g_assert (dpy != NULL);
-  
-  vis = gdk_x11_visual_get_xvisual(gdk_drawable_get_visual(drawable));
-  g_assert (vis != NULL);
-  
-  surface = cairo_xlib_surface_create (dpy, draw, vis, width, height);
-  g_assert (surface != NULL);
+  cr = gdk_cairo_create(drawable);
 
-  cr = cairo_create (surface);
   g_assert(cr != NULL);
-  cairo_surface_destroy(surface);
 
   gdk_threads_leave();
 
   return PTR_TO_JLONG(cr);
 }
 
 JNIEXPORT jlong JNICALL 
 Java_gnu_java_awt_peer_gtk_ComponentGraphics_initFromVolatile
   (JNIEnv *env  __attribute__ ((unused)), jobject obj __attribute__ ((unused)),
-   jlong ptr, jint width, jint height)
+   jlong ptr)
 {
-  Drawable draw;
-  Display * dpy;
-  Visual * vis;
   GdkDrawable *drawable;
-  cairo_surface_t *surface;
   cairo_t *cr;
 
   gdk_threads_enter();
 
   drawable = JLONG_TO_PTR(GdkDrawable, ptr);
   g_assert (drawable != NULL);
 
-  draw = gdk_x11_drawable_get_xid(drawable);
-  g_assert (draw != (XID) 0);
-  
-  dpy = gdk_x11_drawable_get_xdisplay(drawable);
-  g_assert (dpy != NULL);
-  
-  vis = gdk_x11_visual_get_xvisual(gdk_drawable_get_visual(drawable));
-  g_assert (vis != NULL);
-  
-  surface = cairo_xlib_surface_create (dpy, draw, vis, width, height);
-  g_assert (surface != NULL);
-
-  cr = cairo_create (surface);
+  cr = gdk_cairo_create (drawable);
   g_assert(cr != NULL);
-  cairo_surface_destroy(surface);
 
   gdk_threads_leave();
 
   return PTR_TO_JLONG(cr);
 }
 
 JNIEXPORT void JNICALL 
 Java_gnu_java_awt_peer_gtk_ComponentGraphics_start_1gdk_1drawing
   (JNIEnv *env __attribute__ ((unused)), jobject obj __attribute__ ((unused)))
 {
Index: native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphicsCopy.c
===================================================================
RCS file: /cvsroot/classpath/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphicsCopy.c,v
retrieving revision 1.6
diff -u -1 -0 -r1.6 gnu_java_awt_peer_gtk_ComponentGraphicsCopy.c
--- native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphicsCopy.c	10 Jul 2007 14:33:56 -0000	1.6
+++ native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphicsCopy.c	11 Sep 2007 09:44:11 -0000
@@ -30,30 +30,27 @@
 terms of your choice, provided that you also meet, for each linked
 independent module, the terms and conditions of the license of that
 module.  An independent module is a module which is not derived from
 or based on this library.  If you modify this library, you may extend
 this exception to your version of the library, but you are not
 obligated to do so.  If you do not wish to do so, delete this
 exception statement from your version. */
 
 #include "jcl.h"
 #include "gtkpeer.h"
-#include <cairo-xlib.h>
 #include <gdk/gdktypes.h>
 #include <gdk/gdkprivate.h>
-#include <gdk/gdkx.h>
 
 #include <gdk-pixbuf/gdk-pixbuf.h>
 #include <gdk-pixbuf/gdk-pixdata.h>
 
 #include <cairo-ft.h>
-#include <cairo-xlib.h>
 
 #include <stdio.h>
 #include <stdlib.h>
 
 #include "gnu_java_awt_peer_gtk_ComponentGraphicsCopy.h"
 
 JNIEXPORT void JNICALL 
 Java_gnu_java_awt_peer_gtk_ComponentGraphicsCopy_getPixbuf
    (JNIEnv *env, jobject obj __attribute__((unused)),
     jobject peer, jobject image)
Index: native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkRobotPeer.c
===================================================================
RCS file: /cvsroot/classpath/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkRobotPeer.c,v
retrieving revision 1.6
diff -u -1 -0 -r1.6 gnu_java_awt_peer_gtk_GdkRobotPeer.c
--- native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkRobotPeer.c	18 Aug 2005 03:15:15 -0000	1.6
+++ native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkRobotPeer.c	11 Sep 2007 09:44:11 -0000
@@ -30,43 +30,53 @@
 terms of your choice, provided that you also meet, for each linked
 independent module, the terms and conditions of the license of that
 module.  An independent module is a module which is not derived from
 or based on this library.  If you modify this library, you may extend
 this exception to your version of the library, but you are not
 obligated to do so.  If you do not wish to do so, delete this
 exception statement from your version. */
 
 #include "gtkpeer.h"
 #include "gnu_java_awt_peer_gtk_GdkRobotPeer.h"
+
+#ifdef HAVE_XTEST
 #include <gdk/gdkx.h>
 #include <X11/extensions/XTest.h>
+#endif
+
+#ifdef HAVE_XTEST
 
 static int
 awt_button_mask_to_num (int buttons)
 {
   switch (buttons)
     {
     case AWT_BUTTON1_MASK:
       return 1;
     case AWT_BUTTON2_MASK:
       return 2;
     case AWT_BUTTON3_MASK:
       return 3;
     }
 
   return 0;
 }
 
+#endif
+
 JNIEXPORT jboolean JNICALL
 Java_gnu_java_awt_peer_gtk_GdkRobotPeer_initXTest
   (JNIEnv *env __attribute__((unused)), jobject obj __attribute__((unused)))
 {
+
+#ifdef HAVE_XTEST
+
   GdkDisplay *display;
   Display *xdisplay;
   int event_basep;
   int error_basep;
   int majorp;
   int minorp;
   jboolean result;
 
   gdk_threads_enter ();
 
@@ -75,92 +85,133 @@
 
   result = XTestQueryExtension (xdisplay,
 				&event_basep,
 				&error_basep,
 				&majorp,
 				&minorp);
 
   gdk_threads_leave ();
 
   return result;
+
+#else
+
+  return JNI_FALSE;
+
+#endif
+
 }
 
 JNIEXPORT void JNICALL
 Java_gnu_java_awt_peer_gtk_GdkRobotPeer_mouseMove
   (JNIEnv *env __attribute__((unused)), jobject obj __attribute__((unused)), jint x, jint y)
 {
+
+#ifdef HAVE_XTEST
+
   GdkDisplay *display;
   Display *xdisplay;
   int result;
 
   gdk_threads_enter ();
 
   display = gdk_display_get_default ();
   xdisplay = GDK_DISPLAY_XDISPLAY (display);
 
   result = XTestFakeMotionEvent (xdisplay,
 				 -1,
 				 x, y, CurrentTime);
 
   XFlush (xdisplay);
 
   gdk_threads_leave ();
+
+#else
+
+  (void) x; // Unused.
+  (void) y; // Unused.
+
+#endif
+
 }
 
 JNIEXPORT void JNICALL
 Java_gnu_java_awt_peer_gtk_GdkRobotPeer_mousePress
   (JNIEnv *env __attribute__((unused)), jobject obj __attribute__((unused)), jint buttons)
 {
+
+#ifdef HAVE_XTEST
+
   GdkDisplay *display;
   Display *xdisplay;
   int result;
 
   gdk_threads_enter ();
 
   display = gdk_display_get_default ();
   xdisplay = GDK_DISPLAY_XDISPLAY (display);
 
   result = XTestFakeButtonEvent (xdisplay,
 				 awt_button_mask_to_num (buttons),
 				 True, CurrentTime);
 
   XFlush (xdisplay);
 
   gdk_threads_leave ();
+
+#else
+
+  (void) buttons; // Unused.
+
+#endif
+
 }
 
 JNIEXPORT void JNICALL
 Java_gnu_java_awt_peer_gtk_GdkRobotPeer_mouseRelease
   (JNIEnv *env __attribute__((unused)), jobject obj __attribute__((unused)), jint buttons)
 {
+
+#ifdef HAVE_XTEST
+
   GdkDisplay *display;
   Display *xdisplay;
   int result;
 
   gdk_threads_enter ();
 
   display = gdk_display_get_default ();
   xdisplay = GDK_DISPLAY_XDISPLAY (display);
 
   result = XTestFakeButtonEvent (xdisplay,
 				 awt_button_mask_to_num (buttons),
 				 False, CurrentTime);
 
   XFlush (xdisplay);
 
   gdk_threads_leave ();
+
+#else
+
+  (void) buttons; // Unused.
+
+#endif
+
 }
 
 JNIEXPORT void JNICALL
 Java_gnu_java_awt_peer_gtk_GdkRobotPeer_mouseWheel
   (JNIEnv *env __attribute__((unused)), jobject obj __attribute__((unused)), jint wheelAmt)
 {
+
+#ifdef HAVE_XTEST
+
   GdkDisplay *display;
   Display *xdisplay;
   int i = 0;
 
   gdk_threads_enter ();
 
   display = gdk_display_get_default ();
   xdisplay = GDK_DISPLAY_XDISPLAY (display);
 
   if (wheelAmt < 0)
@@ -180,26 +231,36 @@
 			      5,
 			      True, CurrentTime);
 	XTestFakeButtonEvent (xdisplay,
 			      5,
 			      False, CurrentTime);
       }
 
   XFlush (xdisplay);
 
   gdk_threads_leave ();
+
+#else
+
+  (void) wheelAmt; // Unused.
+
+#endif
+
 }
 
 JNIEXPORT void JNICALL
 Java_gnu_java_awt_peer_gtk_GdkRobotPeer_keyPress
   (JNIEnv *env __attribute__((unused)), jobject obj __attribute__((unused)), jint keycode)
 {
+
+#ifdef HAVE_XTEST
+
   GdkDisplay *display;
   Display *xdisplay;
   GdkKeymapKey *keymap_keys = NULL;
   gint n_keys = 0;
   guint lookup_keyval = 0;
   int result;
 
   gdk_threads_enter ();
 
   display = gdk_display_get_default ();
@@ -225,26 +286,36 @@
      gdk_keymap_get_entries_for_keyval. */
   result = XTestFakeKeyEvent (xdisplay,
 			      keymap_keys[0].keycode,
 			      True, CurrentTime);
 
   g_free (keymap_keys);
 
   XFlush (xdisplay);
 
   gdk_threads_leave ();
+
+#else
+
+  (void) keycode; // Unused.
+
+#endif
+
 }
 
 JNIEXPORT void JNICALL
 Java_gnu_java_awt_peer_gtk_GdkRobotPeer_keyRelease
   (JNIEnv *env __attribute__((unused)), jobject obj __attribute__((unused)), jint keycode)
 {
+
+#ifdef HAVE_XTEST
+
   GdkDisplay *display;
   Display *xdisplay;
   GdkKeymapKey *keymap_keys = NULL;
   gint n_keys = 0;
   guint lookup_keyval = 0;
   int result;
 
   gdk_threads_enter ();
 
   display = gdk_display_get_default ();
@@ -270,27 +341,37 @@
      gdk_keymap_get_entries_for_keyval. */
   result = XTestFakeKeyEvent (xdisplay,
 			      keymap_keys[0].keycode,
 			      False, CurrentTime);
 
   g_free (keymap_keys);
 
   XFlush (xdisplay);
 
   gdk_threads_leave ();
+
+#else
+
+  (void) keycode; // Unused.
+
+#endif
+
 }
 
 JNIEXPORT jintArray JNICALL
 Java_gnu_java_awt_peer_gtk_GdkRobotPeer_nativeGetRGBPixels
   (JNIEnv *env, jobject obj __attribute__((unused)), jint x, jint y,
    jint width, jint height)
 {
+
+#ifdef HAVE_XTEST
+
   jint stride_bytes, stride_pixels, n_channels, n_pixels;
   jintArray jpixels;  
   jint *java_pixels;
   guchar *gdk_pixels;
   GdkPixbuf *pixbuf_no_alpha = NULL;
   GdkPixbuf *pixbuf = NULL;
 
 #ifndef WORDS_BIGENDIAN
   int i;
 #endif
@@ -327,11 +408,23 @@
     }
 #endif
 
   g_object_unref (pixbuf);
 
   (*env)->ReleaseIntArrayElements (env, jpixels, java_pixels, 0);
 
   gdk_threads_leave ();
 
   return jpixels;
+
+#else
+
+  (void) env;
+  (void) x;
+  (void) y;
+  (void) width;
+  (void) height;
+  return NULL;
+
+#endif
+
 }
Index: native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c
===================================================================
RCS file: /cvsroot/classpath/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c,v
retrieving revision 1.27
diff -u -1 -0 -r1.27 gnu_java_awt_peer_gtk_GtkImage.c
--- native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c	4 Apr 2007 22:58:55 -0000	1.27
+++ native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c	11 Sep 2007 09:44:11 -0000
@@ -30,22 +30,20 @@
 terms of your choice, provided that you also meet, for each linked
 independent module, the terms and conditions of the license of that
 module.  An independent module is a module which is not derived from
 or based on this library.  If you modify this library, you may extend
 this exception to your version of the library, but you are not
 obligated to do so.  If you do not wish to do so, delete this
 exception statement from your version. */
 
 #include "jcl.h"
 #include "gtkpeer.h"
-#include <cairo-xlib.h>
-#include <gdk/gdkx.h>
 
 #include "gnu_java_awt_peer_gtk_GtkImage.h"
 
 /* The constant fields in java.awt.Image */   
 #define SCALE_DEFAULT      1
 #define SCALE_FAST         2
 #define SCALE_SMOOTH       4
 #define SCALE_REPLICATE    8 
 #define SCALE_AREA_AVERAGING  16
 
Index: native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c
===================================================================
RCS file: /cvsroot/classpath/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c,v
retrieving revision 1.37
diff -u -1 -0 -r1.37 gnu_java_awt_peer_gtk_GtkToolkit.c
--- native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c	25 Apr 2007 14:53:04 -0000	1.37
+++ native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c	11 Sep 2007 09:44:11 -0000
@@ -33,21 +33,20 @@
 module.  An independent module is a module which is not derived from
 or based on this library.  If you modify this library, you may extend
 this exception to your version of the library, but you are not
 obligated to do so.  If you do not wish to do so, delete this
 exception statement from your version. */
 
 
 #include "gtkpeer.h"
 #include "gnu_java_awt_peer_gtk_GtkToolkit.h"
 #include "jcl.h"
-#include <gdk/gdkx.h>
 
 #define RC_FILE ".classpath-gtkrc"
 
 /* From java.awt.SystemColor */
 #define AWT_DESKTOP                  0
 #define AWT_ACTIVE_CAPTION           1
 #define AWT_ACTIVE_CAPTION_TEXT      2
 #define AWT_ACTIVE_CAPTION_BORDER    3
 #define AWT_INACTIVE_CAPTION         4
 #define AWT_INACTIVE_CAPTION_TEXT    5
Index: native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkVolatileImage.c
===================================================================
RCS file: /cvsroot/classpath/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkVolatileImage.c,v
retrieving revision 1.9
diff -u -1 -0 -r1.9 gnu_java_awt_peer_gtk_GtkVolatileImage.c
--- native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkVolatileImage.c	25 Apr 2007 14:53:04 -0000	1.9
+++ native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkVolatileImage.c	11 Sep 2007 09:44:11 -0000
@@ -30,24 +30,22 @@
 terms of your choice, provided that you also meet, for each linked
 independent module, the terms and conditions of the license of that
 module.  An independent module is a module which is not derived from
 or based on this library.  If you modify this library, you may extend
 this exception to your version of the library, but you are not
 obligated to do so.  If you do not wish to do so, delete this
 exception statement from your version. */
 
 #include "jcl.h"
 #include "gtkpeer.h"
-#include <gdk/gdkx.h>
 #include <gdk/gdktypes.h>
 #include <gdk/gdkprivate.h>
-#include <gdk/gdkx.h>
 #include <gdk-pixbuf/gdk-pixbuf.h>
 #include <gdk-pixbuf/gdk-pixdata.h>
 
 #include "gnu_java_awt_peer_gtk_GtkVolatileImage.h"
 #include "cairographics2d.h"
 
 
 /**
  * Creates a cairo surface, ARGB32, native ordering, premultiplied alpha.
  */
Index: native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
===================================================================
RCS file: /cvsroot/classpath/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c,v
retrieving revision 1.72
diff -u -1 -0 -r1.72 gnu_java_awt_peer_gtk_GtkWindowPeer.c
--- native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c	25 Apr 2007 14:53:04 -0000	1.72
+++ native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c	11 Sep 2007 09:44:11 -0000
@@ -33,22 +33,20 @@
 module.  An independent module is a module which is not derived from
 or based on this library.  If you modify this library, you may extend
 this exception to your version of the library, but you are not
 obligated to do so.  If you do not wish to do so, delete this
 exception statement from your version. */
 
 
 #include "gtkpeer.h"
 #include "gnu_java_awt_peer_gtk_GtkWindowPeer.h"
 #include <gdk/gdkprivate.h>
-#include <gdk/gdkx.h>
-#include <X11/Xatom.h>
 #include <gdk/gdkkeysyms.h>
 
 #define AWT_WINDOW_CLOSING 201
 #define AWT_WINDOW_CLOSED 202
 #define AWT_WINDOW_ICONIFIED 203
 #define AWT_WINDOW_DEICONIFIED 204
 #define AWT_WINDOW_ACTIVATED 205
 #define AWT_WINDOW_DEACTIVATED 206
 #define AWT_WINDOW_GAINED_FOCUS 207
 #define AWT_WINDOW_LOST_FOCUS 208
@@ -1032,26 +1030,20 @@
                                      jobject peer);
 
 /* FIXME: we're currently seeing the double-activation that occurs
    with metacity and GTK.  See
    http://bugzilla.gnome.org/show_bug.cgi?id=140977 for details. */
 
 static void window_get_frame_extents (GtkWidget *window,
                                       int *top, int *left,
                                       int *bottom, int *right);
 
-static void request_frame_extents (GtkWidget *window);
-
-static Bool property_notify_predicate (Display *display,
-                                       XEvent  *xevent,
-                                       XPointer arg);
-
 static gboolean window_delete_cb (GtkWidget *widget, GdkEvent *event,
 			      jobject peer);
 static void window_destroy_cb (GtkWidget *widget, GdkEvent *event,
 			       jobject peer);
 static void window_focus_state_change_cb (GtkWidget *widget,
                                           GParamSpec *pspec,
                                           jobject peer);
 static gboolean window_focus_in_cb (GtkWidget * widget,
                                     GdkEventFocus *event,
                                     jobject peer);
@@ -1143,26 +1135,20 @@
   return TRUE;
 }
 
 /* Union used for type punning. */
 union extents_union
 {
   guchar **gu_extents;
   unsigned long **extents;
 };
 
-union atom_list_union
-{
-  guchar **gu_extents;
-  Atom **atom_list;
-};
-
 JNIEXPORT void JNICALL
 Java_gnu_java_awt_peer_gtk_GtkWindowPeer_create
   (JNIEnv *env, jobject obj, jint type, jboolean decorated, jobject parent)
 {
   GtkWidget *window_widget;
   GtkWindow *window;
   void *window_parent;
   GtkWidget *fixed;
 
   gdk_threads_enter ();
@@ -1510,132 +1496,36 @@
 	 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);
     }
 }
 
 static void
 window_get_frame_extents (GtkWidget *window,
                           int *top, int *left, int *bottom, int *right)
 {
-  unsigned long *extents = NULL;
-  union extents_union gu_ex;
-
-  /* Guess frame extents in case _NET_FRAME_EXTENTS is not
-     supported. */
-  if (!gtk_window_get_decorated (GTK_WINDOW (window)))
-    {
-      *top = 0;
-      *left = 0;
-      *bottom = 0;
-      *right = 0;
-
-      return;
-    }
-
-  *top = 23;
-  *left = 6;
-  *bottom = 6;
-  *right = 6;
-
-  /* Request that the window manager set window's
-     _NET_FRAME_EXTENTS property. */
-  request_frame_extents (window);
-
-  /* Attempt to retrieve window's frame extents. */
-  gu_ex.extents = &extents;
-  if (gdk_property_get (window->window,
-                        gdk_atom_intern ("_NET_FRAME_EXTENTS", FALSE),
-                        gdk_atom_intern ("CARDINAL", FALSE),
-                        0,
-                        sizeof (unsigned long) * 4,
-                        FALSE,
-                        NULL,
-                        NULL,
-                        NULL,
-                        gu_ex.gu_extents))
-    {
-      *left = extents [0];
-      *right = extents [1];
-      *top = extents [2];
-      *bottom = extents [3];
-    }
-}
-
-static Atom extents_atom = 0;
-
-/* Requests that the window manager set window's
-   _NET_FRAME_EXTENTS property. */
-static void
-request_frame_extents (GtkWidget *window)
-{
-  const char *request_str = "_NET_REQUEST_FRAME_EXTENTS";
-  GdkAtom request_extents = gdk_atom_intern (request_str, FALSE);
-
-  /* Check if the current window manager supports
-     _NET_REQUEST_FRAME_EXTENTS. */
-  if (gdk_net_wm_supports (request_extents))
-    {
-      GdkDisplay *display = gtk_widget_get_display (window);
-      Display *xdisplay = GDK_DISPLAY_XDISPLAY (display);
+  GdkRectangle extents;
+  GdkWindow* gdkWindow;
 
-      GdkWindow *root_window = gdk_get_default_root_window ();
-      Window xroot_window = GDK_WINDOW_XID (root_window);
+  gint x, y, w, h;
 
-      Atom extents_request_atom =
-	gdk_x11_get_xatom_by_name_for_display (display, request_str);
+  gdkWindow = window->window;
 
-      XEvent xevent;
-      XEvent notify_xevent;
-
-      unsigned long window_id = GDK_WINDOW_XID (GDK_DRAWABLE(window->window));
-
-      if (!extents_atom)
-	{
-	  const char *extents_str = "_NET_FRAME_EXTENTS";
-	  extents_atom =
-	    gdk_x11_get_xatom_by_name_for_display (display, extents_str);
-	}
-
-      xevent.xclient.type = ClientMessage;
-      xevent.xclient.message_type = extents_request_atom;
-      xevent.xclient.display = xdisplay;
-      xevent.xclient.window = window_id;
-      xevent.xclient.format = 32;
-      xevent.xclient.data.l[0] = 0;
-      xevent.xclient.data.l[1] = 0;
-      xevent.xclient.data.l[2] = 0;
-      xevent.xclient.data.l[3] = 0;
-      xevent.xclient.data.l[4] = 0;
-
-      XSendEvent (xdisplay, xroot_window, False,
-		  (SubstructureRedirectMask | SubstructureNotifyMask),
-                  &xevent);
+  gdk_window_get_frame_extents(gdkWindow, &extents);
+  gdk_drawable_get_size(gdkWindow, &w, &h);
+  gdk_window_get_origin(gdkWindow, &x, &y);
 
-      XIfEvent(xdisplay, &notify_xevent,
-	       property_notify_predicate, (XPointer) &window_id);
-    }
-}
+  *left = extents.x - x;
+  *top = extents.y - y;
+  *right = extents.width - w - *left;
+  *bottom = extents.height - h - *top;
 
-static Bool
-property_notify_predicate (Display *xdisplay __attribute__((unused)),
-                           XEvent  *event,
-                           XPointer window_id)
-{
-  unsigned long *window = (unsigned long *) window_id;
-
-  if (event->xany.type == PropertyNotify
-      && event->xany.window == *window
-      && event->xproperty.atom == extents_atom)
-    return True;
-  else
-    return False;
 }
 
 static gboolean
 window_delete_cb (GtkWidget *widget __attribute__((unused)),
 		  GdkEvent *event __attribute__((unused)),
 		  jobject peer)
 {
   (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer,
 			      postWindowEventID,
 			      (jint) AWT_WINDOW_CLOSING,
Index: gnu/java/awt/peer/gtk/ComponentGraphics.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/gtk/ComponentGraphics.java,v
retrieving revision 1.28
diff -u -1 -0 -r1.28 ComponentGraphics.java
--- gnu/java/awt/peer/gtk/ComponentGraphics.java	9 Apr 2007 21:34:27 -0000	1.28
+++ gnu/java/awt/peer/gtk/ComponentGraphics.java	11 Sep 2007 09:44:11 -0000
@@ -146,21 +146,21 @@
       }
     else if (i.intValue() == 2)
       hasLock.set(ONE);
     else
       hasLock.set(Integer.valueOf(i.intValue() - 1));
   }
 
   /**
    * Creates a cairo_t for a volatile image
    */
-  protected native long initFromVolatile( long pixmapPtr, int width, int height);
+  protected native long initFromVolatile( long pixmapPtr);
 
   /**
    * Grab lock
    */
   private native void start_gdk_drawing();
 
   /**
    * Release lock
    */
   private native void end_gdk_drawing();
@@ -931,11 +931,11 @@
     try
     {
       lock();
       super.drawCairoSurface(surface, tx, alpha, interpolation);
     }
     finally
     {
       unlock();
     }
   }
-}
\ No newline at end of file
+}
Index: gnu/java/awt/peer/gtk/VolatileImageGraphics.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/gtk/VolatileImageGraphics.java,v
retrieving revision 1.13
diff -u -1 -0 -r1.13 VolatileImageGraphics.java
--- gnu/java/awt/peer/gtk/VolatileImageGraphics.java	25 Jun 2007 11:25:52 -0000	1.13
+++ gnu/java/awt/peer/gtk/VolatileImageGraphics.java	11 Sep 2007 09:44:11 -0000
@@ -61,28 +61,28 @@
 import java.util.Hashtable;
 
 public class VolatileImageGraphics extends ComponentGraphics
 {
   private GtkVolatileImage owner;
   private BufferedImage buffer;
 
   public VolatileImageGraphics(GtkVolatileImage img)
   {
     this.owner = img;
-    cairo_t = initFromVolatile( owner.nativePointer, img.width, img.height );
+    cairo_t = initFromVolatile( owner.nativePointer );
     setup( cairo_t );
   }
 
   private VolatileImageGraphics(VolatileImageGraphics copy)
   {
     this.owner = copy.owner;
-    cairo_t = initFromVolatile(owner.nativePointer, owner.width, owner.height);
+    cairo_t = initFromVolatile(owner.nativePointer);
     copy( copy, cairo_t );
   }
 
   public void copyAreaImpl(int x, int y, int width, int height, int dx, int dy)
   {
     owner.copyArea(x, y, width, height, dx, dy);
   }
 
   public GraphicsConfiguration getDeviceConfiguration()
   {

Reply via email to