qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/1] ui/cocoa: add zoom-to-fit display option
@ 2023-10-27 15:49 carwynellis
  2023-10-27 15:49 ` [PATCH v3 1/1] " carwynellis
  0 siblings, 1 reply; 3+ messages in thread
From: carwynellis @ 2023-10-27 15:49 UTC (permalink / raw)
  To: qemu-devel
  Cc: peter.maydell, philmd, akihiko.odaki, kraxel, marcandre.lureau,
	Carwyn Ellis

From: Carwyn Ellis <carwynellis@gmail.com>

The intention here is to allow fullscreen scaling of the display to be
enabled by setting the display option `zoom-to-fit` to on, allowing this
to be set from the command line without having to interact with the ui
menu.

Includes changes requested by Akihiko Odaki.

Signed-off-by: Carwyn Ellis <carwynellis@gmail.com>

Carwyn Ellis (1):
  ui/cocoa: add zoom-to-fit display option

 qapi/ui.json |  7 ++++++-
 ui/cocoa.m   | 32 ++++++++++++++++++--------------
 2 files changed, 24 insertions(+), 15 deletions(-)

-- 
2.42.0



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

* [PATCH v3 1/1] ui/cocoa: add zoom-to-fit display option
  2023-10-27 15:49 [PATCH v3 0/1] ui/cocoa: add zoom-to-fit display option carwynellis
@ 2023-10-27 15:49 ` carwynellis
  2023-10-27 16:13   ` Akihiko Odaki
  0 siblings, 1 reply; 3+ messages in thread
From: carwynellis @ 2023-10-27 15:49 UTC (permalink / raw)
  To: qemu-devel
  Cc: peter.maydell, philmd, akihiko.odaki, kraxel, marcandre.lureau,
	Carwyn Ellis

From: Carwyn Ellis <carwynellis@gmail.com>

Provides a display option, zoom-to-fit, that enables scaling of the
display when full-screen mode is enabled.

Also ensures that the corresponding menu item is marked as enabled when
the option is set to on.

Signed-off-by: Carwyn Ellis <carwynellis@gmail.com>
---
 qapi/ui.json |  7 ++++++-
 ui/cocoa.m   | 32 ++++++++++++++++++--------------
 2 files changed, 24 insertions(+), 15 deletions(-)

diff --git a/qapi/ui.json b/qapi/ui.json
index 006616aa77..3718d40fcf 100644
--- a/qapi/ui.json
+++ b/qapi/ui.json
@@ -1409,13 +1409,18 @@
 #     codes match their position on non-Mac keyboards and you can use
 #     Meta/Super and Alt where you expect them.  (default: off)
 #
+# @zoom-to-fit: Zoom guest display to fit into the host window. When
+#     turned off the host window will be resized instead. Defaults to
+#     "off". (Since 8.2)
+#
 # Since: 7.0
 ##
 { 'struct': 'DisplayCocoa',
   'data': {
       '*left-command-key': 'bool',
       '*full-grab': 'bool',
-      '*swap-opt-cmd': 'bool'
+      '*swap-opt-cmd': 'bool',
+      '*zoom-to-fit': 'bool'
   } }
 
 ##
diff --git a/ui/cocoa.m b/ui/cocoa.m
index d95276013c..cd069da696 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -1247,7 +1247,6 @@ - (id) init
         [normalWindow makeKeyAndOrderFront:self];
         [normalWindow center];
         [normalWindow setDelegate: self];
-        stretch_video = false;
 
         /* Used for displaying pause on the screen */
         pauseLabel = [NSTextField new];
@@ -1671,7 +1670,9 @@ static void create_initial_menus(void)
     // View menu
     menu = [[NSMenu alloc] initWithTitle:@"View"];
     [menu addItem: [[[NSMenuItem alloc] initWithTitle:@"Enter Fullscreen" action:@selector(doToggleFullScreen:) keyEquivalent:@"f"] autorelease]]; // Fullscreen
-    [menu addItem: [[[NSMenuItem alloc] initWithTitle:@"Zoom To Fit" action:@selector(zoomToFit:) keyEquivalent:@""] autorelease]];
+    menuItem = [[[NSMenuItem alloc] initWithTitle:@"Zoom To Fit" action:@selector(zoomToFit:) keyEquivalent:@""] autorelease];
+    [menuItem setState: stretch_video ? NSControlStateValueOn : NSControlStateValueOff];
+    [menu addItem: menuItem];
     menuItem = [[[NSMenuItem alloc] initWithTitle:@"View" action:nil keyEquivalent:@""] autorelease];
     [menuItem setSubmenu:menu];
     [[NSApp mainMenu] addItem:menuItem];
@@ -2041,18 +2042,6 @@ static void cocoa_display_init(DisplayState *ds, DisplayOptions *opts)
 
     [QemuApplication sharedApplication];
 
-    create_initial_menus();
-
-    /*
-     * Create the menu entries which depend on QEMU state (for consoles
-     * and removable devices). These make calls back into QEMU functions,
-     * which is OK because at this point we know that the second thread
-     * holds the iothread lock and is synchronously waiting for us to
-     * finish.
-     */
-    add_console_menu_entries();
-    addRemovableDevicesMenuItems();
-
     // Create an Application controller
     QemuCocoaAppController *controller = [[QemuCocoaAppController alloc] init];
     [NSApp setDelegate:controller];
@@ -2077,6 +2066,21 @@ static void cocoa_display_init(DisplayState *ds, DisplayOptions *opts)
         left_command_key_enabled = 0;
     }
 
+    if (opts->u.cocoa.has_zoom_to_fit && opts->u.cocoa.zoom_to_fit) {
+        stretch_video = true;
+    }
+
+    create_initial_menus();
+    /*
+     * Create the menu entries which depend on QEMU state (for consoles
+     * and removable devices). These make calls back into QEMU functions,
+     * which is OK because at this point we know that the second thread
+     * holds the iothread lock and is synchronously waiting for us to
+     * finish.
+     */
+    add_console_menu_entries();
+    addRemovableDevicesMenuItems();
+
     // register vga output callbacks
     register_displaychangelistener(&dcl);
 
-- 
2.42.0



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

* Re: [PATCH v3 1/1] ui/cocoa: add zoom-to-fit display option
  2023-10-27 15:49 ` [PATCH v3 1/1] " carwynellis
@ 2023-10-27 16:13   ` Akihiko Odaki
  0 siblings, 0 replies; 3+ messages in thread
From: Akihiko Odaki @ 2023-10-27 16:13 UTC (permalink / raw)
  To: carwynellis, qemu-devel; +Cc: peter.maydell, philmd, kraxel, marcandre.lureau

On 2023/10/28 0:49, carwynellis@gmail.com wrote:
> From: Carwyn Ellis <carwynellis@gmail.com>
> 
> Provides a display option, zoom-to-fit, that enables scaling of the
> display when full-screen mode is enabled.
> 
> Also ensures that the corresponding menu item is marked as enabled when
> the option is set to on.
> 
> Signed-off-by: Carwyn Ellis <carwynellis@gmail.com>

Thank you for contribution.

Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com>


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

end of thread, other threads:[~2023-10-27 16:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-27 15:49 [PATCH v3 0/1] ui/cocoa: add zoom-to-fit display option carwynellis
2023-10-27 15:49 ` [PATCH v3 1/1] " carwynellis
2023-10-27 16:13   ` 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).