diff options
author | Christian Persch <chpe@src.gnome.org> | 2021-02-21 16:15:40 +0100 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2021-02-21 16:15:40 +0100 |
commit | 98c044a5698cd814fc43465b91d3962267472961 (patch) | |
tree | 08a4f54f0c01d7ceee28bf105c8496770eb18c83 | |
parent | 072fcfc5579986dbe4ed705ccd0bee05274567b3 (diff) | |
download | vte-98c044a5698cd814fc43465b91d3962267472961.tar.gz |
app: Add debug option to track clipboard targets
Trying to help track down the clipboard issue in mutter#1469 /
gnome-shell#3052 / mutter#1656.
(cherry picked from commit 94966f638af6999103f89cd8e31b71701cca495b)
-rw-r--r-- | src/app/app.cc | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/app/app.cc b/src/app/app.cc index 036eab8f..84a99fd6 100644 --- a/src/app/app.cc +++ b/src/app/app.cc @@ -81,6 +81,7 @@ public: gboolean require_systemd_scope{false}; gboolean reverse{false}; gboolean test_mode{false}; + gboolean track_clipboard_targets{false}; gboolean use_theme_colors{false}; gboolean version{false}; gboolean whole_window_transparent{false}; @@ -593,6 +594,8 @@ public: "Specify the number of scrollback-lines (-1 for infinite)", nullptr }, { "transparent", 'T', 0, G_OPTION_ARG_INT, &transparency_percent, "Enable the use of a transparent background", "0..100" }, + { "track-clipboard-targets", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &track_clipboard_targets, + "Track clipboard targets", nullptr }, { "verbose", 'v', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, (void*)parse_verbosity, "Enable verbose debug output", nullptr }, @@ -2369,6 +2372,36 @@ app_stdin_readable_cb(int fd, return G_SOURCE_CONTINUE; } +static void +app_clipboard_targets_received_cb(GtkClipboard* clipboard, + GdkAtom* targets, + int n_targets, + VteappApplication* application) +{ + verbose_print("Clipboard has %d targets:", n_targets); + + for (auto i = 0; i < n_targets; ++i) { + auto atom_name = vte::glib::take_string(gdk_atom_name(targets[i])); + verbose_print(" %s", atom_name.get()); + } + verbose_print("\n"); +} + +static void +app_clipboard_owner_change_cb(GtkClipboard* clipboard, + GdkEvent* event G_GNUC_UNUSED, + VteappApplication* application) +{ + verbose_print("Clipboard owner-change, requesting targets\n"); + + /* We can do this without holding a reference to @application since + * the application lives as long as the process. + */ + gtk_clipboard_request_targets(clipboard, + (GtkClipboardTargetsReceivedFunc)app_clipboard_targets_received_cb, + application); +} + G_DEFINE_TYPE(VteappApplication, vteapp_application, GTK_TYPE_APPLICATION) static void @@ -2394,6 +2427,14 @@ vteapp_application_init(VteappApplication* application) (GUnixFDSourceFunc)app_stdin_readable_cb, application); } + + if (options.track_clipboard_targets) { + auto clipboard = gtk_clipboard_get_for_display(gdk_display_get_default(), + GDK_SELECTION_CLIPBOARD); + app_clipboard_owner_change_cb(clipboard, nullptr, application); + g_signal_connect(clipboard, "owner-change", + G_CALLBACK(app_clipboard_owner_change_cb), application); + } } static void |