-
Notifications
You must be signed in to change notification settings - Fork 801
vz: Fix scrollbar issue with runtime swizzle #4476
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
base: master
Are you sure you want to change the base?
Conversation
The Code-Hex/vz library wraps VZVirtualMachineView in an NSScrollView with scrollbars hardcoded to YES (for their zoom feature). This causes ~16px of the VM display to be cut off by scrollbar gutters. This patch uses Objective-C method swizzling to intercept NSScrollView's setDocumentView: method and disable scrollbars when the document view is a VZVirtualMachineView. This is a self-contained fix that doesn't require forking the vz library. Signed-off-by: stuffbucket <[email protected]>
| // a VZVirtualMachineView. | ||
| // | ||
| // This is a temporary workaround until Code-Hex/vz adds a configuration option | ||
| // to disable scrollbars. See: https://github.com/Code-Hex/vz/issues/XXX |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The link is broken
| } | ||
|
|
||
| // Constructor attribute ensures this runs before main() | ||
| // This patches NSScrollView before Code-Hex/vz creates any windows |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a fan of monkey patching AppKit, could this be fixed in Code-Hex/vz ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AkihiroSuda I agree. I tried to keep things simple here, not knowing how likely it would be to get a PR accepted in Code-Hex/vz, but I took some time to address the problem in Code-Hex/vz instead.
I put together a working solution that lets a caller to Code-Hex/vz implement their own GUI UX. The current GUI UI is still the default (although I fixed the scrollbar issue). The gui-linux example was expanded to show how a custom UX could be generated.
Code-Hex/vz issue: Code-Hex/vz/issues/210
Working implementation: stuffbucket/[email protected]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how likely
Seems likely: Code-Hex/vz#210 (comment)
Let me mark this PR as a draft until the Code-Hex/vz issue can be resolved



The Code-Hex/vz library wraps VZVirtualMachineView in an NSScrollView with scrollbars hardcoded to YES (for their zoom feature). This causes ~16px of the VM display to be cut off by scrollbar gutters.
This patch uses Objective-C method swizzling to intercept NSScrollView's setDocumentView: method and disable scrollbars when the document view is a VZVirtualMachineView.
This is a self-contained fix that doesn't require forking the vz library or add any dependencies.
Tested successfully on macOS 26.2 (see screenshot) with Debian 13 (Plasma) and Alpine (serial console).