]> code.delx.au - gnu-emacs/blobdiff - nt/runemacs.c
Fix compiler warnings in the MinGW build
[gnu-emacs] / nt / runemacs.c
index 905ef30a5d1583c74578ae3b8ec0e36323a14652..9edf148348e3ace290f2144722f1959153c3714a 100644 (file)
@@ -1,13 +1,13 @@
 /* runemacs --- Simple program to start Emacs with its console window hidden.
 
-Copyright (C) 2001-2015 Free Software Foundation, Inc.
+Copyright (C) 2001-2016 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
 GNU Emacs is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
+the Free Software Foundation, either version 3 of the License, or (at
+your option) any later version.
 
 GNU Emacs is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -59,7 +59,7 @@ WinMain (HINSTANCE hSelf, HINSTANCE hPrev, LPSTR cmdline, int nShow)
   char *new_cmdline;
   char *p;
   char modname[MAX_PATH];
-  static const char iconic_opt[] = "--iconic ";
+  static const char iconic_opt[] = "--iconic ", maximized_opt[] = "--maximized ";
 
   if (!ensure_unicows_dll ())
     goto error;
@@ -74,7 +74,10 @@ WinMain (HINSTANCE hSelf, HINSTANCE hPrev, LPSTR cmdline, int nShow)
 
   new_cmdline = alloca (MAX_PATH
                        + strlen (cmdline)
-                       + (nShow == SW_SHOWMINNOACTIVE) * strlen (iconic_opt)
+                       + ((nShow == SW_SHOWMINNOACTIVE
+                           || nShow == SW_SHOWMAXIMIZED)
+                          ? max (sizeof (iconic_opt), sizeof (maximized_opt))
+                          : 0)
                        + 3);
   /* Quote executable name in case of spaces in the path. */
   *new_cmdline = '"';
@@ -146,9 +149,12 @@ WinMain (HINSTANCE hSelf, HINSTANCE hPrev, LPSTR cmdline, int nShow)
 
   /* If the desktop shortcut properties tell to invoke runemacs
      minimized, or if they invoked runemacs via "start /min", pass
-     '--iconic' to Emacs, as that's what users will expect.  */
+     '--iconic' to Emacs, as that's what users will expect.  Likewise
+     with invoking runemacs maximized: pass '--maximized' to Emacs.  */
   if (nShow == SW_SHOWMINNOACTIVE)
     strcat (new_cmdline, iconic_opt);
+  else if (nShow == SW_SHOWMAXIMIZED)
+    strcat (new_cmdline, maximized_opt);
   strcat (new_cmdline, cmdline);
 
   /* Set emacs_dir variable if runemacs was in "%emacs_dir%\bin".  */
@@ -197,7 +203,7 @@ void
 set_user_model_id (void)
 {
   HMODULE shell;
-  HRESULT (WINAPI * set_user_model) (wchar_t * id);
+  HRESULT (WINAPI * set_user_model) (const wchar_t * id);
 
   /* On Windows 7 and later, we need to set the user model ID
      to associate emacsclient launched files with Emacs frames