summaryrefslogtreecommitdiffstats
path: root/src/newt
diff options
context:
space:
mode:
Diffstat (limited to 'src/newt')
-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
4 files changed, 98 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