From 49c1ca3f57699a824ac79cf5cbd3d4a338b2b8aa Mon Sep 17 00:00:00 2001 From: Paris Kasidiaris Date: Wed, 2 Aug 2017 10:44:16 +0300 Subject: [PATCH 1/2] Fix #827: Always focus terminal on click --- src/xterm.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/xterm.js b/src/xterm.js index a3f425d1..8d3228ab 100644 --- a/src/xterm.js +++ b/src/xterm.js @@ -746,13 +746,9 @@ Terminal.prototype.open = function(parent, focus) { this.focus(); } + // Focus terminal when it gets clicked on(this.element, 'click', function() { - var selection = document.getSelection(), - collapsed = selection.isCollapsed, - isRange = typeof collapsed == 'boolean' ? !collapsed : selection.type == 'Range'; - if (!isRange) { - self.focus(); - } + self.focus(); }); // Listen for mouse events and translate @@ -2201,7 +2197,7 @@ Terminal.prototype.ch = function(cur) { /** - * Evaluate if the current erminal is the given argument. + * Evaluate if the current terminal is the given argument. * @param {object} term The terminal to evaluate */ Terminal.prototype.is = function(term) { From 72e85a352af446171fd62a5c8e3b349375d60c66 Mon Sep 17 00:00:00 2001 From: Paris Kasidiaris Date: Wed, 2 Aug 2017 16:03:56 +0300 Subject: [PATCH 2/2] Focus on `mousedown`, instead of `click` --- src/xterm.js | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/xterm.js b/src/xterm.js index 8d3228ab..d4cb0015 100644 --- a/src/xterm.js +++ b/src/xterm.js @@ -746,11 +746,6 @@ Terminal.prototype.open = function(parent, focus) { this.focus(); } - // Focus terminal when it gets clicked - on(this.element, 'click', function() { - self.focus(); - }); - // Listen for mouse events and translate // them into terminal mouse protocols. this.bindMouse(); @@ -1021,14 +1016,14 @@ Terminal.prototype.bindMouse = function() { } on(el, 'mousedown', function(ev) { + // ensure focus + self.focus(); + if (!self.mouseEvents) return; // send the button sendButton(ev); - // ensure focus - self.focus(); - // fix for odd bug //if (self.vt200Mouse && !self.normalMouse) { if (self.vt200Mouse) {