mirror of
https://github.com/shadowfacts/lwjgl2-arm64.git
synced 2026-04-03 11:59:40 +02:00
Complete overhaul of the linux focus system when using Display.setParent(). This should fix the input problems with applets (on linux) due to Display not being able to gain focus.
Also now works perfectly in all browsers, previously input focus was not restored to other browser components when requested (like firefox's address bar).
This commit is contained in:
parent
7ef37e9858
commit
604e52013a
|
|
@ -127,27 +127,11 @@ final class LinuxDisplay implements DisplayImplementation {
|
|||
private Canvas parent;
|
||||
private long parent_window;
|
||||
private boolean xembedded;
|
||||
private boolean parent_focused;
|
||||
private boolean parent_focus_changed;
|
||||
private boolean parent_focus;
|
||||
|
||||
private LinuxKeyboard keyboard;
|
||||
private LinuxMouse mouse;
|
||||
|
||||
private final FocusListener focus_listener = new FocusListener() {
|
||||
public void focusGained(FocusEvent e) {
|
||||
synchronized (GlobalLock.lock) {
|
||||
parent_focused = true;
|
||||
parent_focus_changed = true;
|
||||
}
|
||||
}
|
||||
public void focusLost(FocusEvent e) {
|
||||
synchronized (GlobalLock.lock) {
|
||||
parent_focused = false;
|
||||
parent_focus_changed = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private static ByteBuffer getCurrentGammaRamp() throws LWJGLException {
|
||||
lockAWT();
|
||||
try {
|
||||
|
|
@ -439,11 +423,6 @@ final class LinuxDisplay implements DisplayImplementation {
|
|||
grab = false;
|
||||
minimized = false;
|
||||
dirty = true;
|
||||
if (parent != null) {
|
||||
parent.addFocusListener(focus_listener);
|
||||
parent_focused = parent.isFocusOwner();
|
||||
parent_focus_changed = true;
|
||||
}
|
||||
} finally {
|
||||
peer_info.unlock();
|
||||
}
|
||||
|
|
@ -494,8 +473,6 @@ final class LinuxDisplay implements DisplayImplementation {
|
|||
public void destroyWindow() {
|
||||
lockAWT();
|
||||
try {
|
||||
if (parent != null)
|
||||
parent.removeFocusListener(focus_listener);
|
||||
try {
|
||||
setNativeCursor(null);
|
||||
} catch (LWJGLException e) {
|
||||
|
|
@ -853,16 +830,20 @@ final class LinuxDisplay implements DisplayImplementation {
|
|||
}
|
||||
|
||||
private void checkInput() {
|
||||
if (parent == null || !parent_focus_changed)
|
||||
return;
|
||||
if (parent == null) return;
|
||||
|
||||
if (!focused && parent_focused) {
|
||||
if (xembedded) {
|
||||
// disable parent from taking focus back from Display when it is clicked
|
||||
parent.setFocusable(false);
|
||||
if (parent_focus != parent.hasFocus()) {
|
||||
parent_focus = parent.hasFocus();
|
||||
|
||||
if (parent_focus) {
|
||||
setInputFocusUnsafe(current_window);
|
||||
}
|
||||
setInputFocusUnsafe(getWindow());
|
||||
parent_focus_changed = false;
|
||||
else {
|
||||
setInputFocusUnsafe(0);
|
||||
}
|
||||
}
|
||||
else if (parent_focus && !focused) {
|
||||
setInputFocusUnsafe(current_window);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -874,19 +855,8 @@ final class LinuxDisplay implements DisplayImplementation {
|
|||
if (focused) {
|
||||
acquireInput();
|
||||
}
|
||||
|
||||
if (parent != null && xembedded && focused != parent.hasFocus()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!focused) {
|
||||
else {
|
||||
releaseInput();
|
||||
|
||||
if (parent != null && xembedded) {
|
||||
setInputFocusUnsafe(0);
|
||||
// re-enable parent focus to detect click on window
|
||||
parent.setFocusable(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
static native long nGetInputFocus(long display);
|
||||
|
|
|
|||
Loading…
Reference in a new issue