unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Daniel Colascione <dancol@dancol.org>
To: emacs-devel@gnu.org
Subject: [PATCH 4/4] Fix emacsclient to work with cygw32
Date: Thu, 29 Dec 2011 06:03:20 -0800	[thread overview]
Message-ID: <3a4c4669da1d97d72975e8943d7b8edff22427c1.1325166472.git.dancol@dancol.org> (raw)
In-Reply-To: <cover.1325166472.git.dancol@dancol.org>

---
 lib-src/emacsclient.c |   71 ++++++++++++++++++++++++++----------------------
 lisp/server.el        |   10 +++++--
 2 files changed, 45 insertions(+), 36 deletions(-)

diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c
index 5e1c2d6..086bb86 100644
--- a/lib-src/emacsclient.c
+++ b/lib-src/emacsclient.c
@@ -43,6 +43,10 @@ char *w32_getenv (char *);
 
 #else /* !WINDOWSNT */
 
+# ifdef HAVE_NTGUI
+# include <windows.h>
+# endif /* HAVE_NTGUI */
+
 # include "syswait.h"
 
 # ifdef HAVE_INET_SOCKETS
@@ -184,7 +188,7 @@ struct option longopts[] =
   { "socket-name",	required_argument, NULL, 's' },
 #endif
   { "server-file",	required_argument, NULL, 'f' },
-#ifndef WINDOWSNT
+#ifndef HAVE_NTGUI
   { "display",	required_argument, NULL, 'd' },
 #endif
   { "parent-id", required_argument, NULL, 'p' },
@@ -402,32 +406,6 @@ w32_getenv (char *envvar)
   return NULL;
 }
 
-void
-w32_set_user_model_id (void)
-{
-  HMODULE shell;
-  HRESULT (WINAPI * set_user_model) (wchar_t * id);
-
-  /* On Windows 7 and later, we need to set the user model ID
-     to associate emacsclient launched files with Emacs frames
-     in the UI.  */
-  shell = LoadLibrary ("shell32.dll");
-  if (shell)
-    {
-      set_user_model
-	= (void *) GetProcAddress (shell,
-				   "SetCurrentProcessExplicitAppUserModelID");
-      /* If the function is defined, then we are running on Windows 7
-	 or newer, and the UI uses this to group related windows
-	 together.  Since emacs, runemacs, emacsclient are related, we
-	 want them grouped even though the executables are different,
-	 so we need to set a consistent ID between them.  */
-      if (set_user_model)
-	set_user_model (L"GNU.Emacs");
-
-      FreeLibrary (shell);
-    }
-}
 
 int
 w32_window_app (void)
@@ -1456,10 +1434,37 @@ set_socket (int no_exit_if_error)
   exit (EXIT_FAILURE);
 }
 
-#ifdef WINDOWSNT
+#ifdef HAVE_NTGUI
 FARPROC set_fg;  /* Pointer to AllowSetForegroundWindow.  */
 FARPROC get_wc;  /* Pointer to RealGetWindowClassA.  */
 
+void
+w32_set_user_model_id (void)
+{
+  HMODULE shell;
+  HRESULT (WINAPI * set_user_model) (wchar_t * id);
+
+  /* On Windows 7 and later, we need to set the user model ID
+     to associate emacsclient launched files with Emacs frames
+     in the UI.  */
+  shell = LoadLibrary ("shell32.dll");
+  if (shell)
+    {
+      set_user_model
+	= (void *) GetProcAddress (shell,
+				   "SetCurrentProcessExplicitAppUserModelID");
+      /* If the function is defined, then we are running on Windows 7
+	 or newer, and the UI uses this to group related windows
+	 together.  Since emacs, runemacs, emacsclient are related, we
+	 want them grouped even though the executables are different,
+	 so we need to set a consistent ID between them.  */
+      if (set_user_model)
+	set_user_model (L"GNU.Emacs");
+
+      FreeLibrary (shell);
+    }
+}
+
 BOOL CALLBACK
 w32_find_emacs_process (HWND hWnd, LPARAM lParam)
 {
@@ -1509,7 +1514,7 @@ w32_give_focus (void)
       && (get_wc = GetProcAddress (user32, "RealGetWindowClassA")))
     EnumWindows (w32_find_emacs_process, (LPARAM) 0);
 }
-#endif
+#endif /* HAVE_NTGUI */
 
 /* Start the emacs daemon and try to connect to it.  */
 
@@ -1581,11 +1586,11 @@ main (int argc, char **argv)
   main_argv = argv;
   progname = argv[0];
 
