Skip to content

Commit

Permalink
Handling correctly the events of the about window
Browse files Browse the repository at this point in the history
  • Loading branch information
tesonep committed Mar 29, 2019
1 parent f908305 commit fa1d55e
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
12 changes: 11 additions & 1 deletion platforms/iOS/vm/OSX/SqueakOSXApplication.m
Expand Up @@ -38,8 +38,12 @@ Some of this code was funded via a grant from the European Smalltalk User Group

#import "SqueakOSXApplication.h"
#import "sqSqueakOSXScreenAndWindow.h"
#import "SqueakOSXAppDelegate.h"
#import "sqSqueakOSXApplication.h"

@implementation SqueakOSXApplication
@implementation SqueakOSXApplication

extern SqueakOSXAppDelegate *gDelegateApp;

-(void)sendEvent:(NSEvent*)anEvent
{
Expand All @@ -66,4 +70,10 @@ - (void)showHelp:(id)sender;
[[NSWorkspace sharedWorkspace] openURL: url];
}
#endif

- (void)orderFrontStandardAboutPanel:(id)sender;
{
[super orderFrontStandardAboutPanel: sender];
[gDelegateApp.squeakApplication setAboutWindow: [self keyWindow]];
}
@end
16 changes: 15 additions & 1 deletion platforms/iOS/vm/OSX/sqSqueakOSXApplication+events.m
Expand Up @@ -67,6 +67,20 @@ - (sqButton) resolveModifier:(sqModifier)modifier forMouseButton:(sqButton)mouse

@implementation sqSqueakOSXApplication (events)

// This method filters the event that should not be processed by the Squeak Application.
// This events are related to windows that are launched from a third party library (as SDL)
// Check pumpRunLoopEventSendAndSignal:(BOOL)signal for more details.

// The events processed by the VM are the ones in the main window or in the about window.
- (BOOL) shouldFilterEvent: (NSEvent*)event {

sqSqueakOSXApplication * sqApplication = (sqSqueakOSXApplication*)gDelegateApp.squeakApplication;

return event.window
&& event.window != gDelegateApp.window
&& event.window != [sqApplication aboutWindow];
}

// Consume all pending events in the NSApp
// Events may come from the window open by the VM or windows open by other windowing systems
// We need to consume all events in the queue, otherwise this may produce lockups when e.g., switching resolutions
Expand All @@ -81,7 +95,7 @@ - (void) pumpRunLoopEventSendAndSignal:(BOOL)signal {
dequeue:YES])) {
// If the event is not a system event or an event of *this* window, queue the event
// Otherwise treat the event normally and send it to the app
if (event.window && event.window != gDelegateApp.window){
if ([self shouldFilterEvent: event]){
[alienEventQueue addObject: event];
}else{
[NSApp sendEvent: event];
Expand Down
5 changes: 4 additions & 1 deletion platforms/iOS/vm/OSX/sqSqueakOSXApplication.h
Expand Up @@ -41,9 +41,12 @@
#import "sqSqueakMainApplication.h"

@interface sqSqueakOSXApplication : sqSqueakMainApplication {
NSCursor *squeakCursor;
NSWindow *aboutWindow;
NSCursor *squeakCursor;

}
@property (nonatomic,strong) NSCursor *squeakCursor;
@property (nonatomic,strong) NSWindow *aboutWindow;

- (int) parseArgument: (NSString *) argData peek: (char *) peek;
- (void) parseArgs: (NSArray *) args;
Expand Down
1 change: 1 addition & 0 deletions platforms/iOS/vm/OSX/sqSqueakOSXApplication.m
Expand Up @@ -104,6 +104,7 @@ void mtfsfi(unsigned long long fpscr) {}

@implementation sqSqueakOSXApplication
@synthesize squeakCursor;
@synthesize aboutWindow;

- (void) setupFloat {
fldcw(0x12bf); /* signed infinity, round to nearest, REAL8, disable intrs, disable signals */
Expand Down

0 comments on commit fa1d55e

Please sign in to comment.