mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-03 17:59:46 +02:00
Merge remote-tracking branch
'origin/GP-4857-dragonmacher-focus-fix--SQUASHED' (Closes #6782, #6576)
This commit is contained in:
commit
f20275ed04
4 changed files with 34 additions and 37 deletions
|
@ -26,7 +26,8 @@ import org.jdom.Element;
|
|||
import docking.actions.KeyBindingUtils;
|
||||
import docking.widgets.OptionDialog;
|
||||
import docking.widgets.tabbedpane.DockingTabRenderer;
|
||||
import ghidra.util.*;
|
||||
import ghidra.util.HelpLocation;
|
||||
import ghidra.util.Msg;
|
||||
import ghidra.util.exception.AssertException;
|
||||
import help.HelpService;
|
||||
import utilities.util.reflection.ReflectionUtilities;
|
||||
|
@ -108,12 +109,9 @@ class ComponentNode extends Node {
|
|||
return;
|
||||
}
|
||||
ComponentPlaceholder placeholder = getPlaceHolderForComponent(component);
|
||||
if (placeholder == null) {
|
||||
return;
|
||||
if (placeholder != null) {
|
||||
placeholder.requestFocusWhenReady();
|
||||
}
|
||||
Swing.runLater(() -> {
|
||||
placeholder.requestFocus();
|
||||
});
|
||||
}
|
||||
|
||||
private boolean containsPlaceholder(ComponentPlaceholder placeholder) {
|
||||
|
|
|
@ -15,9 +15,10 @@
|
|||
*/
|
||||
package docking;
|
||||
|
||||
import java.awt.Frame;
|
||||
import java.awt.Window;
|
||||
import java.util.*;
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
|
@ -25,8 +26,8 @@ import org.apache.commons.lang3.StringUtils;
|
|||
|
||||
import docking.action.DockingAction;
|
||||
import docking.action.DockingActionIf;
|
||||
import generic.timer.ExpiringSwingTimer;
|
||||
import ghidra.util.Msg;
|
||||
import ghidra.util.Swing;
|
||||
import ghidra.util.exception.AssertException;
|
||||
import utilities.util.reflection.ReflectionUtilities;
|
||||
|
||||
|
@ -275,7 +276,7 @@ public class ComponentPlaceholder {
|
|||
/**
|
||||
* Requests focus for the component associated with this placeholder.
|
||||
*/
|
||||
void requestFocus() {
|
||||
void requestFocusWhenReady() {
|
||||
DockableComponent tmp = comp;// put in temp variable in case another thread deletes it
|
||||
if (tmp == null) {
|
||||
return;
|
||||
|
@ -285,14 +286,22 @@ public class ComponentPlaceholder {
|
|||
activateWindow();
|
||||
|
||||
// make sure the tab has time to become active before trying to request focus
|
||||
tmp.requestFocus();
|
||||
|
||||
Swing.runLater(() -> {
|
||||
tmp.requestFocus();
|
||||
contextChanged();
|
||||
ExpiringSwingTimer.runWhen(this::isShowing, 750, () -> {
|
||||
doRequestFocus(tmp);
|
||||
});
|
||||
}
|
||||
|
||||
private void doRequestFocus(DockableComponent dockableComponent) {
|
||||
KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
|
||||
Window activeWindow = kfm.getActiveWindow();
|
||||
if (activeWindow == null) {
|
||||
return; // our application isn't focused--don't do anything
|
||||
}
|
||||
|
||||
dockableComponent.requestFocus();
|
||||
contextChanged();
|
||||
}
|
||||
|
||||
// makes sure that the given window is not in an iconified state
|
||||
private void activateWindow() {
|
||||
DetachedWindowNode windowNode = getDetachedWindowNode();
|
||||
|
|
|
@ -1383,19 +1383,9 @@ public class DockingWindowManager implements PropertyChangeListener, Placeholder
|
|||
}
|
||||
|
||||
private void updateFocus(ComponentPlaceholder placeholder) {
|
||||
if (placeholder == null) {
|
||||
return;
|
||||
if (placeholder != null) {
|
||||
placeholder.requestFocusWhenReady();
|
||||
}
|
||||
|
||||
Swing.runLater(() -> {
|
||||
KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
|
||||
Window activeWindow = kfm.getActiveWindow();
|
||||
if (activeWindow == null) {
|
||||
// our application isn't focused--don't do anything
|
||||
return;
|
||||
}
|
||||
placeholder.requestFocus();
|
||||
});
|
||||
}
|
||||
|
||||
void restoreFocusOwner(String focusOwner, String focusName) {
|
||||
|
|
|
@ -234,7 +234,7 @@ class RootNode extends WindowNode {
|
|||
}
|
||||
detachedWindows.add(windowNode);
|
||||
info.getNode().add(info);
|
||||
info.requestFocus();
|
||||
info.requestFocusWhenReady();
|
||||
notifyWindowAdded(windowNode);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue