Add external mouse hover support in SessionView.java (#9495)

This commit is contained in:
kevin147147 2023-10-24 16:05:47 +02:00 committed by GitHub
parent 60ea534ccd
commit 357390acef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -29,8 +29,10 @@ import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection; import android.view.inputmethod.InputConnection;
import com.freerdp.freerdpcore.application.SessionState; import com.freerdp.freerdpcore.application.SessionState;
import com.freerdp.freerdpcore.services.LibFreeRDP;
import com.freerdp.freerdpcore.utils.DoubleGestureDetector; import com.freerdp.freerdpcore.utils.DoubleGestureDetector;
import com.freerdp.freerdpcore.utils.GestureDetector; import com.freerdp.freerdpcore.utils.GestureDetector;
import com.freerdp.freerdpcore.utils.Mouse;
import java.util.Stack; import java.util.Stack;
@ -92,6 +94,23 @@ public class SessionView extends View
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
} }
/* External Mouse Hover */
@Override public boolean onHoverEvent(MotionEvent event)
{
if (event.getAction() == MotionEvent.ACTION_HOVER_MOVE)
{
// Handle hover move event
float x = event.getX();
float y = event.getY();
// Perform actions based on the hover position (x, y)
MotionEvent mappedEvent = mapTouchEvent(event);
LibFreeRDP.sendCursorEvent(currentSession.getInstance(), (int)mappedEvent.getX(),
(int)mappedEvent.getY(), Mouse.getMoveEvent());
}
// Return true to indicate that you've handled the event
return true;
}
public void setScaleGestureDetector(ScaleGestureDetector scaleGestureDetector) public void setScaleGestureDetector(ScaleGestureDetector scaleGestureDetector)
{ {
doubleGestureDetector.setScaleGestureDetector(scaleGestureDetector); doubleGestureDetector.setScaleGestureDetector(scaleGestureDetector);