Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Win32] Showing a directory chooser prevents sending events for other shells #1587

Open
tmssngr opened this issue Nov 11, 2024 · 0 comments
Open
Labels
bug Something isn't working Windows Happens on Windows OS

Comments

@tmssngr
Copy link
Contributor

tmssngr commented Nov 11, 2024

Describe the bug
If a directory chooser is shown on top of one shell, the event handling of other shells is dysfunctional.

To Reproduce
Run this snippet:

import org.eclipse.swt.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;

public class DirectoryChooserOpenRepaintProblem {

	public static void main(String[] args) {
		final Display display = new Display();
		final Shell shell = new Shell(display);
		shell.setLayout(new GridLayout(1, true));

		final Table table = new Table(shell, SWT.BORDER | SWT.MULTI);
		table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
		for (int i = 0 ; i < 10; i++) {
			new TableItem(table, SWT.NONE).setText("row " + i);
		}

		table.addListener(SWT.Selection, even -> {
			final int[] selectionIndices = table.getSelectionIndices();
			String text = selectionIndices.length == 1
					? "row " + selectionIndices[0]
					: selectionIndices.length + " rows";
			text += " selected";
			System.out.println(text);
		});

		shell.setSize(400, 300);
		shell.open();

		final Shell shell2 = new Shell(display);
		shell2.setLayout(new FillLayout());

		final Button button = new Button(shell2, SWT.PUSH);
		button.setText("Open Directory");
		button.addListener(SWT.Selection, even -> {
			final DirectoryDialog dialog = new DirectoryDialog(shell2, SWT.PRIMARY_MODAL | SWT.SHEET);
			dialog.setText("Open Directory");
			dialog.setMessage("Select the dir");
			dialog.open();
		});

		shell2.setSize(400, 200);
		shell2.open();

		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
		display.dispose();
	}
}

It will two shells. One shows a Table control. Selecting something in the table will show a brief summary in the terminal. The other shows a button. Clicking that will show a directory chooser.

  • select different rows in the table
  • -> the terminal will show a selection summary
  • in the second shell, click the button to open the directory chooser
  • keep the directory chooser open and switch back to the first shell
  • select different rows in the table
  • -> the terminal will not show anything
  • select different rows in the table
  • close the directory chooser
  • -> now the terminal spits out the cached selection events

Expected behavior
Either the other shell's listeners should behave correctly (similar to no shown directory chooser). Or show the directory chooser application modal.

Screenshots
screenshot

Environment:

  1. Select the platform(s) on which the behavior is seen:
    • All OS
    • Windows
    • Linux
    • macOS
  1. Additional OS info (e.g. OS version, Linux Desktop, etc)
    Windows 11 23H2

Workaround (or) Additional context
No known workaround.

@jukzi jukzi added bug Something isn't working Windows Happens on Windows OS labels Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Windows Happens on Windows OS
Projects
None yet
Development

No branches or pull requests

2 participants