core: Add clipboard manager

This is a simple clipboard manager implementation on top of MetaSelection.
It will inspect the clipboard content for UTF-8 text and image data whenever
any other selection source claims ownership, and claim it for itself
whenever the clipboard goes unowned.

The stored text has a maximum size of 4MB and images 200MB, to prevent the
compositor from allocating indefinite amounts of memory.

This is not quite a X11 clipboard manager, but also works there.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/320
This commit is contained in:
Carlos Garnacho
2018-11-19 19:57:15 +01:00
parent 535ce00abb
commit 5c009c20ab
5 changed files with 206 additions and 0 deletions

View File

@ -57,6 +57,7 @@
#include "core/frame.h"
#include "core/keybindings-private.h"
#include "core/main-private.h"
#include "core/meta-clipboard-manager.h"
#include "core/meta-workspace-manager-private.h"
#include "core/util-private.h"
#include "core/window-private.h"
@ -725,6 +726,7 @@ meta_display_open (void)
display->bell = meta_bell_new (display);
display->selection = meta_selection_new (display);
meta_clipboard_manager_init (display);
if (meta_should_autostart_x11_display ())
{
@ -965,6 +967,8 @@ meta_display_close (MetaDisplay *display,
g_clear_object (&display->workspace_manager);
g_clear_object (&display->sound_player);
meta_clipboard_manager_shutdown (display);
g_object_unref (display);
the_display = NULL;