summaryrefslogtreecommitdiff
path: root/apps/action.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/action.c')
-rw-r--r--apps/action.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/apps/action.c b/apps/action.c
index 0b21a27ea9..e192daae4e 100644
--- a/apps/action.c
+++ b/apps/action.c
@@ -151,6 +151,10 @@ static inline int get_next_context(const struct button_mapping *items, int i)
}
#if defined(HAVE_GUI_BOOST) && defined(HAVE_ADJUSTABLE_CPU_FREQ)
+
+/* Timeout for gui boost in seconds. */
+#define GUI_BOOST_TIMEOUT (HZ)
+
/* Helper function which is called to boost / unboost CPU. This function
* avoids to increase boost_count with each call of gui_boost(). */
static void gui_boost(bool want_to_boost)
@@ -168,6 +172,15 @@ static void gui_boost(bool want_to_boost)
boosted = false;
}
}
+
+/* gui_unboost_callback() is called GUI_BOOST_TIMEOUT seconds after the
+ * last wheel scrolling event. */
+static int gui_unboost_callback(struct timeout *tmo)
+{
+ (void)tmo;
+ gui_boost(false);
+ return 0;
+}
#endif
/*
@@ -194,7 +207,6 @@ static int get_action_worker(int context, int timeout,
int ret = ACTION_UNKNOWN;
static int last_context = CONTEXT_STD;
-
send_event(GUI_EVENT_ACTIONUPDATE, NULL);
if (timeout == TIMEOUT_NOBLOCK)
@@ -205,19 +217,15 @@ static int get_action_worker(int context, int timeout,
button = button_get_w_tmo(timeout);
#if defined(HAVE_GUI_BOOST) && defined(HAVE_ADJUSTABLE_CPU_FREQ)
- /* Boost the CPU in case of wheel scrolling activity in the defined contexts.
- * Unboost the CPU after timeout. */
- static long last_boost_tick;
+ static struct timeout gui_unboost;
+ /* Boost the CPU in case of wheel scrolling activity in the defined contexts.
+ * Call unboost with a timeout of GUI_BOOST_TIMEOUT. */
if ((button&(BUTTON_SCROLL_BACK|BUTTON_SCROLL_FWD)) &&
(context == CONTEXT_STD || context == CONTEXT_LIST ||
context == CONTEXT_MAINMENU || context == CONTEXT_TREE))
{
- last_boost_tick = current_tick;
gui_boost(true);
- }
- else if (TIME_AFTER(current_tick, last_boost_tick + HZ))
- {
- gui_boost(false);
+ timeout_register(&gui_unboost, gui_unboost_callback, GUI_BOOST_TIMEOUT, 0);
}
#endif