X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2Fbackend%2FAWTBackend.java;h=af2d181a6343da5eef95ce3a66995e070adcc1a0;hb=92554d64c21c6a477fd23a06ca3a64a542b622a3;hp=fce11eaef1e4f9a11bfe2d2ba65c7b968b613c19;hpb=a83fea2bae838f4b9bbf59ce3832e0e67be41378;p=fanfix.git diff --git a/src/jexer/backend/AWTBackend.java b/src/jexer/backend/AWTBackend.java index fce11ea..af2d181 100644 --- a/src/jexer/backend/AWTBackend.java +++ b/src/jexer/backend/AWTBackend.java @@ -49,13 +49,18 @@ public final class AWTBackend extends Backend { /** * Public constructor. + * + * @param listener the object this backend needs to wake up when new + * input comes in */ - public AWTBackend() { + public AWTBackend(final Object listener) { // Create a screen AWTScreen screen = new AWTScreen(); this.screen = screen; - // Create the listeners - terminal = new AWTTerminal(screen); + + // Create the AWT event listeners + terminal = new AWTTerminal(listener, screen); + // Hang onto the session info this.sessionInfo = terminal.getSessionInfo(); } @@ -72,36 +77,10 @@ public final class AWTBackend extends Backend { * Get keyboard, mouse, and screen resize events. * * @param queue list to append new events to - * @param timeout maximum amount of time (in millis) to wait for an - * event. 0 means to return immediately, i.e. perform a poll. */ @Override - public void getEvents(final List queue, final int timeout) { - if (timeout > 0) { - // Try to sleep, let the terminal's input thread wake me up if - // something came in. - synchronized (terminal) { - try { - terminal.wait(timeout); - if (terminal.hasEvents()) { - // System.err.println("getEvents()"); - terminal.getEvents(queue); - } else { - // If I got here, then I timed out. Call - // terminal.getIdleEvents() to pick up stragglers - // like bare resize. - // System.err.println("getIdleEvents()"); - terminal.getIdleEvents(queue); - } - } catch (InterruptedException e) { - // Spurious interrupt, pretend it was like a timeout. - // System.err.println("[interrupt] getEvents()"); - terminal.getIdleEvents(queue); - } - } - } else { - // Asking for a poll, go get it. - // System.err.println("[polled] getEvents()"); + public void getEvents(final List queue) { + if (terminal.hasEvents()) { terminal.getEvents(queue); } }