git://git.nikiroo.be
/
fanfix.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
mouse support inside terminal
[fanfix.git]
/
src
/
jexer
/
io
/
AWTTerminal.java
diff --git
a/src/jexer/io/AWTTerminal.java
b/src/jexer/io/AWTTerminal.java
index 783cffd4ec5f1fba6e6cd2397dd70a37d380a2a5..38f6734b96fcea4c8aac2c97cb5e774c636a7caa 100644
(file)
--- a/
src/jexer/io/AWTTerminal.java
+++ b/
src/jexer/io/AWTTerminal.java
@@
-96,6
+96,16
@@
public final class AWTTerminal implements ComponentListener, KeyListener,
*/
private Thread readerThread;
*/
private Thread readerThread;
+ /**
+ * The last reported mouse X position.
+ */
+ 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.
*/
/**
* true if mouse1 was down. Used to report mouse1 on the release event.
*/
@@
-566,6
+576,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());
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);
TMouseEvent mouseEvent = new TMouseEvent(TMouseEvent.Type.MOUSE_MOTION,
x, y, x, y, mouse1, mouse2, mouse3, false, false);