CVSROOT: /cvsroot/classpath Module name: classpath Changes by: Robert Schuster <rschuster> 06/06/06 10:04:15
Modified files: include : gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.h Makefile.am . : configure.ac ChangeLog gnu/java/awt/peer/gtk: GdkGraphicsConfiguration.java GdkGraphicsEnvironment.java GdkScreenGraphicsDevice.java native/jni/gtk-peer: Makefile.am gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.c Added files: include : gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.h native/jni/gtk-peer: gdkdisplay.h gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.c Log message: 2006-06-06 Robert Schuster <[EMAIL PROTECTED]> * include/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.h: Regenerated. * include/gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.h: New file. * include/Makefile.am: Added gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice. * gnu/java/awt/peer/gtk/GdkGraphicsConfiguration.java: (GdkGraphicsConfiguration): Rewritten. (getColorModel): Rewritten. (getColorModel(int)): Rewritten. (getBounds): Rewritten. (createCompatibleVolatileImage): Implemented. * gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java: Added static initializer. (getDefaultScreenDevice): Rewritten. (nativeGetDefaultScreenDevice): New method. (getScreenDevices): Rewritten. (nativeGetScreenDevices): New method. (nativeInitState): New method. * gnu/java/awt/peer/gtk/GdkScreenGraphicsDevice.java: Entirely rewritten. (X11DisplayMode): New inner class. * native/jni/gtk-peer/Makefile.am: Added gdkdisplay.h and gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.c * native/jni/gtk-peer/gdkdisplay.h: New file. * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.c: (Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment_initStaticState): New function. (Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment_nativeInitState): New function. (Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment _nativeGetScreenDevices): New function. (Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment _nativeGetDefaultScreenDevice): New function. * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.c: New file. * configure.ac: Added check for Xrandr library. CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/classpath/include/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.h?cvsroot=classpath&r1=1.3&r2=1.4 http://cvs.savannah.gnu.org/viewcvs/classpath/include/Makefile.am?cvsroot=classpath&r1=1.62&r2=1.63 http://cvs.savannah.gnu.org/viewcvs/classpath/include/gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.h?cvsroot=classpath&rev=1.1 http://cvs.savannah.gnu.org/viewcvs/classpath/configure.ac?cvsroot=classpath&r1=1.156&r2=1.157 http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpath&r1=1.7666&r2=1.7667 http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/awt/peer/gtk/GdkGraphicsConfiguration.java?cvsroot=classpath&r1=1.5&r2=1.6 http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java?cvsroot=classpath&r1=1.11&r2=1.12 http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/awt/peer/gtk/GdkScreenGraphicsDevice.java?cvsroot=classpath&r1=1.6&r2=1.7 http://cvs.savannah.gnu.org/viewcvs/classpath/native/jni/gtk-peer/Makefile.am?cvsroot=classpath&r1=1.43&r2=1.44 http://cvs.savannah.gnu.org/viewcvs/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.c?cvsroot=classpath&r1=1.5&r2=1.6 http://cvs.savannah.gnu.org/viewcvs/classpath/native/jni/gtk-peer/gdkdisplay.h?cvsroot=classpath&rev=1.1 http://cvs.savannah.gnu.org/viewcvs/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.c?cvsroot=classpath&rev=1.1 Patches: Index: include/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.h =================================================================== RCS file: /cvsroot/classpath/classpath/include/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -b -r1.3 -r1.4 --- include/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.h 30 Apr 2006 10:37:36 -0000 1.3 +++ include/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.h 6 Jun 2006 10:04:14 -0000 1.4 @@ -10,6 +10,10 @@ { #endif +JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment_initStaticState (JNIEnv *env, jclass); +JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment_nativeInitState (JNIEnv *env, jobject); +JNIEXPORT jobjectArray JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment_nativeGetScreenDevices (JNIEnv *env, jobject); +JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment_nativeGetDefaultScreenDevice (JNIEnv *env, jobject); JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment_nativeGetNumFontFamilies (JNIEnv *env, jobject); JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment_nativeGetFontFamilies (JNIEnv *env, jobject, jobjectArray); Index: include/Makefile.am =================================================================== RCS file: /cvsroot/classpath/classpath/include/Makefile.am,v retrieving revision 1.62 retrieving revision 1.63 diff -u -b -r1.62 -r1.63 --- include/Makefile.am 3 Jun 2006 22:41:41 -0000 1.62 +++ include/Makefile.am 6 Jun 2006 10:04:15 -0000 1.63 @@ -45,6 +45,7 @@ $(top_srcdir)/include/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.h \ $(top_srcdir)/include/gnu_java_awt_peer_gtk_GdkPixbufDecoder.h \ $(top_srcdir)/include/gnu_java_awt_peer_gtk_GdkRobotPeer.h \ +$(top_srcdir)/include/gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.h \ $(top_srcdir)/include/gnu_java_awt_peer_gtk_GdkTextLayout.h \ $(top_srcdir)/include/gnu_java_awt_peer_gtk_GtkButtonPeer.h \ $(top_srcdir)/include/gnu_java_awt_peer_gtk_GtkCanvasPeer.h \ Index: configure.ac =================================================================== RCS file: /cvsroot/classpath/classpath/configure.ac,v retrieving revision 1.156 retrieving revision 1.157 diff -u -b -r1.156 -r1.157 --- configure.ac 2 Jun 2006 20:47:05 -0000 1.156 +++ configure.ac 6 Jun 2006 10:04:15 -0000 1.157 @@ -415,6 +415,13 @@ [true], [${X_LIBS}]) + dnl Check if we can link against the XRandR library and set + dnl HAVE_XRANDR accordingly. + AC_CHECK_LIB([Xrandr], [XRRQueryExtension], + [AC_DEFINE(HAVE_XRANDR, 1, [Define to 1 if you have libXrandr.])X_EXTRA_LIBS="$X_EXTRA_LIBS -lXrandr"]], + [true], + [$X_LIBS}]) + AC_SUBST(GTK_CFLAGS) AC_SUBST(GTK_LIBS) AC_SUBST(FREETYPE2_LIBS) Index: ChangeLog =================================================================== RCS file: /cvsroot/classpath/classpath/ChangeLog,v retrieving revision 1.7666 retrieving revision 1.7667 diff -u -b -r1.7666 -r1.7667 --- ChangeLog 6 Jun 2006 09:39:08 -0000 1.7666 +++ ChangeLog 6 Jun 2006 10:04:15 -0000 1.7667 @@ -1,3 +1,43 @@ +2006-06-06 Robert Schuster <[EMAIL PROTECTED]> + + * include/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.h: Regenerated. + * include/gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.h: New file. + * include/Makefile.am: Added + gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice. + * gnu/java/awt/peer/gtk/GdkGraphicsConfiguration.java: + (GdkGraphicsConfiguration): Rewritten. + (getColorModel): Rewritten. + (getColorModel(int)): Rewritten. + (getBounds): Rewritten. + (createCompatibleVolatileImage): Implemented. + * gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java: Added static + initializer. + (getDefaultScreenDevice): Rewritten. + (nativeGetDefaultScreenDevice): New method. + (getScreenDevices): Rewritten. + (nativeGetScreenDevices): New method. + (nativeInitState): New method. + * gnu/java/awt/peer/gtk/GdkScreenGraphicsDevice.java: Entirely + rewritten. + (X11DisplayMode): New inner class. + * native/jni/gtk-peer/Makefile.am: Added gdkdisplay.h and + gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.c + * native/jni/gtk-peer/gdkdisplay.h: New file. + * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.c: + (Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment_initStaticState): + New function. + (Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment_nativeInitState): + New function. + (Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment + _nativeGetScreenDevices): + New function. + (Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment + _nativeGetDefaultScreenDevice): + New function. + * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.c: + New file. + * configure.ac: Added check for Xrandr library. + 2006-06-06 Roman Kennke <[EMAIL PROTECTED]> * javax/swing/plaf/basic/BasicTableUI.java Index: gnu/java/awt/peer/gtk/GdkGraphicsConfiguration.java =================================================================== RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/gtk/GdkGraphicsConfiguration.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -b -r1.5 -r1.6 --- gnu/java/awt/peer/gtk/GdkGraphicsConfiguration.java 19 Aug 2005 01:29:26 -0000 1.5 +++ gnu/java/awt/peer/gtk/GdkGraphicsConfiguration.java 6 Jun 2006 10:04:15 -0000 1.6 @@ -1,5 +1,5 @@ /* GdkGraphicsConfiguration.java -- describes characteristics of graphics - Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation + Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006 Free Software Foundation This file is part of GNU Classpath. @@ -42,26 +42,33 @@ import java.awt.GraphicsDevice; import java.awt.ImageCapabilities; import java.awt.Rectangle; -import java.awt.Toolkit; +import java.awt.Transparency; import java.awt.geom.AffineTransform; import java.awt.image.BufferedImage; import java.awt.image.ColorModel; +import java.awt.image.DirectColorModel; import java.awt.image.VolatileImage; public class GdkGraphicsConfiguration extends GraphicsConfiguration { GdkScreenGraphicsDevice gdkScreenGraphicsDevice; - ColorModel cm; - Rectangle bounds; + + ColorModel opaqueColorModel; + + ColorModel bitmaskColorModel; + + ColorModel translucentColorModel; public GdkGraphicsConfiguration(GdkScreenGraphicsDevice dev) { - this.gdkScreenGraphicsDevice = dev; - cm = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB).getColorModel(); - bounds = ((GtkToolkit) Toolkit.getDefaultToolkit()).getBounds(); + gdkScreenGraphicsDevice = dev; + + opaqueColorModel = new DirectColorModel(32, 0xFF0000, 0xFF00, 0xFF, 0); + bitmaskColorModel = new DirectColorModel(32, 0xFF0000, 0xFF00, 0xFF, 0x1000000); + translucentColorModel = new DirectColorModel(32, 0xFF0000, 0xFF00, 0xFF, 0xFF000000); } public GraphicsDevice getDevice() @@ -94,12 +101,21 @@ public ColorModel getColorModel() { - return cm; + return opaqueColorModel; } public ColorModel getColorModel(int transparency) { - return getColorModel(); + switch (transparency) + { + case Transparency.OPAQUE: + return opaqueColorModel; + case Transparency.BITMASK: + return bitmaskColorModel; + default: + case Transparency.TRANSLUCENT: + return translucentColorModel; + } } public AffineTransform getDefaultTransform() @@ -116,7 +132,7 @@ public Rectangle getBounds() { - return bounds; + return gdkScreenGraphicsDevice.getBounds(); } public BufferCapabilities getBufferCapabilities() @@ -133,8 +149,8 @@ public VolatileImage createCompatibleVolatileImage(int width, int height, int transparency) { - // FIXME: implement - return null; + // FIXME: support the transparency argument + return new GtkVolatileImage(width, height); } } Index: gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java =================================================================== RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -b -r1.11 -r1.12 --- gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java 29 May 2006 16:14:59 -0000 1.11 +++ gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java 6 Jun 2006 10:04:15 -0000 1.12 @@ -1,5 +1,5 @@ /* GdkGraphicsEnvironment.java -- information about the graphics environment - Copyright (C) 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -43,31 +43,64 @@ import java.awt.GraphicsDevice; import java.awt.GraphicsEnvironment; import java.awt.HeadlessException; -import java.awt.Toolkit; import java.awt.image.BufferedImage; import java.awt.image.DataBuffer; import java.util.Locale; public class GdkGraphicsEnvironment extends GraphicsEnvironment { + private final int native_state = GtkGenericPeer.getUniqueInteger (); + + private GdkScreenGraphicsDevice defaultDevice; + + private GdkScreenGraphicsDevice[] devices; + + static + { + System.loadLibrary("gtkpeer"); + + initStaticState (); + } + + static native void initStaticState(); + public GdkGraphicsEnvironment () { + nativeInitState(); } + native void nativeInitState(); + public GraphicsDevice[] getScreenDevices () { - // FIXME: Support multiple screens, since GDK can. - return new GraphicsDevice[] { new GdkScreenGraphicsDevice (this) }; + if (devices == null) + { + devices = nativeGetScreenDevices(); } + return devices.clone(); + } + + private native GdkScreenGraphicsDevice[] nativeGetScreenDevices(); + public GraphicsDevice getDefaultScreenDevice () { if (GraphicsEnvironment.isHeadless ()) throw new HeadlessException (); - return new GdkScreenGraphicsDevice (this); + synchronized (GdkGraphicsEnvironment.class) + { + if (defaultDevice == null) + { + defaultDevice = nativeGetDefaultScreenDevice(); + } + } + + return defaultDevice; } + private native GdkScreenGraphicsDevice nativeGetDefaultScreenDevice(); + public Graphics2D createGraphics (BufferedImage image) { DataBuffer db = image.getRaster().getDataBuffer(); @@ -101,4 +134,5 @@ { throw new java.lang.UnsupportedOperationException (); } + } Index: gnu/java/awt/peer/gtk/GdkScreenGraphicsDevice.java =================================================================== RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/gtk/GdkScreenGraphicsDevice.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -b -r1.6 -r1.7 --- gnu/java/awt/peer/gtk/GdkScreenGraphicsDevice.java 19 Aug 2005 01:29:26 -0000 1.6 +++ gnu/java/awt/peer/gtk/GdkScreenGraphicsDevice.java 6 Jun 2006 10:04:15 -0000 1.7 @@ -1,5 +1,5 @@ /* GdkScreenGraphicsDevice.java -- information about a screen device - Copyright (C) 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -38,44 +38,110 @@ package gnu.java.awt.peer.gtk; -import java.awt.Dimension; import java.awt.DisplayMode; +import java.awt.Frame; import java.awt.GraphicsConfiguration; import java.awt.GraphicsDevice; -import java.awt.Toolkit; +import java.awt.Rectangle; +import java.awt.Window; +import java.util.ArrayList; -public class GdkScreenGraphicsDevice extends GraphicsDevice +class GdkScreenGraphicsDevice extends GraphicsDevice { + private final int native_state = GtkGenericPeer.getUniqueInteger (); + + private Window fullscreenWindow; + + private boolean oldWindowDecorationState; + + private Rectangle oldWindowBounds; + + private Rectangle bounds; + + private GdkGraphicsConfiguration[] configurations; + + /** The <code>GdkGraphicsEnvironment</code> instance that created this + * <code>GdkScreenGraphicsDevice</code>. This is only needed for native + * methods which need to access the 'native_state' field storing a pointer + * to a GdkDisplay object. + */ GdkGraphicsEnvironment env; - public GdkScreenGraphicsDevice (GdkGraphicsEnvironment e) + /** An identifier that is created by Gdk + */ + String idString; + + /** The display modes supported by this <code>GdkScreenGraphicsDevice</code>. + * If the array is <code>null</code> <code>nativeGetDisplayModes</code> has + * to be called. + */ + X11DisplayMode[] displayModes; + + /** The non-changeable display mode of this <code>GdkScreenGraphicsDevice + * </code>. This field gets initialized by the [EMAIL PROTECTED] #init()} method. If it + * is still <code>null</code> afterwards, the XRandR extension is available + * and display mode changes are possible. If it is non-null XRandR is not + * available, no display mode changes are possible and no other native + * method must be called. + */ + DisplayMode fixedDisplayMode; + + static { - super (); + System.loadLibrary("gtkpeer"); + + initStaticState (); + } + + static native void initStaticState(); + + GdkScreenGraphicsDevice (GdkGraphicsEnvironment e) + { + super(); env = e; + + configurations = new GdkGraphicsConfiguration[1]; + configurations[0] = new GdkGraphicsConfiguration(this); } + /** This method is called from the native side immediately after + * the constructor is run. + */ + void init() + { + fixedDisplayMode = nativeGetFixedDisplayMode(env); + } + + /** Depending on the availability of the XRandR extension the method returns + * the screens' non-changeable display mode or null, meaning that XRandR can + * handle display mode changes. + */ + native DisplayMode nativeGetFixedDisplayMode(GdkGraphicsEnvironment env); + public int getType () { + // Gdk manages only raster screens. return GraphicsDevice.TYPE_RASTER_SCREEN; } public String getIDstring () { - // FIXME: query X for this string - return "default GDK device ID string"; + if (idString == null) + idString = nativeGetIDString(); + + return idString; } + private native String nativeGetIDString(); + public GraphicsConfiguration[] getConfigurations () { - // FIXME: query X for the list of possible configurations - return new GraphicsConfiguration [] { new GdkGraphicsConfiguration(this) }; + return (GraphicsConfiguration[]) configurations.clone(); } public GraphicsConfiguration getDefaultConfiguration () { - - // FIXME: query X for default configuration - return new GdkGraphicsConfiguration(this); + return configurations[0]; } @@ -89,23 +155,193 @@ */ public DisplayMode getDisplayMode() { - // determine display mode - Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); - DisplayMode mode = new DisplayMode(dim.width, dim.height, 0, - DisplayMode.REFRESH_RATE_UNKNOWN); - return mode; + if (fixedDisplayMode != null) + return fixedDisplayMode; + + synchronized (this) + { + if (displayModes == null) + displayModes = nativeGetDisplayModes(env); + } + + int index = nativeGetDisplayModeIndex(env); + int rate = nativeGetDisplayModeRate(env); + + return new DisplayMode(displayModes[index].width, + displayModes[index].height, + DisplayMode.BIT_DEPTH_MULTI, + rate); + } + + native int nativeGetDisplayModeIndex(GdkGraphicsEnvironment env); + + native int nativeGetDisplayModeRate(GdkGraphicsEnvironment env); + + public DisplayMode[] getDisplayModes() + { + if (fixedDisplayMode != null) + return new DisplayMode[] { fixedDisplayMode }; + + synchronized (this) + { + if (displayModes == null) + displayModes = nativeGetDisplayModes(env); } + ArrayList list = new ArrayList(); + for(int i=0;i<displayModes.length;i++) + for(int j=0;j<displayModes[i].rates.length;j++) + list.add(new DisplayMode(displayModes[i].width, + displayModes[i].height, + DisplayMode.BIT_DEPTH_MULTI, + displayModes[i].rates[j])); + + return (DisplayMode[]) list.toArray(new DisplayMode[list.size()]); + } + + native X11DisplayMode[] nativeGetDisplayModes(GdkGraphicsEnvironment env); + /** - * This device does not yet support fullscreen exclusive mode, so this - * returns <code>false</code>. + * Real fullscreen exclusive mode is not supported. * * @return <code>false</code> * @since 1.4 */ public boolean isFullScreenSupported() { - return false; + return true; + } + + public boolean isDisplayChangeSupported() + { + return fixedDisplayMode == null; + } + + public void setDisplayMode(DisplayMode dm) + { + if (fixedDisplayMode != null) + throw new UnsupportedOperationException("Cannnot change display mode."); + + if (dm == null) + throw new IllegalArgumentException("DisplayMode must not be null."); + + synchronized (this) + { + if (displayModes == null) + displayModes = nativeGetDisplayModes(env); } + for (int i=0; i<displayModes.length; i++) + if (displayModes[i].width == dm.getWidth() + && displayModes[i].height == dm.getHeight()) + { + synchronized (this) + { + nativeSetDisplayMode(env, + i, + (short) dm.getRefreshRate()); + + bounds = null; + } + + return; + } + + throw new IllegalArgumentException("Mode not supported by this device."); + } + + native void nativeSetDisplayMode(GdkGraphicsEnvironment env, + int index, short rate); + + /** A class that simply encapsulates the X11 display mode data. + */ + static class X11DisplayMode + { + short[] rates; + int width; + int height; + + X11DisplayMode(int width, int height, short[] rates) + { + this.width = width; + this.height = height; + this.rates = rates; + } + + } + + public void setFullScreenWindow(Window w) + { + // Bring old fullscreen window back into its original state. + if (fullscreenWindow != null && w != fullscreenWindow) + { + if (fullscreenWindow instanceof Frame) + { + // Decoration state can only be switched when the peer is + // non-existent. That means we have to dispose the + // Frame. + Frame f = (Frame) fullscreenWindow; + if (oldWindowDecorationState != f.isUndecorated()) + { + f.dispose(); + f.setUndecorated(oldWindowDecorationState); + } + } + + fullscreenWindow.setBounds(oldWindowBounds); + + if (!fullscreenWindow.isVisible()) + fullscreenWindow.setVisible(true); + } + + // If applicable remove decoration, then maximize the window and + // bring it to the foreground. + if (w != null) + { + if (w instanceof Frame) + { + Frame f = (Frame) w; + oldWindowDecorationState = f.isUndecorated(); + if (!oldWindowDecorationState) + { + f.dispose(); + f.setUndecorated(true); + } + } + + oldWindowBounds = w.getBounds(); + + DisplayMode dm = getDisplayMode(); + + w.setBounds(0, 0, dm.getWidth(), dm.getHeight()); + + if (!w.isVisible()) + w.setVisible(true); + + w.requestFocus(); + w.toFront(); + + } + + fullscreenWindow = w; + } + + public Window getFullScreenWindow() + { + return fullscreenWindow; + } + + Rectangle getBounds() + { + synchronized(this) + { + if (bounds == null) + bounds = nativeGetBounds(); + } + + return bounds; + } + + native Rectangle nativeGetBounds(); + } Index: native/jni/gtk-peer/Makefile.am =================================================================== RCS file: /cvsroot/classpath/classpath/native/jni/gtk-peer/Makefile.am,v retrieving revision 1.43 retrieving revision 1.44 diff -u -b -r1.43 -r1.44 --- native/jni/gtk-peer/Makefile.am 3 Jun 2006 22:41:41 -0000 1.43 +++ native/jni/gtk-peer/Makefile.am 6 Jun 2006 10:04:15 -0000 1.44 @@ -10,6 +10,7 @@ gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.c \ gnu_java_awt_peer_gtk_GdkPixbufDecoder.c \ gnu_java_awt_peer_gtk_GdkRobotPeer.c \ + gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.c \ gnu_java_awt_peer_gtk_GdkTextLayout.c \ gnu_java_awt_peer_gtk_GtkButtonPeer.c \ gnu_java_awt_peer_gtk_GtkCanvasPeer.c \ @@ -42,6 +43,7 @@ gnu_java_awt_peer_gtk_GtkVolatileImage.c \ cairographics2d.h \ gthread-jni.c \ + gdkdisplay.h \ gdkfont.h \ gthread-jni.h \ gtk_jawt.c \ Index: native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.c =================================================================== RCS file: /cvsroot/classpath/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -b -r1.5 -r1.6 --- native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.c 22 Nov 2005 20:41:06 -0000 1.5 +++ native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.c 6 Jun 2006 10:04:15 -0000 1.6 @@ -1,5 +1,5 @@ /* gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.c - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -35,9 +35,43 @@ obligated to do so. If you do not wish to do so, delete this exception statement from your version. */ +#include <glib.h> +#include <gdk/gdk.h> + #include "gdkfont.h" +#include "gdkdisplay.h" #include "gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.h" +struct state_table *cp_gtk_native_display_state_table; + +jclass gdkGraphicsEnvironment_class; + +JNIEXPORT void JNICALL +Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment_initStaticState +(JNIEnv *env, jclass klazz __attribute__((unused))) +{ + gdkGraphicsEnvironment_class = (*env)->NewGlobalRef + (env, klazz); + + NSA_DISPLAY_INIT(env, gdkGraphicsEnvironment_class); +} + +JNIEXPORT void JNICALL +Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment_nativeInitState +(JNIEnv *env, jobject obj) +{ + GdkDisplay *defaultDisplay; + + gdk_threads_enter(); + + /* Retrieve the default display. */ + defaultDisplay = gdk_display_get_default(); + + gdk_threads_leave(); + + /* Store display pointer in GdkGraphicsEnvironment instance. */ + NSA_SET_DISPLAY_PTR(env, obj, (void *) defaultDisplay); +} static gint cmp_families (const void *a, const void *b) @@ -101,3 +135,109 @@ return num; } + +JNIEXPORT jobjectArray JNICALL +Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment_nativeGetScreenDevices +(JNIEnv *env, jobject obj) +{ + jmethodID gdkScreenGraphicsDevice_ctor, gdkScreenGraphicsDevice_init; + jclass gdkScreenGraphicsDevice_class; + int numScreens = 0, i = 0; + GdkDisplay *display; + jobjectArray array; + jobject instance; + + gdkScreenGraphicsDevice_class = (*env)->FindClass + (env, "gnu/java/awt/peer/gtk/GdkScreenGraphicsDevice"); + + gdkScreenGraphicsDevice_ctor = (*env)->GetMethodID + (env, gdkScreenGraphicsDevice_class, "<init>", + "(Lgnu/java/awt/peer/gtk/GdkGraphicsEnvironment;)V"); + + gdkScreenGraphicsDevice_init = (*env)->GetMethodID + (env, gdkScreenGraphicsDevice_class, "init", "()V"); + + display = (GdkDisplay *) NSA_GET_DISPLAY_PTR(env, obj); + + gdk_threads_enter(); + + numScreens = gdk_display_get_n_screens(display); + + + /* Create a suitably sized array. */ + array = (*env)->NewObjectArray(env, + numScreens, + gdkScreenGraphicsDevice_class, + NULL); + + /* Create GdkScreenGraphicsDevice instances, store the native pointer to + * the GScreen object with them, run a 2nd initialization phase and + * put the new instance into the result array. + */ + for ( ; i < numScreens ; i++) + { + instance = (*env)->NewObject (env, + gdkScreenGraphicsDevice_class, + gdkScreenGraphicsDevice_ctor, + obj); + + NSA_SET_SCREEN_PTR(env, + instance, + gdk_display_get_screen(display, i)); + + gdk_threads_leave(); + (*env)->CallVoidMethod(env, + instance, + gdkScreenGraphicsDevice_init); + gdk_threads_enter(); + + (*env)->SetObjectArrayElement(env, array, i, instance); + } + + gdk_threads_leave(); + + return array; +} + +JNIEXPORT jobject JNICALL +Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment_nativeGetDefaultScreenDevice +(JNIEnv *env, jobject obj) +{ + jclass gdkScreenGraphicsDevice_class; + jmethodID gdkScreenGraphicsDevice_ctor, gdkScreenGraphicsDevice_init; + jobject defaultDevice; + GdkScreen *defaultScreen; + + gdkScreenGraphicsDevice_class = (*env)->FindClass + (env, "gnu/java/awt/peer/gtk/GdkScreenGraphicsDevice"); + + gdkScreenGraphicsDevice_ctor = (*env)->GetMethodID + (env, gdkScreenGraphicsDevice_class, "<init>", + "(Lgnu/java/awt/peer/gtk/GdkGraphicsEnvironment;)V"); + + gdkScreenGraphicsDevice_init = (*env)->GetMethodID + (env, gdkScreenGraphicsDevice_class, "init", "()V"); + + /* Create the GdkScreenGraphicsDevice instance. */ + defaultDevice = (*env)->NewObject (env, + gdkScreenGraphicsDevice_class, + gdkScreenGraphicsDevice_ctor, + obj); + + gdk_threads_enter(); + + defaultScreen = gdk_screen_get_default(); + + gdk_threads_leave(); + + /* Class initialization will have set up the native_state storage + * mechanism for GdkScreenGraphicsDevice. + */ + NSA_SET_SCREEN_PTR(env, defaultDevice, defaultScreen); + + (*env)->CallVoidMethod(env, + defaultDevice, + gdkScreenGraphicsDevice_init); + + return defaultDevice; +} Index: include/gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.h =================================================================== RCS file: include/gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.h diff -N include/gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ include/gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.h 6 Jun 2006 10:04:15 -0000 1.1 @@ -0,0 +1,26 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ + +#ifndef __gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice__ +#define __gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice__ + +#include <jni.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + +JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice_initStaticState (JNIEnv *env, jclass); +JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice_nativeGetFixedDisplayMode (JNIEnv *env, jobject, jobject); +JNIEXPORT jstring JNICALL Java_gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice_nativeGetIDString (JNIEnv *env, jobject); +JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice_nativeGetDisplayModeIndex (JNIEnv *env, jobject, jobject); +JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice_nativeGetDisplayModeRate (JNIEnv *env, jobject, jobject); +JNIEXPORT jobjectArray JNICALL Java_gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice_nativeGetDisplayModes (JNIEnv *env, jobject, jobject); +JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice_nativeSetDisplayMode (JNIEnv *env, jobject, jobject, jint, jshort); +JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice_nativeGetBounds (JNIEnv *env, jobject); + +#ifdef __cplusplus +} +#endif + +#endif /* __gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice__ */ Index: native/jni/gtk-peer/gdkdisplay.h =================================================================== RCS file: native/jni/gtk-peer/gdkdisplay.h diff -N native/jni/gtk-peer/gdkdisplay.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ native/jni/gtk-peer/gdkdisplay.h 6 Jun 2006 10:04:15 -0000 1.1 @@ -0,0 +1,67 @@ +#ifndef __GDKDISPLAY_H__ +#define __GDKDISPLAY_H__ + +/* gdkdisplay.h -- Some global stuff related to displays & screens + Copyright (C) 2006 Free Software Foundation, Inc. + + This file is part of GNU Classpath. + + GNU Classpath is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + GNU Classpath is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GNU Classpath; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301 USA. + + Linking this library statically or dynamically with other modules is + making a combined work based on this library. Thus, the terms and + conditions of the GNU General Public License cover the whole + combination. + + As a special exception, the copyright holders of this library give you + permission to link this library with independent modules to produce an + executable, regardless of the license terms of these independent + modules, and to copy and distribute the resulting executable under + 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" + +/* Allows storing GdkDisplay pointers in GdkGraphicsEnvironment instances. */ +extern struct state_table *cp_gtk_native_display_state_table; + +/* Allows storing GdkScreen pointers in GdkScreenGraphicsDevice instances. */ +extern struct state_table *cp_gtk_native_screen_state_table; + +#define NSA_DISPLAY_INIT(env, clazz) \ + cp_gtk_native_display_state_table = cp_gtk_init_state_table (env, clazz) + +#define NSA_GET_DISPLAY_PTR(env, obj) \ + cp_gtk_get_state (env, obj, cp_gtk_native_display_state_table) + +#define NSA_SET_DISPLAY_PTR(env, obj, ptr) \ + cp_gtk_set_state (env, obj, cp_gtk_native_display_state_table, (void *)ptr) + +#define NSA_SCREEN_INIT(env, clazz) \ + cp_gtk_native_screen_state_table = cp_gtk_init_state_table (env, clazz) + +#define NSA_GET_SCREEN_PTR(env, obj) \ + cp_gtk_get_state (env, obj, cp_gtk_native_screen_state_table) + +#define NSA_SET_SCREEN_PTR(env, obj, ptr) \ + cp_gtk_set_state (env, obj, cp_gtk_native_screen_state_table, (void *)ptr) + +#endif /* __GDKDISPLAY_H__ */ Index: native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.c =================================================================== RCS file: native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.c diff -N native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.c 6 Jun 2006 10:04:15 -0000 1.1 @@ -0,0 +1,354 @@ +/* gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.c + Copyright (C) 2006 Free Software Foundation, Inc. + + This file is part of GNU Classpath. + + GNU Classpath is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + GNU Classpath is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GNU Classpath; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301 USA. + + Linking this library statically or dynamically with other modules is + making a combined work based on this library. Thus, the terms and + conditions of the GNU General Public License cover the whole + combination. + + As a special exception, the copyright holders of this library give you + permission to link this library with independent modules to produce an + executable, regardless of the license terms of these independent + modules, and to copy and distribute the resulting executable under + 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 <gdk/gdk.h> +#include <gdk/gdkx.h> + +#ifdef HAVE_XRANDR +#include <X11/Xlib.h> +#include <X11/extensions/Xrandr.h> +#endif + +#include "gdkdisplay.h" + +#include "gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.h" + +struct state_table *cp_gtk_native_screen_state_table; + +jclass gdkScreenGraphicsDevice_class; + +JNIEXPORT void JNICALL +Java_gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice_initStaticState +(JNIEnv *env, jclass klazz) +{ + gdkScreenGraphicsDevice_class = (*env)->NewGlobalRef + (env, klazz); + + NSA_SCREEN_INIT(env, gdkScreenGraphicsDevice_class); +} + +JNIEXPORT jobject JNICALL +Java_gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice_nativeGetFixedDisplayMode +(JNIEnv *env, jobject obj, jobject gdkGraphicsEnv __attribute__((unused))) +{ + jclass displayMode_class; + jmethodID displayMode_ctor; + GdkScreen *screen; + jobject fixedDisplayMode = NULL; +#ifdef HAVE_XRANDR + int temp1, temp2; + GdkDisplay *display; + + display = (GdkDisplay *) NSA_GET_DISPLAY_PTR(env, gdkGraphicsEnv); + + gdk_threads_enter(); + + if (!XRRQueryExtension(GDK_DISPLAY_XDISPLAY(display), &temp1, &temp2)) + { + displayMode_class = (*env)->FindClass(env, "java/awt/DisplayMode"); + displayMode_ctor = (*env)->GetMethodID(env, + displayMode_class, + "<init>", + "(IIII)V"); + + screen = (GdkScreen *) NSA_GET_SCREEN_PTR(env, obj); + + fixedDisplayMode = (*env)->NewObject(env, + displayMode_class, + displayMode_ctor, + gdk_screen_get_width(screen), + gdk_screen_get_height(screen), + -1, + 0); + } + + gdk_threads_leave(); + +#else + + displayMode_class = (*env)->FindClass(env, "java/awt/DisplayMode"); + displayMode_ctor = (*env)->GetMethodID(env, + displayMode_class, + "<init>", + "(IIII)V"); + + screen = (GdkScreen *) NSA_GET_SCREEN_PTR(env, obj); + + fixedDisplayMode = (*env)->NewObject(env, + displayMode_class, + displayMode_ctor, + gdk_screen_get_width(screen), + gdk_screen_get_height(screen), + -1, + 0); + +#endif + return fixedDisplayMode; +} + +JNIEXPORT jstring JNICALL +Java_gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice_nativeGetIDString +(JNIEnv *env, jobject obj) +{ + GdkScreen *screen; + gchar* displayName; + jstring string; + + screen = (GdkScreen *) NSA_GET_SCREEN_PTR(env, obj); + + gdk_threads_enter(); + + displayName = gdk_screen_make_display_name(screen); + + gdk_threads_leave(); + + string = (*env)->NewStringUTF(env, displayName); + + g_free(displayName); + + return string; +} + +JNIEXPORT jint JNICALL +Java_gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice_nativeGetDisplayModeRate +(JNIEnv *env, jobject obj __attribute__((unused)), jobject gdkGraphicsEnv __attribute__((unused))) +{ +#ifdef HAVE_XRANDR + + GdkDisplay *display; + XRRScreenConfiguration *config; + int rate; + + display = (GdkDisplay *) NSA_GET_DISPLAY_PTR(env, gdkGraphicsEnv); + + gdk_threads_enter(); + + config = XRRGetScreenInfo (GDK_DISPLAY_XDISPLAY(display), GDK_ROOT_WINDOW()); + + rate = (int) XRRConfigCurrentRate (config); + + XRRFreeScreenConfigInfo (config); + + gdk_threads_leave(); + + return rate; +#else + JCL_ThrowException(env, + "java/lang/InternalError", + "Method should not have been invoked."); + + return -1; +#endif +} + +JNIEXPORT jint JNICALL +Java_gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice_nativeGetDisplayModeIndex +(JNIEnv *env, jobject obj __attribute__((unused)), jobject gdkGraphicsEnv __attribute__((unused))) +{ +#ifdef HAVE_XRANDR + + GdkDisplay *display; + XRRScreenConfiguration *config; + SizeID index; + Rotation rotation; + + display = (GdkDisplay *) NSA_GET_DISPLAY_PTR(env, gdkGraphicsEnv); + + gdk_threads_enter(); + + config = XRRGetScreenInfo (GDK_DISPLAY_XDISPLAY(display), GDK_ROOT_WINDOW()); + + index = XRRConfigCurrentConfiguration (config, &rotation); + + XRRFreeScreenConfigInfo (config); + + gdk_threads_leave(); + + return (int) index; + +#else + + JCL_ThrowException(env, + "java/lang/InternalError", + "Method should not have been invoked."); + + return -1; + +#endif +} + +JNIEXPORT jobjectArray JNICALL +Java_gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice_nativeGetDisplayModes +(JNIEnv *env, jobject obj __attribute__((unused)), jobject gdkGraphicsEnv __attribute__((unused))) +{ +#ifdef HAVE_XRANDR + GdkDisplay *display; + XRRScreenConfiguration *config; + XRRScreenSize *screenSizes; + int nsizes = 0, nrates = 0, i = 0; + jclass x11DisplayMode_class; + jmethodID x11DisplayMode_ctor; + jobjectArray array; + jobject instance; + short *rates; + jshortArray shortArray; + + display = (GdkDisplay *) NSA_GET_DISPLAY_PTR(env, gdkGraphicsEnv); + + gdk_threads_enter(); + + config = XRRGetScreenInfo (GDK_DISPLAY_XDISPLAY(display), GDK_ROOT_WINDOW()); + + screenSizes = XRRConfigSizes(config, &nsizes); + + x11DisplayMode_class = (*env)->FindClass(env, "gnu/java/awt/peer/gtk/GdkScreenGraphicsDevice$X11DisplayMode"); + + x11DisplayMode_ctor = (*env)->GetMethodID(env, x11DisplayMode_class, "<init>", "(II[S)V"); + + array = (*env)->NewObjectArray(env, nsizes, x11DisplayMode_class, NULL); + + for (; i < nsizes ; i++) + { + /* Retrieves refresh rate information. */ + rates = XRRConfigRates(config, i, &nrates); + + /* Create a Java int array and put them in. */ + shortArray = (*env)->NewIntArray(env, nrates); + (*env)->SetShortArrayRegion(env, shortArray, 0, nrates, (jshort *) rates); + + /* Create a GdkScreenGraphicsDevice.X11DisplayMode instance. */ + instance = (*env)->NewObject(env, + x11DisplayMode_class, + x11DisplayMode_ctor, + screenSizes[i].width, + screenSizes[i].height, + shortArray); + + /* Put it into the result array. */ + (*env)->SetObjectArrayElement(env, array, i, instance); + } + + /* Free everything acquired by xlib. */ + XRRFreeScreenConfigInfo (config); + + gdk_threads_leave(); + + return array; +#else + JCL_ThrowException(env, + "java/lang/InternalError", + "Method should not have been invoked."); + + return NULL; + +#endif +} + +JNIEXPORT void JNICALL +Java_gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice_nativeSetDisplayMode +(JNIEnv *env, jobject obj __attribute__((unused)), jobject gdkGraphicsEnv __attribute__((unused)), jint index __attribute__((unused)), jshort rate __attribute__((unused))) +{ +#ifdef HAVE_XRANDR + GdkDisplay *display; + XRRScreenConfiguration *config; + Rotation rotation; + + display = (GdkDisplay *) NSA_GET_DISPLAY_PTR(env, gdkGraphicsEnv); + + gdk_threads_enter(); + + config = XRRGetScreenInfo (GDK_DISPLAY_XDISPLAY(display), GDK_ROOT_WINDOW()); + + /* The rotation is not exposed to the Java API. So we retrieve its current + * value and set it to the same when switching resolution. + */ + XRRConfigCurrentConfiguration (config, &rotation); + + XRRSetScreenConfigAndRate (GDK_DISPLAY_XDISPLAY(display), + config, + GDK_ROOT_WINDOW(), + index, + rotation, + rate, + CurrentTime); + + XRRFreeScreenConfigInfo(config); + + gdk_threads_leave(); + +#else + JCL_ThrowException(env, + "java/lang/InternalError", + "Method should not have been invoked."); +#endif +} + +JNIEXPORT jobject JNICALL +Java_gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice_nativeGetBounds +(JNIEnv *env, jobject obj) +{ + jclass rectangle_class; + jmethodID rectangle_ctor; + GdkScreen *screen; + GdkWindow *window; + int x, y, w, h; + jobject instance; + + rectangle_class = (*env)->FindClass(env, "java/awt/Rectangle"); + + rectangle_ctor = (*env)->GetMethodID + (env, rectangle_class, "<init>", "(IIII)V"); + + screen = (GdkScreen *) NSA_GET_SCREEN_PTR(env, obj); + + gdk_threads_enter(); + + window = gdk_screen_get_root_window(screen); + + gdk_window_get_geometry(window, &x, &y, &w, &h, NULL); + + gdk_threads_leave(); + + instance = (*env)->NewObject(env, + rectangle_class, + rectangle_ctor, + x, y, w, h); + + return instance; +}