@Override public void onSessionViewLeftTouch(int x, int y, boolean down) { if (!down) cancelDelayedMoveEvent(); LibFreeRDP.sendCursorEvent( session.getInstance(), x, y, toggleMouseButtons ? Mouse.getRightButtonEvent(down) : Mouse.getLeftButtonEvent(down)); if (!down) toggleMouseButtons = false; }
@Override public void onTouchPointerMove(int x, int y) { Point p = mapScreenCoordToSessionCoord(x, y); LibFreeRDP.sendCursorEvent(session.getInstance(), p.x, p.y, Mouse.getMoveEvent()); if (autoScrollTouchPointer && !uiHandler.hasMessages(UIHandler.SCROLLING_REQUESTED)) { Log.v(TAG, "Starting auto-scroll"); uiHandler.sendEmptyMessageDelayed(UIHandler.SCROLLING_REQUESTED, SCROLLING_TIMEOUT); } }
private void sendDelayedMoveEvent(int x, int y) { if (uiHandler.hasMessages(UIHandler.SEND_MOVE_EVENT)) { uiHandler.removeMessages(UIHandler.SEND_MOVE_EVENT); discardedMoveEvents++; } else discardedMoveEvents = 0; if (discardedMoveEvents > MAX_DISCARDED_MOVE_EVENTS) LibFreeRDP.sendCursorEvent(session.getInstance(), x, y, Mouse.getMoveEvent()); else uiHandler.sendMessageDelayed( Message.obtain(null, UIHandler.SEND_MOVE_EVENT, x, y), SEND_MOVE_EVENT_TIMEOUT); }
@Override public void handleMessage(Message msg) { switch (msg.what) { case GRAPHICS_CHANGED: { sessionView.onSurfaceChange(session); scrollView.requestLayout(); break; } case REFRESH_SESSIONVIEW: { sessionView.invalidateRegion(); break; } case DISPLAY_TOAST: { Toast errorToast = Toast.makeText(getApplicationContext(), msg.obj.toString(), Toast.LENGTH_LONG); errorToast.show(); break; } case HIDE_ZOOMCONTROLS: { zoomControls.hide(); break; } case SEND_MOVE_EVENT: { LibFreeRDP.sendCursorEvent( session.getInstance(), msg.arg1, msg.arg2, Mouse.getMoveEvent()); break; } case SHOW_DIALOG: { // create and show the dialog ((Dialog) msg.obj).show(); break; } case SCROLLING_REQUESTED: { int scrollX = 0; int scrollY = 0; float[] pointerPos = touchPointerView.getPointerPosition(); if (pointerPos[0] > (screen_width - touchPointerView.getPointerWidth())) scrollX = SCROLLING_DISTANCE; else if (pointerPos[0] < 0) scrollX = -SCROLLING_DISTANCE; if (pointerPos[1] > (screen_height - touchPointerView.getPointerHeight())) scrollY = SCROLLING_DISTANCE; else if (pointerPos[1] < 0) scrollY = -SCROLLING_DISTANCE; scrollView.scrollBy(scrollX, scrollY); // see if we reached the min/max scroll positions if (scrollView.getScrollX() == 0 || scrollView.getScrollX() == (sessionView.getWidth() - scrollView.getWidth())) scrollX = 0; if (scrollView.getScrollY() == 0 || scrollView.getScrollY() == (sessionView.getHeight() - scrollView.getHeight())) scrollY = 0; if (scrollX != 0 || scrollY != 0) uiHandler.sendEmptyMessageDelayed(SCROLLING_REQUESTED, SCROLLING_TIMEOUT); else Log.v(TAG, "Stopping auto-scroll"); break; } } }
@Override public void onTouchPointerScroll(boolean down) { LibFreeRDP.sendCursorEvent(session.getInstance(), 0, 0, Mouse.getScrollEvent(down)); }
@Override public void onTouchPointerRightClick(int x, int y, boolean down) { Point p = mapScreenCoordToSessionCoord(x, y); LibFreeRDP.sendCursorEvent(session.getInstance(), p.x, p.y, Mouse.getRightButtonEvent(down)); }