From nobody Tue Nov 26 11:43:20 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1707825697; cv=none; d=zohomail.com; s=zohoarc; b=alP6HnVxAG70dRQwomXG901i2qNUMuPPjVLHptQ4Pbed9XQjxTQWX9dSxAa8pBvzaUHzNTFqLGupfrRiheoaDugd6euYdfpBXgvvCGl/6Kldf9jO0jDyhdjMOryDDNpLNGs4jXMbLsSOVTgfBB4ArCchIIK+NocH47Wskk3Hsmc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707825697; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=56ee4etfJA850s0p6g1ufFjFmjKUeH8d+LYXSx01txk=; b=eym3oBvTXMo09ubgAKhdnujmB2cd1ZJQy3uYoataI4JJ2iLgVsyXrXBVy8CDbdzha8K1hjlnqJ/280snGSm0nglcU1fRhZTcv2w1cdnFdMp9chAsQMyzFSNGdi6R5R+ESgMl1iBKgfE/oJryJ1zQKyzmhtYnb7aASkPAMh4uKcs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1707825697662199.5009985305212; Tue, 13 Feb 2024 04:01:37 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZrTR-0002al-Lf; Tue, 13 Feb 2024 07:01: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 1rZrTQ-0002Py-0C for qemu-devel@nongnu.org; Tue, 13 Feb 2024 07:01:16 -0500 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rZrTL-0000tT-Ew for qemu-devel@nongnu.org; Tue, 13 Feb 2024 07:01:14 -0500 Received: by mail-pj1-x1030.google.com with SMTP id 98e67ed59e1d1-290d59df3f0so3049627a91.2 for ; Tue, 13 Feb 2024 04:01:11 -0800 (PST) Received: from localhost ([157.82.207.134]) by smtp.gmail.com with UTF8SMTPSA id s63-20020a17090a2f4500b00296f5a3de52sm2545778pjd.4.2024.02.13.04.01.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 13 Feb 2024 04:01:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1707825670; x=1708430470; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=56ee4etfJA850s0p6g1ufFjFmjKUeH8d+LYXSx01txk=; b=L+kRfvtAarJi+4G32c9CLc8Tjb8L3QU6K7TXZlqiLQF+s4aM4ZS0HJoUCnBSwR9Zj2 HC9Wj/jiIjCP1QrbG7sf1FrMOecDhfn3fyRlgPdJXGqgd9rQsr3eQDKKv2AxAlYJg4Ag k7EzlTwPrEWRwPeOsQ9COXnrN2hWXELvjDy8wT7j90CkwqnZk7765hs8Xv/rSKGZ0lpd wID6HdRJi7MBKfMdJ9geQrKgHsagru5NOpdcKWZcJFwiDIXZORndYy8FDb++1qVBAsGM AnXslR0BBwO45yMIzG5vlD7bTI7MeiepPFXynHKJYjZfHy5VMHUnNKmyIVVqW/tTs7rc 7FJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707825670; x=1708430470; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=56ee4etfJA850s0p6g1ufFjFmjKUeH8d+LYXSx01txk=; b=m6dnsnbi5Ppf6TkmKOPXO6co5f1X76XJ9cPvHPCd130JHYVIlSaWcufNJVGYWE7LDn RjfwbhhKXhh1bMuejxnnKQtMlPHN7TvlqeT0xUVYeQpgpeeuq7sYwl0m+Xqb3m+RMGis Ndnqx9zOzOeiiMY2gnaWUIeYiKdqaE4xzyEAvzAv2jfWp4mj/4QbRkwyA0w9oAPjV5f2 cjbKYW+3tkpDt2Xv3qZwSrHgCjShRQMfQ/q2SxVmcqKSOFuAu3UQK09rQ6QIeoVf5Vc4 Z42hII6Gc73eiKHmUlxbqvRqfbalB9zOrn2GO2CON09Kky1pBkPwRXR+2ZCIr7GNJ+77 nSAQ== X-Gm-Message-State: AOJu0YyZH3dOK9ZxhuZQexRIfnKX5aTFTn3TuL0a/+LfzhEWi0JfP2aD RyDUJOulfdEQnmFWN0HZ02shPUNVyDpvTS4C4nUsZXgfNChDETtFSmIqzsWb3sVIn//pSEoQkOM p X-Google-Smtp-Source: AGHT+IGdKogM0T7mZDbx2nlvuAGd4uhS8fQBRjk5DxLlz7yao8yXGwPBQC2zV4yJtN68lI3iX6hMQw== X-Received: by 2002:a17:90b:302:b0:296:f874:6844 with SMTP id ay2-20020a17090b030200b00296f8746844mr6610841pjb.15.1707825669127; Tue, 13 Feb 2024 04:01:09 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWlLePxs+qSy7p1miBUnFsTOAUK78tsewba4w/RJp7BYMGqKC95wvpS2EV+l/lGX3lTNhiiaLnd1gHw0/f31t+mpqeB09Vievz5H5ISH7vFNQSf91flWTsdjjnZIWInHziZMsJPV1tqBzO6YyM/oeDA8/QtJ5ZWbJHTYZDsGPVHtyh+ve7BVlWvcZe1tp1DF+T2kvvoYRb9djKbD9WOwG6JCS4AaYT5rEC99ZS3sifL4sUGKaJyUsrbEpEfQKGA8HMdSMvVqmlILPtE From: Akihiko Odaki Date: Tue, 13 Feb 2024 21:00:55 +0900 Subject: [PATCH v9 1/6] ui/cocoa: Release specific mouse buttons MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240213-cocoa-v9-1-d5a5e1bf0490@daynix.com> References: <20240213-cocoa-v9-0-d5a5e1bf0490@daynix.com> In-Reply-To: <20240213-cocoa-v9-0-d5a5e1bf0490@daynix.com> To: Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Marek Glogowski , BALATON Zoltan , Rene Engel Cc: qemu-devel@nongnu.org, Akihiko Odaki X-Mailer: b4 0.12.3 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::1030; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-x1030.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1707825699869100003 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 --- ui/cocoa.m | 132 ++++++++++++++++++++++++++-------------------------------= ---- 1 file changed, 55 insertions(+), 77 deletions(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index eb99064beeb4..fe0eb74b0743 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -99,7 +99,6 @@ static void cocoa_switch(DisplayChangeListener *dcl, static DisplayChangeListener dcl =3D { .ops =3D &dcl_ops, }; -static int last_buttons; static int cursor_hide =3D 1; static int left_command_key_enabled =3D 1; static bool swap_opt_cmd; @@ -801,8 +800,6 @@ - (bool) handleEventLocked:(NSEvent *)event COCOA_DEBUG("QemuCocoaView: handleEvent\n"); int buttons =3D 0; int keycode =3D 0; - bool mouse_event =3D false; - // Location of event in virtual screen coordinates NSPoint p =3D [self screenLocationOfEvent:event]; NSUInteger modifiers =3D [event modifierFlags]; =20 @@ -883,25 +880,25 @@ - (bool) handleEventLocked:(NSEvent *)event if (!!(modifiers & NSEventModifierFlagShift)) { [self toggleKey:Q_KEY_CODE_SHIFT]; } - break; + return true; =20 case kVK_RightShift: if (!!(modifiers & NSEventModifierFlagShift)) { [self toggleKey:Q_KEY_CODE_SHIFT_R]; } - break; + return true; =20 case kVK_Control: if (!!(modifiers & NSEventModifierFlagControl)) { [self toggleKey:Q_KEY_CODE_CTRL]; } - break; + return true; =20 case kVK_RightControl: if (!!(modifiers & NSEventModifierFlagControl)) { [self toggleKey:Q_KEY_CODE_CTRL_R]; } - break; + return true; =20 case kVK_Option: if (!!(modifiers & NSEventModifierFlagOption)) { @@ -911,7 +908,7 @@ - (bool) handleEventLocked:(NSEvent *)event [self toggleKey:Q_KEY_CODE_ALT]; } } - break; + return true; =20 case kVK_RightOption: if (!!(modifiers & NSEventModifierFlagOption)) { @@ -921,7 +918,7 @@ - (bool) handleEventLocked:(NSEvent *)event [self toggleKey:Q_KEY_CODE_ALT_R]; } } - break; + return true; =20 /* Don't pass command key changes to guest unless mouse is= grabbed */ case kVK_Command: @@ -934,7 +931,7 @@ - (bool) handleEventLocked:(NSEvent *)event [self toggleKey:Q_KEY_CODE_META_L]; } } - break; + return true; =20 case kVK_RightCommand: if (isMouseGrabbed && @@ -945,9 +942,11 @@ - (bool) handleEventLocked:(NSEvent *)event [self toggleKey:Q_KEY_CODE_META_R]; } } - break; + return true; + + default: + return true; } - break; case NSEventTypeKeyDown: keycode =3D cocoa_keycode_to_qemu([event keyCode]); =20 @@ -983,7 +982,7 @@ - (bool) handleEventLocked:(NSEvent *)event } else { [self handleMonitorInput: event]; } - break; + return true; case NSEventTypeKeyUp: keycode =3D cocoa_keycode_to_qemu([event keyCode]); =20 @@ -996,7 +995,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 b= ound to screen coordinates @@ -1012,34 +1011,18 @@ - (bool) handleEventLocked:(NSEvent *)event } } } - mouse_event =3D true; - break; + return [self handleMouseEvent:event]; case NSEventTypeLeftMouseDown: - buttons |=3D MOUSE_EVENT_LBUTTON; - mouse_event =3D true; - break; + return [self handleMouseEvent:event button:MOUSE_EVENT_LBUTTON= down:true]; case NSEventTypeRightMouseDown: - buttons |=3D MOUSE_EVENT_RBUTTON; - mouse_event =3D true; - break; - case NSEventTypeOtherMouseDown: - buttons |=3D MOUSE_EVENT_MBUTTON; - mouse_event =3D true; - break; + return [self handleMouseEvent:event button:MOUSE_EVENT_RBUTTON= down:true]; case NSEventTypeLeftMouseDragged: - buttons |=3D MOUSE_EVENT_LBUTTON; - mouse_event =3D true; - break; + return [self handleMouseEvent:event button:MOUSE_EVENT_LBUTTON= down:true]; case NSEventTypeRightMouseDragged: - buttons |=3D MOUSE_EVENT_RBUTTON; - mouse_event =3D true; - break; + return [self handleMouseEvent:event button:MOUSE_EVENT_RBUTTON= down:true]; case NSEventTypeOtherMouseDragged: - buttons |=3D MOUSE_EVENT_MBUTTON; - mouse_event =3D true; - break; + return [self handleMouseEvent:event button:MOUSE_EVENT_MBUTTON= down:true]; case NSEventTypeLeftMouseUp: - mouse_event =3D true; if (!isMouseGrabbed && [self screenContainsPoint:p]) { /* * In fullscreen mode, the window of cocoaView may not be = the @@ -1050,13 +1033,11 @@ - (bool) handleEventLocked:(NSEvent *)event [self grabMouse]; } } - break; + return [self handleMouseEvent:event button:MOUSE_EVENT_LBUTTON= down:false]; case NSEventTypeRightMouseUp: - mouse_event =3D true; - break; + return [self handleMouseEvent:event button:MOUSE_EVENT_RBUTTON= down:false]; case NSEventTypeOtherMouseUp: - mouse_event =3D true; - break; + return [self handleMouseEvent:event button:MOUSE_EVENT_MBUTTON= down:false]; case NSEventTypeScrollWheel: /* * Send wheel events to the guest regardless of window focus. @@ -1087,52 +1068,49 @@ - (bool) handleEventLocked:(NSEvent *)event * Since deltaX/deltaY also report scroll wheel events we prev= ent mouse * movement code from executing. */ - mouse_event =3D false; - break; + return true; default: return false; } +} + +- (bool) handleMouseEvent:(NSEvent *)event +{ + if (!isMouseGrabbed) { + return false; + } =20 - 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 (isAbsoluteEnabled) { + NSPoint p =3D [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 ran= ge values for + * clicks in the titlebar. */ - if ((isMouseGrabbed || [[self window] isKeyWindow]) && - (last_buttons !=3D buttons)) { - static uint32_t bmap[INPUT_BUTTON__MAX] =3D { - [INPUT_BUTTON_LEFT] =3D MOUSE_EVENT_LBUTTON, - [INPUT_BUTTON_MIDDLE] =3D MOUSE_EVENT_MBUTTON, - [INPUT_BUTTON_RIGHT] =3D MOUSE_EVENT_RBUTTON - }; - qemu_input_update_buttons(dcl.con, bmap, last_buttons, buttons= ); - last_buttons =3D buttons; - } - if (isMouseGrabbed) { - if (isAbsoluteEnabled) { - /* Note that the origin for Cocoa mouse coords is bottom l= eft, not top left. - * The check on screenContainsPoint is to avoid sending ou= t of range values for - * clicks in the titlebar. - */ - if ([self screenContainsPoint:p]) { - qemu_input_queue_abs(dcl.con, INPUT_AXIS_X, p.x, 0, sc= reen.width); - qemu_input_queue_abs(dcl.con, INPUT_AXIS_Y, screen.hei= ght - p.y, 0, screen.height); - } - } else { - qemu_input_queue_rel(dcl.con, INPUT_AXIS_X, (int)[event de= ltaX]); - qemu_input_queue_rel(dcl.con, INPUT_AXIS_Y, (int)[event de= ltaY]); - } - } else { - return false; + if ([self screenContainsPoint:p]) { + qemu_input_queue_abs(dcl.con, INPUT_AXIS_X, p.x, 0, screen.wid= th); + qemu_input_queue_abs(dcl.con, INPUT_AXIS_Y, screen.height - p.= y, 0, screen.height); } - qemu_input_event_sync(); + } 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; } =20 +- (bool) handleMouseEvent:(NSEvent *)event button:(InputButton)button down= :(bool)down +{ + if (!isMouseGrabbed && ![[self window] isKeyWindow]) { + return false; + } + + qemu_input_queue_btn(dcl.con, button, down); + + return [self handleMouseEvent:event]; +} + - (void) grabMouse { COCOA_DEBUG("QemuCocoaView: grabMouse\n"); --=20 2.43.0 From nobody Tue Nov 26 11:43:20 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1707825692; cv=none; d=zohomail.com; s=zohoarc; b=d+0HmQXbp81dSBh9xf5aumtAKvoGmiTndgDpJ7ceKLbe+LTrlunTOu3dYyGrtlTD0m7g4KHwPrmxaV8JIeyLnxdjtAQTK297jobOj5o13k2fsEuqkhzx9AZXkoEAooA1kzfERuBs7J6lcJGY2U1B4nHxv9UAVCBnvtS0xYmK50c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707825692; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=LY24CVC1YBoU/Hz2w0W3aUzItIgVLNe8my76vH7E4TA=; b=YP3Dh5Ld2aL9PG8iC/HbW7bYRrI90NMxs4r4j0qaly5HPjOewLoGiEI/vd5X2BsBcourI6e+XGsQoqpg9Y/5UZ1QPZL1modBIm7BJtvTRoKCEH/prlLvWgBPs8KUnUBfKXYKcW0bnTa6PshSiYtgXZbUs/OCh2VtbfGjcU4HTis= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1707825691701929.340911499967; Tue, 13 Feb 2024 04:01:31 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZrTT-0002ht-NF; Tue, 13 Feb 2024 07:01:19 -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 1rZrTR-0002ad-IX for qemu-devel@nongnu.org; Tue, 13 Feb 2024 07:01:17 -0500 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rZrTP-0000uN-Uc for qemu-devel@nongnu.org; Tue, 13 Feb 2024 07:01:17 -0500 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1d7881b1843so38445715ad.3 for ; Tue, 13 Feb 2024 04:01:15 -0800 (PST) Received: from localhost ([157.82.207.134]) by smtp.gmail.com with UTF8SMTPSA id li15-20020a170903294f00b001d94678a76csm1963784plb.117.2024.02.13.04.01.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 13 Feb 2024 04:01:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1707825674; x=1708430474; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=LY24CVC1YBoU/Hz2w0W3aUzItIgVLNe8my76vH7E4TA=; b=S9KmQXpcmIBEeY+EII/fhc1xjEklxUTD3bEPyzVBLOBpNivIIaAgYUbry8zSECt/Z8 AfppmJ75h1mBjIQwk4RnRqKX5acIM8DJN0mvrbWCxNT816O7AWzRNvM5WYNRn642O2bx Bw2lpJDrrQsfcVEQ+Ok2aDWoBpy+qCJoGh3Tc+MgVvrHayYYiUi7mtL0dBwKIDNjLUpK OXGK5/LW2hBoc1qziq5e/Sxdgo7ZaX7ou1PNaZFvB3N2JprqF8WZ4Sjc2Er2/61cTc6o Eiw72CC6YQ/D/q8Z5U8LXNDRZRLWxkXPJm4LoXSCN0t1vuOevt22QzLYdq+jknp9gIGb bE6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707825674; x=1708430474; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LY24CVC1YBoU/Hz2w0W3aUzItIgVLNe8my76vH7E4TA=; b=pBLVGllBtQJh1AU2c5ZcIy99ISJw1Pry2q4j9A09BilUXa2FDSl+lAMM7cpX700tih ubzoNnHgpiRINyVwsLWlGYQZ+NhwvSH6kgWWJrJ6yfaZ3NbpjrDtotWCmYvzlOmEJiky 8entFAyI9r1+hCB+t7lWPCQZHr8pht2Y71Nx9u36ON/7lLsC6nQbc3Y83fm2Zavl+f4/ kKnY5zG/J9/ZRQTMZBqwzIHiWUzy6g/J3VCPOqzVmzdLu9O5AQbKoWtaHWdkYYCpmlzf x3OvufOpIm5+6usb0Nk3hhxk2SvqUrcLvchWrB9h3SqghzY1uMLrSJPXwT0o+sIPxUVc 4Jyw== X-Gm-Message-State: AOJu0YxX4/yGoS/I5TXi/4ZNTk0mLsN/EThu4of3vKap0A6z6gvGpCOj VdySmXwFXnk+XpQHLg6+4mtxG4/alk4/R6I77QPOUOrCF8Edtpwipm75b3g1iZP13jD2cyzs5T+ o X-Google-Smtp-Source: AGHT+IFEPEgeUbLtBoYh+ZGl7O2zr+BI/9Rwjd81YpcoHv8+gSJsZ6/tS/OhtCsTyJHC8Y+rdgk6wg== X-Received: by 2002:a17:902:680e:b0:1db:3d36:507b with SMTP id h14-20020a170902680e00b001db3d36507bmr931771plk.44.1707825674241; Tue, 13 Feb 2024 04:01:14 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWMLEE+IW2DNt92xe60UZtqFhCGVy/DFF5MEMPlcTMZrMhKfDBMRZMvCjBwYQREbQHaU2zaMhgCy3T/ReuLg+0xZefSwg+MgTHiVtjC+9fXeE/nxO+iwxvFzTxoMt1BrV6lUFXX6bvkPB3cilqOeEB9CMbr2r1Piha+gGk16Zec4CMusMjHJxVlwIthspYDt9AJTiLknIqn2BCgNXPrrkLgUhL7NYLqEDubgcbziIyNucs2IMW/hKGUnPWTKhc06mgogzzuwmg5T7tn From: Akihiko Odaki Date: Tue, 13 Feb 2024 21:00:56 +0900 Subject: [PATCH v9 2/6] ui/cocoa: Scale with NSView instead of Core Graphics MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240213-cocoa-v9-2-d5a5e1bf0490@daynix.com> References: <20240213-cocoa-v9-0-d5a5e1bf0490@daynix.com> In-Reply-To: <20240213-cocoa-v9-0-d5a5e1bf0490@daynix.com> To: Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Marek Glogowski , BALATON Zoltan , Rene Engel Cc: qemu-devel@nongnu.org, Akihiko Odaki X-Mailer: b4 0.12.3 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::630; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x630.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1707825694129100003 Core Graphics is not accelerated and slow. Signed-off-by: Akihiko Odaki --- ui/cocoa.m | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index fe0eb74b0743..cb6090905999 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -496,10 +496,8 @@ - (void) drawRect:(NSRect) rect =20 [self getRectsBeingDrawn:&rectList count:&rectCount]; for (i =3D 0; i < rectCount; i++) { - clipRect.origin.x =3D rectList[i].origin.x / cdx; - clipRect.origin.y =3D (float)h - (rectList[i].origin.y + rectL= ist[i].size.height) / cdy; - clipRect.size.width =3D rectList[i].size.width / cdx; - clipRect.size.height =3D rectList[i].size.height / cdy; + clipRect =3D rectList[i]; + clipRect.origin.y =3D (float)h - (clipRect.origin.y + clipRect= .size.height); clipImageRef =3D CGImageCreateWithImageInRect( imageRef, clipRect @@ -545,6 +543,11 @@ - (void) setContentDimensions } } =20 +- (void) updateBounds +{ + [self setBoundsSize:NSMakeSize(screen.width, screen.height)]; +} + - (void) updateUIInfoLocked { /* Must be called with the BQL, i.e. via updateUIInfo */ @@ -1292,6 +1295,7 @@ - (void)windowDidChangeScreen:(NSNotification *)notif= ication =20 - (void)windowDidResize:(NSNotification *)notification { + [cocoaView updateBounds]; [cocoaView updateUIInfo]; } =20 @@ -1940,16 +1944,7 @@ static void cocoa_update(DisplayChangeListener *dcl, COCOA_DEBUG("qemu_cocoa: cocoa_update\n"); =20 dispatch_async(dispatch_get_main_queue(), ^{ - NSRect rect; - if ([cocoaView cdx] =3D=3D 1.0) { - rect =3D NSMakeRect(x, [cocoaView gscreen].height - y - h, w, = h); - } else { - rect =3D NSMakeRect( - x * [cocoaView cdx], - ([cocoaView gscreen].height - y - h) * [cocoaView cdy], - w * [cocoaView cdx], - h * [cocoaView cdy]); - } + NSRect rect =3D NSMakeRect(x, [cocoaView gscreen].height - y - h, = w, h); [cocoaView setNeedsDisplayInRect:rect]; }); } --=20 2.43.0 From nobody Tue Nov 26 11:43:20 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1707825701; cv=none; d=zohomail.com; s=zohoarc; b=Y8c+BTpP3c3FlQmrkTbh00wHX+O4rOgbK5VkzPFCTQgiw5LJ+Ua5RPPqaDeoFxqcP3UHulVdg6SutOih8+RTGyVyJJPvcHy0zlHhwn6vwsuH7REJCDmdqnQ4uBLsoYpKssDJW++O9x+kUUtZvkrlmf+aDutGuj2SpBvKg1OW5TA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707825701; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=7/0D6jbYf/v47+/nozhjqPNn5hxrsBuqLo9IKVJ3/78=; b=Zn41qXRNipNGdPlRuE3wIiEEx2waPBRYDfWDglZlvdwo/1dtLYkJuHAucq9+rItok/KQbtrGIBdNjdKpDSubKov9l9j9HwGsl/fSMcdwJLtD1KpZyr+epF5ZSgQDsWqUy1djiQ7WeaDneFUKPOAZESzaKi5J3r7PpcYKIz7LmRk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1707825701908260.37049960259253; Tue, 13 Feb 2024 04:01:41 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZrTd-0003HH-Gk; Tue, 13 Feb 2024 07:01:29 -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 1rZrTa-0002vC-Lx for qemu-devel@nongnu.org; Tue, 13 Feb 2024 07:01:26 -0500 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rZrTX-0000ur-IG for qemu-devel@nongnu.org; Tue, 13 Feb 2024 07:01:26 -0500 Received: by mail-pj1-x102c.google.com with SMTP id 98e67ed59e1d1-296cca9169bso2479014a91.3 for ; Tue, 13 Feb 2024 04:01:23 -0800 (PST) Received: from localhost ([157.82.207.134]) by smtp.gmail.com with UTF8SMTPSA id bg7-20020a17090b0d8700b00297317e5e04sm2316446pjb.52.2024.02.13.04.01.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 13 Feb 2024 04:01:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1707825682; x=1708430482; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=7/0D6jbYf/v47+/nozhjqPNn5hxrsBuqLo9IKVJ3/78=; b=q3YXGeeepJVDcR9d0Ov982kCFkI1pftd8T4JtmrYcac6NRXfaFoBR2sDx2Zxsh/yKx ZCwGS5nVbqly/+Dn2JaqF6hjf+/vWOvgY5tosEWO1wMnAlszuFs1o/ytUg3pIjK7/HJq 1ftP+Gwg/7Rfd7Hu4dxNYr4zOL2de6O6Pzqv8TZ4oXVpRkX0EIAwjApaynkjOJ9GQDwo 0LxKHAUXZw9Kl5i1CfdzEMp1s8BTRYy0Z5sVcrTUjydZC7sHWzxQ1XZLV9qc3m+xCAVP u98W/UvIacPH4Ua7puaVEysSvkDAmGQURcpERwXwtEKVCcfn/UhFrUVHxACI0mFNnkW6 6ayA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707825682; x=1708430482; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7/0D6jbYf/v47+/nozhjqPNn5hxrsBuqLo9IKVJ3/78=; b=EkrxPx/KBarEFGGiZq+BCzZgJkXXB2MtbDB8dYmaaDS0xqI9s2VvZ68JuxTq2uy2K/ zSMZciposT/katxblfT/LVhfr2nvv/ZYL3dLBIcVjIsFokkXJrk2a1gYYdqQEjmX47cy qW6QA9DSkpo68HR45flouCa1y6aVdDdyh4px6dJafP0tmztGZZXRdC8swjuJBUI4alK+ DorXWlzL9A7jTABKtIS1BkrZAZupsSp651YX9JP9F+OXAdujb961VbSOlYsa0wLo8mTy AOdCEI1NjGZFAAURKAoDd7yfcumWWn1sLIs0llPC+A5htswBCsg1g/3FCioi8gYRIFQ3 jT3A== X-Gm-Message-State: AOJu0YwJJ18dl0cb8zvfIcgDpjIvMznaqPr6JE0XxpQQGZY6zQAKZtWh iKTmOZtqWWj+C5nNr0V2n3LTODyzGjZnz8N2HvMDhreYI96jXAGMLg+vrmAiL9FCIwwtzBc15hU E X-Google-Smtp-Source: AGHT+IFKR6dbnmbjwpOGBUH/za88+AtZZGwRB4rhXyHRuaYs0h1oSKLxlRIILBqm0jE44xfIobsvUQ== X-Received: by 2002:a17:90b:19cf:b0:296:5b68:45b8 with SMTP id nm15-20020a17090b19cf00b002965b6845b8mr5166084pjb.24.1707825681813; Tue, 13 Feb 2024 04:01:21 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWS9iGznWvaVfR7/Ditnek9coawSATS81kfhayZkF5xKd/O6BT5feMTbVez5+OzcKObZX6eLzh0o3i6xoivfX1QomLindaPt9OpfdZCzKhWnJZxxJFqFBqCUA2gg3oF35NLVmwn3MP0FCr5lPRnOp01ehvOVegmrypPX93+VdIQNxQZtYM0pngTUOS9wkK0lWVXvCPKHnf8F1kcFvh0MPzzZYpMQJvJxNCbcc+2apH0whp7rAAk4MhPK7jF6syZgaZsLJnToZpm/XR1 From: Akihiko Odaki Date: Tue, 13 Feb 2024 21:00:57 +0900 Subject: [PATCH v9 3/6] ui/cocoa: Let the platform toggle fullscreen MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240213-cocoa-v9-3-d5a5e1bf0490@daynix.com> References: <20240213-cocoa-v9-0-d5a5e1bf0490@daynix.com> In-Reply-To: <20240213-cocoa-v9-0-d5a5e1bf0490@daynix.com> To: Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Marek Glogowski , BALATON Zoltan , Rene Engel Cc: qemu-devel@nongnu.org, Akihiko Odaki X-Mailer: b4 0.12.3 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::102c; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-x102c.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_OTHER_BAD_TLD=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1707825703840100003 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 --- ui/cocoa.m | 424 ++++++++++++++++++++++++++++++---------------------------= ---- 1 file changed, 208 insertions(+), 216 deletions(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index cb6090905999..5d21ce143671 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -303,20 +303,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; @@ -332,8 +329,6 @@ - (void) setAbsoluteEnabled:(BOOL)tIsAbsoluteEnabled; */ - (BOOL) isMouseGrabbed; - (BOOL) isAbsoluteEnabled; -- (float) cdx; -- (float) cdy; - (QEMUScreen) gscreen; - (void) raiseAllKeys; @end @@ -391,46 +386,43 @@ - (BOOL) isOpaque return YES; } =20 -- (BOOL) screenContainsPoint:(NSPoint) p +- (void) removeTrackingRect { - return (p.x > -1 && p.x < screen.width && p.y > -1 && p.y < screen.hei= ght); + if (trackingArea) { + [self removeTrackingArea:trackingArea]; + [trackingArea release]; + trackingArea =3D nil; + } } =20 -/* Get location of event and convert to virtual screen coordinate */ -- (CGPoint) screenLocationOfEvent:(NSEvent *)ev +- (void) frameUpdated { - NSWindow *eventWindow =3D [ev window]; - // XXX: Use CGRect and -convertRectFromScreen: to support macOS 10.10 - CGRect r =3D CGRectZero; - r.origin =3D [ev locationInWindow]; - if (!eventWindow) { - if (!isFullscreen) { - return [[self window] convertRectFromScreen:r].origin; - } else { - CGPoint locationInSelfWindow =3D [[self window] convertRectFro= mScreen:r].origin; - CGPoint loc =3D [self convertPoint:locationInSelfWindow fromVi= ew:nil]; - if (stretch_video) { - loc.x /=3D cdx; - loc.y /=3D cdy; - } - return loc; - } - } else if ([[self window] isEqual:eventWindow]) { - if (!isFullscreen) { - return r.origin; - } else { - CGPoint loc =3D [self convertPoint:r.origin fromView:nil]; - if (stretch_video) { - loc.x /=3D cdx; - loc.y /=3D cdy; - } - return loc; - } - } else { - return [[self window] convertRectFromScreen:[eventWindow convertRe= ctToScreen:r]].origin; + [self removeTrackingRect]; + + if ([self window]) { + NSTrackingAreaOptions options =3D NSTrackingActiveInKeyWindow | + NSTrackingMouseEnteredAndExited | + NSTrackingMouseMoved; + trackingArea =3D [[NSTrackingArea alloc] initWithRect:[self frame] + options:options + owner:self + userInfo:nil]; + [self addTrackingArea:trackingArea]; + [self updateUIInfo]; } } =20 +- (void) viewDidMoveToWindow +{ + [self resizeWindow]; + [self frameUpdated]; +} + +- (void) viewWillMoveToWindow:(NSWindow *)newWindow +{ + [self removeTrackingRect]; +} + - (void) hideCursor { if (!cursor_hide) { @@ -510,36 +502,43 @@ - (void) drawRect:(NSRect) rect } } =20 -- (void) setContentDimensions +- (NSSize) fixZoomedFullScreenSize:(NSSize)proposedSize { - COCOA_DEBUG("QemuCocoaView: setContentDimensions\n"); + NSSize size; =20 - if (isFullscreen) { - cdx =3D [[NSScreen mainScreen] frame].size.width / (float)screen.w= idth; - cdy =3D [[NSScreen mainScreen] frame].size.height / (float)screen.= height; + size.width =3D (CGFloat)screen.width * proposedSize.height; + size.height =3D (CGFloat)screen.height * proposedSize.width; =20 - /* stretches video, but keeps same aspect ratio */ - if (stretch_video =3D=3D true) { - /* use smallest stretch value - prevents clipping on sides */ - if (MIN(cdx, cdy) =3D=3D cdx) { - cdy =3D cdx; - } else { - cdx =3D cdy; - } - } else { /* No stretching */ - cdx =3D cdy =3D 1; - } - cw =3D screen.width * cdx; - ch =3D screen.height * cdy; - cx =3D ([[NSScreen mainScreen] frame].size.width - cw) / 2.0; - cy =3D ([[NSScreen mainScreen] frame].size.height - ch) / 2.0; + if (size.width < size.height) { + size.width /=3D screen.height; + size.height =3D proposedSize.height; } else { - cx =3D 0; - cy =3D 0; - cw =3D screen.width; - ch =3D screen.height; - cdx =3D 1.0; - cdy =3D 1.0; + size.width =3D proposedSize.width; + size.height /=3D screen.width; + } + + return size; +} + +- (NSSize) screenSafeAreaSize +{ + NSSize size =3D [[[self window] screen] frame].size; + NSEdgeInsets insets =3D [[[self window] screen] safeAreaInsets]; + size.width -=3D insets.left + insets.right; + size.height -=3D insets.top + insets.bottom; + return size; +} + +- (void) resizeWindow +{ + [[self window] setContentAspectRatio:NSMakeSize(screen.width, screen.h= eight)]; + + if (!stretch_video) { + [[self window] setContentSize:NSMakeSize(screen.width, screen.heig= ht)]; + [[self window] center]; + } else if ([[self window] styleMask] & NSWindowStyleMaskFullScreen) { + [[self window] setContentSize:[self fixZoomedFullScreenSize:[self = screenSafeAreaSize]]]; + [[self window] center]; } } =20 @@ -563,9 +562,10 @@ - (void) updateUIInfoLocked CGDirectDisplayID display =3D [[description objectForKey:@"NSScree= nNumber"] unsignedIntValue]; NSSize screenSize =3D [[[self window] screen] frame].size; CGSize screenPhysicalSize =3D CGDisplayScreenSize(display); + bool isFullscreen =3D ([[self window] styleMask] & NSWindowStyleMa= skFullScreen) !=3D 0; CVDisplayLinkRef displayLink; =20 - frameSize =3D isFullscreen ? screenSize : [self frame].size; + frameSize =3D isFullscreen ? [self screenSafeAreaSize] : [self fra= me].size; =20 if (!CVDisplayLinkCreateWithCGDisplay(display, &displayLink)) { CVTime period =3D CVDisplayLinkGetNominalOutputVideoRefreshPer= iod(displayLink); @@ -612,31 +612,19 @@ - (void) updateUIInfo }); } =20 -- (void)viewDidMoveToWindow -{ - [self updateUIInfo]; -} - - (void) switchSurface:(pixman_image_t *)image { COCOA_DEBUG("QemuCocoaView: switchSurface\n"); =20 int w =3D pixman_image_get_width(image); int h =3D pixman_image_get_height(image); - /* cdx =3D=3D 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 =3D (w !=3D screen.width || h !=3D screen.height || cdx = =3D=3D 0.0); =20 - int oldh =3D screen.height; - if (isResize) { + if (w !=3D screen.width || h !=3D screen.height) { // Resize before we trigger the redraw, or we'll redraw at the wro= ng size COCOA_DEBUG("switchSurface: new size %d x %d\n", w, h); screen.width =3D w; screen.height =3D h; - [self setContentDimensions]; - [self setFrame:NSMakeRect(cx, cy, cw, ch)]; + [self resizeWindow]; } =20 // update screenBuffer @@ -645,51 +633,6 @@ - (void) switchSurface:(pixman_image_t *)image } =20 pixman_image =3D image; - - // update windows - if (isFullscreen) { - [[fullScreenWindow contentView] setFrame:[[NSScreen mainScreen] fr= ame]]; - [normalWindow setFrame:NSMakeRect([normalWindow frame].origin.x, [= normalWindow frame].origin.y - h + oldh, w, h + [normalWindow frame].size.h= eight - 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.h= eight - 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 =3D FALSE; - [self ungrabMouse]; - [self setContentDimensions]; - [fullScreenWindow close]; - [normalWindow setContentView: self]; - [normalWindow makeKeyAndOrderFront: self]; - [NSMenu setMenuBarVisible:YES]; - } else { // switch from desktop to fullscreen - isFullscreen =3D TRUE; - [normalWindow orderOut: nil]; /* Hide the window */ - [self grabMouse]; - [self setContentDimensions]; - [NSMenu setMenuBarVisible:NO]; - fullScreenWindow =3D [[NSWindow alloc] initWithContentRect:[[NSScr= een 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]; - } } =20 - (void) setFullGrab:(id)sender @@ -803,7 +746,6 @@ - (bool) handleEventLocked:(NSEvent *)event COCOA_DEBUG("QemuCocoaView: handleEvent\n"); int buttons =3D 0; int keycode =3D 0; - NSPoint p =3D [self screenLocationOfEvent:event]; NSUInteger modifiers =3D [event modifierFlags]; =20 /* @@ -999,48 +941,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 b= ound to screen coordinates - // and `nil` window property, and in full screen mode, cur= rent window might not be - // key window, where event location alone should suffice. - if (![self screenContainsPoint:p] || !([[self window] isKe= yWindow] || isFullscreen)) { - if (isMouseGrabbed) { - [self ungrabMouse]; - } - } else { - if (!isMouseGrabbed) { - [self grabMouse]; - } - } - } - return [self handleMouseEvent:event]; - case NSEventTypeLeftMouseDown: - return [self handleMouseEvent:event button:MOUSE_EVENT_LBUTTON= down:true]; - case NSEventTypeRightMouseDown: - return [self handleMouseEvent:event button:MOUSE_EVENT_RBUTTON= down:true]; - case NSEventTypeLeftMouseDragged: - return [self handleMouseEvent:event button:MOUSE_EVENT_LBUTTON= down:true]; - case NSEventTypeRightMouseDragged: - return [self handleMouseEvent:event button:MOUSE_EVENT_RBUTTON= down:true]; - case NSEventTypeOtherMouseDragged: - return [self handleMouseEvent:event button:MOUSE_EVENT_MBUTTON= 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 virt= ual - * screen alone will be sufficient. - */ - if(isFullscreen || [[self window] isKeyWindow]) { - [self grabMouse]; - } - } - return [self handleMouseEvent:event button:MOUSE_EVENT_LBUTTON= down:false]; - case NSEventTypeRightMouseUp: - return [self handleMouseEvent:event button:MOUSE_EVENT_RBUTTON= down:false]; - case NSEventTypeOtherMouseUp: - return [self handleMouseEvent:event button:MOUSE_EVENT_MBUTTON= down:false]; case NSEventTypeScrollWheel: /* * Send wheel events to the guest regardless of window focus. @@ -1077,53 +977,118 @@ - (bool) handleEventLocked:(NSEvent *)event } } =20 -- (bool) handleMouseEvent:(NSEvent *)event +- (void) handleMouseEvent:(NSEvent *)event { if (!isMouseGrabbed) { - return false; + return; } =20 - if (isAbsoluteEnabled) { - NSPoint p =3D [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 ran= ge values for - * clicks in the titlebar. - */ - if ([self screenContainsPoint:p]) { - qemu_input_queue_abs(dcl.con, INPUT_AXIS_X, p.x, 0, screen.wid= th); - qemu_input_queue_abs(dcl.con, INPUT_AXIS_Y, screen.height - p.= y, 0, screen.height); + with_bql(^{ + if (isAbsoluteEnabled) { + CGFloat d =3D (CGFloat)screen.height / [self frame].size.heigh= t; + NSPoint p =3D [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 { + CGFloat d =3D (CGFloat)screen.height / [self convertSizeToBack= ing:[self frame].size].height; + qemu_input_queue_rel(dcl.con, INPUT_AXIS_X, [event deltaX] * d= ); + qemu_input_queue_rel(dcl.con, INPUT_AXIS_Y, [event deltaY] * d= ); } - } 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) handleMouseEvent:(NSEvent *)event button:(InputButton)button down= :(bool)down +{ + if (!isMouseGrabbed) { + return; } =20 - qemu_input_event_sync(); + with_bql(^{ + qemu_input_queue_btn(dcl.con, button, down); + }); =20 - return true; + [self handleMouseEvent:event]; } =20 -- (bool) handleMouseEvent:(NSEvent *)event button:(InputButton)button down= :(bool)down +- (void) mouseExited:(NSEvent *)event { - if (!isMouseGrabbed && ![[self window] isKeyWindow]) { - return false; + if (isAbsoluteEnabled && isMouseGrabbed) { + [self ungrabMouse]; } +} =20 - qemu_input_queue_btn(dcl.con, button, down); +- (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]; + } + + [self handleMouseEvent:event button:INPUT_BUTTON_LEFT down:false]; +} + +- (void) rightMouseUp:(NSEvent *)event +{ + [self handleMouseEvent:event button:INPUT_BUTTON_RIGHT down:false]; +} =20 - return [self handleMouseEvent:event]; +- (void) otherMouseUp:(NSEvent *)event +{ + [self handleMouseEvent:event button:INPUT_BUTTON_MIDDLE down:false]; } =20 - (void) grabMouse { COCOA_DEBUG("QemuCocoaView: grabMouse\n"); =20 - 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_A= LT_KEY " G to release Mouse)"]; - } + if (qemu_name) + [normalWindow setTitle:[NSString stringWithFormat:@"QEMU %s - (Pre= ss " UC_CTRL_KEY " " UC_ALT_KEY " G to release Mouse)", qemu_name]]; + else + [normalWindow setTitle:@"QEMU - (Press " UC_CTRL_KEY " " UC_ALT_K= EY " G to release Mouse)"]; [self hideCursor]; CGAssociateMouseAndMouseCursorPosition(isAbsoluteEnabled); isMouseGrabbed =3D TRUE; // while isMouseGrabbed =3D TRUE, QemuCocoaAp= p sends all events to [cocoaView handleEvent:] @@ -1133,15 +1098,14 @@ - (void) ungrabMouse { COCOA_DEBUG("QemuCocoaView: ungrabMouse\n"); =20 - 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 =3D FALSE; + [self raiseAllButtons]; } =20 - (void) setAbsoluteEnabled:(BOOL)tIsAbsoluteEnabled { @@ -1152,8 +1116,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;} =20 /* @@ -1167,6 +1129,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 =20 =20 @@ -1181,7 +1152,6 @@ @interface QemuCocoaAppController : NSObject { } - (void)doToggleFullScreen:(id)sender; -- (void)toggleFullScreen:(id)sender; - (void)showQEMUDoc:(id)sender; - (void)zoomToFit:(id) sender; - (void)displayConsole:(id)sender; @@ -1223,7 +1193,8 @@ - (id) init exit(1); } [normalWindow setAcceptsMouseMovedEvents:YES]; - [normalWindow setTitle:@"QEMU"]; + [normalWindow setCollectionBehavior:NSWindowCollectionBehaviorFull= ScreenPrimary]; + [normalWindow setTitle:qemu_name ? [NSString stringWithFormat:@"QE= MU %s", qemu_name] : @"QEMU"]; [normalWindow setContentView:cocoaView]; [normalWindow makeKeyAndOrderFront:self]; [normalWindow center]; @@ -1293,10 +1264,21 @@ - (void)windowDidChangeScreen:(NSNotification *)not= ification [cocoaView updateUIInfo]; } =20 +- (void)windowDidEnterFullScreen:(NSNotification *)notification +{ + [cocoaView grabMouse]; +} + +- (void)windowDidExitFullScreen:(NSNotification *)notification +{ + [cocoaView resizeWindow]; + [cocoaView ungrabMouse]; +} + - (void)windowDidResize:(NSNotification *)notification { [cocoaView updateBounds]; - [cocoaView updateUIInfo]; + [cocoaView frameUpdated]; } =20 /* Called when the user clicks on a window's close button */ @@ -1312,6 +1294,23 @@ - (BOOL)windowShouldClose:(id)sender return NO; } =20 +- (NSSize) window:(NSWindow *)window willUseFullScreenContentSize:(NSSize)= proposedSize +{ + if (stretch_video) { + return [cocoaView fixZoomedFullScreenSize:proposedSize]; + } + + return NSMakeSize([cocoaView gscreen].width, [cocoaView gscreen].heigh= t); +} + +- (NSApplicationPresentationOptions) window:(NSWindow *)window + willUseFullScreenPresentationOptions:= (NSApplicationPresentationOptions)proposedOptions; + +{ + return (proposedOptions & ~(NSApplicationPresentationAutoHideDock | NS= ApplicationPresentationAutoHideMenuBar)) | + NSApplicationPresentationHideDock | NSApplicationPresentationHi= deMenuBar; +} + /* * Called when QEMU goes into the background. Note that * [-NSWindowDelegate windowDidResignKey:] is used here instead of @@ -1331,14 +1330,7 @@ - (void) windowDidResignKey: (NSNotification *)aNoti= fication */ - (void) doToggleFullScreen:(id)sender { - [self toggleFullScreen:(id)sender]; -} - -- (void)toggleFullScreen:(id)sender -{ - COCOA_DEBUG("QemuCocoaAppController: toggleFullScreen\n"); - - [cocoaView toggleFullScreen:sender]; + [normalWindow toggleFullScreen:sender]; } =20 - (void) setFullGrab:(id)sender @@ -1389,6 +1381,7 @@ - (void)zoomToFit:(id) sender if (stretch_video =3D=3D true) { [sender setState: NSControlStateValueOn]; } else { + [cocoaView resizeWindow]; [sender setState: NSControlStateValueOff]; } } @@ -2021,8 +2014,7 @@ static void cocoa_display_init(DisplayState *ds, Disp= layOptions *opts) =20 /* 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]; --=20 2.43.0 From nobody Tue Nov 26 11:43:20 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1707825721; cv=none; d=zohomail.com; s=zohoarc; b=BnS1haV6x5x3rMUt6fr5GxUIGAULVbR22LXVdU7PTVyi2CYSG6h0RKv+R85JE1k3e89zfJIb/WSh6Eon1n/qY24Py/XNGL5zXjscatPTESHXsHCeF8/X0389rg9xskyzGYdZT/v+72Ns9EClyi7vYiZCcTXgnQ+19V1RQDFFkDw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707825721; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=zthbQp6xqUSSgPtsY42mEFpzp+NHKvQicLn7aLSfUfs=; b=jxTIpb1gd5dhhgaGUPZii5+AEoul7H/V3SKTp3qQXCc0xqro9UvxEX4XYipNtaP+E9LqZ4Y1RJlCjqr3zgbUEAUrbXXWljMOiDuG81w+6SbloB4WpPjyfBCge/Bpns+SEphLDb8gT4vDN9rKQofgNCJ+CZYLADZJY4PhCrdU0hI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1707825721282866.6172861512883; Tue, 13 Feb 2024 04:02:01 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZrTg-0003Zd-E1; Tue, 13 Feb 2024 07:01:32 -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 1rZrTd-0003Hn-Mf for qemu-devel@nongnu.org; Tue, 13 Feb 2024 07:01:29 -0500 Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rZrTc-0000vG-0h for qemu-devel@nongnu.org; Tue, 13 Feb 2024 07:01:29 -0500 Received: by mail-pj1-x102f.google.com with SMTP id 98e67ed59e1d1-29041136f73so2564436a91.0 for ; Tue, 13 Feb 2024 04:01:27 -0800 (PST) Received: from localhost ([157.82.207.134]) by smtp.gmail.com with UTF8SMTPSA id q19-20020a632a13000000b005dc8702f0a9sm1096986pgq.1.2024.02.13.04.01.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 13 Feb 2024 04:01:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1707825686; x=1708430486; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=zthbQp6xqUSSgPtsY42mEFpzp+NHKvQicLn7aLSfUfs=; b=ehLhCMgbTqppBZVQRomM8N5dTj9AC6+3m+lm+tUz/6dT3VXJRVcxXkDgErq2HBBYHG YFVyMcaj8WDK7Uno/j8R6ISxAMzYnkp5TWm5V0eRhO26gJ5OUSlKIuGuQY2KS6V+wTD1 7/ROQIUuuXTuDkORMIvnin+ooTjxGbiBv7OJ53XSrvjCZzJGiSolyVnSk95LSEy8m5Oi ZZABFbrsO5/eUApLRSBKxuFXf9HgEcqHXG9eLLIbeE7aKj9SSeJ1SDIHnjwR5VWF7MII 9XcNTkacnmHg9Qo1Sszy1hmTEgku4I/ay+1lPb+SG6d7lZj/zVtmAIqxV2+XSQA6q5T+ qVUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707825686; x=1708430486; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zthbQp6xqUSSgPtsY42mEFpzp+NHKvQicLn7aLSfUfs=; b=pnbx2IFbdBD++DusdLzfQHIi/DujwOpP/KXMQj9rN9quAPqWjg0gQP1zpjgUWYVMam oGZVUEcmxS4HdkjFgNAb1XElyOINZD/okWB72M3dFVpY9srsK+JaEQDV1TFtpzAcgU8I t7xl1fxR0gEstjgo76v9v7Fox+gAqInj/tyEKb+weLUWigKE7kg1KmX21sQAP7QCmD7o 7C8U2eg7BBGaFjGlGiIdDb7XZGhRtBKjGgdZGSbicjcca38OQzf5AFVg2cTiJZp+eRzR HHcOJEWSzSKba4CsQWMm/W0FVKHr5xySpi2wk/uYBH06lsQWvYOEGc42Jd3Fe//2GNEw zKww== X-Gm-Message-State: AOJu0YwEMGfoKLUacajY+pfQM8EBOPdl6yItku69T/iclENiIwUm3oRq WnkyHZ1UeF4hoZTp/fZYxwq/6CYeE7j0Bd0iBFhIbCeBoof/pjj9VuFQzFlli+adJo/QMYhITus 5 X-Google-Smtp-Source: AGHT+IFoeiw7mqldsysqIm6PSdv0Pvjet1svhREXIAncJwJlZx+blTU5dQb5S3TPkI23HnpHFDogLA== X-Received: by 2002:a17:90a:fd02:b0:297:a6d:a499 with SMTP id cv2-20020a17090afd0200b002970a6da499mr5572430pjb.14.1707825686062; Tue, 13 Feb 2024 04:01:26 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVCyEXq0uE5gEeVNB+u1dQkhJCciqVT0sPLurFwtus7wPb8YyZeGi61bhI4oJdq5Z8ZaOCPOhW9n+kCrIZSLvNxj5QVMcvdldhQ+d+fOPr3Lc3rkyvvQMn7rtNpTbRl6noU9v09YxTm8xgD8CoTlnS9Y6SxGKCinEfZtr3zt+s4XdyuoPRm9p/nP3WTo6DyOubCRYikxrLUgVxN2VyfM/AelSLOQk+oWH6LLrXhk/+xgJcfe6mpMq0rqZwHL+vIyLVLZ4D0XSOIYkjx From: Akihiko Odaki Date: Tue, 13 Feb 2024 21:00:58 +0900 Subject: [PATCH v9 4/6] ui/cocoa: Make window resizable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240213-cocoa-v9-4-d5a5e1bf0490@daynix.com> References: <20240213-cocoa-v9-0-d5a5e1bf0490@daynix.com> In-Reply-To: <20240213-cocoa-v9-0-d5a5e1bf0490@daynix.com> To: Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Marek Glogowski , BALATON Zoltan , Rene Engel Cc: qemu-devel@nongnu.org, Akihiko Odaki X-Mailer: b4 0.12.3 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::102f; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-x102f.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1707825721873100001 The window will be resizable when zoom-to-fit is on. Signed-off-by: Akihiko Odaki --- ui/cocoa.m | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ui/cocoa.m b/ui/cocoa.m index 5d21ce143671..754539937ffe 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -1379,8 +1379,10 @@ - (void)zoomToFit:(id) sender { stretch_video =3D !stretch_video; if (stretch_video =3D=3D true) { + [normalWindow setStyleMask:[normalWindow styleMask] | NSWindowStyl= eMaskResizable]; [sender setState: NSControlStateValueOn]; } else { + [normalWindow setStyleMask:[normalWindow styleMask] & ~NSWindowSty= leMaskResizable]; [cocoaView resizeWindow]; [sender setState: NSControlStateValueOff]; } @@ -2033,6 +2035,7 @@ static void cocoa_display_init(DisplayState *ds, Disp= layOptions *opts) =20 if (opts->u.cocoa.has_zoom_to_fit && opts->u.cocoa.zoom_to_fit) { stretch_video =3D true; + [normalWindow setStyleMask:[normalWindow styleMask] | NSWindowStyl= eMaskResizable]; } =20 create_initial_menus(); --=20 2.43.0 From nobody Tue Nov 26 11:43:20 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1707825707; cv=none; d=zohomail.com; s=zohoarc; b=H2w8YHKrwlQtgcxUQ97LT7153w6hZsd7I50md0hQ2Z+A/wFEM/CGy9sCJ0ikzOje952jO/fVrbHO3n7AINjyJGT/byWVyoLeSOTf+6t8ga3c2emsS2pDOzOqY9ZOSi4Wiyb35VDOA84ItZzOGYTmsuT9efkr/rUjQI0W7sMIUYY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707825707; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=bIJbW/SZ9SYfRb/KZSq6u+h/C9wWWReaQ1TXj2N9m9M=; b=S4k6AEtzGkQzBe44z7jPRviemeEF/db8qMElMhOq6J+eEE7pgtiLiTxcVRCyrlrVBDp28Vf0H+fGFGcqABEKMJ5gd394OzHjsPfkGrU5Azp3rObam8g0pT0bh3exw04l/YxqLvkYFSPSRrvClY89ahjRZMFQDhOpYHWzM0lZzzU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1707825707295618.6784605817663; Tue, 13 Feb 2024 04:01:47 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZrTn-0004Da-MX; Tue, 13 Feb 2024 07:01:40 -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 1rZrTj-0003yf-8P for qemu-devel@nongnu.org; Tue, 13 Feb 2024 07:01:36 -0500 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rZrTg-0000wz-GT for qemu-devel@nongnu.org; Tue, 13 Feb 2024 07:01:33 -0500 Received: by mail-pg1-x536.google.com with SMTP id 41be03b00d2f7-5dbd519bde6so3194019a12.1 for ; Tue, 13 Feb 2024 04:01:32 -0800 (PST) Received: from localhost ([157.82.207.134]) by smtp.gmail.com with UTF8SMTPSA id sx12-20020a17090b2ccc00b00296885dcef7sm2337698pjb.16.2024.02.13.04.01.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 13 Feb 2024 04:01:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1707825691; x=1708430491; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=bIJbW/SZ9SYfRb/KZSq6u+h/C9wWWReaQ1TXj2N9m9M=; b=aDw/8hyIKE+BBO1tlZ2K1jB3ZYmmTX1Y3PFLrWd6vmxCEic4k6KD9SulVhfIBzhbOp z6zmwpHoiZySb+fE/jV+Pq2wXjXp7C6Xwwzry5d3r5wLSTLEOMv+9mtZ4mMWj05poy5l yAQsZq6rkaiTSCvZISoze1ixjiZNMl5NzjU+w+czybNm1dyFGGpHHWIM0JPshbMPW7NS Ut11bNnONk/b0I21TeM38802gudAbFTvVKd2Kkrz3QqCnIY+XhjI/Hlso6ImJz/vv4gX PHgJpzlfC6w+qhSPZgvk0aA2JzaSbWcSU0cLtOLVL8TyJCsWoA47QFATm0Hxu977qE15 I3ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707825691; x=1708430491; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bIJbW/SZ9SYfRb/KZSq6u+h/C9wWWReaQ1TXj2N9m9M=; b=voQ6oBcOk06izM33KpUWBGDB2opn228GtHHUao7RMjsQ9n/WQ7QAVHXfB99VLGjzp2 9UfUqje+FV3ezrIC4zgVy3qy7/P0uBuWebi3KFD/ybV6EvQ8JjtiunfpXL+mJvqvHWOm JWE66sKED7gkHRZuRV19qdSQ2l24jKgq7+A0SUVthwEAC9gdsDSQhvRM9L69Cw5oR0g0 6VHfQ8fO4wmvHLqBtS7iwmDv/AlMTu1AXGRO1JSNamXklhiusXT95+yhaQ8ZlGTHjiZ+ CA4weja9sVK5tVfOAB+H/DHECIojrTJVLlF2xLIL4eAGkYUYP47eMUdR/oMt4jIZAa8J UkKQ== X-Gm-Message-State: AOJu0Yza0j02MZqjptmXO8D5eVc62VF/TExWPVlK1XFt/kQORKtSUzOD qwEjNGtdJ48nyTFZ7cKmw1AjYwiPOlv5tQ4H6dGyE//0lidt5hh5M377c7bTRhW2l7UU9b++kij U X-Google-Smtp-Source: AGHT+IG/ceVvKflKfWF6JB94qWVPWwcYIZYxsfsev0TMEwZTR9ywAr3KxbFQdVZuQqhowbOX26OuLw== X-Received: by 2002:a17:90b:d98:b0:298:988f:4dcf with SMTP id bg24-20020a17090b0d9800b00298988f4dcfmr3044897pjb.0.1707825690942; Tue, 13 Feb 2024 04:01:30 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXaECFEQzkw2TwOwyY8J7papXoOxs3vIFvTZl7rocpoXtvgPG7p07rrhlVf3UtZHG4anqQ5+LlYeJFX2SHTywHAsCKDrqbhcWQeUyG3PTZdutId7hbeAg3wWeyur4p5LwVV387wyjPti5YfbVhEmi0xCXKWkxV+G+q6AAfFja8XQ1EiKf4G5Sbv/79xtyMTQ4KXh9kNu2J4V0kMC1tJbyMPxwYGBJ/y39m1hfN+i6BICvXbB5Tu4VjXGzqKgXE+GhN+UAobuDv3Qgf3 From: Akihiko Odaki Date: Tue, 13 Feb 2024 21:00:59 +0900 Subject: [PATCH v9 5/6] ui/cocoa: Call console_select() with the BQL MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240213-cocoa-v9-5-d5a5e1bf0490@daynix.com> References: <20240213-cocoa-v9-0-d5a5e1bf0490@daynix.com> In-Reply-To: <20240213-cocoa-v9-0-d5a5e1bf0490@daynix.com> To: Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Marek Glogowski , BALATON Zoltan , Rene Engel Cc: qemu-devel@nongnu.org, Akihiko Odaki X-Mailer: b4 0.12.3 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::536; envelope-from=akihiko.odaki@daynix.com; helo=mail-pg1-x536.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1707825707833100001 console_select() can be called anytime so explicitly take the BQL. Signed-off-by: Akihiko Odaki --- ui/cocoa.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index 754539937ffe..93e761f09c6e 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -1391,7 +1391,9 @@ - (void)zoomToFit:(id) sender /* Displays the console on the screen */ - (void)displayConsole:(id)sender { - console_select([sender tag]); + with_bql(^{ + console_select([sender tag]); + }); } =20 /* Pause the guest */ --=20 2.43.0 From nobody Tue Nov 26 11:43:20 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1707825713; cv=none; d=zohomail.com; s=zohoarc; b=hMBLxgOkM2GbPt7tZQ4zQO0vCVLLwF70krRrPbYZMuEv7rkdcbdMgInFQ9H/ASNQqqwpqu6N2//Ls97XjxY0XFwkB+M9TWsl+ujYdoAenNpz12hAS0lHcWT88qgki9Mj0Q/HA0IH7Oi41mF2+yauqUpZtSoeXsQIlZpcTu40tzk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707825713; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=xxggzNoSHA/NLM+K6602kCvWVNLthDE/kRWJr7Ttw8g=; b=OB4XuJygmQNPtpkqAtNyrmHbVBZxXHSikmF+b2rsYJfc9KwUudJMPs6p3TKMP+FgbWUkysYG9jGpg/f+zao3pgtEzlW4pIfxFjzeqibF7KObPYoIKjjNEeJZjitK86WR1cm6IGqkdlBR35/RAopp/FCPo5EAJEWbUwXfUO2m1SA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1707825713302268.3144036834419; Tue, 13 Feb 2024 04:01:53 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZrTw-0004MG-Pf; Tue, 13 Feb 2024 07:01:51 -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 1rZrTn-0004Db-KO for qemu-devel@nongnu.org; Tue, 13 Feb 2024 07:01:40 -0500 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rZrTl-0000xs-E8 for qemu-devel@nongnu.org; Tue, 13 Feb 2024 07:01:39 -0500 Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-6e0fc87fc2dso203217b3a.3 for ; Tue, 13 Feb 2024 04:01:37 -0800 (PST) Received: from localhost ([157.82.207.134]) by smtp.gmail.com with UTF8SMTPSA id y20-20020a056a00181400b006e06af90ff4sm7165010pfa.204.2024.02.13.04.01.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 13 Feb 2024 04:01:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1707825695; x=1708430495; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=xxggzNoSHA/NLM+K6602kCvWVNLthDE/kRWJr7Ttw8g=; b=PurE6EucoYmwmVgBbOtXlJNaF3Kz4FXbD2FsO/ug0DrIOP/uuEVN44Qe2rWqXXmwt3 C7QVWqJ80paxi6mAoRkLe7VwXkzuWtpC37R5vnjyBRL3++J35DlYz2hO2uhlduPkr6WU sPQ4r5pxwSOKMvRehXJEfpHV3cJLlwaoZmzDTMNhUHkGb5VecomWylRXFULHqBSX54ep gIChYNL8CgdjiKTQFPif5EPwXcI9MYz7MniWH8W7I0IbMuJIBFV0ZLTPIjm+t/EQgVSj CvCYb7qXCUdtBVuYmCUcJYW7Rls6+piSHG+A6i4PRuXRopJgY/Cvv+35d2ePMKoV+qTp 5EWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707825695; x=1708430495; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xxggzNoSHA/NLM+K6602kCvWVNLthDE/kRWJr7Ttw8g=; b=DUhHjkeIBCrtStWG6kuMKLx3vbe9emptb7OOnTTPoYxtfOBpRKOBaqyCZGOMWpeM0/ bNqxXyj4kdFxpO/WNgRoMY2YAA6/C2Enjcn1RVILivhCAazfns9CQNUfFmAEyU4laj/0 5mZGdjBqfgQMSX5txVl7HOfA6MtFSIj+01vNPwN1er0IKPLW3LZoq2IfI/wS7CtQyOZ6 wpSGk3GtLnEVvNw24DPRsvaLiDi6q4wZTFt4ooXW7oyQQgpz5qZl82zhFrAtKXxtfARU VkpWXUSPTfgfu69ZQ7fjfgr/7ZoKWNZSZPkXYXEcqtUlVWef3vYwdyk6ewwixBsHOLQp Nrcg== X-Gm-Message-State: AOJu0YwsQBJyIXiogwrE9JNyE42Cj44sgj/gsg/drFPcmzXQcu1JuPaw EohFiABTfFX30JFqhveLQ04cokSomwzmpXknjjbQ5c3DYi7s5HsRJ4xJ6ibXjhR6+DYXUz6QiEg K X-Google-Smtp-Source: AGHT+IH69OyZ84u11JypLgfaCsxD20dK6QyJLhdWQ0vnkEKAaf8nPpEtHQmUsqM1y0eQEgjca90HEg== X-Received: by 2002:a62:ce4e:0:b0:6e0:a025:feb2 with SMTP id y75-20020a62ce4e000000b006e0a025feb2mr7793977pfg.11.1707825695110; Tue, 13 Feb 2024 04:01:35 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWuITPVZOhgMqF73ouEs9ab0OyXijXJpJPWbX5nVB9ICEFuu7FLzRXyHPS0+zXmXx23oGnzCZUgqRs77XWTltYPFrXkEG521Jwak2Mj6No1qdNjGMI4y8Xe/eAIc75myOLsJ5Pmky2B5Tu0/WupXgob78q3e2z6qsduFi16gXrGoo3+fsjv+HPCbO+um8xAAVpKnlBpVxm4Pa7kRwgB9OoYg88rryf+g12OkwQ/AwoPI1qrc3w7uW9WPyHhchn7EG1/jlbWRSNyciO3 From: Akihiko Odaki Date: Tue, 13 Feb 2024 21:01:00 +0900 Subject: [PATCH v9 6/6] ui/cocoa: Remove stretch_video flag MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240213-cocoa-v9-6-d5a5e1bf0490@daynix.com> References: <20240213-cocoa-v9-0-d5a5e1bf0490@daynix.com> In-Reply-To: <20240213-cocoa-v9-0-d5a5e1bf0490@daynix.com> To: Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Marek Glogowski , BALATON Zoltan , Rene Engel Cc: qemu-devel@nongnu.org, Akihiko Odaki X-Mailer: b4 0.12.3 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::433; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x433.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1707825713872100001 Evaluate [normalWindow styleMask] & NSWindowStyleMaskResizable instead. Signed-off-by: Akihiko Odaki --- ui/cocoa.m | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index 93e761f09c6e..e68f418d9e42 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -103,7 +103,6 @@ static void cocoa_switch(DisplayChangeListener *dcl, static int left_command_key_enabled =3D 1; static bool swap_opt_cmd; =20 -static bool stretch_video; static NSTextField *pauseLabel; =20 static bool allow_events; @@ -533,7 +532,7 @@ - (void) resizeWindow { [[self window] setContentAspectRatio:NSMakeSize(screen.width, screen.h= eight)]; =20 - if (!stretch_video) { + if (!([[self window] styleMask] & NSWindowStyleMaskResizable)) { [[self window] setContentSize:NSMakeSize(screen.width, screen.heig= ht)]; [[self window] center]; } else if ([[self window] styleMask] & NSWindowStyleMaskFullScreen) { @@ -1296,7 +1295,7 @@ - (BOOL)windowShouldClose:(id)sender =20 - (NSSize) window:(NSWindow *)window willUseFullScreenContentSize:(NSSize)= proposedSize { - if (stretch_video) { + if ([normalWindow styleMask] & NSWindowStyleMaskResizable) { return [cocoaView fixZoomedFullScreenSize:proposedSize]; } =20 @@ -1377,8 +1376,7 @@ - (void)showQEMUDoc:(id)sender /* Stretches video to fit host monitor size */ - (void)zoomToFit:(id) sender { - stretch_video =3D !stretch_video; - if (stretch_video =3D=3D true) { + if (([normalWindow styleMask] & NSWindowStyleMaskResizable) =3D=3D 0) { [normalWindow setStyleMask:[normalWindow styleMask] | NSWindowStyl= eMaskResizable]; [sender setState: NSControlStateValueOn]; } else { @@ -1650,7 +1648,7 @@ static void create_initial_menus(void) menu =3D [[NSMenu alloc] initWithTitle:@"View"]; [menu addItem: [[[NSMenuItem alloc] initWithTitle:@"Enter Fullscreen" = action:@selector(doToggleFullScreen:) keyEquivalent:@"f"] autorelease]]; //= Fullscreen menuItem =3D [[[NSMenuItem alloc] initWithTitle:@"Zoom To Fit" action:= @selector(zoomToFit:) keyEquivalent:@""] autorelease]; - [menuItem setState: stretch_video ? NSControlStateValueOn : NSControlS= tateValueOff]; + [menuItem setState: [normalWindow styleMask] & NSWindowStyleMaskResiza= ble ? NSControlStateValueOn : NSControlStateValueOff]; [menu addItem: menuItem]; menuItem =3D [[[NSMenuItem alloc] initWithTitle:@"View" action:nil key= Equivalent:@""] autorelease]; [menuItem setSubmenu:menu]; @@ -2036,7 +2034,6 @@ static void cocoa_display_init(DisplayState *ds, Disp= layOptions *opts) } =20 if (opts->u.cocoa.has_zoom_to_fit && opts->u.cocoa.zoom_to_fit) { - stretch_video =3D true; [normalWindow setStyleMask:[normalWindow styleMask] | NSWindowStyl= eMaskResizable]; } =20 --=20 2.43.0