mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-04-20 20:45:02 -05:00
Add a level of indirection to make it rather easier to work out which of a
session's windows we're dealing with. [originally from svn r2804]
This commit is contained in:
parent
be9718cb13
commit
a1e2199dc1
35
mac/mac.c
35
mac/mac.c
@ -1,4 +1,4 @@
|
|||||||
/* $Id: mac.c,v 1.44 2003/02/04 00:33:11 ben Exp $ */
|
/* $Id: mac.c,v 1.45 2003/02/04 23:39:26 ben Exp $ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1999 Ben Harris
|
* Copyright (c) 1999 Ben Harris
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
@ -456,24 +456,15 @@ static void mac_updatelicence(WindowPtr window)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Work out what kind of window we're dealing with.
|
* Work out what kind of window we're dealing with.
|
||||||
* Concept shamelessly nicked from SurfWriter.
|
|
||||||
*/
|
*/
|
||||||
static int mac_windowtype(WindowPtr window) {
|
static int mac_windowtype(WindowPtr window)
|
||||||
int kind;
|
{
|
||||||
long refcon;
|
|
||||||
|
|
||||||
if (window == NULL)
|
#if !TARGET_API_MAC_CARBON
|
||||||
return wNone;
|
if (GetWindowKind(window) < 0)
|
||||||
kind = GetWindowKind(window);
|
|
||||||
if (kind < 0)
|
|
||||||
return wDA;
|
return wDA;
|
||||||
if (GetWVariant(window) == zoomDocProc)
|
#endif
|
||||||
return wTerminal;
|
return ((WinInfo *)GetWRefCon(window))->wtype;
|
||||||
refcon = GetWRefCon(window);
|
|
||||||
if (refcon < 1024)
|
|
||||||
return refcon;
|
|
||||||
else
|
|
||||||
return wSettings;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -568,12 +559,17 @@ static void mac_openabout(void) {
|
|||||||
VersRecHndl vers;
|
VersRecHndl vers;
|
||||||
Rect box;
|
Rect box;
|
||||||
StringPtr longvers;
|
StringPtr longvers;
|
||||||
|
WinInfo *wi;
|
||||||
|
|
||||||
if (windows.about)
|
if (windows.about)
|
||||||
SelectWindow(windows.about);
|
SelectWindow(windows.about);
|
||||||
else {
|
else {
|
||||||
windows.about =
|
windows.about =
|
||||||
GetDialogWindow(GetNewDialog(wAbout, NULL, (WindowPtr)-1));
|
GetDialogWindow(GetNewDialog(wAbout, NULL, (WindowPtr)-1));
|
||||||
|
wi = smalloc(sizeof(*wi));
|
||||||
|
wi->s = NULL;
|
||||||
|
wi->wtype = wAbout;
|
||||||
|
SetWRefCon(windows.about, (long)wi);
|
||||||
vers = (VersRecHndl)Get1Resource('vers', 1);
|
vers = (VersRecHndl)Get1Resource('vers', 1);
|
||||||
if (vers != NULL && *vers != NULL) {
|
if (vers != NULL && *vers != NULL) {
|
||||||
longvers = (*vers)->shortVersion + (*vers)->shortVersion[0] + 1;
|
longvers = (*vers)->shortVersion + (*vers)->shortVersion[0] + 1;
|
||||||
@ -587,11 +583,16 @@ static void mac_openabout(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void mac_openlicence(void) {
|
static void mac_openlicence(void) {
|
||||||
|
WinInfo *wi;
|
||||||
|
|
||||||
if (windows.licence)
|
if (windows.licence)
|
||||||
SelectWindow(windows.licence);
|
SelectWindow(windows.licence);
|
||||||
else {
|
else {
|
||||||
windows.licence = GetNewWindow(wLicence, NULL, (WindowPtr)-1);
|
windows.licence = GetNewWindow(wLicence, NULL, (WindowPtr)-1);
|
||||||
|
wi = smalloc(sizeof(*wi));
|
||||||
|
wi->s = NULL;
|
||||||
|
wi->wtype = wLicence;
|
||||||
|
SetWRefCon(windows.licence, (long)wi);
|
||||||
ShowWindow(windows.licence);
|
ShowWindow(windows.licence);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -601,7 +602,7 @@ static void mac_closewindow(WindowPtr window) {
|
|||||||
switch (mac_windowtype(window)) {
|
switch (mac_windowtype(window)) {
|
||||||
#if !TARGET_API_MAC_CARBON
|
#if !TARGET_API_MAC_CARBON
|
||||||
case wDA:
|
case wDA:
|
||||||
CloseDeskAcc(((WindowPeek)window)->windowKind);
|
CloseDeskAcc(GetWindowKind(window));
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case wTerminal:
|
case wTerminal:
|
||||||
|
@ -40,6 +40,14 @@ extern struct mac_gestalts mac_gestalts;
|
|||||||
#define HAVE_COLOR_QD() (mac_gestalts.qdvers > gestaltOriginalQD)
|
#define HAVE_COLOR_QD() (mac_gestalts.qdvers > gestaltOriginalQD)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Every window used by PuTTY has a refCon field pointing to one of these. */
|
||||||
|
typedef struct {
|
||||||
|
struct Session *s;
|
||||||
|
int wtype;
|
||||||
|
} WinInfo;
|
||||||
|
|
||||||
|
#define mac_windowsession(w) (((WinInfo *)GetWRefCon(w))->s)
|
||||||
|
|
||||||
typedef struct Session {
|
typedef struct Session {
|
||||||
struct Session *next;
|
struct Session *next;
|
||||||
struct Session **prev;
|
struct Session **prev;
|
||||||
|
10
mac/macdlg.c
10
mac/macdlg.c
@ -1,4 +1,4 @@
|
|||||||
/* $Id: macdlg.c,v 1.10 2003/02/02 15:59:00 ben Exp $ */
|
/* $Id: macdlg.c,v 1.11 2003/02/04 23:39:26 ben Exp $ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2002 Ben Harris
|
* Copyright (c) 2002 Ben Harris
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
@ -65,7 +65,7 @@ void mac_newsession(void)
|
|||||||
|
|
||||||
void mac_dupsession(void)
|
void mac_dupsession(void)
|
||||||
{
|
{
|
||||||
Session *s1 = (Session *)GetWRefCon(FrontWindow());
|
Session *s1 = mac_windowsession(FrontWindow());
|
||||||
Session *s2;
|
Session *s2;
|
||||||
|
|
||||||
s2 = smalloc(sizeof(*s2));
|
s2 = smalloc(sizeof(*s2));
|
||||||
@ -180,7 +180,7 @@ void mac_opensession(void)
|
|||||||
|
|
||||||
void mac_savesession(void)
|
void mac_savesession(void)
|
||||||
{
|
{
|
||||||
Session *s = (Session *)GetWRefCon(FrontWindow());
|
Session *s = mac_windowsession(FrontWindow());
|
||||||
void *sesshandle;
|
void *sesshandle;
|
||||||
|
|
||||||
assert(s->hasfile);
|
assert(s->hasfile);
|
||||||
@ -193,7 +193,7 @@ void mac_savesession(void)
|
|||||||
void mac_savesessionas(void)
|
void mac_savesessionas(void)
|
||||||
{
|
{
|
||||||
#if !TARGET_API_MAC_CARBON /* XXX Navigation Services */
|
#if !TARGET_API_MAC_CARBON /* XXX Navigation Services */
|
||||||
Session *s = (Session *)GetWRefCon(FrontWindow());
|
Session *s = mac_windowsession(FrontWindow());
|
||||||
StandardFileReply sfr;
|
StandardFileReply sfr;
|
||||||
void *sesshandle;
|
void *sesshandle;
|
||||||
|
|
||||||
@ -284,7 +284,7 @@ void mac_activatedlg(WindowPtr window, EventRecord *event)
|
|||||||
void mac_clickdlg(WindowPtr window, EventRecord *event)
|
void mac_clickdlg(WindowPtr window, EventRecord *event)
|
||||||
{
|
{
|
||||||
short item;
|
short item;
|
||||||
Session *s = (Session *)GetWRefCon(window);
|
Session *s = mac_windowsession(window);
|
||||||
DialogRef dialog = GetDialogFromWindow(window);
|
DialogRef dialog = GetDialogFromWindow(window);
|
||||||
|
|
||||||
if (DialogSelect(event, &dialog, &item))
|
if (DialogSelect(event, &dialog, &item))
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: macterm.c,v 1.67 2003/02/04 02:08:03 ben Exp $ */
|
/* $Id: macterm.c,v 1.68 2003/02/04 23:39:26 ben Exp $ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1999 Simon Tatham
|
* Copyright (c) 1999 Simon Tatham
|
||||||
* Copyright (c) 1999, 2002 Ben Harris
|
* Copyright (c) 1999, 2002 Ben Harris
|
||||||
@ -98,6 +98,7 @@ void mac_startsession(Session *s)
|
|||||||
{
|
{
|
||||||
char *errmsg;
|
char *errmsg;
|
||||||
int i;
|
int i;
|
||||||
|
WinInfo *wi;
|
||||||
|
|
||||||
init_ucs(s);
|
init_ucs(s);
|
||||||
|
|
||||||
@ -119,7 +120,10 @@ void mac_startsession(Session *s)
|
|||||||
s->window = GetNewCWindow(wTerminal, NULL, (WindowPtr)-1);
|
s->window = GetNewCWindow(wTerminal, NULL, (WindowPtr)-1);
|
||||||
else
|
else
|
||||||
s->window = GetNewWindow(wTerminal, NULL, (WindowPtr)-1);
|
s->window = GetNewWindow(wTerminal, NULL, (WindowPtr)-1);
|
||||||
SetWRefCon(s->window, (long)s);
|
wi = smalloc(sizeof(*wi));
|
||||||
|
wi->s = s;
|
||||||
|
wi->wtype = wTerminal;
|
||||||
|
SetWRefCon(s->window, (long)wi);
|
||||||
s->scrollbar = GetNewControl(cVScroll, s->window);
|
s->scrollbar = GetNewControl(cVScroll, s->window);
|
||||||
s->term = term_init(&s->cfg, &s->ucsdata, s);
|
s->term = term_init(&s->cfg, &s->ucsdata, s);
|
||||||
|
|
||||||
@ -385,7 +389,7 @@ void mac_adjusttermcursor(WindowPtr window, Point mouse, RgnHandle cursrgn) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
SetPort((GrafPtr)GetWindowPort(window));
|
SetPort((GrafPtr)GetWindowPort(window));
|
||||||
s = (Session *)GetWRefCon(window);
|
s = mac_windowsession(window);
|
||||||
GlobalToLocal(&mouse);
|
GlobalToLocal(&mouse);
|
||||||
part = FindControl(mouse, window, &control);
|
part = FindControl(mouse, window, &control);
|
||||||
if (control == s->scrollbar) {
|
if (control == s->scrollbar) {
|
||||||
@ -435,7 +439,7 @@ void mac_adjusttermmenus(WindowPtr window) {
|
|||||||
long offset;
|
long offset;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
s = (Session *)GetWRefCon(window);
|
s = mac_windowsession(window);
|
||||||
menu = GetMenuHandle(mFile);
|
menu = GetMenuHandle(mFile);
|
||||||
DisableItem(menu, iSave); /* XXX enable if modified */
|
DisableItem(menu, iSave); /* XXX enable if modified */
|
||||||
EnableItem(menu, iSaveAs);
|
EnableItem(menu, iSaveAs);
|
||||||
@ -463,7 +467,7 @@ void mac_adjusttermmenus(WindowPtr window) {
|
|||||||
void mac_menuterm(WindowPtr window, short menu, short item) {
|
void mac_menuterm(WindowPtr window, short menu, short item) {
|
||||||
Session *s;
|
Session *s;
|
||||||
|
|
||||||
s = (Session *)GetWRefCon(window);
|
s = mac_windowsession(window);
|
||||||
switch (menu) {
|
switch (menu) {
|
||||||
case mEdit:
|
case mEdit:
|
||||||
switch (item) {
|
switch (item) {
|
||||||
@ -484,7 +488,7 @@ void mac_clickterm(WindowPtr window, EventRecord *event) {
|
|||||||
int part;
|
int part;
|
||||||
static ControlActionUPP mac_scrolltracker_upp = NULL;
|
static ControlActionUPP mac_scrolltracker_upp = NULL;
|
||||||
|
|
||||||
s = (Session *)GetWRefCon(window);
|
s = mac_windowsession(window);
|
||||||
SetPort((GrafPtr)GetWindowPort(window));
|
SetPort((GrafPtr)GetWindowPort(window));
|
||||||
mouse = event->where;
|
mouse = event->where;
|
||||||
GlobalToLocal(&mouse);
|
GlobalToLocal(&mouse);
|
||||||
@ -705,9 +709,9 @@ static pascal void mac_scrolltracker(ControlHandle control, short part) {
|
|||||||
Session *s;
|
Session *s;
|
||||||
|
|
||||||
#if TARGET_API_MAC_CARBON
|
#if TARGET_API_MAC_CARBON
|
||||||
s = (Session *)GetWRefCon(GetControlOwner(control));
|
s = mac_windowsession(GetControlOwner(control));
|
||||||
#else
|
#else
|
||||||
s = (Session *)GetWRefCon((*control)->contrlOwner);
|
s = mac_windowsession((*control)->contrlOwner);
|
||||||
#endif
|
#endif
|
||||||
switch (part) {
|
switch (part) {
|
||||||
case kControlUpButtonPart:
|
case kControlUpButtonPart:
|
||||||
@ -726,7 +730,7 @@ static pascal void mac_scrolltracker(ControlHandle control, short part) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void mac_keyterm(WindowPtr window, EventRecord *event) {
|
void mac_keyterm(WindowPtr window, EventRecord *event) {
|
||||||
Session *s = (Session *)GetWRefCon(window);
|
Session *s = mac_windowsession(window);
|
||||||
Key_Sym keysym = PK_NULL;
|
Key_Sym keysym = PK_NULL;
|
||||||
unsigned int mods = 0, flags = PKF_NUMLOCK;
|
unsigned int mods = 0, flags = PKF_NUMLOCK;
|
||||||
UniChar utxt[1];
|
UniChar utxt[1];
|
||||||
@ -896,7 +900,7 @@ void mac_growterm(WindowPtr window, EventRecord *event) {
|
|||||||
FontInfo fi;
|
FontInfo fi;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
s = (Session *)GetWRefCon(window);
|
s = mac_windowsession(window);
|
||||||
|
|
||||||
#if !TARGET_API_MAC_CARBON
|
#if !TARGET_API_MAC_CARBON
|
||||||
draghooksave = LMGetDragHook();
|
draghooksave = LMGetDragHook();
|
||||||
@ -970,7 +974,7 @@ static pascal void mac_growtermdraghook(void)
|
|||||||
|
|
||||||
void mac_closeterm(WindowPtr window)
|
void mac_closeterm(WindowPtr window)
|
||||||
{
|
{
|
||||||
Session *s = (Session *)GetWRefCon(window);
|
Session *s = mac_windowsession(window);
|
||||||
|
|
||||||
/* XXX warn on close */
|
/* XXX warn on close */
|
||||||
HideWindow(s->window);
|
HideWindow(s->window);
|
||||||
@ -982,6 +986,7 @@ void mac_closeterm(WindowPtr window)
|
|||||||
if (s->uni_to_font != NULL)
|
if (s->uni_to_font != NULL)
|
||||||
DisposeUnicodeToTextInfo(&s->uni_to_font);
|
DisposeUnicodeToTextInfo(&s->uni_to_font);
|
||||||
term_free(s->term);
|
term_free(s->term);
|
||||||
|
sfree((WinInfo *)GetWRefCon(s->window));
|
||||||
DisposeWindow(s->window);
|
DisposeWindow(s->window);
|
||||||
DisposePalette(s->palette);
|
DisposePalette(s->palette);
|
||||||
sfree(s);
|
sfree(s);
|
||||||
@ -990,7 +995,7 @@ void mac_closeterm(WindowPtr window)
|
|||||||
void mac_activateterm(WindowPtr window, Boolean active) {
|
void mac_activateterm(WindowPtr window, Boolean active) {
|
||||||
Session *s;
|
Session *s;
|
||||||
|
|
||||||
s = (Session *)GetWRefCon(window);
|
s = mac_windowsession(window);
|
||||||
s->term->has_focus = active;
|
s->term->has_focus = active;
|
||||||
term_update(s->term);
|
term_update(s->term);
|
||||||
if (active)
|
if (active)
|
||||||
@ -1012,7 +1017,7 @@ void mac_updateterm(WindowPtr window) {
|
|||||||
RgnHandle visrgn;
|
RgnHandle visrgn;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
s = (Session *)GetWRefCon(window);
|
s = mac_windowsession(window);
|
||||||
SetPort((GrafPtr)GetWindowPort(window));
|
SetPort((GrafPtr)GetWindowPort(window));
|
||||||
BeginUpdate(window);
|
BeginUpdate(window);
|
||||||
pre_paint(s);
|
pre_paint(s);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user