Skip to content

Commit

Permalink
fix (wlclient): move only one cursor
Browse files Browse the repository at this point in the history
  • Loading branch information
Xtr126 committed Dec 30, 2023
1 parent d87e497 commit 071d401
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion app/src/main/java/xtr/keymapper/server/InputService.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class InputService implements IInputInterface {
private final boolean isWaylandClient;
private final String touchpadInputMode;

public InputService(KeymapProfile profile, KeymapConfig keymapConfig, IRemoteServiceCallback mCallback, int screenWidth, int screenHeight, boolean isWaylandClient){
public InputService(KeymapProfile profile, KeymapConfig keymapConfig, IRemoteServiceCallback mCallback, int screenWidth, int screenHeight, boolean isWaylandClient) throws RemoteException {
this.keymapProfile = profile;
this.keymapConfig = keymapConfig;
this.mCallback = mCallback;
Expand All @@ -43,6 +43,11 @@ else if (touchpadInputMode.equals(KeymapConfig.TOUCHPAD_RELATIVE))

keyEventHandler = new KeyEventHandler(this);
keyEventHandler.init();

if (isWaylandClient) {
mCallback.cursorSetX(0);
mCallback.cursorSetY(0);
}
}

public void injectEvent(float x, float y, int action, int pointerId) {
Expand Down Expand Up @@ -95,19 +100,23 @@ public IRemoteServiceCallback getCallback() {
}

public void moveCursorX(float x) {
if (isWaylandClient) return;
try {
mCallback.cursorSetX((int) x);
} catch (RemoteException ignored) {
}
// To avoid conflict with touch input when moving virtual pointer
if (input.pointerCount < 1) cursorSetX((int) x);
else if (input.pointerCount == 1 && pointerUp) cursorSetX((int) x);
}

public void moveCursorY(float y) {
if (isWaylandClient) return;
try {
mCallback.cursorSetY((int) y);
} catch (RemoteException ignored) {
}
// To avoid conflict with touch input when moving virtual pointer
if (input.pointerCount < 1) cursorSetY((int) y);
else if (input.pointerCount == 1 && pointerUp) cursorSetY((int) y);
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/xtr/keymapper/server/RemoteService.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public boolean isRoot() {
}

@Override
public void startServer(KeymapProfile profile, KeymapConfig keymapConfig, IRemoteServiceCallback cb, int screenWidth, int screenHeight) {
public void startServer(KeymapProfile profile, KeymapConfig keymapConfig, IRemoteServiceCallback cb, int screenWidth, int screenHeight) throws RemoteException {
if (inputService != null) stopServer();
inputService = new InputService(profile, keymapConfig, cb, screenWidth, screenHeight, isWaylandClient);
if (!isWaylandClient) {
Expand Down

0 comments on commit 071d401

Please sign in to comment.