diff options
author | Sven Gothel <[email protected]> | 2019-12-05 07:25:32 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2019-12-05 07:25:32 +0100 |
commit | 84a2e5a250148d600d48a0dd58e07286a375f616 (patch) | |
tree | a226b0b538e342a4e6bc6d1031a69f02ec227c38 /src/newt/classes/jogamp | |
parent | ea23776919eff10dee57519ce72354bbaea3544e (diff) |
LinuxKeyEventTracker: Factor out 'sendKeyEvent(..)' call with null check.
Diffstat (limited to 'src/newt/classes/jogamp')
-rw-r--r-- | src/newt/classes/jogamp/newt/driver/linux/LinuxKeyEventTracker.java | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/newt/classes/jogamp/newt/driver/linux/LinuxKeyEventTracker.java b/src/newt/classes/jogamp/newt/driver/linux/LinuxKeyEventTracker.java index 8265ec7f8..60d1e5a4b 100644 --- a/src/newt/classes/jogamp/newt/driver/linux/LinuxKeyEventTracker.java +++ b/src/newt/classes/jogamp/newt/driver/linux/LinuxKeyEventTracker.java @@ -169,6 +169,13 @@ public class LinuxKeyEventTracker implements WindowListener, KeyTracker { @Override public void windowRepaint(final WindowUpdateEvent e) { } + private final void sendKeyEvent(final short eventType, final int modifiers, final short keyCode, final short keySym, final char keyChar) { + if(null != focusedWindow) { + focusedWindow.sendKeyEvent(eventType, modifiers, keyCode, keyCode, keyChar); + // focusedWindow.enqueueKeyEvent(false /* wait */, eventType, modifiers, keyCode, keyCode, keyChar); + } + } + class EventDeviceManager implements Runnable { private volatile boolean stop = false; @@ -394,9 +401,7 @@ public class LinuxKeyEventTracker implements WindowListener, KeyTracker { break; } - if(null != focusedWindow) { - focusedWindow.sendKeyEvent(eventType, modifiers, keyCode, keyCode, keyChar); - } + sendKeyEvent(eventType, modifiers, keyCode, keyCode, keyChar); if(Window.DEBUG_KEY_EVENT) { System.err.println("[event released] keyCode: "+keyCode+" keyChar: "+keyChar+ " modifiers: "+modifiers); } @@ -419,9 +424,7 @@ public class LinuxKeyEventTracker implements WindowListener, KeyTracker { break; } - if(null != focusedWindow) { - focusedWindow.sendKeyEvent(eventType, modifiers, keyCode, keyCode, keyChar); - } + sendKeyEvent(eventType, modifiers, keyCode, keyCode, keyChar); if(Window.DEBUG_KEY_EVENT) { System.err.println("[event pressed] keyCode: "+keyCode+" keyChar: "+keyChar+ " modifiers: "+modifiers); } @@ -445,12 +448,9 @@ public class LinuxKeyEventTracker implements WindowListener, KeyTracker { break; } - if(null != focusedWindow) { - //Send syntetic autorepeat release - focusedWindow.sendKeyEvent(KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, keyCode, keyChar); - - focusedWindow.sendKeyEvent(eventType, modifiers, keyCode, keyCode, keyChar); - } + //Send syntetic autorepeat release + sendKeyEvent(KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, keyCode, keyChar); + sendKeyEvent(eventType, modifiers, keyCode, keyCode, keyChar); if(Window.DEBUG_KEY_EVENT) { System.err.println("[event released auto] keyCode: "+keyCode+" keyChar: "+keyChar+ " modifiers: "+modifiers); System.err.println("[event pressed auto] keyCode: "+keyCode+" keyChar: "+keyChar+ " modifiers: "+modifiers); |