commit 32c6c75e8168395f4865f9d3a4531cc0e0716d66 from: Omar Polo date: Thu Jul 15 10:48:00 2021 UTC optimization: don't endwin() when we can simply move the windows After a resize we should do the endwin+refresh+clear dance, but in other situations, like when entering the minibuffer, we can simply re-wrap the page and move the windows. This prevents a small flash when entering the minibuffer, as well as fewer redraw (redraw after the command and shortly after because it was scheduled). commit - 4143ecfecad245316c5461b3e7afe523ccc99c50 commit + 32c6c75e8168395f4865f9d3a4531cc0e0716d66 blob - c6e0558f0d0d3c0f1d2071966bd248c87931242d blob + f08ff5e6e5c025561e9895bd3d4c36a0f2cc2ead --- ChangeLog +++ ChangeLog @@ -1,5 +1,7 @@ 2021-07-15 Omar Polo + * ui.c (rearrange_windows): don't flash the screen when entering the minibuffer + * fs.c (lock_session): use a lockfile to prevent multiple instance of telescope to run at the same time * defaults.c (load_default_keys): bind t to toc blob - 349d0667ece6ee7e363915b11c0dd12740745f4f blob + a8967f141b318cb77d7a1810d4f9997d5b4faac8 --- ui.c +++ ui.c @@ -56,6 +56,7 @@ static void dispatch_stdio(int, short, void*); static void handle_clear_echoarea(int, short, void*); static void handle_resize(int, short, void*); static void handle_resize_nodelay(int, short, void*); +static void rearrange_windows(void); static int wrap_page(struct buffer*, int); static void print_vline(int, int, WINDOW*, struct vline*); static void redraw_tabline(void); @@ -75,6 +76,7 @@ static void recompute_help(void); static void update_loading_anim(int, short, void*); static void stop_loading_anim(struct tab*); +static int should_rearrange_windows; static int too_small; static int x_offset; @@ -288,6 +290,8 @@ done: if (side_window) recompute_help(); + if (should_rearrange_windows) + rearrange_windows(); redraw_tab(current_tab()); } @@ -314,13 +318,21 @@ handle_resize(int sig, short ev, void *d) static void handle_resize_nodelay(int s, short ev, void *d) { - struct tab *tab; - int lines; - endwin(); refresh(); clear(); + + rearrange_windows(); +} + +static void +rearrange_windows(void) +{ + struct tab *tab; + int lines; + should_rearrange_windows = 0; + lines = LINES; if ((too_small = lines < 15)) { @@ -1221,23 +1233,18 @@ ui_toggle_side_window(void) /* * ugly hack, but otherwise the window doesn't get updated - * until I call handle_resize a second time (i.e. C-l). I - * will be happy to know why something like this is needed. + * until I call rearrange_windows a second time (e.g. via + * C-l). I will be happy to know why something like this is + * needed. */ - handle_resize_nodelay(0, 0, NULL); - handle_resize_nodelay(0, 0, NULL); + rearrange_windows(); + rearrange_windows(); } void ui_schedule_redraw(void) { - struct timeval tv = {0, 0}; - - if (event_pending(&resizeev, EV_TIMEOUT, NULL)) - event_del(&resizeev); - - evtimer_set(&resizeev, handle_resize_nodelay, NULL); - evtimer_add(&resizeev, &tv); + should_rearrange_windows = 1; } void