Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 282274
Collapse All | Expand All

(-)src/org/eclipse/swt/widgets/Shell.java (-18 / +107 lines)
Lines 15-22 Link Here
15
import org.eclipse.rwt.lifecycle.ProcessActionRunner;
15
import org.eclipse.rwt.lifecycle.ProcessActionRunner;
16
import org.eclipse.swt.SWT;
16
import org.eclipse.swt.SWT;
17
import org.eclipse.swt.SWTException;
17
import org.eclipse.swt.SWTException;
18
import org.eclipse.swt.events.ShellEvent;
18
import org.eclipse.swt.events.*;
19
import org.eclipse.swt.events.ShellListener;
20
import org.eclipse.swt.graphics.Point;
19
import org.eclipse.swt.graphics.Point;
21
import org.eclipse.swt.graphics.Rectangle;
20
import org.eclipse.swt.graphics.Rectangle;
22
import org.eclipse.swt.internal.events.ActivateEvent;
21
import org.eclipse.swt.internal.events.ActivateEvent;
Lines 123-128 Link Here
123
  private static final int MODE_NONE = 0;
122
  private static final int MODE_NONE = 0;
124
  private static final int MODE_MAXIMIZED = 1;
123
  private static final int MODE_MAXIMIZED = 1;
125
  private static final int MODE_MINIMIZED = 2;
124
  private static final int MODE_MINIMIZED = 2;
125
  private static final int MODE_FULLSCREEN = 4;
126
126
127
  private static final int INITIAL_SIZE_PERCENT = 60;
127
  private static final int INITIAL_SIZE_PERCENT = 60;
128
  private static final int MIN_WIDTH_LIMIT = 80;
128
  private static final int MIN_WIDTH_LIMIT = 80;
Lines 134-139 Link Here
134
  private Button defaultButton;
134
  private Button defaultButton;
135
  private Button saveDefault;
135
  private Button saveDefault;
136
  private Control savedFocus;  // TODO [rh] move to Decorations when exist
136
  private Control savedFocus;  // TODO [rh] move to Decorations when exist
137
  private Rectangle savedBounds;
137
  private int mode;
138
  private int mode;
138
  private boolean modified;
139
  private boolean modified;
139
  private int minWidth;
140
  private int minWidth;
Lines 538-553 Link Here
538
    return result;
539
    return result;
539
  }
540
  }
540
541
542
  public int getBorderWidth() {
543
    return getFullScreen() ? 0 : super.getBorderWidth();
544
  }
545
541
  private int getTitleBarHeight() {
546
  private int getTitleBarHeight() {
542
    ShellThemeAdapter themeAdapter
547
    int result = 0;
543
      = ( ShellThemeAdapter )getAdapter( IThemeAdapter.class );
548
    if( !getFullScreen() ) {
544
    return themeAdapter.getTitleBarHeight( this );
549
      ShellThemeAdapter themeAdapter
550
        = ( ShellThemeAdapter )getAdapter( IThemeAdapter.class );
551
      result = themeAdapter.getTitleBarHeight( this );
552
    }
553
    return result;
545
  }
554
  }
546
555
547
  private Rectangle getTitleBarMargin() {
556
  private Rectangle getTitleBarMargin() {
548
    ShellThemeAdapter themeAdapter
557
    Rectangle result = new Rectangle( 0, 0, 0, 0 );
549
      = ( ShellThemeAdapter )getAdapter( IThemeAdapter.class );
558
    if( !getFullScreen() ) {
550
    return themeAdapter.getTitleBarMargin( this );
559
      ShellThemeAdapter themeAdapter
560
        = ( ShellThemeAdapter )getAdapter( IThemeAdapter.class );
561
      result = themeAdapter.getTitleBarMargin( this );
562
    }
563
    return result;
551
  }
564
  }
