From patchwork Tue Mar 5 11:05:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 777974 Delivered-To: patch@linaro.org Received: by 2002:a5d:48c8:0:b0:33e:474f:8c56 with SMTP id p8csp372399wrs; Tue, 5 Mar 2024 03:08:27 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCX5ew/INQlIoLTRIxWlv0iK66AIBCnYez/crUAkEZMuDIyA7jkAK1MdiB2xVSLlmdQIZn6vyjNgsUq75RXl3dh0 X-Google-Smtp-Source: AGHT+IGKI7V/hTke6pX3G8GD5FQm8K5ty+aR9tR9rXJ79n9YfPehwywC7iV/bakJyjo0gEpVtfX7 X-Received: by 2002:a05:620a:1996:b0:788:38ff:573f with SMTP id bm22-20020a05620a199600b0078838ff573fmr605000qkb.15.1709636907767; Tue, 05 Mar 2024 03:08:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709636907; cv=none; d=google.com; s=arc-20160816; b=tNQ40DLqJpzeVNH+uJG2HojNYurhLCRlhHDBzDaL8hx2oCSdJorjh+BEKbSuxlrISD LuDeU8Pb44NacfE3zILnF+wCoAzjTkCVqiQ/TneOm+WqtgikQHOK/rNFF0jEOgabUkMt 7u3uTK/BIE6YJDZccAYjZoShKFCeK1uIxnMxMz1QSdFJErVDdvxA4dC8EWdtCDasT5Eu I7eQlScZxH8vE22np13TvNcf6W3Ch8Z2Ovdl0tHytiD6Etmhl9rb/jeXQaEMi8dn1fUJ 5IIk9Fu1uHdx/7KZtXBzzLiUqXB9PyZgYN5sOFbfMUNzE7KOfZBDxaoNQwtrTOtxVjJf cqDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Orv4djFB2EMOeVxvQYFyiboh//axFe5wKfX2XCTUXLY=; fh=rJtPWjFQEoUWDlbhLpLvijUXkqLVduvBbobaQca7o6U=; b=Irij1gtQtWwMIB9gZdAjHdGFz/CkVupMTA+npYcTZifhZ2nAzc7t4CR+diTQvq1cfx HR106jCZQ5xuZ+MLn9n3TsU9ORX8bXQGj6+CbE6BkB6GFlZ/lqEE2AO87qaC8jvK87Xg R2rm6jmOZ0mY2N+ZpYbmpzy84Cn7yIiyOZgJJLLiD/f4O7pvkzeSnHpp4QA/d9zrQ26g /D44YOLB5d/xML8DfxURLxUh2mR0pXOwTy5+ISIJAAMfF8xyrTyTDatDXqD9XgGigpxI 5JmoHJHK+sERtF2RxkjJEMU/zwGVgTzXpM4PF2Xw3DKjCTaoRy3jk397R5uBZSAlVd/i nJRQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qso+0RED; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id dv12-20020a05620a1b8c00b00788248873f7si5663530qkb.407.2024.03.05.03.08.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Mar 2024 03:08:27 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qso+0RED; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhSdP-00080Q-13; Tue, 05 Mar 2024 06:06:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhSdB-0007kK-Ac for qemu-devel@nongnu.org; Tue, 05 Mar 2024 06:06:49 -0500 Received: from mail-ed1-x529.google.com ([2a00:1450:4864:20::529]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhSd5-0002mP-ND for qemu-devel@nongnu.org; Tue, 05 Mar 2024 06:06:45 -0500 Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-5656e5754ccso6960723a12.0 for ; Tue, 05 Mar 2024 03:06:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709636798; x=1710241598; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Orv4djFB2EMOeVxvQYFyiboh//axFe5wKfX2XCTUXLY=; b=qso+0REDb2TDP52z5pu2LYECBb87e2BmiifViJlYlXR1HHvw3waFVHKHJxFothz++b 3r1ePWQbVmXWhBY6wMH5xyt3O7XKBNZ7U7kjiEbE2vObPD0WguVAb/aMnehFeSKHAMLW Oqyq1O4qiD+ahZDGWIFW82oc3Ez2z75nkBTqumu0S8sIdD1MBlkQWcDPLuhUv4qrcBZ9 Jq56Yu/gIIz9rE8bgxkzgWD4qa81Q+coXmo6zzsxSFg2Zg25qdKxORZf4JTfOniohxIj Tn7YurYtNS3fmL78Ku4rqZSKEKDEFXvhKWghXskupRjcquwRZAZIG0pav4w+wcFao0vJ f0Ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709636798; x=1710241598; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Orv4djFB2EMOeVxvQYFyiboh//axFe5wKfX2XCTUXLY=; b=mBeEx3zFiZlMdKo/QCHcGn1C+y4/Nx2DZpQBbvOyLQjCu6YTChgJl+6UgoiqAhrK9A cTIJ8Q7qQKbB/6A4cnEMu2QAG9QFZE2j2MPzll+qpBf7X7EVgqi9MUO1mWpDA69+kW9q kNTTSjPz4HK7x9rGnkxaO/W6lHquOJ2qsaXG3ta56Uy6+uDOhTvlIkqnazNAOOHzGlLC FNAtlYUFD/TcoK6YCcl7arp9vrf6lugKwevxaDU/vCAHhkQyBXl9IFnJQUNOccGNI03x /cVEfYq4/FmwZdwkXfKUuhfYgvBhrCESNmxIwQGuy/nH9cEPp94bYzSO4h0XujVQxBxN HY+w== X-Gm-Message-State: AOJu0YySLw4KgqbhQekGILP/qQ2ynRku9f5mxGBZovhboY9a/LU4vUYn 5WAsweKGahzNS4pbxLZHQuh1WSE7wADjVQoVj90TZ8CMYbTFG1ouEmrObUlMfRuLR43Oo5hsXYz 3 X-Received: by 2002:a05:6512:110a:b0:513:33ad:2099 with SMTP id l10-20020a056512110a00b0051333ad2099mr1152533lfg.63.1709636776986; Tue, 05 Mar 2024 03:06:16 -0800 (PST) Received: from m1x-phil.lan ([176.176.177.70]) by smtp.gmail.com with ESMTPSA id um15-20020a170906cf8f00b00a443e6f9403sm5923651ejb.54.2024.03.05.03.06.15 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 05 Mar 2024 03:06:16 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Carwyn Ellis , Akihiko Odaki , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Gerd Hoffmann , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Eric Blake , Markus Armbruster , Peter Maydell Subject: [PULL 01/12] ui/cocoa: add zoom-interpolation display option Date: Tue, 5 Mar 2024 12:05:56 +0100 Message-ID: <20240305110608.21618-2-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240305110608.21618-1-philmd@linaro.org> References: <20240305110608.21618-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::529; envelope-from=philmd@linaro.org; helo=mail-ed1-x529.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Carwyn Ellis Provides a new display option, zoom-interpolation, that enables interpolation of the scaled display when zoom-to-fit is enabled. Also provides a corresponding view menu item to allow this to be toggled as required. Signed-off-by: Carwyn Ellis Reviewed-by: Akihiko Odaki Message-ID: <20231110161729.36822-2-carwynellis@gmail.com> [PMD: QAPI @zoom-interpolation since 9.0] Signed-off-by: Philippe Mathieu-Daudé --- qapi/ui.json | 6 +++++- ui/cocoa.m | 21 ++++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/qapi/ui.json b/qapi/ui.json index e3999b7c07..096a2ad26f 100644 --- a/qapi/ui.json +++ b/qapi/ui.json @@ -1428,6 +1428,9 @@ # turned off the host window will be resized instead. Defaults to # "off". (Since 8.2) # +# @zoom-interpolation: Apply interpolation to smooth output when +# zoom-to-fit is enabled. Defaults to "off". (Since 9.0) +# # Since: 7.0 ## { 'struct': 'DisplayCocoa', @@ -1435,7 +1438,8 @@ '*left-command-key': 'bool', '*full-grab': 'bool', '*swap-opt-cmd': 'bool', - '*zoom-to-fit': 'bool' + '*zoom-to-fit': 'bool', + '*zoom-interpolation': 'bool' } } ## diff --git a/ui/cocoa.m b/ui/cocoa.m index eb99064bee..b7ca0ed94b 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -105,6 +105,7 @@ static void cocoa_switch(DisplayChangeListener *dcl, static bool swap_opt_cmd; static bool stretch_video; +static CGInterpolationQuality zoom_interpolation = kCGInterpolationNone; static NSTextField *pauseLabel; static bool allow_events; @@ -455,7 +456,7 @@ - (void) drawRect:(NSRect) rect // get CoreGraphic context CGContextRef viewContextRef = [[NSGraphicsContext currentContext] CGContext]; - CGContextSetInterpolationQuality (viewContextRef, kCGInterpolationNone); + CGContextSetInterpolationQuality (viewContextRef, zoom_interpolation); CGContextSetShouldAntialias (viewContextRef, NO); // draw screen bitmap directly to Core Graphics context @@ -1411,6 +1412,17 @@ - (void)zoomToFit:(id) sender } } +- (void)toggleZoomInterpolation:(id) sender +{ + if (zoom_interpolation == kCGInterpolationNone) { + zoom_interpolation = kCGInterpolationLow; + [sender setState: NSControlStateValueOn]; + } else { + zoom_interpolation = kCGInterpolationNone; + [sender setState: NSControlStateValueOff]; + } +} + /* Displays the console on the screen */ - (void)displayConsole:(id)sender { @@ -1673,6 +1685,9 @@ static void create_initial_menus(void) menuItem = [[[NSMenuItem alloc] initWithTitle:@"Zoom To Fit" action:@selector(zoomToFit:) keyEquivalent:@""] autorelease]; [menuItem setState: stretch_video ? NSControlStateValueOn : NSControlStateValueOff]; [menu addItem: menuItem]; + menuItem = [[[NSMenuItem alloc] initWithTitle:@"Zoom Interpolation" action:@selector(toggleZoomInterpolation:) keyEquivalent:@""] autorelease]; + [menuItem setState: zoom_interpolation == kCGInterpolationLow ? NSControlStateValueOn : NSControlStateValueOff]; + [menu addItem: menuItem]; menuItem = [[[NSMenuItem alloc] initWithTitle:@"View" action:nil keyEquivalent:@""] autorelease]; [menuItem setSubmenu:menu]; [[NSApp mainMenu] addItem:menuItem]; @@ -2070,6 +2085,10 @@ static void cocoa_display_init(DisplayState *ds, DisplayOptions *opts) stretch_video = true; } + if (opts->u.cocoa.has_zoom_interpolation && opts->u.cocoa.zoom_interpolation) { + zoom_interpolation = kCGInterpolationLow; + } + create_initial_menus(); /* * Create the menu entries which depend on QEMU state (for consoles From patchwork Tue Mar 5 11:05:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 777968 Delivered-To: patch@linaro.org Received: by 2002:a5d:48c8:0:b0:33e:474f:8c56 with SMTP id p8csp371889wrs; Tue, 5 Mar 2024 03:07:22 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCX1VWuiTwjoiTA5hiJyVGNaGF1T0MEFxyaQ3I2/jEXobSSXSqCyWOI1hoTTV++3KeEE2iZGzQGc7Hd6S0jYUPac X-Google-Smtp-Source: AGHT+IFKYfyzLZ5jTov1Cf4Vt5me9RztdT/sIsUHHjCi/lnktbJIh+Nt7NDzncfJCGxogpixqomw X-Received: by 2002:a05:6870:2151:b0:21e:fc35:73ef with SMTP id g17-20020a056870215100b0021efc3573efmr1441596oae.38.1709636842268; Tue, 05 Mar 2024 03:07:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709636842; cv=none; d=google.com; s=arc-20160816; b=u9b0226p77aP9glK1YV7pDIA94I2eIfZsFo2WbpcX0ZT96clTL15Fd4J3bxJ7PCsri 0EnMFg7ENEK9441dDlpUUm3o5ogHCKDF/p1HgyvtgIjonf4CJTGdJYp53G2+vZtu+U/b VQ1oGsKlhmB9lM4+WO65wg8DQmKD+Dwql27c38drVQE5NVS8qqGimSuf1EeYb2by+lNR KJJdLWFRnAaqdr+niPYGLRInqRHzy8YZXcHj1BOu0woC+c6uqfnCANfaxMACNE4tWqmg MUlGmGVt/A8Xf6x49gLO/ZmA7kVc1mxIh+VnlrANdnmebXm1JNtBYKdlW/v0mvog8McM /ayg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Sv16H9PKGwJGLVBAig4t3MlBJQ0Q5jant0j1NpS60/0=; fh=cmtn7s+bxtvEQr7W4Z6Ur3MtqGzzC5CmRSKORhwKJKo=; b=Aj7UTb1g0+Mj5YzsWp4YlH7teh+HGRnqY3BTTbQ6fgbyLS3XNUn0yfYL4mA80CYumU kJhwJa0nuY7LsAiE0v70U6AJrh37QXfBoC4UqHwnA+2w25AatyQdpv1j9o0VtraKve0w WDJmN/8Wi4QKkc+vjNsPWJD/O5JYN20nsyainaLNogh+byO6ephTvLptc9UzpCioINpR NeA3IQJxCBSCm0GfrcnkMhsXnmKkfp6S2o7ZhRFKRn0+8nI2DO04qUw9vyhRrn0Klj1J UwXwGJ0j2kDHIss9XlAVI4R3YptywPFcIKsu+l78hhPL1jhVgcCxZf3NUeRu7ByKcWnI 70aA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="K/PSD++d"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id m4-20020a05620a214400b0078822aa9fb9si5420929qkm.467.2024.03.05.03.07.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Mar 2024 03:07:22 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="K/PSD++d"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhScx-0007Zw-86; Tue, 05 Mar 2024 06:06:31 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhScv-0007Zk-60 for qemu-devel@nongnu.org; Tue, 05 Mar 2024 06:06:29 -0500 Received: from mail-ed1-x52f.google.com ([2a00:1450:4864:20::52f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhScr-0002kH-3b for qemu-devel@nongnu.org; Tue, 05 Mar 2024 06:06:28 -0500 Received: by mail-ed1-x52f.google.com with SMTP id 4fb4d7f45d1cf-5645960cd56so638356a12.1 for ; Tue, 05 Mar 2024 03:06:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709636783; x=1710241583; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Sv16H9PKGwJGLVBAig4t3MlBJQ0Q5jant0j1NpS60/0=; b=K/PSD++dLYSuEFr/KzAucWEs1sSh8Uci0nBn4lnZwUc8Cj5pCbjoTc5XPZYOeXlW83 PbKalhDt1ySaZvj11BDpeE5eHM5VT3blv57SwJCknNXimRJJH7UXJfbk6NGMAqcbWaox XwFRo7hXQ7gGheEF17gWr8VVQCjSPUnEGC+jlRcv7EUN9D22g10Sn+s8DGqRSc/osnLc jEO3D2QwsZj/1wDyGLcSf09BpuONL+yegUbZjtFXVvPrktqYA2g4SqKi96e9c/Rjr1ZJ Sdv/fGRPbB/4hmZ2mC/YQi5zDKqMxTOMCZinRb2+pwBvHf8Dvz1xJqywmN4ehtr8KQxh gDXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709636783; x=1710241583; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Sv16H9PKGwJGLVBAig4t3MlBJQ0Q5jant0j1NpS60/0=; b=Qzw40Y8qyE4JtEm0veozT83WIwYSqPL8TlNPP5HArI1IPEnopDUZQl7sbi+Nse7zdV v9E6F/lc9SOG0GHi5nOAAq+yq04g6DGuJhMTIKzieJcReqm0J7S1MKLNFfF4j+TeqEfZ YyMYwq+Jh/n76KLOZicFJYLKLn72QC0seODzLmy1+QVzzznb51vusXA4vFZxNmifLMpN e89kAzkvdMqJVsB0WOxG/2T9IVN/AywuymiXHlIjmVxh3392d5nXnqUjckA45NyivXmK gI/Ner/YDRCSZCmjzJeQ8ZYp3EWWc3R1qoY1PKZOTVbFtsqnDx+CpBw8WdGLHjnz3WvJ o70w== X-Gm-Message-State: AOJu0YzgSNFF2MzpIuYcwvM10J0KT7wmqByvh1lKuG/YNaukp9XQZyTS fcWgaVIn0zN4yeP51ov71SqvhFwGOjLKR/wL91LQJOKRdnb91iLE5DerTdH0YtOzPzqz94nbtID o X-Received: by 2002:a05:6402:7d7:b0:567:4900:3103 with SMTP id u23-20020a05640207d700b0056749003103mr3218708edy.41.1709636782932; Tue, 05 Mar 2024 03:06:22 -0800 (PST) Received: from m1x-phil.lan ([176.176.177.70]) by smtp.gmail.com with ESMTPSA id v29-20020a50a45d000000b005649f17558bsm5956254edb.42.2024.03.05.03.06.21 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 05 Mar 2024 03:06:22 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: David Parsons , Akihiko Odaki , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Peter Maydell , Gerd Hoffmann , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Subject: [PULL 02/12] ui/cocoa: Fix window clipping on macOS 14 Date: Tue, 5 Mar 2024 12:05:57 +0100 Message-ID: <20240305110608.21618-3-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240305110608.21618-1-philmd@linaro.org> References: <20240305110608.21618-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::52f; envelope-from=philmd@linaro.org; helo=mail-ed1-x52f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: David Parsons macOS Sonoma changes the NSView.clipsToBounds to false by default where it was true in earlier version of macOS. This causes the window contents to be occluded by the frame at the top of the window. This fixes the issue by conditionally compiling the clipping on Sonoma to true. NSView only exposes the clipToBounds in macOS 14 and so has to be fixed via conditional compilation. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1994 Signed-off-by: David Parsons Reviewed-by: Akihiko Odaki Message-ID: <20240224140620.39200-1-dave@daveparsons.net> Signed-off-by: Philippe Mathieu-Daudé --- ui/cocoa.m | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ui/cocoa.m b/ui/cocoa.m index b7ca0ed94b..5618d294c4 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -54,6 +54,10 @@ #define MAC_OS_X_VERSION_10_13 101300 #endif +#ifndef MAC_OS_VERSION_14_0 +#define MAC_OS_VERSION_14_0 140000 +#endif + /* 10.14 deprecates NSOnState and NSOffState in favor of * NSControlStateValueOn/Off, which were introduced in 10.13. * Define for older versions @@ -366,6 +370,9 @@ - (id)initWithFrame:(NSRect)frameRect screen.width = frameRect.size.width; screen.height = frameRect.size.height; kbd = qkbd_state_init(dcl.con); +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_VERSION_14_0 + [self setClipsToBounds:YES]; +#endif } return self; From patchwork Tue Mar 5 11:05:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 777966 Delivered-To: patch@linaro.org Received: by 2002:a5d:48c8:0:b0:33e:474f:8c56 with SMTP id p8csp371691wrs; Tue, 5 Mar 2024 03:06:52 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXYAUvI86KTNjGZZ6diYoWGxQkrPNlMV+kt73WzeeEMzQq+HVuGudzaRwqTQai+s3CAdeCwoyMUCPNLQlDJmZxj X-Google-Smtp-Source: AGHT+IE8ZiE1svS345zy0V2l76SahNdydUmVnMi1WSpS+OewNOnVEElMDx3eWMA5sYDV8BsbO20T X-Received: by 2002:a0c:e094:0:b0:68f:b5ee:140a with SMTP id l20-20020a0ce094000000b0068fb5ee140amr1602725qvk.7.1709636812687; Tue, 05 Mar 2024 03:06:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709636812; cv=none; d=google.com; s=arc-20160816; b=MbBqJyOFmodZajU+oUSEjPgjim2y0TAOGm6xFx7xShJcgcJG77letZdQUzp3k+pF8z Mq2pOMfKqKTxbsvSONL6KupykapgnA8F3emDxsdT2nBvvul7u8GRwTN6xIY5QLymKcSB aePByGZnjd5f+vvFgR4SURf6Ld0lbch9IsYHW+3FHJvnFCOmv6/u3CwYFZihDnBSMeCb xNApqhEzCpWR5XqvyWhrO1ZIXMWm+O3Cjww7pqA1KCYP6cx0vzyvK2OE5wkgcAm6CCGu lNct0oSQJ5q1zwhSC1ylvbXwkkgpGv0WB6HE1EyZQVVT1JPI6qbLF7f954gfFTpN0OWi UkLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=02rqTQfgg62x0uwtLxpx8swa4lkknBArB8S0AINXbvk=; fh=lnLpXpuHHACtmFCFYDz84qQIx2RASFfAeprBY3P3HzE=; b=Wj4a4ZpB7oIvKT0uN5EjtELgnfLMWtZwzD7NC7iqRN5alt5RVN3kXKPBrObfnr3eM0 Js0jC1D3++04jcg7IyK0VwAzYw9K9TNopUu20hsA6TRsnHcOT6mYYASHlP59KiqWh480 mdidp4uA3DJtC2oEg2NOQz1PRPmtJkw3gM2dh98pKlilcep0fGdrAdhCG1wbgy52x3cD FKEafpINJpDMyWtFmPROQdZeF8Aoi4vmSPXtZk1KhDmrdRzvjuw/HLljKCYx76EyREQw lw1pXH+OwxYTHaqt/hu5mXudmnQYbKhU2UuYHUgkcqvzsZubAgdZNoGobdGyP+5zIeO8 WB6Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=z5nt9f6H; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 1-20020a0562140cc100b0068d01989970si11918891qvx.509.2024.03.05.03.06.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Mar 2024 03:06:52 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=z5nt9f6H; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhSdB-0007kH-4X; Tue, 05 Mar 2024 06:06:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhSd9-0007k6-Bn for qemu-devel@nongnu.org; Tue, 05 Mar 2024 06:06:43 -0500 Received: from mail-ed1-x52d.google.com ([2a00:1450:4864:20::52d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhScw-0002lB-UP for qemu-devel@nongnu.org; Tue, 05 Mar 2024 06:06:42 -0500 Received: by mail-ed1-x52d.google.com with SMTP id 4fb4d7f45d1cf-564fc495d83so6730550a12.0 for ; Tue, 05 Mar 2024 03:06:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709636789; x=1710241589; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=02rqTQfgg62x0uwtLxpx8swa4lkknBArB8S0AINXbvk=; b=z5nt9f6H7e4+3kxVwsga5xb4au3vc/KW++bq7Z/v2e65idihxAdgpTRNvqhUuJWVGi YeaqBzJPJAn5sR6mwEwaJ6+oQqJobmy4Xm/ZxcJT9K/Fr3d6G3LgHtdZdu/wl9iCp+Z8 MRF3B+itsHQBNGJ0JhbpXXadsWXVMwD741quMjd0cXhyCMTvO6bn0wuTxe1IgWiigynR vE/Xr7cmy3429P++LuMWnTFzRYdmyKJiRd6vLIlhweKqClA2lZsVQ4mg1+VUn3nq0QOy PnlDlvDEcqGHr3jSva1TlaWMKw8GZXPFPTaZ42jIX6TzQZR19YcJp6cKD84sAYm8nbKC kS0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709636789; x=1710241589; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=02rqTQfgg62x0uwtLxpx8swa4lkknBArB8S0AINXbvk=; b=PliUPwQQDt/fTvQ3i5j0y8Qh7ZXT1XlIesekOYCtAuzUbjxyxiPHuJd+BRnkOPcqA4 hGxq/OIc0EtVFtOdDClzL28Dqej0znrTiRFx6HcK/TxDHQBo/lJTeCKS+RrG0AljETAS Qb3asxc3gxFsuel6je3Dlyuo+B3oQazEZOqYQAcd6rD1iCxsIp1f7l8+wcgmBfWYexw0 0OlsrojBETLYrDUhVs3kgbjUPZtB8odqprq29qXKD3ZEiY+2Lfm75GF/zWfpwlABtR4U eiDWDvClWLX9LEQV95ABz8MAPWEbdTVoeUIrnTosm66rVBwhtnqHk0/6uRa3pzCsdy/+ LXww== X-Gm-Message-State: AOJu0YzSnKGT4OU1mngextz3mM5QVZfBGK1DDB5vIy1M9LNgE3I1DGfW G3qGf8Dqu/Ivuws/VYgVbOSvCaVlO9iwPPr+oQrTC9VKzNag5o2uXwIEvETv3giwHM4jbP5b0DP y X-Received: by 2002:a17:906:409a:b0:a45:68b5:78fd with SMTP id u26-20020a170906409a00b00a4568b578fdmr3132860ejj.5.1709636788755; Tue, 05 Mar 2024 03:06:28 -0800 (PST) Received: from m1x-phil.lan ([176.176.177.70]) by smtp.gmail.com with ESMTPSA id i8-20020a170906698800b00a43e8e76825sm5993981ejr.149.2024.03.05.03.06.27 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 05 Mar 2024 03:06:28 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Akihiko Odaki , Rene Engel , Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Subject: [PULL 03/12] ui/cocoa: Split [-QemuCocoaView handleEventLocked:] Date: Tue, 5 Mar 2024 12:05:58 +0100 Message-ID: <20240305110608.21618-4-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240305110608.21618-1-philmd@linaro.org> References: <20240305110608.21618-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::52d; envelope-from=philmd@linaro.org; helo=mail-ed1-x52d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Akihiko Odaki Currently [-QemuCocoaView handleEventLocked:] parses the passed event, stores operations to be done to variables, and perform them according to the variables. This construct will be cluttered with variables and hard to read when we need more different operations for different events. Split the methods so that we can call appropriate methods depending on events instead of relying on variables. Signed-off-by: Akihiko Odaki Tested-by: Rene Engel Reviewed-by: Peter Maydell Message-ID: <20240224-cocoa-v12-1-e89f70bdda71@daynix.com> Signed-off-by: Philippe Mathieu-Daudé --- ui/cocoa.m | 86 ++++++++++++++++++++++++++++++++---------------------- 1 file changed, 51 insertions(+), 35 deletions(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index 5618d294c4..aecd60df2a 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -1102,45 +1102,61 @@ - (bool) handleEventLocked:(NSEvent *)event } if (mouse_event) { - /* Don't send button events to the guest unless we've got a - * mouse grab or window focus. If we have neither then this event - * is the user clicking on the background window to activate and - * bring us to the front, which will be done by the sendEvent - * call below. We definitely don't want to pass that click through - * to the guest. - */ - if ((isMouseGrabbed || [[self window] isKeyWindow]) && - (last_buttons != buttons)) { - static uint32_t bmap[INPUT_BUTTON__MAX] = { - [INPUT_BUTTON_LEFT] = MOUSE_EVENT_LBUTTON, - [INPUT_BUTTON_MIDDLE] = MOUSE_EVENT_MBUTTON, - [INPUT_BUTTON_RIGHT] = MOUSE_EVENT_RBUTTON - }; - qemu_input_update_buttons(dcl.con, bmap, last_buttons, buttons); - last_buttons = buttons; - } - if (isMouseGrabbed) { - if (isAbsoluteEnabled) { - /* Note that the origin for Cocoa mouse coords is bottom left, not top left. - * The check on screenContainsPoint is to avoid sending out of range values for - * clicks in the titlebar. - */ - if ([self screenContainsPoint:p]) { - qemu_input_queue_abs(dcl.con, INPUT_AXIS_X, p.x, 0, screen.width); - qemu_input_queue_abs(dcl.con, INPUT_AXIS_Y, screen.height - p.y, 0, screen.height); - } - } else { - qemu_input_queue_rel(dcl.con, INPUT_AXIS_X, (int)[event deltaX]); - qemu_input_queue_rel(dcl.con, INPUT_AXIS_Y, (int)[event deltaY]); - } - } else { - return false; - } - qemu_input_event_sync(); + return [self handleMouseEvent:event buttons:buttons]; } return true; } +- (bool) handleMouseEvent:(NSEvent *)event buttons:(uint32_t)buttons +{ + /* Don't send button events to the guest unless we've got a + * mouse grab or window focus. If we have neither then this event + * is the user clicking on the background window to activate and + * bring us to the front, which will be done by the sendEvent + * call below. We definitely don't want to pass that click through + * to the guest. + */ + if ((isMouseGrabbed || [[self window] isKeyWindow]) && + (last_buttons != buttons)) { + static uint32_t bmap[INPUT_BUTTON__MAX] = { + [INPUT_BUTTON_LEFT] = MOUSE_EVENT_LBUTTON, + [INPUT_BUTTON_MIDDLE] = MOUSE_EVENT_MBUTTON, + [INPUT_BUTTON_RIGHT] = MOUSE_EVENT_RBUTTON + }; + qemu_input_update_buttons(dcl.con, bmap, last_buttons, buttons); + last_buttons = buttons; + } + + return [self handleMouseEvent:event]; +} + +- (bool) handleMouseEvent:(NSEvent *)event +{ + if (!isMouseGrabbed) { + return false; + } + + if (isAbsoluteEnabled) { + NSPoint p = [self screenLocationOfEvent:event]; + + /* Note that the origin for Cocoa mouse coords is bottom left, not top left. + * The check on screenContainsPoint is to avoid sending out of range values for + * clicks in the titlebar. + */ + if ([self screenContainsPoint:p]) { + qemu_input_queue_abs(dcl.con, INPUT_AXIS_X, p.x, 0, screen.width); + qemu_input_queue_abs(dcl.con, INPUT_AXIS_Y, screen.height - p.y, 0, screen.height); + } + } else { + qemu_input_queue_rel(dcl.con, INPUT_AXIS_X, (int)[event deltaX]); + qemu_input_queue_rel(dcl.con, INPUT_AXIS_Y, (int)[event deltaY]); + } + + qemu_input_event_sync(); + + return true; +} + - (void) grabMouse { COCOA_DEBUG("QemuCocoaView: grabMouse\n"); From patchwork Tue Mar 5 11:05:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 777969 Delivered-To: patch@linaro.org Received: by 2002:a5d:48c8:0:b0:33e:474f:8c56 with SMTP id p8csp372077wrs; Tue, 5 Mar 2024 03:07:45 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCX2ynoMRT/JWI+JGPasUHh/cTWmVIuZ2RbZau3Dm8e5blabkFZfBGK8M8zlKFQTqQcUO6eQ17OVXxmxkYSyN09w X-Google-Smtp-Source: AGHT+IETvsksQaNX2bUfd2jNDqa23uBI+9TGbnVuiwsFV34E0vaiUfbyQKdHPmr4YAId/Nm4AhvF X-Received: by 2002:a0c:e64f:0:b0:68f:ecde:f13b with SMTP id c15-20020a0ce64f000000b0068fecdef13bmr1662117qvn.62.1709636864776; Tue, 05 Mar 2024 03:07:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709636864; cv=none; d=google.com; s=arc-20160816; b=ghnbaXeJ7ikqhsMpDEeo2w4fyO8BhMhrPGvtnADucbLyEZbYZ2JLMck4mVXnTCHM8f KnOj7yzZuKh84XNfgvTObRU4jyyvgxhpORoLqTH2151QPF/LaRXwHbLqI1/KrBiOhREN i4CmTNgmBwpQkwJ5nFjPy2ibZeURnnf8LgCpbvXGyLo9334gYT9WdGnfjqAJ/OjdXsC6 taLICVgUHdxpq4Nnw3LpVpiCfQ/uMxpS2g7+ts8J7wsXaIUW2Qtdkyof0cdKJh3lZLbn 7tFOCbXVLUrEsyNnW3eFRaJj2d9lVsViXTsKP7ivITfdttZ/XS2MKfAaFkr+ajjqSbtb b+Zw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=YcMZ2wZGvgIXnfKqMdotL5RtUlqFDTHW5fA4eDcdqEc=; fh=tK/W4RaLE17XRjbSJYnFJv8/opvalIcV7yKc21wdriw=; b=irCJUvEVab/giPBq1FeXlnEfWlygrhWqDj516jP+LZ7phNq/mTaO6SQ46U9LHjTuq6 tSD7vkBfqsnkJDuC+/JMjW1C466T4aEIlA1452lYdMZcln8vMSAsBv8xZce9XmpAlNXM Nd4wlFyvvZGbFt4+gnypjIYWNMCjOrvJTYKY/51ToY1xEnqZ0rkCdFfo7szRC9v2rfZ6 xoqVllwa8vBpHoiWUdeE645fSm162R3h1fqs/264sEC83RND31lwQqEbVklFCiooE1oJ OK+Js7ZsZw9d1bWv5g6ZoyQC+T1QITcHhR+Fi2Z6QFMA9oiS/JpFvvpM1hH6PVZyjWBC y6YQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CjnwW2QL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id gs11-20020a056214226b00b0068fff3e72ccsi11647589qvb.372.2024.03.05.03.07.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Mar 2024 03:07:44 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CjnwW2QL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhSdM-0007va-V6; Tue, 05 Mar 2024 06:06:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhSdB-0007kJ-AM for qemu-devel@nongnu.org; Tue, 05 Mar 2024 06:06:46 -0500 Received: from mail-ed1-x52e.google.com ([2a00:1450:4864:20::52e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhSd2-0002lv-KG for qemu-devel@nongnu.org; Tue, 05 Mar 2024 06:06:45 -0500 Received: by mail-ed1-x52e.google.com with SMTP id 4fb4d7f45d1cf-563c595f968so8191737a12.0 for ; Tue, 05 Mar 2024 03:06:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709636794; x=1710241594; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YcMZ2wZGvgIXnfKqMdotL5RtUlqFDTHW5fA4eDcdqEc=; b=CjnwW2QLx3Djf0SsoP0rzi7iAFmrQb5TNCVC5zHA3jkvm++aXjmOfki/i10wA1bvbn SHJmvnEirX61CQ9q7KnyxvasTSp1RvhnqkSC+NhD406daZTcB9G2HzVmSPFbQe6fErfN e+JF0Kb1WArODkOrS8Pfayjb6/Qh0Q2eRDzJ1WKm2E2uZRvmRDa41PY4t8YzOblUl6ND 6l8xx89/BA7HToTey8RFqgmpJ2kIzOHwKoCSSUHIGxRzy/+D4vEcYA/mwOjN39II375n sxQDZ5Ike23TVbswhPwQ74ykFNo0uDgFtCxNXBsgri1V7FDww0e7GqxAWkBahkJloymV Mwfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709636794; x=1710241594; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YcMZ2wZGvgIXnfKqMdotL5RtUlqFDTHW5fA4eDcdqEc=; b=cvqFnvrILZ8fOwe0QuWc/CsqPu5dhV/2OG3qpjbogNQic+isYFfFh5QD7rNbsI9Bvq is4VOrtICIdy8s61kKUmI00nVGByd0pfjumtbDDiwDCcr8EnznH55ETSCyaKygM8+TCa Chtt/f4aayEPwCgjygGqS6hCcK3mtFFgrOVTC13csG7ITGsfQze2XcmjrqqHPzRsvpua j0msDKeodd6JjNNy3Yo/4Y9/Xxu6RScW/rsDqNX9W985NYHOdZSQ7d+Kci5u8GaYHs/q df22hWEfVL/0ZdPxM8vhhMW8e3SgdzSjImsuNAgLwCO5AJ3vEmDyfjlJYOtqieRtl7/j XfHw== X-Gm-Message-State: AOJu0Yw9euMNTEyGVyEpcvTxUZLn9AZ2V+tiUV8z6W8C+3IFOqU3FIxl JcoGPXkTFJpnjcm3dVxCU5V10SN3NIxoFs0lAITguvyVKGoDeRjmar27anDEcAF6SZP17zrpjVw / X-Received: by 2002:a17:906:8301:b0:a43:dae8:d43c with SMTP id j1-20020a170906830100b00a43dae8d43cmr7634044ejx.32.1709636794677; Tue, 05 Mar 2024 03:06:34 -0800 (PST) Received: from m1x-phil.lan ([176.176.177.70]) by smtp.gmail.com with ESMTPSA id ag3-20020a1709069a8300b00a44790d06d3sm4990914ejc.71.2024.03.05.03.06.33 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 05 Mar 2024 03:06:34 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Akihiko Odaki , Peter Maydell , Rene Engel , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Subject: [PULL 04/12] ui/cocoa: Immediately call [-QemuCocoaView handleMouseEvent:buttons:] Date: Tue, 5 Mar 2024 12:05:59 +0100 Message-ID: <20240305110608.21618-5-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240305110608.21618-1-philmd@linaro.org> References: <20240305110608.21618-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::52e; envelope-from=philmd@linaro.org; helo=mail-ed1-x52e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Akihiko Odaki Instead of using mouse_event variable to tell to handle a mouse event later, immediately call [-QemuCocoaView handleMouseEvent:buttons:]. Signed-off-by: Akihiko Odaki Reviewed-by: Peter Maydell Tested-by: Rene Engel Message-ID: <20240224-cocoa-v12-2-e89f70bdda71@daynix.com> Signed-off-by: Philippe Mathieu-Daudé --- ui/cocoa.m | 87 +++++++++++++++++++----------------------------------- 1 file changed, 30 insertions(+), 57 deletions(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index aecd60df2a..ff6486093c 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -807,9 +807,8 @@ - (bool) handleEventLocked:(NSEvent *)event { /* Return true if we handled the event, false if it should be given to OSX */ COCOA_DEBUG("QemuCocoaView: handleEvent\n"); - int buttons = 0; + InputButton button; int keycode = 0; - bool mouse_event = false; // Location of event in virtual screen coordinates NSPoint p = [self screenLocationOfEvent:event]; NSUInteger modifiers = [event modifierFlags]; @@ -955,7 +954,7 @@ - (bool) handleEventLocked:(NSEvent *)event } break; } - break; + return true; case NSEventTypeKeyDown: keycode = cocoa_keycode_to_qemu([event keyCode]); @@ -991,7 +990,7 @@ - (bool) handleEventLocked:(NSEvent *)event } else { [self handleMonitorInput: event]; } - break; + return true; case NSEventTypeKeyUp: keycode = cocoa_keycode_to_qemu([event keyCode]); @@ -1004,7 +1003,7 @@ - (bool) handleEventLocked:(NSEvent *)event if (qemu_console_is_graphic(NULL)) { qkbd_state_key_event(kbd, keycode, false); } - break; + return true; case NSEventTypeMouseMoved: if (isAbsoluteEnabled) { // Cursor re-entered into a window might generate events bound to screen coordinates @@ -1020,34 +1019,20 @@ - (bool) handleEventLocked:(NSEvent *)event } } } - mouse_event = true; - break; + return [self handleMouseEvent:event buttons:0]; case NSEventTypeLeftMouseDown: - buttons |= MOUSE_EVENT_LBUTTON; - mouse_event = true; - break; + return [self handleMouseEvent:event buttons:MOUSE_EVENT_LBUTTON]; case NSEventTypeRightMouseDown: - buttons |= MOUSE_EVENT_RBUTTON; - mouse_event = true; - break; + return [self handleMouseEvent:event buttons:MOUSE_EVENT_RBUTTON]; case NSEventTypeOtherMouseDown: - buttons |= MOUSE_EVENT_MBUTTON; - mouse_event = true; - break; + return [self handleMouseEvent:event buttons:MOUSE_EVENT_MBUTTON]; case NSEventTypeLeftMouseDragged: - buttons |= MOUSE_EVENT_LBUTTON; - mouse_event = true; - break; + return [self handleMouseEvent:event buttons:MOUSE_EVENT_LBUTTON]; case NSEventTypeRightMouseDragged: - buttons |= MOUSE_EVENT_RBUTTON; - mouse_event = true; - break; + return [self handleMouseEvent:event buttons:MOUSE_EVENT_RBUTTON]; case NSEventTypeOtherMouseDragged: - buttons |= MOUSE_EVENT_MBUTTON; - mouse_event = true; - break; + return [self handleMouseEvent:event buttons:MOUSE_EVENT_MBUTTON]; case NSEventTypeLeftMouseUp: - mouse_event = true; if (!isMouseGrabbed && [self screenContainsPoint:p]) { /* * In fullscreen mode, the window of cocoaView may not be the @@ -1058,53 +1043,41 @@ - (bool) handleEventLocked:(NSEvent *)event [self grabMouse]; } } - break; + return [self handleMouseEvent:event buttons:0]; case NSEventTypeRightMouseUp: - mouse_event = true; - break; + return [self handleMouseEvent:event buttons:0]; case NSEventTypeOtherMouseUp: - mouse_event = true; - break; + return [self handleMouseEvent:event buttons:0]; case NSEventTypeScrollWheel: /* * Send wheel events to the guest regardless of window focus. * This is in-line with standard Mac OS X UI behaviour. */ - /* - * We shouldn't have got a scroll event when deltaY and delta Y - * are zero, hence no harm in dropping the event - */ - if ([event deltaY] != 0 || [event deltaX] != 0) { /* Determine if this is a scroll up or scroll down event */ - if ([event deltaY] != 0) { - buttons = ([event deltaY] > 0) ? + if ([event deltaY] != 0) { + button = ([event deltaY] > 0) ? INPUT_BUTTON_WHEEL_UP : INPUT_BUTTON_WHEEL_DOWN; - } else if ([event deltaX] != 0) { - buttons = ([event deltaX] > 0) ? + } else if ([event deltaX] != 0) { + button = ([event deltaX] > 0) ? INPUT_BUTTON_WHEEL_LEFT : INPUT_BUTTON_WHEEL_RIGHT; - } - - qemu_input_queue_btn(dcl.con, buttons, true); - qemu_input_event_sync(); - qemu_input_queue_btn(dcl.con, buttons, false); - qemu_input_event_sync(); + } else { + /* + * We shouldn't have got a scroll event when deltaY and delta Y + * are zero, hence no harm in dropping the event + */ + return true; } - /* - * Since deltaX/deltaY also report scroll wheel events we prevent mouse - * movement code from executing. - */ - mouse_event = false; - break; + qemu_input_queue_btn(dcl.con, button, true); + qemu_input_event_sync(); + qemu_input_queue_btn(dcl.con, button, false); + qemu_input_event_sync(); + + return true; default: return false; } - - if (mouse_event) { - return [self handleMouseEvent:event buttons:buttons]; - } - return true; } - (bool) handleMouseEvent:(NSEvent *)event buttons:(uint32_t)buttons From patchwork Tue Mar 5 11:06:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 777975 Delivered-To: patch@linaro.org Received: by 2002:a5d:48c8:0:b0:33e:474f:8c56 with SMTP id p8csp372650wrs; Tue, 5 Mar 2024 03:09:13 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXjYxK7z9dwTYzsKlgmfVPXP7t3bPjAXdqK9RHvBLqOV2wAkPe0EDX5JRJRotY9mCe5eJT3OXDsd90uEsGpT0AB X-Google-Smtp-Source: AGHT+IHiLzXELnsAQ77XHjgt0LaJ5B5wuEgfU8+MgqR++mFl2OPxYuCIiNQwjSncLp4NfInbn6FI X-Received: by 2002:a05:622a:142:b0:42e:7eac:a4b0 with SMTP id v2-20020a05622a014200b0042e7eaca4b0mr1597917qtw.17.1709636953435; Tue, 05 Mar 2024 03:09:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709636953; cv=none; d=google.com; s=arc-20160816; b=Sxt2BhKBYFfFqKakyogE4r6KlJphDO0X48TUU6ap85EJ4v7ur2okNpetj6HeWGTzdy AO5UgxqtyBWMmf4x0XYxgBpcdOq3v48H85E9i7UNIo5SCKR483XUe1gaY40A+eqPMt+t KHjyrP0nYmQ6naIMBdTe8aEo1C5Kq9ouQp9+kmg3L5hydFrMHOf9xizMUScmt1YIcZhi juVh4NtixHZNLthfACfJFN1CqjacxbCFerT8q1TPRojui0n3dxcMAsE5rY8zg7EUs925 qcRsFQLW49IB3pn8bOyi/jUJ+T/nKXSZ0Bc6FLJW48hMMlx1VyFSJIEjMsI0ayj1zPoS iZfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=XeVy2+vY4lJTRcgog7P6iRUA3ib0rnR15yoPCfgtNoI=; fh=lnLpXpuHHACtmFCFYDz84qQIx2RASFfAeprBY3P3HzE=; b=aUowUvvwiTwu2k/EII3+QKL6CDbirN1KJHZy1XDWGfs9OEMkDMk+UM2llEBVoCWG0u +wDtU0f0dKSf3eGa+jcK8og8LfPF6g4fdfjkh2JTzSSKM68gv3l3ZOIVIqWdjLaGUypg dZLV+LrwEhz64S3A495PqM5DsU0BWHh91luITfOFtD5w3Im9NBIvGYpU9LBpTRmeQy0K qXUR4y8JG6dQsbCBVm8oldZ0r0SqNYd2UHyhGhxIbJKQW1RGmqO0WvRcMulLa+H5rv74 v46EwaL9F2VK1ETQhDiPzBDubaFCHTZE4leuOt6J2LX4TyVZvT4LACLeJQFzJ89JMQ7h L1+g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WopqH3af; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id p11-20020a05622a00cb00b0042e4b2ca25asi1594414qtw.438.2024.03.05.03.09.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Mar 2024 03:09:13 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WopqH3af; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhSdU-0008LZ-Fd; Tue, 05 Mar 2024 06:07:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhSdB-0007kI-A7 for qemu-devel@nongnu.org; Tue, 05 Mar 2024 06:06:45 -0500 Received: from mail-ed1-x52f.google.com ([2a00:1450:4864:20::52f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhSd8-0002mq-6L for qemu-devel@nongnu.org; Tue, 05 Mar 2024 06:06:45 -0500 Received: by mail-ed1-x52f.google.com with SMTP id 4fb4d7f45d1cf-563d56ee65cso8319046a12.2 for ; Tue, 05 Mar 2024 03:06:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709636800; x=1710241600; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XeVy2+vY4lJTRcgog7P6iRUA3ib0rnR15yoPCfgtNoI=; b=WopqH3afYcbBjCiLq71Wf/tQ/cNW5PR4plpJCSK9x0aF4/2xHLVqS3WVzEF8xs32j6 aaSrmqG1VBHzr8CKODbcx1oKwwXqwy78cEy3HuuD61ZTNMdmHnHtTlWTrgaXLkfEBRSq l+4BQSxw8BG2iyBPJlYUbzxPb4h7Aj+rIXhHjTmEvCox9rfbLUlsOh6aNRgM1i/G6iQU 0KpxHB2k1FSDd2+Z0yydto9cUokNd0p5zWFVqruE+saqak/IBieLOYl68seWaHiM/QGD oNnGC15WdogtHmEQCMeyd/TbRjXCgIaI2ZtXlWCffuYtrjqRiNNiV8JlQ73xC56DDEtm ndOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709636800; x=1710241600; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XeVy2+vY4lJTRcgog7P6iRUA3ib0rnR15yoPCfgtNoI=; b=W2fOuLrsplfOvx4NtJQvCl1SeUvj4HUFRrM/sTc4mtoDw7nzuV4ZXFxp+V0OV2L6Q6 NirkWXjDJF0vKKyzEHFTmZkyELyEFpWlLmjlYCY17ZoT2bKAtLo0rzG/Kn8MOh1oquKT n6iRIbYaWnTpSFYJGvaVPpylLugHVVcCB+tg1EKOoJOxTtljKAUnnXniy8VLBI781JAH HF4S1uG8e0K4wsu6nTy9CJNtW1rYGNXpbD3oaCqaMhG9srpBf4X4Dok3PPhbpxxj6/YM 3qoju8uCFM735UqWD/juPkjJHj2Nywdzto5hJADhQk2ncIblcrZj6sPJGrJ8Onx5mbEa juJA== X-Gm-Message-State: AOJu0YztqKtp0FTLF7GKc9vzlU+d4txz5fprWXUJimPznnH5ijyKcGQv sLvRM9Qkkc4yQhze5X5DhgIzYpegWXi2d/Tri5qtPJew6yp7R41oUxMp35HGS302qu/tVFlrsPV C X-Received: by 2002:aa7:c742:0:b0:567:19df:28f with SMTP id c2-20020aa7c742000000b0056719df028fmr5204895eds.18.1709636800596; Tue, 05 Mar 2024 03:06:40 -0800 (PST) Received: from m1x-phil.lan ([176.176.177.70]) by smtp.gmail.com with ESMTPSA id bo19-20020a0564020b3300b005653f390f77sm5653437edb.10.2024.03.05.03.06.39 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 05 Mar 2024 03:06:40 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Akihiko Odaki , Rene Engel , Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Subject: [PULL 05/12] ui/cocoa: Release specific mouse buttons Date: Tue, 5 Mar 2024 12:06:00 +0100 Message-ID: <20240305110608.21618-6-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240305110608.21618-1-philmd@linaro.org> References: <20240305110608.21618-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::52f; envelope-from=philmd@linaro.org; helo=mail-ed1-x52f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Akihiko Odaki ui/cocoa used to release all mouse buttons when it sees NSEventTypeLeftMouseUp, NSEventTypeRightMouseUp, or NSEventTypeOtherMouseUp, but it can instead release specific one according to the delivered event. Signed-off-by: Akihiko Odaki Tested-by: Rene Engel Reviewed-by: Peter Maydell Message-ID: <20240224-cocoa-v12-3-e89f70bdda71@daynix.com> Signed-off-by: Philippe Mathieu-Daudé --- ui/cocoa.m | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index ff6486093c..e156527082 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -103,7 +103,6 @@ static void cocoa_switch(DisplayChangeListener *dcl, static DisplayChangeListener dcl = { .ops = &dcl_ops, }; -static int last_buttons; static int cursor_hide = 1; static int left_command_key_enabled = 1; static bool swap_opt_cmd; @@ -1019,19 +1018,19 @@ - (bool) handleEventLocked:(NSEvent *)event } } } - return [self handleMouseEvent:event buttons:0]; + return [self handleMouseEvent:event]; case NSEventTypeLeftMouseDown: - return [self handleMouseEvent:event buttons:MOUSE_EVENT_LBUTTON]; + return [self handleMouseEvent:event button:INPUT_BUTTON_LEFT down:true]; case NSEventTypeRightMouseDown: - return [self handleMouseEvent:event buttons:MOUSE_EVENT_RBUTTON]; + return [self handleMouseEvent:event button:INPUT_BUTTON_RIGHT down:true]; case NSEventTypeOtherMouseDown: - return [self handleMouseEvent:event buttons:MOUSE_EVENT_MBUTTON]; + return [self handleMouseEvent:event button:INPUT_BUTTON_MIDDLE down:true]; case NSEventTypeLeftMouseDragged: - return [self handleMouseEvent:event buttons:MOUSE_EVENT_LBUTTON]; + return [self handleMouseEvent:event button:INPUT_BUTTON_LEFT down:true]; case NSEventTypeRightMouseDragged: - return [self handleMouseEvent:event buttons:MOUSE_EVENT_RBUTTON]; + return [self handleMouseEvent:event button:INPUT_BUTTON_RIGHT down:true]; case NSEventTypeOtherMouseDragged: - return [self handleMouseEvent:event buttons:MOUSE_EVENT_MBUTTON]; + return [self handleMouseEvent:event button:INPUT_BUTTON_MIDDLE down:true]; case NSEventTypeLeftMouseUp: if (!isMouseGrabbed && [self screenContainsPoint:p]) { /* @@ -1043,11 +1042,11 @@ - (bool) handleEventLocked:(NSEvent *)event [self grabMouse]; } } - return [self handleMouseEvent:event buttons:0]; + return [self handleMouseEvent:event button:INPUT_BUTTON_LEFT down:false]; case NSEventTypeRightMouseUp: - return [self handleMouseEvent:event buttons:0]; + return [self handleMouseEvent:event button:INPUT_BUTTON_RIGHT down:false]; case NSEventTypeOtherMouseUp: - return [self handleMouseEvent:event buttons:0]; + return [self handleMouseEvent:event button:INPUT_BUTTON_MIDDLE down:false]; case NSEventTypeScrollWheel: /* * Send wheel events to the guest regardless of window focus. @@ -1080,7 +1079,7 @@ - (bool) handleEventLocked:(NSEvent *)event } } -- (bool) handleMouseEvent:(NSEvent *)event buttons:(uint32_t)buttons +- (bool) handleMouseEvent:(NSEvent *)event button:(InputButton)button down:(bool)down { /* Don't send button events to the guest unless we've got a * mouse grab or window focus. If we have neither then this event @@ -1089,17 +1088,12 @@ - (bool) handleMouseEvent:(NSEvent *)event buttons:(uint32_t)buttons * call below. We definitely don't want to pass that click through * to the guest. */ - if ((isMouseGrabbed || [[self window] isKeyWindow]) && - (last_buttons != buttons)) { - static uint32_t bmap[INPUT_BUTTON__MAX] = { - [INPUT_BUTTON_LEFT] = MOUSE_EVENT_LBUTTON, - [INPUT_BUTTON_MIDDLE] = MOUSE_EVENT_MBUTTON, - [INPUT_BUTTON_RIGHT] = MOUSE_EVENT_RBUTTON - }; - qemu_input_update_buttons(dcl.con, bmap, last_buttons, buttons); - last_buttons = buttons; + if (!isMouseGrabbed && ![[self window] isKeyWindow]) { + return false; } + qemu_input_queue_btn(dcl.con, button, down); + return [self handleMouseEvent:event]; } From patchwork Tue Mar 5 11:06:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 777978 Delivered-To: patch@linaro.org Received: by 2002:a5d:48c8:0:b0:33e:474f:8c56 with SMTP id p8csp372932wrs; Tue, 5 Mar 2024 03:09:54 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCV8zvEtX1Uz12JOUuQ5Pc6yV7BsDsF//KPZ6/3Ys64jDV9b4M/fYbPgdWAXpKQyl/LldKcQwzR2ahuqdsy8o8k3 X-Google-Smtp-Source: AGHT+IFvsuJPSWbnnxur9cahgxKqEoLM0E22lldRwIA/ZsqcytdtAS9GJ+skTKjiMTgJPsS1elPJ X-Received: by 2002:a05:6122:4b18:b0:4d1:34a1:c896 with SMTP id fc24-20020a0561224b1800b004d134a1c896mr1281019vkb.8.1709636994514; Tue, 05 Mar 2024 03:09:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709636994; cv=none; d=google.com; s=arc-20160816; b=Xs2e1GVoEkjnnK4OFo/f+12c/BbT8P5pOCTfFm6MniJM72ucWynFhbts4BUdBeiyQv WtNBvBjw3Wb3jqjMdTLKSc/3Boh7QA6D+6oQD8K5qcAByuSS+MbojgyG01Cl8EQ/yLnQ nnRPKTn81dHChDUeS1bos9LbT+MGCzWEcyz8wV/LrbtI3Ns2X9gWUSm067Nw3fs8hkRE /wq0DTPb3jKe4mpE009lD3LLYnwld2or/qoao8Ml27bFLnzLlCmEB1eQgF0j76l/BEu8 H+koIxH72mEpnnDtndfYmab3Bzt3exWSthpsyeVi1p0c5oNrZxvw94YTHg+0hm++Fdjy /8/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=aEncxItvyBuKzeJwaGvPvRwTlJqcX1dHZlco9vuriMg=; fh=lnLpXpuHHACtmFCFYDz84qQIx2RASFfAeprBY3P3HzE=; b=da8OGnrvAjoSbJzLUgJUhFuhzkTCBvQ+F1h2CYeUFmWwfnq3Y0ryNCR0N5Qn/hs0Zk 8UfL+OycYth5dlfyfRJzF5Z36aOSiyC9V1Mg52jEzfavSFeSqR7oCR8RKO5gF4wL7X2X 0DrB8H0VPvyNCXE8Xs2UyH2H8A6oCeSwuB3vvuiYyUWZhVA9xfUyQYvJtIc9nGs1UszD QE/bPhJgnwC+dazX9z/r+amaBOBCrZFvMsIezSpp2LAsiLJs5wjC9fDp/orVmMwgtNeT uxPq2J6/eHpU2mLP+mOC/gzf2ojWC2iFlQKDnX1sT3KH7x7cCDyxgFnGrapQLiM7YTa5 NkLQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MYfIyrQ6; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id g14-20020a05620a40ce00b00788136b7872si8904704qko.175.2024.03.05.03.09.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Mar 2024 03:09:54 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MYfIyrQ6; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhSdR-00085I-Ju; Tue, 05 Mar 2024 06:07:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhSdK-0007ue-Bj for qemu-devel@nongnu.org; Tue, 05 Mar 2024 06:06:54 -0500 Received: from mail-ed1-x534.google.com ([2a00:1450:4864:20::534]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhSdG-0002o1-89 for qemu-devel@nongnu.org; Tue, 05 Mar 2024 06:06:53 -0500 Received: by mail-ed1-x534.google.com with SMTP id 4fb4d7f45d1cf-565b434f90aso7948390a12.3 for ; Tue, 05 Mar 2024 03:06:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709636807; x=1710241607; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=aEncxItvyBuKzeJwaGvPvRwTlJqcX1dHZlco9vuriMg=; b=MYfIyrQ6angPUoj52gNZRbOnQHpige8CSZv8khb+kr9S250dK8VOEihxva/gA9dohR URVVvcZC7FfGCLs6l0PeAbM0cxgquT2HtSfvkItO/LiANSu3Wcj4Ck48/1Yat7pAAtm2 8hGFDLryQWUWk08tKjAg2zIx/5+KMLhGS8jG1dFg12gxacs5MWmA0u1S3ulEOejmTOPV jEScj3aeYaXIr/4jFcaySuB4dd9cwO9vzh5xycUoPZKb7wHJo77jT0XJcSshGC2GVFYs OuOlPWg0R1W7GM1/3ejEDvG6H4fILnt0AMyhhkgnoUketRop80BpKeP2j8f3FPUcBsvr vzhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709636807; x=1710241607; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aEncxItvyBuKzeJwaGvPvRwTlJqcX1dHZlco9vuriMg=; b=IVzki+chIfwoYuPOG7weDniAsvQcpYcIJJuhznXAhjqwf4FrtYoV6fbPi3MRZT43hu VE9G/4Nh8ChoSZQVsInwuWnNyg8dmOmnrf7024qofnVXDDSYWghSe2md/47T/4L0UTtD t7m1mhOE5oj4Wz7wHpkR1Q+UoAJPlgBK24yViTk+P0EAkOGIOmw0xH1LTf1HdGnFmWiG peg4764mtVAGVs/c1q4Yerwrh97Vf0Tk+Mg24YtmW6lEsB5Z0olvGF8M/TQkR0kI7CRO fLKh5eyMUjweFG2o2G+MNu+FHgnWASi2g2XcijsYJQ/6OY2iN2tKcfcXICPiZ+qolmfQ LK8A== X-Gm-Message-State: AOJu0YxMehvtw1i4Fb8KpFlpXNL3rbokvzXAGTM0WaLICWJSgX20AgVY mLHSuviohMnNCfX2/VP4n2IHOo7+AgrN8xf68QIJoRb1dw3Urt0LqV3oe3tuXeaMnexluDw/zTf E X-Received: by 2002:a17:906:a24f:b0:a45:aa4a:6495 with SMTP id bi15-20020a170906a24f00b00a45aa4a6495mr804115ejb.37.1709636806828; Tue, 05 Mar 2024 03:06:46 -0800 (PST) Received: from m1x-phil.lan ([176.176.177.70]) by smtp.gmail.com with ESMTPSA id w9-20020a1709064a0900b00a44f0d99d58sm3477672eju.208.2024.03.05.03.06.45 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 05 Mar 2024 03:06:46 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Akihiko Odaki , Rene Engel , Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Subject: [PULL 06/12] ui/cocoa: Scale with NSView instead of Core Graphics Date: Tue, 5 Mar 2024 12:06:01 +0100 Message-ID: <20240305110608.21618-7-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240305110608.21618-1-philmd@linaro.org> References: <20240305110608.21618-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::534; envelope-from=philmd@linaro.org; helo=mail-ed1-x534.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Akihiko Odaki Core Graphics is not accelerated and slow. Signed-off-by: Akihiko Odaki Tested-by: Rene Engel Reviewed-by: Peter Maydell Message-ID: <20240224-cocoa-v12-4-e89f70bdda71@daynix.com> Signed-off-by: Philippe Mathieu-Daudé --- ui/cocoa.m | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index e156527082..6e8cd24e88 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -504,10 +504,8 @@ - (void) drawRect:(NSRect) rect [self getRectsBeingDrawn:&rectList count:&rectCount]; for (i = 0; i < rectCount; i++) { - clipRect.origin.x = rectList[i].origin.x / cdx; - clipRect.origin.y = (float)h - (rectList[i].origin.y + rectList[i].size.height) / cdy; - clipRect.size.width = rectList[i].size.width / cdx; - clipRect.size.height = rectList[i].size.height / cdy; + clipRect = rectList[i]; + clipRect.origin.y = (float)h - (clipRect.origin.y + clipRect.size.height); clipImageRef = CGImageCreateWithImageInRect( imageRef, clipRect @@ -553,6 +551,11 @@ - (void) setContentDimensions } } +- (void) updateBounds +{ + [self setBoundsSize:NSMakeSize(screen.width, screen.height)]; +} + - (void) updateUIInfoLocked { /* Must be called with the BQL, i.e. via updateUIInfo */ @@ -642,6 +645,7 @@ - (void) switchSurface:(pixman_image_t *)image screen.height = h; [self setContentDimensions]; [self setFrame:NSMakeRect(cx, cy, cw, ch)]; + [self updateBounds]; } // update screenBuffer @@ -1305,6 +1309,7 @@ - (void)windowDidChangeScreen:(NSNotification *)notification - (void)windowDidResize:(NSNotification *)notification { + [cocoaView updateBounds]; [cocoaView updateUIInfo]; } @@ -1967,16 +1972,7 @@ static void cocoa_update(DisplayChangeListener *dcl, COCOA_DEBUG("qemu_cocoa: cocoa_update\n"); dispatch_async(dispatch_get_main_queue(), ^{ - NSRect rect; - if ([cocoaView cdx] == 1.0) { - rect = NSMakeRect(x, [cocoaView gscreen].height - y - h, w, h); - } else { - rect = NSMakeRect( - x * [cocoaView cdx], - ([cocoaView gscreen].height - y - h) * [cocoaView cdy], - w * [cocoaView cdx], - h * [cocoaView cdy]); - } + NSRect rect = NSMakeRect(x, [cocoaView gscreen].height - y - h, w, h); [cocoaView setNeedsDisplayInRect:rect]; }); } From patchwork Tue Mar 5 11:06:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 777977 Delivered-To: patch@linaro.org Received: by 2002:a5d:48c8:0:b0:33e:474f:8c56 with SMTP id p8csp372922wrs; Tue, 5 Mar 2024 03:09:53 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVYf/p2d3qx324PZPIiso3fDMFSaE2sVkxxEEv7zUfqpHuApqzb8pa+wOLyhBb4OD6X8nZ9VntoSh63GooEtZ+r X-Google-Smtp-Source: AGHT+IGRN2+QgS2GQZerAY3YAS9bqX2Q23pt6+/Zy9TVuM+p6sD5MHNF3qkxTv1tNzO6CR9hoi9Z X-Received: by 2002:ad4:444c:0:b0:690:747d:f8d4 with SMTP id l12-20020ad4444c000000b00690747df8d4mr1543453qvt.19.1709636993510; Tue, 05 Mar 2024 03:09:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709636993; cv=none; d=google.com; s=arc-20160816; b=QJVjzHO5eFw/aTA0H4F/12pFwqKz/zTPjFGM9Ms+GaA3uFkpromAOUQfDViCPjiLUm oExjm4hthpxpz2C1m1HaJTBDY1LEZ8wZcgGK5RtoGpEx8reV3SWccULncpoGAd63yVfz bTCTjRztHfwPncZac9revu85QydRSuCqVr0OW/5Fg1JO6ha1x7c/3hWuq2GO3vzB6JZu /noB4XdSaRzghiiTZPam9EO1HmOt2GyUwQv6s6MxGAmCFe+o6OnW0B05oRCslBzJ7VO1 omKixTI7SggCIgupo+VimJymBG18h5lNkZbToRZNaAGzRMq6ZFzQFKki2TZp1wL5NzJx 9Z+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=BD6Kyo1n9e4Vc/VDtm7XcC1eUkYKmt1UEkhUMSJXsxM=; fh=lnLpXpuHHACtmFCFYDz84qQIx2RASFfAeprBY3P3HzE=; b=J3XHPYHegO0lj3QuRj+O/d8Ag9CJIeI/LVWQQP0OQ9tLhR5kGLxRMgjdvEmyW75nLo REdU9X6scLGlSybbx/znIyjZTiowlrEDm5X1INIH+v1YCLME01BsWoD+3+B1iih6vF5h gG9b9Kxs3Zh7PwG45L4hbRw3KSYIrBFL+ORWgRmzDjQlOtd264ODm6eWd3GMgD02OrEQ v+4IiNgDM1ui2jiAFQ5J1iajwIsWVnh+qDg70nPr5vfndJ9yBvhK4+XTcd15/dV5E7em tTBN/88ZDkjC2fP6gzTd4fKWF81MCyw1hvYsp2a989UAjc9HibKzCoJRCDWnEamUt5dV QP0Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xdrJFadh; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id kd23-20020a056214401700b0068d0503a3a8si12080719qvb.439.2024.03.05.03.09.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Mar 2024 03:09:53 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xdrJFadh; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhSdT-0008H2-IS; Tue, 05 Mar 2024 06:07:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhSdP-00086E-UT for qemu-devel@nongnu.org; Tue, 05 Mar 2024 06:06:59 -0500 Received: from mail-ed1-x535.google.com ([2a00:1450:4864:20::535]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhSdK-0002ok-Eo for qemu-devel@nongnu.org; Tue, 05 Mar 2024 06:06:59 -0500 Received: by mail-ed1-x535.google.com with SMTP id 4fb4d7f45d1cf-565a3910f86so8243564a12.3 for ; Tue, 05 Mar 2024 03:06:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709636812; x=1710241612; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BD6Kyo1n9e4Vc/VDtm7XcC1eUkYKmt1UEkhUMSJXsxM=; b=xdrJFadh+qvjaykMr2xnsPhCk3/QcXp00uRnYuK9LdIKURzVK0wHGow1JHchVetn8x j3nypfBTEj8Gn3euQg1xgdVMHO3RZjLt2g+kjcJm+GGdDgeLti1HraSVg//2wJul/mAl ldRL4efx/BYKxJLCPylHBThLPfBQOdouNOH/RJp/2t4gaAWfYSmQJaE+dzcLru5E2cYz pXfvUy5XE+J8LbnERv9CNarRPvzQ26sgFX8k5R8lUS46eTEUw+3zHqGks+SjqWsGU7Re xV4bis4HZcFp65UVoXW1Q+tbTdL6sBQAJvyOuPteFBGD1ANrh0/cbbutIZyWh2wX5IjJ mNWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709636812; x=1710241612; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BD6Kyo1n9e4Vc/VDtm7XcC1eUkYKmt1UEkhUMSJXsxM=; b=hs5swByPx2uJcC/s/eJUKS4mw9F1yI8saaI9uuIwy3pPTFwjlV/Mn3CfkqVWYUYsgc jqJroHuhsJh6UtfOSY7jJVypvKUdZ9LZonHdkNTIHMD+DmgoktPz7OILaNxpL8B8dH2l Nn1L4eG3ZAUSOMNTAw/KHi83aNcE77UoK4Q7leSvL41JBUnkQQkQRD4+V9tkHQ4TQPy0 yxWzezowYB/Tr692+6935eHErghtsdJUGAlgorSs+DUXGqqAd88pRPC2BJqbiYA8pVig b6NKKAuBFPKm2/3v/g6VqKPX/Gm89KUapUW1kkdKHmLGaISzmynSaxbAHhkVSYZvTl3W 8Gww== X-Gm-Message-State: AOJu0YyLHtDrfcmRE23zeHVD5/y8wQsmW5iA2pO6/ygPXNDlHAH8Eg8q /A4GavL3Cr5sUiWNbpyZYdkC7muaFyVnVkF+13wFq1MfosIalARCPPI3hCRp/Ub7qeSbkwjMZgS h X-Received: by 2002:a17:906:408d:b0:a45:69f5:c3c9 with SMTP id u13-20020a170906408d00b00a4569f5c3c9mr3176440ejj.6.1709636812815; Tue, 05 Mar 2024 03:06:52 -0800 (PST) Received: from m1x-phil.lan ([176.176.177.70]) by smtp.gmail.com with ESMTPSA id oy29-20020a170907105d00b00a43fe57b2basm5900527ejb.61.2024.03.05.03.06.51 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 05 Mar 2024 03:06:52 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Akihiko Odaki , Rene Engel , Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Subject: [PULL 07/12] ui/cocoa: Fix pause label coordinates Date: Tue, 5 Mar 2024 12:06:02 +0100 Message-ID: <20240305110608.21618-8-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240305110608.21618-1-philmd@linaro.org> References: <20240305110608.21618-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::535; envelope-from=philmd@linaro.org; helo=mail-ed1-x535.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_TEMPERROR=0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Akihiko Odaki A subview is positioned in the superview so the superview's frame should be used instead of one of the window to determine the coordinates. Signed-off-by: Akihiko Odaki Tested-by: Rene Engel Reviewed-by: Peter Maydell Message-ID: <20240224-cocoa-v12-5-e89f70bdda71@daynix.com> Signed-off-by: Philippe Mathieu-Daudé --- ui/cocoa.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index 6e8cd24e88..a2e52ceabc 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -1451,8 +1451,8 @@ - (void)displayPause { /* Coordinates have to be calculated each time because the window can change its size */ int xCoord, yCoord, width, height; - xCoord = ([normalWindow frame].size.width - [pauseLabel frame].size.width)/2; - yCoord = [normalWindow frame].size.height - [pauseLabel frame].size.height - ([pauseLabel frame].size.height * .5); + xCoord = ([cocoaView frame].size.width - [pauseLabel frame].size.width)/2; + yCoord = [cocoaView frame].size.height - [pauseLabel frame].size.height - ([pauseLabel frame].size.height * .5); width = [pauseLabel frame].size.width; height = [pauseLabel frame].size.height; [pauseLabel setFrame: NSMakeRect(xCoord, yCoord, width, height)]; From patchwork Tue Mar 5 11:06:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 777970 Delivered-To: patch@linaro.org Received: by 2002:a5d:48c8:0:b0:33e:474f:8c56 with SMTP id p8csp372078wrs; Tue, 5 Mar 2024 03:07:45 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVH3eGLAl7ZXugxKOLvOjom/bTBHCTwdzLOcSvC9dZIT7c0hOX4Wr0TKkbk3b1iX9wdxoxObHrGa82YcRaWvNfp X-Google-Smtp-Source: AGHT+IE9vdNBufQl3CGwgjvRvrgJBFWBgnOJ9/x8YFttlUD4///EJQkgcKGmoohmN4DY+r56kJDS X-Received: by 2002:a0c:f90f:0:b0:690:88e9:1a27 with SMTP id v15-20020a0cf90f000000b0069088e91a27mr1281542qvn.44.1709636864840; Tue, 05 Mar 2024 03:07:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709636864; cv=none; d=google.com; s=arc-20160816; b=KXUkfnMZirXuQ9lna9xKZEahrgBYfvUSahlKI2K6jFcKF2ku7iGG6nucys0qay5rKX 3TTCgoagMGAWfq4BZ9n1cxVKxzwhixlNbSx94g0sKN+ZZktnDvKp4Qp3tomA3H3bfxWw O+xTs3mhJPoAaxf7wfHLKnk7pxX1jIPgcF+cOgowLdytaCkwM0kMvBgilUr4ys7cBf1d ywHbBbFGMaoFVYWMjqxOUcrwPgUxXZDA5ElSm06eoyT33EHspvGA6LzuSr3/SDWDgqT1 AI2XybNLwmpMMSQVm/7d9/DBh0TDvgg6l1sRRZPzFEaNu4OmeSm0+OyJVObil7Ve6dPl TOXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=YkKUFn7AWxVAg35b06t0kYYg99FgIPb4F94cJxfsPG8=; fh=lnLpXpuHHACtmFCFYDz84qQIx2RASFfAeprBY3P3HzE=; b=0C2mxHyN5DdwxX8u3ETELYWoLWhZXpduQ7qsG/1wQs7x3pFhbTY1/SIzvBVJhF89IV ZGfbFrPPfnvsk6sZe8JPn8Vuk2qThDPSrqnfjL+OWL7RVVhEbTOZNxUS76MHt6MzZVWw SoDQ/KizeWMfgWkH5JgsklfZ4GWIiFQRSkliJOvZEkyNszz4waxouWdjBPE4Ms2ZjAT7 J4gy9aOZp41LCanZ2i9Le9TdjRJiHTlfd92htOrHmLe6CijXw9Ablawzuhvoh45std9z 0nRavkIrcQBQp5Wf7uVhmMNOx9bS+vmmGO4rSeYaj/3ew/bg8P9WAnJZb57B4cMP3XQP hlZQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=inzMcji3; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id u12-20020ad45aac000000b0068fb7e2785dsi12238874qvg.517.2024.03.05.03.07.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Mar 2024 03:07:44 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=inzMcji3; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhSdW-0008RQ-4B; Tue, 05 Mar 2024 06:07:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhSdU-0008Kk-70 for qemu-devel@nongnu.org; Tue, 05 Mar 2024 06:07:04 -0500 Received: from mail-ed1-x52d.google.com ([2a00:1450:4864:20::52d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhSdR-0002px-2m for qemu-devel@nongnu.org; Tue, 05 Mar 2024 06:07:03 -0500 Received: by mail-ed1-x52d.google.com with SMTP id 4fb4d7f45d1cf-565a2c4cc1aso645123a12.2 for ; Tue, 05 Mar 2024 03:07:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709636819; x=1710241619; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YkKUFn7AWxVAg35b06t0kYYg99FgIPb4F94cJxfsPG8=; b=inzMcji3PJuLy0CU2J88vhdw7h9e2ZaR1IM00d4JpWmiPQ4TOF61osHWewP2CkXFWe 0Mm41wdwbJkSgEbwLtftzcXcTV7aFXn5WBowf0QlY1tY9EMl+oeC5u8e/9k/IdZgvN79 mT36qV9nhCaE17YreUxoK54kI1GwY2nfc79ugZpmg0XQeGx78fLAOXsw3gn9vsE3AkAh u7B5fKyNAFK1CXxvC470Pf7yOnXiklEgWfFQ/A09Yd7sp5Z3oQetF0ng2HnBgclk/BJD QBXGXc2/mLgxrgVfr1mIGm8focr8JkciYh+4HBBByuoA/9vuaN6C6WS6NQiE/bttjn9O g6zA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709636819; x=1710241619; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YkKUFn7AWxVAg35b06t0kYYg99FgIPb4F94cJxfsPG8=; b=TscpMjVEuSJIKa04GWDb4Hpiy5EoRAzbeZNQoxxaLyZ4CpnW0keYOTZ5//Y06i2BtY H/tGm6P3BE2q+AHWbrnkcga/P9i2Y1lN1+UAkDF+1w3DndZX7/EF5Q2idhjS8+PngqSx WqGVUoZHWWWsLtw1bNcxsXwkqfjdk/IzGeIO2FpAsQsbCfC+HEg5R06TvVpzOLAZkezO UiMh+VAbG9I5IX/Dtv9Ni7aGZ5q/W9CmNCmqIqgh3fWFMq9zU9zbXwUjk/FLkYeRSrf3 UWsMvdTnSNc50DkUxdVF5j7MPB4K/4YCqhcUAndP2PuhKTnWepefN0fn17RVTl4KNYNI 2EHw== X-Gm-Message-State: AOJu0Yzc7kkl9QoBkz95I3RGfdF2jFdNpxvU0/axqcOO6tWDOgtu2ijt 0C8ATrybvqSocncISqYJi2fsXWLfnl6m892AO5kyBrBUWp72K5BAvPyF51p83qtzYuo4rQGB/aL q X-Received: by 2002:a05:6402:cac:b0:566:1694:7090 with SMTP id cn12-20020a0564020cac00b0056616947090mr8407475edb.11.1709636819024; Tue, 05 Mar 2024 03:06:59 -0800 (PST) Received: from m1x-phil.lan ([176.176.177.70]) by smtp.gmail.com with ESMTPSA id y26-20020a056402135a00b0056694006fa7sm5714070edw.70.2024.03.05.03.06.57 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 05 Mar 2024 03:06:58 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Akihiko Odaki , Rene Engel , Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Subject: [PULL 08/12] ui/cocoa: Let the platform toggle fullscreen Date: Tue, 5 Mar 2024 12:06:03 +0100 Message-ID: <20240305110608.21618-9-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240305110608.21618-1-philmd@linaro.org> References: <20240305110608.21618-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::52d; envelope-from=philmd@linaro.org; helo=mail-ed1-x52d.google.com X-Spam_score_int: 0 X-Spam_score: -0.1 X-Spam_bar: / X-Spam_report: (-0.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_OTHER_BAD_TLD=1.998, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Akihiko Odaki It allows making the window full screen by clicking full screen button provided by the platform (the left-top green button) and save some code. Signed-off-by: Akihiko Odaki Tested-by: Rene Engel Reviewed-by: Peter Maydell Message-ID: <20240224-cocoa-v12-6-e89f70bdda71@daynix.com> Signed-off-by: Philippe Mathieu-Daudé --- ui/cocoa.m | 420 ++++++++++++++++++++++++----------------------------- 1 file changed, 187 insertions(+), 233 deletions(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index a2e52ceabc..20d73098e2 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -308,20 +308,17 @@ static void handleAnyDeviceErrors(Error * err) */ @interface QemuCocoaView : NSView { + NSTrackingArea *trackingArea; QEMUScreen screen; - NSWindow *fullScreenWindow; - float cx,cy,cw,ch,cdx,cdy; pixman_image_t *pixman_image; QKbdState *kbd; BOOL isMouseGrabbed; - BOOL isFullscreen; BOOL isAbsoluteEnabled; CFMachPortRef eventsTap; } - (void) switchSurface:(pixman_image_t *)image; - (void) grabMouse; - (void) ungrabMouse; -- (void) toggleFullScreen:(id)sender; - (void) setFullGrab:(id)sender; - (void) handleMonitorInput:(NSEvent *)event; - (bool) handleEvent:(NSEvent *)event; @@ -337,8 +334,6 @@ - (void) setAbsoluteEnabled:(BOOL)tIsAbsoluteEnabled; */ - (BOOL) isMouseGrabbed; - (BOOL) isAbsoluteEnabled; -- (float) cdx; -- (float) cdy; - (QEMUScreen) gscreen; - (void) raiseAllKeys; @end @@ -399,46 +394,43 @@ - (BOOL) isOpaque return YES; } -- (BOOL) screenContainsPoint:(NSPoint) p +- (void) removeTrackingRect { - return (p.x > -1 && p.x < screen.width && p.y > -1 && p.y < screen.height); + if (trackingArea) { + [self removeTrackingArea:trackingArea]; + [trackingArea release]; + trackingArea = nil; + } } -/* Get location of event and convert to virtual screen coordinate */ -- (CGPoint) screenLocationOfEvent:(NSEvent *)ev +- (void) frameUpdated { - NSWindow *eventWindow = [ev window]; - // XXX: Use CGRect and -convertRectFromScreen: to support macOS 10.10 - CGRect r = CGRectZero; - r.origin = [ev locationInWindow]; - if (!eventWindow) { - if (!isFullscreen) { - return [[self window] convertRectFromScreen:r].origin; - } else { - CGPoint locationInSelfWindow = [[self window] convertRectFromScreen:r].origin; - CGPoint loc = [self convertPoint:locationInSelfWindow fromView:nil]; - if (stretch_video) { - loc.x /= cdx; - loc.y /= cdy; - } - return loc; - } - } else if ([[self window] isEqual:eventWindow]) { - if (!isFullscreen) { - return r.origin; - } else { - CGPoint loc = [self convertPoint:r.origin fromView:nil]; - if (stretch_video) { - loc.x /= cdx; - loc.y /= cdy; - } - return loc; - } - } else { - return [[self window] convertRectFromScreen:[eventWindow convertRectToScreen:r]].origin; + [self removeTrackingRect]; + + if ([self window]) { + NSTrackingAreaOptions options = NSTrackingActiveInKeyWindow | + NSTrackingMouseEnteredAndExited | + NSTrackingMouseMoved; + trackingArea = [[NSTrackingArea alloc] initWithRect:[self frame] + options:options + owner:self + userInfo:nil]; + [self addTrackingArea:trackingArea]; + [self updateUIInfo]; } } +- (void) viewDidMoveToWindow +{ + [self resizeWindow]; + [self frameUpdated]; +} + +- (void) viewWillMoveToWindow:(NSWindow *)newWindow +{ + [self removeTrackingRect]; +} + - (void) hideCursor { if (!cursor_hide) { @@ -518,36 +510,25 @@ - (void) drawRect:(NSRect) rect } } -- (void) setContentDimensions +- (NSSize) screenSafeAreaSize { - COCOA_DEBUG("QemuCocoaView: setContentDimensions\n"); + NSSize size = [[[self window] screen] frame].size; + NSEdgeInsets insets = [[[self window] screen] safeAreaInsets]; + size.width -= insets.left + insets.right; + size.height -= insets.top + insets.bottom; + return size; +} - if (isFullscreen) { - cdx = [[NSScreen mainScreen] frame].size.width / (float)screen.width; - cdy = [[NSScreen mainScreen] frame].size.height / (float)screen.height; +- (void) resizeWindow +{ + [[self window] setContentAspectRatio:NSMakeSize(screen.width, screen.height)]; - /* stretches video, but keeps same aspect ratio */ - if (stretch_video == true) { - /* use smallest stretch value - prevents clipping on sides */ - if (MIN(cdx, cdy) == cdx) { - cdy = cdx; - } else { - cdx = cdy; - } - } else { /* No stretching */ - cdx = cdy = 1; - } - cw = screen.width * cdx; - ch = screen.height * cdy; - cx = ([[NSScreen mainScreen] frame].size.width - cw) / 2.0; - cy = ([[NSScreen mainScreen] frame].size.height - ch) / 2.0; - } else { - cx = 0; - cy = 0; - cw = screen.width; - ch = screen.height; - cdx = 1.0; - cdy = 1.0; + if (!stretch_video) { + [[self window] setContentSize:NSMakeSize(screen.width, screen.height)]; + [[self window] center]; + } else if ([[self window] styleMask] & NSWindowStyleMaskFullScreen) { + [[self window] setContentSize:[self screenSafeAreaSize]]; + [[self window] center]; } } @@ -571,9 +552,10 @@ - (void) updateUIInfoLocked CGDirectDisplayID display = [[description objectForKey:@"NSScreenNumber"] unsignedIntValue]; NSSize screenSize = [[[self window] screen] frame].size; CGSize screenPhysicalSize = CGDisplayScreenSize(display); + bool isFullscreen = ([[self window] styleMask] & NSWindowStyleMaskFullScreen) != 0; CVDisplayLinkRef displayLink; - frameSize = isFullscreen ? screenSize : [self frame].size; + frameSize = isFullscreen ? [self screenSafeAreaSize] : [self frame].size; if (!CVDisplayLinkCreateWithCGDisplay(display, &displayLink)) { CVTime period = CVDisplayLinkGetNominalOutputVideoRefreshPeriod(displayLink); @@ -620,31 +602,19 @@ - (void) updateUIInfo }); } -- (void)viewDidMoveToWindow -{ - [self updateUIInfo]; -} - - (void) switchSurface:(pixman_image_t *)image { COCOA_DEBUG("QemuCocoaView: switchSurface\n"); int w = pixman_image_get_width(image); int h = pixman_image_get_height(image); - /* cdx == 0 means this is our very first surface, in which case we need - * to recalculate the content dimensions even if it happens to be the size - * of the initial empty window. - */ - bool isResize = (w != screen.width || h != screen.height || cdx == 0.0); - int oldh = screen.height; - if (isResize) { + if (w != screen.width || h != screen.height) { // Resize before we trigger the redraw, or we'll redraw at the wrong size COCOA_DEBUG("switchSurface: new size %d x %d\n", w, h); screen.width = w; screen.height = h; - [self setContentDimensions]; - [self setFrame:NSMakeRect(cx, cy, cw, ch)]; + [self resizeWindow]; [self updateBounds]; } @@ -654,51 +624,6 @@ - (void) switchSurface:(pixman_image_t *)image } pixman_image = image; - - // update windows - if (isFullscreen) { - [[fullScreenWindow contentView] setFrame:[[NSScreen mainScreen] frame]]; - [normalWindow setFrame:NSMakeRect([normalWindow frame].origin.x, [normalWindow frame].origin.y - h + oldh, w, h + [normalWindow frame].size.height - oldh) display:NO animate:NO]; - } else { - if (qemu_name) - [normalWindow setTitle:[NSString stringWithFormat:@"QEMU %s", qemu_name]]; - [normalWindow setFrame:NSMakeRect([normalWindow frame].origin.x, [normalWindow frame].origin.y - h + oldh, w, h + [normalWindow frame].size.height - oldh) display:YES animate:NO]; - } - - if (isResize) { - [normalWindow center]; - } -} - -- (void) toggleFullScreen:(id)sender -{ - COCOA_DEBUG("QemuCocoaView: toggleFullScreen\n"); - - if (isFullscreen) { // switch from fullscreen to desktop - isFullscreen = FALSE; - [self ungrabMouse]; - [self setContentDimensions]; - [fullScreenWindow close]; - [normalWindow setContentView: self]; - [normalWindow makeKeyAndOrderFront: self]; - [NSMenu setMenuBarVisible:YES]; - } else { // switch from desktop to fullscreen - isFullscreen = TRUE; - [normalWindow orderOut: nil]; /* Hide the window */ - [self grabMouse]; - [self setContentDimensions]; - [NSMenu setMenuBarVisible:NO]; - fullScreenWindow = [[NSWindow alloc] initWithContentRect:[[NSScreen mainScreen] frame] - styleMask:NSWindowStyleMaskBorderless - backing:NSBackingStoreBuffered - defer:NO]; - [fullScreenWindow setAcceptsMouseMovedEvents: YES]; - [fullScreenWindow setHasShadow:NO]; - [fullScreenWindow setBackgroundColor: [NSColor blackColor]]; - [self setFrame:NSMakeRect(cx, cy, cw, ch)]; - [[fullScreenWindow contentView] addSubview: self]; - [fullScreenWindow makeKeyAndOrderFront:self]; - } } - (void) setFullGrab:(id)sender @@ -812,8 +737,6 @@ - (bool) handleEventLocked:(NSEvent *)event COCOA_DEBUG("QemuCocoaView: handleEvent\n"); InputButton button; int keycode = 0; - // Location of event in virtual screen coordinates - NSPoint p = [self screenLocationOfEvent:event]; NSUInteger modifiers = [event modifierFlags]; /* @@ -1007,50 +930,6 @@ - (bool) handleEventLocked:(NSEvent *)event qkbd_state_key_event(kbd, keycode, false); } return true; - case NSEventTypeMouseMoved: - if (isAbsoluteEnabled) { - // Cursor re-entered into a window might generate events bound to screen coordinates - // and `nil` window property, and in full screen mode, current window might not be - // key window, where event location alone should suffice. - if (![self screenContainsPoint:p] || !([[self window] isKeyWindow] || isFullscreen)) { - if (isMouseGrabbed) { - [self ungrabMouse]; - } - } else { - if (!isMouseGrabbed) { - [self grabMouse]; - } - } - } - return [self handleMouseEvent:event]; - case NSEventTypeLeftMouseDown: - return [self handleMouseEvent:event button:INPUT_BUTTON_LEFT down:true]; - case NSEventTypeRightMouseDown: - return [self handleMouseEvent:event button:INPUT_BUTTON_RIGHT down:true]; - case NSEventTypeOtherMouseDown: - return [self handleMouseEvent:event button:INPUT_BUTTON_MIDDLE down:true]; - case NSEventTypeLeftMouseDragged: - return [self handleMouseEvent:event button:INPUT_BUTTON_LEFT down:true]; - case NSEventTypeRightMouseDragged: - return [self handleMouseEvent:event button:INPUT_BUTTON_RIGHT down:true]; - case NSEventTypeOtherMouseDragged: - return [self handleMouseEvent:event button:INPUT_BUTTON_MIDDLE down:true]; - case NSEventTypeLeftMouseUp: - if (!isMouseGrabbed && [self screenContainsPoint:p]) { - /* - * In fullscreen mode, the window of cocoaView may not be the - * key window, therefore the position relative to the virtual - * screen alone will be sufficient. - */ - if(isFullscreen || [[self window] isKeyWindow]) { - [self grabMouse]; - } - } - return [self handleMouseEvent:event button:INPUT_BUTTON_LEFT down:false]; - case NSEventTypeRightMouseUp: - return [self handleMouseEvent:event button:INPUT_BUTTON_RIGHT down:false]; - case NSEventTypeOtherMouseUp: - return [self handleMouseEvent:event button:INPUT_BUTTON_MIDDLE down:false]; case NSEventTypeScrollWheel: /* * Send wheel events to the guest regardless of window focus. @@ -1083,61 +962,118 @@ - (bool) handleEventLocked:(NSEvent *)event } } -- (bool) handleMouseEvent:(NSEvent *)event button:(InputButton)button down:(bool)down -{ - /* Don't send button events to the guest unless we've got a - * mouse grab or window focus. If we have neither then this event - * is the user clicking on the background window to activate and - * bring us to the front, which will be done by the sendEvent - * call below. We definitely don't want to pass that click through - * to the guest. - */ - if (!isMouseGrabbed && ![[self window] isKeyWindow]) { - return false; - } - - qemu_input_queue_btn(dcl.con, button, down); - - return [self handleMouseEvent:event]; -} - -- (bool) handleMouseEvent:(NSEvent *)event +- (void) handleMouseEvent:(NSEvent *)event button:(InputButton)button down:(bool)down { if (!isMouseGrabbed) { - return false; + return; } - if (isAbsoluteEnabled) { - NSPoint p = [self screenLocationOfEvent:event]; + with_bql(^{ + qemu_input_queue_btn(dcl.con, button, down); + }); - /* Note that the origin for Cocoa mouse coords is bottom left, not top left. - * The check on screenContainsPoint is to avoid sending out of range values for - * clicks in the titlebar. - */ - if ([self screenContainsPoint:p]) { - qemu_input_queue_abs(dcl.con, INPUT_AXIS_X, p.x, 0, screen.width); - qemu_input_queue_abs(dcl.con, INPUT_AXIS_Y, screen.height - p.y, 0, screen.height); + [self handleMouseEvent:event]; +} + +- (void) handleMouseEvent:(NSEvent *)event +{ + if (!isMouseGrabbed) { + return; + } + + with_bql(^{ + if (isAbsoluteEnabled) { + CGFloat d = (CGFloat)screen.height / [self frame].size.height; + NSPoint p = [event locationInWindow]; + + /* Note that the origin for Cocoa mouse coords is bottom left, not top left. */ + qemu_input_queue_abs(dcl.con, INPUT_AXIS_X, p.x * d, 0, screen.width); + qemu_input_queue_abs(dcl.con, INPUT_AXIS_Y, screen.height - p.y * d, 0, screen.height); + } else { + qemu_input_queue_rel(dcl.con, INPUT_AXIS_X, [event deltaX]); + qemu_input_queue_rel(dcl.con, INPUT_AXIS_Y, [event deltaY]); } - } else { - qemu_input_queue_rel(dcl.con, INPUT_AXIS_X, (int)[event deltaX]); - qemu_input_queue_rel(dcl.con, INPUT_AXIS_Y, (int)[event deltaY]); + + qemu_input_event_sync(); + }); +} + +- (void) mouseExited:(NSEvent *)event +{ + if (isAbsoluteEnabled && isMouseGrabbed) { + [self ungrabMouse]; + } +} + +- (void) mouseEntered:(NSEvent *)event +{ + if (isAbsoluteEnabled && !isMouseGrabbed) { + [self grabMouse]; + } +} + +- (void) mouseMoved:(NSEvent *)event +{ + [self handleMouseEvent:event]; +} + +- (void) mouseDown:(NSEvent *)event +{ + [self handleMouseEvent:event button:INPUT_BUTTON_LEFT down:true]; +} + +- (void) rightMouseDown:(NSEvent *)event +{ + [self handleMouseEvent:event button:INPUT_BUTTON_RIGHT down:true]; +} + +- (void) otherMouseDown:(NSEvent *)event +{ + [self handleMouseEvent:event button:INPUT_BUTTON_MIDDLE down:true]; +} + +- (void) mouseDragged:(NSEvent *)event +{ + [self handleMouseEvent:event]; +} + +- (void) rightMouseDragged:(NSEvent *)event +{ + [self handleMouseEvent:event]; +} + +- (void) otherMouseDragged:(NSEvent *)event +{ + [self handleMouseEvent:event]; +} + +- (void) mouseUp:(NSEvent *)event +{ + if (!isMouseGrabbed) { + [self grabMouse]; } - qemu_input_event_sync(); + [self handleMouseEvent:event button:INPUT_BUTTON_LEFT down:false]; +} - return true; +- (void) rightMouseUp:(NSEvent *)event +{ + [self handleMouseEvent:event button:INPUT_BUTTON_RIGHT down:false]; +} + +- (void) otherMouseUp:(NSEvent *)event +{ + [self handleMouseEvent:event button:INPUT_BUTTON_MIDDLE down:false]; } - (void) grabMouse { COCOA_DEBUG("QemuCocoaView: grabMouse\n"); - if (!isFullscreen) { - if (qemu_name) - [normalWindow setTitle:[NSString stringWithFormat:@"QEMU %s - (Press " UC_CTRL_KEY " " UC_ALT_KEY " G to release Mouse)", qemu_name]]; - else - [normalWindow setTitle:@"QEMU - (Press " UC_CTRL_KEY " " UC_ALT_KEY " G to release Mouse)"]; - } + if (qemu_name) + [normalWindow setTitle:[NSString stringWithFormat:@"QEMU %s - (Press " UC_CTRL_KEY " " UC_ALT_KEY " G to release Mouse)", qemu_name]]; + else + [normalWindow setTitle:@"QEMU - (Press " UC_CTRL_KEY " " UC_ALT_KEY " G to release Mouse)"]; [self hideCursor]; CGAssociateMouseAndMouseCursorPosition(isAbsoluteEnabled); isMouseGrabbed = TRUE; // while isMouseGrabbed = TRUE, QemuCocoaApp sends all events to [cocoaView handleEvent:] @@ -1147,15 +1083,14 @@ - (void) ungrabMouse { COCOA_DEBUG("QemuCocoaView: ungrabMouse\n"); - if (!isFullscreen) { - if (qemu_name) - [normalWindow setTitle:[NSString stringWithFormat:@"QEMU %s", qemu_name]]; - else - [normalWindow setTitle:@"QEMU"]; - } + if (qemu_name) + [normalWindow setTitle:[NSString stringWithFormat:@"QEMU %s", qemu_name]]; + else + [normalWindow setTitle:@"QEMU"]; [self unhideCursor]; CGAssociateMouseAndMouseCursorPosition(TRUE); isMouseGrabbed = FALSE; + [self raiseAllButtons]; } - (void) setAbsoluteEnabled:(BOOL)tIsAbsoluteEnabled { @@ -1166,8 +1101,6 @@ - (void) setAbsoluteEnabled:(BOOL)tIsAbsoluteEnabled { } - (BOOL) isMouseGrabbed {return isMouseGrabbed;} - (BOOL) isAbsoluteEnabled {return isAbsoluteEnabled;} -- (float) cdx {return cdx;} -- (float) cdy {return cdy;} - (QEMUScreen) gscreen {return screen;} /* @@ -1181,6 +1114,15 @@ - (void) raiseAllKeys qkbd_state_lift_all_keys(kbd); }); } + +- (void) raiseAllButtons +{ + with_bql(^{ + qemu_input_queue_btn(dcl.con, INPUT_BUTTON_LEFT, false); + qemu_input_queue_btn(dcl.con, INPUT_BUTTON_RIGHT, false); + qemu_input_queue_btn(dcl.con, INPUT_BUTTON_MIDDLE, false); + }); +} @end @@ -1195,7 +1137,6 @@ @interface QemuCocoaAppController : NSObject { } - (void)doToggleFullScreen:(id)sender; -- (void)toggleFullScreen:(id)sender; - (void)showQEMUDoc:(id)sender; - (void)zoomToFit:(id) sender; - (void)displayConsole:(id)sender; @@ -1237,7 +1178,8 @@ - (id) init exit(1); } [normalWindow setAcceptsMouseMovedEvents:YES]; - [normalWindow setTitle:@"QEMU"]; + [normalWindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary]; + [normalWindow setTitle:qemu_name ? [NSString stringWithFormat:@"QEMU %s", qemu_name] : @"QEMU"]; [normalWindow setContentView:cocoaView]; [normalWindow makeKeyAndOrderFront:self]; [normalWindow center]; @@ -1307,10 +1249,21 @@ - (void)windowDidChangeScreen:(NSNotification *)notification [cocoaView updateUIInfo]; } +- (void)windowDidEnterFullScreen:(NSNotification *)notification +{ + [cocoaView grabMouse]; +} + +- (void)windowDidExitFullScreen:(NSNotification *)notification +{ + [cocoaView resizeWindow]; + [cocoaView ungrabMouse]; +} + - (void)windowDidResize:(NSNotification *)notification { [cocoaView updateBounds]; - [cocoaView updateUIInfo]; + [cocoaView frameUpdated]; } /* Called when the user clicks on a window's close button */ @@ -1326,6 +1279,14 @@ - (BOOL)windowShouldClose:(id)sender return NO; } +- (NSApplicationPresentationOptions) window:(NSWindow *)window + willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)proposedOptions; + +{ + return (proposedOptions & ~(NSApplicationPresentationAutoHideDock | NSApplicationPresentationAutoHideMenuBar)) | + NSApplicationPresentationHideDock | NSApplicationPresentationHideMenuBar; +} + /* * Called when QEMU goes into the background. Note that * [-NSWindowDelegate windowDidResignKey:] is used here instead of @@ -1345,14 +1306,7 @@ - (void) windowDidResignKey: (NSNotification *)aNotification */ - (void) doToggleFullScreen:(id)sender { - [self toggleFullScreen:(id)sender]; -} - -- (void)toggleFullScreen:(id)sender -{ - COCOA_DEBUG("QemuCocoaAppController: toggleFullScreen\n"); - - [cocoaView toggleFullScreen:sender]; + [normalWindow toggleFullScreen:sender]; } - (void) setFullGrab:(id)sender @@ -1403,6 +1357,7 @@ - (void)zoomToFit:(id) sender if (stretch_video == true) { [sender setState: NSControlStateValueOn]; } else { + [cocoaView resizeWindow]; [sender setState: NSControlStateValueOff]; } } @@ -2049,8 +2004,7 @@ static void cocoa_display_init(DisplayState *ds, DisplayOptions *opts) /* if fullscreen mode is to be used */ if (opts->has_full_screen && opts->full_screen) { - [NSApp activateIgnoringOtherApps: YES]; - [controller toggleFullScreen: nil]; + [normalWindow toggleFullScreen: nil]; } if (opts->u.cocoa.has_full_grab && opts->u.cocoa.full_grab) { [controller setFullGrab: nil]; From patchwork Tue Mar 5 11:06:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 777976 Delivered-To: patch@linaro.org Received: by 2002:a5d:48c8:0:b0:33e:474f:8c56 with SMTP id p8csp372685wrs; Tue, 5 Mar 2024 03:09:19 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVeEvwLWwE/714CSPQ3BECqtXBTUhffCMa8l5ZWpcJzNES8ur256Uouo26A4/pjridLj2teTda2QfOywmRssffG X-Google-Smtp-Source: AGHT+IGKAfXSDGCOVaXF1IPxsW4xM+UVMVVYzK7koAPml6gwJsOrJBiT7i33hBqBNH16eaQP7Kpj X-Received: by 2002:a81:5243:0:b0:609:89b7:689b with SMTP id g64-20020a815243000000b0060989b7689bmr10813815ywb.16.1709636959137; Tue, 05 Mar 2024 03:09:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709636959; cv=none; d=google.com; s=arc-20160816; b=nEgBIQre7tpqnKnXPtQIMTV5tsN27UByihwT700rrcrJIlwOXT/k3iptzKCaF0e6ri LAWEt7UwKwiG3rN1FvkTTOZ+Wt3pHRoz4OC/oNj8UHKxdZyeizdODD+MMS4UL0WXZkrd G0jPPR4jg6lSHyAitb59lHCJq5GD/CLe1XwRouYv+G0tJK+AB4Y5aUUY4cf2Ht7r+gOm UZPrxPwLCmRfswXkAsH7n0jy6WOikQP0fW4+xp2OgS75cHtQQqrYF5C35k4jMTbra46l jPFpyyNk9+gScegQo/STr+ui0ErnkuWCJFhA54lmXGCvxFZ3I5o4PTHfZR6oEXSdCt3S HGyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=u6bEtJuwfbnOuuvRh3OE+y+ZReFgvS5n0cBCvwV1aiQ=; fh=lnLpXpuHHACtmFCFYDz84qQIx2RASFfAeprBY3P3HzE=; b=TXpFynlxRIJ2TSZ8fk9LfIYyetgi9bTBWVNn44JRo44J3V+DLrpuPm0700S1VGb+SX 6+wagf7t1nAP8qTQFJ87rg6RYUrXR1qjgH27jeHx0vYHaaw/wTztESfZ4Kth5Cbom4g3 1QnXRLcyIdRKAzFGjuRXD7eOaWYZ0VxzdlJYm414reAfTjfiDNADf84UXqaADhHp0OBx ZA7ck0f+1VhV+sco5WnvJiJy3tceMhizSJkeUe01R9mIXu/0ABSjMUvFvyakK6ME1qeF IT+CG+CUiUZV7b1aE9eEOes1woPzxbeU7cvlZvR22ipn7b3OsdWaysr1tnIdmnDyehLi IuFw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ez8TNzMn; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d15-20020ac85d8f000000b0042ef8746f3esi2915447qtx.772.2024.03.05.03.09.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Mar 2024 03:09:19 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ez8TNzMn; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhSde-0000GW-1V; Tue, 05 Mar 2024 06:07:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhSdb-00007J-7W for qemu-devel@nongnu.org; Tue, 05 Mar 2024 06:07:11 -0500 Received: from mail-lf1-x132.google.com ([2a00:1450:4864:20::132]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhSdZ-0002rB-85 for qemu-devel@nongnu.org; Tue, 05 Mar 2024 06:07:10 -0500 Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-51341a5aafbso2539902e87.0 for ; Tue, 05 Mar 2024 03:07:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709636825; x=1710241625; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=u6bEtJuwfbnOuuvRh3OE+y+ZReFgvS5n0cBCvwV1aiQ=; b=Ez8TNzMn9+LJ8pBSXIsfZQKMvqyLKbD9jWduzNxc2IKvY+5m013LTnJchbGQvpex7E EUDBev3y71CZIDS7KvS8MpDWIzsm1opvWPfCT9EX2NAqoK2grCiuCknoc7kjuknnBbyY t3idbmJ9kyyFMAUpMxUAHnVbTWedoRsguflnG3kglcp/nlubPB41CgSU4roJ3OyepKGN X6odDpjMYBEYoW7xyhTADBbdxuRtzmV/g+Pjl4VYvR0xQJnDwXT4r2J3E0mJShB6Yqz8 vIb8hYcNlKWSOG++ds2K7l/6+c4Any59BJ3+aXTmMSyWL1mCkVzGBYWKBAGS/ryeUCTR V+vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709636825; x=1710241625; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=u6bEtJuwfbnOuuvRh3OE+y+ZReFgvS5n0cBCvwV1aiQ=; b=OCvok0wwUKgxpQHrPkts/BUfEUBXQ8SkMfMEZk7bgyHtWLRUZNJLphByHNlc4QkPNU zI0izWem7z2TZKp7a7YTUvGb8pL0TajX8CeWv5KDGzN/wfYHEwG1C2WR2vLa/VRaB1zp rfg1ITa34B+8fUyHQaUlazhxrFVSkVzTYJDAX/4wEIPhuPAb4vUQ/rTPqp8ZqazYSosd hNrTg9pD0xteSER8uH/GB5k8cUC4FQahCC3fYtJ/Cg4/nx28S+9DqjLM2a212mJ/b5Wv 65Bv/n89Q+m2nnvDuBHuesk3RZg297CfsMbN1EnXupZaXJaCJwaexwBLmKsXYMoj6TLz uqIw== X-Gm-Message-State: AOJu0YzUVk7lQLoLfvKgxJj2A1jQWZ3HvKrAqNYqqcq/MljOr6cCVx64 er0fEQFJnQNfGBEozcIOt4phKpKnJeQEy7L9UPDzRPorBjoryZWbdO/bLjuB5bZ7iyXSJQtBCMI 2 X-Received: by 2002:a05:6512:551:b0:511:6a0b:1035 with SMTP id h17-20020a056512055100b005116a0b1035mr1018904lfl.17.1709636825185; Tue, 05 Mar 2024 03:07:05 -0800 (PST) Received: from m1x-phil.lan ([176.176.177.70]) by smtp.gmail.com with ESMTPSA id v23-20020a1709067d9700b00a42ee62b634sm5861402ejo.106.2024.03.05.03.07.03 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 05 Mar 2024 03:07:04 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Akihiko Odaki , Rene Engel , Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Subject: [PULL 09/12] ui/cocoa: Remove normalWindow Date: Tue, 5 Mar 2024 12:06:04 +0100 Message-ID: <20240305110608.21618-10-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240305110608.21618-1-philmd@linaro.org> References: <20240305110608.21618-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::132; envelope-from=philmd@linaro.org; helo=mail-lf1-x132.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Akihiko Odaki QemuCocoaView used to have fullScreenWindow but now it's gone, so we do no longer have to call the window specifically "normalWindow". Instead, refer to it with [-QemuCocoaView window]. Signed-off-by: Akihiko Odaki Tested-by: Rene Engel Reviewed-by: Peter Maydell Message-ID: <20240224-cocoa-v12-7-e89f70bdda71@daynix.com> Signed-off-by: Philippe Mathieu-Daudé --- ui/cocoa.m | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index 20d73098e2..a891e76345 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -93,7 +93,6 @@ static void cocoa_switch(DisplayChangeListener *dcl, static void cocoa_refresh(DisplayChangeListener *dcl); -static NSWindow *normalWindow; static const DisplayChangeListenerOps dcl_ops = { .dpy_name = "cocoa", .dpy_gfx_update = cocoa_update, @@ -1071,9 +1070,9 @@ - (void) grabMouse COCOA_DEBUG("QemuCocoaView: grabMouse\n"); if (qemu_name) - [normalWindow setTitle:[NSString stringWithFormat:@"QEMU %s - (Press " UC_CTRL_KEY " " UC_ALT_KEY " G to release Mouse)", qemu_name]]; + [[self window] setTitle:[NSString stringWithFormat:@"QEMU %s - (Press " UC_CTRL_KEY " " UC_ALT_KEY " G to release Mouse)", qemu_name]]; else - [normalWindow setTitle:@"QEMU - (Press " UC_CTRL_KEY " " UC_ALT_KEY " G to release Mouse)"]; + [[self window] setTitle:@"QEMU - (Press " UC_CTRL_KEY " " UC_ALT_KEY " G to release Mouse)"]; [self hideCursor]; CGAssociateMouseAndMouseCursorPosition(isAbsoluteEnabled); isMouseGrabbed = TRUE; // while isMouseGrabbed = TRUE, QemuCocoaApp sends all events to [cocoaView handleEvent:] @@ -1084,9 +1083,9 @@ - (void) ungrabMouse COCOA_DEBUG("QemuCocoaView: ungrabMouse\n"); if (qemu_name) - [normalWindow setTitle:[NSString stringWithFormat:@"QEMU %s", qemu_name]]; + [[self window] setTitle:[NSString stringWithFormat:@"QEMU %s", qemu_name]]; else - [normalWindow setTitle:@"QEMU"]; + [[self window] setTitle:@"QEMU"]; [self unhideCursor]; CGAssociateMouseAndMouseCursorPosition(TRUE); isMouseGrabbed = FALSE; @@ -1157,6 +1156,8 @@ - (void)adjustSpeed:(id)sender; @implementation QemuCocoaAppController - (id) init { + NSWindow *window; + COCOA_DEBUG("QemuCocoaAppController: init\n"); self = [super init]; @@ -1170,20 +1171,20 @@ - (id) init } // create a window - normalWindow = [[NSWindow alloc] initWithContentRect:[cocoaView frame] + window = [[NSWindow alloc] initWithContentRect:[cocoaView frame] styleMask:NSWindowStyleMaskTitled|NSWindowStyleMaskMiniaturizable|NSWindowStyleMaskClosable backing:NSBackingStoreBuffered defer:NO]; - if(!normalWindow) { + if(!window) { error_report("(cocoa) can't create window"); exit(1); } - [normalWindow setAcceptsMouseMovedEvents:YES]; - [normalWindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary]; - [normalWindow setTitle:qemu_name ? [NSString stringWithFormat:@"QEMU %s", qemu_name] : @"QEMU"]; - [normalWindow setContentView:cocoaView]; - [normalWindow makeKeyAndOrderFront:self]; - [normalWindow center]; - [normalWindow setDelegate: self]; + [window setAcceptsMouseMovedEvents:YES]; + [window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary]; + [window setTitle:qemu_name ? [NSString stringWithFormat:@"QEMU %s", qemu_name] : @"QEMU"]; + [window setContentView:cocoaView]; + [window makeKeyAndOrderFront:self]; + [window center]; + [window setDelegate: self]; /* Used for displaying pause on the screen */ pauseLabel = [NSTextField new]; @@ -1306,7 +1307,7 @@ - (void) windowDidResignKey: (NSNotification *)aNotification */ - (void) doToggleFullScreen:(id)sender { - [normalWindow toggleFullScreen:sender]; + [[cocoaView window] toggleFullScreen:sender]; } - (void) setFullGrab:(id)sender @@ -2004,7 +2005,7 @@ static void cocoa_display_init(DisplayState *ds, DisplayOptions *opts) /* if fullscreen mode is to be used */ if (opts->has_full_screen && opts->full_screen) { - [normalWindow toggleFullScreen: nil]; + [[cocoaView window] toggleFullScreen: nil]; } if (opts->u.cocoa.has_full_grab && opts->u.cocoa.full_grab) { [controller setFullGrab: nil]; From patchwork Tue Mar 5 11:06:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 777971 Delivered-To: patch@linaro.org Received: by 2002:a5d:48c8:0:b0:33e:474f:8c56 with SMTP id p8csp372205wrs; Tue, 5 Mar 2024 03:08:01 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWHhXnAM16ZUkyjMFuPtSIuSWSQFSrvKlLe+Cu0OSdvDt5nCBHkhQj6hR4ANmNjow4AkzwVGQHmyMBVzGIOUYgB X-Google-Smtp-Source: AGHT+IFSUMrzpyCPyKE6Zm65txkfYYzZNHWFuDuxpr+KakmsLskEEuZ5wA5W4SWVnUTxHjEMjlJy X-Received: by 2002:a05:6808:178e:b0:3c0:72ba:64e with SMTP id bg14-20020a056808178e00b003c072ba064emr1629724oib.39.1709636881294; Tue, 05 Mar 2024 03:08:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709636881; cv=none; d=google.com; s=arc-20160816; b=C9qh3C+FSNch7l0EOCMV9jz7s5kUpkxOLSwSS8ejRqo94zOyazOloJM8UX9fCTzWKK tZbfkGPDZxbpO5XTcSEDpGGuS9PUVbVCL3UqcK8M25xMOzpDWy2zPEwYgJLARmfYXqAg vPzBjwBmpk+uGsAP1LQ/lNfAfqEzd2ITgxEqQx8aU3q+QFD4Jv8kbc2AjNSD4h2rfzBk F+mNgB/mzGO0Q2G91ANagrnR3u24TheFm/5JG9oDJbd8s3y/HqTEidd3G/Tf0nYteH/W QQLJ/VxdquI8ijTpdixVRyke2Qdl+CUxa0eE73p4Mln/kOLLAcYKvBeHSpYX8Bvz2CEl z1ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=u3wQ/LWJs/H+DafgGjzo37DBcyLizBxzZHb4EPua6Sw=; fh=lnLpXpuHHACtmFCFYDz84qQIx2RASFfAeprBY3P3HzE=; b=eUilqvasg9YmCRUs7XkoHpkMM7DlaFq11SDB8KxL+yh3OmXThMPxjfY9PlFC3lYAb/ vx0k+hzZo7KJh9INNr3aBr0kxYmCleaacUZHU/Jt0FBHjS8MDz0PODQdc6ZVguo0ICoA IUdKQd4AJIGt/cJG4REfFawXepc495LfbqcfQppfC7sF6kBv8msHORdCIV76jLbRBsM7 zN24Q8G7jysNQG9srN6AMIjSZJkn20cPY0F/iB6CDFSeDUdf2mmDIx87xDSuPK2EjtzM RagqmVvGi2zYAY6CPagXb4cxtxfjRmOsA91TYiOOeYBTc+j2dTATolTPwHIw1hMrDPmK /heA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=W2N9GqTm; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id pi40-20020a05620a37a800b0078553d900c4si11563185qkn.73.2024.03.05.03.08.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Mar 2024 03:08:01 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=W2N9GqTm; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhSdh-0000Wb-TU; Tue, 05 Mar 2024 06:07:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhSdg-0000Rd-46 for qemu-devel@nongnu.org; Tue, 05 Mar 2024 06:07:16 -0500 Received: from mail-lj1-x234.google.com ([2a00:1450:4864:20::234]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhSde-0002uB-AI for qemu-devel@nongnu.org; Tue, 05 Mar 2024 06:07:15 -0500 Received: by mail-lj1-x234.google.com with SMTP id 38308e7fff4ca-2d28387db09so65579051fa.0 for ; Tue, 05 Mar 2024 03:07:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709636831; x=1710241631; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=u3wQ/LWJs/H+DafgGjzo37DBcyLizBxzZHb4EPua6Sw=; b=W2N9GqTmi8rGCgSqf2G+ARoitzqYMt80TQWc2z4+71hWMXPZv+DXCQgua+oSQyr+73 8oGa7Emb+MEwRsLRAKpsruGczGDlknV+2TUNf9hbXm9LG2zBZ4xs/UkzbsSknLvbrM8M /vjB0v4tjfxzALnDu8TidEOgxcPVMi5Tz62jLPObX49zp49LjFLHCmDEy4iP8GJqtUR7 7SqLZ/BVMglkBLy4p1Uz9wkhzptOIUkDgLx9DyCOuAcSI6EqECS9b2bau5repujxNbAc DHRMiR5UYuhpPcMTKY7oE54F4S2Bcl8rNGQTTTYcl6PusgM7VSG50kgt8uhT38Bd9Dmk 140g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709636831; x=1710241631; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=u3wQ/LWJs/H+DafgGjzo37DBcyLizBxzZHb4EPua6Sw=; b=SW8zp3+a8cVkhXnDdOW7CaOcgyvMzyk1Sw1eJxlcjw1jAC2Jn/O0cOLSZ6cccvCWOs IErKrSqQvzbhpk4v8BpzWJkSE/dOaTtxsU7IvjScpva8W+3qX9yB1ne0qbYUpfLGYYBe dSKYXJxA5r62emeyoREYmyTdXq9QqCR8jjdezAJcMkWqvyJ28Fu44c+4oNrV5BdBV9zj vSSRu4yO1vSKxxDn11g2f711uhuHufCUiIoVjXUVDt8UL6JvMIFK3UqNOinONnmLbQYq Ni6+ksIBhroUM9AI4iRCbRt3cIV180CmWK+W1irnH4p+mLle9eeYT/V3AcWt18DrmWsT JjMw== X-Gm-Message-State: AOJu0YxdsosV9RKcBTjym2EkqCaPhvuvtFACWHuCf9yAhQNHjCWq31ra YcFqHcSg5SvJyZDILNesF5e4Yoalsh3+SOV9N6bwp+O8FDsybDRIvD3jfGmeM4IYg9mFBHznbGY p X-Received: by 2002:a05:6512:34d3:b0:513:46be:2465 with SMTP id w19-20020a05651234d300b0051346be2465mr944433lfr.55.1709636831178; Tue, 05 Mar 2024 03:07:11 -0800 (PST) Received: from m1x-phil.lan ([176.176.177.70]) by smtp.gmail.com with ESMTPSA id jw11-20020a170906e94b00b00a455d78be5bsm1945750ejb.9.2024.03.05.03.07.09 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 05 Mar 2024 03:07:10 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Akihiko Odaki , Rene Engel , Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Subject: [PULL 10/12] ui/cocoa: Make window resizable Date: Tue, 5 Mar 2024 12:06:05 +0100 Message-ID: <20240305110608.21618-11-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240305110608.21618-1-philmd@linaro.org> References: <20240305110608.21618-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::234; envelope-from=philmd@linaro.org; helo=mail-lj1-x234.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Akihiko Odaki The window will be resizable when zoom-to-fit is on. Signed-off-by: Akihiko Odaki Tested-by: Rene Engel Reviewed-by: Peter Maydell Message-ID: <20240224-cocoa-v12-8-e89f70bdda71@daynix.com> Signed-off-by: Philippe Mathieu-Daudé --- ui/cocoa.m | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ui/cocoa.m b/ui/cocoa.m index a891e76345..6c9efa0c20 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -1356,8 +1356,10 @@ - (void)zoomToFit:(id) sender { stretch_video = !stretch_video; if (stretch_video == true) { + [cocoaView window].styleMask |= NSWindowStyleMaskResizable; [sender setState: NSControlStateValueOn]; } else { + [cocoaView window].styleMask &= ~NSWindowStyleMaskResizable; [cocoaView resizeWindow]; [sender setState: NSControlStateValueOff]; } @@ -2024,6 +2026,7 @@ static void cocoa_display_init(DisplayState *ds, DisplayOptions *opts) if (opts->u.cocoa.has_zoom_to_fit && opts->u.cocoa.zoom_to_fit) { stretch_video = true; + [cocoaView window].styleMask |= NSWindowStyleMaskResizable; } if (opts->u.cocoa.has_zoom_interpolation && opts->u.cocoa.zoom_interpolation) { From patchwork Tue Mar 5 11:06:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 777972 Delivered-To: patch@linaro.org Received: by 2002:a5d:48c8:0:b0:33e:474f:8c56 with SMTP id p8csp372357wrs; Tue, 5 Mar 2024 03:08:20 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXxGJNdWGzuleu4GfdYFQ8oa3LR2QGjJ6AYX4r64vDGyo1xG2sXzlq6JBfk2eb+LAChLWNIbhZqLQLDnA20ReVX X-Google-Smtp-Source: AGHT+IF2eohJbP8lBI1H+EP+ljo+dsO4ChMi9EZs/Z8yXKaFM1pjILM2YBk1+eEa57MfSiOeAJCU X-Received: by 2002:a05:620a:1b:b0:787:a2f0:2fc2 with SMTP id j27-20020a05620a001b00b00787a2f02fc2mr1621528qki.76.1709636899907; Tue, 05 Mar 2024 03:08:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709636899; cv=none; d=google.com; s=arc-20160816; b=yJBlw8nkG+/3ElYLLWE8h17tE9hgfbeCZuXr6qj3TsJ3VbD17yk7+uNECBtBUBVDW9 m1Kup4J0v2AO1xkHPoWzk9HQXCr1lSP1aoDBhgxBXLAJdDjDPF1rYKticEebtisAuIS2 gx3j6kKBcgBAy19ZA/mDgo6n+0K5M5f+If7Ms5gedLTUcvCSSJIEJV4cQUqmEnVD934F FoZsCO9epsHPY6XpNZwN6ZhIn5O+XmbfGnacCEOrm3oj0yl+1ljXeDtXGjQ5tKTdaRWD I5NwlHbgTv7zfMFKW218SYLnmJRPjtSBc+7pRfqseNfh8rccK0zUz3zF0+TYEnLRi4Ii cFbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=nVNp2XET9C+VfD19+bqo8MRrdyqsLDGvDOE4eeDfw2k=; fh=lnLpXpuHHACtmFCFYDz84qQIx2RASFfAeprBY3P3HzE=; b=NrPekZgcSXLyEtkHIjU/yHxVzt0Jsn0MLZ/2qAR03n0nvyw/Fi51M1oDd9Ia4ZH9OO qvz2YwjYxmDieqy46yyXctt0Qg9HelbyglqAXEttkzPkUL+cyZisefAz2urnF+qivWl+ +7VGXrnjlcz7nH84gi5RWw/fW1gNJqwj6URXxQANQRUAM0b47Rm10JMbJiq7WWJJ62Yg +R2lJyNAUydp/dweAYze9hQDfO+o3tcJ9aKpvEokTufSbivWyYYPZ8ZwU2ID9Z97VpWs U0uco48J/Ohc9VOGNWEmjBdZIygm4Zu8GoDXc3sP4w8A4QHGK1C8Oi5v9x1Qq4T/blnm nUkA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pQRGNolc; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id a4-20020a05620a02e400b0078826020765si4647030qko.422.2024.03.05.03.08.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Mar 2024 03:08:19 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pQRGNolc; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhSds-00011e-36; Tue, 05 Mar 2024 06:07:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhSdn-0000pP-7u for qemu-devel@nongnu.org; Tue, 05 Mar 2024 06:07:25 -0500 Received: from mail-ej1-x62f.google.com ([2a00:1450:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhSdj-0002wF-87 for qemu-devel@nongnu.org; Tue, 05 Mar 2024 06:07:21 -0500 Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-a450615d1c4so421587066b.0 for ; Tue, 05 Mar 2024 03:07:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709636837; x=1710241637; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nVNp2XET9C+VfD19+bqo8MRrdyqsLDGvDOE4eeDfw2k=; b=pQRGNolctMA3JQfpKZV5EWKQg9zG/6TemFeaDDQlzyhGfLnHynn4ROPTGKNJ2l4f73 eZob/18pTGxpPhhgM9X6dUga9RCAfjrL/gXGiiIFwbRjrcQF72P+YJGD3zoCFA4/9Qsh 2G2ZJeE1JDEonc45fy9FkQHUNB31oOJzWEuK1KPamosznrolaqM7ZAncVkVG15kjyc5D BqaJrbnKVxhJpMS9ZsGaJCvijoEeUsz/QI/RAx6REx1cIThkdahNUIMHHA7mUpOMMHyd GdXjAoTeyNhOiAiSKmpm1rwiiOqYj3hkH3EL63ITx2/8sATNTuHD5PKBuF63CzuaF5Sf KfMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709636837; x=1710241637; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nVNp2XET9C+VfD19+bqo8MRrdyqsLDGvDOE4eeDfw2k=; b=SDVhZcXhNbA2BffuBgS705JlHnCQU3XHmjSZTx15cAhe+pmRC62EpffEhXtybylIJJ Beg8XQqCtamaHTTxE7Zkvo7QXqDGcB881s/DM4KRojaxtjGxoCU9llVBi+ZgMinzgWA+ nu/3+zYFVq6pl59OI/kDsnDhtCjjlJguSth+NIXL0FUCmuDiiakh9ubR/ubOHuwMwnes U+5wg6HvR8pw3yR3M4z8KsleY/WqniDW++XQvLTfhB5sVT8xHpcW1unTMUf7H5zCulgS wf2w6gfjNDHiI8dMaVzDYEccrfaXpRL+QVYsYeBYQoWljz7cvYAL2Ign3Anor002lsLu 1WpA== X-Gm-Message-State: AOJu0Yx7Gv5QsIFlh39HVZCql7nJnPBTiiFmSpMs5BOS1fl2sHSISMYU elGZi6EjxXQYKjEsJ3AL8zrXr8siuD5nJOzoqGl0pvTANHQOtGucgjGsdJI3V5ILF5vbazS/G01 / X-Received: by 2002:a17:906:16d6:b0:a44:a1f9:3826 with SMTP id t22-20020a17090616d600b00a44a1f93826mr2262346ejd.25.1709636837244; Tue, 05 Mar 2024 03:07:17 -0800 (PST) Received: from m1x-phil.lan ([176.176.177.70]) by smtp.gmail.com with ESMTPSA id js20-20020a170906ca9400b00a3e643e61e1sm5889216ejb.214.2024.03.05.03.07.15 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 05 Mar 2024 03:07:16 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Akihiko Odaki , Rene Engel , Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Subject: [PULL 11/12] ui/cocoa: Call console_select() with the BQL Date: Tue, 5 Mar 2024 12:06:06 +0100 Message-ID: <20240305110608.21618-12-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240305110608.21618-1-philmd@linaro.org> References: <20240305110608.21618-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62f; envelope-from=philmd@linaro.org; helo=mail-ej1-x62f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Akihiko Odaki [-QemuCocoaView displayConsole:] can be called anytime so explicitly take the BQL before it calls console_select(). Signed-off-by: Akihiko Odaki Tested-by: Rene Engel Reviewed-by: Peter Maydell Message-ID: <20240224-cocoa-v12-9-e89f70bdda71@daynix.com> Signed-off-by: Philippe Mathieu-Daudé --- ui/cocoa.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index 6c9efa0c20..bc63043158 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -1379,7 +1379,9 @@ - (void)toggleZoomInterpolation:(id) sender /* Displays the console on the screen */ - (void)displayConsole:(id)sender { - console_select([sender tag]); + with_bql(^{ + console_select([sender tag]); + }); } /* Pause the guest */ From patchwork Tue Mar 5 11:06:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 777973 Delivered-To: patch@linaro.org Received: by 2002:a5d:48c8:0:b0:33e:474f:8c56 with SMTP id p8csp372380wrs; Tue, 5 Mar 2024 03:08:24 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCX3OdXAFdgG77YLN1UHJoNc6noDITEAKmpDsclrYAbgKFELOYwS+PJkvIeEnHm/JY6NprD9fLStFPqDfGw0QDmD X-Google-Smtp-Source: AGHT+IEMwpO1G/OIt7zGIwxhlweu8+aK4rDj4JnfuEBMnybJ759RI47PUH3A+rWfjUX97DlZbsJb X-Received: by 2002:ac8:5e08:0:b0:42e:f1f8:6957 with SMTP id h8-20020ac85e08000000b0042ef1f86957mr1713584qtx.65.1709636904400; Tue, 05 Mar 2024 03:08:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709636904; cv=none; d=google.com; s=arc-20160816; b=07iD9Z2hzBgyOoAp7z/xQWGV+1fWs+gMikqkRi5GQ8n8lGgouUNrr3WQhAeusk0D3q jb0pKQRFjWBjtT/nG3J571aMtSP3SdnTCj1NqaBpQvz1k7P34qP72azlZV27U0XMdvSV AeoTml7jWwWJkeo0vnCsXrk4o76bgTwlDs1dhHxrRjm3LHa40QdBrFAAkej+8miRN9rt IwNJ5R/g3tXXmzYOL/821F7Y58hixRIplknz2jMD9iakCH4dvd0nT7kpdhIKeet3t2Ci 6A2h2z+5rh/9sc3or4cZ49iQIph5WgGXBemNn97qKCfAuH8iMU9qvV91kU4KDD6Ldena O2vQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=o6n73qW0ydBRSB1J+ZYz20Ufnelrw0ubO1rh+yoO1Cs=; fh=lnLpXpuHHACtmFCFYDz84qQIx2RASFfAeprBY3P3HzE=; b=hj6rN7VyZuIxXefJfpD4K3rEPxLtbUbDiGWovadPRSjbHUp7T+I9rAgt9WdyYE+R8M AETR/GArKw7x/fF6mSMZCnTU2k+nmI/C49KMEvrGe0uVPxjvJeg8+BeE7hIefh7rg4X0 f+yuNykyLFldkuJpTuQfLr9zPN8N8r/bw9mSFRdvG133HcjQeVzBE3KHRwHpx/ne0ah2 +cv4BhZ6WAeVReY8P8W5kqQGRWHl1JIIfKcqQLuTNI4h3vW8RBgwRYVDyY9NkEovvu4e IP7prx3f9w5CXVPhNlmmP5W9JY759zgE8iGDIW/LOMAgm59o8bOLd1j2tQ0vWsyDs53Y 3yNA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=G5CZUp5J; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id o1-20020ac84281000000b0042e646b6d41si10770343qtl.509.2024.03.05.03.08.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Mar 2024 03:08:24 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=G5CZUp5J; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhSdy-0001iY-6k; Tue, 05 Mar 2024 06:07:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhSds-00014l-7m for qemu-devel@nongnu.org; Tue, 05 Mar 2024 06:07:28 -0500 Received: from mail-ej1-x62c.google.com ([2a00:1450:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhSdp-0002yE-8h for qemu-devel@nongnu.org; Tue, 05 Mar 2024 06:07:27 -0500 Received: by mail-ej1-x62c.google.com with SMTP id a640c23a62f3a-a458eb7db13so121856566b.2 for ; Tue, 05 Mar 2024 03:07:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709636843; x=1710241643; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=o6n73qW0ydBRSB1J+ZYz20Ufnelrw0ubO1rh+yoO1Cs=; b=G5CZUp5J6nmQqFFIniPu2h8MCQXloNt2FG34aqq+VZP2dh3ofeCfS/SyEM40I/3Wen J1lC2KkuX5x3anyHQ6DJ6HwWK0MJLa7Fdww34jpKltVDC+zSWWERJdC8TeTSSIylhoYQ w6jn3i7lDmi07OiXEVvxBl5V3YGU/Jtz6cC1Zw7HDPfY7eU8JGoQO8gymp+aO1xDZTSR CtAdTJzohV/84EQ5CWrTNMMKwXja9fmZLWvzZExA1vr7koOqpRsAo0awIbZvk7ZrH46o tqzJXsG6rg3p7mxn3kkv65NPcpM8S22R8khNgEZPRdhZfFRYs2vdQ2pQvXJzgqJb85yL VZlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709636843; x=1710241643; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=o6n73qW0ydBRSB1J+ZYz20Ufnelrw0ubO1rh+yoO1Cs=; b=agNGzkmy6a3Bd/31Dv56KAfFnrRSIL384Dwvv4McCHkXrPS/5g7KJL9p0vZAjvw2Zf hVxVhwx1kbTQwJ/JdTw1dvzNFTeanMOFMyqV/a1L7FJ8A1T6cjBac4ZUduIV9pcmLU6+ NOEFJTBKvPnUttbShQtOeb6i5NTTufYBvQrXZuxKLW6UTFXtk/+BhzuOce36giUo50pO nB+fcr+Fd5eWWShPKeVbkqYaGdIQNBs+LcAZWWQG2LBzOMPqC6tBSj5rimdy32ZgtZ8w zQfJWSviGt/gTF7BWQifhPHbVlNLcqX//syCNkzThJednAChNmyz3+atoho3hCK9T7LA dN6g== X-Gm-Message-State: AOJu0YyptAp/XWfQlG+KQXuTOVnCWpKzW9EgtxNMgxZ5ejisFh2nY3Zp 9XXJSJlNpK1SlZPfR2OIhazfNiCSlXuztzT9gUyZUJh8lncdOCvkKvWk0ZX9McEQB9w4v1Db7F3 V X-Received: by 2002:a17:906:bc54:b0:a43:f182:66c4 with SMTP id s20-20020a170906bc5400b00a43f18266c4mr8561650ejv.17.1709636843351; Tue, 05 Mar 2024 03:07:23 -0800 (PST) Received: from m1x-phil.lan ([176.176.177.70]) by smtp.gmail.com with ESMTPSA id lm7-20020a170906980700b00a449fdfe27bsm4588465ejb.170.2024.03.05.03.07.21 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 05 Mar 2024 03:07:22 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Akihiko Odaki , Rene Engel , Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Subject: [PULL 12/12] ui/cocoa: Remove stretch_video flag Date: Tue, 5 Mar 2024 12:06:07 +0100 Message-ID: <20240305110608.21618-13-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240305110608.21618-1-philmd@linaro.org> References: <20240305110608.21618-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62c; envelope-from=philmd@linaro.org; helo=mail-ej1-x62c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Akihiko Odaki Evaluate [normalWindow styleMask] & NSWindowStyleMaskResizable instead. Signed-off-by: Akihiko Odaki Tested-by: Rene Engel Reviewed-by: Peter Maydell Message-ID: <20240224-cocoa-v12-10-e89f70bdda71@daynix.com> Signed-off-by: Philippe Mathieu-Daudé --- ui/cocoa.m | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index bc63043158..fa879d7dcd 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -106,7 +106,6 @@ static void cocoa_switch(DisplayChangeListener *dcl, static int left_command_key_enabled = 1; static bool swap_opt_cmd; -static bool stretch_video; static CGInterpolationQuality zoom_interpolation = kCGInterpolationNone; static NSTextField *pauseLabel; @@ -522,7 +521,7 @@ - (void) resizeWindow { [[self window] setContentAspectRatio:NSMakeSize(screen.width, screen.height)]; - if (!stretch_video) { + if (!([[self window] styleMask] & NSWindowStyleMaskResizable)) { [[self window] setContentSize:NSMakeSize(screen.width, screen.height)]; [[self window] center]; } else if ([[self window] styleMask] & NSWindowStyleMaskFullScreen) { @@ -1354,15 +1353,10 @@ - (void)showQEMUDoc:(id)sender /* Stretches video to fit host monitor size */ - (void)zoomToFit:(id) sender { - stretch_video = !stretch_video; - if (stretch_video == true) { - [cocoaView window].styleMask |= NSWindowStyleMaskResizable; - [sender setState: NSControlStateValueOn]; - } else { - [cocoaView window].styleMask &= ~NSWindowStyleMaskResizable; - [cocoaView resizeWindow]; - [sender setState: NSControlStateValueOff]; - } + NSWindowStyleMask styleMask = [[cocoaView window] styleMask] ^ NSWindowStyleMaskResizable; + + [[cocoaView window] setStyleMask:styleMask]; + [sender setState:styleMask & NSWindowStyleMaskResizable ? NSControlStateValueOn : NSControlStateValueOff]; } - (void)toggleZoomInterpolation:(id) sender @@ -1638,7 +1632,7 @@ static void create_initial_menus(void) menu = [[NSMenu alloc] initWithTitle:@"View"]; [menu addItem: [[[NSMenuItem alloc] initWithTitle:@"Enter Fullscreen" action:@selector(doToggleFullScreen:) keyEquivalent:@"f"] autorelease]]; // Fullscreen menuItem = [[[NSMenuItem alloc] initWithTitle:@"Zoom To Fit" action:@selector(zoomToFit:) keyEquivalent:@""] autorelease]; - [menuItem setState: stretch_video ? NSControlStateValueOn : NSControlStateValueOff]; + [menuItem setState: [[cocoaView window] styleMask] & NSWindowStyleMaskResizable ? NSControlStateValueOn : NSControlStateValueOff]; [menu addItem: menuItem]; menuItem = [[[NSMenuItem alloc] initWithTitle:@"Zoom Interpolation" action:@selector(toggleZoomInterpolation:) keyEquivalent:@""] autorelease]; [menuItem setState: zoom_interpolation == kCGInterpolationLow ? NSControlStateValueOn : NSControlStateValueOff]; @@ -2027,7 +2021,6 @@ static void cocoa_display_init(DisplayState *ds, DisplayOptions *opts) } if (opts->u.cocoa.has_zoom_to_fit && opts->u.cocoa.zoom_to_fit) { - stretch_video = true; [cocoaView window].styleMask |= NSWindowStyleMaskResizable; }