mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'master' of git.labs.intellij.net:idea/community
This commit is contained in:
@@ -545,21 +545,17 @@ public class IdeEventQueue extends EventQueue {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean fixStickyFocusedComponents(@Nullable AWTEvent e) {
|
||||
boolean attemptedToFix = false;
|
||||
|
||||
if (e != null && !(e instanceof InputEvent)) return attemptedToFix;
|
||||
public void fixStickyFocusedComponents(@Nullable AWTEvent e) {
|
||||
if (e != null && !(e instanceof InputEvent)) return;
|
||||
|
||||
final KeyboardFocusManager mgr = KeyboardFocusManager.getCurrentKeyboardFocusManager();
|
||||
|
||||
if (Registry.is("actionSystem.fixStickyFocusedWindows")) {
|
||||
attemptedToFix = true;
|
||||
fixStickyWindow(mgr, mgr.getActiveWindow(), "setGlobalActiveWindow");
|
||||
fixStickyWindow(mgr, mgr.getFocusedWindow(), "setGlobalFocusedWindow");
|
||||
}
|
||||
|
||||
if (Registry.is("actionSystem.fixNullFocusedComponent")) {
|
||||
attemptedToFix = true;
|
||||
final Component focusOwner = mgr.getFocusOwner();
|
||||
if (focusOwner == null) {
|
||||
|
||||
@@ -615,8 +611,6 @@ public class IdeEventQueue extends EventQueue {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return attemptedToFix;
|
||||
}
|
||||
|
||||
private void enterSuspendModeIfNeeded(AWTEvent e) {
|
||||
|
||||
@@ -31,7 +31,6 @@ import com.intellij.openapi.wm.*;
|
||||
import com.intellij.openapi.wm.ex.IdeFocusTraversalPolicy;
|
||||
import com.intellij.ui.FocusTrackback;
|
||||
import com.intellij.util.Alarm;
|
||||
import com.intellij.util.containers.HashSet;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -70,7 +69,7 @@ public class FocusManagerImpl extends IdeFocusManager implements Disposable {
|
||||
private final EdtAlarm myForcedFocusRequestsAlarm;
|
||||
|
||||
private final EdtAlarm myIdleAlarm;
|
||||
private final Set<Runnable> myIdleRequests = new HashSet<Runnable>();
|
||||
private final Set<Runnable> myIdleRequests = new LinkedHashSet<Runnable>();
|
||||
private final EdtRunnable myIdleRunnable = new EdtRunnable() {
|
||||
public void runEdt() {
|
||||
if (canFlushIdleRequests()) {
|
||||
@@ -81,6 +80,7 @@ public class FocusManagerImpl extends IdeFocusManager implements Disposable {
|
||||
}
|
||||
}
|
||||
};
|
||||
private boolean myFlushWasDelayedToFixFocus;
|
||||
|
||||
private boolean canFlushIdleRequests() {
|
||||
return isFocusTransferReady() && !isIdleQueueEmpty();
|
||||
@@ -350,6 +350,7 @@ public class FocusManagerImpl extends IdeFocusManager implements Disposable {
|
||||
public void run() {
|
||||
if (isFlushingIdleRequests()) {
|
||||
SwingUtilities.invokeLater(this);
|
||||
return;
|
||||
}
|
||||
|
||||
if (myRunContext != null) {
|
||||
@@ -360,7 +361,7 @@ public class FocusManagerImpl extends IdeFocusManager implements Disposable {
|
||||
final boolean needsRestart = isIdleQueueEmpty();
|
||||
myIdleRequests.add(runnable);
|
||||
|
||||
if (isFocusTransferReady()) {
|
||||
if (canFlushIdleRequests()) {
|
||||
flushIdleRequests();
|
||||
} else {
|
||||
if (needsRestart) {
|
||||
@@ -420,19 +421,15 @@ public class FocusManagerImpl extends IdeFocusManager implements Disposable {
|
||||
|
||||
|
||||
if (isPendingKeyEventsRedispatched()) {
|
||||
boolean focusOk = getFocusOwner() != null;
|
||||
boolean attemptedToFixFocus = IdeEventQueue.getInstance().fixStickyFocusedComponents(null);
|
||||
boolean focusOk = getFocusOwner() != null || myFlushWasDelayedToFixFocus;
|
||||
if (!focusOk) {
|
||||
IdeEventQueue.getInstance().fixStickyFocusedComponents(null);
|
||||
myFlushWasDelayedToFixFocus = true;
|
||||
}
|
||||
|
||||
if (canFlushIdleRequests() && myFlushingIdleRequestsEntryCount <= 1) {
|
||||
if (focusOk || !attemptedToFixFocus) {
|
||||
final Runnable[] all = myIdleRequests.toArray(new Runnable[myIdleRequests.size()]);
|
||||
myIdleRequests.clear();
|
||||
for (Runnable each : all) {
|
||||
if (each != null) {
|
||||
each.run();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (canFlushIdleRequests() && myFlushingIdleRequestsEntryCount <= 1 && (focusOk || !myFlushWasDelayedToFixFocus)) {
|
||||
myFlushWasDelayedToFixFocus = false;
|
||||
flushNow();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -444,6 +441,16 @@ public class FocusManagerImpl extends IdeFocusManager implements Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
private void flushNow() {
|
||||
final Runnable[] all = myIdleRequests.toArray(new Runnable[myIdleRequests.size()]);
|
||||
myIdleRequests.clear();
|
||||
for (Runnable each : all) {
|
||||
if (each != null) {
|
||||
each.run();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isFocusTransferReady() {
|
||||
if (myRunContext != null) return true;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user