From 71b7f96668247646d18609e9893d5bcf10d5d306 Mon Sep 17 00:00:00 2001 From: Maxime Schmitt Date: Sat, 22 Aug 2020 16:47:23 +0100 Subject: [PATCH] Fix: initialize the correct ammount of plot location --- src/interface.c | 2 +- src/interface_layout_selection.c | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/interface.c b/src/interface.c index cdd15c7..56d393a 100644 --- a/src/interface.c +++ b/src/interface.c @@ -432,7 +432,7 @@ static void initialize_all_windows(struct nvtop_interface *dwin) { struct window_position *plot_positions = NULL; enum plot_type plot_type; - compute_sizes_from_layout(dwin->show_plot, true, true, dwin->num_devices, 2, + compute_sizes_from_layout(dwin->show_plot, true, true, num_devices, 2, 3, device_length(), rows - 1, cols, device_positions, &process_position, &dwin->num_plots, &plot_positions, &plot_type); diff --git a/src/interface_layout_selection.c b/src/interface_layout_selection.c index 76d2544..0cf4f0d 100644 --- a/src/interface_layout_selection.c +++ b/src/interface_layout_selection.c @@ -123,7 +123,7 @@ void compute_sizes_from_layout( rows_for_process += rows_left - 1; } if (num_plot_stacks > 0) { - // Allocate new plot stack is enough vertical room + // Allocate a new plot stack if there is enough vertical room while (num_plot_stacks < *num_plots && rows_left / (num_plot_stacks + 1) >= 11 && (num_plot_stacks + 1) * min_plot_rows <= rows_left) @@ -170,11 +170,16 @@ void compute_sizes_from_layout( unsigned rows_per_stack = rows_left / num_plot_stacks; if (rows_per_stack > 23) rows_per_stack = 23; - unsigned plot_per_row = (*num_plots + (*num_plots % num_plot_stacks)) / num_plot_stacks; + unsigned plot_per_row = *num_plots / num_plot_stacks; + unsigned stacks_with_extra_plot = *num_plots % num_plot_stacks; unsigned num_plot_done = 0; unsigned currentPosX = 0, currentPosY = rows_for_header; for (unsigned i = 0; i < num_plot_stacks; ++i) { unsigned plot_in_this_row = min(*num_plots - num_plot_done, plot_per_row); + if (stacks_with_extra_plot) { + plot_in_this_row++; + stacks_with_extra_plot--; + } unsigned cols_per_plot = cols / plot_in_this_row; if (*plot_types == plot_gpu_duo) cols_per_plot -= (cols_per_plot - cols_needed_box_drawing) %