diff -r 51cf78066aca cocoa.m --- a/cocoa.m Fri Dec 19 10:38:50 2008 +0000 +++ b/cocoa.m Fri Dec 19 11:22:53 2008 +0000 @@ -58,6 +58,7 @@ NSWindow *normalWindow; id cocoaView; static void *screenBuffer; +static DisplayChangeListener *dcl; int gArgc; char **gArgv; @@ -316,18 +317,13 @@ // draw screen bitmap directly to Core Graphics context if (dataProviderRef) { CGImageRef imageRef = CGImageCreate( - screen.width, //width - screen.height, //height - screen.bitsPerComponent, //bitsPerComponent - screen.bitsPerPixel, //bitsPerPixel - (screen.width * 4), //bytesPerRow -#if __LITTLE_ENDIAN__ - CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB), //colorspace for OS X >= 10.4 - kCGImageAlphaNoneSkipLast, -#else + ds_get_width(ds), //width + ds_get_height(ds), //height + 8, //bitsPerComponent + ds_get_bits_per_pixel(ds), //bitsPerPixel + ds_get_linesize(ds), //bytesPerRow CGColorSpaceCreateDeviceRGB(), //colorspace for OS X < 10.4 (actually ppc) kCGImageAlphaNoneSkipFirst, //bitmapInfo -#endif dataProviderRef, //provider NULL, //decode 0, //interpolate @@ -397,20 +393,8 @@ CGDataProviderRelease(dataProviderRef); if (screenBuffer) free(screenBuffer); - screenBuffer = malloc( w * 4 * h ); - ds->data = screenBuffer; - ds->linesize = (w * 4); - ds->depth = 32; - ds->width = w; - ds->height = h; -#ifdef __LITTLE_ENDIAN__ - ds->bgr = 1; -#else - ds->bgr = 0; -#endif - - dataProviderRef = CGDataProviderCreateWithData(NULL, screenBuffer, w * 4 * h, NULL); + dataProviderRef = CGDataProviderCreateWithData(NULL, ds->data, ds_get_linesize(ds) * ds_get_height(ds), NULL); // update windows if (isFullscreen) { @@ -939,11 +923,11 @@ [cocoaView displayRect:rect]; } -static void cocoa_resize(DisplayState *ds, int w, int h) +static void cocoa_resize(DisplayState *ds) { COCOA_DEBUG("qemu_cocoa: cocoa_resize\n"); - [cocoaView resizeContentToWidth:w height:h displayState:ds]; + [cocoaView resizeContentToWidth:ds_get_width(ds) height:ds_get_height(ds) displayState:ds]; } static void cocoa_refresh(DisplayState *ds) @@ -983,12 +967,13 @@ COCOA_DEBUG("qemu_cocoa: cocoa_display_init\n"); // register vga outpu callbacks - ds->dpy_update = cocoa_update; - ds->dpy_resize = cocoa_resize; - ds->dpy_refresh = cocoa_refresh; - - // give window a initial Size - cocoa_resize(ds, 640, 400); + dcl = qemu_mallocz(sizeof(DisplayChangeListener)); + if (!dcl) + exit(1); + dcl->dpy_update = cocoa_update; + dcl->dpy_resize = cocoa_resize; + dcl->dpy_refresh = cocoa_refresh; + register_displaychangelistener(ds, dcl); // register cleanup function atexit(cocoa_cleanup);