Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [albireo-dev] size/layout platform testing

!   I will therefore disable the propagation from SWT to AWT since it's
!   redundant with the COMPONENT_RESIZED event.

I applied this. Made setAWTSize private instead of protected, because now
that this method is used only on some platforms and not on others, users
should not override it.

Bruno

Index: src/org/eclipse/albireo/core/SwingControl.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.albireo/org.eclipse.albireo.core/src/org/eclipse/albireo/core/SwingControl.java,v
retrieving revision 1.42
diff -c -3 -r1.42 SwingControl.java
*** src/org/eclipse/albireo/core/SwingControl.java	26 Feb 2008 00:38:13 -0000	1.42
--- src/org/eclipse/albireo/core/SwingControl.java	26 Feb 2008 19:55:08 -0000
***************
*** 569,575 ****
          }
      }
  
!     protected void setAWTSize(final int width, final int height) {
          assert Display.getCurrent() != null;     // On SWT event thread
          if (verboseSizeLayout)
              System.err.println("SWT thread: Preparing to set size: " + width + " x " + height + " for " + swingComponent);
--- 569,588 ----
          }
      }
  
!     /**
!      * True if setting the size of this control on the SWT side automatically
!      * resizes the frame and posts a COMPONENT_RESIZED event for the frame to
!      * the AWT event queue.
!      * On platforms where you are not sure, set this constant to false.
!      */
!     static final boolean AUTOMATIC_SET_AWT_SIZE =
!         Platform.isGtk() || Platform.isCarbon();
! 
!     /**
!      * Propagate the width and height from SWT to the AWT frame.
!      * Only used if !AUTOMATIC_SET_AWT_SIZE.
!      */
!     private void setAWTSize(final int width, final int height) {
          assert Display.getCurrent() != null;     // On SWT event thread
          if (verboseSizeLayout)
              System.err.println("SWT thread: Preparing to set size: " + width + " x " + height + " for " + swingComponent);
***************
*** 609,635 ****
          checkPopulated();
          if (verboseSizeLayout)
              System.err.println("SWT thread: setBounds called: "+width+" x "+height);
!         // Pass on the desired size to the embedded component, but only if it could 
!         // be reasonably calculated (i.e. we have cached preferred sizes) and if
!         // computeSize took it into account.
!         // If, however, the SWT side specifies a size for the component while
!         // cachedSizesInitialized < 2 (i.e. usually, before the Swing component
!         // is created), it is tempting to store the size given here and use it
!         // when the Swing component is created later. But this leads to
!         // flickering: If the size could not been reasonably calculated or if
!         // computeSize did not take it into account, the values are always
!         // derived from the default size 64x64 of SWT Composites. Ignore these
!         // values then! It is better than to use them.
!         //
!         // Do not optimize with the cachedSizesInitialized flag on GTK/Java5 or 
!         // win32/SWT3.3 since this will prevent the initial contents of the control
!         // from being displayed. 
!         // TODO: research the initial content display problem further
!         synchronized (this) {
!             if ((cachedSizesInitialized >= 2) || 
!                     (Platform.isGtk() && Platform.JAVA_VERSION < Platform.javaVersion(1, 6, 0)) ||
!                     (Platform.isWin32() && Platform.SWT_VERSION < Platform.SWT_34)) {
!                 setAWTSize(width, height);
              }
          }
      }
--- 622,650 ----
          checkPopulated();
          if (verboseSizeLayout)
              System.err.println("SWT thread: setBounds called: "+width+" x "+height);
!         if (!AUTOMATIC_SET_AWT_SIZE) {
!             // Pass on the desired size to the embedded component, but only if it could 
!             // be reasonably calculated (i.e. we have cached preferred sizes) and if
!             // computeSize took it into account.
!             // If, however, the SWT side specifies a size for the component while
!             // cachedSizesInitialized < 2 (i.e. usually, before the Swing component
!             // is created), it is tempting to store the size given here and use it
!             // when the Swing component is created later. But this leads to
!             // flickering: If the size could not been reasonably calculated or if
!             // computeSize did not take it into account, the values are always
!             // derived from the default size 64x64 of SWT Composites. Ignore these
!             // values then! It is better than to use them.
!             //
!             // Do not optimize with the cachedSizesInitialized flag on GTK/Java5 or 
!             // win32/SWT3.3 since this will prevent the initial contents of the control
!             // from being displayed. 
!             // TODO: research the initial content display problem further
!             synchronized (this) {
!                 if ((cachedSizesInitialized >= 2) || 
!                         (Platform.isGtk() && Platform.JAVA_VERSION < Platform.javaVersion(1, 6, 0)) ||
!                         (Platform.isWin32() && Platform.SWT_VERSION < Platform.SWT_34)) {
!                     setAWTSize(width, height);
!                 }
              }
          }
      }
Index: src/org/eclipse/albireo/internal/Platform.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.albireo/org.eclipse.albireo.core/src/org/eclipse/albireo/internal/Platform.java,v
retrieving revision 1.3
diff -c -3 -r1.3 Platform.java
*** src/org/eclipse/albireo/internal/Platform.java	26 Feb 2008 00:38:13 -0000	1.3
--- src/org/eclipse/albireo/internal/Platform.java	26 Feb 2008 19:55:08 -0000
***************
*** 36,41 ****
--- 36,45 ----
          return "motif".equals(platformString); //$NON-NLS-1$
      }
      
+     public static boolean isCarbon() {
+         return "carbon".equals(platformString); //$NON-NLS-1$
+     }
+ 
      //Java
      /**
       * The JAVA version


Back to the top