aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/newt/classes/com/jogamp/newt/Window.java4
-rw-r--r--src/newt/classes/com/jogamp/newt/opengl/GLWindow.java8
-rw-r--r--src/newt/classes/jogamp/newt/WindowImpl.java82
-rw-r--r--src/newt/native/Window.h30
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java9
5 files changed, 107 insertions, 26 deletions
diff --git a/src/newt/classes/com/jogamp/newt/Window.java b/src/newt/classes/com/jogamp/newt/Window.java
index 84f2f0294..24555bf39 100644
--- a/src/newt/classes/com/jogamp/newt/Window.java
+++ b/src/newt/classes/com/jogamp/newt/Window.java
@@ -217,6 +217,10 @@ public interface Window extends NativeWindow, WindowClosingProtocol {
boolean isUndecorated();
+ void setAlwaysOnTop(boolean value);
+
+ boolean isAlwaysOnTop();
+
void setTitle(String title);
String getTitle();
diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
index bde4373d1..7712b4654 100644
--- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
+++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
@@ -222,6 +222,14 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC
return window.isUndecorated();
}
+ public final void setAlwaysOnTop(boolean value) {
+ window.setAlwaysOnTop(value);
+ }
+
+ public final boolean isAlwaysOnTop() {
+ return window.isAlwaysOnTop();
+ }
+
public final void setFocusAction(FocusRunnable focusAction) {
window.setFocusAction(focusAction);
}
diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java
index 6c71e6082..12534c951 100644
--- a/src/newt/classes/jogamp/newt/WindowImpl.java
+++ b/src/newt/classes/jogamp/newt/WindowImpl.java
@@ -94,6 +94,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
protected int nfs_width, nfs_height, nfs_x, nfs_y; // non fullscreen client-area size/pos w/o insets
protected String title = "Newt Window";
protected boolean undecorated = false;
+ protected boolean alwaysOnTop = false;
private LifecycleHook lifecycleHook = null;
private DestroyAction destroyAction = new DestroyAction();
@@ -422,14 +423,17 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
*/
protected abstract void requestFocusImpl(boolean force);
- public static final int FLAG_CHANGE_PARENTING = 1 << 0;
- public static final int FLAG_CHANGE_DECORATION = 1 << 1;
- public static final int FLAG_CHANGE_FULLSCREEN = 1 << 2;
- public static final int FLAG_CHANGE_VISIBILITY = 1 << 3;
- public static final int FLAG_HAS_PARENT = 1 << 4;
- public static final int FLAG_IS_UNDECORATED = 1 << 5;
- public static final int FLAG_IS_FULLSCREEN = 1 << 6;
- public static final int FLAG_IS_VISIBLE = 1 << 7;
+ public static final int FLAG_CHANGE_PARENTING = 1 << 0;
+ public static final int FLAG_CHANGE_DECORATION = 1 << 1;
+ public static final int FLAG_CHANGE_FULLSCREEN = 1 << 2;
+ public static final int FLAG_CHANGE_ALWAYSONTOP = 1 << 3;
+ public static final int FLAG_CHANGE_VISIBILITY = 1 << 4;
+
+ public static final int FLAG_HAS_PARENT = 1 << 8;
+ public static final int FLAG_IS_UNDECORATED = 1 << 9;
+ public static final int FLAG_IS_FULLSCREEN = 1 << 10;
+ public static final int FLAG_IS_ALWAYSONTOP = 1 << 11;
+ public static final int FLAG_IS_VISIBLE = 1 << 12;
/**
* The native implementation should invoke the referenced java state callbacks
@@ -455,6 +459,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
return changeFlags |= ( ( 0 != getParentWindowHandle() ) ? FLAG_HAS_PARENT : 0 ) |
( isUndecorated() ? FLAG_IS_UNDECORATED : 0 ) |
( isFullscreen() ? FLAG_IS_FULLSCREEN : 0 ) |
+ ( isAlwaysOnTop() ? FLAG_IS_ALWAYSONTOP : 0 ) |
( visible ? FLAG_IS_VISIBLE : 0 ) ;
}
protected static String getReconfigureFlagsAsString(StringBuffer sb, int flags) {
@@ -1223,14 +1228,14 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
// set current state
WindowImpl.this.undecorated = undecorated;
- if( nativeUndecorationChange) {
+ if( nativeUndecorationChange ) {
// Change decoration on active window
// Mirror pos/size so native change notification can get overwritten
- int x = WindowImpl.this.x;
- int y = WindowImpl.this.y;
- int width = WindowImpl.this.width;
- int height = WindowImpl.this.height;
+ final int x = WindowImpl.this.x;
+ final int y = WindowImpl.this.y;
+ final int width = WindowImpl.this.width;
+ final int height = WindowImpl.this.height;
if( isNativeValid() ) {
DisplayImpl display = (DisplayImpl) screen.getDisplay();
@@ -1255,6 +1260,55 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
return 0 != parentWindowHandle || undecorated || fullscreen ;
}
+ private class AlwaysOnTopActionImpl implements Runnable {
+ boolean alwaysOnTop;
+
+ private AlwaysOnTopActionImpl(boolean undecorated) {
+ this.alwaysOnTop = undecorated;
+ }
+
+ public final void run() {
+ windowLock.lock();
+ try {
+ if(WindowImpl.this.alwaysOnTop != alwaysOnTop) {
+ final boolean nativeAlwaysOnTopChange = !fullscreen && isNativeValid() &&
+ isAlwaysOnTop() != alwaysOnTop ;
+
+ // set current state
+ WindowImpl.this.alwaysOnTop = alwaysOnTop;
+
+ if( nativeAlwaysOnTopChange ) {
+ // Change decoration on active window
+
+ // Mirror pos/size so native change notification can get overwritten
+ final int x = WindowImpl.this.x;
+ final int y = WindowImpl.this.y;
+ final int width = WindowImpl.this.width;
+ final int height = WindowImpl.this.height;
+
+ if( isNativeValid() ) {
+ DisplayImpl display = (DisplayImpl) screen.getDisplay();
+ display.dispatchMessagesNative(); // status up2date
+ reconfigureWindowImpl(x, y, width, height, getReconfigureFlags(FLAG_CHANGE_ALWAYSONTOP, isVisible()));
+ display.dispatchMessagesNative(); // status up2date
+ }
+ }
+ }
+ } finally {
+ windowLock.unlock();
+ }
+ sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); // trigger a resize/relayout and repaint to listener
+ }
+ }
+
+ public final void setAlwaysOnTop(boolean value) {
+ runOnEDTIfAvail(true, new AlwaysOnTopActionImpl(value));
+ }
+
+ public final boolean isAlwaysOnTop() {
+ return alwaysOnTop || fullscreen ;
+ }
+
public void requestFocus() {
enqueueRequestFocus(true);
}
@@ -1354,7 +1408,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
"\n, Pos "+getX()+"/"+getY()+", size "+getWidth()+"x"+getHeight()+
"\n, Visible "+isVisible()+
"\n, Undecorated "+undecorated+" ("+isUndecorated()+")"+
- "\n, Fullscreen "+fullscreen+
+ "\n, AlwaysOnTop "+alwaysOnTop+", Fullscreen "+fullscreen+
"\n, WrappedWindow "+getWrappedWindow()+
"\n, ChildWindows "+childWindows.size());
diff --git a/src/newt/native/Window.h b/src/newt/native/Window.h
index f46d9fbe9..865746b91 100644
--- a/src/newt/native/Window.h
+++ b/src/newt/native/Window.h
@@ -2,23 +2,29 @@
#ifndef _WINDOW_H_
#define _WINDOW_H_
-#define FLAG_CHANGE_PARENTING ( 1 << 0 )
-#define FLAG_CHANGE_DECORATION ( 1 << 1 )
-#define FLAG_CHANGE_FULLSCREEN ( 1 << 2 )
-#define FLAG_CHANGE_VISIBILITY ( 1 << 3 )
-#define FLAG_HAS_PARENT ( 1 << 4 )
-#define FLAG_IS_UNDECORATED ( 1 << 5 )
-#define FLAG_IS_FULLSCREEN ( 1 << 6 )
-#define FLAG_IS_VISIBLE ( 1 << 7 )
+#define FLAG_CHANGE_PARENTING ( 1 << 0 )
+#define FLAG_CHANGE_DECORATION ( 1 << 1 )
+#define FLAG_CHANGE_FULLSCREEN ( 1 << 2 )
+#define FLAG_CHANGE_ALWAYSONTOP ( 1 << 3 )
+#define FLAG_CHANGE_VISIBILITY ( 1 << 4 )
-#define TST_FLAG_CHANGE_PARENTING(f) ( 0 != ( (f) & FLAG_CHANGE_PARENTING ) )
-#define TST_FLAG_CHANGE_DECORATION(f) ( 0 != ( (f) & FLAG_CHANGE_DECORATION ) )
-#define TST_FLAG_CHANGE_FULLSCREEN(f) ( 0 != ( (f) & FLAG_CHANGE_FULLSCREEN ) )
-#define TST_FLAG_CHANGE_VISIBILITY(f) ( 0 != ( (f) & FLAG_CHANGE_VISIBILITY ) )
+#define FLAG_HAS_PARENT ( 1 << 8 )
+#define FLAG_IS_UNDECORATED ( 1 << 9 )
+#define FLAG_IS_FULLSCREEN ( 1 << 10 )
+#define FLAG_IS_ALWAYSONTOP ( 1 << 11 )
+#define FLAG_IS_VISIBLE ( 1 << 12 )
+
+#define TST_FLAG_CHANGE_PARENTING(f) ( 0 != ( (f) & FLAG_CHANGE_PARENTING ) )
+#define TST_FLAG_CHANGE_DECORATION(f) ( 0 != ( (f) & FLAG_CHANGE_DECORATION ) )
+#define TST_FLAG_CHANGE_FULLSCREEN(f) ( 0 != ( (f) & FLAG_CHANGE_FULLSCREEN ) )
+#define TST_FLAG_CHANGE_ALWAYSONTOP(f) ( 0 != ( (f) & FLAG_CHANGE_ALWAYSONTOP ) )
+#define TST_FLAG_CHANGE_VISIBILITY(f) ( 0 != ( (f) & FLAG_CHANGE_VISIBILITY ) )
#define TST_FLAG_HAS_PARENT(f) ( 0 != ( (f) & FLAG_HAS_PARENT ) )
#define TST_FLAG_IS_UNDECORATED(f) ( 0 != ( (f) & FLAG_IS_UNDECORATED ) )
#define TST_FLAG_IS_FULLSCREEN(f) ( 0 != ( (f) & FLAG_IS_FULLSCREEN ) )
+#define TST_FLAG_IS_FULLSCREEN(f) ( 0 != ( (f) & FLAG_IS_FULLSCREEN ) )
+#define TST_FLAG_IS_ALWAYSONTOP(f) ( 0 != ( (f) & FLAG_IS_ALWAYSONTOP ) )
#define TST_FLAG_IS_VISIBLE(f) ( 0 != ( (f) & FLAG_IS_VISIBLE ) )
#endif
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java
index 3c7a8a006..ef7d86552 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java
@@ -70,6 +70,7 @@ public class TestGearsES2NEWT extends UITestCase {
}
protected void runTestGL(GLCapabilities caps, boolean undecorated) throws InterruptedException {
+ System.err.println("requested: "+caps);
GLWindow glWindow = GLWindow.create(caps);
Assert.assertNotNull(glWindow);
glWindow.setTitle("Gears NEWT Test (translucent "+!caps.isBackgroundOpaque()+")");
@@ -94,6 +95,13 @@ public class TestGearsES2NEWT extends UITestCase {
f_glWindow.setFullscreen(!f_glWindow.isFullscreen());
System.err.println("[set fullscreen post]: "+f_glWindow.getX()+"/"+f_glWindow.getY()+" "+f_glWindow.getWidth()+"x"+f_glWindow.getHeight()+", f "+f_glWindow.isFullscreen()+", "+f_glWindow.getInsets());
} }.start();
+ } else if(e.getKeyChar()=='a') {
+ new Thread() {
+ public void run() {
+ System.err.println("[set alwaysontop pre]: "+f_glWindow.getX()+"/"+f_glWindow.getY()+" "+f_glWindow.getWidth()+"x"+f_glWindow.getHeight()+", a "+f_glWindow.isAlwaysOnTop()+", "+f_glWindow.getInsets());
+ f_glWindow.setAlwaysOnTop(!f_glWindow.isAlwaysOnTop());
+ System.err.println("[set alwaysontop post]: "+f_glWindow.getX()+"/"+f_glWindow.getY()+" "+f_glWindow.getWidth()+"x"+f_glWindow.getHeight()+", a "+f_glWindow.isAlwaysOnTop()+", "+f_glWindow.getInsets());
+ } }.start();
} else if(e.getKeyChar()=='d') {
new Thread() {
public void run() {
@@ -116,6 +124,7 @@ public class TestGearsES2NEWT extends UITestCase {
glWindow.setVisible(true);
System.err.println("size/pos: "+f_glWindow.getX()+"/"+f_glWindow.getY()+" "+f_glWindow.getWidth()+"x"+f_glWindow.getHeight()+", "+f_glWindow.getInsets());
+ System.err.println("chosen: "+glWindow.getChosenCapabilities());
animator.setUpdateFPSFrames(1, null);
animator.start();