Do not run timeout callbacks when panel is hidden. This will prevent reading cpu or memory status when their widgets are not visible.

This commit is contained in:
Sanel Zukan
2012-04-11 16:15:01 +00:00
parent 6ef8fead33
commit 7d884242bd
8 changed files with 90 additions and 22 deletions

View File

@@ -142,7 +142,6 @@ CPUMonitor::CPUMonitor() : Fl_Box(0, 0, 45, 25)
colors[IWM_IDLE] = FL_BACKGROUND_COLOR;
layout();
Fl::add_timeout(UPDATE_INTERVAL, cpu_timeout_cb, this);
}
void CPUMonitor::clear()
@@ -247,6 +246,22 @@ void CPUMonitor::layout() {
}
}
int CPUMonitor::handle(int e) {
switch(e) {
case FL_SHOW: {
int ret = Fl_Box::handle(e);
Fl::add_timeout(UPDATE_INTERVAL, cpu_timeout_cb, this);
return ret;
}
case FL_HIDE:
Fl::remove_timeout(cpu_timeout_cb);
/* fallthrough */
}
return Fl_Box::handle(e);
}
void CPUMonitor::update_status() {
if(!cpu) return;