summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorthat <github@that.at>2015-02-08 08:55:00 +0100
committerDees Troy <dees_troy@teamw.in>2015-02-09 16:53:21 +0100
commitde72b6d4d8f7106a9cbb611225dd0b726ba23720 (patch)
tree184dcc1e7d96db6f66c81ff639383c1bd10887d3
parentReset data manager variables before running runPages (diff)
downloadandroid_bootable_recovery-de72b6d4d8f7106a9cbb611225dd0b726ba23720.tar
android_bootable_recovery-de72b6d4d8f7106a9cbb611225dd0b726ba23720.tar.gz
android_bootable_recovery-de72b6d4d8f7106a9cbb611225dd0b726ba23720.tar.bz2
android_bootable_recovery-de72b6d4d8f7106a9cbb611225dd0b726ba23720.tar.lz
android_bootable_recovery-de72b6d4d8f7106a9cbb611225dd0b726ba23720.tar.xz
android_bootable_recovery-de72b6d4d8f7106a9cbb611225dd0b726ba23720.tar.zst
android_bootable_recovery-de72b6d4d8f7106a9cbb611225dd0b726ba23720.zip
-rw-r--r--gui/gui.cpp31
-rw-r--r--gui/scrolllist.cpp6
-rw-r--r--minuitwrp/events.c4
-rw-r--r--minuitwrp/minui.h2
4 files changed, 28 insertions, 15 deletions
diff --git a/gui/gui.cpp b/gui/gui.cpp
index 469beb630..8bdd4251c 100644
--- a/gui/gui.cpp
+++ b/gui/gui.cpp
@@ -205,7 +205,7 @@ public:
}
// process input events. returns true if any event was received.
- bool processInput();
+ bool processInput(int timeout_ms);
void handleDrag();
@@ -249,10 +249,10 @@ private:
InputHandler input_handler;
-bool InputHandler::processInput()
+bool InputHandler::processInput(int timeout_ms)
{
input_event ev;
- int ret = ev_get(&ev);
+ int ret = ev_get(&ev, timeout_ms);
if (ret < 0)
{
@@ -546,7 +546,7 @@ static void ors_command_read()
// This special function will return immediately the first time, but then
// always returns 1/30th of a second (or immediately if called later) from
// the last time it was called
-static void loopTimer(void)
+static void loopTimer(int input_timeout_ms)
{
static timespec lastCall;
static int initialized = 0;
@@ -560,7 +560,7 @@ static void loopTimer(void)
do
{
- bool got_event = input_handler.processInput(); // get inputs but don't send drag notices
+ bool got_event = input_handler.processInput(input_timeout_ms); // get inputs but don't send drag notices
timespec curTime;
clock_gettime(CLOCK_MONOTONIC, &curTime);
@@ -583,6 +583,7 @@ static void loopTimer(void)
// We need to sleep some period time microseconds
//unsigned int sleepTime = 33333 -(diff.tv_nsec / 1000);
//usleep(sleepTime); // removed so we can scan for input
+ input_timeout_ms = 0;
} while (1);
}
@@ -615,9 +616,12 @@ static int runPages(const char *page_name, const int stop_on_page_done)
int has_data = 0;
#endif
+ int input_timeout_ms = 0;
+ int idle_frames = 0;
+
for (;;)
{
- loopTimer();
+ loopTimer(input_timeout_ms);
#ifndef TW_OEM_BUILD
if (ors_read_fd > 0) {
FD_ZERO(&fdset);
@@ -637,9 +641,13 @@ static int runPages(const char *page_name, const int stop_on_page_done)
if (!gForceRender.get_value())
{
- int ret;
-
- ret = PageManager::Update();
+ int ret = PageManager::Update();
+ if (ret == 0)
+ ++idle_frames;
+ else
+ idle_frames = 0;
+ // due to possible animation objects, we need to delay activating the input timeout
+ input_timeout_ms = idle_frames > 15 ? 1000 : 0;
#ifndef PRINT_RENDER_TIME
if (ret > 1)
@@ -663,7 +671,7 @@ static int runPages(const char *page_name, const int stop_on_page_done)
LOGINFO("Render(): %u ms, flip(): %u ms, total: %u ms\n", render_t, flip_t, render_t+flip_t);
}
- else if(ret == 1)
+ else if (ret > 0)
flip();
#endif
}
@@ -672,6 +680,7 @@ static int runPages(const char *page_name, const int stop_on_page_done)
gForceRender.set_value(0);
PageManager::Render();
flip();
+ input_timeout_ms = 0;
}
blankTimer.checkForTimeout();
@@ -908,7 +917,7 @@ static void * console_thread(void *cookie)
while (!gGuiConsoleTerminate.get_value())
{
- loopTimer();
+ loopTimer(0);
if (!gForceRender.get_value())
{
diff --git a/gui/scrolllist.cpp b/gui/scrolllist.cpp
index 6143b60a2..02656c79d 100644
--- a/gui/scrolllist.cpp
+++ b/gui/scrolllist.cpp
@@ -632,8 +632,10 @@ void GUIScrollList::HandleScrolling()
firstDisplayedItem--;
y_offset -= actualItemHeight;
}
- if (firstDisplayedItem == 0 && y_offset > 0)
+ if (firstDisplayedItem == 0 && y_offset > 0) {
y_offset = 0; // user kept dragging downward past the top of the list, so always reset the offset to 0 since we can't scroll any further in this direction
+ scrollingSpeed = 0; // stop kinetic scrolling
+ }
// handle dragging upward, scrolling downward
int totalSize = GetItemCount();
@@ -649,9 +651,11 @@ void GUIScrollList::HandleScrolling()
if (bottom_offset != 0 && firstDisplayedItem + lines + 1 >= totalSize && y_offset <= bottom_offset) {
firstDisplayedItem = totalSize - lines - 1;
y_offset = bottom_offset;
+ scrollingSpeed = 0; // stop kinetic scrolling
} else if (firstDisplayedItem + lines >= totalSize && y_offset < 0) {
firstDisplayedItem = totalSize - lines;
y_offset = 0;
+ scrollingSpeed = 0; // stop kinetic scrolling
}
}
diff --git a/minuitwrp/events.c b/minuitwrp/events.c
index e2414a440..0309a9a21 100644
--- a/minuitwrp/events.c
+++ b/minuitwrp/events.c
@@ -719,7 +719,7 @@ static int vk_modify(struct ev *e, struct input_event *ev)
return 0;
}
-int ev_get(struct input_event *ev)
+int ev_get(struct input_event *ev, int timeout_ms)
{
int r;
unsigned n;
@@ -740,7 +740,7 @@ int ev_get(struct input_event *ev)
lastInputStat = curr;
}
- r = poll(ev_fds, ev_count, 0);
+ r = poll(ev_fds, ev_count, timeout_ms);
if(r > 0) {
for(n = 0; n < ev_count; n++) {
diff --git a/minuitwrp/minui.h b/minuitwrp/minui.h
index abebc1450..3aa486511 100644
--- a/minuitwrp/minui.h
+++ b/minuitwrp/minui.h
@@ -75,7 +75,7 @@ struct input_event;
int ev_init(void);
void ev_exit(void);
-int ev_get(struct input_event *ev);
+int ev_get(struct input_event *ev, int timeout_ms);
int ev_has_mouse(void);
// Resources