X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2Fbackend%2FMultiScreen.java;h=0c3a2894bbe29c9bc0af7067cd9b79f8d9b060bc;hb=bfa37f3b2ef87d39c15fad7d565c00cbabd92acf;hp=02084100e900523033433ce205b5693fe749f2ad;hpb=a69ed767c9c07cf35cf1c5f7821fc009cfe79cd2;p=fanfix.git diff --git a/src/jexer/backend/MultiScreen.java b/src/jexer/backend/MultiScreen.java index 0208410..0c3a289 100644 --- a/src/jexer/backend/MultiScreen.java +++ b/src/jexer/backend/MultiScreen.java @@ -28,7 +28,7 @@ */ package jexer.backend; -import java.util.LinkedList; +import java.util.ArrayList; import java.util.List; import jexer.bits.Cell; @@ -46,7 +46,7 @@ public class MultiScreen implements Screen { /** * The list of screens to use. */ - private List screens = new LinkedList(); + private List screens = new ArrayList(); // ------------------------------------------------------------------------ // Constructors ----------------------------------------------------------- @@ -386,7 +386,20 @@ public class MultiScreen implements Screen { */ public void setDimensions(final int width, final int height) { for (Screen screen: screens) { - screen.setDimensions(width, height); + // Do not blindly call setDimension() on every screen. Instead + // call it only on those screens that do not already have the + // requested dimension. With this very small check, we have the + // ability for ANY screen in the MultiBackend to resize ALL of + // the screens. + if ((screen.getWidth() != width) + || (screen.getHeight() != height) + ) { + screen.setDimensions(width, height); + } else { + // The screen that didn't change is probably the one that + // prompted the resize. Force it to repaint. + screen.clearPhysical(); + } } } @@ -633,14 +646,7 @@ public class MultiScreen implements Screen { public int getTextWidth() { int textWidth = 16; for (Screen screen: screens) { - int newTextWidth = textWidth; - if (screen instanceof MultiScreen) { - newTextWidth = ((MultiScreen) screen).getTextWidth(); - } else if (screen instanceof ECMA48Terminal) { - newTextWidth = ((ECMA48Terminal) screen).getTextWidth(); - } else if (screen instanceof SwingTerminal) { - newTextWidth = ((SwingTerminal) screen).getTextWidth(); - } + int newTextWidth = screen.getTextWidth(); if (newTextWidth < textWidth) { textWidth = newTextWidth; } @@ -656,14 +662,7 @@ public class MultiScreen implements Screen { public int getTextHeight() { int textHeight = 20; for (Screen screen: screens) { - int newTextHeight = textHeight; - if (screen instanceof MultiScreen) { - newTextHeight = ((MultiScreen) screen).getTextHeight(); - } else if (screen instanceof ECMA48Terminal) { - newTextHeight = ((ECMA48Terminal) screen).getTextHeight(); - } else if (screen instanceof SwingTerminal) { - newTextHeight = ((SwingTerminal) screen).getTextHeight(); - } + int newTextHeight = screen.getTextHeight(); if (newTextHeight < textHeight) { textHeight = newTextHeight; }