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
|
@ -4,9 +4,9 @@
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@ -26,7 +26,8 @@ import org.jdom.Element;
|
||||||
import docking.actions.KeyBindingUtils;
|
import docking.actions.KeyBindingUtils;
|
||||||
import docking.widgets.OptionDialog;
|
import docking.widgets.OptionDialog;
|
||||||
import docking.widgets.tabbedpane.DockingTabRenderer;
|
import docking.widgets.tabbedpane.DockingTabRenderer;
|
||||||
import ghidra.util.*;
|
import ghidra.util.HelpLocation;
|
||||||
|
import ghidra.util.Msg;
|
||||||
import ghidra.util.exception.AssertException;
|
import ghidra.util.exception.AssertException;
|
||||||
import help.HelpService;
|
import help.HelpService;
|
||||||
import utilities.util.reflection.ReflectionUtilities;
|
import utilities.util.reflection.ReflectionUtilities;
|
||||||
|
@ -108,12 +109,9 @@ class ComponentNode extends Node {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ComponentPlaceholder placeholder = getPlaceHolderForComponent(component);
|
ComponentPlaceholder placeholder = getPlaceHolderForComponent(component);
|
||||||
if (placeholder == null) {
|
if (placeholder != null) {
|
||||||
return;
|
placeholder.requestFocusWhenReady();
|
||||||
}
|
}
|
||||||
Swing.runLater(() -> {
|
|
||||||
placeholder.requestFocus();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean containsPlaceholder(ComponentPlaceholder placeholder) {
|
private boolean containsPlaceholder(ComponentPlaceholder placeholder) {
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@ -15,9 +15,10 @@
|
||||||
*/
|
*/
|
||||||
package docking;
|
package docking;
|
||||||
|
|
||||||
import java.awt.Frame;
|
import java.awt.*;
|
||||||
import java.awt.Window;
|
import java.util.ArrayList;
|
||||||
import java.util.*;
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
|
||||||
|
@ -25,8 +26,8 @@ import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import docking.action.DockingAction;
|
import docking.action.DockingAction;
|
||||||
import docking.action.DockingActionIf;
|
import docking.action.DockingActionIf;
|
||||||
|
import generic.timer.ExpiringSwingTimer;
|
||||||
import ghidra.util.Msg;
|
import ghidra.util.Msg;
|
||||||
import ghidra.util.Swing;
|
|
||||||
import ghidra.util.exception.AssertException;
|
import ghidra.util.exception.AssertException;
|
||||||
import utilities.util.reflection.ReflectionUtilities;
|
import utilities.util.reflection.ReflectionUtilities;
|
||||||
|
|
||||||
|
@ -275,7 +276,7 @@ public class ComponentPlaceholder {
|
||||||
/**
|
/**
|
||||||
* Requests focus for the component associated with this placeholder.
|
* 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
|
DockableComponent tmp = comp;// put in temp variable in case another thread deletes it
|
||||||
if (tmp == null) {
|
if (tmp == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -285,14 +286,22 @@ public class ComponentPlaceholder {
|
||||||
activateWindow();
|
activateWindow();
|
||||||
|
|
||||||
// make sure the tab has time to become active before trying to request focus
|
// make sure the tab has time to become active before trying to request focus
|
||||||
tmp.requestFocus();
|
ExpiringSwingTimer.runWhen(this::isShowing, 750, () -> {
|
||||||
|
doRequestFocus(tmp);
|
||||||
Swing.runLater(() -> {
|
|
||||||
tmp.requestFocus();
|
|
||||||
contextChanged();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
// makes sure that the given window is not in an iconified state
|
||||||
private void activateWindow() {
|
private void activateWindow() {
|
||||||
DetachedWindowNode windowNode = getDetachedWindowNode();
|
DetachedWindowNode windowNode = getDetachedWindowNode();
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@ -1383,19 +1383,9 @@ public class DockingWindowManager implements PropertyChangeListener, Placeholder
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateFocus(ComponentPlaceholder placeholder) {
|
private void updateFocus(ComponentPlaceholder placeholder) {
|
||||||
if (placeholder == null) {
|
if (placeholder != null) {
|
||||||
return;
|
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) {
|
void restoreFocusOwner(String focusOwner, String focusName) {
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@ -234,7 +234,7 @@ class RootNode extends WindowNode {
|
||||||
}
|
}
|
||||||
detachedWindows.add(windowNode);
|
detachedWindows.add(windowNode);
|
||||||
info.getNode().add(info);
|
info.getNode().add(info);
|
||||||
info.requestFocus();
|
info.requestFocusWhenReady();
|
||||||
notifyWindowAdded(windowNode);
|
notifyWindowAdded(windowNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue