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

Bug 486846

Summary: Fix computation of viewerFocused property in FocusModel.
Product: [Tools] GEF Reporter: Matthias Wienand <matthias.wienand>
Component: GEF MVCAssignee: gef-inbox <gef-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: nyssen
Version: 0.2.0   
Target Milestone: 4.0.0 / 3.11.0 (Neon) M5   
Hardware: All   
OS: All   
Whiteboard:

Description Matthias Wienand CLA 2016-01-29 10:50:19 EST
Currently, the viewer focus, which provides the input for focus feedback as outlined in bug #486832, is determined based on the focus of the viewer's scene's window. However, if two viewers share the same scene, they would both be focused at the same time, which is not appropriate.

Instead, the viewer focus should be determined based on the scene's focusOwnerProperty as well as the focusedProperty of the respective focus owner (which indicates whether the window is active or not). The viewer focus should be true if and only if a focus owner exists in its scope (i.e. a nested visual) and its focusedProperty is set to true.

This requires that the focus owner is propertly updated, even if no explicit focus part is set in the FocusModel. The FXFocusBehavior should thus request focus to the root part visual in all cases where no focus part is set in the focus model (i.e. on activation, if no focus part is set, or when the focus part is set to null).
Comment 1 Matthias Wienand CLA 2016-02-01 04:06:02 EST
I pushed the following changes to master:

 - Added IViewer#viewerFocusedProperty():ReadOnlyBooleanProperty and IViewer#isViewerFocused():boolean to access the "viewerFocused" state.

 - Added change listeners for the viewer's scene, that scene's focusOwner, and that focusOwner's focused state to keep the "viewerFocused" state up-to-date.

 - Removed the "viewerFocused" property from the FocusModel.

 - Removed the FXFocusTool as it only updated the "viewerFocused" property of the FocusModel.
Comment 2 Alexander Nyßen CLA 2016-02-01 15:31:31 EST
Reopen, because at least on Mac, the viewerFocus property is not properly updated in case the window looses focus.
Comment 3 Alexander Nyßen CLA 2016-02-01 15:35:47 EST
I pushed the following changes to origin/master:

- Added listener to ensure that window focus events are properly reflected within the viewer's focused property.
- Added a binding so that the value of the viewer focused property is now computed whenever the window's focus or the focus owner's focus changes.

Matthias, can you please validate the behavior on Linux?
Comment 4 Matthias Wienand CLA 2016-02-02 04:50:57 EST
It seems to be working well: when the viewer has focus and the window loses focus, the viewer focus is not displayed anymore; and when the window gains focus again, the viewer focus is also displayed again.
Comment 5 Matthias Wienand CLA 2016-02-03 07:42:40 EST
As the viewer focus is computed correctly now, I resolve this ticket as fixed for 3.11.0 M5 (the code was released with M5 while this ticket was still open).