commit 40236d7667cfdc2a4107c514b64f7f7bf6490f45 from: Omar Polo via: Thomas Adam date: Thu Jun 23 14:09:35 2022 UTC tog: resize main view drawing the child view on top of the main view when the layout is split-screen can produce some ugly glitches when double-width characters are involved. (issue found by stsp) ok stsp@ commit - 8d208d3487a42414bcbbd542d3caca89e442fb33 commit + 40236d7667cfdc2a4107c514b64f7f7bf6490f45 blob - cc1da9ade2720147f1f3088d366efaa7c236844c blob + 0525191d4d4ecef715236ddc4272f0c434b2f474 --- tog/tog.c +++ tog/tog.c @@ -769,32 +769,37 @@ view_resize(struct tog_view *view) ncols = view->ncols - (view->cols - COLS); else ncols = view->ncols + (COLS - view->cols); - - if (wresize(view->window, nlines, ncols) == ERR) - return got_error_from_errno("wresize"); - if (replace_panel(view->panel, view->window) == ERR) - return got_error_from_errno("replace_panel"); - wclear(view->window); - - view->nlines = nlines; - view->ncols = ncols; - view->lines = LINES; - view->cols = COLS; if (view->child) { view->child->begin_x = view_split_begin_x(view->begin_x); if (view->child->begin_x == 0) { + ncols = COLS; + view_fullscreen(view->child); if (view->child->focussed) show_panel(view->child->panel); else show_panel(view->panel); } else { + ncols = view->child->begin_x; + view_splitscreen(view->child); show_panel(view->child->panel); } - } + } else if (view->parent == NULL) + ncols = COLS; + if (wresize(view->window, nlines, ncols) == ERR) + return got_error_from_errno("wresize"); + if (replace_panel(view->panel, view->window) == ERR) + return got_error_from_errno("replace_panel"); + wclear(view->window); + + view->nlines = nlines; + view->ncols = ncols; + view->lines = LINES; + view->cols = COLS; + return NULL; } @@ -811,11 +816,13 @@ view_close_child(struct tog_view *view) return err; } -static void +static const struct got_error * view_set_child(struct tog_view *view, struct tog_view *child) { view->child = child; child->parent = view; + + return view_resize(view); } static int @@ -1092,6 +1099,10 @@ view_loop(struct tog_view *view) if (view->parent) { view->parent->child = NULL; view->parent->focus_child = 0; + + err = view_resize(view->parent); + if (err) + break; } else TAILQ_REMOVE(&views, view, entry); @@ -2706,7 +2717,9 @@ input_log_view(struct tog_view **new_view, struct tog_ err = view_close_child(view); if (err) return err; - view_set_child(view, diff_view); + err = view_set_child(view, diff_view); + if (err) + return err; view->focus_child = 1; } else *new_view = diff_view; @@ -2727,7 +2740,9 @@ input_log_view(struct tog_view **new_view, struct tog_ err = view_close_child(view); if (err) return err; - view_set_child(view, tree_view); + err = view_set_child(view, tree_view); + if (err) + return err; view->focus_child = 1; } else *new_view = tree_view; @@ -2811,7 +2826,9 @@ input_log_view(struct tog_view **new_view, struct tog_ err = view_close_child(view); if (err) return err; - view_set_child(view, ref_view); + err = view_set_child(view, ref_view); + if (err) + return err; view->focus_child = 1; } else *new_view = ref_view; @@ -5112,7 +5129,9 @@ input_blame_view(struct tog_view **new_view, struct to err = view_close_child(view); if (err) break; - view_set_child(view, diff_view); + err = view_set_child(view, diff_view); + if (err) + break; view->focus_child = 1; } else *new_view = diff_view; @@ -5856,7 +5875,9 @@ input_tree_view(struct tog_view **new_view, struct tog err = view_close_child(view); if (err) return err; - view_set_child(view, log_view); + err = view_set_child(view, log_view); + if (err) + return err; view->focus_child = 1; } else *new_view = log_view; @@ -5879,7 +5900,9 @@ input_tree_view(struct tog_view **new_view, struct tog err = view_close_child(view); if (err) return err; - view_set_child(view, ref_view); + err = view_set_child(view, ref_view); + if (err) + return err; view->focus_child = 1; } else *new_view = ref_view; @@ -6013,7 +6036,9 @@ input_tree_view(struct tog_view **new_view, struct tog err = view_close_child(view); if (err) return err; - view_set_child(view, blame_view); + err = view_set_child(view, blame_view); + if (err) + return err; view->focus_child = 1; } else *new_view = blame_view; @@ -6739,7 +6764,9 @@ input_ref_view(struct tog_view **new_view, struct tog_ err = view_close_child(view); if (err) return err; - view_set_child(view, log_view); + err = view_set_child(view, log_view); + if (err) + return err; view->focus_child = 1; } else *new_view = log_view; @@ -6759,7 +6786,9 @@ input_ref_view(struct tog_view **new_view, struct tog_ err = view_close_child(view); if (err) return err; - view_set_child(view, tree_view); + err = view_set_child(view, tree_view); + if (err) + return err; view->focus_child = 1; } else *new_view = tree_view;