From patchwork Wed Jul 21 08:41:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 1508020 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=TjMpspXP; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GV8QS2FWmz9sWX for ; Wed, 21 Jul 2021 18:49:20 +1000 (AEST) Received: from localhost ([::1]:44146 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m67uo-0004Wq-1B for incoming@patchwork.ozlabs.org; Wed, 21 Jul 2021 04:49:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33204) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m67nl-0006NV-56 for qemu-devel@nongnu.org; Wed, 21 Jul 2021 04:42:01 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:37737) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m67nj-0004om-Gw for qemu-devel@nongnu.org; Wed, 21 Jul 2021 04:42:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626856919; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tLQ60TpbJE+zchmjajoumonlNRDrN6jigUuEHNUzb9c=; b=TjMpspXPrQVW1otqMVoMX8UcuJGncuEDeNO803w3fNnZc0cnFuvj5KT3tiNEUuPjhqCkTN 2idUVE16w1XXF1e3VaQdBS/1fkaaJp9kJvn9oaEjrNrYIG/hAntCZ9WRG1yCkKrX1xmY64 n3wS4sZspS8gaZ4DLwhmsZTNluHy/IM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-343--f39LDSmNV-Jd2VH86UtXQ-1; Wed, 21 Jul 2021 04:41:57 -0400 X-MC-Unique: -f39LDSmNV-Jd2VH86UtXQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C916E193579C for ; Wed, 21 Jul 2021 08:41:56 +0000 (UTC) Received: from localhost (unknown [10.36.110.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5EAAD83060; Wed, 21 Jul 2021 08:41:47 +0000 (UTC) From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PATCH v2 01/13] ui/vdagent: fix leak on error path Date: Wed, 21 Jul 2021 12:41:27 +0400 Message-Id: <20210721084139.1124779-2-marcandre.lureau@redhat.com> In-Reply-To: <20210721084139.1124779-1-marcandre.lureau@redhat.com> References: <20210721084139.1124779-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.474, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , kraxel@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Marc-André Lureau "info" was leaked when more than 10 entries. Signed-off-by: Marc-André Lureau --- include/ui/clipboard.h | 2 ++ ui/vdagent.c | 4 +--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/ui/clipboard.h b/include/ui/clipboard.h index b45b984c9f..eb789a285a 100644 --- a/include/ui/clipboard.h +++ b/include/ui/clipboard.h @@ -190,4 +190,6 @@ void qemu_clipboard_set_data(QemuClipboardPeer *peer, const void *data, bool update); +G_DEFINE_AUTOPTR_CLEANUP_FUNC(QemuClipboardInfo, qemu_clipboard_info_unref) + #endif /* QEMU_CLIPBOARD_H */ diff --git a/ui/vdagent.c b/ui/vdagent.c index a253a8fe63..f6ef8d1993 100644 --- a/ui/vdagent.c +++ b/ui/vdagent.c @@ -438,7 +438,7 @@ static void vdagent_chr_recv_clipboard(VDAgentChardev *vd, VDAgentMessage *msg) uint8_t s = VD_AGENT_CLIPBOARD_SELECTION_CLIPBOARD; uint32_t size = msg->size; void *data = msg->data; - QemuClipboardInfo *info; + g_autoptr(QemuClipboardInfo) info = NULL; QemuClipboardType type; if (have_selection(vd)) { @@ -477,7 +477,6 @@ static void vdagent_chr_recv_clipboard(VDAgentChardev *vd, VDAgentMessage *msg) size -= sizeof(uint32_t); } qemu_clipboard_update(info); - qemu_clipboard_info_unref(info); break; case VD_AGENT_CLIPBOARD_REQUEST: if (size < sizeof(uint32_t)) { @@ -523,7 +522,6 @@ static void vdagent_chr_recv_clipboard(VDAgentChardev *vd, VDAgentMessage *msg) /* set empty clipboard info */ info = qemu_clipboard_info_new(NULL, s); qemu_clipboard_update(info); - qemu_clipboard_info_unref(info); } break; } From patchwork Wed Jul 21 08:41:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 1508009 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=SHWGk1o8; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GV8Gz2vKBz9sWX for ; Wed, 21 Jul 2021 18:42:51 +1000 (AEST) Received: from localhost ([::1]:50706 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m67oX-0006uU-1L for incoming@patchwork.ozlabs.org; Wed, 21 Jul 2021 04:42:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33236) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m67nv-0006oC-FW for qemu-devel@nongnu.org; Wed, 21 Jul 2021 04:42:11 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:35806) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m67ns-0004xn-Cu for qemu-devel@nongnu.org; Wed, 21 Jul 2021 04:42:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626856927; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cVjLzHO2nIi8KZy1mMtpuvGp6gSulIYAEN+AKOrF24Y=; b=SHWGk1o8J4RxvruP1yM4SyaUGWiSJM01KFEDUKfB7Z+5cGjJsRgqAVOR9CCY+DMs8kZd6I Q6EDGl/kEQdH3i6EPaidbJe+zkgk0W1Uryqw74Fyq+XcESiuAvBDYIMSQfEnSqpdlaUoZj ASxabw0JBpY35xzC8gPNz1wAxIhOxv4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-151-6pBtdoSlPiW5tk_0ZXvxww-1; Wed, 21 Jul 2021 04:42:04 -0400 X-MC-Unique: 6pBtdoSlPiW5tk_0ZXvxww-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 47FF5107B032 for ; Wed, 21 Jul 2021 08:42:02 +0000 (UTC) Received: from localhost (unknown [10.36.110.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id F0C315D9DC; Wed, 21 Jul 2021 08:42:00 +0000 (UTC) From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PATCH v2 02/13] ui/vdagent: remove copy-pasta comment Date: Wed, 21 Jul 2021 12:41:28 +0400 Message-Id: <20210721084139.1124779-3-marcandre.lureau@redhat.com> In-Reply-To: <20210721084139.1124779-1-marcandre.lureau@redhat.com> References: <20210721084139.1124779-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.474, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , kraxel@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Marc-André Lureau Signed-off-by: Marc-André Lureau --- ui/vdagent.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/vdagent.c b/ui/vdagent.c index f6ef8d1993..5ae5734c81 100644 --- a/ui/vdagent.c +++ b/ui/vdagent.c @@ -516,7 +516,7 @@ static void vdagent_chr_recv_clipboard(VDAgentChardev *vd, VDAgentMessage *msg) qemu_clipboard_set_data(&vd->cbpeer, vd->cbinfo[s], type, size, data, true); break; - case VD_AGENT_CLIPBOARD_RELEASE: /* data */ + case VD_AGENT_CLIPBOARD_RELEASE: if (vd->cbinfo[s] && vd->cbinfo[s]->owner == &vd->cbpeer) { /* set empty clipboard info */ From patchwork Wed Jul 21 08:41:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 1508022 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Nmp1irjy; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GV8TP084Qz9sWX for ; Wed, 21 Jul 2021 18:51:52 +1000 (AEST) Received: from localhost ([::1]:50184 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m67xG-0000Fr-Lr for incoming@patchwork.ozlabs.org; Wed, 21 Jul 2021 04:51:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33248) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m67nw-0006oY-KR for qemu-devel@nongnu.org; Wed, 21 Jul 2021 04:42:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:29298) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m67nt-0004yB-23 for qemu-devel@nongnu.org; Wed, 21 Jul 2021 04:42:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626856928; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bykDuWmowo5cwOmADbmeEKqhIej2kqyYevtwCdn4GsY=; b=Nmp1irjytBrm9LaNrGqbZ6RzICUaGkUTm/FHOMfbgs3aJSejRmcZQ0vHnc+O8Fs0F4DxZx qg1HidYVj4wwtaI1I8kABuW+YgMmA5A5dD3TWSAsIEW2+sHOJ5lfGCkyRw6r0mKtSx944F rmhLRo9G5rVZx+d6NfGLPxz0SVcRKCA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-582-CwRAEkuYP-Ww9NdqcI6YaA-1; Wed, 21 Jul 2021 04:42:07 -0400 X-MC-Unique: CwRAEkuYP-Ww9NdqcI6YaA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 774A410150B6 for ; Wed, 21 Jul 2021 08:42:06 +0000 (UTC) Received: from localhost (unknown [10.36.110.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9AEC45D9FC; Wed, 21 Jul 2021 08:42:05 +0000 (UTC) From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PATCH v2 03/13] ui/gtk-clipboard: use existing macros Date: Wed, 21 Jul 2021 12:41:29 +0400 Message-Id: <20210721084139.1124779-4-marcandre.lureau@redhat.com> In-Reply-To: <20210721084139.1124779-1-marcandre.lureau@redhat.com> References: <20210721084139.1124779-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.474, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , kraxel@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Marc-André Lureau Hardcoding strings is error prone, use dedicated macros instead. Signed-off-by: Marc-André Lureau --- ui/gtk-clipboard.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ui/gtk-clipboard.c b/ui/gtk-clipboard.c index bff28d2030..5e817ae55c 100644 --- a/ui/gtk-clipboard.c +++ b/ui/gtk-clipboard.c @@ -177,11 +177,11 @@ void gd_clipboard_init(GtkDisplayState *gd) qemu_clipboard_peer_register(&gd->cbpeer); gd->gtkcb[QEMU_CLIPBOARD_SELECTION_CLIPBOARD] = - gtk_clipboard_get(gdk_atom_intern("CLIPBOARD", FALSE)); + gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); gd->gtkcb[QEMU_CLIPBOARD_SELECTION_PRIMARY] = - gtk_clipboard_get(gdk_atom_intern("PRIMARY", FALSE)); + gtk_clipboard_get(GDK_SELECTION_PRIMARY); gd->gtkcb[QEMU_CLIPBOARD_SELECTION_SECONDARY] = - gtk_clipboard_get(gdk_atom_intern("SECONDARY", FALSE)); + gtk_clipboard_get(GDK_SELECTION_SECONDARY); g_signal_connect(gd->gtkcb[QEMU_CLIPBOARD_SELECTION_CLIPBOARD], "owner-change", G_CALLBACK(gd_owner_change), gd); From patchwork Wed Jul 21 08:41:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 1508011 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=cL2dRBTz; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GV8HD4vwVz9sWX for ; Wed, 21 Jul 2021 18:43:04 +1000 (AEST) Received: from localhost ([::1]:51986 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m67ok-0007lU-An for incoming@patchwork.ozlabs.org; Wed, 21 Jul 2021 04:43:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33272) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m67o0-0006tV-FE for qemu-devel@nongnu.org; Wed, 21 Jul 2021 04:42:16 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:37692) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m67ny-00052D-VX for qemu-devel@nongnu.org; Wed, 21 Jul 2021 04:42:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626856933; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=h8DWW4GTGc5bGckpzifXOx+F24qr9GjY3WY4ez/Gmhc=; b=cL2dRBTzoB9x67WNBXYoKLx67+ZDwAEAleH7qKU6ESL/1HQJN25hlc7lrVnyhb9C4uoVfx IVWbUyA30MxMOctz8+qouq0v4PgEoW3dwzgrDbVPc9n2vfeiwbzTKId3DqLbE5u1H4xMUH sDKGZznR7n3MlhfZsUtgSuNjaajWXyg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-49-sNdo5nNqMLuOGoVknbMuIw-1; Wed, 21 Jul 2021 04:42:12 -0400 X-MC-Unique: sNdo5nNqMLuOGoVknbMuIw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 484A5845F2C for ; Wed, 21 Jul 2021 08:42:11 +0000 (UTC) Received: from localhost (unknown [10.36.110.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 38F8619D7C; Wed, 21 Jul 2021 08:42:09 +0000 (UTC) From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PATCH v2 04/13] ui/gtk-clipboard: fix clipboard enum typo Date: Wed, 21 Jul 2021 12:41:30 +0400 Message-Id: <20210721084139.1124779-5-marcandre.lureau@redhat.com> In-Reply-To: <20210721084139.1124779-1-marcandre.lureau@redhat.com> References: <20210721084139.1124779-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.474, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , kraxel@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Marc-André Lureau Signed-off-by: Marc-André Lureau --- ui/gtk-clipboard.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/gtk-clipboard.c b/ui/gtk-clipboard.c index 5e817ae55c..2c78de9500 100644 --- a/ui/gtk-clipboard.c +++ b/ui/gtk-clipboard.c @@ -155,7 +155,7 @@ static void gd_owner_change(GtkClipboard *clipboard, switch (event->owner_change.reason) { - case GDK_SETTING_ACTION_NEW: + case GDK_OWNER_CHANGE_NEW_OWNER: info = qemu_clipboard_info_new(&gd->cbpeer, s); if (gtk_clipboard_wait_is_text_available(clipboard)) { info->types[QEMU_CLIPBOARD_TYPE_TEXT].available = true; From patchwork Wed Jul 21 08:41:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 1508010 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Gz1i4iBu; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GV8H71x8gz9sWX for ; Wed, 21 Jul 2021 18:42:59 +1000 (AEST) Received: from localhost ([::1]:51482 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m67oe-0007R8-Ue for incoming@patchwork.ozlabs.org; Wed, 21 Jul 2021 04:42:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33298) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m67o5-00070Q-9w for qemu-devel@nongnu.org; Wed, 21 Jul 2021 04:42:21 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:24468) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m67o2-00055X-DH for qemu-devel@nongnu.org; Wed, 21 Jul 2021 04:42:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626856937; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uxVivlhdggH8hSzuvkWSXHFxbgrHJy6pB7yNHHuxKRs=; b=Gz1i4iBu/OsL4H83r8quAuQ4AQ4k21wgY9A6PxQ7H3tm4sbQfiToKjdBm4O1bwa0fg62JB gNuua3WMrw1rqAhkGx1NwaS13/6lUsZnHkfb1Rp8vqZwLXlXoN90jPA2JqcUtzKTWAtoEX BP9kIIWK3Iux0dvPqXaoj3HPnh96LgE= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-589-RBRLJk3dNYWQIEp_u5N5NQ-1; Wed, 21 Jul 2021 04:42:16 -0400 X-MC-Unique: RBRLJk3dNYWQIEp_u5N5NQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9CF901030C20 for ; Wed, 21 Jul 2021 08:42:15 +0000 (UTC) Received: from localhost (unknown [10.36.110.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id B71E119811; Wed, 21 Jul 2021 08:42:14 +0000 (UTC) From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PATCH v2 05/13] ui/clipboard: add helper to retrieve current clipboard Date: Wed, 21 Jul 2021 12:41:31 +0400 Message-Id: <20210721084139.1124779-6-marcandre.lureau@redhat.com> In-Reply-To: <20210721084139.1124779-1-marcandre.lureau@redhat.com> References: <20210721084139.1124779-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.474, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , kraxel@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Marc-André Lureau Signed-off-by: Marc-André Lureau --- include/ui/clipboard.h | 9 +++++++++ ui/clipboard.c | 15 +++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/include/ui/clipboard.h b/include/ui/clipboard.h index eb789a285a..e9fcb15c66 100644 --- a/include/ui/clipboard.h +++ b/include/ui/clipboard.h @@ -109,6 +109,15 @@ void qemu_clipboard_peer_register(QemuClipboardPeer *peer); */ void qemu_clipboard_peer_unregister(QemuClipboardPeer *peer); +/** + * qemu_clipboard_info + * + * @selection: clipboard selection. + * + * Return the current clipboard data & owner informations. + */ +QemuClipboardInfo *qemu_clipboard_info(QemuClipboardSelection selection); + /** * qemu_clipboard_info_new * diff --git a/ui/clipboard.c b/ui/clipboard.c index 3525b30178..56c14509fe 100644 --- a/ui/clipboard.c +++ b/ui/clipboard.c @@ -4,6 +4,8 @@ static NotifierList clipboard_notifiers = NOTIFIER_LIST_INITIALIZER(clipboard_notifiers); +static QemuClipboardInfo *cbinfo[QEMU_CLIPBOARD_SELECTION__COUNT]; + void qemu_clipboard_peer_register(QemuClipboardPeer *peer) { notifier_list_add(&clipboard_notifiers, &peer->update); @@ -16,7 +18,20 @@ void qemu_clipboard_peer_unregister(QemuClipboardPeer *peer) void qemu_clipboard_update(QemuClipboardInfo *info) { + g_autoptr(QemuClipboardInfo) old = NULL; + assert(info->selection < QEMU_CLIPBOARD_SELECTION__COUNT); + notifier_list_notify(&clipboard_notifiers, info); + + old = cbinfo[info->selection]; + cbinfo[info->selection] = qemu_clipboard_info_ref(info); +} + +QemuClipboardInfo *qemu_clipboard_info(QemuClipboardSelection selection) +{ + assert(selection < QEMU_CLIPBOARD_SELECTION__COUNT); + + return cbinfo[selection]; } QemuClipboardInfo *qemu_clipboard_info_new(QemuClipboardPeer *owner, From patchwork Wed Jul 21 08:41:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 1508015 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ahlA7xRF; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GV8LB3x7qz9sWX for ; Wed, 21 Jul 2021 18:45:38 +1000 (AEST) Received: from localhost ([::1]:60398 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m67rE-0004uZ-66 for incoming@patchwork.ozlabs.org; Wed, 21 Jul 2021 04:45:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33312) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m67o8-00074H-OY for qemu-devel@nongnu.org; Wed, 21 Jul 2021 04:42:24 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:53183) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m67o7-00059W-81 for qemu-devel@nongnu.org; Wed, 21 Jul 2021 04:42:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626856942; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pp+7qQuM/5UkNDkITrrbNiBeKGS9spJa0q99oABY188=; b=ahlA7xRFktj8e1ElvkBPlMI6I5FGODgUSzc0siXmFFqQj6Go83N4y2KsTwIluSuzb1OP4B GKafkt0m2RgzvAvqr0R0DYQBcOxzAyffUZHc153SndByWLPvqSDQJy669+Ho5m6AL9FNr3 UwDLXRQXhFgSXr1U/QZkRCUJbF4pPWA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-225-fVpS4jcAOxKiQuHcFFcytA-1; Wed, 21 Jul 2021 04:42:21 -0400 X-MC-Unique: fVpS4jcAOxKiQuHcFFcytA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7068A873079 for ; Wed, 21 Jul 2021 08:42:20 +0000 (UTC) Received: from localhost (unknown [10.36.110.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 824935D9FC; Wed, 21 Jul 2021 08:42:19 +0000 (UTC) From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PATCH v2 06/13] ui/clipboard: release owned grabs on unregister Date: Wed, 21 Jul 2021 12:41:32 +0400 Message-Id: <20210721084139.1124779-7-marcandre.lureau@redhat.com> In-Reply-To: <20210721084139.1124779-1-marcandre.lureau@redhat.com> References: <20210721084139.1124779-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.474, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , kraxel@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Marc-André Lureau Signed-off-by: Marc-André Lureau --- ui/clipboard.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ui/clipboard.c b/ui/clipboard.c index 56c14509fe..a9512f01a7 100644 --- a/ui/clipboard.c +++ b/ui/clipboard.c @@ -13,6 +13,15 @@ void qemu_clipboard_peer_register(QemuClipboardPeer *peer) void qemu_clipboard_peer_unregister(QemuClipboardPeer *peer) { + int i; + + for (i = 0; i < QEMU_CLIPBOARD_SELECTION__COUNT; i++) { + if (cbinfo[i] && cbinfo[i]->owner == peer) { + /* release owned grabs */ + g_autoptr(QemuClipboardInfo) info = qemu_clipboard_info_new(NULL, i); + qemu_clipboard_update(info); + } + } notifier_remove(&peer->update); } From patchwork Wed Jul 21 08:41:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 1508023 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=cGOMshOr; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GV8WL4yjgz9sWX for ; Wed, 21 Jul 2021 18:53:34 +1000 (AEST) Received: from localhost ([::1]:53626 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m67yu-0002jy-Dy for incoming@patchwork.ozlabs.org; Wed, 21 Jul 2021 04:53:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34018) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m67rp-0008Hf-8t for qemu-devel@nongnu.org; Wed, 21 Jul 2021 04:46:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:28784) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m67rn-00084s-QV for qemu-devel@nongnu.org; Wed, 21 Jul 2021 04:46:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626857171; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=THZGEmL1ON3sOCgaZq2CNcN8xwiiSAihcDMZ4EzEkSY=; b=cGOMshOrrq6ipchGznp0cPQq736syefRqGqsvFaIGGZumTLz9kbrI38lKcHmvOOhhC1VYx 4/HmkwetwncKGB8TLgdpLzl/voX7roK6wvpk1yIpFvDiHa4cRvWbX3rvVDYnZc6TxmWj3Q mm7TbBoAGD9MN0aYUMNIBP9NLTexCbU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-456-FFzeuJS7NdSLcT_Hqrioog-1; Wed, 21 Jul 2021 04:42:32 -0400 X-MC-Unique: FFzeuJS7NdSLcT_Hqrioog-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B5816800D62 for ; Wed, 21 Jul 2021 08:42:31 +0000 (UTC) Received: from localhost (unknown [10.36.110.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id B7A8E84A16; Wed, 21 Jul 2021 08:42:23 +0000 (UTC) From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PATCH v2 07/13] ui/vdagent: disconnect handlers and reset state on finalize Date: Wed, 21 Jul 2021 12:41:33 +0400 Message-Id: <20210721084139.1124779-8-marcandre.lureau@redhat.com> In-Reply-To: <20210721084139.1124779-1-marcandre.lureau@redhat.com> References: <20210721084139.1124779-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.474, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , kraxel@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Marc-André Lureau Avoid handlers being called with dangling pointers when the object is freed. Signed-off-by: Marc-André Lureau --- ui/vdagent.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/ui/vdagent.c b/ui/vdagent.c index 5ae5734c81..1a29016e07 100644 --- a/ui/vdagent.c +++ b/ui/vdagent.c @@ -721,22 +721,26 @@ static void vdagent_chr_accept_input(Chardev *chr) vdagent_send_buf(vd); } +static void vdagent_disconnect(VDAgentChardev *vd) +{ + vdagent_reset_bufs(vd); + vd->caps = 0; + if (vd->mouse_hs) { + qemu_input_handler_deactivate(vd->mouse_hs); + } + if (vd->cbpeer.update.notify) { + qemu_clipboard_peer_unregister(&vd->cbpeer); + memset(&vd->cbpeer, 0, sizeof(vd->cbpeer)); + } +} + static void vdagent_chr_set_fe_open(struct Chardev *chr, int fe_open) { VDAgentChardev *vd = QEMU_VDAGENT_CHARDEV(chr); if (!fe_open) { trace_vdagent_close(); - /* reset state */ - vdagent_reset_bufs(vd); - vd->caps = 0; - if (vd->mouse_hs) { - qemu_input_handler_deactivate(vd->mouse_hs); - } - if (vd->cbpeer.update.notify) { - qemu_clipboard_peer_unregister(&vd->cbpeer); - memset(&vd->cbpeer, 0, sizeof(vd->cbpeer)); - } + vdagent_disconnect(vd); return; } @@ -781,6 +785,7 @@ static void vdagent_chr_fini(Object *obj) { VDAgentChardev *vd = QEMU_VDAGENT_CHARDEV(obj); + vdagent_disconnect(vd); buffer_free(&vd->outbuf); } From patchwork Wed Jul 21 08:41:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 1508019 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=fY5BDX4f; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GV8P50gVqz9sWd for ; Wed, 21 Jul 2021 18:48:08 +1000 (AEST) Received: from localhost ([::1]:40784 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m67te-0002IE-Fm for incoming@patchwork.ozlabs.org; Wed, 21 Jul 2021 04:48:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34110) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m67sk-0002Ds-7D for qemu-devel@nongnu.org; Wed, 21 Jul 2021 04:47:10 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:55167) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m67si-0000I7-PD for qemu-devel@nongnu.org; Wed, 21 Jul 2021 04:47:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626857228; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TUmFx9j8+LWbFJAKqUl0016kVaEt4yxP1wppqlyAezw=; b=fY5BDX4fHrUxwFyWm4NfOo7c+1OKuiLgeEQyZIIgSAJVuWvtp50tz5obF/j8poofE2APdR GHbd7DhQQWRr1xZUgjHpfsKkJx6E3OoljaVMVyQ4cFU27FDuZuo8/BciARKFtkwdUMNNSZ rgh7ekB9GBibNzFhSjadPr+mWjy76d4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-400-vNn1yKuMMEWipg6LbjwTyA-1; Wed, 21 Jul 2021 04:42:37 -0400 X-MC-Unique: vNn1yKuMMEWipg6LbjwTyA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0EBA11023F5B for ; Wed, 21 Jul 2021 08:42:37 +0000 (UTC) Received: from localhost (unknown [10.36.110.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id E417184A15; Wed, 21 Jul 2021 08:42:35 +0000 (UTC) From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PATCH v2 08/13] ui/vdagent: reset outbuf on disconnect Date: Wed, 21 Jul 2021 12:41:34 +0400 Message-Id: <20210721084139.1124779-9-marcandre.lureau@redhat.com> In-Reply-To: <20210721084139.1124779-1-marcandre.lureau@redhat.com> References: <20210721084139.1124779-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.474, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , kraxel@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Marc-André Lureau Signed-off-by: Marc-André Lureau --- ui/vdagent.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ui/vdagent.c b/ui/vdagent.c index 1a29016e07..3770c58b6c 100644 --- a/ui/vdagent.c +++ b/ui/vdagent.c @@ -723,6 +723,7 @@ static void vdagent_chr_accept_input(Chardev *chr) static void vdagent_disconnect(VDAgentChardev *vd) { + buffer_reset(&vd->outbuf); vdagent_reset_bufs(vd); vd->caps = 0; if (vd->mouse_hs) { From patchwork Wed Jul 21 08:41:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 1508018 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=PVZZ9rP8; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GV8Nr1LBJz9sWX for ; Wed, 21 Jul 2021 18:47:56 +1000 (AEST) Received: from localhost ([::1]:40358 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m67tR-00020r-U9 for incoming@patchwork.ozlabs.org; Wed, 21 Jul 2021 04:47:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33438) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m67oU-0008MD-JL for qemu-devel@nongnu.org; Wed, 21 Jul 2021 04:42:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:55781) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m67oS-0005PJ-OZ for qemu-devel@nongnu.org; Wed, 21 Jul 2021 04:42:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626856964; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MiiLtG9jTgAfsEsTqsGDvXGbSys/7B0mP5opXs/AAH4=; b=PVZZ9rP8y2j8ywl50WvZPub/hTd19iJe8ANcgyryFHr4oAJK+w1x5sV6ggscGGtBC2Q9vd zvVXqeH5UyUsWsBkI1Z/Vj5z5ip+SJpVZyNyBOnq8qUtPMmszEllUi2T0X9BSgCcIsmg6c TUuuhlFB85mrPTBzsSlsU6c6rdttvqk= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-222-JEnbNlscNTapQgcyZUM20Q-1; Wed, 21 Jul 2021 04:42:42 -0400 X-MC-Unique: JEnbNlscNTapQgcyZUM20Q-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1112410150A0 for ; Wed, 21 Jul 2021 08:42:42 +0000 (UTC) Received: from localhost (unknown [10.36.110.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id C4BEF19C79; Wed, 21 Jul 2021 08:42:40 +0000 (UTC) From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PATCH v2 09/13] ui/vdagent: split clipboard recv message handling Date: Wed, 21 Jul 2021 12:41:35 +0400 Message-Id: <20210721084139.1124779-10-marcandre.lureau@redhat.com> In-Reply-To: <20210721084139.1124779-1-marcandre.lureau@redhat.com> References: <20210721084139.1124779-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.474, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , kraxel@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Marc-André Lureau Signed-off-by: Marc-André Lureau --- ui/vdagent.c | 157 +++++++++++++++++++++++++++++---------------------- 1 file changed, 89 insertions(+), 68 deletions(-) diff --git a/ui/vdagent.c b/ui/vdagent.c index 3770c58b6c..362064213c 100644 --- a/ui/vdagent.c +++ b/ui/vdagent.c @@ -433,13 +433,94 @@ static void vdagent_clipboard_request(QemuClipboardInfo *info, vdagent_send_msg(vd, msg); } +static void vdagent_clipboard_recv_grab(VDAgentChardev *vd, uint8_t s, uint32_t size, void *data) +{ + g_autoptr(QemuClipboardInfo) info = NULL; + + trace_vdagent_cb_grab_selection(GET_NAME(sel_name, s)); + info = qemu_clipboard_info_new(&vd->cbpeer, s); + if (size > sizeof(uint32_t) * 10) { + /* + * spice has 6 types as of 2021. Limiting to 10 entries + * so we we have some wiggle room. + */ + return; + } + while (size >= sizeof(uint32_t)) { + trace_vdagent_cb_grab_type(GET_NAME(type_name, *(uint32_t *)data)); + switch (*(uint32_t *)data) { + case VD_AGENT_CLIPBOARD_UTF8_TEXT: + info->types[QEMU_CLIPBOARD_TYPE_TEXT].available = true; + break; + default: + break; + } + data += sizeof(uint32_t); + size -= sizeof(uint32_t); + } + qemu_clipboard_update(info); +} + +static void vdagent_clipboard_recv_request(VDAgentChardev *vd, uint8_t s, uint32_t size, void *data) +{ + QemuClipboardType type; + + if (size < sizeof(uint32_t)) { + return; + } + switch (*(uint32_t *)data) { + case VD_AGENT_CLIPBOARD_UTF8_TEXT: + type = QEMU_CLIPBOARD_TYPE_TEXT; + break; + default: + return; + } + if (vd->cbinfo[s] && vd->cbinfo[s]->types[type].available && + vd->cbinfo[s]->owner != &vd->cbpeer) { + if (vd->cbinfo[s]->types[type].data) { + vdagent_send_clipboard_data(vd, vd->cbinfo[s], type); + } else { + vd->cbpending[s] |= (1 << type); + qemu_clipboard_request(vd->cbinfo[s], type); + } + } +} + +static void vdagent_clipboard_recv_data(VDAgentChardev *vd, uint8_t s, uint32_t size, void *data) +{ + QemuClipboardType type; + + if (size < sizeof(uint32_t)) { + return; + } + switch (*(uint32_t *)data) { + case VD_AGENT_CLIPBOARD_UTF8_TEXT: + type = QEMU_CLIPBOARD_TYPE_TEXT; + break; + default: + return; + } + data += 4; + size -= 4; + qemu_clipboard_set_data(&vd->cbpeer, vd->cbinfo[s], type, size, data, true); +} + +static void vdagent_clipboard_recv_release(VDAgentChardev *vd, uint8_t s) +{ + g_autoptr(QemuClipboardInfo) info = NULL; + + if (vd->cbinfo[s] && vd->cbinfo[s]->owner == &vd->cbpeer) { + /* set empty clipboard info */ + info = qemu_clipboard_info_new(NULL, s); + qemu_clipboard_update(info); + } +} + static void vdagent_chr_recv_clipboard(VDAgentChardev *vd, VDAgentMessage *msg) { uint8_t s = VD_AGENT_CLIPBOARD_SELECTION_CLIPBOARD; uint32_t size = msg->size; void *data = msg->data; - g_autoptr(QemuClipboardInfo) info = NULL; - QemuClipboardType type; if (have_selection(vd)) { if (size < 4) { @@ -455,75 +536,15 @@ static void vdagent_chr_recv_clipboard(VDAgentChardev *vd, VDAgentMessage *msg) switch (msg->type) { case VD_AGENT_CLIPBOARD_GRAB: - trace_vdagent_cb_grab_selection(GET_NAME(sel_name, s)); - info = qemu_clipboard_info_new(&vd->cbpeer, s); - if (size > sizeof(uint32_t) * 10) { - /* - * spice has 6 types as of 2021. Limiting to 10 entries - * so we we have some wiggle room. - */ - return; - } - while (size >= sizeof(uint32_t)) { - trace_vdagent_cb_grab_type(GET_NAME(type_name, *(uint32_t *)data)); - switch (*(uint32_t *)data) { - case VD_AGENT_CLIPBOARD_UTF8_TEXT: - info->types[QEMU_CLIPBOARD_TYPE_TEXT].available = true; - break; - default: - break; - } - data += sizeof(uint32_t); - size -= sizeof(uint32_t); - } - qemu_clipboard_update(info); - break; + return vdagent_clipboard_recv_grab(vd, s, size, data); case VD_AGENT_CLIPBOARD_REQUEST: - if (size < sizeof(uint32_t)) { - return; - } - switch (*(uint32_t *)data) { - case VD_AGENT_CLIPBOARD_UTF8_TEXT: - type = QEMU_CLIPBOARD_TYPE_TEXT; - break; - default: - return; - } - if (vd->cbinfo[s] && - vd->cbinfo[s]->types[type].available && - vd->cbinfo[s]->owner != &vd->cbpeer) { - if (vd->cbinfo[s]->types[type].data) { - vdagent_send_clipboard_data(vd, vd->cbinfo[s], type); - } else { - vd->cbpending[s] |= (1 << type); - qemu_clipboard_request(vd->cbinfo[s], type); - } - } - break; + return vdagent_clipboard_recv_request(vd, s, size, data); case VD_AGENT_CLIPBOARD: /* data */ - if (size < sizeof(uint32_t)) { - return; - } - switch (*(uint32_t *)data) { - case VD_AGENT_CLIPBOARD_UTF8_TEXT: - type = QEMU_CLIPBOARD_TYPE_TEXT; - break; - default: - return; - } - data += 4; - size -= 4; - qemu_clipboard_set_data(&vd->cbpeer, vd->cbinfo[s], type, - size, data, true); - break; + return vdagent_clipboard_recv_data(vd, s, size, data); case VD_AGENT_CLIPBOARD_RELEASE: - if (vd->cbinfo[s] && - vd->cbinfo[s]->owner == &vd->cbpeer) { - /* set empty clipboard info */ - info = qemu_clipboard_info_new(NULL, s); - qemu_clipboard_update(info); - } - break; + return vdagent_clipboard_recv_release(vd, s); + default: + g_assert_not_reached(); } } From patchwork Wed Jul 21 08:41:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 1508014 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=gGxpVzT9; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GV8L54876z9sWX for ; Wed, 21 Jul 2021 18:45:33 +1000 (AEST) Received: from localhost ([::1]:60016 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m67r9-0004fL-98 for incoming@patchwork.ozlabs.org; Wed, 21 Jul 2021 04:45:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33492) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m67og-0000jF-Qk for qemu-devel@nongnu.org; Wed, 21 Jul 2021 04:42:59 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:56327) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m67of-0005ZU-1W for qemu-devel@nongnu.org; Wed, 21 Jul 2021 04:42:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626856976; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FXHbR8nJJ0NV3kvnIW/1qe5jkVQkig7Pf2ODI1q+N9o=; b=gGxpVzT98EdvFezPjcBVIBrzPYlTBCcG9yl8kQv7ulmF7015/OLzWrF6UXH34oVy3rQmbW Q6UENyHOwyNswQAEdrBS0RmNpfmZg83YEKGdI6eMvNUJNlPK5p674kKGbkIY/R8UOu03Yj JiVcO2JLiYfTb1WyPpmRXrXNA80+sik= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-500-XhPJw0WnNGqcwbppEGF5WA-1; Wed, 21 Jul 2021 04:42:54 -0400 X-MC-Unique: XhPJw0WnNGqcwbppEGF5WA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0BD1A1853028 for ; Wed, 21 Jul 2021 08:42:54 +0000 (UTC) Received: from localhost (unknown [10.36.110.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0946660BF1; Wed, 21 Jul 2021 08:42:45 +0000 (UTC) From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PATCH v2 10/13] ui/vdagent: use qemu_clipboard_info helper Date: Wed, 21 Jul 2021 12:41:36 +0400 Message-Id: <20210721084139.1124779-11-marcandre.lureau@redhat.com> In-Reply-To: <20210721084139.1124779-1-marcandre.lureau@redhat.com> References: <20210721084139.1124779-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.474, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , kraxel@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Marc-André Lureau Signed-off-by: Marc-André Lureau --- ui/vdagent.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/ui/vdagent.c b/ui/vdagent.c index 362064213c..bc8347f995 100644 --- a/ui/vdagent.c +++ b/ui/vdagent.c @@ -47,7 +47,6 @@ struct VDAgentChardev { /* clipboard */ QemuClipboardPeer cbpeer; - QemuClipboardInfo *cbinfo[QEMU_CLIPBOARD_SELECTION__COUNT]; uint32_t cbpending[QEMU_CLIPBOARD_SELECTION__COUNT]; }; typedef struct VDAgentChardev VDAgentChardev; @@ -384,9 +383,7 @@ static void vdagent_clipboard_notify(Notifier *notifier, void *data) QemuClipboardType type; bool self_update = info->owner == &vd->cbpeer; - if (info != vd->cbinfo[s]) { - qemu_clipboard_info_unref(vd->cbinfo[s]); - vd->cbinfo[s] = qemu_clipboard_info_ref(info); + if (info != qemu_clipboard_info(s)) { vd->cbpending[s] = 0; if (!self_update) { vdagent_send_clipboard_grab(vd, info); @@ -464,6 +461,7 @@ static void vdagent_clipboard_recv_grab(VDAgentChardev *vd, uint8_t s, uint32_t static void vdagent_clipboard_recv_request(VDAgentChardev *vd, uint8_t s, uint32_t size, void *data) { QemuClipboardType type; + QemuClipboardInfo *info; if (size < sizeof(uint32_t)) { return; @@ -475,13 +473,14 @@ static void vdagent_clipboard_recv_request(VDAgentChardev *vd, uint8_t s, uint32 default: return; } - if (vd->cbinfo[s] && vd->cbinfo[s]->types[type].available && - vd->cbinfo[s]->owner != &vd->cbpeer) { - if (vd->cbinfo[s]->types[type].data) { - vdagent_send_clipboard_data(vd, vd->cbinfo[s], type); + + info = qemu_clipboard_info(s); + if (info && info->types[type].available && info->owner != &vd->cbpeer) { + if (info->types[type].data) { + vdagent_send_clipboard_data(vd, info, type); } else { vd->cbpending[s] |= (1 << type); - qemu_clipboard_request(vd->cbinfo[s], type); + qemu_clipboard_request(info, type); } } } @@ -489,6 +488,7 @@ static void vdagent_clipboard_recv_request(VDAgentChardev *vd, uint8_t s, uint32 static void vdagent_clipboard_recv_data(VDAgentChardev *vd, uint8_t s, uint32_t size, void *data) { QemuClipboardType type; + QemuClipboardInfo *info; if (size < sizeof(uint32_t)) { return; @@ -502,14 +502,20 @@ static void vdagent_clipboard_recv_data(VDAgentChardev *vd, uint8_t s, uint32_t } data += 4; size -= 4; - qemu_clipboard_set_data(&vd->cbpeer, vd->cbinfo[s], type, size, data, true); + + info = qemu_clipboard_info(s); + if (info->owner == &vd->cbpeer) { + qemu_clipboard_set_data(&vd->cbpeer, info, type, size, data, true); + } } static void vdagent_clipboard_recv_release(VDAgentChardev *vd, uint8_t s) { + QemuClipboardInfo *cur; g_autoptr(QemuClipboardInfo) info = NULL; - if (vd->cbinfo[s] && vd->cbinfo[s]->owner == &vd->cbpeer) { + cur = qemu_clipboard_info(s); + if (cur && cur->owner == &vd->cbpeer) { /* set empty clipboard info */ info = qemu_clipboard_info_new(NULL, s); qemu_clipboard_update(info); From patchwork Wed Jul 21 08:41:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 1508024 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=TccvDifW; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GV8Wz1Lxkz9sWd for ; Wed, 21 Jul 2021 18:54:07 +1000 (AEST) Received: from localhost ([::1]:54570 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m67zQ-0003Ni-U0 for incoming@patchwork.ozlabs.org; Wed, 21 Jul 2021 04:54:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33516) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m67ol-000115-FX for qemu-devel@nongnu.org; Wed, 21 Jul 2021 04:43:03 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:22253) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m67oj-0005ct-N8 for qemu-devel@nongnu.org; Wed, 21 Jul 2021 04:43:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626856981; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=j9c83z6wiL8GF/bT0bHj/Ul4bxjF1Y2+EXIDB94Ucig=; b=TccvDifWnADPCsKBn1+j79QyaEaXGgLmTahyWL3YhrN7Sobr/1Ux/BhG8INwyhgQIiPHHr PWB1UHZO3KBoFnzVmcJ8B9SYo/gH3/35MK5Y3vUzK+ZjamFtJ5Xkt3ST9YyJryeDi6Mvxg FZpjI2Rz/22qNAl4WGIUXAYNxkoskIU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-460-U0PKzoMkOGG8BHMi0kn1Kg-1; Wed, 21 Jul 2021 04:42:59 -0400 X-MC-Unique: U0PKzoMkOGG8BHMi0kn1Kg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DDAA210150A5 for ; Wed, 21 Jul 2021 08:42:58 +0000 (UTC) Received: from localhost (unknown [10.36.110.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0F9C160BF1; Wed, 21 Jul 2021 08:42:57 +0000 (UTC) From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PATCH v2 11/13] ui/gtk-clipboard: use qemu_clipboard_info helper Date: Wed, 21 Jul 2021 12:41:37 +0400 Message-Id: <20210721084139.1124779-12-marcandre.lureau@redhat.com> In-Reply-To: <20210721084139.1124779-1-marcandre.lureau@redhat.com> References: <20210721084139.1124779-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.474, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , kraxel@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Marc-André Lureau Signed-off-by: Marc-André Lureau --- include/ui/gtk.h | 1 - ui/gtk-clipboard.c | 14 ++++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/include/ui/gtk.h b/include/ui/gtk.h index 9516670ebc..60e9cdc39c 100644 --- a/include/ui/gtk.h +++ b/include/ui/gtk.h @@ -139,7 +139,6 @@ struct GtkDisplayState { bool external_pause_update; QemuClipboardPeer cbpeer; - QemuClipboardInfo *cbinfo[QEMU_CLIPBOARD_SELECTION__COUNT]; uint32_t cbpending[QEMU_CLIPBOARD_SELECTION__COUNT]; GtkClipboard *gtkcb[QEMU_CLIPBOARD_SELECTION__COUNT]; bool cbowner[QEMU_CLIPBOARD_SELECTION__COUNT]; diff --git a/ui/gtk-clipboard.c b/ui/gtk-clipboard.c index 2c78de9500..4e4b3c52bb 100644 --- a/ui/gtk-clipboard.c +++ b/ui/gtk-clipboard.c @@ -45,24 +45,24 @@ static void gd_clipboard_get_data(GtkClipboard *clipboard, GtkDisplayState *gd = data; QemuClipboardSelection s = gd_find_selection(gd, clipboard); QemuClipboardType type = QEMU_CLIPBOARD_TYPE_TEXT; - QemuClipboardInfo *info = qemu_clipboard_info_ref(gd->cbinfo[s]); + g_autoptr(QemuClipboardInfo) info = NULL; + + info = qemu_clipboard_info_ref(qemu_clipboard_info(s)); qemu_clipboard_request(info, type); - while (info == gd->cbinfo[s] && + while (info == qemu_clipboard_info(s) && info->types[type].available && info->types[type].data == NULL) { main_loop_wait(false); } - if (info == gd->cbinfo[s] && gd->cbowner[s]) { + if (info == qemu_clipboard_info(s) && gd->cbowner[s]) { gtk_selection_data_set_text(selection_data, info->types[type].data, info->types[type].size); } else { /* clipboard owner changed while waiting for the data */ } - - qemu_clipboard_info_unref(info); } static void gd_clipboard_clear(GtkClipboard *clipboard, @@ -81,9 +81,7 @@ static void gd_clipboard_notify(Notifier *notifier, void *data) QemuClipboardSelection s = info->selection; bool self_update = info->owner == &gd->cbpeer; - if (info != gd->cbinfo[s]) { - qemu_clipboard_info_unref(gd->cbinfo[s]); - gd->cbinfo[s] = qemu_clipboard_info_ref(info); + if (info != qemu_clipboard_info(s)) { gd->cbpending[s] = 0; if (!self_update) { GtkTargetList *list; From patchwork Wed Jul 21 08:41:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 1508013 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=R7bDOphf; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GV8Km1rp9z9sWX for ; Wed, 21 Jul 2021 18:45:16 +1000 (AEST) Received: from localhost ([::1]:59258 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m67qr-0004Ax-Up for incoming@patchwork.ozlabs.org; Wed, 21 Jul 2021 04:45:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33528) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m67op-0001Hk-My for qemu-devel@nongnu.org; Wed, 21 Jul 2021 04:43:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:24648) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m67oo-0005fv-3l for qemu-devel@nongnu.org; Wed, 21 Jul 2021 04:43:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626856985; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EWkh/wtLFRZY9CylXtq3NuAaKqDyien2TpzZuEmEdaU=; b=R7bDOphfpg5f8zTQrH1uKOoiMD6na/eyWhlOtGh9l4b16I2rOaVCBla80Q5vbBX0qzMzYL nkxTi1hnb891//1vktf5vCxcnDpCksMLGCKH57wtGRxSok7y34GygjQAb2lOuJMEmoT71I pZdJrX0qJFyYpC1dKDH2dUhOYoWDXVY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-546-TshFtXTjMMyU3y70zdBb7A-1; Wed, 21 Jul 2021 04:43:04 -0400 X-MC-Unique: TshFtXTjMMyU3y70zdBb7A-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 64A2A801F97 for ; Wed, 21 Jul 2021 08:43:03 +0000 (UTC) Received: from localhost (unknown [10.36.110.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3D67560CCC; Wed, 21 Jul 2021 08:43:01 +0000 (UTC) From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PATCH v2 12/13] ui/vdagent: send release when no clipboard owner Date: Wed, 21 Jul 2021 12:41:38 +0400 Message-Id: <20210721084139.1124779-13-marcandre.lureau@redhat.com> In-Reply-To: <20210721084139.1124779-1-marcandre.lureau@redhat.com> References: <20210721084139.1124779-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.474, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , kraxel@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Marc-André Lureau Signed-off-by: Marc-André Lureau --- ui/vdagent.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/ui/vdagent.c b/ui/vdagent.c index bc8347f995..efb4546045 100644 --- a/ui/vdagent.c +++ b/ui/vdagent.c @@ -345,6 +345,24 @@ static void vdagent_send_clipboard_grab(VDAgentChardev *vd, vdagent_send_msg(vd, msg); } +static void vdagent_send_clipboard_release(VDAgentChardev *vd, + QemuClipboardInfo *info) +{ + g_autofree VDAgentMessage *msg = g_malloc0(sizeof(VDAgentMessage) + + sizeof(uint32_t)); + + if (have_selection(vd)) { + uint8_t *s = msg->data; + *s = info->selection; + msg->size += sizeof(uint32_t); + } else if (info->selection != QEMU_CLIPBOARD_SELECTION_CLIPBOARD) { + return; + } + + msg->type = VD_AGENT_CLIPBOARD_RELEASE; + vdagent_send_msg(vd, msg); +} + static void vdagent_send_clipboard_data(VDAgentChardev *vd, QemuClipboardInfo *info, QemuClipboardType type) @@ -386,7 +404,11 @@ static void vdagent_clipboard_notify(Notifier *notifier, void *data) if (info != qemu_clipboard_info(s)) { vd->cbpending[s] = 0; if (!self_update) { - vdagent_send_clipboard_grab(vd, info); + if (info->owner) { + vdagent_send_clipboard_grab(vd, info); + } else { + vdagent_send_clipboard_release(vd, info); + } } return; } From patchwork Wed Jul 21 08:41:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 1508021 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ah7v30h7; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GV8Sx1Jxfz9sWX for ; Wed, 21 Jul 2021 18:51:29 +1000 (AEST) Received: from localhost ([::1]:48678 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m67ws-0007Yo-UP for incoming@patchwork.ozlabs.org; Wed, 21 Jul 2021 04:51:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33542) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m67p1-0001pg-Mm for qemu-devel@nongnu.org; Wed, 21 Jul 2021 04:43:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:50154) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m67p0-0005ot-97 for qemu-devel@nongnu.org; Wed, 21 Jul 2021 04:43:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626856997; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1JN7UrKol7qbbldXYzHlGAwiFdzqulFx27Pl4PCm2Ok=; b=ah7v30h7QOnT8v9iq3lizHxtuQlSHe0rhRBQ3GTvocME3O8TP0/fXP85d8etobfYVE2HyC yKcj8akthTdOG/4/GLe6Rh+qp7nC5PlqC/oMvhaIphYJsABE7HQwiWay5ziR/vD/Ym26k2 shNkoLekU0q5/PP1c+hkb9XnD3nsnnU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-156-X1BG1H5KNUW6HT1Vlz6dHQ-1; Wed, 21 Jul 2021 04:43:16 -0400 X-MC-Unique: X1BG1H5KNUW6HT1Vlz6dHQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A193A800D62 for ; Wed, 21 Jul 2021 08:43:15 +0000 (UTC) Received: from localhost (unknown [10.36.110.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 53EBD19C79; Wed, 21 Jul 2021 08:43:07 +0000 (UTC) From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PATCH v2 13/13] ui/gtk-clipboard: emit release clipboard events Date: Wed, 21 Jul 2021 12:41:39 +0400 Message-Id: <20210721084139.1124779-14-marcandre.lureau@redhat.com> In-Reply-To: <20210721084139.1124779-1-marcandre.lureau@redhat.com> References: <20210721084139.1124779-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.474, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , kraxel@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Marc-André Lureau Signed-off-by: Marc-André Lureau --- ui/gtk-clipboard.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ui/gtk-clipboard.c b/ui/gtk-clipboard.c index 4e4b3c52bb..16b2e2063e 100644 --- a/ui/gtk-clipboard.c +++ b/ui/gtk-clipboard.c @@ -144,7 +144,7 @@ static void gd_owner_change(GtkClipboard *clipboard, { GtkDisplayState *gd = data; QemuClipboardSelection s = gd_find_selection(gd, clipboard); - QemuClipboardInfo *info; + g_autoptr(QemuClipboardInfo) info = NULL; if (gd->cbowner[s]) { /* ignore notifications about our own grabs */ @@ -158,13 +158,13 @@ static void gd_owner_change(GtkClipboard *clipboard, if (gtk_clipboard_wait_is_text_available(clipboard)) { info->types[QEMU_CLIPBOARD_TYPE_TEXT].available = true; } - - qemu_clipboard_update(info); - qemu_clipboard_info_unref(info); break; default: + info = qemu_clipboard_info_new(NULL, s); + gd->cbowner[s] = false; break; } + qemu_clipboard_update(info); } void gd_clipboard_init(GtkDisplayState *gd)