public void mouseMoved(int x, int y, MouseEvent event) { if (myLastMotionReport != null && myLastMotionReport.equals(new Point(x, y))) { return; } if (shouldSendMouseData(MouseMode.MOUSE_REPORTING_ALL_MOTION)) { myTerminalOutput.sendBytes(mouseReport(MouseButtonCodes.RELEASE, x + 1, y + 1)); } myLastMotionReport = new Point(x, y); }
@Override public void mouseDragged(int x, int y, MouseEvent event) { if (myLastMotionReport != null && myLastMotionReport.equals(new Point(x, y))) { return; } if (shouldSendMouseData(MouseMode.MOUSE_REPORTING_BUTTON_MOTION)) { // when dragging, button is not in "button", but in "modifier" int cb = createButtonCode(event); if (cb != MouseButtonCodes.NONE) { cb |= MouseButtonModifierFlags.MOUSE_BUTTON_MOTION_FLAG; cb = applyModifierKeys(event, cb); myTerminalOutput.sendBytes(mouseReport(cb, x + 1, y + 1)); } } myLastMotionReport = new Point(x, y); }
@Override public void mousePressed(int x, int y, MouseEvent event) { if (shouldSendMouseData( MouseMode.MOUSE_REPORTING_NORMAL, MouseMode.MOUSE_REPORTING_BUTTON_MOTION)) { int cb = createButtonCode(event); if (cb != MouseButtonCodes.NONE) { if (cb == MouseButtonCodes.SCROLLDOWN || cb == MouseButtonCodes.SCROLLUP) { // convert x11 scroll button number to terminal button code int offset = MouseButtonCodes.SCROLLDOWN; cb -= offset; cb |= MouseButtonModifierFlags.MOUSE_BUTTON_SCROLL_FLAG; } cb = applyModifierKeys(event, cb); myTerminalOutput.sendBytes(mouseReport(cb, x + 1, y + 1)); } } }
@Override public void mouseReleased(int x, int y, MouseEvent event) { if (shouldSendMouseData( MouseMode.MOUSE_REPORTING_NORMAL, MouseMode.MOUSE_REPORTING_BUTTON_MOTION)) { int cb = createButtonCode(event); if (cb != MouseButtonCodes.NONE) { if (myMouseFormat == MouseFormat.MOUSE_FORMAT_SGR) { // for SGR 1006 mode cb |= MouseButtonModifierFlags.MOUSE_BUTTON_SGR_RELEASE_FLAG; } else { // for 1000/1005/1015 mode cb = MouseButtonCodes.RELEASE; } cb = applyModifierKeys(event, cb); myTerminalOutput.sendBytes(mouseReport(cb, x + 1, y + 1)); } } myLastMotionReport = null; }