2002/09/02 18:37:29
[org.ibex.core.git] / src / org / xwt / plat / AWT.java
index 5f12430..ad67bc0 100644 (file)
@@ -69,8 +69,16 @@ public class AWT extends Platform {
     /** some platforms (cough, cough, NetscapeVM) have totally broken modifier masks; they will need to override this */
     protected static int modifiersToButtonNumber(int modifiers) {
         if ((modifiers & InputEvent.BUTTON1_MASK) == InputEvent.BUTTON1_MASK) return 1;
-        if ((modifiers & InputEvent.BUTTON2_MASK) == InputEvent.BUTTON2_MASK) return 3;
-        if ((modifiers & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK) return 2;
+        if ((modifiers & InputEvent.BUTTON2_MASK) == InputEvent.BUTTON2_MASK) {
+            // ugh, MacOSX reports the right mouse button as BUTTON2_MASK...
+            if (System.getProperty("os.name", "").startsWith("Mac OS X")) return 2;
+            return 3;
+        }
+        if ((modifiers & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK) {
+            // ugh, MacOSX reports the right mouse button as BUTTON2_MASK...
+            if (System.getProperty("os.name", "").startsWith("Mac OS X")) return 3;
+            return 2;
+        }
         return 0;
     }
 
@@ -233,9 +241,6 @@ public class AWT extends Platform {
                     componentResized(window.getWidth() - insets.left - insets.right, window.getHeight() - insets.top - insets.bottom);
 
                 Dirty(r.x - insets.left, r.y - insets.top, r.width, r.height);
-
-                // this is safe because AWT's low-level drawing functions are threadsafe
-                blitDirtyScreenRegions();
             }
         }
 
@@ -245,9 +250,6 @@ public class AWT extends Platform {
             public void paint(Graphics gr) {
                 Rectangle r = gr.getClipBounds();
                 Dirty(r.x - insets.left, r.y - insets.top, r.width, r.height);
-
-                // this is safe because AWT's low-level drawing functions are threadsafe
-                blitDirtyScreenRegions();
             }
         }
 
@@ -273,9 +275,10 @@ public class AWT extends Platform {
 
             // IMPORTANT: this must be called before render() to ensure
             // that our peer has been created
-            window.setVisible(true);
-
+            makeVisible();
         }
+
+        protected void makeVisible() { window.setVisible(true); }
         
         public void _dispose() {
             window.removeMouseListener(this);
@@ -324,7 +327,7 @@ public class AWT extends Platform {
         public void windowDeiconified(WindowEvent e) { dirty(0, 0, width, height); Minimized(false); }
         public void windowActivated(WindowEvent e) { Focused(true); }
         public void windowDeactivated(WindowEvent e) { Focused(false); }
-        public void componentMoved(ComponentEvent e) { PosChange(window.getLocation().x, window.getLocation().y); }
+       public void componentMoved(ComponentEvent e) { PosChange(window.getLocation().x + insets.left, window.getLocation().y + insets.top); }
 
         public void componentResized(ComponentEvent e) {
             // we have to periodically do this; I don't know why
@@ -343,7 +346,7 @@ public class AWT extends Platform {
 
             ourGraphics = null;
         }
-        
+
         public void keyTyped(KeyEvent k) { }
         public void keyPressed(KeyEvent k) { KeyPressed(translateKey(k)); }
         public void keyReleased(KeyEvent k) { KeyReleased(translateKey(k)); }
@@ -430,7 +433,11 @@ public class AWT extends Platform {
         if (ret == null) {
             pf.parse(font);
             if (pf.name.equals("tty")) pf.name = "monospace";
-            ret = new MetricatedFont(pf.name, (pf.bold ? Font.BOLD : 0) | (pf.italic ? Font.ITALIC : 0), pf.size);
+            
+            // Java's fonts tend to be, on average, two points smaller than Win32/X11 fonts. This is most acute in
+            // the proxy password dialog on Linux
+            ret = new MetricatedFont(pf.name, (pf.bold ? Font.BOLD : 0) | (pf.italic ? Font.ITALIC : 0), pf.size + 2);
+
             fontCache.put(font, ret);
         }
         return ret;