From: Mark Jamsek Subject: fix cycle view in fullscreen regression To: gameoftrees@openbsd.org Date: Mon, 20 Jun 2022 00:07:23 +1000 When in a child diff view in splitscreen, if you toggle fullscreen and then cycle back to the log view with tab, the log view opens in splitscreen with the diff view still visible and no border line. repro: $ tog return f tab # log view opens in a split instead of fullscreen What used to happen is we would cycle to the log view in fullscreen. The below patch appears to fix this while keeping the hscroll fix in splitscreen when drawing double-width chars (tested in the ja.git repo). This happens because we now resize views _after_ resetting nlines and ncols based on the child start column in splitscreen, which sets the parent view->ncols to the child view's splitscreen start column. The fix checks if the current view is not in a split when cycling views and, if not, resets fullscreen dimensions, then bypasses resetting these dimensions when resizing. diff d8b5af438b16bcea5568b1d4bfc127567e35e2f6 /home/mark/src/git/got-current blob - b8935d8f4d93a4f03c1d8727adb23a6137741acf file + tog/tog.c --- tog/tog.c +++ tog/tog.c @@ -698,7 +698,7 @@ view_split_begin_x(int begin_x) return (COLS - MAX(COLS / 2, 80)); } -static const struct got_error *view_resize(struct tog_view *); +static const struct got_error *view_resize(struct tog_view *, int); static const struct got_error * view_splitscreen(struct tog_view *view) @@ -711,7 +711,7 @@ view_splitscreen(struct tog_view *view) view->ncols = COLS - view->begin_x; view->lines = LINES; view->cols = COLS; - err = view_resize(view); + err = view_resize(view, 0); if (err) return err; @@ -732,7 +732,7 @@ view_fullscreen(struct tog_view *view) view->ncols = COLS; view->lines = LINES; view->cols = COLS; - err = view_resize(view); + err = view_resize(view, 1); if (err) return err; @@ -749,7 +749,7 @@ view_is_parent_view(struct tog_view *view) } static const struct got_error * -view_resize(struct tog_view *view) +view_resize(struct tog_view *view, int fullscreen) { int nlines, ncols; @@ -763,7 +763,7 @@ view_resize(struct tog_view *view) else ncols = view->ncols + (COLS - view->cols); - if (view->child) { + if (view->child && !fullscreen) { view->child->begin_x = view_split_begin_x(view->begin_x); if (view->child->begin_x == 0) { ncols = COLS; @@ -815,7 +815,7 @@ view_set_child(struct tog_view *view, struct tog_view view->child = child; child->parent = view; - return view_resize(view); + return view_resize(view, 0); } static int @@ -928,14 +928,14 @@ view_input(struct tog_view **new, int *done, struct to tog_sigwinch_received = 0; tog_sigcont_received = 0; TAILQ_FOREACH(v, views, entry) { - err = view_resize(v); + err = view_resize(v, 0); if (err) return err; err = v->input(new, v, KEY_RESIZE); if (err) return err; if (v->child) { - err = view_resize(v->child); + err = view_resize(v->child, 0); if (err) return err; err = v->child->input(new, v->child, @@ -956,6 +956,8 @@ view_input(struct tog_view **new, int *done, struct to view->focussed = 0; view->parent->focussed = 1; view->parent->focus_child = 0; + if (!view_is_splitscreen(view)) + err = view_fullscreen(view->parent); } break; case 'q': @@ -1093,7 +1095,7 @@ view_loop(struct tog_view *view) view->parent->child = NULL; view->parent->focus_child = 0; - err = view_resize(view->parent); + err = view_resize(view->parent, 0); if (err) break; } else -- Mark Jamsek GPG: F2FF 13DE 6A06 C471 CA80 E6E2 2930 DC66 86EE CF68