// should probably check offsetParent
// but this is more portable
- while (el !== self.document.documentElement) {
+ while (el && el !== self.document.documentElement) {
x -= el.offsetLeft;
y -= el.offsetTop;
- el = el.parentNode;
+ el = 'offsetParent' in el
+ ? el.offsetParent
+ : el.parentNode;
}
// convert to cols/rows
w = self.element.clientWidth;
h = self.element.clientHeight;
- x = ((x / w) * self.cols) | 0;
- y = ((y / h) * self.rows) | 0;
+ x = Math.round((x / w) * self.cols);
+ y = Math.round((y / h) * self.rows);
// be sure to avoid sending
// bad positions to the program
if (x < 0) x = 0;
- if (x > self.cols) x = self.cols;
+ if (x >= self.cols) x = self.cols - 1;
if (y < 0) y = 0;
- if (y > self.rows) y = self.rows;
+ if (y >= self.rows) y = self.rows - 1;
// xterm sends raw bytes and
// starts at 32 (SP) for each.
return {
x: x,
y: y,
- down: ev.type === 'mousedown',
- up: ev.type === 'mouseup',
- wheel: ev.type === wheelEvent,
- move: ev.type === 'mousemove'
+ type: ev.type === wheelEvent
+ ? 'mousewheel'
+ : ev.type
};
}
self.focus();
// fix for odd bug
+ //if (self.vt200Mouse && !self.normalMouse) {
if (self.vt200Mouse) {
sendButton({ __proto__: ev, type: 'mouseup' });
return cancel(ev);
return cancel(ev);
});
+ //if (self.normalMouse) {
+ // on(self.document, 'mousemove', sendMove);
+ //}
+
on(el, wheelEvent, function(ev) {
if (!self.mouseEvents) return;
if (self.x10Mouse