clipboard: Hold mutex before dispatching any wayland events

The current code correctly guarded the case of Wayland events triggering changes whilst the application was using mimedata.

It didn't safely cover the case of what if wayland is using the thread whilst the application changes the available mimedata.

Putting the mutex in DataSource::send isn't safe as we also need to synchronise dispatching the event to the wl_proxy whilst the main thread deletes things.

The code was simplified to hold a mutex before any wayland event on this queue is dispatched. Unfortunately this simplification meant we couldn't use the helper wayland function to poll and dispatch events.

As we need to control the mutex from more places this is moved to a global.

BUG: 515465

Merge request reports

Loading