mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-25 13:55:34 -05:00
[View] Change refilter timeout limit to be in time units (ms)
Issue: #1683
This commit is contained in:
parent
d5cd4ca32d
commit
f3c1dafec2
5 changed files with 38 additions and 11 deletions
|
@ -154,8 +154,8 @@ Settings config = {
|
||||||
.steal_focus = FALSE,
|
.steal_focus = FALSE,
|
||||||
/** fallback icon */
|
/** fallback icon */
|
||||||
.application_fallback_icon = NULL,
|
.application_fallback_icon = NULL,
|
||||||
/** refilter limit */
|
/** refilter limit in ms*/
|
||||||
.refilter_timeout_limit = 4 * 8192,
|
.refilter_timeout_limit = 300,
|
||||||
/** workaround for broken xserver (#300 on xserver, #611) */
|
/** workaround for broken xserver (#300 on xserver, #611) */
|
||||||
.xserver_i300_workaround = FALSE,
|
.xserver_i300_workaround = FALSE,
|
||||||
};
|
};
|
||||||
|
|
|
@ -456,10 +456,10 @@ Make rofi steal focus on launch and restore close to window that held it when la
|
||||||
\fB\fC-refilter-timeout-limit\fR
|
\fB\fC-refilter-timeout-limit\fR
|
||||||
|
|
||||||
.PP
|
.PP
|
||||||
The limit of elements that is used to switch from instant to delayed filter mode.
|
The time (in ms) boundary filter may take before switch from instant to delayed filter mode.
|
||||||
|
|
||||||
.PP
|
.PP
|
||||||
Default: 8192
|
Default: 300
|
||||||
|
|
||||||
.PP
|
.PP
|
||||||
A fallback icon can be specified for each mode:
|
A fallback icon can be specified for each mode:
|
||||||
|
|
|
@ -275,9 +275,9 @@ Make rofi steal focus on launch and restore close to window that held it when la
|
||||||
|
|
||||||
`-refilter-timeout-limit`
|
`-refilter-timeout-limit`
|
||||||
|
|
||||||
The limit of elements that is used to switch from instant to delayed filter mode.
|
The time (in ms) boundary filter may take before switch from instant to delayed filter mode.
|
||||||
|
|
||||||
Default: 8192
|
Default: 300
|
||||||
|
|
||||||
A fallback icon can be specified for each mode:
|
A fallback icon can be specified for each mode:
|
||||||
|
|
||||||
|
|
|
@ -114,6 +114,9 @@ struct {
|
||||||
/** timeout for reloading */
|
/** timeout for reloading */
|
||||||
guint refilter_timeout;
|
guint refilter_timeout;
|
||||||
guint refilter_timeout_count;
|
guint refilter_timeout_count;
|
||||||
|
|
||||||
|
double max_refilter_time;
|
||||||
|
gboolean delayed_mode;
|
||||||
/** timeout handling */
|
/** timeout handling */
|
||||||
guint user_timeout;
|
guint user_timeout;
|
||||||
/** debug counter for redraws */
|
/** debug counter for redraws */
|
||||||
|
@ -135,6 +138,8 @@ struct {
|
||||||
.idle_timeout = 0,
|
.idle_timeout = 0,
|
||||||
.refilter_timeout = 0,
|
.refilter_timeout = 0,
|
||||||
.refilter_timeout_count = 0,
|
.refilter_timeout_count = 0,
|
||||||
|
.max_refilter_time = 0.0,
|
||||||
|
.delayed_mode = FALSE,
|
||||||
.user_timeout = 0,
|
.user_timeout = 0,
|
||||||
.count = 0L,
|
.count = 0L,
|
||||||
.repaint_source = 0,
|
.repaint_source = 0,
|
||||||
|
@ -1167,6 +1172,7 @@ static gboolean rofi_view_refilter_real(RofiViewState *state) {
|
||||||
if (state->sw == NULL) {
|
if (state->sw == NULL) {
|
||||||
return G_SOURCE_REMOVE;
|
return G_SOURCE_REMOVE;
|
||||||
}
|
}
|
||||||
|
GTimer *timer = g_timer_new();
|
||||||
TICK_N("Filter start");
|
TICK_N("Filter start");
|
||||||
if (state->reload) {
|
if (state->reload) {
|
||||||
_rofi_view_reload_row(state);
|
_rofi_view_reload_row(state);
|
||||||
|
@ -1287,6 +1293,12 @@ static gboolean rofi_view_refilter_real(RofiViewState *state) {
|
||||||
state->refilter = FALSE;
|
state->refilter = FALSE;
|
||||||
TICK_N("Filter done");
|
TICK_N("Filter done");
|
||||||
rofi_view_update(state, TRUE);
|
rofi_view_update(state, TRUE);
|
||||||
|
|
||||||
|
double elapsed = g_timer_elapsed(timer, NULL);
|
||||||
|
if (elapsed > CacheState.max_refilter_time) {
|
||||||
|
CacheState.max_refilter_time = elapsed;
|
||||||
|
}
|
||||||
|
g_timer_destroy(timer);
|
||||||
return G_SOURCE_REMOVE;
|
return G_SOURCE_REMOVE;
|
||||||
}
|
}
|
||||||
static void rofi_view_refilter(RofiViewState *state) {
|
static void rofi_view_refilter(RofiViewState *state) {
|
||||||
|
@ -1296,12 +1308,27 @@ static void rofi_view_refilter(RofiViewState *state) {
|
||||||
g_source_remove(CacheState.refilter_timeout);
|
g_source_remove(CacheState.refilter_timeout);
|
||||||
CacheState.refilter_timeout = 0;
|
CacheState.refilter_timeout = 0;
|
||||||
}
|
}
|
||||||
if (state->num_lines > config.refilter_timeout_limit &&
|
if (CacheState.max_refilter_time >
|
||||||
CacheState.refilter_timeout_count < 25 && state->text &&
|
(config.refilter_timeout_limit / 1000.0f) &&
|
||||||
strlen(state->text->text) > 0) {
|
state->text && strlen(state->text->text) > 0 &&
|
||||||
|
CacheState.refilter_timeout_count < 25) {
|
||||||
|
if (CacheState.delayed_mode == FALSE) {
|
||||||
|
g_warning(
|
||||||
|
"Filtering took %f seconds ( 0.3), switching to delayed filter\n",
|
||||||
|
CacheState.max_refilter_time);
|
||||||
|
CacheState.delayed_mode = TRUE;
|
||||||
|
}
|
||||||
CacheState.refilter_timeout =
|
CacheState.refilter_timeout =
|
||||||
g_timeout_add(200, (GSourceFunc)rofi_view_refilter_real, state);
|
g_timeout_add(200, (GSourceFunc)rofi_view_refilter_real, state);
|
||||||
} else {
|
} else {
|
||||||
|
if (CacheState.delayed_mode == TRUE && state->text &&
|
||||||
|
strlen(state->text->text) > 0 &&
|
||||||
|
CacheState.refilter_timeout_count < 25) {
|
||||||
|
g_warning(
|
||||||
|
"Filtering took %f seconds , switching back to instant filter\n",
|
||||||
|
CacheState.max_refilter_time);
|
||||||
|
CacheState.delayed_mode = FALSE;
|
||||||
|
}
|
||||||
rofi_view_refilter_real(state);
|
rofi_view_refilter_real(state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -430,8 +430,8 @@ static XrmOption xrmOptions[] = {
|
||||||
"refilter-timeout-limit",
|
"refilter-timeout-limit",
|
||||||
{.num = &(config.refilter_timeout_limit)},
|
{.num = &(config.refilter_timeout_limit)},
|
||||||
NULL,
|
NULL,
|
||||||
"When there are more entries then this limit, only refilter after a "
|
"When filtering takes more then this time (in ms) switch to delayed "
|
||||||
"timeout.",
|
"filter.",
|
||||||
CONFIG_DEFAULT},
|
CONFIG_DEFAULT},
|
||||||
{xrm_Boolean,
|
{xrm_Boolean,
|
||||||
"xserver-i300-workaround",
|
"xserver-i300-workaround",
|
||||||
|
|
Loading…
Reference in a new issue