Revert "Made other windows get events when a dialog is running on OS X. Of course I only now realize this creates a recursiion problem..."

This isn't going to work. The only real solution is to disable every window like we're already doing here, make sure it happens on GTK+, and re-add the dialog helper stuff on Windows.

This reverts commit 20994639c0.
This commit is contained in:
Pietro Gagliardi 2016-05-15 19:04:35 -04:00
parent 52fff1520d
commit 0552e7c4a1
2 changed files with 6 additions and 39 deletions

View File

@ -1,6 +1,8 @@
// 26 june 2015
#import "uipriv_darwin.h"
// TODO while a dialog is running no other window receives events
#define windowWindow(w) ((NSWindow *) uiControlHandle(uiControl(w)))
// source of code modal logic: http://stackoverflow.com/questions/604768/wait-for-nsalert-beginsheetmodalforwindow
@ -18,16 +20,11 @@ static void setupSavePanel(NSSavePanel *s)
static char *runSavePanel(NSWindow *parent, NSSavePanel *s)
{
char *filename;
NSInteger res;
// TODO formalize in headers
[(id)parent setWorksWhenModal:NO];
[s beginSheetModalForWindow:parent completionHandler:^(NSInteger result) {
[realNSApp() stopModalWithCode:result];
}];
res = [realNSApp() runModalForWindow:s];
[(id)parent setWorksWhenModal:YES];
if (res != NSFileHandlingPanelOKButton)
if ([realNSApp() runModalForWindow:s] != NSFileHandlingPanelOKButton)
return NULL;
filename = uiDarwinNSStringToText([[s URL] path]);
return filename;
@ -81,17 +78,11 @@ char *uiSaveFile(uiWindow *parent)
- (NSInteger)run
{
NSInteger res;
// TODO like above
[(id)(self->parent) setWorksWhenModal:NO];
[self->panel beginSheetModalForWindow:self->parent
modalDelegate:self
didEndSelector:@selector(panelEnded:result:data:)
contextInfo:NULL];
res = [realNSApp() runModalForWindow:[self->panel window]];
[(id)(self->parent) setWorksWhenModal:YES];
return res;
return [realNSApp() runModalForWindow:[self->panel window]];
}
- (void)panelEnded:(NSAlert *)panel result:(NSInteger)result data:(void *)data

View File

@ -1,16 +1,9 @@
// 15 august 2015
#import "uipriv_darwin.h"
// don't stop other windows from working when one is modal
@interface modalWindow : NSWindow {
BOOL worksModal;
}
- (BOOL)setWorksWhenModal:(BOOL)wwm;
@end
struct uiWindow {
uiDarwinControl c;
modalWindow *window;
NSWindow *window;
uiControl *child;
int margined;
int (*onClosing)(uiWindow *, void *);
@ -18,20 +11,6 @@ struct uiWindow {
struct singleChildConstraints constraints;
};
@implementation modalWindow
- (BOOL)worksWhenModal
{
return self->worksModal;
}
- (void)setWorksWhenModal:(BOOL)wwm
{
self->worksModal = wwm;
}
@end
@interface windowDelegateClass : NSObject<NSWindowDelegate> {
struct mapTable *windows;
}
@ -263,15 +242,12 @@ uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar)
uiDarwinNewControl(uiWindow, w);
w->window = [[modalWindow alloc] initWithContentRect:NSMakeRect(0, 0, (CGFloat) width, (CGFloat) height)
w->window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, (CGFloat) width, (CGFloat) height)
styleMask:(NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask)
backing:NSBackingStoreBuffered
defer:YES];
[w->window setTitle:toNSString(title)];
// default is to work when modal; only the modal owner window should not work when modal
[w->window setWorksWhenModal:YES];
// explicitly release when closed
// the only thing that closes the window is us anyway
[w->window setReleasedWhenClosed:YES];