Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help to implement Zoom In, Zoom out VZVirtualMachineView #35

Open
Code-Hex opened this issue Aug 26, 2022 · 2 comments
Open

Help to implement Zoom In, Zoom out VZVirtualMachineView #35

Code-Hex opened this issue Aug 26, 2022 · 2 comments
Labels
help wanted Extra attention is needed

Comments

@Code-Hex
Copy link
Owner

Code-Hex commented Aug 26, 2022

It is not among the features provided by Apple but, I attempted to provide pinch-in zoom-in, and zoom-out functionality like iPhone for the window that serves as the GUI display in this package.

However, This was too difficult than expected and was once out of the scope.

VZVirtualMachineView inherits from NSView. So I was thinking that if I made the document view of the NSScrollView and applied the scroll view to the window, it would be complete.

The problem is...

  • VZVirtualMachineView receives the VZVirtualMachine object via property. After receiving it, this view no longer accepts multi-touch gestures. Instead, these events are proxied to the guest OS.
  • Therefore necessary to temporarily prevent the events related to mouse movements from being transmitted to this view.
  • This has been successful. However, it was not possible to perform operations such as zooming in on the key views.
  • As I will be described later, this view has an internal NSTrackingArea, which probably needs to do anything.
@Code-Hex Code-Hex added the help wanted Extra attention is needed label Aug 26, 2022
@Code-Hex Code-Hex changed the title Zoom In, Zoom out VZVirtualMachineView Help to implement Zoom In, Zoom out VZVirtualMachineView Aug 26, 2022
@Code-Hex
Copy link
Owner Author

This is a result of dumped VZVirtualMachineView (/System/Library/Frameworks/Virtualization.framework/Versions/A/Virtualization)

@interface VZVirtualMachineView : NSView {
    id  _becomeKeyWindowObserver;
    bool  _capturesSystemKeys;
    NSCursor * _currentGuestCursor;
    <_VZVirtualMachineViewDelegate> * _delegate;
    id  _eventMonitor;
    _VZFramebufferView * _framebufferView;
    bool  _guestIsUsingHostCursor;
    id  _keyEventMonitor;
    struct vector<unsigned short, std::allocator<unsigned short>> { 
        unsigned short *__begin_; 
        unsigned short *__end_; 
        struct __compressed_pair<unsigned short *, std::allocator<unsigned short>> { 
            unsigned short *__value_; 
        } __end_cap_; 
    }  _keys_down;
    bool  _mouseIsInTrackingArea;
    id  _resignKeyWindowObserver;
    long long  _scaleMode;
    bool  _showsHostCursor;
    NSTrackingArea * _trackingArea;
    VZVirtualMachine * _virtualMachine;
    bool  _virtualMachineIsRunning;
    VZObserverProxy * _virtualMachineObserver;
}

@property (readonly) bool _canGrabMouseInput;
@property (readonly) bool _canReleaseMouseInput;
@property (setter=_setDelegate:) <_VZVirtualMachineViewDelegate> *_delegate;
@property (setter=_setScaleMode:) long long _scaleMode;
@property bool capturesSystemKeys;
@property (retain) VZVirtualMachine *virtualMachine;

- (id).cxx_construct;
- (void).cxx_destruct;
- (bool)acceptsFirstResponder;
- (bool)becomeFirstResponder;
- (bool)capturesSystemKeys;
- (void)dealloc;
- (void)flagsChanged:(id)arg1;
- (id)initWithCoder:(id)arg1;
- (id)initWithFrame:(struct CGRect { struct CGPoint { double x_1_1_1; double x_1_1_2; } x1; struct CGSize { double x_2_1_1; double x_2_1_2; } x2; })arg1;
- (void)keyDown:(id)arg1;
- (void)keyUp:(id)arg1;
- (void)layout;
- (void)magnifyWithEvent:(id)arg1;
- (void)mouseDown:(id)arg1;
- (void)mouseDragged:(id)arg1;
- (void)mouseEntered:(id)arg1;
- (void)mouseExited:(id)arg1;
- (void)mouseMoved:(id)arg1;
- (void)mouseUp:(id)arg1;
- (void)observeValueForKeyPath:(id)arg1 ofObject:(id)arg2 change:(id)arg3 context:(void*)arg4;
- (void)otherMouseDown:(id)arg1;
- (void)otherMouseDragged:(id)arg1;
- (void)otherMouseUp:(id)arg1;
- (void)quickLookWithEvent:(id)arg1;
- (bool)resignFirstResponder;
- (void)rightMouseDown:(id)arg1;
- (void)rightMouseDragged:(id)arg1;
- (void)rightMouseUp:(id)arg1;
- (void)rotateWithEvent:(id)arg1;
- (void)scrollWheel:(id)arg1;
- (void)setCapturesSystemKeys:(bool)arg1;
- (void)setVirtualMachine:(id)arg1;
- (void)smartMagnifyWithEvent:(id)arg1;
- (void)updateTrackingAreas;
- (void)viewDidMoveToWindow;
- (void)viewWillMoveToWindow:(id)arg1;
- (id)virtualMachine;

// VZVirtualMachineView (VZPrivate)

- (bool)_canGrabMouseInput;
- (bool)_canReleaseMouseInput;
- (id)_delegate;
- (bool)_grabMouseInput;
- (bool)_releaseMouseInput;
- (long long)_scaleMode;
- (void)_setDelegate:(id)arg1;
- (void)_setScaleMode:(long long)arg1;

@end

@Code-Hex
Copy link
Owner Author

A test repository is available here. https://github.com/Code-Hex/vm-scroll-test

You can try it out by creating a VM.bundle directory on your home directory with the file AuxiliaryStorage Disk.img HardwareModel MachineIdentifier RestoreImage.ipsw. These can be created by preparing a Restore Image according to the examples for macOS in this package. (also followed as Apple Running macOS in a Virtual Machine on Apple Silicon Macs instruction)

@Code-Hex Code-Hex mentioned this issue Aug 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant