process.o gnutls.o callproc.o \
region-cache.o sound.o atimer.o \
doprnt.o intervals.o textprop.o composite.o xml.o \
+ profiler.o \
$(MSDOS_OBJ) $(MSDOS_X_OBJ) $(NS_OBJ) $(CYGWIN_OBJ) $(FONT_OBJ) \
- $(WINDOW_SYSTEM_OBJ)
+ $(W32_OBJ) $(WINDOW_SYSTEM_OBJ)
obj = $(base_obj) $(NS_OBJC_OBJ)
## Object files used on some machine or other.
## Note that SunOS needs -lm to come before -lc; otherwise, you get
## duplicated symbols. If the standard libraries were compiled
## with GCC, we might need LIB_GCC again after them.
-LIBES = $(LIBS) $(LIBX_BASE) $(LIBX_OTHER) $(LIBSOUND) \
- $(RSVG_LIBS) $(IMAGEMAGICK_LIBS) $(LIB_CLOCK_GETTIME) $(LIB_TIMER_TIME) \
- $(DBUS_LIBS) $(LIB_EXECINFO) \
+LIBES = $(LIBS) $(W32_LIBS) $(LIBX_BASE) $(LIBIMAGE) \
+ $(LIBX_OTHER) $(LIBSOUND) \
- $(RSVG_LIBS) $(IMAGEMAGICK_LIBS) $(LIB_CLOCK_GETTIME) $(DBUS_LIBS) \
++ $(RSVG_LIBS) $(IMAGEMAGICK_LIBS) $(LIB_CLOCK_GETTIME) \
++ $(LIB_TIMER_TIME) $(DBUS_LIBS) \
+ $(LIB_EXECINFO) \
$(LIBXML2_LIBS) $(LIBGPM) $(LIBRESOLV) $(LIBS_SYSTEM) \
$(LIBS_TERMCAP) $(GETLOADAVG_LIBS) $(SETTINGS_LIBS) $(LIBSELINUX_LIBS) \
$(FREETYPE_LIBS) $(FONTCONFIG_LIBS) $(LIBOTF_LIBS) $(M17N_FLT_LIBS) \
#ifdef WINDOWSNT
#include <fcntl.h>
-#include <windows.h> /* just for w32.h */
#include "w32.h"
-#include "w32heap.h" /* for prototype of sbrk */
+#endif
+
+#if defined (WINDOWSNT)
+#include "w32heap.h"
+#endif
+
+#if defined (WINDOWSNT) || defined (HAVE_NTGUI)
+#include "w32select.h"
+#include "w32font.h"
+#endif
+
+#if defined (HAVE_NTGUI) && defined (CYGWIN)
+#include "cygw32.h"
#endif
+ #ifdef HAVE_WINDOW_SYSTEM
+ #include TERM_HEADER
+ #endif /* HAVE_WINDOW_SYSTEM */
+
#ifdef NS_IMPL_GNUSTEP
/* At least under Debian, GSConfig is in a subdirectory. --Stef */
#include <GNUstepBase/GSConfig.h>
bool no_loadup = 0;
char *junk = 0;
char *dname_arg = 0;
-#ifdef NS_IMPL_COCOA
+#ifdef DAEMON_MUST_EXEC
char dname_arg2[80];
-#endif
+#endif /* DAEMON_MUST_EXEC */
char *ch_to_dir;
- struct sigaction fatal_error_action;
#if GC_MARK_STACK
stack_base = &dummy;
#define EMACS_FONT_H
#include "ccl.h"
++#include "frame.h"
/* We have three types of Lisp objects related to font.
#endif
extern void x_query_colors (struct frame *f, XColor *, int);
+extern void x_query_color (struct frame *f, XColor *);
- /* In xmenu.c */
- extern void set_frame_menubar (FRAME_PTR, int, int);
-
#endif /* HAVE_WINDOW_SYSTEM */
INLINE_HEADER_END
static Lisp_Object Qcount, Qextension_data, Qdelay;
static Lisp_Object Qlaplace, Qemboss, Qedge_detection, Qheuristic;
- /* Function prototypes. */
+ /* Forward function prototypes. */
- static Lisp_Object define_image_type (struct image_type *type, int loaded);
- static struct image_type *lookup_image_type (Lisp_Object symbol);
- static void image_error (const char *format, Lisp_Object, Lisp_Object);
+ static struct image_type *lookup_image_type (Lisp_Object);
static void x_laplace (struct frame *, struct image *);
static void x_emboss (struct frame *, struct image *);
- static int x_build_heuristic_mask (struct frame *, struct image *,
- Lisp_Object);
+ static void x_build_heuristic_mask (struct frame *, struct image *,
- Lisp_Object);
-#ifdef HAVE_NTGUI
++ Lisp_Object);
+#ifdef WINDOWSNT
+extern Lisp_Object Vlibrary_cache;
#define CACHE_IMAGE_TYPE(type, status) \
do { Vlibrary_cache = Fcons (Fcons (type, status), Vlibrary_cache); } while (0)
#else
/* Define a new image type from TYPE. This adds a copy of TYPE to
image_types and caches the loading status of TYPE. */
- static Lisp_Object
- define_image_type (struct image_type *type, int loaded)
+ static struct image_type *
+ define_image_type (struct image_type *type)
{
- Lisp_Object success;
+ struct image_type *p = NULL;
+ Lisp_Object target_type = *type->type;
+ bool type_valid = 1;
- if (!loaded)
- success = Qnil;
- else
+ block_input ();
+
+ for (p = image_types; p; p = p->next)
+ if (EQ (*p->type, target_type))
+ goto done;
+
+ if (type->init)
+ {
-#ifdef HAVE_NTGUI
++#if defined (HAVE_NTGUI) && defined (WINDOWSNT)
+ /* If we failed to load the library before, don't try again. */
+ Lisp_Object tested = Fassq (target_type, Vlibrary_cache);
+ if (CONSP (tested) && NILP (XCDR (tested)))
+ type_valid = 0;
+ else
+ #endif
+ {
+ type_valid = type->init ();
+ CACHE_IMAGE_TYPE (target_type, type_valid ? Qt : Qnil);
+ }
+ }
+
+ if (type_valid)
{
/* Make a copy of TYPE to avoid a bus error in a dumped Emacs.
The initialized data segment is read-only. */
if (!fn_##func) return 0; \
}
-#endif /* HAVE_NTGUI */
+#endif /* WINDOWSNT */
- static int x_create_x_image_and_pixmap (struct frame *, int, int, int,
- XImagePtr *, Pixmap *);
- static void x_destroy_x_image (XImagePtr);
- static void x_put_x_image (struct frame *, XImagePtr, Pixmap, int, int);
-
- /* Return nonzero if XIMG's size WIDTH x HEIGHT doesn't break the
+ /* Return true if XIMG's size WIDTH x HEIGHT doesn't break the
windowing system.
WIDTH and HEIGHT must both be positive.
If XIMG is null, assume it is a bitmap. */
{":background", IMAGE_STRING_OR_NIL_VALUE, 0}
};
-#ifdef HAVE_NTGUI
++#if defined(HAVE_NTGUI) && defined(WINDOWSNT)
+ static bool init_xpm_functions (void);
+ #else
+ #define init_xpm_functions NULL
+ #endif
+
/* Structure describing the image type XPM. */
static struct image_type xpm_type =
return 1;
}
-#endif /* HAVE_NTGUI */
+#endif /* WINDOWSNT */
+#ifdef HAVE_NTGUI
+/* Glue for code below */
+#define fn_XpmReadFileToImage XpmReadFileToImage
+#define fn_XpmCreateImageFromBuffer XpmCreateImageFromBuffer
+#define fn_XImageFree XImageFree
+#define fn_XpmFreeAttributes XpmFreeAttributes
+#endif /* HAVE_NTGUI */
- /* Value is non-zero if COLOR_SYMBOLS is a valid color symbols list
+ /* Value is true if COLOR_SYMBOLS is a valid color symbols list
for XPM images. Such a list must consist of conses whose car and
cdr are strings. */
{":background", IMAGE_STRING_OR_NIL_VALUE, 0}
};
-#ifdef HAVE_NTGUI
++#if defined(HAVE_NTGUI) && defined (WINDOWSNT)
+ static bool init_png_functions (void);
+ #else
+ #define init_png_functions NULL
+ #endif
+
/* Structure describing the image type `png'. */
static struct image_type png_type =
{":background", IMAGE_STRING_OR_NIL_VALUE, 0}
};
-#ifdef HAVE_NTGUI
++#if defined(HAVE_NTGUI) && defined(WINDOWSNT)
+ static bool init_jpeg_functions (void);
+ #else
+ #define init_jpeg_functions NULL
+ #endif
+
/* Structure describing the image type `jpeg'. */
static struct image_type jpeg_type =
{":background", IMAGE_STRING_OR_NIL_VALUE, 0}
};
-#ifdef HAVE_NTGUI
++#if defined(HAVE_NTGUI) && defined(WINDOWSNT)
+ static bool init_gif_functions (void);
+ #else
+ #define init_gif_functions NULL
+ #endif
+
/* Structure describing the image type `gif'. */
static struct image_type gif_type =
#define fn_g_type_init g_type_init
#define fn_g_object_unref g_object_unref
#define fn_g_error_free g_error_free
-#endif /* !HAVE_NTGUI */
+#endif /* !WINDOWSNT */
- /* Load SVG image IMG for use on frame F. Value is non-zero if
- successful. this function will go into the svg_type structure, and
- the prototype thus needs to be compatible with that structure. */
+ /* Load SVG image IMG for use on frame F. Value is true if
+ successful. */
- static int
+ static bool
svg_load (struct frame *f, struct image *img)
{
- int success_p = 0;
+ bool success_p = 0;
Lisp_Object file_name;
/* If IMG->spec specifies a file name, create a non-file spec from it. */
Initialization
***********************************************************************/
- DEFUN ("init-image-library", Finit_image_library, Sinit_image_library, 2, 2, 0,
+#ifdef WINDOWSNT
+/* Image types that rely on external libraries are loaded dynamically
+ if the library is available. */
+#define CHECK_LIB_AVAILABLE(image_type, init_lib_fn, libraries) \
+ define_image_type (image_type, init_lib_fn (libraries))
+#else
+#define CHECK_LIB_AVAILABLE(image_type, init_lib_fn, libraries) \
+ define_image_type (image_type, 1)
+#endif /* WINDOWSNT */
+
+ DEFUN ("init-image-library", Finit_image_library, Sinit_image_library, 1, 1, 0,
doc: /* Initialize image library implementing image type TYPE.
Return non-nil if TYPE is a supported image type.
#ifdef subprocesses
if (kbd_on_hold_p () && kbd_buffer_nr_stored () < KBD_BUFFER_SIZE/4)
{
- /* Start reading input again, we have processed enough so we can
- accept new events again. */
+ /* Start reading input again because we have processed enough to
+ be able to accept new events again. */
unhold_keyboard_input ();
- #ifdef USABLE_SIGIO
- if (!noninteractive)
- {
- struct sigaction action;
- emacs_sigaction_init (&action, deliver_input_available_signal);
- sigaction (SIGIO, &action, 0);
- }
- #endif
start_polling ();
}
#endif /* subprocesses */
/* Return the string resource associated with KEY of type TYPE. */
extern LPBYTE w32_get_resource (char * key, LPDWORD type);
- extern void init_ntproc (void);
- extern void term_ntproc (void);
+ extern void init_ntproc (int);
+ extern void term_ntproc (int);
extern void globals_of_w32 (void);
-extern void syms_of_w32term (void);
-extern void syms_of_w32fns (void);
-extern void globals_of_w32fns (void);
-extern void syms_of_w32select (void);
-extern void globals_of_w32select (void);
-extern void term_w32select (void);
-extern void syms_of_w32menu (void);
-extern void globals_of_w32menu (void);
-extern void syms_of_fontset (void);
-extern void syms_of_w32font (void);
-extern void check_windows_init_file (void);
+ extern void term_timers (void);
+ extern void init_timers (void);
+
extern int _sys_read_ahead (int fd);
extern int _sys_wait_accept (int fd);
extern void w32_menu_display_help (HWND, HMENU, UINT, UINT);
extern void w32_free_menu_strings (HWND);
extern const char *map_w32_filename (const char *, const char **);
+extern char * w32_strerror (int error_no);
- /* If non-zero, a w32 timer that, when it expires, displays an
- hourglass cursor on all frames. */
- static unsigned hourglass_timer = 0;
+ /* If non-NULL, a handle to a frame where to display the hourglass cursor. */
static HWND hourglass_hwnd = NULL;
#ifndef IDC_HAND
If ALLOC is nonzero, allocate a new colormap cell. */
int
--w32_defined_color (FRAME_PTR f, char *color, XColor *color_def, int alloc)
++w32_defined_color (FRAME_PTR f, const char *color, XColor *color_def, int alloc)
{
register Lisp_Object tem;
COLORREF w32_color_ref;
}
}
- input. */
+#if EMACSDEBUG
+const char*
+w32_name_of_message (UINT msg)
+{
+ unsigned i;
+ static char buf[64];
+ static const struct {
+ UINT msg;
+ const char* name;
+ } msgnames[] = {
+#define M(msg) { msg, # msg }
+ M (WM_PAINT),
+ M (WM_TIMER),
+ M (WM_USER),
+ M (WM_MOUSEMOVE),
+ M (WM_LBUTTONUP),
+ M (WM_KEYDOWN),
+ M (WM_EMACS_KILL),
+ M (WM_EMACS_CREATEWINDOW),
+ M (WM_EMACS_DONE),
+ M (WM_EMACS_CREATESCROLLBAR),
+ M (WM_EMACS_SHOWWINDOW),
+ M (WM_EMACS_SETWINDOWPOS),
+ M (WM_EMACS_DESTROYWINDOW),
+ M (WM_EMACS_TRACKPOPUPMENU),
+ M (WM_EMACS_SETFOCUS),
+ M (WM_EMACS_SETFOREGROUND),
+ M (WM_EMACS_SETLOCALE),
+ M (WM_EMACS_SETKEYBOARDLAYOUT),
+ M (WM_EMACS_REGISTER_HOT_KEY),
+ M (WM_EMACS_UNREGISTER_HOT_KEY),
+ M (WM_EMACS_TOGGLE_LOCK_KEY),
+ M (WM_EMACS_TRACK_CARET),
+ M (WM_EMACS_DESTROY_CARET),
+ M (WM_EMACS_SHOW_CARET),
+ M (WM_EMACS_HIDE_CARET),
+ M (WM_EMACS_SETCURSOR),
+ M (WM_EMACS_PAINT),
+ M (WM_CHAR),
+#undef M
+ { 0, 0 }
+ };
+
+ for (i = 0; msgnames[i].name; ++i)
+ if (msgnames[i].msg == msg)
+ return msgnames[i].name;
+
+ sprintf (buf, "message 0x%04x", (unsigned)msg);
+ return buf;
+}
+#endif /* EMACSDEBUG */
+
+ /* Here's an overview of how Emacs input works on MS-Windows.
+
+ System messages are read and processed by w32_msg_pump below. This
+ function runs in a separate thread. It handles a small number of
+ custom WM_EMACS_* messages (posted by the main thread, look for
+ PostMessage calls), and dispatches the rest to w32_wnd_proc, which
+ is the main window procedure for the entire Emacs application.
+
+ w32_wnd_proc also runs in the same separate input thread. It
+ handles some messages, mostly those that need GDI calls, by itself.
+ For the others, it calls my_post_msg, which inserts the messages
+ into the input queue serviced by w32_read_socket.
+
+ w32_read_socket runs in the main (a.k.a. "Lisp") thread, and is
+ called synchronously from keyboard.c when it is known or suspected
+ that some input is available. w32_read_socket either handles
+ messages immediately, or converts them into Emacs input events and
+ stuffs them into kbd_buffer, where kbd_buffer_get_event can get at
+ them and process them when read_char and its callers require
++ input.
++
++ Under Cygwin with the W32 toolkit, the use of /dev/windows with
++ select(2) takes the place of w32_read_socket.
++
++ */
+
/* Main message dispatch loop. */
static void
file_details->hwndOwner = FRAME_W32_WINDOW (f);
/* Undocumented Bug in Common File Dialog:
If a filter is not specified, shell links are not resolved. */
- file_details->lpstrFilter = "All Files (*.*)\0*.*\0Directories\0*|*\0\0";
- file_details->lpstrFile = filename;
- file_details->nMaxFile = sizeof (filename);
- file_details->lpstrInitialDir = init_dir;
- file_details->lpstrTitle = SDATA (prompt);
-
- if (! NILP (only_dir_p))
- default_filter_index = 2;
-
- file_details->nFilterIndex = default_filter_index;
-
+ file_details->lpstrFilter = filter;
+ file_details->lpstrInitialDir = (guichar_t*) SDATA (dir);
+ file_details->lpstrTitle = (guichar_t*) SDATA (prompt);
+ file_details->nFilterIndex = NILP (only_dir_p) ? 1 : 2;
file_details->Flags = (OFN_HIDEREADONLY | OFN_NOCHANGEDIR
- | OFN_EXPLORER | OFN_ENABLEHOOK);
+ | OFN_EXPLORER | OFN_ENABLEHOOK);
+
if (!NILP (mustmatch))
{
- /* Require that the path to the parent directory exists. */
- file_details->Flags |= OFN_PATHMUSTEXIST;
- /* If we are looking for a file, require that it exists. */
- if (NILP (only_dir_p))
- file_details->Flags |= OFN_FILEMUSTEXIST;
+ /* Require that the path to the parent directory exists. */
+ file_details->Flags |= OFN_PATHMUSTEXIST;
+ /* If we are looking for a file, require that it exists. */
+ if (NILP (only_dir_p))
+ file_details->Flags |= OFN_FILEMUSTEXIST;
}
- file_details->lpfnHook = (LPOFNHOOKPROC) file_dialog_callback;
-
- file_opened = GetOpenFileName (file_details);
+ {
+ int count = SPECPDL_INDEX ();
+ specbind (Qinhibit_redisplay, Qt);
- BLOCK_INPUT;
++ block_input ();
+ file_details->lpfnHook = file_dialog_callback;
- unblock_input ();
+#ifdef NTGUI_UNICODE
+ file_opened = GetOpenFileNameW (file_details);
+#else /* !NTGUI_UNICODE */
+ file_opened = GetOpenFileNameA (file_details);
+#endif /* NTGUI_UNICODE */
- UNBLOCK_INPUT;
++ unblock_input ();
+ unbind_to (count, Qnil);
+ }
if (file_opened)
{
SYSTEM_INFO sysinfo_cache;
/* This gives us version, build, and platform identification. */
+extern unsigned long syspage_mask;
OSVERSIONINFO osinfo_cache;
+ size_t syspage_mask = 0;
+
/* The major and minor versions of NT. */
int w32_major_version;
int w32_minor_version;
utf8to16 (out_string, utf8_len, utf16_string);
return_value = unicode_append_menu (menu, fuFlags,
- item != NULL ? (UINT) item
- : (UINT) wv->call_data,
+ item != NULL ? (UINT_PTR) item
+ : (UINT_PTR) wv->call_data,
utf16_string);
+
+#ifndef NTGUI_UNICODE /* Fallback does not apply when always UNICODE */
if (!return_value)
{
/* On W9x/ME, Unicode menus are not supported, though AppendMenuW
struct frame *f;
struct w32_display_info *dpyinfo = &one_w32_display_info;
Mouse_HLInfo *hlinfo = &dpyinfo->mouse_highlight;
+ static char buf[1];
- if (interrupt_input_blocked)
- {
- interrupt_input_pending = 1;
- pending_signals = 1;
- return -1;
- }
-
- interrupt_input_pending = 0;
- BLOCK_INPUT;
+ block_input ();
/* So people can tell when we have read the available input. */
input_signal_count++;
the bitmaps. */
w32_init_fringe (terminal->rif);
- UNBLOCK_INPUT;
-#ifdef F_SETOWN
- fcntl (connection, F_SETOWN, getpid ());
-#endif /* ! defined (F_SETOWN) */
-
-#ifdef SIGIO
- if (interrupt_input)
- init_sigio (connection);
-#endif /* ! defined (SIGIO) */
-
+ unblock_input ();
return dpyinfo;
}
Lisp_Object, Lisp_Object,
Lisp_Object, Lisp_Object);
+extern void x_focus_on_frame (struct frame *f);
+
+/* also defined in xterm.h XXX: factor out to common header */
+
extern struct w32_display_info *w32_term_init (Lisp_Object,
char *, char *);
-
+extern void check_w32 (void);
- extern int w32_defined_color (FRAME_PTR f, char *color,
++extern int w32_defined_color (FRAME_PTR f, const char *color,
+ XColor *color_def, int alloc);
- extern void set_frame_menubar (struct frame *f, int first_time, int deep_p);
+extern void x_set_window_size (struct frame *f, int change_grav,
+ int cols, int rows);
extern int x_display_pixel_height (struct w32_display_info *);
extern int x_display_pixel_width (struct w32_display_info *);
- extern void x_wm_set_size_hint (struct frame *, long, int);
+extern void x_sync (struct frame *);
+extern Lisp_Object x_get_focus_frame (struct frame *);
+extern void x_set_mouse_position (struct frame *f, int h, int v);
+extern void x_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y);
+extern void x_make_frame_visible (struct frame *f);
+extern void x_make_frame_invisible (struct frame *f);
+extern void x_iconify_frame (struct frame *f);
+extern int x_char_width (struct frame *f);
+extern int x_char_height (struct frame *f);
+extern int x_pixel_width (struct frame *f);
+extern int x_pixel_height (struct frame *f);
+extern void x_set_frame_alpha (struct frame *f);
+extern void x_set_menu_bar_lines (struct frame *, Lisp_Object, Lisp_Object);
+extern void x_set_tool_bar_lines (struct frame *f,
+ Lisp_Object value,
+ Lisp_Object oldval);
+extern void x_activate_menubar (struct frame *);
+extern int x_bitmap_icon (struct frame *, Lisp_Object);
+extern void initialize_frame_menubar (struct frame *);
+extern void x_free_frame_resources (struct frame *);
+extern void x_real_positions (struct frame *, int *, int *);
+
+/* w32inevt.c */
+extern int w32_kbd_patch_key (KEY_EVENT_RECORD *event, int cpId);
+extern int w32_kbd_mods_to_emacs (DWORD mods, WORD key);
+
+ extern Lisp_Object x_get_focus_frame (struct frame *);
+
\f
#define PIX_TYPE COLORREF
#endif /* HAVE_X_WINDOWS */
-#ifdef WINDOWSNT
+#ifdef HAVE_NTGUI
/* W32 emulation of GCs */
- static inline GC
+ static GC
x_create_gc (struct frame *f, unsigned long mask, XGCValues *xgcv)
{
GC gc;