From nobody Tue Nov 26 10:32:52 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=1707885192; cv=none; d=zohomail.com; s=zohoarc; b=NqEKdBHXyozhN6Im+U2Kp2+tglGwtShOvHDTThQ8QEIVOnMX6G9w7wL58W/MVyIM/PDjdCNSh+TnkTQaZ2n2Z4gOeptrtqWSPE5TEH+xJBNKz6F9qunC0F52QqDqq/kwvSKzi8XwZkjyJbhvbR3wvRzBMjW1XzLDaXLYnzG9EsY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707885192; 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=AB/k7okASbZFwQVudFjMWxp8PxDD8ui7JxQAJKZ+69EO1JIiLMx3OFSgLEVsQC6Udo7XJVbDpYZU/qOGkmduVIQq5OqUe90HdeScvXz4dI1u/1v+x/pbmjCTCLIamvwgUlEd4grrMIedKFKbQTHzinxvk7Zx3jIGrYWQpbvxw0I= 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 1707885192978228.57975363086973; Tue, 13 Feb 2024 20:33:12 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ra6we-0001uN-B1; Tue, 13 Feb 2024 23:32: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 1ra6wc-0001u7-F0 for qemu-devel@nongnu.org; Tue, 13 Feb 2024 23:32:26 -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 1ra6wa-00067D-Ih for qemu-devel@nongnu.org; Tue, 13 Feb 2024 23:32:26 -0500 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1d780a392fdso42453835ad.3 for ; Tue, 13 Feb 2024 20:32:24 -0800 (PST) Received: from localhost ([2400:4050:a840:1e00:9ac7:6d57:2b16:6932]) by smtp.gmail.com with UTF8SMTPSA id iz21-20020a170902ef9500b001db499c5c12sm1051136plb.143.2024.02.13.20.32.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 13 Feb 2024 20:32:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1707885143; x=1708489943; 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=b1KmzI9FzKgsoP0lNJlXbLwRgMODvoVCa7oMgmyTxEsKg5Ea3WcihF515PH3YEtTNh TwDTJWQTahEIuAkUbzG4aHOdVKHkaIXypnwWJ/1TLPYrC4KnevrREQj2A0tfu6X8PYb6 sc028OeGLAsgwtpf7vbG0BmKVSC9LrZiT4teIdiNV9dtR37QBZ0y4l44xmICBwssIenw 0T4DixTLF0E1WfAAWhAo9RgWTh0q+UcV6uDt2676GE4Rlsav90Rsz5rfrX+9Q6qZ3CO7 rjItG4MVzYVHQphQHNASnjG1K7UEtyu0knhVBvCehNry3ZCW0a5jjqpY0E7dzVfzLwBp 0JnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707885143; x=1708489943; 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=I5/792nlVYsICHr5mmhc+CyxtW0ZBZGzQSlYqsrszfKdDKjbDWdhCd6MMXoHlZcK+B ISR+Kr/sNLlE2D9M0kQgdxbJoO8cqIzg6VEbWGdnYaGFZaZXM+15dd672mHGtVmUWCV2 fv6tPtZ5DRoAfKBAETeZDfDJ7zYMMLdFh9pwSs2gvaT9kUOhWS/CBo+OKhWoCSsX2e4D dsw0dzq4m9ozIDGC24rDJs+1Tl9EMBQzLvv7V3EjwqnmwV6ykEbmA6ZJNlT7X1dRqGBA e7c8m5ZSAq8rGk6d7zykHx4y4mJuQd0BXcElbdqHFxmsl35rSvSyE035vecSPiSM6gZq Goog== X-Gm-Message-State: AOJu0YySFA5nMpzsDQsby413QyVOOYkh0zNs4tOo9PSNYpzdURSMTbWE ZZtmDYD19r+uvZ3Dku+6G885vpQ76rvJ5If0yG55vqE+3fcIEP1xFc1zyRS0dU0= X-Google-Smtp-Source: AGHT+IHhF4KTQmUYMn6aHIv8qsGYFdXDGv1Ud/ZsYNy5OACKWqEfUFLJBwJ2daMhYGeVPBIE4BMV1g== X-Received: by 2002:a17:902:f80c:b0:1db:3ebe:57da with SMTP id ix12-20020a170902f80c00b001db3ebe57damr1402888plb.33.1707885143065; Tue, 13 Feb 2024 20:32:23 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCX/QW6K/XBXk2OYAiGgT0p+A2wfKrpVj7uyH53KuYioNiZPP1HXKru6UW6Qyv8v0t3hGRBmv7/hnLdxMaToS4ilCGOD+caXeEtptgRxaFUuhusIx5rdrbjfAGdZggFdgZ7GuYVCnyl9tN1QSaX5w/2/ZuAMCKsESLZO8eSpbMug9WuUwAIi/oFze0PcZgn0A/CI1+kFC9JGLnadtLxLC4yT6XCzQH5AvqGbJb3zNsNZWhZcLSJEESgldTYNx/G9E9Z0bK3TVly6K0ym From: Akihiko Odaki Date: Wed, 14 Feb 2024 13:32:01 +0900 Subject: [PATCH v10 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: <20240214-cocoa-v10-1-c7ffe5d9f08a@daynix.com> References: <20240214-cocoa-v10-0-c7ffe5d9f08a@daynix.com> In-Reply-To: <20240214-cocoa-v10-0-c7ffe5d9f08a@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: 1707885193914100006 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 10:32:52 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=1707885192; cv=none; d=zohomail.com; s=zohoarc; b=BwNbUg/mO0etOFHJ/s38G8tvh9Sw3d/GTzPtWJaZpnd1Qy62HlIob9YyOyuDs69M4alBPH8WPeM9hWAYpOwXSUnbr6YbJ4PruQ3b4/4W1jk5NYeKfiJhL5yF+BB9PMReKMFEVW8nWI55Sz5D0urmKgyHis9XkooDQ4aYt/6vQL0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707885192; 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=hSnJMHu1v8ufr5BPhCbCn51shVVvjUDBsIdcDy50PMNseAeMBbTCmF+TNTdz/Ap+KxOjeb2eR3vtoeSeMlHd41ywKmQ2bAaXapwafDLc5VRR7WT5rU5J+oPJaQ+IzA1jahV+evkR8blb5D2ZECfNKkV3KgYGHKG9tr8rhceMdAE= 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 17078851928361012.010702921688; Tue, 13 Feb 2024 20:33:12 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ra6wh-0001ux-Si; Tue, 13 Feb 2024 23:32: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 1ra6wg-0001ub-OB for qemu-devel@nongnu.org; Tue, 13 Feb 2024 23:32:30 -0500 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ra6we-00067w-9e for qemu-devel@nongnu.org; Tue, 13 Feb 2024 23:32:30 -0500 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1d94b222a3aso42148685ad.2 for ; Tue, 13 Feb 2024 20:32:27 -0800 (PST) Received: from localhost ([2400:4050:a840:1e00:9ac7:6d57:2b16:6932]) by smtp.gmail.com with UTF8SMTPSA id o9-20020a170902d4c900b001d739667fc3sm2741586plg.207.2024.02.13.20.32.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 13 Feb 2024 20:32:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1707885147; x=1708489947; 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=RvYkqn6ffce8RQmTCku5gN8j1fgW0RpmIyurWtnggvEguONO5qJfWt0W8mMlWza7vB iWK7sfa59uwoIr0CMWWbtLeUcYsPD/Bj1xK7aaUP5lviEfsILZBcXGnHB1YXEWdkEpPo ycSDd5KBBR5qEuWSQIqpLtesSfbXmOJ6hi7dHyIAiH8f/a4z4ogLdfSYitVrGXW0RQFY VIJnvUbmbZdpUep/IsZwduAwa3qBEOB8IPkPcXce/IDR2mulgxGQ76qABFGQZGjKU41W ttpehy4mj5dIygbTEv2BvUPX1/3x9rN+jsZylXKYU7rNp+OgF0rT2iBwtf+F6toJTzeE tybQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707885147; x=1708489947; 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=Bz39tF5RCLaoJXIQ49LEv3+YnInHzAuVx+5ctW8tHEB9Cfxy6AsyMEcUPi9Nz7abi7 vbPSZ968BqI+9aK1aiB3PXfjAqFJ1RfHMpOFPNhDLy4s8pNgtdihtvw2IMIcIpnYkXFt 7nSnGJcLGCrsuFcgxx4FOzQmw65BbX8jS+miKL4cUbrr0Sqdj3K8QB9qCM2jIVUQMaVm uJBDXuvPoR6nEs6bvQOQuYfpGUQP98AiXoAwlBBW8V4wTzPclBAP+wMXc4qLgCKOrvk6 j6W/zq8D5fnxfd8yk3yTeD+iD4HAjTpZmwDeH8ApO+2bqqMTrFG+ml4GU66aveZvfzV9 pXVg== X-Gm-Message-State: AOJu0Yx+z6bYdHuiVJRMMPOiE+KVU1/3hWY5NC2VFZdpW3jo4Hal9EEf ZC/cbIM9kOjtXlgt0m70+AB7t5ZDAIHzKOX0yQOyqQwZngY1UhUdQCQdWNoxftZgyQfyvjwXLZ7 2 X-Google-Smtp-Source: AGHT+IE2hxlKwiImhrUDdBOKl1qIgd/bV4e80gm8+cE8WDP+W4ZEUrT8A/gOXJZDzuJBNvPhsZNT2g== X-Received: by 2002:a17:902:ecc1:b0:1d8:e7a4:3474 with SMTP id a1-20020a170902ecc100b001d8e7a43474mr1815886plh.68.1707885146889; Tue, 13 Feb 2024 20:32:26 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXGw50+XzAc3K2+zOJ1/dAT1sTy+8PZqWcL4MrKjEv9dmlcuf4T1S++xKXCMvCOkEa/OL6cOkgJIHCm5KXeo+EfyK4uaTxsOUwiaoMZOPURmcNFAZW/JwvzWN/4to1Nw5G+dwJmhLHn62qQOyHKEX6EVvpv7SoyfdLpelE5+/CEWXOT9EpZL6K7NfRj79mM/ytIKgNEgs2hz1Wx/2VL8d1Ir7WtXNyimWgGjNff+ZexsGbtBYo01KMYhS9U20MKh03tIzJVJP90NVyg From: Akihiko Odaki Date: Wed, 14 Feb 2024 13:32:02 +0900 Subject: [PATCH v10 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: <20240214-cocoa-v10-2-c7ffe5d9f08a@daynix.com> References: <20240214-cocoa-v10-0-c7ffe5d9f08a@daynix.com> In-Reply-To: <20240214-cocoa-v10-0-c7ffe5d9f08a@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::62d; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x62d.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: 1707885193908100005 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 10:32:52 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=1707885180; cv=none; d=zohomail.com; s=zohoarc; b=eFr2R6MzW263I05sB8jfedcDHSLgAmuX/amoIA1utn6duFG0hBsSKfMN6QhrYHtUSAU+Ll24pPLMOt60zDrKoirGclYzNtydMW2OnPXibyDfHbSbGXH29/aEk9LOA2m7Ab+tCjxkGuvr+MV14ihOEUQV7/dylJ0mjxwRzwnw1B8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707885180; 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=CqvLiDGHBrVX5ns6Hzc0sYNVn0bp5753CKo5mP+rDlc=; b=iKwLg5KLNLXpLA9f/dCdS4i0FT3G72VmDI/G11/qpoRYmmm/z73oTGGYe3utDfa/OgKuzZq0p4iEr1Ap4m1mvhujxICWZArue4o7noNfeg8QmtsGOfKcEfta9A2kgtmXXaDb/lNo7HeO3GuziT4ZhighHYLPGosJ2ueuPZBRNxE= 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 1707885180338645.9350590208545; Tue, 13 Feb 2024 20:33:00 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ra6wm-0001vR-Ma; Tue, 13 Feb 2024 23:32:36 -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 1ra6wl-0001v4-0d for qemu-devel@nongnu.org; Tue, 13 Feb 2024 23:32:35 -0500 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ra6wi-00068u-7H for qemu-devel@nongnu.org; Tue, 13 Feb 2024 23:32:34 -0500 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1d953fa3286so39750735ad.2 for ; Tue, 13 Feb 2024 20:32:31 -0800 (PST) Received: from localhost ([2400:4050:a840:1e00:9ac7:6d57:2b16:6932]) by smtp.gmail.com with UTF8SMTPSA id m8-20020a1709026bc800b001d93ba1120dsm2788531plt.200.2024.02.13.20.32.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 13 Feb 2024 20:32:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1707885151; x=1708489951; 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=CqvLiDGHBrVX5ns6Hzc0sYNVn0bp5753CKo5mP+rDlc=; b=iNk7KTxXNebZbnkSND6hCY4ySNFLf0MJ/TtOONcI2bYqd+9pNM98vGxyN/OTtUvoPP dXn8gUT0lass+OhjRGsoyOoumIqCXKx8NwgimCeYXTROhK1B+cKm6q+lOsdHWYU7DaWr VE8lVCf1ZNXQ9OqudN7lagDvAYMmxlrZ2wWuuLI/0ogdNT/2e1PZOg1fux5bY18G1/9U 4o5VUCL+mGA2ZJlPjVXT66NLFpyGN55kKEvGr1nHDpPIPzyU34NuayMa07w8hcoKfgvb TfG8erM8m4wEsuEvYgv5ffoaWzbP5eHlzq2EkaosKNqD6/XiFZK3AgAnYlL77/mXy5wc kBEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707885151; x=1708489951; 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=CqvLiDGHBrVX5ns6Hzc0sYNVn0bp5753CKo5mP+rDlc=; b=cTxvNyX90g1J5bOjTFIZRcH60rTvgRqiZG4jiVuYnwv9znUQjM0hAT/CTIDaS1aU10 nOaRFMflv+87X7KTrAIm2mLREtvqna5ZY02bPB+Ozk+XSlOHB49LM0QkHB/BixPItvS0 9Sza6p4Pch241XljQ+5jtsk8W2EUuCI6nB+spbW35YeV+jFFj6guTzz5eFeUeeohUu0F SyKzf5EgQ9o1VMCQR4Z6ageDxdI3HcYkgor3GY2kTMdjIA2+l3jQbw/jN2dgTb0224Rr OEaEeLE0n5Uy+63VzKlnxuerXzEurphdSz1BTk3oTI0apY96p7jjN7DRNHYPSsAm36PP JCdg== X-Gm-Message-State: AOJu0YxIz8KpHK5lJJUbKcUbUkf+hjnTdMMg4ZNQxpzo3ZTODdI0cFff yTEPMJUp6Yj8Ko1uDQMYIoNGXu2j5nC7S64wXTVy+buqHI3WCW3pt6zj0DqiPIA= X-Google-Smtp-Source: AGHT+IGXmax7eC0/5t4dZrHYG7HwBxzb0Rx4IVECJDWTYKRyBsDXJ8YQUuOr3hS3tM2Y58JZDOhr+Q== X-Received: by 2002:a17:903:22ce:b0:1d8:d6f2:5ee0 with SMTP id y14-20020a17090322ce00b001d8d6f25ee0mr1884000plg.8.1707885150737; Tue, 13 Feb 2024 20:32:30 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXDkFDnrVcdkjqRMzg6NrKlX2mOwk5FPo+ieKNC5wdIAosGyXdvFwTH4gD8bkrxZZEJeE3Nsaya92DTdxOmd18vPXyOfoBngQ8/AowxYzN74H/H585sslrj8dqvd20zpU+rPwNU3OKB++v9eJ3hOmdKLSMJhIo+0lmS5GW4YdH5j3BfySMFgy6N7xBgqbibWqKhOT+f2ytVcOraakjSKdAoMYEGHhAlUbvHDNvBXb5GmXcfTcBFdV3R2PYdaK1fIjxt8YYhOktyUIQf From: Akihiko Odaki Date: Wed, 14 Feb 2024 13:32:03 +0900 Subject: [PATCH v10 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: <20240214-cocoa-v10-3-c7ffe5d9f08a@daynix.com> References: <20240214-cocoa-v10-0-c7ffe5d9f08a@daynix.com> In-Reply-To: <20240214-cocoa-v10-0-c7ffe5d9f08a@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::62a; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x62a.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: 1707885181785100003 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 | 423 ++++++++++++++++++++++++++++++---------------------------= ---- 1 file changed, 207 insertions(+), 216 deletions(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index cb6090905999..518fae26f6f4 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,117 @@ - (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 { + 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) 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 +1097,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 +1115,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 +1128,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 +1151,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 +1192,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 +1263,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 +1293,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 +1329,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 +1380,7 @@ - (void)zoomToFit:(id) sender if (stretch_video =3D=3D true) { [sender setState: NSControlStateValueOn]; } else { + [cocoaView resizeWindow]; [sender setState: NSControlStateValueOff]; } } @@ -2021,8 +2013,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 10:32:52 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=1707885215; cv=none; d=zohomail.com; s=zohoarc; b=Mfd2xkL14p2pLf5+sUXCCXSUgpHU510drREPZY+rtunkaM2zklyMYEeoxP64hKV07WDqXAx0C2THZmi1Hr0lBbShMBVWwuBd6sj/0DkD7SB5hXKCqp9ix4rfn9Ma+EGYNqq5Ea9YuvTLzdL6LVMEa2Apxsjd71FaB1T4Wkp4rsU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707885215; 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=UHpMCU9+Q+3IXmsSy1dT2hPPsLkN972lqGuEQ2h6qwE=; b=UqrLSQ0pUTIyBRqtt5z4LnVW3FToQ5d+N3ahdiUc6DWkSTk/jDSH1AxzC9J6YRPuTS9MV51ZHVpZl9ImLyL3SCNuLeJ/Cyjt/eJy6EBYa0HrNgAETfQ1moNiTSVRAXsKfNQUKj7z/ILw7IhQxs2ytVvSNA/Wb3bCqyxMSWf+hu4= 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 1707885215013221.66909445505428; Tue, 13 Feb 2024 20:33:35 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ra6wp-00024G-EA; Tue, 13 Feb 2024 23:32:39 -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 1ra6wn-0001vS-AF for qemu-devel@nongnu.org; Tue, 13 Feb 2024 23:32:37 -0500 Received: from mail-pl1-x62c.google.com ([2607:f8b0: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 1ra6wl-0006B4-Uy for qemu-devel@nongnu.org; Tue, 13 Feb 2024 23:32:37 -0500 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1d746ce7d13so43640005ad.0 for ; Tue, 13 Feb 2024 20:32:35 -0800 (PST) Received: from localhost ([2400:4050:a840:1e00:9ac7:6d57:2b16:6932]) by smtp.gmail.com with UTF8SMTPSA id r3-20020a170903410300b001d70ad0fe79sm966130pld.291.2024.02.13.20.32.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 13 Feb 2024 20:32:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1707885154; x=1708489954; 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=UHpMCU9+Q+3IXmsSy1dT2hPPsLkN972lqGuEQ2h6qwE=; b=seOW5gaZci5nHI+r2+nDyht/hKs6bw/A0EdOxPy7eRbMTsmnRw01AurBerVpvIop2V /z05HA9D6bi//0R3OmmC6oaj/ckEq+3mRIqu1vxbrhfDaj+/+CyQywr75St8VQriu0By cOYo2PJmpePUUOtc0l20ffsjcuHxWKqQDB1+eNzikYmPLq/uP7PPTudmeOs4lPPbQrDb XsytOE17xzeQhe1WJzTbY9oiI11GqDHDWbC+64SNxNEJWiKJ7RlK2vCUljoF1Exf0NHP /wTMKor/LaFKHuvQUlfXiayVCiIn5zq0ASTRNGsFi70qzU80Q0aqdDQwWZAtcIl0VP8l K3lQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707885154; x=1708489954; 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=UHpMCU9+Q+3IXmsSy1dT2hPPsLkN972lqGuEQ2h6qwE=; b=Co5YgZ/0nvmdUh01/LvBE/ptPhv716e97uJ/GVuTHXiWedZ/DQdHmrEZhp/NSptCV1 wBqbpf7JLAQw4PWRqdDkKf8GTmqoQQYWsbBp9Iw8wkYCfB42f9nInT+1pX7ZchsJ+Qpu qgqod+xLDNa4/E4qwb/RtK5LOiddkPwypc9vILmQTiW9BW6sOXv8843XA2GPNPlv17/C BwBJbEDOUF3mVsz/czfQJruQ/2es6Mn/G0mJTiVG6QJC3slLTPB0EfwtWqIbRRVqSccg ZewVPZz+NkHhirxkHcvFMJ+AC3YNvIJvgLdbP5J2skW99/RIpUP0EUEHse3w0urZ66p8 Aymg== X-Gm-Message-State: AOJu0YwouxHAC0nNOScxi7+Na7NtDvZn5Fi8AVJcH8pCt+GldEQ/EKeW O8Sm558F0Fp6sg8XcQC/GBYU8dNrVAfbOWDB9tvP6U2RVqCW1++GAgd1xg9SYp5j2KkEMYwFLPu X X-Google-Smtp-Source: AGHT+IG+7GyWgJ6Wwh5Hl4KEtfF8vZ/R6pampJ1DsN5le7ItEyPkqwFt+wIAUoFx59U4dtwT4RH+1A== X-Received: by 2002:a17:902:ce87:b0:1d9:bc11:66e with SMTP id f7-20020a170902ce8700b001d9bc11066emr1714259plg.37.1707885154549; Tue, 13 Feb 2024 20:32:34 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVjTcZBqpgSaJGz9NDoBkDHizck2k/MID4sQl0Xggkn8C7tQ1Q8dXznKmH6Uqq+7K3ispvAqqHKx4VFLQWLGE361YdTMzDjkL0q245ySC3sY+2cnVKQNUFx9/fb35NBOtyagsCx/sbZ7+WCG8Q5K6hKlEB0/YHZlYxZi2kOid5BLJ3RlJ5S4g4lm+eGk4qVtWFEEvSAZheyu81Qsf5zQVtZT+iaJx0tMXnNUBdpprPl191fuffzzwkxq4eC5fqg3Lz9YCyIu4adgUyv From: Akihiko Odaki Date: Wed, 14 Feb 2024 13:32:04 +0900 Subject: [PATCH v10 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: <20240214-cocoa-v10-4-c7ffe5d9f08a@daynix.com> References: <20240214-cocoa-v10-0-c7ffe5d9f08a@daynix.com> In-Reply-To: <20240214-cocoa-v10-0-c7ffe5d9f08a@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::62c; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x62c.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: 1707885215728100001 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 518fae26f6f4..a1f54b3ebb9a 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -1378,8 +1378,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]; } @@ -2032,6 +2034,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 10:32:52 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=1707885207; cv=none; d=zohomail.com; s=zohoarc; b=n+rvmJdsSQPvRH/GTdTiT8FGnG7hN1VqclmjfYEBYpbCvk2usxPZ90K8ly23zog8gaZjFv/b7XOG+x9O0LQrH2fX246AXKcT1fnG6ej6ryZIlDnS0H8qCPOlyxm0sVqKzjbGZjAb099eupXp3O8cUVhN+LpSIzcEpEb8uW1T4GI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707885207; 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=uDq193jDC/SXS//7zZzp4BuB0pNmGpuo5+lyA6P0aSE=; b=WD1dnaUERAFWXSb/OerHw+UswFoTnP8tArIB8OV6sFRTAXjIJ33VWWCTzQynu8UpyhcSm6s/X1/kTprGsVF6pubOtHID036sec0ySjxc6Y8w9iM+JNu8G9ingF3NV9iIWYATW/8RKoaqgxys1cmTy4k4qHQoyU/3mf1bjW3EBnc= 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 170788520760075.99390416354413; Tue, 13 Feb 2024 20:33:27 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ra6ws-0002PG-TD; Tue, 13 Feb 2024 23:32:42 -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 1ra6wr-0002Go-A0 for qemu-devel@nongnu.org; Tue, 13 Feb 2024 23:32:41 -0500 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ra6wp-0006CJ-Kh for qemu-devel@nongnu.org; Tue, 13 Feb 2024 23:32:40 -0500 Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-6e08dd0fa0bso310846b3a.1 for ; Tue, 13 Feb 2024 20:32:39 -0800 (PST) Received: from localhost ([2400:4050:a840:1e00:9ac7:6d57:2b16:6932]) by smtp.gmail.com with UTF8SMTPSA id r15-20020a638f4f000000b005dc389409c1sm3165487pgn.93.2024.02.13.20.32.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 13 Feb 2024 20:32:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1707885158; x=1708489958; 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=uDq193jDC/SXS//7zZzp4BuB0pNmGpuo5+lyA6P0aSE=; b=jQxyTAuGfc+qgjJsWC6Z1Dcw9s3tAYEGpERzPs2Kg3a2ZM8GetwVTl+BiFN7DZ+3vu q19I1HLL0fF3G31LDo2vXfzNC2K2uSNoAX61ZGtu53uN0ZW5BeVzi/Ia0haPKN3JDn77 ru+cITh/QiloUtN7x0XDX12QuWVPYbNfabuQEIp0t0eIiuhuRY+kz1ms0jXPVtEjwjC2 jEUHo7bSzqG0IJy/xqRZaJ2vnWuMmg1RLiiAs8JampJCYx9pNZGBGXW8/7zD4uVurRWf rFz0cev+2MUyd0H3JhDlAMqMmHpH+h63ybzRgfOrfZguzZrghVlfHi28AQ14uBMr4scd Pcog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707885158; x=1708489958; 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=uDq193jDC/SXS//7zZzp4BuB0pNmGpuo5+lyA6P0aSE=; b=QckzYVn9lCgDiEcg3LpyRr3232r6zbFMVMpd35e47lC2f/iusAbP1kb+KYm4XXFpqZ 89gHarWjofLSzMENlwgBBNRtST3AzlWzArnT+PaNvG6+jKYyENGcnf9FJfKfoshpfNvg dOGacgkKexu34MaHvaPl9pkZlQtDdCM7AW9yJi5Z0xFiCDnZ1GBTRKMFaN9Xd1G+ZY98 qSmCW9Rx0Hgkfxh87sfn00qiqG9fLKujxEGBlIOjqzbSPoUnfPZxYi9muaTECajO8Mij zTCS7m9lAPQIWSL8r2di4M+0o2F+5+5MWbTN/wfOvUyW2eZlu+dJ/RMhnId5Pl3aOuiQ SiMw== X-Gm-Message-State: AOJu0YwyvDlbZrNXV6QEhQySlLAH+VcCoEnc7b0xlLHf1g2xuhDRi+W8 /wdzj7tAKWGcMDWl7RnQ7hb/8XiHkReddHgyu3Ew4Kz0tk/ai4b4tYfuiyazsCQ= X-Google-Smtp-Source: AGHT+IHtmUAPvX+r9pmCfqDX+kZ+KZNATU96SZbneux4+9NdiNaGO0bs9Mm8D7JfsLJA+9AJR83iNQ== X-Received: by 2002:a05:6a00:189e:b0:6dd:c23c:ea4f with SMTP id x30-20020a056a00189e00b006ddc23cea4fmr1409264pfh.5.1707885158199; Tue, 13 Feb 2024 20:32:38 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCV2qRDY2a9pATcQK54jRkuEKZuBXkVYK0F0Xo9AkE3JsN/b9Dk77ADZPQaK1VVTGOj0Xi3Km+uBEktiWb/tdTOypKbgPo6U8g4oEyt9drwCE/wyPEnuISswCHZq77DYOO9yvxGtadG795QdUQNE6MGgJJJpvo/JA7TFd+BHsAOwLJO8H4IEXRW7gh5b6GOMX4IcsHcVzdWqskJcS9mCGL7TSiwf72lLc9N/M2Hp7ENunvKJU/PHd95C5awtzRRSgWX1aFZ9HDrG/A1D From: Akihiko Odaki Date: Wed, 14 Feb 2024 13:32:05 +0900 Subject: [PATCH v10 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: <20240214-cocoa-v10-5-c7ffe5d9f08a@daynix.com> References: <20240214-cocoa-v10-0-c7ffe5d9f08a@daynix.com> In-Reply-To: <20240214-cocoa-v10-0-c7ffe5d9f08a@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::42a; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x42a.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: 1707885209719100003 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 a1f54b3ebb9a..aeec3c48859c 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -1390,7 +1390,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 10:32:52 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=1707885180; cv=none; d=zohomail.com; s=zohoarc; b=YeZf66BpbLtwQGvFUF90X0Iv0oE7N1bl02C/yRpI6MKlUAT63kH/muvLL7fqGTsHITzURuZEyOzmEbDnU56WxLqjClihD46y4Y+eAA7e2E0d0ictoP76VNsFFFj8tKAmGibjXAwI4yZDA/w+jNK3q/zLfpwaxRvSbcK8fCgjzac= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707885180; 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=UAkgWf/eVOSYqx05p8SSBnT0prb7qhT56AlPFl+HP5E=; b=RmwAAdZEiZJXQLDKgDGUQRos0b+Bd8e7KSyvE1bGvUm4rus4kFyotqxDYsUukzrTac9TI3fDgQ0RcdZ1sdM2uEM6BKZoLlEkhTz9Zz49tWNItDC3OLd/hKPzr00dUuElVmSo1mIKZE41b/iSSlRAtuJt3NJdNDQ2BuT5IcWW1W4= 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 1707885180965566.2949897007085; Tue, 13 Feb 2024 20:33:00 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ra6ww-0002VY-Dw; Tue, 13 Feb 2024 23:32:49 -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 1ra6wu-0002SC-Jp for qemu-devel@nongnu.org; Tue, 13 Feb 2024 23:32:44 -0500 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ra6wt-0006Dj-42 for qemu-devel@nongnu.org; Tue, 13 Feb 2024 23:32:44 -0500 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1db562438e0so2892375ad.3 for ; Tue, 13 Feb 2024 20:32:42 -0800 (PST) Received: from localhost ([2400:4050:a840:1e00:9ac7:6d57:2b16:6932]) by smtp.gmail.com with UTF8SMTPSA id 12-20020a170902e9cc00b001d8dbb867b1sm2822005plk.179.2024.02.13.20.32.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 13 Feb 2024 20:32:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1707885162; x=1708489962; 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=UAkgWf/eVOSYqx05p8SSBnT0prb7qhT56AlPFl+HP5E=; b=uIFrcRnBgQdU3PLp+AgO3HJVYpN1M73SrrV6ddjLEiTK8hVSigCOgSoXdXPaOEPbPh N+0ZJOah3S0SfEh8p/S8sCztUZ4P59C1YEDYt9MNtsINCO0h9oWjRHi6sPBLvMM05rbm MVgGGmaMpCWofdAnWionn9Z9LxsWLZ0alSfxJfuSiTUX1UkB1prTV0SDpU8yxYIMxM38 l8W0VEe1XyPnf7pzNhwGAGoAawB0qctWxDbUao0vXQNIGutRju6S069aTgAhex72CUNe p/gj1ddeFiL0S/DGmWN/tFlmlxQp9lrwSI0sOQDQVdc6WFIsxwEeD9nq6uDriTpQxjJ4 eVfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707885162; x=1708489962; 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=UAkgWf/eVOSYqx05p8SSBnT0prb7qhT56AlPFl+HP5E=; b=TIzI2Ru9hZlzx9KJTjCvnNLn5TXygxKsj0gW0rT1n8L+c6wDxJ94tTDeJt2g3xFW76 i3ns3mcGiIyy3e445GWhfuQbiR4YuZmuI0pNJC20x3YenT3IJHtQ9CH9/dnOX3chee/U 93qPbh5/DtCVKl3N0qvNAftxnGZGDt0h+lXuQOUH0ei3UUrgE1KzQMsVU4XxP+AKiNRT hy9bZj7w1ZDtu9sbrQYaRVKZw8YuSV4AbB6SJ19AUhuZe3VVWHpGMJEsijuJ/4VdHE6e NEPjFNsAgGgOoxLUzgi6nFkQPFsWzxQgymD/82VYF8B1rszJc2sdpeITkViP1MiDBev5 zYQw== X-Gm-Message-State: AOJu0YxYHiRAp2TvGrUsGAA3CfhoEYqUDey5rUeS6rCESdnlW/9vDXEX 2LEPZPSdo6BB9ECMd8ClNk1rv5fN9WHO5Xbcd9v4vmgqg/4IBQKd4ZbJPwd/uKg= X-Google-Smtp-Source: AGHT+IFzN09qvkWQ0Vecodybx2TkKMWaTxBDpIOYoQPOBgFfN5ztyB+bgccq65GXVnHY17MaBbRXGw== X-Received: by 2002:a17:903:1246:b0:1db:33bb:1757 with SMTP id u6-20020a170903124600b001db33bb1757mr1675408plh.57.1707885161949; Tue, 13 Feb 2024 20:32:41 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXBKKT0H/bPuudypMdFR7c4AHMg4qtUe9bSLb33mlaJJTUj0PpkVXqKGwEqTbRehA7yccJJMJMsIdf8UtjBWZKB2FZDwjYgG/0xtZF7WqyS5Pppt52a8Xv5/UnpX+O2NNxKcn2V7mzUUcDgn4NwfYKbIL0eO6b0lIOTvd7sk7/RF5OUzuE7tcDzmFRt2NDyV9cYBFuyuk5i+sZ82cVu/5d/i5UENFUb1XMLD6AlreM/Ll9pyMt7ki5aWRnBMih2ZlAwKlrR9oxq50e1 From: Akihiko Odaki Date: Wed, 14 Feb 2024 13:32:06 +0900 Subject: [PATCH v10 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: <20240214-cocoa-v10-6-c7ffe5d9f08a@daynix.com> References: <20240214-cocoa-v10-0-c7ffe5d9f08a@daynix.com> In-Reply-To: <20240214-cocoa-v10-0-c7ffe5d9f08a@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::62b; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x62b.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: 1707885181750100001 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 aeec3c48859c..0ed40cd97d28 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) { @@ -1295,7 +1294,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 @@ -1376,8 +1375,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 { @@ -1649,7 +1647,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]; @@ -2035,7 +2033,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