From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Daniel Colascione Newsgroups: gmane.emacs.devel Subject: [PATCH 4/4] Fix emacsclient to work with cygw32 Date: Thu, 29 Dec 2011 06:03:20 -0800 Message-ID: <3a4c4669da1d97d72975e8943d7b8edff22427c1.1325166472.git.dancol@dancol.org> References: NNTP-Posting-Host: lo.gmane.org X-Trace: dough.gmane.org 1325167426 4954 80.91.229.12 (29 Dec 2011 14:03:46 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 29 Dec 2011 14:03:46 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Dec 29 15:03:43 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RgGa5-0005yu-KF for ged-emacs-devel@m.gmane.org; Thu, 29 Dec 2011 15:03:42 +0100 Original-Received: from localhost ([::1]:38093 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RgGa5-0001L6-1U for ged-emacs-devel@m.gmane.org; Thu, 29 Dec 2011 09:03:41 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:49231) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RgGZt-0000sJ-LF for emacs-devel@gnu.org; Thu, 29 Dec 2011 09:03:30 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RgGZr-0007T6-My for emacs-devel@gnu.org; Thu, 29 Dec 2011 09:03:29 -0500 Original-Received: from dancol.org ([96.126.100.184]:33788) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RgGZr-0007Rq-GN for emacs-devel@gnu.org; Thu, 29 Dec 2011 09:03:27 -0500 Original-Received: from dancol by dancol.org with local (Exim 4.72) (envelope-from ) id 1RgGZk-0007mf-Vj for emacs-devel@gnu.org; Thu, 29 Dec 2011 06:03:20 -0800 In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 96.126.100.184 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:146993 Archived-At: --- 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 +# 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