~ubuntu-branches/ubuntu/lucid/gnome-power-manager/lucid-updates

« back to all changes in this revision

Viewing changes to src/gpm-manager.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2010-02-05 13:28:09 UTC
  • mfrom: (2.1.49 upstream)
  • Revision ID: james.westby@ubuntu.com-20100205132809-jfmqtr00ri6flcv2
Tags: 2.29.2-0ubuntu1
* New upstream release:
  - Move the power management preferences into the hardware section of the
    control center.
  - Use the name of 'Power' for the power management preferences capplet
  - Don't rely on the cached value of the lid status, to fix a double
    suspend issue (LP: #425411)
  - Add a flag to inhibit consolekit events just after we resumed
  - Don't automatically suspend if there are suspend inhibits
  - Do not exit if hal is not available
  - Only connect to HAL if there is no xrandr backlight hardware
  - Fix compile when using an ld that defaults to --as-needed
  - Enable the help action in gnome-power-statistics. Fixes #607005
  - Ensure the window is realized before we invalidate it. Fixes #604918
  - Don't show the user a sleep failed link pointing to the quirk site
  - Show the device name even when using UPower
  - Translation updates.
* Drop patches accepted upstream: 
  + 03-run-without-hal.patch
  + 04-dont-connect-to-hal-with-xrandr.patch
  + 09-fix-double-suspend.patch
* Regenerate 90-autotools.patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *
18
18
 * You should have received a copy of the GNU General Public License
19
19
 * along with this program; if not, write to the Free Software
20
 
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
20
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21
21
 */
22
22
 
23
23
#include "config.h"
91
91
        guint32                  screensaver_lid_throttle_id;
92
92
        DkpClient               *client;
93
93
        gboolean                 on_battery;
 
94
        gboolean                 just_resumed;
94
95
        GtkStatusIcon           *status_icon;
95
96
        gboolean                 supports_notification_actions;
96
97
        NotifyNotification      *notification;
887
888
        gboolean event_when_closed;
888
889
        gint timeout;
889
890
        gboolean on_battery;
 
891
        gboolean lid_is_closed;
890
892
 
891
 
        /* get the on-battery state */
 
893
        /* get the client state */
892
894
        g_object_get (client,
893
895
                      "on-battery", &on_battery,
 
896
                      "lid-is-closed", &lid_is_closed,
894
897
                      NULL);
895
898
        if (on_battery == manager->priv->on_battery) {
896
899
                egg_debug ("same state as before, ignoring");
923
926
        gpm_manager_update_ac_throttle (manager);
924
927
 
925
928
        /* simulate user input, but only when the lid is open */
926
 
        if (!gpm_button_is_lid_closed (manager->priv->button))
 
929
        if (!lid_is_closed)
927
930
                gpm_screensaver_poke (manager->priv->screensaver);
928
931
 
929
932
        if (!on_battery)
938
941
        /* We keep track of the lid state so we can do the
939
942
           lid close on battery action if the ac adapter is removed when the laptop
940
943
           is closed. Fixes #331655 */
941
 
        if (event_when_closed && on_battery && gpm_button_is_lid_closed (manager->priv->button)) {
 
944
        if (event_when_closed && on_battery && lid_is_closed) {
942
945
                gpm_manager_perform_policy (manager, GPM_CONF_BUTTON_LID_BATT,
943
946
                                            "The lid has been closed, and the ac adapter "
944
947
                                            "removed (and gconf is okay).");
1682
1685
        gpm_manager_update_dpms_throttle (manager);
1683
1686
}
1684
1687
 
 
1688
/*
 
1689
 * gpm_manager_reset_just_resumed_cb
 
1690
 */
 
1691
static gboolean
 
1692
gpm_manager_reset_just_resumed_cb (gpointer user_data)
 
1693
{
 
1694
        GpmManager *manager = GPM_MANAGER (user_data);
 
1695
        manager->priv->just_resumed = FALSE;
 
1696
        return FALSE;
 
1697
}
 
1698
 
 
1699
/**
 
1700
 * gpm_manager_control_resume_cb
 
1701
 **/
 
1702
static void
 
1703
gpm_manager_control_resume_cb (GpmControl *control, GpmControlAction action, GpmManager *manager)
 
1704
{
 
1705
        manager->priv->just_resumed = TRUE;
 
1706
        g_timeout_add_seconds (1, gpm_manager_reset_just_resumed_cb, manager);
 
1707
}
 
1708
 
1685
1709
/**
1686
1710
 * gpm_manager_console_kit_active_changed_cb:
1687
1711
 **/
1701
1725
        if (!ret)
1702
1726
                return;
1703
1727
 
 
1728
        /* lid state might not be accurate if just resumed. Don't do anything if
 
1729
         * we've just resumed as we might end up re-suspending the machine due
 
1730
         * to pm-utils and uswsusp changing the tty */
 
1731
        if (manager->priv->just_resumed)
 
1732
                return;
 
1733
 
1704
1734
        /* get ac state */
1705
1735
        if (!manager->priv->on_battery) {
1706
1736
                egg_debug ("Performing AC policy as become active when lid down");
1766
1796
        manager->priv->screensaver_dpms_throttle_id = 0;
1767
1797
        manager->priv->screensaver_lid_throttle_id = 0;
1768
1798
 
 
1799
        /* init to not just_resumed */
 
1800
        manager->priv->just_resumed = FALSE;
 
1801
 
1769
1802
        /* don't apply policy when not active */
1770
1803
        manager->priv->console = egg_console_kit_new ();
1771
1804
        g_signal_connect (manager->priv->console, "active-changed",
1850
1883
        /* use the control object */
1851
1884
        egg_debug ("creating new control instance");
1852
1885
        manager->priv->control = gpm_control_new ();
 
1886
        g_signal_connect (manager->priv->control, "resume",
 
1887
                          G_CALLBACK (gpm_manager_control_resume_cb), manager);
1853
1888
 
1854
1889
        egg_debug ("creating new tray icon");
1855
1890
        manager->priv->tray_icon = gpm_tray_icon_new ();