From 0c5c7f5c1841d6e3d1897e77ea9ee07943f401bf Mon Sep 17 00:00:00 2001 From: ben Date: Sun, 23 Feb 2003 11:58:59 +0000 Subject: [PATCH] Add handling for suspend and resume events, and set the flags in our 'SIZE' resource that say we can handle them. This seems to avoid a crash when PuTTY's switched away from, and is necessary for Carbon anyway. git-svn-id: svn://svn.tartarus.org/sgt/putty@2878 cda61777-01e9-0310-a592-d414129be87e --- mac/mac.c | 31 ++++++++++++++++++++++++++++++- mac/mac_res.r | 6 +++--- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/mac/mac.c b/mac/mac.c index 1ff3a87f..d8b9b2fa 100644 --- a/mac/mac.c +++ b/mac/mac.c @@ -1,4 +1,4 @@ -/* $Id: mac.c,v 1.50 2003/02/20 22:31:52 ben Exp $ */ +/* $Id: mac.c,v 1.51 2003/02/23 11:58:59 ben Exp $ */ /* * Copyright (c) 1999, 2003 Ben Harris * All rights reserved. @@ -76,6 +76,7 @@ static void mac_event(EventRecord *); static void mac_contentclick(WindowPtr, EventRecord *); static void mac_growwindow(WindowPtr, EventRecord *); static void mac_activatewindow(WindowPtr, EventRecord *); +static void mac_suspendresume(EventRecord *); static void mac_activateabout(WindowPtr, EventRecord *); static void mac_updatewindow(WindowPtr); static void mac_updatelicence(WindowPtr); @@ -323,6 +324,13 @@ static void mac_event(EventRecord *event) { } break; #endif + case osEvt: + switch ((event->message & osEvtMessageMask) >> 24) { + case suspendResumeMessage: + mac_suspendresume(event); + break; + } + break; case kHighLevelEvent: AEProcessAppleEvent(event); /* errors? */ break; @@ -467,6 +475,27 @@ static void mac_closewindow(WindowPtr window) { } } +static void mac_suspendresume(EventRecord *event) +{ + WindowPtr front; + EventRecord fakeevent; + + /* + * We're called either before we're suspended or after we're + * resumed, so we're the front application at this point. + */ + front = FrontWindow(); + if (front != NULL) { + fakeevent.what = activateEvt; + fakeevent.message = (UInt32)front; + fakeevent.when = event->when; + fakeevent.where = event->where; + fakeevent.modifiers = + (event->message & resumeFlag) ? activeFlag : 0; + mac_activatewindow(front, &fakeevent); + } +} + static void mac_zoomwindow(WindowPtr window, short part) { /* FIXME: do something */ diff --git a/mac/mac_res.r b/mac/mac_res.r index cdb21437..965b7153 100644 --- a/mac/mac_res.r +++ b/mac/mac_res.r @@ -1,4 +1,4 @@ -/* $Id: mac_res.r,v 1.27 2003/02/12 23:53:15 ben Exp $ */ +/* $Id: mac_res.r,v 1.28 2003/02/23 11:58:59 ben Exp $ */ /* * Copyright (c) 1999, 2002 Ben Harris * All rights reserved. @@ -57,10 +57,10 @@ resource 'pTTY' (0, purgeable) { resource 'SIZE' (-1) { reserved, - ignoreSuspendResumeEvents, + acceptSuspendResumeEvents, reserved, canBackground, - needsActivateOnFGSwitch, + doesActivateOnFGSwitch, backgroundAndForeground, dontGetFrontClicks, ignoreAppDiedEvents, -- 2.11.0