Skip to content

Commit 2f19214

Browse files
committed
Ensure active part receives focus on perspective switch
When switching a perspective, if a view exists in both the old and the new perspective, it doesn't gain focus after the perspective switch. This is contrary to the case in which a view is open only in the new perspective. Since editors are shared between perspectives, the same bug always occurs for editors - the editor will lose focus on a perspective switch. This change adds part focusing code on the code branch, on which the active part already exists in the new perspective. This ensures the active part gains focus. Note that this change doesn't preserve focus of the active part in each perspective. I.e. if View A is active in perspective X and View B was active in perspective Y, upon switching to perspective Y, View A will become active if it exists. The change only ensures that focus is not lost altogether. Fixes: #2839 Signed-off-by: Simeon Andreev <[email protected]>
1 parent edbc549 commit 2f19214

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/PartServiceImpl.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,9 @@ private void activate(MPart part, boolean requiresFocus, boolean activateBranch)
730730
// insert it in the beginning of the activation history, it may not have been inserted
731731
// pending when this service was instantiated
732732
partActivationHistory.prepend(part);
733+
if (requiresFocus) {
734+
focusPart(part);
735+
}
733736
UIEvents.publishEvent(UIEvents.UILifeCycle.ACTIVATE, part);
734737
if (Policy.DEBUG_FOCUS) {
735738
Activator.trace(Policy.DEBUG_FOCUS_FLAG, "Trying to activate already active part: " + part, null);//$NON-NLS-1$

0 commit comments

Comments
 (0)