| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chromoting; | 5 package org.chromium.chromoting; |
| 6 | 6 |
| 7 import android.graphics.Point; | 7 import android.graphics.PointF; |
| 8 import android.view.KeyEvent; | 8 import android.view.KeyEvent; |
| 9 import android.view.MotionEvent; | 9 import android.view.MotionEvent; |
| 10 | 10 |
| 11 import org.chromium.chromoting.jni.TouchEventData; | 11 import org.chromium.chromoting.jni.TouchEventData; |
| 12 | 12 |
| 13 import java.util.ArrayList; | 13 import java.util.ArrayList; |
| 14 import java.util.List; | 14 import java.util.List; |
| 15 import java.util.Set; | 15 import java.util.Set; |
| 16 import java.util.TreeSet; | 16 import java.util.TreeSet; |
| 17 | 17 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 /** Set of pressed keys for which we've sent TextEvent. */ | 29 /** Set of pressed keys for which we've sent TextEvent. */ |
| 30 private final Set<Integer> mPressedTextKeys; | 30 private final Set<Integer> mPressedTextKeys; |
| 31 | 31 |
| 32 public InputEventSender(InputStub injector) { | 32 public InputEventSender(InputStub injector) { |
| 33 Preconditions.notNull(injector); | 33 Preconditions.notNull(injector); |
| 34 mInjector = injector; | 34 mInjector = injector; |
| 35 mPressedTextKeys = new TreeSet<>(); | 35 mPressedTextKeys = new TreeSet<>(); |
| 36 } | 36 } |
| 37 | 37 |
| 38 public void sendMouseEvent(Point pos, int button, boolean down) { | 38 public void sendMouseEvent(PointF pos, int button, boolean down) { |
| 39 Preconditions.isTrue(button == InputStub.BUTTON_UNDEFINED | 39 Preconditions.isTrue(button == InputStub.BUTTON_UNDEFINED |
| 40 || button == InputStub.BUTTON_LEFT | 40 || button == InputStub.BUTTON_LEFT |
| 41 || button == InputStub.BUTTON_MIDDLE | 41 || button == InputStub.BUTTON_MIDDLE |
| 42 || button == InputStub.BUTTON_RIGHT); | 42 || button == InputStub.BUTTON_RIGHT); |
| 43 mInjector.sendMouseEvent(pos.x, pos.y, button, down); | 43 mInjector.sendMouseEvent((int) pos.x, (int) pos.y, button, down); |
| 44 } | 44 } |
| 45 | 45 |
| 46 public void sendMouseDown(Point pos, int button) { | 46 public void sendMouseDown(PointF pos, int button) { |
| 47 sendMouseEvent(pos, button, true); | 47 sendMouseEvent(pos, button, true); |
| 48 } | 48 } |
| 49 | 49 |
| 50 public void sendMouseUp(Point pos, int button) { | 50 public void sendMouseUp(PointF pos, int button) { |
| 51 sendMouseEvent(pos, button, false); | 51 sendMouseEvent(pos, button, false); |
| 52 } | 52 } |
| 53 | 53 |
| 54 public void sendMouseClick(Point pos, int button) { | 54 public void sendMouseClick(PointF pos, int button) { |
| 55 sendMouseDown(pos, button); | 55 sendMouseDown(pos, button); |
| 56 sendMouseUp(pos, button); | 56 sendMouseUp(pos, button); |
| 57 } | 57 } |
| 58 | 58 |
| 59 public void sendCursorMove(Point pos) { | 59 public void sendCursorMove(PointF pos) { |
| 60 sendMouseUp(pos, InputStub.BUTTON_UNDEFINED); | 60 sendMouseUp(pos, InputStub.BUTTON_UNDEFINED); |
| 61 } | 61 } |
| 62 | 62 |
| 63 // TODO(zijiehe): This function will be eventually removed after {@link Inpu
tStrategyInterface} | 63 // TODO(zijiehe): This function will be eventually removed after {@link Inpu
tStrategyInterface} |
| 64 // has been deprecated. | 64 // has been deprecated. |
| 65 public void sendCursorMove(int x, int y) { | 65 public void sendCursorMove(float x, float y) { |
| 66 sendCursorMove(new Point(x, y)); | 66 sendCursorMove(new PointF(x, y)); |
| 67 } | 67 } |
| 68 | 68 |
| 69 public void sendMouseWheelEvent(float distanceX, float distanceY) { | 69 public void sendMouseWheelEvent(float distanceX, float distanceY) { |
| 70 mInjector.sendMouseWheelEvent((int) distanceX, (int) distanceY); | 70 mInjector.sendMouseWheelEvent((int) distanceX, (int) distanceY); |
| 71 } | 71 } |
| 72 | 72 |
| 73 public void sendReverseMouseWheelEvent(float distanceX, float distanceY) { | 73 public void sendReverseMouseWheelEvent(float distanceX, float distanceY) { |
| 74 sendMouseWheelEvent(-distanceX, -distanceY); | 74 sendMouseWheelEvent(-distanceX, -distanceY); |
| 75 } | 75 } |
| 76 | 76 |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 for (int keyCode : keyCodes) { | 217 for (int keyCode : keyCodes) { |
| 218 sendKeyUp(keyCode); | 218 sendKeyUp(keyCode); |
| 219 } | 219 } |
| 220 } | 220 } |
| 221 } | 221 } |
| 222 | 222 |
| 223 public void sendCtrlAltDel() { | 223 public void sendCtrlAltDel() { |
| 224 sendKeysPress(CTRL_ALT_DEL); | 224 sendKeysPress(CTRL_ALT_DEL); |
| 225 } | 225 } |
| 226 } | 226 } |
| OLD | NEW |