On Sun, 27 Jan 2019, Peter Maydell wrote:
On Wed, 19 Dec 2018 at 19:42, Ben Hekster <ben.heks...@foghorn.io> wrote:
Should have tested a little more:
While the crashing has stopped, the window isn't responsive to
keystrokes. This includes the frame buffer emulation itself (so
I can't actually log in) as well as the QEMU Monitor; nothing I
type has any effect in either.
Yes, I can reproduce this with my "refactor the OSX UI code"
patchset too. The problem is that with the removal of the
code that was in the cocoa_refresh() function that manually
pulled events out of the OSX event queue and called our
QemuCocoaView handleEvent method on them, there's nothing
that does cause that code to be called. (I had mistakenly
assumed handleEvent was an OSX UI method and so the run loop
would call it.)
Unfortunately I'm not sufficiently familiar with how OSX
event handling works to figure out how to plumb it back in
again. It ought to be a fairly simple matter of "implement
whatever method OSX sends events to on whatever of our
various classes is the right one, and make it call handleEvent
with the NSEvent", but I've tried a few things and haven't
been able to actually get any event handling methods to
fire at all :-(
I think you need to implement keyDown: and keyUp: methods in QemuCocoaView
to get keyboard events and there are similar methods for mouse events,
see:
https://developer.apple.com/documentation/appkit/nsview?language=objc
But these are a lot of methods which are supposedly called from the
sendEvent: method of the NSWindow containing this view so maybe a better
place to catch all events is there. For this we need an NSWindow subclass
implementing sendEvent: which is then used to hold QemuCocoaView. I may be
wrong though, haven't tested it and don't know what you've tried. (If all
else fails there's also sendEvent: of NSApp which is where all events
should start from and it might be subclassed as well but then some events
may need to be passed on so doing it at the window is probably better.)
Regards,
BALATON Zoltan