hterm: Hide terminal cursor when mouse cursor is over it
This make sure the mouse doesn't get in the way of text selection or
terminal clicks.
BUG=chromium:365910
Change-Id: I65d6b9b5d30ac4e32e69b5cbdc1a39502a34fa93
Reviewed-on: https://chromium-review.googlesource.com/208691
Reviewed-by: Robert Ginda <rginda@chromium.org>
Tested-by: Robert Ginda <rginda@chromium.org>
diff --git a/hterm/js/hterm_terminal.js b/hterm/js/hterm_terminal.js
index 35f96ea..de055e6 100644
--- a/hterm/js/hterm_terminal.js
+++ b/hterm/js/hterm_terminal.js
@@ -2666,15 +2666,25 @@
e.processedByTerminalHandler_ = true;
+ // One based row/column stored on the mouse event.
+ e.terminalRow = parseInt((e.clientY - this.scrollPort_.visibleRowTopMargin) /
+ this.scrollPort_.characterSize.height) + 1;
+ e.terminalColumn = parseInt(e.clientX /
+ this.scrollPort_.characterSize.width) + 1;
+
if (e.type == 'mousedown' && e.terminalColumn > this.screenSize.width) {
// Mousedown in the scrollbar area.
return;
}
- e.terminalRow = parseInt((e.clientY - this.scrollPort_.visibleRowTopMargin) /
- this.scrollPort_.characterSize.height) + 1;
- e.terminalColumn = parseInt(e.clientX /
- this.scrollPort_.characterSize.width) + 1;
+ if (this.options_.cursorVisible) {
+ if (e.terminalRow - 1 == this.screen_.cursorPosition.row &&
+ e.terminalColumn - 1 == this.screen_.cursorPosition.column) {
+ this.cursorNode_.style.display = 'none';
+ } else if (this.cursorNode_.style.display == 'none') {
+ this.cursorNode_.style.display = '';
+ }
+ }
if (e.type == 'mousedown') {
if (e.altKey || this.vt.mouseReport == this.vt.MOUSE_REPORT_DISABLED) {