Commit 5502bbf
committed
Fixed native fullscreen rendering corruption bug
Fix the issue where MacVim would occasionally draws corrupted image in
fullscreen (it would draw mostly black).
The easiest way to reproduce this is as follows:
1. Make a new MacVim window, enter fullscreen
2. Open a new tab or hit Cmd-= a few times
3. Switch to another fullscreen app or desktop, click around, then
switch back
4. Observe most of the screen is black.
The reason this happens is that the MacVim resize code always tries to
resize the window to fit the content size (calculated from how many
lines / columns we have and whether other elements like tab bar are
visible). This means the resize code
(resizeWindowToFitContentSize:keepOnScreen:) would make the window
smaller than the full size of screen. For some reason, when you switch
away from the space, macOS decides to resize the window back to screen
size again, causing a window resize event to happen. The resize event
invalidates the NSView, causing it to draw black.
This is also why fullscreen mode has black bars on top / bottom, which
is especially jarring when font size is large of `linespace` is high.
The fix is to treat guioptions 'k' to be on when in full screen mode,
since the option means we will always try to fit the Vim content inside
the window, rather than resize the window to fit the Vim content. This
way the fullscreen Vim window will take up the whole screen and won't
keep getting resized. This is also more similar to how native Gvim works
when maximized.
Close #496 (black bars)
Close #557, close #674 (full screen rendering issues)
A related issue is that MacVim (without CGLayer backing) doesn't
actually know how to redraw itself properly when invalidated, which is
the root cause of this bug. It receives Vim draw calls incrementally and
doesn't actually cache the rendered content, so it relies on the fact
that MacVim's NSWindow doesn't usually invalidates all the content which
allows it to draw incrementally without needing to perform a full
redraw. This is why non-native fullscreen requires CGLayer backing mode
as macOS's behavior in this mode (basically a borderless window) is that
it does clear the NSWindow's content when setWantsDisplay: is called.
This is also why Vim live window resizing is limited to cell size
instead of allowing smooth resize (to avoid having to trigger redraws).
These are issues that should be fixed later.1 parent 324ff06 commit 5502bbf
1 file changed
Lines changed: 12 additions & 24 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
599 | 599 | | |
600 | 600 | | |
601 | 601 | | |
602 | | - | |
603 | | - | |
604 | | - | |
605 | | - | |
606 | | - | |
607 | 602 | | |
608 | 603 | | |
609 | 604 | | |
610 | 605 | | |
611 | | - | |
| 606 | + | |
612 | 607 | | |
613 | 608 | | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
614 | 615 | | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
615 | 619 | | |
616 | 620 | | |
617 | | - | |
618 | | - | |
619 | | - | |
620 | | - | |
621 | | - | |
622 | | - | |
623 | | - | |
624 | | - | |
625 | | - | |
626 | | - | |
627 | | - | |
628 | | - | |
629 | | - | |
630 | | - | |
631 | | - | |
632 | | - | |
633 | | - | |
634 | | - | |
| 621 | + | |
| 622 | + | |
635 | 623 | | |
636 | 624 | | |
637 | 625 | | |
| |||
0 commit comments