Bug 56231 - Shell deactivation/activation is not reliable
Summary: Shell deactivation/activation is not reliable
Status: RESOLVED WORKSFORME
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.0   Edit
Hardware: PC Linux-GTK
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Billy Biggs CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 56261 56362 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-03-25 15:15 EST by Travis Hume CLA
Modified: 2005-03-07 18:09 EST (History)
5 users (show)

See Also:


Attachments
tracing output (1.59 KB, application/octet-stream)
2004-03-25 23:56 EST, Travis Hume CLA
no flags Details
Patch to "org.eclipse.ui.workbench" (9.17 KB, patch)
2004-03-26 09:40 EST, Douglas Pollock CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Travis Hume CLA 2004-03-25 15:15:05 EST
Show outline, Ctrl+O, followed by ESC to dismiss the window stop all other
keybindings from working.

This is easily reproduced but isn't 100%.  The behaviour is similar to
https://bugs.eclipse.org/bugs/show_bug.cgi?id=55581 in that 55581 would also
stop keybindings from working until another view was focused and then the editor
refocused.

Verified using Build id: 200403251200
Comment 1 Travis Hume CLA 2004-03-25 15:33:19 EST
Additionally, not messages are written to the .log file
Comment 2 Douglas Pollock CLA 2004-03-25 16:59:39 EST
I cannot reproduce this bug on Windows XP or Linux-GTK.  Could you be more 
specific? 
Comment 3 Travis Hume CLA 2004-03-25 17:20:29 EST
That's unfortunate.  This problem is making this build almost unusable.  It is
reproducible by opening the outline and pressing ESC.  At that point most
keybindings no longer work, especially keybinding that use the CTRL key.

I'll try reproducing this with a clean workspace and post again.

I'm running this on Gentoo linux with 
gtk+-2.2.4
glibc-2.3.2
sun jdk 1.4.2_04
Comment 4 Travis Hume CLA 2004-03-25 17:34:19 EST
Ok, I started with a new workspace and created a java project called Test with a
single class file called Test in a package called test.

I wasn't quite as easy to reproduce, but Ctrl+O then Esc definitely triggers the
defect.  Cycling editors also seems to trigger the defect.  Ctrl+Shift+T then
Esc causes it to happen.  In fact Ctrl+Shift+T seems to cause it to happen
everytime.

If focus is in the editor window when the bug occurrs, then focusing the Outline
view will restore keybinding operations.  If focus is in the Outline view when
the bug occurrs, then clicking in the Editor window restores keybinding operation.

No messages are being traced to the .log file.  Is there some other way for me
to pin down what is happening (or not happening)?  I'm happy to self-host and
debug, but don't know where to start.
Comment 5 Chris McLaren CLA 2004-03-25 17:38:53 EST
*** Bug 56261 has been marked as a duplicate of this bug. ***
Comment 6 Douglas Pollock CLA 2004-03-25 17:42:26 EST
Can you edit a text file, and insert a line:  
org.eclipse.ui/trace/contexts=true  
  
Then start Eclipse with "-debug /path/to/file".  On the console, you should see  
information about what contexts are active at any moment.  The question is:  
which contexts are active when you see your keys failing to work?  
  
Also, you can try:  
org.eclipse.ui/trace/handlers=true  
  
Comment 7 Travis Hume CLA 2004-03-25 18:13:21 EST
Interesting.  I added the -debug /opt/eclipse/tracer option and started it up. 
First thing I tried was Ctrl+Shift+T, Esc repeatedly.  It wouldn't reproduce
until I tried cycling editors using Ctrl+F6, then it reproduced easily.

Here is the trace

/opt/eclipse: CLASSPATH="" JAVA_HOME=/opt/sun-jdk-1.4.2.04
PATH=/opt/sun-jdk-1.4.2.04/bin:$PATH ./eclipse -debug /opt/eclipse/tracing -data
/home/thume/work/workspace -vm /opt/sun-jdk-1.4.2.04/bin/java |tee
/tmp/eclipse.log |tee /tmp/eclipse.log
Install location:
    file:/opt/eclipse/
Configuration file:
    file:/opt/eclipse/configuration/config.ini loaded
Configuration location:
    file:/opt/eclipse/configuration/
Framework located:
    file:/opt/eclipse/plugins/org.eclipse.osgi_3.0.0/
Framework classpath:
    file:/opt/eclipse/plugins/org.eclipse.osgi_3.0.0/core.jar
    file:/opt/eclipse/plugins/org.eclipse.osgi_3.0.0/console.jar
    file:/opt/eclipse/plugins/org.eclipse.osgi_3.0.0/osgi.jar
    file:/opt/eclipse/plugins/org.eclipse.osgi_3.0.0/resolver.jar
    file:/opt/eclipse/plugins/org.eclipse.osgi_3.0.0/defaultAdaptor.jar
    file:/opt/eclipse/plugins/org.eclipse.osgi_3.0.0/eclipseAdaptor.jar
Splash location:
    /opt/eclipse/plugins/org.eclipse.platform_3.0.0/splash.bmp
Debug-Options:
    /opt/eclipse/tracing
Time loadBundles in the framework: 46
Time spent in registry parsing: null
Time spent in package admin resolve: null
Time spent resolving the dependency system: null
Start VM: /opt/sun-jdk-1.4.2.04/bin/java
-cp /opt/eclipse/./startup.jar org.eclipse.core.launcher.Main
-os linux
-ws gtk
-arch x86
-showsplash /opt/eclipse/./eclipse -showsplash 600
-exitdata /opt/eclipse/./eclipse -exitdata 1f8010
-debug /opt/eclipse/tracing
-data /home/thume/work/workspace
-vm /opt/sun-jdk-1.4.2.04/bin/java
-vmargs
-cp /opt/eclipse/./startup.jar org.eclipse.core.launcher.Main
Comment 8 Travis Hume CLA 2004-03-25 20:13:58 EST
Just tried with build 200403251651.  Seems I can use Ctrl+Shift+T and
Ctrl+Shift+O  repeatedly unless I try Next Editor (Ctrl+F6).  After that, things
get wonky.
Comment 9 Travis Hume CLA 2004-03-25 21:56:59 EST
I'm not able to reproduce this on winxp
Comment 10 Douglas Pollock CLA 2004-03-25 22:37:02 EST
There are no tracing options turned on in the console log you provided. 
Comment 11 Travis Hume CLA 2004-03-25 22:42:18 EST
I thought that wasn't much information.  Here's what the file looks like I used
as a param to the -debug option:

[fast] /opt/eclipse.broken: cat tracing
org.eclipse.ui/trace/contexts=true
org.eclipse.ui/trace/handlers=true
Comment 12 Travis Hume CLA 2004-03-25 22:44:38 EST
Did you mean the output would be printed to the console view?  I don't have the
console view visible.  I just provided the standard output from the xterm I
started eclipse from.
Comment 13 Douglas Pollock CLA 2004-03-25 22:47:22 EST
Quick thing I've noticed is that you are catting "/opt/eclipse.broken/tracing"  
while the debug option is "/opt/eclipse/tracing".  But I may have forgotten an  
important line.  Try adding:  
  
	org.eclipse.ui/debug=true  
 
Naw, from the console is good. 
 
If you're on IRC, then join irc.freenode.net#eclipse and message "krzysiu". 
Comment 14 Travis Hume CLA 2004-03-25 23:06:23 EST
Nevermind that eclipse.broken thing.  It was all good when I actually ran the
test.  I'm at home now and will try and reproduce the problem on my gentoo
laptop with additional debug line.
Comment 15 Travis Hume CLA 2004-03-25 23:27:50 EST
[slow] /opt/eclipse: CLASSPATH="" JAVA_HOME=/opt/sun-jdk-1.4.2.04
PATH=/opt/sun-jdk-1.4.2.04/bin:$PATH ./eclipse -debug
/home/thume/eclipse.tracing -vm /opt/sun-jdk-1.4.2.04/bin/java -vmargs -Xmx190m
|tee eclipse.log
Install location:
    file:/opt/eclipse/
Configuration file:
    file:/opt/eclipse/configuration/config.ini loaded
Configuration location:
    file:/opt/eclipse/configuration/
Framework located:
    file:/opt/eclipse/plugins/org.eclipse.osgi_3.0.0/
Framework classpath:
    file:/opt/eclipse/plugins/org.eclipse.osgi_3.0.0/core.jar
    file:/opt/eclipse/plugins/org.eclipse.osgi_3.0.0/console.jar
    file:/opt/eclipse/plugins/org.eclipse.osgi_3.0.0/osgi.jar
    file:/opt/eclipse/plugins/org.eclipse.osgi_3.0.0/resolver.jar
    file:/opt/eclipse/plugins/org.eclipse.osgi_3.0.0/defaultAdaptor.jar
    file:/opt/eclipse/plugins/org.eclipse.osgi_3.0.0/eclipseAdaptor.jar
