1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 10:30:25 -08:00

Merge from trunk after cygw32 commit, and resolve conflicts.

This commit is contained in:
Eli Zaretskii 2012-10-08 15:06:31 +02:00
commit 7014794467
87 changed files with 2562 additions and 1098 deletions

View file

@ -1,3 +1,20 @@
2012-10-08 Eli Zaretskii <eliz@gnu.org>
* makefile.w32-in (obj): Add cygw32.o.
2012-10-08 Daniel Colascione <dancol@dancol.org>
* emacsclient.c: Include windows.h when HAVE_NTGUI.
(alt_display): New variable. We send the display held by this
variable when the primary display is either unsupported or not
present.
(longopts): Allow display everywhere.
(w32_set_user_model_id): Move lower in file, inside HAVE_NTGUI
section.
(decode_options): Use alt_display. Explain why.
(main): Retry connection with alt_display if connection with main
display fails.
2012-10-07 Eli Zaretskii <eliz@gnu.org>
* makefile.w32-in (obj): Add w32notify.o.

View file

@ -44,6 +44,10 @@ char *w32_getenv (char *);
#else /* !WINDOWSNT */
# ifdef HAVE_NTGUI
# include <windows.h>
# endif /* HAVE_NTGUI */
# include "syswait.h"
# ifdef HAVE_INET_SOCKETS
@ -140,6 +144,9 @@ int current_frame = 1;
/* The display on which Emacs should work. --display. */
const char *display = NULL;
/* The alternate display we should try if Emacs does not support display. */
const char *alt_display = NULL;
/* The parent window ID, if we are opening a frame via XEmbed. */
char *parent_id = NULL;
@ -182,9 +189,7 @@ struct option longopts[] =
{ "socket-name", required_argument, NULL, 's' },
#endif
{ "server-file", required_argument, NULL, 'f' },
#ifndef WINDOWSNT
{ "display", required_argument, NULL, 'd' },
#endif
{ "parent-id", required_argument, NULL, 'p' },
{ 0, 0, 0, 0 }
};
@ -385,32 +390,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)
@ -605,16 +584,29 @@ decode_options (int argc, char **argv)
Without the -c option, we used to set `display' to $DISPLAY by
default, but this changed the default behavior and is sometimes
inconvenient. So we force users to use "--display $DISPLAY" if
they want Emacs to connect to their current display. */
they want Emacs to connect to their current display.
Some window systems have a notion of default display not
reflected in the DISPLAY variable. If the user didn't give us an
explicit display, try this platform-specific after trying the
display in DISPLAY (if any). */
if (!current_frame && !tty && !display)
{
display = egetenv ("DISPLAY");
#ifdef NS_IMPL_COCOA
/* Under Cocoa, we don't really use displays the same way as in X,
so provide a dummy. */
if (!display || strlen (display) == 0)
display = "ns";
/* Set these here so we use a default_display only when the user
didn't give us an explicit display. */
#if defined (NS_IMPL_COCOA)
alt_display = "ns";
#elif defined (HAVE_NTGUI)
alt_display = "w32";
#endif
display = egetenv ("DISPLAY");
}
if (!display)
{
display = alt_display;
alt_display = NULL;
}
/* A null-string display is invalid. */
@ -1415,10 +1407,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)
{
@ -1467,7 +1486,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. */
@ -1537,11 +1556,13 @@ main (int argc, char **argv)
main_argv = argv;
progname = argv[0];
#ifdef WINDOWSNT
/* On Windows 7 and later, we need to explicitly associate emacsclient
with emacs so the UI behaves sensibly. */
#ifdef HAVE_NTGUI
/* On Windows 7 and later, we need to explicitly associate
emacsclient with emacs so the UI behaves sensibly. This
association does no harm if we're not actually connecting to an
Emacs using a window display. */
w32_set_user_model_id ();
#endif
#endif /* HAVE_NTGUI */
/* Process options. */
decode_options (argc, argv);
@ -1577,9 +1598,10 @@ main (int argc, char **argv)
fail ();
}
#ifdef WINDOWSNT
#ifdef HAVE_NTGUI
if (display && !strcmp (display, "w32"))
w32_give_focus ();
#endif
#endif /* HAVE_NTGUI */
/* Send over our environment and current directory. */
if (!current_frame)
@ -1748,46 +1770,56 @@ main (int argc, char **argv)
if (end_p != NULL)
*end_p++ = '\0';
if (strprefix ("-emacs-pid ", p))
{
/* -emacs-pid PID: The process id of the Emacs process. */
emacs_pid = strtol (p + strlen ("-emacs-pid"), NULL, 10);
}
else if (strprefix ("-window-system-unsupported ", p))
{
/* -window-system-unsupported: Emacs was compiled without X
support. Try again on the terminal. */
nowait = 0;
tty = 1;
goto retry;
}
else if (strprefix ("-print ", p))
{
/* -print STRING: Print STRING on the terminal. */
str = unquote_argument (p + strlen ("-print "));
if (needlf)
printf ("\n");
printf ("%s", str);
needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n';
}
else if (strprefix ("-print-nonl ", p))
{
/* -print-nonl STRING: Print STRING on the terminal.
Used to continue a preceding -print command. */
str = unquote_argument (p + strlen ("-print-nonl "));
printf ("%s", str);
needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n';
}
else if (strprefix ("-error ", p))
{
/* -error DESCRIPTION: Signal an error on the terminal. */
str = unquote_argument (p + strlen ("-error "));
if (needlf)
printf ("\n");
fprintf (stderr, "*ERROR*: %s", str);
needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n';
exit_status = EXIT_FAILURE;
}
if (strprefix ("-emacs-pid ", p))
{
/* -emacs-pid PID: The process id of the Emacs process. */
emacs_pid = strtol (p + strlen ("-emacs-pid"), NULL, 10);
}
else if (strprefix ("-window-system-unsupported ", p))
{
/* -window-system-unsupported: Emacs was compiled without support
for whatever window system we tried. Try the alternate
display, or, failing that, try the terminal. */
if (alt_display)
{
display = alt_display;
alt_display = NULL;
}
else
{
nowait = 0;
tty = 1;
}
goto retry;
}
else if (strprefix ("-print ", p))
{
/* -print STRING: Print STRING on the terminal. */
str = unquote_argument (p + strlen ("-print "));
if (needlf)
printf ("\n");
printf ("%s", str);
needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n';
}
else if (strprefix ("-print-nonl ", p))
{
/* -print-nonl STRING: Print STRING on the terminal.
Used to continue a preceding -print command. */
str = unquote_argument (p + strlen ("-print-nonl "));
printf ("%s", str);
needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n';
}
else if (strprefix ("-error ", p))
{
/* -error DESCRIPTION: Signal an error on the terminal. */
str = unquote_argument (p + strlen ("-error "));
if (needlf)
printf ("\n");
fprintf (stderr, "*ERROR*: %s", str);
needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n';
exit_status = EXIT_FAILURE;
}
#ifdef SIGSTOP
else if (strprefix ("-suspend ", p))
{

View file

@ -124,7 +124,7 @@ $(BLD)/profile.exe: $(PROFILEOBJS)
obj = dosfns.o msdos.o \
xterm.o xfns.o xmenu.o xselect.o xrdb.o xsmfns.o fringe.o image.o \
fontset.o menu.o \
w32.o w32console.o w32fns.o w32heap.o w32inevt.o \
w32.o w32console.o w32fns.o w32heap.o w32inevt.o cygw32.o \
w32menu.o w32proc.o w32reg.o w32select.o w32term.o w32xfns.o \
font.o w32font.o w32uniscribe.o w32notify.o \
dispnew.o frame.o scroll.o xdisp.o window.o bidi.o \