From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44145) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yu5Di-0008Bp-0a for qemu-devel@nongnu.org; Sun, 17 May 2015 16:31:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yu5De-00027X-NY for qemu-devel@nongnu.org; Sun, 17 May 2015 16:31:33 -0400 Received: from mail-qg0-x236.google.com ([2607:f8b0:400d:c04::236]:34789) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yu5De-00027T-Fd for qemu-devel@nongnu.org; Sun, 17 May 2015 16:31:30 -0400 Received: by qgfa7 with SMTP id a7so26605475qgf.1 for ; Sun, 17 May 2015 13:31:30 -0700 (PDT) From: Programmingkid Content-Type: multipart/alternative; boundary=Apple-Mail-1-468431811 Date: Sun, 17 May 2015 16:31:21 -0400 Message-Id: <110BA5BE-68F6-40B5-BA28-C8C37AB6C9BC@gmail.com> Mime-Version: 1.0 (Apple Message framework v1084) Subject: [Qemu-devel] [PATCH v3] ui/cocoa.m: adds Machine menu with pause and resume menu items List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: qemu-devel qemu-devel --Apple-Mail-1-468431811 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Add Machine menu to the Macintosh interface with pause and resume menu items. These items can either pause or resume execution of the guest operating system. Signed-off-by: John Arbuckle --- Remove createMachineMenu() function. Minor space issues fixed. Patch created on top of cocoa.next branch. Machine menu created with other menus. ui/cocoa.m | 65 = ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 65 insertions(+), 0 deletions(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index 85cb24c..2c59d57 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -29,6 +29,7 @@ #include "ui/console.h" #include "ui/input.h" #include "sysemu/sysemu.h" +#include "qmp-commands.h" =20 #ifndef MAC_OS_X_VERSION_10_5 #define MAC_OS_X_VERSION_10_5 1050 @@ -65,6 +66,7 @@ static int last_buttons; int gArgc; char **gArgv; bool stretch_video; +NSTextField *pauseLabel; =20 // keymap conversion int keymap[] =3D @@ -800,6 +802,10 @@ QemuCocoaView *cocoaView; - (void)showQEMUTec:(id)sender; - (void)zoomToFit:(id) sender; - (void)displayConsole:(id)sender; +- (void)pauseQEMU:(id)sender; +- (void)resumeQEMU:(id)sender; +- (void)displayPause; +- (void)removePause; @end =20 @implementation QemuCocoaAppController @@ -834,6 +840,18 @@ QemuCocoaView *cocoaView; [normalWindow makeKeyAndOrderFront:self]; [normalWindow center]; stretch_video =3D false; + + /* Used for displaying pause on the screen */ + pauseLabel =3D [NSTextField new]; + [pauseLabel setBezeled:YES]; + [pauseLabel setDrawsBackground:YES]; + [pauseLabel setBackgroundColor: [NSColor whiteColor]]; + [pauseLabel setEditable:NO]; + [pauseLabel setSelectable:NO]; + [pauseLabel setStringValue: @"Paused"]; + [pauseLabel setFont: [NSFont fontWithName: @"Helvetica" size: = 90]]; + [pauseLabel setTextColor: [NSColor blackColor]]; + [pauseLabel sizeToFit]; } return self; } @@ -977,6 +995,44 @@ QemuCocoaView *cocoaView; { console_select([sender tag]); } + +/* Pause the guest */ +- (void)pauseQEMU:(id)sender +{ + qmp_stop(NULL); + [sender setEnabled: NO]; + [[[sender menu] itemWithTitle: @"Resume"] setEnabled: YES]; + [self displayPause]; +} + +/* Resume running the guest operating system */ +- (void)resumeQEMU:(id)sender +{ + qmp_cont(NULL); + [sender setEnabled: NO]; + [[[sender menu] itemWithTitle: @"Pause"] setEnabled: YES]; + [self removePause]; +} + +/* Displays the word pause on the screen */ +- (void)displayPause +{ + /* Coordinates have to be calculated each time because the window = can change its size */ + int xCoord, yCoord, width, height; + xCoord =3D ([normalWindow frame].size.width - [pauseLabel = frame].size.width)/2; + yCoord =3D [normalWindow frame].size.height - [pauseLabel = frame].size.height - ([pauseLabel frame].size.height * .5); + width =3D [pauseLabel frame].size.width; + height =3D [pauseLabel frame].size.height; + [pauseLabel setFrame: NSMakeRect(xCoord, yCoord, width, height)]; + [cocoaView addSubview: pauseLabel]; +} + +/* Removes the word pause from the screen */ +- (void)removePause +{ + [pauseLabel removeFromSuperview]; +} + @end =20 =20 @@ -1036,6 +1092,15 @@ int main (int argc, const char * argv[]) { [[NSApp mainMenu] addItem:menuItem]; [NSApp performSelector:@selector(setAppleMenu:) withObject:menu]; = // Workaround (this method is private since 10.4+) =20 + // Machine menu + menu =3D [[NSMenu alloc] initWithTitle: @"Machine"]; + [menu setAutoenablesItems: NO]; + [menu addItem: [[[NSMenuItem alloc] initWithTitle: @"Pause" action: = @selector(pauseQEMU:) keyEquivalent: @""] autorelease]]; + [menu addItem: [[[NSMenuItem alloc] initWithTitle: @"Resume" = action: @selector(resumeQEMU:) keyEquivalent: @""] autorelease]]; + menuItem =3D [[[NSMenuItem alloc] initWithTitle: @"Machine" = action:nil keyEquivalent:@""] autorelease]; + [menuItem setSubmenu:menu]; + [[NSApp mainMenu] addItem:menuItem]; + // View menu menu =3D [[NSMenu alloc] initWithTitle:@"View"]; [menu addItem: [[[NSMenuItem alloc] initWithTitle:@"Enter = Fullscreen" action:@selector(doToggleFullScreen:) keyEquivalent:@"f"] = autorelease]]; // Fullscreen --=20 1.7.5.4 --Apple-Mail-1-468431811 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii
Add = Machine menu to the Macintosh interface with pause
and = resume menu items. These items can either pause or
resume = execution of the guest operating system.
Signed-off-by: John Arbuckle <programmingkidx@gmail.com>= ;

---
Remove createMachineMenu() = function.
Minor space issues fixed.
Patch = created on top of cocoa.next branch.
Machine menu created with other = menus.

 ui/cocoa.m |   65 = ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

diff --git a/ui/cocoa.m = b/ui/cocoa.m
index 85cb24c..2c59d57 100644
--- = a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -29,6 +29,7 @@
 #include "ui/input.h"
+#include "qmp-commands.h"

 

 #define = MAC_OS_X_VERSION_10_5 1050
@@ -65,6 +66,7 @@ static int = last_buttons;
 int gArgc;
 char **gArgv;
+NSTextField *pauseLabel;

 

 int keymap[] =3D
@@ = -800,6 +802,10 @@ QemuCocoaView *cocoaView;
 - = (void)showQEMUTec:(id)sender;
 - (void)zoomToFit:(id) = sender;
 - (void)displayConsole:(id)sender;
+- = (void)pauseQEMU:(id)sender;
+- = (void)resumeQEMU:(id)sender;
+- (void)displayPause;
+- = (void)removePause;
 @end

 

 @implementation = QemuCocoaAppController
@@ -834,6 +840,18 @@ QemuCocoaView = *cocoaView;
         [normalWindow = makeKeyAndOrderFront:self];
         = [normalWindow center];
         stretch_video =3D = false;
+
+        /* Used for displaying = pause on the screen */
+        pauseLabel =3D = [NSTextField new];
+        [pauseLabel = setBezeled:YES];
+        [pauseLabel = setDrawsBackground:YES];
+        = [pauseLabel setBackgroundColor: [NSColor whiteColor]];
+        [pauseLabel setFont: = [NSFont fontWithName: @"Helvetica" size: 90]];
+        [pauseLabel = sizeToFit];
     }
     return = self;
 }
