use of com.intellij.openapi.wm.impl.FloatingDecorator in project intellij-community by JetBrains.
the class IdeKeyEventDispatcher method isModalContext.
/**
* @return {@code true} if and only if the {@code component} represents
* modal context.
* @throws IllegalArgumentException if {@code component} is {@code null}.
*/
public static boolean isModalContext(@NotNull Component component) {
Window window = UIUtil.getWindow(component);
if (window instanceof IdeFrameImpl) {
final Component pane = ((IdeFrameImpl) window).getGlassPane();
if (pane instanceof IdeGlassPaneEx) {
return ((IdeGlassPaneEx) pane).isInModalContext();
}
}
if (window instanceof JDialog) {
final JDialog dialog = (JDialog) window;
if (!dialog.isModal()) {
final Window owner = dialog.getOwner();
return owner != null && isModalContext(owner);
}
}
if (window instanceof JFrame) {
return false;
}
boolean isFloatingDecorator = window instanceof FloatingDecorator;
boolean isPopup = !(component instanceof JFrame) && !(component instanceof JDialog);
if (isPopup) {
if (component instanceof JWindow) {
JBPopup popup = (JBPopup) ((JWindow) component).getRootPane().getClientProperty(JBPopup.KEY);
if (popup != null) {
return popup.isModalContext();
}
}
}
return !isFloatingDecorator;
}
use of com.intellij.openapi.wm.impl.FloatingDecorator in project intellij-community by JetBrains.
the class RequestFocusInEditorComponentCmd method run.
public final void run() {
try {
if (myTimestamp.isExpired()) {
final Component owner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
if (owner != null && owner == myComponent) {
myDoneCallback.setDone();
} else {
myDoneCallback.setRejected();
}
}
final Window owner = myComponent != null ? SwingUtilities.getWindowAncestor(myComponent) : null;
if (owner == null) {
myDoneCallback.setRejected();
return;
}
final Window activeFrame = IdeFrameImpl.getActiveFrame();
if (activeFrame != null && owner instanceof IdeFrameImpl && activeFrame != owner) {
myDoneCallback.setRejected();
return;
}
if (myComponent != null) {
final boolean forced = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() == null;
myFocusManager.requestFocus(myComponent, myForced || forced).notifyWhenDone(myDoneCallback).doWhenDone(() -> {
if (SystemInfo.isLinux && Registry.is("suppress.focus.stealing"))
return;
// isn't active.
if (!owner.isActive()) {
final Window activeWindow = getActiveWindow(owner.getOwnedWindows());
if (activeWindow == null || (activeWindow instanceof FloatingDecorator)) {
//Thread.dumpStack();
//System.out.println("------------------------------------------------------");
owner.toFront();
}
}
});
} else {
myDoneCallback.setRejected();
}
} finally {
finish();
}
}
use of com.intellij.openapi.wm.impl.FloatingDecorator in project intellij-community by JetBrains.
the class DataManagerImpl method getFocusedComponent.
@Nullable
private Component getFocusedComponent() {
if (myWindowManager == null) {
return null;
}
Window activeWindow = myWindowManager.getMostRecentFocusedWindow();
if (activeWindow == null) {
activeWindow = KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow();
if (activeWindow == null) {
activeWindow = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow();
if (activeWindow == null)
return null;
}
}
if (Registry.is("actionSystem.noContextComponentWhileFocusTransfer")) {
IdeFocusManager fm = IdeFocusManager.findInstanceByComponent(activeWindow);
if (fm.isFocusBeingTransferred()) {
return null;
}
}
// whereas we want to be able to type in other frames as well.
if (activeWindow instanceof FloatingDecorator) {
IdeFocusManager ideFocusManager = IdeFocusManager.findInstanceByComponent(activeWindow);
IdeFrame lastFocusedFrame = ideFocusManager.getLastFocusedFrame();
JComponent frameComponent = lastFocusedFrame != null ? lastFocusedFrame.getComponent() : null;
Window lastFocusedWindow = frameComponent != null ? SwingUtilities.getWindowAncestor(frameComponent) : null;
boolean toolWindowIsNotFocused = myWindowManager.getFocusedComponent(activeWindow) == null;
if (toolWindowIsNotFocused && lastFocusedWindow != null) {
activeWindow = lastFocusedWindow;
}
}
// try to find first parent window that has focus
Window window = activeWindow;
Component focusedComponent = null;
while (window != null) {
focusedComponent = myWindowManager.getFocusedComponent(window);
if (focusedComponent != null) {
break;
}
window = window.getOwner();
}
if (focusedComponent == null) {
focusedComponent = activeWindow;
}
return focusedComponent;
}
Aggregations