Compare commits
No commits in common. "8f379e97513a4416541960c95c6d97f34bc58ca5" and "a0e2ec7f57491aa7cc978ac7296f6c320168d450" have entirely different histories.
8f379e9751
...
a0e2ec7f57
2 changed files with 34 additions and 29 deletions
|
|
@ -156,7 +156,6 @@
|
||||||
- (NSView *)getView;
|
- (NSView *)getView;
|
||||||
- (MilskoCocoaWindow *)getWindow;
|
- (MilskoCocoaWindow *)getWindow;
|
||||||
- (MilskoFakePointer *)getHandle;
|
- (MilskoFakePointer *)getHandle;
|
||||||
+ (void)eventCanceller:(MilskoCocoa *)this;
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
#define OBJC(x) x
|
#define OBJC(x) x
|
||||||
|
|
|
||||||
|
|
@ -142,9 +142,9 @@ static NSPoint pointFlip(NSPoint point) {
|
||||||
[c->application
|
[c->application
|
||||||
setActivationPolicy:0 /* NSApplicationActivationPolicyRegular */];
|
setActivationPolicy:0 /* NSApplicationActivationPolicyRegular */];
|
||||||
}
|
}
|
||||||
[c->window makeKeyAndOrderFront:nil];
|
|
||||||
[c->application activateIgnoringOtherApps:true];
|
[c->application activateIgnoringOtherApps:true];
|
||||||
[c->window makeFirstResponder:c->view];
|
[c->window makeFirstResponder:c->view];
|
||||||
|
[c->window makeKeyAndOrderFront:nil];
|
||||||
}
|
}
|
||||||
[c->application setDelegate:[[MilskoCocoaApplicationDelegate alloc]
|
[c->application setDelegate:[[MilskoCocoaApplicationDelegate alloc]
|
||||||
initWithAppl:c->application]];
|
initWithAppl:c->application]];
|
||||||
|
|
@ -172,13 +172,6 @@ static NSPoint pointFlip(NSPoint point) {
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
+ (void)eventCanceller:(MilskoCocoa *)this {
|
|
||||||
this->lastEvent = [this->application currentEvent];
|
|
||||||
[this eventProcess:this->lastEvent];
|
|
||||||
|
|
||||||
[[NSApplication sharedApplication] stop:nil];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)polygonWithPoints:(MwPoint *)points
|
- (void)polygonWithPoints:(MwPoint *)points
|
||||||
points_count:(int)points_count
|
points_count:(int)points_count
|
||||||
color:(MwLLColor)color {
|
color:(MwLLColor)color {
|
||||||
|
|
@ -276,29 +269,42 @@ static NSPoint pointFlip(NSPoint point) {
|
||||||
[self forceRender];
|
[self forceRender];
|
||||||
};
|
};
|
||||||
- (int)pending {
|
- (int)pending {
|
||||||
/*
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||||
ok so this is a crime against god but I did in fact try the better method
|
MwBool isPending = MwFALSE;
|
||||||
of using nextEventMatchingMask and then pumping events manually. However
|
if (_forceRender) {
|
||||||
this gives me something that only kind of works, with strange behavior such
|
_forceRender = MwFALSE;
|
||||||
as the window never becoming the main window (have to make it key in order
|
[pool release];
|
||||||
for the menu to show up) occuring. Hours of research and digging led me down
|
return 1;
|
||||||
a rabbit hole that, on all sides, pointed to "just use [NSApplication run]".
|
}
|
||||||
So we just to do that; of course, this is a blocking function, so we
|
self->lastEvent = [self->window nextEventMatchingMask:NSAnyEventMask
|
||||||
register this function that instantly cancels it and pumps whatever event
|
untilDate:[NSDate distantPast]
|
||||||
MacOS has in store for us. We do this on loop and somehow the resulting CPU
|
inMode:NSDefaultRunLoopMode
|
||||||
usage is managable.
|
dequeue:YES];
|
||||||
|
|
||||||
If some Apple developer with 20 years of experience in Objective C is here:
|
isPending = self->lastEvent != NULL;
|
||||||
Pls god send PR if you know how to properly do this.
|
[pool release];
|
||||||
*/
|
return isPending;
|
||||||
[MilskoCocoa performSelectorOnMainThread:@selector(eventCanceller:)
|
|
||||||
withObject:self
|
|
||||||
waitUntilDone:NO];
|
|
||||||
[self->application run];
|
|
||||||
return 1;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
- (void)getNextEvent {
|
- (void)getNextEvent {
|
||||||
|
[self eventProcess:self->lastEvent];
|
||||||
|
while (true) {
|
||||||
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||||
|
NSEvent *ev = [self->window nextEventMatchingMask:NSAnyEventMask
|
||||||
|
untilDate:[NSDate distantPast]
|
||||||
|
inMode:NSDefaultRunLoopMode
|
||||||
|
dequeue:YES];
|
||||||
|
if (!ev) {
|
||||||
|
[pool release];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
/* run through the switch case on ev.type, before calling sendEvent on any
|
||||||
|
* events we handle */
|
||||||
|
[self eventProcess:ev];
|
||||||
|
[pool release];
|
||||||
|
[self->application updateWindows];
|
||||||
|
}
|
||||||
|
|
||||||
[self sendClipboardEvent];
|
[self sendClipboardEvent];
|
||||||
|
|
||||||
if (self->pointerLocked && [self->window isMainWindow]) {
|
if (self->pointerLocked && [self->window isMainWindow]) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue