-/* $Id: mac.c,v 1.49 2003/02/15 16:22:15 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.
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);
}
break;
#endif
+ case osEvt:
+ switch ((event->message & osEvtMessageMask) >> 24) {
+ case suspendResumeMessage:
+ mac_suspendresume(event);
+ break;
+ }
+ break;
case kHighLevelEvent:
AEProcessAppleEvent(event); /* errors? */
break;
static void mac_keypress(EventRecord *event) {
WindowPtr window;
- window = FrontWindow();
+ window = mac_frontwindow();
/*
* Check for a command-key combination, but ignore it if it counts
* as a meta-key combination and we're in a terminal window.
mac_adjustmenus();
mac_menucommand(MenuKey(event->message & charCodeMask));
} else {
- if (mac_wininfo(window)->key != NULL)
+ if (window != NULL && mac_wininfo(window)->key != NULL)
(*mac_wininfo(window)->key)(window, event);
}
}
menu = HiWord(result);
item = LoWord(result);
- window = FrontWindow();
+ window = mac_frontwindow();
/* Things which do the same whatever window we're in. */
switch (menu) {
case mApple:
break;
}
/* 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);
done:
}
}
+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 */
WindowPtr window;
MenuHandle menu;
- window = FrontWindow();
+ window = mac_frontwindow();
menu = GetMenuHandle(mApple);
EnableItem(menu, 0);
EnableItem(menu, iAbout);
DisableItem(menu, iClose);
EnableItem(menu, iQuit);
- if (mac_wininfo(window)->adjustmenus != NULL)
+ if (window != NULL && mac_wininfo(window)->adjustmenus != NULL)
(*mac_wininfo(window)->adjustmenus)(window);
else {
DisableItem(menu, iSave);