Skip to content

Commit

Permalink
Bugfix for drag/drop on Ubuntu 22.04 remote desktop sharing.
Browse files Browse the repository at this point in the history
  • Loading branch information
iiordanov committed Feb 19, 2024
1 parent 0fe6180 commit e1cbceb
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

public abstract class RemotePointer extends com.undatech.opaque.input.RemotePointer {
public RemotePointer(
RfbConnectable protocomm, Context context, InputCarriable remoteInput,
RfbConnectable rfbConnectable, Context context, InputCarriable remoteInput,
Viewable canvas, Handler handler, boolean debugLogging
) {
super(protocomm, context, remoteInput, canvas, handler, debugLogging);
super(rfbConnectable, context, remoteInput, canvas, handler, debugLogging);
}
}
39 changes: 18 additions & 21 deletions bVNC/src/main/java/com/iiordanov/bVNC/input/RemoteRdpPointer.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,24 @@
public class RemoteRdpPointer extends RemotePointer {
private static final String TAG = "RemoteRdpPointer";

private final static int PTRFLAGS_WHEEL = 0x0200;
private final static int PTRFLAGS_WHEEL_NEGATIVE = 0x0100;
//private final static int PTRFLAGS_DOWN = 0x8000;

private final static int POINTER_FLAGS_WHEEL = 0x0200; // 512
private final static int POINTER_FLAGS_WHEEL_NEGATIVE = 0x0100; // 256
/*
private final static int MOUSE_BUTTON_NONE = 0x0000;
private final static int MOUSE_BUTTON_MOVE = 0x0800;
private final static int MOUSE_BUTTON_LEFT = 0x1000;
private final static int MOUSE_BUTTON_RIGHT = 0x2000;
*/
private final static int MOUSE_BUTTON_MOVE = 0x0800; // 2048
private final static int MOUSE_BUTTON_LEFT = 0x1000; // 4096
private final static int MOUSE_BUTTON_RIGHT = 0x2000; // 8192

private static final int MOUSE_BUTTON_MIDDLE = 0x4000;
private static final int MOUSE_BUTTON_SCROLL_UP = PTRFLAGS_WHEEL | 0x0078;
private static final int MOUSE_BUTTON_SCROLL_DOWN = PTRFLAGS_WHEEL | PTRFLAGS_WHEEL_NEGATIVE | 0x0088;
private static final int MOUSE_BUTTON_MIDDLE = 0x4000; // 16384
private static final int MOUSE_BUTTON_SCROLL_UP = POINTER_FLAGS_WHEEL | 0x0078;
private static final int MOUSE_BUTTON_SCROLL_DOWN = POINTER_FLAGS_WHEEL | POINTER_FLAGS_WHEEL_NEGATIVE | 0x0088;

public RemoteRdpPointer(
RfbConnectable spicecomm, Context context, InputCarriable remoteInput,
RfbConnectable rfbConnectable, Context context, InputCarriable remoteInput,
Viewable canvas, Handler handler, boolean debugLogging
) {
super(spicecomm, context, remoteInput, canvas, handler, debugLogging);
super(rfbConnectable, context, remoteInput, canvas, handler, debugLogging);
}

private void sendButtonDownOrMoveButtonDown(int x, int y, int metaState) {
Expand Down Expand Up @@ -106,11 +106,6 @@ public void releaseButton(int x, int y, int metaState) {

/**
* Sends a pointer event to the server.
*
* @param x
* @param y
* @param metaState
* @param isMoving
*/
private void sendPointerEvent(int x, int y, int metaState, boolean isMoving) {

Expand All @@ -121,9 +116,10 @@ private void sendPointerEvent(int x, int y, int metaState, boolean isMoving) {
if (!isMoving) {
// If this is a new mouse down event, release previous button pressed to avoid confusing the remote OS.
if (prevPointerMask != 0 && prevPointerMask != pointerMask) {
protocomm.writePointerEvent(pointerX, pointerY,
combinedMetaState,
prevPointerMask & ~POINTER_DOWN_MASK, false);
int upPointerMask = prevPointerMask & ~POINTER_DOWN_MASK;
GeneralUtils.debugLog(this.debugLogging, TAG, "Sending mouse up event at: " + pointerX +
", " + pointerY + " with prevPointerMask: " + prevPointerMask + ", upPointerMask: " + upPointerMask);
protocomm.writePointerEvent(pointerX, pointerY, combinedMetaState, upPointerMask, false);
}
prevPointerMask = pointerMask;
}
Expand All @@ -145,7 +141,8 @@ private void sendPointerEvent(int x, int y, int metaState, boolean isMoving) {
}
canvas.invalidateMousePosition();
GeneralUtils.debugLog(this.debugLogging, TAG, "Sending absolute mouse event at: " + pointerX +
", " + pointerY + ", pointerMask: " + pointerMask);
", " + pointerY + " with pointerMask: " + pointerMask);
protocomm.writePointerEvent(pointerX, pointerY, combinedMetaState, MOUSE_BUTTON_MOVE | pointerMask, false);
protocomm.writePointerEvent(pointerX, pointerY, combinedMetaState, pointerMask, false);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

public abstract class RemotePointer {

public static final int POINTER_DOWN_MASK = 0x8000;
public static final int POINTER_DOWN_MASK = 0x8000; // 32768
public static float DEFAULT_SENSITIVITY = 2.0f;
public static boolean DEFAULT_ACCELERATED = true;
/**
Expand Down

0 comments on commit e1cbceb

Please sign in to comment.