Removed the dummy NSEvent code from bleh_darwin.m and rewrote it in Objective-C in delegateuitask_darwin.m. And now to nuke bleh_darwin.m and change all the int64_ts to intptr_ts and merge the .h files...
This commit is contained in:
parent
3b4924a156
commit
08e86ea9b3
|
@ -64,20 +64,3 @@ void initBleh()
|
||||||
s_initTrackingArea = sel_getUid("initWithRect:options:owner:userInfo:");
|
s_initTrackingArea = sel_getUid("initWithRect:options:owner:userInfo:");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
See uitask_darwin.go: we need to synthesize a NSEvent so -[NSApplication stop:] will work. We cannot simply init the default NSEvent though (it throws an exception) so we must do it "the right way". This involves a very convoluted initializer; we'll just do it here to keep things clean on the Go side (this will only be run once anyway, on program exit).
|
|
||||||
*/
|
|
||||||
|
|
||||||
id makeDummyEvent()
|
|
||||||
{
|
|
||||||
return objc_msgSend(c_NSEvent, s_newEvent,
|
|
||||||
(NSUInteger) NSApplicationDefined, /* otherEventWithType: */
|
|
||||||
NSMakePoint(0, 0), /* location: */
|
|
||||||
(NSUInteger) 0, /* modifierFlags: */
|
|
||||||
(double) 0, /* timestamp: */
|
|
||||||
(NSInteger) 0, /* windowNumber: */
|
|
||||||
nil, /* context: */
|
|
||||||
(short) 0, /* subtype: */
|
|
||||||
(NSInteger) 0, /* data1: */
|
|
||||||
(NSInteger) 0); /* data2: */
|
|
||||||
}
|
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include <AppKit/NSApplication.h>
|
#include <AppKit/NSApplication.h>
|
||||||
#include <AppKit/NSWindow.h>
|
#include <AppKit/NSWindow.h>
|
||||||
#include <Foundation/NSAutoreleasePool.h>
|
#include <Foundation/NSAutoreleasePool.h>
|
||||||
|
#include <AppKit/NSEvent.h>
|
||||||
|
|
||||||
@interface appDelegate : NSObject
|
@interface appDelegate : NSObject
|
||||||
@end
|
@end
|
||||||
|
@ -80,13 +81,23 @@ void douitask(id appDelegate, void *p)
|
||||||
|
|
||||||
void breakMainLoop(void)
|
void breakMainLoop(void)
|
||||||
{
|
{
|
||||||
|
NSEvent *e;
|
||||||
|
|
||||||
// -[NSApplication stop:] stops the event loop; it won't do a clean termination, but we're not too concerned with that (at least not on the other platforms either so)
|
// -[NSApplication stop:] stops the event loop; it won't do a clean termination, but we're not too concerned with that (at least not on the other platforms either so)
|
||||||
// we can't call -[NSApplication terminate:] because that will just quit the program, ensuring we never leave ui.Go()
|
// we can't call -[NSApplication terminate:] because that will just quit the program, ensuring we never leave ui.Go()
|
||||||
[NSApp stop:NSApp];
|
[NSApp stop:NSApp];
|
||||||
// simply calling -[NSApplication stop:] is not good enough, as the stop flag is only checked when an event comes in
|
// simply calling -[NSApplication stop:] is not good enough, as the stop flag is only checked when an event comes in
|
||||||
// we have to create a "proper" event; a blank event will just throw an exception
|
// we have to create a "proper" event; a blank event will just throw an exception
|
||||||
[NSApp postEvent:makeDummyEvent() // TODO inline this
|
e = [NSEvent otherEventWithType:NSApplicationDefined
|
||||||
atStart:NO]; // not at start, just in case there are other events pending (TODO is this correct?)
|
location:NSZeroPoint
|
||||||
|
modifierFlags:0
|
||||||
|
timestamp:0
|
||||||
|
windowNumber:0
|
||||||
|
context:nil
|
||||||
|
subtype:0
|
||||||
|
data1:0
|
||||||
|
data2:0];
|
||||||
|
[NSApp postEvent:e atStart:NO]; // not at start, just in case there are other events pending (TODO is this correct?)
|
||||||
}
|
}
|
||||||
|
|
||||||
void cocoaMainLoop(void)
|
void cocoaMainLoop(void)
|
||||||
|
|
|
@ -51,6 +51,5 @@ struct xpoint {
|
||||||
|
|
||||||
/* for uitask_darwin.go */
|
/* for uitask_darwin.go */
|
||||||
extern void initBleh();
|
extern void initBleh();
|
||||||
extern id makeDummyEvent();
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue