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

@ -1646,7 +1646,9 @@ MESSAGE_TEST_TARGET = message_test$(EXEEXT)
UNITTEST_SRC = $(JSON_TEST_SRC) $(KWORD_TEST_SRC) $(MEMFILE_TEST_SRC) $(MESSAGE_TEST_SRC)
UNITTEST_TARGETS = $(JSON_TEST_TARGET) $(KWORD_TEST_TARGET) $(MEMFILE_TEST_TARGET) $(MESSAGE_TEST_TARGET)
RUN_UNITTESTS = run_json_test run_kword_test run_memfile_test run_message_test
# We need to put WAYLAND_SRC because the protocol files need to be generated
# else wayland.h will error
RUN_UNITTESTS = $(WAYLAND_SRC) run_json_test run_kword_test run_memfile_test run_message_test
# All sources, also the ones that are not configured
ALL_LOCAL_SRC = $(BASIC_SRC) $(ALL_GUI_SRC) $(UNITTEST_SRC) $(EXTRA_SRC) \
@ -3861,9 +3863,9 @@ objects/clientserver.o: clientserver.c vim.h protodef.h auto/config.h feature.h
ex_cmds.h spell.h proto.h globals.h errors.h
objects/clipboard.o: clipboard.c vim.h protodef.h auto/config.h feature.h \
os_unix.h auto/osdef.h ascii.h keymap.h termdefs.h macros.h option.h \
beval.h proto/gui_beval.pro structs.h regexp.h gui.h \
libvterm/include/vterm.h libvterm/include/vterm_keycodes.h alloc.h \
ex_cmds.h spell.h proto.h globals.h errors.h
beval.h structs.h regexp.h gui.h libvterm/include/vterm.h \
libvterm/include/vterm_keycodes.h xdiff/xdiff.h xdiff/../vim.h alloc.h \
ex_cmds.h spell.h proto.h globals.h errors.h wayland.h
objects/cmdexpand.o: cmdexpand.c vim.h protodef.h auto/config.h feature.h \
os_unix.h auto/osdef.h ascii.h keymap.h termdefs.h macros.h option.h \
beval.h proto/gui_beval.pro structs.h regexp.h gui.h \
@ -4564,7 +4566,7 @@ objects/wayland.o: wayland.c vim.h protodef.h auto/config.h feature.h os_unix.h
auto/osdef.h ascii.h keymap.h termdefs.h macros.h option.h beval.h \
structs.h regexp.h gui.h libvterm/include/vterm.h \
libvterm/include/vterm_keycodes.h xdiff/xdiff.h xdiff/../vim.h alloc.h \
ex_cmds.h spell.h proto.h globals.h errors.h \
ex_cmds.h spell.h proto.h globals.h errors.h wayland.h \
auto/wayland/wlr-data-control-unstable-v1.h \
auto/wayland/ext-data-control-v1.h auto/wayland/xdg-shell.h \
auto/wayland/primary-selection-unstable-v1.h