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] ui/cocoa: Do not automatically zoom for HiDPI
Date: Sat, 20 Jul 2024 16:37:09 +0900 [thread overview]
Message-ID: <ff50879f-fca2-4658-bea5-fce60e396ad1@daynix.com> (raw)
In-Reply-To: <CAFEAcA_i3Os6YPwxx99sWvK5qdzopMGBZgvVKJ7qX-waCc7RnQ@mail.gmail.com>
On 2024/03/22 22:06, Peter Maydell wrote:
> On Mon, 18 Mar 2024 at 09:02, Akihiko Odaki <akihiko.odaki@daynix.com> wrote:
>>
>> Cocoa automatically zooms for a HiDPI display like Retina and makes
>> the display blurry. Revert the automatic zooming.
>>
>> Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
>> ---
>> ui/cocoa.m | 9 ++++++---
>> 1 file changed, 6 insertions(+), 3 deletions(-)
>>
>> diff --git a/ui/cocoa.m b/ui/cocoa.m
>> index fa879d7dcd4b..c5b3c28000ff 100644
>> --- a/ui/cocoa.m
>> +++ b/ui/cocoa.m
>> @@ -522,7 +522,10 @@ - (void) resizeWindow
>> [[self window] setContentAspectRatio:NSMakeSize(screen.width, screen.height)];
>>
>> if (!([[self window] styleMask] & NSWindowStyleMaskResizable)) {
>> - [[self window] setContentSize:NSMakeSize(screen.width, screen.height)];
>> + CGFloat width = screen.width / [[self window] backingScaleFactor];
>> + CGFloat height = screen.height / [[self window] backingScaleFactor];
>> +
>> + [[self window] setContentSize:NSMakeSize(width, height)];
>> [[self window] center];
>> } else if ([[self window] styleMask] & NSWindowStyleMaskFullScreen) {
>> [[self window] setContentSize:[self screenSafeAreaSize]];
>> @@ -575,8 +578,8 @@ - (void) updateUIInfoLocked
>>
>> info.xoff = 0;
>> info.yoff = 0;
>> - info.width = frameSize.width;
>> - info.height = frameSize.height;
>> + info.width = frameSize.width * [[self window] backingScaleFactor];
>> + info.height = frameSize.height * [[self window] backingScaleFactor];
>>
>> dpy_set_ui_info(dcl.con, &info, TRUE);
>> }
>
> Could we / should we use convertRectToBacking and convertRectFromBacking
> rather than doing the multiply/divide ourselves? The docs seem to
> recommend against directly using backingScaleFactor when possible.
Sorry, I forgot to reply this.
Unfortunately, Cocoa does not provide a method to scale NSSize while
convertRectToBacking and convertRectFromBacking work with NSRect, which
is the reason why I opted for manual scaling here.
Regards,
Akihiko Odaki
next prev parent reply other threads:[~2024-07-20 7:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-18 9:02 [PATCH] ui/cocoa: Do not automatically zoom for HiDPI Akihiko Odaki
2024-03-22 13:06 ` Peter Maydell
2024-07-20 7:37 ` Akihiko Odaki [this message]
2025-01-11 6:01 ` Akihiko Odaki
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=ff50879f-fca2-4658-bea5-fce60e396ad1@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).