Splash location:
    /opt/eclipse/plugins/org.eclipse.platform_3.0.0/splash.bmp
Debug-Options:
    /home/thume/eclipse.tracing
Time loadBundles in the framework: 91
CONTEXTS >>> [org.eclipse.ui.contexts.dialogAndWindow,
org.eclipse.ui.contexts.window]
CONTEXTS >>> [org.eclipse.ui.contexts.dialogAndWindow,
org.eclipse.ui.contexts.dialog]
CONTEXTS >>> [org.eclipse.ui.contexts.dialogAndWindow,
org.eclipse.ui.contexts.window]
CONTEXTS >>> [org.eclipse.ui.contexts.dialogAndWindow,
org.eclipse.ui.contexts.dialog]
CONTEXTS >>> [org.eclipse.ui.contexts.dialogAndWindow,
org.eclipse.ui.contexts.window]
CONTEXTS >>> []
CONTEXTS >>> [org.eclipse.ui.contexts.dialogAndWindow,
org.eclipse.ui.contexts.dialog]
CONTEXTS >>> [org.eclipse.ui.contexts.dialogAndWindow,
org.eclipse.ui.contexts.window]
CONTEXTS >>> [org.eclipse.ui.contexts.dialogAndWindow,
org.eclipse.jdt.ui.javaEditorScope, org.eclipse.ui.contexts.window]
CONTEXTS >>> [org.eclipse.ui.contexts.dialogAndWindow,
org.eclipse.ui.contexts.dialog]
CONTEXTS >>> [org.eclipse.ui.contexts.dialogAndWindow,
org.eclipse.jdt.ui.javaEditorScope, org.eclipse.ui.contexts.window]
CONTEXTS >>> [org.eclipse.ui.contexts.dialogAndWindow,
org.eclipse.ui.contexts.dialog]
CONTEXTS >>> [org.eclipse.ui.contexts.dialogAndWindow,
org.eclipse.jdt.ui.javaEditorScope, org.eclipse.ui.contexts.window]
CONTEXTS >>> []
CONTEXTS >>> [org.eclipse.ui.contexts.dialogAndWindow,
org.eclipse.ui.contexts.dialog]
CONTEXTS >>> [org.eclipse.ui.contexts.dialogAndWindow,
org.eclipse.jdt.ui.javaEditorScope, org.eclipse.ui.contexts.window]
CONTEXTS >>> [org.eclipse.ui.contexts.dialogAndWindow,
org.eclipse.ui.contexts.dialog]
CONTEXTS >>> [org.eclipse.ui.contexts.dialogAndWindow,
org.eclipse.jdt.ui.javaEditorScope, org.eclipse.ui.contexts.window]
CONTEXTS >>> [org.eclipse.ui.contexts.dialogAndWindow,
org.eclipse.ui.contexts.dialog]
CONTEXTS >>> [org.eclipse.ui.contexts.dialogAndWindow,
org.eclipse.jdt.ui.javaEditorScope, org.eclipse.ui.contexts.window]
Comment 16 Travis Hume CLA 2004-03-25 23:56:38 EST
Created attachment 8904 [details]
tracing output

This output is the full sequence from when the keybindings go goofy, I change
the view, bring up a dialog, hit escape and they go goofy again.
Comment 17 Douglas Pollock CLA 2004-03-26 00:08:49 EST
Steps to reproduce: 
1.) Focus to Java source editor 
2.) Ctrl+F6 to switch to a Java class file 
3.) Ctrl+F6 to switch back to the Java source editor 
4.) Ctrl+Shift+T to open dialog 
5.) Esc to close dialog 
 
The dialog context is still active.  Clicking on another view changes the 
state to window. 
Comment 18 Douglas Pollock CLA 2004-03-26 09:35:36 EST
This is a problem that appears to be specific to GNOME and most likely to the 
Metacity window manager itself.  It seems that when a dialog is closed with 
"Esc" in Metacity, no activation or deactivation is sent for the shell.  This 
is different than can be expected on KDE/kwin or on Windows XP.  I suspect 
that this either a bug or a "feature" in Metacity itself, but I'm not sure. 
 
