| Summary: | SWT.NO_FOCUS on Linux (Gtk) is inconsistent with Windows | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Feng Yao Yao <fengyaoy> | ||||
| Component: | SWT | Assignee: | Platform-SWT-Inbox <platform-swt-inbox> | ||||
| Status: | CLOSED WORKSFORME | QA Contact: | |||||
| Severity: | minor | ||||||
| Priority: | P3 | CC: | ericwill, pinnamur, Silenio_Quarti, snorthov | ||||
| Version: | 3.4.2 | Keywords: | triaged | ||||
| Target Milestone: | --- | ||||||
| Hardware: | PC | ||||||
| OS: | Linux-GTK | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
Try using SWT.ON_TOP instead of SWT.NO_FOCUS. SWT.NO_FOCUS is badly named. It means "no mouse focus when I click". On possibility to avoid this platform difference in the future is to make Shell.setVisible() set focus for all shells except SWT.ON_TOP ones. This would make the behavior consistent. Yes, ON_TOP can prevent the shell getting focus when it is shown. But this bit makes the shell shown above all the top level windows belonging to other application. This is not what we want. For example, task manager window is open and run above case (with ON_TOP bit), this hover shell is shown above the task manager window. This can be reproduced on both Windows and Linux. Created attachment 154205 [details]
Patch v01
The patch allows the shell created with NO_FOCUS flag to be opened/visible without taking focus.
This bug is still reproducible, not sure of its urgency though. Re-assigning to platform inbox. This seems to have been a GTK2 issue, I can't reproduce it on GTK3 using Wayland or X11 anymore. |
Build ID: 3.4 Steps To Reproduce: 1. Following is the test code for SWT.NO_FOCUS: public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); shell.setText("NO_FOCUS Example"); final Shell hoverShell = new Shell(shell, SWT.TOOL | SWT.NO_FOCUS | SWT.NO_TRIM); hoverShell.setSize(10, 10); hoverShell.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE)); shell.addMouseTrackListener(new MouseTrackAdapter(){ public void mouseEnter(MouseEvent event) { hoverShell.setLocation(100, 100); hoverShell.setVisible(true); } public void mouseExit(MouseEvent event) { hoverShell.setVisible(false); } }); shell.open(); while(!shell.isDisposed()){ if (!display.readAndDispatch()) display.sleep(); } display.dispose(); } 2. On Windows, hovershell would not take focus when it is shown. On Linux (Gtk), hovershell takes focus.