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

Bug 95222

Summary: [KeyBindings] Bindings stop working (no shell activation event)
Product: [Eclipse Project] Platform Reporter: Jared Burns <jared_burns>
Component: UIAssignee: Douglas Pollock <douglas.pollock>
Status: VERIFIED FIXED QA Contact:
Severity: major    
Priority: P1 CC: billy.biggs, daniel_megert, michaelvanmeekeren
Version: 3.1   
Target Milestone: 3.1 RC1   
Hardware: PC   
OS: Linux-GTK   
Whiteboard:
Attachments:
Description Flags
Patch to "org.eclipse.ui.workbench"
none
Patch to "org.eclipse.ui.workbench" none

Description Jared Burns CLA 2005-05-13 16:09:16 EDT
Build 20050513-0010
Linux-GTK

I don't have steps to reproduce yet, but while working on today's build various
keys have randomly stopped functioning. Earlier today I was trying to copy/paste
with ctrl+c/v and it wasn't working. Then I used the context menu items and it
started working again. Just now, I was trying to delete a block of text by
highlighting it and pressing backspace, but pressing backspace had no effect.
After typing in my browser window and switching back to Eclipse, the problem
went away.

It could be that the window needs to lose focus for the keys to start working
again. So maybe it's just a window focus problem.
Comment 1 Dani Megert CLA 2005-05-17 08:34:14 EDT
Looks like bug 95276.

- is the browser widget active (Help, Javadoc view)
- anything in .log?
Comment 2 Dani Megert CLA 2005-05-17 08:48:46 EDT
Not sure whether this is related but I just found this bug:
1. make sure Help view is closed
2. set focus to editor (see tab is blue)
3. open the Help view via Window > Show View
4. click into editor (text area, not the tab)
==> editor tab stays white and actions aren't retargeted (disabled in menus and
commands don't work)
Comment 3 Dani Megert CLA 2005-05-17 08:58:56 EDT
Even more bad things happen with the Help view (after step 3 in comment 2):
- the editor still has the input focus
- if I open the context menu the one for the editor is opened

After step 4 in comment 2 give the focus to the editor by clicking on the tab
and press Ctrl+F7 and we're back into the same trouble.

Those findings are on Windows XP, N20050517-0010.

Javadoc view behaves fine in that scenario.

Jared, is the Help view open in your workbench window? If so, can you reproduce
this bug once the Help view is closed?

Comment 4 Douglas Pollock CLA 2005-05-17 11:19:41 EDT
Okay, Dani please file a separate bug if you feel something else is going on.


Billy and I pulled out a kludge for Bug 56231 a month or two ago.  Since then,
these intermittent failures have been possible.  It is a race condition between
a workaround for a bug in GTK+ and the window manager.  We now have confirmed
that it is possible to make a situation in which a shell activation event will
not be sent when a dialog closes.  All of the key binding code is dependent on
the shell activation events, and so this can cause the key bindings to stop working.

I believe the situation is recreatable with the following conditions:
1.) Mouse pointer is over the main Eclipse window
2.) Use the keyboard to open and close a dialog
3.) Get (un)lucky on the timing of certain focus events

We will likely be putting the kludge back in place.  The kludge is simply to
take the shell on which a key binding arrives as the active shell.  If it does
not correspond to our current internal state of the world, we update our
internal state to match.

The symptoms for this bug are:
1.) Some or all of the key bindings in the menus will appear correctly
2.) No key bindings will work
3.) Clicking around in the workbench window will not restore sanity
4.) Switching to another shell and back to the workbench window will restore sanity
5.) Mnemonics will continue to work
6.) Typing in the focus control (i.e., native widget keyboard behaviour) will
still work

I have opened Bug 95569 to describe a different technical problem that can be
triggered by similar steps.

I have opened Bug 95575 to cover a better (but riskier) way of solving this
problem in SWT itself.

MVM: I would like to commit a patch to workaround this problem in SWT.
Comment 5 Douglas Pollock CLA 2005-05-17 11:28:55 EDT
Created attachment 21263 [details]
Patch to "org.eclipse.ui.workbench"

The ugly kludge patch (first version).	I think some further refinement might
help the performance of this patch.
Comment 6 Dani Megert CLA 2005-05-17 11:46:22 EDT
I filed bug 95581 against Platform Help for the problems reported in comment 2
and comment 3 which I added here since, before comment 4, it was not clear that
this was a Linux-GTK only bug.

Just to confirm: this bug (and the related code) has no effect on any other
Platform i.e. bug 95276 cannot be related to this in any way?
Comment 7 Douglas Pollock CLA 2005-05-17 11:51:09 EDT
There are symptoms are there are problems.  Unfortunately, with key bindings
sometimes there can be very similar symptoms caused by radically different
problems.  I'm taking this bug to be the problem described in comment #4, as
this most closely matches the description.  The problem described in comment #4
occurs only on GTK+.
Comment 8 Jared Burns CLA 2005-05-17 12:05:11 EDT
To answer Dani's question in comment #3, no, I never open the Help view. This
was occurring during my normal development, so Doug's scenario is entirely
possible. I open the "Open Type" dialog using the keybinding (ctrl+shift+t) all
the time.
Comment 9 Michael Van Meekeren CLA 2005-05-18 11:37:28 EDT
approve, please document the patch with the SWT bug so we can remove it in the
future if possible
Comment 10 Douglas Pollock CLA 2005-05-18 14:58:05 EDT
Created attachment 21370 [details]
Patch to "org.eclipse.ui.workbench"

This is just a refinement of the patch which tries to isolate the crazy method
calls that WorkbenchKeyboard needs to make to specific method calls.  These
method calls are then marked with the bug number and big "DO NOT USE" warnings
in their comments.
Comment 11 Douglas Pollock CLA 2005-05-18 15:01:03 EDT
Fixed in CVS.
Comment 12 Douglas Pollock CLA 2005-05-26 15:36:30 EDT
Failed to reproduce this problem by hammering on the "ctrl+shift+t" and "esc"
combo for a while.  I20050526-1200