Project: SWT
Bug 200956 WinXP: Shell draws focus on setVisible(true)
Reported: 2007-08-23 11:01:40 | Status: resolved fixed

Build ID: I20070811-1447 Steps To Reproduce: If a shell got focus once in her lifetime and is hidden using setVisible(false) then calling setVisible(true) will cause it to immediately draw focus. I couldn't find a way to prevent this behavior. Note: On Linux, this works perfectly. Steps to reproduce: 1. Run the snippet below 2. Click on the 'click me' button --> a second shell opens without drawing focus 3. Click on the 'close me' button --> the second shell gains focus and is closed 4. Click again on 'click me' --> the second shell opens again and immediately draws focus More information: import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; public class Snippet { static Shell anotherShell; public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); shell.setLayout(new GridLayout(1, false)); Button button = new Button(shell, SWT.PUSH); button.setText("click me"); button.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent arg0) { if (anotherShell == null) { anotherShell= new Shell(shell, SWT.ON_TOP | SWT.NO_FOCUS | SWT.BORDER | SWT.TOOL); anotherShell.setLayout(new GridLayout(1, false)); Button button = new Button(anotherShell, SWT.PUSH); button.setText("close me"); button.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent arg0) { anotherShell.setVisible(false); } }); } anotherShell.setVisible(true); } }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); } }

Files changed in fix:
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Decorations.java