Skip to content

Commit

Permalink
fix: pause/resume keymap when launching editor
Browse files Browse the repository at this point in the history
  • Loading branch information
Xtr126 committed Aug 8, 2023
1 parent 2632734 commit 70cd485
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
4 changes: 3 additions & 1 deletion app/src/main/java/xtr/keymapper/editor/EditorService.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import xtr.keymapper.R;
import xtr.keymapper.profiles.ProfileSelector;
import xtr.keymapper.server.RemoteService;
import xtr.keymapper.server.RemoteServiceHelper;

public class EditorService extends Service implements EditorUI.OnHideListener {
private EditorUI editor;
Expand All @@ -23,9 +24,9 @@ public class EditorService extends Service implements EditorUI.OnHideListener {
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
mService = RemoteService.getInstance();
RemoteServiceHelper.pauseKeymap();

if (editor != null) editor.hideView();

ProfileSelector.select(this, profile -> {
editor = new EditorUI(this, profile);
editor.open();
Expand Down Expand Up @@ -58,6 +59,7 @@ public void onHideView() {
} catch (RemoteException ignored) {
}
editor = null;
RemoteServiceHelper.resumeKeymap();
stopSelf();
}

Expand Down
12 changes: 8 additions & 4 deletions app/src/main/java/xtr/keymapper/server/RemoteService.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,10 @@ public void unregisterOnKeyEventListener(OnKeyEventListener l) {
}

public void pauseMouse(){
inputService.setMouseLock(false);
inputService.stopEvents = true;
if (inputService != null) {
inputService.setMouseLock(false);
inputService.stopEvents = true;
}
}

@Override
Expand All @@ -119,8 +121,10 @@ public void reloadKeymap() {
}

public void resumeMouse(){
inputService.setMouseLock(true);
inputService.stopEvents = false;
if (inputService != null) {
inputService.setMouseLock(true);
inputService.stopEvents = false;
}
}
};

Expand Down

0 comments on commit 70cd485

Please sign in to comment.