[PATCH] Re-coldplug dock status when resuming from sleep
Evan Broder
evan at ebroder.net
Wed Apr 11 00:19:06 PDT 2012
It's possible for the docked state of a laptop (i.e. the display
connectivity state) to change while the laptop is asleep.
Signed-off-by: Evan Broder <evan at ebroder.net>
---
src/linux/up-dock.c | 17 +++++++++++++++++
1 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/src/linux/up-dock.c b/src/linux/up-dock.c
index 78fb7d3..d2026f1 100644
--- a/src/linux/up-dock.c
+++ b/src/linux/up-dock.c
@@ -33,6 +33,7 @@ struct UpDockPrivate
UpDaemon *daemon;
GUdevClient *gudev_client;
guint poll_id;
+ guint notify_resume_id;
};
G_DEFINE_TYPE (UpDock, up_dock, G_TYPE_OBJECT)
@@ -120,6 +121,17 @@ up_dock_set_should_poll (UpDock *dock, gboolean should_poll)
}
/**
+ * up_dock_notify_resume_signal_handler_cb
+ */
+void
+up_dock_notify_resume_signal_handler_cb (UpDaemon *daemon, char *sleep_kind,
+ gpointer user_data)
+{
+ UpDock *dock = UP_DOCK (user_data);
+ up_dock_refresh (dock);
+}
+
+/**
* up_dock_coldplug:
**/
gboolean
@@ -127,6 +139,9 @@ up_dock_coldplug (UpDock *dock, UpDaemon *daemon)
{
/* save daemon */
dock->priv->daemon = g_object_ref (daemon);
+ dock->priv->notify_resume_id = g_signal_connect (dock->priv->daemon, "notify-resume",
+ G_CALLBACK (up_dock_notify_resume_signal_handler_cb),
+ dock);
return up_dock_refresh (dock);
}
@@ -170,6 +185,8 @@ up_dock_finalize (GObject *object)
g_return_if_fail (dock->priv != NULL);
g_object_unref (dock->priv->gudev_client);
+ if (dock->priv->notify_resume_id != 0)
+ g_signal_handler_disconnect (dock->priv->daemon, dock->priv->notify_resume_id);
if (dock->priv->daemon != NULL)
g_object_unref (dock->priv->daemon);
if (dock->priv->poll_id != 0)
--
1.7.5.4
More information about the devkit-devel
mailing list