-#ifdef WINDOWSNT
+#ifdef HAVE_NTGUI
   /* On Windows 7 and later, we need to explicitly associate emacsclient
      with emacs so the UI behaves sensibly.  */
   w32_set_user_model_id ();
-#endif
+#endif /* HAVE_NTGUI */
 
   /* Process options.  */
   decode_options (argc, argv);
@@ -1636,9 +1641,9 @@ main (int argc, char **argv)
       fail ();
     }
 
-#ifdef WINDOWSNT
+#ifdef HAVE_NTGUI
   w32_give_focus ();
-#endif
+#endif /* HAVE_NTGUI */
 
   /* Send over our environment and current directory. */
   if (!current_frame)
diff --git a/lisp/server.el b/lisp/server.el
index edd8f2a..ec93b18 100644
--- a/lisp/server.el
+++ b/lisp/server.el
@@ -1038,9 +1038,13 @@ The following commands are accepted by the client:
                        tty-type (pop args-left)
                        dontkill (or dontkill
                                     (not use-current-frame)))
-                 ;; On Windows, emacsclient always asks for a tty frame.
-                 ;; If running a GUI server, force the frame type to GUI.
-                 (when (eq window-system 'w32)
+                 ;; On Windows, emacsclient always asks for a tty
+                 ;; frame.  If running a GUI server, force the frame
+                 ;; type to GUI.  (Cygwin is perfectly happy with
+                 ;; multi-tty support, so don't override the user's
+                 ;; choice there.)
+                 (when (and (eq system-type 'windows-nt)
+                            (eq window-system 'w32))
                    (push "-window-system" args-left)))
 
                 ;; -position LINE[:COLUMN]:  Set point to the given
-- 
1.7.5.1




  reply	other threads:[~2011-12-29 14:03 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-29 14:03 [PATCH 0/4] Support Win32 GUI in Cygwin Emacs Daniel Colascione
2011-12-29 14:03 ` Daniel Colascione [this message]
2011-12-29 16:28   ` [PATCH 4/4] Fix emacsclient to work with cygw32 Juanma Barranquero
2011-12-29 16:36     ` Daniel Colascione
2011-12-29 16:43       ` Juanma Barranquero
2011-12-29 16:47         ` Daniel Colascione
2011-12-29 16:49           ` Juanma Barranquero
2011-12-29 17:39   ` Eli Zaretskii
2011-12-29 17:56     ` Daniel Colascione
2011-12-29 18:18       ` Eli Zaretskii
2011-12-29 18:53         ` Juanma Barranquero
2011-12-29 14:03 ` [PATCH 1/4] Compilation cleanups Daniel Colascione
2011-12-29 17:54   ` Paul Eggert
2011-12-31 14:50     ` Ken Brown
2011-12-31 20:29       ` Paul Eggert
2011-12-29 14:03 ` [PATCH 3/4] Implement cygw32 Daniel Colascione
2011-12-29 17:29   ` Eli Zaretskii
2011-12-29 17:53     ` Daniel Colascione
2011-12-29 18:17       ` Eli Zaretskii
2011-12-29 21:50         ` Daniel Colascione
2011-12-30  0:56           ` Jason Rumney
2011-12-30  9:23           ` Eli Zaretskii
2011-12-30  9:36             ` Daniel Colascione
2011-12-30 11:16               ` Eli Zaretskii
2011-12-30  9:49   ` Andreas Schwab
2011-12-29 14:03 ` [PATCH 2/4] Refactor window-system configuration Daniel Colascione
2011-12-29 22:21   ` Dan Nicolaescu
2011-12-29 22:29     ` Daniel Colascione
2011-12-29 22:43       ` Dan Nicolaescu
2011-12-29 22:48         ` Daniel Colascione
2011-12-29 23:05           ` Dan Nicolaescu
2011-12-29 23:08             ` Daniel Colascione
2011-12-30  8:54             ` Eli Zaretskii
2011-12-30  9:07               ` Daniel Colascione
2011-12-30  9:44                 ` Eli Zaretskii
2011-12-30  0:53       ` Stefan Monnier
2011-12-30  8:21       ` Eli Zaretskii
2011-12-30  8:26         ` Daniel Colascione
2011-12-30  9:38           ` Eli Zaretskii
2011-12-30  9:45             ` Daniel Colascione
2011-12-30 11:15             ` Stefan Monnier
2011-12-30  8:19     ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3a4c4669da1d97d72975e8943d7b8edff22427c1.1325166472.git.dancol@dancol.org \
    --to=dancol@dancol.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).