aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMiles Bader2007-12-06 09:51:45 +0000
committerMiles Bader2007-12-06 09:51:45 +0000
commit0bd508417142ff377f34aec8dcec9438d9175c2c (patch)
tree4d60fe09e5cebf7d79766b11e9cda8cc1c9dbb9b /src
parent98fe991da804a42f53f6a5e84cd5eab18a82e181 (diff)
parent9fb1ba8090da3528de56158a79bd3527d31c7f2f (diff)
downloademacs-0bd508417142ff377f34aec8dcec9438d9175c2c.tar.gz
emacs-0bd508417142ff377f34aec8dcec9438d9175c2c.zip
Merge from emacs--devo--0
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-294
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog345
-rw-r--r--src/ChangeLog.102
-rw-r--r--src/Makefile.in19
-rw-r--r--src/alloc.c22
-rw-r--r--src/buffer.c52
-rw-r--r--src/buffer.h38
-rw-r--r--src/config.in3
-rw-r--r--src/data.c102
-rw-r--r--src/dbusbind.c817
-rw-r--r--src/dispnew.c4
-rw-r--r--src/editfns.c53
-rw-r--r--src/emacs.c8
-rw-r--r--src/eval.c17
-rw-r--r--src/gtkutil.c17
-rw-r--r--src/image.c15
-rw-r--r--src/keyboard.c140
-rw-r--r--src/keymap.c3
-rw-r--r--src/lisp.h12
-rw-r--r--src/mac.c51
-rw-r--r--src/macfns.c34
-rw-r--r--src/macterm.c6
-rw-r--r--src/print.c2
-rw-r--r--src/process.c7
-rw-r--r--src/puresize.h2
-rw-r--r--src/s/darwin.h3
-rw-r--r--src/s/gnu-kfreebsd.h11
-rw-r--r--src/s/ms-w32.h8
-rw-r--r--src/search.c35
-rw-r--r--src/sysdep.c55
-rw-r--r--src/term.c11
-rw-r--r--src/termhooks.h50
-rw-r--r--src/unexmacosx.c103
-rw-r--r--src/w32bdf.c4
-rw-r--r--src/w32console.c79
-rw-r--r--src/w32fns.c271
-rw-r--r--src/w32proc.c9
-rw-r--r--src/w32term.h1
-rw-r--r--src/window.c66
-rw-r--r--src/xdisp.c8
-rw-r--r--src/xfaces.c14
-rw-r--r--src/xfns.c22
-rw-r--r--src/xterm.c152
-rw-r--r--src/xterm.h38
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 @@
12007-12-05 Magnus Henoch <mange@freemail.hu>
2
3 * process.c (make_process): Initialize pty_flag to 0.
4
52007-12-05 Jason Rumney <jasonr@gnu.org>
6
7 * image.c (xbm_load) [WINDOWSNT]: Shuffle the bits of directly
8 specified XBMs.
9
102007-12-05 Richard Stallman <rms@gnu.org>
11
12 * xdisp.c (syms_of_xdisp) <scroll-conservatively>: Doc fix.
13
142007-12-05 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
15
16 * mac.c (cfsockets_for_select) [MAC_OSX && SELECT_USE_CFSOCKET]:
17 New variable.
18 (mac_try_close_socket) [MAC_OSX]: New function.
19 [MAC_OSX] (sys_select) [SELECT_USE_CFSOCKET]:
20 Update cfsockets_for_select. Replace invalid CFRunLoop source.
21
22 * sysdep.c (emacs_close) [MAC_OSX && HAVE_CARBON]:
23 Use mac_try_close_socket.
24
252007-12-05 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
26
27 * unexmacosx.c (unrelocate): New argument BASE. Use it instead of
28 reloc_base.
29 (copy_dysymtab): Compute relocation base here.
30 (rebase_reloc_address) [__ppc64__]: New function.
31 (copy_dysymtab) [__ppc64__]: Use it if relocation base needs to be
32 changed.
33
342007-12-05 Jason Rumney <jasonr@gnu.org>
35
36 * w32proc.c (sys_spawnve): Quote args with wildcards.
37
382007-12-05 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
39
40 * unexmacosx.c (copy_data_segment): Also copy __gcc_except_tab and
41 __objc_* sections.
42 (unrelocate) [_LP64]: Set relocation base to address of data segment.
43
442007-12-05 Michael Albinus <michael.albinus@gmx.de>
45
46 * dbusbind.c (xd_read_message): Return value is a Lisp_Object.
47 Move check for Vdbus_registered_functions_table to
48 xd_read_queued_messages.
49 (xd_read_queued_messages): Protect xd_read_message calls by
50 internal_condition_case_1.
51
522007-12-04 Michael Albinus <michael.albinus@gmx.de>
53
54 * dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
55 Qdbus_system_bus and Qdbus_session_bus, respectively.
56 (Vdbus_intern_symbols): Removed.
57 (Vdbus_registered_functions_table): New hash table.
58 (XD_SYMBOL_INTERN_SYMBOL): Removed.
59 (xd_read_message, Fdbus_register_signal, Fdbus_unregister_signal):
60 Rewritten in order to manage registered functions by hash table
61 Vdbus_registered_functions_table.
62
632007-12-03 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
64
65 * xterm.c: Update URL to Window Manager Specification in comment.
66
672007-12-02 Michael Albinus <michael.albinus@gmx.de>
68
69 * config.in (HAVE_DBUS): Add.
70
71 * Makefile.in: (HAVE_DBUS): Add D-Bus definitions if defined.
72 (ALL_CFLAGS): Add ${DBUS_CFLAGS}.
73 (obj): Add $(DBUS_OBJ).
74 (LIBES): Add $(DBUS_LIBS).
75 (dbusbind.o): New target.
76
77 * dbusbind.c: New file.
78
79 * emacs.c (main): Call syms_of_dbusbind when HAVE_DBUS is defined.
80
81 * keyboard.c: All D-Bus related code is wrapped by "#ifdef HAVE_DBUS".
82 (Qdbus_event) New Lisp symbol.
83 (kbd_buffer_get_event, make_lispy_event): Handle DBUS_EVENT.
84 (gobble_input): Call xd_read_queued_messages, reading D-Bus
85 messages.
86 (keys_of_keyboard ): Define dbus-event.
87
88 * termhooks.h (event_kind): Add DBUS_EVENT when HAVE_DBUS is defined.
89
902007-12-01 Richard Stallman <rms@gnu.org>
91
92 * search.c (syms_of_search) <inhibit-changing-match-data>: Doc fix.
93
942007-11-30 Jason Rumney <jasonr@gnu.org>
95
96 * w32console.c (w32con_ins_del_lines, scroll_line): Clip to window.
97 (w32con_reset_terminal_modes): Clear screen buffer.
98 (w32_face_attributes): Don't use color indexes that are out of range.
99 Only reverse the default colors.
100
101 * xfaces.c (map_tty_color, tty_color_name): Remove special case for
102 WINDOWSNT.
103
104 * w32console.c, w32term.h (vga_stdcolor_name): Remove.
105
1062007-11-29 Jason Rumney <jasonr@gnu.org>
107
108 * w32console.c: Leave HAVE_WINDOW_SYSTEM defined.
109 (w32_face_attributes): Use Vtty_defined_color_alist to determine
110 if the terminal colors are initialized.
111 (unspecified_fg, unspecified_bg): Remove unused declarations.
112
1132007-11-29 Andreas Schwab <schwab@suse.de>
114
115 * keyboard.c (apply_modifiers): Fix typo.
116
1172007-11-29 Richard Stallman <rms@gnu.org>
118
119 * keymap.c (Fcurrent_local_map): Doc fix.
120
1212007-11-28 Petr Salinger <Petr.Salinger@seznam.cz> (tiny change)
122
123 * s/gnu-kfreebsd.h: New file.
124
1252007-11-28 Stefan Monnier <monnier@iro.umontreal.ca>
126
127 * buffer.c (Fget_buffer_create, Fmake_indirect_buffer):
128 Don't cast redundantly.
129
130 * keyboard.c (KEY_TO_CHAR): New macro.
131 (parse_modifiers, apply_modifiers): Accept integer arguments.
132 (read_key_sequence): Use them to unify the "shift->unshift" mapping
133 for chars and symbol keys.
134 After doing such remapping, apply function-key-map again.
135
1362007-11-27 Dan Nicolaescu <dann@ics.uci.edu>
137
138 * Makefile.in (SOME_MACHINE_LISP): Remove VMS files, they are not
139 compiled anymore.
140
1412007-11-26 Andreas Schwab <schwab@suse.de>
142
143 * process.c (list_processes_1): Fix indentation level of the
144 command column.
145
1462007-11-23 Andreas Schwab <schwab@suse.de>
147
148 * editfns.c (Fformat): Handle %c specially since it requires the
149 argument to be of type int.
150
1512007-11-23 Markus Triska <markus.triska@gmx.at>
152
153 * emacs.c (main): Call init_editfns before init_process, since
154 init_process sets Vprocess_connection_type depending on OS release
155
1562007-11-22 Stefan Monnier <monnier@iro.umontreal.ca>
157
158 * data.c (do_symval_forwarding): Use same code as in find_symbol_value.
159 (find_symbol_value): Use do_symval_forwarding.
160
161 * data.c (set_internal): Set the value in the `cons-cell' (for
162 Buffer_Local_values) not only for frame-local variables.
163
1642007-11-22 Andreas Schwab <schwab@suse.de>
165
166 * data.c (Fnumber_to_string): Add cast when passing EMACS_INT
167 values to sprintf.
168 * keymap.c (Fsingle_key_description): Likewise.
169 * print.c (print_object): Likewise.
170
1712007-11-22 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
172
173 * gtkutil.c (update_frame_tool_bar): Don't call x-gtk-map-stock if
174 file for image is nil.
175
1762007-11-22 Dan Nicolaescu <dann@ics.uci.edu>
177
178 * term.c: Include stdarg.h.
179 (fatal): Implement using varargs.
180 * lisp.h (fatal): Add argument types. (Restore 2005-09-30 change).
181
1822007-11-21 Stefan Monnier <monnier@iro.umontreal.ca>
183
184 * lisp.h (struct Lisp_Buffer_Objfwd): Add a `slottype' field.
185 * data.c (store_symval_forwarding): Get type from buffer_objfwd.
186 Update call to buffer_slot_type_mismatch.
187 * buffer.h (buffer_local_types, PER_BUFFER_TYPE): Remove.
188 (buffer_slot_type_mismatch): Update.
189 * buffer.c (buffer_local_types): Remove.
190 (buffer_slot_type_mismatch): Get the symbol and type as arguments.
191 (defvar_per_buffer): Set the type in the buffer_objfwd.
192
1932007-11-21 Jason Rumney <jasonr@gnu.org>
194
195 * w32bdf.c (w32_init_bdf_font, w32_BDF_to_x_font):
196 CreateFileMapping returns NULL on failure.
197
1982007-11-21 Stefan Monnier <monnier@iro.umontreal.ca>
199
200 * search.c (Fset_match_data): Remove the `evaporate' feature.
201 (unwind_set_match_data): Don't use the `evaporate' feature.
202
2032007-11-21 Jason Rumney <jasonr@gnu.org>
204
205 * dispnew.c (init_display) [WINDOWSNT]: Hardcode terminal_type.
206
207 * w32console.c (w32con_write_glyphs): Remove unused variables.
208
2092007-11-20 Dan Nicolaescu <dann@ics.uci.edu>
210
211 * macterm.c (mac_term_init): Call add_keyboard_wait_descriptor.
212
213 * s/darwin.h (MULTI_KBOARD): Remove.
214
215 * macfns.c (x_create_tip_frame, Fx_create_frame)
216 (x_create_tip_frame): Don't deal with MULTI_KBOARD.
217
2182007-11-19 Stefan Monnier <monnier@iro.umontreal.ca>
219
220 * buffer.c (Fbuffer_local_value): Remove redundant test.
221 (swap_out_buffer_local_variables): Swap out binding in `buffer' rather
222 than in `current-buffer' to match the comment.
223 Do the swap using swap_in_global_binding.
224
225 * data.c (store_symval_forwarding, set_internal):
226 * eval.c (specbind): Remove dead code.
227
228 * coding.c (detect_coding, Fupdate_coding_systems_internal):
229 * fns.c (Fmd5): Use find_symbol_value rather than SYMBOL_VALUE
230 Since we do not want to see internal Lisp_*fwd objects here.
231
2322007-11-18 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
233
234 * sysdep.c (init_system_name): Use getaddrinfo if available.
235
236 * xterm.c (x_scroll_bar_set_handle, x_scroll_bar_handle_click)
237 (x_scroll_bar_note_movement): start, end, with, height in struct
238 scroll_bar are integers and not Lisp_Object, so remove XINT for them.
239
2402007-11-17 Dan Nicolaescu <dann@ics.uci.edu>
241
242 * puresize.h (BASE_PURESIZE): Increase to 1190000.
243
2442007-11-16 Stefan Monnier <monnier@iro.umontreal.ca>
245
246 * buffer.h (struct buffer): Move `undo_list' back to before `name'.
247 This undoes Richard's change of 14-Oct-2002.
248
249 * alloc.c (allocate_other_vector):
250 * lisp.h (allocate_other_vector): Remove.
251
252 * window.c (struct save_window_data): Move non-lisp data to the end
253 and make it `int' rather than Lisp_Object.
254 (Fcurrent_window_configuration): Use ALLOCATE_PSEUDOVECTOR.
255 Done wrap/unwrap integer values.
256 (Fset_window_configuration, compare_window_configurations):
257 Update use of fields to their new types.
258
259 * xterm.h (struct scroll_bar): Only use Lisp_Object for lisp data.
260 Turn integer fields into `int'. Merge x_window_low and x_window_high.
261 (SCROLL_BAR_PACK, SCROLL_BAR_UNPACK, SCROLL_BAR_X_WINDOW)
262 (SET_SCROLL_BAR_X_WINDOW): Remove.
263 (SCROLL_BAR_X_WIDGET, SET_SCROLL_BAR_X_WIDGET):
264 Access the new x_window field directly.
265 * xterm.c (x_scroll_bar_create): Use a pseudovector.
266 Don't wrap/unwrap integers into Lisp_Objects.
267 (XTset_vertical_scroll_bar, x_scroll_bar_handle_click)
268 (x_scroll_bar_report_motion):
269 Don't wrap/unwrap integers into Lisp_Objects.
270 (x_term_init): Use SDATA.
271 (x_window_to_scroll_bar, x_create_toolkit_scroll_bar)
272 (x_scroll_bar_set_handle, x_scroll_bar_remove)
273 (XTset_vertical_scroll_bar, x_scroll_bar_expose)
274 (x_scroll_bar_report_motion, x_scroll_bar_clear):
275 * xfns.c (x_set_background_color):
276 * gtkutil.c (xg_create_scroll_bar, xg_set_toolkit_scroll_bar_thumb):
277 Access the new x_window field directly.
278
279 * alloc.c (ALLOCATE_PSEUDOVECTOR): Move to lisp.h.
280 (allocate_pseudovector): Make non-static.
281
282 * lisp.h (enum pvec_type): New tag PVEC_OTHER.
283 (allocate_pseudovector): Declare.
284 (ALLOCATE_PSEUDOVECTOR): Move from alloc.c
285
2862007-11-15 Andreas Schwab <schwab@suse.de>
287
288 * editfns.c (Fformat): Correctly format EMACS_INT values.
289 Also take precision into account when formatting an integer.
290
291 * keyboard.c (Fevent_symbol_parse_modifiers): Fix declaration.
292
2932007-11-15 Stefan Monnier <monnier@iro.umontreal.ca>
294
295 * keyboard.c (Fevent_symbol_parse_modifiers): New function.
296 (syms_of_keyboard): Defsubr it.
297
298 * data.c (swap_in_global_binding): Fix longstanding bug where
299 store_symval_forwarding was not called with the right second argument,
300 thus causing objfwd-ing from being dropped.
301
3022007-11-14 Juanma Barranquero <lekktu@gmail.com>
303
304 * macfns.c (Fx_create_frame, Fx_display_pixel_width)
305 (Fx_display_pixel_height, Fx_display_planes)
306 (Fx_display_color_cells, Fx_server_max_request_size)
307 (Fx_server_vendor, Fx_server_version, Fx_display_backing_store)
308 (Fx_display_visual_class, Fx_display_save_under):
309 * w32fns.c (Fx_create_frame, Fx_display_pixel_width)
310 (Fx_display_pixel_height, Fx_display_planes)
311 (Fx_display_color_cells, Fx_server_max_request_size)
312 (Fx_server_vendor, Fx_server_version, Fx_display_screens)
313 (Fx_display_mm_height, Fx_display_mm_width)
314 (Fx_display_backing_store, Fx_display_visual_class)
315 (Fw32_select_font, Fx_display_save_under):
316 * xfns.c (Fx_create_frame, Fx_display_pixel_width)
317 (Fx_display_pixel_height, Fx_display_planes)
318 (Fx_display_color_cells, Fx_server_max_request_size)
319 (Fx_server_vendor, Fx_server_version, Fx_display_backing_store)
320 (Fx_display_save_under): Fix typos in docstrings.
321
3222007-11-14 Juanma Barranquero <lekktu@gmail.com>
323
324 * w32fns.c (Fw32_registered_hot_keys): Don't return the nil values
325 corresponding to deleted entries; they are an implementation detail.
326 (gray_bitmap_width, gray_bitmap_height, gray_bitmap_bits):
327 Remove variables.
328 (w32_pass_extra_mouse_buttons_to_system, w32_strict_fontnames)
329 (w32_pass_multimedia_buttons_to_system, w32_strict_painting)
330 (Vw32_charset_info_alist, w32_to_x_color, w32_init_class)
331 (w32_createscrollbar, w32_createwindow, my_post_msg, w32_get_modifiers)
332 (w32_grabbed_keys, cancel_all_deferred_msgs): Make static.
333 (Fw32_define_rgb_color, Fw32_load_color_file)
334 (syms_of_w32fns) <w32-pass-multimedia-buttons-to-system>:
335 Fix typos in docstrings.
336 (Fx_server_version): Reflow docstring.
337 (Fw32_shell_execute): Doc fixes.
338
3392007-11-13 Juanma Barranquero <lekktu@gmail.com>
340
341 * w32fns.c (Fw32_register_hot_key): Don't try to register hot key
342 if w32_parse_hot_key returned nil.
343
12007-11-10 Stefan Monnier <monnier@iro.umontreal.ca> 3442007-11-10 Stefan Monnier <monnier@iro.umontreal.ca>
2 345
3 * xdisp.c (load_overlay_strings): Fix copy&paste typo. 346 * xdisp.c (load_overlay_strings): Fix copy&paste typo.
@@ -107,7 +450,7 @@
1072007-11-01 Johan Bockg,Ae(Brd <bojohan@gnu.org> 4502007-11-01 Johan Bockg,Ae(Brd <bojohan@gnu.org>
108 451
109 * macterm.c, w32term.c, xterm.c (x_draw_stretch_glyph_string): 452 * macterm.c, w32term.c, xterm.c (x_draw_stretch_glyph_string):
110 Don't set s->stippled_p here, since it has already been set by 453 Don't set s->stippled_p here, since it has already been set by
111 x_set_glyph_string_gc from x_draw_glyph_string. 454 x_set_glyph_string_gc from x_draw_glyph_string.
112 455
1132007-11-01 Dan Nicolaescu <dann@ics.uci.edu> 4562007-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 @@
3016 * w32.c: Fix high cpu load for server sockets. 3016 * w32.c: Fix high cpu load for server sockets.
3017 (pfn_WSAEventSelect): New function ptr. 3017 (pfn_WSAEventSelect): New function ptr.
3018 (init_winsock): Load it. 3018 (init_winsock): Load it.
3019 (sys_listen): Set FILE_LISTEN flag. Set event mask for socket's 3019 (sys_listen): Set FILE_LISTEN flag. Set event mask for socket's
3020 char_avail event object to FD_ACCEPT. 3020 char_avail event object to FD_ACCEPT.
3021 (sys_accept): Check FILE_LISTEN flag. Set event mask on new 3021 (sys_accept): Check FILE_LISTEN flag. Set event mask on new
3022 socket's char_avail event object to FD_READ|FD_CLOSE. 3022 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 =
263#endif 263#endif
264#endif 264#endif
265 265
266#ifdef HAVE_DBUS
267DBUS_CFLAGS = @DBUS_CFLAGS@
268DBUS_LIBS = @DBUS_LIBS@
269DBUS_OBJ = dbusbind.o
270#endif
271
266/* DO NOT use -R. There is a special hack described in lastfile.c 272/* DO NOT use -R. There is a special hack described in lastfile.c
267 which is used instead. Some initialized data areas are modified 273 which is used instead. Some initialized data areas are modified
268 at initial startup, then labeled as part of the text area when 274 at initial startup, then labeled as part of the text area when
@@ -276,7 +282,7 @@ TOOLKIT_DEFINES =
276 282
277/* C_SWITCH_X_SITE must come before C_SWITCH_X_MACHINE and C_SWITCH_X_SYSTEM 283/* C_SWITCH_X_SITE must come before C_SWITCH_X_MACHINE and C_SWITCH_X_SYSTEM
278 since it may have -I options that should override those two. */ 284 since it may have -I options that should override those two. */
279ALL_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@ 285ALL_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@
280.c.o: 286.c.o:
281 $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) $< 287 $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) $<
282 288
@@ -608,7 +614,7 @@ FONTOBJ = font.o
608 whose initialized data areas should be dumped as pure by dump-emacs. */ 614 whose initialized data areas should be dumped as pure by dump-emacs. */
609obj= dispnew.o frame.o scroll.o xdisp.o $(XMENU_OBJ) window.o \ 615obj= dispnew.o frame.o scroll.o xdisp.o $(XMENU_OBJ) window.o \
610 charset.o coding.o category.o ccl.o character.o chartab.o \ 616 charset.o coding.o category.o ccl.o character.o chartab.o \
611 cm.o term.o terminal.o xfaces.o $(XOBJ) $(GTK_OBJ)\ 617 cm.o term.o terminal.o xfaces.o $(XOBJ) $(GTK_OBJ) $(DBUS_OBJ) \
612 emacs.o keyboard.o macros.o keymap.o sysdep.o \ 618 emacs.o keyboard.o macros.o keymap.o sysdep.o \
613 buffer.o filelock.o insdel.o marker.o \ 619 buffer.o filelock.o insdel.o marker.o \
614 minibuf.o fileio.o dired.o filemode.o \ 620 minibuf.o fileio.o dired.o filemode.o \
@@ -925,7 +931,7 @@ shortlisp= \
925 for the sake of systems which can''t handle large ones. */ 931 for the sake of systems which can''t handle large ones. */
926SOME_MACHINE_LISP = ${dotdot}/lisp/mouse.elc \ 932SOME_MACHINE_LISP = ${dotdot}/lisp/mouse.elc \
927 ${dotdot}/lisp/select.elc ${dotdot}/lisp/scroll-bar.elc \ 933 ${dotdot}/lisp/select.elc ${dotdot}/lisp/scroll-bar.elc \
928 ${dotdot}/lisp/vmsproc.elc ${dotdot}/lisp/vms-patch.elc \ 934 VMS_SUPPORT \
929 ${dotdot}/lisp/ls-lisp.elc ${dotdot}/lisp/dos-fns.elc \ 935 ${dotdot}/lisp/ls-lisp.elc ${dotdot}/lisp/dos-fns.elc \
930 ${dotdot}/lisp/w32-fns.elc ${dotdot}/lisp/dos-w32.elc \ 936 ${dotdot}/lisp/w32-fns.elc ${dotdot}/lisp/dos-w32.elc \
931 ${dotdot}/lisp/disp-table.elc ${dotdot}/lisp/dos-vars.elc \ 937 ${dotdot}/lisp/disp-table.elc ${dotdot}/lisp/dos-vars.elc \
@@ -943,8 +949,8 @@ SOME_MACHINE_LISP = ${dotdot}/lisp/mouse.elc \
943 Note that SunOS needs -lm to come before -lc; otherwise, you get 949 Note that SunOS needs -lm to come before -lc; otherwise, you get
944 duplicated symbols. If the standard libraries were compiled 950 duplicated symbols. If the standard libraries were compiled
945 with GCC, we might need gnulib again after them. */ 951 with GCC, we might need gnulib again after them. */
946LIBES = $(LOADLIBES) $(LIBS) $(LIBX) $(LIBSOUND) $(RSVG_LIBS) LIBGPM \ 952LIBES = $(LOADLIBES) $(LIBS) $(LIBX) $(LIBSOUND) $(RSVG_LIBS) $(DBUS_LIBS) \
947 LIBRESOLV LIBS_SYSTEM LIBS_MACHINE LIBS_TERMCAP \ 953 LIBGPM LIBRESOLV LIBS_SYSTEM LIBS_MACHINE LIBS_TERMCAP \
948 LIBS_DEBUG $(GETLOADAVG_LIBS) \ 954 LIBS_DEBUG $(GETLOADAVG_LIBS) \
949 @FREETYPE_LIBS@ @FONTCONFIG_LIBS@ @LIBOTF_LIBS@ @M17N_FLT_LIBS@ \ 955 @FREETYPE_LIBS@ @FONTCONFIG_LIBS@ @LIBOTF_LIBS@ @M17N_FLT_LIBS@ \
950 $(GNULIB_VAR) LIB_MATH LIB_STANDARD $(GNULIB_VAR) 956 $(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 \
1265xrdb.o: xrdb.c $(config_h) epaths.h 1271xrdb.o: xrdb.c $(config_h) epaths.h
1266xsmfns.o: xsmfns.c $(config_h) systime.h sysselect.h termhooks.h xterm.h \ 1272xsmfns.o: xsmfns.c $(config_h) systime.h sysselect.h termhooks.h xterm.h \
1267 lisp.h termopts.h 1273 lisp.h termopts.h
1268gtkutil.o: gtkutil.c gtkutil.h xterm.h lisp.h frame.h $(config_h) \ 1274gtkutil.o: gtkutil.c gtkutil.h xterm.h lisp.h frame.h $(config_h) \
1269 blockinput.h window.h atimer.h systime.h termhooks.h keyboard.h \ 1275 blockinput.h window.h atimer.h systime.h termhooks.h keyboard.h \
1270 charset.h coding.h 1276 charset.h coding.h
1277dbusbind.o: dbusbind.c termhooks.h $(config_h)
1271 1278
1272hftctl.o: hftctl.c $(config_h) 1279hftctl.o: hftctl.c $(config_h)
1273sound.o: sound.c dispextern.h $(config_h) 1280sound.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)
2967 2967
2968/* Allocate other vector-like structures. */ 2968/* Allocate other vector-like structures. */
2969 2969
2970static struct Lisp_Vector * 2970struct Lisp_Vector *
2971allocate_pseudovector (memlen, lisplen, tag) 2971allocate_pseudovector (memlen, lisplen, tag)
2972 int memlen, lisplen; 2972 int memlen, lisplen;
2973 EMACS_INT tag; 2973 EMACS_INT tag;
@@ -2983,10 +2983,6 @@ allocate_pseudovector (memlen, lisplen, tag)
2983 XSETPVECTYPE (v, tag); /* Add the appropriate tag. */ 2983 XSETPVECTYPE (v, tag); /* Add the appropriate tag. */
2984 return v; 2984 return v;
2985} 2985}
2986#define ALLOCATE_PSEUDOVECTOR(typ,field,tag) \
2987 ((typ*) \
2988 allocate_pseudovector \
2989 (VECSIZE (typ), PSEUDOVECSIZE (typ, field), tag))
2990 2986
2991struct Lisp_Hash_Table * 2987struct Lisp_Hash_Table *
2992allocate_hash_table (void) 2988allocate_hash_table (void)
@@ -3033,22 +3029,6 @@ allocate_process ()
3033} 3029}
3034 3030
3035 3031
3036/* Only used for PVEC_WINDOW_CONFIGURATION. */
3037struct Lisp_Vector *
3038allocate_other_vector (len)
3039 EMACS_INT len;
3040{
3041 struct Lisp_Vector *v = allocate_vectorlike (len);
3042 EMACS_INT i;
3043
3044 for (i = 0; i < len; ++i)
3045 v->contents[i] = Qnil;
3046 v->size = len;
3047
3048 return v;
3049}
3050
3051
3052DEFUN ("make-vector", Fmake_vector, Smake_vector, 2, 2, 0, 3032DEFUN ("make-vector", Fmake_vector, Smake_vector, 2, 2, 0,
3053 doc: /* Return a newly created vector of length LENGTH, with each element being INIT. 3033 doc: /* Return a newly created vector of length LENGTH, with each element being INIT.
3054See also the function `vector'. */) 3034See 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);
99/* A Lisp_Object pointer to the above, used for staticpro */ 99/* A Lisp_Object pointer to the above, used for staticpro */
100static Lisp_Object Vbuffer_local_symbols; 100static Lisp_Object Vbuffer_local_symbols;
101 101
102/* This structure holds the required types for the values in the
103 buffer-local slots. If a slot contains Qnil, then the
104 corresponding buffer slot may contain a value of any type. If a
105 slot contains an integer, then prospective values' tags must be
106 equal to that integer (except nil is always allowed).
107 When a tag does not match, the function
108 buffer_slot_type_mismatch will signal an error.
109
110 If a slot here contains -1, the corresponding variable is read-only. */
111struct buffer buffer_local_types;
112
113/* Flags indicating which built-in buffer-local variables 102/* Flags indicating which built-in buffer-local variables
114 are permanent locals. */ 103 are permanent locals. */
115static char buffer_permanent_local_flags[MAX_PER_BUFFER_VARS]; 104static char buffer_permanent_local_flags[MAX_PER_BUFFER_VARS];
@@ -360,7 +349,7 @@ The value is never nil. */)
360 if (SCHARS (name) == 0) 349 if (SCHARS (name) == 0)
361 error ("Empty string for buffer name is not allowed"); 350 error ("Empty string for buffer name is not allowed");
362 351
363 b = (struct buffer *) allocate_buffer (); 352 b = allocate_buffer ();
364 353
365 /* An ordinary buffer uses its own struct buffer_text. */ 354 /* An ordinary buffer uses its own struct buffer_text. */
366 b->text = &b->own_text; 355 b->text = &b->own_text;
@@ -561,7 +550,7 @@ CLONE nil means the indirect buffer's state is reset to default values. */)
561 if (SCHARS (name) == 0) 550 if (SCHARS (name) == 0)
562 error ("Empty string for buffer name is not allowed"); 551 error ("Empty string for buffer name is not allowed");
563 552
564 b = (struct buffer *) allocate_buffer (); 553 b = allocate_buffer ();
565 554
566 b->base_buffer = (XBUFFER (base_buffer)->base_buffer 555 b->base_buffer = (XBUFFER (base_buffer)->base_buffer
567 ? XBUFFER (base_buffer)->base_buffer 556 ? XBUFFER (base_buffer)->base_buffer
@@ -896,8 +885,7 @@ is the default binding of the variable. */)
896 CHECK_BUFFER (buffer); 885 CHECK_BUFFER (buffer);
897 buf = XBUFFER (buffer); 886 buf = XBUFFER (buffer);
898 887
899 if (SYMBOLP (variable)) 888 variable = indirect_variable (variable);
900 variable = indirect_variable (variable);
901 889
902 /* Look in local_var_list */ 890 /* Look in local_var_list */
903 result = Fassoc (variable, buf->local_var_alist); 891 result = Fassoc (variable, buf->local_var_alist);
@@ -2534,26 +2522,11 @@ swap_out_buffer_local_variables (b)
2534 2522
2535 /* Need not do anything if some other buffer's binding is now encached. */ 2523 /* Need not do anything if some other buffer's binding is now encached. */
2536 tem = XBUFFER_LOCAL_VALUE (SYMBOL_VALUE (sym))->buffer; 2524 tem = XBUFFER_LOCAL_VALUE (SYMBOL_VALUE (sym))->buffer;
2537 if (BUFFERP (tem) && XBUFFER (tem) == current_buffer) 2525 if (EQ (tem, buffer))
2538 { 2526 {
2539 /* Symbol is set up for this buffer's old local value. 2527 /* Symbol is set up for this buffer's old local value:
2540 Set it up for the current buffer with the default value. */ 2528 swap it out! */
2541 2529 swap_in_global_binding (sym);
2542 tem = XBUFFER_LOCAL_VALUE (SYMBOL_VALUE (sym))->cdr;
2543 /* Store the symbol's current value into the alist entry
2544 it is currently set up for. This is so that, if the
2545 local is marked permanent, and we make it local again
2546 later in Fkill_all_local_variables, we don't lose the value. */
2547 XSETCDR (XCAR (tem),
2548 do_symval_forwarding (XBUFFER_LOCAL_VALUE (SYMBOL_VALUE (sym))->realvalue));
2549 /* Switch to the symbol's default-value alist entry. */
2550 XSETCAR (tem, tem);
2551 /* Mark it as current for buffer B. */
2552 XBUFFER_LOCAL_VALUE (SYMBOL_VALUE (sym))->buffer = buffer;
2553 /* Store the current value into any forwarding in the symbol. */
2554 store_symval_forwarding (sym,
2555 XBUFFER_LOCAL_VALUE (SYMBOL_VALUE (sym))->realvalue,
2556 XCDR (tem), NULL);
2557 } 2530 }
2558 } 2531 }
2559} 2532}
@@ -4434,13 +4407,13 @@ evaporate_overlays (pos)
4434 in the slot with offset OFFSET. */ 4407 in the slot with offset OFFSET. */
4435 4408
4436void 4409void
4437buffer_slot_type_mismatch (offset) 4410buffer_slot_type_mismatch (sym, type)
4438 int offset; 4411 Lisp_Object sym;
4412 int type;
4439{ 4413{
4440 Lisp_Object sym;
4441 char *type_name; 4414 char *type_name;
4442 4415
4443 switch (XINT (PER_BUFFER_TYPE (offset))) 4416 switch (type)
4444 { 4417 {
4445 case Lisp_Int: 4418 case Lisp_Int:
4446 type_name = "integers"; 4419 type_name = "integers";
@@ -4458,7 +4431,6 @@ buffer_slot_type_mismatch (offset)
4458 abort (); 4431 abort ();
4459 } 4432 }
4460 4433
4461 sym = PER_BUFFER_SYMBOL (offset);
4462 error ("Only %s should be stored in the buffer-local variable %s", 4434 error ("Only %s should be stored in the buffer-local variable %s",
4463 type_name, SDATA (SYMBOL_NAME (sym))); 4435 type_name, SDATA (SYMBOL_NAME (sym)));
4464} 4436}
@@ -5306,9 +5278,9 @@ defvar_per_buffer (namestring, address, type, doc)
5306 5278
5307 XMISCTYPE (val) = Lisp_Misc_Buffer_Objfwd; 5279 XMISCTYPE (val) = Lisp_Misc_Buffer_Objfwd;
5308 XBUFFER_OBJFWD (val)->offset = offset; 5280 XBUFFER_OBJFWD (val)->offset = offset;
5281 XBUFFER_OBJFWD (val)->slottype = type;
5309 SET_SYMBOL_VALUE (sym, val); 5282 SET_SYMBOL_VALUE (sym, val);
5310 PER_BUFFER_SYMBOL (offset) = sym; 5283 PER_BUFFER_SYMBOL (offset) = sym;
5311 PER_BUFFER_TYPE (offset) = type;
5312 5284
5313 if (PER_BUFFER_IDX (offset) == 0) 5285 if (PER_BUFFER_IDX (offset) == 0)
5314 /* Did a DEFVAR_PER_BUFFER without initializing the corresponding 5286 /* 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
561 /* Position where the overlay lists are centered. */ 561 /* Position where the overlay lists are centered. */
562 EMACS_INT overlay_center; 562 EMACS_INT overlay_center;
563 563
564 /* Changes in the buffer are recorded here for undo.
565 t means don't record anything.
566 This information belongs to the base buffer of an indirect buffer,
567 But we can't store it in the struct buffer_text
568 because local variables have to be right in the struct buffer.
569 So we copy it around in set_buffer_internal.
570 This comes before `name' because it is marked in a special way. */
571 Lisp_Object undo_list;
572
564 /* Everything from here down must be a Lisp_Object. */ 573 /* Everything from here down must be a Lisp_Object. */
565 574
566 /* The name of this buffer. */ 575 /* The name of this buffer. */
@@ -601,15 +610,6 @@ struct buffer
601 /* Mode line element that controls format of mode line. */ 610 /* Mode line element that controls format of mode line. */
602 Lisp_Object mode_line_format; 611 Lisp_Object mode_line_format;
603 612
604 /* Changes in the buffer are recorded here for undo.
605 t means don't record anything.
606 This information belongs to the base buffer of an indirect buffer,
607 But we can't store it in the struct buffer_text
608 because local variables have to be right in the struct buffer.
609 So we copy it around in set_buffer_internal.
610 This comes before `name' because it is marked in a special way. */
611 Lisp_Object undo_list;
612
613 /* Analogous to mode_line_format for the line displayed at the top 613 /* Analogous to mode_line_format for the line displayed at the top
614 of windows. Nil means don't display that line. */ 614 of windows. Nil means don't display that line. */
615 Lisp_Object header_line_format; 615 Lisp_Object header_line_format;
@@ -827,18 +827,6 @@ extern struct buffer buffer_local_flags;
827 that don't have such names. */ 827 that don't have such names. */
828 828
829extern struct buffer buffer_local_symbols; 829extern struct buffer buffer_local_symbols;
830
831/* This structure holds the required types for the values in the
832 buffer-local slots. If a slot contains Qnil, then the
833 corresponding buffer slot may contain a value of any type. If a
834 slot contains an integer, then prospective values' tags must be
835 equal to that integer (except nil is always allowed).
836 When a tag does not match, the function
837 buffer_slot_type_mismatch will signal an error.
838
839 If a slot here contains -1, the corresponding variable is read-only. */
840
841extern struct buffer buffer_local_types;
842 830
843extern void delete_all_overlays P_ ((struct buffer *)); 831extern void delete_all_overlays P_ ((struct buffer *));
844extern void reset_buffer P_ ((struct buffer *)); 832extern void reset_buffer P_ ((struct buffer *));
@@ -852,7 +840,7 @@ extern void set_buffer_internal P_ ((struct buffer *));
852extern void set_buffer_internal_1 P_ ((struct buffer *)); 840extern void set_buffer_internal_1 P_ ((struct buffer *));
853extern void set_buffer_temp P_ ((struct buffer *)); 841extern void set_buffer_temp P_ ((struct buffer *));
854extern void record_buffer P_ ((Lisp_Object)); 842extern void record_buffer P_ ((Lisp_Object));
855extern void buffer_slot_type_mismatch P_ ((int)) NO_RETURN; 843extern void buffer_slot_type_mismatch P_ ((Lisp_Object, int)) NO_RETURN;
856extern void fix_overlays_before P_ ((struct buffer *, EMACS_INT, EMACS_INT)); 844extern void fix_overlays_before P_ ((struct buffer *, EMACS_INT, EMACS_INT));
857extern void mmap_set_vars P_ ((int)); 845extern void mmap_set_vars P_ ((int));
858 846
@@ -1005,11 +993,5 @@ extern int last_per_buffer_idx;
1005#define PER_BUFFER_SYMBOL(OFFSET) \ 993#define PER_BUFFER_SYMBOL(OFFSET) \
1006 (*(Lisp_Object *)((OFFSET) + (char *) &buffer_local_symbols)) 994 (*(Lisp_Object *)((OFFSET) + (char *) &buffer_local_symbols))
1007 995
1008/* Return the type of the per-buffer variable at offset OFFSET in the
1009 buffer structure. */
1010
1011#define PER_BUFFER_TYPE(OFFSET) \
1012 (*(Lisp_Object *)((OFFSET) + (char *) &buffer_local_types))
1013
1014/* arch-tag: 679305dd-d41c-4a50-b170-3caf5c97b2d1 996/* arch-tag: 679305dd-d41c-4a50-b170-3caf5c97b2d1
1015 (do not change this comment) */ 997 (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. */
117/* Define to 1 if you have /usr/lib/crti.o. */ 117/* Define to 1 if you have /usr/lib/crti.o. */
118#undef HAVE_CRTIN 118#undef HAVE_CRTIN
119 119
120/* Define to 1 if using D-Bus. */
121#undef HAVE_DBUS
122
120/* Define to 1 if you have the declaration of `sys_siglist', and to 0 if you 123/* Define to 1 if you have the declaration of `sys_siglist', and to 0 if you
121 don't. */ 124 don't. */
122#undef HAVE_DECL_SYS_SIGLIST 125#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)
864 register Lisp_Object valcontents; 864 register Lisp_Object valcontents;
865{ 865{
866 register Lisp_Object val; 866 register Lisp_Object val;
867 int offset;
868 if (MISCP (valcontents)) 867 if (MISCP (valcontents))
869 switch (XMISCTYPE (valcontents)) 868 switch (XMISCTYPE (valcontents))
870 { 869 {
@@ -879,11 +878,10 @@ do_symval_forwarding (valcontents)
879 return *XOBJFWD (valcontents)->objvar; 878 return *XOBJFWD (valcontents)->objvar;
880 879
881 case Lisp_Misc_Buffer_Objfwd: 880 case Lisp_Misc_Buffer_Objfwd:
882 offset = XBUFFER_OBJFWD (valcontents)->offset; 881 return PER_BUFFER_VALUE (current_buffer,
883 return PER_BUFFER_VALUE (current_buffer, offset); 882 XBUFFER_OBJFWD (valcontents)->offset);
884 883
885 case Lisp_Misc_Kboard_Objfwd: 884 case Lisp_Misc_Kboard_Objfwd:
886 offset = XKBOARD_OBJFWD (valcontents)->offset;
887 /* We used to simply use current_kboard here, but from Lisp 885 /* We used to simply use current_kboard here, but from Lisp
888 code, it's value is often unexpected. It seems nicer to 886 code, it's value is often unexpected. It seems nicer to
889 allow constructions like this to work as intuitively expected: 887 allow constructions like this to work as intuitively expected:
@@ -895,7 +893,8 @@ do_symval_forwarding (valcontents)
895 last-command and real-last-command, and people may rely on 893 last-command and real-last-command, and people may rely on
896 that. I took a quick look at the Lisp codebase, and I 894 that. I took a quick look at the Lisp codebase, and I
897 don't think anything will break. --lorentey */ 895 don't think anything will break. --lorentey */
898 return *(Lisp_Object *)(offset + (char *)FRAME_KBOARD (SELECTED_FRAME ())); 896 return *(Lisp_Object *)(XKBOARD_OBJFWD (valcontents)->offset
897 + (char *)FRAME_KBOARD (SELECTED_FRAME ()));
899 } 898 }
900 return valcontents; 899 return valcontents;
901} 900}
@@ -922,13 +921,15 @@ store_symval_forwarding (symbol, valcontents, newval, buf)
922 case Lisp_Misc_Intfwd: 921 case Lisp_Misc_Intfwd:
923 CHECK_NUMBER (newval); 922 CHECK_NUMBER (newval);
924 *XINTFWD (valcontents)->intvar = XINT (newval); 923 *XINTFWD (valcontents)->intvar = XINT (newval);
925 if (*XINTFWD (valcontents)->intvar != XINT (newval)) 924 /* This can never happen since intvar points to an EMACS_INT
926 error ("Value out of range for variable `%s'", 925 which is at least large enough to hold a Lisp_Object.
927 SDATA (SYMBOL_NAME (symbol))); 926 if (*XINTFWD (valcontents)->intvar != XINT (newval))
927 error ("Value out of range for variable `%s'",
928 SDATA (SYMBOL_NAME (symbol))); */
928 break; 929 break;
929 930
930 case Lisp_Misc_Boolfwd: 931 case Lisp_Misc_Boolfwd:
931 *XBOOLFWD (valcontents)->boolvar = NILP (newval) ? 0 : 1; 932 *XBOOLFWD (valcontents)->boolvar = !NILP (newval);
932 break; 933 break;
933 934
934 case Lisp_Misc_Objfwd: 935 case Lisp_Misc_Objfwd:
@@ -968,12 +969,11 @@ store_symval_forwarding (symbol, valcontents, newval, buf)
968 case Lisp_Misc_Buffer_Objfwd: 969 case Lisp_Misc_Buffer_Objfwd:
969 { 970 {
970 int offset = XBUFFER_OBJFWD (valcontents)->offset; 971 int offset = XBUFFER_OBJFWD (valcontents)->offset;
971 Lisp_Object type; 972 Lisp_Object type = XBUFFER_OBJFWD (valcontents)->slottype;
972 973
973 type = PER_BUFFER_TYPE (offset);
974 if (! NILP (type) && ! NILP (newval) 974 if (! NILP (type) && ! NILP (newval)
975 && XTYPE (newval) != XINT (type)) 975 && XTYPE (newval) != XINT (type))
976 buffer_slot_type_mismatch (offset); 976 buffer_slot_type_mismatch (symbol, XINT (type));
977 977
978 if (buf == NULL) 978 if (buf == NULL)
979 buf = current_buffer; 979 buf = current_buffer;
@@ -1011,26 +1011,23 @@ void
1011swap_in_global_binding (symbol) 1011swap_in_global_binding (symbol)
1012 Lisp_Object symbol; 1012 Lisp_Object symbol;
1013{ 1013{
1014 Lisp_Object valcontents, cdr; 1014 Lisp_Object valcontents = SYMBOL_VALUE (symbol);
1015 1015 struct Lisp_Buffer_Local_Value *blv = XBUFFER_LOCAL_VALUE (valcontents);
1016 valcontents = SYMBOL_VALUE (symbol); 1016 Lisp_Object cdr = blv->cdr;
1017 if (!BUFFER_LOCAL_VALUEP (valcontents))
1018 abort ();
1019 cdr = XBUFFER_LOCAL_VALUE (valcontents)->cdr;
1020 1017
1021 /* Unload the previously loaded binding. */ 1018 /* Unload the previously loaded binding. */
1022 Fsetcdr (XCAR (cdr), 1019 Fsetcdr (XCAR (cdr),
1023 do_symval_forwarding (XBUFFER_LOCAL_VALUE (valcontents)->realvalue)); 1020 do_symval_forwarding (blv->realvalue));
1024 1021
1025 /* Select the global binding in the symbol. */ 1022 /* Select the global binding in the symbol. */
1026 XSETCAR (cdr, cdr); 1023 XSETCAR (cdr, cdr);
1027 store_symval_forwarding (symbol, valcontents, XCDR (cdr), NULL); 1024 store_symval_forwarding (symbol, blv->realvalue, XCDR (cdr), NULL);
1028 1025
1029 /* Indicate that the global binding is set up now. */ 1026 /* Indicate that the global binding is set up now. */
1030 XBUFFER_LOCAL_VALUE (valcontents)->frame = Qnil; 1027 blv->frame = Qnil;
1031 XBUFFER_LOCAL_VALUE (valcontents)->buffer = Qnil; 1028 blv->buffer = Qnil;
1032 XBUFFER_LOCAL_VALUE (valcontents)->found_for_frame = 0; 1029 blv->found_for_frame = 0;
1033 XBUFFER_LOCAL_VALUE (valcontents)->found_for_buffer = 0; 1030 blv->found_for_buffer = 0;
1034} 1031}
1035 1032
1036/* Set up the buffer-local symbol SYMBOL for validity in the current buffer. 1033/* Set up the buffer-local symbol SYMBOL for validity in the current buffer.
@@ -1106,31 +1103,7 @@ find_symbol_value (symbol)
1106 if (BUFFER_LOCAL_VALUEP (valcontents)) 1103 if (BUFFER_LOCAL_VALUEP (valcontents))
1107 valcontents = swap_in_symval_forwarding (symbol, valcontents); 1104 valcontents = swap_in_symval_forwarding (symbol, valcontents);
1108 1105
1109 if (MISCP (valcontents)) 1106 return do_symval_forwarding (valcontents);
1110 {
1111 switch (XMISCTYPE (valcontents))
1112 {
1113 case Lisp_Misc_Intfwd:
1114 XSETINT (val, *XINTFWD (valcontents)->intvar);
1115 return val;
1116
1117 case Lisp_Misc_Boolfwd:
1118 return (*XBOOLFWD (valcontents)->boolvar ? Qt : Qnil);
1119
1120 case Lisp_Misc_Objfwd:
1121 return *XOBJFWD (valcontents)->objvar;
1122
1123 case Lisp_Misc_Buffer_Objfwd:
1124 return PER_BUFFER_VALUE (current_buffer,
1125 XBUFFER_OBJFWD (valcontents)->offset);
1126
1127 case Lisp_Misc_Kboard_Objfwd:
1128 return *(Lisp_Object *)(XKBOARD_OBJFWD (valcontents)->offset
1129 + (char *)FRAME_KBOARD (SELECTED_FRAME ()));
1130 }
1131 }
1132
1133 return valcontents;
1134} 1107}
1135 1108
1136DEFUN ("symbol-value", Fsymbol_value, Ssymbol_value, 1, 1, 0, 1109DEFUN ("symbol-value", Fsymbol_value, Ssymbol_value, 1, 1, 0,
@@ -1240,9 +1213,9 @@ set_internal (symbol, newval, buf, bindflag)
1240 || buf != XBUFFER (XBUFFER_LOCAL_VALUE (valcontents)->buffer) 1213 || buf != XBUFFER (XBUFFER_LOCAL_VALUE (valcontents)->buffer)
1241 || (XBUFFER_LOCAL_VALUE (valcontents)->check_frame 1214 || (XBUFFER_LOCAL_VALUE (valcontents)->check_frame
1242 && !EQ (selected_frame, XBUFFER_LOCAL_VALUE (valcontents)->frame)) 1215 && !EQ (selected_frame, XBUFFER_LOCAL_VALUE (valcontents)->frame))
1243 || (BUFFER_LOCAL_VALUEP (valcontents) 1216 /* Also unload a global binding (if the var is local_if_set). */
1244 && EQ (XCAR (current_alist_element), 1217 || (EQ (XCAR (current_alist_element),
1245 current_alist_element))) 1218 current_alist_element)))
1246 { 1219 {
1247 /* The currently loaded binding is not necessarily valid. 1220 /* The currently loaded binding is not necessarily valid.
1248 We need to unload it, and choose a new binding. */ 1221 We need to unload it, and choose a new binding. */
@@ -1260,7 +1233,7 @@ set_internal (symbol, newval, buf, bindflag)
1260 { 1233 {
1261 /* This buffer still sees the default value. */ 1234 /* This buffer still sees the default value. */
1262 1235
1263 /* If the variable is a Lisp_Some_Buffer_Local_Value, 1236 /* If the variable is not local_if_set,
1264 or if this is `let' rather than `set', 1237 or if this is `let' rather than `set',
1265 make CURRENT-ALIST-ELEMENT point to itself, 1238 make CURRENT-ALIST-ELEMENT point to itself,
1266 indicating that we're seeing the default value. 1239 indicating that we're seeing the default value.
@@ -1301,6 +1274,9 @@ set_internal (symbol, newval, buf, bindflag)
1301 XBUFFER_LOCAL_VALUE (valcontents)->frame = selected_frame; 1274 XBUFFER_LOCAL_VALUE (valcontents)->frame = selected_frame;
1302 } 1275 }
1303 innercontents = XBUFFER_LOCAL_VALUE (valcontents)->realvalue; 1276 innercontents = XBUFFER_LOCAL_VALUE (valcontents)->realvalue;
1277
1278 /* Store the new value in the cons-cell. */
1279 XSETCDR (XCAR (XBUFFER_LOCAL_VALUE (valcontents)->cdr), newval);
1304 } 1280 }
1305 1281
1306 /* If storing void (making the symbol void), forward only through 1282 /* If storing void (making the symbol void), forward only through
@@ -1310,24 +1286,6 @@ set_internal (symbol, newval, buf, bindflag)
1310 else 1286 else
1311 store_symval_forwarding (symbol, innercontents, newval, buf); 1287 store_symval_forwarding (symbol, innercontents, newval, buf);
1312 1288
1313 /* If we just set a variable whose current binding is frame-local,
1314 store the new value in the frame parameter too. */
1315
1316 if (BUFFER_LOCAL_VALUEP (valcontents))
1317 {
1318 /* What binding is loaded right now? */
1319 current_alist_element
1320 = XCAR (XBUFFER_LOCAL_VALUE (valcontents)->cdr);
1321
1322 /* If the current buffer is not the buffer whose binding is
1323 loaded, or if there may be frame-local bindings and the frame
1324 isn't the right one, or if it's a Lisp_Buffer_Local_Value and
1325 the default binding is loaded, the loaded binding may be the
1326 wrong one. */
1327 if (XBUFFER_LOCAL_VALUE (valcontents)->found_for_frame)
1328 XSETCDR (current_alist_element, newval);
1329 }
1330
1331 return newval; 1289 return newval;
1332} 1290}
1333 1291
@@ -2320,7 +2278,7 @@ NUMBER may be an integer or a floating point number. */)
2320 } 2278 }
2321 2279
2322 if (sizeof (int) == sizeof (EMACS_INT)) 2280 if (sizeof (int) == sizeof (EMACS_INT))
2323 sprintf (buffer, "%d", XINT (number)); 2281 sprintf (buffer, "%d", (int) XINT (number));
2324 else if (sizeof (long) == sizeof (EMACS_INT)) 2282 else if (sizeof (long) == sizeof (EMACS_INT))
2325 sprintf (buffer, "%ld", (long) XINT (number)); 2283 sprintf (buffer, "%ld", (long) XINT (number));
2326 else 2284 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 @@
1/* Elisp bindings for D-Bus.
2 Copyright (C) 2007 Free Software Foundation, Inc.
3
4This file is part of GNU Emacs.
5
6GNU Emacs is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 3, or (at your option)
9any later version.
10
11GNU Emacs is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Emacs; see the file COPYING. If not, write to
18the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19Boston, MA 02110-1301, USA. */
20
21#include "config.h"
22
23#ifdef HAVE_DBUS
24#include <stdlib.h>
25#include <dbus/dbus.h>
26#include "lisp.h"
27#include "frame.h"
28#include "termhooks.h"
29#include "keyboard.h"
30
31
32/* Subroutines. */
33Lisp_Object Qdbus_get_unique_name;
34Lisp_Object Qdbus_call_method;
35Lisp_Object Qdbus_send_signal;
36Lisp_Object Qdbus_register_signal;
37Lisp_Object Qdbus_unregister_signal;
38
39/* D-Bus error symbol. */
40Lisp_Object Qdbus_error;
41
42/* Lisp symbols of the system and session buses. */
43Lisp_Object QCdbus_system_bus, QCdbus_session_bus;
44
45/* Hash table which keeps function definitions. */
46Lisp_Object Vdbus_registered_functions_table;
47
48/* Whether to debug D-Bus. */
49Lisp_Object Vdbus_debug;
50
51
52/* We use "xd_" and "XD_" as prefix for all internal symbols, because
53 we don't want to poison other namespaces with "dbus_". */
54
55/* Raise a Lisp error from a D-Bus error. */
56#define XD_ERROR(error) \
57 { \
58 char s[1024]; \
59 strcpy (s, error.message); \
60 dbus_error_free (&error); \
61 /* Remove the trailing newline. */ \
62 if (strchr (s, '\n') != NULL) \
63 s[strlen (s) - 1] = '\0'; \
64 xsignal1 (Qdbus_error, build_string (s)); \
65 }
66
67/* Macros for debugging. In order to enable them, build with
68 "make MYCPPFLAGS='-DDBUS_DEBUG'". */
69#ifdef DBUS_DEBUG
70#define XD_DEBUG_MESSAGE(...) \
71 { \
72 char s[1024]; \
73 sprintf (s, __VA_ARGS__); \
74 printf ("%s: %s\n", __func__, s); \
75 message ("%s: %s", __func__, s); \
76 }
77#define XD_DEBUG_VALID_LISP_OBJECT_P(object) \
78 if (!valid_lisp_object_p (object)) \
79 { \
80 XD_DEBUG_MESSAGE ("%s Assertion failure", __LINE__); \
81 xsignal1 (Qdbus_error, build_string ("Assertion failure")); \
82 }
83
84#else /* !DBUS_DEBUG */
85#define XD_DEBUG_MESSAGE(...) \
86 if (!NILP (Vdbus_debug)) \
87 { \
88 char s[1024]; \
89 sprintf (s, __VA_ARGS__); \
90 message ("%s: %s", __func__, s); \
91 }
92#define XD_DEBUG_VALID_LISP_OBJECT_P(object)
93#endif
94
95/* Determine the DBusType of a given Lisp object. It is used to
96 convert Lisp objects, being arguments of `dbus-call-method' or
97 `dbus-send-signal', into corresponding C values appended as
98 arguments to a D-Bus message. */
99#define XD_LISP_OBJECT_TO_DBUS_TYPE(object) \
100 (EQ (object, Qt) || EQ (object, Qnil)) ? DBUS_TYPE_BOOLEAN : \
101 (NATNUMP (object)) ? DBUS_TYPE_UINT32 : \
102 (INTEGERP (object)) ? DBUS_TYPE_INT32 : \
103 (FLOATP (object)) ? DBUS_TYPE_DOUBLE : \
104 (STRINGP (object)) ? DBUS_TYPE_STRING : \
105 DBUS_TYPE_INVALID
106
107/* Extract C value from Lisp OBJECT. DTYPE must be a valid DBusType,
108 as detected by XD_LISP_OBJECT_TO_DBUS_TYPE. Compound types are not
109 supported (yet). It is used to convert Lisp objects, being
110 arguments of `dbus-call-method' or `dbus-send-signal', into
111 corresponding C values appended as arguments to a D-Bus
112 message. */
113char *
114xd_retrieve_value (dtype, object)
115 uint dtype;
116 Lisp_Object object;
117{
118
119 XD_DEBUG_VALID_LISP_OBJECT_P (object);
120 switch (dtype)
121 {
122 case DBUS_TYPE_BOOLEAN:
123 XD_DEBUG_MESSAGE ("%d %s", dtype, (NILP (object)) ? "false" : "true");
124 return (NILP (object)) ? (char *) FALSE : (char *) TRUE;
125 case DBUS_TYPE_UINT32:
126 XD_DEBUG_MESSAGE ("%d %d", dtype, XUINT (object));
127 return (char *) XUINT (object);
128 case DBUS_TYPE_INT32:
129 XD_DEBUG_MESSAGE ("%d %d", dtype, XINT (object));
130 return (char *) XINT (object);
131 case DBUS_TYPE_DOUBLE:
132 XD_DEBUG_MESSAGE ("%d %d", dtype, XFLOAT (object));
133 return (char *) XFLOAT (object);
134 case DBUS_TYPE_STRING:
135 XD_DEBUG_MESSAGE ("%d %s", dtype, SDATA (object));
136 return SDATA (object);
137 default:
138 XD_DEBUG_MESSAGE ("DBus-Type %d not supported", dtype);
139 return NULL;
140 }
141}
142
143/* Retrieve C value from a DBusMessageIter structure ITER, and return
144 a converted Lisp object. The type DTYPE of the argument of the
145 D-Bus message must be a valid DBusType. Compound D-Bus types are
146 partly supported; they result always in a Lisp list. */
147Lisp_Object
148xd_retrieve_arg (dtype, iter)
149 uint dtype;
150 DBusMessageIter *iter;
151{
152
153 switch (dtype)
154 {
155 case DBUS_TYPE_BOOLEAN:
156 {
157 dbus_bool_t val;
158 dbus_message_iter_get_basic (iter, &val);
159 XD_DEBUG_MESSAGE ("%d %s", dtype, (val == FALSE) ? "false" : "true");
160 return (val == FALSE) ? Qnil : Qt;
161 }
162 case DBUS_TYPE_INT32:
163 case DBUS_TYPE_UINT32:
164 {
165 dbus_uint32_t val;
166 dbus_message_iter_get_basic (iter, &val);
167 XD_DEBUG_MESSAGE ("%d %d", dtype, val);
168 return make_number (val);
169 }
170 case DBUS_TYPE_STRING:
171 case DBUS_TYPE_OBJECT_PATH:
172 {
173 char *val;
174 dbus_message_iter_get_basic (iter, &val);
175 XD_DEBUG_MESSAGE ("%d %s", dtype, val);
176 return build_string (val);
177 }
178 case DBUS_TYPE_ARRAY:
179 case DBUS_TYPE_VARIANT:
180 case DBUS_TYPE_STRUCT:
181 case DBUS_TYPE_DICT_ENTRY:
182 {
183 Lisp_Object result;
184 struct gcpro gcpro1;
185 result = Qnil;
186 GCPRO1 (result);
187 DBusMessageIter subiter;
188 int subtype;
189 dbus_message_iter_recurse (iter, &subiter);
190 while ((subtype = dbus_message_iter_get_arg_type (&subiter))
191 != DBUS_TYPE_INVALID)
192 {
193 result = Fcons (xd_retrieve_arg (subtype, &subiter), result);
194 dbus_message_iter_next (&subiter);
195 }
196 RETURN_UNGCPRO (Fnreverse (result));
197 }
198 default:
199 XD_DEBUG_MESSAGE ("DBusType %d not supported", dtype);
200 return Qnil;
201 }
202}
203
204
205/* Initialize D-Bus connection. BUS is a Lisp symbol, either :system
206 or :session. It tells which D-Bus to be initialized. */
207DBusConnection *
208xd_initialize (bus)
209 Lisp_Object bus;
210{
211 DBusConnection *connection;
212 DBusError derror;
213
214 /* Parameter check. */
215 CHECK_SYMBOL (bus);
216 if (!((EQ (bus, QCdbus_system_bus)) || (EQ (bus, QCdbus_session_bus))))
217 xsignal2 (Qdbus_error, build_string ("Wrong bus name"), bus);
218
219 /* Open a connection to the bus. */
220 dbus_error_init (&derror);
221
222 if (EQ (bus, QCdbus_system_bus))
223 connection = dbus_bus_get (DBUS_BUS_SYSTEM, &derror);
224 else
225 connection = dbus_bus_get (DBUS_BUS_SESSION, &derror);
226
227 if (dbus_error_is_set (&derror))
228 XD_ERROR (derror);
229
230 if (connection == NULL)
231 xsignal2 (Qdbus_error, build_string ("No connection"), bus);
232
233 /* Return the result. */
234 return connection;
235}
236
237DEFUN ("dbus-get-unique-name", Fdbus_get_unique_name, Sdbus_get_unique_name,
238 1, 1, 0,
239 doc: /* Return the unique name of Emacs registered at D-Bus BUS as string. */)
240 (bus)
241 Lisp_Object bus;
242{
243 DBusConnection *connection;
244 char name[1024];
245
246 /* Check parameters. */
247 CHECK_SYMBOL (bus);
248
249 /* Open a connection to the bus. */
250 connection = xd_initialize (bus);
251
252 /* Request the name. */
253 strcpy (name, dbus_bus_get_unique_name (connection));
254 if (name == NULL)
255 xsignal1 (Qdbus_error, build_string ("No unique name available"));
256
257 /* Return. */
258 return build_string (name);
259}
260
261DEFUN ("dbus-call-method", Fdbus_call_method, Sdbus_call_method, 5, MANY, 0,
262 doc: /* Call METHOD on the D-Bus BUS.
263
264BUS is either the symbol `:system' or the symbol `:session'.
265
266SERVICE is the D-Bus service name to be used. PATH is the D-Bus
267object path SERVICE is registered at. INTERFACE is an interface
268offered by SERVICE. It must provide METHOD.
269
270All other arguments ARGS are passed to METHOD as arguments. They are
271converted into D-Bus types via the following rules:
272
273 t and nil => DBUS_TYPE_BOOLEAN
274 number => DBUS_TYPE_UINT32
275 integer => DBUS_TYPE_INT32
276 float => DBUS_TYPE_DOUBLE
277 string => DBUS_TYPE_STRING
278
279Other Lisp objects are not supported as input arguments of METHOD.
280
281`dbus-call-method' returns the resulting values of METHOD as a list of
282Lisp objects. The type conversion happens the other direction as for
283input arguments. Additionally to the types supported for input
284arguments, the D-Bus compound types DBUS_TYPE_ARRAY, DBUS_TYPE_VARIANT,
285DBUS_TYPE_STRUCT and DBUS_TYPE_DICT_ENTRY are accepted. All of them
286are converted into a list of Lisp objects which correspond to the
287elements of the D-Bus container. Example:
288
289\(dbus-call-method
290 :session "GetKeyField" "org.gnome.seahorse"
291 "/org/gnome/seahorse/keys/openpgp" "org.gnome.seahorse.Keys"
292 "openpgp:657984B8C7A966DD" "simple-name")
293
294 => (t ("Philip R. Zimmermann"))
295
296If the result of the METHOD call is just one value, the converted Lisp
297object is returned instead of a list containing this single Lisp object.
298
299\(dbus-call-method
300 :system "GetPropertyString" "org.freedesktop.Hal"
301 "/org/freedesktop/Hal/devices/computer" "org.freedesktop.Hal.Device"
302 "system.kernel.machine")
303
304 => "i686"
305
306usage: (dbus-call-method BUS METHOD SERVICE PATH INTERFACE &rest ARGS) */)
307 (nargs, args)
308 int nargs;
309 register Lisp_Object *args;
310{
311 Lisp_Object bus, method, service, path, interface;
312 Lisp_Object result;
313 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
314 DBusConnection *connection;
315 DBusMessage *dmessage;
316 DBusMessage *reply;
317 DBusMessageIter iter;
318 DBusError derror;
319 uint dtype;
320 int i;
321 char *value;
322
323 /* Check parameters. */
324 bus = args[0];
325 method = args[1];
326 service = args[2];
327 path = args[3];
328 interface = args[4];
329
330 CHECK_SYMBOL (bus);
331 CHECK_STRING (method);
332 CHECK_STRING (service);
333 CHECK_STRING (path);
334 CHECK_STRING (interface);
335 GCPRO5 (bus, method, service, path, interface);
336
337 XD_DEBUG_MESSAGE ("%s %s %s %s",
338 SDATA (method),
339 SDATA (service),
340 SDATA (path),
341 SDATA (interface));
342
343 /* Open a connection to the bus. */
344 connection = xd_initialize (bus);
345
346 /* Create the message. */
347 dmessage = dbus_message_new_method_call (SDATA (service),
348 SDATA (path),
349 SDATA (interface),
350 SDATA (method));
351 if (dmessage == NULL)
352 {
353 UNGCPRO;
354 xsignal1 (Qdbus_error, build_string ("Unable to create a new message"));
355 }
356
357 UNGCPRO;
358
359 /* Append parameters to the message. */
360 for (i = 5; i < nargs; ++i)
361 {
362
363 XD_DEBUG_VALID_LISP_OBJECT_P (args[i]);
364 XD_DEBUG_MESSAGE ("Parameter%d %s",
365 i-4,
366 SDATA (format2 ("%s", args[i], Qnil)));
367
368 dtype = XD_LISP_OBJECT_TO_DBUS_TYPE (args[i]);
369 if (dtype == DBUS_TYPE_INVALID)
370 xsignal2 (Qdbus_error, build_string ("Not a valid argument"), args[i]);
371
372 value = (char *) xd_retrieve_value (dtype, args[i]);
373
374 if (!dbus_message_append_args (dmessage,
375 dtype,
376 &value,
377 DBUS_TYPE_INVALID))
378 xsignal2 (Qdbus_error,
379 build_string ("Unable to append argument"), args[i]);
380 }
381
382 /* Send the message. */
383 dbus_error_init (&derror);
384 reply = dbus_connection_send_with_reply_and_block (connection,
385 dmessage,
386 -1,
387 &derror);
388
389 if (dbus_error_is_set (&derror))
390 XD_ERROR (derror);
391
392 if (reply == NULL)
393 xsignal1 (Qdbus_error, build_string ("No reply"));
394
395 XD_DEBUG_MESSAGE ("Message sent");
396
397 /* Collect the results. */
398 result = Qnil;
399 GCPRO1 (result);
400
401 if (!dbus_message_iter_init (reply, &iter))
402 {
403 UNGCPRO;
404 xsignal1 (Qdbus_error, build_string ("Cannot read reply"));
405 }
406
407 /* Loop over the parameters of the D-Bus reply message. Construct a
408 Lisp list, which is returned by `dbus-call-method'. */
409 while ((dtype = dbus_message_iter_get_arg_type (&iter)) != DBUS_TYPE_INVALID)
410 {
411 result = Fcons (xd_retrieve_arg (dtype, &iter), result);
412 dbus_message_iter_next (&iter);
413 }
414
415 /* Cleanup. */
416 dbus_message_unref (dmessage);
417 dbus_message_unref (reply);
418
419 /* Return the result. If there is only one single Lisp object,
420 return it as-it-is, otherwise return the reversed list. */
421 if (XUINT (Flength (result)) == 1)
422 RETURN_UNGCPRO (XCAR (result));
423 else
424 RETURN_UNGCPRO (Fnreverse (result));
425}
426
427DEFUN ("dbus-send-signal", Fdbus_send_signal, Sdbus_send_signal, 5, MANY, 0,
428 doc: /* Send signal SIGNAL on the D-Bus BUS.
429
430BUS is either the symbol `:system' or the symbol `:session'.
431
432SERVICE is the D-Bus service name SIGNAL is sent from. PATH is the
433D-Bus object path SERVICE is registered at. INTERFACE is an interface
434offered by SERVICE. It must provide signal SIGNAL.
435
436All other arguments ARGS are passed to SIGNAL as arguments. They are
437converted into D-Bus types via the following rules:
438
439 t and nil => DBUS_TYPE_BOOLEAN
440 number => DBUS_TYPE_UINT32
441 integer => DBUS_TYPE_INT32
442 float => DBUS_TYPE_DOUBLE
443 string => DBUS_TYPE_STRING
444
445Other Lisp objects are not supported as arguments of SIGNAL.
446
447Example:
448
449\(dbus-send-signal
450 :session "Started" "org.gnu.emacs" "/org/gnu/emacs" "org.gnu.emacs")))
451
452usage: (dbus-send-signal BUS SIGNAL SERVICE PATH INTERFACE &rest ARGS) */)
453 (nargs, args)
454 int nargs;
455 register Lisp_Object *args;
456{
457 Lisp_Object bus, signal, service, path, interface;
458 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
459 DBusConnection *connection;
460 DBusMessage *dmessage;
461 uint dtype;
462 int i;
463 char *value;
464
465 /* Check parameters. */
466 bus = args[0];
467 signal = args[1];
468 service = args[2];
469 path = args[3];
470 interface = args[4];
471
472 CHECK_SYMBOL (bus);
473 CHECK_STRING (signal);
474 CHECK_STRING (service);
475 CHECK_STRING (path);
476 CHECK_STRING (interface);
477 GCPRO5 (bus, signal, service, path, interface);
478
479 XD_DEBUG_MESSAGE ("%s %s %s %s",
480 SDATA (signal),
481 SDATA (service),
482 SDATA (path),
483 SDATA (interface));
484
485 /* Open a connection to the bus. */
486 connection = xd_initialize (bus);
487
488 /* Create the message. */
489 dmessage = dbus_message_new_signal (SDATA (path),
490 SDATA (interface),
491 SDATA (signal));
492 if (dmessage == NULL)
493 {
494 UNGCPRO;
495 xsignal1 (Qdbus_error, build_string ("Unable to create a new message"));
496 }
497
498 UNGCPRO;
499
500 /* Append parameters to the message. */
501 for (i = 5; i < nargs; ++i)
502 {
503 XD_DEBUG_VALID_LISP_OBJECT_P (args[i]);
504 XD_DEBUG_MESSAGE ("Parameter%d %s",
505 i-4,
506 SDATA (format2 ("%s", args[i], Qnil)));
507
508 dtype = XD_LISP_OBJECT_TO_DBUS_TYPE (args[i]);
509 if (dtype == DBUS_TYPE_INVALID)
510 xsignal2 (Qdbus_error, build_string ("Not a valid argument"), args[i]);
511
512 value = (char *) xd_retrieve_value (dtype, args[i]);
513
514 if (!dbus_message_append_args (dmessage,
515 dtype,
516 &value,
517 DBUS_TYPE_INVALID))
518 xsignal2 (Qdbus_error,
519 build_string ("Unable to append argument"), args[i]);
520 }
521
522 /* Send the message. The message is just added to the outgoing
523 message queue. */
524 if (!dbus_connection_send (connection, dmessage, NULL))
525 xsignal1 (Qdbus_error, build_string ("Cannot send message"));
526
527 /* Flush connection to ensure the message is handled. */
528 dbus_connection_flush (connection);
529
530 XD_DEBUG_MESSAGE ("Signal sent");
531
532 /* Cleanup. */
533 dbus_message_unref (dmessage);
534
535 /* Return. */
536 return Qt;
537}
538
539/* Read queued incoming message of the D-Bus BUS. BUS is a Lisp
540 symbol, either :system or :session. */
541Lisp_Object
542xd_read_message (bus)
543 Lisp_Object bus;
544{
545 Lisp_Object key;
546 struct gcpro gcpro1;
547 static struct input_event event;
548 DBusConnection *connection;
549 DBusMessage *dmessage;
550 DBusMessageIter iter;
551 uint dtype;
552 char service[1024], path[1024], interface[1024], member[1024];
553
554 /* Open a connection to the bus. */
555 connection = xd_initialize (bus);
556
557 /* Non blocking read of the next available message. */
558 dbus_connection_read_write (connection, 0);
559 dmessage = dbus_connection_pop_message (connection);
560
561 /* Return if there is no queued message. */
562 if (dmessage == NULL)
563 return;
564
565 /* There is a message in the queue. Construct the D-Bus event. */
566 XD_DEBUG_MESSAGE ("Event received");
567 EVENT_INIT (event);
568
569 event.kind = DBUS_EVENT;
570 event.frame_or_window = Qnil;
571
572 /* Collect the parameters. */
573 event.arg = Qnil;
574 GCPRO1 (event.arg);
575
576 if (!dbus_message_iter_init (dmessage, &iter))
577 {
578 UNGCPRO;
579 XD_DEBUG_MESSAGE ("Cannot read event");
580 return;
581 }
582
583 /* Loop over the resulting parameters. Construct a list. */
584 while ((dtype = dbus_message_iter_get_arg_type (&iter)) != DBUS_TYPE_INVALID)
585 {
586 event.arg = Fcons (xd_retrieve_arg (dtype, &iter), event.arg);
587 dbus_message_iter_next (&iter);
588 }
589
590 /* The arguments are stored in reverse order. Reorder them. */
591 event.arg = Fnreverse (event.arg);
592
593 /* Read service, object path interface and member from the
594 message. */
595 strcpy (service, dbus_message_get_sender (dmessage));
596 strcpy (path, dbus_message_get_path (dmessage));
597 strcpy (interface, dbus_message_get_interface (dmessage));
598 strcpy (member, dbus_message_get_member (dmessage));
599
600 /* Add them to the event. */
601 event.arg = Fcons ((member == NULL ? Qnil : build_string (member)),
602 event.arg);
603 event.arg = Fcons ((interface == NULL ? Qnil : build_string (interface)),
604 event.arg);
605 event.arg = Fcons ((path == NULL ? Qnil : build_string (path)),
606 event.arg);
607 event.arg = Fcons ((service == NULL ? Qnil : build_string (service)),
608 event.arg);
609
610 /* Add the bus symbol to the event. */
611 event.arg = Fcons (bus, event.arg);
612
613 /* Add the registered function of the message. */
614 key = list3 (bus,
615 (interface == NULL ? Qnil : build_string (interface)),
616 (member == NULL ? Qnil : build_string (member)));
617 event.arg = Fcons (Fgethash (key, Vdbus_registered_functions_table, Qnil),
618 event.arg);
619
620 /* Store it into the input event queue. */
621 kbd_buffer_store_event (&event);
622
623 /* Cleanup. */
624 dbus_message_unref (dmessage);
625 UNGCPRO;
626}
627
628/* Read queued incoming messages from the system and session buses. */
629void
630xd_read_queued_messages ()
631{
632
633 /* Vdbus_registered_functions_table will be made as hash table in
634 dbus.el. When it isn't loaded yet, it doesn't make sense to
635 handle D-Bus messages. Furthermore, we ignore all Lisp errors
636 during the call. */
637 if (HASH_TABLE_P (Vdbus_registered_functions_table))
638 {
639 internal_condition_case_1 (xd_read_message, QCdbus_system_bus,
640 Qerror, Fidentity);
641 internal_condition_case_1 (xd_read_message, QCdbus_session_bus,
642 Qerror, Fidentity);
643 }
644}
645
646DEFUN ("dbus-register-signal", Fdbus_register_signal, Sdbus_register_signal,
647 6, 6, 0,
648 doc: /* Register for signal SIGNAL on the D-Bus BUS.
649
650BUS is either the symbol `:system' or the symbol `:session'.
651
652SERVICE is the D-Bus service name used by the sending D-Bus object.
653It can be either a known name or the unique name of the D-Bus object
654sending the signal. When SERVICE is nil, related signals from all
655D-Bus objects shall be accepted.
656
657PATH is the D-Bus object path SERVICE is registered. It can also be
658nil if the path name of incoming signals shall not be checked.
659
660INTERFACE is an interface offered by SERVICE. It must provide SIGNAL.
661HANDLER is a Lisp function to be called when the signal is received.
662It must accept as arguments the values SIGNAL is sending. INTERFACE,
663SIGNAL and HANDLER must not be nil. Example:
664
665\(defun my-signal-handler (device)
666 (message "Device %s added" device))
667
668\(dbus-register-signal
669 :system "DeviceAdded"
670 (dbus-get-name-owner :system "org.freedesktop.Hal")
671 "/org/freedesktop/Hal/Manager" "org.freedesktop.Hal.Manager"
672 'my-signal-handler)
673
674 => (:system "org.freedesktop.Hal.Manager" "DeviceAdded")
675
676`dbus-register-signal' returns an object, which can be used in
677`dbus-unregister-signal' for removing the registration. */)
678 (bus, signal, service, path, interface, handler)
679 Lisp_Object bus, signal, service, path, interface, handler;
680{
681 Lisp_Object key;
682 DBusConnection *connection;
683 char rule[1024];
684 DBusError derror;
685
686 /* Check parameters. */
687 CHECK_SYMBOL (bus);
688 CHECK_STRING (signal);
689 if (!NILP (service)) CHECK_STRING (service);
690 if (!NILP (path)) CHECK_STRING (path);
691 CHECK_STRING (interface);
692 CHECK_SYMBOL (handler);
693
694 /* Open a connection to the bus. */
695 connection = xd_initialize (bus);
696
697 /* Create a rule to receive related signals. */
698 sprintf (rule,
699 "type='signal',interface='%s',member=%s%",
700 SDATA (interface),
701 SDATA (signal));
702
703 /* Add service and path to the rule if they are non-nil. */
704 if (!NILP (service))
705 sprintf (rule, "%s,sender='%s'%", rule, SDATA (service));
706
707 if (!NILP (path))
708 sprintf (rule, "%s,path='%s'", rule, SDATA (path));
709
710 /* Add the rule to the bus. */
711 dbus_error_init (&derror);
712 dbus_bus_add_match (connection, rule, &derror);
713 if (dbus_error_is_set (&derror))
714 XD_ERROR (derror);
715
716 XD_DEBUG_MESSAGE ("Matching rule \"%s\" created", rule);
717
718 /* Create a hash table entry. */
719 key = list3 (bus, interface, signal);
720 Fputhash (key, handler, Vdbus_registered_functions_table);
721 XD_DEBUG_MESSAGE ("\"%s\" registered with handler \"%s\"",
722 SDATA (format2 ("%s", key, Qnil)),
723 SDATA (format2 ("%s", handler, Qnil)));
724
725 /* Return key. */
726 return key;
727}
728
729DEFUN ("dbus-unregister-signal", Fdbus_unregister_signal, Sdbus_unregister_signal,
730 1, 1, 0,
731 doc: /* Unregister OBJECT from the D-Bus.
732OBJECT must be the result of a preceding `dbus-register-signal' call. */)
733 (object)
734 Lisp_Object object;
735{
736
737 /* Check parameters. */
738 CHECK_SYMBOL (object);
739
740 XD_DEBUG_MESSAGE ("\"%s\" unregistered with handler \"%s\"",
741 SDATA (format2 ("%s", object, Qnil)),
742 SDATA (format2 ("%s", Fsymbol_function (object), Qnil)));
743
744 /* Unintern the signal symbol. */
745 Fremhash (object, Vdbus_registered_functions_table);
746
747 /* Return. */
748 return Qnil;
749}
750
751
752void
753syms_of_dbusbind ()
754{
755
756 Qdbus_get_unique_name = intern ("dbus-get-unique-name");
757 staticpro (&Qdbus_get_unique_name);
758 defsubr (&Sdbus_get_unique_name);
759
760 Qdbus_call_method = intern ("dbus-call-method");
761 staticpro (&Qdbus_call_method);
762 defsubr (&Sdbus_call_method);
763
764 Qdbus_send_signal = intern ("dbus-send-signal");
765 staticpro (&Qdbus_send_signal);
766 defsubr (&Sdbus_send_signal);
767
768 Qdbus_register_signal = intern ("dbus-register-signal");
769 staticpro (&Qdbus_register_signal);
770 defsubr (&Sdbus_register_signal);
771
772 Qdbus_unregister_signal = intern ("dbus-unregister-signal");
773 staticpro (&Qdbus_unregister_signal);
774 defsubr (&Sdbus_unregister_signal);
775
776 Qdbus_error = intern ("dbus-error");
777 staticpro (&Qdbus_error);
778 Fput (Qdbus_error, Qerror_conditions,
779 list2 (Qdbus_error, Qerror));
780 Fput (Qdbus_error, Qerror_message,
781 build_string ("D-Bus error"));
782
783 QCdbus_system_bus = intern (":system");
784 staticpro (&QCdbus_system_bus);
785
786 QCdbus_session_bus = intern (":session");
787 staticpro (&QCdbus_session_bus);
788
789 DEFVAR_LISP ("dbus-registered-functions-table", &Vdbus_registered_functions_table,
790 doc: /* Hash table of registered functions for D-Bus.
791The key in the hash table is the list (BUS INTERFACE MEMBER). BUS is
792either the symbol `:system' or the symbol `:session'. INTERFACE is a
793string which denotes a D-Bus interface, and MEMBER, also a string, is
794either a method or a signal INTERFACE is offering.
795
796The value in the hash table a the function to be called when a D-Bus
797message, which matches the key criteria, arrives. */);
798 /* We initialize Vdbus_registered_functions_table in dbus.el,
799 because we need to define a hash table function first. */
800 Vdbus_registered_functions_table = Qnil;
801
802 DEFVAR_LISP ("dbus-debug", &Vdbus_debug,
803 doc: /* If non-nil, debug messages of D-Bus bindings are raised. */);
804#ifdef DBUS_DEBUG
805 Vdbus_debug = Qt;
806#else
807 Vdbus_debug = Qnil;
808#endif
809
810 Fprovide (intern ("dbusbind"), Qnil);
811
812}
813
814#endif /* HAVE_DBUS */
815
816/* arch-tag: 0e828477-b571-4fe4-b559-5c9211bc14b8
817 (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 ()
6893 exit (1); 6893 exit (1);
6894 } 6894 }
6895 6895
6896#ifdef WINDOWSNT
6897 terminal_type = "w32console";
6898#else
6896 /* Look at the TERM variable. */ 6899 /* Look at the TERM variable. */
6897 terminal_type = (char *) getenv ("TERM"); 6900 terminal_type = (char *) getenv ("TERM");
6901#endif
6898 if (!terminal_type) 6902 if (!terminal_type)
6899 { 6903 {
6900#ifdef VMS 6904#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) */)
3673 precision[n+1] = 10 * precision[n+1] + *format - '0'; 3673 precision[n+1] = 10 * precision[n+1] + *format - '0';
3674 } 3674 }
3675 3675
3676 if (format - this_format_start + 1 > longest_format) 3676 /* Extra +1 for 'l' that we may need to insert into the
3677 longest_format = format - this_format_start + 1; 3677 format. */
3678 if (format - this_format_start + 2 > longest_format)
3679 longest_format = format - this_format_start + 2;
3678 3680
3679 if (format == end) 3681 if (format == end)
3680 error ("Format string ends in middle of format specifier"); 3682 error ("Format string ends in middle of format specifier");
@@ -3735,7 +3737,7 @@ usage: (format STRING &rest OBJECTS) */)
3735 && *format != 'i' && *format != 'X' && *format != 'c') 3737 && *format != 'i' && *format != 'X' && *format != 'c')
3736 error ("Invalid format operation %%%c", *format); 3738 error ("Invalid format operation %%%c", *format);
3737 3739
3738 thissize = 30; 3740 thissize = 30 + (precision[n] > 0 ? precision[n] : 0);
3739 if (*format == 'c') 3741 if (*format == 'c')
3740 { 3742 {
3741 if (! ASCII_CHAR_P (XINT (args[n])) 3743 if (! ASCII_CHAR_P (XINT (args[n]))
@@ -3933,23 +3935,40 @@ usage: (format STRING &rest OBJECTS) */)
3933 format - this_format_start); 3935 format - this_format_start);
3934 this_format[format - this_format_start] = 0; 3936 this_format[format - this_format_start] = 0;
3935 3937
3936 if (INTEGERP (args[n])) 3938 if (format[-1] == 'e' || format[-1] == 'f' || format[-1] == 'g')
3939 sprintf (p, this_format, XFLOAT_DATA (args[n]));
3940 else
3937 { 3941 {
3938 if (format[-1] == 'd') 3942 if (sizeof (EMACS_INT) > sizeof (int)
3939 sprintf (p, this_format, XINT (args[n])); 3943 && format[-1] != 'c')
3940 /* Don't sign-extend for octal or hex printing. */ 3944 {
3945 /* Insert 'l' before format spec. */
3946 this_format[format - this_format_start]
3947 = this_format[format - this_format_start - 1];
3948 this_format[format - this_format_start - 1] = 'l';
3949 this_format[format - this_format_start + 1] = 0;
3950 }
3951
3952 if (INTEGERP (args[n]))
3953 {
3954 if (format[-1] == 'c')
3955 sprintf (p, this_format, (int) XINT (args[n]));
3956 else if (format[-1] == 'd')
3957 sprintf (p, this_format, XINT (args[n]));
3958 /* Don't sign-extend for octal or hex printing. */
3959 else
3960 sprintf (p, this_format, XUINT (args[n]));
3961 }
3962 else if (format[-1] == 'c')
3963 sprintf (p, this_format, (int) XFLOAT_DATA (args[n]));
3964 else if (format[-1] == 'd')
3965 /* Maybe we should use "%1.0f" instead so it also works
3966 for values larger than MAXINT. */
3967 sprintf (p, this_format, (EMACS_INT) XFLOAT_DATA (args[n]));
3941 else 3968 else
3942 sprintf (p, this_format, XUINT (args[n])); 3969 /* Don't sign-extend for octal or hex printing. */
3970 sprintf (p, this_format, (EMACS_UINT) XFLOAT_DATA (args[n]));
3943 } 3971 }
3944 else if (format[-1] == 'e' || format[-1] == 'f' || format[-1] == 'g')
3945 sprintf (p, this_format, XFLOAT_DATA (args[n]));
3946 else if (format[-1] == 'd')
3947 /* Maybe we should use "%1.0f" instead so it also works
3948 for values larger than MAXINT. */
3949 sprintf (p, this_format, (EMACS_INT) XFLOAT_DATA (args[n]));
3950 else
3951 /* Don't sign-extend for octal or hex printing. */
3952 sprintf (p, this_format, (EMACS_UINT) XFLOAT_DATA (args[n]));
3953 3972
3954 if (p > buf 3973 if (p > buf
3955 && multibyte 3974 && 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;
353void (*fatal_error_signal_hook) P_ ((void)); 353void (*fatal_error_signal_hook) P_ ((void));
354 354
355#ifdef HAVE_GTK_AND_PTHREAD 355#ifdef HAVE_GTK_AND_PTHREAD
356/* When compiled with GTK and running under Gnome, multiple threads meay be 356/* When compiled with GTK and running under Gnome, multiple threads may be
357 created. Keep track of our main thread to make sure signals are delivered 357 created. Keep track of our main thread to make sure signals are delivered
358 to it (see syssignal.h). */ 358 to it (see syssignal.h). */
359 359
@@ -1664,6 +1664,10 @@ main (argc, argv
1664 syms_of_fontset (); 1664 syms_of_fontset ();
1665#endif /* MAC_OSX && HAVE_CARBON */ 1665#endif /* MAC_OSX && HAVE_CARBON */
1666 1666
1667#ifdef HAVE_DBUS
1668 syms_of_dbusbind ();
1669#endif /* HAVE_DBUS */
1670
1667#ifdef SYMS_SYSTEM 1671#ifdef SYMS_SYSTEM
1668 SYMS_SYSTEM; 1672 SYMS_SYSTEM;
1669#endif 1673#endif
@@ -1693,6 +1697,7 @@ main (argc, argv
1693 1697
1694 init_charset (); 1698 init_charset ();
1695 1699
1700 init_editfns (); /* init_process uses Voperating_system_release. */
1696 init_process (); /* init_display uses add_keyboard_wait_descriptor. */ 1701 init_process (); /* init_display uses add_keyboard_wait_descriptor. */
1697#ifndef MAC_OS8 1702#ifndef MAC_OS8
1698 /* Called before init_window_once for Mac OS Classic. */ 1703 /* Called before init_window_once for Mac OS Classic. */
@@ -1715,7 +1720,6 @@ main (argc, argv
1715 init_image (); 1720 init_image ();
1716#endif /* HAVE_WINDOW_SYSTEM */ 1721#endif /* HAVE_WINDOW_SYSTEM */
1717 init_macros (); 1722 init_macros ();
1718 init_editfns ();
1719 init_floatfns (); 1723 init_floatfns ();
1720#ifdef VMS 1724#ifdef VMS
1721 init_vmsfns (); 1725 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
3263specbind (symbol, value) 3263specbind (symbol, value)
3264 Lisp_Object symbol, value; 3264 Lisp_Object symbol, value;
3265{ 3265{
3266 Lisp_Object ovalue;
3267 Lisp_Object valcontents; 3266 Lisp_Object valcontents;
3268 3267
3269 CHECK_SYMBOL (symbol); 3268 CHECK_SYMBOL (symbol);
@@ -3283,9 +3282,7 @@ specbind (symbol, value)
3283 } 3282 }
3284 else 3283 else
3285 { 3284 {
3286 Lisp_Object valcontents; 3285 Lisp_Object ovalue = find_symbol_value (symbol);
3287
3288 ovalue = find_symbol_value (symbol);
3289 specpdl_ptr->func = 0; 3286 specpdl_ptr->func = 0;
3290 specpdl_ptr->old_value = ovalue; 3287 specpdl_ptr->old_value = ovalue;
3291 3288
@@ -3330,10 +3327,14 @@ specbind (symbol, value)
3330 specpdl_ptr->symbol = symbol; 3327 specpdl_ptr->symbol = symbol;
3331 3328
3332 specpdl_ptr++; 3329 specpdl_ptr++;
3333 if (BUFFER_OBJFWDP (ovalue) || KBOARD_OBJFWDP (ovalue)) 3330 /* We used to do
3334 store_symval_forwarding (symbol, ovalue, value, NULL); 3331 if (BUFFER_OBJFWDP (ovalue) || KBOARD_OBJFWDP (ovalue))
3335 else 3332 store_symval_forwarding (symbol, ovalue, value, NULL);
3336 set_internal (symbol, value, 0, 1); 3333 else
3334 but ovalue comes from find_symbol_value which should never return
3335 such an internal value. */
3336 eassert (!(BUFFER_OBJFWDP (ovalue) || KBOARD_OBJFWDP (ovalue)));
3337 set_internal (symbol, value, 0, 1);
3337 } 3338 }
3338} 3339}
3339 3340
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)
2970 2970
2971int xg_ignore_gtk_scrollbar; 2971int xg_ignore_gtk_scrollbar;
2972 2972
2973/* SET_SCROLL_BAR_X_WINDOW assumes the second argument fits in 2973/* Xlib's `Window' fits in 32 bits. But we want to store pointers, and they
2974 32 bits. But we want to store pointers, and they may be larger 2974 may be larger than 32 bits. Keep a mapping from integer index to widget
2975 than 32 bits. Keep a mapping from integer index to widget pointers 2975 pointers to get around the 32 bit limitation. */
2976 to get around the 32 bit limitation. */
2977 2976
2978static struct 2977static struct
2979{ 2978{
@@ -3183,7 +3182,7 @@ xg_create_scroll_bar (f, bar, scroll_callback, scroll_bar_name)
3183 /* Set the cursor to an arrow. */ 3182 /* Set the cursor to an arrow. */
3184 xg_set_cursor (webox, FRAME_X_DISPLAY_INFO (f)->xg_cursor); 3183 xg_set_cursor (webox, FRAME_X_DISPLAY_INFO (f)->xg_cursor);
3185 3184
3186 SET_SCROLL_BAR_X_WINDOW (bar, scroll_id); 3185 bar->x_window = scroll_id;
3187} 3186}
3188 3187
3189/* Make the scroll bar represented by SCROLLBAR_ID visible. */ 3188/* Make the scroll bar represented by SCROLLBAR_ID visible. */
@@ -3258,7 +3257,7 @@ xg_set_toolkit_scroll_bar_thumb (bar, portion, position, whole)
3258 struct scroll_bar *bar; 3257 struct scroll_bar *bar;
3259 int portion, position, whole; 3258 int portion, position, whole;
3260{ 3259{
3261 GtkWidget *wscroll = xg_get_widget_from_map (SCROLL_BAR_X_WINDOW (bar)); 3260 GtkWidget *wscroll = xg_get_widget_from_map (bar->x_window);
3262 3261
3263 FRAME_PTR f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window))); 3262 FRAME_PTR f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window)));
3264 3263
@@ -3822,6 +3821,7 @@ update_frame_tool_bar (f)
3822 GtkWidget *wbutton = NULL; 3821 GtkWidget *wbutton = NULL;
3823 GtkWidget *weventbox; 3822 GtkWidget *weventbox;
3824 Lisp_Object func = intern ("x-gtk-map-stock"); 3823 Lisp_Object func = intern ("x-gtk-map-stock");
3824 Lisp_Object specified_file;
3825 3825
3826 ti = gtk_toolbar_get_nth_item (GTK_TOOLBAR (x->toolbar_widget), i); 3826 ti = gtk_toolbar_get_nth_item (GTK_TOOLBAR (x->toolbar_widget), i);
3827 3827
@@ -3840,8 +3840,9 @@ update_frame_tool_bar (f)
3840 continue; 3840 continue;
3841 } 3841 }
3842 3842
3843 if (EQ (Qt, Ffboundp (func))) 3843 specified_file = file_for_image (image);
3844 stock = call1 (func, file_for_image (image)); 3844 if (!NILP (specified_file) && EQ (Qt, Ffboundp (func)))
3845 stock = call1 (func, specified_file);
3845 3846
3846 if (! NILP (stock) && STRINGP (stock)) 3847 if (! NILP (stock) && STRINGP (stock))
3847 { 3848 {
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)
3128 release_frame_dc (f, hdc); 3128 release_frame_dc (f, hdc);
3129 old_prev = SelectObject (old_img_dc, img->pixmap); 3129 old_prev = SelectObject (old_img_dc, img->pixmap);
3130 new_prev = SelectObject (new_img_dc, new_pixmap); 3130 new_prev = SelectObject (new_img_dc, new_pixmap);
3131 /* Windows convention for mono bitmaps is black = background,
3132 white = foreground. */
3131 SetTextColor (new_img_dc, background); 3133 SetTextColor (new_img_dc, background);
3132 SetBkColor (new_img_dc, foreground); 3134 SetBkColor (new_img_dc, foreground);
3133 3135
@@ -3523,6 +3525,19 @@ xbm_load (f, img)
3523 else 3525 else
3524 bits = XBOOL_VECTOR (data)->data; 3526 bits = XBOOL_VECTOR (data)->data;
3525 3527
3528#ifdef WINDOWSNT
3529 {
3530 char *invertedBits;
3531 int nbytes, i;
3532 /* Windows mono bitmaps are reversed compared with X. */
3533 invertedBits = bits;
3534 nbytes = (img->width + BITS_PER_CHAR - 1) / BITS_PER_CHAR
3535 * img->height;
3536 bits = (char *) alloca(nbytes);
3537 for (i = 0; i < nbytes; i++)
3538 bits[i] = XBM_BIT_SHUFFLE (invertedBits[i]);
3539 }
3540#endif
3526 /* Create the pixmap. */ 3541 /* Create the pixmap. */
3527 3542
3528 Create_Pixmap_From_Bitmap_Data (f, img, bits, 3543 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;
514#ifdef MAC_OS 514#ifdef MAC_OS
515Lisp_Object Qmac_apple_event; 515Lisp_Object Qmac_apple_event;
516#endif 516#endif
517 517#ifdef HAVE_DBUS
518Lisp_Object Qdbus_event;
519#endif
518/* Lisp_Object Qmouse_movement; - also an event header */ 520/* Lisp_Object Qmouse_movement; - also an event header */
519 521
520/* Properties of event headers. */ 522/* Properties of event headers. */
@@ -1570,7 +1572,7 @@ command_loop_1 ()
1570#ifdef MULTI_KBOARD 1572#ifdef MULTI_KBOARD
1571 int was_locked = single_kboard; 1573 int was_locked = single_kboard;
1572#endif 1574#endif
1573#endif 1575#endif
1574 int already_adjusted = 0; 1576 int already_adjusted = 0;
1575 1577
1576 current_kboard->Vprefix_arg = Qnil; 1578 current_kboard->Vprefix_arg = Qnil;
@@ -2566,7 +2568,7 @@ do { if (polling_stopped_here) start_polling (); \
2566 USED_MOUSE_MENU is null, we don't dereference it. 2568 USED_MOUSE_MENU is null, we don't dereference it.
2567 2569
2568 Value is -2 when we find input on another keyboard. A second call 2570 Value is -2 when we find input on another keyboard. A second call
2569 to read_char will read it. 2571 to read_char will read it.
2570 2572
2571 If END_TIME is non-null, it is a pointer to an EMACS_TIME 2573 If END_TIME is non-null, it is a pointer to an EMACS_TIME
2572 specifying the maximum time to wait until. If no input arrives by 2574 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)
3181 int count = SPECPDL_INDEX (); 3183 int count = SPECPDL_INDEX ();
3182 record_single_kboard_state (); 3184 record_single_kboard_state ();
3183#endif 3185#endif
3184 3186
3185 last_input_char = c; 3187 last_input_char = c;
3186 Fcommand_execute (tem, Qnil, Fvector (1, &last_input_char), Qt); 3188 Fcommand_execute (tem, Qnil, Fvector (1, &last_input_char), Qt);
3187 3189
@@ -4097,7 +4099,7 @@ kbd_buffer_get_event (kbp, used_mouse_menu, end_time)
4097 events. */ 4099 events. */
4098 if (CONSP (Vunread_command_events)) 4100 if (CONSP (Vunread_command_events))
4099 break; 4101 break;
4100 4102
4101 if (kbd_fetch_ptr != kbd_store_ptr) 4103 if (kbd_fetch_ptr != kbd_store_ptr)
4102 break; 4104 break;
4103#if defined (HAVE_MOUSE) || defined (HAVE_GPM) 4105#if defined (HAVE_MOUSE) || defined (HAVE_GPM)
@@ -4309,6 +4311,13 @@ kbd_buffer_get_event (kbp, used_mouse_menu, end_time)
4309 internal_last_event_frame = frame; 4311 internal_last_event_frame = frame;
4310 kbd_fetch_ptr = event + 1; 4312 kbd_fetch_ptr = event + 1;
4311 } 4313 }
4314#ifdef HAVE_DBUS
4315 else if (event->kind == DBUS_EVENT)
4316 {
4317 obj = make_lispy_event (event);
4318 kbd_fetch_ptr = event + 1;
4319 }
4320#endif
4312 else 4321 else
4313 { 4322 {
4314 /* If this event is on a different frame, return a switch-frame this 4323 /* If this event is on a different frame, return a switch-frame this
@@ -6187,6 +6196,13 @@ make_lispy_event (event)
6187 } 6196 }
6188#endif 6197#endif
6189 6198
6199#ifdef HAVE_DBUS
6200 case DBUS_EVENT:
6201 {
6202 return Fcons (Qdbus_event, event->arg);
6203 }
6204#endif /* HAVE_DBUS */
6205
6190#ifdef HAVE_GPM 6206#ifdef HAVE_GPM
6191 case GPM_CLICK_EVENT: 6207 case GPM_CLICK_EVENT:
6192 { 6208 {
@@ -6505,12 +6521,21 @@ lispy_modifier_list (modifiers)
6505 SYMBOL's Qevent_symbol_element_mask property, and maintains the 6521 SYMBOL's Qevent_symbol_element_mask property, and maintains the
6506 Qevent_symbol_elements property. */ 6522 Qevent_symbol_elements property. */
6507 6523
6524#define KEY_TO_CHAR(k) (XINT (k) & ((1 << CHARACTERBITS) - 1))
6525
6508Lisp_Object 6526Lisp_Object
6509parse_modifiers (symbol) 6527parse_modifiers (symbol)
6510 Lisp_Object symbol; 6528 Lisp_Object symbol;
6511{ 6529{
6512 Lisp_Object elements; 6530 Lisp_Object elements;
6513 6531
6532 if (INTEGERP (symbol))
6533 return (Fcons (make_number (KEY_TO_CHAR (symbol)),
6534 Fcons (make_number (XINT (symbol) & CHAR_MODIFIER_MASK),
6535 Qnil)));
6536 else if (!SYMBOLP (symbol))
6537 return Qnil;
6538
6514 elements = Fget (symbol, Qevent_symbol_element_mask); 6539 elements = Fget (symbol, Qevent_symbol_element_mask);
6515 if (CONSP (elements)) 6540 if (CONSP (elements))
6516 return elements; 6541 return elements;
@@ -6545,6 +6570,20 @@ parse_modifiers (symbol)
6545 } 6570 }
6546} 6571}
6547 6572
6573DEFUN ("internal-event-symbol-parse-modifiers", Fevent_symbol_parse_modifiers,
6574 Sevent_symbol_parse_modifiers, 1, 1, 0,
6575 doc: /* Parse the event symbol. For internal use. */)
6576 (symbol)
6577 Lisp_Object symbol;
6578{
6579 /* Fill the cache if needed. */
6580 parse_modifiers (symbol);
6581 /* Ignore the result (which is stored on Qevent_symbol_element_mask)
6582 and use the Lispier representation stored on Qevent_symbol_elements
6583 instead. */
6584 return Fget (symbol, Qevent_symbol_elements);
6585}
6586
6548/* Apply the modifiers MODIFIERS to the symbol BASE. 6587/* Apply the modifiers MODIFIERS to the symbol BASE.
6549 BASE must be unmodified. 6588 BASE must be unmodified.
6550 6589
@@ -6564,6 +6603,9 @@ apply_modifiers (modifiers, base)
6564 /* Mask out upper bits. We don't know where this value's been. */ 6603 /* Mask out upper bits. We don't know where this value's been. */
6565 modifiers &= INTMASK; 6604 modifiers &= INTMASK;
6566 6605
6606 if (INTEGERP (base))
6607 return make_number (XINT (base) | modifiers);
6608
6567 /* The click modifier never figures into cache indices. */ 6609 /* The click modifier never figures into cache indices. */
6568 cache = Fget (base, Qmodifier_cache); 6610 cache = Fget (base, Qmodifier_cache);
6569 XSETFASTINT (index, (modifiers & ~click_modifier)); 6611 XSETFASTINT (index, (modifiers & ~click_modifier));
@@ -6975,6 +7017,11 @@ void
6975gobble_input (expected) 7017gobble_input (expected)
6976 int expected; 7018 int expected;
6977{ 7019{
7020#ifdef HAVE_DBUS
7021 /* Check whether a D-Bus message has arrived. */
7022 xd_read_queued_messages ();
7023#endif /* HAVE_DBUS */
7024
6978#ifndef VMS 7025#ifndef VMS
6979#ifdef SIGIO 7026#ifdef SIGIO
6980 if (interrupt_input) 7027 if (interrupt_input)
@@ -7094,7 +7141,7 @@ read_avail_input (expected)
7094 nread += nr; 7141 nread += nr;
7095 expected = 0; 7142 expected = 0;
7096 } 7143 }
7097 7144
7098 if (nr == -1) /* Not OK to read input now. */ 7145 if (nr == -1) /* Not OK to read input now. */
7099 { 7146 {
7100 err = 1; 7147 err = 1;
@@ -7102,7 +7149,7 @@ read_avail_input (expected)
7102 else if (nr == -2) /* Non-transient error. */ 7149 else if (nr == -2) /* Non-transient error. */
7103 { 7150 {
7104 /* The terminal device terminated; it should be closed. */ 7151 /* The terminal device terminated; it should be closed. */
7105 7152
7106 /* Kill Emacs if this was our last terminal. */ 7153 /* Kill Emacs if this was our last terminal. */
7107 if (!terminal_list->next_terminal) 7154 if (!terminal_list->next_terminal)
7108 /* Formerly simply reported no input, but that 7155 /* Formerly simply reported no input, but that
@@ -7114,7 +7161,7 @@ read_avail_input (expected)
7114 group? Perhaps on systems with FIONREAD Emacs is 7161 group? Perhaps on systems with FIONREAD Emacs is
7115 alone in its group. */ 7162 alone in its group. */
7116 kill (getpid (), SIGHUP); 7163 kill (getpid (), SIGHUP);
7117 7164
7118 /* XXX Is calling delete_terminal safe here? It calls Fdelete_frame. */ 7165 /* XXX Is calling delete_terminal safe here? It calls Fdelete_frame. */
7119 if (t->delete_terminal_hook) 7166 if (t->delete_terminal_hook)
7120 (*t->delete_terminal_hook) (t); 7167 (*t->delete_terminal_hook) (t);
@@ -7287,14 +7334,14 @@ tty_read_avail_input (struct terminal *terminal,
7287 buf.modifiers = meta_modifier; 7334 buf.modifiers = meta_modifier;
7288 if (tty->meta_key != 2) 7335 if (tty->meta_key != 2)
7289 cbuf[i] &= ~0x80; 7336 cbuf[i] &= ~0x80;
7290 7337
7291 buf.code = cbuf[i]; 7338 buf.code = cbuf[i];
7292 /* Set the frame corresponding to the active tty. Note that the 7339 /* Set the frame corresponding to the active tty. Note that the
7293 value of selected_frame is not reliable here, redisplay tends 7340 value of selected_frame is not reliable here, redisplay tends
7294 to temporarily change it. */ 7341 to temporarily change it. */
7295 buf.frame_or_window = tty->top_frame; 7342 buf.frame_or_window = tty->top_frame;
7296 buf.arg = Qnil; 7343 buf.arg = Qnil;
7297 7344
7298 kbd_buffer_store_event (&buf); 7345 kbd_buffer_store_event (&buf);
7299 /* Don't look at input that follows a C-g too closely. 7346 /* Don't look at input that follows a C-g too closely.
7300 This reduces lossage due to autorepeat on C-g. */ 7347 This reduces lossage due to autorepeat on C-g. */
@@ -9210,7 +9257,7 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
9210 last_nonmenu_event = Qnil; 9257 last_nonmenu_event = Qnil;
9211 9258
9212 delayed_switch_frame = Qnil; 9259 delayed_switch_frame = Qnil;
9213 9260
9214 if (INTERACTIVE) 9261 if (INTERACTIVE)
9215 { 9262 {
9216 if (!NILP (prompt)) 9263 if (!NILP (prompt))
@@ -10102,32 +10149,44 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
10102 and is a shifted function key, 10149 and is a shifted function key,
10103 use the corresponding unshifted function key instead. */ 10150 use the corresponding unshifted function key instead. */
10104 if (first_binding >= nmaps 10151 if (first_binding >= nmaps
10105 && /* indec.start >= t && fkey.start >= t && */ keytran.start >= t 10152 && /* indec.start >= t && fkey.start >= t && */ keytran.start >= t)
10106 && SYMBOLP (key)) 10153 {
10107 { 10154 Lisp_Object breakdown = parse_modifiers (key);
10108 Lisp_Object breakdown; 10155 int modifiers
10109 int modifiers; 10156 = CONSP (breakdown) ? (XINT (XCAR (XCDR (breakdown)))) : 0;
10110 10157
10111 breakdown = parse_modifiers (key); 10158 if (modifiers & shift_modifier
10112 modifiers = XINT (XCAR (XCDR (breakdown))); 10159 /* Treat uppercase keys as shifted. */
10113 if (modifiers & shift_modifier) 10160 || (INTEGERP (key)
10161 & (KEY_TO_CHAR (key)
10162 < XCHAR_TABLE (current_buffer->downcase_table)->size)
10163 && UPPERCASEP (KEY_TO_CHAR (key))))
10114 { 10164 {
10115 Lisp_Object new_key; 10165 Lisp_Object new_key
10166 = (modifiers & shift_modifier
10167 ? apply_modifiers (modifiers & ~shift_modifier,
10168 XCAR (breakdown))
10169 : make_number (DOWNCASE (KEY_TO_CHAR (key)) | modifiers));
10116 10170
10117 original_uppercase = key; 10171 original_uppercase = key;
10118 original_uppercase_position = t - 1; 10172 original_uppercase_position = t - 1;
10119 10173
10120 modifiers &= ~shift_modifier; 10174 /* We have to do this unconditionally, regardless of whether
10121 new_key = apply_modifiers (modifiers, 10175 the lower-case char is defined in the keymaps, because they
10122 XCAR (breakdown)); 10176 might get translated through function-key-map. */
10123
10124 keybuf[t - 1] = new_key; 10177 keybuf[t - 1] = new_key;
10125 mock_input = max (t, mock_input); 10178 mock_input = max (t, mock_input);
10179 /* Reset fkey (and consequently keytran) to apply
10180 function-key-map on the result, so that S-backspace is
10181 correctly mapped to DEL (via backspace). OTOH,
10182 input-decode-map doesn't need to go through it again. */
10183 fkey.start = fkey.end = 0;
10184 keytran.start = keytran.end = 0;
10185
10126 goto replay_sequence; 10186 goto replay_sequence;
10127 } 10187 }
10128 } 10188 }
10129 } 10189 }
10130
10131 if (!dummyflag) 10190 if (!dummyflag)
10132 read_key_sequence_cmd = (first_binding < nmaps 10191 read_key_sequence_cmd = (first_binding < nmaps
10133 ? defs[first_binding] 10192 ? defs[first_binding]
@@ -11244,7 +11303,7 @@ See also `current-input-mode'. */)
11244 new_interrupt_input = 1; 11303 new_interrupt_input = 1;
11245#endif 11304#endif
11246 11305
11247 if (new_interrupt_input != interrupt_input) 11306 if (new_interrupt_input != interrupt_input)
11248 { 11307 {
11249#ifdef POLL_FOR_INPUT 11308#ifdef POLL_FOR_INPUT
11250 stop_polling (); 11309 stop_polling ();
@@ -11324,7 +11383,7 @@ See also `current-input-mode'. */)
11324 struct terminal *t = get_terminal (terminal, 1); 11383 struct terminal *t = get_terminal (terminal, 1);
11325 struct tty_display_info *tty; 11384 struct tty_display_info *tty;
11326 int new_meta; 11385 int new_meta;
11327 11386
11328 if (t == NULL || t->type != output_termcap) 11387 if (t == NULL || t->type != output_termcap)
11329 return Qnil; 11388 return Qnil;
11330 tty = t->display_info.tty; 11389 tty = t->display_info.tty;
@@ -11336,7 +11395,7 @@ See also `current-input-mode'. */)
11336 else 11395 else
11337 new_meta = 2; 11396 new_meta = 2;
11338 11397
11339 if (tty->meta_key != new_meta) 11398 if (tty->meta_key != new_meta)
11340 { 11399 {
11341#ifndef DOS_NT 11400#ifndef DOS_NT
11342 /* this causes startup screen to be restored and messes with the mouse */ 11401 /* this causes startup screen to be restored and messes with the mouse */
@@ -11344,7 +11403,7 @@ See also `current-input-mode'. */)
11344#endif 11403#endif
11345 11404
11346 tty->meta_key = new_meta; 11405 tty->meta_key = new_meta;
11347 11406
11348#ifndef DOS_NT 11407#ifndef DOS_NT
11349 init_sys_modes (tty); 11408 init_sys_modes (tty);
11350#endif 11409#endif
@@ -11376,7 +11435,7 @@ See also `current-input-mode'. */)
11376 /* this causes startup screen to be restored and messes with the mouse */ 11435 /* this causes startup screen to be restored and messes with the mouse */
11377 reset_sys_modes (tty); 11436 reset_sys_modes (tty);
11378#endif 11437#endif
11379 11438
11380 /* Don't let this value be out of range. */ 11439 /* Don't let this value be out of range. */
11381 quit_char = XINT (quit) & (tty->meta_key == 0 ? 0177 : 0377); 11440 quit_char = XINT (quit) & (tty->meta_key == 0 ? 0177 : 0377);
11382 11441
@@ -11386,7 +11445,7 @@ See also `current-input-mode'. */)
11386 11445
11387 return Qnil; 11446 return Qnil;
11388} 11447}
11389 11448
11390DEFUN ("set-input-mode", Fset_input_mode, Sset_input_mode, 3, 4, 0, 11449DEFUN ("set-input-mode", Fset_input_mode, Sset_input_mode, 3, 4, 0,
11391 doc: /* Set mode of reading keyboard input. 11450 doc: /* Set mode of reading keyboard input.
11392First arg INTERRUPT non-nil means use input interrupts; 11451First arg INTERRUPT non-nil means use input interrupts;
@@ -11785,6 +11844,11 @@ syms_of_keyboard ()
11785 staticpro (&Qmac_apple_event); 11844 staticpro (&Qmac_apple_event);
11786#endif 11845#endif
11787 11846
11847#ifdef HAVE_DBUS
11848 Qdbus_event = intern ("dbus-event");
11849 staticpro (&Qdbus_event);
11850#endif
11851
11788 Qmenu_enable = intern ("menu-enable"); 11852 Qmenu_enable = intern ("menu-enable");
11789 staticpro (&Qmenu_enable); 11853 staticpro (&Qmenu_enable);
11790 Qmenu_alias = intern ("menu-alias"); 11854 Qmenu_alias = intern ("menu-alias");
@@ -11945,6 +12009,7 @@ syms_of_keyboard ()
11945 staticpro (&help_form_saved_window_configs); 12009 staticpro (&help_form_saved_window_configs);
11946 12010
11947 defsubr (&Scurrent_idle_time); 12011 defsubr (&Scurrent_idle_time);
12012 defsubr (&Sevent_symbol_parse_modifiers);
11948 defsubr (&Sevent_convert_list); 12013 defsubr (&Sevent_convert_list);
11949 defsubr (&Sread_key_sequence); 12014 defsubr (&Sread_key_sequence);
11950 defsubr (&Sread_key_sequence_vector); 12015 defsubr (&Sread_key_sequence_vector);
@@ -12346,7 +12411,7 @@ here. If a mapping is defined in both the current
12346`local-function-key-map' binding and this variable, then the local 12411`local-function-key-map' binding and this variable, then the local
12347definition will take precendence. */); 12412definition will take precendence. */);
12348 Vfunction_key_map = Fmake_sparse_keymap (Qnil); 12413 Vfunction_key_map = Fmake_sparse_keymap (Qnil);
12349 12414
12350 DEFVAR_LISP ("key-translation-map", &Vkey_translation_map, 12415 DEFVAR_LISP ("key-translation-map", &Vkey_translation_map,
12351 doc: /* Keymap of key translations that can override keymaps. 12416 doc: /* Keymap of key translations that can override keymaps.
12352This keymap works like `function-key-map', but comes after that, 12417This keymap works like `function-key-map', but comes after that,
@@ -12468,7 +12533,7 @@ and tool-bar buttons. */);
12468 /* Vwindow_system is left at t for now. */ 12533 /* Vwindow_system is left at t for now. */
12469 initial_kboard->next_kboard = all_kboards; 12534 initial_kboard->next_kboard = all_kboards;
12470 all_kboards = initial_kboard; 12535 all_kboards = initial_kboard;
12471#endif 12536#endif
12472} 12537}
12473 12538
12474void 12539void
@@ -12513,6 +12578,13 @@ keys_of_keyboard ()
12513 * "handle-select-window"); */ 12578 * "handle-select-window"); */
12514 initial_define_lispy_key (Vspecial_event_map, "save-session", 12579 initial_define_lispy_key (Vspecial_event_map, "save-session",
12515 "handle-save-session"); 12580 "handle-save-session");
12581
12582#ifdef HAVE_DBUS
12583 /* Define a special event which is raised for dbus callback
12584 functions. */
12585 initial_define_lispy_key (Vspecial_event_map, "dbus-event",
12586 "dbus-handle-event");
12587#endif
12516} 12588}
12517 12589
12518/* Mark the pointers in the kboard objects. 12590/* 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. */)
2047} 2047}
2048 2048
2049DEFUN ("current-local-map", Fcurrent_local_map, Scurrent_local_map, 0, 0, 0, 2049DEFUN ("current-local-map", Fcurrent_local_map, Scurrent_local_map, 0, 0, 0,
2050 doc: /* Return current buffer's local keymap, or nil if it has none. */) 2050 doc: /* Return current buffer's local keymap, or nil if it has none.
2051Normally the local keymap is set by the major mode with `use-local-map'. */)
2051 () 2052 ()
2052{ 2053{
2053 return current_buffer->keymap; 2054 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
349 PVEC_HASH_TABLE = 0x40000, 349 PVEC_HASH_TABLE = 0x40000,
350 PVEC_TERMINAL = 0x80000, 350 PVEC_TERMINAL = 0x80000,
351 PVEC_SUB_CHAR_TABLE = 0x100000, 351 PVEC_SUB_CHAR_TABLE = 0x100000,
352 PVEC_TYPE_MASK = 0x1ffe00 352 PVEC_OTHER = 0x200000,
353 PVEC_TYPE_MASK = 0x2ffe00
353 354
354#if 0 /* This is used to make the value of PSEUDOVECTOR_FLAG available to 355#if 0 /* This is used to make the value of PSEUDOVECTOR_FLAG available to
355 GDB. It doesn't work on OS Alpha. Moved to a variable in 356 GDB. It doesn't work on OS Alpha. Moved to a variable in
@@ -1209,6 +1210,7 @@ struct Lisp_Buffer_Objfwd
1209 int type : 16; /* = Lisp_Misc_Buffer_Objfwd */ 1210 int type : 16; /* = Lisp_Misc_Buffer_Objfwd */
1210 unsigned gcmarkbit : 1; 1211 unsigned gcmarkbit : 1;
1211 int spacer : 15; 1212 int spacer : 15;
1213 Lisp_Object slottype; /* Qnil, Lisp_Int, Lisp_Symbol, or Lisp_String. */
1212 int offset; 1214 int offset;
1213 }; 1215 };
1214 1216
@@ -2568,7 +2570,11 @@ EXFUN (Fmake_byte_code, MANY);
2568EXFUN (Fmake_bool_vector, 2); 2570EXFUN (Fmake_bool_vector, 2);
2569extern Lisp_Object Qchar_table_extra_slots; 2571extern Lisp_Object Qchar_table_extra_slots;
2570extern struct Lisp_Vector *allocate_vector P_ ((EMACS_INT)); 2572extern struct Lisp_Vector *allocate_vector P_ ((EMACS_INT));
2571extern struct Lisp_Vector *allocate_other_vector P_ ((EMACS_INT)); 2573extern struct Lisp_Vector *allocate_pseudovector P_ ((int memlen, int lisplen, EMACS_INT tag));
2574#define ALLOCATE_PSEUDOVECTOR(typ,field,tag) \
2575 ((typ*) \
2576 allocate_pseudovector \
2577 (VECSIZE (typ), PSEUDOVECSIZE (typ, field), tag))
2572extern struct Lisp_Hash_Table *allocate_hash_table P_ ((void)); 2578extern struct Lisp_Hash_Table *allocate_hash_table P_ ((void));
2573extern struct window *allocate_window P_ ((void)); 2579extern struct window *allocate_window P_ ((void));
2574extern struct frame *allocate_frame P_ ((void)); 2580extern struct frame *allocate_frame P_ ((void));
@@ -3245,7 +3251,7 @@ extern void syms_of_dired P_ ((void));
3245 3251
3246/* Defined in term.c */ 3252/* Defined in term.c */
3247extern void syms_of_term P_ ((void)); 3253extern void syms_of_term P_ ((void));
3248extern void fatal () NO_RETURN; 3254extern void fatal P_ ((const char *msgid, ...)) NO_RETURN;
3249 3255
3250/* Defined in terminal.c */ 3256/* Defined in terminal.c */
3251extern void syms_of_terminal P_ ((void)); 3257extern 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;
5004#if SELECT_USE_CFSOCKET 5004#if SELECT_USE_CFSOCKET
5005#define SELECT_TIMEOUT_THRESHOLD_RUNLOOP 0.2 5005#define SELECT_TIMEOUT_THRESHOLD_RUNLOOP 0.2
5006 5006
5007/* Dictionary of file descriptors vs CFSocketRef's allocated in
5008 sys_select. */
5009static CFMutableDictionaryRef cfsockets_for_select;
5010
5007static void 5011static void
5008socket_callback (s, type, address, data, info) 5012socket_callback (s, type, address, data, info)
5009 CFSocketRef s; 5013 CFSocketRef s;
@@ -5089,6 +5093,43 @@ select_and_poll_event (nfds, rfds, wfds, efds, timeout)
5089 return 0; 5093 return 0;
5090} 5094}
5091 5095
5096/* Clean up the CFSocket associated with the file descriptor FD in
5097 case the same descriptor is used in other threads later. If no
5098 CFSocket is associated with FD, then return 0 without closing FD.
5099 Otherwise, return 1 with closing FD. */
5100
5101int
5102mac_try_close_socket (fd)
5103 int fd;
5104{
5105#if SELECT_USE_CFSOCKET
5106 if (cfsockets_for_select)
5107 {
5108 void *key = (void *) fd;
5109 CFSocketRef socket =
5110 (CFSocketRef) CFDictionaryGetValue (cfsockets_for_select, key);
5111
5112 if (socket)
5113 {
5114#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
5115 CFOptionFlags flags = CFSocketGetSocketFlags (socket);
5116
5117 if (!(flags & kCFSocketCloseOnInvalidate))
5118 CFSocketSetSocketFlags (socket, flags | kCFSocketCloseOnInvalidate);
5119#endif
5120 BLOCK_INPUT;
5121 CFSocketInvalidate (socket);
5122 CFDictionaryRemoveValue (cfsockets_for_select, key);
5123 UNBLOCK_INPUT;
5124
5125 return 1;
5126 }
5127 }
5128#endif
5129
5130 return 0;
5131}
5132
5092int 5133int
5093sys_select (nfds, rfds, wfds, efds, timeout) 5134sys_select (nfds, rfds, wfds, efds, timeout)
5094 int nfds; 5135 int nfds;
@@ -5165,6 +5206,11 @@ sys_select (nfds, rfds, wfds, efds, timeout)
5165 CFDictionaryCreateMutable (NULL, 0, NULL, 5206 CFDictionaryCreateMutable (NULL, 0, NULL,
5166 &kCFTypeDictionaryValueCallBacks); 5207 &kCFTypeDictionaryValueCallBacks);
5167 5208
5209 if (cfsockets_for_select == NULL)
5210 cfsockets_for_select =
5211 CFDictionaryCreateMutable (NULL, 0, NULL,
5212 &kCFTypeDictionaryValueCallBacks);
5213
5168 for (minfd = 1; ; minfd++) /* nfds-1 works as a sentinel. */ 5214 for (minfd = 1; ; minfd++) /* nfds-1 works as a sentinel. */
5169 if (FD_ISSET (minfd, rfds) || (wfds && FD_ISSET (minfd, wfds))) 5215 if (FD_ISSET (minfd, rfds) || (wfds && FD_ISSET (minfd, wfds)))
5170 break; 5216 break;
@@ -5176,7 +5222,7 @@ sys_select (nfds, rfds, wfds, efds, timeout)
5176 CFRunLoopSourceRef source = 5222 CFRunLoopSourceRef source =
5177 (CFRunLoopSourceRef) CFDictionaryGetValue (sources, key); 5223 (CFRunLoopSourceRef) CFDictionaryGetValue (sources, key);
5178 5224
5179 if (source == NULL) 5225 if (source == NULL || !CFRunLoopSourceIsValid (source))
5180 { 5226 {
5181 CFSocketRef socket = 5227 CFSocketRef socket =
5182 CFSocketCreateWithNative (NULL, fd, 5228 CFSocketCreateWithNative (NULL, fd,
@@ -5186,11 +5232,12 @@ sys_select (nfds, rfds, wfds, efds, timeout)
5186 5232
5187 if (socket == NULL) 5233 if (socket == NULL)
5188 continue; 5234 continue;
5235 CFDictionarySetValue (cfsockets_for_select, key, socket);
5189 source = CFSocketCreateRunLoopSource (NULL, socket, 0); 5236 source = CFSocketCreateRunLoopSource (NULL, socket, 0);
5190 CFRelease (socket); 5237 CFRelease (socket);
5191 if (source == NULL) 5238 if (source == NULL)
5192 continue; 5239 continue;
5193 CFDictionaryAddValue (sources, key, source); 5240 CFDictionarySetValue (sources, key, source);
5194 CFRelease (source); 5241 CFRelease (source);
5195 } 5242 }
5196 CFRunLoopAddSource (runloop, source, kCFRunLoopDefaultMode); 5243 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)
2513DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame, 2513DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
2514 1, 1, 0, 2514 1, 1, 0,
2515 doc: /* Make a new window, which is called a "frame" in Emacs terms. 2515 doc: /* Make a new window, which is called a "frame" in Emacs terms.
2516Returns an Emacs frame object. 2516Return an Emacs frame object.
2517PARAMETERS is an alist of frame parameters. 2517PARAMETERS is an alist of frame parameters.
2518If the parameters specify that the frame should not have a minibuffer, 2518If the parameters specify that the frame should not have a minibuffer,
2519and do not specify a specific minibuffer window to use, 2519and do not specify a specific minibuffer window to use,
@@ -2547,11 +2547,7 @@ This function is an internal primitive--use `make-frame' instead. */)
2547 if (EQ (display, Qunbound)) 2547 if (EQ (display, Qunbound))
2548 display = Qnil; 2548 display = Qnil;
2549 dpyinfo = check_x_display_info (display); 2549 dpyinfo = check_x_display_info (display);
2550#ifdef MULTI_KBOARD
2551 kb = dpyinfo->terminal->kboard; 2550 kb = dpyinfo->terminal->kboard;
2552#else
2553 kb = &the_only_kboard;
2554#endif
2555 2551
2556 name = mac_get_arg (parameters, Qname, "name", "Name", RES_TYPE_STRING); 2552 name = mac_get_arg (parameters, Qname, "name", "Name", RES_TYPE_STRING);
2557 if (!STRINGP (name) 2553 if (!STRINGP (name)
@@ -2615,9 +2611,7 @@ This function is an internal primitive--use `make-frame' instead. */)
2615 image_cache_refcount = FRAME_X_IMAGE_CACHE (f)->refcount; 2611 image_cache_refcount = FRAME_X_IMAGE_CACHE (f)->refcount;
2616 dpyinfo_refcount = dpyinfo->reference_count; 2612 dpyinfo_refcount = dpyinfo->reference_count;
2617#endif /* GLYPH_DEBUG */ 2613#endif /* GLYPH_DEBUG */
2618#ifdef MULTI_KBOARD
2619 FRAME_KBOARD (f) = kb; 2614 FRAME_KBOARD (f) = kb;
2620#endif
2621 2615
2622 /* Specify the parent under which to make this window. */ 2616 /* Specify the parent under which to make this window. */
2623 2617
@@ -2975,7 +2969,7 @@ If omitted or nil, that stands for the selected frame's display. */)
2975 2969
2976DEFUN ("x-display-pixel-width", Fx_display_pixel_width, Sx_display_pixel_width, 2970DEFUN ("x-display-pixel-width", Fx_display_pixel_width, Sx_display_pixel_width,
2977 0, 1, 0, 2971 0, 1, 0,
2978 doc: /* Returns the width in pixels of DISPLAY. 2972 doc: /* Return the width in pixels of DISPLAY.
2979The optional argument DISPLAY specifies which display to ask about. 2973The optional argument DISPLAY specifies which display to ask about.
2980DISPLAY should be either a frame or a display name (a string). 2974DISPLAY should be either a frame or a display name (a string).
2981If omitted or nil, that stands for the selected frame's display. */) 2975If 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. */)
2989 2983
2990DEFUN ("x-display-pixel-height", Fx_display_pixel_height, 2984DEFUN ("x-display-pixel-height", Fx_display_pixel_height,
2991 Sx_display_pixel_height, 0, 1, 0, 2985 Sx_display_pixel_height, 0, 1, 0,
2992 doc: /* Returns the height in pixels of DISPLAY. 2986 doc: /* Return the height in pixels of DISPLAY.
2993The optional argument DISPLAY specifies which display to ask about. 2987The optional argument DISPLAY specifies which display to ask about.
2994DISPLAY should be either a frame or a display name (a string). 2988DISPLAY should be either a frame or a display name (a string).
2995If omitted or nil, that stands for the selected frame's display. */) 2989If 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. */)
3003 2997
3004DEFUN ("x-display-planes", Fx_display_planes, Sx_display_planes, 2998DEFUN ("x-display-planes", Fx_display_planes, Sx_display_planes,
3005 0, 1, 0, 2999 0, 1, 0,
3006 doc: /* Returns the number of bitplanes of DISPLAY. 3000 doc: /* Return the number of bitplanes of DISPLAY.
3007The optional argument DISPLAY specifies which display to ask about. 3001The optional argument DISPLAY specifies which display to ask about.
3008DISPLAY should be either a frame or a display name (a string). 3002DISPLAY should be either a frame or a display name (a string).
3009If omitted or nil, that stands for the selected frame's display. */) 3003If 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. */)
3017 3011
3018DEFUN ("x-display-color-cells", Fx_display_color_cells, Sx_display_color_cells, 3012DEFUN ("x-display-color-cells", Fx_display_color_cells, Sx_display_color_cells,
3019 0, 1, 0, 3013 0, 1, 0,
3020 doc: /* Returns the number of color cells of DISPLAY. 3014 doc: /* Return the number of color cells of DISPLAY.
3021The optional argument DISPLAY specifies which display to ask about. 3015The optional argument DISPLAY specifies which display to ask about.
3022DISPLAY should be either a frame or a display name (a string). 3016DISPLAY should be either a frame or a display name (a string).
3023If omitted or nil, that stands for the selected frame's display. */) 3017If 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. */)
3033DEFUN ("x-server-max-request-size", Fx_server_max_request_size, 3027DEFUN ("x-server-max-request-size", Fx_server_max_request_size,
3034 Sx_server_max_request_size, 3028 Sx_server_max_request_size,
3035 0, 1, 0, 3029 0, 1, 0,
3036 doc: /* Returns the maximum request size of the server of DISPLAY. 3030 doc: /* Return the maximum request size of the server of DISPLAY.
3037The optional argument DISPLAY specifies which display to ask about. 3031The optional argument DISPLAY specifies which display to ask about.
3038DISPLAY should be either a frame or a display name (a string). 3032DISPLAY should be either a frame or a display name (a string).
3039If omitted or nil, that stands for the selected frame's display. */) 3033If 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. */)
3046} 3040}
3047 3041
3048DEFUN ("x-server-vendor", Fx_server_vendor, Sx_server_vendor, 0, 1, 0, 3042DEFUN ("x-server-vendor", Fx_server_vendor, Sx_server_vendor, 0, 1, 0,
3049 doc: /* Returns the "vendor ID" string of the Mac OS system (Apple). 3043 doc: /* Return the "vendor ID" string of the Mac OS system (Apple).
3050The optional argument DISPLAY specifies which display to ask about. 3044The optional argument DISPLAY specifies which display to ask about.
3051DISPLAY should be either a frame or a display name (a string). 3045DISPLAY should be either a frame or a display name (a string).
3052If omitted or nil, that stands for the selected frame's display. */) 3046If 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. */)
3057} 3051}
3058 3052
3059DEFUN ("x-server-version", Fx_server_version, Sx_server_version, 0, 1, 0, 3053DEFUN ("x-server-version", Fx_server_version, Sx_server_version, 0, 1, 0,
3060 doc: /* Returns the version numbers of the Mac OS system. 3054 doc: /* Return the version numbers of the Mac OS system.
3061The value is a list of three integers: the major and minor 3055The value is a list of three integers: the major and minor
3062version numbers, and the vendor-specific release 3056version numbers, and the vendor-specific release
3063number. See also the function `x-server-vendor'. 3057number. See also the function `x-server-vendor'.
@@ -3191,7 +3185,7 @@ If omitted or nil, that stands for the selected frame's display. */)
3191 3185
3192DEFUN ("x-display-backing-store", Fx_display_backing_store, 3186DEFUN ("x-display-backing-store", Fx_display_backing_store,
3193 Sx_display_backing_store, 0, 1, 0, 3187 Sx_display_backing_store, 0, 1, 0,
3194 doc: /* Returns an indication of whether DISPLAY does backing store. 3188 doc: /* Return an indication of whether DISPLAY does backing store.
3195The value may be `always', `when-mapped', or `not-useful'. 3189The value may be `always', `when-mapped', or `not-useful'.
3196The optional argument DISPLAY specifies which display to ask about. 3190The optional argument DISPLAY specifies which display to ask about.
3197DISPLAY should be either a frame or a display name (a string). 3191DISPLAY 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. */)
3204 3198
3205DEFUN ("x-display-visual-class", Fx_display_visual_class, 3199DEFUN ("x-display-visual-class", Fx_display_visual_class,
3206 Sx_display_visual_class, 0, 1, 0, 3200 Sx_display_visual_class, 0, 1, 0,
3207 doc: /* Returns the visual class of DISPLAY. 3201 doc: /* Return the visual class of DISPLAY.
3208The value is one of the symbols `static-gray', `gray-scale', 3202The value is one of the symbols `static-gray', `gray-scale',
3209`static-color', `pseudo-color', `true-color', or `direct-color'. 3203`static-color', `pseudo-color', `true-color', or `direct-color'.
3210 3204
@@ -3235,7 +3229,7 @@ If omitted or nil, that stands for the selected frame's display. */)
3235 3229
3236DEFUN ("x-display-save-under", Fx_display_save_under, 3230DEFUN ("x-display-save-under", Fx_display_save_under,
3237 Sx_display_save_under, 0, 1, 0, 3231 Sx_display_save_under, 0, 1, 0,
3238 doc: /* Returns t if DISPLAY supports the save-under feature. 3232 doc: /* Return t if DISPLAY supports the save-under feature.
3239The optional argument DISPLAY specifies which display to ask about. 3233The optional argument DISPLAY specifies which display to ask about.
3240DISPLAY should be either a frame or a display name (a string). 3234DISPLAY should be either a frame or a display name (a string).
3241If omitted or nil, that stands for the selected frame's display. */) 3235If omitted or nil, that stands for the selected frame's display. */)
@@ -3809,11 +3803,7 @@ x_create_tip_frame (dpyinfo, parms, text)
3809 3803
3810 parms = Fcopy_alist (parms); 3804 parms = Fcopy_alist (parms);
3811 3805
3812#ifdef MULTI_KBOARD
3813 kb = dpyinfo->terminal->kboard; 3806 kb = dpyinfo->terminal->kboard;
3814#else
3815 kb = &the_only_kboard;
3816#endif
3817 3807
3818 /* Get the name of the frame to use for resource lookup. */ 3808 /* Get the name of the frame to use for resource lookup. */
3819 name = mac_get_arg (parms, Qname, "name", "Name", RES_TYPE_STRING); 3809 name = mac_get_arg (parms, Qname, "name", "Name", RES_TYPE_STRING);
@@ -3859,9 +3849,7 @@ x_create_tip_frame (dpyinfo, parms, text)
3859 image_cache_refcount = FRAME_X_IMAGE_CACHE (f)->refcount; 3849 image_cache_refcount = FRAME_X_IMAGE_CACHE (f)->refcount;
3860 dpyinfo_refcount = dpyinfo->reference_count; 3850 dpyinfo_refcount = dpyinfo->reference_count;
3861#endif /* GLYPH_DEBUG */ 3851#endif /* GLYPH_DEBUG */
3862#ifdef MULTI_KBOARD
3863 FRAME_KBOARD (f) = kb; 3852 FRAME_KBOARD (f) = kb;
3864#endif
3865 f->output_data.mac->parent_desc = FRAME_MAC_DISPLAY_INFO (f)->root_window; 3853 f->output_data.mac->parent_desc = FRAME_MAC_DISPLAY_INFO (f)->root_window;
3866 f->output_data.mac->explicit_parent = 0; 3854 f->output_data.mac->explicit_parent = 0;
3867 3855
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)
12625 x_display_name_list); 12625 x_display_name_list);
12626 dpyinfo->name_list_element = XCAR (x_display_name_list); 12626 dpyinfo->name_list_element = XCAR (x_display_name_list);
12627 12627
12628 /* FIXME: Untested.
12629 Add the default keyboard. */
12630 add_keyboard_wait_descriptor (0);
12631
12628#if USE_CG_DRAWING 12632#if USE_CG_DRAWING
12629 mac_init_fringe (terminal->rif); 12633 mac_init_fringe (terminal->rif);
12630#endif 12634#endif
@@ -12844,7 +12848,6 @@ mac_create_terminal (struct mac_display_info *dpyinfo)
12844 /* FIXME: This keyboard setup is 100% untested, just copied from 12848 /* FIXME: This keyboard setup is 100% untested, just copied from
12845 w32_create_terminal in order to set window-system now that it's 12849 w32_create_terminal in order to set window-system now that it's
12846 a keyboard object. */ 12850 a keyboard object. */
12847#ifdef MULTI_KBOARD
12848 /* We don't yet support separate terminals on Mac, so don't try to share 12851 /* We don't yet support separate terminals on Mac, so don't try to share
12849 keyboards between virtual terminals that are on the same physical 12852 keyboards between virtual terminals that are on the same physical
12850 terminal like X does. */ 12853 terminal like X does. */
@@ -12859,7 +12862,6 @@ mac_create_terminal (struct mac_display_info *dpyinfo)
12859 if (current_kboard == initial_kboard) 12862 if (current_kboard == initial_kboard)
12860 current_kboard = terminal->kboard; 12863 current_kboard = terminal->kboard;
12861 terminal->kboard->reference_count++; 12864 terminal->kboard->reference_count++;
12862#endif
12863 12865
12864 return terminal; 12866 return terminal;
12865} 12867}
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)
1636 { 1636 {
1637 case Lisp_Int: 1637 case Lisp_Int:
1638 if (sizeof (int) == sizeof (EMACS_INT)) 1638 if (sizeof (int) == sizeof (EMACS_INT))
1639 sprintf (buf, "%d", XINT (obj)); 1639 sprintf (buf, "%d", (int) XINT (obj));
1640 else if (sizeof (long) == sizeof (EMACS_INT)) 1640 else if (sizeof (long) == sizeof (EMACS_INT))
1641 sprintf (buf, "%ld", (long) XINT (obj)); 1641 sprintf (buf, "%ld", (long) XINT (obj));
1642 else 1642 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)
631 p->tick = 0; 631 p->tick = 0;
632 p->update_tick = 0; 632 p->update_tick = 0;
633 p->pid = 0; 633 p->pid = 0;
634 p->pty_flag = 0;
634 p->raw_status_new = 0; 635 p->raw_status_new = 0;
635 p->status = Qrun; 636 p->status = Qrun;
636 p->mark = Fmake_marker (); 637 p->mark = Fmake_marker ();
@@ -1374,8 +1375,10 @@ list_processes_1 (query_only)
1374 if (w_tty) 1375 if (w_tty)
1375 { 1376 {
1376 XSETFASTINT (i_tty, XFASTINT (i_buffer) + w_buffer + 1); 1377 XSETFASTINT (i_tty, XFASTINT (i_buffer) + w_buffer + 1);
1377 XSETFASTINT (i_command, XFASTINT (i_buffer) + w_tty + 1); 1378 XSETFASTINT (i_command, XFASTINT (i_tty) + w_tty + 1);
1378 } else { 1379 }
1380 else
1381 {
1379 i_tty = Qnil; 1382 i_tty = Qnil;
1380 XSETFASTINT (i_command, XFASTINT (i_buffer) + w_buffer + 1); 1383 XSETFASTINT (i_command, XFASTINT (i_buffer) + w_buffer + 1);
1381 } 1384 }
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. */
43#endif 43#endif
44 44
45#ifndef BASE_PURESIZE 45#ifndef BASE_PURESIZE
46#define BASE_PURESIZE (1180000 + SYSTEM_PURESIZE_EXTRA + SITELOAD_PURESIZE_EXTRA) 46#define BASE_PURESIZE (1190000 + SYSTEM_PURESIZE_EXTRA + SITELOAD_PURESIZE_EXTRA)
47#endif 47#endif
48 48
49/* Increase BASE_PURESIZE by a ratio depending on the machine's word size. */ 49/* 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. */
53/* We need a little extra space, see ../../lisp/loadup.el. */ 53/* We need a little extra space, see ../../lisp/loadup.el. */
54#define SYSTEM_PURESIZE_EXTRA 30000 54#define SYSTEM_PURESIZE_EXTRA 30000
55 55
56/* XXX The MULTI_KBOARD support does not work yet on this platform. */
57#undef MULTI_KBOARD
58
59#endif 56#endif
60#endif 57#endif
61 58
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 @@
1#include "gnu-linux.h"
2
3/* SYSTEM_TYPE should indicate the kind of system you are using.
4 It sets the Lisp variable system-type. */
5#undef SYSTEM_TYPE
6#define SYSTEM_TYPE "gnu/kfreebsd" /* All the best software is free */
7
8#define NO_TERMIO /* use only <termios.h> */
9
10/* arch-tag: 8d098200-2586-469e-99ab-6d092c035e03
11 (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);
477#endif 477#endif
478#include <string.h> 478#include <string.h>
479 479
480/* We need a little extra space, see ../../lisp/loadup.el. 480/* We need a little extra space, see ../../lisp/loadup.el. */
481 The number below comes from 23923 bytes worth (as of 2006-04)
482 of w32-specific files loaded by loadup.el, plus 1K spare. */
483#define SYSTEM_PURESIZE_EXTRA 50000 481#define SYSTEM_PURESIZE_EXTRA 50000
484 482
485/* For unexec to work on Alpha systems, we need to put Emacs' 483/* For unexec to work on Alpha systems, we need to put Emacs'
@@ -491,9 +489,9 @@ extern char *get_emacs_configuration_options (void);
491 into its own section. VC5 intermingles uninitialized data from the CRT 489 into its own section. VC5 intermingles uninitialized data from the CRT
492 between Emacs' static uninitialized data and its public uninitialized 490 between Emacs' static uninitialized data and its public uninitialized
493 data. A separate .bss section for Emacs groups both static and 491 data. A separate .bss section for Emacs groups both static and
494 public uninitalized together. 492 public uninitialized together.
495 493
496 Note that unexnt.c relies on this fact, and must be modified 494 Note that unexw32.c relies on this fact, and must be modified
497 accordingly if this section name is changed, or if this pragma is 495 accordingly if this section name is changed, or if this pragma is
498 removed. Also, obviously, all files that define initialized data 496 removed. Also, obviously, all files that define initialized data
499 must include config.h to pick up this pragma. */ 497 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. */)
2942 return reuse; 2942 return reuse;
2943} 2943}
2944 2944
2945/* Internal usage only: 2945/* We used to have an internal use variant of `reseat' described as:
2946 If RESEAT is `evaporate', put the markers back on the free list 2946
2947 immediately. No other references to the markers must exist in this case, 2947 If RESEAT is `evaporate', put the markers back on the free list
2948 so it is used only internally on the unwind stack and save-match-data from 2948 immediately. No other references to the markers must exist in this
2949 Lisp. */ 2949 case, so it is used only internally on the unwind stack and
2950 save-match-data from Lisp.
2951
2952 But it was ill-conceived: those supposedly-internal markers get exposed via
2953 the undo-list, so freeing them here is unsafe. */
2950 2954
2951DEFUN ("set-match-data", Fset_match_data, Sset_match_data, 1, 2, 0, 2955DEFUN ("set-match-data", Fset_match_data, Sset_match_data, 1, 2, 0,
2952 doc: /* Set internal data on last search match from elements of LIST. 2956 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. */)
3031 3035
3032 if (!NILP (reseat) && MARKERP (m)) 3036 if (!NILP (reseat) && MARKERP (m))
3033 { 3037 {
3034 if (EQ (reseat, Qevaporate)) 3038 unchain_marker (XMARKER (m));
3035 free_marker (m);
3036 else
3037 unchain_marker (XMARKER (m));
3038 XSETCAR (list, Qnil); 3039 XSETCAR (list, Qnil);
3039 } 3040 }
3040 3041
@@ -3052,10 +3053,7 @@ If optional arg RESEAT is non-nil, make markers on LIST point nowhere. */)
3052 3053
3053 if (!NILP (reseat) && MARKERP (m)) 3054 if (!NILP (reseat) && MARKERP (m))
3054 { 3055 {
3055 if (EQ (reseat, Qevaporate)) 3056 unchain_marker (XMARKER (m));
3056 free_marker (m);
3057 else
3058 unchain_marker (XMARKER (m));
3059 XSETCAR (list, Qnil); 3057 XSETCAR (list, Qnil);
3060 } 3058 }
3061 } 3059 }
@@ -3119,8 +3117,8 @@ static Lisp_Object
3119unwind_set_match_data (list) 3117unwind_set_match_data (list)
3120 Lisp_Object list; 3118 Lisp_Object list;
3121{ 3119{
3122 /* It is safe to free (evaporate) the markers immediately. */ 3120 /* It is NOT ALWAYS safe to free (evaporate) the markers immediately. */
3123 return Fset_match_data (list, Qevaporate); 3121 return Fset_match_data (list, Qt);
3124} 3122}
3125 3123
3126/* Called to unwind protect the match data. */ 3124/* Called to unwind protect the match data. */
@@ -3219,9 +3217,10 @@ A value of nil (which is the normal value) means treat spaces literally. */);
3219 3217
3220 DEFVAR_LISP ("inhibit-changing-match-data", &Vinhibit_changing_match_data, 3218 DEFVAR_LISP ("inhibit-changing-match-data", &Vinhibit_changing_match_data,
3221 doc: /* Internal use only. 3219 doc: /* Internal use only.
3222If non-nil, the match data will not be changed during call to searching or 3220If non-nil, the primitive searching and matching functions
3223matching functions, such as `looking-at', `string-match', `re-search-forward' 3221such as `looking-at', `string-match', `re-search-forward', etc.,
3224etc. */); 3222do not set the match data. The proper way to use this variable
3223is to bind it with `let' around a small expression. */);
3225 Vinhibit_changing_match_data = Qnil; 3224 Vinhibit_changing_match_data = Qnil;
3226 3225
3227 defsubr (&Slooking_at); 3226 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 ()
2518#endif /* not CANNOT_DUMP */ 2518#endif /* not CANNOT_DUMP */
2519 if (! index (hostname, '.')) 2519 if (! index (hostname, '.'))
2520 { 2520 {
2521 struct hostent *hp;
2522 int count; 2521 int count;
2522#ifdef HAVE_GETADDRINFO
2523 struct addrinfo *res;
2524 struct addrinfo hints;
2525 int ret;
2526
2527 memset (&hints, 0, sizeof(hints));
2528 hints.ai_socktype = SOCK_STREAM;
2529 hints.ai_flags = AI_CANONNAME;
2530
2531 for (count = 0;; count++)
2532 {
2533 if ((ret = getaddrinfo (hostname, NULL, &hints, &res)) == 0
2534 || ret != EAI_AGAIN)
2535 break;
2536
2537 if (count >= 5)
2538 break;
2539 Fsleep_for (make_number (1), Qnil);
2540 }
2541
2542 if (ret == 0)
2543 {
2544 struct addrinfo *it = res;
2545 while (it)
2546 {
2547 char *fqdn = it->ai_canonname;
2548 if (fqdn && index (fqdn, '.')
2549 && strcmp (fqdn, "localhost.localdomain") != 0)
2550 break;
2551 it = it->ai_next;
2552 }
2553 if (it)
2554 {
2555 hostname = alloca (strlen (it->ai_canonname) + 1);
2556 strcpy (hostname, it->ai_canonname);
2557 }
2558 freeaddrinfo (res);
2559 }
2560#else /* !HAVE_GETADDRINFO */
2561 struct hostent *hp;
2523 for (count = 0;; count++) 2562 for (count = 0;; count++)
2524 { 2563 {
2564
2525#ifdef TRY_AGAIN 2565#ifdef TRY_AGAIN
2526 h_errno = 0; 2566 h_errno = 0;
2527#endif 2567#endif
@@ -2529,11 +2569,14 @@ init_system_name ()
2529#ifdef TRY_AGAIN 2569#ifdef TRY_AGAIN
2530 if (! (hp == 0 && h_errno == TRY_AGAIN)) 2570 if (! (hp == 0 && h_errno == TRY_AGAIN))
2531#endif 2571#endif
2572
2532 break; 2573 break;
2574
2533 if (count >= 5) 2575 if (count >= 5)
2534 break; 2576 break;
2535 Fsleep_for (make_number (1), Qnil); 2577 Fsleep_for (make_number (1), Qnil);
2536 } 2578 }
2579
2537 if (hp) 2580 if (hp)
2538 { 2581 {
2539 char *fqdn = (char *) hp->h_name; 2582 char *fqdn = (char *) hp->h_name;
@@ -2567,6 +2610,7 @@ init_system_name ()
2567 } 2610 }
2568#endif 2611#endif
2569 } 2612 }
2613#endif /* !HAVE_GETADDRINFO */
2570 } 2614 }
2571#endif /* HAVE_SOCKETS */ 2615#endif /* HAVE_SOCKETS */
2572 /* We used to try using getdomainname here, 2616 /* We used to try using getdomainname here,
@@ -3442,6 +3486,15 @@ emacs_close (fd)
3442 int did_retry = 0; 3486 int did_retry = 0;
3443 register int rtnval; 3487 register int rtnval;
3444 3488
3489#if defined (MAC_OSX) && defined (HAVE_CARBON)
3490 {
3491 extern int mac_try_close_socket P_ ((int));
3492
3493 if (mac_try_close_socket (fd))
3494 return 0;
3495 }
3496#endif
3497
3445 while ((rtnval = close (fd)) == -1 3498 while ((rtnval = close (fd)) == -1
3446 && (errno == EINTR)) 3499 && (errno == EINTR))
3447 did_retry = 1; 3500 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. */
37#endif 37#endif
38 38
39#include <signal.h> 39#include <signal.h>
40#include <stdarg.h>
40 41
41#include "lisp.h" 42#include "lisp.h"
42#include "termchar.h" 43#include "termchar.h"
@@ -3866,14 +3867,14 @@ maybe_fatal (must_succeed, buffer, terminal, str1, str2, arg1, arg2)
3866 abort (); 3867 abort ();
3867} 3868}
3868 3869
3869/* VARARGS 1 */
3870void 3870void
3871fatal (str, arg1, arg2) 3871fatal (const char *str, ...)
3872 char *str, *arg1, *arg2;
3873{ 3872{
3873 va_list ap;
3874 va_start (ap, str);
3874 fprintf (stderr, "emacs: "); 3875 fprintf (stderr, "emacs: ");
3875 fprintf (stderr, str, arg1, arg2); 3876 vfprintf (stderr, str, ap);
3876 fprintf (stderr, "\n"); 3877 va_end (ap);
3877 fflush (stderr); 3878 fflush (stderr);
3878 exit (1); 3879 exit (1);
3879} 3880}
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
197 , GPM_CLICK_EVENT 197 , GPM_CLICK_EVENT
198#endif 198#endif
199 199
200#ifdef HAVE_DBUS
201 , DBUS_EVENT
202#endif
203
200#ifdef WINDOWSNT 204#ifdef WINDOWSNT
201 /* Generated when an APPCOMMAND event is received, in response to 205 /* Generated when an APPCOMMAND event is received, in response to
202 Multimedia or Internet buttons on some keyboards. 206 Multimedia or Internet buttons on some keyboards.
@@ -336,7 +340,7 @@ struct terminal
336 340
337 /* All fields before `next_terminal' should be Lisp_Object and are traced 341 /* All fields before `next_terminal' should be Lisp_Object and are traced
338 by the GC. All fields afterwards are ignored by the GC. */ 342 by the GC. All fields afterwards are ignored by the GC. */
339 343
340 /* Chain of all terminal devices. */ 344 /* Chain of all terminal devices. */
341 struct terminal *next_terminal; 345 struct terminal *next_terminal;
342 346
@@ -382,12 +386,12 @@ struct terminal
382 386
383 /* Terminal characteristics. */ 387 /* Terminal characteristics. */
384 /* XXX Are these really used on non-termcap displays? */ 388 /* XXX Are these really used on non-termcap displays? */
385 389
386 int must_write_spaces; /* Nonzero means spaces in the text must 390 int must_write_spaces; /* Nonzero means spaces in the text must
387 actually be output; can't just skip over 391 actually be output; can't just skip over
388 some columns to leave them blank. */ 392 some columns to leave them blank. */
389 int fast_clear_end_of_line; /* Nonzero means terminal has a `ce' string */ 393 int fast_clear_end_of_line; /* Nonzero means terminal has a `ce' string */
390 394
391 int line_ins_del_ok; /* Terminal can insert and delete lines */ 395 int line_ins_del_ok; /* Terminal can insert and delete lines */
392 int char_ins_del_ok; /* Terminal can insert and delete chars */ 396 int char_ins_del_ok; /* Terminal can insert and delete chars */
393 int scroll_region_ok; /* Terminal supports setting the scroll 397 int scroll_region_ok; /* Terminal supports setting the scroll
@@ -410,24 +414,24 @@ struct terminal
410 struct redisplay_interface *rif; 414 struct redisplay_interface *rif;
411 415
412 /* Frame-based redisplay interface. */ 416 /* Frame-based redisplay interface. */
413 417
414 /* Text display hooks. */ 418 /* Text display hooks. */
415 419
416 void (*cursor_to_hook) P_ ((struct frame *f, int vpos, int hpos)); 420 void (*cursor_to_hook) P_ ((struct frame *f, int vpos, int hpos));
417 void (*raw_cursor_to_hook) P_ ((struct frame *, int, int)); 421 void (*raw_cursor_to_hook) P_ ((struct frame *, int, int));
418 422
419 void (*clear_to_end_hook) P_ ((struct frame *)); 423 void (*clear_to_end_hook) P_ ((struct frame *));
420 void (*clear_frame_hook) P_ ((struct frame *)); 424 void (*clear_frame_hook) P_ ((struct frame *));
421 void (*clear_end_of_line_hook) P_ ((struct frame *, int)); 425 void (*clear_end_of_line_hook) P_ ((struct frame *, int));
422 426
423 void (*ins_del_lines_hook) P_ ((struct frame *f, int, int)); 427 void (*ins_del_lines_hook) P_ ((struct frame *f, int, int));
424 428
425 void (*insert_glyphs_hook) P_ ((struct frame *f, struct glyph *s, int n)); 429 void (*insert_glyphs_hook) P_ ((struct frame *f, struct glyph *s, int n));
426 void (*write_glyphs_hook) P_ ((struct frame *f, struct glyph *s, int n)); 430 void (*write_glyphs_hook) P_ ((struct frame *f, struct glyph *s, int n));
427 void (*delete_glyphs_hook) P_ ((struct frame *, int)); 431 void (*delete_glyphs_hook) P_ ((struct frame *, int));
428 432
429 void (*ring_bell_hook) P_ ((struct frame *f)); 433 void (*ring_bell_hook) P_ ((struct frame *f));
430 434
431 void (*reset_terminal_modes_hook) P_ ((struct terminal *)); 435 void (*reset_terminal_modes_hook) P_ ((struct terminal *));
432 void (*set_terminal_modes_hook) P_ ((struct terminal *)); 436 void (*set_terminal_modes_hook) P_ ((struct terminal *));
433 437
@@ -442,7 +446,7 @@ struct terminal
442 Set *f to the frame the mouse is in, or zero if the mouse is in no 446 Set *f to the frame the mouse is in, or zero if the mouse is in no
443 Emacs frame. If it is set to zero, all the other arguments are 447 Emacs frame. If it is set to zero, all the other arguments are
444 garbage. 448 garbage.
445 449
446 If the motion started in a scroll bar, set *bar_window to the 450 If the motion started in a scroll bar, set *bar_window to the
447 scroll bar's window, *part to the part the mouse is currently over, 451 scroll bar's window, *part to the part the mouse is currently over,
448 *x to the position of the mouse along the scroll bar, and *y to the 452 *x to the position of the mouse along the scroll bar, and *y to the
@@ -452,7 +456,7 @@ struct terminal
452 row of the character cell the mouse is over. 456 row of the character cell the mouse is over.
453 457
454 Set *time to the time the mouse was at the returned position. 458 Set *time to the time the mouse was at the returned position.
455 459
456 This should clear mouse_moved until the next motion 460 This should clear mouse_moved until the next motion
457 event arrives. */ 461 event arrives. */
458 void (*mouse_position_hook) P_ ((struct frame **f, int, 462 void (*mouse_position_hook) P_ ((struct frame **f, int,
@@ -478,7 +482,7 @@ struct terminal
478 hook is zero, that means the terminal we're displaying on doesn't 482 hook is zero, that means the terminal we're displaying on doesn't
479 support overlapping frames, so there's no need to raise or lower 483 support overlapping frames, so there's no need to raise or lower
480 anything. 484 anything.
481 485
482 If RAISE is non-zero, F is brought to the front, before all other 486 If RAISE is non-zero, F is brought to the front, before all other
483 windows. If RAISE is zero, F is sent to the back, behind all other 487 windows. If RAISE is zero, F is sent to the back, behind all other
484 windows. */ 488 windows. */
@@ -488,7 +492,7 @@ struct terminal
488 For example, if going from fullscreen to not fullscreen this hook 492 For example, if going from fullscreen to not fullscreen this hook
489 may do something OS dependent, like extended window manager hints on X11. */ 493 may do something OS dependent, like extended window manager hints on X11. */
490 void (*fullscreen_hook) P_ ((struct frame *f)); 494 void (*fullscreen_hook) P_ ((struct frame *f));
491 495
492 496
493 /* Scroll bar hooks. */ 497 /* Scroll bar hooks. */
494 498
@@ -497,21 +501,21 @@ struct terminal
497 lisp objects. This allows us to place references to them in 501 lisp objects. This allows us to place references to them in
498 Lisp_Windows without worrying about those references becoming 502 Lisp_Windows without worrying about those references becoming
499 dangling references when the scroll bar is destroyed. 503 dangling references when the scroll bar is destroyed.
500 504
501 The window-system-independent portion of Emacs just refers to 505 The window-system-independent portion of Emacs just refers to
502 scroll bars via their windows, and never looks inside the scroll bar 506 scroll bars via their windows, and never looks inside the scroll bar
503 representation; it always uses hook functions to do all the 507 representation; it always uses hook functions to do all the
504 scroll bar manipulation it needs. 508 scroll bar manipulation it needs.
505 509
506 The `vertical_scroll_bar' field of a Lisp_Window refers to that 510 The `vertical_scroll_bar' field of a Lisp_Window refers to that
507 window's scroll bar, or is nil if the window doesn't have a 511 window's scroll bar, or is nil if the window doesn't have a
508 scroll bar. 512 scroll bar.
509 513
510 The `scroll_bars' and `condemned_scroll_bars' fields of a Lisp_Frame 514 The `scroll_bars' and `condemned_scroll_bars' fields of a Lisp_Frame
511 are free for use by the scroll bar implementation in any way it sees 515 are free for use by the scroll bar implementation in any way it sees
512 fit. They are marked by the garbage collector. */ 516 fit. They are marked by the garbage collector. */
513 517
514 518
515 /* Set the vertical scroll bar for WINDOW to have its upper left corner 519 /* Set the vertical scroll bar for WINDOW to have its upper left corner
516 at (TOP, LEFT), and be LENGTH rows high. Set its handle to 520 at (TOP, LEFT), and be LENGTH rows high. Set its handle to
517 indicate that we are displaying PORTION characters out of a total 521 indicate that we are displaying PORTION characters out of a total
@@ -529,16 +533,16 @@ struct terminal
529 Instead, we just assert at the beginning of redisplay that *all* 533 Instead, we just assert at the beginning of redisplay that *all*
530 scroll bars are to be removed, and then save scroll bars from the 534 scroll bars are to be removed, and then save scroll bars from the
531 fiery pit when we actually redisplay their window. */ 535 fiery pit when we actually redisplay their window. */
532 536
533 /* Arrange for all scroll bars on FRAME to be removed at the next call 537 /* Arrange for all scroll bars on FRAME to be removed at the next call
534 to `*judge_scroll_bars_hook'. A scroll bar may be spared if 538 to `*judge_scroll_bars_hook'. A scroll bar may be spared if
535 `*redeem_scroll_bar_hook' is applied to its window before the judgement. 539 `*redeem_scroll_bar_hook' is applied to its window before the judgement.
536 540
537 This should be applied to each frame each time its window tree is 541 This should be applied to each frame each time its window tree is
538 redisplayed, even if it is not displaying scroll bars at the moment; 542 redisplayed, even if it is not displaying scroll bars at the moment;
539 if the HAS_SCROLL_BARS flag has just been turned off, only calling 543 if the HAS_SCROLL_BARS flag has just been turned off, only calling
540 this and the judge_scroll_bars_hook will get rid of them. 544 this and the judge_scroll_bars_hook will get rid of them.
541 545
542 If non-zero, this hook should be safe to apply to any frame, 546 If non-zero, this hook should be safe to apply to any frame,
543 whether or not it can support scroll bars, and whether or not it is 547 whether or not it can support scroll bars, and whether or not it is
544 currently displaying them. */ 548 currently displaying them. */
@@ -555,7 +559,7 @@ struct terminal
555 tree is redisplayed, even if it is not displaying scroll bars at the 559 tree is redisplayed, even if it is not displaying scroll bars at the
556 moment; if the HAS_SCROLL_BARS flag has just been turned off, only 560 moment; if the HAS_SCROLL_BARS flag has just been turned off, only
557 calling this and condemn_scroll_bars_hook will get rid of them. 561 calling this and condemn_scroll_bars_hook will get rid of them.
558 562
559 If non-zero, this hook should be safe to apply to any frame, 563 If non-zero, this hook should be safe to apply to any frame,
560 whether or not it can support scroll bars, and whether or not it is 564 whether or not it can support scroll bars, and whether or not it is
561 currently displaying them. */ 565 currently displaying them. */
@@ -595,7 +599,7 @@ struct terminal
595 599
596 /* Called after the last frame on this terminal is deleted, or when 600 /* Called after the last frame on this terminal is deleted, or when
597 the display device was closed (hangup). 601 the display device was closed (hangup).
598 602
599 If this is NULL, then the generic delete_terminal is called 603 If this is NULL, then the generic delete_terminal is called
600 instead. Otherwise the hook must call delete_terminal itself. 604 instead. Otherwise the hook must call delete_terminal itself.
601 605
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)
819 || strncmp (sectp->sectname, "__la_sym_ptr2", 16) == 0 819 || strncmp (sectp->sectname, "__la_sym_ptr2", 16) == 0
820 || strncmp (sectp->sectname, "__dyld", 16) == 0 820 || strncmp (sectp->sectname, "__dyld", 16) == 0
821 || strncmp (sectp->sectname, "__const", 16) == 0 821 || strncmp (sectp->sectname, "__const", 16) == 0
822 || strncmp (sectp->sectname, "__cfstring", 16) == 0) 822 || strncmp (sectp->sectname, "__cfstring", 16) == 0
823 || strncmp (sectp->sectname, "__gcc_except_tab", 16) == 0
824 || strncmp (sectp->sectname, "__objc_", 7) == 0)
823 { 825 {
824 if (!unexec_copy (sectp->offset, old_file_offset, sectp->size)) 826 if (!unexec_copy (sectp->offset, old_file_offset, sectp->size))
825 unexec_error ("cannot copy section %s", sectp->sectname); 827 unexec_error ("cannot copy section %s", sectp->sectname);
@@ -898,12 +900,13 @@ copy_symtab (struct load_command *lc, long delta)
898 900
899/* Fix up relocation entries. */ 901/* Fix up relocation entries. */
900static void 902static void
901unrelocate (const char *name, off_t reloff, int nrel) 903unrelocate (const char *name, off_t reloff, int nrel, vm_address_t base)
902{ 904{
903 int i, unreloc_count; 905 int i, unreloc_count;
904 struct relocation_info reloc_info; 906 struct relocation_info reloc_info;
905 struct scattered_relocation_info *sc_reloc_info 907 struct scattered_relocation_info *sc_reloc_info
906 = (struct scattered_relocation_info *) &reloc_info; 908 = (struct scattered_relocation_info *) &reloc_info;
909 vm_address_t location;
907 910
908 for (unreloc_count = 0, i = 0; i < nrel; i++) 911 for (unreloc_count = 0, i = 0; i < nrel; i++)
909 { 912 {
@@ -917,14 +920,15 @@ unrelocate (const char *name, off_t reloff, int nrel)
917 switch (reloc_info.r_type) 920 switch (reloc_info.r_type)
918 { 921 {
919 case GENERIC_RELOC_VANILLA: 922 case GENERIC_RELOC_VANILLA:
920 if (reloc_info.r_address >= data_segment_scp->vmaddr 923 location = base + reloc_info.r_address;
921 && reloc_info.r_address < (data_segment_scp->vmaddr 924 if (location >= data_segment_scp->vmaddr
922 + data_segment_scp->vmsize)) 925 && location < (data_segment_scp->vmaddr
926 + data_segment_scp->vmsize))
923 { 927 {
924 off_t src_off = data_segment_old_fileoff 928 off_t src_off = data_segment_old_fileoff
925 + reloc_info.r_address - data_segment_scp->vmaddr; 929 + (location - data_segment_scp->vmaddr);
926 off_t dst_off = data_segment_scp->fileoff 930 off_t dst_off = data_segment_scp->fileoff
927 + reloc_info.r_address - data_segment_scp->vmaddr; 931 + (location - data_segment_scp->vmaddr);
928 932
929 if (!unexec_copy (dst_off, src_off, 1 << reloc_info.r_length)) 933 if (!unexec_copy (dst_off, src_off, 1 << reloc_info.r_length))
930 unexec_error ("unrelocate: %s:%d cannot copy original value", 934 unexec_error ("unrelocate: %s:%d cannot copy original value",
@@ -955,15 +959,73 @@ unrelocate (const char *name, off_t reloff, int nrel)
955 unreloc_count, nrel, name); 959 unreloc_count, nrel, name);
956} 960}
957 961
962#if __ppc64__
963/* Rebase r_address in the relocation table. */
964static void
965rebase_reloc_address (off_t reloff, int nrel, long linkedit_delta, long diff)
966{
967 int i;
968 struct relocation_info reloc_info;
969 struct scattered_relocation_info *sc_reloc_info
970 = (struct scattered_relocation_info *) &reloc_info;
971
972 for (i = 0; i < nrel; i++, reloff += sizeof (reloc_info))
973 {
974 if (lseek (infd, reloff - linkedit_delta, L_SET)
975 != reloff - linkedit_delta)
976 unexec_error ("rebase_reloc_table: cannot seek to reloc_info");
977 if (!unexec_read (&reloc_info, sizeof (reloc_info)))
978 unexec_error ("rebase_reloc_table: cannot read reloc_info");
979
980 if (sc_reloc_info->r_scattered == 0
981 && reloc_info.r_type == GENERIC_RELOC_VANILLA)
982 {
983 reloc_info.r_address -= diff;
984 if (!unexec_write (reloff, &reloc_info, sizeof (reloc_info)))
985 unexec_error ("rebase_reloc_table: cannot write reloc_info");
986 }
987 }
988}
989#endif
990
958/* Copy a LC_DYSYMTAB load command from the input file to the output 991/* Copy a LC_DYSYMTAB load command from the input file to the output
959 file, adjusting the file offset fields. */ 992 file, adjusting the file offset fields. */
960static void 993static void
961copy_dysymtab (struct load_command *lc, long delta) 994copy_dysymtab (struct load_command *lc, long delta)
962{ 995{
963 struct dysymtab_command *dstp = (struct dysymtab_command *) lc; 996 struct dysymtab_command *dstp = (struct dysymtab_command *) lc;
997 vm_address_t base;
964 998
965 unrelocate ("local", dstp->locreloff, dstp->nlocrel); 999#ifdef _LP64
966 unrelocate ("external", dstp->extreloff, dstp->nextrel); 1000#if __ppc64__
1001 {
1002 int i;
1003
1004 base = 0;
1005 for (i = 0; i < nlc; i++)
1006 if (lca[i]->cmd == LC_SEGMENT)
1007 {
1008 struct segment_command *scp = (struct segment_command *) lca[i];
1009
1010 if (scp->vmaddr + scp->vmsize > 0x100000000
1011 && (scp->initprot & VM_PROT_WRITE) != 0)
1012 {
1013 base = data_segment_scp->vmaddr;
1014 break;
1015 }
1016 }
1017 }
1018#else
1019 /* First writable segment address. */
1020 base = data_segment_scp->vmaddr;
1021#endif
1022#else
1023 /* First segment address in the file (unless MH_SPLIT_SEGS set). */
1024 base = 0;
1025#endif
1026
1027 unrelocate ("local", dstp->locreloff, dstp->nlocrel, base);
1028 unrelocate ("external", dstp->extreloff, dstp->nextrel, base);
967 1029
968 if (dstp->nextrel > 0) { 1030 if (dstp->nextrel > 0) {
969 dstp->extreloff += delta; 1031 dstp->extreloff += delta;
@@ -982,6 +1044,29 @@ copy_dysymtab (struct load_command *lc, long delta)
982 unexec_error ("cannot write symtab command to header"); 1044 unexec_error ("cannot write symtab command to header");
983 1045
984 curr_header_offset += lc->cmdsize; 1046 curr_header_offset += lc->cmdsize;
1047
1048#if __ppc64__
1049 /* Check if the relocation base needs to be changed. */
1050 if (base == 0)
1051 {
1052 vm_address_t newbase = 0;
1053 int i;
1054
1055 for (i = 0; i < num_unexec_regions; i++)
1056 if (unexec_regions[i].range.address + unexec_regions[i].range.size
1057 > 0x100000000)
1058 {
1059 newbase = data_segment_scp->vmaddr;
1060 break;
1061 }
1062
1063 if (newbase)
1064 {
1065 rebase_reloc_address (dstp->locreloff, dstp->nlocrel, delta, newbase);
1066 rebase_reloc_address (dstp->extreloff, dstp->nextrel, delta, newbase);
1067 }
1068 }
1069#endif
985} 1070}
986 1071
987/* Copy a LC_TWOLEVEL_HINTS load command from the input file to the output 1072/* 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)
261 error("Fail to open BDF file"); 261 error("Fail to open BDF file");
262 } 262 }
263 hfilemap = CreateFileMapping(hfile, NULL, PAGE_READONLY, 0, 0, NULL); 263 hfilemap = CreateFileMapping(hfile, NULL, PAGE_READONLY, 0, 0, NULL);
264 if (hfilemap == INVALID_HANDLE_VALUE) 264 if (!hfilemap)
265 { 265 {
266 CloseHandle(hfile); 266 CloseHandle(hfile);
267 error("Can't map font"); 267 error("Can't map font");
@@ -828,7 +828,7 @@ int w32_BDF_to_x_font (char *file, char* xstr, int len)
828 size = fileinfo.nFileSizeLow; 828 size = fileinfo.nFileSizeLow;
829 829
830 hfilemap = CreateFileMapping (hfile, NULL, PAGE_READONLY, 0, 0, NULL); 830 hfilemap = CreateFileMapping (hfile, NULL, PAGE_READONLY, 0, 0, NULL);
831 if (hfilemap == INVALID_HANDLE_VALUE) 831 if (!hfilemap)
832 { 832 {
833 CloseHandle (hfile); 833 CloseHandle (hfile);
834 return 0; 834 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.
35#include "character.h" 35#include "character.h"
36#include "coding.h" 36#include "coding.h"
37#include "disptab.h" 37#include "disptab.h"
38/* Disable features in frame.h that require a Window System. */
39#undef HAVE_WINDOW_SYSTEM
40#include "frame.h" 38#include "frame.h"
41#include "termhooks.h" 39#include "termhooks.h"
42#include "termchar.h" 40#include "termchar.h"
@@ -76,6 +74,8 @@ static DWORD prev_console_mode;
76static CONSOLE_CURSOR_INFO prev_console_cursor; 74static CONSOLE_CURSOR_INFO prev_console_cursor;
77#endif 75#endif
78 76
77extern Lisp_Object Vtty_defined_color_alist;
78
79/* Determine whether to make frame dimensions match the screen buffer, 79/* Determine whether to make frame dimensions match the screen buffer,
80 or the current window size. The former is desirable when running 80 or the current window size. The former is desirable when running
81 over telnet, while the latter is more useful when working directly at 81 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)
164{ 164{
165 int i, nb; 165 int i, nb;
166 SMALL_RECT scroll; 166 SMALL_RECT scroll;
167 SMALL_RECT clip;
167 COORD dest; 168 COORD dest;
168 CHAR_INFO fill; 169 CHAR_INFO fill;
169 170
@@ -179,15 +180,16 @@ w32con_ins_del_lines (struct frame *f, int vpos, int n)
179 scroll.Bottom = FRAME_LINES (f) - n; 180 scroll.Bottom = FRAME_LINES (f) - n;
180 dest.Y = vpos + n; 181 dest.Y = vpos + n;
181 } 182 }
182 scroll.Left = 0; 183 clip.Top = clip.Left = scroll.Left = 0;
183 scroll.Right = FRAME_COLS (f); 184 clip.Right = scroll.Right = FRAME_COLS (f);
185 clip.Bottom = FRAME_LINES (f);
184 186
185 dest.X = 0; 187 dest.X = 0;
186 188
187 fill.Char.AsciiChar = 0x20; 189 fill.Char.AsciiChar = 0x20;
188 fill.Attributes = char_attr_normal; 190 fill.Attributes = char_attr_normal;
189 191
190 ScrollConsoleScreenBuffer (cur_screen, &scroll, NULL, dest, &fill); 192 ScrollConsoleScreenBuffer (cur_screen, &scroll, &clip, dest, &fill);
191 193
192 /* Here we have to deal with a w32 console flake: If the scroll 194 /* Here we have to deal with a w32 console flake: If the scroll
193 region looks like abc and we scroll c to a and fill with d we get 195 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)
235{ 237{
236 /* The idea here is to implement a horizontal scroll in one line to 238 /* The idea here is to implement a horizontal scroll in one line to
237 implement delete and half of insert. */ 239 implement delete and half of insert. */
238 SMALL_RECT scroll; 240 SMALL_RECT scroll, clip;
239 COORD dest; 241 COORD dest;
240 CHAR_INFO fill; 242 CHAR_INFO fill;
241 243
242 scroll.Top = cursor_coords.Y; 244 clip.Top = scroll.Top = clip.Bottom = scroll.Bottom = cursor_coords.Y;
243 scroll.Bottom = cursor_coords.Y; 245 clip.Left = 0;
246 clip.Right = FRAME_COLS (f);
244 247
245 if (direction == LEFT) 248 if (direction == LEFT)
246 { 249 {
@@ -259,7 +262,7 @@ scroll_line (struct frame *f, int dist, int direction)
259 fill.Char.AsciiChar = 0x20; 262 fill.Char.AsciiChar = 0x20;
260 fill.Attributes = char_attr_normal; 263 fill.Attributes = char_attr_normal;
261 264
262 ScrollConsoleScreenBuffer (cur_screen, &scroll, NULL, dest, &fill); 265 ScrollConsoleScreenBuffer (cur_screen, &scroll, &clip, dest, &fill);
263} 266}
264 267
265 268
@@ -290,7 +293,6 @@ static void
290w32con_write_glyphs (struct frame *f, register struct glyph *string, 293w32con_write_glyphs (struct frame *f, register struct glyph *string,
291 register int len) 294 register int len)
292{ 295{
293 int produced, consumed;
294 DWORD r; 296 DWORD r;
295 WORD char_attr; 297 WORD char_attr;
296 unsigned char *conversion_buffer; 298 unsigned char *conversion_buffer;
@@ -418,11 +420,31 @@ SOUND is nil to use the normal beep. */)
418static void 420static void
419w32con_reset_terminal_modes (struct terminal *t) 421w32con_reset_terminal_modes (struct terminal *t)
420{ 422{
423 COORD dest;
424 CONSOLE_SCREEN_BUFFER_INFO info;
425 int n;
426 DWORD r;
427
428 /* Clear the complete screen buffer. This is required because Emacs
429 sets the cursor position to the top of the buffer, but there might
430 be other output below the bottom of the Emacs frame if the screen buffer
431 is larger than the window size. */
432 GetConsoleScreenBufferInfo (cur_screen, &info);
433 dest.X = 0;
434 dest.Y = 0;
435 n = info.dwSize.X * info.dwSize.Y;
436
437 FillConsoleOutputAttribute (cur_screen, char_attr_normal, n, dest, &r);
438 FillConsoleOutputCharacter (cur_screen, ' ', n, dest, &r);
439 /* Now that the screen is clear, put the cursor at the top. */
440 SetConsoleCursorPosition (cur_screen, dest);
441
421#ifdef USE_SEPARATE_SCREEN 442#ifdef USE_SEPARATE_SCREEN
422 SetConsoleActiveScreenBuffer (prev_screen); 443 SetConsoleActiveScreenBuffer (prev_screen);
423#else 444#else
424 SetConsoleCursorInfo (prev_screen, &prev_console_cursor); 445 SetConsoleCursorInfo (prev_screen, &prev_console_cursor);
425#endif 446#endif
447
426 SetConsoleMode (keyboard_handle, prev_console_mode); 448 SetConsoleMode (keyboard_handle, prev_console_mode);
427} 449}
428 450
@@ -484,32 +506,31 @@ w32_face_attributes (f, face_id)
484 506
485 char_attr = char_attr_normal; 507 char_attr = char_attr_normal;
486 508
487 if (face->foreground != FACE_TTY_DEFAULT_FG_COLOR 509 /* Reverse the default color if requested. If background and
488 && face->foreground != FACE_TTY_DEFAULT_COLOR) 510 foreground are specified, then they have been reversed already. */
489 char_attr = (char_attr & 0xfff0) + (face->foreground % 16);
490
491 if (face->background != FACE_TTY_DEFAULT_BG_COLOR
492 && face->background != FACE_TTY_DEFAULT_COLOR)
493 char_attr = (char_attr & 0xff0f) + ((face->background % 16) << 4);
494
495
496 /* NTEMACS_TODO: Faces defined during startup get both foreground
497 and background of 0. Need a better way around this - for now detect
498 the problem and invert one of the faces to make the text readable. */
499 if (((char_attr & 0x00f0) >> 4) == (char_attr & 0x000f))
500 char_attr ^= 0x0007;
501
502 if (face->tty_reverse_p) 511 if (face->tty_reverse_p)
503 char_attr = (char_attr & 0xff00) + ((char_attr & 0x000f) << 4) 512 char_attr = (char_attr & 0xff00) + ((char_attr & 0x000f) << 4)
504 + ((char_attr & 0x00f0) >> 4); 513 + ((char_attr & 0x00f0) >> 4);
505 514
506 return char_attr; 515 /* Before the terminal is properly initialized, all colors map to 0.
507} 516 Don't try to resolve them. */
517 if (NILP (Vtty_defined_color_alist))
518 return char_attr;
519
520 /* Colors should be in the range 0...15 unless they are one of
521 FACE_TTY_DEFAULT_COLOR, FACE_TTY_DEFAULT_FG_COLOR or
522 FACE_TTY_DEFAULT_BG_COLOR. Other out of range colors are
523 invalid, so it is better to use the default color if they ever
524 get through to here. */
525 if (face->foreground >= 0 && face->foreground < 16)
526 char_attr = (char_attr & 0xfff0) + face->foreground;
508 527
528 if (face->background >= 0 && face->background < 16)
529 char_attr = (char_attr & 0xff0f) + (face->background << 4);
509 530
510/* Emulation of some X window features from xfns.c and xfaces.c. */ 531 return char_attr;
532}
511 533
512extern char unspecified_fg[], unspecified_bg[];
513 534
514 535
515/* Given a color index, return its standard name. */ 536/* 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;
79 79
80extern char *lispy_function_keys[]; 80extern char *lispy_function_keys[];
81 81
82/* The gray bitmap `bitmaps/gray'. This is done because w32term.c uses
83 it, and including `bitmaps/gray' more than once is a problem when
84 config.h defines `static' as an empty replacement string. */
85
86int gray_bitmap_width = gray_width;
87int gray_bitmap_height = gray_height;
88unsigned char *gray_bitmap_bits = gray_bits;
89
90/* The colormap for converting color names to RGB values */ 82/* The colormap for converting color names to RGB values */
91Lisp_Object Vw32_color_map; 83Lisp_Object Vw32_color_map;
92 84
@@ -149,10 +141,10 @@ int w32_mouse_button_tolerance;
149int w32_mouse_move_interval; 141int w32_mouse_move_interval;
150 142
151/* Flag to indicate if XBUTTON events should be passed on to Windows. */ 143/* Flag to indicate if XBUTTON events should be passed on to Windows. */
152int w32_pass_extra_mouse_buttons_to_system; 144static int w32_pass_extra_mouse_buttons_to_system;
153 145
154/* Flag to indicate if media keys should be passed on to Windows. */ 146/* Flag to indicate if media keys should be passed on to Windows. */
155int w32_pass_multimedia_buttons_to_system; 147static int w32_pass_multimedia_buttons_to_system;
156 148
157/* Non nil if no window manager is in use. */ 149/* Non nil if no window manager is in use. */
158Lisp_Object Vx_no_window_manager; 150Lisp_Object Vx_no_window_manager;
@@ -191,14 +183,14 @@ Lisp_Object Vx_pixel_size_width_font_regexp;
191Lisp_Object Vw32_bdf_filename_alist; 183Lisp_Object Vw32_bdf_filename_alist;
192 184
193/* A flag to control whether fonts are matched strictly or not. */ 185/* A flag to control whether fonts are matched strictly or not. */
194int w32_strict_fontnames; 186static int w32_strict_fontnames;
195 187
196/* A flag to control whether we should only repaint if GetUpdateRect 188/* A flag to control whether we should only repaint if GetUpdateRect
197 indicates there is an update region. */ 189 indicates there is an update region. */
198int w32_strict_painting; 190static int w32_strict_painting;
199 191
200/* Associative list linking character set strings to Windows codepages. */ 192/* Associative list linking character set strings to Windows codepages. */
201Lisp_Object Vw32_charset_info_alist; 193static Lisp_Object Vw32_charset_info_alist;
202 194
203/* VIETNAMESE_CHARSET is not defined in some versions of MSVC. */ 195/* VIETNAMESE_CHARSET is not defined in some versions of MSVC. */
204#ifndef VIETNAMESE_CHARSET 196#ifndef VIETNAMESE_CHARSET
@@ -478,7 +470,7 @@ x_real_positions (f, xptr, yptr)
478DEFUN ("w32-define-rgb-color", Fw32_define_rgb_color, 470DEFUN ("w32-define-rgb-color", Fw32_define_rgb_color,
479 Sw32_define_rgb_color, 4, 4, 0, 471 Sw32_define_rgb_color, 4, 4, 0,
480 doc: /* Convert RGB numbers to a windows color reference and associate with NAME. 472 doc: /* Convert RGB numbers to a windows color reference and associate with NAME.
481This adds or updates a named color to w32-color-map, making it 473This adds or updates a named color to `w32-color-map', making it
482available for use. The original entry's RGB ref is returned, or nil 474available for use. The original entry's RGB ref is returned, or nil
483if the entry is new. */) 475if the entry is new. */)
484 (red, green, blue, name) 476 (red, green, blue, name)
@@ -493,7 +485,7 @@ if the entry is new. */)
493 CHECK_NUMBER (blue); 485 CHECK_NUMBER (blue);
494 CHECK_STRING (name); 486 CHECK_STRING (name);
495 487
496 XSETINT (rgb, RGB(XUINT (red), XUINT (green), XUINT (blue))); 488 XSETINT (rgb, RGB (XUINT (red), XUINT (green), XUINT (blue)));
497 489
498 BLOCK_INPUT; 490 BLOCK_INPUT;
499 491
@@ -518,7 +510,7 @@ if the entry is new. */)
518DEFUN ("w32-load-color-file", Fw32_load_color_file, 510DEFUN ("w32-load-color-file", Fw32_load_color_file,
519 Sw32_load_color_file, 1, 1, 0, 511 Sw32_load_color_file, 1, 1, 0,
520 doc: /* Create an alist of color entries from an external file. 512 doc: /* Create an alist of color entries from an external file.
521Assign this value to w32-color-map to replace the existing color map. 513Assign this value to `w32-color-map' to replace the existing color map.
522 514
523The file should define one named RGB color per line like so: 515The file should define one named RGB color per line like so:
524 R G B name 516 R G B name
@@ -836,7 +828,7 @@ DEFUN ("w32-default-color-map", Fw32_default_color_map, Sw32_default_color_map,
836 return (cmap); 828 return (cmap);
837} 829}
838 830
839Lisp_Object 831static Lisp_Object
840w32_to_x_color (rgb) 832w32_to_x_color (rgb)
841 Lisp_Object rgb; 833 Lisp_Object rgb;
842{ 834{
@@ -953,7 +945,7 @@ x_to_w32_color (colorname)
953 int size; 945 int size;
954 color = colorname + 1; 946 color = colorname + 1;
955 947
956 size = strlen(color); 948 size = strlen (color);
957 if (size == 3 || size == 6 || size == 9 || size == 12) 949 if (size == 3 || size == 6 || size == 9 || size == 12)
958 { 950 {
959 UINT colorval; 951 UINT colorval;
@@ -971,11 +963,11 @@ x_to_w32_color (colorname)
971 /* The check for 'x' in the following conditional takes into 963 /* The check for 'x' in the following conditional takes into
972 account the fact that strtol allows a "0x" in front of 964 account the fact that strtol allows a "0x" in front of
973 our numbers, and we don't. */ 965 our numbers, and we don't. */
974 if (!isxdigit(color[0]) || color[1] == 'x') 966 if (!isxdigit (color[0]) || color[1] == 'x')
975 break; 967 break;
976 t = color[size]; 968 t = color[size];
977 color[size] = '\0'; 969 color[size] = '\0';
978 value = strtoul(color, &end, 16); 970 value = strtoul (color, &end, 16);
979 color[size] = t; 971 color[size] = t;
980 if (errno == ERANGE || end - color != size) 972 if (errno == ERANGE || end - color != size)
981 break; 973 break;
@@ -1005,7 +997,7 @@ x_to_w32_color (colorname)
1005 } 997 }
1006 } 998 }
1007 } 999 }
1008 else if (strnicmp(colorname, "rgb:", 4) == 0) 1000 else if (strnicmp (colorname, "rgb:", 4) == 0)
1009 { 1001 {
1010 char *color; 1002 char *color;
1011 UINT colorval; 1003 UINT colorval;
@@ -1022,9 +1014,9 @@ x_to_w32_color (colorname)
1022 /* The check for 'x' in the following conditional takes into 1014 /* The check for 'x' in the following conditional takes into
1023 account the fact that strtol allows a "0x" in front of 1015 account the fact that strtol allows a "0x" in front of
1024 our numbers, and we don't. */ 1016 our numbers, and we don't. */
1025 if (!isxdigit(color[0]) || color[1] == 'x') 1017 if (!isxdigit (color[0]) || color[1] == 'x')
1026 break; 1018 break;
1027 value = strtoul(color, &end, 16); 1019 value = strtoul (color, &end, 16);
1028 if (errno == ERANGE) 1020 if (errno == ERANGE)
1029 break; 1021 break;
1030 switch (end - color) 1022 switch (end - color)
@@ -1060,7 +1052,7 @@ x_to_w32_color (colorname)
1060 color = end + 1; 1052 color = end + 1;
1061 } 1053 }
1062 } 1054 }
1063 else if (strnicmp(colorname, "rgbi:", 5) == 0) 1055 else if (strnicmp (colorname, "rgbi:", 5) == 0)
1064 { 1056 {
1065 /* This is an RGB Intensity specification. */ 1057 /* This is an RGB Intensity specification. */
1066 char *color; 1058 char *color;
@@ -1076,7 +1068,7 @@ x_to_w32_color (colorname)
1076 double value; 1068 double value;
1077 UINT val; 1069 UINT val;
1078 1070
1079 value = strtod(color, &end); 1071 value = strtod (color, &end);
1080 if (errno == ERANGE) 1072 if (errno == ERANGE)
1081 break; 1073 break;
1082 if (value < 0.0 || value > 1.0) 1074 if (value < 0.0 || value > 1.0)
@@ -1574,7 +1566,6 @@ x_set_mouse_color (f, arg, oldval)
1574#endif /* TODO */ 1566#endif /* TODO */
1575} 1567}
1576 1568
1577/* Defined in w32term.c. */
1578void 1569void
1579x_set_cursor_color (f, arg, oldval) 1570x_set_cursor_color (f, arg, oldval)
1580 struct frame *f; 1571 struct frame *f;
@@ -1926,7 +1917,7 @@ x_set_name (f, name, explicit)
1926 name = ENCODE_SYSTEM (name); 1917 name = ENCODE_SYSTEM (name);
1927 1918
1928 BLOCK_INPUT; 1919 BLOCK_INPUT;
1929 SetWindowText(FRAME_W32_WINDOW (f), SDATA (name)); 1920 SetWindowText (FRAME_W32_WINDOW (f), SDATA (name));
1930 UNBLOCK_INPUT; 1921 UNBLOCK_INPUT;
1931 } 1922 }
1932} 1923}
@@ -1978,7 +1969,7 @@ x_set_title (f, name, old_name)
1978 name = ENCODE_SYSTEM (name); 1969 name = ENCODE_SYSTEM (name);
1979 1970
1980 BLOCK_INPUT; 1971 BLOCK_INPUT;
1981 SetWindowText(FRAME_W32_WINDOW (f), SDATA (name)); 1972 SetWindowText (FRAME_W32_WINDOW (f), SDATA (name));
1982 UNBLOCK_INPUT; 1973 UNBLOCK_INPUT;
1983 } 1974 }
1984} 1975}
@@ -2025,7 +2016,7 @@ Cursor
2025w32_load_cursor (LPCTSTR name) 2016w32_load_cursor (LPCTSTR name)
2026{ 2017{
2027 /* Try first to load cursor from application resource. */ 2018 /* Try first to load cursor from application resource. */
2028 Cursor cursor = LoadImage ((HINSTANCE) GetModuleHandle(NULL), 2019 Cursor cursor = LoadImage ((HINSTANCE) GetModuleHandle (NULL),
2029 name, IMAGE_CURSOR, 0, 0, 2020 name, IMAGE_CURSOR, 0, 0,
2030 LR_DEFAULTCOLOR | LR_DEFAULTSIZE | LR_SHARED); 2021 LR_DEFAULTCOLOR | LR_DEFAULTSIZE | LR_SHARED);
2031 if (!cursor) 2022 if (!cursor)
@@ -2039,7 +2030,7 @@ w32_load_cursor (LPCTSTR name)
2039 2030
2040extern LRESULT CALLBACK w32_wnd_proc (); 2031extern LRESULT CALLBACK w32_wnd_proc ();
2041 2032
2042BOOL 2033static BOOL
2043w32_init_class (hinst) 2034w32_init_class (hinst)
2044 HINSTANCE hinst; 2035 HINSTANCE hinst;
2045{ 2036{
@@ -2059,24 +2050,24 @@ w32_init_class (hinst)
2059 return (RegisterClass (&wc)); 2050 return (RegisterClass (&wc));
2060} 2051}
2061 2052
2062HWND 2053static HWND
2063w32_createscrollbar (f, bar) 2054w32_createscrollbar (f, bar)
2064 struct frame *f; 2055 struct frame *f;
2065 struct scroll_bar * bar; 2056 struct scroll_bar * bar;
2066{ 2057{
2067 return (CreateWindow ("SCROLLBAR", "", SBS_VERT | WS_CHILD | WS_VISIBLE, 2058 return (CreateWindow ("SCROLLBAR", "", SBS_VERT | WS_CHILD | WS_VISIBLE,
2068 /* Position and size of scroll bar. */ 2059 /* Position and size of scroll bar. */
2069 XINT(bar->left) + VERTICAL_SCROLL_BAR_WIDTH_TRIM, 2060 XINT (bar->left) + VERTICAL_SCROLL_BAR_WIDTH_TRIM,
2070 XINT(bar->top), 2061 XINT (bar->top),
2071 XINT(bar->width) - VERTICAL_SCROLL_BAR_WIDTH_TRIM * 2, 2062 XINT (bar->width) - VERTICAL_SCROLL_BAR_WIDTH_TRIM * 2,
2072 XINT(bar->height), 2063 XINT (bar->height),
2073 FRAME_W32_WINDOW (f), 2064 FRAME_W32_WINDOW (f),
2074 NULL, 2065 NULL,
2075 hinst, 2066 hinst,
2076 NULL)); 2067 NULL));
2077} 2068}
2078 2069
2079void 2070static void
2080w32_createwindow (f) 2071w32_createwindow (f)
2081 struct frame *f; 2072 struct frame *f;
2082{ 2073{
@@ -2146,7 +2137,7 @@ w32_createwindow (f)
2146 } 2137 }
2147} 2138}
2148 2139
2149void 2140static void
2150my_post_msg (wmsg, hwnd, msg, wParam, lParam) 2141my_post_msg (wmsg, hwnd, msg, wParam, lParam)
2151 W32Msg * wmsg; 2142 W32Msg * wmsg;
2152 HWND hwnd; 2143 HWND hwnd;
@@ -2378,7 +2369,7 @@ w32_key_to_modifier (int key)
2378 return 0; 2369 return 0;
2379} 2370}
2380 2371
2381unsigned int 2372static unsigned int
2382w32_get_modifiers () 2373w32_get_modifiers ()
2383{ 2374{
2384 return ((modifier_set (VK_SHIFT) ? shift_modifier : 0) | 2375 return ((modifier_set (VK_SHIFT) ? shift_modifier : 0) |
@@ -2449,12 +2440,12 @@ map_keypad_keys (unsigned int virt_key, unsigned int extended)
2449} 2440}
2450 2441
2451/* List of special key combinations which w32 would normally capture, 2442/* List of special key combinations which w32 would normally capture,
2452 but emacs should grab instead. Not directly visible to lisp, to 2443 but Emacs should grab instead. Not directly visible to lisp, to
2453 simplify synchronization. Each item is an integer encoding a virtual 2444 simplify synchronization. Each item is an integer encoding a virtual
2454 key code and modifier combination to capture. */ 2445 key code and modifier combination to capture. */
2455Lisp_Object w32_grabbed_keys; 2446static Lisp_Object w32_grabbed_keys;
2456 2447
2457#define HOTKEY(vk,mods) make_number (((vk) & 255) | ((mods) << 8)) 2448#define HOTKEY(vk, mods) make_number (((vk) & 255) | ((mods) << 8))
2458#define HOTKEY_ID(k) (XFASTINT (k) & 0xbfff) 2449#define HOTKEY_ID(k) (XFASTINT (k) & 0xbfff)
2459#define HOTKEY_VK_CODE(k) (XFASTINT (k) & 255) 2450#define HOTKEY_VK_CODE(k) (XFASTINT (k) & 255)
2460#define HOTKEY_MODIFIERS(k) (XFASTINT (k) >> 8) 2451#define HOTKEY_MODIFIERS(k) (XFASTINT (k) >> 8)
@@ -2680,7 +2671,7 @@ complete_deferred_msg (HWND hwnd, UINT msg, LRESULT result)
2680 deferred_msg * msg_buf = find_deferred_msg (hwnd, msg); 2671 deferred_msg * msg_buf = find_deferred_msg (hwnd, msg);
2681 2672
2682 if (msg_buf == NULL) 2673 if (msg_buf == NULL)
2683 /* Message may have been cancelled, so don't abort(). */ 2674 /* Message may have been cancelled, so don't abort. */
2684 return; 2675 return;
2685 2676
2686 msg_buf->result = result; 2677 msg_buf->result = result;
@@ -2690,7 +2681,7 @@ complete_deferred_msg (HWND hwnd, UINT msg, LRESULT result)
2690 PostThreadMessage (dwWindowsThreadId, WM_NULL, 0, 0); 2681 PostThreadMessage (dwWindowsThreadId, WM_NULL, 0, 0);
2691} 2682}
2692 2683
2693void 2684static void
2694cancel_all_deferred_msgs () 2685cancel_all_deferred_msgs ()
2695{ 2686{
2696 deferred_msg * item; 2687 deferred_msg * item;
@@ -2768,7 +2759,7 @@ post_character_message (hwnd, msg, wParam, lParam, modifiers)
2768 2759
2769 /* Detect quit_char and set quit-flag directly. Note that we 2760 /* Detect quit_char and set quit-flag directly. Note that we
2770 still need to post a message to ensure the main thread will be 2761 still need to post a message to ensure the main thread will be
2771 woken up if blocked in sys_select(), but we do NOT want to post 2762 woken up if blocked in sys_select, but we do NOT want to post
2772 the quit_char message itself (because it will usually be as if 2763 the quit_char message itself (because it will usually be as if
2773 the user had typed quit_char twice). Instead, we post a dummy 2764 the user had typed quit_char twice). Instead, we post a dummy
2774 message that has no particular effect. */ 2765 message that has no particular effect. */
@@ -2923,7 +2914,7 @@ w32_wnd_proc (hwnd, msg, wParam, lParam)
2923 2914
2924 /* If GetUpdateRect returns 0 (meaning there is no update 2915 /* If GetUpdateRect returns 0 (meaning there is no update
2925 region), assume the whole window needs to be repainted. */ 2916 region), assume the whole window needs to be repainted. */
2926 GetClientRect(hwnd, &wmsg.rect); 2917 GetClientRect (hwnd, &wmsg.rect);
2927 my_post_msg (&wmsg, hwnd, msg, wParam, lParam); 2918 my_post_msg (&wmsg, hwnd, msg, wParam, lParam);
2928 return 0; 2919 return 0;
2929 } 2920 }
@@ -3774,7 +3765,7 @@ w32_wnd_proc (hwnd, msg, wParam, lParam)
3774 DWORD scrollbar_extra; 3765 DWORD scrollbar_extra;
3775 RECT wr; 3766 RECT wr;
3776 3767
3777 wp.length = sizeof(wp); 3768 wp.length = sizeof (wp);
3778 GetWindowRect (hwnd, &wr); 3769 GetWindowRect (hwnd, &wr);
3779 3770
3780 enter_crit (); 3771 enter_crit ();
@@ -4251,7 +4242,7 @@ x_default_font_parameter (f, parms)
4251DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame, 4242DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
4252 1, 1, 0, 4243 1, 1, 0,
4253 doc: /* Make a new window, which is called a \"frame\" in Emacs terms. 4244 doc: /* Make a new window, which is called a \"frame\" in Emacs terms.
4254Returns an Emacs frame object. 4245Return an Emacs frame object.
4255PARAMETERS is an alist of frame parameters. 4246PARAMETERS is an alist of frame parameters.
4256If the parameters specify that the frame should not have a minibuffer, 4247If the parameters specify that the frame should not have a minibuffer,
4257and do not specify a specific minibuffer window to use, 4248and 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,
4621 4612
4622 4613
4623/* Return the charset portion of a font name. */ 4614/* Return the charset portion of a font name. */
4624char * xlfd_charset_of_font (char * fontname) 4615char *
4616xlfd_charset_of_font (char * fontname)
4625{ 4617{
4626 char *charset, *encoding; 4618 char *charset, *encoding;
4627 4619
4628 encoding = strrchr(fontname, '-'); 4620 encoding = strrchr (fontname, '-');
4629 if (!encoding || encoding == fontname) 4621 if (!encoding || encoding == fontname)
4630 return NULL; 4622 return NULL;
4631 4623
@@ -4633,7 +4625,7 @@ char * xlfd_charset_of_font (char * fontname)
4633 if (*charset == '-') 4625 if (*charset == '-')
4634 break; 4626 break;
4635 4627
4636 if (charset == fontname || strcmp(charset, "-*-*") == 0) 4628 if (charset == fontname || strcmp (charset, "-*-*") == 0)
4637 return NULL; 4629 return NULL;
4638 4630
4639 return charset + 1; 4631 return charset + 1;
@@ -4647,7 +4639,7 @@ static BOOL w32_to_x_font (LOGFONT * lplf, char * lpxstr, int len,
4647static BOOL x_to_w32_font (char *lpxstr, LOGFONT *lplogfont); 4639static BOOL x_to_w32_font (char *lpxstr, LOGFONT *lplogfont);
4648 4640
4649static struct font_info * 4641static struct font_info *
4650w32_load_system_font (f,fontname,size) 4642w32_load_system_font (f, fontname, size)
4651 struct frame *f; 4643 struct frame *f;
4652 char * fontname; 4644 char * fontname;
4653 int size; 4645 int size;
@@ -4750,7 +4742,7 @@ w32_load_system_font (f,fontname,size)
4750 GetFontLanguageInfo, we check the properties of the 4742 GetFontLanguageInfo, we check the properties of the
4751 codepage directly, since that is ultimately what we are 4743 codepage directly, since that is ultimately what we are
4752 working from anyway. */ 4744 working from anyway. */
4753 /* font->double_byte_p = GetFontLanguageInfo(hdc) & GCP_DBCS; */ 4745 /* font->double_byte_p = GetFontLanguageInfo (hdc) & GCP_DBCS; */
4754 CPINFO cpi = {0}; 4746 CPINFO cpi = {0};
4755 GetCPInfo (codepage, &cpi); 4747 GetCPInfo (codepage, &cpi);
4756 font->double_byte_p = cpi.MaxCharSize > 1; 4748 font->double_byte_p = cpi.MaxCharSize > 1;
@@ -4887,10 +4879,10 @@ w32_load_system_font (f,fontname,size)
4887 pointer to the structure font_info while allocating it dynamically. 4879 pointer to the structure font_info while allocating it dynamically.
4888 If loading fails, return NULL. */ 4880 If loading fails, return NULL. */
4889struct font_info * 4881struct font_info *
4890w32_load_font (f,fontname,size) 4882w32_load_font (f, fontname, size)
4891struct frame *f; 4883 struct frame *f;
4892char * fontname; 4884 char * fontname;
4893int size; 4885 int size;
4894{ 4886{
4895 Lisp_Object bdf_fonts; 4887 Lisp_Object bdf_fonts;
4896 struct font_info *retval = NULL; 4888 struct font_info *retval = NULL;
@@ -4926,7 +4918,7 @@ int size;
4926 if (retval) 4918 if (retval)
4927 return retval; 4919 return retval;
4928 4920
4929 return w32_load_system_font(f, fontname, size); 4921 return w32_load_system_font (f, fontname, size);
4930} 4922}
4931 4923
4932 4924
@@ -4940,7 +4932,7 @@ w32_unload_font (dpyinfo, font)
4940 if (font->per_char) xfree (font->per_char); 4932 if (font->per_char) xfree (font->per_char);
4941 if (font->bdf) w32_free_bdf_font (font->bdf); 4933 if (font->bdf) w32_free_bdf_font (font->bdf);
4942 4934
4943 if (font->hfont) DeleteObject(font->hfont); 4935 if (font->hfont) DeleteObject (font->hfont);
4944 xfree (font); 4936 xfree (font);
4945 } 4937 }
4946} 4938}
@@ -4974,16 +4966,16 @@ x_to_w32_weight (lpw)
4974{ 4966{
4975 if (!lpw) return (FW_DONTCARE); 4967 if (!lpw) return (FW_DONTCARE);
4976 4968
4977 if (stricmp (lpw,"heavy") == 0) return FW_HEAVY; 4969 if (stricmp (lpw, "heavy") == 0) return FW_HEAVY;
4978 else if (stricmp (lpw,"extrabold") == 0) return FW_EXTRABOLD; 4970 else if (stricmp (lpw, "extrabold") == 0) return FW_EXTRABOLD;
4979 else if (stricmp (lpw,"bold") == 0) return FW_BOLD; 4971 else if (stricmp (lpw, "bold") == 0) return FW_BOLD;
4980 else if (stricmp (lpw,"demibold") == 0) return FW_SEMIBOLD; 4972 else if (stricmp (lpw, "demibold") == 0) return FW_SEMIBOLD;
4981 else if (stricmp (lpw,"semibold") == 0) return FW_SEMIBOLD; 4973 else if (stricmp (lpw, "semibold") == 0) return FW_SEMIBOLD;
4982 else if (stricmp (lpw,"medium") == 0) return FW_MEDIUM; 4974 else if (stricmp (lpw, "medium") == 0) return FW_MEDIUM;
4983 else if (stricmp (lpw,"normal") == 0) return FW_NORMAL; 4975 else if (stricmp (lpw, "normal") == 0) return FW_NORMAL;
4984 else if (stricmp (lpw,"light") == 0) return FW_LIGHT; 4976 else if (stricmp (lpw, "light") == 0) return FW_LIGHT;
4985 else if (stricmp (lpw,"extralight") == 0) return FW_EXTRALIGHT; 4977 else if (stricmp (lpw, "extralight") == 0) return FW_EXTRALIGHT;
4986 else if (stricmp (lpw,"thin") == 0) return FW_THIN; 4978 else if (stricmp (lpw, "thin") == 0) return FW_THIN;
4987 else 4979 else
4988 return FW_DONTCARE; 4980 return FW_DONTCARE;
4989} 4981}
@@ -5033,12 +5025,12 @@ x_to_w32_charset (lpcs)
5033 Format of each entry is 5025 Format of each entry is
5034 (CHARSET_NAME . (WINDOWS_CHARSET . CODEPAGE)). 5026 (CHARSET_NAME . (WINDOWS_CHARSET . CODEPAGE)).
5035 */ 5027 */
5036 this_entry = Fassoc (build_string(charset), Vw32_charset_info_alist); 5028 this_entry = Fassoc (build_string (charset), Vw32_charset_info_alist);
5037 5029
5038 if (NILP(this_entry)) 5030 if (NILP (this_entry))
5039 { 5031 {
5040 /* At startup, we want iso8859-1 fonts to come up properly. */ 5032 /* At startup, we want iso8859-1 fonts to come up properly. */
5041 if (stricmp(charset, "iso8859-1") == 0) 5033 if (stricmp (charset, "iso8859-1") == 0)
5042 return ANSI_CHARSET; 5034 return ANSI_CHARSET;
5043 else 5035 else
5044 return DEFAULT_CHARSET; 5036 return DEFAULT_CHARSET;
@@ -5121,7 +5113,7 @@ w32_to_x_charset (fncharset, matching)
5121 case ANSI_CHARSET: 5113 case ANSI_CHARSET:
5122 /* Handle startup case of w32-charset-info-alist not 5114 /* Handle startup case of w32-charset-info-alist not
5123 being set up yet. */ 5115 being set up yet. */
5124 if (NILP(Vw32_charset_info_alist)) 5116 if (NILP (Vw32_charset_info_alist))
5125 return "iso8859-1"; 5117 return "iso8859-1";
5126 charset_type = Qw32_charset_ansi; 5118 charset_type = Qw32_charset_ansi;
5127 break; 5119 break;
@@ -5315,7 +5307,7 @@ w32_to_all_x_charsets (fncharset)
5315 case ANSI_CHARSET: 5307 case ANSI_CHARSET:
5316 /* Handle startup case of w32-charset-info-alist not 5308 /* Handle startup case of w32-charset-info-alist not
5317 being set up yet. */ 5309 being set up yet. */
5318 if (NILP(Vw32_charset_info_alist)) 5310 if (NILP (Vw32_charset_info_alist))
5319 return Fcons (build_string ("iso8859-1"), Qnil); 5311 return Fcons (build_string ("iso8859-1"), Qnil);
5320 5312
5321 charset_type = Qw32_charset_ansi; 5313 charset_type = Qw32_charset_ansi;
@@ -5543,6 +5535,9 @@ w32_to_x_font (lplogfont, lpxstr, len, specific_charset)
5543 strlen(lplogfont->lfFaceName), Qnil); 5535 strlen(lplogfont->lfFaceName), Qnil);
5544 fontname = coding.destination; 5536 fontname = coding.destination;
5545 5537
5538 fontname = alloca (sizeof (*fontname) * bufsz);
5539 decode_coding (&coding, lplogfont->lfFaceName, fontname,
5540 strlen (lplogfont->lfFaceName), bufsz - 1);
5546 *(fontname + coding.produced) = '\0'; 5541 *(fontname + coding.produced) = '\0';
5547 5542
5548 /* Replace dashes with underscores so the dashes are not 5543 /* Replace dashes with underscores so the dashes are not
@@ -5754,7 +5749,7 @@ x_to_w32_font (lpxstr, lplogfont)
5754 5749
5755 if (fields > 0) 5750 if (fields > 0)
5756 { 5751 {
5757 strncpy (lplogfont->lfFaceName,name, LF_FACESIZE); 5752 strncpy (lplogfont->lfFaceName, name, LF_FACESIZE);
5758 lplogfont->lfFaceName[LF_FACESIZE-1] = 0; 5753 lplogfont->lfFaceName[LF_FACESIZE-1] = 0;
5759 } 5754 }
5760 else 5755 else
@@ -5953,7 +5948,7 @@ w32_font_match (fontname, pattern)
5953 } 5948 }
5954 5949
5955 return (fast_string_match_ignore_case (build_string (regex), 5950 return (fast_string_match_ignore_case (build_string (regex),
5956 build_string(font_name_copy)) >= 0); 5951 build_string (font_name_copy)) >= 0);
5957} 5952}
5958 5953
5959/* Callback functions, and a structure holding info they need, for 5954/* Callback functions, and a structure holding info they need, for
@@ -6189,7 +6184,8 @@ enum_fontex_cb1 (lplf, lptm, font_type, lpef)
6189/* Interface to fontset handler. (adapted from mw32font.c in Meadow 6184/* Interface to fontset handler. (adapted from mw32font.c in Meadow
6190 and xterm.c in Emacs 20.3) */ 6185 and xterm.c in Emacs 20.3) */
6191 6186
6192static Lisp_Object w32_list_bdf_fonts (Lisp_Object pattern, int max_names) 6187static Lisp_Object
6188w32_list_bdf_fonts (Lisp_Object pattern, int max_names)
6193{ 6189{
6194 char *fontname, *ptnstr; 6190 char *fontname, *ptnstr;
6195 Lisp_Object list, tem, newlist = Qnil; 6191 Lisp_Object list, tem, newlist = Qnil;
@@ -6260,7 +6256,7 @@ w32_list_fonts (f, pattern, size, maxnames)
6260 codepage = w32_codepage_for_font (SDATA (tpat)); 6256 codepage = w32_codepage_for_font (SDATA (tpat));
6261 if (codepage != CP_8BIT && codepage != CP_UNICODE 6257 if (codepage != CP_8BIT && codepage != CP_UNICODE
6262 && codepage != CP_DEFAULT && codepage != CP_UNKNOWN 6258 && codepage != CP_DEFAULT && codepage != CP_UNKNOWN
6263 && !IsValidCodePage(codepage)) 6259 && !IsValidCodePage (codepage))
6264 continue; 6260 continue;
6265 6261
6266 /* See if we cached the result for this particular query. 6262 /* See if we cached the result for this particular query.
@@ -6371,7 +6367,7 @@ w32_list_fonts (f, pattern, size, maxnames)
6371 XSETCDR (tem, make_number (0)); 6367 XSETCDR (tem, make_number (0));
6372 SelectObject (hdc, oldobj); 6368 SelectObject (hdc, oldobj);
6373 ReleaseDC (dpyinfo->root_window, hdc); 6369 ReleaseDC (dpyinfo->root_window, hdc);
6374 DeleteObject(thisinfo.hfont); 6370 DeleteObject (thisinfo.hfont);
6375 UNBLOCK_INPUT; 6371 UNBLOCK_INPUT;
6376 } 6372 }
6377 found_size = XINT (XCDR (tem)); 6373 found_size = XINT (XCDR (tem));
@@ -6420,7 +6416,7 @@ w32_list_fonts (f, pattern, size, maxnames)
6420 Lisp_Object combined[2]; 6416 Lisp_Object combined[2];
6421 combined[0] = w32_list_bdf_fonts (pattern, maxnames - n_fonts); 6417 combined[0] = w32_list_bdf_fonts (pattern, maxnames - n_fonts);
6422 combined[1] = newlist; 6418 combined[1] = newlist;
6423 newlist = Fnconc(2, combined); 6419 newlist = Fnconc (2, combined);
6424 } 6420 }
6425 6421
6426 return newlist; 6422 return newlist;
@@ -6447,7 +6443,7 @@ w32_query_font (struct frame *f, char *fontname)
6447 6443
6448 for (i = 0; i < one_w32_display_info.n_fonts ;i++, pfi++) 6444 for (i = 0; i < one_w32_display_info.n_fonts ;i++, pfi++)
6449 { 6445 {
6450 if (stricmp(pfi->name, fontname) == 0) return pfi; 6446 if (stricmp (pfi->name, fontname) == 0) return pfi;
6451 } 6447 }
6452 6448
6453 return NULL; 6449 return NULL;
@@ -6484,7 +6480,7 @@ w32_find_ccl_program (fontp)
6484} 6480}
6485 6481
6486/* directory-files from dired.c. */ 6482/* directory-files from dired.c. */
6487Lisp_Object Fdirectory_files P_((Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object)); 6483Lisp_Object Fdirectory_files P_ ((Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object));
6488 6484
6489 6485
6490/* Find BDF files in a specified directory. (use GCPRO when calling, 6486/* Find BDF files in a specified directory. (use GCPRO when calling,
@@ -6495,13 +6491,13 @@ w32_find_bdf_fonts_in_dir (Lisp_Object directory)
6495 Lisp_Object filelist, list = Qnil; 6491 Lisp_Object filelist, list = Qnil;
6496 char fontname[100]; 6492 char fontname[100];
6497 6493
6498 if (!STRINGP(directory)) 6494 if (!STRINGP (directory))
6499 return Qnil; 6495 return Qnil;
6500 6496
6501 filelist = Fdirectory_files (directory, Qt, 6497 filelist = Fdirectory_files (directory, Qt,
6502 build_string (".*\\.[bB][dD][fF]"), Qt); 6498 build_string (".*\\.[bB][dD][fF]"), Qt);
6503 6499
6504 for ( ; CONSP(filelist); filelist = XCDR (filelist)) 6500 for ( ; CONSP (filelist); filelist = XCDR (filelist))
6505 { 6501 {
6506 Lisp_Object filename = XCAR (filelist); 6502 Lisp_Object filename = XCAR (filelist);
6507 if (w32_BDF_to_x_font (SDATA (filename), fontname, 100)) 6503 if (w32_BDF_to_x_font (SDATA (filename), fontname, 100))
@@ -6531,8 +6527,8 @@ in the list. DIRECTORY may be a list of directories. */)
6531 pair[0] = list; 6527 pair[0] = list;
6532 pair[1] = Qnil; 6528 pair[1] = Qnil;
6533 GCPRO2 (directory, list); 6529 GCPRO2 (directory, list);
6534 pair[1] = w32_find_bdf_fonts_in_dir( XCAR (directory) ); 6530 pair[1] = w32_find_bdf_fonts_in_dir ( XCAR (directory) );
6535 list = Fnconc( 2, pair ); 6531 list = Fnconc ( 2, pair );
6536 UNGCPRO; 6532 UNGCPRO;
6537 } 6533 }
6538 return list; 6534 return list;
@@ -6609,7 +6605,7 @@ If omitted or nil, that stands for the selected frame's display. */)
6609 6605
6610DEFUN ("x-display-pixel-width", Fx_display_pixel_width, 6606DEFUN ("x-display-pixel-width", Fx_display_pixel_width,
6611 Sx_display_pixel_width, 0, 1, 0, 6607 Sx_display_pixel_width, 0, 1, 0,
6612 doc: /* Returns the width in pixels of DISPLAY. 6608 doc: /* Return the width in pixels of DISPLAY.
6613The optional argument DISPLAY specifies which display to ask about. 6609The optional argument DISPLAY specifies which display to ask about.
6614DISPLAY should be either a frame or a display name (a string). 6610DISPLAY should be either a frame or a display name (a string).
6615If omitted or nil, that stands for the selected frame's display. */) 6611If 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. */)
6623 6619
6624DEFUN ("x-display-pixel-height", Fx_display_pixel_height, 6620DEFUN ("x-display-pixel-height", Fx_display_pixel_height,
6625 Sx_display_pixel_height, 0, 1, 0, 6621 Sx_display_pixel_height, 0, 1, 0,
6626 doc: /* Returns the height in pixels of DISPLAY. 6622 doc: /* Return the height in pixels of DISPLAY.
6627The optional argument DISPLAY specifies which display to ask about. 6623The optional argument DISPLAY specifies which display to ask about.
6628DISPLAY should be either a frame or a display name (a string). 6624DISPLAY should be either a frame or a display name (a string).
6629If omitted or nil, that stands for the selected frame's display. */) 6625If 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. */)
6637 6633
6638DEFUN ("x-display-planes", Fx_display_planes, Sx_display_planes, 6634DEFUN ("x-display-planes", Fx_display_planes, Sx_display_planes,
6639 0, 1, 0, 6635 0, 1, 0,
6640 doc: /* Returns the number of bitplanes of DISPLAY. 6636 doc: /* Return the number of bitplanes of DISPLAY.
6641The optional argument DISPLAY specifies which display to ask about. 6637The optional argument DISPLAY specifies which display to ask about.
6642DISPLAY should be either a frame or a display name (a string). 6638DISPLAY should be either a frame or a display name (a string).
6643If omitted or nil, that stands for the selected frame's display. */) 6639If 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. */)
6651 6647
6652DEFUN ("x-display-color-cells", Fx_display_color_cells, Sx_display_color_cells, 6648DEFUN ("x-display-color-cells", Fx_display_color_cells, Sx_display_color_cells,
6653 0, 1, 0, 6649 0, 1, 0,
6654 doc: /* Returns the number of color cells of DISPLAY. 6650 doc: /* Return the number of color cells of DISPLAY.
6655The optional argument DISPLAY specifies which display to ask about. 6651The optional argument DISPLAY specifies which display to ask about.
6656DISPLAY should be either a frame or a display name (a string). 6652DISPLAY should be either a frame or a display name (a string).
6657If omitted or nil, that stands for the selected frame's display. */) 6653If 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. */)
6671 /* We force 24+ bit depths to 24-bit, both to prevent an overflow 6667 /* We force 24+ bit depths to 24-bit, both to prevent an overflow
6672 and because probably is more meaningful on Windows anyway */ 6668 and because probably is more meaningful on Windows anyway */
6673 if (cap < 0) 6669 if (cap < 0)
6674 cap = 1 << min(dpyinfo->n_planes * dpyinfo->n_cbits, 24); 6670 cap = 1 << min (dpyinfo->n_planes * dpyinfo->n_cbits, 24);
6675 6671
6676 ReleaseDC (dpyinfo->root_window, hdc); 6672 ReleaseDC (dpyinfo->root_window, hdc);
6677 6673
@@ -6681,7 +6677,7 @@ If omitted or nil, that stands for the selected frame's display. */)
6681DEFUN ("x-server-max-request-size", Fx_server_max_request_size, 6677DEFUN ("x-server-max-request-size", Fx_server_max_request_size,
6682 Sx_server_max_request_size, 6678 Sx_server_max_request_size,
6683 0, 1, 0, 6679 0, 1, 0,
6684 doc: /* Returns the maximum request size of the server of DISPLAY. 6680 doc: /* Return the maximum request size of the server of DISPLAY.
6685The optional argument DISPLAY specifies which display to ask about. 6681The optional argument DISPLAY specifies which display to ask about.
6686DISPLAY should be either a frame or a display name (a string). 6682DISPLAY should be either a frame or a display name (a string).
6687If omitted or nil, that stands for the selected frame's display. */) 6683If 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. */)
6694} 6690}
6695 6691
6696DEFUN ("x-server-vendor", Fx_server_vendor, Sx_server_vendor, 0, 1, 0, 6692DEFUN ("x-server-vendor", Fx_server_vendor, Sx_server_vendor, 0, 1, 0,
6697 doc: /* Returns the "vendor ID" string of the W32 system (Microsoft). 6693 doc: /* Return the "vendor ID" string of the W32 system (Microsoft).
6698The optional argument DISPLAY specifies which display to ask about. 6694The optional argument DISPLAY specifies which display to ask about.
6699DISPLAY should be either a frame or a display name (a string). 6695DISPLAY should be either a frame or a display name (a string).
6700If omitted or nil, that stands for the selected frame's display. */) 6696If 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. */)
6705} 6701}
6706 6702
6707DEFUN ("x-server-version", Fx_server_version, Sx_server_version, 0, 1, 0, 6703DEFUN ("x-server-version", Fx_server_version, Sx_server_version, 0, 1, 0,
6708 doc: /* Returns the version numbers of the server of DISPLAY. 6704 doc: /* Return the version numbers of the server of DISPLAY.
6709The value is a list of three integers: the major and minor 6705The value is a list of three integers: the major and minor
6710version numbers of the X Protocol in use, and the distributor-specific release 6706version numbers of the X Protocol in use, and the distributor-specific
6711number. See also the function `x-server-vendor'. 6707release number. See also the function `x-server-vendor'.
6712 6708
6713The optional argument DISPLAY specifies which display to ask about. 6709The optional argument DISPLAY specifies which display to ask about.
6714DISPLAY should be either a frame or a display name (a string). 6710DISPLAY 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. */)
6722} 6718}
6723 6719
6724DEFUN ("x-display-screens", Fx_display_screens, Sx_display_screens, 0, 1, 0, 6720DEFUN ("x-display-screens", Fx_display_screens, Sx_display_screens, 0, 1, 0,
6725 doc: /* Returns the number of screens on the server of DISPLAY. 6721 doc: /* Return the number of screens on the server of DISPLAY.
6726The optional argument DISPLAY specifies which display to ask about. 6722The optional argument DISPLAY specifies which display to ask about.
6727DISPLAY should be either a frame or a display name (a string). 6723DISPLAY should be either a frame or a display name (a string).
6728If omitted or nil, that stands for the selected frame's display. */) 6724If 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. */)
6734 6730
6735DEFUN ("x-display-mm-height", Fx_display_mm_height, 6731DEFUN ("x-display-mm-height", Fx_display_mm_height,
6736 Sx_display_mm_height, 0, 1, 0, 6732 Sx_display_mm_height, 0, 1, 0,
6737 doc: /* Returns the height in millimeters of DISPLAY. 6733 doc: /* Return the height in millimeters of DISPLAY.
6738The optional argument DISPLAY specifies which display to ask about. 6734The optional argument DISPLAY specifies which display to ask about.
6739DISPLAY should be either a frame or a display name (a string). 6735DISPLAY should be either a frame or a display name (a string).
6740If omitted or nil, that stands for the selected frame's display. */) 6736If 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. */)
6755} 6751}
6756 6752
6757DEFUN ("x-display-mm-width", Fx_display_mm_width, Sx_display_mm_width, 0, 1, 0, 6753DEFUN ("x-display-mm-width", Fx_display_mm_width, Sx_display_mm_width, 0, 1, 0,
6758 doc: /* Returns the width in millimeters of DISPLAY. 6754 doc: /* Return the width in millimeters of DISPLAY.
6759The optional argument DISPLAY specifies which display to ask about. 6755The optional argument DISPLAY specifies which display to ask about.
6760DISPLAY should be either a frame or a display name (a string). 6756DISPLAY should be either a frame or a display name (a string).
6761If omitted or nil, that stands for the selected frame's display. */) 6757If 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. */)
6778 6774
6779DEFUN ("x-display-backing-store", Fx_display_backing_store, 6775DEFUN ("x-display-backing-store", Fx_display_backing_store,
6780 Sx_display_backing_store, 0, 1, 0, 6776 Sx_display_backing_store, 0, 1, 0,
6781 doc: /* Returns an indication of whether DISPLAY does backing store. 6777 doc: /* Return an indication of whether DISPLAY does backing store.
6782The value may be `always', `when-mapped', or `not-useful'. 6778The value may be `always', `when-mapped', or `not-useful'.
6783The optional argument DISPLAY specifies which display to ask about. 6779The optional argument DISPLAY specifies which display to ask about.
6784DISPLAY should be either a frame or a display name (a string). 6780DISPLAY 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. */)
6791 6787
6792DEFUN ("x-display-visual-class", Fx_display_visual_class, 6788DEFUN ("x-display-visual-class", Fx_display_visual_class,
6793 Sx_display_visual_class, 0, 1, 0, 6789 Sx_display_visual_class, 0, 1, 0,
6794 doc: /* Returns the visual class of DISPLAY. 6790 doc: /* Return the visual class of DISPLAY.
6795The value is one of the symbols `static-gray', `gray-scale', 6791The value is one of the symbols `static-gray', `gray-scale',
6796`static-color', `pseudo-color', `true-color', or `direct-color'. 6792`static-color', `pseudo-color', `true-color', or `direct-color'.
6797 6793
@@ -6818,7 +6814,7 @@ If omitted or nil, that stands for the selected frame's display. */)
6818 6814
6819DEFUN ("x-display-save-under", Fx_display_save_under, 6815DEFUN ("x-display-save-under", Fx_display_save_under,
6820 Sx_display_save_under, 0, 1, 0, 6816 Sx_display_save_under, 0, 1, 0,
6821 doc: /* Returns t if DISPLAY supports the save-under feature. 6817 doc: /* Return t if DISPLAY supports the save-under feature.
6822The optional argument DISPLAY specifies which display to ask about. 6818The optional argument DISPLAY specifies which display to ask about.
6823DISPLAY should be either a frame or a display name (a string). 6819DISPLAY should be either a frame or a display name (a string).
6824If omitted or nil, that stands for the selected frame's display. */) 6820If omitted or nil, that stands for the selected frame's display. */)
@@ -6934,7 +6930,7 @@ terminate Emacs if we can't open the connection. */)
6934 Lisp_Object color_file; 6930 Lisp_Object color_file;
6935 struct gcpro gcpro1; 6931 struct gcpro gcpro1;
6936 6932
6937 color_file = build_string("~/rgb.txt"); 6933 color_file = build_string ("~/rgb.txt");
6938 6934
6939 GCPRO1 (color_file); 6935 GCPRO1 (color_file);
6940 6936
@@ -8192,7 +8188,7 @@ If ONLY-DIR-P is non-nil, the user can only select directories. */)
8192 *last = '\0'; 8188 *last = '\0';
8193 } 8189 }
8194 8190
8195 file = DECODE_FILE(build_string (filename)); 8191 file = DECODE_FILE (build_string (filename));
8196 } 8192 }
8197 /* User cancelled the dialog without making a selection. */ 8193 /* User cancelled the dialog without making a selection. */
8198 else if (!CommDlgExtendedError ()) 8194 else if (!CommDlgExtendedError ())
@@ -8223,7 +8219,7 @@ If ONLY-DIR-P is non-nil, the user can only select directories. */)
8223 8219
8224DEFUN ("w32-select-font", Fw32_select_font, Sw32_select_font, 0, 2, 0, 8220DEFUN ("w32-select-font", Fw32_select_font, Sw32_select_font, 0, 2, 0,
8225 doc: /* Select a font for the named FRAME using the W32 font dialog. 8221 doc: /* Select a font for the named FRAME using the W32 font dialog.
8226Returns an X-style font string corresponding to the selection. 8222Return an X-style font string corresponding to the selection.
8227 8223
8228If FRAME is omitted or nil, it defaults to the selected frame. 8224If FRAME is omitted or nil, it defaults to the selected frame.
8229If INCLUDE-PROPORTIONAL is non-nil, include proportional fonts 8225If 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
8327also be a program executable to run, or a directory to open in the 8323also be a program executable to run, or a directory to open in the
8328Windows Explorer. 8324Windows Explorer.
8329 8325
8330If DOCUMENT is a program executable, the optional arg PARAMETERS can 8326If DOCUMENT is a program executable, the optional third arg PARAMETERS
8331be a string containing command line parameters that will be passed to 8327can be a string containing command line parameters that will be passed
8332the program; otherwise, PARAMETERS should be nil or unspecified. 8328to the program; otherwise, PARAMETERS should be nil or unspecified.
8333 8329
8334Second optional argument SHOW-FLAG can be used to control how the 8330Optional fourth argument SHOW-FLAG can be used to control how the
8335application will be displayed when it is invoked. If SHOW-FLAG is nil 8331application will be displayed when it is invoked. If SHOW-FLAG is nil
8336or unspceified, the application is displayed normally, otherwise it is 8332or unspecified, the application is displayed normally, otherwise it is
8337an integer representing a ShowWindow flag: 8333an integer representing a ShowWindow flag:
8338 8334
8339 0 - start hidden 8335 0 - start hidden
@@ -8470,7 +8466,7 @@ The return value is the hotkey-id if registered, otherwise nil. */)
8470{ 8466{
8471 key = w32_parse_hot_key (key); 8467 key = w32_parse_hot_key (key);
8472 8468
8473 if (NILP (Fmemq (key, w32_grabbed_keys))) 8469 if (!NILP (key) && NILP (Fmemq (key, w32_grabbed_keys)))
8474 { 8470 {
8475 /* Reuse an empty slot if possible. */ 8471 /* Reuse an empty slot if possible. */
8476 Lisp_Object item = Fmemq (Qnil, w32_grabbed_keys); 8472 Lisp_Object item = Fmemq (Qnil, w32_grabbed_keys);
@@ -8518,7 +8514,6 @@ DEFUN ("w32-unregister-hot-key", Fw32_unregister_hot_key,
8518#else 8514#else
8519 if (PostThreadMessage (dwWindowsThreadId, WM_EMACS_UNREGISTER_HOT_KEY, 8515 if (PostThreadMessage (dwWindowsThreadId, WM_EMACS_UNREGISTER_HOT_KEY,
8520 (WPARAM) XINT (XCAR (item)), (LPARAM) item)) 8516 (WPARAM) XINT (XCAR (item)), (LPARAM) item))
8521
8522#endif 8517#endif
8523 { 8518 {
8524 MSG msg; 8519 MSG msg;
@@ -8534,7 +8529,7 @@ DEFUN ("w32-registered-hot-keys", Fw32_registered_hot_keys,
8534 doc: /* Return list of registered hot-key IDs. */) 8529 doc: /* Return list of registered hot-key IDs. */)
8535 () 8530 ()
8536{ 8531{
8537 return Fcopy_sequence (w32_grabbed_keys); 8532 return Fdelq (Qnil, Fcopy_sequence (w32_grabbed_keys));
8538} 8533}
8539 8534
8540DEFUN ("w32-reconstruct-hot-key", Fw32_reconstruct_hot_key, 8535DEFUN ("w32-reconstruct-hot-key", Fw32_reconstruct_hot_key,
@@ -8697,10 +8692,10 @@ If the underlying system call fails, value is nil. */)
8697 LARGE_INTEGER freebytes; 8692 LARGE_INTEGER freebytes;
8698 LARGE_INTEGER totalbytes; 8693 LARGE_INTEGER totalbytes;
8699 8694
8700 if (pfn_GetDiskFreeSpaceEx(rootname, 8695 if (pfn_GetDiskFreeSpaceEx (rootname,
8701 (ULARGE_INTEGER *)&availbytes, 8696 (ULARGE_INTEGER *)&availbytes,
8702 (ULARGE_INTEGER *)&totalbytes, 8697 (ULARGE_INTEGER *)&totalbytes,
8703 (ULARGE_INTEGER *)&freebytes)) 8698 (ULARGE_INTEGER *)&freebytes))
8704 value = list3 (make_float ((double) totalbytes.QuadPart), 8699 value = list3 (make_float ((double) totalbytes.QuadPart),
8705 make_float ((double) freebytes.QuadPart), 8700 make_float ((double) freebytes.QuadPart),
8706 make_float ((double) availbytes.QuadPart)); 8701 make_float ((double) availbytes.QuadPart));
@@ -8712,11 +8707,11 @@ If the underlying system call fails, value is nil. */)
8712 DWORD free_clusters; 8707 DWORD free_clusters;
8713 DWORD total_clusters; 8708 DWORD total_clusters;
8714 8709
8715 if (GetDiskFreeSpace(rootname, 8710 if (GetDiskFreeSpace (rootname,
8716 &sectors_per_cluster, 8711 &sectors_per_cluster,
8717 &bytes_per_sector, 8712 &bytes_per_sector,
8718 &free_clusters, 8713 &free_clusters,
8719 &total_clusters)) 8714 &total_clusters))
8720 value = list3 (make_float ((double) total_clusters 8715 value = list3 (make_float ((double) total_clusters
8721 * sectors_per_cluster * bytes_per_sector), 8716 * sectors_per_cluster * bytes_per_sector),
8722 make_float ((double) free_clusters 8717 make_float ((double) free_clusters
@@ -8762,12 +8757,12 @@ DEFUN ("default-printer-name", Fdefault_printer_name, Sdefault_printer_name,
8762 ClosePrinter (hPrn); 8757 ClosePrinter (hPrn);
8763 return Qnil; 8758 return Qnil;
8764 } 8759 }
8765 /* Call GetPrinter() again with big enouth memory block */ 8760 /* Call GetPrinter again with big enouth memory block */
8766 err = GetPrinter (hPrn, 2, (LPBYTE)ppi2, dwNeeded, &dwReturned); 8761 err = GetPrinter (hPrn, 2, (LPBYTE)ppi2, dwNeeded, &dwReturned);
8767 ClosePrinter (hPrn); 8762 ClosePrinter (hPrn);
8768 if (!err) 8763 if (!err)
8769 { 8764 {
8770 xfree(ppi2); 8765 xfree (ppi2);
8771 return Qnil; 8766 return Qnil;
8772 } 8767 }
8773 8768
@@ -8777,23 +8772,23 @@ DEFUN ("default-printer-name", Fdefault_printer_name, Sdefault_printer_name,
8777 { 8772 {
8778 /* a remote printer */ 8773 /* a remote printer */
8779 if (*ppi2->pServerName == '\\') 8774 if (*ppi2->pServerName == '\\')
8780 _snprintf(pname_buf, sizeof (pname_buf), "%s\\%s", ppi2->pServerName, 8775 _snprintf (pname_buf, sizeof (pname_buf), "%s\\%s", ppi2->pServerName,
8781 ppi2->pShareName); 8776 ppi2->pShareName);
8782 else 8777 else
8783 _snprintf(pname_buf, sizeof (pname_buf), "\\\\%s\\%s", ppi2->pServerName, 8778 _snprintf (pname_buf, sizeof (pname_buf), "\\\\%s\\%s", ppi2->pServerName,
8784 ppi2->pShareName); 8779 ppi2->pShareName);
8785 pname_buf[sizeof (pname_buf) - 1] = '\0'; 8780 pname_buf[sizeof (pname_buf) - 1] = '\0';
8786 } 8781 }
8787 else 8782 else
8788 { 8783 {
8789 /* a local printer */ 8784 /* a local printer */
8790 strncpy(pname_buf, ppi2->pPortName, sizeof (pname_buf)); 8785 strncpy (pname_buf, ppi2->pPortName, sizeof (pname_buf));
8791 pname_buf[sizeof (pname_buf) - 1] = '\0'; 8786 pname_buf[sizeof (pname_buf) - 1] = '\0';
8792 /* `pPortName' can include several ports, delimited by ','. 8787 /* `pPortName' can include several ports, delimited by ','.
8793 * we only use the first one. */ 8788 * we only use the first one. */
8794 strtok(pname_buf, ","); 8789 strtok (pname_buf, ",");
8795 } 8790 }
8796 xfree(ppi2); 8791 xfree (ppi2);
8797 } 8792 }
8798 8793
8799 return build_string (pname_buf); 8794 return build_string (pname_buf);
@@ -9023,7 +9018,7 @@ system to handle them. */);
9023 &w32_pass_multimedia_buttons_to_system, 9018 &w32_pass_multimedia_buttons_to_system,
9024 doc: /* If non-nil, media buttons are passed to Windows. 9019 doc: /* If non-nil, media buttons are passed to Windows.
9025Some modern keyboards contain buttons for controlling media players, web 9020Some modern keyboards contain buttons for controlling media players, web
9026browsers and other applications. Generally these buttons are handled on a 9021browsers and other applications. Generally these buttons are handled on a
9027system wide basis, but by setting this to nil they are made available 9022system wide basis, but by setting this to nil they are made available
9028to Emacs for binding. Depending on your keyboard, additional keys that 9023to Emacs for binding. Depending on your keyboard, additional keys that
9029may be available are: 9024may be available are:
@@ -9039,8 +9034,7 @@ media-play, media-pause, media-record, media-fast-forward, media-rewind,
9039media-channel-up, media-channel-down, 9034media-channel-up, media-channel-down,
9040volume-mute, volume-up, volume-down, 9035volume-mute, volume-up, volume-down,
9041mic-volume-mute, mic-volume-down, mic-volume-up, mic-toggle, 9036mic-volume-mute, mic-volume-down, mic-volume-up, mic-toggle,
9042bass-down, bass-boost, bass-up, treble-down, treble-up 9037bass-down, bass-boost, bass-up, treble-down, treble-up */);
9043 */);
9044 w32_pass_multimedia_buttons_to_system = 1; 9038 w32_pass_multimedia_buttons_to_system = 1;
9045 9039
9046 DEFVAR_LISP ("x-pointer-shape", &Vx_pointer_shape, 9040 DEFVAR_LISP ("x-pointer-shape", &Vx_pointer_shape,
@@ -9069,14 +9063,14 @@ Value must be an integer or float. */);
9069 Vhourglass_delay = make_number (DEFAULT_HOURGLASS_DELAY); 9063 Vhourglass_delay = make_number (DEFAULT_HOURGLASS_DELAY);
9070 9064
9071 DEFVAR_LISP ("x-sensitive-text-pointer-shape", 9065 DEFVAR_LISP ("x-sensitive-text-pointer-shape",
9072 &Vx_sensitive_text_pointer_shape, 9066 &Vx_sensitive_text_pointer_shape,
9073 doc: /* The shape of the pointer when over mouse-sensitive text. 9067 doc: /* The shape of the pointer when over mouse-sensitive text.
9074This variable takes effect when you create a new frame 9068This variable takes effect when you create a new frame
9075or when you set the mouse color. */); 9069or when you set the mouse color. */);
9076 Vx_sensitive_text_pointer_shape = Qnil; 9070 Vx_sensitive_text_pointer_shape = Qnil;
9077 9071
9078 DEFVAR_LISP ("x-window-horizontal-drag-cursor", 9072 DEFVAR_LISP ("x-window-horizontal-drag-cursor",
9079 &Vx_window_horizontal_drag_shape, 9073 &Vx_window_horizontal_drag_shape,
9080 doc: /* Pointer shape to use for indicating a window can be dragged horizontally. 9074 doc: /* Pointer shape to use for indicating a window can be dragged horizontally.
9081This variable takes effect when you create a new frame 9075This variable takes effect when you create a new frame
9082or when you set the mouse color. */); 9076or when you set the mouse color. */);
@@ -9282,7 +9276,8 @@ versions of Windows) characters. */);
9282 variable initialized is 0 and directly from main when initialized 9276 variable initialized is 0 and directly from main when initialized
9283 is non zero. 9277 is non zero.
9284 */ 9278 */
9285void globals_of_w32fns () 9279void
9280globals_of_w32fns ()
9286{ 9281{
9287 HMODULE user32_lib = GetModuleHandle ("user32.dll"); 9282 HMODULE user32_lib = GetModuleHandle ("user32.dll");
9288 /* 9283 /*
@@ -9313,7 +9308,7 @@ void globals_of_w32fns ()
9313#undef abort 9308#undef abort
9314 9309
9315void 9310void
9316w32_abort() 9311w32_abort ()
9317{ 9312{
9318 int button; 9313 int button;
9319 button = MessageBox (NULL, 9314 button = MessageBox (NULL,
@@ -9341,7 +9336,7 @@ w32_abort()
9341 9336
9342/* For convenience when debugging. */ 9337/* For convenience when debugging. */
9343int 9338int
9344w32_last_error() 9339w32_last_error ()
9345{ 9340{
9346 return GetLastError (); 9341 return GetLastError ();
9347} 9342}
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)
782 variable in their environment. */ 782 variable in their environment. */
783 char ppid_env_var_buffer[64]; 783 char ppid_env_var_buffer[64];
784 char *extra_env[] = {ppid_env_var_buffer, NULL}; 784 char *extra_env[] = {ppid_env_var_buffer, NULL};
785 char *sepchars = " \t"; 785 /* These are the characters that cause an argument to need quoting.
786 Arguments with whitespace characters need quoting to prevent the
787 argument being split into two or more. Arguments with wildcards
788 are also quoted, for consistency with posix platforms, where wildcards
789 are not expanded if we run the program directly without a shell.
790 Some extra whitespace characters need quoting in Cygwin programs,
791 so this list is conditionally modified below. */
792 char *sepchars = " \t*?";
786 793
787 /* We don't care about the other modes */ 794 /* We don't care about the other modes */
788 if (mode != _P_NOWAIT) 795 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;
768 768
769XGCValues *XCreateGC (void *, Window, unsigned long, XGCValues *); 769XGCValues *XCreateGC (void *, Window, unsigned long, XGCValues *);
770struct frame * check_x_frame (Lisp_Object); 770struct frame * check_x_frame (Lisp_Object);
771Lisp_Object vga_stdcolor_name (int);
772 771
773EXFUN (Fx_display_color_p, 1); 772EXFUN (Fx_display_color_p, 1);
774EXFUN (Fx_display_grayscale_p, 1); 773EXFUN (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
6053 { 6053 {
6054 EMACS_UINT size; 6054 EMACS_UINT size;
6055 struct Lisp_Vector *next_from_Lisp_Vector_struct; 6055 struct Lisp_Vector *next_from_Lisp_Vector_struct;
6056 Lisp_Object frame_cols, frame_lines, frame_menu_bar_lines;
6057 Lisp_Object frame_tool_bar_lines;
6058 Lisp_Object selected_frame; 6056 Lisp_Object selected_frame;
6059 Lisp_Object current_window; 6057 Lisp_Object current_window;
6060 Lisp_Object current_buffer; 6058 Lisp_Object current_buffer;
@@ -6062,12 +6060,18 @@ struct save_window_data
6062 Lisp_Object minibuf_selected_window; 6060 Lisp_Object minibuf_selected_window;
6063 Lisp_Object root_window; 6061 Lisp_Object root_window;
6064 Lisp_Object focus_frame; 6062 Lisp_Object focus_frame;
6065 /* Record the values of window-min-width and window-min-height
6066 so that window sizes remain consistent with them. */
6067 Lisp_Object min_width, min_height;
6068 /* A vector, each of whose elements is a struct saved_window 6063 /* A vector, each of whose elements is a struct saved_window
6069 for one window. */ 6064 for one window. */
6070 Lisp_Object saved_windows; 6065 Lisp_Object saved_windows;
6066
6067 /* All fields above are traced by the GC.
6068 From `fame-cols' down, the fields are ignored by the GC. */
6069
6070 int frame_cols, frame_lines, frame_menu_bar_lines;
6071 int frame_tool_bar_lines;
6072 /* Record the values of window-min-width and window-min-height
6073 so that window sizes remain consistent with them. */
6074 int min_width, min_height;
6071 }; 6075 };
6072 6076
6073/* This is saved as a Lisp_Vector */ 6077/* This is saved as a Lisp_Vector */
@@ -6207,18 +6211,20 @@ the return value is nil. Otherwise the value is t. */)
6207 if it runs during this. */ 6211 if it runs during this. */
6208 BLOCK_INPUT; 6212 BLOCK_INPUT;
6209 6213
6210 if (XFASTINT (data->frame_lines) != previous_frame_lines 6214 if (data->frame_lines != previous_frame_lines
6211 || XFASTINT (data->frame_cols) != previous_frame_cols) 6215 || data->frame_cols != previous_frame_cols)
6212 change_frame_size (f, XFASTINT (data->frame_lines), 6216 change_frame_size (f, data->frame_lines,
6213 XFASTINT (data->frame_cols), 0, 0, 0); 6217 data->frame_cols, 0, 0, 0);
6214#if defined (HAVE_WINDOW_SYSTEM) || defined (MSDOS) 6218#if defined (HAVE_WINDOW_SYSTEM) || defined (MSDOS)
6215 if (XFASTINT (data->frame_menu_bar_lines) 6219 if (data->frame_menu_bar_lines
6216 != previous_frame_menu_bar_lines) 6220 != previous_frame_menu_bar_lines)
6217 x_set_menu_bar_lines (f, data->frame_menu_bar_lines, make_number (0)); 6221 x_set_menu_bar_lines (f, make_number (data->frame_menu_bar_lines),
6222 make_number (0));
6218#ifdef HAVE_WINDOW_SYSTEM 6223#ifdef HAVE_WINDOW_SYSTEM
6219 if (XFASTINT (data->frame_tool_bar_lines) 6224 if (data->frame_tool_bar_lines
6220 != previous_frame_tool_bar_lines) 6225 != previous_frame_tool_bar_lines)
6221 x_set_tool_bar_lines (f, data->frame_tool_bar_lines, make_number (0)); 6226 x_set_tool_bar_lines (f, make_number (data->frame_tool_bar_lines),
6227 make_number (0));
6222#endif 6228#endif
6223#endif 6229#endif
6224 6230
@@ -6452,8 +6458,8 @@ the return value is nil. Otherwise the value is t. */)
6452 Fset_buffer (new_current_buffer); 6458 Fset_buffer (new_current_buffer);
6453 6459
6454 /* Restore the minimum heights recorded in the configuration. */ 6460 /* Restore the minimum heights recorded in the configuration. */
6455 window_min_height = XINT (data->min_height); 6461 window_min_height = data->min_height;
6456 window_min_width = XINT (data->min_width); 6462 window_min_width = data->min_width;
6457 6463
6458 Vminibuf_scroll_window = data->minibuf_scroll_window; 6464 Vminibuf_scroll_window = data->minibuf_scroll_window;
6459 minibuf_selected_window = data->minibuf_selected_window; 6465 minibuf_selected_window = data->minibuf_selected_window;
@@ -6654,7 +6660,6 @@ redirection (see `redirect-frame-focus'). */)
6654 register Lisp_Object tem; 6660 register Lisp_Object tem;
6655 register int n_windows; 6661 register int n_windows;
6656 register struct save_window_data *data; 6662 register struct save_window_data *data;
6657 register struct Lisp_Vector *vec;
6658 register int i; 6663 register int i;
6659 FRAME_PTR f; 6664 FRAME_PTR f;
6660 6665
@@ -6664,14 +6669,13 @@ redirection (see `redirect-frame-focus'). */)
6664 f = XFRAME (frame); 6669 f = XFRAME (frame);
6665 6670
6666 n_windows = count_windows (XWINDOW (FRAME_ROOT_WINDOW (f))); 6671 n_windows = count_windows (XWINDOW (FRAME_ROOT_WINDOW (f)));
6667 vec = allocate_other_vector (VECSIZE (struct save_window_data)); 6672 data = ALLOCATE_PSEUDOVECTOR (struct save_window_data, frame_cols,
6668 XSETPVECTYPE (vec, PVEC_WINDOW_CONFIGURATION); 6673 PVEC_WINDOW_CONFIGURATION);
6669 data = (struct save_window_data *)vec; 6674
6670 6675 data->frame_cols = FRAME_COLS (f);
6671 XSETFASTINT (data->frame_cols, FRAME_COLS (f)); 6676 data->frame_lines = FRAME_LINES (f);
6672 XSETFASTINT (data->frame_lines, FRAME_LINES (f)); 6677 data->frame_menu_bar_lines = FRAME_MENU_BAR_LINES (f);
6673 XSETFASTINT (data->frame_menu_bar_lines, FRAME_MENU_BAR_LINES (f)); 6678 data->frame_tool_bar_lines = FRAME_TOOL_BAR_LINES (f);
6674 XSETFASTINT (data->frame_tool_bar_lines, FRAME_TOOL_BAR_LINES (f));
6675 data->selected_frame = selected_frame; 6679 data->selected_frame = selected_frame;
6676 data->current_window = FRAME_SELECTED_WINDOW (f); 6680 data->current_window = FRAME_SELECTED_WINDOW (f);
6677 XSETBUFFER (data->current_buffer, current_buffer); 6681 XSETBUFFER (data->current_buffer, current_buffer);
@@ -6679,8 +6683,8 @@ redirection (see `redirect-frame-focus'). */)
6679 data->minibuf_selected_window = minibuf_level > 0 ? minibuf_selected_window : Qnil; 6683 data->minibuf_selected_window = minibuf_level > 0 ? minibuf_selected_window : Qnil;
6680 data->root_window = FRAME_ROOT_WINDOW (f); 6684 data->root_window = FRAME_ROOT_WINDOW (f);
6681 data->focus_frame = FRAME_FOCUS_FRAME (f); 6685 data->focus_frame = FRAME_FOCUS_FRAME (f);
6682 XSETINT (data->min_height, window_min_height); 6686 data->min_height = window_min_height;
6683 XSETINT (data->min_width, window_min_width); 6687 data->min_width = window_min_width;
6684 tem = Fmake_vector (make_number (n_windows), Qnil); 6688 tem = Fmake_vector (make_number (n_windows), Qnil);
6685 data->saved_windows = tem; 6689 data->saved_windows = tem;
6686 for (i = 0; i < n_windows; i++) 6690 for (i = 0; i < n_windows; i++)
@@ -7187,11 +7191,11 @@ compare_window_configurations (c1, c2, ignore_positions)
7187 sw1 = XVECTOR (d1->saved_windows); 7191 sw1 = XVECTOR (d1->saved_windows);
7188 sw2 = XVECTOR (d2->saved_windows); 7192 sw2 = XVECTOR (d2->saved_windows);
7189 7193
7190 if (! EQ (d1->frame_cols, d2->frame_cols)) 7194 if (d1->frame_cols != d2->frame_cols)
7191 return 0; 7195 return 0;
7192 if (! EQ (d1->frame_lines, d2->frame_lines)) 7196 if (d1->frame_lines != d2->frame_lines)
7193 return 0; 7197 return 0;
7194 if (! EQ (d1->frame_menu_bar_lines, d2->frame_menu_bar_lines)) 7198 if (d1->frame_menu_bar_lines != d2->frame_menu_bar_lines)
7195 return 0; 7199 return 0;
7196 if (! EQ (d1->selected_frame, d2->selected_frame)) 7200 if (! EQ (d1->selected_frame, d2->selected_frame))
7197 return 0; 7201 return 0;
@@ -7213,9 +7217,9 @@ compare_window_configurations (c1, c2, ignore_positions)
7213 if everything else compares equal. */ 7217 if everything else compares equal. */
7214 if (! EQ (d1->focus_frame, d2->focus_frame)) 7218 if (! EQ (d1->focus_frame, d2->focus_frame))
7215 return 0; 7219 return 0;
7216 if (! EQ (d1->min_width, d2->min_width)) 7220 if (d1->min_width != d2->min_width)
7217 return 0; 7221 return 0;
7218 if (! EQ (d1->min_height, d2->min_height)) 7222 if (d1->min_height != d2->min_height)
7219 return 0; 7223 return 0;
7220 7224
7221 /* Verify that the two confis have the same number of windows. */ 7225 /* 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
24494 24494
24495 DEFVAR_INT ("scroll-conservatively", &scroll_conservatively, 24495 DEFVAR_INT ("scroll-conservatively", &scroll_conservatively,
24496 doc: /* *Scroll up to this many lines, to bring point back on screen. 24496 doc: /* *Scroll up to this many lines, to bring point back on screen.
24497A value of zero means to scroll the text to center point vertically 24497If point moves off-screen, redisplay will scroll by up to
24498in the window. */); 24498`scroll-conservatively' lines in order to bring point just barely
24499onto the screen again. If that cannot be done, then redisplay
24500recenters point as usual.
24501
24502A value of zero means always recenter point if it moves off screen. */);
24499 scroll_conservatively = 0; 24503 scroll_conservatively = 0;
24500 24504
24501 DEFVAR_INT ("scroll-margin", &scroll_margin, 24505 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)
1474 if (idx == FACE_TTY_DEFAULT_BG_COLOR) 1474 if (idx == FACE_TTY_DEFAULT_BG_COLOR)
1475 return build_string (unspecified_bg); 1475 return build_string (unspecified_bg);
1476 1476
1477#ifdef WINDOWSNT
1478 return vga_stdcolor_name (idx);
1479#endif
1480
1481 return Qunspecified; 1477 return Qunspecified;
1482} 1478}
1483 1479
@@ -7948,13 +7944,11 @@ map_tty_color (f, face, idx, defaulted)
7948 { 7944 {
7949 pixel = load_color (f, face, color, idx); 7945 pixel = load_color (f, face, color, idx);
7950 7946
7951#if defined (MSDOS) || defined (WINDOWSNT) 7947#ifdef MSDOS
7952 /* If the foreground of the default face is the default color, 7948 /* If the foreground of the default face is the default color,
7953 use the foreground color defined by the frame. */ 7949 use the foreground color defined by the frame. */
7954#ifdef MSDOS
7955 if (FRAME_MSDOS_P (f)) 7950 if (FRAME_MSDOS_P (f))
7956 { 7951 {
7957#endif /* MSDOS */
7958 if (pixel == default_pixel 7952 if (pixel == default_pixel
7959 || pixel == FACE_TTY_DEFAULT_COLOR) 7953 || pixel == FACE_TTY_DEFAULT_COLOR)
7960 { 7954 {
@@ -7974,10 +7968,8 @@ map_tty_color (f, face, idx, defaulted)
7974 face->lface[idx] = tty_color_name (f, pixel); 7968 face->lface[idx] = tty_color_name (f, pixel);
7975 *defaulted = 1; 7969 *defaulted = 1;
7976 } 7970 }
7977#ifdef MSDOS 7971 }
7978 } 7972#endif /* MSDOS */
7979#endif
7980#endif /* MSDOS or WINDOWSNT */
7981 } 7973 }
7982 7974
7983 if (foreground_p) 7975 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)
938 !NILP (bar); 938 !NILP (bar);
939 bar = XSCROLL_BAR (bar)->next) 939 bar = XSCROLL_BAR (bar)->next)
940 { 940 {
941 Window window = SCROLL_BAR_X_WINDOW (XSCROLL_BAR (bar)); 941 Window window = XSCROLL_BAR (bar)->x_window;
942 XSetWindowBackground (dpy, window, bg); 942 XSetWindowBackground (dpy, window, bg);
943 } 943 }
944 } 944 }
@@ -3205,7 +3205,7 @@ x_default_font_parameter (f, parms)
3205DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame, 3205DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
3206 1, 1, 0, 3206 1, 1, 0,
3207 doc: /* Make a new X window, which is called a "frame" in Emacs terms. 3207 doc: /* Make a new X window, which is called a "frame" in Emacs terms.
3208Returns an Emacs frame object. 3208Return an Emacs frame object.
3209ALIST is an alist of frame parameters. 3209ALIST is an alist of frame parameters.
3210If the parameters specify that the frame should not have a minibuffer, 3210If the parameters specify that the frame should not have a minibuffer,
3211and do not specify a specific minibuffer window to use, 3211and 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. */)
3798 3798
3799DEFUN ("x-display-pixel-width", Fx_display_pixel_width, Sx_display_pixel_width, 3799DEFUN ("x-display-pixel-width", Fx_display_pixel_width, Sx_display_pixel_width,
3800 0, 1, 0, 3800 0, 1, 0,
3801 doc: /* Returns the width in pixels of the X display TERMINAL. 3801 doc: /* Return the width in pixels of the X display TERMINAL.
3802The optional argument TERMINAL specifies which display to ask about. 3802The optional argument TERMINAL specifies which display to ask about.
3803TERMINAL should be a terminal id, a frame or a display name (a string). 3803TERMINAL should be a terminal id, a frame or a display name (a string).
3804If omitted or nil, that stands for the selected frame's display. */) 3804If 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. */)
3812 3812
3813DEFUN ("x-display-pixel-height", Fx_display_pixel_height, 3813DEFUN ("x-display-pixel-height", Fx_display_pixel_height,
3814 Sx_display_pixel_height, 0, 1, 0, 3814 Sx_display_pixel_height, 0, 1, 0,
3815 doc: /* Returns the height in pixels of the X display TERMINAL. 3815 doc: /* Return the height in pixels of the X display TERMINAL.
3816The optional argument TERMINAL specifies which display to ask about. 3816The optional argument TERMINAL specifies which display to ask about.
3817TERMINAL should be a terminal id, a frame or a display name (a string). 3817TERMINAL should be a terminal id, a frame or a display name (a string).
3818If omitted or nil, that stands for the selected frame's display. */) 3818If 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. */)
3826 3826
3827DEFUN ("x-display-planes", Fx_display_planes, Sx_display_planes, 3827DEFUN ("x-display-planes", Fx_display_planes, Sx_display_planes,
3828 0, 1, 0, 3828 0, 1, 0,
3829 doc: /* Returns the number of bitplanes of the X display TERMINAL. 3829 doc: /* Return the number of bitplanes of the X display TERMINAL.
3830The optional argument TERMINAL specifies which display to ask about. 3830The optional argument TERMINAL specifies which display to ask about.
3831TERMINAL should be a terminal id, a frame or a display name (a string). 3831TERMINAL should be a terminal id, a frame or a display name (a string).
3832If omitted or nil, that stands for the selected frame's display. */) 3832If 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. */)
3840 3840
3841DEFUN ("x-display-color-cells", Fx_display_color_cells, Sx_display_color_cells, 3841DEFUN ("x-display-color-cells", Fx_display_color_cells, Sx_display_color_cells,
3842 0, 1, 0, 3842 0, 1, 0,
3843 doc: /* Returns the number of color cells of the X display TERMINAL. 3843 doc: /* Return the number of color cells of the X display TERMINAL.
3844The optional argument TERMINAL specifies which display to ask about. 3844The optional argument TERMINAL specifies which display to ask about.
3845TERMINAL should be a terminal id, a frame or a display name (a string). 3845TERMINAL should be a terminal id, a frame or a display name (a string).
3846If omitted or nil, that stands for the selected frame's display. */) 3846If 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. */)
3865DEFUN ("x-server-max-request-size", Fx_server_max_request_size, 3865DEFUN ("x-server-max-request-size", Fx_server_max_request_size,
3866 Sx_server_max_request_size, 3866 Sx_server_max_request_size,
3867 0, 1, 0, 3867 0, 1, 0,
3868 doc: /* Returns the maximum request size of the X server of display TERMINAL. 3868 doc: /* Return the maximum request size of the X server of display TERMINAL.
3869The optional argument TERMINAL specifies which display to ask about. 3869The optional argument TERMINAL specifies which display to ask about.
3870TERMINAL should be a terminal id, a frame or a display name (a string). 3870TERMINAL should be a terminal id, a frame or a display name (a string).
3871If omitted or nil, that stands for the selected frame's display. */) 3871If 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. */)
3878} 3878}
3879 3879
3880DEFUN ("x-server-vendor", Fx_server_vendor, Sx_server_vendor, 0, 1, 0, 3880DEFUN ("x-server-vendor", Fx_server_vendor, Sx_server_vendor, 0, 1, 0,
3881 doc: /* Returns the "vendor ID" string of the X server of display TERMINAL. 3881 doc: /* Return the "vendor ID" string of the X server of display TERMINAL.
3882\(Labelling every distributor as a "vendor" embodies the false assumption 3882\(Labelling every distributor as a "vendor" embodies the false assumption
3883that operating systems cannot be developed and distributed noncommercially.) 3883that operating systems cannot be developed and distributed noncommercially.)
3884The optional argument TERMINAL specifies which display to ask about. 3884The 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. */)
3895} 3895}
3896 3896
3897DEFUN ("x-server-version", Fx_server_version, Sx_server_version, 0, 1, 0, 3897DEFUN ("x-server-version", Fx_server_version, Sx_server_version, 0, 1, 0,
3898 doc: /* Returns the version numbers of the X server of display TERMINAL. 3898 doc: /* Return the version numbers of the X server of display TERMINAL.
3899The value is a list of three integers: the major and minor 3899The value is a list of three integers: the major and minor
3900version numbers of the X Protocol in use, and the distributor-specific release 3900version numbers of the X Protocol in use, and the distributor-specific release
3901number. See also the function `x-server-vendor'. 3901number. See also the function `x-server-vendor'.
@@ -3955,7 +3955,7 @@ If omitted or nil, that stands for the selected frame's display. */)
3955 3955
3956DEFUN ("x-display-backing-store", Fx_display_backing_store, 3956DEFUN ("x-display-backing-store", Fx_display_backing_store,
3957 Sx_display_backing_store, 0, 1, 0, 3957 Sx_display_backing_store, 0, 1, 0,
3958 doc: /* Returns an indication of whether X display TERMINAL does backing store. 3958 doc: /* Return an indication of whether X display TERMINAL does backing store.
3959The value may be `always', `when-mapped', or `not-useful'. 3959The value may be `always', `when-mapped', or `not-useful'.
3960The optional argument TERMINAL specifies which display to ask about. 3960The optional argument TERMINAL specifies which display to ask about.
3961TERMINAL should be a terminal id, a frame or a display name (a string). 3961TERMINAL 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. */)
4033 4033
4034DEFUN ("x-display-save-under", Fx_display_save_under, 4034DEFUN ("x-display-save-under", Fx_display_save_under,
4035 Sx_display_save_under, 0, 1, 0, 4035 Sx_display_save_under, 0, 1, 0,
4036 doc: /* Returns t if the X display TERMINAL supports the save-under feature. 4036 doc: /* Return t if the X display TERMINAL supports the save-under feature.
4037The optional argument TERMINAL specifies which display to ask about. 4037The optional argument TERMINAL specifies which display to ask about.
4038TERMINAL should be a terminal id, a frame or a display name (a string). 4038TERMINAL should be a terminal id, a frame or a display name (a string).
4039If omitted or nil, that stands for the selected frame's display. */) 4039If 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)
4209 condemned = Qnil, 4209 condemned = Qnil,
4210 ! NILP (bar)); 4210 ! NILP (bar));
4211 bar = XSCROLL_BAR (bar)->next) 4211 bar = XSCROLL_BAR (bar)->next)
4212 if (SCROLL_BAR_X_WINDOW (XSCROLL_BAR (bar)) == window_id && 4212 if (XSCROLL_BAR (bar)->x_window == window_id &&
4213 FRAME_X_DISPLAY (XFRAME (frame)) == display) 4213 FRAME_X_DISPLAY (XFRAME (frame)) == display)
4214 return XSCROLL_BAR (bar); 4214 return XSCROLL_BAR (bar);
4215 } 4215 }
@@ -4525,9 +4525,8 @@ xm_scroll_callback (widget, client_data, call_data)
4525 } 4525 }
4526} 4526}
4527 4527
4528#elif defined USE_GTK
4528 4529
4529#else /* !USE_MOTIF, i.e. Xaw or GTK */
4530#ifdef USE_GTK
4531/* Scroll bar callback for GTK scroll bars. WIDGET is the scroll 4530/* Scroll bar callback for GTK scroll bars. WIDGET is the scroll
4532 bar widget. DATA is a pointer to the scroll_bar structure. */ 4531 bar widget. DATA is a pointer to the scroll_bar structure. */
4533 4532
@@ -4598,7 +4597,7 @@ xg_scroll_callback (widget, data)
4598 } 4597 }
4599} 4598}
4600 4599
4601#else /* not USE_GTK */ 4600#else /* not USE_GTK and not USE_MOTIF */
4602 4601
4603/* Xaw scroll bar callback. Invoked when the thumb is dragged. 4602/* Xaw scroll bar callback. Invoked when the thumb is dragged.
4604 WIDGET is the scroll bar widget. CLIENT_DATA is a pointer to the 4603 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)
4681 x_send_scroll_bar_event (bar->window, part, position, height); 4680 x_send_scroll_bar_event (bar->window, part, position, height);
4682} 4681}
4683 4682
4684#endif /* not USE_GTK */ 4683#endif /* not USE_GTK and not USE_MOTIF */
4685#endif /* not USE_MOTIF */
4686 4684
4687#define SCROLL_BAR_NAME "verticalScrollBar" 4685#define SCROLL_BAR_NAME "verticalScrollBar"
4688 4686
@@ -4888,7 +4886,7 @@ x_create_toolkit_scroll_bar (f, bar)
4888 /* Remember X window and widget in the scroll bar vector. */ 4886 /* Remember X window and widget in the scroll bar vector. */
4889 SET_SCROLL_BAR_X_WIDGET (bar, widget); 4887 SET_SCROLL_BAR_X_WIDGET (bar, widget);
4890 xwindow = XtWindow (widget); 4888 xwindow = XtWindow (widget);
4891 SET_SCROLL_BAR_X_WINDOW (bar, xwindow); 4889 bar->x_window = xwindow;
4892 4890
4893 UNBLOCK_INPUT; 4891 UNBLOCK_INPUT;
4894} 4892}
@@ -5032,7 +5030,7 @@ x_scroll_bar_create (w, top, left, width, height)
5032{ 5030{
5033 struct frame *f = XFRAME (w->frame); 5031 struct frame *f = XFRAME (w->frame);
5034 struct scroll_bar *bar 5032 struct scroll_bar *bar
5035 = XSCROLL_BAR (Fmake_vector (make_number (SCROLL_BAR_VEC_SIZE), Qnil)); 5033 = ALLOCATE_PSEUDOVECTOR (struct scroll_bar, x_window, PVEC_OTHER);
5036 5034
5037 BLOCK_INPUT; 5035 BLOCK_INPUT;
5038 5036
@@ -5076,21 +5074,19 @@ x_scroll_bar_create (w, top, left, width, height)
5076 CopyFromParent, 5074 CopyFromParent,
5077 /* Attributes. */ 5075 /* Attributes. */
5078 mask, &a); 5076 mask, &a);
5079 SET_SCROLL_BAR_X_WINDOW (bar, window); 5077 bar->x_window = window;
5080 } 5078 }
5081#endif /* not USE_TOOLKIT_SCROLL_BARS */ 5079#endif /* not USE_TOOLKIT_SCROLL_BARS */
5082 5080
5083 XSETWINDOW (bar->window, w); 5081 XSETWINDOW (bar->window, w);
5084 XSETINT (bar->top, top); 5082 bar->top = top;
5085 XSETINT (bar->left, left); 5083 bar->left = left;
5086 XSETINT (bar->width, width); 5084 bar->width = width;
5087 XSETINT (bar->height, height); 5085 bar->height = height;
5088 XSETINT (bar->start, 0); 5086 bar->start = 0;
5089 XSETINT (bar->end, 0); 5087 bar->end = 0;
5090 bar->dragging = Qnil; 5088 bar->dragging = Qnil;
5091#ifdef USE_TOOLKIT_SCROLL_BARS 5089 bar->fringe_extended_p = 0;
5092 bar->fringe_extended_p = Qnil;
5093#endif
5094 5090
5095 /* Add bar to its frame's list of scroll bars. */ 5091 /* Add bar to its frame's list of scroll bars. */
5096 bar->next = FRAME_SCROLL_BARS (f); 5092 bar->next = FRAME_SCROLL_BARS (f);
@@ -5104,12 +5100,12 @@ x_scroll_bar_create (w, top, left, width, height)
5104 { 5100 {
5105#ifdef USE_GTK 5101#ifdef USE_GTK
5106 xg_update_scrollbar_pos (f, 5102 xg_update_scrollbar_pos (f,
5107 SCROLL_BAR_X_WINDOW (bar), 5103 bar->x_window,
5108 top, 5104 top,
5109 left + VERTICAL_SCROLL_BAR_WIDTH_TRIM, 5105 left + VERTICAL_SCROLL_BAR_WIDTH_TRIM,
5110 width - VERTICAL_SCROLL_BAR_WIDTH_TRIM * 2, 5106 width - VERTICAL_SCROLL_BAR_WIDTH_TRIM * 2,
5111 max (height, 1)); 5107 max (height, 1));
5112 xg_show_scroll_bar (SCROLL_BAR_X_WINDOW (bar)); 5108 xg_show_scroll_bar (bar->x_window);
5113#else /* not USE_GTK */ 5109#else /* not USE_GTK */
5114 Widget scroll_bar = SCROLL_BAR_X_WIDGET (FRAME_X_DISPLAY (f), bar); 5110 Widget scroll_bar = SCROLL_BAR_X_WIDGET (FRAME_X_DISPLAY (f), bar);
5115 XtConfigureWidget (scroll_bar, 5111 XtConfigureWidget (scroll_bar,
@@ -5121,7 +5117,7 @@ x_scroll_bar_create (w, top, left, width, height)
5121#endif /* not USE_GTK */ 5117#endif /* not USE_GTK */
5122 } 5118 }
5123#else /* not USE_TOOLKIT_SCROLL_BARS */ 5119#else /* not USE_TOOLKIT_SCROLL_BARS */
5124 XMapRaised (FRAME_X_DISPLAY (f), SCROLL_BAR_X_WINDOW (bar)); 5120 XMapRaised (FRAME_X_DISPLAY (f), bar->x_window);
5125#endif /* not USE_TOOLKIT_SCROLL_BARS */ 5121#endif /* not USE_TOOLKIT_SCROLL_BARS */
5126 5122
5127 UNBLOCK_INPUT; 5123 UNBLOCK_INPUT;
@@ -5129,6 +5125,8 @@ x_scroll_bar_create (w, top, left, width, height)
5129} 5125}
5130 5126
5131 5127
5128#ifndef USE_TOOLKIT_SCROLL_BARS
5129
5132/* Draw BAR's handle in the proper position. 5130/* Draw BAR's handle in the proper position.
5133 5131
5134 If the handle is already drawn from START to END, don't bother 5132 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)
5142 the bar's top is as far down as it goes; otherwise, there's no way 5140 the bar's top is as far down as it goes; otherwise, there's no way
5143 to move to the very end of the buffer. */ 5141 to move to the very end of the buffer. */
5144 5142
5145#ifndef USE_TOOLKIT_SCROLL_BARS
5146
5147static void 5143static void
5148x_scroll_bar_set_handle (bar, start, end, rebuild) 5144x_scroll_bar_set_handle (bar, start, end, rebuild)
5149 struct scroll_bar *bar; 5145 struct scroll_bar *bar;
@@ -5151,22 +5147,22 @@ x_scroll_bar_set_handle (bar, start, end, rebuild)
5151 int rebuild; 5147 int rebuild;
5152{ 5148{
5153 int dragging = ! NILP (bar->dragging); 5149 int dragging = ! NILP (bar->dragging);
5154 Window w = SCROLL_BAR_X_WINDOW (bar); 5150 Window w = bar->x_window;
5155 FRAME_PTR f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window))); 5151 FRAME_PTR f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window)));
5156 GC gc = f->output_data.x->normal_gc; 5152 GC gc = f->output_data.x->normal_gc;
5157 5153
5158 /* If the display is already accurate, do nothing. */ 5154 /* If the display is already accurate, do nothing. */
5159 if (! rebuild 5155 if (! rebuild
5160 && start == XINT (bar->start) 5156 && start == bar->start
5161 && end == XINT (bar->end)) 5157 && end == bar->end)
5162 return; 5158 return;
5163 5159
5164 BLOCK_INPUT; 5160 BLOCK_INPUT;
5165 5161
5166 { 5162 {
5167 int inside_width = VERTICAL_SCROLL_BAR_INSIDE_WIDTH (f, XINT (bar->width)); 5163 int inside_width = VERTICAL_SCROLL_BAR_INSIDE_WIDTH (f, bar->width);
5168 int inside_height = VERTICAL_SCROLL_BAR_INSIDE_HEIGHT (f, XINT (bar->height)); 5164 int inside_height = VERTICAL_SCROLL_BAR_INSIDE_HEIGHT (f, bar->height);
5169 int top_range = VERTICAL_SCROLL_BAR_TOP_RANGE (f, XINT (bar->height)); 5165 int top_range = VERTICAL_SCROLL_BAR_TOP_RANGE (f, bar->height);
5170 5166
5171 /* Make sure the values are reasonable, and try to preserve 5167 /* Make sure the values are reasonable, and try to preserve
5172 the distance between start and end. */ 5168 the distance between start and end. */
@@ -5186,8 +5182,8 @@ x_scroll_bar_set_handle (bar, start, end, rebuild)
5186 } 5182 }
5187 5183
5188 /* Store the adjusted setting in the scroll bar. */ 5184 /* Store the adjusted setting in the scroll bar. */
5189 XSETINT (bar->start, start); 5185 bar->start = start;
5190 XSETINT (bar->end, end); 5186 bar->end = end;
5191 5187
5192 /* Clip the end position, just for display. */ 5188 /* Clip the end position, just for display. */
5193 if (end > top_range) 5189 if (end > top_range)
@@ -5254,12 +5250,12 @@ x_scroll_bar_remove (bar)
5254 5250
5255#ifdef USE_TOOLKIT_SCROLL_BARS 5251#ifdef USE_TOOLKIT_SCROLL_BARS
5256#ifdef USE_GTK 5252#ifdef USE_GTK
5257 xg_remove_scroll_bar (f, SCROLL_BAR_X_WINDOW (bar)); 5253 xg_remove_scroll_bar (f, bar->x_window);
5258#else /* not USE_GTK */ 5254#else /* not USE_GTK */
5259 XtDestroyWidget (SCROLL_BAR_X_WIDGET (FRAME_X_DISPLAY (f), bar)); 5255 XtDestroyWidget (SCROLL_BAR_X_WIDGET (FRAME_X_DISPLAY (f), bar));
5260#endif /* not USE_GTK */ 5256#endif /* not USE_GTK */
5261#else 5257#else
5262 XDestroyWindow (FRAME_X_DISPLAY (f), SCROLL_BAR_X_WINDOW (bar)); 5258 XDestroyWindow (FRAME_X_DISPLAY (f), bar->x_window);
5263#endif 5259#endif
5264 5260
5265 /* Disassociate this scroll bar from its window. */ 5261 /* Disassociate this scroll bar from its window. */
@@ -5357,19 +5353,19 @@ XTset_vertical_scroll_bar (w, portion, whole, position)
5357 5353
5358 BLOCK_INPUT; 5354 BLOCK_INPUT;
5359 5355
5360 if (sb_left != XINT (bar->left)) 5356 if (sb_left != bar->left)
5361 mask |= CWX; 5357 mask |= CWX;
5362 if (top != XINT (bar->top)) 5358 if (top != bar->top)
5363 mask |= CWY; 5359 mask |= CWY;
5364 if (sb_width != XINT (bar->width)) 5360 if (sb_width != bar->width)
5365 mask |= CWWidth; 5361 mask |= CWWidth;
5366 if (height != XINT (bar->height)) 5362 if (height != bar->height)
5367 mask |= CWHeight; 5363 mask |= CWHeight;
5368 5364
5369#ifdef USE_TOOLKIT_SCROLL_BARS 5365#ifdef USE_TOOLKIT_SCROLL_BARS
5370 5366
5371 /* Move/size the scroll bar widget. */ 5367 /* Move/size the scroll bar widget. */
5372 if (mask || !NILP (bar->fringe_extended_p) != fringe_extended_p) 5368 if (mask || bar->fringe_extended_p != fringe_extended_p)
5373 { 5369 {
5374 /* Since toolkit scroll bars are smaller than the space reserved 5370 /* Since toolkit scroll bars are smaller than the space reserved
5375 for them on the frame, we have to clear "under" them. */ 5371 for them on the frame, we have to clear "under" them. */
@@ -5384,7 +5380,7 @@ XTset_vertical_scroll_bar (w, portion, whole, position)
5384 } 5380 }
5385#ifdef USE_GTK 5381#ifdef USE_GTK
5386 xg_update_scrollbar_pos (f, 5382 xg_update_scrollbar_pos (f,
5387 SCROLL_BAR_X_WINDOW (bar), 5383 bar->x_window,
5388 top, 5384 top,
5389 sb_left + VERTICAL_SCROLL_BAR_WIDTH_TRIM, 5385 sb_left + VERTICAL_SCROLL_BAR_WIDTH_TRIM,
5390 sb_width - VERTICAL_SCROLL_BAR_WIDTH_TRIM *2, 5386 sb_width - VERTICAL_SCROLL_BAR_WIDTH_TRIM *2,
@@ -5440,23 +5436,23 @@ XTset_vertical_scroll_bar (w, portion, whole, position)
5440 wc.y = top; 5436 wc.y = top;
5441 wc.width = sb_width - VERTICAL_SCROLL_BAR_WIDTH_TRIM * 2; 5437 wc.width = sb_width - VERTICAL_SCROLL_BAR_WIDTH_TRIM * 2;
5442 wc.height = height; 5438 wc.height = height;
5443 XConfigureWindow (FRAME_X_DISPLAY (f), SCROLL_BAR_X_WINDOW (bar), 5439 XConfigureWindow (FRAME_X_DISPLAY (f), bar->x_window,
5444 mask, &wc); 5440 mask, &wc);
5445 } 5441 }
5446 5442
5447#endif /* not USE_TOOLKIT_SCROLL_BARS */ 5443#endif /* not USE_TOOLKIT_SCROLL_BARS */
5448 5444
5449 /* Remember new settings. */ 5445 /* Remember new settings. */
5450 XSETINT (bar->left, sb_left); 5446 bar->left = sb_left;
5451 XSETINT (bar->top, top); 5447 bar->top = top;
5452 XSETINT (bar->width, sb_width); 5448 bar->width = sb_width;
5453 XSETINT (bar->height, height); 5449 bar->height = height;
5454 5450
5455 UNBLOCK_INPUT; 5451 UNBLOCK_INPUT;
5456 } 5452 }
5457 5453
5458#ifdef USE_TOOLKIT_SCROLL_BARS 5454#ifdef USE_TOOLKIT_SCROLL_BARS
5459 bar->fringe_extended_p = fringe_extended_p ? Qt : Qnil; 5455 bar->fringe_extended_p = fringe_extended_p;
5460 5456
5461 x_set_toolkit_scroll_bar_thumb (bar, portion, position, whole); 5457 x_set_toolkit_scroll_bar_thumb (bar, portion, position, whole);
5462#else /* not USE_TOOLKIT_SCROLL_BARS */ 5458#else /* not USE_TOOLKIT_SCROLL_BARS */
@@ -5600,14 +5596,14 @@ x_scroll_bar_expose (bar, event)
5600 struct scroll_bar *bar; 5596 struct scroll_bar *bar;
5601 XEvent *event; 5597 XEvent *event;
5602{ 5598{
5603 Window w = SCROLL_BAR_X_WINDOW (bar); 5599 Window w = bar->x_window;
5604 FRAME_PTR f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window))); 5600 FRAME_PTR f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window)));
5605 GC gc = f->output_data.x->normal_gc; 5601 GC gc = f->output_data.x->normal_gc;
5606 int width_trim = VERTICAL_SCROLL_BAR_WIDTH_TRIM; 5602 int width_trim = VERTICAL_SCROLL_BAR_WIDTH_TRIM;
5607 5603
5608 BLOCK_INPUT; 5604 BLOCK_INPUT;
5609 5605
5610 x_scroll_bar_set_handle (bar, XINT (bar->start), XINT (bar->end), 1); 5606 x_scroll_bar_set_handle (bar, bar->start, bar->end, 1);
5611 5607
5612 /* Switch to scroll bar foreground color. */ 5608 /* Switch to scroll bar foreground color. */
5613 if (f->output_data.x->scroll_bar_foreground_pixel != -1) 5609 if (f->output_data.x->scroll_bar_foreground_pixel != -1)
@@ -5619,8 +5615,8 @@ x_scroll_bar_expose (bar, event)
5619 5615
5620 /* x, y, width, height */ 5616 /* x, y, width, height */
5621 0, 0, 5617 0, 0,
5622 XINT (bar->width) - 1 - width_trim - width_trim, 5618 bar->width - 1 - width_trim - width_trim,
5623 XINT (bar->height) - 1); 5619 bar->height - 1);
5624 5620
5625 /* Restore the foreground color of the GC if we changed it above. */ 5621 /* Restore the foreground color of the GC if we changed it above. */
5626 if (f->output_data.x->scroll_bar_foreground_pixel != -1) 5622 if (f->output_data.x->scroll_bar_foreground_pixel != -1)
@@ -5664,18 +5660,18 @@ x_scroll_bar_handle_click (bar, event, emacs_event)
5664#if 0 5660#if 0
5665 FRAME_PTR f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window))); 5661 FRAME_PTR f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window)));
5666 int internal_height 5662 int internal_height
5667 = VERTICAL_SCROLL_BAR_INSIDE_HEIGHT (f, XINT (bar->height)); 5663 = VERTICAL_SCROLL_BAR_INSIDE_HEIGHT (f, bar->height);
5668#endif 5664#endif
5669 int top_range 5665 int top_range
5670 = VERTICAL_SCROLL_BAR_TOP_RANGE (f, XINT (bar->height)); 5666 = VERTICAL_SCROLL_BAR_TOP_RANGE (f, bar->height);
5671 int y = event->xbutton.y - VERTICAL_SCROLL_BAR_TOP_BORDER; 5667 int y = event->xbutton.y - VERTICAL_SCROLL_BAR_TOP_BORDER;
5672 5668
5673 if (y < 0) y = 0; 5669 if (y < 0) y = 0;
5674 if (y > top_range) y = top_range; 5670 if (y > top_range) y = top_range;
5675 5671
5676 if (y < XINT (bar->start)) 5672 if (y < bar->start)
5677 emacs_event->part = scroll_bar_above_handle; 5673 emacs_event->part = scroll_bar_above_handle;
5678 else if (y < XINT (bar->end) + VERTICAL_SCROLL_BAR_MIN_HANDLE) 5674 else if (y < bar->end + VERTICAL_SCROLL_BAR_MIN_HANDLE)
5679 emacs_event->part = scroll_bar_handle; 5675 emacs_event->part = scroll_bar_handle;
5680 else 5676 else
5681 emacs_event->part = scroll_bar_below_handle; 5677 emacs_event->part = scroll_bar_below_handle;
@@ -5688,7 +5684,7 @@ x_scroll_bar_handle_click (bar, event, emacs_event)
5688 holding it. */ 5684 holding it. */
5689 if (event->type == ButtonPress 5685 if (event->type == ButtonPress
5690 && emacs_event->part == scroll_bar_handle) 5686 && emacs_event->part == scroll_bar_handle)
5691 XSETINT (bar->dragging, y - XINT (bar->start)); 5687 XSETINT (bar->dragging, y - bar->start);
5692#endif 5688#endif
5693 5689
5694#ifndef USE_TOOLKIT_SCROLL_BARS 5690#ifndef USE_TOOLKIT_SCROLL_BARS
@@ -5697,7 +5693,7 @@ x_scroll_bar_handle_click (bar, event, emacs_event)
5697 && ! NILP (bar->dragging)) 5693 && ! NILP (bar->dragging))
5698 { 5694 {
5699 int new_start = y - XINT (bar->dragging); 5695 int new_start = y - XINT (bar->dragging);
5700 int new_end = new_start + (XINT (bar->end) - XINT (bar->start)); 5696 int new_end = new_start + bar->end - bar->start;
5701 5697
5702 x_scroll_bar_set_handle (bar, new_start, new_end, 0); 5698 x_scroll_bar_set_handle (bar, new_start, new_end, 0);
5703 bar->dragging = Qnil; 5699 bar->dragging = Qnil;
@@ -5745,9 +5741,9 @@ x_scroll_bar_note_movement (bar, event)
5745 /* Where should the handle be now? */ 5741 /* Where should the handle be now? */
5746 int new_start = event->xmotion.y - XINT (bar->dragging); 5742 int new_start = event->xmotion.y - XINT (bar->dragging);
5747 5743
5748 if (new_start != XINT (bar->start)) 5744 if (new_start != bar->start)
5749 { 5745 {
5750 int new_end = new_start + (XINT (bar->end) - XINT (bar->start)); 5746 int new_end = new_start + bar->end - bar->start;
5751 5747
5752 x_scroll_bar_set_handle (bar, new_start, new_end, 0); 5748 x_scroll_bar_set_handle (bar, new_start, new_end, 0);
5753 } 5749 }
@@ -5768,7 +5764,7 @@ x_scroll_bar_report_motion (fp, bar_window, part, x, y, time)
5768 unsigned long *time; 5764 unsigned long *time;
5769{ 5765{
5770 struct scroll_bar *bar = XSCROLL_BAR (last_mouse_scroll_bar); 5766 struct scroll_bar *bar = XSCROLL_BAR (last_mouse_scroll_bar);
5771 Window w = SCROLL_BAR_X_WINDOW (bar); 5767 Window w = bar->x_window;
5772 FRAME_PTR f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window))); 5768 FRAME_PTR f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window)));
5773 int win_x, win_y; 5769 int win_x, win_y;
5774 Window dummy_window; 5770 Window dummy_window;
@@ -5795,10 +5791,10 @@ x_scroll_bar_report_motion (fp, bar_window, part, x, y, time)
5795 { 5791 {
5796#if 0 5792#if 0
5797 int inside_height 5793 int inside_height
5798 = VERTICAL_SCROLL_BAR_INSIDE_HEIGHT (f, XINT (bar->height)); 5794 = VERTICAL_SCROLL_BAR_INSIDE_HEIGHT (f, bar->height);
5799#endif 5795#endif
5800 int top_range 5796 int top_range
5801 = VERTICAL_SCROLL_BAR_TOP_RANGE (f, XINT (bar->height)); 5797 = VERTICAL_SCROLL_BAR_TOP_RANGE (f, bar->height);
5802 5798
5803 win_y -= VERTICAL_SCROLL_BAR_TOP_BORDER; 5799 win_y -= VERTICAL_SCROLL_BAR_TOP_BORDER;
5804 5800
@@ -5815,9 +5811,9 @@ x_scroll_bar_report_motion (fp, bar_window, part, x, y, time)
5815 5811
5816 if (! NILP (bar->dragging)) 5812 if (! NILP (bar->dragging))
5817 *part = scroll_bar_handle; 5813 *part = scroll_bar_handle;
5818 else if (win_y < XINT (bar->start)) 5814 else if (win_y < bar->start)
5819 *part = scroll_bar_above_handle; 5815 *part = scroll_bar_above_handle;
5820 else if (win_y < XINT (bar->end) + VERTICAL_SCROLL_BAR_MIN_HANDLE) 5816 else if (win_y < bar->end + VERTICAL_SCROLL_BAR_MIN_HANDLE)
5821 *part = scroll_bar_handle; 5817 *part = scroll_bar_handle;
5822 else 5818 else
5823 *part = scroll_bar_below_handle; 5819 *part = scroll_bar_below_handle;
@@ -5854,7 +5850,7 @@ x_scroll_bar_clear (f)
5854 for (bar = FRAME_SCROLL_BARS (f); VECTORP (bar); 5850 for (bar = FRAME_SCROLL_BARS (f); VECTORP (bar);
5855 bar = XSCROLL_BAR (bar)->next) 5851 bar = XSCROLL_BAR (bar)->next)
5856 XClearArea (FRAME_X_DISPLAY (f), 5852 XClearArea (FRAME_X_DISPLAY (f),
5857 SCROLL_BAR_X_WINDOW (XSCROLL_BAR (bar)), 5853 XSCROLL_BAR (bar)->x_window,
5858 0, 0, 0, 0, True); 5854 0, 0, 0, 0, True);
5859#endif /* not USE_TOOLKIT_SCROLL_BARS */ 5855#endif /* not USE_TOOLKIT_SCROLL_BARS */
5860} 5856}
@@ -7065,12 +7061,10 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
7065 7061
7066 if (tool_bar_p && event.xbutton.button < 4) 7062 if (tool_bar_p && event.xbutton.button < 4)
7067 { 7063 {
7068 if (event.xbutton.type == ButtonPress) 7064 handle_tool_bar_click (f, x, y,
7069 handle_tool_bar_click (f, x, y, 1, 0); 7065 event.xbutton.type == ButtonPress,
7070 else 7066 x_x_to_emacs_modifiers (dpyinfo,
7071 handle_tool_bar_click (f, x, y, 0, 7067 event.xbutton.state));
7072 x_x_to_emacs_modifiers (dpyinfo,
7073 event.xbutton.state));
7074 } 7068 }
7075 } 7069 }
7076 7070
@@ -8072,7 +8066,7 @@ x_connection_closed (dpy, error_message)
8072 8066
8073 Closing the display is reported to lead to a bus error on 8067 Closing the display is reported to lead to a bus error on
8074 OpenWindows in certain situations. I suspect that is a bug 8068 OpenWindows in certain situations. I suspect that is a bug
8075 in OpenWindows. I don't know how to cicumvent it here. */ 8069 in OpenWindows. I don't know how to circumvent it here. */
8076 8070
8077#ifdef USE_X_TOOLKIT 8071#ifdef USE_X_TOOLKIT
8078 /* If DPYINFO is null, this means we didn't open the display 8072 /* If DPYINFO is null, this means we didn't open the display
@@ -8123,6 +8117,10 @@ x_connection_closed (dpy, error_message)
8123 8117
8124 unbind_to (index, Qnil); 8118 unbind_to (index, Qnil);
8125 clear_waiting_for_input (); 8119 clear_waiting_for_input ();
8120 /* FIXME: This is an asynchronous interrupt w.r.t elisp, so signalling an
8121 error might not be the best thing to do. I'd vote for creating an
8122 elisp event and stuffing it in the queue so people can bind to it via
8123 the global map. --Stef */
8126 error ("%s", error_msg); 8124 error ("%s", error_msg);
8127} 8125}
8128 8126
@@ -8726,7 +8724,7 @@ x_set_offset (f, xoff, yoff, change_gravity)
8726 on the root window for frame F contains ATOMNAME. 8724 on the root window for frame F contains ATOMNAME.
8727 This is how a WM check shall be done according to the Window Manager 8725 This is how a WM check shall be done according to the Window Manager
8728 Specification/Extended Window Manager Hints at 8726 Specification/Extended Window Manager Hints at
8729 http://freedesktop.org/wiki/Standards_2fwm_2dspec. */ 8727 http://freedesktop.org/wiki/Specifications/wm-spec. */
8730 8728
8731static int 8729static int
8732wm_supports (f, atomname) 8730wm_supports (f, atomname)
@@ -9259,7 +9257,7 @@ x_ewmh_activate_frame (f)
9259 FRAME_PTR f; 9257 FRAME_PTR f;
9260{ 9258{
9261 /* See Window Manager Specification/Extended Window Manager Hints at 9259 /* See Window Manager Specification/Extended Window Manager Hints at
9262 http://freedesktop.org/wiki/Standards_2fwm_2dspec */ 9260 http://freedesktop.org/wiki/Specifications/wm-spec */
9263 9261
9264 const char *atom = "_NET_ACTIVE_WINDOW"; 9262 const char *atom = "_NET_ACTIVE_WINDOW";
9265 if (f->async_visible && wm_supports (f, atom)) 9263 if (f->async_visible && wm_supports (f, atom))
@@ -11329,8 +11327,8 @@ x_term_init (display_name, xrm_option, resource_name)
11329 /* Mac OS X 10.3's Xserver sometimes reports 0.0mm. */ 11327 /* Mac OS X 10.3's Xserver sometimes reports 0.0mm. */
11330 dpyinfo->resy = (mm < 1) ? 100 : pixels * 25.4 / mm; 11328 dpyinfo->resy = (mm < 1) ? 100 : pixels * 25.4 / mm;
11331 pixels = DisplayWidth (dpyinfo->display, screen_number); 11329 pixels = DisplayWidth (dpyinfo->display, screen_number);
11332 /* Mac OS X 10.3's Xserver sometimes reports 0.0mm. */
11333 mm = DisplayWidthMM (dpyinfo->display, screen_number); 11330 mm = DisplayWidthMM (dpyinfo->display, screen_number);
11331 /* Mac OS X 10.3's Xserver sometimes reports 0.0mm. */
11334 dpyinfo->resx = (mm < 1) ? 100 : pixels * 25.4 / mm; 11332 dpyinfo->resx = (mm < 1) ? 100 : pixels * 25.4 / mm;
11335 } 11333 }
11336 11334
@@ -11499,13 +11497,13 @@ x_term_init (display_name, xrm_option, resource_name)
11499 Qnil, Qnil); 11497 Qnil, Qnil);
11500#ifdef USE_XIM 11498#ifdef USE_XIM
11501 if (STRINGP (value) 11499 if (STRINGP (value)
11502 && (!strcmp (XSTRING (value)->data, "false") 11500 && (!strcmp (SDATA (value), "false")
11503 || !strcmp (XSTRING (value)->data, "off"))) 11501 || !strcmp (SDATA (value), "off")))
11504 use_xim = 0; 11502 use_xim = 0;
11505#else 11503#else
11506 if (STRINGP (value) 11504 if (STRINGP (value)
11507 && (!strcmp (XSTRING (value)->data, "true") 11505 && (!strcmp (SDATA (value), "true")
11508 || !strcmp (XSTRING (value)->data, "on"))) 11506 || !strcmp (SDATA (value), "on")))
11509 use_xim = 1; 11507 use_xim = 1;
11510#endif 11508#endif
11511 } 11509 }
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
757 /* The next and previous in the chain of scroll bars in this frame. */ 757 /* The next and previous in the chain of scroll bars in this frame. */
758 Lisp_Object next, prev; 758 Lisp_Object next, prev;
759 759
760 /* The X window representing this scroll bar. Since this is a full 760 /* Fields from `x_window' down will not be traced by the GC. */
761 32-bit quantity, we store it split into two 32-bit values. */ 761
762 Lisp_Object x_window_low, x_window_high; 762 /* The X window representing this scroll bar. */
763 Window x_window;
763 764
764 /* The position and size of the scroll bar in pixels, relative to the 765 /* The position and size of the scroll bar in pixels, relative to the
765 frame. */ 766 frame. */
766 Lisp_Object top, left, width, height; 767 int top, left, width, height;
767 768
768 /* The starting and ending positions of the handle, relative to the 769 /* The starting and ending positions of the handle, relative to the
769 handle area (i.e. zero is the top position, not 770 handle area (i.e. zero is the top position, not
@@ -776,7 +777,7 @@ struct scroll_bar
776 drawing handle bottoms VERTICAL_SCROLL_BAR_MIN_HANDLE pixels below 777 drawing handle bottoms VERTICAL_SCROLL_BAR_MIN_HANDLE pixels below
777 where they would be normally; the bottom and top are in a 778 where they would be normally; the bottom and top are in a
778 different co-ordinate system. */ 779 different co-ordinate system. */
779 Lisp_Object start, end; 780 int start, end;
780 781
781 /* If the scroll bar handle is currently being dragged by the user, 782 /* If the scroll bar handle is currently being dragged by the user,
782 this is the number of pixels from the top of the handle to the 783 this is the number of pixels from the top of the handle to the
@@ -784,11 +785,9 @@ struct scroll_bar
784 being dragged, this is Qnil. */ 785 being dragged, this is Qnil. */
785 Lisp_Object dragging; 786 Lisp_Object dragging;
786 787
787#ifdef USE_TOOLKIT_SCROLL_BARS 788 /* 1 if the background of the fringe that is adjacent to a scroll
788 /* t if the background of the fringe that is adjacent to a scroll
789 bar is extended to the gap between the fringe and the bar. */ 789 bar is extended to the gap between the fringe and the bar. */
790 Lisp_Object fringe_extended_p; 790 unsigned int fringe_extended_p : 1;
791#endif
792}; 791};
793 792
794/* The number of elements a vector holding a struct scroll_bar needs. */ 793/* The number of elements a vector holding a struct scroll_bar needs. */
@@ -801,36 +800,19 @@ struct scroll_bar
801#define XSCROLL_BAR(vec) ((struct scroll_bar *) XVECTOR (vec)) 800#define XSCROLL_BAR(vec) ((struct scroll_bar *) XVECTOR (vec))
802 801
803 802
804/* Building a 32-bit C integer from two 16-bit lisp integers. */
805#define SCROLL_BAR_PACK(low, high) (XINT (high) << 16 | XINT (low))
806
807/* Setting two lisp integers to the low and high words of a 32-bit C int. */
808#define SCROLL_BAR_UNPACK(low, high, int32) \
809 (XSETINT ((low), (int32) & 0xffff), \
810 XSETINT ((high), ((int32) >> 16) & 0xffff))
811
812
813/* Extract the X window id of the scroll bar from a struct scroll_bar. */
814#define SCROLL_BAR_X_WINDOW(ptr) \
815 ((Window) SCROLL_BAR_PACK ((ptr)->x_window_low, (ptr)->x_window_high))
816
817/* Store a window id in a struct scroll_bar. */
818#define SET_SCROLL_BAR_X_WINDOW(ptr, id) \
819 (SCROLL_BAR_UNPACK ((ptr)->x_window_low, (ptr)->x_window_high, (int) id))
820
821/* Extract the X widget of the scroll bar from a struct scroll_bar. 803/* Extract the X widget of the scroll bar from a struct scroll_bar.
822 XtWindowToWidget should be fast enough since Xt uses a hash table 804 XtWindowToWidget should be fast enough since Xt uses a hash table
823 to map windows to widgets. */ 805 to map windows to widgets. */
824 806
825#define SCROLL_BAR_X_WIDGET(dpy, ptr) \ 807#define SCROLL_BAR_X_WIDGET(dpy, ptr) \
826 XtWindowToWidget (dpy, SCROLL_BAR_X_WINDOW (ptr)) 808 XtWindowToWidget (dpy, ptr->x_window)
827 809
828/* Store a widget id in a struct scroll_bar. */ 810/* Store a widget id in a struct scroll_bar. */
829 811
830#define SET_SCROLL_BAR_X_WIDGET(ptr, w) \ 812#define SET_SCROLL_BAR_X_WIDGET(ptr, w) \
831 do { \ 813 do { \
832 Window window = XtWindow (w); \ 814 Window window = XtWindow (w); \
833 SET_SCROLL_BAR_X_WINDOW (ptr, window); \ 815 ptr->x_window = window; \
834} while (0) 816} while (0)
835 817
836 818