]> git.eshelyaron.com Git - emacs.git/commitdiff
(create_child): Add new parameter is_gui_app.
authorAndrew Innes <andrewi@gnu.org>
Mon, 11 Jun 2001 11:00:24 +0000 (11:00 +0000)
committerAndrew Innes <andrewi@gnu.org>
Mon, 11 Jun 2001 11:00:24 +0000 (11:00 +0000)
(w32_executable_type): Add new parameter is_gui_app.
(sys_spawnve): Use it.
(sys_kill): Fake ^C for SIGINT, and ^Break (if possible) for
SIGQUIT.  This matches better how the signals are interpreted by
MSVC compiled programs.
(syms_of_ntproc): Update docstring.

src/ChangeLog
src/w32proc.c

index 6bd268132169e85b06d48eb1d4520fd3629536f1..f775a250c5dd7ddbe035afd6eb9cc87eaa468149 100644 (file)
@@ -1,3 +1,13 @@
+2001-06-11  Andrew Innes  <andrewi@gnu.org>
+
+       * w32proc.c (create_child): Add new parameter is_gui_app.
+       (w32_executable_type): Add new parameter is_gui_app.
+       (sys_spawnve): Use it.
+       (sys_kill): Fake ^C for SIGINT, and ^Break (if possible) for
+       SIGQUIT.  This matches better how the signals are interpreted by
+       MSVC compiled programs.
+       (syms_of_ntproc): Update docstring.
+
 2001-06-02  Stefan Monnier  <monnier@cs.yale.edu>
 
        * xterm.c (clear_mouse_face): Reset dpyinfo->mouse_face_overlay as
index a2b5000b88d4739f9f2cd5204e8091a77b6ad0a2..8d5890b86ddf5eadc996893924e82cc3c235df1a 100644 (file)
@@ -304,7 +304,7 @@ reader_thread (void *arg)
 static char * process_dir;
 
 static BOOL 
-create_child (char *exe, char *cmdline, char *env,
+create_child (char *exe, char *cmdline, char *env, int is_gui_app,
              int * pPid, child_process *cp)
 {
   STARTUPINFO start;
@@ -321,7 +321,7 @@ create_child (char *exe, char *cmdline, char *env,
   start.cb = sizeof (start);
   
 #ifdef HAVE_NTGUI
-  if (NILP (Vw32_start_process_show_window))
+  if (NILP (Vw32_start_process_show_window) && !is_gui_app)
     start.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
   else
     start.dwFlags = STARTF_USESTDHANDLES;
@@ -571,7 +571,7 @@ get_result:
 }
 
 void
-w32_executable_type (char * filename, int * is_dos_app, int * is_cygnus_app)
+w32_executable_type (char * filename, int * is_dos_app, int * is_cygnus_app, int * is_gui_app)
 {
   file_data executable;
   char * p;
@@ -579,6 +579,7 @@ w32_executable_type (char * filename, int * is_dos_app, int * is_cygnus_app)
   /* Default values in case we can't tell for sure.  */
   *is_dos_app = FALSE;
   *is_cygnus_app = FALSE;
+  *is_gui_app = FALSE;
 
   if (!open_input_file (&executable, filename))
     return;
@@ -599,7 +600,7 @@ w32_executable_type (char * filename, int * is_dos_app, int * is_cygnus_app)
         extension, which is defined in the registry.  */
       p = egetenv ("COMSPEC");
       if (p)
-       w32_executable_type (p, is_dos_app, is_cygnus_app);
+       w32_executable_type (p, is_dos_app, is_cygnus_app, is_gui_app);
     }
   else
     {
@@ -651,6 +652,11 @@ w32_executable_type (char * filename, int * is_dos_app, int * is_cygnus_app)
                  break;
                }
            }
+
+         /* Check whether app is marked as a console or windowed (aka
+             GUI) app.  Accept Posix and OS2 subsytem apps as console
+             apps.  */
+         *is_gui_app = (nt_header->OptionalHeader.Subsystem == IMAGE_SUBSYSTEM_WINDOWS_GUI);
        }
     }
   
@@ -714,7 +720,7 @@ sys_spawnve (int mode, char *cmdname, char **argv, char **envp)
   int arglen, numenv;
   int pid;
   child_process *cp;
-  int is_dos_app, is_cygnus_app;
+  int is_dos_app, is_cygnus_app, is_gui_app;
   int do_quoting = 0;
   char escape_char;
   /* We pass our process ID to our children by setting up an environment
@@ -757,8 +763,11 @@ sys_spawnve (int mode, char *cmdname, char **argv, char **envp)
      executable that is implicitly linked to the Cygnus dll (implying it
      was compiled with the Cygnus GNU toolchain and hence relies on
      cygwin.dll to parse the command line - we use this to decide how to
-     escape quote chars in command line args that must be quoted). */
-  w32_executable_type (cmdname, &is_dos_app, &is_cygnus_app);
+     escape quote chars in command line args that must be quoted).
+
+     Also determine whether it is a GUI app, so that we don't hide its
+     initial window unless specifically requested.  */
+  w32_executable_type (cmdname, &is_dos_app, &is_cygnus_app, &is_gui_app);
 
   /* On Windows 95, if cmdname is a DOS app, we invoke a helper
      application to start it by specifying the helper app as cmdname,
@@ -992,7 +1001,7 @@ sys_spawnve (int mode, char *cmdname, char **argv, char **envp)
     }
   
   /* Now create the process.  */
-  if (!create_child (cmdname, cmdline, env, &pid, cp))
+  if (!create_child (cmdname, cmdline, env, is_gui_app, &pid, cp))
     {
       delete_child (cp);
       errno = ENOEXEC;
@@ -1383,18 +1392,19 @@ sys_kill (int pid, int sig)
       EnumWindows (find_child_console, (LPARAM) cp);
     }
   
-  if (sig == SIGINT)
+  if (sig == SIGINT || sig == SIGQUIT)
     {
       if (NILP (Vw32_start_process_share_console) && cp && cp->hwnd)
        {
          BYTE control_scan_code = (BYTE) MapVirtualKey (VK_CONTROL, 0);
-         BYTE vk_break_code = VK_CANCEL;
+         /* Fake Ctrl-C for SIGINT, and Ctrl-Break for SIGQUIT.  */
+         BYTE vk_break_code = (sig == SIGINT) ? 'C' : VK_CANCEL;
          BYTE break_scan_code = (BYTE) MapVirtualKey (vk_break_code, 0);
          HWND foreground_window;
 
          if (break_scan_code == 0)
            {
-             /* Fake Ctrl-C if we can't manage Ctrl-Break. */
+             /* Fake Ctrl-C for SIGQUIT if we can't manage Ctrl-Break. */
              vk_break_code = 'C';
              break_scan_code = (BYTE) MapVirtualKey (vk_break_code, 0);
            }
@@ -2154,7 +2164,8 @@ will be chosen based on the type of the program.");
   DEFVAR_LISP ("w32-start-process-show-window",
               &Vw32_start_process_show_window,
     "When nil, new child processes hide their windows.\n\
-When non-nil, they show their window in the method of their choice.");
+When non-nil, they show their window in the method of their choice.\n\
+This variable doesn't affect GUI applications, which will never be hidden.");
   Vw32_start_process_show_window = Qnil;
 
   DEFVAR_LISP ("w32-start-process-share-console",