This Bugzilla instance is deprecated, and most Eclipse projects now use GitHub or Eclipse GitLab. Please see the deprecation plan for details.
Bug 373814 - Missing setFocus() call on maximize/minimize/restore of stack
Summary: Missing setFocus() call on maximize/minimize/restore of stack
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.2   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 4.3 M7   Edit
Assignee: Curtis Windatt CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 348398
Blocks:
  Show dependency tree
 
Reported: 2012-03-09 11:32 EST by Curtis Windatt CLA
Modified: 2013-04-30 15:19 EDT (History)
3 users (show)

See Also:


Attachments
patch v.1 (1.07 KB, patch)
2013-01-07 11:29 EST, Piotr Aniola CLA
curtis.windatt.public: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Curtis Windatt CLA 2012-03-09 11:32:46 EST
Found while investigating Bug 348398.

Double clicking to maximize/unmaximize works inconsistently based on the fix on bug 348398.  However, using the buttons/actions to max/min the view always loses focus.
Comment 1 Curtis Windatt CLA 2012-03-09 12:31:56 EST
I don't know if I will find a solution for this in M6, but it should be of similar priority to bug 348398, so I'm marking it for 4.2 M6.
Comment 2 Eric Moffatt CLA 2012-04-04 11:26:40 EDT
Curtis, can you provide a bit more info on what you were doing ? I have a suspicion that you maximized a part with an empty editor area but I'm not sure.

I'm unable to reproduce this just playing with M6, double-click, buttons and Ctrl-M all seem to maintain focus on the active part..
Comment 3 Curtis Windatt CLA 2012-04-10 12:52:54 EDT
Sorry about the slow reply, still a few cases are not working for me.  Tested using the Problems View, with several editors open and several views stacked with the problems view.

1) Have a selection in the problems view.  Double click the tab to maximize.  Now the tab has focus, not the view part. (The view part does retain focus if the maximize button is used) (The view part also retains focus if the double click happens outside of the tab).

2) Have a selection in the problems view.  Click the minimize button.  Click the problems view icon to pop it open.  Check that there is still selection and focus on the popped open view.  Click the restore button.  View no longer has focus (not sure if any part has focus).

Interestingly, minimizing the view, popping it open, then double clicking to maximize (combo of 1 and 2) keeps focus correctly.
Comment 4 Piotr Aniola CLA 2012-12-31 11:57:36 EST
I found that minimizing the view keeps focus correctly. Maximizing looses focus.
The problem seems to be in StackRenderer$8.mouseUp():

// If the user clicks on the tab or empty stack space, call
// setFocus()
if (e.button == 1) {
	if (item == null) {
		Rectangle clientArea = ctf.getClientArea();
	if (!clientArea.contains(e.x, e.y)) {
			// User clicked in empty space
			item = ctf.getSelection();
		}
	}
	if (item != null) {
		MUIElement ele = (MUIElement) item.getData(OWNING_ME);
		if (ele.getParent().getSelectedElement() == ele) {
			Control ctrl = (Control) ele.getWidget();
			if (ctrl != null) {
				ctrl.setFocus();
			}
		}
	}
}

As far as I can tell, the above code only deals with the "empty space" part, not with the "clicking the tab" part. When maximizing, the mouse event coordinates are not outside of the (new) client area, hence the item is not retrieved, and setFocus() is not called.
Comment 5 Eric Moffatt CLA 2013-01-02 13:25:52 EST
Piotr, thanks for the info ! I think you may have figured this one out, want to try for a patch..;-) ?
Comment 6 Piotr Aniola CLA 2013-01-03 11:08:13 EST
hello Eric,

I will try, but this is not a trivial problem.

The real issue is, with a double click there are two mouseUp events. The second one appears after the view has already been maximized. The mouse coordinates are checked against where the view is now, rather than where it was at the point the click was made. This doesn't make any sense, and it causes CTabItem item = ctf.getItem(new Point(e.x, e.y)); to fail. This is where the code is supposed to handle the "user clicked the tab" case, but the tab is in a different place already.

Any hints are welcome.
Comment 7 Piotr Aniola CLA 2013-01-07 11:29:49 EST
Created attachment 225291 [details]
patch v.1

this is my first attempt at the patch.
It basically deals with the case when the user double-clicks on the tab header, which is not correctly handles bu the mouseUp method.
Please note I hadn't changed the behavior of mouseUp, as it seems to be correct for all scenarios other than minimizing/maximizing a view with doubleClick.
Comment 8 Eric Moffatt CLA 2013-01-15 14:35:13 EST
Piotr, I've just tested your patch and it seems to work fine...thanks again !!

I'm going to wait until 4.2.2 (SR2) goes out before applying it since I'm still working on 'hi pri' stuff, just wanted to let you know...;-).
Comment 9 Curtis Windatt CLA 2013-04-10 16:52:29 EDT
Piotr's patch fixed the remaining issue.

Fixed in master
http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=e1a1fff989407054cf4e7ece964b90b66ce7b554
Comment 10 Eric Moffatt CLA 2013-04-30 15:19:01 EDT

Verified in 4.3.0.I20130430-0031.  Nice one...