You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reduce flicker when changing fonts/adding tabs in go+=k/fullscreen
MacVim would previously show a quick flicker when adjusting font (e.g.
Cmd =/-) or showing/hiding tabs/scroll bar when in fixed window size
mode (guioptions+=k or full screen). This was because after the state
change, Vim requests a resize asynchronously to the GUI to fit it in the
window. MacVim does so after changing the font/showing the tab, leading
to a momentary incorrect result before Vim then redraws the resized
grid. In normal GVim this is not an issue because Vim requests the
resize synchronously in a single-process environment, and we would like
to avoid that as the message passing between Vim/MacVim and designed to
be mostly non-blocking.
To fix this, after receiving the Vim resize request, we block all
further text rendering commands, until Vim has resized / redrawn,
preventing the short period of time where text view is drawing the old
state using the new font. For tabs / scroll bars, the text view itself
has moved after the new layout, so we temporarily apply a render offset
to make the text view pretend it didn't move and looks mostly the same
to the user while we wait for Vim to redraw with the updated grid.
There are some potential ways to still see flicker, but they are mostly
edge cases:
- When changing fonts, if Vim is slow and the user gets MacVim to
re-draw the text view (e.g. dragging the window to resize) while we
wait for Vim to resize, it would still draw an incorrect result (since
it has the new font, but old text grid). This should realistically
only happen if Vim takes an abnormal amount of time to respond.
- For tabs / scrollbars we have a similar issue. We immediately
place/remove them while we wait for Vim to resize, which could cause a
small visual discontinuity (easiest way is to toggle `go+=e`). From
testing, having the tab bar / etc immediately show up and hide feels
better as the user feels like something has happened, so keeping the
responsiveness is more important than delaying showing/hiding the tab
bar for visual stability (not to mention the deferral is more
complicated to implement).
If Vim takes a long time to resize/redraw, this change could make font
size change *feel* less responsive because nothing happens on the screen
until the fully redrawn screen is shown. This is ok, and if Vim takes so
long to resize then that's the actual issue to address.
This change also removes unnecessary code:
- Excessive and unnecessary redraws when showing/hiding tabs and setting
fonts. They were written a long time ago as temporary hacks which
survived till now. From testing this makes changing font size and
showing/hiding tabs feel a fair bit more responsive because Vim isn't
trying to redraw over and over again now.
- Stale "maximize" code that has long been unused. It was trying to solve
a similar issue but long obsolete and disabled.
@property (nonatomic) NSSize drawRectOffset; ///< A render offset to apply to the draw rects. This is currently only used in specific situations when rendering is blocked.
0 commit comments