patch: use Xrecord extension in syndaemon to avoid polling

Peter Hutterer peter.hutterer at who-t.net
Mon Oct 20 23:07:11 PDT 2008


On Fri, Oct 17, 2008 at 08:23:32AM +0200, Andre Herms wrote:
> > Thanks for the patch! There's a number of irrelevant white-space changes in
> > that patch. Can you please clean it up and re-send it? Thanks.
> >
> 
> Sorry, my mistake.
> 
> I removed the whitespace changes and further added a a small change in the
> syndamon manpage.

playing the happy relay game, the following are comments on your patch by
Henrik Rydberg regarding your patch. Please CC him and christoph brill on your
next version. Thanks. 

Cheers,
  Peter


its looking better, but there are still some minor things. The better
initial patch from someone, the better succeeding patches ;-)

Eventually I will get down to what it actually does.

-------------------------------------

New dependency (debian x11proto-record-dev) not listed?

 @@ -45,6 +48,7 @@ static SynapticsSHM *synshm;
 static int pad_disabled;
 static int disable_taps_only;
 static int ignore_modifier_combos;
+static int ignore_modifier_keys = 0;
 static int background;
 static const char *pid_file;

Assigning statics to zero is never necessary.

@@ -333,11 +530,16 @@ main(int argc, char *argv[])
 	    fclose(fd);
 	}
     }
-
-    setup_keyboard_mask(display, ignore_modifier_keys);
-
-    /* Run the main loop */
-    main_loop(display, idle_time, poll_delay);
-
+#ifdef HAVE_XRECORD
+    if (use_xrecord && check_xrecord(display)) {
+	record_main_loop(display, idle_time);
+    } else
+#endif HAVE_XRECORD
+      {
+	setup_keyboard_mask(display, ignore_modifier_keys);
+
+	/* Run the main loop */
+	main_loop(display, idle_time, poll_delay);
+      }
     return 0;
 }

The "HAVE_RECORD" after #endif produces warning.

+    status = XRecordQueryVersion(display, version, version+1);
+    if (!background && status) {
+       printf("X RECORD extension version %d.%d\n", version[0], version[1]);
+    }
+    return found;

background and printf... there are debug and info functions to use.
Goes for all instances of this construct.

+    int nxev;
+
+    cbres = (struct xrecord_callback_results *)closure;
+    /*printf("something happend, category=%d\n", recorded_data->category); */
+

commented-out lines of code...

+
+           cbres->key_event = 1; /* remember, a key was pressed. */
+

... or released, according to the code



+
+       ret = select(fd+1, &read_fds, NULL, NULL,
+                    pad_disabled ? &timeout : NULL /* timeout only required for enabling */ );
+
+

I do not doubt that this is correct, but (fd+1) is somewhat magic here - perhaps
an explanation is in order?

           /* adjust the enable_time */
+           timeout.tv_sec  = (int)idle_time;
+           timeout.tv_usec = (idle_time-(double)timeout.tv_sec) * 100000.;
+

microseconds, but a constant of 10^5?




More information about the xorg mailing list