Add handling for suspend and resume events, and set the flags in our 'SIZE'
authorben <ben@cda61777-01e9-0310-a592-d414129be87e>
Sun, 23 Feb 2003 11:58:59 +0000 (11:58 +0000)
committerben <ben@cda61777-01e9-0310-a592-d414129be87e>
Sun, 23 Feb 2003 11:58:59 +0000 (11:58 +0000)
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
mac/mac_res.r

index 1ff3a87..d8b9b2f 100644 (file)
--- 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 */
index cdb2143..965b715 100644 (file)
@@ -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,