mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-04-19 03:58:05 -05:00
Make this compile in a Carbon world (while still supporting everything else).
[originally from svn r2773]
This commit is contained in:
parent
fc17465c33
commit
ac8177763e
104
mac/mac.c
104
mac/mac.c
@ -1,4 +1,4 @@
|
|||||||
/* $Id: mac.c,v 1.41 2003/02/01 21:44:05 ben Exp $ */
|
/* $Id: mac.c,v 1.42 2003/02/01 23:42:30 ben Exp $ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1999 Ben Harris
|
* Copyright (c) 1999 Ben Harris
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
@ -62,7 +62,9 @@
|
|||||||
#include "ssh.h"
|
#include "ssh.h"
|
||||||
#include "mac.h"
|
#include "mac.h"
|
||||||
|
|
||||||
|
#if !TARGET_API_MAC_CARBON
|
||||||
QDGlobals qd;
|
QDGlobals qd;
|
||||||
|
#endif
|
||||||
|
|
||||||
Session *sesslist;
|
Session *sesslist;
|
||||||
|
|
||||||
@ -110,6 +112,7 @@ static void mac_startup(void) {
|
|||||||
Handle menuBar;
|
Handle menuBar;
|
||||||
TECInfoHandle ti;
|
TECInfoHandle ti;
|
||||||
|
|
||||||
|
#if !TARGET_API_MAC_CARBON
|
||||||
/* Init Memory Manager */
|
/* Init Memory Manager */
|
||||||
MaxApplZone();
|
MaxApplZone();
|
||||||
/* Init QuickDraw */
|
/* Init QuickDraw */
|
||||||
@ -124,6 +127,7 @@ static void mac_startup(void) {
|
|||||||
TEInit();
|
TEInit();
|
||||||
/* Init Dialog Manager */
|
/* Init Dialog Manager */
|
||||||
InitDialogs(NULL);
|
InitDialogs(NULL);
|
||||||
|
#endif
|
||||||
cold = 0;
|
cold = 0;
|
||||||
|
|
||||||
/* Get base system version (only used if there's no better selector) */
|
/* Get base system version (only used if there's no better selector) */
|
||||||
@ -202,6 +206,7 @@ static void mac_startup(void) {
|
|||||||
}
|
}
|
||||||
flags = FLAG_INTERACTIVE;
|
flags = FLAG_INTERACTIVE;
|
||||||
|
|
||||||
|
#if !TARGET_API_MAC_CARBON
|
||||||
{
|
{
|
||||||
short vol;
|
short vol;
|
||||||
long dirid;
|
long dirid;
|
||||||
@ -213,6 +218,7 @@ static void mac_startup(void) {
|
|||||||
LMSetCurDirStore(dirid);
|
LMSetCurDirStore(dirid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Install Apple Event handlers. */
|
/* Install Apple Event handlers. */
|
||||||
AEInstallEventHandler(kCoreEventClass, kAEOpenApplication,
|
AEInstallEventHandler(kCoreEventClass, kAEOpenApplication,
|
||||||
@ -248,7 +254,6 @@ static void mac_eventloop(void) {
|
|||||||
static void mac_event(EventRecord *event) {
|
static void mac_event(EventRecord *event) {
|
||||||
short part;
|
short part;
|
||||||
WindowPtr window;
|
WindowPtr window;
|
||||||
Point pt;
|
|
||||||
|
|
||||||
switch (event->what) {
|
switch (event->what) {
|
||||||
case mouseDown:
|
case mouseDown:
|
||||||
@ -258,9 +263,11 @@ static void mac_event(EventRecord *event) {
|
|||||||
mac_adjustmenus();
|
mac_adjustmenus();
|
||||||
mac_menucommand(MenuSelect(event->where));
|
mac_menucommand(MenuSelect(event->where));
|
||||||
break;
|
break;
|
||||||
|
#if !TARGET_API_MAC_CARBON
|
||||||
case inSysWindow:
|
case inSysWindow:
|
||||||
SystemClick(event, window);
|
SystemClick(event, window);
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
case inContent:
|
case inContent:
|
||||||
if (window != FrontWindow())
|
if (window != FrontWindow())
|
||||||
/* XXX: check for movable modal dboxes? */
|
/* XXX: check for movable modal dboxes? */
|
||||||
@ -274,7 +281,16 @@ static void mac_event(EventRecord *event) {
|
|||||||
break;
|
break;
|
||||||
case inDrag:
|
case inDrag:
|
||||||
/* XXX: moveable modal check? */
|
/* XXX: moveable modal check? */
|
||||||
|
#if TARGET_API_MAC_CARBON
|
||||||
|
{
|
||||||
|
BitMap screenBits;
|
||||||
|
|
||||||
|
GetQDGlobalsScreenBits(&screenBits);
|
||||||
|
DragWindow(window, event->where, &screenBits.bounds);
|
||||||
|
}
|
||||||
|
#else
|
||||||
DragWindow(window, event->where, &qd.screenBits.bounds);
|
DragWindow(window, event->where, &qd.screenBits.bounds);
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
case inGrow:
|
case inGrow:
|
||||||
mac_growwindow(window, event);
|
mac_growwindow(window, event);
|
||||||
@ -296,12 +312,16 @@ static void mac_event(EventRecord *event) {
|
|||||||
case updateEvt:
|
case updateEvt:
|
||||||
mac_updatewindow((WindowPtr)event->message);
|
mac_updatewindow((WindowPtr)event->message);
|
||||||
break;
|
break;
|
||||||
|
#if !TARGET_API_MAC_CARBON
|
||||||
case diskEvt:
|
case diskEvt:
|
||||||
if (HiWord(event->message) != noErr) {
|
if (HiWord(event->message) != noErr) {
|
||||||
|
Point pt;
|
||||||
|
|
||||||
SetPt(&pt, 120, 120);
|
SetPt(&pt, 120, 120);
|
||||||
DIBadMount(pt, event->message);
|
DIBadMount(pt, event->message);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
case kHighLevelEvent:
|
case kHighLevelEvent:
|
||||||
AEProcessAppleEvent(event); /* errors? */
|
AEProcessAppleEvent(event); /* errors? */
|
||||||
break;
|
break;
|
||||||
@ -310,13 +330,15 @@ static void mac_event(EventRecord *event) {
|
|||||||
|
|
||||||
static void mac_contentclick(WindowPtr window, EventRecord *event) {
|
static void mac_contentclick(WindowPtr window, EventRecord *event) {
|
||||||
short item;
|
short item;
|
||||||
|
DialogRef dialog;
|
||||||
|
|
||||||
switch (mac_windowtype(window)) {
|
switch (mac_windowtype(window)) {
|
||||||
case wTerminal:
|
case wTerminal:
|
||||||
mac_clickterm(window, event);
|
mac_clickterm(window, event);
|
||||||
break;
|
break;
|
||||||
case wAbout:
|
case wAbout:
|
||||||
if (DialogSelect(event, &window, &item))
|
dialog = GetDialogFromWindow(window);
|
||||||
|
if (DialogSelect(event, &dialog, &item))
|
||||||
switch (item) {
|
switch (item) {
|
||||||
case wiAboutLicence:
|
case wiAboutLicence:
|
||||||
mac_openlicence();
|
mac_openlicence();
|
||||||
@ -356,19 +378,25 @@ static void mac_activatewindow(WindowPtr window, EventRecord *event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void mac_activateabout(WindowPtr window, EventRecord *event) {
|
static void mac_activateabout(WindowPtr window, EventRecord *event) {
|
||||||
|
DialogRef dialog;
|
||||||
DialogItemType itemtype;
|
DialogItemType itemtype;
|
||||||
Handle itemhandle;
|
Handle itemhandle;
|
||||||
short item;
|
short item;
|
||||||
Rect itemrect;
|
Rect itemrect;
|
||||||
int active;
|
int active;
|
||||||
|
|
||||||
|
dialog = GetDialogFromWindow(window);
|
||||||
active = (event->modifiers & activeFlag) != 0;
|
active = (event->modifiers & activeFlag) != 0;
|
||||||
GetDialogItem(window, wiAboutLicence, &itemtype, &itemhandle, &itemrect);
|
GetDialogItem(dialog, wiAboutLicence, &itemtype, &itemhandle, &itemrect);
|
||||||
HiliteControl((ControlHandle)itemhandle, active ? 0 : 255);
|
HiliteControl((ControlHandle)itemhandle, active ? 0 : 255);
|
||||||
DialogSelect(event, &window, &item);
|
DialogSelect(event, &dialog, &item);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mac_updatewindow(WindowPtr window) {
|
static void mac_updatewindow(WindowPtr window)
|
||||||
|
{
|
||||||
|
#if TARGET_API_MAC_CARBON
|
||||||
|
RgnHandle rgn;
|
||||||
|
#endif
|
||||||
|
|
||||||
switch (mac_windowtype(window)) {
|
switch (mac_windowtype(window)) {
|
||||||
case wTerminal:
|
case wTerminal:
|
||||||
@ -377,7 +405,14 @@ static void mac_updatewindow(WindowPtr window) {
|
|||||||
case wAbout:
|
case wAbout:
|
||||||
case wSettings:
|
case wSettings:
|
||||||
BeginUpdate(window);
|
BeginUpdate(window);
|
||||||
|
#if TARGET_API_MAC_CARBON
|
||||||
|
rgn = NewRgn();
|
||||||
|
GetPortVisibleRegion(GetWindowPort(window), rgn);
|
||||||
|
UpdateDialog(GetDialogFromWindow(window), rgn);
|
||||||
|
DisposeRgn(rgn);
|
||||||
|
#else
|
||||||
UpdateDialog(window, window->visRgn);
|
UpdateDialog(window, window->visRgn);
|
||||||
|
#endif
|
||||||
EndUpdate(window);
|
EndUpdate(window);
|
||||||
break;
|
break;
|
||||||
case wLicence:
|
case wLicence:
|
||||||
@ -391,17 +426,23 @@ static void mac_updatelicence(WindowPtr window)
|
|||||||
Handle h;
|
Handle h;
|
||||||
int len;
|
int len;
|
||||||
long fondsize;
|
long fondsize;
|
||||||
|
Rect textrect;
|
||||||
|
|
||||||
SetPort(window);
|
SetPort((GrafPtr)GetWindowPort(window));
|
||||||
BeginUpdate(window);
|
BeginUpdate(window);
|
||||||
fondsize = GetScriptVariable(smRoman, smScriptSmallFondSize);
|
fondsize = GetScriptVariable(smRoman, smScriptSmallFondSize);
|
||||||
TextFont(HiWord(fondsize));
|
TextFont(HiWord(fondsize));
|
||||||
TextSize(LoWord(fondsize));
|
TextSize(LoWord(fondsize));
|
||||||
h = Get1Resource('TEXT', wLicence);
|
h = Get1Resource('TEXT', wLicence);
|
||||||
len = GetResourceSizeOnDisk(h);
|
len = GetResourceSizeOnDisk(h);
|
||||||
|
#if TARGET_API_MAC_CARBON
|
||||||
|
GetPortBounds(GetWindowPort(window), &textrect);
|
||||||
|
#else
|
||||||
|
textrect = window->portRect;
|
||||||
|
#endif
|
||||||
if (h != NULL) {
|
if (h != NULL) {
|
||||||
HLock(h);
|
HLock(h);
|
||||||
TETextBox(*h, len, &window->portRect, teFlushDefault);
|
TETextBox(*h, len, &textrect, teFlushDefault);
|
||||||
HUnlock(h);
|
HUnlock(h);
|
||||||
}
|
}
|
||||||
EndUpdate(window);
|
EndUpdate(window);
|
||||||
@ -417,7 +458,7 @@ static int mac_windowtype(WindowPtr window) {
|
|||||||
|
|
||||||
if (window == NULL)
|
if (window == NULL)
|
||||||
return wNone;
|
return wNone;
|
||||||
kind = ((WindowPeek)window)->windowKind;
|
kind = GetWindowKind(window);
|
||||||
if (kind < 0)
|
if (kind < 0)
|
||||||
return wDA;
|
return wDA;
|
||||||
if (GetWVariant(window) == zoomDocProc)
|
if (GetWVariant(window) == zoomDocProc)
|
||||||
@ -456,14 +497,17 @@ static void mac_keypress(EventRecord *event) {
|
|||||||
|
|
||||||
static void mac_menucommand(long result) {
|
static void mac_menucommand(long result) {
|
||||||
short menu, item;
|
short menu, item;
|
||||||
Str255 da;
|
|
||||||
WindowPtr window;
|
WindowPtr window;
|
||||||
|
#if !TARGET_API_MAC_CARBON
|
||||||
|
Str255 da;
|
||||||
|
#endif
|
||||||
|
|
||||||
menu = HiWord(result);
|
menu = HiWord(result);
|
||||||
item = LoWord(result);
|
item = LoWord(result);
|
||||||
window = FrontWindow();
|
window = 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) {
|
||||||
|
#if !TARGET_API_MAC_CARBON
|
||||||
case mApple:
|
case mApple:
|
||||||
switch (item) {
|
switch (item) {
|
||||||
case iAbout:
|
case iAbout:
|
||||||
@ -475,6 +519,7 @@ static void mac_menucommand(long result) {
|
|||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
case mFile:
|
case mFile:
|
||||||
switch (item) {
|
switch (item) {
|
||||||
case iNew:
|
case iNew:
|
||||||
@ -521,11 +566,12 @@ static void mac_openabout(void) {
|
|||||||
if (windows.about)
|
if (windows.about)
|
||||||
SelectWindow(windows.about);
|
SelectWindow(windows.about);
|
||||||
else {
|
else {
|
||||||
windows.about = GetNewDialog(wAbout, NULL, (WindowPtr)-1);
|
windows.about =
|
||||||
|
GetDialogWindow(GetNewDialog(wAbout, NULL, (WindowPtr)-1));
|
||||||
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;
|
||||||
GetDialogItem(windows.about, wiAboutVersion,
|
GetDialogItem(GetDialogFromWindow(windows.about), wiAboutVersion,
|
||||||
&itemtype, &item, &box);
|
&itemtype, &item, &box);
|
||||||
assert(itemtype & kStaticTextDialogItem);
|
assert(itemtype & kStaticTextDialogItem);
|
||||||
SetDialogItemText(item, longvers);
|
SetDialogItemText(item, longvers);
|
||||||
@ -547,15 +593,17 @@ static void mac_openlicence(void) {
|
|||||||
static void mac_closewindow(WindowPtr window) {
|
static void mac_closewindow(WindowPtr window) {
|
||||||
|
|
||||||
switch (mac_windowtype(window)) {
|
switch (mac_windowtype(window)) {
|
||||||
|
#if !TARGET_API_MAC_CARBON
|
||||||
case wDA:
|
case wDA:
|
||||||
CloseDeskAcc(((WindowPeek)window)->windowKind);
|
CloseDeskAcc(((WindowPeek)window)->windowKind);
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
case wTerminal:
|
case wTerminal:
|
||||||
mac_closeterm(window);
|
mac_closeterm(window);
|
||||||
break;
|
break;
|
||||||
case wAbout:
|
case wAbout:
|
||||||
windows.about = NULL;
|
windows.about = NULL;
|
||||||
DisposeDialog(window);
|
DisposeDialog(GetDialogFromWindow(window));
|
||||||
break;
|
break;
|
||||||
case wLicence:
|
case wLicence:
|
||||||
windows.licence = NULL;
|
windows.licence = NULL;
|
||||||
@ -572,6 +620,11 @@ static void mac_zoomwindow(WindowPtr window, short part) {
|
|||||||
/*
|
/*
|
||||||
* Make the menus look right before the user gets to see them.
|
* Make the menus look right before the user gets to see them.
|
||||||
*/
|
*/
|
||||||
|
#if TARGET_API_MAC_CARBON
|
||||||
|
/* XXX Is this good enough? What about Carbon on OS 8.1? */
|
||||||
|
#define EnableItem EnableMenuItem
|
||||||
|
#define DisableItem DisableMenuItem
|
||||||
|
#endif
|
||||||
static void mac_adjustmenus(void) {
|
static void mac_adjustmenus(void) {
|
||||||
WindowPtr window;
|
WindowPtr window;
|
||||||
MenuHandle menu;
|
MenuHandle menu;
|
||||||
@ -619,6 +672,10 @@ static void mac_adjustcursor(RgnHandle cursrgn) {
|
|||||||
Point mouse;
|
Point mouse;
|
||||||
WindowPtr window, front;
|
WindowPtr window, front;
|
||||||
short part;
|
short part;
|
||||||
|
#if TARGET_API_MAC_CARBON
|
||||||
|
Cursor arrow;
|
||||||
|
RgnHandle visrgn;
|
||||||
|
#endif
|
||||||
|
|
||||||
GetMouse(&mouse);
|
GetMouse(&mouse);
|
||||||
LocalToGlobal(&mouse);
|
LocalToGlobal(&mouse);
|
||||||
@ -626,18 +683,37 @@ static void mac_adjustcursor(RgnHandle cursrgn) {
|
|||||||
front = FrontWindow();
|
front = FrontWindow();
|
||||||
if (part != inContent || window == NULL || window != front) {
|
if (part != inContent || window == NULL || window != front) {
|
||||||
/* Cursor isn't in the front window, so switch to arrow */
|
/* Cursor isn't in the front window, so switch to arrow */
|
||||||
|
#if TARGET_API_MAC_CARBON
|
||||||
|
GetQDGlobalsArrow(&arrow);
|
||||||
|
SetCursor(&arrow);
|
||||||
|
#else
|
||||||
SetCursor(&qd.arrow);
|
SetCursor(&qd.arrow);
|
||||||
|
#endif
|
||||||
SetRectRgn(cursrgn, SHRT_MIN, SHRT_MIN, SHRT_MAX, SHRT_MAX);
|
SetRectRgn(cursrgn, SHRT_MIN, SHRT_MIN, SHRT_MAX, SHRT_MAX);
|
||||||
if (front != NULL)
|
if (front != NULL) {
|
||||||
|
#if TARGET_API_MAC_CARBON
|
||||||
|
visrgn = NewRgn();
|
||||||
|
GetPortVisibleRegion(GetWindowPort(front), visrgn);
|
||||||
|
DiffRgn(cursrgn, visrgn, cursrgn);
|
||||||
|
DisposeRgn(visrgn);
|
||||||
|
#else
|
||||||
DiffRgn(cursrgn, front->visRgn, cursrgn);
|
DiffRgn(cursrgn, front->visRgn, cursrgn);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
switch (mac_windowtype(window)) {
|
switch (mac_windowtype(window)) {
|
||||||
case wTerminal:
|
case wTerminal:
|
||||||
mac_adjusttermcursor(window, mouse, cursrgn);
|
mac_adjusttermcursor(window, mouse, cursrgn);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
#if TARGET_API_MAC_CARBON
|
||||||
|
GetQDGlobalsArrow(&arrow);
|
||||||
|
SetCursor(&arrow);
|
||||||
|
GetPortVisibleRegion(GetWindowPort(window), cursrgn);
|
||||||
|
#else
|
||||||
SetCursor(&qd.arrow);
|
SetCursor(&qd.arrow);
|
||||||
CopyRgn(window->visRgn, cursrgn);
|
CopyRgn(window->visRgn, cursrgn);
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user