From: Kevin Lamonte Date: Sat, 10 Aug 2019 11:24:32 +0000 (-0500) Subject: #37 reduce calls to resizeToScreen X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=ea54454247fe483a5c586220dd511fa8d73b2bce;p=fanfix-jexer.git #37 reduce calls to resizeToScreen --- diff --git a/src/jexer/TApplication.java b/src/jexer/TApplication.java index bffe38e..fdbc0e3 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;