Skip to content

Commit

Permalink
[remux] don't listen for stylus events when hidden
Browse files Browse the repository at this point in the history
this should save CPU (~6-7%) while the stylus is active and remux is not
showing.
  • Loading branch information
okay committed Feb 20, 2021
1 parent 4f3a283 commit 0324d79
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/remux/launcher.cpy
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ class App: public IApp:
app_dialog->on_hide += PLS_LAMBDA(auto &d):
self.render_bg()
launch(CURRENT_APP)
ui::MainLoop::in.unmonitor(ui::MainLoop::in.wacom.fd)
if USE_KOREADER_WORKAROUND and CURRENT_APP != "KOReader":
ui::MainLoop::in.ungrab()
;
Expand Down Expand Up @@ -427,6 +428,7 @@ class App: public IApp:
if ui::MainLoop::overlay_is_visible:
return

ui::MainLoop::in.monitor(ui::MainLoop::in.wacom.fd)
ClockWatch cz

ClockWatch c0
Expand Down Expand Up @@ -796,6 +798,8 @@ class App: public IApp:
ui::MainLoop::motion_event += PLS_DELEGATE(self.handle_motion_event)
// ui::MainLoop::gesture_event += PLS_DELEGATE(self.handle_gesture_event)

ui::MainLoop::in.unmonitor(ui::MainLoop::in.wacom.fd)

while true:
ui::MainLoop::main()
ui::MainLoop::check_resize()
Expand Down
3 changes: 3 additions & 0 deletions src/rmkit/input/input.cpy
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ namespace input:
FD_SET(fd,&rdfs)
max_fd = max(max_fd, fd+1)

void unmonitor(int fd):
FD_CLR(fd, &rdfs)

def handle_ipc():
char buf[1024];
int bytes = read(input::ipc_fd[0], buf, 1024);
Expand Down

0 comments on commit 0324d79

Please sign in to comment.