[gnome-settings-daemon/wip/carlosg/x11-clipboard-for-screenshots] media-keys: Use X11 display for clipboard



commit e1fc4599764c9b10e086317164267c78f9338883
Author: Carlos Garnacho <carlosg gnome org>
Date:   Wed Nov 6 14:15:41 2019 +0100

    media-keys: Use X11 display for clipboard
    
    This daemon does not specify to be X11, and arguably "make it able
    to save to clipboard" is hardly a reason. Make it use a X11 display
    specifically for saving screenshots to clipboard, as it's got at
    least some guarantees of working there.
    
    Related: https://gitlab.gnome.org/GNOME/mutter/issues/789

 NEWS                                      | 10 ++++++++++
 plugins/media-keys/gsd-screenshot-utils.c |  6 ++++--
 2 files changed, 14 insertions(+), 2 deletions(-)
---
diff --git a/NEWS b/NEWS
index 94643503..fb47a5ed 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,13 @@
+==============
+Version 3.34.2
+==============
+Media-keys:
+- Fixed saving screenshots to clipboard on wayland.
+  For 3.34, this feature was fixed by using the X11 clipboard,
+  saving to clipboard will indefinitely raise Xwayland
+  if the Xwayland-on-demand experimental feature was enabled,
+  and will not work at all if --no-x11 is passed to gnome-shell.
+
 ==============
 Version 3.34.1
 ==============
diff --git a/plugins/media-keys/gsd-screenshot-utils.c b/plugins/media-keys/gsd-screenshot-utils.c
index 45f91096..2950ef2d 100644
--- a/plugins/media-keys/gsd-screenshot-utils.c
+++ b/plugins/media-keys/gsd-screenshot-utils.c
@@ -97,6 +97,7 @@ screenshot_save_to_recent (ScreenshotContext *ctx)
 static void
 screenshot_save_to_clipboard (ScreenshotContext *ctx)
 {
+  static GdkDisplay *x11_display = NULL;
   GdkPixbuf *screenshot;
   GtkClipboard *clipboard;
   GError *error = NULL;
@@ -111,8 +112,9 @@ screenshot_save_to_clipboard (ScreenshotContext *ctx)
     }
 
   screenshot_play_sound_effect ("screen-capture", _("Screenshot taken"));
-  clipboard = gtk_clipboard_get_for_display (gdk_display_get_default (),
-                                             GDK_SELECTION_CLIPBOARD);
+  if (!x11_display)
+    x11_display = gdk_display_open (g_getenv ("DISPLAY"));
+  clipboard = gtk_clipboard_get_for_display (x11_display, GDK_SELECTION_CLIPBOARD);
   gtk_clipboard_set_image (clipboard, screenshot);
 
   /* remove the temporary file created by the shell */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]