]> git.eshelyaron.com Git - emacs.git/commitdiff
2002-08-10 Andrew Choi <akochoi@shaw.ca>
authorAndrew Choi <akochoi@shaw.ca>
Sun, 11 Aug 2002 00:26:24 +0000 (00:26 +0000)
committerAndrew Choi <akochoi@shaw.ca>
Sun, 11 Aug 2002 00:26:24 +0000 (00:26 +0000)
* mac.c (sys_select) [MAC_OSX]: New function.

* macterm.c (MakeMeTheFrontProcess): New function.
(mac_initialize): Call MakeMeTheFrontProcess.

* s/darwin.h: Define select to sys_select.

src/ChangeLog
src/mac.c
src/macterm.c
src/s/darwin.h

index 51409076df876025bbf8be9bddc8e71f7a8ffeca..4abbbfbf3de736dac5a48a9b5e66399375c57458 100644 (file)
@@ -1,3 +1,12 @@
+2002-08-10  Andrew Choi  <akochoi@shaw.ca>
+
+       * mac.c (sys_select) [MAC_OSX]: New function.
+
+       * macterm.c (MakeMeTheFrontProcess): New function.
+       (mac_initialize): Call MakeMeTheFrontProcess.
+
+       * s/darwin.h: Define select to sys_select.
+
 2002-08-09  Richard M. Stallman  <rms@gnu.org>
 
        * keyboard.c (make_lispy_event): Test WINDOWSNT, not WINDOWS_NT.
index 6070c6a0dc7da3a0019c71687d9dc8bda8fb30b7..a9c97849d551be91ce00ae541dec86b3f12377d7 100644 (file)
--- a/src/mac.c
+++ b/src/mac.c
@@ -2745,6 +2745,30 @@ and t is the same as `SECONDARY'.  */)
   return Qnil;
 }
 
+#ifdef MAC_OSX
+#undef select
+
+extern int inhibit_window_system;
+
+/* When Emacs is started from the Finder, SELECT always immediately
+   returns as if input is present when file descriptor 0 is polled for
+   input.  Strangely, when Emacs is run as a GUI application from the
+   command line, it blocks in the same situation.  This `wrapper' of
+   the system call SELECT corrects this discrepancy.  */
+int
+sys_select (n, rfds, wfds, efds, timeout)
+  int n;
+  SELECT_TYPE *rfds;
+  SELECT_TYPE *wfds;
+  SELECT_TYPE *efds;
+  struct timeval *timeout;
+{
+  if (!inhibit_window_system && rfds && FD_ISSET (0, rfds))
+    return 1;
+  else
+    return select (n, rfds, wfds, efds, timeout);
+}
+#endif /* MAC_OSX */
 
 void
 syms_of_mac ()
index e9cb1b07de77f04495d9a83f1912042cca034358..a907425c391cd33b8f03d723dff5c86beac1f153 100644 (file)
@@ -366,6 +366,7 @@ extern XrmDatabase x_load_resources P_ ((Display *, char *, char *, char *));
 
 extern Lisp_Object x_icon_type P_ ((struct frame *));
 
+extern int inhibit_window_system;
 
 #if __MRC__
 QDGlobals qd;  /* QuickDraw global information structure.  */
@@ -13405,6 +13406,18 @@ mac_term_init (display_name, xrm_option, resource_name)
   return dpyinfo;
 }
 \f
+#ifdef MAC_OSX
+void MakeMeTheFrontProcess ()
+{
+  ProcessSerialNumber psn;
+  OSErr err;
+  
+  err = GetCurrentProcess (&psn);
+  if (err == noErr)
+    (void) SetFrontProcess (&psn);
+}
+#endif /* MAC_OSX */
+
 /* Set up use of X before we make the first connection.  */
 
 static struct redisplay_interface x_redisplay_interface =
@@ -13514,6 +13527,9 @@ mac_initialize ()
 #endif
 
   DisableMenuCommand (NULL, kHICommandQuit);
+
+  if (!inhibit_window_system)
+    MakeMeTheFrontProcess ();
 #endif
 }
 
index a4b3b72753719572ed98b12a8f460148a6f73ec8..c8e5ac54f7a7d6f7c89104dd185eea2b869b12ab 100644 (file)
@@ -308,3 +308,10 @@ struct kboard;
 #define realloc unexec_realloc
 #define free unexec_free
 #endif
+
+/* Reroute calls to SELECT to the version defined in mac.c to fix the
+   problem of Emacs requiring an extra return to be typed to start
+   working when started from the command line.  */
+#if defined (emacs) || defined (temacs)
+#define select sys_select
+#endif