Merge commit '77d3a60869e7a780c6ae069e51530e1eacece5e2'
[fanfix.git] / src / jexer / backend / TWindowBackend.java
index a34ba78bc23f173b1d43b4066539b74825955fc3..f644b76ba4bf3d9e1642502ae330fc97146d1a5d 100644 (file)
  */
 package jexer.backend;
 
-import java.util.LinkedList;
+import java.util.ArrayList;
 import java.util.List;
 
-import jexer.bits.CellAttributes;
+import jexer.TApplication;
+import jexer.TWindow;
+import jexer.event.TCommandEvent;
 import jexer.event.TInputEvent;
 import jexer.event.TKeypressEvent;
 import jexer.event.TMouseEvent;
 import jexer.event.TResizeEvent;
-import jexer.TApplication;
-import jexer.TWindow;
+import static jexer.TCommand.*;
 
 /**
  * TWindowBackend uses a window in one TApplication to provide a backend for
@@ -111,6 +112,26 @@ public class TWindowBackend extends TWindow implements Backend {
             window.setHeight(getHeight() + 2);
         }
 
+        /**
+         * Get the width of a character cell in pixels.
+         *
+         * @return the width in pixels of a character cell
+         */
+        @Override
+        public int getTextWidth() {
+            return window.getScreen().getTextWidth();
+        }
+
+        /**
+         * Get the height of a character cell in pixels.
+         *
+         * @return the height in pixels of a character cell
+         */
+        @Override
+        public int getTextHeight() {
+            return window.getScreen().getTextHeight();
+        }
+
     }
 
 
@@ -135,7 +156,7 @@ public class TWindowBackend extends TWindow implements Backend {
         super(application, title, width, height);
 
         this.listener = listener;
-        eventQueue = new LinkedList<TInputEvent>();
+        eventQueue = new ArrayList<TInputEvent>();
         sessionInfo = new TSessionInfo(width, height);
         otherScreen = new OtherScreen(this);
         otherScreen.setDimensions(width - 2, height - 2);
@@ -161,7 +182,7 @@ public class TWindowBackend extends TWindow implements Backend {
         super(application, title, width, height, flags);
 
         this.listener = listener;
-        eventQueue = new LinkedList<TInputEvent>();
+        eventQueue = new ArrayList<TInputEvent>();
         sessionInfo = new TSessionInfo(width, height);
         otherScreen = new OtherScreen(this);
         otherScreen.setDimensions(width - 2, height - 2);
@@ -188,7 +209,7 @@ public class TWindowBackend extends TWindow implements Backend {
         super(application, title, x, y, width, height);
 
         this.listener = listener;
-        eventQueue = new LinkedList<TInputEvent>();
+        eventQueue = new ArrayList<TInputEvent>();
         sessionInfo = new TSessionInfo(width, height);
         otherScreen = new OtherScreen(this);
         otherScreen.setDimensions(width - 2, height - 2);
@@ -217,7 +238,7 @@ public class TWindowBackend extends TWindow implements Backend {
         super(application, title, x, y, width, height, flags);
 
         this.listener = listener;
-        eventQueue = new LinkedList<TInputEvent>();
+        eventQueue = new ArrayList<TInputEvent>();
         sessionInfo = new TSessionInfo(width, height);
         otherScreen = new OtherScreen(this);
         otherScreen.setDimensions(width - 2, height - 2);
@@ -409,7 +430,9 @@ public class TWindowBackend extends TWindow implements Backend {
      */
     @Override
     public void onClose() {
-        // TODO: send a screen disconnect
+        synchronized (eventQueue) {
+            eventQueue.add(new TCommandEvent(cmBackendDisconnect));
+        }
     }
 
     // ------------------------------------------------------------------------