aboutsummaryrefslogtreecommitdiffstats
path: root/src/classes
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2009-01-05 21:45:45 +0000
committerKenneth Russel <[email protected]>2009-01-05 21:45:45 +0000
commit8d38222fc13c1e3f42ee0c0afb193e517749e94e (patch)
tree14f09bdf37173b6063622c5c44f1f5162795fd8c /src/classes
parent5234bcafd962ac17c56162473acd72e0804911fa (diff)
Native (non-AWT) port of Newt to Mac OS X using Cocoa. Most
functionality (mouse click, mouse motion, mouse dragging, keyboard events) appears to be working. Currently works with the Apple JRE and requires the JVM command-line arguments -XstartOnFirstThread and -Djava.awt.headless=true . Will work with the standalone SoyLatte JRE pending additional launcher changes. Tested with Angeles demo and various JavaFX demos. Added -Dnewt.ws.name=AWT option to force the use of the AWT port of Newt on any supported platform. Known bugs: - While resizing a window or dropping down a menu, the application will hang. This is due to how the event processing is currently done in Newt (via Window.dispatchMessages()) and how Mac OS X deals with resize operations (by pushing a nested event loop into which we have no visibility). There are at least a couple of solutions. One would be to preserve the current API semantics but use a Newt Launcher class to move main() on to a different thread, saving the primordial thread for [NSApplication run]. Another would be to move Newt (and, by association, the JavaFX runtime code) to a callback model like GLUT. - Command-Q and the Quit menu option do not yet properly exit the application. - The coordinates for the WINDOW_MOVED event are wrong. Added the rest of the VK_ constants to the KeyEvent class. Made preliminary changes to support the SoyLatte JRE. Worked around initialization order issues with Fmod. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JOGL_2_SANDBOX@1838 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/classes')
-rw-r--r--src/classes/com/sun/javafx/newt/KeyEvent.java460
-rwxr-xr-xsrc/classes/com/sun/javafx/newt/NewtFactory.java18
-rwxr-xr-xsrc/classes/com/sun/javafx/newt/Window.java16
-rw-r--r--src/classes/com/sun/javafx/newt/awt/AWTWindow.java5
-rwxr-xr-xsrc/classes/com/sun/javafx/newt/macosx/MacWindow.java296
-rwxr-xr-xsrc/classes/com/sun/opengl/util/texture/TextureIO.java.javase4
-rw-r--r--src/classes/javax/media/opengl/GLDrawableFactory.java3
7 files changed, 759 insertions, 43 deletions
diff --git a/src/classes/com/sun/javafx/newt/KeyEvent.java b/src/classes/com/sun/javafx/newt/KeyEvent.java
index 92366bc93..b2ab58cba 100644
--- a/src/classes/com/sun/javafx/newt/KeyEvent.java
+++ b/src/classes/com/sun/javafx/newt/KeyEvent.java
@@ -140,24 +140,147 @@ public class KeyEvent extends InputEvent
/**
* Constant for the non-numpad <b>left</b> arrow key.
+ * @see #VK_KP_LEFT
*/
public static final int VK_LEFT = 0x25;
/**
* Constant for the non-numpad <b>up</b> arrow key.
+ * @see #VK_KP_UP
*/
public static final int VK_UP = 0x26;
/**
* Constant for the non-numpad <b>right</b> arrow key.
+ * @see #VK_KP_RIGHT
*/
public static final int VK_RIGHT = 0x27;
/**
* Constant for the non-numpad <b>down</b> arrow key.
+ * @see #VK_KP_DOWN
*/
public static final int VK_DOWN = 0x28;
+ /**
+ * Constant for the comma key, ","
+ */
+ public static final int VK_COMMA = 0x2C;
+
+ /**
+ * Constant for the minus key, "-"
+ * @since 1.2
+ */
+ public static final int VK_MINUS = 0x2D;
+
+ /**
+ * Constant for the period key, "."
+ */
+ public static final int VK_PERIOD = 0x2E;
+
+ /**
+ * Constant for the forward slash key, "/"
+ */
+ public static final int VK_SLASH = 0x2F;
+
+ /** VK_0 thru VK_9 are the same as ASCII '0' thru '9' (0x30 - 0x39) */
+ public static final int VK_0 = 0x30;
+ public static final int VK_1 = 0x31;
+ public static final int VK_2 = 0x32;
+ public static final int VK_3 = 0x33;
+ public static final int VK_4 = 0x34;
+ public static final int VK_5 = 0x35;
+ public static final int VK_6 = 0x36;
+ public static final int VK_7 = 0x37;
+ public static final int VK_8 = 0x38;
+ public static final int VK_9 = 0x39;
+
+ /**
+ * Constant for the semicolon key, ";"
+ */
+ public static final int VK_SEMICOLON = 0x3B;
+
+ /**
+ * Constant for the equals key, "="
+ */
+ public static final int VK_EQUALS = 0x3D;
+
+ /** VK_A thru VK_Z are the same as ASCII 'A' thru 'Z' (0x41 - 0x5A) */
+ public static final int VK_A = 0x41;
+ public static final int VK_B = 0x42;
+ public static final int VK_C = 0x43;
+ public static final int VK_D = 0x44;
+ public static final int VK_E = 0x45;
+ public static final int VK_F = 0x46;
+ public static final int VK_G = 0x47;
+ public static final int VK_H = 0x48;
+ public static final int VK_I = 0x49;
+ public static final int VK_J = 0x4A;
+ public static final int VK_K = 0x4B;
+ public static final int VK_L = 0x4C;
+ public static final int VK_M = 0x4D;
+ public static final int VK_N = 0x4E;
+ public static final int VK_O = 0x4F;
+ public static final int VK_P = 0x50;
+ public static final int VK_Q = 0x51;
+ public static final int VK_R = 0x52;
+ public static final int VK_S = 0x53;
+ public static final int VK_T = 0x54;
+ public static final int VK_U = 0x55;
+ public static final int VK_V = 0x56;
+ public static final int VK_W = 0x57;
+ public static final int VK_X = 0x58;
+ public static final int VK_Y = 0x59;
+ public static final int VK_Z = 0x5A;
+
+ /**
+ * Constant for the open bracket key, "["
+ */
+ public static final int VK_OPEN_BRACKET = 0x5B;
+
+ /**
+ * Constant for the back slash key, "\"
+ */
+ public static final int VK_BACK_SLASH = 0x5C;
+
+ /**
+ * Constant for the close bracket key, "]"
+ */
+ public static final int VK_CLOSE_BRACKET = 0x5D;
+
+ public static final int VK_NUMPAD0 = 0x60;
+ public static final int VK_NUMPAD1 = 0x61;
+ public static final int VK_NUMPAD2 = 0x62;
+ public static final int VK_NUMPAD3 = 0x63;
+ public static final int VK_NUMPAD4 = 0x64;
+ public static final int VK_NUMPAD5 = 0x65;
+ public static final int VK_NUMPAD6 = 0x66;
+ public static final int VK_NUMPAD7 = 0x67;
+ public static final int VK_NUMPAD8 = 0x68;
+ public static final int VK_NUMPAD9 = 0x69;
+ public static final int VK_MULTIPLY = 0x6A;
+ public static final int VK_ADD = 0x6B;
+
+ /**
+ * This constant is obsolete, and is included only for backwards
+ * compatibility.
+ * @see #VK_SEPARATOR
+ */
+ public static final int VK_SEPARATER = 0x6C;
+
+ /**
+ * Constant for the Numpad Separator key.
+ * @since 1.4
+ */
+ public static final int VK_SEPARATOR = VK_SEPARATER;
+
+ public static final int VK_SUBTRACT = 0x6D;
+ public static final int VK_DECIMAL = 0x6E;
+ public static final int VK_DIVIDE = 0x6F;
+ public static final int VK_DELETE = 0x7F; /* ASCII DEL */
+ public static final int VK_NUM_LOCK = 0x90;
+ public static final int VK_SCROLL_LOCK = 0x91;
+
/** Constant for the F1 function key. */
public static final int VK_F1 = 0x70;
@@ -275,6 +398,341 @@ public class KeyEvent extends InputEvent
public static final int VK_BACK_QUOTE = 0xC0;
public static final int VK_QUOTE = 0xDE;
- public static final int VK_WINDOWS = 0x020C;
+ /**
+ * Constant for the numeric keypad <b>up</b> arrow key.
+ * @see #VK_UP
+ * @since 1.2
+ */
+ public static final int VK_KP_UP = 0xE0;
+
+ /**
+ * Constant for the numeric keypad <b>down</b> arrow key.
+ * @see #VK_DOWN
+ * @since 1.2
+ */
+ public static final int VK_KP_DOWN = 0xE1;
+
+ /**
+ * Constant for the numeric keypad <b>left</b> arrow key.
+ * @see #VK_LEFT
+ * @since 1.2
+ */
+ public static final int VK_KP_LEFT = 0xE2;
+
+ /**
+ * Constant for the numeric keypad <b>right</b> arrow key.
+ * @see #VK_RIGHT
+ * @since 1.2
+ */
+ public static final int VK_KP_RIGHT = 0xE3;
+
+ /* For European keyboards */
+ /** @since 1.2 */
+ public static final int VK_DEAD_GRAVE = 0x80;
+ /** @since 1.2 */
+ public static final int VK_DEAD_ACUTE = 0x81;
+ /** @since 1.2 */
+ public static final int VK_DEAD_CIRCUMFLEX = 0x82;
+ /** @since 1.2 */
+ public static final int VK_DEAD_TILDE = 0x83;
+ /** @since 1.2 */
+ public static final int VK_DEAD_MACRON = 0x84;
+ /** @since 1.2 */
+ public static final int VK_DEAD_BREVE = 0x85;
+ /** @since 1.2 */
+ public static final int VK_DEAD_ABOVEDOT = 0x86;
+ /** @since 1.2 */
+ public static final int VK_DEAD_DIAERESIS = 0x87;
+ /** @since 1.2 */
+ public static final int VK_DEAD_ABOVERING = 0x88;
+ /** @since 1.2 */
+ public static final int VK_DEAD_DOUBLEACUTE = 0x89;
+ /** @since 1.2 */
+ public static final int VK_DEAD_CARON = 0x8a;
+ /** @since 1.2 */
+ public static final int VK_DEAD_CEDILLA = 0x8b;
+ /** @since 1.2 */
+ public static final int VK_DEAD_OGONEK = 0x8c;
+ /** @since 1.2 */
+ public static final int VK_DEAD_IOTA = 0x8d;
+ /** @since 1.2 */
+ public static final int VK_DEAD_VOICED_SOUND = 0x8e;
+ /** @since 1.2 */
+ public static final int VK_DEAD_SEMIVOICED_SOUND = 0x8f;
+
+ /** @since 1.2 */
+ public static final int VK_AMPERSAND = 0x96;
+ /** @since 1.2 */
+ public static final int VK_ASTERISK = 0x97;
+ /** @since 1.2 */
+ public static final int VK_QUOTEDBL = 0x98;
+ /** @since 1.2 */
+ public static final int VK_LESS = 0x99;
+
+ /** @since 1.2 */
+ public static final int VK_GREATER = 0xa0;
+ /** @since 1.2 */
+ public static final int VK_BRACELEFT = 0xa1;
+ /** @since 1.2 */
+ public static final int VK_BRACERIGHT = 0xa2;
+
+ /**
+ * Constant for the "@" key.
+ * @since 1.2
+ */
+ public static final int VK_AT = 0x0200;
+
+ /**
+ * Constant for the ":" key.
+ * @since 1.2
+ */
+ public static final int VK_COLON = 0x0201;
+
+ /**
+ * Constant for the "^" key.
+ * @since 1.2
+ */
+ public static final int VK_CIRCUMFLEX = 0x0202;
+
+ /**
+ * Constant for the "$" key.
+ * @since 1.2
+ */
+ public static final int VK_DOLLAR = 0x0203;
+
+ /**
+ * Constant for the Euro currency sign key.
+ * @since 1.2
+ */
+ public static final int VK_EURO_SIGN = 0x0204;
+
+ /**
+ * Constant for the "!" key.
+ * @since 1.2
+ */
+ public static final int VK_EXCLAMATION_MARK = 0x0205;
+
+ /**
+ * Constant for the inverted exclamation mark key.
+ * @since 1.2
+ */
+ public static final int VK_INVERTED_EXCLAMATION_MARK = 0x0206;
+
+ /**
+ * Constant for the "(" key.
+ * @since 1.2
+ */
+ public static final int VK_LEFT_PARENTHESIS = 0x0207;
+
+ /**
+ * Constant for the "#" key.
+ * @since 1.2
+ */
+ public static final int VK_NUMBER_SIGN = 0x0208;
+
+ /**
+ * Constant for the "+" key.
+ * @since 1.2
+ */
+ public static final int VK_PLUS = 0x0209;
+
+ /**
+ * Constant for the ")" key.
+ * @since 1.2
+ */
+ public static final int VK_RIGHT_PARENTHESIS = 0x020A;
+
+ /**
+ * Constant for the "_" key.
+ * @since 1.2
+ */
+ public static final int VK_UNDERSCORE = 0x020B;
+
+ /**
+ * Constant for the Microsoft Windows "Windows" key.
+ * It is used for both the left and right version of the key.
+ * @see #getKeyLocation()
+ * @since 1.5
+ */
+ public static final int VK_WINDOWS = 0x020C;
+
+ /**
+ * Constant for the Microsoft Windows Context Menu key.
+ * @since 1.5
+ */
+ public static final int VK_CONTEXT_MENU = 0x020D;
+
+ /* for input method support on Asian Keyboards */
+
+ /* not clear what this means - listed in Microsoft Windows API */
+ public static final int VK_FINAL = 0x0018;
+
+ /** Constant for the Convert function key. */
+ /* Japanese PC 106 keyboard, Japanese Solaris keyboard: henkan */
+ public static final int VK_CONVERT = 0x001C;
+
+ /** Constant for the Don't Convert function key. */
+ /* Japanese PC 106 keyboard: muhenkan */
+ public static final int VK_NONCONVERT = 0x001D;
+
+ /** Constant for the Accept or Commit function key. */
+ /* Japanese Solaris keyboard: kakutei */
+ public static final int VK_ACCEPT = 0x001E;
+
+ /* not clear what this means - listed in Microsoft Windows API */
+ public static final int VK_MODECHANGE = 0x001F;
+
+ /* replaced by VK_KANA_LOCK for Microsoft Windows and Solaris;
+ might still be used on other platforms */
+ public static final int VK_KANA = 0x0015;
+
+ /* replaced by VK_INPUT_METHOD_ON_OFF for Microsoft Windows and Solaris;
+ might still be used for other platforms */
+ public static final int VK_KANJI = 0x0019;
+
+ /**
+ * Constant for the Alphanumeric function key.
+ * @since 1.2
+ */
+ /* Japanese PC 106 keyboard: eisuu */
+ public static final int VK_ALPHANUMERIC = 0x00F0;
+
+ /**
+ * Constant for the Katakana function key.
+ * @since 1.2
+ */
+ /* Japanese PC 106 keyboard: katakana */
+ public static final int VK_KATAKANA = 0x00F1;
+
+ /**
+ * Constant for the Hiragana function key.
+ * @since 1.2
+ */
+ /* Japanese PC 106 keyboard: hiragana */
+ public static final int VK_HIRAGANA = 0x00F2;
+
+ /**
+ * Constant for the Full-Width Characters function key.
+ * @since 1.2
+ */
+ /* Japanese PC 106 keyboard: zenkaku */
+ public static final int VK_FULL_WIDTH = 0x00F3;
+
+ /**
+ * Constant for the Half-Width Characters function key.
+ * @since 1.2
+ */
+ /* Japanese PC 106 keyboard: hankaku */
+ public static final int VK_HALF_WIDTH = 0x00F4;
+
+ /**
+ * Constant for the Roman Characters function key.
+ * @since 1.2
+ */
+ /* Japanese PC 106 keyboard: roumaji */
+ public static final int VK_ROMAN_CHARACTERS = 0x00F5;
+
+ /**
+ * Constant for the All Candidates function key.
+ * @since 1.2
+ */
+ /* Japanese PC 106 keyboard - VK_CONVERT + ALT: zenkouho */
+ public static final int VK_ALL_CANDIDATES = 0x0100;
+
+ /**
+ * Constant for the Previous Candidate function key.
+ * @since 1.2
+ */
+ /* Japanese PC 106 keyboard - VK_CONVERT + SHIFT: maekouho */
+ public static final int VK_PREVIOUS_CANDIDATE = 0x0101;
+
+ /**
+ * Constant for the Code Input function key.
+ * @since 1.2
+ */
+ /* Japanese PC 106 keyboard - VK_ALPHANUMERIC + ALT: kanji bangou */
+ public static final int VK_CODE_INPUT = 0x0102;
+
+ /**
+ * Constant for the Japanese-Katakana function key.
+ * This key switches to a Japanese input method and selects its Katakana input mode.
+ * @since 1.2
+ */
+ /* Japanese Macintosh keyboard - VK_JAPANESE_HIRAGANA + SHIFT */
+ public static final int VK_JAPANESE_KATAKANA = 0x0103;
+
+ /**
+ * Constant for the Japanese-Hiragana function key.
+ * This key switches to a Japanese input method and selects its Hiragana input mode.
+ * @since 1.2
+ */
+ /* Japanese Macintosh keyboard */
+ public static final int VK_JAPANESE_HIRAGANA = 0x0104;
+
+ /**
+ * Constant for the Japanese-Roman function key.
+ * This key switches to a Japanese input method and selects its Roman-Direct input mode.
+ * @since 1.2
+ */
+ /* Japanese Macintosh keyboard */
+ public static final int VK_JAPANESE_ROMAN = 0x0105;
+
+ /**
+ * Constant for the locking Kana function key.
+ * This key locks the keyboard into a Kana layout.
+ * @since 1.3
+ */
+ /* Japanese PC 106 keyboard with special Windows driver - eisuu + Control; Japanese Solaris keyboard: kana */
+ public static final int VK_KANA_LOCK = 0x0106;
+
+ /**
+ * Constant for the input method on/off key.
+ * @since 1.3
+ */
+ /* Japanese PC 106 keyboard: kanji. Japanese Solaris keyboard: nihongo */
+ public static final int VK_INPUT_METHOD_ON_OFF = 0x0107;
+
+ /* for Sun keyboards */
+ /** @since 1.2 */
+ public static final int VK_CUT = 0xFFD1;
+ /** @since 1.2 */
+ public static final int VK_COPY = 0xFFCD;
+ /** @since 1.2 */
+ public static final int VK_PASTE = 0xFFCF;
+ /** @since 1.2 */
+ public static final int VK_UNDO = 0xFFCB;
+ /** @since 1.2 */
+ public static final int VK_AGAIN = 0xFFC9;
+ /** @since 1.2 */
+ public static final int VK_FIND = 0xFFD0;
+ /** @since 1.2 */
+ public static final int VK_PROPS = 0xFFCA;
+ /** @since 1.2 */
+ public static final int VK_STOP = 0xFFC8;
+
+ /**
+ * Constant for the Compose function key.
+ * @since 1.2
+ */
+ public static final int VK_COMPOSE = 0xFF20;
+
+ /**
+ * Constant for the AltGraph function key.
+ * @since 1.2
+ */
+ public static final int VK_ALT_GRAPH = 0xFF7E;
+
+ /**
+ * Constant for the Begin key.
+ * @since 1.5
+ */
+ public static final int VK_BEGIN = 0xFF58;
+
+ /**
+ * This value is used to indicate that the keyCode is unknown.
+ * KEY_TYPED events do not have a keyCode value; this value
+ * is used instead.
+ */
+ public static final int VK_UNDEFINED = 0x0;
}
diff --git a/src/classes/com/sun/javafx/newt/NewtFactory.java b/src/classes/com/sun/javafx/newt/NewtFactory.java
index ffd530082..f9f8678af 100755
--- a/src/classes/com/sun/javafx/newt/NewtFactory.java
+++ b/src/classes/com/sun/javafx/newt/NewtFactory.java
@@ -53,7 +53,13 @@ public abstract class NewtFactory {
/** Generic AWT wrapped window type, if available */
public static final String AWT = "AWT";
- public static int getPropertyIntValue(String propname) {
+ // Work-around for initialization order problems on Mac OS X
+ // between native Newt and (apparently) Fmod
+ static {
+ Window.init(getWindowType());
+ }
+
+ static int getPropertyIntValue(String propname) {
int i=0;
String s = System.getProperty(propname);
if(null!=s) {
@@ -76,13 +82,11 @@ public abstract class NewtFactory {
windowType = KD;
} else if (osNameLowerCase.startsWith("wind")) {
windowType = WINDOWS;
- } else if (osNameLowerCase.startsWith("mac os x")) {
- // For the time being, use the AWT on Mac OS X since
- // there's no advantage to avoiding its usage -- this
- // would change if we were running on the iPhone and
- // didn't have an AWT
+ } else if (osNameLowerCase.startsWith("mac os x") ||
+ osNameLowerCase.startsWith("darwin")) {
+ windowType = MACOSX;
+ } else if (osNameLowerCase.equals("awt")) {
windowType = AWT;
- //windowType = MACOSX;
} else {
windowType = X11;
}
diff --git a/src/classes/com/sun/javafx/newt/Window.java b/src/classes/com/sun/javafx/newt/Window.java
index ab0588e8e..710c88bbe 100755
--- a/src/classes/com/sun/javafx/newt/Window.java
+++ b/src/classes/com/sun/javafx/newt/Window.java
@@ -47,6 +47,20 @@ public abstract class Window implements NativeWindow
public static final boolean DEBUG_WINDOW_EVENT = false;
public static final boolean DEBUG_IMPLEMENTATION = false;
+ // Workaround for initialization order problems on Mac OS X
+ // between native Newt and (apparently) Fmod -- if Fmod is
+ // initialized first then the connection to the window server
+ // breaks, leading to errors from deep within the AppKit
+ static void init(String type) {
+ if (NewtFactory.MACOSX.equals(type)) {
+ try {
+ getWindowClass(type);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
private static Class getWindowClass(String type)
throws ClassNotFoundException
{
@@ -175,7 +189,7 @@ public abstract class Window implements NativeWindow
protected int width, height, x, y;
protected int eventMask;
- protected String title = "AWT NewtWindow";
+ protected String title = "Newt Window";
protected boolean undecorated = false;
public String getTitle() {
diff --git a/src/classes/com/sun/javafx/newt/awt/AWTWindow.java b/src/classes/com/sun/javafx/newt/awt/AWTWindow.java
index 595e84cb0..2315cb1a4 100644
--- a/src/classes/com/sun/javafx/newt/awt/AWTWindow.java
+++ b/src/classes/com/sun/javafx/newt/awt/AWTWindow.java
@@ -53,6 +53,11 @@ import javax.media.opengl.GLCapabilities;
public class AWTWindow extends Window {
+ public AWTWindow() {
+ super();
+ title = "AWT NewtWindow";
+ }
+
static void setWindowAlpha(java.awt.Window w, float alpha) {
// hack for macosx only
Object peer = w.getPeer();
diff --git a/src/classes/com/sun/javafx/newt/macosx/MacWindow.java b/src/classes/com/sun/javafx/newt/macosx/MacWindow.java
index dce504f83..1eff34b79 100755
--- a/src/classes/com/sun/javafx/newt/macosx/MacWindow.java
+++ b/src/classes/com/sun/javafx/newt/macosx/MacWindow.java
@@ -39,13 +39,102 @@ import com.sun.javafx.newt.*;
import com.sun.opengl.impl.*;
public class MacWindow extends Window {
+ private static final boolean DEBUG = false;
- private static native boolean _initIDs();
+ private static native boolean initIDs();
+ // Window styles
+ private static final int NSBorderlessWindowMask = 0;
+ private static final int NSTitledWindowMask = 1 << 0;
+ private static final int NSClosableWindowMask = 1 << 1;
+ private static final int NSMiniaturizableWindowMask = 1 << 2;
+ private static final int NSResizableWindowMask = 1 << 3;
+
+ // Window backing store types
+ private static final int NSBackingStoreRetained = 0;
+ private static final int NSBackingStoreNonretained = 1;
+ private static final int NSBackingStoreBuffered = 2;
+
+ // Key constants handled differently on Mac OS X than other platforms
+ private static final int NSUpArrowFunctionKey = 0xF700;
+ private static final int NSDownArrowFunctionKey = 0xF701;
+ private static final int NSLeftArrowFunctionKey = 0xF702;
+ private static final int NSRightArrowFunctionKey = 0xF703;
+ private static final int NSF1FunctionKey = 0xF704;
+ private static final int NSF2FunctionKey = 0xF705;
+ private static final int NSF3FunctionKey = 0xF706;
+ private static final int NSF4FunctionKey = 0xF707;
+ private static final int NSF5FunctionKey = 0xF708;
+ private static final int NSF6FunctionKey = 0xF709;
+ private static final int NSF7FunctionKey = 0xF70A;
+ private static final int NSF8FunctionKey = 0xF70B;
+ private static final int NSF9FunctionKey = 0xF70C;
+ private static final int NSF10FunctionKey = 0xF70D;
+ private static final int NSF11FunctionKey = 0xF70E;
+ private static final int NSF12FunctionKey = 0xF70F;
+ private static final int NSF13FunctionKey = 0xF710;
+ private static final int NSF14FunctionKey = 0xF711;
+ private static final int NSF15FunctionKey = 0xF712;
+ private static final int NSF16FunctionKey = 0xF713;
+ private static final int NSF17FunctionKey = 0xF714;
+ private static final int NSF18FunctionKey = 0xF715;
+ private static final int NSF19FunctionKey = 0xF716;
+ private static final int NSF20FunctionKey = 0xF717;
+ private static final int NSF21FunctionKey = 0xF718;
+ private static final int NSF22FunctionKey = 0xF719;
+ private static final int NSF23FunctionKey = 0xF71A;
+ private static final int NSF24FunctionKey = 0xF71B;
+ private static final int NSF25FunctionKey = 0xF71C;
+ private static final int NSF26FunctionKey = 0xF71D;
+ private static final int NSF27FunctionKey = 0xF71E;
+ private static final int NSF28FunctionKey = 0xF71F;
+ private static final int NSF29FunctionKey = 0xF720;
+ private static final int NSF30FunctionKey = 0xF721;
+ private static final int NSF31FunctionKey = 0xF722;
+ private static final int NSF32FunctionKey = 0xF723;
+ private static final int NSF33FunctionKey = 0xF724;
+ private static final int NSF34FunctionKey = 0xF725;
+ private static final int NSF35FunctionKey = 0xF726;
+ private static final int NSInsertFunctionKey = 0xF727;
+ private static final int NSDeleteFunctionKey = 0xF728;
+ private static final int NSHomeFunctionKey = 0xF729;
+ private static final int NSBeginFunctionKey = 0xF72A;
+ private static final int NSEndFunctionKey = 0xF72B;
+ private static final int NSPageUpFunctionKey = 0xF72C;
+ private static final int NSPageDownFunctionKey = 0xF72D;
+ private static final int NSPrintScreenFunctionKey = 0xF72E;
+ private static final int NSScrollLockFunctionKey = 0xF72F;
+ private static final int NSPauseFunctionKey = 0xF730;
+ private static final int NSSysReqFunctionKey = 0xF731;
+ private static final int NSBreakFunctionKey = 0xF732;
+ private static final int NSResetFunctionKey = 0xF733;
+ private static final int NSStopFunctionKey = 0xF734;
+ private static final int NSMenuFunctionKey = 0xF735;
+ private static final int NSUserFunctionKey = 0xF736;
+ private static final int NSSystemFunctionKey = 0xF737;
+ private static final int NSPrintFunctionKey = 0xF738;
+ private static final int NSClearLineFunctionKey = 0xF739;
+ private static final int NSClearDisplayFunctionKey = 0xF73A;
+ private static final int NSInsertLineFunctionKey = 0xF73B;
+ private static final int NSDeleteLineFunctionKey = 0xF73C;
+ private static final int NSInsertCharFunctionKey = 0xF73D;
+ private static final int NSDeleteCharFunctionKey = 0xF73E;
+ private static final int NSPrevFunctionKey = 0xF73F;
+ private static final int NSNextFunctionKey = 0xF740;
+ private static final int NSSelectFunctionKey = 0xF741;
+ private static final int NSExecuteFunctionKey = 0xF742;
+ private static final int NSUndoFunctionKey = 0xF743;
+ private static final int NSRedoFunctionKey = 0xF744;
+ private static final int NSFindFunctionKey = 0xF745;
+ private static final int NSHelpFunctionKey = 0xF746;
+ private static final int NSModeSwitchFunctionKey = 0xF747;
+
+ private long nativeWindow;
+
static {
NativeLibLoader.loadNEWT();
- if (_initIDs() == false) {
+ if (!initIDs()) {
throw new RuntimeException("Failed to initialize jmethodIDs");
}
}
@@ -53,60 +142,201 @@ public class MacWindow extends Window {
public MacWindow() {
}
- protected final void createNative(GLCapabilities caps) {
+ protected void createNative(GLCapabilities caps) {
chosenCaps = (GLCapabilities) caps.clone(); // FIXME: visualID := f1(caps); caps := f2(visualID)
visualID = 0; // n/a
}
- protected final void closeNative() {
+ protected void closeNative() {
+ if (nativeWindow != 0) {
+ close0(nativeWindow);
+ nativeWindow = 0;
+ }
}
public long getSurfaceHandle() {
- return 0;
- }
-
- public final int getDisplayWidth() {
- return 640;
- }
-
- public final int getDisplayHeight() {
- return 480;
+ if (nativeWindow == 0) {
+ return 0;
+ }
+ return contentView(nativeWindow);
}
- public final void setVisible(boolean visible) {
+ public void setVisible(boolean visible) {
+ if (visible) {
+ boolean created = false;
+ if (nativeWindow == 0) {
+ nativeWindow = createWindow(getX(), getY(), getWidth(), getHeight(),
+ (isUndecorated() ?
+ NSBorderlessWindowMask :
+ NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask),
+ NSBackingStoreBuffered,
+ true);
+ setTitle0(nativeWindow, getTitle());
+ created = true;
+ }
+ makeKeyAndOrderFront(nativeWindow);
+ if (created) {
+ sendWindowEvent(WindowEvent.EVENT_WINDOW_MOVED);
+ sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED);
+ }
+ } else {
+ if (nativeWindow != 0) {
+ orderOut(nativeWindow);
+ }
+ }
+
+ this.visible = visible;
}
- public final void setSize(int width, int height) {
+ public void setSize(int width, int height) {
+ this.width = width;
+ this.height = height;
+ if (nativeWindow != 0) {
+ setContentSize(nativeWindow, width, height);
+ }
}
- public final void setPosition(int x, int y) {
+ public void setPosition(int x, int y) {
+ this.x = x;
+ this.y = y;
+ if (nativeWindow != 0) {
+ setFrameTopLeftPoint(nativeWindow, x, y);
+ }
}
public boolean setFullscreen(boolean fullscreen) {
- return true;
+ // FIXME: implement this
+ return false;
}
- protected final void dispatchMessages(int eventMask) {
-
- }
-
-/*
private void sizeChanged(int newWidth, int newHeight) {
- width = newWidth;
- height = newHeight;
- sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED);
+ if (DEBUG) {
+ System.out.println("Size changed to " + newWidth + ", " + newHeight);
+ }
+ if (width != newWidth || height != newHeight) {
+ width = newWidth;
+ height = newHeight;
+ if (DEBUG) {
+ System.out.println(" Posted WINDOW_RESIZED event");
+ }
+ sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED);
+ }
}
-
+
private void positionChanged(int newX, int newY) {
- x = newX;
- y = newY;
- sendWindowEvent(WindowEvent.EVENT_WINDOW_MOVED);
+ if (DEBUG) {
+ System.out.println("Position changed to " + newX + ", " + newY);
+ }
+ if (x != newX || y != newY) {
+ x = newX;
+ y = newY;
+ if (DEBUG) {
+ System.out.println(" Posted WINDOW_MOVED event");
+ }
+ sendWindowEvent(WindowEvent.EVENT_WINDOW_MOVED);
+ }
}
-
+
private void windowClosed() {
+ nativeWindow = 0;
+ visible = false;
}
-
- private void windowDestroyed() {
+
+ private char convertKeyChar(char keyChar) {
+ if (keyChar >= NSUpArrowFunctionKey && keyChar <= NSModeSwitchFunctionKey) {
+ switch (keyChar) {
+ case NSUpArrowFunctionKey: return KeyEvent.VK_UP;
+ case NSDownArrowFunctionKey: return KeyEvent.VK_DOWN;
+ case NSLeftArrowFunctionKey: return KeyEvent.VK_LEFT;
+ case NSRightArrowFunctionKey: return KeyEvent.VK_RIGHT;
+ case NSF1FunctionKey: return KeyEvent.VK_F1;
+ case NSF2FunctionKey: return KeyEvent.VK_F2;
+ case NSF3FunctionKey: return KeyEvent.VK_F3;
+ case NSF4FunctionKey: return KeyEvent.VK_F4;
+ case NSF5FunctionKey: return KeyEvent.VK_F5;
+ case NSF6FunctionKey: return KeyEvent.VK_F6;
+ case NSF7FunctionKey: return KeyEvent.VK_F7;
+ case NSF8FunctionKey: return KeyEvent.VK_F8;
+ case NSF9FunctionKey: return KeyEvent.VK_F9;
+ case NSF10FunctionKey: return KeyEvent.VK_F10;
+ case NSF11FunctionKey: return KeyEvent.VK_F11;
+ case NSF12FunctionKey: return KeyEvent.VK_F12;
+ case NSF13FunctionKey: return KeyEvent.VK_F13;
+ case NSF14FunctionKey: return KeyEvent.VK_F14;
+ case NSF15FunctionKey: return KeyEvent.VK_F15;
+ case NSF16FunctionKey: return KeyEvent.VK_F16;
+ case NSF17FunctionKey: return KeyEvent.VK_F17;
+ case NSF18FunctionKey: return KeyEvent.VK_F18;
+ case NSF19FunctionKey: return KeyEvent.VK_F19;
+ case NSF20FunctionKey: return KeyEvent.VK_F20;
+ case NSF21FunctionKey: return KeyEvent.VK_F21;
+ case NSF22FunctionKey: return KeyEvent.VK_F22;
+ case NSF23FunctionKey: return KeyEvent.VK_F23;
+ case NSF24FunctionKey: return KeyEvent.VK_F24;
+ case NSInsertFunctionKey: return KeyEvent.VK_INSERT;
+ case NSDeleteFunctionKey: return KeyEvent.VK_DELETE;
+ case NSHomeFunctionKey: return KeyEvent.VK_HOME;
+ case NSBeginFunctionKey: return KeyEvent.VK_BEGIN;
+ case NSEndFunctionKey: return KeyEvent.VK_END;
+ case NSPageUpFunctionKey: return KeyEvent.VK_PAGE_UP;
+ case NSPageDownFunctionKey: return KeyEvent.VK_PAGE_DOWN;
+ case NSPrintScreenFunctionKey: return KeyEvent.VK_PRINTSCREEN;
+ case NSScrollLockFunctionKey: return KeyEvent.VK_SCROLL_LOCK;
+ case NSPauseFunctionKey: return KeyEvent.VK_PAUSE;
+ // Not handled:
+ // NSSysReqFunctionKey
+ // NSBreakFunctionKey
+ // NSResetFunctionKey
+ case NSStopFunctionKey: return KeyEvent.VK_STOP;
+ // Not handled:
+ // NSMenuFunctionKey
+ // NSUserFunctionKey
+ // NSSystemFunctionKey
+ // NSPrintFunctionKey
+ // NSClearLineFunctionKey
+ // NSClearDisplayFunctionKey
+ // NSInsertLineFunctionKey
+ // NSDeleteLineFunctionKey
+ // NSInsertCharFunctionKey
+ // NSDeleteCharFunctionKey
+ // NSPrevFunctionKey
+ // NSNextFunctionKey
+ // NSSelectFunctionKey
+ // NSExecuteFunctionKey
+ // NSUndoFunctionKey
+ // NSRedoFunctionKey
+ // NSFindFunctionKey
+ // NSHelpFunctionKey
+ // NSModeSwitchFunctionKey
+ default: break;
+ }
+ }
+
+ // NSEvent's charactersIgnoringModifiers doesn't ignore the shift key
+ if (keyChar >= 'a' && keyChar <= 'z') {
+ return Character.toUpperCase(keyChar);
+ }
+
+ return keyChar;
+ }
+
+ protected void sendKeyEvent(int eventType, int modifiers, int keyCode, char keyChar) {
+ keyChar = convertKeyChar(keyChar);
+ // Note that we send the key char for the key code on this
+ // platform -- we do not get any useful key codes out of the system
+ super.sendKeyEvent(eventType, modifiers, keyChar, keyChar);
}
-*/
+
+ private native long createWindow(int x, int y, int w, int h,
+ int windowStyle,
+ int backingStoreType,
+ boolean deferCreation);
+ private native void makeKeyAndOrderFront(long window);
+ private native void orderOut(long window);
+ private native void close0(long window);
+ private native void setTitle0(long window, String title);
+ protected native void dispatchMessages(int eventMask);
+ private native long contentView(long window);
+ private native void setContentSize(long window, int w, int h);
+ private native void setFrameTopLeftPoint(long window, int x, int y);
}
diff --git a/src/classes/com/sun/opengl/util/texture/TextureIO.java.javase b/src/classes/com/sun/opengl/util/texture/TextureIO.java.javase
index aa2cb1799..29912db24 100755
--- a/src/classes/com/sun/opengl/util/texture/TextureIO.java.javase
+++ b/src/classes/com/sun/opengl/util/texture/TextureIO.java.javase
@@ -736,6 +736,10 @@ public class TextureIO {
if (DEBUG) {
e.printStackTrace();
}
+ } catch (Error e) {
+ if (DEBUG) {
+ e.printStackTrace();
+ }
}
// Other special-case writers
diff --git a/src/classes/javax/media/opengl/GLDrawableFactory.java b/src/classes/javax/media/opengl/GLDrawableFactory.java
index 677441572..dbbb42a0e 100644
--- a/src/classes/javax/media/opengl/GLDrawableFactory.java
+++ b/src/classes/javax/media/opengl/GLDrawableFactory.java
@@ -121,7 +121,8 @@ public abstract class GLDrawableFactory {
if (factoryClassName == null) {
if (osNameLowerCase.startsWith("windows")) {
factoryClassName = "com.sun.opengl.impl.windows.wgl.WindowsWGLDrawableFactory";
- } else if (osNameLowerCase.startsWith("mac os x")) {
+ } else if (osNameLowerCase.startsWith("mac os x") ||
+ osNameLowerCase.startsWith("darwin")) {
// FIXME: remove this residual dependence on the AWT
factoryClassName = "com.sun.opengl.impl.macosx.cgl.awt.MacOSXAWTCGLDrawableFactory";
} else {