Revision: 3498
          http://vexi.svn.sourceforge.net/vexi/?rev=3498&view=rev
Author:   clrg
Date:     2009-05-18 13:24:47 +0000 (Mon, 18 May 2009)

Log Message:
-----------
Improved multi-monitor support (work against default screen rather than 
guessing)

Modified Paths:
--------------
    trunk/core/org.vexi.core/src/org/vexi/core/Surface.java
    trunk/core/org.vexi.core/src/org/vexi/core/Vexi.jpp
    trunk/core/org.vexi.core/src/org/vexi/plat/AWT.java
    trunk/core/org.vexi.core/src/org/vexi/plat/Platform.java

Modified: trunk/core/org.vexi.core/src/org/vexi/core/Surface.java
===================================================================
--- trunk/core/org.vexi.core/src/org/vexi/core/Surface.java     2009-05-18 
11:28:55 UTC (rev 3497)
+++ trunk/core/org.vexi.core/src/org/vexi/core/Surface.java     2009-05-18 
13:24:47 UTC (rev 3498)
@@ -4,6 +4,7 @@
 
 package org.vexi.core;
 
+import java.awt.Rectangle;
 import java.net.URL;
 import java.util.Stack;
 
@@ -351,15 +352,16 @@
     private final Callable poschanger = new Callable() {
         public Object run(Object o) throws JSExn {
             poschangeScheduled = false;
-            int sw = Platform.getScreenWidth();
-            int sh = Platform.getScreenHeight();
+            Rectangle s = Platform.getScreenBounds();;
             // horizontal
             int rootx = leftAlign ? x :
-                x - sw + leftInset + rightInset + root.maxwidth;
+                x - s.width + leftInset + rightInset + root.maxwidth;
+            rootx -= s.x;
             if (!rightAlign) rootx = rootx / 2;
             // vertical
             int rooty = topAlign ? y :
-                y - sh + leftInset + rightInset + root.maxheight;
+                y - s.height + leftInset + rightInset + root.maxheight;
+            rooty -= s.y;
             if (!bottomAlign) rooty = rooty / 2;
             root.setRootPosition(rootx, rooty);
             return o;
@@ -378,20 +380,21 @@
 
     /** set the position of the frame or window according to the root box 
position and frame alignment */
     protected final void setPosition() {
-        int sw = Platform.getScreenWidth();
-        int sh = Platform.getScreenHeight();
+        Rectangle s = Platform.getScreenBounds();
         int x = this.x;
         int y = this.y;
         // horizontal
         if (leftAlign) x = root.x;
         else if (rightAlign)
-            x = root.x+sw-leftInset-rightInset-pendingWidth;
-        else x = root.x+(sw-leftInset-rightInset-pendingWidth)/2;
+            x = root.x+s.width-leftInset-rightInset-pendingWidth;
+        else x = root.x+(s.width-leftInset-rightInset-pendingWidth)/2;
+        x += s.x;
         // vertical
         if (topAlign) y = root.y;
         else if (bottomAlign)
-            y = root.y+sh-leftInset-rightInset-pendingHeight;
-        else y = root.y+(sh-topInset-bottomInset-pendingHeight)/2;
+            y = root.y+s.height-leftInset-rightInset-pendingHeight;
+        else y = root.y+(s.height-topInset-bottomInset-pendingHeight)/2;
+        y += s.y;
         // propagate to frame/window
         if (x!=this.x || y!=this.y) {
             this.x = x;
@@ -523,15 +526,17 @@
         JS align = b.getAndTriggerTraps(SC_framealign);
         surface.setAlign(align == null ? null : JSU.toString(align));
         
+        Rectangle s = Platform.getScreenBounds();
+        
         JS framewidth = b.getAndTriggerTraps(SC_framewidth);
-        int w = framewidth != null ? JSU.toInt(framewidth) : 
Platform.getScreenWidth() / 2;
+        int w = framewidth != null ? JSU.toInt(framewidth) : s.width/2;
         
         JS frameheight = b.getAndTriggerTraps(SC_frameheight);
-        int h = frameheight != null ? JSU.toInt(frameheight) : 
Platform.getScreenHeight() / 2;
+        int h = frameheight != null ? JSU.toInt(frameheight) : s.height/2;
         surface.setSize(w, h);
         
         surface.setPosition();
-        surface.dirty(); // invokes Refresh()
+        surface.Refresh();
         return surface;
     }
 
@@ -618,7 +623,7 @@
 
         public DoubleBufferedSurface(Box root) { super(root); }
         public PixelBuffer getPixelBuffer() { return this; }
-        final protected PixelBuffer backbuffer = 
Platform.createPixelBuffer(Platform.getScreenWidth(), 
Platform.getScreenHeight(), this);
+        final protected PixelBuffer backbuffer = 
Platform.createPixelBuffer(Platform.getScreenBounds().width, 
Platform.getScreenBounds().height, this);
         final private DirtyList screenDirtyRegions = new DirtyList();
 
         /** draw an unscaled image onto the backbuffer where:

Modified: trunk/core/org.vexi.core/src/org/vexi/core/Vexi.jpp
===================================================================
--- trunk/core/org.vexi.core/src/org/vexi/core/Vexi.jpp 2009-05-18 11:28:55 UTC 
(rev 3497)
+++ trunk/core/org.vexi.core/src/org/vexi/core/Vexi.jpp 2009-05-18 13:24:47 UTC 
(rev 3498)
@@ -160,8 +160,8 @@
         case "ui.clipboard": return JSU.S((String)Platform.getClipBoard());
         case "ui.maxdim": return JSU.N(Short.MAX_VALUE);
         case "ui.screen": return getSub(name);
-        case "ui.screen.width": return JSU.N(Platform.getScreenWidth());
-        case "ui.screen.height": return JSU.N(Platform.getScreenHeight());
+        case "ui.screen.width": return JSU.N(Platform.getScreenBounds().width);
+        case "ui.screen.height": return 
JSU.N(Platform.getScreenBounds().height);
         case "unclone": return METHOD;
         case "undocumented": return getSub(name);
         case "undocumented.initialOrigin": return JSU.S(Main.origin);

Modified: trunk/core/org.vexi.core/src/org/vexi/plat/AWT.java
===================================================================
--- trunk/core/org.vexi.core/src/org/vexi/plat/AWT.java 2009-05-18 11:28:55 UTC 
(rev 3497)
+++ trunk/core/org.vexi.core/src/org/vexi/plat/AWT.java 2009-05-18 13:24:47 UTC 
(rev 3498)
@@ -73,18 +73,9 @@
     protected Picture _createPicture(JS r) { return new AWTPicture(r); }
     protected Surface _createSurface(Box b, boolean framed) { return new 
AWTSurface(b, framed); }
 
-    protected int _getScreenWidth() {  return 
getPrimaryDisplayConfiguration().getBounds().width; }
-    protected int _getScreenHeight() { return 
getPrimaryDisplayConfiguration().getBounds().height; }
+    protected Rectangle _getScreenBounds() { return 
getPrimaryDisplayConfiguration().getBounds(); }
     private GraphicsConfiguration getPrimaryDisplayConfiguration() {
-        // place us in the middle of the primary display device
-        GraphicsEnvironment ge = 
GraphicsEnvironment.getLocalGraphicsEnvironment();
-        GraphicsDevice[] gs = ge.getScreenDevices();
-        for (int j=0; j < gs.length; j++) {
-            GraphicsDevice gd = gs[j];
-            GraphicsConfiguration[] gc = gd.getConfigurations();
-            for (int i=0; i < gc.length; i++) return gc[i];
-        }
-        throw new Error("Could not find valid display device configuration");
+        return 
GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
     }
 
     protected void postInit() {
@@ -259,7 +250,9 @@
 
         public AWTPixelBuffer() { }
         public AWTPixelBuffer(Image i) { this.i = i; g = i.getGraphics(); }
-        public AWTPixelBuffer(AWTSurface s) { this(Platform.getScreenWidth(), 
Platform.getScreenHeight()); this.surface = s; }
+        public AWTPixelBuffer(AWTSurface s) {
+            this(Platform.getScreenBounds().width, 
Platform.getScreenBounds().height); this.surface = s;
+        }
         public AWTPixelBuffer(int w, int h) {
             synchronized(AWTPixelBuffer.class) {
                 if (component == null) {

Modified: trunk/core/org.vexi.core/src/org/vexi/plat/Platform.java
===================================================================
--- trunk/core/org.vexi.core/src/org/vexi/plat/Platform.java    2009-05-18 
11:28:55 UTC (rev 3497)
+++ trunk/core/org.vexi.core/src/org/vexi/plat/Platform.java    2009-05-18 
13:24:47 UTC (rev 3498)
@@ -4,6 +4,7 @@
 
 package org.vexi.plat;
 
+import java.awt.Rectangle;
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.IOException;
@@ -151,14 +152,10 @@
     public static void setClipBoard(String s) { platform._setClipBoard(s); }
     protected void _setClipBoard(String s) { }
 
-    /** returns the width of the screen, in pixels */
-    public static int getScreenWidth() { return platform._getScreenWidth(); }
-    protected int _getScreenWidth() { return 640; }
+    /** returns a rectangle matching the bounds of the screen, in pixels */
+    public static Rectangle getScreenBounds() { return 
platform._getScreenBounds(); }
+    protected Rectangle _getScreenBounds() { return new Rectangle(); }
 
-    /** returns the height of the screen, in pixels */
-    public static int getScreenHeight() { return platform._getScreenHeight(); }
-    protected int _getScreenHeight() { return 480; }
-
     /** used to notify the user of very serious failures; usually used when 
logging is not working or unavailable */
     protected void _criticalAbort(String message) { System.exit(-1); }
     public static void criticalAbort(String message) {


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables 
unlimited royalty-free distribution of the report engine 
for externally facing server and web deployment. 
http://p.sf.net/sfu/businessobjects
_______________________________________________
Vexi-svn mailing list
Vexi-svn@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to