From patchwork Fri Jun 19 10:30:35 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 50073 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1AFFF22904 for ; Fri, 19 Jun 2015 10:31:52 +0000 (UTC) Received: by lbcak1 with SMTP id ak1sf27298480lbc.2 for ; Fri, 19 Jun 2015 03:31:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:in-reply-to:references:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=w6irA2NfWAuvvg32s/oCxz0a/VUjf0YTgSUupi1r27I=; b=SV4csdGEGM3glBfQ/knj5+DeDDcbk367NNI+Kk37CwLxlG59MZEUPleFJO6bk6aoNM 2CbDvdWkPu58/eYtmzr2kjS+orBIiD/h+pjX2MAYWLVCYlZHdnN8wDmLhGPeO/xxaB24 VvusKUpXc98PZn5D8VQIZ7aVMjIQSFYWlop+/5kQF02dR1nbd0a3MSrrk8Q8a4su0X7g 4KZuYVxzNHJIiek9Yd92ny6K+sxwDSiaj7eGiPF10Bz20opRfbHudvoibBUp/SAKY/2r BxJNLkU2QqLtn+0t/T8LMWK3eb+DvKT0cn1k3inv1QoAIHHcNmXURhc7JM8jpGaof6bC gJCQ== X-Gm-Message-State: ALoCoQk2FeGigQ5JkVxvq//nEeUGrNkVcoceqgeiOTfp06LnFpkzRYNfdHFqAVpPp5bRKTHUwkSL X-Received: by 10.180.105.226 with SMTP id gp2mr2691279wib.1.1434709911066; Fri, 19 Jun 2015 03:31:51 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.206.36 with SMTP id ll4ls557733lac.36.gmail; Fri, 19 Jun 2015 03:31:50 -0700 (PDT) X-Received: by 10.112.63.201 with SMTP id i9mr16919516lbs.93.1434709910904; Fri, 19 Jun 2015 03:31:50 -0700 (PDT) Received: from mail-lb0-f181.google.com (mail-lb0-f181.google.com. [209.85.217.181]) by mx.google.com with ESMTPS id is4si8807198lac.103.2015.06.19.03.31.50 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Jun 2015 03:31:50 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.181 as permitted sender) client-ip=209.85.217.181; Received: by lbbwc1 with SMTP id wc1so69553306lbb.2 for ; Fri, 19 Jun 2015 03:31:50 -0700 (PDT) X-Received: by 10.112.93.37 with SMTP id cr5mr17359667lbb.106.1434709910807; Fri, 19 Jun 2015 03:31:50 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp479582lbb; Fri, 19 Jun 2015 03:31:49 -0700 (PDT) X-Received: by 10.55.25.207 with SMTP id 76mr33065235qkz.82.1434709908531; Fri, 19 Jun 2015 03:31:48 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id o3si10478215qcj.22.2015.06.19.03.31.47 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 19 Jun 2015 03:31:48 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:57345 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z5taN-00025d-N6 for patch@linaro.org; Fri, 19 Jun 2015 06:31:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58507) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z5tZP-00011b-Ma for qemu-devel@nongnu.org; Fri, 19 Jun 2015 06:30:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z5tZO-0007LM-2q for qemu-devel@nongnu.org; Fri, 19 Jun 2015 06:30:47 -0400 Received: from mnementh.archaic.org.uk ([2001:8b0:1d0::1]:34488) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z5tZN-00074r-R5 for qemu-devel@nongnu.org; Fri, 19 Jun 2015 06:30:45 -0400 Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1Z5tZF-0006QM-Vn for qemu-devel@nongnu.org; Fri, 19 Jun 2015 11:30:37 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 19 Jun 2015 11:30:35 +0100 Message-Id: <1434709837-24665-2-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1434709837-24665-1-git-send-email-peter.maydell@linaro.org> References: <1434709837-24665-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:8b0:1d0::1 Subject: [Qemu-devel] [PULL 1/3] ui/cocoa.m: Add 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.181 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: John Arbuckle 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 Message-id: 6D7AE6AA-0595-4FAD-AACF-9DFAB87248F0@gmail.com Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- ui/cocoa.m | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) 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