diff options
author | Carlos Garnacho <carlosg@gnome.org> | 2019-11-06 13:19:31 +0100 |
---|---|---|
committer | Carlos Garnacho <carlosg@gnome.org> | 2019-11-06 23:50:55 +0100 |
commit | 41a84e315d865bff16fb45717d1ef0ee23c65f25 (patch) | |
tree | be99a1ab94a00ab1ae812d9dce8019b59e09c261 | |
parent | 2535cde979baa18d4e0569eeee9de9415cde51d0 (diff) | |
download | gnome-settings-daemon-41a84e315d865bff16fb45717d1ef0ee23c65f25.tar.gz |
media-keys: Let the screenshot service save to clipboard itself
This is both broken currently on wayland (since this daemon doesn't
request the x11 backend, and wayland clients need a proper surface/serial
to request clipboard), and conceptually wrong (we wouldn't like to
enable the X11 backend just to let it save to clipboard).
Let gnome-shell handle saving the screenshot to clipboard instead, this
also saves us from saving to /tmp just to copy it to the clipboard
afterwards. We achieve this by passing an empty string as the filename.
Related: https://gitlab.gnome.org/GNOME/mutter/issues/789
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/810
-rw-r--r-- | plugins/media-keys/gsd-screenshot-utils.c | 34 |
1 files changed, 2 insertions, 32 deletions
diff --git a/plugins/media-keys/gsd-screenshot-utils.c b/plugins/media-keys/gsd-screenshot-utils.c index 45f91096..9494f97c 100644 --- a/plugins/media-keys/gsd-screenshot-utils.c +++ b/plugins/media-keys/gsd-screenshot-utils.c @@ -95,32 +95,6 @@ screenshot_save_to_recent (ScreenshotContext *ctx) } static void -screenshot_save_to_clipboard (ScreenshotContext *ctx) -{ - GdkPixbuf *screenshot; - GtkClipboard *clipboard; - GError *error = NULL; - - screenshot = gdk_pixbuf_new_from_file (ctx->used_filename, &error); - if (error != NULL) - { - screenshot_play_error_sound_effect (); - g_warning ("Failed to save a screenshot to clipboard: %s\n", error->message); - g_error_free (error); - return; - } - - screenshot_play_sound_effect ("screen-capture", _("Screenshot taken")); - clipboard = gtk_clipboard_get_for_display (gdk_display_get_default (), - GDK_SELECTION_CLIPBOARD); - gtk_clipboard_set_image (clipboard, screenshot); - - /* remove the temporary file created by the shell */ - g_unlink (ctx->used_filename); - g_object_unref (screenshot); -} - -static void bus_call_ready_cb (GObject *source, GAsyncResult *res, gpointer user_data) @@ -146,11 +120,7 @@ bus_call_ready_cb (GObject *source, if (success) { - if (ctx->copy_to_clipboard) - { - screenshot_save_to_clipboard (ctx); - } - else + if (!ctx->copy_to_clipboard) { screenshot_play_sound_effect ("screen-capture", _("Screenshot taken")); screenshot_save_to_recent (ctx); @@ -313,7 +283,7 @@ static void screenshot_check_name_ready (ScreenshotContext *ctx) { if (ctx->copy_to_clipboard) - ctx->save_filename = screenshot_build_tmp_path (); + ctx->save_filename = g_strdup (""); else ctx->save_filename = screenshot_build_filename (); |