From ea54454247fe483a5c586220dd511fa8d73b2bce Mon Sep 17 00:00:00 2001 From: Kevin Lamonte Date: Sat, 10 Aug 2019 06:24:32 -0500 Subject: [PATCH] #37 reduce calls to resizeToScreen --- src/jexer/TApplication.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/jexer/TApplication.java b/src/jexer/TApplication.java index bffe38e4..fdbc0e39 100644 --- a/src/jexer/TApplication.java +++ b/src/jexer/TApplication.java @@ -294,6 +294,11 @@ public class TApplication implements Runnable { */ private List invokeLaters = new LinkedList(); + /** + * The last time the screen was resized. + */ + private long screenResizeTime = 0; + /** * WidgetEventHandler is the main event consumer loop. There are at most * two such threads in existence: the primary for normal case and a @@ -1025,8 +1030,14 @@ public class TApplication implements Runnable { if (event instanceof TResizeEvent) { TResizeEvent resize = (TResizeEvent) event; synchronized (getScreen()) { - getScreen().setDimensions(resize.getWidth(), - resize.getHeight()); + 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; mouseX = 0; mouseY = 0; -- 2.27.0