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



commit 274b351e61521dbe61519b7a874d545872ad20ab
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

 plugins/media-keys/gsd-screenshot-utils.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/plugins/media-keys/gsd-screenshot-utils.c b/plugins/media-keys/gsd-screenshot-utils.c
index 45f91096..90dbfabb 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,8 @@ 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);
+  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]