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 323570 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/swt/widgets/Control.java (-2 / +19 lines)
Lines 748-754 Link Here
748
    // if (display.focusEvent == SWT.FocusOut) return false;
748
    // if (display.focusEvent == SWT.FocusOut) return false;
749
    Shell shell = getShell(); // was: Decorations shell = menuShell();
749
    Shell shell = getShell(); // was: Decorations shell = menuShell();
750
    shell.setSavedFocus( this );
750
    shell.setSavedFocus( this );
751
    if( !isEnabled() || !isVisible() /* || !isActive() */) {
751
    if( !isEnabled() || !isVisible() || !isActive() ) {
752
      return false;
752
      return false;
753
    }
753
    }
754
    if( isFocusControl() ) {
754
    if( isFocusControl() ) {
Lines 1865-1871 Link Here
1865
    checkWidget();
1865
    checkWidget();
1866
    MenuDetectEvent.removeListener( this, listener );
1866
    MenuDetectEvent.removeListener( this, listener );
1867
  }
1867
  }
1868
  
1868
1869
  ////////////////
1869
  ////////////////
1870
  // drawing (Note that we can't really force a redraw. This is just a
1870
  // drawing (Note that we can't really force a redraw. This is just a
1871
  // fake for event notifications that come on OS systems with redraws)
1871
  // fake for event notifications that come on OS systems with redraws)
Lines 2182-2187 Link Here
2182
    return forceFocus ();
2182
    return forceFocus ();
2183
  }
2183
  }
2184
2184
2185
  boolean isActive() {
2186
    Shell shell = getShell();
2187
    boolean result = shell.getEnabled();
2188
    Shell[] allShells = getDisplay().getShells();
2189
    int bits = SWT.APPLICATION_MODAL | SWT.SYSTEM_MODAL | SWT.PRIMARY_MODAL;
2190
    int shellIndex = allShells.length;
2191
    for( int i = 0; i < allShells.length && result; i++ ) {
2192
      if( allShells[ i ] == shell ) {
2193
        shellIndex = i;
2194
      }
2195
      if( ( allShells[ i ].style & bits ) != 0 && shellIndex < i ) {
2196
        result = false;
2197
      }
2198
    }
2199
    return result;
2200
  }
2201
2185
  ///////////////////////////////////////////////////////
2202
  ///////////////////////////////////////////////////////
2186
  // Helping methods to observe the disposal of the menu
2203
  // Helping methods to observe the disposal of the menu
2187
2204
(-)src/org/eclipse/swt/widgets/Control_Test.java (-12 / +27 lines)
Lines 424-430 Link Here
424
    assertNull( adapter.getUserForeground() );
424
    assertNull( adapter.getUserForeground() );
425
    Color themeColor = control.getForeground();
425
    Color themeColor = control.getForeground();
426
    // enabled state:
426
    // enabled state:
427
    control.setForeground( blue );    
427
    control.setForeground( blue );
428
    assertEquals( blue, adapter.getUserForeground() );
428
    assertEquals( blue, adapter.getUserForeground() );
429
    assertEquals( blue, control.getForeground() );
429
    assertEquals( blue, control.getForeground() );
430
    // disabled directly
430
    // disabled directly
Lines 436-442 Link Here
436
    composite.setEnabled( false );
436
    composite.setEnabled( false );
437
    assertEquals( null, adapter.getUserForeground() );
437
    assertEquals( null, adapter.getUserForeground() );
438
    assertEquals( blue, control.getForeground() );
438
    assertEquals( blue, control.getForeground() );
439
    // re-enabled 
439
    // re-enabled
440
    composite.setEnabled( true );
440
    composite.setEnabled( true );
441
    assertEquals( blue, adapter.getUserForeground() );
441
    assertEquals( blue, adapter.getUserForeground() );
442
    assertEquals( blue, control.getForeground() );
442
    assertEquals( blue, control.getForeground() );
Lines 445-451 Link Here
445
    assertEquals( null, adapter.getUserForeground() );
445
    assertEquals( null, adapter.getUserForeground() );
446
    assertEquals( themeColor, control.getForeground() );
446
    assertEquals( themeColor, control.getForeground() );
447
  }
447
  }
448
  
448
449
  public void testVisible() {
449
  public void testVisible() {
450
    Display display = new Display();
450
    Display display = new Display();
451
    Shell shell = new Shell( display, SWT.NONE );
451
    Shell shell = new Shell( display, SWT.NONE );
Lines 679-684 Link Here
679
    assertEquals( "", log.toString() );
679
    assertEquals( "", log.toString() );
680
  }
680
  }
