Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 267056

Summary: Shell activate and deactivate events don't fire properly
Product: [RT] RAP Reporter: Enrico Zanaga <ezanaga>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: ivan, maghen.calinghee, webmaster
Version: 1.2   
Target Milestone: 1.2 M7   
Hardware: All   
OS: All   
Whiteboard:
Bug Depends on:    
Bug Blocks: 245100    

Description Enrico Zanaga CLA 2009-03-04 12:08:18 EST
Having two shells with ShellListeners attached and a button for activate the other shell, the shellActivated and shellDeactivated events don't fire when the setActive method is called.
Also, shellDeactivated event doesn't fire in active shell when another shell is created.

In SWT the events are always fired correctly.

Here's a snippet with a simple log:

public class RapTest implements IEntryPoint {

    private Display d;
    private Shell s1;
    private Shell s2;

    @Override
    public int createUI() {
        d = new Display();
        s1 = new Shell(d, SWT.SHELL_TRIM | SWT.NO_FOCUS);
        s2 = new Shell(d, SWT.SHELL_TRIM | SWT.NO_FOCUS);
        s1.setBounds(0, 0, 400, 200);
        s2.setBounds(400, 0, 400, 200);
        s1.setLayout(new FillLayout());
        s2.setLayout(new FillLayout());

        s1.addShellListener(new ShellAdapter() {
            @Override
            public void shellActivated(ShellEvent e) {
                System.out.println("s1: shellActivated");
            }
            @Override
            public void shellDeactivated(ShellEvent e) {
                System.out.println("s1: shellDeactivated");
            }
        });
        s2.addShellListener(new ShellAdapter() {
            @Override
            public void shellActivated(ShellEvent e) {
                System.out.println("s2: shellActivated");
            }
            @Override
            public void shellDeactivated(ShellEvent e) {
                System.out.println("s2: shellDeactivated");
            }
        });

        Button b1 = new Button(s1, SWT.PUSH);
        Button b2 = new Button(s2, SWT.PUSH);
        b1.setText("activate s2");
        b2.setText("activate s1");

        b1.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                System.out.println("b1: widgetSelected");
                s2.setActive();
            }
        });
        b2.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                System.out.println("b2: widgetSelected");
                s1.setActive();
            }
        });

        s1.open();
        s2.open();

        while( !s1.isDisposed() && !s2.isDisposed() )
            if( !d.readAndDispatch() )
                d.sleep();
        d.dispose();

        return 0;
    }
}
Comment 1 Ivan Furnadjiev CLA 2009-04-27 13:11:02 EDT
Shell activate/deactivate events are fired in Display#setActiveShell(). Changes in CVS HEAD.