X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2Fio%2FAWTTerminal.java;h=27ba80aa12b7180accfd394e9c340627fe32a9f6;hb=92554d64c21c6a477fd23a06ca3a64a542b622a3;hp=6cc252f22f0a65590990ce50595a2b9d6e647f30;hpb=a83fea2bae838f4b9bbf59ce3832e0e67be41378;p=nikiroo-utils.git diff --git a/src/jexer/io/AWTTerminal.java b/src/jexer/io/AWTTerminal.java index 6cc252f..27ba80a 100644 --- a/src/jexer/io/AWTTerminal.java +++ b/src/jexer/io/AWTTerminal.java @@ -81,6 +81,11 @@ public final class AWTTerminal implements ComponentListener, KeyListener, return sessionInfo; } + /** + * The listening object that run() wakes up on new input. + */ + private Object listener; + /** * The event queue, filled up by a thread reading on input. */ @@ -120,9 +125,12 @@ public final class AWTTerminal implements ComponentListener, KeyListener, /** * Constructor sets up state for getEvent(). * + * @param listener the object this backend needs to wake up when new + * input comes in * @param screen the top-level AWT frame */ - public AWTTerminal(final AWTScreen screen) { + public AWTTerminal(final Object listener, final AWTScreen screen) { + this.listener = listener; this.screen = screen; mouse1 = false; mouse2 = false; @@ -162,26 +170,6 @@ public final class AWTTerminal implements ComponentListener, KeyListener, } } - /** - * Return any events in the IO queue due to timeout. - * - * @param queue list to append new events to - */ - public void getIdleEvents(final List queue) { - - // Insert any polling action here... - - // Return any events that showed up - synchronized (eventQueue) { - if (eventQueue.size() > 0) { - synchronized (queue) { - queue.addAll(eventQueue); - } - eventQueue.clear(); - } - } - } - /** * Pass AWT keystrokes into the event queue. * @@ -396,9 +384,8 @@ public final class AWTTerminal implements ComponentListener, KeyListener, synchronized (eventQueue) { eventQueue.add(new TKeypressEvent(keypress)); } - // Wake up the backend - synchronized (this) { - this.notifyAll(); + synchronized (listener) { + listener.notifyAll(); } } @@ -433,9 +420,8 @@ public final class AWTTerminal implements ComponentListener, KeyListener, synchronized (eventQueue) { eventQueue.add(new TCommandEvent(cmAbort)); } - // Wake up the backend - synchronized (this) { - this.notifyAll(); + synchronized (listener) { + listener.notifyAll(); } } @@ -523,9 +509,8 @@ public final class AWTTerminal implements ComponentListener, KeyListener, sessionInfo.getWindowWidth(), sessionInfo.getWindowHeight()); eventQueue.add(windowResize); } - // Wake up the backend - synchronized (this) { - this.notifyAll(); + synchronized (listener) { + listener.notifyAll(); } } @@ -561,9 +546,8 @@ public final class AWTTerminal implements ComponentListener, KeyListener, synchronized (eventQueue) { eventQueue.add(mouseEvent); } - // Wake up the backend - synchronized (this) { - this.notifyAll(); + synchronized (listener) { + listener.notifyAll(); } } @@ -582,9 +566,8 @@ public final class AWTTerminal implements ComponentListener, KeyListener, synchronized (eventQueue) { eventQueue.add(mouseEvent); } - // Wake up the backend - synchronized (this) { - this.notifyAll(); + synchronized (listener) { + listener.notifyAll(); } } @@ -650,9 +633,8 @@ public final class AWTTerminal implements ComponentListener, KeyListener, synchronized (eventQueue) { eventQueue.add(mouseEvent); } - // Wake up the backend - synchronized (this) { - this.notifyAll(); + synchronized (listener) { + listener.notifyAll(); } } @@ -697,9 +679,8 @@ public final class AWTTerminal implements ComponentListener, KeyListener, synchronized (eventQueue) { eventQueue.add(mouseEvent); } - // Wake up the backend - synchronized (this) { - this.notifyAll(); + synchronized (listener) { + listener.notifyAll(); } } @@ -743,9 +724,8 @@ public final class AWTTerminal implements ComponentListener, KeyListener, synchronized (eventQueue) { eventQueue.add(mouseEvent); } - // Wake up the backend - synchronized (this) { - this.notifyAll(); + synchronized (listener) { + listener.notifyAll(); } }