aboutsummaryrefslogtreecommitdiffstats
path: root/src/newt/classes/com
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2010-05-04 06:35:37 +0200
committerSven Gothel <[email protected]>2010-05-04 06:35:37 +0200
commit9e792dcef900de7039cd277459c0629abfab9f21 (patch)
tree81adfd1e07e2118675d62836e1289225f408bb00 /src/newt/classes/com
parenta677e9db03ea44ea353fb9de61e2a86a6e063d0f (diff)
NEWT Fixes:
- Common native in NewtCommon.c/.h - Add simple NEWTEventFiFo, providing a pattern to spool events by an EventListener and to process them where it impacts (GLEventListener ..) - Window [X11|Windows]: setSize/setPosition: - always store the values, - only act if valid and !fullscreen - Window [X11]: - Add requestFocus - Add setTitle - Fix parent/child window creation - Fix parent/child window fullscreen (reparenting) - JUnit Test: ParentTest: - Shows parent and client window animation - Client window shall be able to go into fullscreen, ie disconnect/reconnect from its parent. Test: Focus-client + type-'f' - Both windows receive/dispatch events properly
Diffstat (limited to 'src/newt/classes/com')
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/Window.java3
-rw-r--r--src/newt/classes/com/jogamp/newt/event/NEWTEventFiFo.java66
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/impl/windows/WindowsWindow.java12
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/impl/x11/X11Window.java80
4 files changed, 131 insertions, 30 deletions
diff --git a/src/newt/classes/com/jogamp/newt/Window.java b/src/newt/classes/com/jogamp/newt/Window.java
index 1802cab8e..653d76522 100755
--- a/src/newt/classes/com/jogamp/newt/Window.java
+++ b/src/newt/classes/com/jogamp/newt/Window.java
@@ -254,6 +254,9 @@ public abstract class Window implements NativeWindow
}
public void setTitle(String title) {
+ if (title == null) {
+ title = "";
+ }
this.title = title;
}
diff --git a/src/newt/classes/com/jogamp/newt/event/NEWTEventFiFo.java b/src/newt/classes/com/jogamp/newt/event/NEWTEventFiFo.java
new file mode 100644
index 000000000..976085aa6
--- /dev/null
+++ b/src/newt/classes/com/jogamp/newt/event/NEWTEventFiFo.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2010 Sven Gothel. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution 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 Sven Gothel or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SVEN GOTHEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+package com.jogamp.newt.event;
+
+import com.jogamp.newt.*;
+import java.util.LinkedList;
+
+public class NEWTEventFiFo
+{
+ private LinkedList/*<NEWTEvent>*/ events = new LinkedList/*<NEWTEvent>*/();
+
+ /** Add NEWTEvent to tail */
+ public synchronized void put(NEWTEvent event) {
+ events.addLast(event);
+ notifyAll();
+ }
+
+ /** Remove NEWTEvent from head */
+ public synchronized NEWTEvent get() {
+ if (0 == events.size()) {
+ return null;
+ }
+
+ return (NEWTEvent) events.removeFirst();
+ }
+
+ /** Get NEWTEvents in queue */
+ public synchronized int size() {
+ return events.size();
+ }
+
+ /** Clear all NEWTEvents from queue */
+ public synchronized void clear() {
+ events.clear();
+ }
+
+}
diff --git a/src/newt/classes/com/jogamp/newt/impl/windows/WindowsWindow.java b/src/newt/classes/com/jogamp/newt/impl/windows/WindowsWindow.java
index dc870f43d..ce1a0ad2e 100755
--- a/src/newt/classes/com/jogamp/newt/impl/windows/WindowsWindow.java
+++ b/src/newt/classes/com/jogamp/newt/impl/windows/WindowsWindow.java
@@ -157,27 +157,31 @@ public class WindowsWindow extends Window {
// @Override
public void setSize(int width, int height) {
- if (0!=windowHandle && (width != this.width || this.height != height)) {
+ if (width != this.width || this.height != height) {
if(!fullscreen) {
nfs_width=width;
nfs_height=height;
}
this.width = width;
this.height = height;
- setSize0(parentWindowHandle, windowHandle, x, y, width, height);
+ if(0!=windowHandle && !fullscreen) {
+ setSize0(parentWindowHandle, windowHandle, x, y, width, height);
+ }
}
}
//@Override
public void setPosition(int x, int y) {
- if (0!=windowHandle && (this.x != x || this.y != y)) {
+ if ( this.x != x || this.y != y ) {
if(!fullscreen) {
nfs_x=x;
nfs_y=y;
}
this.x = x;
this.y = y;
- setPosition(parentWindowHandle, windowHandle, x , y);
+ if(0!=windowHandle && !fullscreen) {
+ setPosition(parentWindowHandle, windowHandle, x , y);
+ }
}
}
diff --git a/src/newt/classes/com/jogamp/newt/impl/x11/X11Window.java b/src/newt/classes/com/jogamp/newt/impl/x11/X11Window.java
index c7401ef23..cd089ccfb 100755
--- a/src/newt/classes/com/jogamp/newt/impl/x11/X11Window.java
+++ b/src/newt/classes/com/jogamp/newt/impl/x11/X11Window.java
@@ -61,7 +61,8 @@ public class X11Window extends Window {
long visualID = x11config.getVisualID();
long w = CreateWindow(parentWindowHandle,
display.getHandle(), screen.getIndex(), visualID,
- display.getJavaObjectAtom(), display.getWindowDeleteAtom(), x, y, width, height);
+ display.getJavaObjectAtom(), display.getWindowDeleteAtom(),
+ x, y, width, height, undecorated||0!=parentWindowHandle);
if (w == 0 || w!=windowHandle) {
throw new NativeWindowException("Error creating window: "+w);
}
@@ -93,24 +94,22 @@ public class X11Window extends Window {
}
}
- public void requestFocus() {
- super.requestFocus();
- }
-
public void setSize(int width, int height) {
if(DEBUG_IMPLEMENTATION) {
System.err.println("X11Window setSize: "+this.x+"/"+this.y+" "+this.width+"x"+this.height+" -> "+width+"x"+height);
// Exception e = new Exception("XXXXXXXXXX");
// e.printStackTrace();
}
- this.width = width;
- this.height = height;
- if(!fullscreen) {
- nfs_width=width;
- nfs_height=height;
- }
- if(0!=windowHandle) {
- setSize0(parentWindowHandle, getDisplayHandle(), getScreenIndex(), windowHandle, x, y, width, height, (undecorated||fullscreen)?-1:1, false);
+ if (width != this.width || this.height != height) {
+ this.width = width;
+ this.height = height;
+ if(!fullscreen) {
+ nfs_width=width;
+ nfs_height=height;
+ }
+ if(0!=windowHandle && !fullscreen) {
+ setSize0(getDisplayHandle(), windowHandle, width, height);
+ }
}
}
@@ -120,14 +119,16 @@ public class X11Window extends Window {
// Exception e = new Exception("XXXXXXXXXX");
// e.printStackTrace();
}
- this.x = x;
- this.y = y;
- if(!fullscreen) {
- nfs_x=x;
- nfs_y=y;
- }
- if(0!=windowHandle) {
- setPosition0(getDisplayHandle(), windowHandle, x, y);
+ if ( this.x != x || this.y != y ) {
+ this.x = x;
+ this.y = y;
+ if(!fullscreen) {
+ nfs_x=x;
+ nfs_y=y;
+ }
+ if(0!=windowHandle && !fullscreen) {
+ setPosition0(parentWindowHandle, getDisplayHandle(), windowHandle, x, y);
+ }
}
}
@@ -148,23 +149,50 @@ public class X11Window extends Window {
if(DEBUG_IMPLEMENTATION || DEBUG_WINDOW_EVENT) {
System.err.println("X11Window fs: "+fullscreen+" "+x+"/"+y+" "+w+"x"+h);
}
- setSize0(parentWindowHandle, getDisplayHandle(), getScreenIndex(), windowHandle, x, y, w, h, (undecorated||fullscreen)?-1:1, false);
+ setPosSizeDecor0(fullscreen?0:parentWindowHandle, getDisplayHandle(), getScreenIndex(), windowHandle, x, y, w, h, (undecorated||fullscreen)?-1:1);
+ if(fullscreen) {
+ requestFocus0(getDisplayHandle(), windowHandle);
+ }
}
return fullscreen;
}
+ // @Override
+ public void requestFocus() {
+ super.requestFocus();
+ if (windowHandle != 0L) {
+ requestFocus0(getDisplayHandle(), windowHandle);
+ }
+ }
+
+ // @Override
+ public void setTitle(String title) {
+ if (title == null) {
+ title = "";
+ }
+ if (0!=windowHandle && !title.equals(getTitle())) {
+ super.setTitle(title);
+ setTitle0(getDisplayHandle(), windowHandle, title);
+ }
+ }
+
+
//----------------------------------------------------------------------
// Internals only
//
protected static native boolean initIDs();
private native long CreateWindow(long parentWindowHandle, long display, int screen_index,
- long visualID, long javaObjectAtom, long windowDeleteAtom, int x, int y, int width, int height);
+ long visualID, long javaObjectAtom, long windowDeleteAtom,
+ int x, int y, int width, int height, boolean undecorated);
private native void CloseWindow(long display, long windowHandle, long javaObjectAtom);
private native void setVisible0(long display, long windowHandle, boolean visible);
- private native void setSize0(long parentWindowHandle, long display, int screen_index, long windowHandle,
- int x, int y, int width, int height, int decorationToggle, boolean setVisible);
- private native void setPosition0(long display, long windowHandle, int x, int y);
+ private native void setSize0(long display, long windowHandle, int width, int height);
+ private native void setPosSizeDecor0(long parentWindowHandle, long display, int screen_index, long windowHandle,
+ int x, int y, int width, int height, int decorationToggle);
+ private native void setTitle0(long display, long windowHandle, String title);
+ private native void requestFocus0(long display, long windowHandle);
+ private native void setPosition0(long parentWindowHandle, long display, long windowHandle, int x, int y);
private void windowChanged(int newX, int newY, int newWidth, int newHeight) {
if(width != newWidth || height != newHeight) {