Skip to content

fix: flickering on opaque popups for overlapping text#19534

Closed
JavierJF wants to merge 2 commits intovim:masterfrom
JavierJF:fix-19510
Closed

fix: flickering on opaque popups for overlapping text#19534
JavierJF wants to merge 2 commits intovim:masterfrom
JavierJF:fix-19510

Conversation

@JavierJF
Copy link
Contributor

Description

A flickering effect was introduced in commit 6c20307 for all popups. This is a consequence of a double redraw of the overlapping background characters. This could be expected for transparent popups, but, it should exclude opaque ones. For a complete fix of the flickering this commit is required in combination with fix present in 97c5bed.

Reproduction

Sourcing this simple script with background text (this can be the script itself) reproduces the issue:

" scroll_popup.vim
" Continuously scrolling popup with multi-line content

let s:text = []
for i in range(1, 50)
	call add(s:text, printf("This is scrolling line %02d — Vim popup demo", i))
endfor

let s:firstline = 1
let s:popup_id = -1

function! s:scroll_popup(timer) abort
	let s:firstline += 1

	" Wrap when reaching the end
	if s:firstline > len(s:text)
		let s:firstline = 1
	endif

	call popup_setoptions(s:popup_id, {'firstline': s:firstline})
	call popup_move(s:popup_id, { 'pos': 'botleft', 'line': s:firstline, 'col': 10 })
endfunction

function! StartScrollingPopup() abort
	let s:popup_id = popup_create(s:text, {
		\ 'title': 'Scrolling Popup',
		\ 'pos': 'botleft',
		\ 'minwidth': 60,
		\ 'minheight': 10,
		\ 'maxheight': 10,
		\ 'border': [],
		\ 'scrollbar': 1,
		\ 'opacity': 100,
	\ })

	call timer_start(1000, function('s:scroll_popup'), {'repeat': -1})
endfunction

call StartScrollingPopup()

This is a video of the issue being triggered:

2026_02_28-19_18_41-issue.mp4

And this is a video with the fix applied:

2026_02_28-19_19_33-fix.mp4

Questions

Maybe this is a question for the mailing list, in this case I would ask in that channel. I would like to know which was the rationale behind the transparency feature, right now it looks like popup rendering with transparencies must end in flickering, since the background and frontend double drawing will force it. Is this a known limitation that will be addressed or it's a side effect that was unexpected when the feature was introduced?

@mattn
Copy link
Member

mattn commented Mar 1, 2026

Please try #19536

@JavierJF
Copy link
Contributor Author

JavierJF commented Mar 1, 2026

Hi @mattn, I have tried your branch and it doesn't address the issue. Maybe I'm missing something, but to me it's clear that those changes can't fix the issue.

The issue is motivated by a double redrawn, as long as the double redraw takes place, a flicker might be seem. Unless this double redrawn is prevented, and the final character is drawn only once, this issue will continue to take place, for opaque or transparent popups (right now for both). This is why I have posted questions in the first comment on this PR, in case I was missing something, if I need to post those questions in the mailing list, please let me know! Thanks.

@habamax
Copy link
Contributor

habamax commented Mar 1, 2026

This PR fixes flickering for me:

Before:

vim-popups

After:

vim-popups2

@chrisbra
Copy link
Member

chrisbra commented Mar 2, 2026

There are a few compile errors. Can you please fix those? I am also not sure, why so many tests fail, so let's hope those were flaky

A flickering effect was introduced in commit 6c20307 for all popups.
This is a consequence of a double redraw of the overlapping background
characters. This could be expected for transparent popups, but, it
should exclude opaque ones. For a complete fix of the flickering this
commit is required in combination with fix present in 97c5bed.
This commit revert changes introduced for tests dumps for masks in
commits 6c20307 and cded5e2. These dumps were updated preventing
characters from popups to take into account the masks specified for
them. This forces the redraw of popup characters, even when masks
attempt to prevent them, leading to flickering effects. See issues 19510
and PR 19534.
@JavierJF
Copy link
Contributor Author

JavierJF commented Mar 3, 2026

Hi @chrisbra, I fixed the errors and also reverted some changes in some tests. Details are in 2bdcd69.

I think those changes need to be reverted, as they represent undesired behaviors for masks and popups with opacity. For Test_popupwin_popupmenu_masking_1.dump, as a result of the previous changes, the popup with the least z-index was being drawn on top of the other popups that were supposed to occlude it.

For popups with transparencies, this might be desired if flickering is addressed, but for opaque popups I think it's just undesired behavior. You let me know if the PR needs more changes, thanks!

@chrisbra
Copy link
Member

chrisbra commented Mar 3, 2026

Thanks!

@chrisbra chrisbra closed this in 2a74145 Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants