From patchwork Mon May 18 03:51:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Programmingkid X-Patchwork-Id: 473250 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 76D1C14029C for ; Mon, 18 May 2015 13:51:44 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=rcAeDTbc; dkim-atps=neutral Received: from localhost ([::1]:39063 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YuC5e-0001Kc-IG for incoming@patchwork.ozlabs.org; Sun, 17 May 2015 23:51:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60895) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YuC5P-00012i-JP for qemu-devel@nongnu.org; Sun, 17 May 2015 23:51:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YuC5M-0000Ne-CP for qemu-devel@nongnu.org; Sun, 17 May 2015 23:51:27 -0400 Received: from mail-qk0-x22c.google.com ([2607:f8b0:400d:c09::22c]:36499) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YuC5L-0000NU-VM for qemu-devel@nongnu.org; Sun, 17 May 2015 23:51:24 -0400 Received: by qkgw4 with SMTP id w4so62017196qkg.3 for ; Sun, 17 May 2015 20:51:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:content-type:content-transfer-encoding:subject:date:message-id :cc:to:mime-version; bh=4j2sUrtT/TmRPLBbZsGt5TE0pu5L7N5D2V+N925NxFI=; b=rcAeDTbcqAEA4AioqFcRX7fF8tbJlmNkvg4zszhT4V/RqgW4JPMrFiJDhCRwWRYSan 3uGisdA8M/ExiHVYX+C+5Uzj9AlxahpHany9Fo3Qi65L5tDE+k7IDddL0KF1W2mXc6Nl Y/OqALkPZ8EAQSXIIfOM4Ee92z1oxnFg7GtUjXA2+nQNwqyeYQyQA38jJnN+30lAAg1n 3DQZk83u2ABcEdrryVXvJPL3oynDnWWXYbkXbWKTBbg6V+IHGdLmStDE2HMyNa1gI8H4 Qau20TRfU8xXxJkTgMiFN0K5YaikrgQE3kM8WXcNM6O3l33X1ifuqNlpH+ea/gfTP1t8 2LlQ== X-Received: by 10.140.93.1 with SMTP id c1mr17600428qge.72.1431921083470; Sun, 17 May 2015 20:51:23 -0700 (PDT) Received: from [192.168.0.3] (d199-74-164-53.col.wideopenwest.com. [74.199.53.164]) by mx.google.com with ESMTPSA id z21sm6306415qge.18.2015.05.17.20.51.22 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 17 May 2015 20:51:22 -0700 (PDT) From: Programmingkid Date: Sun, 17 May 2015 23:51:21 -0400 Message-Id: <6D7AE6AA-0595-4FAD-AACF-9DFAB87248F0@gmail.com> To: Peter Maydell Mime-Version: 1.0 (Apple Message framework v1084) X-Mailer: Apple Mail (2.1084) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400d:c09::22c Cc: qemu-devel qemu-devel Subject: [Qemu-devel] [PATCH v4] ui/cocoa.m: adds Machine menu with pause and resume menu items X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- Disable the Resume menu item initially. ui/cocoa.m | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 67 insertions(+), 0 deletions(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index 85cb24c..d28140b 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" #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; // keymap conversion int keymap[] = @@ -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 = false; + + /* Used for displaying pause on the screen */ + pauseLabel = [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 = ([normalWindow frame].size.width - [pauseLabel frame].size.width)/2; + yCoord = [normalWindow frame].size.height - [pauseLabel frame].size.height - ([pauseLabel frame].size.height * .5); + width = [pauseLabel frame].size.width; + height = [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 @@ -1036,6 +1092,17 @@ 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 = [[NSMenu alloc] initWithTitle: @"Machine"]; + [menu setAutoenablesItems: NO]; + [menu addItem: [[[NSMenuItem alloc] initWithTitle: @"Pause" action: @selector(pauseQEMU:) keyEquivalent: @""] autorelease]]; + menuItem = [[[NSMenuItem alloc] initWithTitle: @"Resume" action: @selector(resumeQEMU:) keyEquivalent: @""] autorelease]; + [menu addItem: menuItem]; + [menuItem setEnabled: NO]; + menuItem = [[[NSMenuItem alloc] initWithTitle: @"Machine" action:nil keyEquivalent:@""] autorelease]; + [menuItem setSubmenu:menu]; + [[NSApp mainMenu] addItem:menuItem]; + // View menu menu = [[NSMenu alloc] initWithTitle:@"View"]; [menu addItem: [[[NSMenuItem alloc] initWithTitle:@"Enter Fullscreen" action:@selector(doToggleFullScreen:) keyEquivalent:@"f"] autorelease]]; // Fullscreen