reduce cpu usage on event loop
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good
This commit is contained in:
parent
6c53df0fc5
commit
02faed2f04
1 changed files with 36 additions and 32 deletions
|
|
@ -188,27 +188,6 @@ static NSPoint pointFlip(NSPoint point) {
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
+ (void)eventCanceller:(MilskoCocoa *)this {
|
|
||||||
this->lastEvent = [this->application currentEvent];
|
|
||||||
[this eventProcess:this->lastEvent];
|
|
||||||
|
|
||||||
if (this->_forceRender) {
|
|
||||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
|
||||||
NSEvent *event = [NSEvent otherEventWithType:NSApplicationDefined
|
|
||||||
location:NSMakePoint(0, 0)
|
|
||||||
modifierFlags:0
|
|
||||||
timestamp:0
|
|
||||||
windowNumber:0
|
|
||||||
context:nil
|
|
||||||
subtype:0
|
|
||||||
data1:0
|
|
||||||
data2:0];
|
|
||||||
[NSApp postEvent:event atStart:YES];
|
|
||||||
[pool release];
|
|
||||||
}
|
|
||||||
|
|
||||||
[[NSApplication sharedApplication] stop:nil];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)polygonWithPoints:(MwPoint *)points
|
- (void)polygonWithPoints:(MwPoint *)points
|
||||||
points_count:(int)points_count
|
points_count:(int)points_count
|
||||||
|
|
@ -329,7 +308,34 @@ static NSPoint pointFlip(NSPoint point) {
|
||||||
return 1;
|
return 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
+ (void)eventCanceller:(MilskoCocoa *)this {
|
||||||
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||||
|
NSEvent *event = [NSEvent otherEventWithType:NSApplicationDefined
|
||||||
|
location:NSMakePoint(0, 0)
|
||||||
|
modifierFlags:0
|
||||||
|
timestamp:0
|
||||||
|
windowNumber:0
|
||||||
|
context:nil
|
||||||
|
subtype:0
|
||||||
|
data1:0
|
||||||
|
data2:0];
|
||||||
|
|
||||||
|
this->lastEvent = [this->window currentEvent];
|
||||||
|
[this eventProcess:this->lastEvent];
|
||||||
|
|
||||||
|
[NSApp postEvent:event atStart:YES];
|
||||||
|
[pool release];
|
||||||
|
|
||||||
|
[[NSApplication sharedApplication] stop:nil];
|
||||||
|
usleep(1000);
|
||||||
|
}
|
||||||
|
|
||||||
- (void)getNextEvent {
|
- (void)getNextEvent {
|
||||||
|
if (_forceRender) {
|
||||||
|
MwLL h = [self->handle pointer];
|
||||||
|
MwLLDispatch(h, draw, NULL);
|
||||||
|
_forceRender = MwFALSE;
|
||||||
|
}
|
||||||
[self sendClipboardEvent];
|
[self sendClipboardEvent];
|
||||||
|
|
||||||
if (self->pointerLocked && [self->window isMainWindow] && self->lastEvent) {
|
if (self->pointerLocked && [self->window isMainWindow] && self->lastEvent) {
|
||||||
|
|
@ -401,10 +407,15 @@ static NSPoint pointFlip(NSPoint point) {
|
||||||
case NSScrollWheel:
|
case NSScrollWheel:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
/* mute bizarre "unknown subtype" errors that flood the console */
|
||||||
|
if (ev.subtype > 8) {
|
||||||
|
doSendEvent = false;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
[win sendEvent:ev];
|
if (doSendEvent) {
|
||||||
|
[win sendEvent:ev];
|
||||||
|
}
|
||||||
[pool release];
|
[pool release];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -909,7 +920,7 @@ static NSPoint pointFlip(NSPoint point) {
|
||||||
}
|
}
|
||||||
- (void)applicationDidBecomeActive:(NSNotification *)notification {
|
- (void)applicationDidBecomeActive:(NSNotification *)notification {
|
||||||
[self->appl activateIgnoringOtherApps:true];
|
[self->appl activateIgnoringOtherApps:true];
|
||||||
printf("test\n");
|
// printf("test\n");
|
||||||
}
|
}
|
||||||
- (void)applicationWillFinishLaunching:(NSNotification *)notification {
|
- (void)applicationWillFinishLaunching:(NSNotification *)notification {
|
||||||
// printf("test\n");
|
// printf("test\n");
|
||||||
|
|
@ -1069,14 +1080,7 @@ static void MwLLSetWHImpl(MwLL handle, int w, int height) {
|
||||||
|
|
||||||
static void MwLLFreeColorImpl(MwLLColor color) { free(color); }
|
static void MwLLFreeColorImpl(MwLLColor color) { free(color); }
|
||||||
|
|
||||||
static int MwLLPendingImpl(MwLL handle) {
|
static int MwLLPendingImpl(MwLL handle) { return [handle->cocoa.real pending]; }
|
||||||
MilskoCocoa *h = handle->cocoa.real;
|
|
||||||
if ([h pending]) {
|
|
||||||
MwLLDispatch(handle, draw, NULL);
|
|
||||||
return 1;
|
|
||||||
};
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void MwLLNextEventImpl(MwLL handle) {
|
static void MwLLNextEventImpl(MwLL handle) {
|
||||||
MilskoCocoa *h = handle->cocoa.real;
|
MilskoCocoa *h = handle->cocoa.real;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue