diff options
author | Roman Kennke <roman@kennke.org> | 2007-09-11 09:48:49 +0000 |
---|---|---|
committer | Roman Kennke <roman@kennke.org> | 2007-09-11 09:48:49 +0000 |
commit | 82bdf5ea5b628a257f3103e7505c963f9d2f97db (patch) | |
tree | 37c51f8e01df9773547d1090214ab7b5090dd85d /native/jni | |
parent | 727d023cd74fec43257a4b753f576094b3379757 (diff) | |
download | classpath-82bdf5ea5b628a257f3103e7505c963f9d2f97db.tar.gz |
2007-09-11 Roman Kennke <roman@kennke.org>
* 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.
Diffstat (limited to 'native/jni')
9 files changed, 116 insertions, 180 deletions
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c index 2d093102c..6bb8b9476 100644 --- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c +++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c @@ -41,10 +41,8 @@ exception statement from your version. */ #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> diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoSurface.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoSurface.c index 839153a15..23340fb5b 100644 --- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoSurface.c +++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoSurface.c @@ -37,8 +37,6 @@ 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" diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c index 9de0d7b95..3364640a0 100644 --- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c +++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c @@ -37,21 +37,22 @@ 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" @@ -62,7 +63,7 @@ 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 (); @@ -107,7 +108,7 @@ Java_gnu_java_awt_peer_gtk_ComponentGraphics_hasXRender { #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; @@ -118,13 +119,8 @@ 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; @@ -137,29 +133,15 @@ Java_gnu_java_awt_peer_gtk_ComponentGraphics_initState 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); + cr = gdk_cairo_create(drawable); - 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); g_assert(cr != NULL); - cairo_surface_destroy(surface); gdk_threads_leave(); @@ -169,13 +151,9 @@ Java_gnu_java_awt_peer_gtk_ComponentGraphics_initState 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(); @@ -183,21 +161,8 @@ Java_gnu_java_awt_peer_gtk_ComponentGraphics_initFromVolatile 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(); diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphicsCopy.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphicsCopy.c index 7ce93b0a7..df700f559 100644 --- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphicsCopy.c +++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphicsCopy.c @@ -37,16 +37,13 @@ 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> diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkRobotPeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkRobotPeer.c index 7389fa3a4..4240f112e 100644 --- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkRobotPeer.c +++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkRobotPeer.c @@ -37,8 +37,13 @@ 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) @@ -56,10 +61,15 @@ awt_button_mask_to_num (int buttons) 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; @@ -82,12 +92,22 @@ Java_gnu_java_awt_peer_gtk_GdkRobotPeer_initXTest 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; @@ -104,12 +124,23 @@ Java_gnu_java_awt_peer_gtk_GdkRobotPeer_mouseMove 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; @@ -126,12 +157,22 @@ Java_gnu_java_awt_peer_gtk_GdkRobotPeer_mousePress 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; @@ -148,12 +189,22 @@ Java_gnu_java_awt_peer_gtk_GdkRobotPeer_mouseRelease 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; @@ -187,12 +238,22 @@ Java_gnu_java_awt_peer_gtk_GdkRobotPeer_mouseWheel 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; @@ -232,12 +293,22 @@ Java_gnu_java_awt_peer_gtk_GdkRobotPeer_keyPress 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; @@ -277,6 +348,13 @@ Java_gnu_java_awt_peer_gtk_GdkRobotPeer_keyRelease XFlush (xdisplay); gdk_threads_leave (); + +#else + + (void) keycode; // Unused. + +#endif + } JNIEXPORT jintArray JNICALL @@ -284,6 +362,9 @@ 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; @@ -334,4 +415,16 @@ Java_gnu_java_awt_peer_gtk_GdkRobotPeer_nativeGetRGBPixels gdk_threads_leave (); return jpixels; + +#else + + (void) env; + (void) x; + (void) y; + (void) width; + (void) height; + return NULL; + +#endif + } diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c index ae7027e76..c2fbba212 100644 --- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c +++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c @@ -37,8 +37,6 @@ 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" diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c index 1186f659c..5dbd86ada 100644 --- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c +++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c @@ -40,7 +40,6 @@ 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" diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkVolatileImage.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkVolatileImage.c index e3edf1fb5..50197cab0 100644 --- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkVolatileImage.c +++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkVolatileImage.c @@ -37,10 +37,8 @@ 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> diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c index 6ba8d4767..4ea753a8e 100644 --- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c +++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c @@ -40,8 +40,6 @@ 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 @@ -1039,12 +1037,6 @@ 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, @@ -1150,12 +1142,6 @@ union extents_union 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) @@ -1517,118 +1503,22 @@ 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; + GdkRectangle extents; + GdkWindow* gdkWindow; - /* 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; + gint x, y, w, h; - return; - } + gdkWindow = window->window; - *top = 23; - *left = 6; - *bottom = 6; - *right = 6; + gdk_window_get_frame_extents(gdkWindow, &extents); + gdk_drawable_get_size(gdkWindow, &w, &h); + gdk_window_get_origin(gdkWindow, &x, &y); - /* Request that the window manager set window's - _NET_FRAME_EXTENTS property. */ - request_frame_extents (window); + *left = extents.x - x; + *top = extents.y - y; + *right = extents.width - w - *left; + *bottom = extents.height - h - *top; - /* 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); - - GdkWindow *root_window = gdk_get_default_root_window (); - Window xroot_window = GDK_WINDOW_XID (root_window); - - Atom extents_request_atom = - gdk_x11_get_xatom_by_name_for_display (display, request_str); - - 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); - - XIfEvent(xdisplay, ¬ify_xevent, - property_notify_predicate, (XPointer) &window_id); - } -} - -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 |