qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ui/cocoa: Do not automatically zoom for HiDPI
@ 2024-03-18  9:02 Akihiko Odaki
  2024-03-22 13:06 ` Peter Maydell
  2025-01-11  6:01 ` Akihiko Odaki
  0 siblings, 2 replies; 4+ messages in thread
From: Akihiko Odaki @ 2024-03-18  9:02 UTC (permalink / raw)
  To: Peter Maydell, Philippe Mathieu-Daudé, Gerd Hoffmann,
	Marc-André Lureau
  Cc: qemu-devel, Akihiko Odaki

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);
 }

---
base-commit: ba49d760eb04630e7b15f423ebecf6c871b8f77b
change-id: 20240318-zoom-df4d6834e56b

Best regards,
-- 
Akihiko Odaki <akihiko.odaki@daynix.com>



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] ui/cocoa: Do not automatically zoom for HiDPI
  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
  2025-01-11  6:01 ` Akihiko Odaki
  1 sibling, 1 reply; 4+ messages in thread
From: Peter Maydell @ 2024-03-22 13:06 UTC (permalink / raw)
  To: Akihiko Odaki
  Cc: Philippe Mathieu-Daudé, Gerd Hoffmann,
	Marc-André Lureau, qemu-devel

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.

thanks
-- PMM


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ui/cocoa: Do not automatically zoom for HiDPI
  2024-03-22 13:06 ` Peter Maydell
@ 2024-07-20  7:37   ` Akihiko Odaki
  0 siblings, 0 replies; 4+ messages in thread
From: Akihiko Odaki @ 2024-07-20  7:37 UTC (permalink / raw)
  To: Peter Maydell
  Cc: Philippe Mathieu-Daudé, Gerd Hoffmann,
	Marc-André Lureau, qemu-devel

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ui/cocoa: Do not automatically zoom for HiDPI
  2024-03-18  9:02 [PATCH] ui/cocoa: Do not automatically zoom for HiDPI Akihiko Odaki
  2024-03-22 13:06 ` Peter Maydell
@ 2025-01-11  6:01 ` Akihiko Odaki
  1 sibling, 0 replies; 4+ messages in thread
From: Akihiko Odaki @ 2025-01-11  6:01 UTC (permalink / raw)
  To: Peter Maydell, Philippe Mathieu-Daudé, Gerd Hoffmann,
	Marc-André Lureau
  Cc: qemu-devel

Hi,

Can anyone review this change?

Regards,
Akihiko Odaki

On 2024/03/18 18:02, Akihiko Odaki 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);
>   }
> 
> ---
> base-commit: ba49d760eb04630e7b15f423ebecf6c871b8f77b
> change-id: 20240318-zoom-df4d6834e56b
> 
> Best regards,



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-01-11  6:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2025-01-11  6:01 ` Akihiko Odaki

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).