Remove selection requests on the keyboard buffer when closing display

* src/xterm.c (X_NEXT_KBD_EVENT): New macro.
(x_defer_selection_requests): Set input_pending if the kbd
buffer was modified.
(x_delete_selection_requests): New function.
(x_delete_display): Call that.  Bug found when a display died
while the clipboard manager was sending an unreasonably high
number of requests.
2 jobs for master in 174 minutes and 49 seconds (queued for 6 seconds)
Status Job ID Name Coverage
  Build Images
failed #47933
build-image-inotify

02:54:49

 
  Normal
skipped #47934
test-src-inotify
 
Name Stage Failure
failed
build-image-inotify Build Images
received unexpected HTTP status: 502 Bad Gateway
Running after_script
Running after script...
$ test -n "$(docker ps -aq -f name=${test_name})" && docker cp ${test_name}:checkout/test ${test_name}
$ test -n "$(docker ps -aq -f name=${test_name})" && docker rm ${test_name}
find: build-image-inotify-01834ba0: No such file or directory
$ find ${test_name} ! \( -name "*.log" -o -name ${EMACS_TEST_JUNIT_REPORT} \) -type f -delete
Cleaning up project directory and file based variables
ERROR: Job failed: exit code 1