aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJoakim Verona2011-11-07 10:03:00 +0100
committerJoakim Verona2011-11-07 10:03:00 +0100
commitc649990b73768c7a024e111d8c63246030647b53 (patch)
treee5b47169dfc679b53fed30bbd66e2df98de2f02c /src
parentc823c667cd00b9d8036ce06b943f58f3f4efd7d9 (diff)
parentca78dc431fff3bc2a4f33f2a0fc1449608568d23 (diff)
downloademacs-c649990b73768c7a024e111d8c63246030647b53.tar.gz
emacs-c649990b73768c7a024e111d8c63246030647b53.zip
upstream
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog160
-rw-r--r--src/alloc.c7
-rw-r--r--src/callproc.c1
-rw-r--r--src/coding.c2
-rw-r--r--src/dispextern.h16
-rw-r--r--src/gtkutil.c10
-rw-r--r--src/intervals.c22
-rw-r--r--src/keyboard.c8
-rw-r--r--src/lisp.h56
-rw-r--r--src/makefile.w32-in10
-rw-r--r--src/nsfns.m208
-rw-r--r--src/nsterm.m21
-rw-r--r--src/process.c1
-rw-r--r--src/regex.c4
-rw-r--r--src/s/ms-w32.h24
-rw-r--r--src/w32.c7
-rw-r--r--src/w32fns.c24
-rw-r--r--src/w32font.c27
-rw-r--r--src/w32term.c16
-rw-r--r--src/window.c129
-rw-r--r--src/xdisp.c29
-rw-r--r--src/xfns.c35
-rw-r--r--src/xmenu.c31
23 files changed, 582 insertions, 266 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index ccfcb48daf0..3711292ad35 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,160 @@
12011-11-07 Paul Eggert <eggert@cs.ucla.edu>
2
3 * alloc.c (DEADP): New macro, for porting to GNU/Hurd (Bug#9926).
4 This is also needed for porting to any host where GC_MARK_STACK is
5 not GC_MAKE_GCPROS_NOOPS.
6 (which_symbols): Use it.
7
82011-11-07 Kenichi Handa <handa@m17n.org>
9
10 * coding.c (coding_set_destination): Check coding->src_pos only
11 when coding->src_object is a buffer (bug#9910).
12
13 * process.c (send_process): Set the member src_multibyte of coding
14 to 0 (bug#9911) when sending a unibyte text.
15
16 * callproc.c (Fcall_process): Set the member src_multibyte of
17 process_coding to 0 (bug#9912).
18
192011-11-06 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
20
21 * xmenu.c (cleanup_widget_value_tree): New function.
22 (xmenu_show, xdialog_show): Use it in record_unwind_protect instead of
23 calling free_menubar_widget_value_tree directly (Bug#9830).
24
252011-11-06 Paul Eggert <eggert@cs.ucla.edu>
26
27 Fix some portability problems with 'inline'.
28 * dispextern.h (window_box, window_box_height, window_text_bottom_y)
29 (window_box_width, window_box_left, window_box_left_offset)
30 (window_box_right, window_box_right_offset): Declare extern.
31 Otherwise, these inline functions do not conform to C99 and
32 are miscompiled by Microsoft compilers. Reported by Eli Zaretskii in
33 <http://lists.gnu.org/archive/html/emacs-devel/2011-11/msg00084.html>.
34 * intervals.c (adjust_intervals_for_insertion)
35 (adjust_intervals_for_deletion): Now extern, because otherwise the
36 extern inline functions 'offset_intervals' couldn't refer to it.
37 (static_offset_intervals): Remove.
38 (offset_intervals): Rewrite using the old contents of
39 static_offset_intervals. The old version didn't conform to C99
40 because an extern inline function contained a reference to an
41 identifier with static linkage.
42
432011-11-06 Andreas Schwab <schwab@linux-m68k.org>
44
45 * keyboard.c (interrupt_signal): Don't call kill-emacs while in
46 GC.
47
482011-11-06 Eli Zaretskii <eliz@gnu.org>
49
50 * xdisp.c (init_iterator, reseat_to_string): Don't set the
51 iterator's bidi_p flag if Vpurify_flag is non-nil. (Bug#9963)
52 (Fcurrent_bidi_paragraph_direction): If Vpurify_flag is non-nil,
53 return Qleft_to_right.
54
552011-11-06 Chong Yidong <cyd@gnu.org>
56
57 * window.c (Fwindow_live_p, Fwindow_frame, Fframe_root_window)
58 (Fminibuffer_window, Fwindow_buffer, Fwindow_splits)
59 (Fset_window_splits, Fwindow_nest, Fset_window_nest)
60 (Fwindow_use_time, Fwindow_total_size, Fwindow_normal_size)
61 (Fwindow_new_normal, Fwindow_left_column, Fwindow_top_line)
62 (Fwindow_margins, Fwindow_fringes, Fwindow_scroll_bars)
63 (Fwindow_vscroll): Doc fix.
64 (Fwindow_top_child, Fwindow_left_child): Eliminate a nil default
65 argument, since it makes no sense to pass a live window and for
66 consistency with window-child.
67
682011-11-05 Christoph Scholtes <cschol2112@googlemail.com>
69
70 * makefile.w32-in ($(TEMACS), (gl-stamp)): Use $(THISDIR) to
71 support MSVC.
72
732011-11-05 Jason Rumney <jasonr@gnu.org>
74
75 * w32font.c (font_matches_spec): Filter out non-Japanese kana fonts.
76 (add_font_entity_to_list): Filter out non-Japanese Shift-JIS
77 fonts (Bug#6029).
78 (add_font_entity_to_list): Fix logic errors in mixed boolean and
79 bitwise arithmetic preventing use of unicode-sip and non-truetype
80 opentype fonts.
81
822011-11-05 Eli Zaretskii <eliz@gnu.org>
83
84 * s/ms-w32.h (fstat, stat, utime): Move redirections to
85 "emacs"-only part.
86
87 * w32fns.c (x_create_tip_frame, Fx_create_frame): Rearrange
88 initialization code to keep similarity to xfns.c after changes
89 from 2011-11-05.
90
912011-11-05 Jan Djärv <jan.h.d@swipnet.se>
92
93 * nsfns.m: Declare image_cache_refcount if GLYPH_DEBUG.
94 (unwind_create_frame): New function (Bug#9943).
95 (Fx_create_frame): Restructure code to be more similar to the one in
96 xfns.c. Call record_unwind_protect with unwind_create_frame (Bug#9943).
97 Initialize image_cache_refcount if GLYPH_DEBUG (Bug#9943).
98 Move terminal->reference_count++ just before making the frame official
99 (Bug#9943).
100
101 * nsterm.m (x_free_frame_resources): New function.
102 (x_destroy_window): Move code to x_free_frame_resources.
103
104 * xfns.c (unwind_create_frame): Fix comment.
105 (Fx_create_frame, x_create_tip_frame): Move
106 terminal->reference_count++ just before making the frame
107 official. Move initialization of image_cache_refcount and
108 dpyinfo_refcount before calling init_frame_faces (Bug#9943).
109
1102011-11-05 Eli Zaretskii <eliz@gnu.org>
111
112 Support MSVC build with newer versions of Visual Studio.
113 * makefile.w32-in (TAGS-gmake): Don't use $(patsubst ...), as
114 Nmake barfs on that. Use $(OBJ*_c) variables instead, defined on
115 nt/gmake.defs.
116
117 * lisp.h (ENUM_BF): New macro, for enumerated types in bitfields,
118 which are not supported by MSVC.
119 (Lisp_Symbol, Lisp_Misc_Any, Lisp_Marker, Lisp_Misc_Overlay)
120 (Lisp_Save_Value, Lisp_Free): Use ENUM_BF for enumerated types in
121 bitfields.
122 (Lisp_Object) [USE_LISP_UNION_TYPE]: Use ENUM_BF for enumerated
123 types in bitfields.
124 (DEFUN) [_MSC_VER]: Define in a different way for MSVC.
125
126 * w32fns.c [_MSC_VER]: DECLARE_HANDLE for any MSVC version.
127
1282011-11-05 Fabrice Popineau <fabrice.popineau@supelec.fr> (tiny change)
129
130 Support MSVC build with newer versions of Visual Studio.
131 * w32.c: Don't include w32api.h for MSVC.
132 (init_environment) [_MSC_VER]: Call sys_access, not _access.
133
134 * s/ms-w32.h <sigset_t, ssize_t> [_MSC_VER]: Typedefs for MSVC.
135 [_MSC_VER]: Include sys/timeb.h, sys/stat.h, and signal.h.
136 (fstat, stat, utime) [_MSC_VER]: Redirect to their sys_* cousins.
137 (malloc, free, realloc, calloc) [_MSC_VER]: Always redirect to the
138 e_* cousins.
139 (alloca) [_MSC_VER]: Define to _alloca.
140
141 * lisp.h (DECL_ALIGN) [_MSC_VER]: Define for MSVC.
142
143 * regex.c <re_char> [_MSC_VER]: A separate definition for MSVC.
144
1452011-11-04 Eli Zaretskii <eliz@gnu.org>
146
147 * xdisp.c (note_mouse_highlight): If either of
148 previous/next-single-property-change returns nil, treat that as
149 the beginning or the end of the buffer. (Bug#9955)
150
1512011-11-04 Jan Djärv <jan.h.d@swipnet.se>
152
153 * gtkutil.c (xg_make_tool_item): Add callbacks if one of wimage or
154 label is not null (Bug#9951).
155 (xg_tool_item_stale_p): Handle the fact that wimage and/or wlbl
156 may be NULL.
157
12011-11-04 Eli Zaretskii <eliz@gnu.org> 1582011-11-04 Eli Zaretskii <eliz@gnu.org>
2 159
3 * window.c (Fwindow_body_size): Mention in the doc string that the 160 * window.c (Fwindow_body_size): Mention in the doc string that the
@@ -2736,6 +2893,9 @@
2736 2893
27372011-07-08 Jason Rumney <jasonr@gnu.org> 28942011-07-08 Jason Rumney <jasonr@gnu.org>
2738 2895
2896 * w32term.c (x_make_frame_visible): Use SH_SHOWNORMAL rather than
2897 SH_SHOW for hidden windows (Bug#5482).
2898
2739 * w32fns.c (w32_wnd_proc) [WM_TIMER, WM_SET_CURSOR]: Avoid using 2899 * w32fns.c (w32_wnd_proc) [WM_TIMER, WM_SET_CURSOR]: Avoid using
2740 frame struct members of non-existent frames (Bug#6284). 2900 frame struct members of non-existent frames (Bug#6284).
2741 2901
diff --git a/src/alloc.c b/src/alloc.c
index 210dd7d1687..985e4b71426 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -315,6 +315,7 @@ static POINTER_TYPE *lisp_malloc (size_t, enum mem_type);
315 on free lists recognizable in O(1). */ 315 on free lists recognizable in O(1). */
316 316
317static Lisp_Object Vdead; 317static Lisp_Object Vdead;
318#define DEADP(x) EQ (x, Vdead)
318 319
319#ifdef GC_MALLOC_CHECK 320#ifdef GC_MALLOC_CHECK
320 321
@@ -411,6 +412,10 @@ static void check_gcpros (void);
411 412
412#endif /* GC_MARK_STACK || GC_MALLOC_CHECK */ 413#endif /* GC_MARK_STACK || GC_MALLOC_CHECK */
413 414
415#ifndef DEADP
416# define DEADP(x) 0
417#endif
418
414/* Recording what needs to be marked for gc. */ 419/* Recording what needs to be marked for gc. */
415 420
416struct gcpro *gcprolist; 421struct gcpro *gcprolist;
@@ -6261,7 +6266,7 @@ which_symbols (Lisp_Object obj, EMACS_INT find_max)
6261 int gc_count = inhibit_garbage_collection (); 6266 int gc_count = inhibit_garbage_collection ();
6262 Lisp_Object found = Qnil; 6267 Lisp_Object found = Qnil;
6263 6268
6264 if (!EQ (obj, Vdead)) 6269 if (! DEADP (obj))
6265 { 6270 {
6266 for (sblk = symbol_block; sblk; sblk = sblk->next) 6271 for (sblk = symbol_block; sblk; sblk = sblk->next)
6267 { 6272 {
diff --git a/src/callproc.c b/src/callproc.c
index 97531f73848..0859aaef2e6 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -748,6 +748,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
748 val = raw_text_coding_system (val); 748 val = raw_text_coding_system (val);
749 setup_coding_system (val, &process_coding); 749 setup_coding_system (val, &process_coding);
750 } 750 }
751 process_coding.src_multibyte = 0;
751 752
752 immediate_quit = 1; 753 immediate_quit = 1;
753 QUIT; 754 QUIT;
diff --git a/src/coding.c b/src/coding.c
index 5fd59d394d9..79908e9b29b 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -1043,7 +1043,7 @@ coding_set_destination (struct coding_system *coding)
1043{ 1043{
1044 if (BUFFERP (coding->dst_object)) 1044 if (BUFFERP (coding->dst_object))
1045 { 1045 {
1046 if (coding->src_pos < 0) 1046 if (BUFFERP (coding->src_object) && coding->src_pos < 0)
1047 { 1047 {
1048 coding->destination = BEG_ADDR + coding->dst_pos_byte - BEG_BYTE; 1048 coding->destination = BEG_ADDR + coding->dst_pos_byte - BEG_BYTE;
1049 coding->dst_bytes = (GAP_END_ADDR 1049 coding->dst_bytes = (GAP_END_ADDR
diff --git a/src/dispextern.h b/src/dispextern.h
index 006ceb31a5a..d36cdd167ff 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -3034,14 +3034,14 @@ int resize_mini_window (struct window *, int);
3034void set_vertical_scroll_bar (struct window *); 3034void set_vertical_scroll_bar (struct window *);
3035#endif 3035#endif
3036int try_window (Lisp_Object, struct text_pos, int); 3036int try_window (Lisp_Object, struct text_pos, int);
3037void window_box (struct window *, int, int *, int *, int *, int *); 3037extern void window_box (struct window *, int, int *, int *, int *, int *);
3038int window_box_height (struct window *); 3038extern int window_box_height (struct window *);
3039int window_text_bottom_y (struct window *); 3039extern int window_text_bottom_y (struct window *);
3040int window_box_width (struct window *, int); 3040extern int window_box_width (struct window *, int);
3041int window_box_left (struct window *, int); 3041extern int window_box_left (struct window *, int);
3042int window_box_left_offset (struct window *, int); 3042extern int window_box_left_offset (struct window *, int);
3043int window_box_right (struct window *, int); 3043extern int window_box_right (struct window *, int);
3044int window_box_right_offset (struct window *, int); 3044extern int window_box_right_offset (struct window *, int);
3045int estimate_mode_line_height (struct frame *, enum face_id); 3045int estimate_mode_line_height (struct frame *, enum face_id);
3046void pixel_to_glyph_coords (struct frame *, int, int, int *, int *, 3046void pixel_to_glyph_coords (struct frame *, int, int, int *, int *,
3047 NativeRectangle *, int); 3047 NativeRectangle *, int);
diff --git a/src/gtkutil.c b/src/gtkutil.c
index 26959d57d4b..af697c72673 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -4237,7 +4237,7 @@ xg_make_tool_item (FRAME_PTR f,
4237 gtk_container_add (GTK_CONTAINER (weventbox), wb); 4237 gtk_container_add (GTK_CONTAINER (weventbox), wb);
4238 gtk_container_add (GTK_CONTAINER (ti), weventbox); 4238 gtk_container_add (GTK_CONTAINER (ti), weventbox);
4239 4239
4240 if (wimage) 4240 if (wimage || label)
4241 { 4241 {
4242 intptr_t ii = i; 4242 intptr_t ii = i;
4243 gpointer gi = (gpointer) ii; 4243 gpointer gi = (gpointer) ii;
@@ -4302,21 +4302,21 @@ xg_tool_item_stale_p (GtkWidget *wbutton, const char *stock_name,
4302 GtkWidget *wlbl = xg_get_tool_bar_widgets (vb, &wimage); 4302 GtkWidget *wlbl = xg_get_tool_bar_widgets (vb, &wimage);
4303 4303
4304 /* Check if the tool icon matches. */ 4304 /* Check if the tool icon matches. */
4305 if (stock_name) 4305 if (stock_name && wimage)
4306 { 4306 {
4307 old = g_object_get_data (G_OBJECT (wimage), 4307 old = g_object_get_data (G_OBJECT (wimage),
4308 XG_TOOL_BAR_STOCK_NAME); 4308 XG_TOOL_BAR_STOCK_NAME);
4309 if (!old || strcmp (old, stock_name)) 4309 if (!old || strcmp (old, stock_name))
4310 return 1; 4310 return 1;
4311 } 4311 }
4312 else if (icon_name) 4312 else if (icon_name && wimage)
4313 { 4313 {
4314 old = g_object_get_data (G_OBJECT (wimage), 4314 old = g_object_get_data (G_OBJECT (wimage),
4315 XG_TOOL_BAR_ICON_NAME); 4315 XG_TOOL_BAR_ICON_NAME);
4316 if (!old || strcmp (old, icon_name)) 4316 if (!old || strcmp (old, icon_name))
4317 return 1; 4317 return 1;
4318 } 4318 }
4319 else 4319 else if (wimage)
4320 { 4320 {
4321 gpointer gold_img = g_object_get_data (G_OBJECT (wimage), 4321 gpointer gold_img = g_object_get_data (G_OBJECT (wimage),
4322 XG_TOOL_BAR_IMAGE_DATA); 4322 XG_TOOL_BAR_IMAGE_DATA);
@@ -4331,7 +4331,7 @@ xg_tool_item_stale_p (GtkWidget *wbutton, const char *stock_name,
4331 return 1; 4331 return 1;
4332 4332
4333 /* Ensure label is correct. */ 4333 /* Ensure label is correct. */
4334 if (label) 4334 if (label && wlbl)
4335 gtk_label_set_text (GTK_LABEL (wlbl), label); 4335 gtk_label_set_text (GTK_LABEL (wlbl), label);
4336 return 0; 4336 return 0;
4337} 4337}
diff --git a/src/intervals.c b/src/intervals.c
index 1f3f8cf793e..be1bdfb9056 100644
--- a/src/intervals.c
+++ b/src/intervals.c
@@ -52,6 +52,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
52 52
53#define TMEM(sym, set) (CONSP (set) ? ! NILP (Fmemq (sym, set)) : ! NILP (set)) 53#define TMEM(sym, set) (CONSP (set) ? ! NILP (Fmemq (sym, set)) : ! NILP (set))
54 54
55extern INTERVAL adjust_intervals_for_insertion (INTERVAL,
56 EMACS_INT, EMACS_INT);
57extern void adjust_intervals_for_deletion (struct buffer *,
58 EMACS_INT, EMACS_INT);
59
55static Lisp_Object merge_properties_sticky (Lisp_Object, Lisp_Object); 60static Lisp_Object merge_properties_sticky (Lisp_Object, Lisp_Object);
56static INTERVAL merge_interval_right (INTERVAL); 61static INTERVAL merge_interval_right (INTERVAL);
57static INTERVAL reproduce_tree (INTERVAL, INTERVAL); 62static INTERVAL reproduce_tree (INTERVAL, INTERVAL);
@@ -798,7 +803,7 @@ update_interval (register INTERVAL i, EMACS_INT pos)
798 and check the hungry bits of both. Then add the length going back up 803 and check the hungry bits of both. Then add the length going back up
799 to the root. */ 804 to the root. */
800 805
801static INTERVAL 806INTERVAL
802adjust_intervals_for_insertion (INTERVAL tree, EMACS_INT position, 807adjust_intervals_for_insertion (INTERVAL tree, EMACS_INT position,
803 EMACS_INT length) 808 EMACS_INT length)
804{ 809{
@@ -859,7 +864,7 @@ adjust_intervals_for_insertion (INTERVAL tree, EMACS_INT position,
859 interval. Another possibility would be to create a new interval for 864 interval. Another possibility would be to create a new interval for
860 this text, and make it have the merged properties of both ends. */ 865 this text, and make it have the merged properties of both ends. */
861 866
862static INTERVAL 867INTERVAL
863adjust_intervals_for_insertion (INTERVAL tree, 868adjust_intervals_for_insertion (INTERVAL tree,
864 EMACS_INT position, EMACS_INT length) 869 EMACS_INT position, EMACS_INT length)
865{ 870{
@@ -1369,7 +1374,7 @@ interval_deletion_adjustment (register INTERVAL tree, register EMACS_INT from,
1369 text. The deletion is effected at position START (which is a 1374 text. The deletion is effected at position START (which is a
1370 buffer position, i.e. origin 1). */ 1375 buffer position, i.e. origin 1). */
1371 1376
1372static void 1377void
1373adjust_intervals_for_deletion (struct buffer *buffer, 1378adjust_intervals_for_deletion (struct buffer *buffer,
1374 EMACS_INT start, EMACS_INT length) 1379 EMACS_INT start, EMACS_INT length)
1375{ 1380{
@@ -1425,9 +1430,8 @@ adjust_intervals_for_deletion (struct buffer *buffer,
1425 compiler that does not allow calling a static function (here, 1430 compiler that does not allow calling a static function (here,
1426 adjust_intervals_for_deletion) from a non-static inline function. */ 1431 adjust_intervals_for_deletion) from a non-static inline function. */
1427 1432
1428static inline void 1433inline void
1429static_offset_intervals (struct buffer *buffer, EMACS_INT start, 1434offset_intervals (struct buffer *buffer, EMACS_INT start, EMACS_INT length)
1430 EMACS_INT length)
1431{ 1435{
1432 if (NULL_INTERVAL_P (BUF_INTERVALS (buffer)) || length == 0) 1436 if (NULL_INTERVAL_P (BUF_INTERVALS (buffer)) || length == 0)
1433 return; 1437 return;
@@ -1440,12 +1444,6 @@ static_offset_intervals (struct buffer *buffer, EMACS_INT start,
1440 adjust_intervals_for_deletion (buffer, start, -length); 1444 adjust_intervals_for_deletion (buffer, start, -length);
1441 } 1445 }
1442} 1446}
1443
1444inline void
1445offset_intervals (struct buffer *buffer, EMACS_INT start, EMACS_INT length)
1446{
1447 static_offset_intervals (buffer, start, length);
1448}
1449 1447
1450/* Merge interval I with its lexicographic successor. The resulting 1448/* Merge interval I with its lexicographic successor. The resulting
1451 interval is returned, and has the properties of the original 1449 interval is returned, and has the properties of the original
diff --git a/src/keyboard.c b/src/keyboard.c
index bda8a1d82f3..a9350fc32f3 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -10872,8 +10872,12 @@ interrupt_signal (int signalnum) /* If we don't have an argument, some */
10872 if (!terminal) 10872 if (!terminal)
10873 { 10873 {
10874 /* If there are no frames there, let's pretend that we are a 10874 /* If there are no frames there, let's pretend that we are a
10875 well-behaving UN*X program and quit. */ 10875 well-behaving UN*X program and quit. We cannot do that while
10876 Fkill_emacs (Qnil); 10876 GC is in progress, though. */
10877 if (!gc_in_progress)
10878 Fkill_emacs (Qnil);
10879 else
10880 Vquit_flag = Qt;
10877 } 10881 }
10878 else 10882 else
10879 { 10883 {
diff --git a/src/lisp.h b/src/lisp.h
index c0ddb7f2b02..fd53bf13731 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -168,6 +168,9 @@ extern int suppress_checking EXTERNALLY_VISIBLE;
168# if HAVE_ATTRIBUTE_ALIGNED 168# if HAVE_ATTRIBUTE_ALIGNED
169# define DECL_ALIGN(type, var) \ 169# define DECL_ALIGN(type, var) \
170 type __attribute__ ((__aligned__ (1 << GCTYPEBITS))) var 170 type __attribute__ ((__aligned__ (1 << GCTYPEBITS))) var
171# elif defined(_MSC_VER)
172# define DECL_ALIGN(type, var) \
173 type __declspec(align(1 << GCTYPEBITS)) var
171# else 174# else
172 /* What directives do other compilers use? */ 175 /* What directives do other compilers use? */
173# endif 176# endif
@@ -225,6 +228,15 @@ extern int suppress_checking EXTERNALLY_VISIBLE;
225# endif 228# endif
226#endif 229#endif
227 230
231/* Stolen from GDB. The only known compiler that doesn't support
232 enums in bitfields is MSVC. */
233#ifdef _MSC_VER
234#define ENUM_BF(TYPE) unsigned int
235#else
236#define ENUM_BF(TYPE) enum TYPE
237#endif
238
239
228enum Lisp_Type 240enum Lisp_Type
229 { 241 {
230 /* Integer. XINT (obj) is the integer value. */ 242 /* Integer. XINT (obj) is the integer value. */
@@ -315,12 +327,12 @@ union Lisp_Object
315 /* Use explict signed, the signedness of a bit-field of type 327 /* Use explict signed, the signedness of a bit-field of type
316 int is implementation defined. */ 328 int is implementation defined. */
317 signed EMACS_INT val : VALBITS; 329 signed EMACS_INT val : VALBITS;
318 enum Lisp_Type type : GCTYPEBITS; 330 ENUM_BF (Lisp_Type) type : GCTYPEBITS;
319 } s; 331 } s;
320 struct 332 struct
321 { 333 {
322 EMACS_UINT val : VALBITS; 334 EMACS_UINT val : VALBITS;
323 enum Lisp_Type type : GCTYPEBITS; 335 ENUM_BF (Lisp_Type) type : GCTYPEBITS;
324 } u; 336 } u;
325 } 337 }
326Lisp_Object; 338Lisp_Object;
@@ -336,14 +348,14 @@ union Lisp_Object
336 348
337 struct 349 struct
338 { 350 {
339 enum Lisp_Type type : GCTYPEBITS; 351 ENUM_BF (Lisp_Type) type : GCTYPEBITS;
340 /* Use explict signed, the signedness of a bit-field of type 352 /* Use explict signed, the signedness of a bit-field of type
341 int is implementation defined. */ 353 int is implementation defined. */
342 signed EMACS_INT val : VALBITS; 354 signed EMACS_INT val : VALBITS;
343 } s; 355 } s;
344 struct 356 struct
345 { 357 {
346 enum Lisp_Type type : GCTYPEBITS; 358 ENUM_BF (Lisp_Type) type : GCTYPEBITS;
347 EMACS_UINT val : VALBITS; 359 EMACS_UINT val : VALBITS;
348 } u; 360 } u;
349 } 361 }
@@ -1100,7 +1112,7 @@ struct Lisp_Symbol
1100 1 : it's a varalias, the value is really in the `alias' symbol. 1112 1 : it's a varalias, the value is really in the `alias' symbol.
1101 2 : it's a localized var, the value is in the `blv' object. 1113 2 : it's a localized var, the value is in the `blv' object.
1102 3 : it's a forwarding variable, the value is in `forward'. */ 1114 3 : it's a forwarding variable, the value is in `forward'. */
1103 enum symbol_redirect redirect : 3; 1115 ENUM_BF (symbol_redirect) redirect : 3;
1104 1116
1105 /* Non-zero means symbol is constant, i.e. changing its value 1117 /* Non-zero means symbol is constant, i.e. changing its value
1106 should signal an error. If the value is 3, then the var 1118 should signal an error. If the value is 3, then the var
@@ -1313,7 +1325,7 @@ struct Lisp_Hash_Table
1313 1325
1314struct Lisp_Misc_Any /* Supertype of all Misc types. */ 1326struct Lisp_Misc_Any /* Supertype of all Misc types. */
1315{ 1327{
1316 enum Lisp_Misc_Type type : 16; /* = Lisp_Misc_??? */ 1328 ENUM_BF (Lisp_Misc_Type) type : 16; /* = Lisp_Misc_??? */
1317 unsigned gcmarkbit : 1; 1329 unsigned gcmarkbit : 1;
1318 int spacer : 15; 1330 int spacer : 15;
1319 /* Make it as long as "Lisp_Free without padding". */ 1331 /* Make it as long as "Lisp_Free without padding". */
@@ -1322,7 +1334,7 @@ struct Lisp_Misc_Any /* Supertype of all Misc types. */
1322 1334
1323struct Lisp_Marker 1335struct Lisp_Marker
1324{ 1336{
1325 enum Lisp_Misc_Type type : 16; /* = Lisp_Misc_Marker */ 1337 ENUM_BF (Lisp_Misc_Type) type : 16; /* = Lisp_Misc_Marker */
1326 unsigned gcmarkbit : 1; 1338 unsigned gcmarkbit : 1;
1327 int spacer : 13; 1339 int spacer : 13;
1328 /* This flag is temporarily used in the functions 1340 /* This flag is temporarily used in the functions
@@ -1472,7 +1484,7 @@ struct Lisp_Overlay
1472 I.e. 9words plus 2 bits, 3words of which are for external linked lists. 1484 I.e. 9words plus 2 bits, 3words of which are for external linked lists.
1473*/ 1485*/
1474 { 1486 {
1475 enum Lisp_Misc_Type type : 16; /* = Lisp_Misc_Overlay */ 1487 ENUM_BF (Lisp_Misc_Type) type : 16; /* = Lisp_Misc_Overlay */
1476 unsigned gcmarkbit : 1; 1488 unsigned gcmarkbit : 1;
1477 int spacer : 15; 1489 int spacer : 15;
1478 struct Lisp_Overlay *next; 1490 struct Lisp_Overlay *next;
@@ -1491,7 +1503,7 @@ struct Lisp_Kboard_Objfwd
1491 This type of object is used in the arg to record_unwind_protect. */ 1503 This type of object is used in the arg to record_unwind_protect. */
1492struct Lisp_Save_Value 1504struct Lisp_Save_Value
1493 { 1505 {
1494 enum Lisp_Misc_Type type : 16; /* = Lisp_Misc_Save_Value */ 1506 ENUM_BF (Lisp_Misc_Type) type : 16; /* = Lisp_Misc_Save_Value */
1495 unsigned gcmarkbit : 1; 1507 unsigned gcmarkbit : 1;
1496 int spacer : 14; 1508 int spacer : 14;
1497 /* If DOGC is set, POINTER is the address of a memory 1509 /* If DOGC is set, POINTER is the address of a memory
@@ -1505,7 +1517,7 @@ struct Lisp_Save_Value
1505/* A miscellaneous object, when it's on the free list. */ 1517/* A miscellaneous object, when it's on the free list. */
1506struct Lisp_Free 1518struct Lisp_Free
1507 { 1519 {
1508 enum Lisp_Misc_Type type : 16; /* = Lisp_Misc_Free */ 1520 ENUM_BF (Lisp_Misc_Type) type : 16; /* = Lisp_Misc_Free */
1509 unsigned gcmarkbit : 1; 1521 unsigned gcmarkbit : 1;
1510 int spacer : 15; 1522 int spacer : 15;
1511 union Lisp_Misc *chain; 1523 union Lisp_Misc *chain;
@@ -1900,13 +1912,23 @@ typedef struct {
1900 1912
1901/* This version of DEFUN declares a function prototype with the right 1913/* This version of DEFUN declares a function prototype with the right
1902 arguments, so we can catch errors with maxargs at compile-time. */ 1914 arguments, so we can catch errors with maxargs at compile-time. */
1903#define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc) \ 1915#ifdef _MSC_VER
1904 Lisp_Object fnname DEFUN_ARGS_ ## maxargs ; \ 1916#define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc) \
1905 static DECL_ALIGN (struct Lisp_Subr, sname) = \ 1917 Lisp_Object fnname DEFUN_ARGS_ ## maxargs ; \
1906 { PVEC_SUBR, \ 1918 static DECL_ALIGN (struct Lisp_Subr, sname) = \
1907 { .a ## maxargs = fnname }, \ 1919 { PVEC_SUBR | (sizeof (struct Lisp_Subr) / sizeof (EMACS_INT)), \
1908 minargs, maxargs, lname, intspec, 0}; \ 1920 { (Lisp_Object (__cdecl *)(void))fnname }, \
1909 Lisp_Object fnname 1921 minargs, maxargs, lname, intspec, 0}; \
1922 Lisp_Object fnname
1923#else /* not _MSC_VER */
1924#define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc) \
1925 Lisp_Object fnname DEFUN_ARGS_ ## maxargs ; \
1926 static DECL_ALIGN (struct Lisp_Subr, sname) = \
1927 { PVEC_SUBR, \
1928 { .a ## maxargs = fnname }, \
1929 minargs, maxargs, lname, intspec, 0}; \
1930 Lisp_Object fnname
1931#endif
1910 1932
1911/* Note that the weird token-substitution semantics of ANSI C makes 1933/* Note that the weird token-substitution semantics of ANSI C makes
1912 this work for MANY and UNEVALLED. */ 1934 this work for MANY and UNEVALLED. */
diff --git a/src/makefile.w32-in b/src/makefile.w32-in
index 53cb5f857ab..e97f7f3aca4 100644
--- a/src/makefile.w32-in
+++ b/src/makefile.w32-in
@@ -177,7 +177,7 @@ temacs: stamp_BLD $(TEMACS)
177$(TEMACS): $(TLIB0) $(TLIB1) $(TLIB2) $(TLASTLIB) $(TOBJ) $(TRES) \ 177$(TEMACS): $(TLIB0) $(TLIB1) $(TLIB2) $(TLASTLIB) $(TOBJ) $(TRES) \
178 ../nt/$(BLD)/addsection.exe $(GNULIB) 178 ../nt/$(BLD)/addsection.exe $(GNULIB)
179 $(LINK) $(LINK_OUT)$(TEMACS_TMP) $(FULL_LINK_FLAGS) $(TOBJ) $(TRES) $(LIBS) 179 $(LINK) $(LINK_OUT)$(TEMACS_TMP) $(FULL_LINK_FLAGS) $(TOBJ) $(TRES) $(LIBS)
180 "../nt/$(BLD)/addsection" "$(TEMACS_TMP)" "$(TEMACS)" EMHEAP 21 180 "$(THISDIR)/../nt/$(BLD)/addsection" "$(TEMACS_TMP)" "$(TEMACS)" EMHEAP 21
181 181
182# These omit firstfile.${O}, but there's no documentation in there 182# These omit firstfile.${O}, but there's no documentation in there
183# anyways. 183# anyways.
@@ -232,7 +232,7 @@ globals.h: gl-stamp
232 232
233gl-stamp: ../lib-src/$(BLD)/make-docfile.exe $(GLOBAL_SOURCES) 233gl-stamp: ../lib-src/$(BLD)/make-docfile.exe $(GLOBAL_SOURCES)
234 - $(DEL) gl-tmp 234 - $(DEL) gl-tmp
235 "../lib-src/$(BLD)/make-docfile" -d . -g $(SOME_MACHINE_OBJECTS) $(obj) > gl-tmp 235 "$(THISDIR)/../lib-src/$(BLD)/make-docfile" -d . -g $(SOME_MACHINE_OBJECTS) $(obj) > gl-tmp
236 cmd /c "fc /b gl-tmp globals.h >nul 2>&1 || $(CP) gl-tmp globals.h" 236 cmd /c "fc /b gl-tmp globals.h >nul 2>&1 || $(CP) gl-tmp globals.h"
237 - $(DEL) gl-tmp 237 - $(DEL) gl-tmp
238 echo timestamp > $@ 238 echo timestamp > $@
@@ -348,11 +348,11 @@ TAGS-LISP: $(OBJ0) $(OBJ1) $(OBJ2)
348TAGS-gmake: 348TAGS-gmake:
349 ../lib-src/$(BLD)/etags.exe --include=TAGS-LISP --include=../nt/TAGS \ 349 ../lib-src/$(BLD)/etags.exe --include=TAGS-LISP --include=../nt/TAGS \
350 --regex=@../nt/emacs-src.tags \ 350 --regex=@../nt/emacs-src.tags \
351 $(patsubst $(BLD)%.$(O),$(CURDIR)%.c,$(OBJ0)) 351 $(OBJ0_c)
352 ../lib-src/$(BLD)/etags.exe -a --regex=@../nt/emacs-src.tags \ 352 ../lib-src/$(BLD)/etags.exe -a --regex=@../nt/emacs-src.tags \
353 $(patsubst $(BLD)%.$(O),$(CURDIR)%.c,$(OBJ1)) 353 $(OBJ1_c)
354 ../lib-src/$(BLD)/etags.exe -a --regex=@../nt/emacs-src.tags \ 354 ../lib-src/$(BLD)/etags.exe -a --regex=@../nt/emacs-src.tags \
355 $(patsubst $(BLD)%.$(O),$(CURDIR)%.c,$(OBJ2)) \ 355 $(OBJ2_c) \
356 $(CURDIR)/*.h $(CURDIR)/m/intel386.h $(CURDIR)/s/ms-w32.h 356 $(CURDIR)/*.h $(CURDIR)/m/intel386.h $(CURDIR)/s/ms-w32.h
357 357
358TAGS-nmake: 358TAGS-nmake:
diff --git a/src/nsfns.m b/src/nsfns.m
index a09011d8461..23362433a39 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -101,6 +101,10 @@ extern BOOL ns_in_resize;
101static Lisp_Object as_script, *as_result; 101static Lisp_Object as_script, *as_result;
102static int as_status; 102static int as_status;
103 103
104#if GLYPH_DEBUG
105static ptrdiff_t image_cache_refcount;
106#endif
107
104/* ========================================================================== 108/* ==========================================================================
105 109
106 Internal utility functions 110 Internal utility functions
@@ -1038,6 +1042,41 @@ frame_parm_handler ns_frame_parm_handlers[] =
1038}; 1042};
1039 1043
1040 1044
1045/* Handler for signals raised during x_create_frame.
1046 FRAME is the frame which is partially constructed. */
1047
1048static Lisp_Object
1049unwind_create_frame (Lisp_Object frame)
1050{
1051 struct frame *f = XFRAME (frame);
1052
1053 /* If frame is already dead, nothing to do. This can happen if the
1054 display is disconnected after the frame has become official, but
1055 before x_create_frame removes the unwind protect. */
1056 if (!FRAME_LIVE_P (f))
1057 return Qnil;
1058
1059 /* If frame is ``official'', nothing to do. */
1060 if (!CONSP (Vframe_list) || !EQ (XCAR (Vframe_list), frame))
1061 {
1062#if GLYPH_DEBUG && XASSERTS
1063 struct ns_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
1064#endif
1065
1066 x_free_frame_resources (f);
1067 free_glyphs (f);
1068
1069#if GLYPH_DEBUG
1070 /* Check that reference counts are indeed correct. */
1071 xassert (dpyinfo->terminal->image_cache->refcount == image_cache_refcount);
1072#endif
1073 return Qt;
1074 }
1075
1076 return Qnil;
1077}
1078
1079
1041 1080
1042/* ========================================================================== 1081/* ==========================================================================
1043 1082
@@ -1047,46 +1086,50 @@ frame_parm_handler ns_frame_parm_handlers[] =
1047 1086
1048DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame, 1087DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
1049 1, 1, 0, 1088 1, 1, 0,
1050 doc: /* Make a new Nextstep window, called a \"frame\" in Emacs terms. 1089 doc: /* Make a new Nextstep window, called a "frame" in Emacs terms.
1051Return an Emacs frame object. 1090Return an Emacs frame object.
1052PARMS is an alist of frame parameters. 1091PARMS is an alist of frame parameters.
1053If the parameters specify that the frame should not have a minibuffer, 1092If the parameters specify that the frame should not have a minibuffer,
1054and do not specify a specific minibuffer window to use, 1093and do not specify a specific minibuffer window to use,
1055then `default-minibuffer-frame' must be a frame whose minibuffer can 1094then `default-minibuffer-frame' must be a frame whose minibuffer can
1056be shared by the new frame. */) 1095be shared by the new frame.
1096
1097This function is an internal primitive--use `make-frame' instead. */)
1057 (Lisp_Object parms) 1098 (Lisp_Object parms)
1058{ 1099{
1059 static int desc_ctr = 1;
1060 struct frame *f; 1100 struct frame *f;
1061 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
1062 Lisp_Object frame, tem; 1101 Lisp_Object frame, tem;
1063 Lisp_Object name; 1102 Lisp_Object name;
1064 int minibuffer_only = 0; 1103 int minibuffer_only = 0;
1104 int window_prompting = 0;
1105 int width, height;
1065 int count = specpdl_ptr - specpdl; 1106 int count = specpdl_ptr - specpdl;
1107 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
1066 Lisp_Object display; 1108 Lisp_Object display;
1067 struct ns_display_info *dpyinfo = NULL; 1109 struct ns_display_info *dpyinfo = NULL;
1068 Lisp_Object parent; 1110 Lisp_Object parent;
1069 struct kboard *kb; 1111 struct kboard *kb;
1070 Lisp_Object tfont, tfontsize; 1112 Lisp_Object tfont, tfontsize;
1071 int window_prompting = 0; 1113 static int desc_ctr = 1;
1072 int width, height;
1073 1114
1074 check_ns (); 1115 check_ns ();
1075 1116
1076 /* Seems a little strange, but other terms do it. Perhaps the code below 1117 /* x_get_arg modifies parms. */
1077 is modifying something? */
1078 parms = Fcopy_alist (parms); 1118 parms = Fcopy_alist (parms);
1079 1119
1120 /* Use this general default value to start with
1121 until we know if this frame has a specified name. */
1122 Vx_resource_name = Vinvocation_name;
1123
1080 display = x_get_arg (dpyinfo, parms, Qterminal, 0, 0, RES_TYPE_STRING); 1124 display = x_get_arg (dpyinfo, parms, Qterminal, 0, 0, RES_TYPE_STRING);
1081 if (EQ (display, Qunbound)) 1125 if (EQ (display, Qunbound))
1082 display = Qnil; 1126 display = Qnil;
1083 dpyinfo = check_ns_display_info (display); 1127 dpyinfo = check_ns_display_info (display);
1128 kb = dpyinfo->terminal->kboard;
1084 1129
1085 if (!dpyinfo->terminal->name) 1130 if (!dpyinfo->terminal->name)
1086 error ("Terminal is not live, can't create new frames on it"); 1131 error ("Terminal is not live, can't create new frames on it");
1087 1132
1088 kb = dpyinfo->terminal->kboard;
1089
1090 name = x_get_arg (dpyinfo, parms, Qname, 0, 0, RES_TYPE_STRING); 1133 name = x_get_arg (dpyinfo, parms, Qname, 0, 0, RES_TYPE_STRING);
1091 if (!STRINGP (name) 1134 if (!STRINGP (name)
1092 && ! EQ (name, Qunbound) 1135 && ! EQ (name, Qunbound)
@@ -1095,8 +1138,6 @@ be shared by the new frame. */)
1095 1138
1096 if (STRINGP (name)) 1139 if (STRINGP (name))
1097 Vx_resource_name = name; 1140 Vx_resource_name = name;
1098 else
1099 Vx_resource_name = Vinvocation_name;
1100 1141
1101 parent = x_get_arg (dpyinfo, parms, Qparent_id, 0, 0, RES_TYPE_NUMBER); 1142 parent = x_get_arg (dpyinfo, parms, Qparent_id, 0, 0, RES_TYPE_NUMBER);
1102 if (EQ (parent, Qunbound)) 1143 if (EQ (parent, Qunbound))
@@ -1104,57 +1145,36 @@ be shared by the new frame. */)
1104 if (! NILP (parent)) 1145 if (! NILP (parent))
1105 CHECK_NUMBER (parent); 1146 CHECK_NUMBER (parent);
1106 1147
1148 /* make_frame_without_minibuffer can run Lisp code and garbage collect. */
1149 /* No need to protect DISPLAY because that's not used after passing
1150 it to make_frame_without_minibuffer. */
1107 frame = Qnil; 1151 frame = Qnil;
1108 GCPRO4 (parms, parent, name, frame); 1152 GCPRO4 (parms, parent, name, frame);
1109
1110 tem = x_get_arg (dpyinfo, parms, Qminibuffer, "minibuffer", "Minibuffer", 1153 tem = x_get_arg (dpyinfo, parms, Qminibuffer, "minibuffer", "Minibuffer",
1111 RES_TYPE_SYMBOL); 1154 RES_TYPE_SYMBOL);
1112 if (EQ (tem, Qnone) || NILP (tem)) 1155 if (EQ (tem, Qnone) || NILP (tem))
1113 {
1114 f = make_frame_without_minibuffer (Qnil, kb, display); 1156 f = make_frame_without_minibuffer (Qnil, kb, display);
1115 }
1116 else if (EQ (tem, Qonly)) 1157 else if (EQ (tem, Qonly))
1117 { 1158 {
1118 f = make_minibuffer_frame (); 1159 f = make_minibuffer_frame ();
1119 minibuffer_only = 1; 1160 minibuffer_only = 1;
1120 } 1161 }
1121 else if (WINDOWP (tem)) 1162 else if (WINDOWP (tem))
1122 {
1123 f = make_frame_without_minibuffer (tem, kb, display); 1163 f = make_frame_without_minibuffer (tem, kb, display);
1124 }
1125 else 1164 else
1126 {
1127 f = make_frame (1); 1165 f = make_frame (1);
1128 }
1129
1130 /* Set the name; the functions to which we pass f expect the name to
1131 be set. */
1132 if (EQ (name, Qunbound) || NILP (name) || (XTYPE (name) != Lisp_String))
1133 {
1134 f->name = build_string ([ns_app_name UTF8String]);
1135 f->explicit_name =0;
1136 }
1137 else
1138 {
1139 f->name = name;
1140 f->explicit_name = 1;
1141 specbind (Qx_resource_name, name);
1142 }
1143 1166
1144 XSETFRAME (frame, f); 1167 XSETFRAME (frame, f);
1145 FRAME_CAN_HAVE_SCROLL_BARS (f) = 1; 1168 FRAME_CAN_HAVE_SCROLL_BARS (f) = 1;
1146 1169
1147 f->terminal = dpyinfo->terminal; 1170 f->terminal = dpyinfo->terminal;
1148 f->terminal->reference_count++;
1149 1171
1150 f->output_method = output_ns; 1172 f->output_method = output_ns;
1151 f->output_data.ns = (struct ns_output *)xmalloc (sizeof *(f->output_data.ns)); 1173 f->output_data.ns = (struct ns_output *)xmalloc (sizeof *(f->output_data.ns));
1152 memset (f->output_data.ns, 0, sizeof (*(f->output_data.ns))); 1174 memset (f->output_data.ns, 0, sizeof *(f->output_data.ns));
1153 1175
1154 FRAME_FONTSET (f) = -1; 1176 FRAME_FONTSET (f) = -1;
1155 1177
1156 /* record_unwind_protect (unwind_create_frame, frame); safety; maybe later? */
1157
1158 f->icon_name = x_get_arg (dpyinfo, parms, Qicon_name, "iconName", "Title", 1178 f->icon_name = x_get_arg (dpyinfo, parms, Qicon_name, "iconName", "Title",
1159 RES_TYPE_STRING); 1179 RES_TYPE_STRING);
1160 if (! STRINGP (f->icon_name)) 1180 if (! STRINGP (f->icon_name))
@@ -1162,6 +1182,9 @@ be shared by the new frame. */)
1162 1182
1163 FRAME_NS_DISPLAY_INFO (f) = dpyinfo; 1183 FRAME_NS_DISPLAY_INFO (f) = dpyinfo;
1164 1184
1185 /* With FRAME_NS_DISPLAY_INFO set up, this unwind-protect is safe. */
1186 record_unwind_protect (unwind_create_frame, frame);
1187
1165 f->output_data.ns->window_desc = desc_ctr++; 1188 f->output_data.ns->window_desc = desc_ctr++;
1166 if (!NILP (parent)) 1189 if (!NILP (parent))
1167 { 1190 {
@@ -1174,6 +1197,20 @@ be shared by the new frame. */)
1174 f->output_data.ns->explicit_parent = 0; 1197 f->output_data.ns->explicit_parent = 0;
1175 } 1198 }
1176 1199
1200 /* Set the name; the functions to which we pass f expect the name to
1201 be set. */
1202 if (EQ (name, Qunbound) || NILP (name) || ! STRINGP (name))
1203 {
1204 f->name = build_string ([ns_app_name UTF8String]);
1205 f->explicit_name = 0;
1206 }
1207 else
1208 {
1209 f->name = name;
1210 f->explicit_name = 1;
1211 specbind (Qx_resource_name, name);
1212 }
1213
1177 f->resx = dpyinfo->resx; 1214 f->resx = dpyinfo->resx;
1178 f->resy = dpyinfo->resy; 1215 f->resy = dpyinfo->resy;
1179 1216
@@ -1223,11 +1260,15 @@ be shared by the new frame. */)
1223 "leftFringe", "LeftFringe", RES_TYPE_NUMBER); 1260 "leftFringe", "LeftFringe", RES_TYPE_NUMBER);
1224 x_default_parameter (f, parms, Qright_fringe, Qnil, 1261 x_default_parameter (f, parms, Qright_fringe, Qnil,
1225 "rightFringe", "RightFringe", RES_TYPE_NUMBER); 1262 "rightFringe", "RightFringe", RES_TYPE_NUMBER);
1226 /* end PENDING */
1227 1263
1228 init_frame_faces (f); 1264#if GLYPH_DEBUG
1265 image_cache_refcount =
1266 FRAME_IMAGE_CACHE (f) ? FRAME_IMAGE_CACHE (f)->refcount : 0;
1267#endif
1229 1268
1230 /* The X resources controlling the menu-bar and tool-bar are 1269 init_frame_faces (f);
1270
1271 /* The resources controlling the menu-bar and tool-bar are
1231 processed specially at startup, and reflected in the mode 1272 processed specially at startup, and reflected in the mode
1232 variables; ignore them here. */ 1273 variables; ignore them here. */
1233 x_default_parameter (f, parms, Qmenu_bar_lines, 1274 x_default_parameter (f, parms, Qmenu_bar_lines,
@@ -1244,38 +1285,6 @@ be shared by the new frame. */)
1244 x_default_parameter (f, parms, Qtitle, Qnil, "title", "Title", 1285 x_default_parameter (f, parms, Qtitle, Qnil, "title", "Title",
1245 RES_TYPE_STRING); 1286 RES_TYPE_STRING);
1246 1287
1247/* TODO: other terms seem to get away w/o this complexity.. */
1248 if (NILP (Fassq (Qwidth, parms)))
1249 {
1250 Lisp_Object value
1251 = x_get_arg (dpyinfo, parms, Qwidth, "width", "Width",
1252 RES_TYPE_NUMBER);
1253 if (! EQ (value, Qunbound))
1254 parms = Fcons (Fcons (Qwidth, value), parms);
1255 }
1256 if (NILP (Fassq (Qheight, parms)))
1257 {
1258 Lisp_Object value
1259 = x_get_arg (dpyinfo, parms, Qheight, "height", "Height",
1260 RES_TYPE_NUMBER);
1261 if (! EQ (value, Qunbound))
1262 parms = Fcons (Fcons (Qheight, value), parms);
1263 }
1264 if (NILP (Fassq (Qleft, parms)))
1265 {
1266 Lisp_Object value
1267 = x_get_arg (dpyinfo, parms, Qleft, "left", "Left", RES_TYPE_NUMBER);
1268 if (! EQ (value, Qunbound))
1269 parms = Fcons (Fcons (Qleft, value), parms);
1270 }
1271 if (NILP (Fassq (Qtop, parms)))
1272 {
1273 Lisp_Object value
1274 = x_get_arg (dpyinfo, parms, Qtop, "top", "Top", RES_TYPE_NUMBER);
1275 if (! EQ (value, Qunbound))
1276 parms = Fcons (Fcons (Qtop, value), parms);
1277 }
1278
1279 window_prompting = x_figure_window_size (f, parms, 1); 1288 window_prompting = x_figure_window_size (f, parms, 1);
1280 1289
1281 tem = x_get_arg (dpyinfo, parms, Qunsplittable, 0, 0, RES_TYPE_BOOLEAN); 1290 tem = x_get_arg (dpyinfo, parms, Qunsplittable, 0, 0, RES_TYPE_BOOLEAN);
@@ -1297,23 +1306,27 @@ be shared by the new frame. */)
1297 1306
1298 x_icon (f, parms); 1307 x_icon (f, parms);
1299 1308
1309 /* ns_display_info does not have a reference_count. */
1310 f->terminal->reference_count++;
1311
1300 /* It is now ok to make the frame official even if we get an error below. 1312 /* It is now ok to make the frame official even if we get an error below.
1301 The frame needs to be on Vframe_list or making it visible won't work. */ 1313 The frame needs to be on Vframe_list or making it visible won't work. */
1302 Vframe_list = Fcons (frame, Vframe_list); 1314 Vframe_list = Fcons (frame, Vframe_list);
1303 /*FRAME_NS_DISPLAY_INFO (f)->reference_count++; */ 1315
1304 1316 x_default_parameter (f, parms, Qicon_type, Qnil,
1305 x_default_parameter (f, parms, Qicon_type, Qnil, "bitmapIcon", "BitmapIcon", 1317 "bitmapIcon", "BitmapIcon", RES_TYPE_SYMBOL);
1306 RES_TYPE_SYMBOL); 1318
1307 x_default_parameter (f, parms, Qauto_raise, Qnil, "autoRaise", "AutoRaiseLower", 1319 x_default_parameter (f, parms, Qauto_raise, Qnil,
1308 RES_TYPE_BOOLEAN); 1320 "autoRaise", "AutoRaiseLower", RES_TYPE_BOOLEAN);
1309 x_default_parameter (f, parms, Qauto_lower, Qnil, "autoLower", "AutoLower", 1321 x_default_parameter (f, parms, Qauto_lower, Qnil,
1310 RES_TYPE_BOOLEAN); 1322 "autoLower", "AutoLower", RES_TYPE_BOOLEAN);
1311 x_default_parameter (f, parms, Qcursor_type, Qbox, "cursorType", "CursorType", 1323 x_default_parameter (f, parms, Qcursor_type, Qbox,
1312 RES_TYPE_SYMBOL); 1324 "cursorType", "CursorType", RES_TYPE_SYMBOL);
1313 x_default_parameter (f, parms, Qscroll_bar_width, Qnil, "scrollBarWidth", 1325 x_default_parameter (f, parms, Qscroll_bar_width, Qnil,
1314 "ScrollBarWidth", RES_TYPE_NUMBER); 1326 "scrollBarWidth", "ScrollBarWidth",
1315 x_default_parameter (f, parms, Qalpha, Qnil, "alpha", "Alpha", 1327 RES_TYPE_NUMBER);
1316 RES_TYPE_NUMBER); 1328 x_default_parameter (f, parms, Qalpha, Qnil,
1329 "alpha", "Alpha", RES_TYPE_NUMBER);
1317 1330
1318 width = FRAME_COLS (f); 1331 width = FRAME_COLS (f);
1319 height = FRAME_LINES (f); 1332 height = FRAME_LINES (f);
@@ -1324,20 +1337,24 @@ be shared by the new frame. */)
1324 1337
1325 if (! f->output_data.ns->explicit_parent) 1338 if (! f->output_data.ns->explicit_parent)
1326 { 1339 {
1327 tem = x_get_arg (dpyinfo, parms, Qvisibility, 0, 0, RES_TYPE_SYMBOL); 1340 Lisp_Object visibility;
1328 if (EQ (tem, Qunbound)) 1341
1329 tem = Qt; 1342 visibility = x_get_arg (dpyinfo, parms, Qvisibility, 0, 0,
1330 x_set_visibility (f, tem, Qnil); 1343 RES_TYPE_SYMBOL);
1331 if (EQ (tem, Qicon)) 1344 if (EQ (visibility, Qunbound))
1345 visibility = Qt;
1346
1347 if (EQ (visibility, Qicon))
1332 x_iconify_frame (f); 1348 x_iconify_frame (f);
1333 else if (! NILP (tem)) 1349 else if (! NILP (visibility))
1334 { 1350 {
1335 x_make_frame_visible (f); 1351 x_make_frame_visible (f);
1336 f->async_visible = 1;
1337 [[FRAME_NS_VIEW (f) window] makeKeyWindow]; 1352 [[FRAME_NS_VIEW (f) window] makeKeyWindow];
1338 } 1353 }
1339 else 1354 else
1340 f->async_visible = 0; 1355 {
1356 /* Must have been Qnil. */
1357 }
1341 } 1358 }
1342 1359
1343 if (FRAME_HAS_MINIBUF_P (f) 1360 if (FRAME_HAS_MINIBUF_P (f)
@@ -1352,6 +1369,9 @@ be shared by the new frame. */)
1352 f->param_alist = Fcons (XCAR (tem), f->param_alist); 1369 f->param_alist = Fcons (XCAR (tem), f->param_alist);
1353 1370
1354 UNGCPRO; 1371 UNGCPRO;
1372
1373 /* Make sure windows on this frame appear in calls to next-window
1374 and similar functions. */
1355 Vwindow_list = Qnil; 1375 Vwindow_list = Qnil;
1356 1376
1357 return unbind_to (count, frame); 1377 return unbind_to (count, frame);
diff --git a/src/nsterm.m b/src/nsterm.m
index a2ae5e69512..3d3723fc28c 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -164,7 +164,7 @@ static Lisp_Object last_mouse_motion_frame;
164static EmacsScroller *last_mouse_scroll_bar = nil; 164static EmacsScroller *last_mouse_scroll_bar = nil;
165static struct frame *ns_updating_frame; 165static struct frame *ns_updating_frame;
166static NSView *focus_view = NULL; 166static NSView *focus_view = NULL;
167static int ns_window_num =0; 167static int ns_window_num = 0;
168static NSRect uRect; 168static NSRect uRect;
169static BOOL gsaved = NO; 169static BOOL gsaved = NO;
170BOOL ns_in_resize = NO; 170BOOL ns_in_resize = NO;
@@ -1123,12 +1123,10 @@ x_iconify_frame (struct frame *f)
1123 [[view window] miniaturize: NSApp]; 1123 [[view window] miniaturize: NSApp];
1124} 1124}
1125 1125
1126/* Free X resources of frame F. */
1126 1127
1127void 1128void
1128x_destroy_window (struct frame *f) 1129x_free_frame_resources (struct frame *f)
1129/* --------------------------------------------------------------------------
1130 External: Delete the window
1131 -------------------------------------------------------------------------- */
1132{ 1130{
1133 NSView *view = FRAME_NS_VIEW (f); 1131 NSView *view = FRAME_NS_VIEW (f);
1134 struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (f); 1132 struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (f);
@@ -1163,10 +1161,21 @@ x_destroy_window (struct frame *f)
1163 [[view window] close]; 1161 [[view window] close];
1164 [view release]; 1162 [view release];
1165 1163
1166 ns_window_num--;
1167 UNBLOCK_INPUT; 1164 UNBLOCK_INPUT;
1168} 1165}
1169 1166
1167void
1168x_destroy_window (struct frame *f)
1169/* --------------------------------------------------------------------------
1170 External: Delete the window
1171 -------------------------------------------------------------------------- */
1172{
1173 NSTRACE (x_destroy_window);
1174 check_ns ();
1175 x_free_frame_resources (f);
1176 ns_window_num--;
1177}
1178
1170 1179
1171void 1180void
1172x_set_offset (struct frame *f, int xoff, int yoff, int change_grav) 1181x_set_offset (struct frame *f, int xoff, int yoff, int change_grav)
diff --git a/src/process.c b/src/process.c
index c316139a713..301274676d6 100644
--- a/src/process.c
+++ b/src/process.c
@@ -5387,6 +5387,7 @@ send_process (volatile Lisp_Object proc, const char *volatile buf,
5387 } 5387 }
5388 else 5388 else
5389 { 5389 {
5390 coding->src_multibyte = 0;
5390 /* For sending a unibyte text, character code conversion should 5391 /* For sending a unibyte text, character code conversion should
5391 not take place but EOL conversion should. So, setup raw-text 5392 not take place but EOL conversion should. So, setup raw-text
5392 or one of the subsidiary if we have not yet done it. */ 5393 or one of the subsidiary if we have not yet done it. */
diff --git a/src/regex.c b/src/regex.c
index 8033ab9edaa..ccbad58abb3 100644
--- a/src/regex.c
+++ b/src/regex.c
@@ -530,7 +530,11 @@ init_syntax_once (void)
530#define MIN(a, b) ((a) < (b) ? (a) : (b)) 530#define MIN(a, b) ((a) < (b) ? (a) : (b))
531 531
532/* Type of source-pattern and string chars. */ 532/* Type of source-pattern and string chars. */
533#ifdef _MSC_VER
534typedef unsigned char re_char;
535#else
533typedef const unsigned char re_char; 536typedef const unsigned char re_char;
537#endif
534 538
535typedef char boolean; 539typedef char boolean;
536#define false 0 540#define false 0
diff --git a/src/s/ms-w32.h b/src/s/ms-w32.h
index 813c3cef115..fb0882860d1 100644
--- a/src/s/ms-w32.h
+++ b/src/s/ms-w32.h
@@ -86,6 +86,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
86#define IS_ANY_SEP(_c_) (IS_DIRECTORY_SEP (_c_) || IS_DEVICE_SEP (_c_)) 86#define IS_ANY_SEP(_c_) (IS_DIRECTORY_SEP (_c_) || IS_DEVICE_SEP (_c_))
87 87
88#include <sys/types.h> 88#include <sys/types.h>
89
90#ifdef _MSC_VER
91typedef unsigned long sigset_t;
92typedef int ssize_t;
93#endif
94
89struct sigaction { 95struct sigaction {
90 int sa_flags; 96 int sa_flags;
91 void (*sa_handler)(int); 97 void (*sa_handler)(int);
@@ -181,6 +187,17 @@ struct sigaction {
181 187
182#ifdef emacs 188#ifdef emacs
183 189
190#ifdef _MSC_VER
191#include <sys/timeb.h>
192#include <sys/stat.h>
193#include <signal.h>
194
195/* MSVC gets link-time errors without these redirections. */
196#define fstat(a, b) sys_fstat(a, b)
197#define stat(a, b) sys_stat(a, b)
198#define utime sys_utime
199#endif
200
184/* Calls that are emulated or shadowed. */ 201/* Calls that are emulated or shadowed. */
185#undef access 202#undef access
186#define access sys_access 203#define access sys_access
@@ -267,6 +284,7 @@ typedef int pid_t;
267 284
268#if !defined (_MSC_VER) || (_MSC_VER < 1400) 285#if !defined (_MSC_VER) || (_MSC_VER < 1400)
269#define tzname _tzname 286#define tzname _tzname
287#undef utime
270#define utime _utime 288#define utime _utime
271#endif 289#endif
272 290
@@ -317,13 +335,17 @@ extern char *get_emacs_configuration_options (void);
317#define _WINSOCK_H 335#define _WINSOCK_H
318 336
319/* Defines size_t and alloca (). */ 337/* Defines size_t and alloca (). */
320#ifdef USE_CRT_DLL 338#if (defined(_MSC_VER) && defined(emacs)) || defined(USE_CRT_DLL)
321#define malloc e_malloc 339#define malloc e_malloc
322#define free e_free 340#define free e_free
323#define realloc e_realloc 341#define realloc e_realloc
324#define calloc e_calloc 342#define calloc e_calloc
325#endif 343#endif
344#ifdef _MSC_VER
345#define alloca _alloca
346#else
326#include <malloc.h> 347#include <malloc.h>
348#endif
327 349
328#include <sys/stat.h> 350#include <sys/stat.h>
329 351
diff --git a/src/w32.c b/src/w32.c
index 42546fc8d49..f17e987f437 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -94,7 +94,9 @@ typedef struct _MEMORY_STATUS_EX {
94 94
95#include <tlhelp32.h> 95#include <tlhelp32.h>
96#include <psapi.h> 96#include <psapi.h>
97#ifndef _MSC_VER
97#include <w32api.h> 98#include <w32api.h>
99#endif
98#if !defined (__MINGW32__) || __W32API_MAJOR_VERSION < 3 || (__W32API_MAJOR_VERSION == 3 && __W32API_MINOR_VERSION < 15) 100#if !defined (__MINGW32__) || __W32API_MAJOR_VERSION < 3 || (__W32API_MAJOR_VERSION == 3 && __W32API_MINOR_VERSION < 15)
99/* This either is not in psapi.h or guarded by higher value of 101/* This either is not in psapi.h or guarded by higher value of
100 _WIN32_WINNT than what we use. w32api supplied with MinGW 3.15 102 _WIN32_WINNT than what we use. w32api supplied with MinGW 3.15
@@ -1547,7 +1549,12 @@ init_environment (char ** argv)
1547 read-only filesystem, like CD-ROM or a write-protected floppy. 1549 read-only filesystem, like CD-ROM or a write-protected floppy.
1548 The only way to be really sure is to actually create a file and 1550 The only way to be really sure is to actually create a file and
1549 see if it succeeds. But I think that's too much to ask. */ 1551 see if it succeeds. But I think that's too much to ask. */
1552#ifdef _MSC_VER
1553 /* MSVC's _access crashes with D_OK. */
1554 if (tmp && sys_access (tmp, D_OK) == 0)
1555#else
1550 if (tmp && _access (tmp, D_OK) == 0) 1556 if (tmp && _access (tmp, D_OK) == 0)
1557#endif
1551 { 1558 {
1552 char * var = alloca (strlen (tmp) + 8); 1559 char * var = alloca (strlen (tmp) + 8);
1553 sprintf (var, "TMPDIR=%s", tmp); 1560 sprintf (var, "TMPDIR=%s", tmp);
diff --git a/src/w32fns.c b/src/w32fns.c
index f7ba1c59e7b..6f32442514a 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -140,8 +140,8 @@ struct MONITOR_INFO
140 DWORD dwFlags; 140 DWORD dwFlags;
141}; 141};
142 142
143/* Reportedly, VS 6 does not have this in its headers. */ 143/* Reportedly, MSVC does not have this in its headers. */
144#if defined (_MSC_VER) && _MSC_VER < 1300 144#ifdef _MSC_VER
145DECLARE_HANDLE(HMONITOR); 145DECLARE_HANDLE(HMONITOR);
146#endif 146#endif
147 147
@@ -3977,7 +3977,7 @@ x_make_gc (struct frame *f)
3977 3977
3978 3978
3979/* Handler for signals raised during x_create_frame and 3979/* Handler for signals raised during x_create_frame and
3980 x_create_top_frame. FRAME is the frame which is partially 3980 x_create_tip_frame. FRAME is the frame which is partially
3981 constructed. */ 3981 constructed. */
3982 3982
3983static Lisp_Object 3983static Lisp_Object
@@ -4135,7 +4135,6 @@ This function is an internal primitive--use `make-frame' instead. */)
4135 FRAME_CONFIG_SCROLL_BAR_WIDTH (f) = GetSystemMetrics (SM_CXVSCROLL); 4135 FRAME_CONFIG_SCROLL_BAR_WIDTH (f) = GetSystemMetrics (SM_CXVSCROLL);
4136 4136
4137 f->terminal = dpyinfo->terminal; 4137 f->terminal = dpyinfo->terminal;
4138 f->terminal->reference_count++;
4139 4138
4140 f->output_method = output_w32; 4139 f->output_method = output_w32;
4141 f->output_data.w32 = 4140 f->output_data.w32 =
@@ -4154,7 +4153,8 @@ This function is an internal primitive--use `make-frame' instead. */)
4154 /* With FRAME_X_DISPLAY_INFO set up, this unwind-protect is safe. */ 4153 /* With FRAME_X_DISPLAY_INFO set up, this unwind-protect is safe. */
4155 record_unwind_protect (unwind_create_frame, frame); 4154 record_unwind_protect (unwind_create_frame, frame);
4156#if GLYPH_DEBUG 4155#if GLYPH_DEBUG
4157 image_cache_refcount = FRAME_IMAGE_CACHE (f)->refcount; 4156 image_cache_refcount =
4157 FRAME_IMAGE_CACHE (f) ? FRAME_IMAGE_CACHE (f)->refcount : 0;
4158 dpyinfo_refcount = dpyinfo->reference_count; 4158 dpyinfo_refcount = dpyinfo->reference_count;
4159#endif /* GLYPH_DEBUG */ 4159#endif /* GLYPH_DEBUG */
4160 4160
@@ -4287,6 +4287,7 @@ This function is an internal primitive--use `make-frame' instead. */)
4287 x_make_gc (f); 4287 x_make_gc (f);
4288 4288
4289 /* Now consider the frame official. */ 4289 /* Now consider the frame official. */
4290 f->terminal->reference_count++;
4290 FRAME_W32_DISPLAY_INFO (f)->reference_count++; 4291 FRAME_W32_DISPLAY_INFO (f)->reference_count++;
4291 Vframe_list = Fcons (frame, Vframe_list); 4292 Vframe_list = Fcons (frame, Vframe_list);
4292 4293
@@ -5229,7 +5230,6 @@ x_create_tip_frame (struct w32_display_info *dpyinfo,
5229 from this point on, x_destroy_window might screw up reference 5230 from this point on, x_destroy_window might screw up reference
5230 counts etc. */ 5231 counts etc. */
5231 f->terminal = dpyinfo->terminal; 5232 f->terminal = dpyinfo->terminal;
5232 f->terminal->reference_count++;
5233 f->output_method = output_w32; 5233 f->output_method = output_w32;
5234 f->output_data.w32 = 5234 f->output_data.w32 =
5235 (struct w32_output *) xmalloc (sizeof (struct w32_output)); 5235 (struct w32_output *) xmalloc (sizeof (struct w32_output));
@@ -5239,7 +5239,8 @@ x_create_tip_frame (struct w32_display_info *dpyinfo,
5239 f->icon_name = Qnil; 5239 f->icon_name = Qnil;
5240 5240
5241#if GLYPH_DEBUG 5241#if GLYPH_DEBUG
5242 image_cache_refcount = FRAME_IMAGE_CACHE (f)->refcount; 5242 image_cache_refcount =
5243 FRAME_IMAGE_CACHE ? FRAME_IMAGE_CACHE (f)->refcount : 0;
5243 dpyinfo_refcount = dpyinfo->reference_count; 5244 dpyinfo_refcount = dpyinfo->reference_count;
5244#endif /* GLYPH_DEBUG */ 5245#endif /* GLYPH_DEBUG */
5245 FRAME_KBOARD (f) = kb; 5246 FRAME_KBOARD (f) = kb;
@@ -5380,15 +5381,16 @@ x_create_tip_frame (struct w32_display_info *dpyinfo,
5380 5381
5381 UNGCPRO; 5382 UNGCPRO;
5382 5383
5384 /* Now that the frame is official, it counts as a reference to
5385 its display. */
5386 FRAME_W32_DISPLAY_INFO (f)->reference_count++;
5387 f->terminal->reference_count++;
5388
5383 /* It is now ok to make the frame official even if we get an error 5389 /* It is now ok to make the frame official even if we get an error
5384 below. And the frame needs to be on Vframe_list or making it 5390 below. And the frame needs to be on Vframe_list or making it
5385 visible won't work. */ 5391 visible won't work. */
5386 Vframe_list = Fcons (frame, Vframe_list); 5392 Vframe_list = Fcons (frame, Vframe_list);
5387 5393
5388 /* Now that the frame is official, it counts as a reference to
5389 its display. */
5390 FRAME_W32_DISPLAY_INFO (f)->reference_count++;
5391
5392 /* Setting attributes of faces of the tooltip frame from resources 5394 /* Setting attributes of faces of the tooltip frame from resources
5393 and similar will increment face_change_count, which leads to the 5395 and similar will increment face_change_count, which leads to the
5394 clearing of all current matrices. Since this isn't necessary 5396 clearing of all current matrices. Since this isn't necessary
diff --git a/src/w32font.c b/src/w32font.c
index 6c1b4d0bc20..26bf4207de5 100644
--- a/src/w32font.c
+++ b/src/w32font.c
@@ -1292,6 +1292,15 @@ font_matches_spec (DWORD type, NEWTEXTMETRICEX *font,
1292 = font_supported_scripts (&font->ntmFontSig); 1292 = font_supported_scripts (&font->ntmFontSig);
1293 if (! memq_no_quit (val, support)) 1293 if (! memq_no_quit (val, support))
1294 return 0; 1294 return 0;
1295
1296 /* Avoid using non-Japanese fonts for Japanese, even
1297 if they claim they are capable, due to known
1298 breakage in Vista and Windows 7 fonts
1299 (bug#6029). */
1300 if (EQ (val, Qkana)
1301 && (font->ntmTm.tmCharSet != SHIFTJIS_CHARSET
1302 || !(font->ntmFontSig.fsCsb[0] & CSB_JAPANESE)))
1303 return 0;
1295 } 1304 }
1296 else 1305 else
1297 { 1306 {
@@ -1507,7 +1516,7 @@ add_font_entity_to_list (ENUMLOGFONTEX *logical_font,
1507 /* For uniscribe backend, consider only truetype or opentype fonts 1516 /* For uniscribe backend, consider only truetype or opentype fonts
1508 that have some unicode coverage. */ 1517 that have some unicode coverage. */
1509 if (match_data->opentype_only 1518 if (match_data->opentype_only
1510 && ((!physical_font->ntmTm.ntmFlags & NTMFLAGS_OPENTYPE 1519 && ((!(physical_font->ntmTm.ntmFlags & NTMFLAGS_OPENTYPE)
1511 && !(font_type & TRUETYPE_FONTTYPE)) 1520 && !(font_type & TRUETYPE_FONTTYPE))
1512 || !is_unicode)) 1521 || !is_unicode))
1513 return 1; 1522 return 1;
@@ -1568,8 +1577,8 @@ add_font_entity_to_list (ENUMLOGFONTEX *logical_font,
1568 the bits for CJK ranges that include those characters. */ 1577 the bits for CJK ranges that include those characters. */
1569 else if (EQ (spec_charset, Qunicode_sip)) 1578 else if (EQ (spec_charset, Qunicode_sip))
1570 { 1579 {
1571 if (!physical_font->ntmFontSig.fsUsb[1] & 0x02000000 1580 if (!(physical_font->ntmFontSig.fsUsb[1] & 0x02000000)
1572 || !physical_font->ntmFontSig.fsUsb[1] & 0x28000000) 1581 || !(physical_font->ntmFontSig.fsUsb[1] & 0x28000000))
1573 return 1; 1582 return 1;
1574 } 1583 }
1575 1584
@@ -1577,8 +1586,16 @@ add_font_entity_to_list (ENUMLOGFONTEX *logical_font,
1577 1586
1578 /* If registry was specified, ensure it is reported as the same. */ 1587 /* If registry was specified, ensure it is reported as the same. */
1579 if (!NILP (spec_charset)) 1588 if (!NILP (spec_charset))
1580 ASET (entity, FONT_REGISTRY_INDEX, spec_charset); 1589 {
1581 1590 /* Avoid using non-Japanese fonts for Japanese, even if they
1591 claim they are capable, due to known breakage in Vista
1592 and Windows 7 fonts (bug#6029). */
1593 if (logical_font->elfLogFont.lfCharSet == SHIFTJIS_CHARSET
1594 && !(physical_font->ntmFontSig.fsCsb[0] & CSB_JAPANESE))
1595 return 1;
1596 else
1597 ASET (entity, FONT_REGISTRY_INDEX, spec_charset);
1598 }
1582 /* Otherwise if using the uniscribe backend, report ANSI and DEFAULT 1599 /* Otherwise if using the uniscribe backend, report ANSI and DEFAULT
1583 fonts as unicode and skip other charsets. */ 1600 fonts as unicode and skip other charsets. */
1584 else if (match_data->opentype_only) 1601 else if (match_data->opentype_only)
diff --git a/src/w32term.c b/src/w32term.c
index 39f1e245e18..f876cff0363 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -5690,15 +5690,15 @@ x_make_frame_visible (struct frame *f)
5690 5690
5691 f->output_data.w32->asked_for_visible = 1; 5691 f->output_data.w32->asked_for_visible = 1;
5692 5692
5693 /* The first of these seems to give more expected behavior, but 5693 /* According to a report in emacs-devel 2008-06-03, SW_SHOWNORMAL
5694 was added as a commented out line in Sept 1997, with the 5694 causes unexpected behaviour when unminimizing frames that were
5695 second version remaining uncommented. There may have been 5695 previously maximised. But only SW_SHOWNORMAL works properly for
5696 some problem with it that led to it not being enabled, 5696 frames that were truely hidden (using make-frame-invisible), so
5697 so the old version remains commented out below in case we 5697 we need it to avoid Bug#5482. It seems that async_iconified
5698 decide we need to go back to it [23.0.60 2008-06-09]. */ 5698 is only set for minimised windows that are still visible, so
5699 use that to determine the appropriate flag to pass ShowWindow. */
5699 my_show_window (f, FRAME_W32_WINDOW (f), 5700 my_show_window (f, FRAME_W32_WINDOW (f),
5700 f->async_iconified ? SW_RESTORE : SW_SHOW); 5701 f->async_iconified ? SW_RESTORE : SW_SHOWNORMAL);
5701 /* my_show_window (f, FRAME_W32_WINDOW (f), SW_SHOWNORMAL); */
5702 } 5702 }
5703 5703
5704 /* Synchronize to ensure Emacs knows the frame is visible 5704 /* Synchronize to ensure Emacs knows the frame is visible
diff --git a/src/window.c b/src/window.c
index 496a4e6c6ea..5cc77fb8f02 100644
--- a/src/window.c
+++ b/src/window.c
@@ -161,7 +161,8 @@ DEFUN ("windowp", Fwindowp, Swindowp, 1, 1, 0,
161 161
162DEFUN ("window-live-p", Fwindow_live_p, Swindow_live_p, 1, 1, 0, 162DEFUN ("window-live-p", Fwindow_live_p, Swindow_live_p, 1, 1, 0,
163 doc: /* Return t if OBJECT is a live window and nil otherwise. 163 doc: /* Return t if OBJECT is a live window and nil otherwise.
164A live window is a window that displays a buffer. */) 164A live window is a window that displays a buffer.
165Internal windows and deleted windows are not live. */)
165 (Lisp_Object object) 166 (Lisp_Object object)
166{ 167{
167 return WINDOW_LIVE_P (object) ? Qt : Qnil; 168 return WINDOW_LIVE_P (object) ? Qt : Qnil;
@@ -170,7 +171,7 @@ A live window is a window that displays a buffer. */)
170/* Frames and windows. */ 171/* Frames and windows. */
171DEFUN ("window-frame", Fwindow_frame, Swindow_frame, 1, 1, 0, 172DEFUN ("window-frame", Fwindow_frame, Swindow_frame, 1, 1, 0,
172 doc: /* Return the frame that window WINDOW is on. 173 doc: /* Return the frame that window WINDOW is on.
173WINDOW can be any window and defaults to the selected one. */) 174If WINDOW is omitted or nil, it defaults to the selected window. */)
174 (Lisp_Object window) 175 (Lisp_Object window)
175{ 176{
176 return decode_any_window (window)->frame; 177 return decode_any_window (window)->frame;
@@ -179,9 +180,8 @@ WINDOW can be any window and defaults to the selected one. */)
179DEFUN ("frame-root-window", Fframe_root_window, Sframe_root_window, 0, 1, 0, 180DEFUN ("frame-root-window", Fframe_root_window, Sframe_root_window, 0, 1, 0,
180 doc: /* Return the root window of FRAME-OR-WINDOW. 181 doc: /* Return the root window of FRAME-OR-WINDOW.
181If omitted, FRAME-OR-WINDOW defaults to the currently selected frame. 182If omitted, FRAME-OR-WINDOW defaults to the currently selected frame.
182Else if FRAME-OR-WINDOW denotes any window, return the root window of 183With a frame argument, return that frame's root window.
183that window's frame. If FRAME-OR-WINDOW denotes a live frame, return 184With a window argument, return the root window of that window's frame. */)
184the root window of that frame. */)
185 (Lisp_Object frame_or_window) 185 (Lisp_Object frame_or_window)
186{ 186{
187 Lisp_Object window; 187 Lisp_Object window;
@@ -200,9 +200,8 @@ the root window of that frame. */)
200} 200}
201 201
202DEFUN ("minibuffer-window", Fminibuffer_window, Sminibuffer_window, 0, 1, 0, 202DEFUN ("minibuffer-window", Fminibuffer_window, Sminibuffer_window, 0, 1, 0,
203 doc: /* Return the window used now for minibuffers. 203 doc: /* Return the minibuffer window for frame FRAME.
204If the optional argument FRAME is specified, return the minibuffer window 204If FRAME is omitted or nil, it defaults to the selected frame. */)
205used by that frame. */)
206 (Lisp_Object frame) 205 (Lisp_Object frame)
207{ 206{
208 if (NILP (frame)) 207 if (NILP (frame))
@@ -214,7 +213,7 @@ used by that frame. */)
214DEFUN ("window-minibuffer-p", Fwindow_minibuffer_p, 213DEFUN ("window-minibuffer-p", Fwindow_minibuffer_p,
215 Swindow_minibuffer_p, 0, 1, 0, 214 Swindow_minibuffer_p, 0, 1, 0,
216 doc: /* Return non-nil if WINDOW is a minibuffer window. 215 doc: /* Return non-nil if WINDOW is a minibuffer window.
217WINDOW can be any window and defaults to the selected one. */) 216If WINDOW is omitted or nil, it defaults to the selected window. */)
218 (Lisp_Object window) 217 (Lisp_Object window)
219{ 218{
220 return MINI_WINDOW_P (decode_any_window (window)) ? Qt : Qnil; 219 return MINI_WINDOW_P (decode_any_window (window)) ? Qt : Qnil;
@@ -411,44 +410,48 @@ buffer of the selected window before each command. */)
411} 410}
412 411
413DEFUN ("window-buffer", Fwindow_buffer, Swindow_buffer, 0, 1, 0, 412DEFUN ("window-buffer", Fwindow_buffer, Swindow_buffer, 0, 1, 0,
414 doc: /* Return the buffer that WINDOW is displaying. 413 doc: /* Return the buffer displayed in window WINDOW.
415WINDOW can be any window and defaults to the selected one. 414If WINDOW is omitted or nil, it defaults to the selected window.
416If WINDOW is an internal window return nil. */) 415Return nil for an internal window or a deleted window. */)
417 (Lisp_Object window) 416 (Lisp_Object window)
418{ 417{
419 return decode_any_window (window)->buffer; 418 return decode_any_window (window)->buffer;
420} 419}
421 420
422DEFUN ("window-parent", Fwindow_parent, Swindow_parent, 0, 1, 0, 421DEFUN ("window-parent", Fwindow_parent, Swindow_parent, 0, 1, 0,
423 doc: /* Return WINDOW's parent window. 422 doc: /* Return the parent window of window WINDOW.
424WINDOW can be any window and defaults to the selected one. 423If WINDOW is omitted or nil, it defaults to the selected window.
425Return nil if WINDOW has no parent. */) 424Return nil for a window with no parent (e.g. a root window). */)
426 (Lisp_Object window) 425 (Lisp_Object window)
427{ 426{
428 return decode_any_window (window)->parent; 427 return decode_any_window (window)->parent;
429} 428}
430 429
431DEFUN ("window-top-child", Fwindow_top_child, Swindow_top_child, 0, 1, 0, 430DEFUN ("window-top-child", Fwindow_top_child, Swindow_top_child, 1, 1, 0,
432 doc: /* Return WINDOW's topmost child window. 431 doc: /* Return the topmost child window of window WINDOW.
433WINDOW can be any window and defaults to the selected one. 432Return nil if WINDOW is a live window (live windows have no children).
434Return nil if WINDOW is not a vertical combination. */) 433Return nil if WINDOW is an internal window whose children form a
434horizontal combination. */)
435 (Lisp_Object window) 435 (Lisp_Object window)
436{ 436{
437 CHECK_WINDOW (window);
437 return decode_any_window (window)->vchild; 438 return decode_any_window (window)->vchild;
438} 439}
439 440
440DEFUN ("window-left-child", Fwindow_left_child, Swindow_left_child, 0, 1, 0, 441DEFUN ("window-left-child", Fwindow_left_child, Swindow_left_child, 1, 1, 0,
441 doc: /* Return WINDOW's leftmost child window. 442 doc: /* Return the leftmost child window of window WINDOW.
442WINDOW can be any window and defaults to the selected one. 443Return nil if WINDOW is a live window (live windows have no children).
443Return nil if WINDOW is not a horizontal combination. */) 444Return nil if WINDOW is an internal window whose children form a
445vertical combination. */)
444 (Lisp_Object window) 446 (Lisp_Object window)
445{ 447{
448 CHECK_WINDOW (window);
446 return decode_any_window (window)->hchild; 449 return decode_any_window (window)->hchild;
447} 450}
448 451
449DEFUN ("window-next-sibling", Fwindow_next_sibling, Swindow_next_sibling, 0, 1, 0, 452DEFUN ("window-next-sibling", Fwindow_next_sibling, Swindow_next_sibling, 0, 1, 0,
450 doc: /* Return WINDOW's next sibling window. 453 doc: /* Return the next sibling window of window WINDOW.
451WINDOW can be any window and defaults to the selected one. 454If WINDOW is omitted or nil, it defaults to the selected window.
452Return nil if WINDOW has no next sibling. */) 455Return nil if WINDOW has no next sibling. */)
453 (Lisp_Object window) 456 (Lisp_Object window)
454{ 457{
@@ -456,8 +459,8 @@ Return nil if WINDOW has no next sibling. */)
456} 459}
457 460
458DEFUN ("window-prev-sibling", Fwindow_prev_sibling, Swindow_prev_sibling, 0, 1, 0, 461DEFUN ("window-prev-sibling", Fwindow_prev_sibling, Swindow_prev_sibling, 0, 1, 0,
459 doc: /* Return WINDOW's previous sibling window. 462 doc: /* Return the previous sibling window of window WINDOW.
460WINDOW can be any window and defaults to the selected one. 463If WINDOW is omitted or nil, it defaults to the selected window.
461Return nil if WINDOW has no previous sibling. */) 464Return nil if WINDOW has no previous sibling. */)
462 (Lisp_Object window) 465 (Lisp_Object window)
463{ 466{
@@ -465,8 +468,8 @@ Return nil if WINDOW has no previous sibling. */)
465} 468}
466 469
467DEFUN ("window-splits", Fwindow_splits, Swindow_splits, 0, 1, 0, 470DEFUN ("window-splits", Fwindow_splits, Swindow_splits, 0, 1, 0,
468 doc: /* Return splits status for WINDOW. 471 doc: /* Return splits status for the window WINDOW.
469WINDOW can be any window and defaults to the selected one. 472If WINDOW is omitted or nil, it defaults to the selected window.
470 473
471If the value returned by this function is nil and WINDOW is resized, the 474If the value returned by this function is nil and WINDOW is resized, the
472corresponding space is preferably taken from (or given to) WINDOW's 475corresponding space is preferably taken from (or given to) WINDOW's
@@ -481,9 +484,8 @@ WINDOW may resize all windows in the same combination. */)
481} 484}
482 485
483DEFUN ("set-window-splits", Fset_window_splits, Sset_window_splits, 2, 2, 0, 486DEFUN ("set-window-splits", Fset_window_splits, Sset_window_splits, 2, 2, 0,
484 doc: /* Set splits status of WINDOW to STATUS. 487 doc: /* Set splits status of window WINDOW to STATUS.
485WINDOW can be any window and defaults to the selected one. Return 488If WINDOW is omitted or nil, it defaults to the selected window.
486STATUS.
487 489
488If STATUS is nil and WINDOW is later resized, the corresponding space is 490If STATUS is nil and WINDOW is later resized, the corresponding space is
489preferably taken from (or given to) WINDOW's right sibling. When WINDOW 491preferably taken from (or given to) WINDOW's right sibling. When WINDOW
@@ -501,8 +503,8 @@ windows in the same combination. */)
501} 503}
502 504
503DEFUN ("window-nest", Fwindow_nest, Swindow_nest, 0, 1, 0, 505DEFUN ("window-nest", Fwindow_nest, Swindow_nest, 0, 1, 0,
504 doc: /* Return nest status of WINDOW. 506 doc: /* Return nest status of window WINDOW.
505WINDOW can be any window and defaults to the selected one. 507If WINDOW is omitted or nil, it defaults to the selected window.
506 508
507If the return value is nil, subwindows of WINDOW can be recombined with 509If the return value is nil, subwindows of WINDOW can be recombined with
508WINDOW's siblings. A return value of non-nil means that subwindows of 510WINDOW's siblings. A return value of non-nil means that subwindows of
@@ -513,9 +515,8 @@ WINDOW are never \(re-)combined with WINDOW's siblings. */)
513} 515}
514 516
515DEFUN ("set-window-nest", Fset_window_nest, Sset_window_nest, 2, 2, 0, 517DEFUN ("set-window-nest", Fset_window_nest, Sset_window_nest, 2, 2, 0,
516 doc: /* Set nest status of WINDOW to STATUS. 518 doc: /* Set nest status of window WINDOW to STATUS; return STATUS.
517WINDOW can be any window and defaults to the selected one. Return 519If WINDOW is omitted or nil, it defaults to the selected window.
518STATUS.
519 520
520If STATUS is nil, subwindows of WINDOW can be recombined with WINDOW's 521If STATUS is nil, subwindows of WINDOW can be recombined with WINDOW's
521siblings. STATUS non-nil means that subwindows of WINDOW are never 522siblings. STATUS non-nil means that subwindows of WINDOW are never
@@ -530,22 +531,24 @@ siblings. STATUS non-nil means that subwindows of WINDOW are never
530} 531}
531 532
532DEFUN ("window-use-time", Fwindow_use_time, Swindow_use_time, 0, 1, 0, 533DEFUN ("window-use-time", Fwindow_use_time, Swindow_use_time, 0, 1, 0,
533 doc: /* Return WINDOW's use time. 534 doc: /* Return the use time of window WINDOW.
534WINDOW defaults to the selected window. The window with the highest use 535If WINDOW is omitted or nil, it defaults to the selected window.
535time is the most recently selected one. The window with the lowest use 536The window with the highest use time is the most recently selected
536time is the least recently selected one. */) 537one. The window with the lowest use time is the least recently
538selected one. */)
537 (Lisp_Object window) 539 (Lisp_Object window)
538{ 540{
539 return decode_window (window)->use_time; 541 return decode_window (window)->use_time;
540} 542}
541 543
542DEFUN ("window-total-size", Fwindow_total_size, Swindow_total_size, 0, 2, 0, 544DEFUN ("window-total-size", Fwindow_total_size, Swindow_total_size, 0, 2, 0,
543 doc: /* Return the total number of lines of WINDOW. 545 doc: /* Return the total number of lines of window WINDOW.
544WINDOW can be any window and defaults to the selected one. The return 546If WINDOW is omitted or nil, it defaults to the selected window.
545value includes WINDOW's mode line and header line, if any. If WINDOW 547
546is internal, the return value is the sum of the total number of lines 548The return value includes WINDOW's mode line and header line, if any.
547of WINDOW's child windows if these are vertically combined and the 549If WINDOW is internal, the return value is the sum of the total number
548height of WINDOW's first child otherwise. 550of lines of WINDOW's child windows if these are vertically combined
551and the height of WINDOW's first child otherwise.
549 552
550Optional argument HORIZONTAL non-nil means return the total number of 553Optional argument HORIZONTAL non-nil means return the total number of
551columns of WINDOW. In this case the return value includes any vertical 554columns of WINDOW. In this case the return value includes any vertical
@@ -562,17 +565,17 @@ first child otherwise. */)
562} 565}
563 566
564DEFUN ("window-new-total", Fwindow_new_total, Swindow_new_total, 0, 1, 0, 567DEFUN ("window-new-total", Fwindow_new_total, Swindow_new_total, 0, 1, 0,
565 doc: /* Return new total size of WINDOW. 568 doc: /* Return the new total size of window WINDOW.
566WINDOW defaults to the selected window. */) 569If WINDOW is omitted or nil, it defaults to the selected window. */)
567 (Lisp_Object window) 570 (Lisp_Object window)
568{ 571{
569 return decode_any_window (window)->new_total; 572 return decode_any_window (window)->new_total;
570} 573}
571 574
572DEFUN ("window-normal-size", Fwindow_normal_size, Swindow_normal_size, 0, 2, 0, 575DEFUN ("window-normal-size", Fwindow_normal_size, Swindow_normal_size, 0, 2, 0,
573 doc: /* Return normal height of WINDOW. 576 doc: /* Return the normal height of window WINDOW.
574WINDOW can be any window and defaults to the selected one. Optional 577If WINDOW is omitted or nil, it defaults to the selected window.
575argument HORIZONTAL non-nil means return normal width of WINDOW. */) 578If HORIZONTAL is non-nil, return the normal width of WINDOW. */)
576 (Lisp_Object window, Lisp_Object horizontal) 579 (Lisp_Object window, Lisp_Object horizontal)
577{ 580{
578 if (NILP (horizontal)) 581 if (NILP (horizontal))
@@ -582,24 +585,24 @@ argument HORIZONTAL non-nil means return normal width of WINDOW. */)
582} 585}
583 586
584DEFUN ("window-new-normal", Fwindow_new_normal, Swindow_new_normal, 0, 1, 0, 587DEFUN ("window-new-normal", Fwindow_new_normal, Swindow_new_normal, 0, 1, 0,
585 doc: /* Return new normal size of WINDOW. 588 doc: /* Return new normal size of window WINDOW.
586WINDOW can be any window and defaults to the selected one. */) 589If WINDOW is omitted or nil, it defaults to the selected window. */)
587 (Lisp_Object window) 590 (Lisp_Object window)
588{ 591{
589 return decode_any_window (window)->new_normal; 592 return decode_any_window (window)->new_normal;
590} 593}
591 594
592DEFUN ("window-left-column", Fwindow_left_column, Swindow_left_column, 0, 1, 0, 595DEFUN ("window-left-column", Fwindow_left_column, Swindow_left_column, 0, 1, 0,
593 doc: /* Return left column of WINDOW. 596 doc: /* Return left column of window WINDOW.
594WINDOW can be any window and defaults to the selected one. */) 597If WINDOW is omitted or nil, it defaults to the selected window. */)
595 (Lisp_Object window) 598 (Lisp_Object window)
596{ 599{
597 return decode_any_window (window)->left_col; 600 return decode_any_window (window)->left_col;
598} 601}
599 602
600DEFUN ("window-top-line", Fwindow_top_line, Swindow_top_line, 0, 1, 0, 603DEFUN ("window-top-line", Fwindow_top_line, Swindow_top_line, 0, 1, 0,
601 doc: /* Return top line of WINDOW. 604 doc: /* Return top line of window WINDOW.
602WINDOW can be any window and defaults to the selected one. */) 605If WINDOW is omitted or nil, it defaults to the selected window. */)
603 (Lisp_Object window) 606 (Lisp_Object window)
604{ 607{
605 return decode_any_window (window)->top_line; 608 return decode_any_window (window)->top_line;
@@ -2313,7 +2316,7 @@ window_list_1 (Lisp_Object window, Lisp_Object minibuf, Lisp_Object all_frames)
2313DEFUN ("window-list", Fwindow_list, Swindow_list, 0, 3, 0, 2316DEFUN ("window-list", Fwindow_list, Swindow_list, 0, 3, 0,
2314 doc: /* Return a list of windows on FRAME, starting with WINDOW. 2317 doc: /* Return a list of windows on FRAME, starting with WINDOW.
2315FRAME nil or omitted means use the selected frame. 2318FRAME nil or omitted means use the selected frame.
2316WINDOW nil or omitted means use the selected window. 2319WINDOW nil or omitted means use the window selected within FRAME.
2317MINIBUF t means include the minibuffer window, even if it isn't active. 2320MINIBUF t means include the minibuffer window, even if it isn't active.
2318MINIBUF nil or omitted means include the minibuffer window only 2321MINIBUF nil or omitted means include the minibuffer window only
2319if it's active. 2322if it's active.
@@ -6007,7 +6010,7 @@ means no margin. */)
6007DEFUN ("window-margins", Fwindow_margins, Swindow_margins, 6010DEFUN ("window-margins", Fwindow_margins, Swindow_margins,
6008 0, 1, 0, 6011 0, 1, 0,
6009 doc: /* Get width of marginal areas of window WINDOW. 6012 doc: /* Get width of marginal areas of window WINDOW.
6010If WINDOW is omitted or nil, use the currently selected window. 6013If WINDOW is omitted or nil, it defaults to the selected window.
6011Value is a cons of the form (LEFT-WIDTH . RIGHT-WIDTH). 6014Value is a cons of the form (LEFT-WIDTH . RIGHT-WIDTH).
6012If a marginal area does not exist, its width will be returned 6015If a marginal area does not exist, its width will be returned
6013as nil. */) 6016as nil. */)
@@ -6071,7 +6074,7 @@ display marginal areas and the text area. */)
6071DEFUN ("window-fringes", Fwindow_fringes, Swindow_fringes, 6074DEFUN ("window-fringes", Fwindow_fringes, Swindow_fringes,
6072 0, 1, 0, 6075 0, 1, 0,
6073 doc: /* Get width of fringes of window WINDOW. 6076 doc: /* Get width of fringes of window WINDOW.
6074If WINDOW is omitted or nil, use the currently selected window. 6077If WINDOW is omitted or nil, it defaults to the selected window.
6075Value is a list of the form (LEFT-WIDTH RIGHT-WIDTH OUTSIDE-MARGINS). */) 6078Value is a list of the form (LEFT-WIDTH RIGHT-WIDTH OUTSIDE-MARGINS). */)
6076 (Lisp_Object window) 6079 (Lisp_Object window)
6077{ 6080{
@@ -6140,7 +6143,7 @@ Fourth parameter HORIZONTAL-TYPE is currently unused. */)
6140DEFUN ("window-scroll-bars", Fwindow_scroll_bars, Swindow_scroll_bars, 6143DEFUN ("window-scroll-bars", Fwindow_scroll_bars, Swindow_scroll_bars,
6141 0, 1, 0, 6144 0, 1, 0,
6142 doc: /* Get width and type of scroll bars of window WINDOW. 6145 doc: /* Get width and type of scroll bars of window WINDOW.
6143If WINDOW is omitted or nil, use the currently selected window. 6146If WINDOW is omitted or nil, it defaults to the selected window.
6144Value is a list of the form (WIDTH COLS VERTICAL-TYPE HORIZONTAL-TYPE). 6147Value is a list of the form (WIDTH COLS VERTICAL-TYPE HORIZONTAL-TYPE).
6145If WIDTH is nil or TYPE is t, the window is using the frame's corresponding 6148If WIDTH is nil or TYPE is t, the window is using the frame's corresponding
6146value. */) 6149value. */)
@@ -6163,7 +6166,7 @@ value. */)
6163 6166
6164DEFUN ("window-vscroll", Fwindow_vscroll, Swindow_vscroll, 0, 2, 0, 6167DEFUN ("window-vscroll", Fwindow_vscroll, Swindow_vscroll, 0, 2, 0,
6165 doc: /* Return the amount by which WINDOW is scrolled vertically. 6168 doc: /* Return the amount by which WINDOW is scrolled vertically.
6166Use the selected window if WINDOW is nil or omitted. 6169If WINDOW is omitted or nil, it defaults to the selected window.
6167Normally, value is a multiple of the canonical character height of WINDOW; 6170Normally, value is a multiple of the canonical character height of WINDOW;
6168optional second arg PIXELS-P means value is measured in pixels. */) 6171optional second arg PIXELS-P means value is measured in pixels. */)
6169 (Lisp_Object window, Lisp_Object pixels_p) 6172 (Lisp_Object window, Lisp_Object pixels_p)
diff --git a/src/xdisp.c b/src/xdisp.c
index 6414ab00fd8..5d6d919af67 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -2768,9 +2768,13 @@ init_iterator (struct it *it, struct window *w,
2768 /* Do we need to reorder bidirectional text? Not if this is a 2768 /* Do we need to reorder bidirectional text? Not if this is a
2769 unibyte buffer: by definition, none of the single-byte 2769 unibyte buffer: by definition, none of the single-byte
2770 characters are strong R2L, so no reordering is needed. And 2770 characters are strong R2L, so no reordering is needed. And
2771 bidi.c doesn't support unibyte buffers anyway. */ 2771 bidi.c doesn't support unibyte buffers anyway. Also, don't
2772 reorder while we are loading loadup.el, since the tables of
2773 character properties needed for reordering are not yet
2774 available. */
2772 it->bidi_p = 2775 it->bidi_p =
2773 !NILP (BVAR (current_buffer, bidi_display_reordering)) 2776 NILP (Vpurify_flag)
2777 && !NILP (BVAR (current_buffer, bidi_display_reordering))
2774 && it->multibyte_p; 2778 && it->multibyte_p;
2775 2779
2776 /* If we are to reorder bidirectional text, init the bidi 2780 /* If we are to reorder bidirectional text, init the bidi
@@ -6171,8 +6175,12 @@ reseat_to_string (struct it *it, const char *s, Lisp_Object string,
6171 it->multibyte_p = multibyte > 0; 6175 it->multibyte_p = multibyte > 0;
6172 6176
6173 /* Bidirectional reordering of strings is controlled by the default 6177 /* Bidirectional reordering of strings is controlled by the default
6174 value of bidi-display-reordering. */ 6178 value of bidi-display-reordering. Don't try to reorder while
6175 it->bidi_p = !NILP (BVAR (&buffer_defaults, bidi_display_reordering)); 6179 loading loadup.el, as the necessary character property tables are
6180 not yet available. */
6181 it->bidi_p =
6182 NILP (Vpurify_flag)
6183 && !NILP (BVAR (&buffer_defaults, bidi_display_reordering));
6176 6184
6177 if (s == NULL) 6185 if (s == NULL)
6178 { 6186 {
@@ -19565,7 +19573,10 @@ See also `bidi-paragraph-direction'. */)
19565 } 19573 }
19566 19574
19567 if (NILP (BVAR (buf, bidi_display_reordering)) 19575 if (NILP (BVAR (buf, bidi_display_reordering))
19568 || NILP (BVAR (buf, enable_multibyte_characters))) 19576 || NILP (BVAR (buf, enable_multibyte_characters))
19577 /* When we are loading loadup.el, the character property tables
19578 needed for bidi iteration are not yet available. */
19579 || !NILP (Vpurify_flag))
19569 return Qleft_to_right; 19580 return Qleft_to_right;
19570 else if (!NILP (BVAR (buf, bidi_paragraph_direction))) 19581 else if (!NILP (BVAR (buf, bidi_paragraph_direction)))
19571 return BVAR (buf, bidi_paragraph_direction); 19582 return BVAR (buf, bidi_paragraph_direction);
@@ -27390,8 +27401,12 @@ note_mouse_highlight (struct frame *f, int x, int y)
27390 } 27401 }
27391 27402
27392 mouse_face_from_buffer_pos (window, hlinfo, pos, 27403 mouse_face_from_buffer_pos (window, hlinfo, pos,
27393 XFASTINT (before), 27404 NILP (before)
27394 XFASTINT (after), 27405 ? 1
27406 : XFASTINT (before),
27407 NILP (after)
27408 ? BUF_Z (XBUFFER (buffer))
27409 : XFASTINT (after),
27395 before_string, after_string, 27410 before_string, after_string,
27396 disp_string); 27411 disp_string);
27397 cursor = No_Cursor; 27412 cursor = No_Cursor;
diff --git a/src/xfns.c b/src/xfns.c
index ac030582ffe..49c4c774cae 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -2914,7 +2914,7 @@ x_free_gcs (struct frame *f)
2914 2914
2915 2915
2916/* Handler for signals raised during x_create_frame and 2916/* Handler for signals raised during x_create_frame and
2917 x_create_top_frame. FRAME is the frame which is partially 2917 x_create_tip_frame. FRAME is the frame which is partially
2918 constructed. */ 2918 constructed. */
2919 2919
2920static Lisp_Object 2920static Lisp_Object
@@ -3138,7 +3138,6 @@ This function is an internal primitive--use `make-frame' instead. */)
3138 FRAME_CAN_HAVE_SCROLL_BARS (f) = 1; 3138 FRAME_CAN_HAVE_SCROLL_BARS (f) = 1;
3139 3139
3140 f->terminal = dpyinfo->terminal; 3140 f->terminal = dpyinfo->terminal;
3141 f->terminal->reference_count++;
3142 3141
3143 f->output_method = output_x_window; 3142 f->output_method = output_x_window;
3144 f->output_data.x = (struct x_output *) xmalloc (sizeof (struct x_output)); 3143 f->output_data.x = (struct x_output *) xmalloc (sizeof (struct x_output));
@@ -3308,6 +3307,12 @@ This function is an internal primitive--use `make-frame' instead. */)
3308 "scrollBarBackground", 3307 "scrollBarBackground",
3309 "ScrollBarBackground", 0); 3308 "ScrollBarBackground", 0);
3310 3309
3310#if GLYPH_DEBUG
3311 image_cache_refcount =
3312 FRAME_IMAGE_CACHE (f) ? FRAME_IMAGE_CACHE (f)->refcount : 0;
3313 dpyinfo_refcount = dpyinfo->reference_count;
3314#endif /* GLYPH_DEBUG */
3315
3311 /* Init faces before x_default_parameter is called for scroll-bar 3316 /* Init faces before x_default_parameter is called for scroll-bar
3312 parameters because that function calls x_set_scroll_bar_width, 3317 parameters because that function calls x_set_scroll_bar_width,
3313 which calls change_frame_size, which calls Fset_window_buffer, 3318 which calls change_frame_size, which calls Fset_window_buffer,
@@ -3316,11 +3321,6 @@ This function is an internal primitive--use `make-frame' instead. */)
3316 happen. */ 3321 happen. */
3317 init_frame_faces (f); 3322 init_frame_faces (f);
3318 3323
3319#if GLYPH_DEBUG
3320 image_cache_refcount = FRAME_IMAGE_CACHE (f)->refcount;
3321 dpyinfo_refcount = dpyinfo->reference_count;
3322#endif /* GLYPH_DEBUG */
3323
3324 /* The X resources controlling the menu-bar and tool-bar are 3324 /* The X resources controlling the menu-bar and tool-bar are
3325 processed specially at startup, and reflected in the mode 3325 processed specially at startup, and reflected in the mode
3326 variables; ignore them here. */ 3326 variables; ignore them here. */
@@ -3364,6 +3364,7 @@ This function is an internal primitive--use `make-frame' instead. */)
3364 x_make_gc (f); 3364 x_make_gc (f);
3365 3365
3366 /* Now consider the frame official. */ 3366 /* Now consider the frame official. */
3367 f->terminal->reference_count++;
3367 FRAME_X_DISPLAY_INFO (f)->reference_count++; 3368 FRAME_X_DISPLAY_INFO (f)->reference_count++;
3368 Vframe_list = Fcons (frame, Vframe_list); 3369 Vframe_list = Fcons (frame, Vframe_list);
3369 3370
@@ -4594,7 +4595,6 @@ x_create_tip_frame (struct x_display_info *dpyinfo,
4594 record_unwind_protect (unwind_create_tip_frame, frame); 4595 record_unwind_protect (unwind_create_tip_frame, frame);
4595 4596
4596 f->terminal = dpyinfo->terminal; 4597 f->terminal = dpyinfo->terminal;
4597 f->terminal->reference_count++;
4598 4598
4599 /* By setting the output method, we're essentially saying that 4599 /* By setting the output method, we're essentially saying that
4600 the frame is live, as per FRAME_LIVE_P. If we get a signal 4600 the frame is live, as per FRAME_LIVE_P. If we get a signal
@@ -4716,6 +4716,12 @@ x_create_tip_frame (struct x_display_info *dpyinfo,
4716 x_default_parameter (f, parms, Qborder_color, build_string ("black"), 4716 x_default_parameter (f, parms, Qborder_color, build_string ("black"),
4717 "borderColor", "BorderColor", RES_TYPE_STRING); 4717 "borderColor", "BorderColor", RES_TYPE_STRING);
4718 4718
4719#if GLYPH_DEBUG
4720 image_cache_refcount =
4721 FRAME_IMAGE_CACHE (f) ? FRAME_IMAGE_CACHE (f)->refcount : 0;
4722 dpyinfo_refcount = dpyinfo->reference_count;
4723#endif /* GLYPH_DEBUG */
4724
4719 /* Init faces before x_default_parameter is called for scroll-bar 4725 /* Init faces before x_default_parameter is called for scroll-bar
4720 parameters because that function calls x_set_scroll_bar_width, 4726 parameters because that function calls x_set_scroll_bar_width,
4721 which calls change_frame_size, which calls Fset_window_buffer, 4727 which calls change_frame_size, which calls Fset_window_buffer,
@@ -4724,11 +4730,6 @@ x_create_tip_frame (struct x_display_info *dpyinfo,
4724 happen. */ 4730 happen. */
4725 init_frame_faces (f); 4731 init_frame_faces (f);
4726 4732
4727#if GLYPH_DEBUG
4728 image_cache_refcount = FRAME_IMAGE_CACHE (f)->refcount;
4729 dpyinfo_refcount = dpyinfo->reference_count;
4730#endif /* GLYPH_DEBUG */
4731
4732 f->output_data.x->parent_desc = FRAME_X_DISPLAY_INFO (f)->root_window; 4733 f->output_data.x->parent_desc = FRAME_X_DISPLAY_INFO (f)->root_window;
4733 4734
4734 x_figure_window_size (f, parms, 0); 4735 x_figure_window_size (f, parms, 0);
@@ -4834,14 +4835,16 @@ x_create_tip_frame (struct x_display_info *dpyinfo,
4834 4835
4835 UNGCPRO; 4836 UNGCPRO;
4836 4837
4838 /* Now that the frame will be official, it counts as a reference to
4839 its display and terminal. */
4840 FRAME_X_DISPLAY_INFO (f)->reference_count++;
4841 f->terminal->reference_count++;
4842
4837 /* It is now ok to make the frame official even if we get an error 4843 /* It is now ok to make the frame official even if we get an error
4838 below. And the frame needs to be on Vframe_list or making it 4844 below. And the frame needs to be on Vframe_list or making it
4839 visible won't work. */ 4845 visible won't work. */
4840 Vframe_list = Fcons (frame, Vframe_list); 4846 Vframe_list = Fcons (frame, Vframe_list);
4841 4847
4842 /* Now that the frame is official, it counts as a reference to
4843 its display. */
4844 FRAME_X_DISPLAY_INFO (f)->reference_count++;
4845 4848
4846 /* Setting attributes of faces of the tooltip frame from resources 4849 /* Setting attributes of faces of the tooltip frame from resources
4847 and similar will increment face_change_count, which leads to the 4850 and similar will increment face_change_count, which leads to the
diff --git a/src/xmenu.c b/src/xmenu.c
index 7fcd2ad3724..0dd652b566d 100644
--- a/src/xmenu.c
+++ b/src/xmenu.c
@@ -1604,6 +1604,17 @@ create_and_show_popup_menu (FRAME_PTR f, widget_value *first_wv,
1604 1604
1605#endif /* not USE_GTK */ 1605#endif /* not USE_GTK */
1606 1606
1607static Lisp_Object
1608cleanup_widget_value_tree (Lisp_Object arg)
1609{
1610 struct Lisp_Save_Value *p = XSAVE_VALUE (arg);
1611 widget_value *wv = p->pointer;
1612
1613 free_menubar_widget_value_tree (wv);
1614
1615 return Qnil;
1616}
1617
1607Lisp_Object 1618Lisp_Object
1608xmenu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps, 1619xmenu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps,
1609 Lisp_Object title, const char **error_name, Time timestamp) 1620 Lisp_Object title, const char **error_name, Time timestamp)
@@ -1618,6 +1629,8 @@ xmenu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps,
1618 1629
1619 int first_pane; 1630 int first_pane;
1620 1631
1632 int specpdl_count = SPECPDL_INDEX ();
1633
1621 if (! FRAME_X_P (f)) 1634 if (! FRAME_X_P (f))
1622 abort (); 1635 abort ();
1623 1636
@@ -1812,11 +1825,15 @@ xmenu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps,
1812 /* No selection has been chosen yet. */ 1825 /* No selection has been chosen yet. */
1813 menu_item_selection = 0; 1826 menu_item_selection = 0;
1814 1827
1828 /* Make sure to free the widget_value objects we used to specify the
1829 contents even with longjmp. */
1830 record_unwind_protect (cleanup_widget_value_tree,
1831 make_save_value (first_wv, 0));
1832
1815 /* Actually create and show the menu until popped down. */ 1833 /* Actually create and show the menu until popped down. */
1816 create_and_show_popup_menu (f, first_wv, x, y, for_click, timestamp); 1834 create_and_show_popup_menu (f, first_wv, x, y, for_click, timestamp);
1817 1835
1818 /* Free the widget_value objects we used to specify the contents. */ 1836 unbind_to (specpdl_count, Qnil);
1819 free_menubar_widget_value_tree (first_wv);
1820 1837
1821 /* Find the selected item, and its pane, to return 1838 /* Find the selected item, and its pane, to return
1822 the proper value. */ 1839 the proper value. */
@@ -2003,6 +2020,8 @@ xdialog_show (FRAME_PTR f,
2003 /* 1 means we've seen the boundary between left-hand elts and right-hand. */ 2020 /* 1 means we've seen the boundary between left-hand elts and right-hand. */
2004 int boundary_seen = 0; 2021 int boundary_seen = 0;
2005 2022
2023 int specpdl_count = SPECPDL_INDEX ();
2024
2006 if (! FRAME_X_P (f)) 2025 if (! FRAME_X_P (f))
2007 abort (); 2026 abort ();
2008 2027
@@ -2116,11 +2135,15 @@ xdialog_show (FRAME_PTR f,
2116 /* No selection has been chosen yet. */ 2135 /* No selection has been chosen yet. */
2117 menu_item_selection = 0; 2136 menu_item_selection = 0;
2118 2137
2138 /* Make sure to free the widget_value objects we used to specify the
2139 contents even with longjmp. */
2140 record_unwind_protect (cleanup_widget_value_tree,
2141 make_save_value (first_wv, 0));
2142
2119 /* Actually create and show the dialog. */ 2143 /* Actually create and show the dialog. */
2120 create_and_show_dialog (f, first_wv); 2144 create_and_show_dialog (f, first_wv);
2121 2145
2122 /* Free the widget_value objects we used to specify the contents. */ 2146 unbind_to (specpdl_count, Qnil);
2123 free_menubar_widget_value_tree (first_wv);
2124 2147
2125 /* Find the selected item, and its pane, to return 2148 /* Find the selected item, and its pane, to return
2126 the proper value. */ 2149 the proper value. */