diff --git a/src/jexer/TApplication.java b/src/jexer/TApplication.java index 8f7db40..c04ff3d 100644 --- a/src/jexer/TApplication.java +++ b/src/jexer/TApplication.java @@ -1019,17 +1019,18 @@ public class TApplication implements Runnable { synchronized (fillEventQueue) { // Pull any pending I/O events backend.getEvents(fillEventQueue); + } - // Dispatch each event to the appropriate handler, one at a - // time. - for (;;) { - TInputEvent event = null; + // Dispatch each event to the appropriate handler, one at a time. + for (;;) { + TInputEvent event = null; + synchronized (fillEventQueue) { if (fillEventQueue.size() == 0) { break; } event = fillEventQueue.remove(0); - metaHandleEvent(event); } + metaHandleEvent(event); } // Wake a consumer thread if we have any pending events. @@ -1411,51 +1412,51 @@ public class TApplication implements Runnable { } } - synchronized (drainEventQueue) { - // Screen resize - if (event instanceof TResizeEvent) { - TResizeEvent resize = (TResizeEvent) event; - assert (resize.getType() == TResizeEvent.Type.SCREEN); + // Screen resize + if (event instanceof TResizeEvent) { + TResizeEvent resize = (TResizeEvent) event; + assert (resize.getType() == TResizeEvent.Type.SCREEN); - synchronized (getScreen()) { - if ((System.currentTimeMillis() - screenResizeTime >= 15) - || (resize.getWidth() < getScreen().getWidth()) - || (resize.getHeight() < getScreen().getHeight()) - ) { - getScreen().setDimensions(resize.getWidth(), - resize.getHeight()); - screenResizeTime = System.currentTimeMillis(); - } - desktopBottom = getScreen().getHeight() - 1; - if (hideStatusBar) { - desktopBottom++; - } - mouseX = 0; - mouseY = 0; + synchronized (getScreen()) { + if ((System.currentTimeMillis() - screenResizeTime >= 15) + || (resize.getWidth() < getScreen().getWidth()) + || (resize.getHeight() < getScreen().getHeight()) + ) { + getScreen().setDimensions(resize.getWidth(), + resize.getHeight()); + screenResizeTime = System.currentTimeMillis(); + } + desktopBottom = getScreen().getHeight() - 1; + if (hideStatusBar) { + desktopBottom++; + } + mouseX = 0; + mouseY = 0; - if (desktop != null) { - desktop.setDimensions(0, desktopTop, resize.getWidth(), - (desktopBottom - desktopTop)); - desktop.onResize(resize); - } - for (TWindow window: windows) { - window.onResize(resize); - } - - // Change menu edges if needed. - recomputeMenuX(); + if (desktop != null) { + desktop.setDimensions(0, desktopTop, resize.getWidth(), + (desktopBottom - desktopTop)); + desktop.onResize(resize); + } + for (TWindow window: windows) { + window.onResize(resize); } - // We are dirty, redraw the screen. - doRepaint(); - - /* - System.err.println("New screen: " + resize.getWidth() + - " x " + resize.getHeight()); - */ - return; + // Change menu edges if needed. + recomputeMenuX(); } + // We are dirty, redraw the screen. + doRepaint(); + + /* + System.err.println("New screen: " + resize.getWidth() + + " x " + resize.getHeight()); + */ + return; + } + + synchronized (drainEventQueue) { // Put into the main queue drainEventQueue.add(event); } @@ -2046,6 +2047,7 @@ public class TApplication implements Runnable { */ public void doRepaint() { repaint = true; + boolean wakeAndReturn = false; synchronized (drainEventQueue) { if (fillEventQueue.size() > 0) { // User input is waiting, that will update the screen. Wake @@ -2053,12 +2055,15 @@ public class TApplication implements Runnable { if (debugEvents) { System.err.printf("Drop: input waiting in backend\n"); } - synchronized (this) { - this.notify(); - } - return; + wakeAndReturn = true; } } + if (wakeAndReturn) { + synchronized (this) { + this.notify(); + } + return; + } if (screenHandler != null) { long now = System.currentTimeMillis(); if (now - screenHandler.lastFlushTime < screenHandler.lastFrameTime) { diff --git a/src/jexer/TScreenOptionsWindow.java b/src/jexer/TScreenOptionsWindow.java index 7d2c618..34a4052 100644 --- a/src/jexer/TScreenOptionsWindow.java +++ b/src/jexer/TScreenOptionsWindow.java @@ -854,10 +854,8 @@ public class TScreenOptionsWindow extends TWindow { ecmaTerminal.setRgbColor(rgbColor.isChecked()); } if (terminal != null) { - synchronized (terminal) { - terminal.setTripleBuffer(tripleBuffer.isChecked()); - terminal.setFont(terminal.getFont()); - } + terminal.setTripleBuffer(tripleBuffer.isChecked()); + terminal.setFont(terminal.getFont()); } // Close window. @@ -871,17 +869,15 @@ public class TScreenOptionsWindow extends TWindow { public void DO() { // Restore old values, then close the window. if (terminal != null) { - synchronized (terminal) { - terminal.setFont(oldFont); - terminal.setFontSize(oldFontSize); - terminal.setTextAdjustX(oldTextAdjustX); - terminal.setTextAdjustY(oldTextAdjustY); - terminal.setTextAdjustHeight(oldTextAdjustHeight); - terminal.setTextAdjustWidth(oldTextAdjustWidth); - terminal.setTripleBuffer(oldTripleBuffer); - terminal.setCursorStyle(oldCursorStyle); - terminal.setMouseStyle(oldMouseStyle); - } + terminal.setFont(oldFont); + terminal.setFontSize(oldFontSize); + terminal.setTextAdjustX(oldTextAdjustX); + terminal.setTextAdjustY(oldTextAdjustY); + terminal.setTextAdjustHeight(oldTextAdjustHeight); + terminal.setTextAdjustWidth(oldTextAdjustWidth); + terminal.setTripleBuffer(oldTripleBuffer); + terminal.setCursorStyle(oldCursorStyle); + terminal.setMouseStyle(oldMouseStyle); } if (ecmaTerminal != null) { ecmaTerminal.setHasSixel(oldSixel); @@ -914,17 +910,15 @@ public class TScreenOptionsWindow extends TWindow { if (keypress.equals(kbEsc)) { // Restore old values, then close the window. if (terminal != null) { - synchronized (terminal) { - terminal.setFont(oldFont); - terminal.setFontSize(oldFontSize); - terminal.setTextAdjustX(oldTextAdjustX); - terminal.setTextAdjustY(oldTextAdjustY); - terminal.setTextAdjustHeight(oldTextAdjustHeight); - terminal.setTextAdjustWidth(oldTextAdjustWidth); - terminal.setTripleBuffer(oldTripleBuffer); - terminal.setCursorStyle(oldCursorStyle); - terminal.setMouseStyle(oldMouseStyle); - } + terminal.setFont(oldFont); + terminal.setFontSize(oldFontSize); + terminal.setTextAdjustX(oldTextAdjustX); + terminal.setTextAdjustY(oldTextAdjustY); + terminal.setTextAdjustHeight(oldTextAdjustHeight); + terminal.setTextAdjustWidth(oldTextAdjustWidth); + terminal.setTripleBuffer(oldTripleBuffer); + terminal.setCursorStyle(oldCursorStyle); + terminal.setMouseStyle(oldMouseStyle); } if (ecmaTerminal != null) { ecmaTerminal.setHasSixel(oldSixel); diff --git a/src/jexer/tterminal/ECMA48.java b/src/jexer/tterminal/ECMA48.java index a4550f4..50cf8d5 100644 --- a/src/jexer/tterminal/ECMA48.java +++ b/src/jexer/tterminal/ECMA48.java @@ -861,15 +861,12 @@ public class ECMA48 implements Runnable { } // Permit my enclosing UI to know that I updated. if (displayListener != null) { - // Don't step on UI events - synchronized (this) { - if (screenIsDirty) { - displayListener.displayChanged(false); - screenIsDirty = false; - } else { - displayListener.displayChanged(true); - screenIsDirty = false; - } + if (screenIsDirty) { + displayListener.displayChanged(false); + screenIsDirty = false; + } else { + displayListener.displayChanged(true); + screenIsDirty = false; } } } @@ -3652,6 +3649,7 @@ public class ECMA48 implements Runnable { * https://github.com/hackerb9/lsix/issues/41 */ sixelScrolling = false; + // System.err.println("DECSDM activated"); } else { // Reset DECSDM: Enable sixel scrolling (default). sixelScrolling = true;