diff -pNur qemu-5.2.0-orig/ui/cocoa.m qemu-5.2.0/ui/cocoa.m
old
|
new
|
QemuCocoaView *cocoaView; |
418 | 418 | COCOA_DEBUG("QemuCocoaView: drawRect\n"); |
419 | 419 | |
420 | 420 | // get CoreGraphic context |
421 | | CGContextRef viewContextRef = [[NSGraphicsContext currentContext] CGContext]; |
| 421 | CGContextRef viewContextRef = [[NSGraphicsContext currentContext] graphicsPort]; |
422 | 422 | |
423 | 423 | CGContextSetInterpolationQuality (viewContextRef, kCGInterpolationNone); |
424 | 424 | CGContextSetShouldAntialias (viewContextRef, NO); |
… |
… |
QemuCocoaView *cocoaView; |
585 | 585 | } else { |
586 | 586 | [NSMenu setMenuBarVisible:NO]; |
587 | 587 | fullScreenWindow = [[NSWindow alloc] initWithContentRect:[[NSScreen mainScreen] frame] |
588 | | styleMask:NSWindowStyleMaskBorderless |
| 588 | styleMask:NSBorderlessWindowMask |
589 | 589 | backing:NSBackingStoreBuffered |
590 | 590 | defer:NO]; |
591 | 591 | [fullScreenWindow setAcceptsMouseMovedEvents: YES]; |
… |
… |
QemuCocoaView *cocoaView; |
620 | 620 | int control_key = 0; |
621 | 621 | |
622 | 622 | // if the control key is down |
623 | | if ([event modifierFlags] & NSEventModifierFlagControl) { |
| 623 | if ([event modifierFlags] & NSControlKeyMask) { |
624 | 624 | control_key = 1; |
625 | 625 | } |
626 | 626 | |
… |
… |
QemuCocoaView *cocoaView; |
706 | 706 | NSPoint p = [self screenLocationOfEvent:event]; |
707 | 707 | |
708 | 708 | switch ([event type]) { |
709 | | case NSEventTypeFlagsChanged: |
| 709 | case NSFlagsChangedMask: |
710 | 710 | if ([event keyCode] == 0) { |
711 | 711 | // When the Cocoa keyCode is zero that means keys should be |
712 | 712 | // synthesized based on the values in in the eventModifiers |
… |
… |
QemuCocoaView *cocoaView; |
715 | 715 | if (qemu_console_is_graphic(NULL)) { |
716 | 716 | NSUInteger modifiers = [event modifierFlags]; |
717 | 717 | |
718 | | if (!!(modifiers & NSEventModifierFlagCapsLock) != !!modifiers_state[Q_KEY_CODE_CAPS_LOCK]) { |
| 718 | if (!!(modifiers & NSAlphaShiftKeyMask) != !!modifiers_state[Q_KEY_CODE_CAPS_LOCK]) { |
719 | 719 | [self toggleStatefulModifier:Q_KEY_CODE_CAPS_LOCK]; |
720 | 720 | } |
721 | | if (!!(modifiers & NSEventModifierFlagShift) != !!modifiers_state[Q_KEY_CODE_SHIFT]) { |
| 721 | if (!!(modifiers & NSShiftKeyMask) != !!modifiers_state[Q_KEY_CODE_SHIFT]) { |
722 | 722 | [self toggleModifier:Q_KEY_CODE_SHIFT]; |
723 | 723 | } |
724 | | if (!!(modifiers & NSEventModifierFlagControl) != !!modifiers_state[Q_KEY_CODE_CTRL]) { |
| 724 | if (!!(modifiers & NSControlKeyMask) != !!modifiers_state[Q_KEY_CODE_CTRL]) { |
725 | 725 | [self toggleModifier:Q_KEY_CODE_CTRL]; |
726 | 726 | } |
727 | | if (!!(modifiers & NSEventModifierFlagOption) != !!modifiers_state[Q_KEY_CODE_ALT]) { |
| 727 | if (!!(modifiers & NSAlternateKeyMask) != !!modifiers_state[Q_KEY_CODE_ALT]) { |
728 | 728 | [self toggleModifier:Q_KEY_CODE_ALT]; |
729 | 729 | } |
730 | | if (!!(modifiers & NSEventModifierFlagCommand) != !!modifiers_state[Q_KEY_CODE_META_L]) { |
| 730 | if (!!(modifiers & NSCommandKeyMask) != !!modifiers_state[Q_KEY_CODE_META_L]) { |
731 | 731 | [self toggleModifier:Q_KEY_CODE_META_L]; |
732 | 732 | } |
733 | 733 | } |
… |
… |
QemuCocoaView *cocoaView; |
756 | 756 | } |
757 | 757 | |
758 | 758 | break; |
759 | | case NSEventTypeKeyDown: |
| 759 | case NSKeyDownMask: |
760 | 760 | keycode = cocoa_keycode_to_qemu([event keyCode]); |
761 | 761 | |
762 | 762 | // forward command key combos to the host UI unless the mouse is grabbed |
763 | | if (!isMouseGrabbed && ([event modifierFlags] & NSEventModifierFlagCommand)) { |
| 763 | if (!isMouseGrabbed && ([event modifierFlags] & NSCommandKeyMask)) { |
764 | 764 | /* |
765 | 765 | * Prevent the command key from being stuck down in the guest |
766 | 766 | * when using Command-F to switch to full screen mode. |
… |
… |
QemuCocoaView *cocoaView; |
774 | 774 | // default |
775 | 775 | |
776 | 776 | // handle control + alt Key Combos (ctrl+alt+[1..9,g] is reserved for QEMU) |
777 | | if (([event modifierFlags] & NSEventModifierFlagControl) && ([event modifierFlags] & NSEventModifierFlagOption)) { |
| 777 | if (([event modifierFlags] & NSControlKeyMask) && ([event modifierFlags] & NSAlternateKeyMask)) { |
778 | 778 | NSString *keychar = [event charactersIgnoringModifiers]; |
779 | 779 | if ([keychar length] == 1) { |
780 | 780 | char key = [keychar characterAtIndex:0]; |
… |
… |
QemuCocoaView *cocoaView; |
799 | 799 | [self handleMonitorInput: event]; |
800 | 800 | } |
801 | 801 | break; |
802 | | case NSEventTypeKeyUp: |
| 802 | case NSKeyUpMask: |
803 | 803 | keycode = cocoa_keycode_to_qemu([event keyCode]); |
804 | 804 | |
805 | 805 | // don't pass the guest a spurious key-up if we treated this |
806 | 806 | // command-key combo as a host UI action |
807 | | if (!isMouseGrabbed && ([event modifierFlags] & NSEventModifierFlagCommand)) { |
| 807 | if (!isMouseGrabbed && ([event modifierFlags] & NSCommandKeyMask)) { |
808 | 808 | return true; |
809 | 809 | } |
810 | 810 | |
… |
… |
QemuCocoaView *cocoaView; |
812 | 812 | qemu_input_event_send_key_qcode(dcl->con, keycode, false); |
813 | 813 | } |
814 | 814 | break; |
815 | | case NSEventTypeMouseMoved: |
| 815 | case NSMouseMovedMask: |
816 | 816 | if (isAbsoluteEnabled) { |
817 | 817 | // Cursor re-entered into a window might generate events bound to screen coordinates |
818 | 818 | // and `nil` window property, and in full screen mode, current window might not be |
… |
… |
QemuCocoaView *cocoaView; |
829 | 829 | } |
830 | 830 | mouse_event = true; |
831 | 831 | break; |
832 | | case NSEventTypeLeftMouseDown: |
833 | | if ([event modifierFlags] & NSEventModifierFlagCommand) { |
| 832 | case NSLeftMouseDownMask: |
| 833 | if ([event modifierFlags] & NSCommandKeyMask) { |
834 | 834 | buttons |= MOUSE_EVENT_RBUTTON; |
835 | 835 | } else { |
836 | 836 | buttons |= MOUSE_EVENT_LBUTTON; |
837 | 837 | } |
838 | 838 | mouse_event = true; |
839 | 839 | break; |
840 | | case NSEventTypeRightMouseDown: |
| 840 | case NSRightMouseDownMask: |
841 | 841 | buttons |= MOUSE_EVENT_RBUTTON; |
842 | 842 | mouse_event = true; |
843 | 843 | break; |
844 | | case NSEventTypeOtherMouseDown: |
| 844 | case NSOtherMouseDownMask: |
845 | 845 | buttons |= MOUSE_EVENT_MBUTTON; |
846 | 846 | mouse_event = true; |
847 | 847 | break; |
848 | | case NSEventTypeLeftMouseDragged: |
849 | | if ([event modifierFlags] & NSEventModifierFlagCommand) { |
| 848 | case NSLeftMouseDraggedMask: |
| 849 | if ([event modifierFlags] & NSCommandKeyMask) { |
850 | 850 | buttons |= MOUSE_EVENT_RBUTTON; |
851 | 851 | } else { |
852 | 852 | buttons |= MOUSE_EVENT_LBUTTON; |
853 | 853 | } |
854 | 854 | mouse_event = true; |
855 | 855 | break; |
856 | | case NSEventTypeRightMouseDragged: |
| 856 | case NSRightMouseDraggedMask: |
857 | 857 | buttons |= MOUSE_EVENT_RBUTTON; |
858 | 858 | mouse_event = true; |
859 | 859 | break; |
860 | | case NSEventTypeOtherMouseDragged: |
| 860 | case NSOtherMouseDraggedMask: |
861 | 861 | buttons |= MOUSE_EVENT_MBUTTON; |
862 | 862 | mouse_event = true; |
863 | 863 | break; |
864 | | case NSEventTypeLeftMouseUp: |
| 864 | case NSLeftMouseUpMask: |
865 | 865 | mouse_event = true; |
866 | 866 | if (!isMouseGrabbed && [self screenContainsPoint:p]) { |
867 | 867 | /* |
… |
… |
QemuCocoaView *cocoaView; |
874 | 874 | } |
875 | 875 | } |
876 | 876 | break; |
877 | | case NSEventTypeRightMouseUp: |
| 877 | case NSRightMouseUpMask: |
878 | 878 | mouse_event = true; |
879 | 879 | break; |
880 | | case NSEventTypeOtherMouseUp: |
| 880 | case NSOtherMouseUpMask: |
881 | 881 | mouse_event = true; |
882 | 882 | break; |
883 | | case NSEventTypeScrollWheel: |
| 883 | case NSScrollWheelMask: |
884 | 884 | /* |
885 | 885 | * Send wheel events to the guest regardless of window focus. |
886 | 886 | * This is in-line with standard Mac OS X UI behaviour. |
… |
… |
QemuCocoaView *cocoaView; |
1064 | 1064 | |
1065 | 1065 | // create a window |
1066 | 1066 | normalWindow = [[NSWindow alloc] initWithContentRect:[cocoaView frame] |
1067 | | styleMask:NSWindowStyleMaskTitled|NSWindowStyleMaskMiniaturizable|NSWindowStyleMaskClosable |
| 1067 | styleMask:NSTitledWindowMask|NSMiniaturizableWindowMask|NSClosableWindowMask |
1068 | 1068 | backing:NSBackingStoreBuffered defer:NO]; |
1069 | 1069 | if(!normalWindow) { |
1070 | 1070 | fprintf(stderr, "(cocoa) can't create window\n"); |
… |
… |
QemuCocoaView *cocoaView; |
1370 | 1370 | int x = 0, y = 0, about_width = 400, about_height = 200; |
1371 | 1371 | NSRect window_rect = NSMakeRect(x, y, about_width, about_height); |
1372 | 1372 | about_window = [[NSWindow alloc] initWithContentRect:window_rect |
1373 | | styleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | |
1374 | | NSWindowStyleMaskMiniaturizable |
| 1373 | styleMask:NSTitledWindowMask | NSClosableWindowMask | |
| 1374 | NSMiniaturizableWindowMask |
1375 | 1375 | backing:NSBackingStoreBuffered |
1376 | 1376 | defer:NO]; |
1377 | 1377 | [about_window setTitle: @"About"]; |
… |
… |
QemuCocoaView *cocoaView; |
1410 | 1410 | [name_label setEditable: NO]; |
1411 | 1411 | [name_label setBezeled: NO]; |
1412 | 1412 | [name_label setDrawsBackground: NO]; |
1413 | | [name_label setAlignment: NSTextAlignmentCenter]; |
| 1413 | [name_label setAlignment: NSCenterTextAlignment]; |
1414 | 1414 | NSString *qemu_name = [[NSString alloc] initWithCString: gArgv[0] |
1415 | 1415 | encoding: NSASCIIStringEncoding]; |
1416 | 1416 | qemu_name = [qemu_name lastPathComponent]; |
… |
… |
QemuCocoaView *cocoaView; |
1426 | 1426 | version_rect]; |
1427 | 1427 | [version_label setEditable: NO]; |
1428 | 1428 | [version_label setBezeled: NO]; |
1429 | | [version_label setAlignment: NSTextAlignmentCenter]; |
| 1429 | [version_label setAlignment: NSCenterTextAlignment]; |
1430 | 1430 | [version_label setDrawsBackground: NO]; |
1431 | 1431 | |
1432 | 1432 | /* Create the version string*/ |
… |
… |
QemuCocoaView *cocoaView; |
1446 | 1446 | [copyright_label setEditable: NO]; |
1447 | 1447 | [copyright_label setBezeled: NO]; |
1448 | 1448 | [copyright_label setDrawsBackground: NO]; |
1449 | | [copyright_label setAlignment: NSTextAlignmentCenter]; |
| 1449 | [copyright_label setAlignment: NSCenterTextAlignment]; |
1450 | 1450 | [copyright_label setStringValue: [NSString stringWithFormat: @"%s", |
1451 | 1451 | QEMU_COPYRIGHT]]; |
1452 | 1452 | [superView addSubview: copyright_label]; |
… |
… |
static void create_initial_menus(void) |
1511 | 1511 | [menu addItem:[NSMenuItem separatorItem]]; //Separator |
1512 | 1512 | [menu addItemWithTitle:@"Hide QEMU" action:@selector(hide:) keyEquivalent:@"h"]; //Hide QEMU |
1513 | 1513 | menuItem = (NSMenuItem *)[menu addItemWithTitle:@"Hide Others" action:@selector(hideOtherApplications:) keyEquivalent:@"h"]; // Hide Others |
1514 | | [menuItem setKeyEquivalentModifierMask:(NSEventModifierFlagOption|NSEventModifierFlagCommand)]; |
| 1514 | [menuItem setKeyEquivalentModifierMask:(NSAlternateKeyMask|NSCommandKeyMask)]; |
1515 | 1515 | [menu addItemWithTitle:@"Show All" action:@selector(unhideAllApplications:) keyEquivalent:@""]; // Show All |
1516 | 1516 | [menu addItem:[NSMenuItem separatorItem]]; //Separator |
1517 | 1517 | [menu addItemWithTitle:@"Quit QEMU" action:@selector(terminate:) keyEquivalent:@"q"]; |