You can subscribe to this list here.
| 2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(134) |
Sep
(52) |
Oct
(13) |
Nov
(342) |
Dec
(163) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2003 |
Jan
(44) |
Feb
(62) |
Mar
(158) |
Apr
(38) |
May
(70) |
Jun
(58) |
Jul
(104) |
Aug
(207) |
Sep
(83) |
Oct
(122) |
Nov
(23) |
Dec
(49) |
| 2004 |
Jan
(119) |
Feb
(132) |
Mar
(192) |
Apr
(140) |
May
(77) |
Jun
(74) |
Jul
(201) |
Aug
(63) |
Sep
(102) |
Oct
(70) |
Nov
(173) |
Dec
(78) |
| 2005 |
Jan
(174) |
Feb
(197) |
Mar
(105) |
Apr
(59) |
May
(77) |
Jun
(43) |
Jul
(21) |
Aug
(18) |
Sep
(47) |
Oct
(37) |
Nov
(74) |
Dec
(50) |
| 2006 |
Jan
(44) |
Feb
(19) |
Mar
(32) |
Apr
(24) |
May
(31) |
Jun
(55) |
Jul
(138) |
Aug
(28) |
Sep
(12) |
Oct
(41) |
Nov
(58) |
Dec
(24) |
| 2007 |
Jan
(28) |
Feb
(14) |
Mar
(10) |
Apr
(68) |
May
(30) |
Jun
(26) |
Jul
(18) |
Aug
(63) |
Sep
(19) |
Oct
(29) |
Nov
(20) |
Dec
(10) |
| 2008 |
Jan
(38) |
Feb
(7) |
Mar
(37) |
Apr
(120) |
May
(41) |
Jun
(36) |
Jul
(39) |
Aug
(24) |
Sep
(28) |
Oct
(30) |
Nov
(36) |
Dec
(75) |
| 2009 |
Jan
(46) |
Feb
(22) |
Mar
(50) |
Apr
(70) |
May
(134) |
Jun
(105) |
Jul
(75) |
Aug
(34) |
Sep
(38) |
Oct
(34) |
Nov
(19) |
Dec
(20) |
| 2010 |
Jan
(11) |
Feb
(20) |
Mar
(65) |
Apr
(83) |
May
(104) |
Jun
(73) |
Jul
(78) |
Aug
(57) |
Sep
(43) |
Oct
(35) |
Nov
(9) |
Dec
(4) |
| 2011 |
Jan
(21) |
Feb
(11) |
Mar
(18) |
Apr
(10) |
May
(18) |
Jun
(15) |
Jul
(48) |
Aug
(25) |
Sep
(17) |
Oct
(45) |
Nov
(15) |
Dec
(12) |
| 2012 |
Jan
(21) |
Feb
(9) |
Mar
(12) |
Apr
(9) |
May
(9) |
Jun
(5) |
Jul
(1) |
Aug
(10) |
Sep
(12) |
Oct
(1) |
Nov
(28) |
Dec
(5) |
| 2013 |
Jan
(4) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2014 |
Jan
|
Feb
(1) |
Mar
(1) |
Apr
|
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
| 2015 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
|
| 2016 |
Jan
(2) |
Feb
(1) |
Mar
(1) |
Apr
(1) |
May
(2) |
Jun
|
Jul
(1) |
Aug
(2) |
Sep
|
Oct
|
Nov
(1) |
Dec
|
| 2017 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <eli...@us...> - 2008-04-07 13:34:22
|
Revision: 2977
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=2977&view=rev
Author: elias_naur
Date: 2008-04-07 06:34:20 -0700 (Mon, 07 Apr 2008)
Log Message:
-----------
Mac OS X: Split canvas listener from MacOSXGLCanvas
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java
trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXFrame.java
trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXGLCanvas.java
Added Paths:
-----------
trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasListener.java
Added: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasListener.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasListener.java (rev 0)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasListener.java 2008-04-07 13:34:20 UTC (rev 2977)
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2002-2004 LWJGL Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of 'LWJGL' nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.lwjgl.opengl;
+
+/**
+ * The AWT compatible Canvas for Mac OS X.
+ * @author elias_naur
+ */
+
+import java.awt.Canvas;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Point;
+import java.awt.event.ComponentEvent;
+import java.awt.event.ComponentListener;
+import java.awt.event.HierarchyEvent;
+import java.awt.event.HierarchyListener;
+
+final class MacOSXCanvasListener implements ComponentListener, HierarchyListener {
+ private final Canvas canvas;
+ private int width;
+ private int height;
+ private boolean context_update;
+
+ public MacOSXCanvasListener(Canvas canvas) {
+ this.canvas = canvas;
+// ((MacOSXDisplay)Display.getImplementation()).setView(this);
+ }
+
+ public void enableListeners() {
+ canvas.addComponentListener(this);
+ canvas.addHierarchyListener(this);
+ setUpdate();
+ }
+
+ public void disableListeners() {
+ canvas.removeComponentListener(this);
+ canvas.removeHierarchyListener(this);
+ }
+
+ public boolean syncShouldUpdateContext() {
+ boolean should_update;
+ synchronized ( this ) {
+ should_update = context_update;
+ context_update = false;
+ }
+ return should_update;
+ }
+
+ private synchronized void setUpdate() {
+ synchronized ( this ) {
+ width = canvas.getWidth();
+ height = canvas.getHeight();
+ context_update = true;
+ }
+ }
+
+ public int syncGetWidth() {
+ synchronized ( this ) {
+ return width;
+ }
+ }
+
+ public int syncGetHeight() {
+ synchronized ( this ) {
+ return height;
+ }
+ }
+
+ public void componentShown(ComponentEvent e) {
+ }
+
+ public void componentHidden(ComponentEvent e) {
+ }
+
+ public void componentResized(ComponentEvent e) {
+ setUpdate();
+ }
+
+ public void componentMoved(ComponentEvent e) {
+ setUpdate();
+ }
+
+ public void hierarchyChanged(HierarchyEvent e) {
+ setUpdate();
+ }
+}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2008-04-07 13:01:52 UTC (rev 2976)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2008-04-07 13:34:20 UTC (rev 2977)
@@ -61,6 +61,7 @@
private static final int PBUFFER_HANDLE_SIZE = 24;
private static final int GAMMA_LENGTH = 256;
+ private MacOSXCanvasListener canvas_listener;
private MacOSXFrame frame;
private Robot robot;
private MacOSXMouseEventQueue mouse_queue;
@@ -79,6 +80,8 @@
close_requested = false;
try {
frame = new MacOSXFrame(mode, requested_mode, fullscreen, x, y);
+ canvas_listener = new MacOSXCanvasListener(frame.getCanvas());
+ canvas_listener.enableListeners();
robot = AWTUtil.createRobot(frame);
} catch (LWJGLException e) {
destroyWindow();
@@ -93,6 +96,10 @@
}
public void destroyWindow() {
+ if (canvas_listener != null) {
+ canvas_listener.disableListeners();
+ canvas_listener = null;
+ }
if (frame != null) {
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
@@ -216,7 +223,7 @@
private final static IntBuffer current_viewport = BufferUtils.createIntBuffer(16);
public void update() {
- boolean should_update = frame.getCanvas().syncShouldUpdateContext();
+ boolean should_update = canvas_listener.syncShouldUpdateContext();
/*
* Workaround for the "white screen in fullscreen mode" problem
*
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXFrame.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXFrame.java 2008-04-07 13:01:52 UTC (rev 2976)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXFrame.java 2008-04-07 13:34:20 UTC (rev 2977)
@@ -101,7 +101,6 @@
setVisible(true);
requestFocus();
canvas.requestFocus();
- canvas.initializeCanvas();
updateBounds();
}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXGLCanvas.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXGLCanvas.java 2008-04-07 13:01:52 UTC (rev 2976)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXGLCanvas.java 2008-04-07 13:34:20 UTC (rev 2977)
@@ -45,13 +45,10 @@
import java.awt.event.HierarchyEvent;
import java.awt.event.HierarchyListener;
-final class MacOSXGLCanvas extends Canvas implements ComponentListener, HierarchyListener {
+final class MacOSXGLCanvas extends Canvas {
private static final long serialVersionUID = 6916664741667434870L;
- private int width;
- private int height;
- private boolean context_update;
private boolean canvas_painted;
private boolean dirty;
@@ -71,12 +68,6 @@
*/
public void initializeCanvas() {
setFocusTraversalKeysEnabled(false);
- /* Input methods are not enabled in fullscreen anyway, so disable always */
- enableInputMethods(false);
- addComponentListener(this);
- addHierarchyListener(this);
-// ((MacOSXDisplay)Display.getImplementation()).setView(this);
- setUpdate();
}
public boolean syncCanvasPainted() {
@@ -96,76 +87,4 @@
}
return result;
}
-
- public boolean syncShouldUpdateContext() {
- boolean should_update;
- synchronized ( this ) {
- should_update = context_update;
- context_update = false;
- }
- return should_update;
- }
-
- private synchronized void setUpdate() {
- synchronized ( this ) {
- width = getWidth();
- height = getHeight();
- context_update = true;
- }
- }
-
- public int syncGetWidth() {
- synchronized ( this ) {
- return width;
- }
- }
-
- public int syncGetHeight() {
- synchronized ( this ) {
- return height;
- }
- }
-
- public void componentShown(ComponentEvent e) {
- }
-
- public void componentHidden(ComponentEvent e) {
- }
-
- public void componentResized(ComponentEvent e) {
- setUpdate();
- }
-
- public void componentMoved(ComponentEvent e) {
- setUpdate();
- }
-
- public void setLocation(int x, int y) {
- super.setLocation(x, y);
- setUpdate();
- }
-
- public void setLocation(Point p) {
- super.setLocation(p);
- setUpdate();
- }
-
- public void setSize(Dimension d) {
- super.setSize(d);
- setUpdate();
- }
-
- public void setSize(int width, int height) {
- super.setSize(width, height);
- setUpdate();
- }
-
- public void setBounds(int x, int y, int width, int height) {
- super.setBounds(x, y, width, height);
- setUpdate();
- }
-
- public void hierarchyChanged(HierarchyEvent e) {
- setUpdate();
- }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <eli...@us...> - 2008-04-07 13:01:54
|
Revision: 2976
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=2976&view=rev
Author: elias_naur
Date: 2008-04-07 06:01:52 -0700 (Mon, 07 Apr 2008)
Log Message:
-----------
Mac OS X: Fixed 10.5 compiler warning
Modified Paths:
--------------
trunk/LWJGL/src/native/macosx/org_lwjgl_opengl_MacOSXContextImplementation.m
Modified: trunk/LWJGL/src/native/macosx/org_lwjgl_opengl_MacOSXContextImplementation.m
===================================================================
--- trunk/LWJGL/src/native/macosx/org_lwjgl_opengl_MacOSXContextImplementation.m 2008-04-07 11:48:20 UTC (rev 2975)
+++ trunk/LWJGL/src/native/macosx/org_lwjgl_opengl_MacOSXContextImplementation.m 2008-04-07 13:01:52 UTC (rev 2976)
@@ -142,7 +142,7 @@
(JNIEnv *env, jclass clazz, jobject context_handle, jint int_value) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
MacOSXContext *context_info = (MacOSXContext *)(*env)->GetDirectBufferAddress(env, context_handle);
- long value = int_value;
+ GLint value = int_value;
[context_info->context setValues:&value forParameter:NSOpenGLCPSwapInterval];
[pool release];
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <eli...@us...> - 2008-04-07 11:48:23
|
Revision: 2975
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=2975&view=rev
Author: elias_naur
Date: 2008-04-07 04:48:20 -0700 (Mon, 07 Apr 2008)
Log Message:
-----------
Mac OS X: Added support for x86_64
Modified Paths:
--------------
trunk/LWJGL/platform_build/macosx_ant/build.xml
Modified: trunk/LWJGL/platform_build/macosx_ant/build.xml
===================================================================
--- trunk/LWJGL/platform_build/macosx_ant/build.xml 2008-04-07 11:30:43 UTC (rev 2974)
+++ trunk/LWJGL/platform_build/macosx_ant/build.xml 2008-04-07 11:48:20 UTC (rev 2975)
@@ -4,12 +4,14 @@
<target name="init">
<mkdir dir="ppc"/>
- <mkdir dir="intel"/>
+ <mkdir dir="i386"/>
+ <mkdir dir="x86_64"/>
</target>
<target name="clean">
<delete failonerror="false">
- <fileset dir="intel"/>
+ <fileset dir="i386"/>
+ <fileset dir="x86_64"/>
<fileset dir="ppc"/>
<fileset dir="." includes="liblwjgl.jnilib"/>
<fileset dir="." includes="lwjgl.symbols"/>
@@ -41,16 +43,23 @@
<target name="nativelibrary" depends="init">
<property name="universal_sdkroot" location="/Developer/SDKs/MacOSX10.4u.sdk"/>
+ <property name="x86_64_sdkroot" location="/Developer/SDKs/MacOSX10.5.sdk"/>
<property name="legacy_sdkroot" location="/Developer/SDKs/MacOSX10.4u.sdk"/>
- <property name="universal_flags" value="-isysroot ${universal_sdkroot} -arch i386 -mmacosx-version-min=10.4"/>
+ <property name="universal_flags" value="-isysroot ${universal_sdkroot}"/>
<property name="legacy_flags" value="-F${legacy_sdkroot}/System/Library/Frameworks -arch ppc"/>
<antcall target="compile">
- <param name="dstdir" location="intel"/>
+ <param name="dstdir" location="i386"/>
<param name="compiler" value="gcc-4.0"/>
<param name="sdkroot" location="${universal_sdkroot}"/>
- <param name="cflags" value="${universal_flags}"/>
+ <param name="cflags" value="${universal_flags} -arch i386 -mmacosx-version-min=10.4"/>
</antcall>
<antcall target="compile">
+ <param name="dstdir" location="x86_64"/>
+ <param name="compiler" value="gcc-4.0"/>
+ <param name="sdkroot" location="${universal_sdkroot}"/>
+ <param name="cflags" value="-isysroot ${x86_64_sdkroot} -arch x86_64 -mmacosx-version-min=10.5"/>
+ </antcall>
+ <antcall target="compile">
<param name="dstdir" location="ppc"/>
<param name="compiler" value="gcc-3.3"/>
<param name="sdkroot" location="${legacy_sdkroot}"/>
@@ -58,15 +67,21 @@
</antcall>
<exec vmlauncher="true" executable="sh" output="lwjgl.symbols" failonerror="true">
<arg path="../../platform_build/macosx_ant/build-symbol-list"/>
- <arg path="intel"/>
+ <arg path="i386"/>
</exec>
<antcall target="link">
- <param name="objdir" location="intel"/>
- <param name="libname" value="liblwjgl-intel.jnilib"/>
+ <param name="objdir" location="i386"/>
+ <param name="libname" value="liblwjgl-i386.jnilib"/>
<param name="linker" value="gcc-4.0"/>
- <param name="linkerflags" value="${universal_flags}"/>
+ <param name="linkerflags" value="${universal_flags} -arch i386 -mmacosx-version-min=10.4"/>
</antcall>
<antcall target="link">
+ <param name="objdir" location="x86_64"/>
+ <param name="libname" value="liblwjgl-i86_64.jnilib"/>
+ <param name="linker" value="gcc-4.0"/>
+ <param name="linkerflags" value="-isysroot ${x86_64_sdkroot} -arch x86_64 -mmacosx-version-min=10.5"/>
+ </antcall>
+ <antcall target="link">
<param name="objdir" location="ppc"/>
<param name="libname" value="liblwjgl-ppc.jnilib"/>
<param name="linker" value="gcc-3.3"/>
@@ -78,7 +93,8 @@
<arg value="-output"/>
<arg path="liblwjgl.jnilib"/>
<fileset file="ppc/liblwjgl-ppc.jnilib"/>
- <fileset file="intel/liblwjgl-intel.jnilib"/>
+ <fileset file="i386/liblwjgl-i386.jnilib"/>
+ <fileset file="x86_64/liblwjgl-i86_64.jnilib"/>
</apply>
</target>
</project>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <eli...@us...> - 2008-04-07 11:30:46
|
Revision: 2974
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=2974&view=rev
Author: elias_naur
Date: 2008-04-07 04:30:43 -0700 (Mon, 07 Apr 2008)
Log Message:
-----------
Mac OS X: 10.5 build fixes
Modified Paths:
--------------
trunk/LWJGL/platform_build/macosx_ant/build.xml
Modified: trunk/LWJGL/platform_build/macosx_ant/build.xml
===================================================================
--- trunk/LWJGL/platform_build/macosx_ant/build.xml 2008-04-07 10:18:09 UTC (rev 2973)
+++ trunk/LWJGL/platform_build/macosx_ant/build.xml 2008-04-07 11:30:43 UTC (rev 2974)
@@ -1,4 +1,4 @@
-<?xml version="1.0" ?>
+
<project name="OS X Native code" basedir="../../bin/lwjgl" default="nativelibrary">
<property name="native" location="../../src/native"/>
@@ -30,7 +30,7 @@
<target name="link">
<apply dir="${objdir}" parallel="true" executable="${linker}" os="Mac OS X" failonerror="true" skipemptyfilesets="true">
- <arg line="${linkerflags} -exported_symbols_list ../lwjgl.symbols -dynamiclib -o ${libname} -framework Foundation -framework AppKit -framework JavaVM -framework Carbon"/>
+ <arg line="${linkerflags} -mmacosx-version-min=10.4 -exported_symbols_list ../lwjgl.symbols -dynamiclib -o ${libname} -framework Foundation -framework AppKit -framework JavaVM -framework Carbon"/>
<fileset dir="${objdir}" includes="*.o"/>
</apply>
<apply dir="${objdir}" executable="strip" os="Mac OS X" failonerror="true">
@@ -42,7 +42,7 @@
<target name="nativelibrary" depends="init">
<property name="universal_sdkroot" location="/Developer/SDKs/MacOSX10.4u.sdk"/>
<property name="legacy_sdkroot" location="/Developer/SDKs/MacOSX10.4u.sdk"/>
- <property name="universal_flags" value="-isysroot ${universal_sdkroot} -arch i386"/>
+ <property name="universal_flags" value="-isysroot ${universal_sdkroot} -arch i386 -mmacosx-version-min=10.4"/>
<property name="legacy_flags" value="-F${legacy_sdkroot}/System/Library/Frameworks -arch ppc"/>
<antcall target="compile">
<param name="dstdir" location="intel"/>
@@ -56,7 +56,8 @@
<param name="sdkroot" location="${legacy_sdkroot}"/>
<param name="cflags" value="${legacy_flags}"/>
</antcall>
- <exec vmlauncher="false" executable="../../platform_build/macosx_ant/build-symbol-list" output="lwjgl.symbols" failonerror="true">
+ <exec vmlauncher="true" executable="sh" output="lwjgl.symbols" failonerror="true">
+ <arg path="../../platform_build/macosx_ant/build-symbol-list"/>
<arg path="intel"/>
</exec>
<antcall target="link">
@@ -69,7 +70,7 @@
<param name="objdir" location="ppc"/>
<param name="libname" value="liblwjgl-ppc.jnilib"/>
<param name="linker" value="gcc-3.3"/>
- <param name="linkerflags" value="${legacy_flags}"/>
+ <param name="linkerflags" value="${legacy_flags} -Wl,-syslibroot -Wl,${legacy_sdkroot}"/>
</antcall>
<apply dir="." parallel="true" executable="lipo" os="Mac OS X" failonerror="true" skipemptyfilesets="true" >
<arg value="-create"/>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <eli...@us...> - 2008-04-07 10:18:13
|
Revision: 2973
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=2973&view=rev
Author: elias_naur
Date: 2008-04-07 03:18:09 -0700 (Mon, 07 Apr 2008)
Log Message:
-----------
Windows: Implemented Display.setParent support
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java
trunk/LWJGL/src/java/org/lwjgl/test/opengl/awt/DisplayParentTest.java
trunk/LWJGL/src/native/windows/context.c
trunk/LWJGL/src/native/windows/context.h
trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2008-04-07 09:23:27 UTC (rev 2972)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2008-04-07 10:18:09 UTC (rev 2973)
@@ -71,6 +71,8 @@
private final static int WM_QUIT = 0x0012;
private final static int WM_SYSCOMMAND = 0x0112;
private final static int WM_PAINT = 0x000F;
+ private final static int WM_KILLFOCUS = 8;
+ private final static int WM_SETFOCUS = 7;
private final static int SC_SIZE = 0xF000;
private final static int SC_MOVE = 0xF010;
@@ -118,6 +120,7 @@
private static boolean cursor_clipped;
private WindowsDisplayPeerInfo peer_info;
private Object current_cursor;
+ private Canvas parent;
private WindowsKeyboard keyboard;
private WindowsMouse mouse;
@@ -140,21 +143,41 @@
current_display = this;
}
- public void createWindow(DisplayMode mode, boolean fullscreen, Canvas container, int x, int y) throws LWJGLException {
+ public void createWindow(DisplayMode mode, boolean fullscreen, Canvas parent, int x, int y) throws LWJGLException {
close_requested = false;
is_dirty = false;
isFullscreen = fullscreen;
isMinimized = false;
isFocused = false;
did_maximize = false;
- nCreateWindow(mode, fullscreen, x, y);
+ this.parent = parent;
+ long parent_hwnd = parent != null ? getHwnd(parent) : 0;
+ boolean isUndecorated = isUndecorated();
+ nCreateWindow(mode, fullscreen, x, y, isUndecorated, parent_hwnd);
peer_info.initDC();
showWindow(getHwnd(), SW_SHOWDEFAULT);
- setForegroundWindow(getHwnd());
- setFocus(getHwnd());
+ if (parent == null) {
+ setForegroundWindow(getHwnd());
+ setFocus(getHwnd());
+ }
}
- private native void nCreateWindow(DisplayMode mode, boolean fullscreen, int x, int y) throws LWJGLException;
+ private native void nCreateWindow(DisplayMode mode, boolean fullscreen, int x, int y, boolean undecorated, long parent_hwnd) throws LWJGLException;
+ private static boolean isUndecorated() {
+ return Display.getPrivilegedBoolean("org.lwjgl.opengl.Window.undecorated");
+ }
+
+ private static long getHwnd(Canvas parent) throws LWJGLException {
+ AWTCanvasImplementation awt_impl = AWTGLCanvas.createImplementation();
+ WindowsPeerInfo parent_peer_info = (WindowsPeerInfo)awt_impl.createPeerInfo(parent, null);
+ ByteBuffer parent_peer_info_handle = parent_peer_info.lockAndGetHandle();
+ try {
+ return parent_peer_info.getHwnd();
+ } finally {
+ parent_peer_info.unlock();
+ }
+ }
+
public void destroyWindow() {
nDestroyWindow();
resetCursorClipping();
@@ -213,7 +236,6 @@
return;
}
inAppActivate = true;
- isFocused = active;
if (active) {
if (isFullscreen) {
restoreDisplayMode();
@@ -350,6 +372,9 @@
public void update() {
nUpdate();
+ if (parent != null && parent.isFocusOwner()) {
+ setFocus(getHwnd());
+ }
if (did_maximize) {
did_maximize = false;
/**
@@ -369,9 +394,9 @@
public void reshape(int x, int y, int width, int height) {
if (!isFullscreen)
- nReshape(getHwnd(), x, y, width, height);
+ nReshape(getHwnd(), x, y, width, height, isUndecorated(), parent != null);
}
- private static native void nReshape(long hwnd, int x, int y, int width, int height);
+ private static native void nReshape(long hwnd, int x, int y, int width, int height, boolean undecorated, boolean child);
public native DisplayMode[] getAvailableDisplayModes() throws LWJGLException;
/* Mouse */
@@ -682,6 +707,12 @@
break;
}
return defWindowProc(hwnd, msg, wParam, lParam);
+ case WM_KILLFOCUS:
+ isFocused = false;
+ return 0;
+ case WM_SETFOCUS:
+ isFocused = true;
+ return 0;
case WM_MOUSEMOVE:
int xPos = (int)(short)(lParam & 0xFFFF);
int yPos = transformY(getHwnd(), (int)(short)((lParam >> 16) & 0xFFFF));
Modified: trunk/LWJGL/src/java/org/lwjgl/test/opengl/awt/DisplayParentTest.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/test/opengl/awt/DisplayParentTest.java 2008-04-07 09:23:27 UTC (rev 2972)
+++ trunk/LWJGL/src/java/org/lwjgl/test/opengl/awt/DisplayParentTest.java 2008-04-07 10:18:09 UTC (rev 2973)
@@ -65,11 +65,12 @@
final Canvas display_parent = new Canvas();
display_parent.setFocusable(true);
add(display_parent);
- addWindowListener(new WindowAdapter() {
+/* addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
+ Display.destroy();
dispose();
}
- });
+ });*/
setResizable(true);
setVisible(true);
Display.setParent(display_parent);
@@ -102,7 +103,9 @@
while(Keyboard.next()) {
// closing on ESCAPE
if(Keyboard.getEventKey() == Keyboard.KEY_ESCAPE && Keyboard.getEventKeyState()) {
+ Display.destroy();
dispose();
+ break;
}
if(Keyboard.getEventKey() == Keyboard.KEY_SPACE && Keyboard.getEventKeyState()) {
Modified: trunk/LWJGL/src/native/windows/context.c
===================================================================
--- trunk/LWJGL/src/native/windows/context.c 2008-04-07 09:23:27 UTC (rev 2972)
+++ trunk/LWJGL/src/native/windows/context.c 2008-04-07 10:18:09 UTC (rev 2973)
@@ -112,7 +112,7 @@
}
}
-void getWindowFlags(DWORD *windowflags_return, DWORD *exstyle_return, bool fullscreen, bool undecorated) {
+void getWindowFlags(DWORD *windowflags_return, DWORD *exstyle_return, bool fullscreen, bool undecorated, bool child_window) {
DWORD exstyle, windowflags;
if (fullscreen) {
exstyle = WS_EX_APPWINDOW;
@@ -120,6 +120,9 @@
} else if (undecorated) {
exstyle = WS_EX_APPWINDOW;
windowflags = WS_POPUP;
+ } else if (child_window) {
+ exstyle = 0;
+ windowflags = WS_CHILDWINDOW;
} else {
exstyle = WS_EX_APPWINDOW;
windowflags = WS_OVERLAPPED | WS_BORDER | WS_CAPTION | WS_MINIMIZEBOX | WS_SYSMENU;
@@ -136,13 +139,13 @@
*
* Returns true for success, or false for failure
*/
-HWND createWindow(LPCTSTR window_class_name, int x, int y, int width, int height, bool fullscreen, bool undecorated)
+HWND createWindow(LPCTSTR window_class_name, int x, int y, int width, int height, bool fullscreen, bool undecorated, HWND parent)
{
RECT clientSize;
DWORD exstyle, windowflags;
HWND new_hwnd;
- getWindowFlags(&windowflags, &exstyle, fullscreen, undecorated);
+ getWindowFlags(&windowflags, &exstyle, fullscreen, undecorated, parent != NULL);
// If we're not a fullscreen window, adjust the height to account for the
// height of the title bar (unless undecorated)
@@ -164,8 +167,8 @@
"",
windowflags,
x, y, clientSize.right - clientSize.left, clientSize.bottom - clientSize.top,
+ parent,
NULL,
- NULL,
dll_handle,
NULL);
@@ -462,5 +465,5 @@
HWND createDummyWindow(int origin_x, int origin_y) {
if (!registerDummyWindow())
return NULL;
- return createWindow(_CONTEXT_PRIVATE_CLASS_NAME, origin_x, origin_y, 1, 1, false, false);
+ return createWindow(_CONTEXT_PRIVATE_CLASS_NAME, origin_x, origin_y, 1, 1, false, false, NULL);
}
Modified: trunk/LWJGL/src/native/windows/context.h
===================================================================
--- trunk/LWJGL/src/native/windows/context.h 2008-04-07 09:23:27 UTC (rev 2972)
+++ trunk/LWJGL/src/native/windows/context.h 2008-04-07 10:18:09 UTC (rev 2973)
@@ -80,7 +80,7 @@
/**
* Return appropriate window and extended style flags from the given fullscreen and undecorated property
*/
-extern void getWindowFlags(DWORD *windowflags_return, DWORD *exstyle_return, bool fullscreen, bool undecorated);
+extern void getWindowFlags(DWORD *windowflags_return, DWORD *exstyle_return, bool fullscreen, bool undecorated, bool child_window);
/*
* Create a window with the specified position, size, and
@@ -89,7 +89,7 @@
*
* Returns true for success, or false for failure
*/
-extern HWND createWindow(LPCTSTR window_class_name, int x, int y, int width, int height, bool fullscreen, bool undecorated);
+extern HWND createWindow(LPCTSTR window_class_name, int x, int y, int width, int height, bool fullscreen, bool undecorated, HWND parent);
extern int findPixelFormatOnDC(JNIEnv *env, HDC hdc, int origin_x, int origin_y, jobject pixel_format, jobject pixelFormatCaps, bool use_hdc_bpp, bool window, bool pbuffer, bool double_buffer, bool floating_point);
Modified: trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c
===================================================================
--- trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c 2008-04-07 09:23:27 UTC (rev 2972)
+++ trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c 2008-04-07 10:18:09 UTC (rev 2973)
@@ -178,13 +178,12 @@
return getAvailableDisplayModes(env);
}
-JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nCreateWindow(JNIEnv *env, jobject self, jobject mode, jboolean fullscreen, jint x, jint y) {
+JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nCreateWindow(JNIEnv *env, jobject self, jobject mode, jboolean fullscreen, jint x, jint y, jboolean undecorated, jlong parent_hwnd) {
jclass cls_displayMode = (*env)->GetObjectClass(env, mode);
jfieldID fid_width = (*env)->GetFieldID(env, cls_displayMode, "width", "I");
jfieldID fid_height = (*env)->GetFieldID(env, cls_displayMode, "height", "I");
int width = (*env)->GetIntField(env, mode, fid_width);
int height = (*env)->GetIntField(env, mode, fid_height);
- bool isUndecorated; // Whether we're undecorated or not
static bool oneShotInitialised = false;
if (!oneShotInitialised) {
if (!registerWindow(lwjglWindowProc, WINDOWCLASSNAME)) {
@@ -194,8 +193,7 @@
oneShotInitialised = true;
}
- isUndecorated = getBooleanProperty(env, "org.lwjgl.opengl.Window.undecorated");
- display_hwnd = createWindow(WINDOWCLASSNAME, x, y, width, height, fullscreen, isUndecorated);
+ display_hwnd = createWindow(WINDOWCLASSNAME, x, y, width, height, fullscreen, undecorated, (HWND)parent_hwnd);
if (display_hwnd == NULL) {
throwException(env, "Failed to create the window.");
return;
@@ -320,12 +318,12 @@
return result;
}
-JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nReshape(JNIEnv *env, jclass unused, jlong hwnd_ptr, jint x, jint y, jint width, jint height) {
+JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nReshape(JNIEnv *env, jclass unused, jlong hwnd_ptr, jint x, jint y, jint width, jint height, jboolean undecorated, jboolean child) {
HWND hwnd = (HWND)(INT_PTR)hwnd_ptr;
DWORD exstyle, windowflags;
RECT clientSize;
- getWindowFlags(&windowflags, &exstyle, false, getBooleanProperty(env, "org.lwjgl.opengl.Window.undecorated"));
+ getWindowFlags(&windowflags, &exstyle, false, undecorated, child);
// If we're not a fullscreen window, adjust the height to account for the
// height of the title bar:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <eli...@us...> - 2008-04-07 09:23:34
|
Revision: 2972
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=2972&view=rev
Author: elias_naur
Date: 2008-04-07 02:23:27 -0700 (Mon, 07 Apr 2008)
Log Message:
-----------
Linux: Use icon mask as monochrome to please some xorg versions
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java
trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2008-04-06 22:15:16 UTC (rev 2971)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2008-04-07 09:23:27 UTC (rev 2972)
@@ -997,10 +997,11 @@
throw new UnsupportedOperationException();
}
- private static void convertIcon(ByteBuffer icon, int width, int height, ByteBuffer icon_rgb, ByteBuffer icon_mask) {
- int x = 0;
- int y = 5;
- byte r,g,b,a;
+ private static ByteBuffer convertIcon(ByteBuffer icon, int width, int height) {
+ ByteBuffer icon_rgb = BufferUtils.createByteBuffer(icon.capacity());
+ int x;
+ int y;
+ byte r,g,b;
int depth = 4;
@@ -1009,18 +1010,38 @@
r = icon.get((x*4)+(y*width*4));
g = icon.get((x*4)+(y*width*4)+1);
b = icon.get((x*4)+(y*width*4)+2);
- a = icon.get((x*4)+(y*width*4)+3);
icon_rgb.put((x*depth)+(y*width*depth), b); // blue
icon_rgb.put((x*depth)+(y*width*depth)+1, g); // green
icon_rgb.put((x*depth)+(y*width*depth)+2, r);
- icon_mask.put((x*depth)+(y*width*depth), a);
- icon_mask.put((x*depth)+(y*width*depth)+1, a);
- icon_mask.put((x*depth)+(y*width*depth)+2, a);
}
}
+ return icon_rgb;
}
+ private static ByteBuffer convertIconMask(ByteBuffer icon, int width, int height) {
+ ByteBuffer icon_mask = BufferUtils.createByteBuffer((icon.capacity()/4)/8);
+ int x;
+ int y;
+ byte a;
+
+ int depth = 4;
+
+ for (y = 0; y < height; y++) {
+ for (x = 0; x < width; x++) {
+ a = icon.get((x*4)+(y*width*4)+3);
+
+ int mask_index = x + y*width;
+ int mask_byte_index = mask_index/8;
+ int mask_bit_index = mask_index%8;
+ byte bit = (((int)a) & 0xff) >= 127 ? (byte)1 : (byte)0;
+ byte new_byte = (byte)((icon_mask.get(mask_byte_index) | (bit<<mask_bit_index)) & 0xff);
+ icon_mask.put(mask_byte_index, new_byte);
+ }
+ }
+ return icon_mask;
+ }
+
/**
* Sets one or more icons for the Display.
* <ul>
@@ -1041,11 +1062,9 @@
for (int i=0;i<icons.length;i++) {
int size = icons[i].limit() / 4;
int dimension = (int)Math.sqrt(size);
- int cap = icons[i].capacity();
- ByteBuffer icon_rgb = BufferUtils.createByteBuffer(cap);
- ByteBuffer icon_mask = BufferUtils.createByteBuffer(cap);
- convertIcon(icons[i], dimension, dimension, icon_rgb, icon_mask);
- nSetWindowIcon(getDisplay(), getWindow(), icon_rgb, icon_mask, cap, dimension, dimension);
+ ByteBuffer icon_rgb = convertIcon(icons[i], dimension, dimension);
+ ByteBuffer icon_mask = convertIconMask(icons[i], dimension, dimension);
+ nSetWindowIcon(getDisplay(), getWindow(), icon_rgb, icon_rgb.capacity(), icon_mask, icon_mask.capacity(), dimension, dimension);
return 1;
}
return 0;
@@ -1060,7 +1079,7 @@
}
}
- private static native void nSetWindowIcon(long display, long window, ByteBuffer icon_rgb, ByteBuffer icon_mask, int icon_size, int width, int height);
+ private static native void nSetWindowIcon(long display, long window, ByteBuffer icon_rgb, int icon_rgb_size, ByteBuffer icon_mask, int icon_mask_size, int width, int height);
public int getWidth() {
return Display.getDisplayMode().getWidth();
Modified: trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c
===================================================================
--- trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c 2008-04-06 22:15:16 UTC (rev 2971)
+++ trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c 2008-04-07 09:23:27 UTC (rev 2972)
@@ -398,8 +398,8 @@
jawt.Unlock(env);
}
-static Pixmap createPixmapFromBuffer(JNIEnv *env, Display *disp, Window window, char *data, int data_size, int width, int height) {
- Pixmap pixmap = XCreatePixmap(disp, window, width, height, current_depth);
+static Pixmap createPixmapFromBuffer(JNIEnv *env, Display *disp, Window window, char *data, int data_size, int width, int height, int format, int depth) {
+ Pixmap pixmap = XCreatePixmap(disp, window, width, height, depth);
/* We need to copy the image data since XDestroyImage will also free its data buffer, which can't be allowed
* since the data buffer is managed by the jvm (it's the storage for the direct ByteBuffer)
*/
@@ -408,15 +408,15 @@
if (icon_copy == NULL) {
XFreePixmap(disp, pixmap);
throwException(env, "malloc failed");
- return 0;
+ return None;
}
memcpy(icon_copy, data, data_size);
- XImage *image = XCreateImage(disp, current_visual, current_depth, ZPixmap, 0, icon_copy, width, height, 32, 0);
+ XImage *image = XCreateImage(disp, current_visual, depth, format, 0, icon_copy, width, height, 32, 0);
if (image == NULL) {
XFreePixmap(disp, pixmap);
free(icon_copy);
throwException(env, "XCreateImage failed");
- return 0;
+ return None;
}
GC gc = XCreateGC(disp, pixmap, 0, NULL);
@@ -427,12 +427,12 @@
return pixmap;
}
-static void setIcon(JNIEnv *env, Display *disp, Window window, char *rgb_data, char *mask_data, int icon_size, int width, int height) {
+static void setIcon(JNIEnv *env, Display *disp, Window window, char *rgb_data, int rgb_size, char *mask_data, int mask_size, int width, int height) {
freeIconPixmap(disp);
- current_icon_pixmap = createPixmapFromBuffer(env, disp, window, rgb_data, icon_size, width, height);
+ current_icon_pixmap = createPixmapFromBuffer(env, disp, window, rgb_data, rgb_size, width, height, ZPixmap, current_depth);
if ((*env)->ExceptionCheck(env))
return;
- current_icon_mask_pixmap = createPixmapFromBuffer(env, disp, window, mask_data, icon_size, width, height);
+ current_icon_mask_pixmap = createPixmapFromBuffer(env, disp, window, mask_data, mask_size, width, height, XYPixmap, 1);
if ((*env)->ExceptionCheck(env)) {
freeIconPixmap(disp);
return;
@@ -442,14 +442,14 @@
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetWindowIcon
- (JNIEnv *env, jclass clazz, jlong display, jlong window_ptr, jobject icon_rgb_buffer, jobject icon_mask_buffer, jint icon_size, jint width, jint height)
+ (JNIEnv *env, jclass clazz, jlong display, jlong window_ptr, jobject icon_rgb_buffer, jint rgb_size, jobject icon_mask_buffer, jint mask_size, jint width, jint height)
{
Display *disp = (Display *)(intptr_t)display;
Window window = (Window)window_ptr;
char *rgb_data= (char *)(*env)->GetDirectBufferAddress(env, icon_rgb_buffer);
char *mask_data= (char *)(*env)->GetDirectBufferAddress(env, icon_mask_buffer);
- setIcon(env, disp, window, rgb_data, mask_data, icon_size, width, height);
+ setIcon(env, disp, window, rgb_data, rgb_size, mask_data, mask_size, width, height);
}
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nUngrabKeyboard(JNIEnv *env, jclass unused, jlong display_ptr) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2008-04-06 22:15:20
|
Revision: 2971
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=2971&view=rev
Author: matzon
Date: 2008-04-06 15:15:16 -0700 (Sun, 06 Apr 2008)
Log Message:
-----------
fixed issue with prematurely interrupting the inputstream getter thread\nmade secondary check for inputstream null
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java
Modified: trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2008-04-06 21:34:22 UTC (rev 2970)
+++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2008-04-06 22:15:16 UTC (rev 2971)
@@ -732,7 +732,7 @@
t.start();
int iterationCount = 0;
- while(is == null && iterationCount++ < 5) {
+ while(is[0] == null && iterationCount++ < 5) {
try {
t.join(1000);
} catch (InterruptedException inte) {
@@ -740,12 +740,14 @@
}
}
- try {
- t.interrupt();
- t.join();
- } catch (InterruptedException inte) {
- /* ignored */
- }
+ if(is[0] == null) {
+ try {
+ t.interrupt();
+ t.join();
+ } catch (InterruptedException inte) {
+ /* ignored */
+ }
+ }
}
if(is[0] == null) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <eli...@us...> - 2008-04-06 21:34:32
|
Revision: 2970
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=2970&view=rev
Author: elias_naur
Date: 2008-04-06 14:34:22 -0700 (Sun, 06 Apr 2008)
Log Message:
-----------
Linux: Attempt to avoid race condition when tracking Display parent focus
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java
trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2008-04-06 20:56:52 UTC (rev 2969)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2008-04-06 21:34:22 UTC (rev 2970)
@@ -623,8 +623,6 @@
private native static void setInputFocus(long display, long window);
private void processEvents() {
- if (!focused && parent != null && parent.isFocusOwner())
- setInputFocus(getDisplay(), getWindow());
while (LinuxEvent.getPending(getDisplay()) > 0) {
event_buffer.nextEvent(getDisplay());
long event_window = event_buffer.getWindow();
@@ -742,15 +740,30 @@
}
private void checkInput() {
- focused = nGetInputFocus(getDisplay()) == getWindow();
+ long current_focus = nGetInputFocus(getDisplay());
+ focused = current_focus == getWindow();
if (focused) {
focused_at_least_once = true;
acquireInput();
- } else if (focused_at_least_once) {
- releaseInput();
+ } else {
+ if (focused_at_least_once)
+ releaseInput();
+ if (parent != null && parent.isFocusOwner()) {
+ // Normally, a real time stamp from an event should be passed to XSetInputFocus instead of CurrentTime, but we don't get timestamps
+ // from awt. Instead we grab the server and check if the focus changed to avoid a race where our window is made unviewable while focusing it.
+ grabServer(getDisplay());
+ try {
+ if (nGetInputFocus(getDisplay()) == current_focus)
+ setInputFocus(getDisplay(), getWindow());
+ } finally {
+ ungrabServer(getDisplay());
+ }
+ }
}
}
static native long nGetInputFocus(long display);
+ private static native void grabServer(long display);
+ private static native void ungrabServer(long display);
private void releaseInput() {
if (isLegacyFullscreen() || input_released)
Modified: trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c
===================================================================
--- trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c 2008-04-06 20:56:52 UTC (rev 2969)
+++ trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c 2008-04-06 21:34:22 UTC (rev 2970)
@@ -327,14 +327,20 @@
return win;
}
+JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_grabServer(JNIEnv *env, jclass unused, jlong display) {
+ Display *disp = (Display *)(intptr_t)display;
+ XGrabServer(disp);
+}
+
+JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_ungrabServer(JNIEnv *env, jclass unused, jlong display) {
+ Display *disp = (Display *)(intptr_t)display;
+ XUngrabServer(disp);
+}
+
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_setInputFocus(JNIEnv *env, jclass clazz, jlong display, jlong window_ptr) {
Display *disp = (Display *)(intptr_t)display;
Window window = (Window)window_ptr;
- // Normally, a real time stamp from an event should be passed instead of CurrentTime, but we don't get timestamps
- // from awt. Instead we grab the server before and ungrab it after the request
- XGrabServer(disp);
XSetInputFocus(disp, window, RevertToParent, CurrentTime);
- XUngrabServer(disp);
}
JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nCreateWindow(JNIEnv *env, jclass clazz, jlong display, jint screen, jobject peer_info_handle, jobject mode, jint window_mode, jint x, jint y, jboolean undecorated, jlong parent_handle) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <eli...@us...> - 2008-04-06 20:56:54
|
Revision: 2969
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=2969&view=rev
Author: elias_naur
Date: 2008-04-06 13:56:52 -0700 (Sun, 06 Apr 2008)
Log Message:
-----------
Added experimental Display.setParent to allow Display to be embedded in an AWT Canvas. Added basic linux implementation and test.
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/opengl/AWTCanvasImplementation.java
trunk/LWJGL/src/java/org/lwjgl/opengl/AWTSurfaceLock.java
trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java
trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java
trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxAWTGLCanvasPeerInfo.java
trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxCanvasImplementation.java
trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java
trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXAWTGLCanvasPeerInfo.java
trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasImplementation.java
trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasPeerInfo.java
trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java
trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsAWTGLCanvasPeerInfo.java
trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsCanvasImplementation.java
trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java
trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c
Added Paths:
-----------
trunk/LWJGL/src/java/org/lwjgl/test/opengl/awt/DisplayParentTest.java
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/AWTCanvasImplementation.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/AWTCanvasImplementation.java 2008-04-06 14:39:32 UTC (rev 2968)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/AWTCanvasImplementation.java 2008-04-06 20:56:52 UTC (rev 2969)
@@ -33,7 +33,7 @@
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
-import java.awt.Component;
+import java.awt.Canvas;
import org.lwjgl.LWJGLException;
@@ -47,7 +47,7 @@
/**
* Return an opaque handle to the canvas peer information required to create a context from it.
*/
- PeerInfo createPeerInfo(Component component, PixelFormat pixel_format) throws LWJGLException;
+ PeerInfo createPeerInfo(Canvas component, PixelFormat pixel_format) throws LWJGLException;
/**
* Find a proper GraphicsConfiguration from the given GraphicsDevice and PixelFormat.
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/AWTSurfaceLock.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/AWTSurfaceLock.java 2008-04-06 14:39:32 UTC (rev 2968)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/AWTSurfaceLock.java 2008-04-06 20:56:52 UTC (rev 2969)
@@ -31,7 +31,7 @@
*/
package org.lwjgl.opengl;
-import java.awt.Component;
+import java.awt.Canvas;
import java.nio.ByteBuffer;
import java.security.AccessController;
import java.security.PrivilegedActionException;
@@ -60,7 +60,7 @@
private static native ByteBuffer createHandle();
- public ByteBuffer lockAndGetHandle(Component component) throws LWJGLException {
+ public ByteBuffer lockAndGetHandle(Canvas component) throws LWJGLException {
while (!privilegedLockAndInitHandle(component)) {
LWJGLUtil.log("Could not get drawing surface info, retrying...");
try {
@@ -73,12 +73,12 @@
return lock_buffer;
}
- private boolean privilegedLockAndInitHandle(final Component component) throws LWJGLException {
+ private boolean privilegedLockAndInitHandle(final Canvas component) throws LWJGLException {
// Workaround for Sun JDK bug 4796548 which still exists in java for OS X
// We need to elevate privileges because of an AWT bug. Please see
// http://192.18.37.44/forums/index.php?topic=10572 for a discussion.
// It is only needed on first call, so we avoid it on all subsequent calls
- // due to performance.
+ // due to performance.
if (firstLockSucceeded)
return lockAndInitHandle(lock_buffer, component);
else
@@ -96,7 +96,7 @@
}
}
- private static native boolean lockAndInitHandle(ByteBuffer lock_buffer, Component component) throws LWJGLException;
+ private static native boolean lockAndInitHandle(ByteBuffer lock_buffer, Canvas component) throws LWJGLException;
protected void unlock() throws LWJGLException {
nUnlock(lock_buffer);
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2008-04-06 14:39:32 UTC (rev 2968)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2008-04-06 20:56:52 UTC (rev 2969)
@@ -49,6 +49,7 @@
import java.security.PrivilegedAction;
import java.util.Arrays;
import java.util.HashSet;
+import java.awt.Canvas;
import org.lwjgl.BufferUtils;
import org.lwjgl.LWJGLException;
@@ -71,6 +72,9 @@
/** The initial display mode */
private static final DisplayMode initial_mode;
+ /** The parent, if any */
+ private static Canvas parent;
+
/** The current display mode, if created */
private static DisplayMode current_mode;
@@ -244,7 +248,7 @@
}
int window_x;
int window_y;
- if (!fullscreen) {
+ if (!fullscreen && parent == null) {
// if no display location set, center window
if (x == -1 && y == -1) {
window_x = Math.max(0, (initial_mode.getWidth() - current_mode.getWidth()) / 2);
@@ -257,7 +261,10 @@
window_x = 0;
window_y = 0;
}
- display_impl.createWindow(current_mode, fullscreen, window_x, window_y);
+ Canvas tmp_parent = fullscreen ? null : parent;
+ if (tmp_parent != null && !tmp_parent.isDisplayable()) // Only a best effort check, since the parent can turn undisplayable hereafter
+ throw new LWJGLException("Parent.isDisplayable() must be true");
+ display_impl.createWindow(current_mode, fullscreen, tmp_parent, window_x, window_y);
window_created = true;
setTitle(title);
@@ -465,6 +472,50 @@
}
/**
+ * Return the last parent set with setParent().
+ */
+ public static Canvas getParent() {
+ synchronized (GlobalLock.lock) {
+ return parent;
+ }
+ }
+
+ /**
+ * Set the parent of the Display. If parent is null, the Display will appear as a top level window.
+ * If parent is not null, the Display is made a child of the parent. A parent's isDisplayable() must be true when
+ * setParent() is called and remain true until setParent() is called again with
+ * null or a different parent. This generally means that the parent component must remain added to it's parent container.<p>
+ * It is not advisable to call this method from an AWT thread, since the context will be made current on the thread
+ * and it is difficult to predict which AWT thread will process any given AWT event.<p>
+ * If the Display is in fullscreen mode, the current parent will be ignored.
+ *
+ */
+ public static void setParent(Canvas parent) throws LWJGLException {
+ synchronized (GlobalLock.lock) {
+ if (Display.parent != parent) {
+ Display.parent = parent;
+ if (!isCreated())
+ return;
+ destroyWindow();
+ try {
+ if (fullscreen) {
+ switchDisplayMode();
+ } else {
+ display_impl.resetDisplayMode();
+ }
+ createWindow();
+ makeCurrentAndSetSwapInterval();
+ } catch (LWJGLException e) {
+ destroyContext();
+ destroyPeerInfo();
+ display_impl.resetDisplayMode();
+ throw e;
+ }
+ }
+ }
+ }
+
+ /**
* Set the fullscreen mode of the context. If no context has been created through create(),
* the mode will apply when create() is called. If fullscreen is true, the context will become
* a fullscreen context and the display mode is switched to the mode given by getDisplayMode(). If
@@ -914,7 +965,7 @@
}
/**
- * Set the window's location. This is a no-op on fullscreen windows.
+ * Set the window's location. This is a no-op on fullscreen windows or when getParent() != null.
* The window is clamped to remain entirely on the screen. If you attempt
* to position the window such that it would extend off the screen, the window
* is simply placed as close to the edge as possible.
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java 2008-04-06 14:39:32 UTC (rev 2968)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java 2008-04-06 20:56:52 UTC (rev 2969)
@@ -41,12 +41,13 @@
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
+import java.awt.Canvas;
import org.lwjgl.LWJGLException;
interface DisplayImplementation extends InputImplementation {
- void createWindow(DisplayMode mode, boolean fullscreen, int x, int y) throws LWJGLException;
+ void createWindow(DisplayMode mode, boolean fullscreen, Canvas parent, int x, int y) throws LWJGLException;
void destroyWindow();
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxAWTGLCanvasPeerInfo.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxAWTGLCanvasPeerInfo.java 2008-04-06 14:39:32 UTC (rev 2968)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxAWTGLCanvasPeerInfo.java 2008-04-06 20:56:52 UTC (rev 2969)
@@ -35,7 +35,7 @@
import org.lwjgl.LWJGLException;
import org.lwjgl.LWJGLUtil;
-import java.awt.Component;
+import java.awt.Canvas;
/**
*
@@ -44,11 +44,11 @@
* $Id$
*/
final class LinuxAWTGLCanvasPeerInfo extends LinuxPeerInfo {
- private final Component component;
+ private final Canvas component;
private final AWTSurfaceLock awt_surface = new AWTSurfaceLock();
private int screen = -1;
- public LinuxAWTGLCanvasPeerInfo(Component component) {
+ public LinuxAWTGLCanvasPeerInfo(Canvas component) {
this.component = component;
}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxCanvasImplementation.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxCanvasImplementation.java 2008-04-06 14:39:32 UTC (rev 2968)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxCanvasImplementation.java 2008-04-06 20:56:52 UTC (rev 2969)
@@ -33,7 +33,7 @@
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
-import java.awt.Component;
+import java.awt.Canvas;
import java.lang.reflect.Method;
import java.security.AccessController;
import java.security.PrivilegedExceptionAction;
@@ -76,7 +76,7 @@
}
}
- public PeerInfo createPeerInfo(Component component, PixelFormat pixel_format) throws LWJGLException {
+ public PeerInfo createPeerInfo(Canvas component, PixelFormat pixel_format) throws LWJGLException {
return new LinuxAWTGLCanvasPeerInfo(component);
}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2008-04-06 14:39:32 UTC (rev 2968)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2008-04-06 20:56:52 UTC (rev 2969)
@@ -42,6 +42,8 @@
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
+import java.awt.Canvas;
+
import org.lwjgl.BufferUtils;
import org.lwjgl.LWJGLException;
import org.lwjgl.LWJGLUtil;
@@ -103,6 +105,7 @@
private boolean focused_at_least_once;
private long current_cursor;
private long blank_cursor;
+ private Canvas parent;
private LinuxKeyboard keyboard;
private LinuxMouse mouse;
@@ -357,7 +360,7 @@
ungrabKeyboard();
}
- public void createWindow(DisplayMode mode, boolean fullscreen, int x, int y) throws LWJGLException {
+ public void createWindow(DisplayMode mode, boolean fullscreen, Canvas parent, int x, int y) throws LWJGLException {
lockAWT();
try {
incDisplay();
@@ -365,7 +368,10 @@
ByteBuffer handle = peer_info.lockAndGetHandle();
try {
current_window_mode = getWindowMode(fullscreen);
- current_window = nCreateWindow(getDisplay(), getDefaultScreen(), handle, mode, current_window_mode, x, y);
+ boolean undecorated = Display.getPrivilegedBoolean("org.lwjgl.opengl.Window.undecorated") || current_window_mode != WINDOWED;
+ this.parent = parent;
+ long parent_window = parent != null ? getHandle(parent) : getRootWindow(getDisplay(), getDefaultScreen());
+ current_window = nCreateWindow(getDisplay(), getDefaultScreen(), handle, mode, current_window_mode, x, y, undecorated, parent_window);
blank_cursor = createBlankCursor();
current_cursor = None;
focused = true;
@@ -388,8 +394,20 @@
unlockAWT();
}
}
- private static native long nCreateWindow(long display, int screen, ByteBuffer peer_info_handle, DisplayMode mode, int window_mode, int x, int y) throws LWJGLException;
+ private static native long nCreateWindow(long display, int screen, ByteBuffer peer_info_handle, DisplayMode mode, int window_mode, int x, int y, boolean undecorated, long parent_handle) throws LWJGLException;
+ private static native long getRootWindow(long display, int screen);
+ private static long getHandle(Canvas parent) throws LWJGLException {
+ AWTCanvasImplementation awt_impl = AWTGLCanvas.createImplementation();
+ LinuxPeerInfo parent_peer_info = (LinuxPeerInfo)awt_impl.createPeerInfo(parent, null);
+ ByteBuffer parent_peer_info_handle = parent_peer_info.lockAndGetHandle();
+ try {
+ return parent_peer_info.getDrawable();
+ } finally {
+ parent_peer_info.unlock();
+ }
+ }
+
private void updateInputGrab() {
updatePointerGrab();
updateKeyboardGrab();
@@ -602,7 +620,11 @@
return peer_info;
}
+ private native static void setInputFocus(long display, long window);
+
private void processEvents() {
+ if (!focused && parent != null && parent.isFocusOwner())
+ setInputFocus(getDisplay(), getWindow());
while (LinuxEvent.getPending(getDisplay()) > 0) {
event_buffer.nextEvent(getDisplay());
long event_window = event_buffer.getWindow();
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXAWTGLCanvasPeerInfo.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXAWTGLCanvasPeerInfo.java 2008-04-06 14:39:32 UTC (rev 2968)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXAWTGLCanvasPeerInfo.java 2008-04-06 20:56:52 UTC (rev 2969)
@@ -33,7 +33,7 @@
import org.lwjgl.LWJGLException;
-import java.awt.Component;
+import java.awt.Canvas;
/**
*
@@ -42,9 +42,9 @@
* $Id$
*/
final class MacOSXAWTGLCanvasPeerInfo extends MacOSXCanvasPeerInfo {
- private final Component component;
+ private final Canvas component;
- public MacOSXAWTGLCanvasPeerInfo(Component component, PixelFormat pixel_format, boolean support_pbuffer) throws LWJGLException {
+ public MacOSXAWTGLCanvasPeerInfo(Canvas component, PixelFormat pixel_format, boolean support_pbuffer) throws LWJGLException {
super(pixel_format, support_pbuffer);
this.component = component;
}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasImplementation.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasImplementation.java 2008-04-06 14:39:32 UTC (rev 2968)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasImplementation.java 2008-04-06 20:56:52 UTC (rev 2969)
@@ -33,7 +33,7 @@
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
-import java.awt.Component;
+import java.awt.Canvas;
import org.lwjgl.LWJGLException;
@@ -44,7 +44,7 @@
* $Id$
*/
final class MacOSXCanvasImplementation implements AWTCanvasImplementation {
- public PeerInfo createPeerInfo(Component component, PixelFormat pixel_format) throws LWJGLException {
+ public PeerInfo createPeerInfo(Canvas component, PixelFormat pixel_format) throws LWJGLException {
try {
return new MacOSXAWTGLCanvasPeerInfo(component, pixel_format, true);
} catch (LWJGLException e) {
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasPeerInfo.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasPeerInfo.java 2008-04-06 14:39:32 UTC (rev 2968)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasPeerInfo.java 2008-04-06 20:56:52 UTC (rev 2969)
@@ -31,7 +31,7 @@
*/
package org.lwjgl.opengl;
-import java.awt.Component;
+import java.awt.Canvas;
import java.nio.ByteBuffer;
import org.lwjgl.LWJGLException;
@@ -49,7 +49,7 @@
super(pixel_format, true, true, support_pbuffer, true);
}
- protected void initHandle(Component component) throws LWJGLException {
+ protected void initHandle(Canvas component) throws LWJGLException {
nInitHandle(awt_surface.lockAndGetHandle(component), getHandle());
}
private static native void nInitHandle(ByteBuffer surface_buffer, ByteBuffer peer_info_handle) throws LWJGLException;
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2008-04-06 14:39:32 UTC (rev 2968)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2008-04-06 20:56:52 UTC (rev 2969)
@@ -39,6 +39,7 @@
*/
import java.awt.Cursor;
+import java.awt.Canvas;
import java.awt.Robot;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
@@ -73,7 +74,7 @@
new MacOSXApplicationListener();
}
- public void createWindow(DisplayMode mode, boolean fullscreen, int x, int y) throws LWJGLException {
+ public void createWindow(DisplayMode mode, boolean fullscreen, Canvas parent, int x, int y) throws LWJGLException {
hideUI(fullscreen);
close_requested = false;
try {
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsAWTGLCanvasPeerInfo.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsAWTGLCanvasPeerInfo.java 2008-04-06 14:39:32 UTC (rev 2968)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsAWTGLCanvasPeerInfo.java 2008-04-06 20:56:52 UTC (rev 2969)
@@ -35,7 +35,7 @@
import org.lwjgl.LWJGLException;
-import java.awt.Component;
+import java.awt.Canvas;
/**
*
@@ -44,12 +44,12 @@
* $Id$
*/
final class WindowsAWTGLCanvasPeerInfo extends WindowsPeerInfo {
- private final Component component;
+ private final Canvas component;
private final AWTSurfaceLock awt_surface = new AWTSurfaceLock();
private final PixelFormat pixel_format;
private boolean has_pixel_format= false;
- public WindowsAWTGLCanvasPeerInfo(Component component, PixelFormat pixel_format) {
+ public WindowsAWTGLCanvasPeerInfo(Canvas component, PixelFormat pixel_format) {
this.component = component;
this.pixel_format = pixel_format;
}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsCanvasImplementation.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsCanvasImplementation.java 2008-04-06 14:39:32 UTC (rev 2968)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsCanvasImplementation.java 2008-04-06 20:56:52 UTC (rev 2969)
@@ -34,7 +34,7 @@
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.Toolkit;
-import java.awt.Component;
+import java.awt.Canvas;
import java.security.PrivilegedAction;
import java.security.AccessController;
@@ -70,7 +70,7 @@
return new WindowsAWTInput(canvas);
}
- public PeerInfo createPeerInfo(Component component, PixelFormat pixel_format) throws LWJGLException {
+ public PeerInfo createPeerInfo(Canvas component, PixelFormat pixel_format) throws LWJGLException {
return new WindowsAWTGLCanvasPeerInfo(component, pixel_format);
}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2008-04-06 14:39:32 UTC (rev 2968)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2008-04-06 20:56:52 UTC (rev 2969)
@@ -41,6 +41,7 @@
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
+import java.awt.Canvas;
import org.lwjgl.LWJGLException;
import org.lwjgl.LWJGLUtil;
@@ -139,7 +140,7 @@
current_display = this;
}
- public void createWindow(DisplayMode mode, boolean fullscreen, int x, int y) throws LWJGLException {
+ public void createWindow(DisplayMode mode, boolean fullscreen, Canvas container, int x, int y) throws LWJGLException {
close_requested = false;
is_dirty = false;
isFullscreen = fullscreen;
Copied: trunk/LWJGL/src/java/org/lwjgl/test/opengl/awt/DisplayParentTest.java (from rev 2967, trunk/LWJGL/src/java/org/lwjgl/test/opengl/awt/AWTTest.java)
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/test/opengl/awt/DisplayParentTest.java (rev 0)
+++ trunk/LWJGL/src/java/org/lwjgl/test/opengl/awt/DisplayParentTest.java 2008-04-06 20:56:52 UTC (rev 2969)
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) 2002-2005 LWJGL Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of 'LWJGL' nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.lwjgl.test.opengl.awt;
+
+import java.awt.Frame;
+import java.awt.Graphics;
+import java.awt.GridLayout;
+import java.awt.Container;
+import java.awt.Component;
+import java.awt.Canvas;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+
+import org.lwjgl.LWJGLException;
+import org.lwjgl.opengl.AWTGLCanvas;
+import org.lwjgl.opengl.GL11;
+import org.lwjgl.input.Keyboard;
+import org.lwjgl.input.Mouse;
+import org.lwjgl.util.glu.GLU;
+import org.lwjgl.opengl.Display;
+import org.lwjgl.opengl.DisplayMode;
+
+/**
+ * <p>
+ * Tests Display.setParent()
+ * <p>
+ * @version $Revision$
+ * @author $Author$
+ * $Id$
+ */
+public class DisplayParentTest extends Frame {
+ public DisplayParentTest() throws LWJGLException {
+ setTitle("LWJGL Display Parent Test");
+ setSize(640, 320);
+ setLayout(new GridLayout(1, 2));
+ final Canvas display_parent = new Canvas();
+ display_parent.setFocusable(true);
+ add(display_parent);
+ addWindowListener(new WindowAdapter() {
+ public void windowClosing(WindowEvent e) {
+ dispose();
+ }
+ });
+ setResizable(true);
+ setVisible(true);
+ Display.setParent(display_parent);
+ Display.create();
+ float angle = 0f;
+
+ int current_height = 0;
+ int current_width = 0;
+ while (isVisible()) {
+ angle += 1.0f;
+ if (getWidth() != current_width || getHeight() != current_height) {
+ current_width = getWidth();
+ current_height = getHeight();
+ Display.setDisplayMode(new DisplayMode(getWidth(), getHeight()));
+ GL11.glViewport(0, 0, current_width, current_height);
+ }
+ GL11.glViewport(0, 0, getWidth(), getHeight());
+ GL11.glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
+ GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
+ GL11.glMatrixMode(GL11.GL_PROJECTION);
+ GL11.glLoadIdentity();
+ GLU.gluOrtho2D(0.0f, (float) getWidth(), 0.0f, (float) getHeight());
+ GL11.glMatrixMode(GL11.GL_MODELVIEW);
+ GL11.glPushMatrix();
+ GL11.glTranslatef(getWidth() / 2.0f, getHeight() / 2.0f, 0.0f);
+ GL11.glRotatef(2*angle, 0f, 0f, -1.0f);
+ GL11.glRectf(-50.0f, -50.0f, 50.0f, 50.0f);
+ GL11.glPopMatrix();
+ Display.update();
+ while(Keyboard.next()) {
+ // closing on ESCAPE
+ if(Keyboard.getEventKey() == Keyboard.KEY_ESCAPE && Keyboard.getEventKeyState()) {
+ dispose();
+ }
+
+ if(Keyboard.getEventKey() == Keyboard.KEY_SPACE && Keyboard.getEventKeyState()) {
+ Mouse.setGrabbed(!Mouse.isGrabbed());
+ }
+ }
+/* while (Mouse.next()) {
+System.out.println(" Mouse.getEventX() = " + Mouse.getEventX() + " | Mouse.getEventY() = " + Mouse.getEventY());
+ }*/
+ }
+ System.exit(0);
+ }
+
+ public static void main(String[] args) throws LWJGLException {
+ new DisplayParentTest();
+ }
+}
Modified: trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c
===================================================================
--- trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c 2008-04-06 14:39:32 UTC (rev 2968)
+++ trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c 2008-04-06 20:56:52 UTC (rev 2969)
@@ -242,18 +242,44 @@
XMoveWindow(disp, window, x, y);
}
-static Window createWindow(JNIEnv* env, Display *disp, int screen, jint window_mode, X11PeerInfo *peer_info, int x, int y, int width, int height) {
- bool undecorated = getBooleanProperty(env, "org.lwjgl.opengl.Window.undecorated");
- Window root_win;
+JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_getRootWindow(JNIEnv *env, jclass clazz, jlong display, jint screen) {
+ Display *disp = (Display *)(intptr_t)display;
+ return RootWindow(disp, screen);
+}
+
+static void updateWindowHints(JNIEnv *env, Display *disp, Window window) {
+ XWMHints* win_hints = XAllocWMHints();
+ if (win_hints == NULL) {
+ throwException(env, "XAllocWMHints failed");
+ return;
+ }
+
+ win_hints->flags = InputHint;
+ win_hints->input = True;
+ if (current_icon_pixmap != 0) {
+ win_hints->flags |= IconPixmapHint;
+ win_hints->icon_pixmap = current_icon_pixmap;
+ }
+ if (current_icon_mask_pixmap != 0) {
+ win_hints->flags |= IconMaskHint;
+ win_hints->icon_mask = current_icon_mask_pixmap;
+ }
+
+ XSetWMHints(disp, window, win_hints);
+ XFree(win_hints);
+ XFlush(disp);
+}
+
+static Window createWindow(JNIEnv* env, Display *disp, int screen, jint window_mode, X11PeerInfo *peer_info, int x, int y, int width, int height, jboolean undecorated, long parent_handle) {
+ Window parent = (Window)parent_handle;
Window win;
XSetWindowAttributes attribs;
int attribmask;
- root_win = RootWindow(disp, screen);
XVisualInfo *vis_info = getVisualInfoFromPeerInfo(env, peer_info);
if (vis_info == NULL)
return false;
- cmap = XCreateColormap(disp, root_win, vis_info->visual, AllocNone);
+ cmap = XCreateColormap(disp, parent, vis_info->visual, AllocNone);
attribs.colormap = cmap;
attribs.event_mask = ExposureMask | /*FocusChangeMask | */VisibilityChangeMask | StructureNotifyMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask;
attribmask = CWColormap | CWEventMask;
@@ -261,7 +287,7 @@
attribmask |= CWOverrideRedirect;
attribs.override_redirect = True;
}
- win = XCreateWindow(disp, root_win, x, y, width, height, 0, vis_info->depth, InputOutput, vis_info->visual, attribmask, &attribs);
+ win = XCreateWindow(disp, parent, x, y, width, height, 0, vis_info->depth, InputOutput, vis_info->visual, attribmask, &attribs);
current_depth = vis_info->depth;
current_visual = vis_info->visual;
@@ -271,8 +297,8 @@
XFreeColormap(disp, cmap);
return false;
}
- printfDebugJava(env, "Created window");
- if (window_mode != org_lwjgl_opengl_LinuxDisplay_WINDOWED || undecorated) {
+// printfDebugJava(env, "Created window");
+ if (undecorated) {
// Use Motif decoration hint property and hope the window manager respects them
setDecorations(disp, win, 0);
}
@@ -283,9 +309,11 @@
size_hints->min_height = height;
size_hints->max_height = height;
XSetWMNormalHints(disp, win, size_hints);
+ updateWindowHints(env, disp, win);
XFree(size_hints);
- Atom delete_atom = XInternAtom(disp, "WM_DELETE_WINDOW", False);
- XSetWMProtocols(disp, win, &delete_atom, 1);
+#define NUM_ATOMS 1
+ Atom protocol_atoms[NUM_ATOMS] = {XInternAtom(disp, "WM_DELETE_WINDOW", False)/*, XInternAtom(disp, "WM_TAKE_FOCUS", False)*/};
+ XSetWMProtocols(disp, win, protocol_atoms, NUM_ATOMS);
if (window_mode == org_lwjgl_opengl_LinuxDisplay_FULLSCREEN_NETWM) {
Atom fullscreen_atom = XInternAtom(disp, "_NET_WM_STATE_FULLSCREEN", False);
XChangeProperty(disp, win, XInternAtom(disp, "_NET_WM_STATE", False),
@@ -299,8 +327,18 @@
return win;
}
-JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nCreateWindow(JNIEnv *env, jclass clazz, jlong display, jint screen, jobject peer_info_handle, jobject mode, jint window_mode, jint x, jint y) {
+JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_setInputFocus(JNIEnv *env, jclass clazz, jlong display, jlong window_ptr) {
Display *disp = (Display *)(intptr_t)display;
+ Window window = (Window)window_ptr;
+ // Normally, a real time stamp from an event should be passed instead of CurrentTime, but we don't get timestamps
+ // from awt. Instead we grab the server before and ungrab it after the request
+ XGrabServer(disp);
+ XSetInputFocus(disp, window, RevertToParent, CurrentTime);
+ XUngrabServer(disp);
+}
+
+JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nCreateWindow(JNIEnv *env, jclass clazz, jlong display, jint screen, jobject peer_info_handle, jobject mode, jint window_mode, jint x, jint y, jboolean undecorated, jlong parent_handle) {
+ Display *disp = (Display *)(intptr_t)display;
X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle);
GLXFBConfig *fb_config = NULL;
if (peer_info->glx13) {
@@ -313,7 +351,7 @@
jfieldID fid_height = (*env)->GetFieldID(env, cls_displayMode, "height", "I");
int width = (*env)->GetIntField(env, mode, fid_width);
int height = (*env)->GetIntField(env, mode, fid_height);
- Window win = createWindow(env, disp, screen, window_mode, peer_info, x, y, width, height);
+ Window win = createWindow(env, disp, screen, window_mode, peer_info, x, y, width, height, undecorated, parent_handle);
if ((*env)->ExceptionOccurred(env)) {
return 0;
}
@@ -384,7 +422,6 @@
}
static void setIcon(JNIEnv *env, Display *disp, Window window, char *rgb_data, char *mask_data, int icon_size, int width, int height) {
- XWMHints* win_hints;
freeIconPixmap(disp);
current_icon_pixmap = createPixmapFromBuffer(env, disp, window, rgb_data, icon_size, width, height);
if ((*env)->ExceptionCheck(env))
@@ -395,19 +432,7 @@
return;
}
- win_hints = XAllocWMHints();
- if (win_hints == NULL) {
- throwException(env, "XAllocWMHints failed");
- return;
- }
-
- win_hints->flags = IconPixmapHint | IconMaskHint;
- win_hints->icon_pixmap = current_icon_pixmap;
- win_hints->icon_mask = current_icon_mask_pixmap;
-
- XSetWMHints(disp, window, win_hints);
- XFree(win_hints);
- XFlush(disp);
+ updateWindowHints(env, disp, window);
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetWindowIcon
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <eli...@us...> - 2008-04-06 14:39:35
|
Revision: 2968
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=2968&view=rev
Author: elias_naur
Date: 2008-04-06 07:39:32 -0700 (Sun, 06 Apr 2008)
Log Message:
-----------
Let otherwise generic AWT utilities classes take a Component instead of the more specific AWTGLCanvas
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/opengl/AWTCanvasImplementation.java
trunk/LWJGL/src/java/org/lwjgl/opengl/AWTGLCanvas.java
trunk/LWJGL/src/java/org/lwjgl/opengl/AWTSurfaceLock.java
trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxAWTGLCanvasPeerInfo.java
trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxCanvasImplementation.java
trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXAWTGLCanvasPeerInfo.java
trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasImplementation.java
trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasPeerInfo.java
trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsAWTGLCanvasPeerInfo.java
trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsCanvasImplementation.java
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/AWTCanvasImplementation.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/AWTCanvasImplementation.java 2008-04-01 20:45:24 UTC (rev 2967)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/AWTCanvasImplementation.java 2008-04-06 14:39:32 UTC (rev 2968)
@@ -33,6 +33,7 @@
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
+import java.awt.Component;
import org.lwjgl.LWJGLException;
@@ -46,7 +47,7 @@
/**
* Return an opaque handle to the canvas peer information required to create a context from it.
*/
- PeerInfo createPeerInfo(AWTGLCanvas canvas, PixelFormat pixel_format) throws LWJGLException;
+ PeerInfo createPeerInfo(Component component, PixelFormat pixel_format) throws LWJGLException;
/**
* Find a proper GraphicsConfiguration from the given GraphicsDevice and PixelFormat.
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/AWTGLCanvas.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/AWTGLCanvas.java 2008-04-01 20:45:24 UTC (rev 2967)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/AWTGLCanvas.java 2008-04-06 14:39:32 UTC (rev 2968)
@@ -89,7 +89,7 @@
implementation = createImplementation();
}
- private static AWTCanvasImplementation createImplementation() {
+ static AWTCanvasImplementation createImplementation() {
switch (LWJGLUtil.getPlatform()) {
case LWJGLUtil.PLATFORM_LINUX:
return new LinuxCanvasImplementation();
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/AWTSurfaceLock.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/AWTSurfaceLock.java 2008-04-01 20:45:24 UTC (rev 2967)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/AWTSurfaceLock.java 2008-04-06 14:39:32 UTC (rev 2968)
@@ -31,7 +31,7 @@
*/
package org.lwjgl.opengl;
-import java.awt.Canvas;
+import java.awt.Component;
import java.nio.ByteBuffer;
import java.security.AccessController;
import java.security.PrivilegedActionException;
@@ -60,8 +60,8 @@
private static native ByteBuffer createHandle();
- public ByteBuffer lockAndGetHandle(Canvas canvas) throws LWJGLException {
- while (!privilegedLockAndInitHandle(canvas)) {
+ public ByteBuffer lockAndGetHandle(Component component) throws LWJGLException {
+ while (!privilegedLockAndInitHandle(component)) {
LWJGLUtil.log("Could not get drawing surface info, retrying...");
try {
Thread.sleep(WAIT_DELAY_MILLIS);
@@ -73,20 +73,20 @@
return lock_buffer;
}
- private boolean privilegedLockAndInitHandle(final Canvas canvas) throws LWJGLException {
+ private boolean privilegedLockAndInitHandle(final Component component) throws LWJGLException {
// Workaround for Sun JDK bug 4796548 which still exists in java for OS X
// We need to elevate privileges because of an AWT bug. Please see
// http://192.18.37.44/forums/index.php?topic=10572 for a discussion.
// It is only needed on first call, so we avoid it on all subsequent calls
// due to performance.
if (firstLockSucceeded)
- return lockAndInitHandle(lock_buffer, canvas);
+ return lockAndInitHandle(lock_buffer, component);
else
try {
final Object result = AccessController.doPrivileged(new PrivilegedExceptionAction() {
public Object run() throws LWJGLException {
- return Boolean.valueOf(lockAndInitHandle(lock_buffer, canvas));
+ return Boolean.valueOf(lockAndInitHandle(lock_buffer, component));
}
});
firstLockSucceeded = ((Boolean) result).booleanValue();
@@ -96,7 +96,7 @@
}
}
- private static native boolean lockAndInitHandle(ByteBuffer lock_buffer, Canvas canvas) throws LWJGLException;
+ private static native boolean lockAndInitHandle(ByteBuffer lock_buffer, Component component) throws LWJGLException;
protected void unlock() throws LWJGLException {
nUnlock(lock_buffer);
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxAWTGLCanvasPeerInfo.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxAWTGLCanvasPeerInfo.java 2008-04-01 20:45:24 UTC (rev 2967)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxAWTGLCanvasPeerInfo.java 2008-04-06 14:39:32 UTC (rev 2968)
@@ -35,6 +35,7 @@
import org.lwjgl.LWJGLException;
import org.lwjgl.LWJGLUtil;
+import java.awt.Component;
/**
*
@@ -43,16 +44,16 @@
* $Id$
*/
final class LinuxAWTGLCanvasPeerInfo extends LinuxPeerInfo {
- private final AWTGLCanvas canvas;
+ private final Component component;
private final AWTSurfaceLock awt_surface = new AWTSurfaceLock();
private int screen = -1;
- public LinuxAWTGLCanvasPeerInfo(AWTGLCanvas canvas) {
- this.canvas = canvas;
+ public LinuxAWTGLCanvasPeerInfo(Component component) {
+ this.component = component;
}
protected void doLockAndInitHandle() throws LWJGLException {
- ByteBuffer surface_handle = awt_surface.lockAndGetHandle(canvas);
+ ByteBuffer surface_handle = awt_surface.lockAndGetHandle(component);
if (screen == -1) {
try {
screen = getScreenFromSurfaceInfo(surface_handle);
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxCanvasImplementation.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxCanvasImplementation.java 2008-04-01 20:45:24 UTC (rev 2967)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxCanvasImplementation.java 2008-04-06 14:39:32 UTC (rev 2968)
@@ -33,6 +33,7 @@
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
+import java.awt.Component;
import java.lang.reflect.Method;
import java.security.AccessController;
import java.security.PrivilegedExceptionAction;
@@ -75,8 +76,8 @@
}
}
- public PeerInfo createPeerInfo(AWTGLCanvas canvas, PixelFormat pixel_format) throws LWJGLException {
- return new LinuxAWTGLCanvasPeerInfo(canvas);
+ public PeerInfo createPeerInfo(Component component, PixelFormat pixel_format) throws LWJGLException {
+ return new LinuxAWTGLCanvasPeerInfo(component);
}
/**
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXAWTGLCanvasPeerInfo.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXAWTGLCanvasPeerInfo.java 2008-04-01 20:45:24 UTC (rev 2967)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXAWTGLCanvasPeerInfo.java 2008-04-06 14:39:32 UTC (rev 2968)
@@ -33,6 +33,8 @@
import org.lwjgl.LWJGLException;
+import java.awt.Component;
+
/**
*
* @author elias_naur <eli...@us...>
@@ -40,14 +42,14 @@
* $Id$
*/
final class MacOSXAWTGLCanvasPeerInfo extends MacOSXCanvasPeerInfo {
- private final AWTGLCanvas canvas;
+ private final Component component;
- public MacOSXAWTGLCanvasPeerInfo(AWTGLCanvas canvas, PixelFormat pixel_format, boolean support_pbuffer) throws LWJGLException {
+ public MacOSXAWTGLCanvasPeerInfo(Component component, PixelFormat pixel_format, boolean support_pbuffer) throws LWJGLException {
super(pixel_format, support_pbuffer);
- this.canvas = canvas;
+ this.component = component;
}
protected void doLockAndInitHandle() throws LWJGLException {
- initHandle(canvas);
+ initHandle(component);
}
}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasImplementation.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasImplementation.java 2008-04-01 20:45:24 UTC (rev 2967)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasImplementation.java 2008-04-06 14:39:32 UTC (rev 2968)
@@ -33,6 +33,7 @@
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
+import java.awt.Component;
import org.lwjgl.LWJGLException;
@@ -43,11 +44,11 @@
* $Id$
*/
final class MacOSXCanvasImplementation implements AWTCanvasImplementation {
- public PeerInfo createPeerInfo(AWTGLCanvas canvas, PixelFormat pixel_format) throws LWJGLException {
+ public PeerInfo createPeerInfo(Component component, PixelFormat pixel_format) throws LWJGLException {
try {
- return new MacOSXAWTGLCanvasPeerInfo(canvas, pixel_format, true);
+ return new MacOSXAWTGLCanvasPeerInfo(component, pixel_format, true);
} catch (LWJGLException e) {
- return new MacOSXAWTGLCanvasPeerInfo(canvas, pixel_format, false);
+ return new MacOSXAWTGLCanvasPeerInfo(component, pixel_format, false);
}
}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasPeerInfo.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasPeerInfo.java 2008-04-01 20:45:24 UTC (rev 2967)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasPeerInfo.java 2008-04-06 14:39:32 UTC (rev 2968)
@@ -31,7 +31,7 @@
*/
package org.lwjgl.opengl;
-import java.awt.Canvas;
+import java.awt.Component;
import java.nio.ByteBuffer;
import org.lwjgl.LWJGLException;
@@ -49,8 +49,8 @@
super(pixel_format, true, true, support_pbuffer, true);
}
- protected void initHandle(Canvas canvas) throws LWJGLException {
- nInitHandle(awt_surface.lockAndGetHandle(canvas), getHandle());
+ protected void initHandle(Component component) throws LWJGLException {
+ nInitHandle(awt_surface.lockAndGetHandle(component), getHandle());
}
private static native void nInitHandle(ByteBuffer surface_buffer, ByteBuffer peer_info_handle) throws LWJGLException;
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsAWTGLCanvasPeerInfo.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsAWTGLCanvasPeerInfo.java 2008-04-01 20:45:24 UTC (rev 2967)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsAWTGLCanvasPeerInfo.java 2008-04-06 14:39:32 UTC (rev 2968)
@@ -35,6 +35,8 @@
import org.lwjgl.LWJGLException;
+import java.awt.Component;
+
/**
*
* @author elias_naur <eli...@us...>
@@ -42,21 +44,21 @@
* $Id$
*/
final class WindowsAWTGLCanvasPeerInfo extends WindowsPeerInfo {
- private final AWTGLCanvas canvas;
+ private final Component component;
private final AWTSurfaceLock awt_surface = new AWTSurfaceLock();
private final PixelFormat pixel_format;
private boolean has_pixel_format= false;
- public WindowsAWTGLCanvasPeerInfo(AWTGLCanvas canvas, PixelFormat pixel_format) {
- this.canvas = canvas;
+ public WindowsAWTGLCanvasPeerInfo(Component component, PixelFormat pixel_format) {
+ this.component = component;
this.pixel_format = pixel_format;
}
protected void doLockAndInitHandle() throws LWJGLException {
- nInitHandle(awt_surface.lockAndGetHandle(canvas), getHandle());
- if (!has_pixel_format) {
+ nInitHandle(awt_surface.lockAndGetHandle(component), getHandle());
+ if (!has_pixel_format && pixel_format != null) {
// If we haven't applied a pixel format yet, do it now
- choosePixelFormat(canvas.getX(), canvas.getY(), pixel_format, null, true, true, false, true);
+ choosePixelFormat(component.getX(), component.getY(), pixel_format, null, true, true, false, true);
has_pixel_format = true;
}
}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsCanvasImplementation.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsCanvasImplementation.java 2008-04-01 20:45:24 UTC (rev 2967)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsCanvasImplementation.java 2008-04-06 14:39:32 UTC (rev 2968)
@@ -34,6 +34,7 @@
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.Toolkit;
+import java.awt.Component;
import java.security.PrivilegedAction;
import java.security.AccessController;
@@ -69,8 +70,8 @@
return new WindowsAWTInput(canvas);
}
- public PeerInfo createPeerInfo(AWTGLCanvas canvas, PixelFormat pixel_format) throws LWJGLException {
- return new WindowsAWTGLCanvasPeerInfo(canvas, pixel_format);
+ public PeerInfo createPeerInfo(Component component, PixelFormat pixel_format) throws LWJGLException {
+ return new WindowsAWTGLCanvasPeerInfo(component, pixel_format);
}
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: Navarro <Bet...@PO...> - 2008-04-06 13:11:43
|
Get ready for your new career on Wall Street. http://www.pojerrant.com/ |
|
From: fabrice <fab...@Kl...> - 2008-04-05 08:11:39
|
Get all your branded goods needs here, with more than 70 top brands http://www.loniermain.com/ |
|
From: beatrice F. <gni...@De...> - 2008-04-03 11:15:45
|
Top notch fashion pieces for sale here Cool to have these without burning a hole in my pocket. http://www.muehsoie.com/ |
|
From: Janos m. <Jan...@HE...> - 2008-04-02 00:05:24
|
Give her blast of her life You can see instant growth results after only one month http://www.burinmipo.com/ |
|
From: <eli...@us...> - 2008-04-01 20:45:26
|
Revision: 2967
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=2967&view=rev
Author: elias_naur
Date: 2008-04-01 13:45:24 -0700 (Tue, 01 Apr 2008)
Log Message:
-----------
Windows: Moved Display.setIcon logic to java
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java
trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2008-04-01 19:46:20 UTC (rev 2966)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2008-04-01 20:45:24 UTC (rev 2967)
@@ -550,31 +550,33 @@
* @return number of icons used.
*/
public int setIcon(ByteBuffer[] icons) {
- boolean done16 = false;
- boolean done32 = false;
+ boolean done_small = false;
+ boolean done_large = false;
int used = 0;
+ int small_icon_size = 16;
+ int large_icon_size = 32;
for (int i=0;i<icons.length;i++) {
int size = icons[i].limit() / 4;
- if ((((int) Math.sqrt(size)) == 16) && (!done16)) {
- nSetWindowIcon16(icons[i].asIntBuffer());
+ if ((((int) Math.sqrt(size)) == small_icon_size) && (!done_small)) {
+ nSetWindowIconSmall(small_icon_size, small_icon_size, icons[i].asIntBuffer());
used++;
- done16 = true;
+ done_small = true;
}
- if ((((int) Math.sqrt(size)) == 32) && (!done32)) {
- nSetWindowIcon32(icons[i].asIntBuffer());
+ if ((((int) Math.sqrt(size)) == large_icon_size) && (!done_large)) {
+ nSetWindowIconLarge(large_icon_size, large_icon_size, icons[i].asIntBuffer());
used++;
- done32 = true;
+ done_large = true;
}
}
return used;
}
- private static native int nSetWindowIcon16(IntBuffer icon);
+ private static native int nSetWindowIconSmall(int width, int height, IntBuffer icon);
- private static native int nSetWindowIcon32(IntBuffer icon);
+ private static native int nSetWindowIconLarge(int width, int height, IntBuffer icon);
private void handleMouseButton(int button, int state, long millis) {
if (mouse != null)
Modified: trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c
===================================================================
--- trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c 2008-04-01 19:46:20 UTC (rev 2966)
+++ trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c 2008-04-01 20:45:24 UTC (rev 2967)
@@ -462,13 +462,13 @@
return icon;
}
-JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nSetWindowIcon16
- (JNIEnv *env, jclass clazz, jobject iconBuffer)
+JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nSetWindowIconSmall
+ (JNIEnv *env, jclass clazz, jint width, jint height, jobject iconBuffer)
{
jint *imgData = (jint *)(*env)->GetDirectBufferAddress(env, iconBuffer);
freeSmallIcon();
- small_icon = createWindowIcon(env, imgData, 16, 16);
+ small_icon = createWindowIcon(env, imgData, width, height);
if (small_icon != NULL) {
if (display_hwnd != NULL) {
SendMessage(display_hwnd, WM_SETICON, ICON_SMALL, (LPARAM) (small_icon));
@@ -480,13 +480,13 @@
return -1;
}
-JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nSetWindowIcon32
- (JNIEnv *env, jclass clazz, jobject iconBuffer)
+JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nSetWindowIconLarge
+ (JNIEnv *env, jclass clazz, jint width, jint height, jobject iconBuffer)
{
jint *imgData = (jint *)(*env)->GetDirectBufferAddress(env, iconBuffer);
freeLargeIcon();
- large_icon = createWindowIcon(env, imgData, 32, 32);
+ large_icon = createWindowIcon(env, imgData, width, height);
if (large_icon != NULL) {
if (display_hwnd != NULL) {
SendMessage(display_hwnd, WM_SETICON, ICON_BIG, (LPARAM) (large_icon));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <eli...@us...> - 2008-04-01 19:46:29
|
Revision: 2966
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=2966&view=rev
Author: elias_naur
Date: 2008-04-01 12:46:20 -0700 (Tue, 01 Apr 2008)
Log Message:
-----------
Linux: Added alpha mask support to Display.setIcon
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java
trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2008-03-23 15:51:10 UTC (rev 2965)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2008-04-01 19:46:20 UTC (rev 2966)
@@ -962,8 +962,7 @@
throw new UnsupportedOperationException();
}
- private static ByteBuffer convertIcon(ByteBuffer icon, int width, int height) {
- ByteBuffer icon_copy = BufferUtils.createByteBuffer(icon.capacity());
+ private static void convertIcon(ByteBuffer icon, int width, int height, ByteBuffer icon_rgb, ByteBuffer icon_mask) {
int x = 0;
int y = 5;
byte r,g,b,a;
@@ -977,13 +976,14 @@
b = icon.get((x*4)+(y*width*4)+2);
a = icon.get((x*4)+(y*width*4)+3);
- icon_copy.put((x*depth)+(y*width*depth), b); // blue
- icon_copy.put((x*depth)+(y*width*depth)+1, g); // green
- icon_copy.put((x*depth)+(y*width*depth)+2, r);
- icon_copy.put((x*depth)+(y*width*depth)+3, a);
+ icon_rgb.put((x*depth)+(y*width*depth), b); // blue
+ icon_rgb.put((x*depth)+(y*width*depth)+1, g); // green
+ icon_rgb.put((x*depth)+(y*width*depth)+2, r);
+ icon_mask.put((x*depth)+(y*width*depth), a);
+ icon_mask.put((x*depth)+(y*width*depth)+1, a);
+ icon_mask.put((x*depth)+(y*width*depth)+2, a);
}
}
- return icon_copy;
}
/**
@@ -1006,8 +1006,11 @@
for (int i=0;i<icons.length;i++) {
int size = icons[i].limit() / 4;
int dimension = (int)Math.sqrt(size);
- ByteBuffer icon = convertIcon(icons[i], dimension, dimension);
- nSetWindowIcon(getDisplay(), getWindow(), icon, icon.capacity(), dimension, dimension);
+ int cap = icons[i].capacity();
+ ByteBuffer icon_rgb = BufferUtils.createByteBuffer(cap);
+ ByteBuffer icon_mask = BufferUtils.createByteBuffer(cap);
+ convertIcon(icons[i], dimension, dimension, icon_rgb, icon_mask);
+ nSetWindowIcon(getDisplay(), getWindow(), icon_rgb, icon_mask, cap, dimension, dimension);
return 1;
}
return 0;
@@ -1022,7 +1025,7 @@
}
}
- private static native void nSetWindowIcon(long display, long window, ByteBuffer icon, int icons_size, int width, int height);
+ private static native void nSetWindowIcon(long display, long window, ByteBuffer icon_rgb, ByteBuffer icon_mask, int icon_size, int width, int height);
public int getWidth() {
return Display.getDisplayMode().getWidth();
Modified: trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c
===================================================================
--- trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c 2008-03-23 15:51:10 UTC (rev 2965)
+++ trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c 2008-04-01 19:46:20 UTC (rev 2966)
@@ -72,6 +72,7 @@
static Colormap cmap;
static int current_depth;
static Pixmap current_icon_pixmap;
+static Pixmap current_icon_mask_pixmap;
static Visual *current_visual;
@@ -185,6 +186,10 @@
}
static void freeIconPixmap(Display *disp) {
+ if (current_icon_mask_pixmap != 0) {
+ XFreePixmap(disp, current_icon_mask_pixmap);
+ current_icon_mask_pixmap = 0;
+ }
if (current_icon_pixmap != 0) {
XFreePixmap(disp, current_icon_pixmap);
current_icon_pixmap = 0;
@@ -349,33 +354,46 @@
jawt.Unlock(env);
}
-static void setIcon(JNIEnv *env, Display *disp, Window window, char *data, int icon_size, int width,int height) {
- XWMHints* win_hints;
- freeIconPixmap(disp);
- current_icon_pixmap = XCreatePixmap(disp, window, width, height, current_depth);
+static Pixmap createPixmapFromBuffer(JNIEnv *env, Display *disp, Window window, char *data, int data_size, int width, int height) {
+ Pixmap pixmap = XCreatePixmap(disp, window, width, height, current_depth);
/* We need to copy the image data since XDestroyImage will also free its data buffer, which can't be allowed
* since the data buffer is managed by the jvm (it's the storage for the direct ByteBuffer)
*/
- char *icon_copy = (char *)malloc(sizeof(*icon_copy)*icon_size);
+ char *icon_copy = (char *)malloc(sizeof(*icon_copy)*data_size);
if (icon_copy == NULL) {
+ XFreePixmap(disp, pixmap);
throwException(env, "malloc failed");
- return;
+ return 0;
}
- memcpy(icon_copy, data, icon_size);
+ memcpy(icon_copy, data, data_size);
XImage *image = XCreateImage(disp, current_visual, current_depth, ZPixmap, 0, icon_copy, width, height, 32, 0);
if (image == NULL) {
- freeIconPixmap(disp);
+ XFreePixmap(disp, pixmap);
free(icon_copy);
throwException(env, "XCreateImage failed");
- return;
+ return 0;
}
- GC gc = XCreateGC(disp, current_icon_pixmap, 0, NULL);
- XPutImage(disp, current_icon_pixmap, gc, image, 0, 0, 0, 0, width, height);
+ GC gc = XCreateGC(disp, pixmap, 0, NULL);
+ XPutImage(disp, pixmap, gc, image, 0, 0, 0, 0, width, height);
XFreeGC(disp, gc);
XDestroyImage(image);
// We won't free icon_copy because it is freed by XDestroyImage
+ return pixmap;
+}
+
+static void setIcon(JNIEnv *env, Display *disp, Window window, char *rgb_data, char *mask_data, int icon_size, int width, int height) {
+ XWMHints* win_hints;
+ freeIconPixmap(disp);
+ current_icon_pixmap = createPixmapFromBuffer(env, disp, window, rgb_data, icon_size, width, height);
+ if ((*env)->ExceptionCheck(env))
+ return;
+ current_icon_mask_pixmap = createPixmapFromBuffer(env, disp, window, mask_data, icon_size, width, height);
+ if ((*env)->ExceptionCheck(env)) {
+ freeIconPixmap(disp);
+ return;
+ }
win_hints = XAllocWMHints();
if (win_hints == NULL) {
@@ -383,8 +401,9 @@
return;
}
- win_hints->flags = IconPixmapHint;
+ win_hints->flags = IconPixmapHint | IconMaskHint;
win_hints->icon_pixmap = current_icon_pixmap;
+ win_hints->icon_mask = current_icon_mask_pixmap;
XSetWMHints(disp, window, win_hints);
XFree(win_hints);
@@ -392,13 +411,14 @@
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetWindowIcon
- (JNIEnv *env, jclass clazz, jlong display, jlong window_ptr, jobject iconBuffer, jint icon_size, jint width, jint height)
+ (JNIEnv *env, jclass clazz, jlong display, jlong window_ptr, jobject icon_rgb_buffer, jobject icon_mask_buffer, jint icon_size, jint width, jint height)
{
Display *disp = (Display *)(intptr_t)display;
Window window = (Window)window_ptr;
- char *imgData = (char *)(*env)->GetDirectBufferAddress(env, iconBuffer);
+ char *rgb_data= (char *)(*env)->GetDirectBufferAddress(env, icon_rgb_buffer);
+ char *mask_data= (char *)(*env)->GetDirectBufferAddress(env, icon_mask_buffer);
- setIcon(env, disp, window, imgData, icon_size, width, height);
+ setIcon(env, disp, window, rgb_data, mask_data, icon_size, width, height);
}
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nUngrabKeyboard(JNIEnv *env, jclass unused, jlong display_ptr) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: maiko M. <suk...@GO...> - 2008-03-30 21:16:44
|
No good lovemaking, no problem Make the decision that will change your life forever. http://www.wetinger.com/ |
|
From: jonghan H. <jon...@PU...> - 2008-03-30 10:30:25
|
Touch her like never before Buy now, limited time offer only for newly launched wonderdrug http://www.bolleai.com/ |
|
From: Niki c. <Nik...@GR...> - 2008-03-29 16:54:04
|
Pacify her with this Attain levels of excitement you have never reached before, click here http://www.palanct.com/ |
|
From: richelle n. <ric...@24...> - 2008-03-28 11:46:37
|
Proven to add inches http://www.jackispade.com/ Elizabeth kept riding me the whole night long, and coming over and over again. |
|
From: parimal H. <par...@Eb...> - 2008-03-27 09:54:45
|
She just keep asking for more and more and more http://www.crumeurs.com/ Pocket Rocket in Your Pants |
|
From: fayez F. <fay...@al...> - 2008-03-26 11:52:33
|
The joys of lovemaking await you when you click here http://www.volxwherego.com/ Re: I am sorry I banged her |
|
From: Taam H. <sel...@HI...> - 2008-03-23 17:17:46
|
Renew and invigorate your sex life with our certified male enlargement supplement. http://www.arhkrusk.com/ Gorgeous breasts and lips |
|
From: <eli...@us...> - 2008-03-23 15:51:11
|
Revision: 2965
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=2965&view=rev
Author: elias_naur
Date: 2008-03-23 08:51:10 -0700 (Sun, 23 Mar 2008)
Log Message:
-----------
Removed 2D OpenGL initialization code from Display. It messes with the implicit, but well-defined, opengl default state and doesn't fit well with multiple context types (gl3 and d3d)
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2008-03-02 18:16:39 UTC (rev 2964)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2008-03-23 15:51:10 UTC (rev 2965)
@@ -782,14 +782,6 @@
}
private static void initContext() {
- // Put the window into orthographic projection mode with 1:1 pixel ratio.
- // We haven't used GLU here to do this to avoid an unnecessary dependency.
- GL11.glMatrixMode(GL11.GL_PROJECTION);
- GL11.glLoadIdentity();
- GL11.glOrtho(0.0, current_mode.getWidth(), 0.0, current_mode.getHeight(), -1.0, 1.0);
- GL11.glMatrixMode(GL11.GL_MODELVIEW);
- GL11.glLoadIdentity();
- GL11.glViewport(0, 0, current_mode.getWidth(), current_mode.getHeight());
// Clear window to avoid the desktop "showing through"
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
update();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: London S. <hie...@10...> - 2008-03-21 16:54:32
|
Elizabeth loves it now that Im nine inches and can penetrate her so deeply. http://www.lapeusete.com/ Cutest exotic asian celeb |