From: Victor Toso <me@xxxxxxxxxxxxxx> There is no need to use an index variable to keep track of the number of VD_AGENT_CLIPBOARD types we are storing. Signed-off-by: Victor Toso <victortoso@xxxxxxxxxx> --- src/spice-gtk-session.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/spice-gtk-session.c b/src/spice-gtk-session.c index cfdfc4c..2ae512f 100644 --- a/src/spice-gtk-session.c +++ b/src/spice-gtk-session.c @@ -619,6 +619,7 @@ static void clipboard_get_targets(GtkClipboard *clipboard, char *name; int a, m, t; int selection; + gint num_types; if (s->main == NULL) return; @@ -635,6 +636,8 @@ static void clipboard_get_targets(GtkClipboard *clipboard, } } + /* Set all Atoms that matches our current protocol implementation */ + num_types = 0; for (a = 0; a < n_atoms; a++) { name = gdk_atom_name(atoms[a]); for (m = 0; m < SPICE_N_ELEMENTS(atom2agent); m++) { @@ -650,6 +653,7 @@ static void clipboard_get_targets(GtkClipboard *clipboard, if (types[t] == 0) { /* add type to empty slot */ types[t] = atom2agent[m].vdagent; + num_types++; break; } } @@ -657,16 +661,17 @@ static void clipboard_get_targets(GtkClipboard *clipboard, } g_free(name); } - for (t = 0; t < SPICE_N_ELEMENTS(atom2agent); t++) { - if (types[t] == 0) { - break; - } + + if (num_types == 0) { + SPICE_DEBUG("No GdkAtoms will be sent from %d", n_atoms); + return; } - if (!s->clip_grabbed[selection] && t > 0) { + + if (!s->clip_grabbed[selection]) { s->clip_grabbed[selection] = TRUE; if (spice_main_agent_test_capability(s->main, VD_AGENT_CAP_CLIPBOARD_BY_DEMAND)) - spice_main_clipboard_selection_grab(s->main, selection, types, t); + spice_main_clipboard_selection_grab(s->main, selection, types, num_types); /* Sending a grab causes the agent to do an implicit release */ s->nclip_targets[selection] = 0; } -- 2.13.0 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel