NSWindow *normalWindow;
id cocoaView;
static DisplayChangeListener *dcl;
+static int last_vm_running;
int gArgc;
char **gArgv;
- (float) cdx;
- (float) cdy;
- (QEMUScreen) gscreen;
+- (void) updateCaption;
@end
@implementation QemuCocoaView
0, //interpolate
kCGRenderingIntentDefault //intent
);
-
// test if host support "CGImageCreateWithImageInRect" at compiletime
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4)
if (CGImageCreateWithImageInRect == NULL) { // test if "CGImageCreateWithImageInRect" is supported on host at runtime
} else {
// selective drawing code (draws only dirty rectangles) (OS X >= 10.4)
const NSRect *rectList;
- int rectCount;
+ NSInteger rectCount;
int i;
CGImageRef clipImageRef;
CGRect clipRect;
clipRect.origin.y = (float)screen.height - (rectList[i].origin.y + rectList[i].size.height) / cdy;
clipRect.size.width = rectList[i].size.width / cdx;
clipRect.size.height = rectList[i].size.height / cdy;
- clipImageRef = CGImageCreateWithImageInRect(imageRef, clipRect);
- CGContextDrawImage(viewContextRef, cgrect(rectList[i]), clipImageRef);
- CGImageRelease(clipImageRef);
+ clipImageRef = CGImageCreateWithImageInRect(
+ imageRef,
+ clipRect
+ );
+ CGContextDrawImage (viewContextRef, cgrect(rectList[i]), clipImageRef);
+ CGImageRelease (clipImageRef);
}
}
#endif
[[fullScreenWindow contentView] setFrame:[[NSScreen mainScreen] frame]];
[normalWindow setFrame:NSMakeRect([normalWindow frame].origin.x, [normalWindow frame].origin.y - h + screen.height, w, h + [normalWindow frame].size.height - screen.height) display:NO animate:NO];
} else {
- if (qemu_name)
- [normalWindow setTitle:[NSString stringWithFormat:@"QEMU %s", qemu_name]];
[normalWindow setFrame:NSMakeRect([normalWindow frame].origin.x, [normalWindow frame].origin.y - h + screen.height, w, h + [normalWindow frame].size.height - screen.height) display:YES animate:NO];
}
+ [self updateCaption];
screen.width = w;
screen.height = h;
[normalWindow center];
- (void) grabMouse
{
COCOA_DEBUG("QemuCocoaView: grabMouse\n");
-
- if (!isFullscreen) {
- if (qemu_name)
- [normalWindow setTitle:[NSString stringWithFormat:@"QEMU %s - (Press ctrl + alt to release Mouse)", qemu_name]];
- else
- [normalWindow setTitle:@"QEMU - (Press ctrl + alt to release Mouse)"];
- }
if (cursor_hide) [NSCursor hide];
CGAssociateMouseAndMouseCursorPosition(FALSE);
isMouseGrabed = TRUE; // while isMouseGrabed = TRUE, QemuCocoaApp sends all events to [cocoaView handleEvent:]
+ [self updateCaption];
}
- (void) ungrabMouse
{
COCOA_DEBUG("QemuCocoaView: ungrabMouse\n");
- if (!isFullscreen) {
- if (qemu_name)
- [normalWindow setTitle:[NSString stringWithFormat:@"QEMU %s", qemu_name]];
- else
- [normalWindow setTitle:@"QEMU"];
- }
if (cursor_hide) [NSCursor unhide];
CGAssociateMouseAndMouseCursorPosition(TRUE);
isMouseGrabed = FALSE;
+ [self updateCaption];
+}
+
+- (void) updateCaption
+{
+ //if (!isFullScreen)...
+ NSMutableString *caption = [NSMutableString stringWithCapacity:10];
+ [caption appendFormat:@"QEMU"];
+ if (qemu_name)
+ [caption appendFormat:@" (%s)", qemu_name];
+ if (!vm_running)
+ [caption appendString:@" [Stopped]"];
+ else if (isMouseGrabed)
+ [caption appendString:@" - Press Ctrl-Alt to release mouse"];
+ [normalWindow setTitle:caption];
}
- (void) setAbsoluteEnabled:(BOOL)tIsAbsoluteEnabled {isAbsoluteEnabled = tIsAbsoluteEnabled;}
[normalWindow setContentView:cocoaView];
[normalWindow makeKeyAndOrderFront:self];
[normalWindow center];
-
+ [cocoaView updateCaption];
}
return self;
}
}
+
#pragma mark qemu
static void cocoa_update(DisplayState *ds, int x, int y, int w, int h)
{
{
COCOA_DEBUG("qemu_cocoa: cocoa_refresh\n");
+ if (last_vm_running != vm_running) {
+ last_vm_running = vm_running;
+ [cocoaView updateCaption];
+ }
+
if (kbd_mouse_is_absolute()) {
if (![cocoaView isAbsoluteEnabled]) {
if ([cocoaView isMouseGrabed]) {