552
565
553
  private int getMenuBarHeight() {
566
  private int getMenuBarHeight() {
Lines 570-575 Link Here
570
  void updateMode() {
583
  void updateMode() {
571
    mode &= ~MODE_MAXIMIZED;
584
    mode &= ~MODE_MAXIMIZED;
572
    mode &= ~MODE_MINIMIZED;
585
    mode &= ~MODE_MINIMIZED;
586
    mode &= ~MODE_FULLSCREEN;
573
  }
587
  }
574
588
575
  /////////////////////
589
  /////////////////////
Lines 1197-1202 Link Here
1197
   * @see #setMaximized
1211
   * @see #setMaximized
1198
   */
1212
   */
1199
  public void setMinimized( final boolean minimized ) {
1213
  public void setMinimized( final boolean minimized ) {
1214
    checkWidget();
1200
    if( minimized ) {
1215
    if( minimized ) {
1201
      mode |= MODE_MINIMIZED;
1216
      mode |= MODE_MINIMIZED;
1202
    } else {
1217
    } else {
Lines 1231-1245 Link Here
1231
   * @see #setMinimized
1246
   * @see #setMinimized
1232
   */
1247
   */
1233
  public void setMaximized( final boolean maximized ) {
1248
  public void setMaximized( final boolean maximized ) {
1234
    if( maximized ) {
1249
    checkWidget();
1235
      if( mode != MODE_MAXIMIZED ) {
1250
    if( ( mode & MODE_FULLSCREEN ) == 0 ) {
1236
        setActive();
1251
      if( maximized ) {
1237
        setBounds( display.getBounds() );
1252
        if( ( mode & MODE_MAXIMIZED ) == 0 ) {
1253
          setActive();
1254
          savedBounds = getBounds();
1255
          setBounds( display.getBounds(), false );
1256
        }
1257
        mode |= MODE_MAXIMIZED;
1258
        mode &= ~MODE_MINIMIZED;
1259
      } else {
1260
        if( ( mode & MODE_MAXIMIZED ) != 0 ) {
1261
          setBounds( savedBounds, false );
1262
        }
1263
        mode &= ~MODE_MAXIMIZED;
1238
      }
1264
      }
1239
      mode |= MODE_MAXIMIZED;
1240
      mode &= ~MODE_MINIMIZED;
1241
    } else {
1242
      mode &= ~MODE_MAXIMIZED;
1243
    }
1265
    }
1244
  }
1266
  }
1245
1267
Lines 1258-1264 Link Here
1258
   * @see #setMinimized
1280
   * @see #setMinimized
1259
   */
1281
   */
1260
  public boolean getMinimized() {
1282
  public boolean getMinimized() {
1261
    return ( this.mode & MODE_MINIMIZED ) != 0;
1283
    checkWidget();
1284
    return ( mode & MODE_MINIMIZED ) != 0;
1262
  }
1285
  }
1263
1286
1264
  /**
1287
  /**
Lines 1276-1282 Link Here
1276
   * @see #setMaximized
1299
   * @see #setMaximized
1277
   */
1300
   */
1278
  public boolean getMaximized() {
1301
  public boolean getMaximized() {
1279
    return mode == MODE_MAXIMIZED;
1302
    checkWidget();
1303
    return    ( mode & MODE_FULLSCREEN ) == 0
1304
           && ( mode & MODE_MINIMIZED ) == 0
1305
           && ( mode & MODE_MAXIMIZED ) != 0;
1306
  }
1307
1308
  /**
1309
   * Sets the full screen state of the receiver.
1310
   * If the argument is <code>true</code> causes the receiver
1311
   * to switch to the full screen state, and if the argument is
1312
   * <code>false</code> and the receiver was previously switched
1313
   * into full screen state, causes the receiver to switch back
1314
   * to either the maximized or normal states.
1315
   * <p>
1316
   * Note: The result of intermixing calls to <code>setFullScreen(true)</code>,
1317
   * <code>setMaximized(true)</code> and <code>setMinimized(true)</code> will
1318
   * vary by platform. Typically, the behavior will match the platform user's
1319
   * expectations, but not always. This should be avoided if possible.
1320
   * </p>
1321
   *
1322
   * @param fullScreen the new fullscreen state
1323
   *
1324
   * @exception SWTException <ul>
1325
   *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
1326
   *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
1327
   * </ul>
1328
   *
1329
   * @since 1.3
1330
   */
1331
  public void setFullScreen( final boolean fullScreen ) {
1332
    checkWidget();
1333
    if( ( ( mode & MODE_FULLSCREEN ) != 0 ) != fullScreen ) {
1334
      if( fullScreen ) {
1335
        setActive();
1336
        if( ( mode & MODE_MAXIMIZED ) == 0 ) {
1337
          savedBounds = getBounds();
1338
        }
1339
        setBounds( display.getBounds(), false );
1340
        mode |= MODE_FULLSCREEN;
1341
        mode &= ~MODE_MINIMIZED;
1342
      } else {
1343
        if( ( mode & MODE_MAXIMIZED ) == 0 ) {
1344
          setBounds( savedBounds, false );
1345
        }
1346
        mode &= ~MODE_FULLSCREEN;
1347
      }
1348
      layout();
1349
    }
1350
  }
1351
1352
  /**
1353
   * Returns <code>true</code> if the receiver is currently
1354
   * in fullscreen state, and false otherwise.
1355
   * <p>
1356
   *
1357
   * @return the fullscreen state
1358
   *
1359
   * @exception SWTException <ul>
1360
   *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
1361
   *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
1362
   * </ul>
1363
   *
1364
   * @since 1.3
1365
   */
1366
  public boolean getFullScreen() {
1367
    checkWidget();
1368
    return ( this.mode & MODE_FULLSCREEN ) != 0;
1280
  }
1369
  }
1281
1370
1282
  ///////////////////
1371
  ///////////////////
(-)src/org/eclipse/swt/internal/widgets/shellkit/ShellLCA.java (-4 / +17 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2009 Innoopract Informationssysteme GmbH.
2
 * Copyright (c) 2002, 2010 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 38-43 Link Here
38
  static final String PROP_ACTIVE_CONTROL = "activeControl";
38
  static final String PROP_ACTIVE_CONTROL = "activeControl";
39
  static final String PROP_ACTIVE_SHELL = "activeShell";
39
  static final String PROP_ACTIVE_SHELL = "activeShell";
40
  static final String PROP_MODE = "mode";
40
  static final String PROP_MODE = "mode";
41
  static final String PROP_FULLSCREEN = "fullScreen";
41
  static final String PROP_MINIMUM_SIZE = "minimumSize";
42
  static final String PROP_MINIMUM_SIZE = "minimumSize";
42
  static final String PROP_SHELL_LISTENER = "shellListener";
43
  static final String PROP_SHELL_LISTENER = "shellListener";
43
  private static final String PROP_SHELL_MENU  = "menuBar";
44
  private static final String PROP_SHELL_MENU  = "menuBar";
Lines 55-60 Link Here
55
    adapter.preserve( PROP_IMAGE, shell.getImage() );
56
    adapter.preserve( PROP_IMAGE, shell.getImage() );
56
    adapter.preserve( PROP_ALPHA, new Integer( shell.getAlpha() ) );
57
    adapter.preserve( PROP_ALPHA, new Integer( shell.getAlpha() ) );
57
    adapter.preserve( PROP_MODE, getMode( shell ) );
58
    adapter.preserve( PROP_MODE, getMode( shell ) );
59
    adapter.preserve( PROP_FULLSCREEN,
60
                      Boolean.valueOf( shell.getFullScreen() ) );
58
    adapter.preserve( PROP_SHELL_LISTENER,
61
    adapter.preserve( PROP_SHELL_LISTENER,
59
                      Boolean.valueOf( ShellEvent.hasListener( shell ) ) );
62
                      Boolean.valueOf( ShellEvent.hasListener( shell ) ) );
60
    adapter.preserve( PROP_SHELL_MENU, shell.getMenuBar() );
63
    adapter.preserve( PROP_SHELL_MENU, shell.getMenuBar() );
Lines 119-125 Link Here
119
122
120
  public void renderChanges( final Widget widget ) throws IOException {
123
  public void renderChanges( final Widget widget ) throws IOException {
121
    Shell shell = ( Shell )widget;
124
    Shell shell = ( Shell )widget;
122
    // TODO [rst] Do not render bounds if shell is maximized
125
    // Important: Order matters, write setMode() before setBounds()
126
    writeMode( shell );
123
    ControlLCAUtil.writeChanges( shell );
127
    ControlLCAUtil.writeChanges( shell );
124
    writeImage( shell );
128
    writeImage( shell );
125
    writeText( shell );
129
    writeText( shell );
Lines 128-134 Link Here
128
    //            strange behavior!
132
    //            strange behavior!
129
    writeOpen( shell );
133
    writeOpen( shell );
130
    writeActiveShell( shell );
134
    writeActiveShell( shell );
131
    writeMode( shell );
135
    writeFullScreen( shell );
132
    writeCloseListener( shell );
136
    writeCloseListener( shell );
133
    writeMinimumSize( shell );
137
    writeMinimumSize( shell );
134
    writeDefaultButton( shell );
138
    writeDefaultButton( shell );
Lines 335-345 Link Here
335
    writer.set( PROP_SHELL_LISTENER, "hasShellListener", newValue, defValue );
339
    writer.set( PROP_SHELL_LISTENER, "hasShellListener", newValue, defValue );
336
  }
340
  }
337
341
342
  private static void writeFullScreen( final Shell shell ) throws IOException {
343
    Object defValue = Boolean.FALSE;
344
    Boolean newValue = Boolean.valueOf( shell.getFullScreen() );
345
    if( WidgetLCAUtil.hasChanged( shell, PROP_FULLSCREEN, newValue, defValue ) ) {
346
      JSWriter writer = JSWriter.getWriterFor( shell );
347
      writer.set( "fullScreen", newValue );
348
    }
349
  }
350
338
  private static String getMode( final Shell shell ) {
351
  private static String getMode( final Shell shell ) {
339
    String result = null;
352
    String result = null;
340
    if( shell.getMinimized() ) {
353
    if( shell.getMinimized() ) {
341
      result = "minimized";
354
      result = "minimized";
342
    } else if( shell.getMaximized() ) {
355
    } else if( shell.getMaximized() || shell.getFullScreen() ) {
343
      result = "maximized";
356
      result = "maximized";
344
    }
357
    }
345
    return result;
358
    return result;
(-)js/org/eclipse/swt/widgets/Shell.js (-1 / +9 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2009 Innoopract Informationssysteme GmbH.
2
 * Copyright (c) 2002, 2010 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 483-488 Link Here
483
          this._blocker = null;
483
          this._blocker = null;
484
        }
484
        }
485
      }
485
      }
486
    },
487
    
488
    setFullScreen : function( fullScreen ) {
489
      if( fullScreen ) {
490
        this._captionBar.setDisplay( false );
491
      } else {
492
        this._captionBar.setDisplay( this.hasState( "rwt_TITLE" ) );
493
      }
486
    }
494
    }
487
  }
495
  }
488
} );
496
} );
(-)src/org/eclipse/swt/widgets/Shell_Test.java (-2 / +129 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2009 Innoopract Informationssysteme GmbH.
2
 * Copyright (c) 2002, 2010 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 22-27 Link Here
22
import org.eclipse.swt.events.*;
22
import org.eclipse.swt.events.*;
23
import org.eclipse.swt.graphics.Point;
23
import org.eclipse.swt.graphics.Point;
24
import org.eclipse.swt.graphics.Rectangle;
24
import org.eclipse.swt.graphics.Rectangle;
25
import org.eclipse.swt.internal.widgets.IDisplayAdapter;
25
import org.eclipse.swt.internal.widgets.IShellAdapter;
26
import org.eclipse.swt.internal.widgets.IShellAdapter;
26
import org.eclipse.swt.layout.FillLayout;
27
import org.eclipse.swt.layout.FillLayout;
27
28
Lines 131-137 Link Here
131
    assertNull( backgroundShell[ 0 ] );
132
    assertNull( backgroundShell[ 0 ] );
132
    assertTrue( failed[ 0 ] );
133
    assertTrue( failed[ 0 ] );
133
  }
134
  }
134
  
135
135
  public void testInitialValues() {
136
  public void testInitialValues() {
136
    Display display = new Display();
137
    Display display = new Display();
137
    Shell shell = new Shell( display, SWT.NONE );
138
    Shell shell = new Shell( display, SWT.NONE );
Lines 593-598 Link Here
593
    }
594
    }
594
  }
595
  }
595
596
597
  public void testFullScreen() {
598
    Fixture.fakePhase( PhaseId.PROCESS_ACTION );
599
    final java.util.List log = new ArrayList();
600
    Display display = new Display();
601
    Rectangle displayBounds = new Rectangle( 0, 0, 800, 600 );
602
    getDisplayAdapter( display ).setBounds( displayBounds );
603
    Shell shell = new Shell( display );
604
    Rectangle shellBounds = new Rectangle( 10, 10, 100, 100 );
605
    shell.setBounds( shellBounds );
606
    shell.addControlListener( new ControlListener() {
607
      public void controlMoved( final ControlEvent event ) {
608
        log.add( "controlMoved" );
609
      }
610
      public void controlResized( final ControlEvent event ) {
611
        log.add( "controlResized" );
612
      }
613
    } );
614
    shell.open();
615
    assertFalse( shell.getFullScreen() );
616
    assertFalse( shell.getMaximized() );
617
    assertFalse( shell.getMinimized() );
618
619
    log.clear();
620
    shell.setMaximized( true );
621
    assertFalse( shell.getFullScreen() );
622
    assertTrue( shell.getMaximized() );
623
    assertFalse( shell.getMinimized() );
624
    assertEquals( 2, log.size() );
625
    assertEquals( "controlMoved", log.get( 0 ) );
626
    assertEquals( "controlResized", log.get( 1 ) );
627
    assertEquals( displayBounds, shell.getBounds() );
628
629
    shell.setMinimized( true );
630
    assertFalse( shell.getFullScreen() );
631
    assertFalse( shell.getMaximized() );
632
    assertTrue( shell.getMinimized() );
633
634
    shell.setMinimized( false );
635
    assertFalse( shell.getFullScreen() );
636
    assertTrue( shell.getMaximized() );
637
    assertFalse( shell.getMinimized() );
638
639
    log.clear();
640
    shell.setFullScreen( true );
641
    assertTrue( shell.getFullScreen() );
642
    assertFalse( shell.getMaximized() );
643
    assertFalse( shell.getMinimized() );
644
    assertEquals( 0, log.size() );
645
    assertEquals( displayBounds, shell.getBounds() );
646
647
    log.clear();
648
    shell.setMaximized( true );
649
    assertTrue( shell.getFullScreen() );
650
    assertFalse( shell.getMaximized() );
651
    assertFalse( shell.getMinimized() );
652
    assertEquals( 0, log.size() );
653
    assertEquals( displayBounds, shell.getBounds() );
654
655
    log.clear();
656
    shell.setMaximized( false );
657
    assertTrue( shell.getFullScreen() );
658
    assertFalse( shell.getMaximized() );
659
    assertFalse( shell.getMinimized() );
660
    assertEquals( 0, log.size() );
661
    assertEquals( displayBounds, shell.getBounds() );
662
663
    log.clear();
664
    shell.setMinimized( true );
665
    assertTrue( shell.getFullScreen() );
666
    assertFalse( shell.getMaximized() );
667
    assertTrue( shell.getMinimized() );
668
    assertEquals( 0, log.size() );
669
670
    log.clear();
671
    shell.setMinimized( false );
672
    assertTrue( shell.getFullScreen() );
673
    assertFalse( shell.getMaximized() );
674
    assertFalse( shell.getMinimized() );
675
    assertEquals( 0, log.size() );
676
677
    log.clear();
678
    shell.setFullScreen( false );
679
    assertFalse( shell.getFullScreen() );
680
    assertTrue( shell.getMaximized() );
681
    assertFalse( shell.getMinimized() );
682
    assertEquals( 0, log.size() );
683
    assertEquals( displayBounds, shell.getBounds() );
684
685
    shell.setMaximized( false );
686
    shell.setMinimized( true );
687
    log.clear();
688
    shell.setFullScreen( true );
689
    assertTrue( shell.getFullScreen() );
690
    assertFalse( shell.getMaximized() );
691
    assertFalse( shell.getMinimized() );
692
    assertEquals( 2, log.size() );
693
    assertEquals( "controlMoved", log.get( 0 ) );
694
    assertEquals( "controlResized", log.get( 1 ) );
695
    assertEquals( displayBounds, shell.getBounds() );
696
697
    log.clear();
698
    shell.setFullScreen( false );
699
    assertFalse( shell.getFullScreen() );
700
    assertFalse( shell.getMaximized() );
701
    assertFalse( shell.getMinimized() );
702
    assertEquals( 2, log.size() );
703
    assertEquals( "controlMoved", log.get( 0 ) );
704
    assertEquals( "controlResized", log.get( 1 ) );
705
    assertEquals( shellBounds, shell.getBounds() );
706
707
    shell.setFullScreen( true );
708
    log.clear();
709
    shell.setBounds( 20, 20, 200, 200 );
710
    assertFalse( shell.getFullScreen() );
711
    assertFalse( shell.getMaximized() );
712
    assertFalse( shell.getMinimized() );
713
    assertEquals( 2, log.size() );
714
    assertEquals( "controlMoved", log.get( 0 ) );
715
    assertEquals( "controlResized", log.get( 1 ) );
716
  }
717
718
  private static IDisplayAdapter getDisplayAdapter( final Display display ) {
719
    Object adapter = display.getAdapter( IDisplayAdapter.class );
720
    return ( IDisplayAdapter )adapter;
721
  }
722
596
  protected void setUp() throws Exception {
723
  protected void setUp() throws Exception {
597
    Fixture.setUp();
724
    Fixture.setUp();
598
    Fixture.fakePhase( PhaseId.PROCESS_ACTION );
725
    Fixture.fakePhase( PhaseId.PROCESS_ACTION );

Return to bug 282274