From: Daniel Colascione Date: Sun, 7 Oct 2012 22:31:58 +0000 (-0800) Subject: Merge from trunk X-Git-Tag: emacs-24.2.90~237^2~61^2~3 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=36a305a723c63fd345be65c536c52fe9765c14be;p=emacs.git Merge from trunk --- 36a305a723c63fd345be65c536c52fe9765c14be diff --cc src/Makefile.in index a31499e2767,f8da0091711..e704f2f5c0c --- a/src/Makefile.in +++ b/src/Makefile.in @@@ -343,8 -340,9 +344,9 @@@ base_obj = dispnew.o frame.o scroll.o x 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. @@@ -387,10 -385,9 +389,11 @@@ otherobj= $(TERMCAP_OBJ) $(PRE_ALLOC_OB ## 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) \ diff --cc src/emacs.c index 80d536a5c14,bc54f56b98a..6cc50a23d66 --- a/src/emacs.c +++ b/src/emacs.c @@@ -35,22 -33,15 +33,26 @@@ along with GNU Emacs. If not, see -#include /* 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 @@@ -712,11 -669,10 +696,10 @@@ main (int argc, char **argv 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; diff --cc src/font.h index 71cb26ccfdc,0475eb665dd..3035a909efc --- a/src/font.h +++ b/src/font.h @@@ -23,6 -23,6 +23,7 @@@ along with GNU Emacs. If not, see 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. */ @@@ -1875,14 -1845,9 +1850,9 @@@ mark_image_cache (struct image_cache *c 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. */ @@@ -3050,6 -3008,12 +3013,12 @@@ static const struct image_keyword xpm_f {":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 = @@@ -3272,17 -3233,10 +3238,17 @@@ init_xpm_functions (void 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. */ @@@ -5393,6 -5340,12 +5352,12 @@@ static const struct image_keyword png_f {":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 = @@@ -6045,6 -5999,12 +6011,12 @@@ static const struct image_keyword jpeg_ {":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 = @@@ -7084,6 -7046,12 +7064,12 @@@ static const struct image_keyword gif_f {":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 = @@@ -8238,16 -8215,15 +8233,15 @@@ init_svg_functions (void #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. */ @@@ -8786,17 -8763,7 +8781,17 @@@ DEFUN ("lookup-image", Flookup_image, S Initialization ***********************************************************************/ +#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, 2, 2, 0, + 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. diff --cc src/keyboard.c index 451ffd9d600,d06b02024c5..05b9a9dde01 --- a/src/keyboard.c +++ b/src/keyboard.c @@@ -3790,17 -3766,9 +3766,9 @@@ kbd_buffer_get_event (KBOARD **kbp #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 */ diff --cc src/w32.h index b83b716b617,2e2315e245d..c4cfdf5fedd --- a/src/w32.h +++ b/src/w32.h @@@ -133,10 -127,24 +133,13 @@@ extern void reset_standard_handles (in /* 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); diff --cc src/w32fns.c index cd48ae65e32,db3b3e64b2d..7f0e6d5e5bf --- a/src/w32fns.c +++ b/src/w32fns.c @@@ -81,11 -78,8 +81,9 @@@ extern int w32_console_toggle_lock_key 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 @@@ -1106,7 -1068,7 +1103,7 @@@ gamma_correct (struct frame *f, COLORRE 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; @@@ -2281,58 -2246,27 +2278,84 @@@ unregister_hot_keys (HWND hwnd } } +#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. */ ++ 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 @@@ -6196,36 -6011,33 +6197,36 @@@ Otherwise, if ONLY-DIR-P is non-nil, th 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) { diff --cc src/w32heap.c index e7d4c29e043,8b9b19ea35d..bc8aa356923 --- a/src/w32heap.c +++ b/src/w32heap.c @@@ -32,9 -32,10 +32,11 @@@ along with GNU Emacs. If not, see 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 diff --cc src/w32term.c index af075955e2c,517813672c4..627ff54394b --- a/src/w32term.c +++ b/src/w32term.c @@@ -4172,17 -4163,8 +4177,9 @@@ w32_read_socket (struct terminal *termi 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++; @@@ -6351,7 -6319,16 +6348,7 @@@ w32_term_init (Lisp_Object display_name 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; } diff --cc src/w32term.h index 434eb92fdea,fcaccc4d624..9fb37b9f030 --- a/src/w32term.h +++ b/src/w32term.h @@@ -197,48 -195,14 +197,48 @@@ Lisp_Object display_x_get_resource (str 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_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_wm_set_size_hint (struct frame *, long, int); +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 *); + #define PIX_TYPE COLORREF diff --cc src/xfaces.c index 51e568547ee,f861dde2d15..3e6e9dc8ec0 --- a/src/xfaces.c +++ b/src/xfaces.c @@@ -625,10 -625,10 +625,10 @@@ x_free_gc (struct frame *f, GC gc #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;