1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-18 13:54:36 -05:00

[listview] Don't calculate infinite rows on empty height.

Issue: #1769
This commit is contained in:
Dave Davenport 2022-12-29 18:41:51 +01:00
parent 34810e72be
commit d47b1515b5
3 changed files with 7 additions and 16 deletions

View file

@ -232,13 +232,6 @@ void listview_set_scroll_type(listview *lv, ScrollType type);
void listview_set_mouse_activated_cb(listview *lv, void listview_set_mouse_activated_cb(listview *lv,
listview_mouse_activated_cb cb, listview_mouse_activated_cb cb,
void *udata); 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. * @param lv Handler to the listview object.

View file

@ -2166,9 +2166,6 @@ static void rofi_view_add_widget(RofiViewState *state, widget *parent_widget,
listview_set_mouse_activated_cb( listview_set_mouse_activated_cb(
state->list_view, rofi_view_listview_mouse_activated_cb, state); 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); listview_set_max_lines(state->list_view, state->num_lines);
} }
/** /**

View file

@ -607,7 +607,11 @@ static void listview_resize(widget *wid, short w, short h) {
lv->widget.h = MAX(0, h); lv->widget.h = MAX(0, h);
int height = lv->widget.h - widget_padding_get_padding_height(WIDGET(lv)); int height = lv->widget.h - widget_padding_get_padding_height(WIDGET(lv));
int spacing_vert = distance_get_pixel(lv->spacing, ROFI_ORIENTATION_VERTICAL); 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; lv->max_elements = lv->max_rows * lv->menu_columns;
widget_move(WIDGET(lv->scrollbar), 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->spacing = rofi_theme_get_distance(WIDGET(lv), "spacing", DEFAULT_SPACING);
lv->menu_columns = lv->menu_columns =
rofi_theme_get_integer(WIDGET(lv), "columns", DEFAULT_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", lv->fixed_num_lines = rofi_theme_get_boolean(WIDGET(lv), "fixed-height",
config.fixed_num_lines); config.fixed_num_lines);
lv->dynamic = rofi_theme_get_boolean(WIDGET(lv), "dynamic", TRUE); 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; 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) { void listview_set_max_lines(listview *lv, unsigned int max_lines) {
if (lv) { if (lv) {