summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 864295f)
raw | patch | inline | side by side (parent: 864295f)
author | Max Kellermann <max@duempel.org> | |
Sat, 3 Oct 2009 23:10:29 +0000 (01:10 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Sat, 3 Oct 2009 23:10:29 +0000 (01:10 +0200) |
We don't need the timer when ncmpc is not connected and the clock is
disabled.
disabled.
src/main.c | patch | blob | history |
diff --git a/src/main.c b/src/main.c
index 8669b6358bda9dcf87617790a99f8793f814add2..fa68e8c218ec5bda585b17bb5402f8aec64c7caa 100644 (file)
--- a/src/main.c
+++ b/src/main.c
update_source_id = 0;
}
+static bool
+should_enable_update_timer(void)
+{
+ return mpdclient_is_connected(mpd)
+#ifndef NCMPC_MINI
+ || options.display_time
+#endif
+ ;
+}
+
+static void
+auto_update_timer(void)
+{
+ if (should_enable_update_timer())
+ enable_update_timer();
+ else
+ disable_update_timer();
+}
+
static void
check_reconnect(void);
do_mpd_update();
+ auto_update_timer();
+
return FALSE;
}
{
do_mpd_update();
- return true;
+ if (should_enable_update_timer())
+ return true;
+ else {
+ update_source_id = 0;
+ return false;
+ }
}
void begin_input_event(void)
mpd->events = 0;
check_reconnect();
+ auto_update_timer();
}
int do_input_event(command_t cmd)
screen_cmd(mpd, cmd);
- if (cmd == CMD_VOLUME_UP || cmd == CMD_VOLUME_DOWN) {
+ if (cmd == CMD_VOLUME_UP || cmd == CMD_VOLUME_DOWN)
/* make sure we don't update the volume yet */
disable_update_timer();
- enable_update_timer();
- }
return 0;
}
/* attempt to connect */
reconnect_source_id = g_timeout_add(1, timer_reconnect, NULL);
- enable_update_timer();
+ auto_update_timer();
#ifndef NCMPC_MINI
check_key_bindings_source_id = g_timeout_add(10000, timer_check_key_bindings, NULL);