vz: Fix scrollbar issue with runtime swizzle#4476
vz: Fix scrollbar issue with runtime swizzle#4476stuffbucket wants to merge 1 commit intolima-vm:masterfrom
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 <231133237+stuffbucket@users.noreply.github.com>
| // 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 |
| } | ||
|
|
||
| // Constructor attribute ensures this runs before main() | ||
| // This patches NSScrollView before Code-Hex/vz creates any windows |
There was a problem hiding this comment.
Not a fan of monkey patching AppKit, could this be fixed in Code-Hex/vz ?
There was a problem hiding this comment.
@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/vz@v0.0.1-pluggable-window-api
There was a problem hiding this comment.
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).