From 477a3877fdc3125f309133ce511236f39f58c16e Mon Sep 17 00:00:00 2001 From: Henry Harrington Date: Tue, 27 Nov 2012 08:59:41 +0000 Subject: [PATCH 1/2] cocoa: Fix VBE function Set Display Start MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Register a dpy_gfx_setdata callback so that the Cocoa code is notified whenever the screen start address changes. Commit 1d3323d has a similar fix for the VNC UI. Signed-off-by: Henry Harrington Cc: qemu-stable@nongnu.org (1.3.x) Signed-off-by: Andreas Färber --- ui/cocoa.m | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/ui/cocoa.m b/ui/cocoa.m index 3bf1c6e890..fbd7386295 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -265,6 +265,7 @@ static int cocoa_keycode_to_qemu(int keycode) BOOL isTabletEnabled; } - (void) resizeContentToWidth:(int)w height:(int)h displayState:(DisplayState *)ds; +- (void) updateDataOffset:(DisplayState *)ds; - (void) grabMouse; - (void) ungrabMouse; - (void) toggleFullScreen:(id)sender; @@ -429,6 +430,20 @@ QemuCocoaView *cocoaView; [self setFrame:NSMakeRect(cx, cy, cw, ch)]; } +- (void) updateDataOffset:(DisplayState *)ds +{ + COCOA_DEBUG("QemuCocoaView: UpdateDataOffset\n"); + + // update screenBuffer + if (dataProviderRef) { + CGDataProviderRelease(dataProviderRef); + } + + size_t size = ds_get_width(ds) * 4 * ds_get_height(ds); + dataProviderRef = CGDataProviderCreateWithData(NULL, ds_get_data(ds), + size, NULL); +} + - (void) toggleFullScreen:(id)sender { COCOA_DEBUG("QemuCocoaView: toggleFullScreen\n"); @@ -1004,6 +1019,11 @@ static void cocoa_refresh(DisplayState *ds) vga_hw_update(); } +static void cocoa_setdata(DisplayState *ds) +{ + [cocoaView updateDataOffset:ds]; +} + static void cocoa_cleanup(void) { COCOA_DEBUG("qemu_cocoa: cocoa_cleanup\n"); @@ -1020,6 +1040,7 @@ void cocoa_display_init(DisplayState *ds, int full_screen) dcl->dpy_gfx_update = cocoa_update; dcl->dpy_gfx_resize = cocoa_resize; dcl->dpy_refresh = cocoa_refresh; + dcl->dpy_gfx_setdata = cocoa_setdata; register_displaychangelistener(ds, dcl); From 7e02dc63b8f16372107434d44269e21cdff5d19d Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Wed, 16 Jan 2013 07:38:40 +0000 Subject: [PATCH 2/2] cocoa: Replace non-portable asprintf() by g_strdup_printf() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stefan Weil Signed-off-by: Andreas Färber --- ui/cocoa.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index fbd7386295..ca42413b34 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -828,9 +828,9 @@ QemuCocoaView *cocoaView; [sheet close]; - asprintf(&argv[0], "%s", bin); - asprintf(&argv[1], "-hda"); - asprintf(&argv[2], "%s", img); + argv[0] = g_strdup_printf("%s", bin); + argv[1] = g_strdup_printf("-hda"); + argv[2] = g_strdup_printf("%s", img); printf("Using argc %d argv %s -hda %s\n", 3, bin, img);