[Pommed-commits] r353 - in trunk: . pommed
jblache at alioth.debian.org
jblache at alioth.debian.org
Wed Aug 22 14:25:35 UTC 2007
Author: jblache
Date: 2007-08-22 14:25:35 +0000 (Wed, 22 Aug 2007)
New Revision: 353
Modified:
trunk/ChangeLog
trunk/pommed/pommed.c
Log:
Kill code duplication in the main loop.
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2007-08-22 14:14:16 UTC (rev 352)
+++ trunk/ChangeLog 2007-08-22 14:25:35 UTC (rev 353)
@@ -5,6 +5,7 @@
- pommed: add an idle timer to automatically switch off the
keyboard backlight. Suggested by Javier Marcet.
- pommed: turn has_kbd_backlight() into an inline function.
+ - pommed: kill code duplication in the main loop.
version 1.8:
- pommed: probe for the applesmc sysfs path in the ambient light
Modified: trunk/pommed/pommed.c
===================================================================
--- trunk/pommed/pommed.c 2007-08-22 14:14:16 UTC (rev 352)
+++ trunk/pommed/pommed.c 2007-08-22 14:25:35 UTC (rev 353)
@@ -795,6 +795,8 @@
ret = poll(fds, nfds, LOOP_TIMEOUT);
+ gettimeofday(&tv_now, NULL);
+
if (ret < 0) /* error */
{
if (errno != EINTR)
@@ -821,7 +823,6 @@
}
/* is it time to chek the ambient light sensors and AC state ? */
- gettimeofday(&tv_now, NULL);
tv_diff.tv_sec = tv_now.tv_sec - tv_als.tv_sec;
if (tv_diff.tv_sec < 0)
tv_diff.tv_sec = 0;
@@ -839,24 +840,13 @@
if (tv_diff.tv_usec >= (1000 * LOOP_TIMEOUT))
{
- if (has_kbd_backlight())
- {
- /* Increment keyboard backlight idle timer */
- kbd_bck_info.idle++;
- if ((kbd_cfg.idle > 0) && (kbd_bck_info.idle > kbd_cfg.idle))
- kbd_backlight_inhibit_set(KBD_INHIBIT_IDLE);
-
- kbd_backlight_ambient_check();
- }
-
- power_check_ac_state();
-
- tv_als = tv_now;
+ ret = 0; /* go and check ALS, AC state and idle time */
}
}
- else
+
+ if (ret == 0)
{
- /* poll() timed out, check ambient light sensors and AC state */
+ /* time to check ambient light sensors, AC state and idle time */
if (has_kbd_backlight())
{
/* Increment keyboard backlight idle timer */
@@ -869,7 +859,7 @@
power_check_ac_state();
- gettimeofday(&tv_als, NULL);
+ tv_als = tv_now;
}
/* Process DBus requests */
More information about the Pommed-commits
mailing list