More preparation for the OS X window move/resize code: uiMainStep() is split into an internal function that takes a pre-sendEvent: interception specifically intended for internal loops.

This commit is contained in:
Pietro Gagliardi 2016-10-27 23:32:33 -04:00
parent 8cbae7d2b7
commit 39fdf7457b
2 changed files with 12 additions and 3 deletions

View File

@ -169,10 +169,17 @@ void uiMainSteps(void)
stepsIsRunning = YES;
}
int uiMainStep(int wait)
{
return mainStep(wait, ^(NSEvent *e) {
return NO;
});
}
// see also:
// - http://www.cocoawithlove.com/2009/01/demystifying-nsapplication-by.html
// - https://github.com/gnustep/gui/blob/master/Source/NSApplication.m
int uiMainStep(int wait)
int mainStep(int wait, BOOL (^interceptEvent)(NSEvent *e))
{
NSDate *expire;
NSEvent *e;
@ -196,6 +203,7 @@ int uiMainStep(int wait)
return 1;
type = [e type];
if (!interceptEvent(e))
[realNSApp() sendEvent:e];
[realNSApp() updateWindows];

View File

@ -34,7 +34,7 @@
extern void finalizeMenus(void);
extern void uninitMenus(void);
// init.m
// main.m
@interface applicationClass : NSApplication
@end
// this is needed because NSApp is of type id, confusing clang
@ -43,6 +43,7 @@ extern void uninitMenus(void);
@property (strong) menuManager *menuManager;
@end
#define appDelegate() ((appDelegate *) [realNSApp() delegate])
extern int mainStep(int wait, BOOL (^interceptEvent)(NSEvent *));
// util.m
extern void disableAutocorrect(NSTextView *);