+/*
+ * Like FrontWindow(), but return NULL if we aren't the front process
+ * (i.e. the front window isn't one of ours).
+ */
+WindowPtr mac_frontwindow(void)
+{
+ ProcessSerialNumber frontpsn;
+ ProcessSerialNumber curpsn = { 0, kCurrentProcess };
+ Boolean result;
+
+ GetFrontProcess(&frontpsn);
+ if (SameProcess(&frontpsn, &curpsn, &result) == noErr && result)
+ return FrontWindow();
+ return NULL;
+}
+