@@ -977,6 +995,44 @@ QemuCocoaView = *cocoaView;
 {
     = console_select([sender tag]);
 }
+
+/* Pause the guest = */
+{
+    = qmp_stop(NULL);
+    [sender setEnabled: NO];
+    [self displayPause];
+
+/* Resume running the guest operating system = */
+{
+    = qmp_cont(NULL);
+    [sender setEnabled: NO];
+    [self removePause];
+
+/* Displays the word pause on the screen = */
+{
+    /* Coordinates = have to be calculated each time because the window can change its size = */
+    yCoord =3D = [normalWindow frame].size.height - [pauseLabel frame].size.height - = ([pauseLabel frame].size.height * .5);
+    width =3D = [pauseLabel frame].size.width;
+    height =3D [pauseLabel = frame].size.height;
+    [pauseLabel setFrame: = NSMakeRect(xCoord, yCoord, width, height)];
+    [cocoaView = addSubview: pauseLabel];
+}
+
+/* Removes the word pause = from the screen */
+- (void)removePause
+{
+
 @end

 

 

@@ -1036,6 +1092,15 @@ int main (int = argc, const char * argv[]) {
     [[NSApp mainMenu] = addItem:menuItem];
     [NSApp = performSelector:@selector(setAppleMenu:) withObject:menu]; // Workaround = (this method is private since 10.4+)

 

+    // Machine = menu
+    menu =3D [[NSMenu alloc] = initWithTitle: @"Machine"];
+    [menu = setAutoenablesItems: NO];
+    [menu addItem: = [[[NSMenuItem alloc] initWithTitle: @"Pause" action: = @selector(pauseQEMU:) keyEquivalent: @""] autorelease]];
+    menuItem =3D [[[NSMenuItem alloc] = initWithTitle: @"Machine" action:nil keyEquivalent:@""] = autorelease];
+    [menuItem = setSubmenu:menu];
+    [[NSApp mainMenu] = addItem:menuItem];
+
     // View menu
     [menu addItem: = [[[NSMenuItem alloc] initWithTitle:@"Enter Fullscreen" = action:@selector(doToggleFullScreen:) keyEquivalent:@"f"] autorelease]]; = // Fullscreen
-- 
1.7.5.4