fix eclipse warnings
[nikiroo-utils.git] / src / jexer / io / AWTTerminal.java
index 783cffd4ec5f1fba6e6cd2397dd70a37d380a2a5..da521ddb0fc3c7fa435bef3ae8aee22d9b3217c3 100644 (file)
@@ -92,9 +92,14 @@ public final class AWTTerminal implements ComponentListener, KeyListener,
     private List<TInputEvent> eventQueue;
 
     /**
-     * The reader thread.
+     * The last reported mouse X position.
      */
-    private Thread readerThread;
+    private int oldMouseX = -1;
+
+    /**
+     * The last reported mouse Y position.
+     */
+    private int oldMouseY = -1;
 
     /**
      * true if mouse1 was down.  Used to report mouse1 on the release event.
@@ -202,7 +207,6 @@ public final class AWTTerminal implements ComponentListener, KeyListener,
         boolean ctrl = false;
         char ch = ' ';
         boolean isKey = false;
-        int fnKey = 0;
         if (key.isActionKey()) {
             isKey = true;
         } else {
@@ -376,7 +380,7 @@ public final class AWTTerminal implements ComponentListener, KeyListener,
                 break;
             default:
                 if (!alt && ctrl && !shift) {
-                    ch = key.getKeyText(key.getKeyCode()).charAt(0);
+                    ch = KeyEvent.getKeyText(key.getKeyCode()).charAt(0);
                 }
                 // Not a special key, put it together
                 keypress = new TKeypress(false, 0, ch, alt, ctrl, shift);
@@ -566,6 +570,13 @@ public final class AWTTerminal implements ComponentListener, KeyListener,
     public void mouseMoved(final MouseEvent mouse) {
         int x = screen.textColumn(mouse.getX());
         int y = screen.textRow(mouse.getY());
+        if ((x == oldMouseX) && (y == oldMouseY)) {
+            // Bail out, we've moved some pixels but not a whole text cell.
+            return;
+        }
+        oldMouseX = x;
+        oldMouseY = y;
+
         TMouseEvent mouseEvent = new TMouseEvent(TMouseEvent.Type.MOUSE_MOTION,
             x, y, x, y, mouse1, mouse2, mouse3, false, false);