Commit 7148eba2 authored by Daniel Colascione's avatar Daniel Colascione
Browse files

Merge cygw32

parents 97fbed87 a28a3ae3
2012-10-08 Daniel Colascione <dancol@dancol.org>
* configure.ac: Add --with-w32 as a window system option. Limit
it to Cygwin for now. Integrate w32 into the refactored window
system configuration and set TERM_HEADER to w32term.h when w32 is
configured.
(CYGWIN_OBJ): Add cygw32.o.
2012-10-07 Jan Djärv <jan.h.d@swipnet.se>
* configure.ac: Check that OSX is 10.4 or newer.
......
......@@ -177,6 +177,7 @@ OPTION_DEFAULT_ON([toolkit-scroll-bars],[don't use Motif or Xaw3d scroll bars])
OPTION_DEFAULT_ON([xaw3d],[don't use Xaw3d])
OPTION_DEFAULT_ON([xim],[don't use X11 XIM])
OPTION_DEFAULT_OFF([ns],[use NeXTstep (Cocoa or GNUstep) windowing system])
OPTION_DEFAULT_OFF([w32], [use native Windows GUI])
OPTION_DEFAULT_ON([gpm],[don't use -lgpm for mouse support on a GNU/Linux console])
OPTION_DEFAULT_ON([dbus],[don't compile with D-Bus support])
......@@ -1534,6 +1535,7 @@ fail;
AC_DEFINE(NS_HAVE_NSINTEGER, 1, [Define to 1 if `NSInteger' is defined.])
fi
fi
AC_SUBST(TEMACS_LDFLAGS2)
INSTALL_ARCH_INDEP_EXTRA=install-etc
......@@ -1574,6 +1576,30 @@ AC_SUBST(NS_OBJ)
AC_SUBST(NS_OBJC_OBJ)
AC_SUBST(LIB_STANDARD)
HAVE_W32=no
W32_OBJ=
W32_LIBS=
if test "${with_w32}" != no; then
if test "${opsys}" != "cygwin"; then
AC_MSG_ERROR([Using w32 with an autotools build is only supported for Cygwin.])
fi
AC_CHECK_HEADER([windows.h], [HAVE_W32=yes],
[AC_MSG_ERROR([`--with-w32' was specified, but windows.h
cannot be found.])])
AC_DEFINE(HAVE_NTGUI, 1, [Define to use native Windows GUI.])
W32_OBJ="w32fns.o w32menu.o w32reg.o w32font.o w32term.o"
W32_OBJ="$W32_OBJ w32xfns.o w32select.o w32uniscribe.o"
W32_LIBS="$W32_LIBS -lkernel32 -luser32 -lgdi32 -lole32 -lcomdlg32"
W32_LIBS="$W32_LIBS -lusp10 -lcomctl32 -lwinspool"
fi
AC_SUBST(W32_OBJ)
AC_SUBST(W32_LIBS)
if test "${HAVE_W32}" = "yes"; then
window_system=w32
with_xft=no
fi
## $window_system is now set to the window system we will
## ultimately use.
......@@ -1610,6 +1636,9 @@ dnl use the toolkit if we have gtk, or X11R5 or newer.
nextstep )
term_header=nsterm.h
;;
w32 )
term_header=w32term.h
;;
esac
if test -n "${term_header}"; then
......@@ -2310,6 +2339,9 @@ if test "${with_toolkit_scroll_bars}" != "no"; then
elif test "${HAVE_NS}" = "yes"; then
AC_DEFINE(USE_TOOLKIT_SCROLL_BARS)
USE_TOOLKIT_SCROLL_BARS=yes
elif test "${HAVE_W32}" = "yes"; then
AC_DEFINE(USE_TOOLKIT_SCROLL_BARS)
USE_TOOLKIT_SCROLL_BARS=yes
fi
fi
......@@ -2476,6 +2508,41 @@ AC_SUBST(M17N_FLT_LIBS)
### Use -lXpm if available, unless `--with-xpm=no'.
HAVE_XPM=no
LIBXPM=
if test "${HAVE_W32}" = "yes"; then
if test "${with_xpm}" != "no"; then
SAVE_CPPFLAGS="$CPPFLAGS"
SAVE_LDFLAGS="$LDFLAGS"
CPPFLAGS="$CPPFLAGS -I/usr/include/noX"
LDFLAGS="$LDFLAGS -L/usr/lib/noX"
AC_CHECK_HEADER(X11/xpm.h,
[AC_CHECK_LIB(Xpm, XpmReadFileToImage, HAVE_XPM=yes)])
if test "${HAVE_XPM}" = "yes"; then
AC_MSG_CHECKING(for XpmReturnAllocPixels preprocessor define)
AC_EGREP_CPP(no_return_alloc_pixels,
[#include "X11/xpm.h"
#ifndef XpmReturnAllocPixels
no_return_alloc_pixels
#endif
], HAVE_XPM=no, HAVE_XPM=yes)
if test "${HAVE_XPM}" = "yes"; then
REAL_CPPFLAGS="$REAL_CPPFLAGS -I/usr/include/noX"
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
CPPFLAGS="$SAVE_CPPFLAGS"
LDFLAGS="$SAVE_LDFLAGS"
fi
fi
fi
if test "${HAVE_XPM}" = "yes"; then
AC_DEFINE(HAVE_XPM, 1, [Define to 1 if you have the Xpm libary (-lXpm).])
LIBXPM=-lXpm
fi
fi
if test "${HAVE_X11}" = "yes"; then
if test "${with_xpm}" != "no"; then
AC_CHECK_HEADER(X11/xpm.h,
......@@ -2502,12 +2569,13 @@ no_return_alloc_pixels
LIBXPM=-lXpm
fi
fi
AC_SUBST(LIBXPM)
### Use -ljpeg if available, unless `--with-jpeg=no'.
HAVE_JPEG=no
LIBJPEG=
if test "${HAVE_X11}" = "yes"; then
if test "${HAVE_X11}" = "yes" || test "${HAVE_W32}" = "yes"; then
if test "${with_jpeg}" != "no"; then
dnl Checking for jpeglib.h can lose because of a redefinition of
dnl HAVE_STDLIB_H.
......@@ -2535,7 +2603,7 @@ AC_SUBST(LIBJPEG)
### Use -lpng if available, unless `--with-png=no'.
HAVE_PNG=no
LIBPNG=
if test "${HAVE_X11}" = "yes"; then
if test "${HAVE_X11}" = "yes" || test "${HAVE_W32}" = "yes"; then
if test "${with_png}" != "no"; then
# Debian unstable as of July 2003 has multiple libpngs, and puts png.h
# in /usr/include/libpng.
......@@ -2568,7 +2636,7 @@ AC_SUBST(LIBPNG)
### Use -ltiff if available, unless `--with-tiff=no'.
HAVE_TIFF=no
LIBTIFF=
if test "${HAVE_X11}" = "yes"; then
if test "${HAVE_X11}" = "yes" || test "${HAVE_W32}" = "yes"; then
if test "${with_tiff}" != "no"; then
AC_CHECK_HEADER(tiffio.h,
[tifflibs="-lz -lm"
......@@ -2588,7 +2656,8 @@ AC_SUBST(LIBTIFF)
### Use -lgif or -lungif if available, unless `--with-gif=no'.
HAVE_GIF=no
LIBGIF=
if test "${HAVE_X11}" = "yes" && test "${with_gif}" != "no"; then
if test "${HAVE_X11}" = "yes" && test "${with_gif}" != "no" \
|| test "${HAVE_W32}" = "yes"; then
AC_CHECK_HEADER(gif_lib.h,
# EGifPutExtensionLast only exists from version libungif-4.1.0b1.
# Earlier versions can crash Emacs.
......@@ -2670,6 +2739,9 @@ if test "${HAVE_NS}" = "yes"; then
OTHER_FILES=ns-app
fi
if test "${HAVE_W32}" = "yes"; then
HAVE_MENUS=yes
fi
### Use session management (-lSM -lICE) if available
HAVE_X_SM=no
......@@ -4205,7 +4277,7 @@ fi
AC_SUBST(RALLOC_OBJ)
if test "$opsys" = "cygwin"; then
CYGWIN_OBJ="sheap.o"
CYGWIN_OBJ="sheap.o cygw32.o"
## Cygwin differs because of its unexec().
PRE_ALLOC_OBJ=
POST_ALLOC_OBJ=lastfile.o
......
......@@ -78,6 +78,11 @@ directories to the search path. You must add them yourself if you want them.
(from the bin and libexec directories, respectively). The former is
no longer relevant, the latter is replaced by lisp (in vc-sccs.el).
---
** The native Windows user interface is available for Cygwin. Passing
--with-w32 will configure a Cygwin emacs to use the Windows user
interface instead of the default, X11.
* Startup Changes in Emacs 24.3
......@@ -882,6 +887,11 @@ is detected.
Emacs now supports mouse highlight, help-echo (in the echo area), and
mouse-autoselect-window.
** Two new functions are available in Cygwin builds of Emacs:
cygwin-convert-path-from-windows and cygwin-convert-path-to-windows.
These functions allows lisp code to access the Cygwin path mapping
machinery to convert between Cygwin and Windows-native paths.
** On MS-Windows Vista and later Emacs now supports symbolic links.
* Changes in Emacs 24.2
......
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-01 Fabrice Popineau <fabrice.popineau@gmail.com>
* make-docfile.c (write_globals): Special-case
......
......@@ -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))
{
......
......@@ -30,6 +30,73 @@
* comint.el (comint-preinput-scroll-to-bottom): Preserve the
frame-selected-windows.
 
2012-10-08 Daniel Colascione <dancol@dancol.org>
* battery.el (battery-status-function): Check for
w32-battery-status itself, not system-time windows-nt.
* frame.el: Require cl-lib.
(display-format-alist): New variable mapping frame types to
functions that initialize them.
(window-system-for-display): New function: interprets
display-format-alist.
(make-frame-on-display): Remove existing display-selection logic
and just forward to make-frame, which will now DTRT.
(make-frame): Restructure to use window-system-for-display to
figure out how to create a frame on a given display.
(display-mouse-p): Look for frame-type w32, not a particular
system-type.
* loadup.el: Load w32 lisp code when we have the w32 feature.
* mouse.el (mouse-yank-primarY): Look for frame-type w32, not
system-type windows-nt.
* server.el (server-create-window-system-frame): Look for window
type.
(server-proces-filter): Only force a window system when windows-nt
_and_ w32. Explain why.
* simple.el (normal-erase-is-backspace-mode): Add w32 to the list
of window systems we configure for the mode.
* startup.el (command-line): Mark window system is initialized
after we've done it.
* common-win.el (x-select-text): Look for w32, not windows-nt.
* ns-win.el: Require cl-lib. Add ourselves to
display-format-alist.
(ns-initialize-window-system): Assert we're not initialized twice.
* w32-win.el: Enable lexical binding; require cl-lib; add
ourselves to display-format-alist.
(w32-handle-dropped-file): Convert incoming dropped files from
Windows paths to Cygwin ones before passing them on to the rest of
Emacs.
(w32-drag-n-drop): New paramter new-frame. Simplify logic.
(w32-initialize-window-system): Assert we're not initialized twice.
* x-win.el: Require cl-lib; add ourselves to display-format-alist.
(x-initialize-window-system): Assert we're not initialized twice.
* w32-common-fns.el: New File.
(w32-version, w32-using-nt, w32-get-clipboard-data)
(w32-set-clipboard-data, x-set-selection, x-get-selection)
(w32-charset-info-alist, x-last-selected, text)
(x-get-selection-value, x-selection-value): Move here.
* w32-fns.el: Require w32-common-fns.
(w32-version, w32-using-nt, w32-get-clipboard-data)
(w32-set-clipboard-data, x-set-selection, x-get-selection)
(w32-charset-info-alist, x-last-selected, text)
(x-get-selection-value, x-selection-value): Move to
w32-common-fns.
* w32-vars.el:
(w32-allow-system-shell, w32-system-shells): Define only in
non-cygwin case.
2012-10-07 Stefan Monnier <monnier@iro.umontreal.ca>
 
* subr.el (read-passwd-map): Don't use `defconst' (bug#12597).
......
......@@ -60,7 +60,7 @@
(> (buffer-size) 0)))
(error nil)))
'battery-pmset)
((eq system-type 'windows-nt)
((fboundp 'w32-battery-status)
'w32-battery-status))
"Function for getting battery status information.
The function has to return an alist of conversion definitions.
......
......@@ -96,7 +96,7 @@ ALTERNATIVE2 etc."
;; This is defined originally in xfaces.c.
(defcustom face-font-registry-alternatives
(mapcar (lambda (arg) (mapcar 'purecopy arg))
(if (eq system-type 'windows-nt)
(if (featurep 'w32)
'(("iso8859-1" "ms-oemlatin")
("gb2312.1980" "gb2312" "gbk" "gb18030")
("jisx0208.1990" "jisx0208.1983" "jisx0208.1978")
......
......@@ -25,6 +25,8 @@
;;; Commentary:
;;; Code:
(eval-when-compile (require 'cl-lib))
(defvar frame-creation-function-alist
(list (cons nil
(if (fboundp 'tty-create-frame-with-faces)
......@@ -45,6 +47,12 @@ Then, for frames on WINDOW-SYSTEM, any parameters specified in
ALIST supersede the corresponding parameters specified in
`default-frame-alist'.")
(defvar display-format-alist nil
"Alist of patterns to decode display names.
The car of each entry is a regular expression matching a display
name string. The cdr is a symbol giving the window-system that
handles the corresponding kind of display.")
;; The initial value given here used to ask for a minibuffer.
;; But that's not necessary, because the default is to have one.
;; By not specifying it here, we let an X resource specify it.
......@@ -510,31 +518,19 @@ is not considered (see `next-frame')."
0))
(select-frame-set-input-focus (selected-frame)))
(declare-function x-initialize-window-system "term/x-win" ())
(declare-function ns-initialize-window-system "term/ns-win" ())
(defvar x-display-name) ; term/x-win
(defun window-system-for-display (display)
"Return the window system for DISPLAY.
Return nil if we don't know how to interpret DISPLAY."
(cl-loop for descriptor in display-format-alist
for pattern = (car descriptor)
for system = (cdr descriptor)
when (string-match-p pattern display) return system))
(defun make-frame-on-display (display &optional parameters)
"Make a frame on display DISPLAY.
The optional argument PARAMETERS specifies additional frame parameters."
(interactive "sMake frame on display: ")
(cond ((featurep 'ns)
(when (and (boundp 'ns-initialized) (not ns-initialized))
(setq x-display-name display)
(ns-initialize-window-system))
(make-frame `((window-system . ns)
(display . ,display) . ,parameters)))
((eq system-type 'windows-nt)
;; On Windows, ignore DISPLAY.
(make-frame parameters))
(t
(unless (string-match-p "\\`[^:]*:[0-9]+\\(\\.[0-9]+\\)?\\'" display)
(error "Invalid display, not HOST:SERVER or HOST:SERVER.SCREEN"))
(when (and (boundp 'x-initialized) (not x-initialized))
(se