Fix small race condition in LinuxDisplay when focusing in and out really fast.
This commit is contained in:
parent
6e15f0b781
commit
7782156962
|
@ -148,16 +148,12 @@ final class LinuxDisplay implements DisplayImplementation {
|
||||||
private final FocusListener focus_listener = new FocusListener() {
|
private final FocusListener focus_listener = new FocusListener() {
|
||||||
public void focusGained(FocusEvent e) {
|
public void focusGained(FocusEvent e) {
|
||||||
synchronized (GlobalLock.lock) {
|
synchronized (GlobalLock.lock) {
|
||||||
nGrabKeyboard(getDisplay(), current_window);
|
|
||||||
focused = true;
|
focused = true;
|
||||||
input_released = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void focusLost(FocusEvent e) {
|
public void focusLost(FocusEvent e) {
|
||||||
synchronized (GlobalLock.lock) {
|
synchronized (GlobalLock.lock) {
|
||||||
nUngrabKeyboard(getDisplay());
|
|
||||||
focused = false;
|
focused = false;
|
||||||
input_released = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -823,6 +819,7 @@ final class LinuxDisplay implements DisplayImplementation {
|
||||||
lockAWT();
|
lockAWT();
|
||||||
try {
|
try {
|
||||||
processEvents();
|
processEvents();
|
||||||
|
checkInput();
|
||||||
} finally {
|
} finally {
|
||||||
unlockAWT();
|
unlockAWT();
|
||||||
}
|
}
|
||||||
|
@ -904,6 +901,21 @@ final class LinuxDisplay implements DisplayImplementation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void checkInput() {
|
||||||
|
if (parent == null) return;
|
||||||
|
|
||||||
|
if (focused != keyboard_grabbed) {
|
||||||
|
if (focused) {
|
||||||
|
grabKeyboard();
|
||||||
|
input_released = false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ungrabKeyboard();
|
||||||
|
input_released = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void setFocused(boolean got_focus, int focus_detail) {
|
private void setFocused(boolean got_focus, int focus_detail) {
|
||||||
if (focused == got_focus || focus_detail == NotifyDetailNone || focus_detail == NotifyPointer || focus_detail == NotifyPointerRoot || parent != null)
|
if (focused == got_focus || focus_detail == NotifyDetailNone || focus_detail == NotifyPointer || focus_detail == NotifyPointerRoot || parent != null)
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue