+ * The given icon will replace the default icon for this frame only.
+ * If the icon is null the default icon will be used instead.
+ * The default application icon can be set using the system properties with
+ * the key 'newt.window.icons'. More informations on the default application
+ * icon can be found in the Window class javadoc.
+ *
+ *
+ * @param icon frame icon or null for default icon.
+ */
+ void setIcon(PixelRectangle icon);
+
+ /**
+ * Get window icon.
+ *
+ * @return window icon, can be null
+ */
+ PixelRectangle getIcon();
/** @see #setPointerVisible(boolean) */
boolean isPointerVisible();
diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
index 3ef017d..5389d14 100644
--- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
+++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
@@ -75,6 +75,7 @@ import jogamp.opengl.GLDrawableImpl;
import com.jogamp.common.GlueGenVersion;
import com.jogamp.common.util.VersionUtil;
import com.jogamp.common.util.locks.RecursiveLock;
+import com.jogamp.nativewindow.util.PixelRectangle;
import com.jogamp.newt.MonitorDevice;
import com.jogamp.newt.NewtFactory;
import com.jogamp.newt.Screen;
@@ -527,6 +528,16 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind
return window.getLocationOnScreen(storage);
}
+ @Override
+ public void setIcon(PixelRectangle icon) {
+ window.setIcon(icon);
+ }
+
+ @Override
+ public PixelRectangle getIcon() {
+ return window.getIcon();
+ }
+
// Hide methods here ..
protected class GLLifecycleHook implements WindowImpl.LifecycleHook {
diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java
index 8e31d1d..7660d8c 100644
--- a/src/newt/classes/jogamp/newt/WindowImpl.java
+++ b/src/newt/classes/jogamp/newt/WindowImpl.java
@@ -182,6 +182,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
private boolean nfs_alwaysOnTop; // non fullscreen alwaysOnTop setting
private NativeWindow nfs_parent = null; // non fullscreen parent, in case explicit reparenting is performed (offscreen)
private String title = "Newt Window";
+ private PixelRectangle icon = null;
private boolean undecorated = false;
private boolean alwaysOnTop = false;
private PointerIconImpl pointerIcon = null;
@@ -716,6 +717,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
protected void setTitleImpl(final String title) {}
+ protected void setIconImpl(final PixelRectangle icon) {}
+
/**
* Translates the given window client-area coordinates with top-left origin
* to screen coordinates in window units.
@@ -1739,6 +1742,25 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
}
@Override
+ public final PixelRectangle getIcon() {
+ return icon;
+ }
+ @Override
+ public final void setIcon(PixelRectangle icon) {
+ if(this.icon==icon) return;
+
+ this.icon = icon;
+ if(0 != getWindowHandle()) {
+ if(icon==null){
+ //reset default icon
+ setIconImpl(null);
+ }else{
+ setIconImpl(icon);
+ }
+ }
+ }
+
+ @Override
public final boolean isPointerVisible() {
return pointerVisible;
}
diff --git a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java
index 6cf9727..9985638 100644
--- a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java
@@ -52,6 +52,8 @@ import com.jogamp.nativewindow.util.Point;
import com.jogamp.common.ExceptionUtils;
import com.jogamp.common.nio.Buffers;
+import com.jogamp.nativewindow.util.DimensionImmutable;
+import com.jogamp.nativewindow.util.PixelRectangle;
import com.jogamp.nativewindow.x11.X11GraphicsDevice;
import com.jogamp.nativewindow.x11.X11GraphicsScreen;
import com.jogamp.newt.NewtFactory;
@@ -276,6 +278,34 @@ public class WindowDriver extends WindowImpl {
}
});
}
+
+ @Override
+ protected void setIconImpl(final PixelRectangle icon) {
+ if(icon!=null){
+ final DimensionImmutable size = icon.getSize();
+ final int pixelDataSize = size.getWidth() * size.getHeight() * icon.getPixelformat().comp.bytesPerPixel();
+ final Buffer pixels = icon.getPixels();
+
+ runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable