[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [albireo-dev] considering each platform

Gordon Hirsch wrote:
> After a lot of head-scratching, I realized that the frame resize is 
> happening automatically when the SWT composite is resized. On Windows, 
> this happens in the method Composite.resizeEmbeddedHandle(). This is 
> done separately from the setBounds call, and it is implemented with 
> messages at the native windowing system level.
> 
> I can't find the equivalent code for Gtk. Perhaps the same thing happens 
> implicitly there.
> 
> All of this makes me ask if we have unnecessary code in SwingControl 
> today.

Yes, we should look more in detail what each platform has or has not.

For example, the special code for the initial display of the control
is not there for the 'carbon' (MacOS X) platform. We can therefore omit
the workaround there:

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.40
diff -c -3 -r1.40 SwingControl.java
*** src/org/eclipse/albireo/core/SwingControl.java	25 Feb 2008 20:12:35 -0000	1.40
--- src/org/eclipse/albireo/core/SwingControl.java	25 Feb 2008 21:09:32 -0000
***************
*** 408,413 ****
--- 408,416 ----
      //     });
      // This code overwrites the size of the frame with a size that is not
      // valid any more!
+     static final boolean INITIAL_CLIENT_AREA_WORKAROUND =
+         // This code is found in SWT_AWT.new_Frame for gtk, motif, win32.
+         Platform.isGtk() || "motif".equals(SWT.getPlatform()) || Platform.isWin32();
      private Rectangle initialClientArea;
      /**
       * Overridden.
***************
*** 415,421 ****
      public Rectangle getClientArea() {
          assert Display.getCurrent() != null;     // On SWT event thread
          Rectangle rect = super.getClientArea();
!         if (initialClientArea == null) {
              synchronized (this) {
                  if (cachedSizesInitialized >= 1) {
                      rect.width = cachedPrefSize.width;
--- 418,424 ----
      public Rectangle getClientArea() {
          assert Display.getCurrent() != null;     // On SWT event thread
          Rectangle rect = super.getClientArea();
!         if (INITIAL_CLIENT_AREA_WORKAROUND && initialClientArea == null) {
              synchronized (this) {
                  if (cachedSizesInitialized >= 1) {
                      rect.width = cachedPrefSize.width;
***************
*** 512,518 ****
              /**
               * Part of a workaround, see {@link #getClientArea()}.
               */
!             if (initialClientArea != null) {
                  initialClientArea.width = cachedPrefSize.width;
                  initialClientArea.height = cachedPrefSize.height;
              }
--- 515,521 ----
              /**
               * Part of a workaround, see {@link #getClientArea()}.
               */
!             if (INITIAL_CLIENT_AREA_WORKAROUND && initialClientArea != null) {
                  initialClientArea.width = cachedPrefSize.width;
                  initialClientArea.height = cachedPrefSize.height;
              }