Revision: 4067
          http://vexi.svn.sourceforge.net/vexi/?rev=4067&view=rev
Author:   clrg
Date:     2011-03-24 03:35:30 +0000 (Thu, 24 Mar 2011)

Log Message:
-----------
Fix #45 - irregular maximize behaviour

Modified Paths:
--------------
    trunk/org.vexi-core.main/src/main/java/org/vexi/plat/Swing.java

Modified: trunk/org.vexi-core.main/src/main/java/org/vexi/plat/Swing.java
===================================================================
--- trunk/org.vexi-core.main/src/main/java/org/vexi/plat/Swing.java     
2011-03-24 03:22:24 UTC (rev 4066)
+++ trunk/org.vexi-core.main/src/main/java/org/vexi/plat/Swing.java     
2011-03-24 03:35:30 UTC (rev 4067)
@@ -307,12 +307,20 @@
             }
             public void paint(Graphics g) {
                 super.paint(g);
-                if (maximized!=((getExtendedState() & 
JFrame.MAXIMIZED_BOTH)!=0)) {
-                    setExtendedState(maximized ? JFrame.MAXIMIZED_BOTH : 
JFrame.NORMAL);
+                final int state = getExtendedState();
+                if (maximized) {
+                    if ((state & JFrame.MAXIMIZED_BOTH)==0) {
+                        setExtendedState(JFrame.MAXIMIZED_BOTH | (state & 
JFrame.ICONIFIED));
+                    }
                 }
-                if (minimized!=((getExtendedState() & JFrame.ICONIFIED)!=0)) {
-                    frame.setExtendedState(minimized ? JFrame.ICONIFIED : 
JFrame.NORMAL);
+                if (minimized) {
+                    if ((state & JFrame.ICONIFIED)==0) {
+                        frame.setExtendedState(JFrame.ICONIFIED | (state & 
JFrame.MAXIMIZED_BOTH));
+                    }
                 }
+                if ((state & JFrame.NORMAL)==0) {
+                    frame.setExtendedState(JFrame.NORMAL);
+                }
             }
 
 //            public ComponentAdapter enforceMinSize = new ComponentAdapter() {
@@ -575,7 +583,24 @@
             else if (cursor.equals("hand")) 
window.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
             else 
window.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
         }
-        
+
+        public boolean _isLockingKeyOn(int key) {
+            // AWT's support for getLockingKeyState is minimal at best and
+            // more often than not throws an UnsupportedOperationException
+            int eventkeyid = -1;
+            switch (key) {
+            case Surface.CAPS_LOCK: eventkeyid = KeyEvent.VK_CAPS_LOCK; break;
+            case Surface.KANA_LOCK: eventkeyid = KeyEvent.VK_KANA_LOCK; break;
+            case Surface.NUM_LOCK: eventkeyid = KeyEvent.VK_NUM_LOCK; break;
+            case Surface.SCROLL_LOCK: eventkeyid = KeyEvent.VK_SCROLL_LOCK; 
break;
+            }
+            if (eventkeyid == -1) {
+                return false;
+            }
+            return window.getToolkit().getLockingKeyState(eventkeyid);
+        }
+
+
         // AWT Message translation 
////////////////////////////////////////////////////////////////
         
         // These functions are all executed in the AWT thread, not the
@@ -595,9 +620,12 @@
         public void windowActivated(WindowEvent e) { Focused(true); }
         public void windowDeactivated(WindowEvent e) { Focused(false); }
         public void windowStateChanged(WindowEvent e) {
-            boolean maximized = (e.getNewState() & JFrame.MAXIMIZED_BOTH) != 0;
-            if (maximized != this.maximized) {
-                Maximized(maximized);
+            if (e.getOldState() != e.getNewState()) {
+                if ((e.getNewState() & Frame.MAXIMIZED_BOTH) != 0) {
+                    Maximized(true);
+                } else if (((e.getOldState() & Frame.MAXIMIZED_BOTH) != 0) && 
(e.getNewState() & Frame.MAXIMIZED_BOTH) == 0) {
+                    Maximized(false);
+                }
             }
         }
         public void componentMoved(ComponentEvent e) { 
PosChange(window.getLocation().x, window.getLocation().y); }
@@ -665,21 +693,6 @@
             // FIXME: take into account WHEEL_BLOCK_SCROLL / WHEEL_UNIT_SCROLL
             VScroll(notches);
         }
-        protected boolean _isLockingKeyOn(int key) {
-            // AWT's support for getLockingKeyState is minimal at best and
-            // more often than not throws an UnsupportedOperationException
-            int eventkeyid = -1;
-            switch (key) {
-            case Surface.CAPS_LOCK: eventkeyid = KeyEvent.VK_CAPS_LOCK; break;
-            case Surface.KANA_LOCK: eventkeyid = KeyEvent.VK_KANA_LOCK; break;
-            case Surface.NUM_LOCK: eventkeyid = KeyEvent.VK_NUM_LOCK; break;
-            case Surface.SCROLL_LOCK: eventkeyid = KeyEvent.VK_SCROLL_LOCK; 
break;
-            }
-            if (eventkeyid == -1) {
-                return false;
-            }
-            return window.getToolkit().getLockingKeyState(eventkeyid);
-        }
         
         String translateKey(KeyEvent k) {
             switch (k.getKeyCode()) {


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

------------------------------------------------------------------------------
Enable your software for Intel(R) Active Management Technology to meet the
growing manageability and security demands of your customers. Businesses
are taking advantage of Intel(R) vPro (TM) technology - will your software 
be a part of the solution? Download the Intel(R) Manageability Checker 
today! http://p.sf.net/sfu/intel-dev2devmar
_______________________________________________
Vexi-svn mailing list
Vexi-svn@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to