Steve: can you comment? 
Comment 19 Douglas Pollock CLA 2004-03-26 09:40:32 EST
Created attachment 8910 [details]
Patch to "org.eclipse.ui.workbench"

This patches WorkbenchCommandSupport and WorkbenchContextSupport to include a
traverse listener.  The traverse listener waits until the event loop is idle
(asyncExec), and then processes all submissions.  It needs to wait, as the
shell is not marked as active until later in the event processing loop.

I've also added a small optimization: caching the reference to the display, so
a method call isn't need every time it is required.

Those listening to this bug: please test and provide feedback.	I'm hoping to
release this for the noon rebuild.
Comment 20 Travis Hume CLA 2004-03-26 11:32:26 EST
Seems better, but I can still repro the bug.  Open a dialog and pressing Esc
doesn't seem to trigger it anymore, but Next Editor does.

1. Open 2 editors
2. Ctrl+F6 twice to focus the same editor
3. keybindings no longer work

This seems to be reproducible for me
Comment 21 Travis Hume CLA 2004-03-26 11:33:27 EST
I was just now able to repro this behaviour (non-patched) on a kde workstation.
 It is a lot harder though and not predictable.
Comment 22 Douglas Pollock CLA 2004-03-26 12:47:56 EST
We've put in a temporary workaround that seems to cover all cases, but we 
believe the bug is truly in SWT.  Moving to SWT to fix post-M8.  We will 
remove our workaround after M8 ships. 
Comment 23 Travis Hume CLA 2004-03-26 12:54:39 EST
Which build will this workaround be included?
Comment 24 Douglas Pollock CLA 2004-03-26 13:59:30 EST
*** Bug 56362 has been marked as a duplicate of this bug. ***
Comment 25 Douglas Pollock CLA 2004-03-26 14:01:04 EST
The workaround is in the 1300 build today.  As a warning, we don't guarantee 
the workaround will cover all cases.  We do feel it makes the problem much 
harder to trigger. 
Comment 26 Travis Hume CLA 2004-03-29 12:19:31 EST
The workaround seems to work pretty well.  Thanks, M8 is a nice piece of work!
Comment 27 Steve Northover CLA 2004-03-30 15:01:06 EST
Doug, what exactly was the SWT bug again?
Comment 28 Douglas Pollock CLA 2004-03-30 15:05:32 EST
The problem is that the shell activation event is not reliable.  You created a 
small test case I believe which demonstrated the problem.  Using Metacity, 
shell deactivation/activation events are not sent when closing a dialog with a 
traversal key (e.g., "Esc", "Enter", etc.).  This problem might occur on other 
window managers as well. 
 
Comment 29 Steve Northover CLA 2004-03-30 15:25:20 EST
Right thanks.  I'm going to change the title.
Comment 30 Steve Northover CLA 2004-03-30 17:34:30 EST
This seems to WORKFORME (after I fixed the bug where the dialog shell was not 
taking focus by adding a bogus button.  The real bug has been fixed in HEAD 
but you don't have that yet).  CAn ytou try it>?

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

public class PR_56231 {
	
public static void main(String[] args) {
	Display display = new Display();
	Shell shell = new Shell(display);
	shell.setText ("Shell");
	shell.setSize(200, 200);
	Button b1 = new Button (shell, SWT.PUSH);
	b1.setSize(32, 32);
	shell.open();
	Shell dialog = new Shell(shell);
	dialog.setText ("Dialog - Press ESC");
	Button b2 = new Button (dialog, SWT.PUSH);
	b2.setSize(32, 32);
	dialog.setSize(200, 200);
	dialog.open();
	Listener listener = new Listener () {
		public void handleEvent (Event e) {
			System.out.println ("SWT.Activate " + e.widget);
		}
	};
	shell.addListener (SWT.Activate, listener);
	dialog.addListener (SWT.Activate, listener);
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch()) display.sleep();
	}
	display.dispose();
}

}
Comment 31 Billy Biggs CLA 2005-03-07 17:37:48 EST
This bug report is old and things have changed in this area.  I am having
trouble reproducing these cases using metacity 2.4.55 (RHEL3), metacity 2.8.6
(FC3), kwin 0.95 (RHEL3) and kwin from KDE 3.3 (FC3).  It may be worth
revisiting this problem.  I am going to close this bug as WORKSFORME, and Doug,
maybe we should try removing the hacks to see what happens.
Comment 32 Douglas Pollock CLA 2005-03-07 18:09:41 EST
Workaround is backed out.