From 39fdf7457b1e53672808f4133bec9e17d9ea5f73 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Thu, 27 Oct 2016 23:32:33 -0400 Subject: [PATCH] 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. --- darwin/main.m | 12 ++++++++++-- darwin/uipriv_darwin.h | 3 ++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/darwin/main.m b/darwin/main.m index 7dbea05f..054a79af 100644 --- a/darwin/main.m +++ b/darwin/main.m @@ -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,7 +203,8 @@ int uiMainStep(int wait) return 1; type = [e type]; - [realNSApp() sendEvent:e]; + if (!interceptEvent(e)) + [realNSApp() sendEvent:e]; [realNSApp() updateWindows]; // GNUstep does this diff --git a/darwin/uipriv_darwin.h b/darwin/uipriv_darwin.h index a4e44fac..4b17268d 100644 --- a/darwin/uipriv_darwin.h +++ b/darwin/uipriv_darwin.h @@ -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 *);