Skip to content

Commit

Permalink
Bug fixed: VM window will be dragged to the center of screen in some …
Browse files Browse the repository at this point in the history
…case.
  • Loading branch information
js-john committed Dec 14, 2023
1 parent 5a1ed68 commit 2e9489e
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions Platform/macOS/Display/VMDisplayQemuMetalWindowController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -402,17 +402,20 @@ extension VMDisplayQemuMetalWindowController {
}

func windowDidBecomeMain(_ notification: Notification) {
if isWindowFocusAutoCapture {
captureMouseToolbarButton.state = .on
captureMouse()
// Do not capture mouse if user did not clicked inside the metalView because the window will be draged if user hold the mouse button.
guard let window = window,
window.mouseLocationOutsideOfEventStream.y < metalView.frame.height,
captureMouseToolbarButton.state == .off,
isWindowFocusAutoCapture else {
return
}
captureMouseToolbarButton.state = .on
captureMouse()
}

func windowDidResignMain(_ notification: Notification) {
if isWindowFocusAutoCapture {
captureMouseToolbarButton.state = .off
releaseMouse()
}
captureMouseToolbarButton.state = .off
releaseMouse()
}

override func windowDidResignKey(_ notification: Notification) {
Expand Down

0 comments on commit 2e9489e

Please sign in to comment.