src/macosx/classes/sun/lwawt/macosx/CPlatformLWWindow.java
Print this page
*** 27,42 ****
--- 27,48 ----
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.GraphicsDevice;
+ import java.awt.GraphicsEnvironment;
import java.awt.Insets;
import java.awt.MenuBar;
import java.awt.Point;
+ import java.awt.Rectangle;
import java.awt.Window;
+ import sun.awt.CGraphicsDevice;
+ import sun.awt.CGraphicsEnvironment;
import sun.awt.CausedFocusEvent;
+ import sun.awt.LightweightFrame;
import sun.java2d.SurfaceData;
+ import sun.lwawt.LWLightweightFramePeer;
import sun.lwawt.LWWindowPeer;
import sun.lwawt.PlatformWindow;
public class CPlatformLWWindow extends CPlatformWindow {
*** 71,85 ****
public Point getLocationOnScreen() {
return null;
}
@Override
- public GraphicsDevice getGraphicsDevice() {
- return null;
- }
-
- @Override
public SurfaceData getScreenSurface() {
return null;
}
@Override
--- 77,86 ----
*** 197,202 ****
--- 198,223 ----
@Override
public long getLayerPtr() {
return 0;
}
+
+ @Override
+ public GraphicsDevice getGraphicsDevice() {
+ CGraphicsEnvironment ge = (CGraphicsEnvironment)GraphicsEnvironment.
+ getLocalGraphicsEnvironment();
+
+ LWLightweightFramePeer peer = (LWLightweightFramePeer)getPeer();
+ int scale = ((LightweightFrame)peer.getTarget()).getScaleFactor();
+
+ Rectangle bounds = ((LightweightFrame)peer.getTarget()).getHostBounds();
+ for (GraphicsDevice d : ge.getScreenDevices()) {
+ if (d.getDefaultConfiguration().getBounds().intersects(bounds) &&
+ ((CGraphicsDevice)d).getScaleFactor() == scale)
+ {
+ return d;
+ }
+ }
+ // We shouldn't be here...
+ return ge.getDefaultScreenDevice();
+ }
}