patch 9.1.1725: Wayland code can be improved

Problem:  Wayland code can be improved
Solution: Refactor Wayland Clipboard code (Foxe Chen)

This refactor makes the Wayland codebase less convoluted:
- Move clipboard code in wayland.c to clipboard.c
- Use C99 bool type
- Properly poll the Wayland display file descriptor
- Instead of checking if the data source is not NULL in order to
  determine if a selection event comes from us, use a special mime type to
  identify selection events coming from ourselves. The problem with the
  previous approach is that race conditions may occur.
- Put the focus stealing code under a new feature "wayland_focus_steal"
- Use ELAPSED_* macros instead of gettimeofday()
- Pass tests
- Reimplement commented out code
- Update docs
- Make Wayland clipboard behaviour more in line with X11 when connection is lost
- add missing malloc checks and possible memory leaks + refactored some
  tests.

closes: #18139

Signed-off-by: Foxe Chen <chen.foxe@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Foxe Chen
2025-09-01 20:52:44 +02:00
committed by Christian Brabandt
parent 6a2d0496a1
commit f50504a87b
29 changed files with 2613 additions and 2684 deletions

View File

@ -1,7 +1,7 @@
" These commands create the option window.
"
" Maintainer: The Vim Project <https://github.com/vim/vim>
" Last Change: 2025 Aug 23
" Last Change: 2025 Sep 01
" Former Maintainer: Bram Moolenaar <Bram@vim.org>
" If there already is an option window, jump to that one.
@ -822,7 +822,7 @@ if has('wayland')
call <SID>AddOption("wlseat", gettext("Wayland seat to use"))
call <SID>OptionG("wse", &wse)
endif
if has("wayland_clipboard")
if has("wayland_focus_steal")
call <SID>AddOption("wlsteal", gettext("Enable wayland focus stealing functionality in order to access the clipboard"))
call <SID>BinOptionG("wst", &wst)
endif