Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 466114 - [content assist] Parameter Hints popup closes when attempting to resize on GTK
Summary: [content assist] Parameter Hints popup closes when attempting to resize on GTK
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 4.5   Edit
Hardware: PC Linux
: P3 normal with 2 votes (vote)
Target Milestone: 4.6 RC1   Edit
Assignee: Markus Keller CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-05-01 22:33 EDT by Stefan Xenos CLA
Modified: 2016-05-13 12:40 EDT (History)
6 users (show)

See Also:
daniel_megert: review+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Xenos CLA 2015-05-01 22:33:34 EDT
To reproduce, put this class in your workspace:

public class Zip extends Foo {
	@Override
	void blam(String foo, int bar) {
		super.blam();
	}
	
	void blam(int a, int b) {
		
	}
	
	void zo() {
		blam();
	}
}

...then open it in a java editor, move your cursor between the brackets of blam() and press ctrl-shift-space. 

A content assist window opens asking you which blam() you meant to use.

Hover your cursor over the window trim. Observe that you get a mouseover affordance suggesting the window is resizable. Try to resize it.

Observed:

The window closes.

Expected:

The window resizes.
Comment 1 Eclipse Genie CLA 2015-05-01 22:52:11 EDT
New Gerrit change created: https://git.eclipse.org/r/46971
Comment 2 Stefan Xenos CLA 2015-05-01 22:59:13 EDT
ContentAssistant.java was closing the dialog in a number of situations. One of them seems to be focus change to another view. During the act of resizing, keyboard focus seems to be disabled in some circumstances (this bit I don't understand exactly) and SWT is firing a FocusEvent to the dialog. 

The dialog was handling treating this as a focus change and closing itself. However, the event was just informing the dialog that nothing had focus - not that focus had moved anywhere else yet.

My fix was to add a check to ensure that something else actually has received focus before closing the dialog due to a focus event.

I also added a check to ensure that the initial size of the dialog is large enough for the resize drag handles to be clickable and for some minimum content.
Comment 3 Dani Megert CLA 2015-05-04 03:08:58 EDT
I won't make such a change during RC*. I'll take a closer look early 4.6.
Comment 4 Eclipse Genie CLA 2015-05-04 22:53:40 EDT
New Gerrit change created: https://git.eclipse.org/r/47114
Comment 5 Marc-André Laperle CLA 2015-05-06 00:57:40 EDT
I can't reproduce this on Ubuntu 15.04 with GTK 2.24.27 (SWT_GTK3=0) and GTK 3.14.12. Can you add information about your distribution and GTK version? Thanks!
Comment 6 Stefan Xenos CLA 2015-06-05 19:07:49 EDT
Ubuntu 14.0.4 LTS

My gtk versions:
 2.24.23-0ubuntu1.2
 3.10.8-0ubuntu1.4
Comment 7 Stefan Xenos CLA 2015-06-05 19:26:41 EDT
Re: comment 4

I can't actually reproduce it right now, either.

However, since one of the characteristics of this bug is a null focus control, I suspect that the SWT bits may be related to bug 469525. That bug is intermittent since it depends on the SWT event order, so it's possible that this one is intermittent, too.
Comment 8 Dani Megert CLA 2015-06-06 04:02:19 EDT
(In reply to Stefan Xenos from comment #7)
> Re: comment 4
> 
> I can't actually reproduce it right now, either.
> 
> However, since one of the characteristics of this bug is a null focus
> control, I suspect that the SWT bits may be related to bug 469525. That bug
> is intermittent since it depends on the SWT event order, so it's possible
> that this one is intermittent, too.

OK, let's close this bug and reopen it if someone sees this again.
Comment 9 Marcel Lohmann CLA 2015-08-13 16:52:33 EDT
I can confirm this bug. My system is Ubuntu 15.04 with 
 - libgtk version 3.14.13-0ubuntu1
 - libgtk2 version 2.24.27-0ubuntu1
and Eclipse Mars on OpenJDK 1.8.0_45 (also Ubuntu-Version)

Fist of all we have to distinguish between the two versions of "Content Assist":

1) The first version is accessible via CTRL-SPACE and is identifiable by the status bar showing "Press 'Ctrl+Space' to show ..."
2) The second version is accessible via CTRL-SHIFT-SPACE and does not contain the status bar

The first version works perfectly as expected. It keeps the size every time you invoke it and is resizeable with the mouse.

The second version does show the misbehavior. It is not resizeable, as it disappears on resizing with the mouse. Also it shrinks every time you invoke the content assist (by a small amount), until it is totally useless as it is almost invisible.

It helps to edit workspace/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml and increasing the value
        <section name="completion_proposal_size">
                <item value="357" key="contextSelector.size.y"/>
                <item value="889" key="contextSelector.size.x"/>
        </section>
If you make it large you can invoke the content assist several times before it shrinks to almost zero.

What scares me is, that this bug is related to Bug 23980 which is almost thirteen years old.

It would be great if one could make the second version like the first (working) one.
Comment 10 Stefan Xenos CLA 2015-08-13 18:59:04 EDT
Reopening, as per Marcel's comment.
Comment 11 Marcel Lohmann CLA 2015-08-14 11:45:48 EDT
I can also confirm the bug on openSUSE 13.2 with Eclipse Mars.
And just to make sure that this is not a new bug, I can also confirm this on Knoppix 7.4.2, Eclipse 3.8.1 with libgtk3 (3.12.2) and libgtk2 (2.24.24)

On the other hand a MacOSX 10.10.4 (with Mars) is not affected; Windows 8.1 64bit (with Mars) does also work as expected.
Comment 12 Markus Keller CLA 2016-05-04 12:26:50 EDT
Fixing the summary: This is about Parameter Hints (Ctrl+Shift+Space) on GTK.

There are some platform inconsistencies in SWT APIs about focus and activation events that have never been fixed or documented completely.

The workaround that has been in use for ages is to use Display#getActiveShell() instead of trying to call #isFocusControl() on all possible controls.

See e.g. bug 62652, bug 23980, the Javadoc of IInformationControlExtension5, and 
http://git.eclipse.org/c/platform/eclipse.platform.text.git/diff/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposalPopup.java?id=cef6230e04a6f55f8bb087bfd0ca0d40e1fdfacd

The fix is to use the same code in ContextInformationPopup (which is in large parts an outdated copy of CompletionProposalPopup).
Comment 13 Eclipse Genie CLA 2016-05-04 12:35:48 EDT
New Gerrit change created: https://git.eclipse.org/r/72056
Comment 14 Dani Megert CLA 2016-05-05 09:04:17 EDT
(In reply to Markus Keller from comment #12)
> The fix is to use the same code in ContextInformationPopup (which is in
> large parts an outdated copy of CompletionProposalPopup).

I've pushed that fix on behalf of you with http://git.eclipse.org/c/platform/eclipse.platform.text.git/commit/?id=a42daa50b482b9f5f93b024be42757c427433f1e
Comment 15 Markus Keller CLA 2016-05-13 12:40:47 EDT
Verified in I20160512-1000.