diff options
author | Miles Bader <miles@gnu.org> | 2007-12-06 09:51:45 +0000 |
---|---|---|
committer | Miles Bader <miles@gnu.org> | 2007-12-06 09:51:45 +0000 |
commit | 0bd508417142ff377f34aec8dcec9438d9175c2c (patch) | |
tree | 4d60fe09e5cebf7d79766b11e9cda8cc1c9dbb9b /src | |
parent | 98fe991da804a42f53f6a5e84cd5eab18a82e181 (diff) | |
parent | 9fb1ba8090da3528de56158a79bd3527d31c7f2f (diff) | |
download | emacs-0bd508417142ff377f34aec8dcec9438d9175c2c.tar.gz |
Merge from emacs--devo--0
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-294
Diffstat (limited to 'src')
-rw-r--r-- | src/ChangeLog | 345 | ||||
-rw-r--r-- | src/ChangeLog.10 | 2 | ||||
-rw-r--r-- | src/Makefile.in | 19 | ||||
-rw-r--r-- | src/alloc.c | 22 | ||||
-rw-r--r-- | src/buffer.c | 52 | ||||
-rw-r--r-- | src/buffer.h | 38 | ||||
-rw-r--r-- | src/config.in | 3 | ||||
-rw-r--r-- | src/data.c | 102 | ||||
-rw-r--r-- | src/dbusbind.c | 817 | ||||
-rw-r--r-- | src/dispnew.c | 4 | ||||
-rw-r--r-- | src/editfns.c | 53 | ||||
-rw-r--r-- | src/emacs.c | 8 | ||||
-rw-r--r-- | src/eval.c | 17 | ||||
-rw-r--r-- | src/gtkutil.c | 17 | ||||
-rw-r--r-- | src/image.c | 15 | ||||
-rw-r--r-- | src/keyboard.c | 140 | ||||
-rw-r--r-- | src/keymap.c | 3 | ||||
-rw-r--r-- | src/lisp.h | 12 | ||||
-rw-r--r-- | src/mac.c | 51 | ||||
-rw-r--r-- | src/macfns.c | 34 | ||||
-rw-r--r-- | src/macterm.c | 6 | ||||
-rw-r--r-- | src/print.c | 2 | ||||
-rw-r--r-- | src/process.c | 7 | ||||
-rw-r--r-- | src/puresize.h | 2 | ||||
-rw-r--r-- | src/s/darwin.h | 3 | ||||
-rw-r--r-- | src/s/gnu-kfreebsd.h | 11 | ||||
-rw-r--r-- | src/s/ms-w32.h | 8 | ||||
-rw-r--r-- | src/search.c | 35 | ||||
-rw-r--r-- | src/sysdep.c | 55 | ||||
-rw-r--r-- | src/term.c | 11 | ||||
-rw-r--r-- | src/termhooks.h | 50 | ||||
-rw-r--r-- | src/unexmacosx.c | 103 | ||||
-rw-r--r-- | src/w32bdf.c | 4 | ||||
-rw-r--r-- | src/w32console.c | 79 | ||||
-rw-r--r-- | src/w32fns.c | 271 | ||||
-rw-r--r-- | src/w32proc.c | 9 | ||||
-rw-r--r-- | src/w32term.h | 1 | ||||
-rw-r--r-- | src/window.c | 66 | ||||
-rw-r--r-- | src/xdisp.c | 8 | ||||
-rw-r--r-- | src/xfaces.c | 14 | ||||
-rw-r--r-- | src/xfns.c | 22 | ||||
-rw-r--r-- | src/xterm.c | 152 | ||||
-rw-r--r-- | src/xterm.h | 38 |
43 files changed, 2043 insertions, 668 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 4cf00fc3c30..f55e4ac786c 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,346 @@ +2007-12-05 Magnus Henoch <mange@freemail.hu> + + * process.c (make_process): Initialize pty_flag to 0. + +2007-12-05 Jason Rumney <jasonr@gnu.org> + + * image.c (xbm_load) [WINDOWSNT]: Shuffle the bits of directly + specified XBMs. + +2007-12-05 Richard Stallman <rms@gnu.org> + + * xdisp.c (syms_of_xdisp) <scroll-conservatively>: Doc fix. + +2007-12-05 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> + + * mac.c (cfsockets_for_select) [MAC_OSX && SELECT_USE_CFSOCKET]: + New variable. + (mac_try_close_socket) [MAC_OSX]: New function. + [MAC_OSX] (sys_select) [SELECT_USE_CFSOCKET]: + Update cfsockets_for_select. Replace invalid CFRunLoop source. + + * sysdep.c (emacs_close) [MAC_OSX && HAVE_CARBON]: + Use mac_try_close_socket. + +2007-12-05 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> + + * unexmacosx.c (unrelocate): New argument BASE. Use it instead of + reloc_base. + (copy_dysymtab): Compute relocation base here. + (rebase_reloc_address) [__ppc64__]: New function. + (copy_dysymtab) [__ppc64__]: Use it if relocation base needs to be + changed. + +2007-12-05 Jason Rumney <jasonr@gnu.org> + + * w32proc.c (sys_spawnve): Quote args with wildcards. + +2007-12-05 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> + + * unexmacosx.c (copy_data_segment): Also copy __gcc_except_tab and + __objc_* sections. + (unrelocate) [_LP64]: Set relocation base to address of data segment. + +2007-12-05 Michael Albinus <michael.albinus@gmx.de> + + * dbusbind.c (xd_read_message): Return value is a Lisp_Object. + Move check for Vdbus_registered_functions_table to + xd_read_queued_messages. + (xd_read_queued_messages): Protect xd_read_message calls by + internal_condition_case_1. + +2007-12-04 Michael Albinus <michael.albinus@gmx.de> + + * dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from + Qdbus_system_bus and Qdbus_session_bus, respectively. + (Vdbus_intern_symbols): Removed. + (Vdbus_registered_functions_table): New hash table. + (XD_SYMBOL_INTERN_SYMBOL): Removed. + (xd_read_message, Fdbus_register_signal, Fdbus_unregister_signal): + Rewritten in order to manage registered functions by hash table + Vdbus_registered_functions_table. + +2007-12-03 Jan Dj,Ad(Brv <jan.h.d@swipnet.se> + + * xterm.c: Update URL to Window Manager Specification in comment. + +2007-12-02 Michael Albinus <michael.albinus@gmx.de> + + * config.in (HAVE_DBUS): Add. + + * Makefile.in: (HAVE_DBUS): Add D-Bus definitions if defined. + (ALL_CFLAGS): Add ${DBUS_CFLAGS}. + (obj): Add $(DBUS_OBJ). + (LIBES): Add $(DBUS_LIBS). + (dbusbind.o): New target. + + * dbusbind.c: New file. + + * emacs.c (main): Call syms_of_dbusbind when HAVE_DBUS is defined. + + * keyboard.c: All D-Bus related code is wrapped by "#ifdef HAVE_DBUS". + (Qdbus_event) New Lisp symbol. + (kbd_buffer_get_event, make_lispy_event): Handle DBUS_EVENT. + (gobble_input): Call xd_read_queued_messages, reading D-Bus + messages. + (keys_of_keyboard ): Define dbus-event. + + * termhooks.h (event_kind): Add DBUS_EVENT when HAVE_DBUS is defined. + +2007-12-01 Richard Stallman <rms@gnu.org> + + * search.c (syms_of_search) <inhibit-changing-match-data>: Doc fix. + +2007-11-30 Jason Rumney <jasonr@gnu.org> + + * w32console.c (w32con_ins_del_lines, scroll_line): Clip to window. + (w32con_reset_terminal_modes): Clear screen buffer. + (w32_face_attributes): Don't use color indexes that are out of range. + Only reverse the default colors. + + * xfaces.c (map_tty_color, tty_color_name): Remove special case for + WINDOWSNT. + + * w32console.c, w32term.h (vga_stdcolor_name): Remove. + +2007-11-29 Jason Rumney <jasonr@gnu.org> + + * w32console.c: Leave HAVE_WINDOW_SYSTEM defined. + (w32_face_attributes): Use Vtty_defined_color_alist to determine + if the terminal colors are initialized. + (unspecified_fg, unspecified_bg): Remove unused declarations. + +2007-11-29 Andreas Schwab <schwab@suse.de> + + * keyboard.c (apply_modifiers): Fix typo. + +2007-11-29 Richard Stallman <rms@gnu.org> + + * keymap.c (Fcurrent_local_map): Doc fix. + +2007-11-28 Petr Salinger <Petr.Salinger@seznam.cz> (tiny change) + + * s/gnu-kfreebsd.h: New file. + +2007-11-28 Stefan Monnier <monnier@iro.umontreal.ca> + + * buffer.c (Fget_buffer_create, Fmake_indirect_buffer): + Don't cast redundantly. + + * keyboard.c (KEY_TO_CHAR): New macro. + (parse_modifiers, apply_modifiers): Accept integer arguments. + (read_key_sequence): Use them to unify the "shift->unshift" mapping + for chars and symbol keys. + After doing such remapping, apply function-key-map again. + +2007-11-27 Dan Nicolaescu <dann@ics.uci.edu> + + * Makefile.in (SOME_MACHINE_LISP): Remove VMS files, they are not + compiled anymore. + +2007-11-26 Andreas Schwab <schwab@suse.de> + + * process.c (list_processes_1): Fix indentation level of the + command column. + +2007-11-23 Andreas Schwab <schwab@suse.de> + + * editfns.c (Fformat): Handle %c specially since it requires the + argument to be of type int. + +2007-11-23 Markus Triska <markus.triska@gmx.at> + + * emacs.c (main): Call init_editfns before init_process, since + init_process sets Vprocess_connection_type depending on OS release + +2007-11-22 Stefan Monnier <monnier@iro.umontreal.ca> + + * data.c (do_symval_forwarding): Use same code as in find_symbol_value. + (find_symbol_value): Use do_symval_forwarding. + + * data.c (set_internal): Set the value in the `cons-cell' (for + Buffer_Local_values) not only for frame-local variables. + +2007-11-22 Andreas Schwab <schwab@suse.de> + + * data.c (Fnumber_to_string): Add cast when passing EMACS_INT + values to sprintf. + * keymap.c (Fsingle_key_description): Likewise. + * print.c (print_object): Likewise. + +2007-11-22 Jan Dj,Ad(Brv <jan.h.d@swipnet.se> + + * gtkutil.c (update_frame_tool_bar): Don't call x-gtk-map-stock if + file for image is nil. + +2007-11-22 Dan Nicolaescu <dann@ics.uci.edu> + + * term.c: Include stdarg.h. + (fatal): Implement using varargs. + * lisp.h (fatal): Add argument types. (Restore 2005-09-30 change). + +2007-11-21 Stefan Monnier <monnier@iro.umontreal.ca> + + * lisp.h (struct Lisp_Buffer_Objfwd): Add a `slottype' field. + * data.c (store_symval_forwarding): Get type from buffer_objfwd. + Update call to buffer_slot_type_mismatch. + * buffer.h (buffer_local_types, PER_BUFFER_TYPE): Remove. + (buffer_slot_type_mismatch): Update. + * buffer.c (buffer_local_types): Remove. + (buffer_slot_type_mismatch): Get the symbol and type as arguments. + (defvar_per_buffer): Set the type in the buffer_objfwd. + +2007-11-21 Jason Rumney <jasonr@gnu.org> + + * w32bdf.c (w32_init_bdf_font, w32_BDF_to_x_font): + CreateFileMapping returns NULL on failure. + +2007-11-21 Stefan Monnier <monnier@iro.umontreal.ca> + + * search.c (Fset_match_data): Remove the `evaporate' feature. + (unwind_set_match_data): Don't use the `evaporate' feature. + +2007-11-21 Jason Rumney <jasonr@gnu.org> + + * dispnew.c (init_display) [WINDOWSNT]: Hardcode terminal_type. + + * w32console.c (w32con_write_glyphs): Remove unused variables. + +2007-11-20 Dan Nicolaescu <dann@ics.uci.edu> + + * macterm.c (mac_term_init): Call add_keyboard_wait_descriptor. + + * s/darwin.h (MULTI_KBOARD): Remove. + + * macfns.c (x_create_tip_frame, Fx_create_frame) + (x_create_tip_frame): Don't deal with MULTI_KBOARD. + +2007-11-19 Stefan Monnier <monnier@iro.umontreal.ca> + + * buffer.c (Fbuffer_local_value): Remove redundant test. + (swap_out_buffer_local_variables): Swap out binding in `buffer' rather + than in `current-buffer' to match the comment. + Do the swap using swap_in_global_binding. + + * data.c (store_symval_forwarding, set_internal): + * eval.c (specbind): Remove dead code. + + * coding.c (detect_coding, Fupdate_coding_systems_internal): + * fns.c (Fmd5): Use find_symbol_value rather than SYMBOL_VALUE + Since we do not want to see internal Lisp_*fwd objects here. + +2007-11-18 Jan Dj,Ad(Brv <jan.h.d@swipnet.se> + + * sysdep.c (init_system_name): Use getaddrinfo if available. + + * xterm.c (x_scroll_bar_set_handle, x_scroll_bar_handle_click) + (x_scroll_bar_note_movement): start, end, with, height in struct + scroll_bar are integers and not Lisp_Object, so remove XINT for them. + +2007-11-17 Dan Nicolaescu <dann@ics.uci.edu> + + * puresize.h (BASE_PURESIZE): Increase to 1190000. + +2007-11-16 Stefan Monnier <monnier@iro.umontreal.ca> + + * buffer.h (struct buffer): Move `undo_list' back to before `name'. + This undoes Richard's change of 14-Oct-2002. + + * alloc.c (allocate_other_vector): + * lisp.h (allocate_other_vector): Remove. + + * window.c (struct save_window_data): Move non-lisp data to the end + and make it `int' rather than Lisp_Object. + (Fcurrent_window_configuration): Use ALLOCATE_PSEUDOVECTOR. + Done wrap/unwrap integer values. + (Fset_window_configuration, compare_window_configurations): + Update use of fields to their new types. + + * xterm.h (struct scroll_bar): Only use Lisp_Object for lisp data. + Turn integer fields into `int'. Merge x_window_low and x_window_high. + (SCROLL_BAR_PACK, SCROLL_BAR_UNPACK, SCROLL_BAR_X_WINDOW) + (SET_SCROLL_BAR_X_WINDOW): Remove. + (SCROLL_BAR_X_WIDGET, SET_SCROLL_BAR_X_WIDGET): + Access the new x_window field directly. + * xterm.c (x_scroll_bar_create): Use a pseudovector. + Don't wrap/unwrap integers into Lisp_Objects. + (XTset_vertical_scroll_bar, x_scroll_bar_handle_click) + (x_scroll_bar_report_motion): + Don't wrap/unwrap integers into Lisp_Objects. + (x_term_init): Use SDATA. + (x_window_to_scroll_bar, x_create_toolkit_scroll_bar) + (x_scroll_bar_set_handle, x_scroll_bar_remove) + (XTset_vertical_scroll_bar, x_scroll_bar_expose) + (x_scroll_bar_report_motion, x_scroll_bar_clear): + * xfns.c (x_set_background_color): + * gtkutil.c (xg_create_scroll_bar, xg_set_toolkit_scroll_bar_thumb): + Access the new x_window field directly. + + * alloc.c (ALLOCATE_PSEUDOVECTOR): Move to lisp.h. + (allocate_pseudovector): Make non-static. + + * lisp.h (enum pvec_type): New tag PVEC_OTHER. + (allocate_pseudovector): Declare. + (ALLOCATE_PSEUDOVECTOR): Move from alloc.c + +2007-11-15 Andreas Schwab <schwab@suse.de> + + * editfns.c (Fformat): Correctly format EMACS_INT values. + Also take precision into account when formatting an integer. + + * keyboard.c (Fevent_symbol_parse_modifiers): Fix declaration. + +2007-11-15 Stefan Monnier <monnier@iro.umontreal.ca> + + * keyboard.c (Fevent_symbol_parse_modifiers): New function. + (syms_of_keyboard): Defsubr it. + + * data.c (swap_in_global_binding): Fix longstanding bug where + store_symval_forwarding was not called with the right second argument, + thus causing objfwd-ing from being dropped. + +2007-11-14 Juanma Barranquero <lekktu@gmail.com> + + * macfns.c (Fx_create_frame, Fx_display_pixel_width) + (Fx_display_pixel_height, Fx_display_planes) + (Fx_display_color_cells, Fx_server_max_request_size) + (Fx_server_vendor, Fx_server_version, Fx_display_backing_store) + (Fx_display_visual_class, Fx_display_save_under): + * w32fns.c (Fx_create_frame, Fx_display_pixel_width) + (Fx_display_pixel_height, Fx_display_planes) + (Fx_display_color_cells, Fx_server_max_request_size) + (Fx_server_vendor, Fx_server_version, Fx_display_screens) + (Fx_display_mm_height, Fx_display_mm_width) + (Fx_display_backing_store, Fx_display_visual_class) + (Fw32_select_font, Fx_display_save_under): + * xfns.c (Fx_create_frame, Fx_display_pixel_width) + (Fx_display_pixel_height, Fx_display_planes) + (Fx_display_color_cells, Fx_server_max_request_size) + (Fx_server_vendor, Fx_server_version, Fx_display_backing_store) + (Fx_display_save_under): Fix typos in docstrings. + +2007-11-14 Juanma Barranquero <lekktu@gmail.com> + + * w32fns.c (Fw32_registered_hot_keys): Don't return the nil values + corresponding to deleted entries; they are an implementation detail. + (gray_bitmap_width, gray_bitmap_height, gray_bitmap_bits): + Remove variables. + (w32_pass_extra_mouse_buttons_to_system, w32_strict_fontnames) + (w32_pass_multimedia_buttons_to_system, w32_strict_painting) + (Vw32_charset_info_alist, w32_to_x_color, w32_init_class) + (w32_createscrollbar, w32_createwindow, my_post_msg, w32_get_modifiers) + (w32_grabbed_keys, cancel_all_deferred_msgs): Make static. + (Fw32_define_rgb_color, Fw32_load_color_file) + (syms_of_w32fns) <w32-pass-multimedia-buttons-to-system>: + Fix typos in docstrings. + (Fx_server_version): Reflow docstring. + (Fw32_shell_execute): Doc fixes. + +2007-11-13 Juanma Barranquero <lekktu@gmail.com> + + * w32fns.c (Fw32_register_hot_key): Don't try to register hot key + if w32_parse_hot_key returned nil. + 2007-11-10 Stefan Monnier <monnier@iro.umontreal.ca> * xdisp.c (load_overlay_strings): Fix copy&paste typo. @@ -107,7 +450,7 @@ 2007-11-01 Johan Bockg,Ae(Brd <bojohan@gnu.org> * macterm.c, w32term.c, xterm.c (x_draw_stretch_glyph_string): - Don't set s->stippled_p here, since it has already been set by + Don't set s->stippled_p here, since it has already been set by x_set_glyph_string_gc from x_draw_glyph_string. 2007-11-01 Dan Nicolaescu <dann@ics.uci.edu> diff --git a/src/ChangeLog.10 b/src/ChangeLog.10 index c5e7bc61e47..b7187263257 100644 --- a/src/ChangeLog.10 +++ b/src/ChangeLog.10 @@ -3016,7 +3016,7 @@ * w32.c: Fix high cpu load for server sockets. (pfn_WSAEventSelect): New function ptr. (init_winsock): Load it. - (sys_listen): Set FILE_LISTEN flag. Set event mask for socket's + (sys_listen): Set FILE_LISTEN flag. Set event mask for socket's char_avail event object to FD_ACCEPT. (sys_accept): Check FILE_LISTEN flag. Set event mask on new socket's char_avail event object to FD_READ|FD_CLOSE. diff --git a/src/Makefile.in b/src/Makefile.in index 5e476cd59ca..e1e5d457fc2 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -263,6 +263,12 @@ TOOLKIT_DEFINES = #endif #endif +#ifdef HAVE_DBUS +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +DBUS_OBJ = dbusbind.o +#endif + /* DO NOT use -R. There is a special hack described in lastfile.c which is used instead. Some initialized data areas are modified at initial startup, then labeled as part of the text area when @@ -276,7 +282,7 @@ TOOLKIT_DEFINES = /* C_SWITCH_X_SITE must come before C_SWITCH_X_MACHINE and C_SWITCH_X_SYSTEM since it may have -I options that should override those two. */ -ALL_CFLAGS=-Demacs -DHAVE_CONFIG_H $(TOOLKIT_DEFINES) $(MYCPPFLAGS) -I. -I${srcdir} C_SWITCH_MACHINE C_SWITCH_SYSTEM C_SWITCH_SITE C_SWITCH_X_SITE C_SWITCH_X_MACHINE C_SWITCH_X_SYSTEM C_SWITCH_SYSTEM_TEMACS ${CFLAGS_SOUND} ${RSVG_CFLAGS} ${CFLAGS} @FREETYPE_CFLAGS@ @FONTCONFIG_CFLAGS@ @LIBOTF_CFLAGS@ @M17N_FLT_CFLAGS@ +ALL_CFLAGS=-Demacs -DHAVE_CONFIG_H $(TOOLKIT_DEFINES) $(MYCPPFLAGS) -I. -I${srcdir} C_SWITCH_MACHINE C_SWITCH_SYSTEM C_SWITCH_SITE C_SWITCH_X_SITE C_SWITCH_X_MACHINE C_SWITCH_X_SYSTEM C_SWITCH_SYSTEM_TEMACS ${CFLAGS_SOUND} ${RSVG_CFLAGS} ${DBUS_CFLAGS} ${CFLAGS} @FREETYPE_CFLAGS@ @FONTCONFIG_CFLAGS@ @LIBOTF_CFLAGS@ @M17N_FLT_CFLAGS@ .c.o: $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) $< @@ -608,7 +614,7 @@ FONTOBJ = font.o whose initialized data areas should be dumped as pure by dump-emacs. */ obj= dispnew.o frame.o scroll.o xdisp.o $(XMENU_OBJ) window.o \ charset.o coding.o category.o ccl.o character.o chartab.o \ - cm.o term.o terminal.o xfaces.o $(XOBJ) $(GTK_OBJ)\ + cm.o term.o terminal.o xfaces.o $(XOBJ) $(GTK_OBJ) $(DBUS_OBJ) \ emacs.o keyboard.o macros.o keymap.o sysdep.o \ buffer.o filelock.o insdel.o marker.o \ minibuf.o fileio.o dired.o filemode.o \ @@ -925,7 +931,7 @@ shortlisp= \ for the sake of systems which can''t handle large ones. */ SOME_MACHINE_LISP = ${dotdot}/lisp/mouse.elc \ ${dotdot}/lisp/select.elc ${dotdot}/lisp/scroll-bar.elc \ - ${dotdot}/lisp/vmsproc.elc ${dotdot}/lisp/vms-patch.elc \ + VMS_SUPPORT \ ${dotdot}/lisp/ls-lisp.elc ${dotdot}/lisp/dos-fns.elc \ ${dotdot}/lisp/w32-fns.elc ${dotdot}/lisp/dos-w32.elc \ ${dotdot}/lisp/disp-table.elc ${dotdot}/lisp/dos-vars.elc \ @@ -943,8 +949,8 @@ SOME_MACHINE_LISP = ${dotdot}/lisp/mouse.elc \ 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 gnulib again after them. */ -LIBES = $(LOADLIBES) $(LIBS) $(LIBX) $(LIBSOUND) $(RSVG_LIBS) LIBGPM \ - LIBRESOLV LIBS_SYSTEM LIBS_MACHINE LIBS_TERMCAP \ +LIBES = $(LOADLIBES) $(LIBS) $(LIBX) $(LIBSOUND) $(RSVG_LIBS) $(DBUS_LIBS) \ + LIBGPM LIBRESOLV LIBS_SYSTEM LIBS_MACHINE LIBS_TERMCAP \ LIBS_DEBUG $(GETLOADAVG_LIBS) \ @FREETYPE_LIBS@ @FONTCONFIG_LIBS@ @LIBOTF_LIBS@ @M17N_FLT_LIBS@ \ $(GNULIB_VAR) LIB_MATH LIB_STANDARD $(GNULIB_VAR) @@ -1265,9 +1271,10 @@ xselect.o: xselect.c process.h dispextern.h frame.h xterm.h blockinput.h \ xrdb.o: xrdb.c $(config_h) epaths.h xsmfns.o: xsmfns.c $(config_h) systime.h sysselect.h termhooks.h xterm.h \ lisp.h termopts.h -gtkutil.o: gtkutil.c gtkutil.h xterm.h lisp.h frame.h $(config_h) \ +gtkutil.o: gtkutil.c gtkutil.h xterm.h lisp.h frame.h $(config_h) \ blockinput.h window.h atimer.h systime.h termhooks.h keyboard.h \ charset.h coding.h +dbusbind.o: dbusbind.c termhooks.h $(config_h) hftctl.o: hftctl.c $(config_h) sound.o: sound.c dispextern.h $(config_h) diff --git a/src/alloc.c b/src/alloc.c index 5e3c38943f4..88f37ee363c 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -2967,7 +2967,7 @@ allocate_vector (nslots) /* Allocate other vector-like structures. */ -static struct Lisp_Vector * +struct Lisp_Vector * allocate_pseudovector (memlen, lisplen, tag) int memlen, lisplen; EMACS_INT tag; @@ -2983,10 +2983,6 @@ allocate_pseudovector (memlen, lisplen, tag) XSETPVECTYPE (v, tag); /* Add the appropriate tag. */ return v; } -#define ALLOCATE_PSEUDOVECTOR(typ,field,tag) \ - ((typ*) \ - allocate_pseudovector \ - (VECSIZE (typ), PSEUDOVECSIZE (typ, field), tag)) struct Lisp_Hash_Table * allocate_hash_table (void) @@ -3033,22 +3029,6 @@ allocate_process () } -/* Only used for PVEC_WINDOW_CONFIGURATION. */ -struct Lisp_Vector * -allocate_other_vector (len) - EMACS_INT len; -{ - struct Lisp_Vector *v = allocate_vectorlike (len); - EMACS_INT i; - - for (i = 0; i < len; ++i) - v->contents[i] = Qnil; - v->size = len; - - return v; -} - - DEFUN ("make-vector", Fmake_vector, Smake_vector, 2, 2, 0, doc: /* Return a newly created vector of length LENGTH, with each element being INIT. See also the function `vector'. */) diff --git a/src/buffer.c b/src/buffer.c index 416ff7e3702..77af23ace39 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -99,17 +99,6 @@ DECL_ALIGN (struct buffer, buffer_local_symbols); /* A Lisp_Object pointer to the above, used for staticpro */ static Lisp_Object Vbuffer_local_symbols; -/* This structure holds the required types for the values in the - buffer-local slots. If a slot contains Qnil, then the - corresponding buffer slot may contain a value of any type. If a - slot contains an integer, then prospective values' tags must be - equal to that integer (except nil is always allowed). - When a tag does not match, the function - buffer_slot_type_mismatch will signal an error. - - If a slot here contains -1, the corresponding variable is read-only. */ -struct buffer buffer_local_types; - /* Flags indicating which built-in buffer-local variables are permanent locals. */ static char buffer_permanent_local_flags[MAX_PER_BUFFER_VARS]; @@ -360,7 +349,7 @@ The value is never nil. */) if (SCHARS (name) == 0) error ("Empty string for buffer name is not allowed"); - b = (struct buffer *) allocate_buffer (); + b = allocate_buffer (); /* An ordinary buffer uses its own struct buffer_text. */ b->text = &b->own_text; @@ -561,7 +550,7 @@ CLONE nil means the indirect buffer's state is reset to default values. */) if (SCHARS (name) == 0) error ("Empty string for buffer name is not allowed"); - b = (struct buffer *) allocate_buffer (); + b = allocate_buffer (); b->base_buffer = (XBUFFER (base_buffer)->base_buffer ? XBUFFER (base_buffer)->base_buffer @@ -896,8 +885,7 @@ is the default binding of the variable. */) CHECK_BUFFER (buffer); buf = XBUFFER (buffer); - if (SYMBOLP (variable)) - variable = indirect_variable (variable); + variable = indirect_variable (variable); /* Look in local_var_list */ result = Fassoc (variable, buf->local_var_alist); @@ -2534,26 +2522,11 @@ swap_out_buffer_local_variables (b) /* Need not do anything if some other buffer's binding is now encached. */ tem = XBUFFER_LOCAL_VALUE (SYMBOL_VALUE (sym))->buffer; - if (BUFFERP (tem) && XBUFFER (tem) == current_buffer) + if (EQ (tem, buffer)) { - /* Symbol is set up for this buffer's old local value. - Set it up for the current buffer with the default value. */ - - tem = XBUFFER_LOCAL_VALUE (SYMBOL_VALUE (sym))->cdr; - /* Store the symbol's current value into the alist entry - it is currently set up for. This is so that, if the - local is marked permanent, and we make it local again - later in Fkill_all_local_variables, we don't lose the value. */ - XSETCDR (XCAR (tem), - do_symval_forwarding (XBUFFER_LOCAL_VALUE (SYMBOL_VALUE (sym))->realvalue)); - /* Switch to the symbol's default-value alist entry. */ - XSETCAR (tem, tem); - /* Mark it as current for buffer B. */ - XBUFFER_LOCAL_VALUE (SYMBOL_VALUE (sym))->buffer = buffer; - /* Store the current value into any forwarding in the symbol. */ - store_symval_forwarding (sym, - XBUFFER_LOCAL_VALUE (SYMBOL_VALUE (sym))->realvalue, - XCDR (tem), NULL); + /* Symbol is set up for this buffer's old local value: + swap it out! */ + swap_in_global_binding (sym); } } } @@ -4434,13 +4407,13 @@ evaporate_overlays (pos) in the slot with offset OFFSET. */ void -buffer_slot_type_mismatch (offset) - int offset; +buffer_slot_type_mismatch (sym, type) + Lisp_Object sym; + int type; { - Lisp_Object sym; char *type_name; - switch (XINT (PER_BUFFER_TYPE (offset))) + switch (type) { case Lisp_Int: type_name = "integers"; @@ -4458,7 +4431,6 @@ buffer_slot_type_mismatch (offset) abort (); } - sym = PER_BUFFER_SYMBOL (offset); error ("Only %s should be stored in the buffer-local variable %s", type_name, SDATA (SYMBOL_NAME (sym))); } @@ -5306,9 +5278,9 @@ defvar_per_buffer (namestring, address, type, doc) XMISCTYPE (val) = Lisp_Misc_Buffer_Objfwd; XBUFFER_OBJFWD (val)->offset = offset; + XBUFFER_OBJFWD (val)->slottype = type; SET_SYMBOL_VALUE (sym, val); PER_BUFFER_SYMBOL (offset) = sym; - PER_BUFFER_TYPE (offset) = type; if (PER_BUFFER_IDX (offset) == 0) /* Did a DEFVAR_PER_BUFFER without initializing the corresponding diff --git a/src/buffer.h b/src/buffer.h index d9e82d62b17..22cb21cb3ae 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -561,6 +561,15 @@ struct buffer /* Position where the overlay lists are centered. */ EMACS_INT overlay_center; + /* Changes in the buffer are recorded here for undo. + t means don't record anything. + This information belongs to the base buffer of an indirect buffer, + But we can't store it in the struct buffer_text + because local variables have to be right in the struct buffer. + So we copy it around in set_buffer_internal. + This comes before `name' because it is marked in a special way. */ + Lisp_Object undo_list; + /* Everything from here down must be a Lisp_Object. */ /* The name of this buffer. */ @@ -601,15 +610,6 @@ struct buffer /* Mode line element that controls format of mode line. */ Lisp_Object mode_line_format; - /* Changes in the buffer are recorded here for undo. - t means don't record anything. - This information belongs to the base buffer of an indirect buffer, - But we can't store it in the struct buffer_text - because local variables have to be right in the struct buffer. - So we copy it around in set_buffer_internal. - This comes before `name' because it is marked in a special way. */ - Lisp_Object undo_list; - /* Analogous to mode_line_format for the line displayed at the top of windows. Nil means don't display that line. */ Lisp_Object header_line_format; @@ -827,18 +827,6 @@ extern struct buffer buffer_local_flags; that don't have such names. */ extern struct buffer buffer_local_symbols; - -/* This structure holds the required types for the values in the - buffer-local slots. If a slot contains Qnil, then the - corresponding buffer slot may contain a value of any type. If a - slot contains an integer, then prospective values' tags must be - equal to that integer (except nil is always allowed). - When a tag does not match, the function - buffer_slot_type_mismatch will signal an error. - - If a slot here contains -1, the corresponding variable is read-only. */ - -extern struct buffer buffer_local_types; extern void delete_all_overlays P_ ((struct buffer *)); extern void reset_buffer P_ ((struct buffer *)); @@ -852,7 +840,7 @@ extern void set_buffer_internal P_ ((struct buffer *)); extern void set_buffer_internal_1 P_ ((struct buffer *)); extern void set_buffer_temp P_ ((struct buffer *)); extern void record_buffer P_ ((Lisp_Object)); -extern void buffer_slot_type_mismatch P_ ((int)) NO_RETURN; +extern void buffer_slot_type_mismatch P_ ((Lisp_Object, int)) NO_RETURN; extern void fix_overlays_before P_ ((struct buffer *, EMACS_INT, EMACS_INT)); extern void mmap_set_vars P_ ((int)); @@ -1005,11 +993,5 @@ extern int last_per_buffer_idx; #define PER_BUFFER_SYMBOL(OFFSET) \ (*(Lisp_Object *)((OFFSET) + (char *) &buffer_local_symbols)) -/* Return the type of the per-buffer variable at offset OFFSET in the - buffer structure. */ - -#define PER_BUFFER_TYPE(OFFSET) \ - (*(Lisp_Object *)((OFFSET) + (char *) &buffer_local_types)) - /* arch-tag: 679305dd-d41c-4a50-b170-3caf5c97b2d1 (do not change this comment) */ diff --git a/src/config.in b/src/config.in index 874f74ba256..d7023aafa70 100644 --- a/src/config.in +++ b/src/config.in @@ -117,6 +117,9 @@ Boston, MA 02110-1301, USA. */ /* Define to 1 if you have /usr/lib/crti.o. */ #undef HAVE_CRTIN +/* Define to 1 if using D-Bus. */ +#undef HAVE_DBUS + /* Define to 1 if you have the declaration of `sys_siglist', and to 0 if you don't. */ #undef HAVE_DECL_SYS_SIGLIST diff --git a/src/data.c b/src/data.c index e02e22aa0e3..88a665b3cf8 100644 --- a/src/data.c +++ b/src/data.c @@ -864,7 +864,6 @@ do_symval_forwarding (valcontents) register Lisp_Object valcontents; { register Lisp_Object val; - int offset; if (MISCP (valcontents)) switch (XMISCTYPE (valcontents)) { @@ -879,11 +878,10 @@ do_symval_forwarding (valcontents) return *XOBJFWD (valcontents)->objvar; case Lisp_Misc_Buffer_Objfwd: - offset = XBUFFER_OBJFWD (valcontents)->offset; - return PER_BUFFER_VALUE (current_buffer, offset); + return PER_BUFFER_VALUE (current_buffer, + XBUFFER_OBJFWD (valcontents)->offset); case Lisp_Misc_Kboard_Objfwd: - offset = XKBOARD_OBJFWD (valcontents)->offset; /* We used to simply use current_kboard here, but from Lisp code, it's value is often unexpected. It seems nicer to allow constructions like this to work as intuitively expected: @@ -895,7 +893,8 @@ do_symval_forwarding (valcontents) last-command and real-last-command, and people may rely on that. I took a quick look at the Lisp codebase, and I don't think anything will break. --lorentey */ - return *(Lisp_Object *)(offset + (char *)FRAME_KBOARD (SELECTED_FRAME ())); + return *(Lisp_Object *)(XKBOARD_OBJFWD (valcontents)->offset + + (char *)FRAME_KBOARD (SELECTED_FRAME ())); } return valcontents; } @@ -922,13 +921,15 @@ store_symval_forwarding (symbol, valcontents, newval, buf) case Lisp_Misc_Intfwd: CHECK_NUMBER (newval); *XINTFWD (valcontents)->intvar = XINT (newval); - if (*XINTFWD (valcontents)->intvar != XINT (newval)) - error ("Value out of range for variable `%s'", - SDATA (SYMBOL_NAME (symbol))); + /* This can never happen since intvar points to an EMACS_INT + which is at least large enough to hold a Lisp_Object. + if (*XINTFWD (valcontents)->intvar != XINT (newval)) + error ("Value out of range for variable `%s'", + SDATA (SYMBOL_NAME (symbol))); */ break; case Lisp_Misc_Boolfwd: - *XBOOLFWD (valcontents)->boolvar = NILP (newval) ? 0 : 1; + *XBOOLFWD (valcontents)->boolvar = !NILP (newval); break; case Lisp_Misc_Objfwd: @@ -968,12 +969,11 @@ store_symval_forwarding (symbol, valcontents, newval, buf) case Lisp_Misc_Buffer_Objfwd: { int offset = XBUFFER_OBJFWD (valcontents)->offset; - Lisp_Object type; + Lisp_Object type = XBUFFER_OBJFWD (valcontents)->slottype; - type = PER_BUFFER_TYPE (offset); if (! NILP (type) && ! NILP (newval) && XTYPE (newval) != XINT (type)) - buffer_slot_type_mismatch (offset); + buffer_slot_type_mismatch (symbol, XINT (type)); if (buf == NULL) buf = current_buffer; @@ -1011,26 +1011,23 @@ void swap_in_global_binding (symbol) Lisp_Object symbol; { - Lisp_Object valcontents, cdr; - - valcontents = SYMBOL_VALUE (symbol); - if (!BUFFER_LOCAL_VALUEP (valcontents)) - abort (); - cdr = XBUFFER_LOCAL_VALUE (valcontents)->cdr; + Lisp_Object valcontents = SYMBOL_VALUE (symbol); + struct Lisp_Buffer_Local_Value *blv = XBUFFER_LOCAL_VALUE (valcontents); + Lisp_Object cdr = blv->cdr; /* Unload the previously loaded binding. */ Fsetcdr (XCAR (cdr), - do_symval_forwarding (XBUFFER_LOCAL_VALUE (valcontents)->realvalue)); + do_symval_forwarding (blv->realvalue)); /* Select the global binding in the symbol. */ XSETCAR (cdr, cdr); - store_symval_forwarding (symbol, valcontents, XCDR (cdr), NULL); + store_symval_forwarding (symbol, blv->realvalue, XCDR (cdr), NULL); /* Indicate that the global binding is set up now. */ - XBUFFER_LOCAL_VALUE (valcontents)->frame = Qnil; - XBUFFER_LOCAL_VALUE (valcontents)->buffer = Qnil; - XBUFFER_LOCAL_VALUE (valcontents)->found_for_frame = 0; - XBUFFER_LOCAL_VALUE (valcontents)->found_for_buffer = 0; + blv->frame = Qnil; + blv->buffer = Qnil; + blv->found_for_frame = 0; + blv->found_for_buffer = 0; } /* Set up the buffer-local symbol SYMBOL for validity in the current buffer. @@ -1106,31 +1103,7 @@ find_symbol_value (symbol) if (BUFFER_LOCAL_VALUEP (valcontents)) valcontents = swap_in_symval_forwarding (symbol, valcontents); - if (MISCP (valcontents)) - { - switch (XMISCTYPE (valcontents)) - { - case Lisp_Misc_Intfwd: - XSETINT (val, *XINTFWD (valcontents)->intvar); - return val; - - case Lisp_Misc_Boolfwd: - return (*XBOOLFWD (valcontents)->boolvar ? Qt : Qnil); - - case Lisp_Misc_Objfwd: - return *XOBJFWD (valcontents)->objvar; - - case Lisp_Misc_Buffer_Objfwd: - return PER_BUFFER_VALUE (current_buffer, - XBUFFER_OBJFWD (valcontents)->offset); - - case Lisp_Misc_Kboard_Objfwd: - return *(Lisp_Object *)(XKBOARD_OBJFWD (valcontents)->offset - + (char *)FRAME_KBOARD (SELECTED_FRAME ())); - } - } - - return valcontents; + return do_symval_forwarding (valcontents); } DEFUN ("symbol-value", Fsymbol_value, Ssymbol_value, 1, 1, 0, @@ -1240,9 +1213,9 @@ set_internal (symbol, newval, buf, bindflag) || buf != XBUFFER (XBUFFER_LOCAL_VALUE (valcontents)->buffer) || (XBUFFER_LOCAL_VALUE (valcontents)->check_frame && !EQ (selected_frame, XBUFFER_LOCAL_VALUE (valcontents)->frame)) - || (BUFFER_LOCAL_VALUEP (valcontents) - && EQ (XCAR (current_alist_element), - current_alist_element))) + /* Also unload a global binding (if the var is local_if_set). */ + || (EQ (XCAR (current_alist_element), + current_alist_element))) { /* The currently loaded binding is not necessarily valid. We need to unload it, and choose a new binding. */ @@ -1260,7 +1233,7 @@ set_internal (symbol, newval, buf, bindflag) { /* This buffer still sees the default value. */ - /* If the variable is a Lisp_Some_Buffer_Local_Value, + /* If the variable is not local_if_set, or if this is `let' rather than `set', make CURRENT-ALIST-ELEMENT point to itself, indicating that we're seeing the default value. @@ -1301,6 +1274,9 @@ set_internal (symbol, newval, buf, bindflag) XBUFFER_LOCAL_VALUE (valcontents)->frame = selected_frame; } innercontents = XBUFFER_LOCAL_VALUE (valcontents)->realvalue; + + /* Store the new value in the cons-cell. */ + XSETCDR (XCAR (XBUFFER_LOCAL_VALUE (valcontents)->cdr), newval); } /* If storing void (making the symbol void), forward only through @@ -1310,24 +1286,6 @@ set_internal (symbol, newval, buf, bindflag) else store_symval_forwarding (symbol, innercontents, newval, buf); - /* If we just set a variable whose current binding is frame-local, - store the new value in the frame parameter too. */ - - if (BUFFER_LOCAL_VALUEP (valcontents)) - { - /* What binding is loaded right now? */ - current_alist_element - = XCAR (XBUFFER_LOCAL_VALUE (valcontents)->cdr); - - /* If the current buffer is not the buffer whose binding is - loaded, or if there may be frame-local bindings and the frame - isn't the right one, or if it's a Lisp_Buffer_Local_Value and - the default binding is loaded, the loaded binding may be the - wrong one. */ - if (XBUFFER_LOCAL_VALUE (valcontents)->found_for_frame) - XSETCDR (current_alist_element, newval); - } - return newval; } @@ -2320,7 +2278,7 @@ NUMBER may be an integer or a floating point number. */) } if (sizeof (int) == sizeof (EMACS_INT)) - sprintf (buffer, "%d", XINT (number)); + sprintf (buffer, "%d", (int) XINT (number)); else if (sizeof (long) == sizeof (EMACS_INT)) sprintf (buffer, "%ld", (long) XINT (number)); else diff --git a/src/dbusbind.c b/src/dbusbind.c new file mode 100644 index 00000000000..07fc24243d7 --- /dev/null +++ b/src/dbusbind.c @@ -0,0 +1,817 @@ +/* Elisp bindings for D-Bus. + Copyright (C) 2007 Free Software Foundation, Inc. + +This file is part of GNU Emacs. + +GNU Emacs is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GNU Emacs is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Emacs; see the file COPYING. If not, write to +the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +Boston, MA 02110-1301, USA. */ + +#include "config.h" + +#ifdef HAVE_DBUS +#include <stdlib.h> +#include <dbus/dbus.h> +#include "lisp.h" +#include "frame.h" +#include "termhooks.h" +#include "keyboard.h" + + +/* Subroutines. */ +Lisp_Object Qdbus_get_unique_name; +Lisp_Object Qdbus_call_method; +Lisp_Object Qdbus_send_signal; +Lisp_Object Qdbus_register_signal; +Lisp_Object Qdbus_unregister_signal; + +/* D-Bus error symbol. */ +Lisp_Object Qdbus_error; + +/* Lisp symbols of the system and session buses. */ +Lisp_Object QCdbus_system_bus, QCdbus_session_bus; + +/* Hash table which keeps function definitions. */ +Lisp_Object Vdbus_registered_functions_table; + +/* Whether to debug D-Bus. */ +Lisp_Object Vdbus_debug; + + +/* We use "xd_" and "XD_" as prefix for all internal symbols, because + we don't want to poison other namespaces with "dbus_". */ + +/* Raise a Lisp error from a D-Bus error. */ +#define XD_ERROR(error) \ + { \ + char s[1024]; \ + strcpy (s, error.message); \ + dbus_error_free (&error); \ + /* Remove the trailing newline. */ \ + if (strchr (s, '\n') != NULL) \ + s[strlen (s) - 1] = '\0'; \ + xsignal1 (Qdbus_error, build_string (s)); \ + } + +/* Macros for debugging. In order to enable them, build with + "make MYCPPFLAGS='-DDBUS_DEBUG'". */ +#ifdef DBUS_DEBUG +#define XD_DEBUG_MESSAGE(...) \ + { \ + char s[1024]; \ + sprintf (s, __VA_ARGS__); \ + printf ("%s: %s\n", __func__, s); \ + message ("%s: %s", __func__, s); \ + } +#define XD_DEBUG_VALID_LISP_OBJECT_P(object) \ + if (!valid_lisp_object_p (object)) \ + { \ + XD_DEBUG_MESSAGE ("%s Assertion failure", __LINE__); \ + xsignal1 (Qdbus_error, build_string ("Assertion failure")); \ + } + +#else /* !DBUS_DEBUG */ +#define XD_DEBUG_MESSAGE(...) \ + if (!NILP (Vdbus_debug)) \ + { \ + char s[1024]; \ + sprintf (s, __VA_ARGS__); \ + message ("%s: %s", __func__, s); \ + } +#define XD_DEBUG_VALID_LISP_OBJECT_P(object) +#endif + +/* Determine the DBusType of a given Lisp object. It is used to + convert Lisp objects, being arguments of `dbus-call-method' or + `dbus-send-signal', into corresponding C values appended as + arguments to a D-Bus message. */ +#define XD_LISP_OBJECT_TO_DBUS_TYPE(object) \ + (EQ (object, Qt) || EQ (object, Qnil)) ? DBUS_TYPE_BOOLEAN : \ + (NATNUMP (object)) ? DBUS_TYPE_UINT32 : \ + (INTEGERP (object)) ? DBUS_TYPE_INT32 : \ + (FLOATP (object)) ? DBUS_TYPE_DOUBLE : \ + (STRINGP (object)) ? DBUS_TYPE_STRING : \ + DBUS_TYPE_INVALID + +/* Extract C value from Lisp OBJECT. DTYPE must be a valid DBusType, + as detected by XD_LISP_OBJECT_TO_DBUS_TYPE. Compound types are not + supported (yet). It is used to convert Lisp objects, being + arguments of `dbus-call-method' or `dbus-send-signal', into + corresponding C values appended as arguments to a D-Bus + message. */ +char * +xd_retrieve_value (dtype, object) + uint dtype; + Lisp_Object object; +{ + + XD_DEBUG_VALID_LISP_OBJECT_P (object); + switch (dtype) + { + case DBUS_TYPE_BOOLEAN: + XD_DEBUG_MESSAGE ("%d %s", dtype, (NILP (object)) ? "false" : "true"); + return (NILP (object)) ? (char *) FALSE : (char *) TRUE; + case DBUS_TYPE_UINT32: + XD_DEBUG_MESSAGE ("%d %d", dtype, XUINT (object)); + return (char *) XUINT (object); + case DBUS_TYPE_INT32: + XD_DEBUG_MESSAGE ("%d %d", dtype, XINT (object)); + return (char *) XINT (object); + case DBUS_TYPE_DOUBLE: + XD_DEBUG_MESSAGE ("%d %d", dtype, XFLOAT (object)); + return (char *) XFLOAT (object); + case DBUS_TYPE_STRING: + XD_DEBUG_MESSAGE ("%d %s", dtype, SDATA (object)); + return SDATA (object); + default: + XD_DEBUG_MESSAGE ("DBus-Type %d not supported", dtype); + return NULL; + } +} + +/* Retrieve C value from a DBusMessageIter structure ITER, and return + a converted Lisp object. The type DTYPE of the argument of the + D-Bus message must be a valid DBusType. Compound D-Bus types are + partly supported; they result always in a Lisp list. */ +Lisp_Object +xd_retrieve_arg (dtype, iter) + uint dtype; + DBusMessageIter *iter; +{ + + switch (dtype) + { + case DBUS_TYPE_BOOLEAN: + { + dbus_bool_t val; + dbus_message_iter_get_basic (iter, &val); + XD_DEBUG_MESSAGE ("%d %s", dtype, (val == FALSE) ? "false" : "true"); + return (val == FALSE) ? Qnil : Qt; + } + case DBUS_TYPE_INT32: + case DBUS_TYPE_UINT32: + { + dbus_uint32_t val; + dbus_message_iter_get_basic (iter, &val); + XD_DEBUG_MESSAGE ("%d %d", dtype, val); + return make_number (val); + } + case DBUS_TYPE_STRING: + case DBUS_TYPE_OBJECT_PATH: + { + char *val; + dbus_message_iter_get_basic (iter, &val); + XD_DEBUG_MESSAGE ("%d %s", dtype, val); + return build_string (val); + } + case DBUS_TYPE_ARRAY: + case DBUS_TYPE_VARIANT: + case DBUS_TYPE_STRUCT: + case DBUS_TYPE_DICT_ENTRY: + { + Lisp_Object result; + struct gcpro gcpro1; + result = Qnil; + GCPRO1 (result); + DBusMessageIter subiter; + int subtype; + dbus_message_iter_recurse (iter, &subiter); + while ((subtype = dbus_message_iter_get_arg_type (&subiter)) + != DBUS_TYPE_INVALID) + { + result = Fcons (xd_retrieve_arg (subtype, &subiter), result); + dbus_message_iter_next (&subiter); + } + RETURN_UNGCPRO (Fnreverse (result)); + } + default: + XD_DEBUG_MESSAGE ("DBusType %d not supported", dtype); + return Qnil; + } +} + + +/* Initialize D-Bus connection. BUS is a Lisp symbol, either :system + or :session. It tells which D-Bus to be initialized. */ +DBusConnection * +xd_initialize (bus) + Lisp_Object bus; +{ + DBusConnection *connection; + DBusError derror; + + /* Parameter check. */ + CHECK_SYMBOL (bus); + if (!((EQ (bus, QCdbus_system_bus)) || (EQ (bus, QCdbus_session_bus)))) + xsignal2 (Qdbus_error, build_string ("Wrong bus name"), bus); + + /* Open a connection to the bus. */ + dbus_error_init (&derror); + + if (EQ (bus, QCdbus_system_bus)) + connection = dbus_bus_get (DBUS_BUS_SYSTEM, &derror); + else + connection = dbus_bus_get (DBUS_BUS_SESSION, &derror); + + if (dbus_error_is_set (&derror)) + XD_ERROR (derror); + + if (connection == NULL) + xsignal2 (Qdbus_error, build_string ("No connection"), bus); + + /* Return the result. */ + return connection; +} + +DEFUN ("dbus-get-unique-name", Fdbus_get_unique_name, Sdbus_get_unique_name, + 1, 1, 0, + doc: /* Return the unique name of Emacs registered at D-Bus BUS as string. */) + (bus) + Lisp_Object bus; +{ + DBusConnection *connection; + char name[1024]; + + /* Check parameters. */ + CHECK_SYMBOL (bus); + + /* Open a connection to the bus. */ + connection = xd_initialize (bus); + + /* Request the name. */ + strcpy (name, dbus_bus_get_unique_name (connection)); + if (name == NULL) + xsignal1 (Qdbus_error, build_string ("No unique name available")); + + /* Return. */ + return build_string (name); +} + +DEFUN ("dbus-call-method", Fdbus_call_method, Sdbus_call_method, 5, MANY, 0, + doc: /* Call METHOD on the D-Bus BUS. + +BUS is either the symbol `:system' or the symbol `:session'. + +SERVICE is the D-Bus service name to be used. PATH is the D-Bus +object path SERVICE is registered at. INTERFACE is an interface +offered by SERVICE. It must provide METHOD. + +All other arguments ARGS are passed to METHOD as arguments. They are +converted into D-Bus types via the following rules: + + t and nil => DBUS_TYPE_BOOLEAN + number => DBUS_TYPE_UINT32 + integer => DBUS_TYPE_INT32 + float => DBUS_TYPE_DOUBLE + string => DBUS_TYPE_STRING + +Other Lisp objects are not supported as input arguments of METHOD. + +`dbus-call-method' returns the resulting values of METHOD as a list of +Lisp objects. The type conversion happens the other direction as for +input arguments. Additionally to the types supported for input +arguments, the D-Bus compound types DBUS_TYPE_ARRAY, DBUS_TYPE_VARIANT, +DBUS_TYPE_STRUCT and DBUS_TYPE_DICT_ENTRY are accepted. All of them +are converted into a list of Lisp objects which correspond to the +elements of the D-Bus container. Example: + +\(dbus-call-method + :session "GetKeyField" "org.gnome.seahorse" + "/org/gnome/seahorse/keys/openpgp" "org.gnome.seahorse.Keys" + "openpgp:657984B8C7A966DD" "simple-name") + + => (t ("Philip R. Zimmermann")) + +If the result of the METHOD call is just one value, the converted Lisp +object is returned instead of a list containing this single Lisp object. + +\(dbus-call-method + :system "GetPropertyString" "org.freedesktop.Hal" + "/org/freedesktop/Hal/devices/computer" "org.freedesktop.Hal.Device" + "system.kernel.machine") + + => "i686" + +usage: (dbus-call-method BUS METHOD SERVICE PATH INTERFACE &rest ARGS) */) + (nargs, args) + int nargs; + register Lisp_Object *args; +{ + Lisp_Object bus, method, service, path, interface; + Lisp_Object result; + struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; + DBusConnection *connection; + DBusMessage *dmessage; + DBusMessage *reply; + DBusMessageIter iter; + DBusError derror; + uint dtype; + int i; + char *value; + + /* Check parameters. */ + bus = args[0]; + method = args[1]; + service = args[2]; + path = args[3]; + interface = args[4]; + + CHECK_SYMBOL (bus); + CHECK_STRING (method); + CHECK_STRING (service); + CHECK_STRING (path); + CHECK_STRING (interface); + GCPRO5 (bus, method, service, path, interface); + + XD_DEBUG_MESSAGE ("%s %s %s %s", + SDATA (method), + SDATA (service), + SDATA (path), + SDATA (interface)); + + /* Open a connection to the bus. */ + connection = xd_initialize (bus); + + /* Create the message. */ + dmessage = dbus_message_new_method_call (SDATA (service), + SDATA (path), + SDATA (interface), + SDATA (method)); + if (dmessage == NULL) + { + UNGCPRO; + xsignal1 (Qdbus_error, build_string ("Unable to create a new message")); + } + + UNGCPRO; + + /* Append parameters to the message. */ + for (i = 5; i < nargs; ++i) + { + + XD_DEBUG_VALID_LISP_OBJECT_P (args[i]); + XD_DEBUG_MESSAGE ("Parameter%d %s", + i-4, + SDATA (format2 ("%s", args[i], Qnil))); + + dtype = XD_LISP_OBJECT_TO_DBUS_TYPE (args[i]); + if (dtype == DBUS_TYPE_INVALID) + xsignal2 (Qdbus_error, build_string ("Not a valid argument"), args[i]); + + value = (char *) xd_retrieve_value (dtype, args[i]); + + if (!dbus_message_append_args (dmessage, + dtype, + &value, + DBUS_TYPE_INVALID)) + xsignal2 (Qdbus_error, + build_string ("Unable to append argument"), args[i]); + } + + /* Send the message. */ + dbus_error_init (&derror); + reply = dbus_connection_send_with_reply_and_block (connection, + dmessage, + -1, + &derror); + + if (dbus_error_is_set (&derror)) + XD_ERROR (derror); + + if (reply == NULL) + xsignal1 (Qdbus_error, build_string ("No reply")); + + XD_DEBUG_MESSAGE ("Message sent"); + + /* Collect the results. */ + result = Qnil; + GCPRO1 (result); + + if (!dbus_message_iter_init (reply, &iter)) + { + UNGCPRO; + xsignal1 (Qdbus_error, build_string ("Cannot read reply")); + } + + /* Loop over the parameters of the D-Bus reply message. Construct a + Lisp list, which is returned by `dbus-call-method'. */ + while ((dtype = dbus_message_iter_get_arg_type (&iter)) != DBUS_TYPE_INVALID) + { + result = Fcons (xd_retrieve_arg (dtype, &iter), result); + dbus_message_iter_next (&iter); + } + + /* Cleanup. */ + dbus_message_unref (dmessage); + dbus_message_unref (reply); + + /* Return the result. If there is only one single Lisp object, + return it as-it-is, otherwise return the reversed list. */ + if (XUINT (Flength (result)) == 1) + RETURN_UNGCPRO (XCAR (result)); + else + RETURN_UNGCPRO (Fnreverse (result)); +} + +DEFUN ("dbus-send-signal", Fdbus_send_signal, Sdbus_send_signal, 5, MANY, 0, + doc: /* Send signal SIGNAL on the D-Bus BUS. + +BUS is either the symbol `:system' or the symbol `:session'. + +SERVICE is the D-Bus service name SIGNAL is sent from. PATH is the +D-Bus object path SERVICE is registered at. INTERFACE is an interface +offered by SERVICE. It must provide signal SIGNAL. + +All other arguments ARGS are passed to SIGNAL as arguments. They are +converted into D-Bus types via the following rules: + + t and nil => DBUS_TYPE_BOOLEAN + number => DBUS_TYPE_UINT32 + integer => DBUS_TYPE_INT32 + float => DBUS_TYPE_DOUBLE + string => DBUS_TYPE_STRING + +Other Lisp objects are not supported as arguments of SIGNAL. + +Example: + +\(dbus-send-signal + :session "Started" "org.gnu.emacs" "/org/gnu/emacs" "org.gnu.emacs"))) + +usage: (dbus-send-signal BUS SIGNAL SERVICE PATH INTERFACE &rest ARGS) */) + (nargs, args) + int nargs; + register Lisp_Object *args; +{ + Lisp_Object bus, signal, service, path, interface; + struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; + DBusConnection *connection; + DBusMessage *dmessage; + uint dtype; + int i; + char *value; + + /* Check parameters. */ + bus = args[0]; + signal = args[1]; + service = args[2]; + path = args[3]; + interface = args[4]; + + CHECK_SYMBOL (bus); + CHECK_STRING (signal); + CHECK_STRING (service); + CHECK_STRING (path); + CHECK_STRING (interface); + GCPRO5 (bus, signal, service, path, interface); + + XD_DEBUG_MESSAGE ("%s %s %s %s", + SDATA (signal), + SDATA (service), + SDATA (path), + SDATA (interface)); + + /* Open a connection to the bus. */ + connection = xd_initialize (bus); + + /* Create the message. */ + dmessage = dbus_message_new_signal (SDATA (path), + SDATA (interface), + SDATA (signal)); + if (dmessage == NULL) + { + UNGCPRO; + xsignal1 (Qdbus_error, build_string ("Unable to create a new message")); + } + + UNGCPRO; + + /* Append parameters to the message. */ + for (i = 5; i < nargs; ++i) + { + XD_DEBUG_VALID_LISP_OBJECT_P (args[i]); + XD_DEBUG_MESSAGE ("Parameter%d %s", + i-4, + SDATA (format2 ("%s", args[i], Qnil))); + + dtype = XD_LISP_OBJECT_TO_DBUS_TYPE (args[i]); + if (dtype == DBUS_TYPE_INVALID) + xsignal2 (Qdbus_error, build_string ("Not a valid argument"), args[i]); + + value = (char *) xd_retrieve_value (dtype, args[i]); + + if (!dbus_message_append_args (dmessage, + dtype, + &value, + DBUS_TYPE_INVALID)) + xsignal2 (Qdbus_error, + build_string ("Unable to append argument"), args[i]); + } + + /* Send the message. The message is just added to the outgoing + message queue. */ + if (!dbus_connection_send (connection, dmessage, NULL)) + xsignal1 (Qdbus_error, build_string ("Cannot send message")); + + /* Flush connection to ensure the message is handled. */ + dbus_connection_flush (connection); + + XD_DEBUG_MESSAGE ("Signal sent"); + + /* Cleanup. */ + dbus_message_unref (dmessage); + + /* Return. */ + return Qt; +} + +/* Read queued incoming message of the D-Bus BUS. BUS is a Lisp + symbol, either :system or :session. */ +Lisp_Object +xd_read_message (bus) + Lisp_Object bus; +{ + Lisp_Object key; + struct gcpro gcpro1; + static struct input_event event; + DBusConnection *connection; + DBusMessage *dmessage; + DBusMessageIter iter; + uint dtype; + char service[1024], path[1024], interface[1024], member[1024]; + + /* Open a connection to the bus. */ + connection = xd_initialize (bus); + + /* Non blocking read of the next available message. */ + dbus_connection_read_write (connection, 0); + dmessage = dbus_connection_pop_message (connection); + + /* Return if there is no queued message. */ + if (dmessage == NULL) + return; + + /* There is a message in the queue. Construct the D-Bus event. */ + XD_DEBUG_MESSAGE ("Event received"); + EVENT_INIT (event); + + event.kind = DBUS_EVENT; + event.frame_or_window = Qnil; + + /* Collect the parameters. */ + event.arg = Qnil; + GCPRO1 (event.arg); + + if (!dbus_message_iter_init (dmessage, &iter)) + { + UNGCPRO; + XD_DEBUG_MESSAGE ("Cannot read event"); + return; + } + + /* Loop over the resulting parameters. Construct a list. */ + while ((dtype = dbus_message_iter_get_arg_type (&iter)) != DBUS_TYPE_INVALID) + { + event.arg = Fcons (xd_retrieve_arg (dtype, &iter), event.arg); + dbus_message_iter_next (&iter); + } + + /* The arguments are stored in reverse order. Reorder them. */ + event.arg = Fnreverse (event.arg); + + /* Read service, object path interface and member from the + message. */ + strcpy (service, dbus_message_get_sender (dmessage)); + strcpy (path, dbus_message_get_path (dmessage)); + strcpy (interface, dbus_message_get_interface (dmessage)); + strcpy (member, dbus_message_get_member (dmessage)); + + /* Add them to the event. */ + event.arg = Fcons ((member == NULL ? Qnil : build_string (member)), + event.arg); + event.arg = Fcons ((interface == NULL ? Qnil : build_string (interface)), + event.arg); + event.arg = Fcons ((path == NULL ? Qnil : build_string (path)), + event.arg); + event.arg = Fcons ((service == NULL ? Qnil : build_string (service)), + event.arg); + + /* Add the bus symbol to the event. */ + event.arg = Fcons (bus, event.arg); + + /* Add the registered function of the message. */ + key = list3 (bus, + (interface == NULL ? Qnil : build_string (interface)), + (member == NULL ? Qnil : build_string (member))); + event.arg = Fcons (Fgethash (key, Vdbus_registered_functions_table, Qnil), + event.arg); + + /* Store it into the input event queue. */ + kbd_buffer_store_event (&event); + + /* Cleanup. */ + dbus_message_unref (dmessage); + UNGCPRO; +} + +/* Read queued incoming messages from the system and session buses. */ +void +xd_read_queued_messages () +{ + + /* Vdbus_registered_functions_table will be made as hash table in + dbus.el. When it isn't loaded yet, it doesn't make sense to + handle D-Bus messages. Furthermore, we ignore all Lisp errors + during the call. */ + if (HASH_TABLE_P (Vdbus_registered_functions_table)) + { + internal_condition_case_1 (xd_read_message, QCdbus_system_bus, + Qerror, Fidentity); + internal_condition_case_1 (xd_read_message, QCdbus_session_bus, + Qerror, Fidentity); + } +} + +DEFUN ("dbus-register-signal", Fdbus_register_signal, Sdbus_register_signal, + 6, 6, 0, + doc: /* Register for signal SIGNAL on the D-Bus BUS. + +BUS is either the symbol `:system' or the symbol `:session'. + +SERVICE is the D-Bus service name used by the sending D-Bus object. +It can be either a known name or the unique name of the D-Bus object +sending the signal. When SERVICE is nil, related signals from all +D-Bus objects shall be accepted. + +PATH is the D-Bus object path SERVICE is registered. It can also be +nil if the path name of incoming signals shall not be checked. + +INTERFACE is an interface offered by SERVICE. It must provide SIGNAL. +HANDLER is a Lisp function to be called when the signal is received. +It must accept as arguments the values SIGNAL is sending. INTERFACE, +SIGNAL and HANDLER must not be nil. Example: + +\(defun my-signal-handler (device) + (message "Device %s added" device)) + +\(dbus-register-signal + :system "DeviceAdded" + (dbus-get-name-owner :system "org.freedesktop.Hal") + "/org/freedesktop/Hal/Manager" "org.freedesktop.Hal.Manager" + 'my-signal-handler) + + => (:system "org.freedesktop.Hal.Manager" "DeviceAdded") + +`dbus-register-signal' returns an object, which can be used in +`dbus-unregister-signal' for removing the registration. */) + (bus, signal, service, path, interface, handler) + Lisp_Object bus, signal, service, path, interface, handler; +{ + Lisp_Object key; + DBusConnection *connection; + char rule[1024]; + DBusError derror; + + /* Check parameters. */ + CHECK_SYMBOL (bus); + CHECK_STRING (signal); + if (!NILP (service)) CHECK_STRING (service); + if (!NILP (path)) CHECK_STRING (path); + CHECK_STRING (interface); + CHECK_SYMBOL (handler); + + /* Open a connection to the bus. */ + connection = xd_initialize (bus); + + /* Create a rule to receive related signals. */ + sprintf (rule, + "type='signal',interface='%s',member=%s%", + SDATA (interface), + SDATA (signal)); + + /* Add service and path to the rule if they are non-nil. */ + if (!NILP (service)) + sprintf (rule, "%s,sender='%s'%", rule, SDATA (service)); + + if (!NILP (path)) + sprintf (rule, "%s,path='%s'", rule, SDATA (path)); + + /* Add the rule to the bus. */ + dbus_error_init (&derror); + dbus_bus_add_match (connection, rule, &derror); + if (dbus_error_is_set (&derror)) + XD_ERROR (derror); + + XD_DEBUG_MESSAGE ("Matching rule \"%s\" created", rule); + + /* Create a hash table entry. */ + key = list3 (bus, interface, signal); + Fputhash (key, handler, Vdbus_registered_functions_table); + XD_DEBUG_MESSAGE ("\"%s\" registered with handler \"%s\"", + SDATA (format2 ("%s", key, Qnil)), + SDATA (format2 ("%s", handler, Qnil))); + + /* Return key. */ + return key; +} + +DEFUN ("dbus-unregister-signal", Fdbus_unregister_signal, Sdbus_unregister_signal, + 1, 1, 0, + doc: /* Unregister OBJECT from the D-Bus. +OBJECT must be the result of a preceding `dbus-register-signal' call. */) + (object) + Lisp_Object object; +{ + + /* Check parameters. */ + CHECK_SYMBOL (object); + + XD_DEBUG_MESSAGE ("\"%s\" unregistered with handler \"%s\"", + SDATA (format2 ("%s", object, Qnil)), + SDATA (format2 ("%s", Fsymbol_function (object), Qnil))); + + /* Unintern the signal symbol. */ + Fremhash (object, Vdbus_registered_functions_table); + + /* Return. */ + return Qnil; +} + + +void +syms_of_dbusbind () +{ + + Qdbus_get_unique_name = intern ("dbus-get-unique-name"); + staticpro (&Qdbus_get_unique_name); + defsubr (&Sdbus_get_unique_name); + + Qdbus_call_method = intern ("dbus-call-method"); + staticpro (&Qdbus_call_method); + defsubr (&Sdbus_call_method); + + Qdbus_send_signal = intern ("dbus-send-signal"); + staticpro (&Qdbus_send_signal); + defsubr (&Sdbus_send_signal); + + Qdbus_register_signal = intern ("dbus-register-signal"); + staticpro (&Qdbus_register_signal); + defsubr (&Sdbus_register_signal); + + Qdbus_unregister_signal = intern ("dbus-unregister-signal"); + staticpro (&Qdbus_unregister_signal); + defsubr (&Sdbus_unregister_signal); + + Qdbus_error = intern ("dbus-error"); + staticpro (&Qdbus_error); + Fput (Qdbus_error, Qerror_conditions, + list2 (Qdbus_error, Qerror)); + Fput (Qdbus_error, Qerror_message, + build_string ("D-Bus error")); + + QCdbus_system_bus = intern (":system"); + staticpro (&QCdbus_system_bus); + + QCdbus_session_bus = intern (":session"); + staticpro (&QCdbus_session_bus); + + DEFVAR_LISP ("dbus-registered-functions-table", &Vdbus_registered_functions_table, + doc: /* Hash table of registered functions for D-Bus. +The key in the hash table is the list (BUS INTERFACE MEMBER). BUS is +either the symbol `:system' or the symbol `:session'. INTERFACE is a +string which denotes a D-Bus interface, and MEMBER, also a string, is +either a method or a signal INTERFACE is offering. + +The value in the hash table a the function to be called when a D-Bus +message, which matches the key criteria, arrives. */); + /* We initialize Vdbus_registered_functions_table in dbus.el, + because we need to define a hash table function first. */ + Vdbus_registered_functions_table = Qnil; + + DEFVAR_LISP ("dbus-debug", &Vdbus_debug, + doc: /* If non-nil, debug messages of D-Bus bindings are raised. */); +#ifdef DBUS_DEBUG + Vdbus_debug = Qt; +#else + Vdbus_debug = Qnil; +#endif + + Fprovide (intern ("dbusbind"), Qnil); + +} + +#endif /* HAVE_DBUS */ + +/* arch-tag: 0e828477-b571-4fe4-b559-5c9211bc14b8 + (do not change this comment) */ diff --git a/src/dispnew.c b/src/dispnew.c index 973630609b6..d7bca7acbc4 100644 --- a/src/dispnew.c +++ b/src/dispnew.c @@ -6893,8 +6893,12 @@ init_display () exit (1); } +#ifdef WINDOWSNT + terminal_type = "w32console"; +#else /* Look at the TERM variable. */ terminal_type = (char *) getenv ("TERM"); +#endif if (!terminal_type) { #ifdef VMS diff --git a/src/editfns.c b/src/editfns.c index 66e3883494f..fa1b229bfc4 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -3673,8 +3673,10 @@ usage: (format STRING &rest OBJECTS) */) precision[n+1] = 10 * precision[n+1] + *format - '0'; } - if (format - this_format_start + 1 > longest_format) - longest_format = format - this_format_start + 1; + /* Extra +1 for 'l' that we may need to insert into the + format. */ + if (format - this_format_start + 2 > longest_format) + longest_format = format - this_format_start + 2; if (format == end) error ("Format string ends in middle of format specifier"); @@ -3735,7 +3737,7 @@ usage: (format STRING &rest OBJECTS) */) && *format != 'i' && *format != 'X' && *format != 'c') error ("Invalid format operation %%%c", *format); - thissize = 30; + thissize = 30 + (precision[n] > 0 ? precision[n] : 0); if (*format == 'c') { if (! ASCII_CHAR_P (XINT (args[n])) @@ -3933,23 +3935,40 @@ usage: (format STRING &rest OBJECTS) */) format - this_format_start); this_format[format - this_format_start] = 0; - if (INTEGERP (args[n])) + if (format[-1] == 'e' || format[-1] == 'f' || format[-1] == 'g') + sprintf (p, this_format, XFLOAT_DATA (args[n])); + else { - if (format[-1] == 'd') - sprintf (p, this_format, XINT (args[n])); - /* Don't sign-extend for octal or hex printing. */ + if (sizeof (EMACS_INT) > sizeof (int) + && format[-1] != 'c') + { + /* Insert 'l' before format spec. */ + this_format[format - this_format_start] + = this_format[format - this_format_start - 1]; + this_format[format - this_format_start - 1] = 'l'; + this_format[format - this_format_start + 1] = 0; + } + + if (INTEGERP (args[n])) + { + if (format[-1] == 'c') + sprintf (p, this_format, (int) XINT (args[n])); + else if (format[-1] == 'd') + sprintf (p, this_format, XINT (args[n])); + /* Don't sign-extend for octal or hex printing. */ + else + sprintf (p, this_format, XUINT (args[n])); + } + else if (format[-1] == 'c') + sprintf (p, this_format, (int) XFLOAT_DATA (args[n])); + else if (format[-1] == 'd') + /* Maybe we should use "%1.0f" instead so it also works + for values larger than MAXINT. */ + sprintf (p, this_format, (EMACS_INT) XFLOAT_DATA (args[n])); else - sprintf (p, this_format, XUINT (args[n])); + /* Don't sign-extend for octal or hex printing. */ + sprintf (p, this_format, (EMACS_UINT) XFLOAT_DATA (args[n])); } - else if (format[-1] == 'e' || format[-1] == 'f' || format[-1] == 'g') - sprintf (p, this_format, XFLOAT_DATA (args[n])); - else if (format[-1] == 'd') - /* Maybe we should use "%1.0f" instead so it also works - for values larger than MAXINT. */ - sprintf (p, this_format, (EMACS_INT) XFLOAT_DATA (args[n])); - else - /* Don't sign-extend for octal or hex printing. */ - sprintf (p, this_format, (EMACS_UINT) XFLOAT_DATA (args[n])); if (p > buf && multibyte diff --git a/src/emacs.c b/src/emacs.c index 71743c45964..21e583f7d91 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -353,7 +353,7 @@ int fatal_error_in_progress; void (*fatal_error_signal_hook) P_ ((void)); #ifdef HAVE_GTK_AND_PTHREAD -/* When compiled with GTK and running under Gnome, multiple threads meay be +/* When compiled with GTK and running under Gnome, multiple threads may be created. Keep track of our main thread to make sure signals are delivered to it (see syssignal.h). */ @@ -1664,6 +1664,10 @@ main (argc, argv syms_of_fontset (); #endif /* MAC_OSX && HAVE_CARBON */ +#ifdef HAVE_DBUS + syms_of_dbusbind (); +#endif /* HAVE_DBUS */ + #ifdef SYMS_SYSTEM SYMS_SYSTEM; #endif @@ -1693,6 +1697,7 @@ main (argc, argv init_charset (); + init_editfns (); /* init_process uses Voperating_system_release. */ init_process (); /* init_display uses add_keyboard_wait_descriptor. */ #ifndef MAC_OS8 /* Called before init_window_once for Mac OS Classic. */ @@ -1715,7 +1720,6 @@ main (argc, argv init_image (); #endif /* HAVE_WINDOW_SYSTEM */ init_macros (); - init_editfns (); init_floatfns (); #ifdef VMS init_vmsfns (); diff --git a/src/eval.c b/src/eval.c index 7f5f58a2e81..74ebb0c90b6 100644 --- a/src/eval.c +++ b/src/eval.c @@ -3263,7 +3263,6 @@ void specbind (symbol, value) Lisp_Object symbol, value; { - Lisp_Object ovalue; Lisp_Object valcontents; CHECK_SYMBOL (symbol); @@ -3283,9 +3282,7 @@ specbind (symbol, value) } else { - Lisp_Object valcontents; - - ovalue = find_symbol_value (symbol); + Lisp_Object ovalue = find_symbol_value (symbol); specpdl_ptr->func = 0; specpdl_ptr->old_value = ovalue; @@ -3330,10 +3327,14 @@ specbind (symbol, value) specpdl_ptr->symbol = symbol; specpdl_ptr++; - if (BUFFER_OBJFWDP (ovalue) || KBOARD_OBJFWDP (ovalue)) - store_symval_forwarding (symbol, ovalue, value, NULL); - else - set_internal (symbol, value, 0, 1); + /* We used to do + if (BUFFER_OBJFWDP (ovalue) || KBOARD_OBJFWDP (ovalue)) + store_symval_forwarding (symbol, ovalue, value, NULL); + else + but ovalue comes from find_symbol_value which should never return + such an internal value. */ + eassert (!(BUFFER_OBJFWDP (ovalue) || KBOARD_OBJFWDP (ovalue))); + set_internal (symbol, value, 0, 1); } } diff --git a/src/gtkutil.c b/src/gtkutil.c index e36e192c65e..41926ace154 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c @@ -2970,10 +2970,9 @@ free_frame_menubar (f) int xg_ignore_gtk_scrollbar; -/* SET_SCROLL_BAR_X_WINDOW assumes the second argument fits in - 32 bits. But we want to store pointers, and they may be larger - than 32 bits. Keep a mapping from integer index to widget pointers - to get around the 32 bit limitation. */ +/* Xlib's `Window' fits in 32 bits. But we want to store pointers, and they + may be larger than 32 bits. Keep a mapping from integer index to widget + pointers to get around the 32 bit limitation. */ static struct { @@ -3183,7 +3182,7 @@ xg_create_scroll_bar (f, bar, scroll_callback, scroll_bar_name) /* Set the cursor to an arrow. */ xg_set_cursor (webox, FRAME_X_DISPLAY_INFO (f)->xg_cursor); - SET_SCROLL_BAR_X_WINDOW (bar, scroll_id); + bar->x_window = scroll_id; } /* Make the scroll bar represented by SCROLLBAR_ID visible. */ @@ -3258,7 +3257,7 @@ xg_set_toolkit_scroll_bar_thumb (bar, portion, position, whole) struct scroll_bar *bar; int portion, position, whole; { - GtkWidget *wscroll = xg_get_widget_from_map (SCROLL_BAR_X_WINDOW (bar)); + GtkWidget *wscroll = xg_get_widget_from_map (bar->x_window); FRAME_PTR f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window))); @@ -3822,6 +3821,7 @@ update_frame_tool_bar (f) GtkWidget *wbutton = NULL; GtkWidget *weventbox; Lisp_Object func = intern ("x-gtk-map-stock"); + Lisp_Object specified_file; ti = gtk_toolbar_get_nth_item (GTK_TOOLBAR (x->toolbar_widget), i); @@ -3840,8 +3840,9 @@ update_frame_tool_bar (f) continue; } - if (EQ (Qt, Ffboundp (func))) - stock = call1 (func, file_for_image (image)); + specified_file = file_for_image (image); + if (!NILP (specified_file) && EQ (Qt, Ffboundp (func))) + stock = call1 (func, specified_file); if (! NILP (stock) && STRINGP (stock)) { diff --git a/src/image.c b/src/image.c index 91be3f4b57e..a9b1e9835ed 100644 --- a/src/image.c +++ b/src/image.c @@ -3128,6 +3128,8 @@ convert_mono_to_color_image (f, img, foreground, background) release_frame_dc (f, hdc); old_prev = SelectObject (old_img_dc, img->pixmap); new_prev = SelectObject (new_img_dc, new_pixmap); + /* Windows convention for mono bitmaps is black = background, + white = foreground. */ SetTextColor (new_img_dc, background); SetBkColor (new_img_dc, foreground); @@ -3523,6 +3525,19 @@ xbm_load (f, img) else bits = XBOOL_VECTOR (data)->data; +#ifdef WINDOWSNT + { + char *invertedBits; + int nbytes, i; + /* Windows mono bitmaps are reversed compared with X. */ + invertedBits = bits; + nbytes = (img->width + BITS_PER_CHAR - 1) / BITS_PER_CHAR + * img->height; + bits = (char *) alloca(nbytes); + for (i = 0; i < nbytes; i++) + bits[i] = XBM_BIT_SHUFFLE (invertedBits[i]); + } +#endif /* Create the pixmap. */ Create_Pixmap_From_Bitmap_Data (f, img, bits, diff --git a/src/keyboard.c b/src/keyboard.c index 0678fcdb4de..6595b7f800d 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -514,7 +514,9 @@ Lisp_Object Qsave_session; #ifdef MAC_OS Lisp_Object Qmac_apple_event; #endif - +#ifdef HAVE_DBUS +Lisp_Object Qdbus_event; +#endif /* Lisp_Object Qmouse_movement; - also an event header */ /* Properties of event headers. */ @@ -1570,7 +1572,7 @@ command_loop_1 () #ifdef MULTI_KBOARD int was_locked = single_kboard; #endif -#endif +#endif int already_adjusted = 0; current_kboard->Vprefix_arg = Qnil; @@ -2566,7 +2568,7 @@ do { if (polling_stopped_here) start_polling (); \ USED_MOUSE_MENU is null, we don't dereference it. Value is -2 when we find input on another keyboard. A second call - to read_char will read it. + to read_char will read it. If END_TIME is non-null, it is a pointer to an EMACS_TIME specifying the maximum time to wait until. If no input arrives by @@ -3181,7 +3183,7 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu, end_time) int count = SPECPDL_INDEX (); record_single_kboard_state (); #endif - + last_input_char = c; Fcommand_execute (tem, Qnil, Fvector (1, &last_input_char), Qt); @@ -4097,7 +4099,7 @@ kbd_buffer_get_event (kbp, used_mouse_menu, end_time) events. */ if (CONSP (Vunread_command_events)) break; - + if (kbd_fetch_ptr != kbd_store_ptr) break; #if defined (HAVE_MOUSE) || defined (HAVE_GPM) @@ -4309,6 +4311,13 @@ kbd_buffer_get_event (kbp, used_mouse_menu, end_time) internal_last_event_frame = frame; kbd_fetch_ptr = event + 1; } +#ifdef HAVE_DBUS + else if (event->kind == DBUS_EVENT) + { + obj = make_lispy_event (event); + kbd_fetch_ptr = event + 1; + } +#endif else { /* If this event is on a different frame, return a switch-frame this @@ -6187,6 +6196,13 @@ make_lispy_event (event) } #endif +#ifdef HAVE_DBUS + case DBUS_EVENT: + { + return Fcons (Qdbus_event, event->arg); + } +#endif /* HAVE_DBUS */ + #ifdef HAVE_GPM case GPM_CLICK_EVENT: { @@ -6505,12 +6521,21 @@ lispy_modifier_list (modifiers) SYMBOL's Qevent_symbol_element_mask property, and maintains the Qevent_symbol_elements property. */ +#define KEY_TO_CHAR(k) (XINT (k) & ((1 << CHARACTERBITS) - 1)) + Lisp_Object parse_modifiers (symbol) Lisp_Object symbol; { Lisp_Object elements; + if (INTEGERP (symbol)) + return (Fcons (make_number (KEY_TO_CHAR (symbol)), + Fcons (make_number (XINT (symbol) & CHAR_MODIFIER_MASK), + Qnil))); + else if (!SYMBOLP (symbol)) + return Qnil; + elements = Fget (symbol, Qevent_symbol_element_mask); if (CONSP (elements)) return elements; @@ -6545,6 +6570,20 @@ parse_modifiers (symbol) } } +DEFUN ("internal-event-symbol-parse-modifiers", Fevent_symbol_parse_modifiers, + Sevent_symbol_parse_modifiers, 1, 1, 0, + doc: /* Parse the event symbol. For internal use. */) + (symbol) + Lisp_Object symbol; +{ + /* Fill the cache if needed. */ + parse_modifiers (symbol); + /* Ignore the result (which is stored on Qevent_symbol_element_mask) + and use the Lispier representation stored on Qevent_symbol_elements + instead. */ + return Fget (symbol, Qevent_symbol_elements); +} + /* Apply the modifiers MODIFIERS to the symbol BASE. BASE must be unmodified. @@ -6564,6 +6603,9 @@ apply_modifiers (modifiers, base) /* Mask out upper bits. We don't know where this value's been. */ modifiers &= INTMASK; + if (INTEGERP (base)) + return make_number (XINT (base) | modifiers); + /* The click modifier never figures into cache indices. */ cache = Fget (base, Qmodifier_cache); XSETFASTINT (index, (modifiers & ~click_modifier)); @@ -6975,6 +7017,11 @@ void gobble_input (expected) int expected; { +#ifdef HAVE_DBUS + /* Check whether a D-Bus message has arrived. */ + xd_read_queued_messages (); +#endif /* HAVE_DBUS */ + #ifndef VMS #ifdef SIGIO if (interrupt_input) @@ -7094,7 +7141,7 @@ read_avail_input (expected) nread += nr; expected = 0; } - + if (nr == -1) /* Not OK to read input now. */ { err = 1; @@ -7102,7 +7149,7 @@ read_avail_input (expected) else if (nr == -2) /* Non-transient error. */ { /* The terminal device terminated; it should be closed. */ - + /* Kill Emacs if this was our last terminal. */ if (!terminal_list->next_terminal) /* Formerly simply reported no input, but that @@ -7114,7 +7161,7 @@ read_avail_input (expected) group? Perhaps on systems with FIONREAD Emacs is alone in its group. */ kill (getpid (), SIGHUP); - + /* XXX Is calling delete_terminal safe here? It calls Fdelete_frame. */ if (t->delete_terminal_hook) (*t->delete_terminal_hook) (t); @@ -7287,14 +7334,14 @@ tty_read_avail_input (struct terminal *terminal, buf.modifiers = meta_modifier; if (tty->meta_key != 2) cbuf[i] &= ~0x80; - + buf.code = cbuf[i]; /* Set the frame corresponding to the active tty. Note that the value of selected_frame is not reliable here, redisplay tends to temporarily change it. */ buf.frame_or_window = tty->top_frame; buf.arg = Qnil; - + kbd_buffer_store_event (&buf); /* Don't look at input that follows a C-g too closely. This reduces lossage due to autorepeat on C-g. */ @@ -9210,7 +9257,7 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, last_nonmenu_event = Qnil; delayed_switch_frame = Qnil; - + if (INTERACTIVE) { if (!NILP (prompt)) @@ -10102,32 +10149,44 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, and is a shifted function key, use the corresponding unshifted function key instead. */ if (first_binding >= nmaps - && /* indec.start >= t && fkey.start >= t && */ keytran.start >= t - && SYMBOLP (key)) - { - Lisp_Object breakdown; - int modifiers; - - breakdown = parse_modifiers (key); - modifiers = XINT (XCAR (XCDR (breakdown))); - if (modifiers & shift_modifier) + && /* indec.start >= t && fkey.start >= t && */ keytran.start >= t) + { + Lisp_Object breakdown = parse_modifiers (key); + int modifiers + = CONSP (breakdown) ? (XINT (XCAR (XCDR (breakdown)))) : 0; + + if (modifiers & shift_modifier + /* Treat uppercase keys as shifted. */ + || (INTEGERP (key) + & (KEY_TO_CHAR (key) + < XCHAR_TABLE (current_buffer->downcase_table)->size) + && UPPERCASEP (KEY_TO_CHAR (key)))) { - Lisp_Object new_key; + Lisp_Object new_key + = (modifiers & shift_modifier + ? apply_modifiers (modifiers & ~shift_modifier, + XCAR (breakdown)) + : make_number (DOWNCASE (KEY_TO_CHAR (key)) | modifiers)); original_uppercase = key; original_uppercase_position = t - 1; - modifiers &= ~shift_modifier; - new_key = apply_modifiers (modifiers, - XCAR (breakdown)); - + /* We have to do this unconditionally, regardless of whether + the lower-case char is defined in the keymaps, because they + might get translated through function-key-map. */ keybuf[t - 1] = new_key; mock_input = max (t, mock_input); + /* Reset fkey (and consequently keytran) to apply + function-key-map on the result, so that S-backspace is + correctly mapped to DEL (via backspace). OTOH, + input-decode-map doesn't need to go through it again. */ + fkey.start = fkey.end = 0; + keytran.start = keytran.end = 0; + goto replay_sequence; } } } - if (!dummyflag) read_key_sequence_cmd = (first_binding < nmaps ? defs[first_binding] @@ -11244,7 +11303,7 @@ See also `current-input-mode'. */) new_interrupt_input = 1; #endif - if (new_interrupt_input != interrupt_input) + if (new_interrupt_input != interrupt_input) { #ifdef POLL_FOR_INPUT stop_polling (); @@ -11324,7 +11383,7 @@ See also `current-input-mode'. */) struct terminal *t = get_terminal (terminal, 1); struct tty_display_info *tty; int new_meta; - + if (t == NULL || t->type != output_termcap) return Qnil; tty = t->display_info.tty; @@ -11336,7 +11395,7 @@ See also `current-input-mode'. */) else new_meta = 2; - if (tty->meta_key != new_meta) + if (tty->meta_key != new_meta) { #ifndef DOS_NT /* this causes startup screen to be restored and messes with the mouse */ @@ -11344,7 +11403,7 @@ See also `current-input-mode'. */) #endif tty->meta_key = new_meta; - + #ifndef DOS_NT init_sys_modes (tty); #endif @@ -11376,7 +11435,7 @@ See also `current-input-mode'. */) /* this causes startup screen to be restored and messes with the mouse */ reset_sys_modes (tty); #endif - + /* Don't let this value be out of range. */ quit_char = XINT (quit) & (tty->meta_key == 0 ? 0177 : 0377); @@ -11386,7 +11445,7 @@ See also `current-input-mode'. */) return Qnil; } - + DEFUN ("set-input-mode", Fset_input_mode, Sset_input_mode, 3, 4, 0, doc: /* Set mode of reading keyboard input. First arg INTERRUPT non-nil means use input interrupts; @@ -11785,6 +11844,11 @@ syms_of_keyboard () staticpro (&Qmac_apple_event); #endif +#ifdef HAVE_DBUS + Qdbus_event = intern ("dbus-event"); + staticpro (&Qdbus_event); +#endif + Qmenu_enable = intern ("menu-enable"); staticpro (&Qmenu_enable); Qmenu_alias = intern ("menu-alias"); @@ -11945,6 +12009,7 @@ syms_of_keyboard () staticpro (&help_form_saved_window_configs); defsubr (&Scurrent_idle_time); + defsubr (&Sevent_symbol_parse_modifiers); defsubr (&Sevent_convert_list); defsubr (&Sread_key_sequence); defsubr (&Sread_key_sequence_vector); @@ -12346,7 +12411,7 @@ here. If a mapping is defined in both the current `local-function-key-map' binding and this variable, then the local definition will take precendence. */); Vfunction_key_map = Fmake_sparse_keymap (Qnil); - + DEFVAR_LISP ("key-translation-map", &Vkey_translation_map, doc: /* Keymap of key translations that can override keymaps. This keymap works like `function-key-map', but comes after that, @@ -12468,7 +12533,7 @@ and tool-bar buttons. */); /* Vwindow_system is left at t for now. */ initial_kboard->next_kboard = all_kboards; all_kboards = initial_kboard; -#endif +#endif } void @@ -12513,6 +12578,13 @@ keys_of_keyboard () * "handle-select-window"); */ initial_define_lispy_key (Vspecial_event_map, "save-session", "handle-save-session"); + +#ifdef HAVE_DBUS + /* Define a special event which is raised for dbus callback + functions. */ + initial_define_lispy_key (Vspecial_event_map, "dbus-event", + "dbus-handle-event"); +#endif } /* Mark the pointers in the kboard objects. diff --git a/src/keymap.c b/src/keymap.c index b5abb194e1f..1630ac22a53 100644 --- a/src/keymap.c +++ b/src/keymap.c @@ -2047,7 +2047,8 @@ If KEYMAP is nil, that means no local keymap. */) } DEFUN ("current-local-map", Fcurrent_local_map, Scurrent_local_map, 0, 0, 0, - doc: /* Return current buffer's local keymap, or nil if it has none. */) + doc: /* Return current buffer's local keymap, or nil if it has none. +Normally the local keymap is set by the major mode with `use-local-map'. */) () { return current_buffer->keymap; diff --git a/src/lisp.h b/src/lisp.h index f4b93ff9dce..fb53f68b073 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -349,7 +349,8 @@ enum pvec_type PVEC_HASH_TABLE = 0x40000, PVEC_TERMINAL = 0x80000, PVEC_SUB_CHAR_TABLE = 0x100000, - PVEC_TYPE_MASK = 0x1ffe00 + PVEC_OTHER = 0x200000, + PVEC_TYPE_MASK = 0x2ffe00 #if 0 /* This is used to make the value of PSEUDOVECTOR_FLAG available to GDB. It doesn't work on OS Alpha. Moved to a variable in @@ -1209,6 +1210,7 @@ struct Lisp_Buffer_Objfwd int type : 16; /* = Lisp_Misc_Buffer_Objfwd */ unsigned gcmarkbit : 1; int spacer : 15; + Lisp_Object slottype; /* Qnil, Lisp_Int, Lisp_Symbol, or Lisp_String. */ int offset; }; @@ -2568,7 +2570,11 @@ EXFUN (Fmake_byte_code, MANY); EXFUN (Fmake_bool_vector, 2); extern Lisp_Object Qchar_table_extra_slots; extern struct Lisp_Vector *allocate_vector P_ ((EMACS_INT)); -extern struct Lisp_Vector *allocate_other_vector P_ ((EMACS_INT)); +extern struct Lisp_Vector *allocate_pseudovector P_ ((int memlen, int lisplen, EMACS_INT tag)); +#define ALLOCATE_PSEUDOVECTOR(typ,field,tag) \ + ((typ*) \ + allocate_pseudovector \ + (VECSIZE (typ), PSEUDOVECSIZE (typ, field), tag)) extern struct Lisp_Hash_Table *allocate_hash_table P_ ((void)); extern struct window *allocate_window P_ ((void)); extern struct frame *allocate_frame P_ ((void)); @@ -3245,7 +3251,7 @@ extern void syms_of_dired P_ ((void)); /* Defined in term.c */ extern void syms_of_term P_ ((void)); -extern void fatal () NO_RETURN; +extern void fatal P_ ((const char *msgid, ...)) NO_RETURN; /* Defined in terminal.c */ extern void syms_of_terminal P_ ((void)); diff --git a/src/mac.c b/src/mac.c index 75a606b60b3..9c1a08075f8 100644 --- a/src/mac.c +++ b/src/mac.c @@ -5004,6 +5004,10 @@ extern int noninteractive; #if SELECT_USE_CFSOCKET #define SELECT_TIMEOUT_THRESHOLD_RUNLOOP 0.2 +/* Dictionary of file descriptors vs CFSocketRef's allocated in + sys_select. */ +static CFMutableDictionaryRef cfsockets_for_select; + static void socket_callback (s, type, address, data, info) CFSocketRef s; @@ -5089,6 +5093,43 @@ select_and_poll_event (nfds, rfds, wfds, efds, timeout) return 0; } +/* Clean up the CFSocket associated with the file descriptor FD in + case the same descriptor is used in other threads later. If no + CFSocket is associated with FD, then return 0 without closing FD. + Otherwise, return 1 with closing FD. */ + +int +mac_try_close_socket (fd) + int fd; +{ +#if SELECT_USE_CFSOCKET + if (cfsockets_for_select) + { + void *key = (void *) fd; + CFSocketRef socket = + (CFSocketRef) CFDictionaryGetValue (cfsockets_for_select, key); + + if (socket) + { +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020 + CFOptionFlags flags = CFSocketGetSocketFlags (socket); + + if (!(flags & kCFSocketCloseOnInvalidate)) + CFSocketSetSocketFlags (socket, flags | kCFSocketCloseOnInvalidate); +#endif + BLOCK_INPUT; + CFSocketInvalidate (socket); + CFDictionaryRemoveValue (cfsockets_for_select, key); + UNBLOCK_INPUT; + + return 1; + } + } +#endif + + return 0; +} + int sys_select (nfds, rfds, wfds, efds, timeout) int nfds; @@ -5165,6 +5206,11 @@ sys_select (nfds, rfds, wfds, efds, timeout) CFDictionaryCreateMutable (NULL, 0, NULL, &kCFTypeDictionaryValueCallBacks); + if (cfsockets_for_select == NULL) + cfsockets_for_select = + CFDictionaryCreateMutable (NULL, 0, NULL, + &kCFTypeDictionaryValueCallBacks); + for (minfd = 1; ; minfd++) /* nfds-1 works as a sentinel. */ if (FD_ISSET (minfd, rfds) || (wfds && FD_ISSET (minfd, wfds))) break; @@ -5176,7 +5222,7 @@ sys_select (nfds, rfds, wfds, efds, timeout) CFRunLoopSourceRef source = (CFRunLoopSourceRef) CFDictionaryGetValue (sources, key); - if (source == NULL) + if (source == NULL || !CFRunLoopSourceIsValid (source)) { CFSocketRef socket = CFSocketCreateWithNative (NULL, fd, @@ -5186,11 +5232,12 @@ sys_select (nfds, rfds, wfds, efds, timeout) if (socket == NULL) continue; + CFDictionarySetValue (cfsockets_for_select, key, socket); source = CFSocketCreateRunLoopSource (NULL, socket, 0); CFRelease (socket); if (source == NULL) continue; - CFDictionaryAddValue (sources, key, source); + CFDictionarySetValue (sources, key, source); CFRelease (source); } CFRunLoopAddSource (runloop, source, kCFRunLoopDefaultMode); diff --git a/src/macfns.c b/src/macfns.c index 2b8c24db3b3..1b2c2d5702a 100644 --- a/src/macfns.c +++ b/src/macfns.c @@ -2513,7 +2513,7 @@ unwind_create_frame (frame) DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame, 1, 1, 0, doc: /* Make a new window, which is called a "frame" in Emacs terms. -Returns an Emacs frame object. +Return an Emacs frame object. PARAMETERS is an alist of frame parameters. If the parameters specify that the frame should not have a minibuffer, and do not specify a specific minibuffer window to use, @@ -2547,11 +2547,7 @@ This function is an internal primitive--use `make-frame' instead. */) if (EQ (display, Qunbound)) display = Qnil; dpyinfo = check_x_display_info (display); -#ifdef MULTI_KBOARD kb = dpyinfo->terminal->kboard; -#else - kb = &the_only_kboard; -#endif name = mac_get_arg (parameters, Qname, "name", "Name", RES_TYPE_STRING); if (!STRINGP (name) @@ -2615,9 +2611,7 @@ This function is an internal primitive--use `make-frame' instead. */) image_cache_refcount = FRAME_X_IMAGE_CACHE (f)->refcount; dpyinfo_refcount = dpyinfo->reference_count; #endif /* GLYPH_DEBUG */ -#ifdef MULTI_KBOARD FRAME_KBOARD (f) = kb; -#endif /* Specify the parent under which to make this window. */ @@ -2975,7 +2969,7 @@ If omitted or nil, that stands for the selected frame's display. */) DEFUN ("x-display-pixel-width", Fx_display_pixel_width, Sx_display_pixel_width, 0, 1, 0, - doc: /* Returns the width in pixels of DISPLAY. + doc: /* Return the width in pixels of DISPLAY. The optional argument DISPLAY specifies which display to ask about. DISPLAY should be either a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) @@ -2989,7 +2983,7 @@ If omitted or nil, that stands for the selected frame's display. */) DEFUN ("x-display-pixel-height", Fx_display_pixel_height, Sx_display_pixel_height, 0, 1, 0, - doc: /* Returns the height in pixels of DISPLAY. + doc: /* Return the height in pixels of DISPLAY. The optional argument DISPLAY specifies which display to ask about. DISPLAY should be either a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) @@ -3003,7 +2997,7 @@ If omitted or nil, that stands for the selected frame's display. */) DEFUN ("x-display-planes", Fx_display_planes, Sx_display_planes, 0, 1, 0, - doc: /* Returns the number of bitplanes of DISPLAY. + doc: /* Return the number of bitplanes of DISPLAY. The optional argument DISPLAY specifies which display to ask about. DISPLAY should be either a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) @@ -3017,7 +3011,7 @@ If omitted or nil, that stands for the selected frame's display. */) DEFUN ("x-display-color-cells", Fx_display_color_cells, Sx_display_color_cells, 0, 1, 0, - doc: /* Returns the number of color cells of DISPLAY. + doc: /* Return the number of color cells of DISPLAY. The optional argument DISPLAY specifies which display to ask about. DISPLAY should be either a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) @@ -3033,7 +3027,7 @@ If omitted or nil, that stands for the selected frame's display. */) DEFUN ("x-server-max-request-size", Fx_server_max_request_size, Sx_server_max_request_size, 0, 1, 0, - doc: /* Returns the maximum request size of the server of DISPLAY. + doc: /* Return the maximum request size of the server of DISPLAY. The optional argument DISPLAY specifies which display to ask about. DISPLAY should be either a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) @@ -3046,7 +3040,7 @@ If omitted or nil, that stands for the selected frame's display. */) } DEFUN ("x-server-vendor", Fx_server_vendor, Sx_server_vendor, 0, 1, 0, - doc: /* Returns the "vendor ID" string of the Mac OS system (Apple). + doc: /* Return the "vendor ID" string of the Mac OS system (Apple). The optional argument DISPLAY specifies which display to ask about. DISPLAY should be either a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) @@ -3057,7 +3051,7 @@ If omitted or nil, that stands for the selected frame's display. */) } DEFUN ("x-server-version", Fx_server_version, Sx_server_version, 0, 1, 0, - doc: /* Returns the version numbers of the Mac OS system. + doc: /* Return the version numbers of the Mac OS system. The value is a list of three integers: the major and minor version numbers, and the vendor-specific release number. See also the function `x-server-vendor'. @@ -3191,7 +3185,7 @@ If omitted or nil, that stands for the selected frame's display. */) DEFUN ("x-display-backing-store", Fx_display_backing_store, Sx_display_backing_store, 0, 1, 0, - doc: /* Returns an indication of whether DISPLAY does backing store. + doc: /* Return an indication of whether DISPLAY does backing store. The value may be `always', `when-mapped', or `not-useful'. The optional argument DISPLAY specifies which display to ask about. DISPLAY should be either a frame or a display name (a string). @@ -3204,7 +3198,7 @@ If omitted or nil, that stands for the selected frame's display. */) DEFUN ("x-display-visual-class", Fx_display_visual_class, Sx_display_visual_class, 0, 1, 0, - doc: /* Returns the visual class of DISPLAY. + doc: /* Return the visual class of DISPLAY. The value is one of the symbols `static-gray', `gray-scale', `static-color', `pseudo-color', `true-color', or `direct-color'. @@ -3235,7 +3229,7 @@ If omitted or nil, that stands for the selected frame's display. */) DEFUN ("x-display-save-under", Fx_display_save_under, Sx_display_save_under, 0, 1, 0, - doc: /* Returns t if DISPLAY supports the save-under feature. + doc: /* Return t if DISPLAY supports the save-under feature. The optional argument DISPLAY specifies which display to ask about. DISPLAY should be either a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) @@ -3809,11 +3803,7 @@ x_create_tip_frame (dpyinfo, parms, text) parms = Fcopy_alist (parms); -#ifdef MULTI_KBOARD kb = dpyinfo->terminal->kboard; -#else - kb = &the_only_kboard; -#endif /* Get the name of the frame to use for resource lookup. */ name = mac_get_arg (parms, Qname, "name", "Name", RES_TYPE_STRING); @@ -3859,9 +3849,7 @@ x_create_tip_frame (dpyinfo, parms, text) image_cache_refcount = FRAME_X_IMAGE_CACHE (f)->refcount; dpyinfo_refcount = dpyinfo->reference_count; #endif /* GLYPH_DEBUG */ -#ifdef MULTI_KBOARD FRAME_KBOARD (f) = kb; -#endif f->output_data.mac->parent_desc = FRAME_MAC_DISPLAY_INFO (f)->root_window; f->output_data.mac->explicit_parent = 0; diff --git a/src/macterm.c b/src/macterm.c index f107f081421..f07b9eb0a5d 100644 --- a/src/macterm.c +++ b/src/macterm.c @@ -12625,6 +12625,10 @@ mac_term_init (display_name, xrm_option, resource_name) x_display_name_list); dpyinfo->name_list_element = XCAR (x_display_name_list); + /* FIXME: Untested. + Add the default keyboard. */ + add_keyboard_wait_descriptor (0); + #if USE_CG_DRAWING mac_init_fringe (terminal->rif); #endif @@ -12844,7 +12848,6 @@ mac_create_terminal (struct mac_display_info *dpyinfo) /* FIXME: This keyboard setup is 100% untested, just copied from w32_create_terminal in order to set window-system now that it's a keyboard object. */ -#ifdef MULTI_KBOARD /* We don't yet support separate terminals on Mac, so don't try to share keyboards between virtual terminals that are on the same physical terminal like X does. */ @@ -12859,7 +12862,6 @@ mac_create_terminal (struct mac_display_info *dpyinfo) if (current_kboard == initial_kboard) current_kboard = terminal->kboard; terminal->kboard->reference_count++; -#endif return terminal; } diff --git a/src/print.c b/src/print.c index c6304bbd24e..a88404cb52e 100644 --- a/src/print.c +++ b/src/print.c @@ -1636,7 +1636,7 @@ print_object (obj, printcharfun, escapeflag) { case Lisp_Int: if (sizeof (int) == sizeof (EMACS_INT)) - sprintf (buf, "%d", XINT (obj)); + sprintf (buf, "%d", (int) XINT (obj)); else if (sizeof (long) == sizeof (EMACS_INT)) sprintf (buf, "%ld", (long) XINT (obj)); else diff --git a/src/process.c b/src/process.c index d80d7db2554..c2f0c82a6a8 100644 --- a/src/process.c +++ b/src/process.c @@ -631,6 +631,7 @@ make_process (name) p->tick = 0; p->update_tick = 0; p->pid = 0; + p->pty_flag = 0; p->raw_status_new = 0; p->status = Qrun; p->mark = Fmake_marker (); @@ -1374,8 +1375,10 @@ list_processes_1 (query_only) if (w_tty) { XSETFASTINT (i_tty, XFASTINT (i_buffer) + w_buffer + 1); - XSETFASTINT (i_command, XFASTINT (i_buffer) + w_tty + 1); - } else { + XSETFASTINT (i_command, XFASTINT (i_tty) + w_tty + 1); + } + else + { i_tty = Qnil; XSETFASTINT (i_command, XFASTINT (i_buffer) + w_buffer + 1); } diff --git a/src/puresize.h b/src/puresize.h index bf4971a0b5f..100721b36cc 100644 --- a/src/puresize.h +++ b/src/puresize.h @@ -43,7 +43,7 @@ Boston, MA 02110-1301, USA. */ #endif #ifndef BASE_PURESIZE -#define BASE_PURESIZE (1180000 + SYSTEM_PURESIZE_EXTRA + SITELOAD_PURESIZE_EXTRA) +#define BASE_PURESIZE (1190000 + SYSTEM_PURESIZE_EXTRA + SITELOAD_PURESIZE_EXTRA) #endif /* Increase BASE_PURESIZE by a ratio depending on the machine's word size. */ diff --git a/src/s/darwin.h b/src/s/darwin.h index 6bfa0e95106..c1108e7c295 100644 --- a/src/s/darwin.h +++ b/src/s/darwin.h @@ -53,9 +53,6 @@ Boston, MA 02110-1301, USA. */ /* We need a little extra space, see ../../lisp/loadup.el. */ #define SYSTEM_PURESIZE_EXTRA 30000 -/* XXX The MULTI_KBOARD support does not work yet on this platform. */ -#undef MULTI_KBOARD - #endif #endif diff --git a/src/s/gnu-kfreebsd.h b/src/s/gnu-kfreebsd.h new file mode 100644 index 00000000000..a1e8c024744 --- /dev/null +++ b/src/s/gnu-kfreebsd.h @@ -0,0 +1,11 @@ +#include "gnu-linux.h" + +/* SYSTEM_TYPE should indicate the kind of system you are using. + It sets the Lisp variable system-type. */ +#undef SYSTEM_TYPE +#define SYSTEM_TYPE "gnu/kfreebsd" /* All the best software is free */ + +#define NO_TERMIO /* use only <termios.h> */ + +/* arch-tag: 8d098200-2586-469e-99ab-6d092c035e03 + (do not change this comment) */ diff --git a/src/s/ms-w32.h b/src/s/ms-w32.h index 2881fa1eb75..ee64a5d94f2 100644 --- a/src/s/ms-w32.h +++ b/src/s/ms-w32.h @@ -477,9 +477,7 @@ extern char *get_emacs_configuration_options (void); #endif #include <string.h> -/* We need a little extra space, see ../../lisp/loadup.el. - The number below comes from 23923 bytes worth (as of 2006-04) - of w32-specific files loaded by loadup.el, plus 1K spare. */ +/* We need a little extra space, see ../../lisp/loadup.el. */ #define SYSTEM_PURESIZE_EXTRA 50000 /* For unexec to work on Alpha systems, we need to put Emacs' @@ -491,9 +489,9 @@ extern char *get_emacs_configuration_options (void); into its own section. VC5 intermingles uninitialized data from the CRT between Emacs' static uninitialized data and its public uninitialized data. A separate .bss section for Emacs groups both static and - public uninitalized together. + public uninitialized together. - Note that unexnt.c relies on this fact, and must be modified + Note that unexw32.c relies on this fact, and must be modified accordingly if this section name is changed, or if this pragma is removed. Also, obviously, all files that define initialized data must include config.h to pick up this pragma. */ diff --git a/src/search.c b/src/search.c index aff998b154b..2060abda6d7 100644 --- a/src/search.c +++ b/src/search.c @@ -2942,11 +2942,15 @@ Return value is undefined if the last search failed. */) return reuse; } -/* Internal usage only: - If RESEAT is `evaporate', put the markers back on the free list - immediately. No other references to the markers must exist in this case, - so it is used only internally on the unwind stack and save-match-data from - Lisp. */ +/* We used to have an internal use variant of `reseat' described as: + + If RESEAT is `evaporate', put the markers back on the free list + immediately. No other references to the markers must exist in this + case, so it is used only internally on the unwind stack and + save-match-data from Lisp. + + But it was ill-conceived: those supposedly-internal markers get exposed via + the undo-list, so freeing them here is unsafe. */ DEFUN ("set-match-data", Fset_match_data, Sset_match_data, 1, 2, 0, doc: /* Set internal data on last search match from elements of LIST. @@ -3031,10 +3035,7 @@ If optional arg RESEAT is non-nil, make markers on LIST point nowhere. */) if (!NILP (reseat) && MARKERP (m)) { - if (EQ (reseat, Qevaporate)) - free_marker (m); - else - unchain_marker (XMARKER (m)); + unchain_marker (XMARKER (m)); XSETCAR (list, Qnil); } @@ -3052,10 +3053,7 @@ If optional arg RESEAT is non-nil, make markers on LIST point nowhere. */) if (!NILP (reseat) && MARKERP (m)) { - if (EQ (reseat, Qevaporate)) - free_marker (m); - else - unchain_marker (XMARKER (m)); + unchain_marker (XMARKER (m)); XSETCAR (list, Qnil); } } @@ -3119,8 +3117,8 @@ static Lisp_Object unwind_set_match_data (list) Lisp_Object list; { - /* It is safe to free (evaporate) the markers immediately. */ - return Fset_match_data (list, Qevaporate); + /* It is NOT ALWAYS safe to free (evaporate) the markers immediately. */ + return Fset_match_data (list, Qt); } /* Called to unwind protect the match data. */ @@ -3219,9 +3217,10 @@ A value of nil (which is the normal value) means treat spaces literally. */); DEFVAR_LISP ("inhibit-changing-match-data", &Vinhibit_changing_match_data, doc: /* Internal use only. -If non-nil, the match data will not be changed during call to searching or -matching functions, such as `looking-at', `string-match', `re-search-forward' -etc. */); +If non-nil, the primitive searching and matching functions +such as `looking-at', `string-match', `re-search-forward', etc., +do not set the match data. The proper way to use this variable +is to bind it with `let' around a small expression. */); Vinhibit_changing_match_data = Qnil; defsubr (&Slooking_at); diff --git a/src/sysdep.c b/src/sysdep.c index 35a107f34cf..d1f378a3f87 100644 --- a/src/sysdep.c +++ b/src/sysdep.c @@ -2518,10 +2518,50 @@ init_system_name () #endif /* not CANNOT_DUMP */ if (! index (hostname, '.')) { - struct hostent *hp; int count; +#ifdef HAVE_GETADDRINFO + struct addrinfo *res; + struct addrinfo hints; + int ret; + + memset (&hints, 0, sizeof(hints)); + hints.ai_socktype = SOCK_STREAM; + hints.ai_flags = AI_CANONNAME; + + for (count = 0;; count++) + { + if ((ret = getaddrinfo (hostname, NULL, &hints, &res)) == 0 + || ret != EAI_AGAIN) + break; + + if (count >= 5) + break; + Fsleep_for (make_number (1), Qnil); + } + + if (ret == 0) + { + struct addrinfo *it = res; + while (it) + { + char *fqdn = it->ai_canonname; + if (fqdn && index (fqdn, '.') + && strcmp (fqdn, "localhost.localdomain") != 0) + break; + it = it->ai_next; + } + if (it) + { + hostname = alloca (strlen (it->ai_canonname) + 1); + strcpy (hostname, it->ai_canonname); + } + freeaddrinfo (res); + } +#else /* !HAVE_GETADDRINFO */ + struct hostent *hp; for (count = 0;; count++) { + #ifdef TRY_AGAIN h_errno = 0; #endif @@ -2529,11 +2569,14 @@ init_system_name () #ifdef TRY_AGAIN if (! (hp == 0 && h_errno == TRY_AGAIN)) #endif + break; + if (count >= 5) break; Fsleep_for (make_number (1), Qnil); } + if (hp) { char *fqdn = (char *) hp->h_name; @@ -2567,6 +2610,7 @@ init_system_name () } #endif } +#endif /* !HAVE_GETADDRINFO */ } #endif /* HAVE_SOCKETS */ /* We used to try using getdomainname here, @@ -3442,6 +3486,15 @@ emacs_close (fd) int did_retry = 0; register int rtnval; +#if defined (MAC_OSX) && defined (HAVE_CARBON) + { + extern int mac_try_close_socket P_ ((int)); + + if (mac_try_close_socket (fd)) + return 0; + } +#endif + while ((rtnval = close (fd)) == -1 && (errno == EINTR)) did_retry = 1; diff --git a/src/term.c b/src/term.c index bb7c139eafd..e7d66420ffa 100644 --- a/src/term.c +++ b/src/term.c @@ -37,6 +37,7 @@ Boston, MA 02110-1301, USA. */ #endif #include <signal.h> +#include <stdarg.h> #include "lisp.h" #include "termchar.h" @@ -3866,14 +3867,14 @@ maybe_fatal (must_succeed, buffer, terminal, str1, str2, arg1, arg2) abort (); } -/* VARARGS 1 */ void -fatal (str, arg1, arg2) - char *str, *arg1, *arg2; +fatal (const char *str, ...) { + va_list ap; + va_start (ap, str); fprintf (stderr, "emacs: "); - fprintf (stderr, str, arg1, arg2); - fprintf (stderr, "\n"); + vfprintf (stderr, str, ap); + va_end (ap); fflush (stderr); exit (1); } diff --git a/src/termhooks.h b/src/termhooks.h index 369bdff158d..e5c7dcea140 100644 --- a/src/termhooks.h +++ b/src/termhooks.h @@ -197,6 +197,10 @@ enum event_kind , GPM_CLICK_EVENT #endif +#ifdef HAVE_DBUS + , DBUS_EVENT +#endif + #ifdef WINDOWSNT /* Generated when an APPCOMMAND event is received, in response to Multimedia or Internet buttons on some keyboards. @@ -336,7 +340,7 @@ struct terminal /* All fields before `next_terminal' should be Lisp_Object and are traced by the GC. All fields afterwards are ignored by the GC. */ - + /* Chain of all terminal devices. */ struct terminal *next_terminal; @@ -382,12 +386,12 @@ struct terminal /* Terminal characteristics. */ /* XXX Are these really used on non-termcap displays? */ - + int must_write_spaces; /* Nonzero means spaces in the text must actually be output; can't just skip over some columns to leave them blank. */ int fast_clear_end_of_line; /* Nonzero means terminal has a `ce' string */ - + int line_ins_del_ok; /* Terminal can insert and delete lines */ int char_ins_del_ok; /* Terminal can insert and delete chars */ int scroll_region_ok; /* Terminal supports setting the scroll @@ -410,24 +414,24 @@ struct terminal struct redisplay_interface *rif; /* Frame-based redisplay interface. */ - + /* Text display hooks. */ void (*cursor_to_hook) P_ ((struct frame *f, int vpos, int hpos)); void (*raw_cursor_to_hook) P_ ((struct frame *, int, int)); - + void (*clear_to_end_hook) P_ ((struct frame *)); void (*clear_frame_hook) P_ ((struct frame *)); void (*clear_end_of_line_hook) P_ ((struct frame *, int)); - + void (*ins_del_lines_hook) P_ ((struct frame *f, int, int)); - + void (*insert_glyphs_hook) P_ ((struct frame *f, struct glyph *s, int n)); void (*write_glyphs_hook) P_ ((struct frame *f, struct glyph *s, int n)); void (*delete_glyphs_hook) P_ ((struct frame *, int)); - + void (*ring_bell_hook) P_ ((struct frame *f)); - + void (*reset_terminal_modes_hook) P_ ((struct terminal *)); void (*set_terminal_modes_hook) P_ ((struct terminal *)); @@ -442,7 +446,7 @@ struct terminal Set *f to the frame the mouse is in, or zero if the mouse is in no Emacs frame. If it is set to zero, all the other arguments are garbage. - + If the motion started in a scroll bar, set *bar_window to the scroll bar's window, *part to the part the mouse is currently over, *x to the position of the mouse along the scroll bar, and *y to the @@ -452,7 +456,7 @@ struct terminal row of the character cell the mouse is over. Set *time to the time the mouse was at the returned position. - + This should clear mouse_moved until the next motion event arrives. */ void (*mouse_position_hook) P_ ((struct frame **f, int, @@ -478,7 +482,7 @@ struct terminal hook is zero, that means the terminal we're displaying on doesn't support overlapping frames, so there's no need to raise or lower anything. - + If RAISE is non-zero, F is brought to the front, before all other windows. If RAISE is zero, F is sent to the back, behind all other windows. */ @@ -488,7 +492,7 @@ struct terminal For example, if going from fullscreen to not fullscreen this hook may do something OS dependent, like extended window manager hints on X11. */ void (*fullscreen_hook) P_ ((struct frame *f)); - + /* Scroll bar hooks. */ @@ -497,21 +501,21 @@ struct terminal lisp objects. This allows us to place references to them in Lisp_Windows without worrying about those references becoming dangling references when the scroll bar is destroyed. - + The window-system-independent portion of Emacs just refers to scroll bars via their windows, and never looks inside the scroll bar representation; it always uses hook functions to do all the scroll bar manipulation it needs. - + The `vertical_scroll_bar' field of a Lisp_Window refers to that window's scroll bar, or is nil if the window doesn't have a scroll bar. - + The `scroll_bars' and `condemned_scroll_bars' fields of a Lisp_Frame are free for use by the scroll bar implementation in any way it sees fit. They are marked by the garbage collector. */ - - + + /* Set the vertical scroll bar for WINDOW to have its upper left corner at (TOP, LEFT), and be LENGTH rows high. Set its handle to indicate that we are displaying PORTION characters out of a total @@ -529,16 +533,16 @@ struct terminal Instead, we just assert at the beginning of redisplay that *all* scroll bars are to be removed, and then save scroll bars from the fiery pit when we actually redisplay their window. */ - + /* Arrange for all scroll bars on FRAME to be removed at the next call to `*judge_scroll_bars_hook'. A scroll bar may be spared if `*redeem_scroll_bar_hook' is applied to its window before the judgement. - + This should be applied to each frame each time its window tree is redisplayed, even if it is not displaying scroll bars at the moment; if the HAS_SCROLL_BARS flag has just been turned off, only calling this and the judge_scroll_bars_hook will get rid of them. - + If non-zero, this hook should be safe to apply to any frame, whether or not it can support scroll bars, and whether or not it is currently displaying them. */ @@ -555,7 +559,7 @@ struct terminal tree is redisplayed, even if it is not displaying scroll bars at the moment; if the HAS_SCROLL_BARS flag has just been turned off, only calling this and condemn_scroll_bars_hook will get rid of them. - + If non-zero, this hook should be safe to apply to any frame, whether or not it can support scroll bars, and whether or not it is currently displaying them. */ @@ -595,7 +599,7 @@ struct terminal /* Called after the last frame on this terminal is deleted, or when the display device was closed (hangup). - + If this is NULL, then the generic delete_terminal is called instead. Otherwise the hook must call delete_terminal itself. diff --git a/src/unexmacosx.c b/src/unexmacosx.c index 3646aec6983..dadc19d52e3 100644 --- a/src/unexmacosx.c +++ b/src/unexmacosx.c @@ -819,7 +819,9 @@ copy_data_segment (struct load_command *lc) || strncmp (sectp->sectname, "__la_sym_ptr2", 16) == 0 || strncmp (sectp->sectname, "__dyld", 16) == 0 || strncmp (sectp->sectname, "__const", 16) == 0 - || strncmp (sectp->sectname, "__cfstring", 16) == 0) + || strncmp (sectp->sectname, "__cfstring", 16) == 0 + || strncmp (sectp->sectname, "__gcc_except_tab", 16) == 0 + || strncmp (sectp->sectname, "__objc_", 7) == 0) { if (!unexec_copy (sectp->offset, old_file_offset, sectp->size)) unexec_error ("cannot copy section %s", sectp->sectname); @@ -898,12 +900,13 @@ copy_symtab (struct load_command *lc, long delta) /* Fix up relocation entries. */ static void -unrelocate (const char *name, off_t reloff, int nrel) +unrelocate (const char *name, off_t reloff, int nrel, vm_address_t base) { int i, unreloc_count; struct relocation_info reloc_info; struct scattered_relocation_info *sc_reloc_info = (struct scattered_relocation_info *) &reloc_info; + vm_address_t location; for (unreloc_count = 0, i = 0; i < nrel; i++) { @@ -917,14 +920,15 @@ unrelocate (const char *name, off_t reloff, int nrel) switch (reloc_info.r_type) { case GENERIC_RELOC_VANILLA: - if (reloc_info.r_address >= data_segment_scp->vmaddr - && reloc_info.r_address < (data_segment_scp->vmaddr - + data_segment_scp->vmsize)) + location = base + reloc_info.r_address; + if (location >= data_segment_scp->vmaddr + && location < (data_segment_scp->vmaddr + + data_segment_scp->vmsize)) { off_t src_off = data_segment_old_fileoff - + reloc_info.r_address - data_segment_scp->vmaddr; + + (location - data_segment_scp->vmaddr); off_t dst_off = data_segment_scp->fileoff - + reloc_info.r_address - data_segment_scp->vmaddr; + + (location - data_segment_scp->vmaddr); if (!unexec_copy (dst_off, src_off, 1 << reloc_info.r_length)) unexec_error ("unrelocate: %s:%d cannot copy original value", @@ -955,15 +959,73 @@ unrelocate (const char *name, off_t reloff, int nrel) unreloc_count, nrel, name); } +#if __ppc64__ +/* Rebase r_address in the relocation table. */ +static void +rebase_reloc_address (off_t reloff, int nrel, long linkedit_delta, long diff) +{ + int i; + struct relocation_info reloc_info; + struct scattered_relocation_info *sc_reloc_info + = (struct scattered_relocation_info *) &reloc_info; + + for (i = 0; i < nrel; i++, reloff += sizeof (reloc_info)) + { + if (lseek (infd, reloff - linkedit_delta, L_SET) + != reloff - linkedit_delta) + unexec_error ("rebase_reloc_table: cannot seek to reloc_info"); + if (!unexec_read (&reloc_info, sizeof (reloc_info))) + unexec_error ("rebase_reloc_table: cannot read reloc_info"); + + if (sc_reloc_info->r_scattered == 0 + && reloc_info.r_type == GENERIC_RELOC_VANILLA) + { + reloc_info.r_address -= diff; + if (!unexec_write (reloff, &reloc_info, sizeof (reloc_info))) + unexec_error ("rebase_reloc_table: cannot write reloc_info"); + } + } +} +#endif + /* Copy a LC_DYSYMTAB load command from the input file to the output file, adjusting the file offset fields. */ static void copy_dysymtab (struct load_command *lc, long delta) { struct dysymtab_command *dstp = (struct dysymtab_command *) lc; + vm_address_t base; - unrelocate ("local", dstp->locreloff, dstp->nlocrel); - unrelocate ("external", dstp->extreloff, dstp->nextrel); +#ifdef _LP64 +#if __ppc64__ + { + int i; + + base = 0; + for (i = 0; i < nlc; i++) + if (lca[i]->cmd == LC_SEGMENT) + { + struct segment_command *scp = (struct segment_command *) lca[i]; + + if (scp->vmaddr + scp->vmsize > 0x100000000 + && (scp->initprot & VM_PROT_WRITE) != 0) + { + base = data_segment_scp->vmaddr; + break; + } + } + } +#else + /* First writable segment address. */ + base = data_segment_scp->vmaddr; +#endif +#else + /* First segment address in the file (unless MH_SPLIT_SEGS set). */ + base = 0; +#endif + + unrelocate ("local", dstp->locreloff, dstp->nlocrel, base); + unrelocate ("external", dstp->extreloff, dstp->nextrel, base); if (dstp->nextrel > 0) { dstp->extreloff += delta; @@ -982,6 +1044,29 @@ copy_dysymtab (struct load_command *lc, long delta) unexec_error ("cannot write symtab command to header"); curr_header_offset += lc->cmdsize; + +#if __ppc64__ + /* Check if the relocation base needs to be changed. */ + if (base == 0) + { + vm_address_t newbase = 0; + int i; + + for (i = 0; i < num_unexec_regions; i++) + if (unexec_regions[i].range.address + unexec_regions[i].range.size + > 0x100000000) + { + newbase = data_segment_scp->vmaddr; + break; + } + + if (newbase) + { + rebase_reloc_address (dstp->locreloff, dstp->nlocrel, delta, newbase); + rebase_reloc_address (dstp->extreloff, dstp->nextrel, delta, newbase); + } + } +#endif } /* Copy a LC_TWOLEVEL_HINTS load command from the input file to the output diff --git a/src/w32bdf.c b/src/w32bdf.c index 1ccd7ff2424..dd6abd8a743 100644 --- a/src/w32bdf.c +++ b/src/w32bdf.c @@ -261,7 +261,7 @@ w32_init_bdf_font(char *filename) error("Fail to open BDF file"); } hfilemap = CreateFileMapping(hfile, NULL, PAGE_READONLY, 0, 0, NULL); - if (hfilemap == INVALID_HANDLE_VALUE) + if (!hfilemap) { CloseHandle(hfile); error("Can't map font"); @@ -828,7 +828,7 @@ int w32_BDF_to_x_font (char *file, char* xstr, int len) size = fileinfo.nFileSizeLow; hfilemap = CreateFileMapping (hfile, NULL, PAGE_READONLY, 0, 0, NULL); - if (hfilemap == INVALID_HANDLE_VALUE) + if (!hfilemap) { CloseHandle (hfile); return 0; diff --git a/src/w32console.c b/src/w32console.c index 72411d7d4be..d5f7a66a0e8 100644 --- a/src/w32console.c +++ b/src/w32console.c @@ -35,8 +35,6 @@ Boston, MA 02110-1301, USA. #include "character.h" #include "coding.h" #include "disptab.h" -/* Disable features in frame.h that require a Window System. */ -#undef HAVE_WINDOW_SYSTEM #include "frame.h" #include "termhooks.h" #include "termchar.h" @@ -76,6 +74,8 @@ static DWORD prev_console_mode; static CONSOLE_CURSOR_INFO prev_console_cursor; #endif +extern Lisp_Object Vtty_defined_color_alist; + /* Determine whether to make frame dimensions match the screen buffer, or the current window size. The former is desirable when running over telnet, while the latter is more useful when working directly at @@ -164,6 +164,7 @@ w32con_ins_del_lines (struct frame *f, int vpos, int n) { int i, nb; SMALL_RECT scroll; + SMALL_RECT clip; COORD dest; CHAR_INFO fill; @@ -179,15 +180,16 @@ w32con_ins_del_lines (struct frame *f, int vpos, int n) scroll.Bottom = FRAME_LINES (f) - n; dest.Y = vpos + n; } - scroll.Left = 0; - scroll.Right = FRAME_COLS (f); + clip.Top = clip.Left = scroll.Left = 0; + clip.Right = scroll.Right = FRAME_COLS (f); + clip.Bottom = FRAME_LINES (f); dest.X = 0; fill.Char.AsciiChar = 0x20; fill.Attributes = char_attr_normal; - ScrollConsoleScreenBuffer (cur_screen, &scroll, NULL, dest, &fill); + ScrollConsoleScreenBuffer (cur_screen, &scroll, &clip, dest, &fill); /* Here we have to deal with a w32 console flake: If the scroll region looks like abc and we scroll c to a and fill with d we get @@ -235,12 +237,13 @@ scroll_line (struct frame *f, int dist, int direction) { /* The idea here is to implement a horizontal scroll in one line to implement delete and half of insert. */ - SMALL_RECT scroll; + SMALL_RECT scroll, clip; COORD dest; CHAR_INFO fill; - scroll.Top = cursor_coords.Y; - scroll.Bottom = cursor_coords.Y; + clip.Top = scroll.Top = clip.Bottom = scroll.Bottom = cursor_coords.Y; + clip.Left = 0; + clip.Right = FRAME_COLS (f); if (direction == LEFT) { @@ -259,7 +262,7 @@ scroll_line (struct frame *f, int dist, int direction) fill.Char.AsciiChar = 0x20; fill.Attributes = char_attr_normal; - ScrollConsoleScreenBuffer (cur_screen, &scroll, NULL, dest, &fill); + ScrollConsoleScreenBuffer (cur_screen, &scroll, &clip, dest, &fill); } @@ -290,7 +293,6 @@ static void w32con_write_glyphs (struct frame *f, register struct glyph *string, register int len) { - int produced, consumed; DWORD r; WORD char_attr; unsigned char *conversion_buffer; @@ -418,11 +420,31 @@ SOUND is nil to use the normal beep. */) static void w32con_reset_terminal_modes (struct terminal *t) { + COORD dest; + CONSOLE_SCREEN_BUFFER_INFO info; + int n; + DWORD r; + + /* Clear the complete screen buffer. This is required because Emacs + sets the cursor position to the top of the buffer, but there might + be other output below the bottom of the Emacs frame if the screen buffer + is larger than the window size. */ + GetConsoleScreenBufferInfo (cur_screen, &info); + dest.X = 0; + dest.Y = 0; + n = info.dwSize.X * info.dwSize.Y; + + FillConsoleOutputAttribute (cur_screen, char_attr_normal, n, dest, &r); + FillConsoleOutputCharacter (cur_screen, ' ', n, dest, &r); + /* Now that the screen is clear, put the cursor at the top. */ + SetConsoleCursorPosition (cur_screen, dest); + #ifdef USE_SEPARATE_SCREEN SetConsoleActiveScreenBuffer (prev_screen); #else SetConsoleCursorInfo (prev_screen, &prev_console_cursor); #endif + SetConsoleMode (keyboard_handle, prev_console_mode); } @@ -484,32 +506,31 @@ w32_face_attributes (f, face_id) char_attr = char_attr_normal; - if (face->foreground != FACE_TTY_DEFAULT_FG_COLOR - && face->foreground != FACE_TTY_DEFAULT_COLOR) - char_attr = (char_attr & 0xfff0) + (face->foreground % 16); - - if (face->background != FACE_TTY_DEFAULT_BG_COLOR - && face->background != FACE_TTY_DEFAULT_COLOR) - char_attr = (char_attr & 0xff0f) + ((face->background % 16) << 4); - - - /* NTEMACS_TODO: Faces defined during startup get both foreground - and background of 0. Need a better way around this - for now detect - the problem and invert one of the faces to make the text readable. */ - if (((char_attr & 0x00f0) >> 4) == (char_attr & 0x000f)) - char_attr ^= 0x0007; - + /* Reverse the default color if requested. If background and + foreground are specified, then they have been reversed already. */ if (face->tty_reverse_p) char_attr = (char_attr & 0xff00) + ((char_attr & 0x000f) << 4) + ((char_attr & 0x00f0) >> 4); - return char_attr; -} + /* Before the terminal is properly initialized, all colors map to 0. + Don't try to resolve them. */ + if (NILP (Vtty_defined_color_alist)) + return char_attr; + + /* Colors should be in the range 0...15 unless they are one of + FACE_TTY_DEFAULT_COLOR, FACE_TTY_DEFAULT_FG_COLOR or + FACE_TTY_DEFAULT_BG_COLOR. Other out of range colors are + invalid, so it is better to use the default color if they ever + get through to here. */ + if (face->foreground >= 0 && face->foreground < 16) + char_attr = (char_attr & 0xfff0) + face->foreground; + if (face->background >= 0 && face->background < 16) + char_attr = (char_attr & 0xff0f) + (face->background << 4); -/* Emulation of some X window features from xfns.c and xfaces.c. */ + return char_attr; +} -extern char unspecified_fg[], unspecified_bg[]; /* Given a color index, return its standard name. */ diff --git a/src/w32fns.c b/src/w32fns.c index 03179c6952e..3e4413a0bee 100644 --- a/src/w32fns.c +++ b/src/w32fns.c @@ -79,14 +79,6 @@ extern int quit_char; extern char *lispy_function_keys[]; -/* The gray bitmap `bitmaps/gray'. This is done because w32term.c uses - it, and including `bitmaps/gray' more than once is a problem when - config.h defines `static' as an empty replacement string. */ - -int gray_bitmap_width = gray_width; -int gray_bitmap_height = gray_height; -unsigned char *gray_bitmap_bits = gray_bits; - /* The colormap for converting color names to RGB values */ Lisp_Object Vw32_color_map; @@ -149,10 +141,10 @@ int w32_mouse_button_tolerance; int w32_mouse_move_interval; /* Flag to indicate if XBUTTON events should be passed on to Windows. */ -int w32_pass_extra_mouse_buttons_to_system; +static int w32_pass_extra_mouse_buttons_to_system; /* Flag to indicate if media keys should be passed on to Windows. */ -int w32_pass_multimedia_buttons_to_system; +static int w32_pass_multimedia_buttons_to_system; /* Non nil if no window manager is in use. */ Lisp_Object Vx_no_window_manager; @@ -191,14 +183,14 @@ Lisp_Object Vx_pixel_size_width_font_regexp; Lisp_Object Vw32_bdf_filename_alist; /* A flag to control whether fonts are matched strictly or not. */ -int w32_strict_fontnames; +static int w32_strict_fontnames; /* A flag to control whether we should only repaint if GetUpdateRect indicates there is an update region. */ -int w32_strict_painting; +static int w32_strict_painting; /* Associative list linking character set strings to Windows codepages. */ -Lisp_Object Vw32_charset_info_alist; +static Lisp_Object Vw32_charset_info_alist; /* VIETNAMESE_CHARSET is not defined in some versions of MSVC. */ #ifndef VIETNAMESE_CHARSET @@ -478,7 +470,7 @@ x_real_positions (f, xptr, yptr) DEFUN ("w32-define-rgb-color", Fw32_define_rgb_color, Sw32_define_rgb_color, 4, 4, 0, doc: /* Convert RGB numbers to a windows color reference and associate with NAME. -This adds or updates a named color to w32-color-map, making it +This adds or updates a named color to `w32-color-map', making it available for use. The original entry's RGB ref is returned, or nil if the entry is new. */) (red, green, blue, name) @@ -493,7 +485,7 @@ if the entry is new. */) CHECK_NUMBER (blue); CHECK_STRING (name); - XSETINT (rgb, RGB(XUINT (red), XUINT (green), XUINT (blue))); + XSETINT (rgb, RGB (XUINT (red), XUINT (green), XUINT (blue))); BLOCK_INPUT; @@ -518,7 +510,7 @@ if the entry is new. */) DEFUN ("w32-load-color-file", Fw32_load_color_file, Sw32_load_color_file, 1, 1, 0, doc: /* Create an alist of color entries from an external file. -Assign this value to w32-color-map to replace the existing color map. +Assign this value to `w32-color-map' to replace the existing color map. The file should define one named RGB color per line like so: R G B name @@ -836,7 +828,7 @@ DEFUN ("w32-default-color-map", Fw32_default_color_map, Sw32_default_color_map, return (cmap); } -Lisp_Object +static Lisp_Object w32_to_x_color (rgb) Lisp_Object rgb; { @@ -953,7 +945,7 @@ x_to_w32_color (colorname) int size; color = colorname + 1; - size = strlen(color); + size = strlen (color); if (size == 3 || size == 6 || size == 9 || size == 12) { UINT colorval; @@ -971,11 +963,11 @@ x_to_w32_color (colorname) /* The check for 'x' in the following conditional takes into account the fact that strtol allows a "0x" in front of our numbers, and we don't. */ - if (!isxdigit(color[0]) || color[1] == 'x') + if (!isxdigit (color[0]) || color[1] == 'x') break; t = color[size]; color[size] = '\0'; - value = strtoul(color, &end, 16); + value = strtoul (color, &end, 16); color[size] = t; if (errno == ERANGE || end - color != size) break; @@ -1005,7 +997,7 @@ x_to_w32_color (colorname) } } } - else if (strnicmp(colorname, "rgb:", 4) == 0) + else if (strnicmp (colorname, "rgb:", 4) == 0) { char *color; UINT colorval; @@ -1022,9 +1014,9 @@ x_to_w32_color (colorname) /* The check for 'x' in the following conditional takes into account the fact that strtol allows a "0x" in front of our numbers, and we don't. */ - if (!isxdigit(color[0]) || color[1] == 'x') + if (!isxdigit (color[0]) || color[1] == 'x') break; - value = strtoul(color, &end, 16); + value = strtoul (color, &end, 16); if (errno == ERANGE) break; switch (end - color) @@ -1060,7 +1052,7 @@ x_to_w32_color (colorname) color = end + 1; } } - else if (strnicmp(colorname, "rgbi:", 5) == 0) + else if (strnicmp (colorname, "rgbi:", 5) == 0) { /* This is an RGB Intensity specification. */ char *color; @@ -1076,7 +1068,7 @@ x_to_w32_color (colorname) double value; UINT val; - value = strtod(color, &end); + value = strtod (color, &end); if (errno == ERANGE) break; if (value < 0.0 || value > 1.0) @@ -1574,7 +1566,6 @@ x_set_mouse_color (f, arg, oldval) #endif /* TODO */ } -/* Defined in w32term.c. */ void x_set_cursor_color (f, arg, oldval) struct frame *f; @@ -1926,7 +1917,7 @@ x_set_name (f, name, explicit) name = ENCODE_SYSTEM (name); BLOCK_INPUT; - SetWindowText(FRAME_W32_WINDOW (f), SDATA (name)); + SetWindowText (FRAME_W32_WINDOW (f), SDATA (name)); UNBLOCK_INPUT; } } @@ -1978,7 +1969,7 @@ x_set_title (f, name, old_name) name = ENCODE_SYSTEM (name); BLOCK_INPUT; - SetWindowText(FRAME_W32_WINDOW (f), SDATA (name)); + SetWindowText (FRAME_W32_WINDOW (f), SDATA (name)); UNBLOCK_INPUT; } } @@ -2025,7 +2016,7 @@ Cursor w32_load_cursor (LPCTSTR name) { /* Try first to load cursor from application resource. */ - Cursor cursor = LoadImage ((HINSTANCE) GetModuleHandle(NULL), + Cursor cursor = LoadImage ((HINSTANCE) GetModuleHandle (NULL), name, IMAGE_CURSOR, 0, 0, LR_DEFAULTCOLOR | LR_DEFAULTSIZE | LR_SHARED); if (!cursor) @@ -2039,7 +2030,7 @@ w32_load_cursor (LPCTSTR name) extern LRESULT CALLBACK w32_wnd_proc (); -BOOL +static BOOL w32_init_class (hinst) HINSTANCE hinst; { @@ -2059,24 +2050,24 @@ w32_init_class (hinst) return (RegisterClass (&wc)); } -HWND +static HWND w32_createscrollbar (f, bar) struct frame *f; struct scroll_bar * bar; { return (CreateWindow ("SCROLLBAR", "", SBS_VERT | WS_CHILD | WS_VISIBLE, /* Position and size of scroll bar. */ - XINT(bar->left) + VERTICAL_SCROLL_BAR_WIDTH_TRIM, - XINT(bar->top), - XINT(bar->width) - VERTICAL_SCROLL_BAR_WIDTH_TRIM * 2, - XINT(bar->height), + XINT (bar->left) + VERTICAL_SCROLL_BAR_WIDTH_TRIM, + XINT (bar->top), + XINT (bar->width) - VERTICAL_SCROLL_BAR_WIDTH_TRIM * 2, + XINT (bar->height), FRAME_W32_WINDOW (f), NULL, hinst, NULL)); } -void +static void w32_createwindow (f) struct frame *f; { @@ -2146,7 +2137,7 @@ w32_createwindow (f) } } -void +static void my_post_msg (wmsg, hwnd, msg, wParam, lParam) W32Msg * wmsg; HWND hwnd; @@ -2378,7 +2369,7 @@ w32_key_to_modifier (int key) return 0; } -unsigned int +static unsigned int w32_get_modifiers () { return ((modifier_set (VK_SHIFT) ? shift_modifier : 0) | @@ -2449,12 +2440,12 @@ map_keypad_keys (unsigned int virt_key, unsigned int extended) } /* List of special key combinations which w32 would normally capture, - but emacs should grab instead. Not directly visible to lisp, to + but Emacs should grab instead. Not directly visible to lisp, to simplify synchronization. Each item is an integer encoding a virtual key code and modifier combination to capture. */ -Lisp_Object w32_grabbed_keys; +static Lisp_Object w32_grabbed_keys; -#define HOTKEY(vk,mods) make_number (((vk) & 255) | ((mods) << 8)) +#define HOTKEY(vk, mods) make_number (((vk) & 255) | ((mods) << 8)) #define HOTKEY_ID(k) (XFASTINT (k) & 0xbfff) #define HOTKEY_VK_CODE(k) (XFASTINT (k) & 255) #define HOTKEY_MODIFIERS(k) (XFASTINT (k) >> 8) @@ -2680,7 +2671,7 @@ complete_deferred_msg (HWND hwnd, UINT msg, LRESULT result) deferred_msg * msg_buf = find_deferred_msg (hwnd, msg); if (msg_buf == NULL) - /* Message may have been cancelled, so don't abort(). */ + /* Message may have been cancelled, so don't abort. */ return; msg_buf->result = result; @@ -2690,7 +2681,7 @@ complete_deferred_msg (HWND hwnd, UINT msg, LRESULT result) PostThreadMessage (dwWindowsThreadId, WM_NULL, 0, 0); } -void +static void cancel_all_deferred_msgs () { deferred_msg * item; @@ -2768,7 +2759,7 @@ post_character_message (hwnd, msg, wParam, lParam, modifiers) /* Detect quit_char and set quit-flag directly. Note that we still need to post a message to ensure the main thread will be - woken up if blocked in sys_select(), but we do NOT want to post + woken up if blocked in sys_select, but we do NOT want to post the quit_char message itself (because it will usually be as if the user had typed quit_char twice). Instead, we post a dummy message that has no particular effect. */ @@ -2923,7 +2914,7 @@ w32_wnd_proc (hwnd, msg, wParam, lParam) /* If GetUpdateRect returns 0 (meaning there is no update region), assume the whole window needs to be repainted. */ - GetClientRect(hwnd, &wmsg.rect); + GetClientRect (hwnd, &wmsg.rect); my_post_msg (&wmsg, hwnd, msg, wParam, lParam); return 0; } @@ -3774,7 +3765,7 @@ w32_wnd_proc (hwnd, msg, wParam, lParam) DWORD scrollbar_extra; RECT wr; - wp.length = sizeof(wp); + wp.length = sizeof (wp); GetWindowRect (hwnd, &wr); enter_crit (); @@ -4251,7 +4242,7 @@ x_default_font_parameter (f, parms) DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame, 1, 1, 0, doc: /* Make a new window, which is called a \"frame\" in Emacs terms. -Returns an Emacs frame object. +Return an Emacs frame object. PARAMETERS is an alist of frame parameters. If the parameters specify that the frame should not have a minibuffer, and do not specify a specific minibuffer window to use, @@ -4621,11 +4612,12 @@ DEFUN ("x-focus-frame", Fx_focus_frame, Sx_focus_frame, 1, 1, 0, /* Return the charset portion of a font name. */ -char * xlfd_charset_of_font (char * fontname) +char * +xlfd_charset_of_font (char * fontname) { char *charset, *encoding; - encoding = strrchr(fontname, '-'); + encoding = strrchr (fontname, '-'); if (!encoding || encoding == fontname) return NULL; @@ -4633,7 +4625,7 @@ char * xlfd_charset_of_font (char * fontname) if (*charset == '-') break; - if (charset == fontname || strcmp(charset, "-*-*") == 0) + if (charset == fontname || strcmp (charset, "-*-*") == 0) return NULL; return charset + 1; @@ -4647,7 +4639,7 @@ static BOOL w32_to_x_font (LOGFONT * lplf, char * lpxstr, int len, static BOOL x_to_w32_font (char *lpxstr, LOGFONT *lplogfont); static struct font_info * -w32_load_system_font (f,fontname,size) +w32_load_system_font (f, fontname, size) struct frame *f; char * fontname; int size; @@ -4750,7 +4742,7 @@ w32_load_system_font (f,fontname,size) GetFontLanguageInfo, we check the properties of the codepage directly, since that is ultimately what we are working from anyway. */ - /* font->double_byte_p = GetFontLanguageInfo(hdc) & GCP_DBCS; */ + /* font->double_byte_p = GetFontLanguageInfo (hdc) & GCP_DBCS; */ CPINFO cpi = {0}; GetCPInfo (codepage, &cpi); font->double_byte_p = cpi.MaxCharSize > 1; @@ -4887,10 +4879,10 @@ w32_load_system_font (f,fontname,size) pointer to the structure font_info while allocating it dynamically. If loading fails, return NULL. */ struct font_info * -w32_load_font (f,fontname,size) -struct frame *f; -char * fontname; -int size; +w32_load_font (f, fontname, size) + struct frame *f; + char * fontname; + int size; { Lisp_Object bdf_fonts; struct font_info *retval = NULL; @@ -4926,7 +4918,7 @@ int size; if (retval) return retval; - return w32_load_system_font(f, fontname, size); + return w32_load_system_font (f, fontname, size); } @@ -4940,7 +4932,7 @@ w32_unload_font (dpyinfo, font) if (font->per_char) xfree (font->per_char); if (font->bdf) w32_free_bdf_font (font->bdf); - if (font->hfont) DeleteObject(font->hfont); + if (font->hfont) DeleteObject (font->hfont); xfree (font); } } @@ -4974,16 +4966,16 @@ x_to_w32_weight (lpw) { if (!lpw) return (FW_DONTCARE); - if (stricmp (lpw,"heavy") == 0) return FW_HEAVY; - else if (stricmp (lpw,"extrabold") == 0) return FW_EXTRABOLD; - else if (stricmp (lpw,"bold") == 0) return FW_BOLD; - else if (stricmp (lpw,"demibold") == 0) return FW_SEMIBOLD; - else if (stricmp (lpw,"semibold") == 0) return FW_SEMIBOLD; - else if (stricmp (lpw,"medium") == 0) return FW_MEDIUM; - else if (stricmp (lpw,"normal") == 0) return FW_NORMAL; - else if (stricmp (lpw,"light") == 0) return FW_LIGHT; - else if (stricmp (lpw,"extralight") == 0) return FW_EXTRALIGHT; - else if (stricmp (lpw,"thin") == 0) return FW_THIN; + if (stricmp (lpw, "heavy") == 0) return FW_HEAVY; + else if (stricmp (lpw, "extrabold") == 0) return FW_EXTRABOLD; + else if (stricmp (lpw, "bold") == 0) return FW_BOLD; + else if (stricmp (lpw, "demibold") == 0) return FW_SEMIBOLD; + else if (stricmp (lpw, "semibold") == 0) return FW_SEMIBOLD; + else if (stricmp (lpw, "medium") == 0) return FW_MEDIUM; + else if (stricmp (lpw, "normal") == 0) return FW_NORMAL; + else if (stricmp (lpw, "light") == 0) return FW_LIGHT; + else if (stricmp (lpw, "extralight") == 0) return FW_EXTRALIGHT; + else if (stricmp (lpw, "thin") == 0) return FW_THIN; else return FW_DONTCARE; } @@ -5033,12 +5025,12 @@ x_to_w32_charset (lpcs) Format of each entry is (CHARSET_NAME . (WINDOWS_CHARSET . CODEPAGE)). */ - this_entry = Fassoc (build_string(charset), Vw32_charset_info_alist); + this_entry = Fassoc (build_string (charset), Vw32_charset_info_alist); - if (NILP(this_entry)) + if (NILP (this_entry)) { /* At startup, we want iso8859-1 fonts to come up properly. */ - if (stricmp(charset, "iso8859-1") == 0) + if (stricmp (charset, "iso8859-1") == 0) return ANSI_CHARSET; else return DEFAULT_CHARSET; @@ -5121,7 +5113,7 @@ w32_to_x_charset (fncharset, matching) case ANSI_CHARSET: /* Handle startup case of w32-charset-info-alist not being set up yet. */ - if (NILP(Vw32_charset_info_alist)) + if (NILP (Vw32_charset_info_alist)) return "iso8859-1"; charset_type = Qw32_charset_ansi; break; @@ -5315,7 +5307,7 @@ w32_to_all_x_charsets (fncharset) case ANSI_CHARSET: /* Handle startup case of w32-charset-info-alist not being set up yet. */ - if (NILP(Vw32_charset_info_alist)) + if (NILP (Vw32_charset_info_alist)) return Fcons (build_string ("iso8859-1"), Qnil); charset_type = Qw32_charset_ansi; @@ -5543,6 +5535,9 @@ w32_to_x_font (lplogfont, lpxstr, len, specific_charset) strlen(lplogfont->lfFaceName), Qnil); fontname = coding.destination; + fontname = alloca (sizeof (*fontname) * bufsz); + decode_coding (&coding, lplogfont->lfFaceName, fontname, + strlen (lplogfont->lfFaceName), bufsz - 1); *(fontname + coding.produced) = '\0'; /* Replace dashes with underscores so the dashes are not @@ -5754,7 +5749,7 @@ x_to_w32_font (lpxstr, lplogfont) if (fields > 0) { - strncpy (lplogfont->lfFaceName,name, LF_FACESIZE); + strncpy (lplogfont->lfFaceName, name, LF_FACESIZE); lplogfont->lfFaceName[LF_FACESIZE-1] = 0; } else @@ -5953,7 +5948,7 @@ w32_font_match (fontname, pattern) } return (fast_string_match_ignore_case (build_string (regex), - build_string(font_name_copy)) >= 0); + build_string (font_name_copy)) >= 0); } /* Callback functions, and a structure holding info they need, for @@ -6189,7 +6184,8 @@ enum_fontex_cb1 (lplf, lptm, font_type, lpef) /* Interface to fontset handler. (adapted from mw32font.c in Meadow and xterm.c in Emacs 20.3) */ -static Lisp_Object w32_list_bdf_fonts (Lisp_Object pattern, int max_names) +static Lisp_Object +w32_list_bdf_fonts (Lisp_Object pattern, int max_names) { char *fontname, *ptnstr; Lisp_Object list, tem, newlist = Qnil; @@ -6260,7 +6256,7 @@ w32_list_fonts (f, pattern, size, maxnames) codepage = w32_codepage_for_font (SDATA (tpat)); if (codepage != CP_8BIT && codepage != CP_UNICODE && codepage != CP_DEFAULT && codepage != CP_UNKNOWN - && !IsValidCodePage(codepage)) + && !IsValidCodePage (codepage)) continue; /* See if we cached the result for this particular query. @@ -6371,7 +6367,7 @@ w32_list_fonts (f, pattern, size, maxnames) XSETCDR (tem, make_number (0)); SelectObject (hdc, oldobj); ReleaseDC (dpyinfo->root_window, hdc); - DeleteObject(thisinfo.hfont); + DeleteObject (thisinfo.hfont); UNBLOCK_INPUT; } found_size = XINT (XCDR (tem)); @@ -6420,7 +6416,7 @@ w32_list_fonts (f, pattern, size, maxnames) Lisp_Object combined[2]; combined[0] = w32_list_bdf_fonts (pattern, maxnames - n_fonts); combined[1] = newlist; - newlist = Fnconc(2, combined); + newlist = Fnconc (2, combined); } return newlist; @@ -6447,7 +6443,7 @@ w32_query_font (struct frame *f, char *fontname) for (i = 0; i < one_w32_display_info.n_fonts ;i++, pfi++) { - if (stricmp(pfi->name, fontname) == 0) return pfi; + if (stricmp (pfi->name, fontname) == 0) return pfi; } return NULL; @@ -6484,7 +6480,7 @@ w32_find_ccl_program (fontp) } /* directory-files from dired.c. */ -Lisp_Object Fdirectory_files P_((Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object)); +Lisp_Object Fdirectory_files P_ ((Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object)); /* Find BDF files in a specified directory. (use GCPRO when calling, @@ -6495,13 +6491,13 @@ w32_find_bdf_fonts_in_dir (Lisp_Object directory) Lisp_Object filelist, list = Qnil; char fontname[100]; - if (!STRINGP(directory)) + if (!STRINGP (directory)) return Qnil; filelist = Fdirectory_files (directory, Qt, build_string (".*\\.[bB][dD][fF]"), Qt); - for ( ; CONSP(filelist); filelist = XCDR (filelist)) + for ( ; CONSP (filelist); filelist = XCDR (filelist)) { Lisp_Object filename = XCAR (filelist); if (w32_BDF_to_x_font (SDATA (filename), fontname, 100)) @@ -6531,8 +6527,8 @@ in the list. DIRECTORY may be a list of directories. */) pair[0] = list; pair[1] = Qnil; GCPRO2 (directory, list); - pair[1] = w32_find_bdf_fonts_in_dir( XCAR (directory) ); - list = Fnconc( 2, pair ); + pair[1] = w32_find_bdf_fonts_in_dir ( XCAR (directory) ); + list = Fnconc ( 2, pair ); UNGCPRO; } return list; @@ -6609,7 +6605,7 @@ If omitted or nil, that stands for the selected frame's display. */) DEFUN ("x-display-pixel-width", Fx_display_pixel_width, Sx_display_pixel_width, 0, 1, 0, - doc: /* Returns the width in pixels of DISPLAY. + doc: /* Return the width in pixels of DISPLAY. The optional argument DISPLAY specifies which display to ask about. DISPLAY should be either a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) @@ -6623,7 +6619,7 @@ If omitted or nil, that stands for the selected frame's display. */) DEFUN ("x-display-pixel-height", Fx_display_pixel_height, Sx_display_pixel_height, 0, 1, 0, - doc: /* Returns the height in pixels of DISPLAY. + doc: /* Return the height in pixels of DISPLAY. The optional argument DISPLAY specifies which display to ask about. DISPLAY should be either a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) @@ -6637,7 +6633,7 @@ If omitted or nil, that stands for the selected frame's display. */) DEFUN ("x-display-planes", Fx_display_planes, Sx_display_planes, 0, 1, 0, - doc: /* Returns the number of bitplanes of DISPLAY. + doc: /* Return the number of bitplanes of DISPLAY. The optional argument DISPLAY specifies which display to ask about. DISPLAY should be either a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) @@ -6651,7 +6647,7 @@ If omitted or nil, that stands for the selected frame's display. */) DEFUN ("x-display-color-cells", Fx_display_color_cells, Sx_display_color_cells, 0, 1, 0, - doc: /* Returns the number of color cells of DISPLAY. + doc: /* Return the number of color cells of DISPLAY. The optional argument DISPLAY specifies which display to ask about. DISPLAY should be either a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) @@ -6671,7 +6667,7 @@ If omitted or nil, that stands for the selected frame's display. */) /* We force 24+ bit depths to 24-bit, both to prevent an overflow and because probably is more meaningful on Windows anyway */ if (cap < 0) - cap = 1 << min(dpyinfo->n_planes * dpyinfo->n_cbits, 24); + cap = 1 << min (dpyinfo->n_planes * dpyinfo->n_cbits, 24); ReleaseDC (dpyinfo->root_window, hdc); @@ -6681,7 +6677,7 @@ If omitted or nil, that stands for the selected frame's display. */) DEFUN ("x-server-max-request-size", Fx_server_max_request_size, Sx_server_max_request_size, 0, 1, 0, - doc: /* Returns the maximum request size of the server of DISPLAY. + doc: /* Return the maximum request size of the server of DISPLAY. The optional argument DISPLAY specifies which display to ask about. DISPLAY should be either a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) @@ -6694,7 +6690,7 @@ If omitted or nil, that stands for the selected frame's display. */) } DEFUN ("x-server-vendor", Fx_server_vendor, Sx_server_vendor, 0, 1, 0, - doc: /* Returns the "vendor ID" string of the W32 system (Microsoft). + doc: /* Return the "vendor ID" string of the W32 system (Microsoft). The optional argument DISPLAY specifies which display to ask about. DISPLAY should be either a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) @@ -6705,10 +6701,10 @@ If omitted or nil, that stands for the selected frame's display. */) } DEFUN ("x-server-version", Fx_server_version, Sx_server_version, 0, 1, 0, - doc: /* Returns the version numbers of the server of DISPLAY. + doc: /* Return the version numbers of the server of DISPLAY. The value is a list of three integers: the major and minor -version numbers of the X Protocol in use, and the distributor-specific release -number. See also the function `x-server-vendor'. +version numbers of the X Protocol in use, and the distributor-specific +release number. See also the function `x-server-vendor'. The optional argument DISPLAY specifies which display to ask about. DISPLAY should be either a frame or a display name (a string). @@ -6722,7 +6718,7 @@ If omitted or nil, that stands for the selected frame's display. */) } DEFUN ("x-display-screens", Fx_display_screens, Sx_display_screens, 0, 1, 0, - doc: /* Returns the number of screens on the server of DISPLAY. + doc: /* Return the number of screens on the server of DISPLAY. The optional argument DISPLAY specifies which display to ask about. DISPLAY should be either a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) @@ -6734,7 +6730,7 @@ If omitted or nil, that stands for the selected frame's display. */) DEFUN ("x-display-mm-height", Fx_display_mm_height, Sx_display_mm_height, 0, 1, 0, - doc: /* Returns the height in millimeters of DISPLAY. + doc: /* Return the height in millimeters of DISPLAY. The optional argument DISPLAY specifies which display to ask about. DISPLAY should be either a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) @@ -6755,7 +6751,7 @@ If omitted or nil, that stands for the selected frame's display. */) } DEFUN ("x-display-mm-width", Fx_display_mm_width, Sx_display_mm_width, 0, 1, 0, - doc: /* Returns the width in millimeters of DISPLAY. + doc: /* Return the width in millimeters of DISPLAY. The optional argument DISPLAY specifies which display to ask about. DISPLAY should be either a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) @@ -6778,7 +6774,7 @@ If omitted or nil, that stands for the selected frame's display. */) DEFUN ("x-display-backing-store", Fx_display_backing_store, Sx_display_backing_store, 0, 1, 0, - doc: /* Returns an indication of whether DISPLAY does backing store. + doc: /* Return an indication of whether DISPLAY does backing store. The value may be `always', `when-mapped', or `not-useful'. The optional argument DISPLAY specifies which display to ask about. DISPLAY should be either a frame or a display name (a string). @@ -6791,7 +6787,7 @@ If omitted or nil, that stands for the selected frame's display. */) DEFUN ("x-display-visual-class", Fx_display_visual_class, Sx_display_visual_class, 0, 1, 0, - doc: /* Returns the visual class of DISPLAY. + doc: /* Return the visual class of DISPLAY. The value is one of the symbols `static-gray', `gray-scale', `static-color', `pseudo-color', `true-color', or `direct-color'. @@ -6818,7 +6814,7 @@ If omitted or nil, that stands for the selected frame's display. */) DEFUN ("x-display-save-under", Fx_display_save_under, Sx_display_save_under, 0, 1, 0, - doc: /* Returns t if DISPLAY supports the save-under feature. + doc: /* Return t if DISPLAY supports the save-under feature. The optional argument DISPLAY specifies which display to ask about. DISPLAY should be either a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) @@ -6934,7 +6930,7 @@ terminate Emacs if we can't open the connection. */) Lisp_Object color_file; struct gcpro gcpro1; - color_file = build_string("~/rgb.txt"); + color_file = build_string ("~/rgb.txt"); GCPRO1 (color_file); @@ -8192,7 +8188,7 @@ If ONLY-DIR-P is non-nil, the user can only select directories. */) *last = '\0'; } - file = DECODE_FILE(build_string (filename)); + file = DECODE_FILE (build_string (filename)); } /* User cancelled the dialog without making a selection. */ else if (!CommDlgExtendedError ()) @@ -8223,7 +8219,7 @@ If ONLY-DIR-P is non-nil, the user can only select directories. */) DEFUN ("w32-select-font", Fw32_select_font, Sw32_select_font, 0, 2, 0, doc: /* Select a font for the named FRAME using the W32 font dialog. -Returns an X-style font string corresponding to the selection. +Return an X-style font string corresponding to the selection. If FRAME is omitted or nil, it defaults to the selected frame. If INCLUDE-PROPORTIONAL is non-nil, include proportional fonts @@ -8327,13 +8323,13 @@ DOCUMENT is typically the name of a document file or a URL, but can also be a program executable to run, or a directory to open in the Windows Explorer. -If DOCUMENT is a program executable, the optional arg PARAMETERS can -be a string containing command line parameters that will be passed to -the program; otherwise, PARAMETERS should be nil or unspecified. +If DOCUMENT is a program executable, the optional third arg PARAMETERS +can be a string containing command line parameters that will be passed +to the program; otherwise, PARAMETERS should be nil or unspecified. -Second optional argument SHOW-FLAG can be used to control how the +Optional fourth argument SHOW-FLAG can be used to control how the application will be displayed when it is invoked. If SHOW-FLAG is nil -or unspceified, the application is displayed normally, otherwise it is +or unspecified, the application is displayed normally, otherwise it is an integer representing a ShowWindow flag: 0 - start hidden @@ -8470,7 +8466,7 @@ The return value is the hotkey-id if registered, otherwise nil. */) { key = w32_parse_hot_key (key); - if (NILP (Fmemq (key, w32_grabbed_keys))) + if (!NILP (key) && NILP (Fmemq (key, w32_grabbed_keys))) { /* Reuse an empty slot if possible. */ Lisp_Object item = Fmemq (Qnil, w32_grabbed_keys); @@ -8518,7 +8514,6 @@ DEFUN ("w32-unregister-hot-key", Fw32_unregister_hot_key, #else if (PostThreadMessage (dwWindowsThreadId, WM_EMACS_UNREGISTER_HOT_KEY, (WPARAM) XINT (XCAR (item)), (LPARAM) item)) - #endif { MSG msg; @@ -8534,7 +8529,7 @@ DEFUN ("w32-registered-hot-keys", Fw32_registered_hot_keys, doc: /* Return list of registered hot-key IDs. */) () { - return Fcopy_sequence (w32_grabbed_keys); + return Fdelq (Qnil, Fcopy_sequence (w32_grabbed_keys)); } DEFUN ("w32-reconstruct-hot-key", Fw32_reconstruct_hot_key, @@ -8697,10 +8692,10 @@ If the underlying system call fails, value is nil. */) LARGE_INTEGER freebytes; LARGE_INTEGER totalbytes; - if (pfn_GetDiskFreeSpaceEx(rootname, - (ULARGE_INTEGER *)&availbytes, - (ULARGE_INTEGER *)&totalbytes, - (ULARGE_INTEGER *)&freebytes)) + if (pfn_GetDiskFreeSpaceEx (rootname, + (ULARGE_INTEGER *)&availbytes, + (ULARGE_INTEGER *)&totalbytes, + (ULARGE_INTEGER *)&freebytes)) value = list3 (make_float ((double) totalbytes.QuadPart), make_float ((double) freebytes.QuadPart), make_float ((double) availbytes.QuadPart)); @@ -8712,11 +8707,11 @@ If the underlying system call fails, value is nil. */) DWORD free_clusters; DWORD total_clusters; - if (GetDiskFreeSpace(rootname, - §ors_per_cluster, - &bytes_per_sector, - &free_clusters, - &total_clusters)) + if (GetDiskFreeSpace (rootname, + §ors_per_cluster, + &bytes_per_sector, + &free_clusters, + &total_clusters)) value = list3 (make_float ((double) total_clusters * sectors_per_cluster * bytes_per_sector), make_float ((double) free_clusters @@ -8762,12 +8757,12 @@ DEFUN ("default-printer-name", Fdefault_printer_name, Sdefault_printer_name, ClosePrinter (hPrn); return Qnil; } - /* Call GetPrinter() again with big enouth memory block */ + /* Call GetPrinter again with big enouth memory block */ err = GetPrinter (hPrn, 2, (LPBYTE)ppi2, dwNeeded, &dwReturned); ClosePrinter (hPrn); if (!err) { - xfree(ppi2); + xfree (ppi2); return Qnil; } @@ -8777,23 +8772,23 @@ DEFUN ("default-printer-name", Fdefault_printer_name, Sdefault_printer_name, { /* a remote printer */ if (*ppi2->pServerName == '\\') - _snprintf(pname_buf, sizeof (pname_buf), "%s\\%s", ppi2->pServerName, - ppi2->pShareName); + _snprintf (pname_buf, sizeof (pname_buf), "%s\\%s", ppi2->pServerName, + ppi2->pShareName); else - _snprintf(pname_buf, sizeof (pname_buf), "\\\\%s\\%s", ppi2->pServerName, - ppi2->pShareName); + _snprintf (pname_buf, sizeof (pname_buf), "\\\\%s\\%s", ppi2->pServerName, + ppi2->pShareName); pname_buf[sizeof (pname_buf) - 1] = '\0'; } else { /* a local printer */ - strncpy(pname_buf, ppi2->pPortName, sizeof (pname_buf)); + strncpy (pname_buf, ppi2->pPortName, sizeof (pname_buf)); pname_buf[sizeof (pname_buf) - 1] = '\0'; /* `pPortName' can include several ports, delimited by ','. * we only use the first one. */ - strtok(pname_buf, ","); + strtok (pname_buf, ","); } - xfree(ppi2); + xfree (ppi2); } return build_string (pname_buf); @@ -9023,7 +9018,7 @@ system to handle them. */); &w32_pass_multimedia_buttons_to_system, doc: /* If non-nil, media buttons are passed to Windows. Some modern keyboards contain buttons for controlling media players, web -browsers and other applications. Generally these buttons are handled on a +browsers and other applications. Generally these buttons are handled on a system wide basis, but by setting this to nil they are made available to Emacs for binding. Depending on your keyboard, additional keys that may be available are: @@ -9039,8 +9034,7 @@ media-play, media-pause, media-record, media-fast-forward, media-rewind, media-channel-up, media-channel-down, volume-mute, volume-up, volume-down, mic-volume-mute, mic-volume-down, mic-volume-up, mic-toggle, -bass-down, bass-boost, bass-up, treble-down, treble-up - */); +bass-down, bass-boost, bass-up, treble-down, treble-up */); w32_pass_multimedia_buttons_to_system = 1; DEFVAR_LISP ("x-pointer-shape", &Vx_pointer_shape, @@ -9069,14 +9063,14 @@ Value must be an integer or float. */); Vhourglass_delay = make_number (DEFAULT_HOURGLASS_DELAY); DEFVAR_LISP ("x-sensitive-text-pointer-shape", - &Vx_sensitive_text_pointer_shape, + &Vx_sensitive_text_pointer_shape, doc: /* The shape of the pointer when over mouse-sensitive text. This variable takes effect when you create a new frame or when you set the mouse color. */); Vx_sensitive_text_pointer_shape = Qnil; DEFVAR_LISP ("x-window-horizontal-drag-cursor", - &Vx_window_horizontal_drag_shape, + &Vx_window_horizontal_drag_shape, doc: /* Pointer shape to use for indicating a window can be dragged horizontally. This variable takes effect when you create a new frame or when you set the mouse color. */); @@ -9282,7 +9276,8 @@ versions of Windows) characters. */); variable initialized is 0 and directly from main when initialized is non zero. */ -void globals_of_w32fns () +void +globals_of_w32fns () { HMODULE user32_lib = GetModuleHandle ("user32.dll"); /* @@ -9313,7 +9308,7 @@ void globals_of_w32fns () #undef abort void -w32_abort() +w32_abort () { int button; button = MessageBox (NULL, @@ -9341,7 +9336,7 @@ w32_abort() /* For convenience when debugging. */ int -w32_last_error() +w32_last_error () { return GetLastError (); } diff --git a/src/w32proc.c b/src/w32proc.c index 6c5f9b89f77..7ce01aa3e50 100644 --- a/src/w32proc.c +++ b/src/w32proc.c @@ -782,7 +782,14 @@ sys_spawnve (int mode, char *cmdname, char **argv, char **envp) variable in their environment. */ char ppid_env_var_buffer[64]; char *extra_env[] = {ppid_env_var_buffer, NULL}; - char *sepchars = " \t"; + /* These are the characters that cause an argument to need quoting. + Arguments with whitespace characters need quoting to prevent the + argument being split into two or more. Arguments with wildcards + are also quoted, for consistency with posix platforms, where wildcards + are not expanded if we run the program directly without a shell. + Some extra whitespace characters need quoting in Cygwin programs, + so this list is conditionally modified below. */ + char *sepchars = " \t*?"; /* We don't care about the other modes */ if (mode != _P_NOWAIT) diff --git a/src/w32term.h b/src/w32term.h index df0328ba410..75ff9f71e4a 100644 --- a/src/w32term.h +++ b/src/w32term.h @@ -768,7 +768,6 @@ struct face; XGCValues *XCreateGC (void *, Window, unsigned long, XGCValues *); struct frame * check_x_frame (Lisp_Object); -Lisp_Object vga_stdcolor_name (int); EXFUN (Fx_display_color_p, 1); EXFUN (Fx_display_grayscale_p, 1); diff --git a/src/window.c b/src/window.c index a377ff76718..129a553f65d 100644 --- a/src/window.c +++ b/src/window.c @@ -6053,8 +6053,6 @@ struct save_window_data { EMACS_UINT size; struct Lisp_Vector *next_from_Lisp_Vector_struct; - Lisp_Object frame_cols, frame_lines, frame_menu_bar_lines; - Lisp_Object frame_tool_bar_lines; Lisp_Object selected_frame; Lisp_Object current_window; Lisp_Object current_buffer; @@ -6062,12 +6060,18 @@ struct save_window_data Lisp_Object minibuf_selected_window; Lisp_Object root_window; Lisp_Object focus_frame; - /* Record the values of window-min-width and window-min-height - so that window sizes remain consistent with them. */ - Lisp_Object min_width, min_height; /* A vector, each of whose elements is a struct saved_window for one window. */ Lisp_Object saved_windows; + + /* All fields above are traced by the GC. + From `fame-cols' down, the fields are ignored by the GC. */ + + int frame_cols, frame_lines, frame_menu_bar_lines; + int frame_tool_bar_lines; + /* Record the values of window-min-width and window-min-height + so that window sizes remain consistent with them. */ + int min_width, min_height; }; /* This is saved as a Lisp_Vector */ @@ -6207,18 +6211,20 @@ the return value is nil. Otherwise the value is t. */) if it runs during this. */ BLOCK_INPUT; - if (XFASTINT (data->frame_lines) != previous_frame_lines - || XFASTINT (data->frame_cols) != previous_frame_cols) - change_frame_size (f, XFASTINT (data->frame_lines), - XFASTINT (data->frame_cols), 0, 0, 0); + if (data->frame_lines != previous_frame_lines + || data->frame_cols != previous_frame_cols) + change_frame_size (f, data->frame_lines, + data->frame_cols, 0, 0, 0); #if defined (HAVE_WINDOW_SYSTEM) || defined (MSDOS) - if (XFASTINT (data->frame_menu_bar_lines) + if (data->frame_menu_bar_lines != previous_frame_menu_bar_lines) - x_set_menu_bar_lines (f, data->frame_menu_bar_lines, make_number (0)); + x_set_menu_bar_lines (f, make_number (data->frame_menu_bar_lines), + make_number (0)); #ifdef HAVE_WINDOW_SYSTEM - if (XFASTINT (data->frame_tool_bar_lines) + if (data->frame_tool_bar_lines != previous_frame_tool_bar_lines) - x_set_tool_bar_lines (f, data->frame_tool_bar_lines, make_number (0)); + x_set_tool_bar_lines (f, make_number (data->frame_tool_bar_lines), + make_number (0)); #endif #endif @@ -6452,8 +6458,8 @@ the return value is nil. Otherwise the value is t. */) Fset_buffer (new_current_buffer); /* Restore the minimum heights recorded in the configuration. */ - window_min_height = XINT (data->min_height); - window_min_width = XINT (data->min_width); + window_min_height = data->min_height; + window_min_width = data->min_width; Vminibuf_scroll_window = data->minibuf_scroll_window; minibuf_selected_window = data->minibuf_selected_window; @@ -6654,7 +6660,6 @@ redirection (see `redirect-frame-focus'). */) register Lisp_Object tem; register int n_windows; register struct save_window_data *data; - register struct Lisp_Vector *vec; register int i; FRAME_PTR f; @@ -6664,14 +6669,13 @@ redirection (see `redirect-frame-focus'). */) f = XFRAME (frame); n_windows = count_windows (XWINDOW (FRAME_ROOT_WINDOW (f))); - vec = allocate_other_vector (VECSIZE (struct save_window_data)); - XSETPVECTYPE (vec, PVEC_WINDOW_CONFIGURATION); - data = (struct save_window_data *)vec; - - XSETFASTINT (data->frame_cols, FRAME_COLS (f)); - XSETFASTINT (data->frame_lines, FRAME_LINES (f)); - XSETFASTINT (data->frame_menu_bar_lines, FRAME_MENU_BAR_LINES (f)); - XSETFASTINT (data->frame_tool_bar_lines, FRAME_TOOL_BAR_LINES (f)); + data = ALLOCATE_PSEUDOVECTOR (struct save_window_data, frame_cols, + PVEC_WINDOW_CONFIGURATION); + + data->frame_cols = FRAME_COLS (f); + data->frame_lines = FRAME_LINES (f); + data->frame_menu_bar_lines = FRAME_MENU_BAR_LINES (f); + data->frame_tool_bar_lines = FRAME_TOOL_BAR_LINES (f); data->selected_frame = selected_frame; data->current_window = FRAME_SELECTED_WINDOW (f); XSETBUFFER (data->current_buffer, current_buffer); @@ -6679,8 +6683,8 @@ redirection (see `redirect-frame-focus'). */) data->minibuf_selected_window = minibuf_level > 0 ? minibuf_selected_window : Qnil; data->root_window = FRAME_ROOT_WINDOW (f); data->focus_frame = FRAME_FOCUS_FRAME (f); - XSETINT (data->min_height, window_min_height); - XSETINT (data->min_width, window_min_width); + data->min_height = window_min_height; + data->min_width = window_min_width; tem = Fmake_vector (make_number (n_windows), Qnil); data->saved_windows = tem; for (i = 0; i < n_windows; i++) @@ -7187,11 +7191,11 @@ compare_window_configurations (c1, c2, ignore_positions) sw1 = XVECTOR (d1->saved_windows); sw2 = XVECTOR (d2->saved_windows); - if (! EQ (d1->frame_cols, d2->frame_cols)) + if (d1->frame_cols != d2->frame_cols) return 0; - if (! EQ (d1->frame_lines, d2->frame_lines)) + if (d1->frame_lines != d2->frame_lines) return 0; - if (! EQ (d1->frame_menu_bar_lines, d2->frame_menu_bar_lines)) + if (d1->frame_menu_bar_lines != d2->frame_menu_bar_lines) return 0; if (! EQ (d1->selected_frame, d2->selected_frame)) return 0; @@ -7213,9 +7217,9 @@ compare_window_configurations (c1, c2, ignore_positions) if everything else compares equal. */ if (! EQ (d1->focus_frame, d2->focus_frame)) return 0; - if (! EQ (d1->min_width, d2->min_width)) + if (d1->min_width != d2->min_width) return 0; - if (! EQ (d1->min_height, d2->min_height)) + if (d1->min_height != d2->min_height) return 0; /* Verify that the two confis have the same number of windows. */ diff --git a/src/xdisp.c b/src/xdisp.c index 9c79684e438..fbf7569583a 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -24494,8 +24494,12 @@ If you want scrolling to always be a line at a time, you should set DEFVAR_INT ("scroll-conservatively", &scroll_conservatively, doc: /* *Scroll up to this many lines, to bring point back on screen. -A value of zero means to scroll the text to center point vertically -in the window. */); +If point moves off-screen, redisplay will scroll by up to +`scroll-conservatively' lines in order to bring point just barely +onto the screen again. If that cannot be done, then redisplay +recenters point as usual. + +A value of zero means always recenter point if it moves off screen. */); scroll_conservatively = 0; DEFVAR_INT ("scroll-margin", &scroll_margin, diff --git a/src/xfaces.c b/src/xfaces.c index f43054fe06a..853a3867f63 100644 --- a/src/xfaces.c +++ b/src/xfaces.c @@ -1474,10 +1474,6 @@ tty_color_name (f, idx) if (idx == FACE_TTY_DEFAULT_BG_COLOR) return build_string (unspecified_bg); -#ifdef WINDOWSNT - return vga_stdcolor_name (idx); -#endif - return Qunspecified; } @@ -7948,13 +7944,11 @@ map_tty_color (f, face, idx, defaulted) { pixel = load_color (f, face, color, idx); -#if defined (MSDOS) || defined (WINDOWSNT) +#ifdef MSDOS /* If the foreground of the default face is the default color, use the foreground color defined by the frame. */ -#ifdef MSDOS if (FRAME_MSDOS_P (f)) { -#endif /* MSDOS */ if (pixel == default_pixel || pixel == FACE_TTY_DEFAULT_COLOR) { @@ -7974,10 +7968,8 @@ map_tty_color (f, face, idx, defaulted) face->lface[idx] = tty_color_name (f, pixel); *defaulted = 1; } -#ifdef MSDOS - } -#endif -#endif /* MSDOS or WINDOWSNT */ + } +#endif /* MSDOS */ } if (foreground_p) diff --git a/src/xfns.c b/src/xfns.c index 95efa697110..8239fc3475c 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -938,7 +938,7 @@ x_set_background_color (f, arg, oldval) !NILP (bar); bar = XSCROLL_BAR (bar)->next) { - Window window = SCROLL_BAR_X_WINDOW (XSCROLL_BAR (bar)); + Window window = XSCROLL_BAR (bar)->x_window; XSetWindowBackground (dpy, window, bg); } } @@ -3205,7 +3205,7 @@ x_default_font_parameter (f, parms) DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame, 1, 1, 0, doc: /* Make a new X window, which is called a "frame" in Emacs terms. -Returns an Emacs frame object. +Return an Emacs frame object. ALIST is an alist of frame parameters. If the parameters specify that the frame should not have a minibuffer, and do not specify a specific minibuffer window to use, @@ -3798,7 +3798,7 @@ If omitted or nil, that stands for the selected frame's display. */) DEFUN ("x-display-pixel-width", Fx_display_pixel_width, Sx_display_pixel_width, 0, 1, 0, - doc: /* Returns the width in pixels of the X display TERMINAL. + doc: /* Return the width in pixels of the X display TERMINAL. The optional argument TERMINAL specifies which display to ask about. TERMINAL should be a terminal id, a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) @@ -3812,7 +3812,7 @@ If omitted or nil, that stands for the selected frame's display. */) DEFUN ("x-display-pixel-height", Fx_display_pixel_height, Sx_display_pixel_height, 0, 1, 0, - doc: /* Returns the height in pixels of the X display TERMINAL. + doc: /* Return the height in pixels of the X display TERMINAL. The optional argument TERMINAL specifies which display to ask about. TERMINAL should be a terminal id, a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) @@ -3826,7 +3826,7 @@ If omitted or nil, that stands for the selected frame's display. */) DEFUN ("x-display-planes", Fx_display_planes, Sx_display_planes, 0, 1, 0, - doc: /* Returns the number of bitplanes of the X display TERMINAL. + doc: /* Return the number of bitplanes of the X display TERMINAL. The optional argument TERMINAL specifies which display to ask about. TERMINAL should be a terminal id, a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) @@ -3840,7 +3840,7 @@ If omitted or nil, that stands for the selected frame's display. */) DEFUN ("x-display-color-cells", Fx_display_color_cells, Sx_display_color_cells, 0, 1, 0, - doc: /* Returns the number of color cells of the X display TERMINAL. + doc: /* Return the number of color cells of the X display TERMINAL. The optional argument TERMINAL specifies which display to ask about. TERMINAL should be a terminal id, a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) @@ -3865,7 +3865,7 @@ If omitted or nil, that stands for the selected frame's display. */) DEFUN ("x-server-max-request-size", Fx_server_max_request_size, Sx_server_max_request_size, 0, 1, 0, - doc: /* Returns the maximum request size of the X server of display TERMINAL. + doc: /* Return the maximum request size of the X server of display TERMINAL. The optional argument TERMINAL specifies which display to ask about. TERMINAL should be a terminal id, a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) @@ -3878,7 +3878,7 @@ If omitted or nil, that stands for the selected frame's display. */) } DEFUN ("x-server-vendor", Fx_server_vendor, Sx_server_vendor, 0, 1, 0, - doc: /* Returns the "vendor ID" string of the X server of display TERMINAL. + doc: /* Return the "vendor ID" string of the X server of display TERMINAL. \(Labelling every distributor as a "vendor" embodies the false assumption that operating systems cannot be developed and distributed noncommercially.) The optional argument TERMINAL specifies which display to ask about. @@ -3895,7 +3895,7 @@ If omitted or nil, that stands for the selected frame's display. */) } DEFUN ("x-server-version", Fx_server_version, Sx_server_version, 0, 1, 0, - doc: /* Returns the version numbers of the X server of display TERMINAL. + doc: /* Return the version numbers of the X server of display TERMINAL. The value is a list of three integers: the major and minor version numbers of the X Protocol in use, and the distributor-specific release number. See also the function `x-server-vendor'. @@ -3955,7 +3955,7 @@ If omitted or nil, that stands for the selected frame's display. */) DEFUN ("x-display-backing-store", Fx_display_backing_store, Sx_display_backing_store, 0, 1, 0, - doc: /* Returns an indication of whether X display TERMINAL does backing store. + doc: /* Return an indication of whether X display TERMINAL does backing store. The value may be `always', `when-mapped', or `not-useful'. The optional argument TERMINAL specifies which display to ask about. TERMINAL should be a terminal id, a frame or a display name (a string). @@ -4033,7 +4033,7 @@ If omitted or nil, that stands for the selected frame's display. */) DEFUN ("x-display-save-under", Fx_display_save_under, Sx_display_save_under, 0, 1, 0, - doc: /* Returns t if the X display TERMINAL supports the save-under feature. + doc: /* Return t if the X display TERMINAL supports the save-under feature. The optional argument TERMINAL specifies which display to ask about. TERMINAL should be a terminal id, a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) diff --git a/src/xterm.c b/src/xterm.c index 55185fb57f2..023d0194c59 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -4209,7 +4209,7 @@ x_window_to_scroll_bar (display, window_id) condemned = Qnil, ! NILP (bar)); bar = XSCROLL_BAR (bar)->next) - if (SCROLL_BAR_X_WINDOW (XSCROLL_BAR (bar)) == window_id && + if (XSCROLL_BAR (bar)->x_window == window_id && FRAME_X_DISPLAY (XFRAME (frame)) == display) return XSCROLL_BAR (bar); } @@ -4525,9 +4525,8 @@ xm_scroll_callback (widget, client_data, call_data) } } +#elif defined USE_GTK -#else /* !USE_MOTIF, i.e. Xaw or GTK */ -#ifdef USE_GTK /* Scroll bar callback for GTK scroll bars. WIDGET is the scroll bar widget. DATA is a pointer to the scroll_bar structure. */ @@ -4598,7 +4597,7 @@ xg_scroll_callback (widget, data) } } -#else /* not USE_GTK */ +#else /* not USE_GTK and not USE_MOTIF */ /* Xaw scroll bar callback. Invoked when the thumb is dragged. WIDGET is the scroll bar widget. CLIENT_DATA is a pointer to the @@ -4681,8 +4680,7 @@ xaw_scroll_callback (widget, client_data, call_data) x_send_scroll_bar_event (bar->window, part, position, height); } -#endif /* not USE_GTK */ -#endif /* not USE_MOTIF */ +#endif /* not USE_GTK and not USE_MOTIF */ #define SCROLL_BAR_NAME "verticalScrollBar" @@ -4888,7 +4886,7 @@ x_create_toolkit_scroll_bar (f, bar) /* Remember X window and widget in the scroll bar vector. */ SET_SCROLL_BAR_X_WIDGET (bar, widget); xwindow = XtWindow (widget); - SET_SCROLL_BAR_X_WINDOW (bar, xwindow); + bar->x_window = xwindow; UNBLOCK_INPUT; } @@ -5032,7 +5030,7 @@ x_scroll_bar_create (w, top, left, width, height) { struct frame *f = XFRAME (w->frame); struct scroll_bar *bar - = XSCROLL_BAR (Fmake_vector (make_number (SCROLL_BAR_VEC_SIZE), Qnil)); + = ALLOCATE_PSEUDOVECTOR (struct scroll_bar, x_window, PVEC_OTHER); BLOCK_INPUT; @@ -5076,21 +5074,19 @@ x_scroll_bar_create (w, top, left, width, height) CopyFromParent, /* Attributes. */ mask, &a); - SET_SCROLL_BAR_X_WINDOW (bar, window); + bar->x_window = window; } #endif /* not USE_TOOLKIT_SCROLL_BARS */ XSETWINDOW (bar->window, w); - XSETINT (bar->top, top); - XSETINT (bar->left, left); - XSETINT (bar->width, width); - XSETINT (bar->height, height); - XSETINT (bar->start, 0); - XSETINT (bar->end, 0); + bar->top = top; + bar->left = left; + bar->width = width; + bar->height = height; + bar->start = 0; + bar->end = 0; bar->dragging = Qnil; -#ifdef USE_TOOLKIT_SCROLL_BARS - bar->fringe_extended_p = Qnil; -#endif + bar->fringe_extended_p = 0; /* Add bar to its frame's list of scroll bars. */ bar->next = FRAME_SCROLL_BARS (f); @@ -5104,12 +5100,12 @@ x_scroll_bar_create (w, top, left, width, height) { #ifdef USE_GTK xg_update_scrollbar_pos (f, - SCROLL_BAR_X_WINDOW (bar), + bar->x_window, top, left + VERTICAL_SCROLL_BAR_WIDTH_TRIM, width - VERTICAL_SCROLL_BAR_WIDTH_TRIM * 2, max (height, 1)); - xg_show_scroll_bar (SCROLL_BAR_X_WINDOW (bar)); + xg_show_scroll_bar (bar->x_window); #else /* not USE_GTK */ Widget scroll_bar = SCROLL_BAR_X_WIDGET (FRAME_X_DISPLAY (f), bar); XtConfigureWidget (scroll_bar, @@ -5121,7 +5117,7 @@ x_scroll_bar_create (w, top, left, width, height) #endif /* not USE_GTK */ } #else /* not USE_TOOLKIT_SCROLL_BARS */ - XMapRaised (FRAME_X_DISPLAY (f), SCROLL_BAR_X_WINDOW (bar)); + XMapRaised (FRAME_X_DISPLAY (f), bar->x_window); #endif /* not USE_TOOLKIT_SCROLL_BARS */ UNBLOCK_INPUT; @@ -5129,6 +5125,8 @@ x_scroll_bar_create (w, top, left, width, height) } +#ifndef USE_TOOLKIT_SCROLL_BARS + /* Draw BAR's handle in the proper position. If the handle is already drawn from START to END, don't bother @@ -5142,8 +5140,6 @@ x_scroll_bar_create (w, top, left, width, height) the bar's top is as far down as it goes; otherwise, there's no way to move to the very end of the buffer. */ -#ifndef USE_TOOLKIT_SCROLL_BARS - static void x_scroll_bar_set_handle (bar, start, end, rebuild) struct scroll_bar *bar; @@ -5151,22 +5147,22 @@ x_scroll_bar_set_handle (bar, start, end, rebuild) int rebuild; { int dragging = ! NILP (bar->dragging); - Window w = SCROLL_BAR_X_WINDOW (bar); + Window w = bar->x_window; FRAME_PTR f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window))); GC gc = f->output_data.x->normal_gc; /* If the display is already accurate, do nothing. */ if (! rebuild - && start == XINT (bar->start) - && end == XINT (bar->end)) + && start == bar->start + && end == bar->end) return; BLOCK_INPUT; { - int inside_width = VERTICAL_SCROLL_BAR_INSIDE_WIDTH (f, XINT (bar->width)); - int inside_height = VERTICAL_SCROLL_BAR_INSIDE_HEIGHT (f, XINT (bar->height)); - int top_range = VERTICAL_SCROLL_BAR_TOP_RANGE (f, XINT (bar->height)); + int inside_width = VERTICAL_SCROLL_BAR_INSIDE_WIDTH (f, bar->width); + int inside_height = VERTICAL_SCROLL_BAR_INSIDE_HEIGHT (f, bar->height); + int top_range = VERTICAL_SCROLL_BAR_TOP_RANGE (f, bar->height); /* Make sure the values are reasonable, and try to preserve the distance between start and end. */ @@ -5186,8 +5182,8 @@ x_scroll_bar_set_handle (bar, start, end, rebuild) } /* Store the adjusted setting in the scroll bar. */ - XSETINT (bar->start, start); - XSETINT (bar->end, end); + bar->start = start; + bar->end = end; /* Clip the end position, just for display. */ if (end > top_range) @@ -5254,12 +5250,12 @@ x_scroll_bar_remove (bar) #ifdef USE_TOOLKIT_SCROLL_BARS #ifdef USE_GTK - xg_remove_scroll_bar (f, SCROLL_BAR_X_WINDOW (bar)); + xg_remove_scroll_bar (f, bar->x_window); #else /* not USE_GTK */ XtDestroyWidget (SCROLL_BAR_X_WIDGET (FRAME_X_DISPLAY (f), bar)); #endif /* not USE_GTK */ #else - XDestroyWindow (FRAME_X_DISPLAY (f), SCROLL_BAR_X_WINDOW (bar)); + XDestroyWindow (FRAME_X_DISPLAY (f), bar->x_window); #endif /* Disassociate this scroll bar from its window. */ @@ -5357,19 +5353,19 @@ XTset_vertical_scroll_bar (w, portion, whole, position) BLOCK_INPUT; - if (sb_left != XINT (bar->left)) + if (sb_left != bar->left) mask |= CWX; - if (top != XINT (bar->top)) + if (top != bar->top) mask |= CWY; - if (sb_width != XINT (bar->width)) + if (sb_width != bar->width) mask |= CWWidth; - if (height != XINT (bar->height)) + if (height != bar->height) mask |= CWHeight; #ifdef USE_TOOLKIT_SCROLL_BARS /* Move/size the scroll bar widget. */ - if (mask || !NILP (bar->fringe_extended_p) != fringe_extended_p) + if (mask || bar->fringe_extended_p != fringe_extended_p) { /* Since toolkit scroll bars are smaller than the space reserved for them on the frame, we have to clear "under" them. */ @@ -5384,7 +5380,7 @@ XTset_vertical_scroll_bar (w, portion, whole, position) } #ifdef USE_GTK xg_update_scrollbar_pos (f, - SCROLL_BAR_X_WINDOW (bar), + bar->x_window, top, sb_left + VERTICAL_SCROLL_BAR_WIDTH_TRIM, sb_width - VERTICAL_SCROLL_BAR_WIDTH_TRIM *2, @@ -5440,23 +5436,23 @@ XTset_vertical_scroll_bar (w, portion, whole, position) wc.y = top; wc.width = sb_width - VERTICAL_SCROLL_BAR_WIDTH_TRIM * 2; wc.height = height; - XConfigureWindow (FRAME_X_DISPLAY (f), SCROLL_BAR_X_WINDOW (bar), + XConfigureWindow (FRAME_X_DISPLAY (f), bar->x_window, mask, &wc); } #endif /* not USE_TOOLKIT_SCROLL_BARS */ /* Remember new settings. */ - XSETINT (bar->left, sb_left); - XSETINT (bar->top, top); - XSETINT (bar->width, sb_width); - XSETINT (bar->height, height); + bar->left = sb_left; + bar->top = top; + bar->width = sb_width; + bar->height = height; UNBLOCK_INPUT; } #ifdef USE_TOOLKIT_SCROLL_BARS - bar->fringe_extended_p = fringe_extended_p ? Qt : Qnil; + bar->fringe_extended_p = fringe_extended_p; x_set_toolkit_scroll_bar_thumb (bar, portion, position, whole); #else /* not USE_TOOLKIT_SCROLL_BARS */ @@ -5600,14 +5596,14 @@ x_scroll_bar_expose (bar, event) struct scroll_bar *bar; XEvent *event; { - Window w = SCROLL_BAR_X_WINDOW (bar); + Window w = bar->x_window; FRAME_PTR f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window))); GC gc = f->output_data.x->normal_gc; int width_trim = VERTICAL_SCROLL_BAR_WIDTH_TRIM; BLOCK_INPUT; - x_scroll_bar_set_handle (bar, XINT (bar->start), XINT (bar->end), 1); + x_scroll_bar_set_handle (bar, bar->start, bar->end, 1); /* Switch to scroll bar foreground color. */ if (f->output_data.x->scroll_bar_foreground_pixel != -1) @@ -5619,8 +5615,8 @@ x_scroll_bar_expose (bar, event) /* x, y, width, height */ 0, 0, - XINT (bar->width) - 1 - width_trim - width_trim, - XINT (bar->height) - 1); + bar->width - 1 - width_trim - width_trim, + bar->height - 1); /* Restore the foreground color of the GC if we changed it above. */ if (f->output_data.x->scroll_bar_foreground_pixel != -1) @@ -5664,18 +5660,18 @@ x_scroll_bar_handle_click (bar, event, emacs_event) #if 0 FRAME_PTR f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window))); int internal_height - = VERTICAL_SCROLL_BAR_INSIDE_HEIGHT (f, XINT (bar->height)); + = VERTICAL_SCROLL_BAR_INSIDE_HEIGHT (f, bar->height); #endif int top_range - = VERTICAL_SCROLL_BAR_TOP_RANGE (f, XINT (bar->height)); + = VERTICAL_SCROLL_BAR_TOP_RANGE (f, bar->height); int y = event->xbutton.y - VERTICAL_SCROLL_BAR_TOP_BORDER; if (y < 0) y = 0; if (y > top_range) y = top_range; - if (y < XINT (bar->start)) + if (y < bar->start) emacs_event->part = scroll_bar_above_handle; - else if (y < XINT (bar->end) + VERTICAL_SCROLL_BAR_MIN_HANDLE) + else if (y < bar->end + VERTICAL_SCROLL_BAR_MIN_HANDLE) emacs_event->part = scroll_bar_handle; else emacs_event->part = scroll_bar_below_handle; @@ -5688,7 +5684,7 @@ x_scroll_bar_handle_click (bar, event, emacs_event) holding it. */ if (event->type == ButtonPress && emacs_event->part == scroll_bar_handle) - XSETINT (bar->dragging, y - XINT (bar->start)); + XSETINT (bar->dragging, y - bar->start); #endif #ifndef USE_TOOLKIT_SCROLL_BARS @@ -5697,7 +5693,7 @@ x_scroll_bar_handle_click (bar, event, emacs_event) && ! NILP (bar->dragging)) { int new_start = y - XINT (bar->dragging); - int new_end = new_start + (XINT (bar->end) - XINT (bar->start)); + int new_end = new_start + bar->end - bar->start; x_scroll_bar_set_handle (bar, new_start, new_end, 0); bar->dragging = Qnil; @@ -5745,9 +5741,9 @@ x_scroll_bar_note_movement (bar, event) /* Where should the handle be now? */ int new_start = event->xmotion.y - XINT (bar->dragging); - if (new_start != XINT (bar->start)) + if (new_start != bar->start) { - int new_end = new_start + (XINT (bar->end) - XINT (bar->start)); + int new_end = new_start + bar->end - bar->start; x_scroll_bar_set_handle (bar, new_start, new_end, 0); } @@ -5768,7 +5764,7 @@ x_scroll_bar_report_motion (fp, bar_window, part, x, y, time) unsigned long *time; { struct scroll_bar *bar = XSCROLL_BAR (last_mouse_scroll_bar); - Window w = SCROLL_BAR_X_WINDOW (bar); + Window w = bar->x_window; FRAME_PTR f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window))); int win_x, win_y; Window dummy_window; @@ -5795,10 +5791,10 @@ x_scroll_bar_report_motion (fp, bar_window, part, x, y, time) { #if 0 int inside_height - = VERTICAL_SCROLL_BAR_INSIDE_HEIGHT (f, XINT (bar->height)); + = VERTICAL_SCROLL_BAR_INSIDE_HEIGHT (f, bar->height); #endif int top_range - = VERTICAL_SCROLL_BAR_TOP_RANGE (f, XINT (bar->height)); + = VERTICAL_SCROLL_BAR_TOP_RANGE (f, bar->height); win_y -= VERTICAL_SCROLL_BAR_TOP_BORDER; @@ -5815,9 +5811,9 @@ x_scroll_bar_report_motion (fp, bar_window, part, x, y, time) if (! NILP (bar->dragging)) *part = scroll_bar_handle; - else if (win_y < XINT (bar->start)) + else if (win_y < bar->start) *part = scroll_bar_above_handle; - else if (win_y < XINT (bar->end) + VERTICAL_SCROLL_BAR_MIN_HANDLE) + else if (win_y < bar->end + VERTICAL_SCROLL_BAR_MIN_HANDLE) *part = scroll_bar_handle; else *part = scroll_bar_below_handle; @@ -5854,7 +5850,7 @@ x_scroll_bar_clear (f) for (bar = FRAME_SCROLL_BARS (f); VECTORP (bar); bar = XSCROLL_BAR (bar)->next) XClearArea (FRAME_X_DISPLAY (f), - SCROLL_BAR_X_WINDOW (XSCROLL_BAR (bar)), + XSCROLL_BAR (bar)->x_window, 0, 0, 0, 0, True); #endif /* not USE_TOOLKIT_SCROLL_BARS */ } @@ -7065,12 +7061,10 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit) if (tool_bar_p && event.xbutton.button < 4) { - if (event.xbutton.type == ButtonPress) - handle_tool_bar_click (f, x, y, 1, 0); - else - handle_tool_bar_click (f, x, y, 0, - x_x_to_emacs_modifiers (dpyinfo, - event.xbutton.state)); + handle_tool_bar_click (f, x, y, + event.xbutton.type == ButtonPress, + x_x_to_emacs_modifiers (dpyinfo, + event.xbutton.state)); } } @@ -8072,7 +8066,7 @@ x_connection_closed (dpy, error_message) Closing the display is reported to lead to a bus error on OpenWindows in certain situations. I suspect that is a bug - in OpenWindows. I don't know how to cicumvent it here. */ + in OpenWindows. I don't know how to circumvent it here. */ #ifdef USE_X_TOOLKIT /* If DPYINFO is null, this means we didn't open the display @@ -8123,6 +8117,10 @@ x_connection_closed (dpy, error_message) unbind_to (index, Qnil); clear_waiting_for_input (); + /* FIXME: This is an asynchronous interrupt w.r.t elisp, so signalling an + error might not be the best thing to do. I'd vote for creating an + elisp event and stuffing it in the queue so people can bind to it via + the global map. --Stef */ error ("%s", error_msg); } @@ -8726,7 +8724,7 @@ x_set_offset (f, xoff, yoff, change_gravity) on the root window for frame F contains ATOMNAME. This is how a WM check shall be done according to the Window Manager Specification/Extended Window Manager Hints at - http://freedesktop.org/wiki/Standards_2fwm_2dspec. */ + http://freedesktop.org/wiki/Specifications/wm-spec. */ static int wm_supports (f, atomname) @@ -9259,7 +9257,7 @@ x_ewmh_activate_frame (f) FRAME_PTR f; { /* See Window Manager Specification/Extended Window Manager Hints at - http://freedesktop.org/wiki/Standards_2fwm_2dspec */ + http://freedesktop.org/wiki/Specifications/wm-spec */ const char *atom = "_NET_ACTIVE_WINDOW"; if (f->async_visible && wm_supports (f, atom)) @@ -11329,8 +11327,8 @@ x_term_init (display_name, xrm_option, resource_name) /* Mac OS X 10.3's Xserver sometimes reports 0.0mm. */ dpyinfo->resy = (mm < 1) ? 100 : pixels * 25.4 / mm; pixels = DisplayWidth (dpyinfo->display, screen_number); - /* Mac OS X 10.3's Xserver sometimes reports 0.0mm. */ mm = DisplayWidthMM (dpyinfo->display, screen_number); + /* Mac OS X 10.3's Xserver sometimes reports 0.0mm. */ dpyinfo->resx = (mm < 1) ? 100 : pixels * 25.4 / mm; } @@ -11499,13 +11497,13 @@ x_term_init (display_name, xrm_option, resource_name) Qnil, Qnil); #ifdef USE_XIM if (STRINGP (value) - && (!strcmp (XSTRING (value)->data, "false") - || !strcmp (XSTRING (value)->data, "off"))) + && (!strcmp (SDATA (value), "false") + || !strcmp (SDATA (value), "off"))) use_xim = 0; #else if (STRINGP (value) - && (!strcmp (XSTRING (value)->data, "true") - || !strcmp (XSTRING (value)->data, "on"))) + && (!strcmp (SDATA (value), "true") + || !strcmp (SDATA (value), "on"))) use_xim = 1; #endif } diff --git a/src/xterm.h b/src/xterm.h index 40cbf695d38..25b04fe75fa 100644 --- a/src/xterm.h +++ b/src/xterm.h @@ -757,13 +757,14 @@ struct scroll_bar /* The next and previous in the chain of scroll bars in this frame. */ Lisp_Object next, prev; - /* The X window representing this scroll bar. Since this is a full - 32-bit quantity, we store it split into two 32-bit values. */ - Lisp_Object x_window_low, x_window_high; + /* Fields from `x_window' down will not be traced by the GC. */ + + /* The X window representing this scroll bar. */ + Window x_window; /* The position and size of the scroll bar in pixels, relative to the frame. */ - Lisp_Object top, left, width, height; + int top, left, width, height; /* The starting and ending positions of the handle, relative to the handle area (i.e. zero is the top position, not @@ -776,7 +777,7 @@ struct scroll_bar drawing handle bottoms VERTICAL_SCROLL_BAR_MIN_HANDLE pixels below where they would be normally; the bottom and top are in a different co-ordinate system. */ - Lisp_Object start, end; + int start, end; /* If the scroll bar handle is currently being dragged by the user, this is the number of pixels from the top of the handle to the @@ -784,11 +785,9 @@ struct scroll_bar being dragged, this is Qnil. */ Lisp_Object dragging; -#ifdef USE_TOOLKIT_SCROLL_BARS - /* t if the background of the fringe that is adjacent to a scroll + /* 1 if the background of the fringe that is adjacent to a scroll bar is extended to the gap between the fringe and the bar. */ - Lisp_Object fringe_extended_p; -#endif + unsigned int fringe_extended_p : 1; }; /* The number of elements a vector holding a struct scroll_bar needs. */ @@ -801,36 +800,19 @@ struct scroll_bar #define XSCROLL_BAR(vec) ((struct scroll_bar *) XVECTOR (vec)) -/* Building a 32-bit C integer from two 16-bit lisp integers. */ -#define SCROLL_BAR_PACK(low, high) (XINT (high) << 16 | XINT (low)) - -/* Setting two lisp integers to the low and high words of a 32-bit C int. */ -#define SCROLL_BAR_UNPACK(low, high, int32) \ - (XSETINT ((low), (int32) & 0xffff), \ - XSETINT ((high), ((int32) >> 16) & 0xffff)) - - -/* Extract the X window id of the scroll bar from a struct scroll_bar. */ -#define SCROLL_BAR_X_WINDOW(ptr) \ - ((Window) SCROLL_BAR_PACK ((ptr)->x_window_low, (ptr)->x_window_high)) - -/* Store a window id in a struct scroll_bar. */ -#define SET_SCROLL_BAR_X_WINDOW(ptr, id) \ - (SCROLL_BAR_UNPACK ((ptr)->x_window_low, (ptr)->x_window_high, (int) id)) - /* Extract the X widget of the scroll bar from a struct scroll_bar. XtWindowToWidget should be fast enough since Xt uses a hash table to map windows to widgets. */ #define SCROLL_BAR_X_WIDGET(dpy, ptr) \ - XtWindowToWidget (dpy, SCROLL_BAR_X_WINDOW (ptr)) + XtWindowToWidget (dpy, ptr->x_window) /* Store a widget id in a struct scroll_bar. */ #define SET_SCROLL_BAR_X_WIDGET(ptr, w) \ do { \ Window window = XtWindow (w); \ - SET_SCROLL_BAR_X_WINDOW (ptr, window); \ + ptr->x_window = window; \ } while (0) |