mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-10 09:58:01 +00:00
Be careful not to try to get information from windows we don't own, or that
don't exist at all. Also a small PuTTYgen change that I can't be bothered to filter out of this commit. [originally from svn r2874]
This commit is contained in:
parent
fb90fa8650
commit
f53c998569
14
mac/mac.c
14
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
|
* Copyright (c) 1999, 2003 Ben Harris
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
@ -377,7 +377,7 @@ static int mac_windowtype(WindowPtr window)
|
|||||||
static void mac_keypress(EventRecord *event) {
|
static void mac_keypress(EventRecord *event) {
|
||||||
WindowPtr window;
|
WindowPtr window;
|
||||||
|
|
||||||
window = FrontWindow();
|
window = mac_frontwindow();
|
||||||
/*
|
/*
|
||||||
* Check for a command-key combination, but ignore it if it counts
|
* Check for a command-key combination, but ignore it if it counts
|
||||||
* as a meta-key combination and we're in a terminal window.
|
* 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_adjustmenus();
|
||||||
mac_menucommand(MenuKey(event->message & charCodeMask));
|
mac_menucommand(MenuKey(event->message & charCodeMask));
|
||||||
} else {
|
} else {
|
||||||
if (mac_wininfo(window)->key != NULL)
|
if (window != NULL && mac_wininfo(window)->key != NULL)
|
||||||
(*mac_wininfo(window)->key)(window, event);
|
(*mac_wininfo(window)->key)(window, event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -402,7 +402,7 @@ static void mac_menucommand(long result) {
|
|||||||
|
|
||||||
menu = HiWord(result);
|
menu = HiWord(result);
|
||||||
item = LoWord(result);
|
item = LoWord(result);
|
||||||
window = FrontWindow();
|
window = mac_frontwindow();
|
||||||
/* Things which do the same whatever window we're in. */
|
/* Things which do the same whatever window we're in. */
|
||||||
switch (menu) {
|
switch (menu) {
|
||||||
case mApple:
|
case mApple:
|
||||||
@ -445,7 +445,7 @@ static void mac_menucommand(long result) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* If we get here, handling is up to window-specific code. */
|
/* 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);
|
(*mac_wininfo(window)->menu)(window, menu, item);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
@ -483,7 +483,7 @@ static void mac_adjustmenus(void) {
|
|||||||
WindowPtr window;
|
WindowPtr window;
|
||||||
MenuHandle menu;
|
MenuHandle menu;
|
||||||
|
|
||||||
window = FrontWindow();
|
window = mac_frontwindow();
|
||||||
menu = GetMenuHandle(mApple);
|
menu = GetMenuHandle(mApple);
|
||||||
EnableItem(menu, 0);
|
EnableItem(menu, 0);
|
||||||
EnableItem(menu, iAbout);
|
EnableItem(menu, iAbout);
|
||||||
@ -497,7 +497,7 @@ static void mac_adjustmenus(void) {
|
|||||||
DisableItem(menu, iClose);
|
DisableItem(menu, iClose);
|
||||||
EnableItem(menu, iQuit);
|
EnableItem(menu, iQuit);
|
||||||
|
|
||||||
if (mac_wininfo(window)->adjustmenus != NULL)
|
if (window != NULL && mac_wininfo(window)->adjustmenus != NULL)
|
||||||
(*mac_wininfo(window)->adjustmenus)(window);
|
(*mac_wininfo(window)->adjustmenus)(window);
|
||||||
else {
|
else {
|
||||||
DisableItem(menu, iSave);
|
DisableItem(menu, iSave);
|
||||||
|
@ -112,10 +112,16 @@ extern Session *sesslist;
|
|||||||
/* PuTTYgen per-window state */
|
/* PuTTYgen per-window state */
|
||||||
typedef struct KeyState {
|
typedef struct KeyState {
|
||||||
DialogPtr box;
|
DialogPtr box;
|
||||||
|
int collecting_entropy;
|
||||||
|
int entropy_got, entropy_required, entropy_size;
|
||||||
|
unsigned *entropy;
|
||||||
|
ControlHandle progress;
|
||||||
} KeyState;
|
} KeyState;
|
||||||
|
|
||||||
#define mac_windowkey(w) (((WinInfo *)GetWRefCon(w))->ks)
|
#define mac_windowkey(w) (((WinInfo *)GetWRefCon(w))->ks)
|
||||||
|
|
||||||
|
/* from macmisc.c */
|
||||||
|
extern WindowPtr mac_frontwindow(void);
|
||||||
/* from macdlg.c */
|
/* from macdlg.c */
|
||||||
extern void mac_newsession(void);
|
extern void mac_newsession(void);
|
||||||
extern void mac_dupsession(void);
|
extern void mac_dupsession(void);
|
||||||
|
@ -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
|
* Copyright (c) 1999, 2003 Ben Harris
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
@ -28,6 +28,8 @@
|
|||||||
#include <MacTypes.h>
|
#include <MacTypes.h>
|
||||||
#include <Dialogs.h>
|
#include <Dialogs.h>
|
||||||
#include <Files.h>
|
#include <Files.h>
|
||||||
|
#include <MacWindows.h>
|
||||||
|
#include <Processes.h>
|
||||||
#include <Quickdraw.h>
|
#include <Quickdraw.h>
|
||||||
#include <TextUtils.h>
|
#include <TextUtils.h>
|
||||||
|
|
||||||
@ -35,6 +37,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "putty.h"
|
#include "putty.h"
|
||||||
|
#include "mac.h"
|
||||||
|
|
||||||
#if TARGET_API_MAC_CARBON
|
#if TARGET_API_MAC_CARBON
|
||||||
/*
|
/*
|
||||||
@ -48,6 +51,22 @@ const CFAllocatorRef kCFAllocatorDefault = NULL;
|
|||||||
QDGlobals qd;
|
QDGlobals qd;
|
||||||
#endif
|
#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, ...) {
|
void fatalbox(char *fmt, ...) {
|
||||||
va_list ap;
|
va_list ap;
|
||||||
Str255 stuff;
|
Str255 stuff;
|
||||||
|
Loading…
Reference in New Issue
Block a user