summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2022-12-29 18:41:51 +0100
committerDave Davenport <qball@gmpclient.org>2022-12-29 18:41:51 +0100
commitd47b1515b5d189f7e080ffe00a62651308b65741 (patch)
tree1d5a769e542a23502e076800eafa4cbc59698365
parent34810e72be9dff6f73a2ad68ad53266f718ba934 (diff)
[listview] Don't calculate infinite rows on empty height.
Issue: #1769
-rw-r--r--include/widgets/listview.h7
-rw-r--r--source/view.c3
-rw-r--r--source/widgets/listview.c13
3 files changed, 7 insertions, 16 deletions
diff --git a/include/widgets/listview.h b/include/widgets/listview.h
index 461c784f..29211838 100644
--- a/include/widgets/listview.h
+++ b/include/widgets/listview.h
@@ -232,13 +232,6 @@ void listview_set_scroll_type(listview *lv, ScrollType type);
void listview_set_mouse_activated_cb(listview *lv,
listview_mouse_activated_cb cb,
void *udata);
-/**
- * @param lv Handler to the listview object.
- * @param num_lines the maximum number of lines to display.
- *
- * Set the maximum number of lines to display.
- */
-void listview_set_num_lines(listview *lv, unsigned int num_lines);
/**
* @param lv Handler to the listview object.
diff --git a/source/view.c b/source/view.c
index 331b7852..fecd48e0 100644
--- a/source/view.c
+++ b/source/view.c
@@ -2166,9 +2166,6 @@ static void rofi_view_add_widget(RofiViewState *state, widget *parent_widget,
listview_set_mouse_activated_cb(
state->list_view, rofi_view_listview_mouse_activated_cb, state);
- int lines = rofi_theme_get_integer(WIDGET(state->list_view), "lines",
- DEFAULT_MENU_LINES);
- listview_set_num_lines(state->list_view, lines);
listview_set_max_lines(state->list_view, state->num_lines);
}
/**
diff --git a/source/widgets/listview.c b/source/widgets/listview.c
index 79e81893..02b6d109 100644
--- a/source/widgets/listview.c
+++ b/source/widgets/listview.c
@@ -607,7 +607,11 @@ static void listview_resize(widget *wid, short w, short h) {
lv->widget.h = MAX(0, h);
int height = lv->widget.h - widget_padding_get_padding_height(WIDGET(lv));
int spacing_vert = distance_get_pixel(lv->spacing, ROFI_ORIENTATION_VERTICAL);
- lv->max_rows = (spacing_vert + height) / (lv->element_height + spacing_vert);
+ if ( lv->widget.h == 0 ) {
+ lv->max_rows = lv->menu_lines;
+ } else {
+ lv->max_rows = (spacing_vert + height) / (lv->element_height + spacing_vert);
+ }
lv->max_elements = lv->max_rows * lv->menu_columns;
widget_move(WIDGET(lv->scrollbar),
@@ -758,6 +762,8 @@ listview *listview_create(widget *parent, const char *name,
lv->spacing = rofi_theme_get_distance(WIDGET(lv), "spacing", DEFAULT_SPACING);
lv->menu_columns =
rofi_theme_get_integer(WIDGET(lv), "columns", DEFAULT_MENU_COLUMNS);
+ lv->menu_lines =
+ rofi_theme_get_integer(WIDGET(lv), "lines", DEFAULT_MENU_LINES);
lv->fixed_num_lines = rofi_theme_get_boolean(WIDGET(lv), "fixed-height",
config.fixed_num_lines);
lv->dynamic = rofi_theme_get_boolean(WIDGET(lv), "dynamic", TRUE);
@@ -1080,11 +1086,6 @@ void listview_set_mouse_activated_cb(listview *lv,
lv->mouse_activated_data = udata;
}
}
-void listview_set_num_lines(listview *lv, unsigned int num_lines) {
- if (lv) {
- lv->menu_lines = num_lines;
- }
-}
void listview_set_max_lines(listview *lv, unsigned int max_lines) {
if (lv) {