diff -ru gnome-power-manager-2.28.1.old/debian/changelog gnome-power-manager-2.28.1.new/debian/changelog --- gnome-power-manager-2.28.1.old/debian/changelog 2009-12-10 08:47:42.000000000 +0100 +++ gnome-power-manager-2.28.1.new/debian/changelog 2009-12-10 09:14:00.000000000 +0100 @@ -1,3 +1,17 @@ +gnome-power-manager (2.28.1-0ubuntu1local2) karmic; urgency=low + + * Changed check of board name to handle different version of the + MSI Wind U100 BIOS. + + -- Sylvain Defresne Thu, 10 Dec 2009 08:48:20 +0100 + +gnome-power-manager (2.28.1-0ubuntu1local1) karmic; urgency=low + + * Work-around for bug in MSI Wind U100 BIOS that handle brightness key + press but send event to kernel and then userspace. + + -- Sylvain Defresne Thu, 10 Dec 2009 00:03:32 +0100 + gnome-power-manager (2.28.1-0ubuntu1) karmic; urgency=low * New upstream bug fix release: diff -ru gnome-power-manager-2.28.1.old/src/gpm-brightness-xrandr.c gnome-power-manager-2.28.1.new/src/gpm-brightness-xrandr.c --- gnome-power-manager-2.28.1.old/src/gpm-brightness-xrandr.c 2009-12-10 08:47:42.000000000 +0100 +++ gnome-power-manager-2.28.1.new/src/gpm-brightness-xrandr.c 2009-12-10 09:14:21.000000000 +0100 @@ -66,6 +66,9 @@ gboolean hw_changed; /* A cache of XRRScreenResources is used as XRRGetScreenResources is expensive */ GPtrArray *resources; + + /* true if hardware automatically sets brightness in response to key press events */ + gboolean brightness_in_hardware; }; enum { @@ -83,6 +86,72 @@ G_DEFINE_TYPE (GpmBrightnessXRandR, gpm_brightness_xrandr, G_TYPE_OBJECT) static guint signals [LAST_SIGNAL] = { 0 }; +static gboolean +gpm_brightness_is_board_property(const gchar* property, const gchar* regex) +{ + gchar* filename; + GIOChannel* channel; + GIOStatus status; + gchar* line; + gsize len, pos; + gboolean result; + + filename = g_strdup_printf("/sys/devices/virtual/dmi/id/board_%s", property); + if (filename == NULL) + return FALSE; + + channel = g_io_channel_new_file(filename, "r", NULL); + + g_free(filename); + filename = NULL; + + if (channel == NULL) + return FALSE; + + status = g_io_channel_read_line(channel, &line, &len, &pos, NULL); + + g_io_channel_unref(channel); + channel = NULL; + + if (status != G_IO_STATUS_NORMAL) + return FALSE; + + result = g_regex_match_simple(regex, line, G_REGEX_RAW, 0); + + g_free(line); + line = NULL; + + return result; +} + +static gboolean +gpm_brightness_is_board_vendor(const char* vendor) +{ + return gpm_brightness_is_board_property("vendor", vendor); +} + +static gboolean +gpm_brightness_is_board_name(const char* name) +{ + return gpm_brightness_is_board_property("name", name); +} + +/** + * gpm_brightness_get_brighness_in_hardware + **/ +static gboolean +gpm_brightness_get_brighness_in_hardware() +{ + /* work-around for MSI Wind U100 */ + if (gpm_brightness_is_board_vendor("MICRO-STAR INTERNATIONAL CO., LTD")) { + if (gpm_brightness_is_board_name("U-100|U100")) { + return TRUE; + } + } + + return FALSE; +} + /** * gpm_brightness_xrandr_output_get_internal: **/ @@ -268,6 +337,8 @@ guint min, max; g_return_val_if_fail (GPM_IS_BRIGHTNESS_XRANDR (brightness), FALSE); + if (brightness->priv->brightness_in_hardware) + return TRUE; ret = gpm_brightness_xrandr_output_get_internal (brightness, output, &cur); if (!ret) @@ -302,6 +373,8 @@ guint min, max; g_return_val_if_fail (GPM_IS_BRIGHTNESS_XRANDR (brightness), FALSE); + if (brightness->priv->brightness_in_hardware) + return TRUE; ret = gpm_brightness_xrandr_output_get_internal (brightness, output, &cur); if (!ret) @@ -741,6 +814,9 @@ /* create cache of XRRScreenResources as XRRGetScreenResources() is slow */ gpm_brightness_xrandr_update_cache (brightness); + + /* work around broken BIOS that handle event in hardware but send the key to userspace */ + brightness->priv->brightness_in_hardware = gpm_brightness_get_brighness_in_hardware(); } /**