iberianpig / fusuma

Multitouch gestures with libinput driver on Linux
MIT License
3.63k stars 146 forks source link

use grep to filter out pointer events #279

Closed ces42 closed 2 years ago

ces42 commented 2 years ago

On my computer moving the cursor with the touchpad or scrolling would generated quite high (~10%) cpu usage from fusuma. It seems like this is due to the large amount of output generated by libinput debug-events. Removing all of the POINTER_MOTION and POINTER_SCROLL_FINGER events with grep fixed that for me (I guess grep is much more cpu-efficient than ruby...).

I already wrote this code for use on my computer so I wasn't sure it was necessary to open an issue before creating this PR

iberianpig commented 2 years ago

Hi @ces42, thank you so much for your nice pull request!

The failing RSpec, it should probably pass your tests with the following code

diff --git a/spec/lib/libinput_command_spec.rb b/spec/lib/libinput_command_spec.rb
index 949184f..3ecc8f1 100644
--- a/spec/lib/libinput_command_spec.rb
+++ b/spec/lib/libinput_command_spec.rb
@@ -132,8 +132,12 @@ module Fusuma
         end

         it 'should call dummy events' do
-          expect(Process).to receive(:spawn).with('dummy_debug_events',
-                                                  { out: @dummy_io, in: '/dev/null' }).once
+          th = double(Thread, pid: 'dummy pid')
+          expect(Open3).to receive(:pipeline_start).with(
+            ['dummy_debug_events'],
+            ['grep -v POINTER_ --line-buffered'],
+            { out: @dummy_io, in: '/dev/null' }
+          ).once.and_return([th])
           subject
         end
       end
ces42 commented 2 years ago

I think this is ready now

iberianpig commented 2 years ago

@ces42 Thank you for your contribution!