[gnome-screensaver] Reduce the number of wakeups
- From: Ray Strode <halfline src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-screensaver] Reduce the number of wakeups
- Date: Fri, 30 Nov 2012 19:50:19 +0000 (UTC)
commit 2a39bfb8da38223b02307687083dfec6e531a3da
Author: B.Prathibha <prathibhab cdac in>
Date: Sun Nov 25 21:29:58 2012 +0530
Reduce the number of wakeups
gnome-screensaver uses g_timeout_add with an integral number
of seconds as a timeout duration in various parts of the code.
These bits of code will work just as well using g_timeout_add_seconds
instead.
g_timeout_add_seconds has the advantage that it consolidates all wake
ups that happen near each other to happen at the same time, there by
creating less wake ups overall (which improves power savings)
This commit changes the applicable g_timeout_add calls to
g_timeout_add_seconds calls.
https://bugzilla.gnome.org/show_bug.cgi?id=689032
src/gnome-screensaver-dialog.c | 4 ++--
src/gs-lock-plug.c | 12 ++++++------
src/gs-monitor.c | 2 +-
src/gs-watcher-x11.c | 16 ++++++++--------
src/test-window.c | 2 +-
5 files changed, 18 insertions(+), 18 deletions(-)
---
diff --git a/src/gnome-screensaver-dialog.c b/src/gnome-screensaver-dialog.c
index 134d7a3..1ea7db7 100644
--- a/src/gnome-screensaver-dialog.c
+++ b/src/gnome-screensaver-dialog.c
@@ -363,7 +363,7 @@ auth_check_idle (GSLockPlug *plug)
if (loop_counter < MAX_FAILURES) {
gs_debug ("Authentication failed, retrying (%u)", loop_counter);
- g_timeout_add (3000, (GSourceFunc)reset_idle_cb, plug);
+ g_timeout_add_seconds (3, (GSourceFunc)reset_idle_cb, plug);
} else {
gs_debug ("Authentication failed, quitting (max failures)");
again = FALSE;
@@ -371,7 +371,7 @@ auth_check_idle (GSLockPlug *plug)
* terminates us after it has finished the dialog shake. Time out
* after 5 seconds and quit anyway if this doesn't happen though */
g_idle_add ((GSourceFunc)response_request_quit, NULL);
- g_timeout_add (5000, (GSourceFunc)quit_timeout_cb, NULL);
+ g_timeout_add_seconds (5, (GSourceFunc)quit_timeout_cb, NULL);
}
}
diff --git a/src/gs-lock-plug.c b/src/gs-lock-plug.c
index 4552646..1e74d8f 100644
--- a/src/gs-lock-plug.c
+++ b/src/gs-lock-plug.c
@@ -260,9 +260,9 @@ dialog_timed_out (GSLockPlug *plug)
remove_response_idle (plug);
- plug->priv->response_idle_id = g_timeout_add (2000,
- (GSourceFunc)response_cancel_idle_cb,
- plug);
+ plug->priv->response_idle_id = g_timeout_add_seconds (2,
+ (GSourceFunc)response_cancel_idle_cb,
+ plug);
return FALSE;
}
@@ -1452,9 +1452,9 @@ switch_user_button_clicked (GtkButton *button,
gs_lock_plug_set_sensitive (plug, FALSE);
- plug->priv->response_idle_id = g_timeout_add (2000,
- (GSourceFunc)response_cancel_idle_cb,
- plug);
+ plug->priv->response_idle_id = g_timeout_add_seconds (2,
+ (GSourceFunc)response_cancel_idle_cb,
+ plug);
gs_lock_plug_set_busy (plug);
do_user_switch (plug);
diff --git a/src/gs-monitor.c b/src/gs-monitor.c
index 6e43a2b..f038bab 100644
--- a/src/gs-monitor.c
+++ b/src/gs-monitor.c
@@ -151,7 +151,7 @@ watcher_idle_notice_cb (GSWatcher *watcher,
if (monitor->priv->release_grab_id != 0) {
g_source_remove (monitor->priv->release_grab_id);
}
- monitor->priv->release_grab_id = g_timeout_add (1000, (GSourceFunc)release_grab_timeout, monitor);
+ monitor->priv->release_grab_id = g_timeout_add_seconds (1, (GSourceFunc)release_grab_timeout, monitor);
} else {
gs_debug ("manager active, skipping fade cancellation");
}
diff --git a/src/gs-watcher-x11.c b/src/gs-watcher-x11.c
index f0b0d83..1da5116 100644
--- a/src/gs-watcher-x11.c
+++ b/src/gs-watcher-x11.c
@@ -93,9 +93,9 @@ static void
add_watchdog_timer (GSWatcher *watcher,
glong timeout)
{
- watcher->priv->watchdog_timer_id = g_timeout_add (timeout,
- (GSourceFunc)watchdog_timer,
- watcher);
+ watcher->priv->watchdog_timer_id = g_timeout_add_seconds (timeout,
+ (GSourceFunc)watchdog_timer,
+ watcher);
}
static void
@@ -360,9 +360,9 @@ set_status (GSWatcher *watcher,
if (watcher->priv->idle_id > 0) {
g_source_remove (watcher->priv->idle_id);
}
- watcher->priv->idle_id = g_timeout_add (watcher->priv->delta_notice_timeout,
- (GSourceFunc)on_idle_timeout,
- watcher);
+ watcher->priv->idle_id = g_timeout_add_seconds (watcher->priv->delta_notice_timeout,
+ (GSourceFunc)on_idle_timeout,
+ watcher);
} else {
/* cancel notice too */
if (watcher->priv->idle_id > 0) {
@@ -490,9 +490,9 @@ gs_watcher_init (GSWatcher *watcher)
connect_presence_watcher (watcher);
/* time before idle signal to send notice signal */
- watcher->priv->delta_notice_timeout = 10000;
+ watcher->priv->delta_notice_timeout = 10;
- add_watchdog_timer (watcher, 600000);
+ add_watchdog_timer (watcher, 600);
}
static void
diff --git a/src/test-window.c b/src/test-window.c
index 6f07b3b..a82e160 100644
--- a/src/test-window.c
+++ b/src/test-window.c
@@ -158,7 +158,7 @@ main (int argc,
test_window ();
/* safety valve in case we can't authenticate */
- g_timeout_add (30000, (GSourceFunc)gtk_main_quit, NULL);
+ g_timeout_add_seconds (30, (GSourceFunc)gtk_main_quit, NULL);
gtk_main ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]