From 84a2e5a250148d600d48a0dd58e07286a375f616 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 5 Dec 2019 07:25:32 +0100 Subject: LinuxKeyEventTracker: Factor out 'sendKeyEvent(..)' call with null check. --- .../newt/driver/linux/LinuxKeyEventTracker.java | 24 +++++++++++----------- 1 file 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); -- cgit v1.2.3