mutter/src/x11
Carlos Garnacho 5671f0a284 x11: Allow X11 clients to clear the selection
According to the XSetSelectionOwner libX11 documentation:

  [...] If the owner window it has specified in the request is later
  destroyed, the owner of the selection automatically reverts to None,
  but the last-change time is not affected.

This is indeed visible through the selection_timestamp field in
XFixesSelectionNotify events.

Use this to check whether the selection time is recent-ish (thus
likely coming from an explicit XSetSelectionOwner request) and honor
the client intent by setting a "NULL" owner. If the selection time
is too old, it's definitely an indication of the owner client being
closed, the scenario where we do want the clipboard manager to take
over.

This fixes two usecases:
- X11 LibreOffice / WPS clear the selection each time before copying
  its own content. Mutter's clipboard manager would see each of those
  as a hint to take over, competing with the client over selection
  ownership. This would simply no longer happen
- Password managers may want to clear the selection, which would be
  frustrated by our clipboard manager.

There's a slight window of opportunity for the heuristics to fail
though, if a X11 client sets the selection and closes within 50ms, we
would miss the clipboard manager taking over.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1206
2020-04-21 21:32:53 +00:00
..
atomnames.h x11-display: add support for _GTK_WORKAREAS_Dn 2020-01-29 11:08:21 +00:00
events.c cogl: Install cogl-trace.h and include from cogl.h 2020-03-26 09:05:38 +01:00
events.h Clean up include macros mess 2018-11-06 17:17:36 +01:00
group-private.h Clean up include macros mess 2018-11-06 17:17:36 +01:00
group-props.c Clean up include macros mess 2018-11-06 17:17:36 +01:00
group-props.h Clean up include macros mess 2018-11-06 17:17:36 +01:00
group.c group: Free group if returning early 2020-04-12 21:40:20 +00:00
iconcache.c iconcache: Avoid xrender picture formats when creating cairo surface 2019-08-27 18:47:41 +03:00
iconcache.h Move X11 event, icon cache and property handling to MetaX11Display 2018-07-06 19:47:16 +02:00
meta-selection-source-x11-private.h Make MetaSelection, MetaSelectionSource and MetaMemorySelectionSource public 2019-05-02 16:31:45 +02:00
meta-selection-source-x11.c x11-selection: Plug potential GInputStream leak 2020-02-01 14:02:19 +00:00
meta-startup-notification-x11.c startup: Fix build with 'startup_notification=false' 2019-12-05 01:27:14 +00:00
meta-startup-notification-x11.h x11: Add method to launch applications, using SnLauncher 2019-01-18 17:03:57 +00:00
meta-x11-display-private.h x11/window-controls: Pass around MetaX11Display directly 2019-10-15 07:17:29 +00:00
meta-x11-display.c x11-display: add support for _GTK_WORKAREAS_Dn 2020-01-29 11:08:21 +00:00
meta-x11-errors.c Clean up include macros mess 2018-11-06 17:17:36 +01:00
meta-x11-selection-input-stream-private.h x11: Add X11 selection input/output streams 2019-05-02 15:40:13 +02:00
meta-x11-selection-input-stream.c x11: Detach selection streams on dispose 2019-10-21 11:47:40 +02:00
meta-x11-selection-output-stream-private.h x11: Add X11 selection input/output streams 2019-05-02 15:40:13 +02:00
meta-x11-selection-output-stream.c x11: Do not trust there is task in error paths 2020-04-16 16:26:04 +00:00
meta-x11-selection-private.h Make MetaSelection, MetaSelectionSource and MetaMemorySelectionSource public 2019-05-02 16:31:45 +02:00
meta-x11-selection.c x11: Allow X11 clients to clear the selection 2020-04-21 21:32:53 +00:00
meta-x11-stack-private.h x11: Add MetaX11Stack object 2019-05-24 15:30:31 +00:00
meta-x11-stack.c core: Move Stack to StackTracker synchronization back to stack.c 2019-08-26 17:39:10 +00:00
meta-x11-window-control.c x11/window-controls: Pass around MetaX11Display directly 2019-10-15 07:17:29 +00:00
meta-x11-window-control.h x11/window-controls: Pass around MetaX11Display directly 2019-10-15 07:17:29 +00:00
mutter-Xatomtype.h mutter-Xatomtype: Fix the sizes of these structs 2015-06-23 11:46:29 -07:00
session.c Add MetaGravity and replace X11 equivalent with it 2020-02-29 21:01:50 +00:00
session.h Add MetaGravity and replace X11 equivalent with it 2020-02-29 21:01:50 +00:00
window-props.c surface-actor-x11: Move window related unredirect logic to MetaWindowX11 2020-04-16 14:08:19 +02:00
window-props.h Clean up include macros mess 2018-11-06 17:17:36 +01:00
window-x11-private.h surface-actor-x11: Move window related unredirect logic to MetaWindowX11 2020-04-16 14:08:19 +02:00
window-x11.c surface-actor-x11: Move window related unredirect logic to MetaWindowX11 2020-04-16 14:08:19 +02:00
window-x11.h surface-actor-x11: Move window related unredirect logic to MetaWindowX11 2020-04-16 14:08:19 +02:00
xprops.c xprops: Use g_new0 instead of malloc in size_hints_from_results() 2019-10-03 17:20:54 +00:00
xprops.h Clean up include macros mess 2018-11-06 17:17:36 +01:00