mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-18 13:54:36 -05:00
[Dmenu] Add a minimum update rate for dmenu reading. (#1681)
This avoid slow loading for some weird slow spaced out input stream. (one input every 250ms). Not sure what use-case this fixes. This fix does cause a noticable slow-down on very large lists. Issue: #1680
This commit is contained in:
parent
78d596dc53
commit
89e00ebb32
1 changed files with 12 additions and 4 deletions
|
@ -256,6 +256,7 @@ static gpointer read_input_thread(gpointer userdata) {
|
||||||
pd->async_queue = g_async_queue_new();
|
pd->async_queue = g_async_queue_new();
|
||||||
Block *block = NULL;
|
Block *block = NULL;
|
||||||
|
|
||||||
|
GTimer *tim = g_timer_new();
|
||||||
int fd = pd->fd;
|
int fd = pd->fd;
|
||||||
while (1) {
|
while (1) {
|
||||||
// Wait for input from the input or from the main thread.
|
// Wait for input from the input or from the main thread.
|
||||||
|
@ -295,10 +296,14 @@ static gpointer read_input_thread(gpointer userdata) {
|
||||||
memmove(&line[0], &line[i + 1], nread - (i + 1));
|
memmove(&line[0], &line[i + 1], nread - (i + 1));
|
||||||
nread -= (i + 1);
|
nread -= (i + 1);
|
||||||
i = 0;
|
i = 0;
|
||||||
if (block && block->length == BLOCK_LINES_SIZE) {
|
if (block) {
|
||||||
g_async_queue_push(pd->async_queue, block);
|
double elapsed = g_timer_elapsed(tim, NULL);
|
||||||
block = NULL;
|
if ( elapsed >= 0.1 || block->length == BLOCK_LINES_SIZE) {
|
||||||
write(pd->pipefd2[1], "r", 1);
|
g_timer_start(tim);
|
||||||
|
g_async_queue_push(pd->async_queue, block);
|
||||||
|
block = NULL;
|
||||||
|
write(pd->pipefd2[1], "r", 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
i++;
|
i++;
|
||||||
|
@ -311,6 +316,7 @@ static gpointer read_input_thread(gpointer userdata) {
|
||||||
read_add_block(pd, &block, line, nread);
|
read_add_block(pd, &block, line, nread);
|
||||||
}
|
}
|
||||||
if (block) {
|
if (block) {
|
||||||
|
g_timer_start(tim);
|
||||||
g_async_queue_push(pd->async_queue, block);
|
g_async_queue_push(pd->async_queue, block);
|
||||||
block = NULL;
|
block = NULL;
|
||||||
write(pd->pipefd2[1], "r", 1);
|
write(pd->pipefd2[1], "r", 1);
|
||||||
|
@ -326,12 +332,14 @@ static gpointer read_input_thread(gpointer userdata) {
|
||||||
nread = 0;
|
nread = 0;
|
||||||
}
|
}
|
||||||
if (block) {
|
if (block) {
|
||||||
|
g_timer_start(tim);
|
||||||
g_async_queue_push(pd->async_queue, block);
|
g_async_queue_push(pd->async_queue, block);
|
||||||
block = NULL;
|
block = NULL;
|
||||||
write(pd->pipefd2[1], "r", 1);
|
write(pd->pipefd2[1], "r", 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
g_timer_destroy(tim);
|
||||||
free(line);
|
free(line);
|
||||||
write(pd->pipefd2[1], "q", 1);
|
write(pd->pipefd2[1], "q", 1);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Reference in a new issue