From: Akihiko Odaki <akihiko.odaki@daynix.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: "Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Gerd Hoffmann" <kraxel@redhat.com>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
qemu-devel@nongnu.org
Subject: Re: [PATCH 1/3] ui/cocoa: Fix aspect ratio
Date: Fri, 22 Mar 2024 21:25:49 +0900 [thread overview]
Message-ID: <805177eb-7cd4-463c-9d01-c955d6b91cf8@daynix.com> (raw)
In-Reply-To: <CAFEAcA80J1zDs1odrHmJGm0sjcg1O_rS0N3su4Gvq+NNLpaUXQ@mail.gmail.com>
On 2024/03/22 21:22, Peter Maydell wrote:
> On Mon, 18 Mar 2024 at 07:53, Akihiko Odaki <akihiko.odaki@daynix.com> wrote:
>>
>> [NSWindow setContentAspectRatio:] does not trigger window resize itself,
>> so the wrong aspect ratio will persist if nothing resizes the window.
>> Call [NSWindow setContentSize:] in such a case.
>>
>> Fixes: 91aa508d0274 ("ui/cocoa: Let the platform toggle fullscreen")
>> Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
>> ---
>> ui/cocoa.m | 23 ++++++++++++++++++++++-
>> 1 file changed, 22 insertions(+), 1 deletion(-)
>>
>> diff --git a/ui/cocoa.m b/ui/cocoa.m
>> index fa879d7dcd4b..d6a5b462f78b 100644
>> --- a/ui/cocoa.m
>> +++ b/ui/cocoa.m
>> @@ -508,6 +508,25 @@ - (void) drawRect:(NSRect) rect
>> }
>> }
>>
>> +- (NSSize)fixAspectRatio:(NSSize)original
>> +{
>> + NSSize scaled;
>> + NSSize fixed;
>> +
>> + scaled.width = screen.width * original.height;
>> + scaled.height = screen.height * original.width;
>> +
>> + if (scaled.width < scaled.height) {
>
> Is this a standard algorithm for scaling with a fixed
> aspect ratio? It looks rather weird to be comparing
> a width against a height here, and to be multiplying a
> width by a height.
Not sure if it's a standard, but it's an algorithm with least error I
came up with.
Regards,
Akihiko Odaki
>
>> + fixed.width = scaled.width / screen.height;
>> + fixed.height = original.height;
>> + } else {
>> + fixed.width = original.width;
>> + fixed.height = scaled.height / screen.width;
>> + }
>> +
>> + return fixed;
>> +}
>> +
>
> thanks
> -- PMM
next prev parent reply other threads:[~2024-03-22 12:35 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-18 7:52 [PATCH 0/3] Fixes for "ui/cocoa: Let the platform toggle fullscreen" Akihiko Odaki
2024-03-18 7:53 ` [PATCH 1/3] ui/cocoa: Fix aspect ratio Akihiko Odaki
2024-03-22 12:22 ` Peter Maydell
2024-03-22 12:25 ` Akihiko Odaki [this message]
2024-03-22 12:55 ` Peter Maydell
2024-03-23 6:29 ` Akihiko Odaki
2024-03-18 7:53 ` [PATCH 2/3] ui/cocoa: Resize window after toggling zoom-to-fit Akihiko Odaki
2024-03-22 12:23 ` Peter Maydell
2024-03-18 7:53 ` [PATCH 3/3] ui/cocoa: Use NSTrackingInVisibleRect Akihiko Odaki
2024-03-22 12:28 ` Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=805177eb-7cd4-463c-9d01-c955d6b91cf8@daynix.com \
--to=akihiko.odaki@daynix.com \
--cc=kraxel@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).