From: <eli...@us...> - 2008-04-07 17:10:17
|
Revision: 2981 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=2981&view=rev Author: elias_naur Date: 2008-04-07 10:10:14 -0700 (Mon, 07 Apr 2008) Log Message: ----------- Mac OS X: Implemented Display.setParent support Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplayPeerInfo.java trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXGLCanvas.java trunk/LWJGL/src/java/org/lwjgl/test/opengl/awt/DisplayParentTest.java Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2008-04-07 16:37:39 UTC (rev 2980) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2008-04-07 17:10:14 UTC (rev 2981) @@ -63,6 +63,7 @@ private MacOSXCanvasListener canvas_listener; private MacOSXFrame frame; + private Canvas canvas; private Robot robot; private MacOSXMouseEventQueue mouse_queue; private KeyboardEventQueue keyboard_queue; @@ -79,10 +80,16 @@ hideUI(fullscreen); close_requested = false; try { - frame = new MacOSXFrame(mode, requested_mode, fullscreen, x, y); - canvas_listener = new MacOSXCanvasListener(frame.getCanvas()); + if (parent == null) { + frame = new MacOSXFrame(mode, requested_mode, fullscreen, x, y); + canvas = frame.getCanvas(); + } else { + frame = null; + canvas = parent; + } + canvas_listener = new MacOSXCanvasListener(canvas); canvas_listener.enableListeners(); - robot = AWTUtil.createRobot(frame); + robot = AWTUtil.createRobot(canvas); } catch (LWJGLException e) { destroyWindow(); throw e; @@ -185,7 +192,8 @@ } public void setTitle(String title) { - frame.setTitle(title); + if (frame != null) + frame.setTitle(title); } public boolean isCloseRequested() { @@ -198,19 +206,19 @@ } public boolean isVisible() { - return frame.syncIsVisible(); + return frame == null || frame.syncIsVisible(); } public boolean isActive() { - return frame.syncIsActive(); + return canvas.isFocusOwner(); } - public MacOSXFrame getFrame() { - return frame; + public Canvas getCanvas() { + return canvas; } public boolean isDirty() { - return frame.getCanvas().syncIsDirty(); + return frame != null && frame.getCanvas().syncIsDirty(); } public PeerInfo createPeerInfo(PixelFormat pixel_format) throws LWJGLException { @@ -245,7 +253,7 @@ * * - elias */ - if (Display.isFullscreen() && (frame.getCanvas().syncCanvasPainted() || should_update)) { + if (Display.isFullscreen() && (frame != null && frame.getCanvas().syncCanvasPainted() || should_update)) { try { MacOSXContextImplementation.resetView(Display.getDrawable().getContext().getPeerInfo(), Display.getDrawable().getContext()); } catch (LWJGLException e) { @@ -258,7 +266,7 @@ GL11.glGetInteger(GL11.GL_VIEWPORT, current_viewport); GL11.glViewport(current_viewport.get(0), current_viewport.get(1), current_viewport.get(2), current_viewport.get(3)); } - if (frame.syncShouldWarpCursor() && mouse_queue != null) { + if (frame != null && frame.syncShouldWarpCursor() && mouse_queue != null) { mouse_queue.warpCursor(); } } @@ -280,7 +288,8 @@ private native void nHideUI(boolean hide); public void reshape(int x, int y, int width, int height) { - frame.resize(x, y, width, height); + if (frame != null) + frame.resize(x, y, width, height); } /* Mouse */ @@ -293,7 +302,6 @@ } public void createMouse() throws LWJGLException { - MacOSXGLCanvas canvas = frame.getCanvas(); this.mouse_queue = new MacOSXMouseEventQueue(canvas); mouse_queue.register(); } @@ -323,12 +331,13 @@ } public void setCursorPosition(int x, int y) { - AWTUtil.setCursorPosition(frame.getCanvas(), robot, x, y); + AWTUtil.setCursorPosition(canvas, robot, x, y); } public void setNativeCursor(Object handle) throws LWJGLException { Cursor awt_cursor = (Cursor)handle; - frame.setCursor(awt_cursor); + if (frame != null) + frame.setCursor(awt_cursor); } public int getMinCursorSize() { @@ -341,7 +350,6 @@ /* Keyboard */ public void createKeyboard() throws LWJGLException { - MacOSXGLCanvas canvas = frame.getCanvas(); this.keyboard_queue = new KeyboardEventQueue(canvas); keyboard_queue.register(); } Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplayPeerInfo.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplayPeerInfo.java 2008-04-07 16:37:39 UTC (rev 2980) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplayPeerInfo.java 2008-04-07 17:10:14 UTC (rev 2981) @@ -51,10 +51,9 @@ protected void doLockAndInitHandle() throws LWJGLException { if (locked) throw new RuntimeException("Already locked"); - MacOSXFrame frame = ((MacOSXDisplay)Display.getImplementation()).getFrame(); - if (frame != null) { - Canvas gl_canvas = frame.getCanvas(); - initHandle(gl_canvas); + Canvas canvas = ((MacOSXDisplay)Display.getImplementation()).getCanvas(); + if (canvas != null) { + initHandle(canvas); locked = true; } } Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXGLCanvas.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXGLCanvas.java 2008-04-07 16:37:39 UTC (rev 2980) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXGLCanvas.java 2008-04-07 17:10:14 UTC (rev 2981) @@ -63,13 +63,6 @@ } } - /** - * This initializes the canvas and binds the context to it. - */ - public void initializeCanvas() { - setFocusTraversalKeysEnabled(false); - } - public boolean syncCanvasPainted() { boolean result; synchronized (this) { 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 16:37:39 UTC (rev 2980) +++ trunk/LWJGL/src/java/org/lwjgl/test/opengl/awt/DisplayParentTest.java 2008-04-07 17:10:14 UTC (rev 2981) @@ -64,6 +64,7 @@ setLayout(new GridLayout(1, 2)); final Canvas display_parent = new Canvas(); display_parent.setFocusable(true); + display_parent.setIgnoreRepaint(true); add(display_parent); /* addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { @@ -74,6 +75,7 @@ setResizable(true); setVisible(true); Display.setParent(display_parent); + Display.setVSyncEnabled(true); Display.create(); float angle = 0f; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |