[vte/vte-0-62] app: Add debug option to track clipboard targets
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte/vte-0-62] app: Add debug option to track clipboard targets
- Date: Sun, 21 Feb 2021 15:17:53 +0000 (UTC)
commit 56c81b7a5d1a6bfe4fe3f1400a472296bc9b0ac7
Author: Christian Persch <chpe src gnome org>
Date: Sun Feb 21 16:17:45 2021 +0100
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)
(cherry picked from commit 98c044a5698cd814fc43465b91d3962267472961)
src/app/app.cc | 41 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
---
diff --git a/src/app/app.cc b/src/app/app.cc
index 6453ef85..4114356f 100644
--- a/src/app/app.cc
+++ b/src/app/app.cc
@@ -74,6 +74,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};
@@ -584,6 +585,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 },
@@ -2354,6 +2357,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
@@ -2379,6 +2412,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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]