From nobody Sat May 18 10:48:36 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641145434424164.0247433318441; Sun, 2 Jan 2022 09:43:54 -0800 (PST) Received: from localhost ([::1]:42312 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n44td-0000ce-Em for importer@patchew.org; Sun, 02 Jan 2022 12:43:53 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44236) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n44rr-0006KS-Bh; Sun, 02 Jan 2022 12:42:04 -0500 Received: from [2a00:1450:4864:20::32d] (port=52820 helo=mail-wm1-x32d.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n44rp-0003lY-QM; Sun, 02 Jan 2022 12:42:03 -0500 Received: by mail-wm1-x32d.google.com with SMTP id g132so20266284wmg.2; Sun, 02 Jan 2022 09:42:01 -0800 (PST) Received: from localhost.localdomain (201.11.75.194.dyn.plus.net. [194.75.11.201]) by smtp.googlemail.com with ESMTPSA id w9sm1626565wrq.70.2022.01.02.09.41.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Jan 2022 09:42:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:signed-off-by:content-transfer-encoding; bh=uCyL1Q9YZmojI8gjUnStkPWS7TvApbOtoS+o3RyLBNk=; b=jwhzm/HD9ToSjyfYQPGe5oB8CaYAwm1Bwnb92xNRgED1FPhD/5Ev44eRbnpkTDmbIG 5DWPF0fdqjd4QudAq3hEzoNGUdgO1KJxqf6khjR28e0Oyi35SCBHEsRu4zeltmMNzIx1 ljb91eDe874rzt4OXSaU1OOL7okrzyfuLULD2Sy9BGaOY6EV7ERZCyBKEp2Q9U5zZFTi poGXDZS7U5Tk1PP4kH4LjzjcBDwBEOu0ZDtZFRxVogXYDa5sjTmCuqP/QgZM8ZiNnV2G rge3Uu0jd72O5Yh312bU0rKKqnXNS0YbRChzzYV6cIIw7j6Fw6UNEfcKSD8K8gZnZwZ9 QpOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:signed-off-by:content-transfer-encoding; bh=uCyL1Q9YZmojI8gjUnStkPWS7TvApbOtoS+o3RyLBNk=; b=5f1Z7ER6w5gWPIFFod0DmMihTmjIHccfeGNk6oriPmsFMnGO7OiyjjQAn7O/EerHPA K5MWysjMXqB643UpJYTP6QN672JUCk9fXvMJnjqxaaVQkLQWnRBhQhnhbFXEITil1HTI nVYv8zdSjWab1/ez5qfc4wa7RIawbEM5uK97bmvpagZuS7SC0IHM4bB33Bjt3jLexn+2 b9HOXuzI2YN8gctk9T0eF012Z1Xtcnpj+LLSrKJ24r1QGsa7pqjLEzlO6uIIb3T/wBV1 dpZ81T0mw8lHfsN0MfiA8u2EvfG/Hpe3yJzqQKCXo0I2PqpUkqDoaXy59X2Zqj3Y/8GD rdjw== X-Gm-Message-State: AOAM531TTdGozcNenqDKEs028SDQkgstASXeb2LAP+hJWwqm+vyVlunF pKMIG1VaMNhrrvm2JLYCN0U+10teYAM= X-Google-Smtp-Source: ABdhPJyrM8Y48NkXiitJUY8nX53eoiwOt/uF+/RPf6zkVkQeOpqf+Bt+G6INrEypDn3uLrT0qzgNiA== X-Received: by 2002:a1c:4644:: with SMTP id t65mr35921020wma.116.1641145320164; Sun, 02 Jan 2022 09:42:00 -0800 (PST) From: Carwyn Ellis To: qemu-devel@nongnu.org Subject: [PATCH 1/2] ui/cocoa: add option to disable left-command forwarding to guest Date: Sun, 2 Jan 2022 17:41:52 +0000 Message-Id: <20220102174153.70043-2-carwynellis@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220102174153.70043-1-carwynellis@gmail.com> References: <20220102174153.70043-1-carwynellis@gmail.com> MIME-Version: 1.0 Signed-off-by: Carwyn Ellis Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::32d (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=carwynellis@gmail.com; helo=mail-wm1-x32d.google.com X-Spam_score_int: 6 X-Spam_score: 0.6 X-Spam_bar: / X-Spam_report: (0.6 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-trivial@nongnu.org, peter.maydell@linaro.org, Carwyn Ellis Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641145435351100001 Content-Type: text/plain; charset="utf-8" When switching between guest and host on a Mac using command-tab the command key is sent to the guest which can trigger functionality in the guest OS. Specifying left-command-key=3Doff disables forwarding this key to the guest. Defaults to enabled. Also updated the cocoa display documentation to reference the new left-command-key option along with the existing show-cursor option. Signed-off-by: Carwyn Ellis Reviewed-by: Akihiko Odaki --- qapi/ui.json | 17 +++++++++++++++++ qemu-options.hx | 12 ++++++++++++ ui/cocoa.m | 8 +++++++- 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/qapi/ui.json b/qapi/ui.json index 2b4371da37..764480e145 100644 --- a/qapi/ui.json +++ b/qapi/ui.json @@ -1107,6 +1107,22 @@ 'data' : { '*grab-on-hover' : 'bool', '*zoom-to-fit' : 'bool' } } =20 +## +# @DisplayCocoa: +# +# Cocoa display options. +# +# @left-command-key: Enable/disable forwarding of left command key to +# guest. Allows command-tab window switching on the +# host without sending this key to the guest when +# "off". Defaults to "on" +# +# Since: 6.2.50 +# +## +{ 'struct' : 'DisplayCocoa', + 'data' : { '*left-command-key' : 'bool' } } + ## # @DisplayEGLHeadless: # @@ -1254,6 +1270,7 @@ 'discriminator' : 'type', 'data' : { 'gtk': { 'type': 'DisplayGTK', 'if': 'CONFIG_GTK' }, + 'cocoa': { 'type': 'DisplayCocoa', 'if': 'CONFIG_COCOA' }, 'curses': { 'type': 'DisplayCurses', 'if': 'CONFIG_CURSES' }, 'egl-headless': { 'type': 'DisplayEGLHeadless', 'if': { 'all': ['CONFIG_OPENGL', 'CONFIG_GBM'] } }, diff --git a/qemu-options.hx b/qemu-options.hx index fd1f8135fb..6fa9c38c83 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -1912,6 +1912,9 @@ DEF("display", HAS_ARG, QEMU_OPTION_display, #if defined(CONFIG_DBUS_DISPLAY) "-display dbus[,addr=3D]\n" " [,gl=3Don|core|es|off][,rendernode=3D]\n" +#endif +#if defined(CONFIG_COCOA) + "-display cocoa[,show-cursor=3Don|off][,left-command-key=3Don|off]\n" #endif "-display none\n" " select display backend type\n" @@ -1999,6 +2002,15 @@ SRST ``charset=3DCP850`` for IBM CP850 encoding. The default is ``CP437``. =20 + ``cocoa`` + Display video output in a Cocoa window. Mac only. This interface + provides drop-down menus and other UI elements to configure and + control the VM during runtime. Valid parameters are: + + ``show-cursor=3Don|off`` : Force showing the mouse cursor + + ``left-command-key=3Don|off`` : Disable forwarding left command ke= y to host + ``egl-headless[,rendernode=3D]`` Offload all OpenGL operations to a local DRI device. For any graphical display, this display needs to be paired with either diff --git a/ui/cocoa.m b/ui/cocoa.m index 69745c483b..01045d6698 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -95,6 +95,7 @@ static DisplayChangeListener dcl =3D { }; static int last_buttons; static int cursor_hide =3D 1; +static int left_command_key_enabled =3D 1; =20 static int gArgc; static char **gArgv; @@ -834,7 +835,8 @@ QemuCocoaView *cocoaView; /* Don't pass command key changes to guest unless mouse is= grabbed */ case kVK_Command: if (isMouseGrabbed && - !!(modifiers & NSEventModifierFlagCommand)) { + !!(modifiers & NSEventModifierFlagCommand) && + left_command_key_enabled) { [self toggleKey:Q_KEY_CODE_META_L]; } break; @@ -2054,6 +2056,10 @@ static void cocoa_display_init(DisplayState *ds, Dis= playOptions *opts) cursor_hide =3D 0; } =20 + if (opts->u.cocoa.has_left_command_key && !opts->u.cocoa.left_command_= key) { + left_command_key_enabled =3D 0; + } + // register vga output callbacks register_displaychangelistener(&dcl); =20 --=20 2.34.1 From nobody Sat May 18 10:48:36 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641145399155641.2814808142804; Sun, 2 Jan 2022 09:43:19 -0800 (PST) Received: from localhost ([::1]:41468 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n44t3-0008VO-OV for importer@patchew.org; Sun, 02 Jan 2022 12:43:17 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44250) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n44rs-0006Kg-Sf; Sun, 02 Jan 2022 12:42:04 -0500 Received: from [2a00:1450:4864:20::42e] (port=33642 helo=mail-wr1-x42e.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n44rr-0003lj-3M; Sun, 02 Jan 2022 12:42:04 -0500 Received: by mail-wr1-x42e.google.com with SMTP id d9so65918405wrb.0; Sun, 02 Jan 2022 09:42:02 -0800 (PST) Received: from localhost.localdomain (201.11.75.194.dyn.plus.net. [194.75.11.201]) by smtp.googlemail.com with ESMTPSA id w9sm1626565wrq.70.2022.01.02.09.42.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Jan 2022 09:42:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:signed-off-by:content-transfer-encoding; bh=pHCAwqns1twtPFixgldOfBOPXptGKHgFxpFDmDRmBVg=; b=lAl50+GPB3pIhLuudiXTIDrYGSifmxGpOpu6yCoZWHPpLeV4u44stFn5/PMNlAhwwM B/KcIO7zAuBIQaC1M5POM3DCI8zrOBQ9HVWBVfzvCkB74BVg576cgrCtidDhmxD4S57e zzuX65SjAHLEzwqEfrvOqbtf296e4wm8KnMm941gQU+e+AhKNWUH+4SuhUepI7v/9EV0 RNpd//gxFUk5oA1iVI74yzAvRblMfW1FdU8x6yrSRqFUOBSa+zeDryMk77b3EKaQmLi2 iKDXM0A8HmAG/+QFi/xPDWx7O+zjCsYYlOr686s6oY8kn0BGauAkzhI5f7NIjKSPBpaA oFjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:signed-off-by:content-transfer-encoding; bh=pHCAwqns1twtPFixgldOfBOPXptGKHgFxpFDmDRmBVg=; b=AYocj8MFIFlyqg/pgWL6DJfVsG3b2qBqyg+glAL5mHmGJYj+TryZFZ48F3GEs/7BKU bX1NglzX6uAESRmcYfCaIq10og45P3Csp71eQCZkQP/wDvgpjN2puTimmMiRqQipylFt b/GVaycYkeXh1g5OHlTYlcZIzPiXyyDISTRByxo6dxQcGXwOD9D+4I1OdeWcIp8e4L21 cD+aGSqJK9A9Lc4rCs5j5e1+LtYcZ2SIIFAcv3g6WZpuFziNsLZaITVsddWsa+Fw5bNS qZY4hqMBZqaQmyNPm2K+PlnN3w7WGv89X5g4qhXk9BkGC96gwBd/zoT9heu0ZakepIMZ p/DQ== X-Gm-Message-State: AOAM533yx70dJ9ynW2BikUFBRtIYsdEf5xlARBGodx1xSLSTonCoWoaE 8Xafs1N+zUNV9p7WgJRPZnjVQp8BmVI= X-Google-Smtp-Source: ABdhPJzhNs0LfxYOMI0U/boWBDL1Yro+z7I4B7hOrlH9zDgtM+5enU/KSl9UmwZeZuYArWTpXNonSw== X-Received: by 2002:a5d:6049:: with SMTP id j9mr34787212wrt.332.1641145321566; Sun, 02 Jan 2022 09:42:01 -0800 (PST) From: Carwyn Ellis To: qemu-devel@nongnu.org Subject: [PATCH 2/2] ui/cocoa: release mouse when user switches away from QEMU window Date: Sun, 2 Jan 2022 17:41:53 +0000 Message-Id: <20220102174153.70043-3-carwynellis@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220102174153.70043-1-carwynellis@gmail.com> References: <20220102174153.70043-1-carwynellis@gmail.com> MIME-Version: 1.0 Signed-off-by: Carwyn Ellis Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::42e (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=carwynellis@gmail.com; helo=mail-wr1-x42e.google.com X-Spam_score_int: 6 X-Spam_score: 0.6 X-Spam_bar: / X-Spam_report: (0.6 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-trivial@nongnu.org, peter.maydell@linaro.org, Carwyn Ellis Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641145401678100001 Content-Type: text/plain; charset="utf-8" This resolves an issue where using command-tab to switch between QEMU and other windows on the host can leave the mouse pointer visible. By releasing the mouse when the user switches away, the user must left click on the QEMU window when switching back in order to hide the pointer and return control to the guest. This appraoch ensures that the calls to NSCursor hide and unhide are always balanced and thus work correctly when invoked. Signed-off-by: Carwyn Ellis Reviewed-by: Akihiko Odaki --- ui/cocoa.m | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ui/cocoa.m b/ui/cocoa.m index 01045d6698..3f7af4a8fa 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -1243,6 +1243,7 @@ QemuCocoaView *cocoaView; - (void) applicationWillResignActive: (NSNotification *)aNotification { COCOA_DEBUG("QemuCocoaAppController: applicationWillResignActive\n"); + [cocoaView ungrabMouse]; [cocoaView raiseAllKeys]; } =20 @@ -2052,6 +2053,7 @@ static void cocoa_display_init(DisplayState *ds, Disp= layOptions *opts) [(QemuCocoaAppController *)[[NSApplication sharedApplication] = delegate] toggleFullScreen: nil]; }); } + if (opts->has_show_cursor && opts->show_cursor) { cursor_hide =3D 0; } --=20 2.34.1