681
681
682
  // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=323570
683
  public void testFocusOnBlockedShell() {
684
    Display display = new Display();
685
    Shell shell1 = new Shell( display, SWT.NONE );
686
    Control button1 = new Button( shell1, SWT.PUSH );
687
    Shell shell2 = new Shell( shell1, SWT.APPLICATION_MODAL );
688
    shell1.open();
689
    assertEquals( button1, display.getFocusControl() );
690
    assertEquals( shell1, display.getActiveShell() );
691
    shell2.open();
692
    button1.setFocus();
693
    assertEquals( shell2, display.getFocusControl() );
694
    assertEquals( shell2, display.getActiveShell() );
695
  }
696
682
  public void testToControl() {
697
  public void testToControl() {
683
    Display display = new Display();
698
    Display display = new Display();
684
    Shell shell = new Shell( display, SWT.NONE );
699
    Shell shell = new Shell( display, SWT.NONE );
Lines 824-833 Link Here
824
    assertNotNull( monitor );
839
    assertNotNull( monitor );
825
    assertEquals( display.getPrimaryMonitor(), monitor );
840
    assertEquals( display.getPrimaryMonitor(), monitor );
826
  }
841
  }
827
  
842
828
  
843
829
  public void testUntypedHelpListener() {
844
  public void testUntypedHelpListener() {
830
    final Event[] untypedHelpEvent = { null }; 
845
    final Event[] untypedHelpEvent = { null };
831
    Fixture.fakePhase( PhaseId.PROCESS_ACTION );
846
    Fixture.fakePhase( PhaseId.PROCESS_ACTION );
832
    Display display = new Display();
847
    Display display = new Display();
833
    Control control = new Shell( display );
848
    Control control = new Shell( display );
Lines 839-852 Link Here
839
    control.notifyListeners( SWT.Help, new Event() );
854
    control.notifyListeners( SWT.Help, new Event() );
840
    assertNotNull( untypedHelpEvent[ 0 ] );
855
    assertNotNull( untypedHelpEvent[ 0 ] );
841
  }
856
  }
842
  
857
843
  public void testRedraw() {
858
  public void testRedraw() {
844
    Display display = new Display();
859
    Display display = new Display();
845
    Composite control = new Shell( display );
860
    Composite control = new Shell( display );
846
    control.redraw();
861
    control.redraw();
847
    assertTrue( RWTLifeCycle.needsFakeRedraw( control ) );
862
    assertTrue( RWTLifeCycle.needsFakeRedraw( control ) );
848
  }
863
  }
849
  
864
850
  public void testSetBackground() {
865
  public void testSetBackground() {
851
    Display display = new Display();
866
    Display display = new Display();
852
    Composite control = new Shell( display );
867
    Composite control = new Shell( display );
Lines 866-872 Link Here
866
      // Expected Exception
881
      // Expected Exception
867
    }
882
    }
868
  }
883
  }
869
  
884
870
  public void testSetBackgroundImage() {
885
  public void testSetBackgroundImage() {
871
    ClassLoader loader = Fixture.class.getClassLoader();
886
    ClassLoader loader = Fixture.class.getClassLoader();
872
    InputStream stream = loader.getResourceAsStream( Fixture.IMAGE1 );
887
    InputStream stream = loader.getResourceAsStream( Fixture.IMAGE1 );
Lines 889-895 Link Here
889
      }
904
      }
890
    }
905
    }
891
  }
906
  }
892
  
907
893
  public void testSetCursor() {
908
  public void testSetCursor() {
894
    Display display = new Display();
909
    Display display = new Display();
895
    Composite control = new Shell( display );
910
    Composite control = new Shell( display );
Lines 906-912 Link Here
906
      // Expected Exception
921
      // Expected Exception
907
    }
922
    }
908
  }
923
  }
909
  
924
910
  public void testSetFont() {
925
  public void testSetFont() {
911
    Display display = new Display();
926
    Display display = new Display();
912
    Composite control = new Shell( display );
927
    Composite control = new Shell( display );
Lines 932-938 Link Here
932
      // Expected Exception
947
      // Expected Exception
933
    }
948
    }
934
  }
949
  }
935
  
950
936
  public void testSetForeground() {
951
  public void testSetForeground() {
937
    Display display = new Display();
952
    Display display = new Display();
938
    Composite control = new Shell( display );
953
    Composite control = new Shell( display );

Return to bug 323570