aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/JAWTWindow.java68
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/macosx/MacOSXJAWTWindow.java5
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/windows/WindowsJAWTWindow.java17
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/x11/X11JAWTWindow.java24
-rw-r--r--src/newt/classes/com/jogamp/newt/impl/windows/WindowsWindow.java2
5 files changed, 84 insertions, 32 deletions
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/JAWTWindow.java
index 8ef2ba227..de6360212 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/JAWTWindow.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/JAWTWindow.java
@@ -41,7 +41,10 @@ import com.jogamp.common.util.locks.RecursiveLock;
import java.awt.Component;
import java.awt.Window;
-import javax.media.nativewindow.*;
+import javax.media.nativewindow.AbstractGraphicsConfiguration;
+import javax.media.nativewindow.NativeSurface;
+import javax.media.nativewindow.NativeWindow;
+import javax.media.nativewindow.NativeWindowException;
import javax.media.nativewindow.util.Point;
import javax.media.nativewindow.util.Rectangle;
@@ -64,12 +67,11 @@ public abstract class JAWTWindow implements NativeWindow {
init((Component)comp);
}
- protected void init(Component windowObject) throws NativeWindowException {
+ private final void init(Component windowObject) throws NativeWindowException {
invalidate();
this.component = windowObject;
validateNative();
}
-
protected abstract void validateNative() throws NativeWindowException;
protected synchronized void invalidate() {
@@ -78,7 +80,7 @@ public abstract class JAWTWindow implements NativeWindow {
bounds = new Rectangle();
}
- protected void updateBounds(JAWT_Rectangle jawtBounds) {
+ protected final void updateBounds(JAWT_Rectangle jawtBounds) {
bounds.setX(jawtBounds.getX());
bounds.setY(jawtBounds.getY());
bounds.setWidth(jawtBounds.getWidth());
@@ -86,9 +88,9 @@ public abstract class JAWTWindow implements NativeWindow {
}
/** @return the JAWT_DrawingSurfaceInfo's (JAWT_Rectangle) bounds, updated with lock */
- public Rectangle getBounds() { return bounds; }
+ public final Rectangle getBounds() { return bounds; }
- public Component getAWTComponent() {
+ public final Component getAWTComponent() {
return component;
}
@@ -96,7 +98,7 @@ public abstract class JAWTWindow implements NativeWindow {
// SurfaceUpdateListener
//
- public void surfaceUpdated(Object updater, NativeSurface ns, long when) {
+ public final void surfaceUpdated(Object updater, NativeSurface ns, long when) {
// nop
}
@@ -158,36 +160,36 @@ public abstract class JAWTWindow implements NativeWindow {
return recurLock.getOwner();
}
- public boolean surfaceSwap() {
+ public final boolean surfaceSwap() {
return false;
}
- public void surfaceUpdated(Object updater, NativeWindow window, long when) { }
+ public final void surfaceUpdated(Object updater, NativeWindow window, long when) { }
- public long getSurfaceHandle() {
+ public final long getSurfaceHandle() {
return drawable;
}
- public AbstractGraphicsConfiguration getGraphicsConfiguration() {
+ public final AbstractGraphicsConfiguration getGraphicsConfiguration() {
return config;
}
- public long getDisplayHandle() {
+ public final long getDisplayHandle() {
return config.getScreen().getDevice().getHandle();
}
- public int getScreenIndex() {
+ public final int getScreenIndex() {
return config.getScreen().getIndex();
}
- public void setSize(int width, int height) {
+ public final void setSize(int width, int height) {
component.setSize(width, height);
}
- public int getWidth() {
+ public final int getWidth() {
return component.getWidth();
}
- public int getHeight() {
+ public final int getHeight() {
return component.getHeight();
}
@@ -204,7 +206,7 @@ public abstract class JAWTWindow implements NativeWindow {
invalidate();
}
- public NativeWindow getParent() {
+ public final NativeWindow getParent() {
return null;
}
@@ -212,23 +214,45 @@ public abstract class JAWTWindow implements NativeWindow {
return drawable;
}
- public int getX() {
+ public final int getX() {
return component.getX();
}
- public int getY() {
+ public final int getY() {
return component.getY();
}
- public Point getLocationOnScreen(Point point) {
+ public Point getLocationOnScreen(Point storage) {
+ if( 0 != getWindowHandle() ) {
+ Point d;
+ // windowLock.lock();
+ try {
+ d = getLocationOnScreenImpl(0, 0);
+ } finally {
+ // windowLock.unlock();
+ }
+ if(null!=d) {
+ if(null!=storage) {
+ storage.translate(d.getX(),d.getY());
+ return storage;
+ }
+ return d;
+ }
+ // fall through intended ..
+ }
+
+ if(!Thread.holdsLock(component.getTreeLock())) {
+ return null; // avoid deadlock ..
+ }
java.awt.Point awtLOS = component.getLocationOnScreen();
int dx = (int) ( awtLOS.getX() + .5 ) ;
int dy = (int) ( awtLOS.getY() + .5 ) ;
- if(null!=point) {
- return point.translate(dx, dy);
+ if(null!=storage) {
+ return storage.translate(dx, dy);
}
return new Point(dx, dy);
}
+ protected abstract Point getLocationOnScreenImpl(int x, int y);
public String toString() {
StringBuffer sb = new StringBuffer();
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/macosx/MacOSXJAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/macosx/MacOSXJAWTWindow.java
index bcaa66847..f511c7082 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/macosx/MacOSXJAWTWindow.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/macosx/MacOSXJAWTWindow.java
@@ -47,6 +47,7 @@ import java.awt.GraphicsEnvironment;
import javax.media.nativewindow.*;
import java.security.*;
+import javax.media.nativewindow.util.Point;
public class MacOSXJAWTWindow extends JAWTWindow {
@@ -125,6 +126,10 @@ public class MacOSXJAWTWindow extends JAWTWindow {
macosxdsi = null;
}
+ protected Point getLocationOnScreenImpl(int x, int y) {
+ return null; // FIXME
+ }
+
// Variables for lockSurface/unlockSurface
private JAWT_DrawingSurface ds;
private boolean dsLocked;
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/windows/WindowsJAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/windows/WindowsJAWTWindow.java
index d19a11f66..14d6eebcd 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/windows/WindowsJAWTWindow.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/windows/WindowsJAWTWindow.java
@@ -40,10 +40,17 @@
package com.jogamp.nativewindow.impl.jawt.windows;
-import com.jogamp.nativewindow.impl.*;
-import com.jogamp.nativewindow.impl.jawt.*;
+import com.jogamp.nativewindow.impl.jawt.JAWT;
+import com.jogamp.nativewindow.impl.jawt.JAWTFactory;
+import com.jogamp.nativewindow.impl.jawt.JAWTWindow;
+import com.jogamp.nativewindow.impl.jawt.JAWT_DrawingSurface;
+import com.jogamp.nativewindow.impl.jawt.JAWT_DrawingSurfaceInfo;
+import com.jogamp.nativewindow.impl.windows.GDI;
-import javax.media.nativewindow.*;
+import javax.media.nativewindow.AbstractGraphicsConfiguration;
+import javax.media.nativewindow.NativeWindow;
+import javax.media.nativewindow.NativeWindowException;
+import javax.media.nativewindow.util.Point;
public class WindowsJAWTWindow extends JAWTWindow {
@@ -152,6 +159,10 @@ public class WindowsJAWTWindow extends JAWTWindow {
return windowHandle;
}
+ protected Point getLocationOnScreenImpl(int x, int y) {
+ return GDI.GetRelativeLocation( getWindowHandle(), 0 /*root win*/, x, y);
+ }
+
// Variables for lockSurface/unlockSurface
private JAWT_DrawingSurface ds;
private boolean dsLocked;
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/x11/X11JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/x11/X11JAWTWindow.java
index a5d36b6dd..1324bd199 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/x11/X11JAWTWindow.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/x11/X11JAWTWindow.java
@@ -37,12 +37,20 @@
package com.jogamp.nativewindow.impl.jawt.x11;
-import javax.media.nativewindow.*;
-import javax.media.nativewindow.awt.*;
-
-import com.jogamp.nativewindow.impl.x11.*;
-import com.jogamp.nativewindow.impl.jawt.*;
-
+import com.jogamp.nativewindow.impl.jawt.JAWT;
+import com.jogamp.nativewindow.impl.jawt.JAWTFactory;
+import com.jogamp.nativewindow.impl.jawt.JAWTWindow;
+import com.jogamp.nativewindow.impl.jawt.JAWT_DrawingSurface;
+import com.jogamp.nativewindow.impl.jawt.JAWT_DrawingSurfaceInfo;
+import com.jogamp.nativewindow.impl.x11.X11Util;
+import javax.media.nativewindow.AbstractGraphicsConfiguration;
+import javax.media.nativewindow.AbstractGraphicsDevice;
+import javax.media.nativewindow.AbstractGraphicsScreen;
+import javax.media.nativewindow.NativeWindow;
+import javax.media.nativewindow.NativeWindowException;
+import javax.media.nativewindow.NativeWindowFactory;
+import javax.media.nativewindow.awt.AWTGraphicsDevice;
+import javax.media.nativewindow.util.Point;
public class X11JAWTWindow extends JAWTWindow {
@@ -134,6 +142,10 @@ public class X11JAWTWindow extends JAWTWindow {
x11dsi = null;
}
+ protected Point getLocationOnScreenImpl(int x, int y) {
+ return X11Util.GetRelativeLocation( getDisplayHandle(), getScreenIndex(), getWindowHandle(), 0 /*root win*/, x, y);
+ }
+
// Variables for lockSurface/unlockSurface
private JAWT_DrawingSurface ds;
private boolean dsLocked;
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 1691e4bf0..2c3ffc3cc 100644
--- a/src/newt/classes/com/jogamp/newt/impl/windows/WindowsWindow.java
+++ b/src/newt/classes/com/jogamp/newt/impl/windows/WindowsWindow.java
@@ -169,7 +169,7 @@ public class WindowsWindow extends WindowImpl {
}
protected Point getLocationOnScreenImpl(int x, int y) {
- return (Point) GDI.GetRelativeLocation( getWindowHandle(), 0 /*root win*/, x, y);
+ return GDI.GetRelativeLocation( getWindowHandle(), 0 /*root win*/, x, y);
}
//----------------------------------------------------------------------