diff --git a/mac/mac.c b/mac/mac.c index a0bc998b..1ff3a87f 100644 --- a/mac/mac.c +++ b/mac/mac.c @@ -1,4 +1,4 @@ -/* $Id: mac.c,v 1.49 2003/02/15 16:22:15 ben Exp $ */ +/* $Id: mac.c,v 1.50 2003/02/20 22:31:52 ben Exp $ */ /* * Copyright (c) 1999, 2003 Ben Harris * All rights reserved. @@ -377,7 +377,7 @@ static int mac_windowtype(WindowPtr window) static void mac_keypress(EventRecord *event) { WindowPtr window; - window = FrontWindow(); + window = mac_frontwindow(); /* * Check for a command-key combination, but ignore it if it counts * as a meta-key combination and we're in a terminal window. @@ -388,7 +388,7 @@ static void mac_keypress(EventRecord *event) { mac_adjustmenus(); mac_menucommand(MenuKey(event->message & charCodeMask)); } else { - if (mac_wininfo(window)->key != NULL) + if (window != NULL && mac_wininfo(window)->key != NULL) (*mac_wininfo(window)->key)(window, event); } } @@ -402,7 +402,7 @@ static void mac_menucommand(long result) { menu = HiWord(result); item = LoWord(result); - window = FrontWindow(); + window = mac_frontwindow(); /* Things which do the same whatever window we're in. */ switch (menu) { case mApple: @@ -445,7 +445,7 @@ static void mac_menucommand(long result) { break; } /* If we get here, handling is up to window-specific code. */ - if (mac_wininfo(window)->menu != NULL) + if (window != NULL && mac_wininfo(window)->menu != NULL) (*mac_wininfo(window)->menu)(window, menu, item); done: @@ -483,7 +483,7 @@ static void mac_adjustmenus(void) { WindowPtr window; MenuHandle menu; - window = FrontWindow(); + window = mac_frontwindow(); menu = GetMenuHandle(mApple); EnableItem(menu, 0); EnableItem(menu, iAbout); @@ -497,7 +497,7 @@ static void mac_adjustmenus(void) { DisableItem(menu, iClose); EnableItem(menu, iQuit); - if (mac_wininfo(window)->adjustmenus != NULL) + if (window != NULL && mac_wininfo(window)->adjustmenus != NULL) (*mac_wininfo(window)->adjustmenus)(window); else { DisableItem(menu, iSave); diff --git a/mac/mac.h b/mac/mac.h index c228d1bd..e18ff742 100644 --- a/mac/mac.h +++ b/mac/mac.h @@ -112,10 +112,16 @@ extern Session *sesslist; /* PuTTYgen per-window state */ typedef struct KeyState { DialogPtr box; + int collecting_entropy; + int entropy_got, entropy_required, entropy_size; + unsigned *entropy; + ControlHandle progress; } KeyState; #define mac_windowkey(w) (((WinInfo *)GetWRefCon(w))->ks) +/* from macmisc.c */ +extern WindowPtr mac_frontwindow(void); /* from macdlg.c */ extern void mac_newsession(void); extern void mac_dupsession(void); diff --git a/mac/macmisc.c b/mac/macmisc.c index a5cb1f5f..b2479781 100644 --- a/mac/macmisc.c +++ b/mac/macmisc.c @@ -1,4 +1,4 @@ -/* $Id: macmisc.c,v 1.1 2003/02/12 23:53:15 ben Exp $ */ +/* $Id: macmisc.c,v 1.2 2003/02/20 22:31:52 ben Exp $ */ /* * Copyright (c) 1999, 2003 Ben Harris * All rights reserved. @@ -28,6 +28,8 @@ #include #include #include +#include +#include #include #include @@ -35,6 +37,7 @@ #include #include "putty.h" +#include "mac.h" #if TARGET_API_MAC_CARBON /* @@ -48,6 +51,22 @@ const CFAllocatorRef kCFAllocatorDefault = NULL; QDGlobals qd; #endif +/* + * Like FrontWindow(), but return NULL if we aren't the front process + * (i.e. the front window isn't one of ours). + */ +WindowPtr mac_frontwindow(void) +{ + ProcessSerialNumber frontpsn; + ProcessSerialNumber curpsn = { 0, kCurrentProcess }; + Boolean result; + + GetFrontProcess(&frontpsn); + if (SameProcess(&frontpsn, &curpsn, &result) == noErr && result) + return FrontWindow(); + return NULL; +} + void fatalbox(char *fmt, ...) { va_list ap; Str255 stuff;