aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKaroly Lorentey2006-03-15 17:22:12 +0000
committerKaroly Lorentey2006-03-15 17:22:12 +0000
commitb336ee388ed5300440e7bab24bf9eec9f250911a (patch)
tree62c9058bd403d158d7d18d1cbd4ead3abf36a7aa /src
parent47f3c6b4dbed851762dca99273d78642c3794188 (diff)
parent4034b0e259dd59eda180bd0683876c9d0110f719 (diff)
downloademacs-b336ee388ed5300440e7bab24bf9eec9f250911a.tar.gz
emacs-b336ee388ed5300440e7bab24bf9eec9f250911a.zip
Merged from emacs@sv.gnu.org
Patches applied: * emacs@sv.gnu.org/emacs--devo--0--patch-153 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-154 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-155 Remove nick-abbrevs stuff from rcirc.el * emacs@sv.gnu.org/emacs--devo--0--patch-156 rcirc.el update from Ryan Yeske * emacs@sv.gnu.org/emacs--devo--0--patch-157 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-158 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-159 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-532
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog60
-rw-r--r--src/mac.c3
-rw-r--r--src/macfns.c1
-rw-r--r--src/macgui.h18
-rw-r--r--src/macterm.c230
-rw-r--r--src/macterm.h8
-rw-r--r--src/w32fns.c36
-rw-r--r--src/w32menu.c8
-rw-r--r--src/w32term.c18
-rw-r--r--src/xterm.c9
10 files changed, 320 insertions, 71 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 389538b1617..f6edc410276 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,61 @@
12006-03-14 Chong Yidong <cyd@stupidchicken.com>
2
3 * xterm.c (x_uncatch_errors): Block input for entire function.
4
52006-03-12 Jason Rumney <jasonr@gnu.org>
6
7 * w32fns.c (Fx_create_frame): Remove call to
8 Qface_set_after_frame_default. (from xfns.c 2003-05-26)
9
10 * w32menu.c (Fx_popup_menu): Call w32_free_menu_strings when
11 finished with the menu.
12
13 * w32term.c: Sync 2005-10-24 xterm.c changes.
14 (last_mouse_glyph_frame): New var.
15 (note_mouse_movement): Say mouse moved if current frame differs
16 from last_mouse_glyph_frame, and update last_mouse_glyph_frame.
17 (w32_mouse_position): Set last_mouse_glyph_frame.
18 Remove OLD_REDISPLAY_CODE block.
19
202006-03-12 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
21
22 * macgui.h [USE_ATSUI && MAC_OSX]: Define USE_CG_TEXT_DRAWING to 1.
23
24 * macterm.h (struct mac_output) [USE_CG_DRAWING]: New member cg_context.
25 (mac_prepare_for_quickdraw) [USE_CG_DRAWING]: Add prototype.
26
27 * mac.c (sys_select) [USE_CG_DRAWING]: Call mac_prepare_for_quickdraw.
28
29 * macfns.c (x_create_tip_frame): Apply 2006-03-11 change for xfns.c.
30
31 * macterm.c (mac_draw_rectangle, x_draw_glyph_string_foreground)
32 (x_draw_composite_glyph_string_foreground)
33 (x_draw_image_foreground): Undo previous changes.
34 (x_draw_hollow_cursor): Likewise. Subtract 1 from the last
35 argument of mac_draw_rectangle.
36 (CG_SET_FILL_COLOR, CG_SET_STROKE_COLOR): New macros.
37 (mac_draw_string_common, mac_draw_image_string_cg): Use them.
38 (FRAME_CG_CONTEXT) [USE_CG_DRAWING]: New macro.
39 (mac_begin_cg_clip, mac_end_cg_clip, mac_prepare_for_quickdraw)
40 [USE_CG_DRAWING]: New functions.
41 (mac_draw_line, mac_erase_rectangle, mac_clear_window)
42 (mac_fill_rectangle, mac_draw_rectangle, mac_draw_string_common)
43 (mac_draw_image_string_cg) [USE_CG_DRAWING]: Add Quartz 2D drawing part.
44 (mac_draw_bitmap, mac_invert_rectangle, mac_draw_string_common)
45 (mac_copy_area, mac_scroll_area, x_scroll_bar_create)
46 (x_scroll_bar_remove, XTset_vertical_scroll_bar, x_set_window_size)
47 (XTread_socket) [USE_CG_DRAWING]: Call mac_prepare_for_quickdraw.
48
492006-03-12 L$,1 q(Brentey K,Aa(Broly <lorentey@elte.hu>
50
51 * xfns.c (x_icon): Disable redundant call to `x_wm_set_window_state'.
52
532006-03-11 Jason Rumney <jasonr@gnu.org>
54
55 * w32fns.c (signal_user_input): New function.
56 (post_character_message): Use it for keyboard input.
57 (w32_msg_pump): Use it for mouse input.
58
12006-03-11 Luc Teirlinck <teirllm@auburn.edu> 592006-03-11 Luc Teirlinck <teirllm@auburn.edu>
2 60
3 * window.c: Rename preserve_y to window_scroll_pixel_based_preserve_y. 61 * window.c: Rename preserve_y to window_scroll_pixel_based_preserve_y.
@@ -95,7 +153,7 @@
95 153
96 * image.c [MAC_OS] (XPutPixel): Set alpha channel bits if pixmap 154 * image.c [MAC_OS] (XPutPixel): Set alpha channel bits if pixmap
97 depth is 32. 155 depth is 32.
98 [MAC_OS] (XGetPixel): Strip off alpha channel bits if pixmap 156 [MAC_OS] (XGetPixel): Strip off alpha channel bits if pixmap
99 depth is 32. 157 depth is 32.
100 158
1012006-03-06 Chong Yidong <cyd@stupidchicken.com> 1592006-03-06 Chong Yidong <cyd@stupidchicken.com>
diff --git a/src/mac.c b/src/mac.c
index a71194f9aee..40bbacf15ce 100644
--- a/src/mac.c
+++ b/src/mac.c
@@ -4829,6 +4829,9 @@ sys_select (n, rfds, wfds, efds, timeout)
4829 return 0; 4829 return 0;
4830 } 4830 }
4831 4831
4832#if USE_CG_DRAWING
4833 mac_prepare_for_quickdraw (NULL);
4834#endif
4832 /* Avoid initial overhead of RunLoop setup for the case that 4835 /* Avoid initial overhead of RunLoop setup for the case that
4833 some input is already available. */ 4836 some input is already available. */
4834 EMACS_SET_SECS_USECS (select_timeout, 0, 0); 4837 EMACS_SET_SECS_USECS (select_timeout, 0, 0);
diff --git a/src/macfns.c b/src/macfns.c
index 92a78a7319b..8e241205cd4 100644
--- a/src/macfns.c
+++ b/src/macfns.c
@@ -3591,6 +3591,7 @@ x_create_tip_frame (dpyinfo, parms, text)
3591 3591
3592 check_mac (); 3592 check_mac ();
3593 3593
3594 parms = Fcopy_alist (parms);
3594 3595
3595#ifdef MULTI_KBOARD 3596#ifdef MULTI_KBOARD
3596 kb = dpyinfo->kboard; 3597 kb = dpyinfo->kboard;
diff --git a/src/macgui.h b/src/macgui.h
index a84fea1ae91..7eb6c9942ab 100644
--- a/src/macgui.h
+++ b/src/macgui.h
@@ -79,6 +79,18 @@ typedef unsigned long Time;
79#include <Gestalt.h> 79#include <Gestalt.h>
80#endif /* not HAVE_CARBON */ 80#endif /* not HAVE_CARBON */
81 81
82#ifndef USE_CG_TEXT_DRAWING
83#if USE_ATSUI && MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
84#define USE_CG_TEXT_DRAWING 1
85#endif
86#endif
87
88#ifndef USE_CG_DRAWING
89#if USE_ATSUI && defined (MAC_OSX)
90#define USE_CG_DRAWING 1
91#endif
92#endif
93
82typedef WindowPtr Window; 94typedef WindowPtr Window;
83typedef GWorldPtr Pixmap; 95typedef GWorldPtr Pixmap;
84 96
@@ -92,12 +104,6 @@ typedef GWorldPtr Pixmap;
92#endif 104#endif
93 105
94 106
95#ifndef USE_CG_TEXT_DRAWING
96#if USE_ATSUI && MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
97#define USE_CG_TEXT_DRAWING 1
98#endif
99#endif
100
101/* Emulate XCharStruct. */ 107/* Emulate XCharStruct. */
102typedef struct _XCharStruct 108typedef struct _XCharStruct
103{ 109{
diff --git a/src/macterm.c b/src/macterm.c
index 9252d3bd914..d3510dbf516 100644
--- a/src/macterm.c
+++ b/src/macterm.c
@@ -268,6 +268,72 @@ extern void menubar_selection_callback (FRAME_PTR, int);
268#define GC_BACK_COLOR(gc) (&(gc)->back_color) 268#define GC_BACK_COLOR(gc) (&(gc)->back_color)
269#define GC_FONT(gc) ((gc)->xgcv.font) 269#define GC_FONT(gc) ((gc)->xgcv.font)
270#define FRAME_NORMAL_GC(f) ((f)->output_data.mac->normal_gc) 270#define FRAME_NORMAL_GC(f) ((f)->output_data.mac->normal_gc)
271#define CG_SET_FILL_COLOR(context, color) \
272 CGContextSetRGBFillColor (context, \
273 RED_FROM_ULONG (color) / 255.0f, \
274 GREEN_FROM_ULONG (color) / 255.0f, \
275 BLUE_FROM_ULONG (color) / 255.0f, 1.0f)
276#define CG_SET_STROKE_COLOR(context, color) \
277 CGContextSetRGBStrokeColor (context, \
278 RED_FROM_ULONG (color) / 255.0f, \
279 GREEN_FROM_ULONG (color) / 255.0f, \
280 BLUE_FROM_ULONG (color) / 255.0f, 1.0f)
281#if USE_CG_DRAWING
282#define FRAME_CG_CONTEXT(f) ((f)->output_data.mac->cg_context)
283
284static CGContextRef
285mac_begin_cg_clip (f, gc)
286 struct frame *f;
287 GC gc;
288{
289 CGContextRef context = FRAME_CG_CONTEXT (f);
290
291 if (!context)
292 {
293 QDBeginCGContext (GetWindowPort (FRAME_MAC_WINDOW (f)), &context);
294 FRAME_CG_CONTEXT (f) = context;
295 }
296
297 CGContextSaveGState (context);
298 CGContextTranslateCTM (context, 0, FRAME_PIXEL_HEIGHT (f));
299 CGContextScaleCTM (context, 1, -1);
300 if (gc && gc->n_clip_rects)
301 CGContextClipToRects (context, gc->clip_rects, gc->n_clip_rects);
302
303 return context;
304}
305
306static void
307mac_end_cg_clip (f)
308 struct frame *f;
309{
310 CGContextRestoreGState (FRAME_CG_CONTEXT (f));
311}
312
313void
314mac_prepare_for_quickdraw (f)
315 struct frame *f;
316{
317 if (f == NULL)
318 {
319 Lisp_Object rest, frame;
320 FOR_EACH_FRAME (rest, frame)
321 if (FRAME_MAC_P (XFRAME (frame)))
322 mac_prepare_for_quickdraw (XFRAME (frame));
323 }
324 else
325 {
326 CGContextRef context = FRAME_CG_CONTEXT (f);
327
328 if (context)
329 {
330 CGContextSynchronize (context);
331 QDEndCGContext (GetWindowPort (FRAME_MAC_WINDOW (f)),
332 &FRAME_CG_CONTEXT (f));
333 }
334 }
335}
336#endif
271 337
272static RgnHandle saved_port_clip_region = NULL; 338static RgnHandle saved_port_clip_region = NULL;
273 339
@@ -318,6 +384,18 @@ mac_draw_line (f, gc, x1, y1, x2, y2)
318 GC gc; 384 GC gc;
319 int x1, y1, x2, y2; 385 int x1, y1, x2, y2;
320{ 386{
387#if USE_CG_DRAWING
388 CGContextRef context;
389
390 context = mac_begin_cg_clip (f, gc);
391 CG_SET_STROKE_COLOR (context, gc->xgcv.foreground);
392 CGContextBeginPath (context);
393 CGContextMoveToPoint (context, x1 + 0.5f, y1 + 0.5f);
394 CGContextAddLineToPoint (context, x2 + 0.5f, y2 + 0.5f);
395 CGContextClosePath (context);
396 CGContextStrokePath (context);
397 mac_end_cg_clip (f);
398#else
321 SetPortWindowPort (FRAME_MAC_WINDOW (f)); 399 SetPortWindowPort (FRAME_MAC_WINDOW (f));
322 400
323 RGBForeColor (GC_FORE_COLOR (gc)); 401 RGBForeColor (GC_FORE_COLOR (gc));
@@ -326,6 +404,7 @@ mac_draw_line (f, gc, x1, y1, x2, y2)
326 MoveTo (x1, y1); 404 MoveTo (x1, y1);
327 LineTo (x2, y2); 405 LineTo (x2, y2);
328 mac_end_clip (gc); 406 mac_end_clip (gc);
407#endif
329} 408}
330 409
331void 410void
@@ -359,6 +438,14 @@ mac_erase_rectangle (f, gc, x, y, width, height)
359 int x, y; 438 int x, y;
360 unsigned int width, height; 439 unsigned int width, height;
361{ 440{
441#if USE_CG_DRAWING
442 CGContextRef context;
443
444 context = mac_begin_cg_clip (f, gc);
445 CG_SET_FILL_COLOR (context, gc->xgcv.background);
446 CGContextFillRect (context, CGRectMake (x, y, width, height));
447 mac_end_cg_clip (f);
448#else
362 Rect r; 449 Rect r;
363 450
364 SetPortWindowPort (FRAME_MAC_WINDOW (f)); 451 SetPortWindowPort (FRAME_MAC_WINDOW (f));
@@ -371,6 +458,7 @@ mac_erase_rectangle (f, gc, x, y, width, height)
371 mac_end_clip (gc); 458 mac_end_clip (gc);
372 459
373 RGBBackColor (GC_BACK_COLOR (FRAME_NORMAL_GC (f))); 460 RGBBackColor (GC_BACK_COLOR (FRAME_NORMAL_GC (f)));
461#endif
374} 462}
375 463
376 464
@@ -391,6 +479,16 @@ static void
391mac_clear_window (f) 479mac_clear_window (f)
392 struct frame *f; 480 struct frame *f;
393{ 481{
482#if USE_CG_DRAWING
483 CGContextRef context;
484 GC gc = FRAME_NORMAL_GC (f);
485
486 context = mac_begin_cg_clip (f, NULL);
487 CG_SET_FILL_COLOR (context, gc->xgcv.background);
488 CGContextFillRect (context, CGRectMake (0, 0, FRAME_PIXEL_WIDTH (f),
489 FRAME_PIXEL_HEIGHT (f)));
490 mac_end_cg_clip (f);
491#else
394 SetPortWindowPort (FRAME_MAC_WINDOW (f)); 492 SetPortWindowPort (FRAME_MAC_WINDOW (f));
395 493
396 RGBBackColor (GC_BACK_COLOR (FRAME_NORMAL_GC (f))); 494 RGBBackColor (GC_BACK_COLOR (FRAME_NORMAL_GC (f)));
@@ -405,6 +503,7 @@ mac_clear_window (f)
405#else /* not TARGET_API_MAC_CARBON */ 503#else /* not TARGET_API_MAC_CARBON */
406 EraseRect (&(FRAME_MAC_WINDOW (f)->portRect)); 504 EraseRect (&(FRAME_MAC_WINDOW (f)->portRect));
407#endif /* not TARGET_API_MAC_CARBON */ 505#endif /* not TARGET_API_MAC_CARBON */
506#endif
408} 507}
409 508
410 509
@@ -425,6 +524,9 @@ mac_draw_bitmap (f, gc, x, y, width, height, bits, overlay_p)
425 bitmap.baseAddr = (char *)bits; 524 bitmap.baseAddr = (char *)bits;
426 SetRect (&(bitmap.bounds), 0, 0, width, height); 525 SetRect (&(bitmap.bounds), 0, 0, width, height);
427 526
527#if USE_CG_DRAWING
528 mac_prepare_for_quickdraw (f);
529#endif
428 SetPortWindowPort (FRAME_MAC_WINDOW (f)); 530 SetPortWindowPort (FRAME_MAC_WINDOW (f));
429 531
430 RGBForeColor (GC_FORE_COLOR (gc)); 532 RGBForeColor (GC_FORE_COLOR (gc));
@@ -571,6 +673,14 @@ mac_fill_rectangle (f, gc, x, y, width, height)
571 int x, y; 673 int x, y;
572 unsigned int width, height; 674 unsigned int width, height;
573{ 675{
676#if USE_CG_DRAWING
677 CGContextRef context;
678
679 context = mac_begin_cg_clip (f, gc);
680 CG_SET_FILL_COLOR (context, gc->xgcv.foreground);
681 CGContextFillRect (context, CGRectMake (x, y, width, height));
682 mac_end_cg_clip (f);
683#else
574 Rect r; 684 Rect r;
575 685
576 SetPortWindowPort (FRAME_MAC_WINDOW (f)); 686 SetPortWindowPort (FRAME_MAC_WINDOW (f));
@@ -581,6 +691,7 @@ mac_fill_rectangle (f, gc, x, y, width, height)
581 mac_begin_clip (gc); 691 mac_begin_clip (gc);
582 PaintRect (&r); /* using foreground color of gc */ 692 PaintRect (&r); /* using foreground color of gc */
583 mac_end_clip (gc); 693 mac_end_clip (gc);
694#endif
584} 695}
585 696
586 697
@@ -593,16 +704,26 @@ mac_draw_rectangle (f, gc, x, y, width, height)
593 int x, y; 704 int x, y;
594 unsigned int width, height; 705 unsigned int width, height;
595{ 706{
707#if USE_CG_DRAWING
708 CGContextRef context;
709
710 context = mac_begin_cg_clip (f, gc);
711 CG_SET_STROKE_COLOR (context, gc->xgcv.foreground);
712 CGContextStrokeRect (context,
713 CGRectMake (x + 0.5f, y + 0.5f, width, height));
714 mac_end_cg_clip (f);
715#else
596 Rect r; 716 Rect r;
597 717
598 SetPortWindowPort (FRAME_MAC_WINDOW (f)); 718 SetPortWindowPort (FRAME_MAC_WINDOW (f));
599 719
600 RGBForeColor (GC_FORE_COLOR (gc)); 720 RGBForeColor (GC_FORE_COLOR (gc));
601 SetRect (&r, x, y, x + width, y + height); 721 SetRect (&r, x, y, x + width + 1, y + height + 1);
602 722
603 mac_begin_clip (gc); 723 mac_begin_clip (gc);
604 FrameRect (&r); /* using foreground color of gc */ 724 FrameRect (&r); /* using foreground color of gc */
605 mac_end_clip (gc); 725 mac_end_clip (gc);
726#endif
606} 727}
607 728
608 729
@@ -672,6 +793,9 @@ mac_invert_rectangle (f, x, y, width, height)
672{ 793{
673 Rect r; 794 Rect r;
674 795
796#if USE_CG_DRAWING
797 mac_prepare_for_quickdraw (f);
798#endif
675 SetPortWindowPort (FRAME_MAC_WINDOW (f)); 799 SetPortWindowPort (FRAME_MAC_WINDOW (f));
676 800
677 SetRect (&r, x, y, x + width, y + height); 801 SetRect (&r, x, y, x + width, y + height);
@@ -717,6 +841,9 @@ mac_draw_string_common (f, gc, x, y, buf, nchars, bg_width, bytes_per_char)
717 if (!mac_use_core_graphics) 841 if (!mac_use_core_graphics)
718 { 842 {
719#endif 843#endif
844#if USE_CG_DRAWING
845 mac_prepare_for_quickdraw (f);
846#endif
720 mac_begin_clip (gc); 847 mac_begin_clip (gc);
721 RGBForeColor (GC_FORE_COLOR (gc)); 848 RGBForeColor (GC_FORE_COLOR (gc));
722 if (bg_width) 849 if (bg_width)
@@ -745,6 +872,9 @@ mac_draw_string_common (f, gc, x, y, buf, nchars, bg_width, bytes_per_char)
745 ByteCount sizes[] = {sizeof (CGContextRef)}; 872 ByteCount sizes[] = {sizeof (CGContextRef)};
746 ATSUAttributeValuePtr values[] = {&context}; 873 ATSUAttributeValuePtr values[] = {&context};
747 874
875#if USE_CG_DRAWING
876 context = mac_begin_cg_clip (f, gc);
877#else
748 GetPort (&port); 878 GetPort (&port);
749 QDBeginCGContext (port, &context); 879 QDBeginCGContext (port, &context);
750 if (gc->n_clip_rects || bg_width) 880 if (gc->n_clip_rects || bg_width)
@@ -754,14 +884,10 @@ mac_draw_string_common (f, gc, x, y, buf, nchars, bg_width, bytes_per_char)
754 if (gc->n_clip_rects) 884 if (gc->n_clip_rects)
755 CGContextClipToRects (context, gc->clip_rects, 885 CGContextClipToRects (context, gc->clip_rects,
756 gc->n_clip_rects); 886 gc->n_clip_rects);
887#endif
757 if (bg_width) 888 if (bg_width)
758 { 889 {
759 CGContextSetRGBFillColor 890 CG_SET_FILL_COLOR (context, gc->xgcv.background);
760 (context,
761 RED_FROM_ULONG (gc->xgcv.background) / 255.0f,
762 GREEN_FROM_ULONG (gc->xgcv.background) / 255.0f,
763 BLUE_FROM_ULONG (gc->xgcv.background) / 255.0f,
764 1.0);
765 CGContextFillRect 891 CGContextFillRect
766 (context, 892 (context,
767 CGRectMake (x, y - FONT_BASE (GC_FONT (gc)), 893 CGRectMake (x, y - FONT_BASE (GC_FONT (gc)),
@@ -769,13 +895,10 @@ mac_draw_string_common (f, gc, x, y, buf, nchars, bg_width, bytes_per_char)
769 } 895 }
770 CGContextScaleCTM (context, 1, -1); 896 CGContextScaleCTM (context, 1, -1);
771 CGContextTranslateCTM (context, 0, -port_height); 897 CGContextTranslateCTM (context, 0, -port_height);
898#if !USE_CG_DRAWING
772 } 899 }
773 CGContextSetRGBFillColor 900#endif
774 (context, 901 CG_SET_FILL_COLOR (context, gc->xgcv.foreground);
775 RED_FROM_ULONG (gc->xgcv.foreground) / 255.0f,
776 GREEN_FROM_ULONG (gc->xgcv.foreground) / 255.0f,
777 BLUE_FROM_ULONG (gc->xgcv.foreground) / 255.0f,
778 1.0);
779 err = ATSUSetLayoutControls (text_layout, 902 err = ATSUSetLayoutControls (text_layout,
780 sizeof (tags) / sizeof (tags[0]), 903 sizeof (tags) / sizeof (tags[0]),
781 tags, sizes, values); 904 tags, sizes, values);
@@ -783,8 +906,13 @@ mac_draw_string_common (f, gc, x, y, buf, nchars, bg_width, bytes_per_char)
783 ATSUDrawText (text_layout, 906 ATSUDrawText (text_layout,
784 kATSUFromTextBeginning, kATSUToTextEnd, 907 kATSUFromTextBeginning, kATSUToTextEnd,
785 Long2Fix (x), Long2Fix (port_height - y)); 908 Long2Fix (x), Long2Fix (port_height - y));
909#if USE_CG_DRAWING
910 mac_end_cg_clip (f);
911 context = NULL;
912#else
786 CGContextSynchronize (context); 913 CGContextSynchronize (context);
787 QDEndCGContext (port, &context); 914 QDEndCGContext (port, &context);
915#endif
788#if 0 916#if 0
789 /* This doesn't work on Mac OS X 10.1. */ 917 /* This doesn't work on Mac OS X 10.1. */
790 ATSUClearLayoutControls (text_layout, 918 ATSUClearLayoutControls (text_layout,
@@ -806,6 +934,9 @@ mac_draw_string_common (f, gc, x, y, buf, nchars, bg_width, bytes_per_char)
806 if (mac_use_core_graphics) 934 if (mac_use_core_graphics)
807 savedFlags = SwapQDTextFlags (kQDUseCGTextRendering); 935 savedFlags = SwapQDTextFlags (kQDUseCGTextRendering);
808#endif 936#endif
937#if USE_CG_DRAWING
938 mac_prepare_for_quickdraw (f);
939#endif
809 mac_begin_clip (gc); 940 mac_begin_clip (gc);
810 RGBForeColor (GC_FORE_COLOR (gc)); 941 RGBForeColor (GC_FORE_COLOR (gc));
811#ifdef MAC_OS8 942#ifdef MAC_OS8
@@ -1113,6 +1244,9 @@ mac_draw_image_string_cg (f, gc, x, y, buf, nchars, bg_width)
1113 buf++; 1244 buf++;
1114 } 1245 }
1115 1246
1247#if USE_CG_DRAWING
1248 context = mac_begin_cg_clip (f, gc);
1249#else
1116 QDBeginCGContext (port, &context); 1250 QDBeginCGContext (port, &context);
1117 if (gc->n_clip_rects || bg_width) 1251 if (gc->n_clip_rects || bg_width)
1118 { 1252 {
@@ -1120,14 +1254,10 @@ mac_draw_image_string_cg (f, gc, x, y, buf, nchars, bg_width)
1120 CGContextScaleCTM (context, 1, -1); 1254 CGContextScaleCTM (context, 1, -1);
1121 if (gc->n_clip_rects) 1255 if (gc->n_clip_rects)
1122 CGContextClipToRects (context, gc->clip_rects, gc->n_clip_rects); 1256 CGContextClipToRects (context, gc->clip_rects, gc->n_clip_rects);
1257#endif
1123 if (bg_width) 1258 if (bg_width)
1124 { 1259 {
1125 CGContextSetRGBFillColor 1260 CG_SET_FILL_COLOR (context, gc->xgcv.background);
1126 (context,
1127 RED_FROM_ULONG (gc->xgcv.background) / 255.0f,
1128 GREEN_FROM_ULONG (gc->xgcv.background) / 255.0f,
1129 BLUE_FROM_ULONG (gc->xgcv.background) / 255.0f,
1130 1.0);
1131 CGContextFillRect 1261 CGContextFillRect
1132 (context, 1262 (context,
1133 CGRectMake (gx, y - FONT_BASE (GC_FONT (gc)), 1263 CGRectMake (gx, y - FONT_BASE (GC_FONT (gc)),
@@ -1135,12 +1265,10 @@ mac_draw_image_string_cg (f, gc, x, y, buf, nchars, bg_width)
1135 } 1265 }
1136 CGContextScaleCTM (context, 1, -1); 1266 CGContextScaleCTM (context, 1, -1);
1137 CGContextTranslateCTM (context, 0, -port_height); 1267 CGContextTranslateCTM (context, 0, -port_height);
1268#if !USE_CG_DRAWING
1138 } 1269 }
1139 CGContextSetRGBFillColor (context, 1270#endif
1140 RED_FROM_ULONG (gc->xgcv.foreground) / 255.0f, 1271 CG_SET_FILL_COLOR (context, gc->xgcv.foreground);
1141 GREEN_FROM_ULONG (gc->xgcv.foreground) / 255.0f,
1142 BLUE_FROM_ULONG (gc->xgcv.foreground) / 255.0f,
1143 1.0);
1144 CGContextSetFont (context, GC_FONT (gc)->cg_font); 1272 CGContextSetFont (context, GC_FONT (gc)->cg_font);
1145 CGContextSetFontSize (context, GC_FONT (gc)->mac_fontsize); 1273 CGContextSetFontSize (context, GC_FONT (gc)->mac_fontsize);
1146 if (GC_FONT (gc)->mac_fontsize <= cg_text_anti_aliasing_threshold) 1274 if (GC_FONT (gc)->mac_fontsize <= cg_text_anti_aliasing_threshold)
@@ -1155,8 +1283,12 @@ mac_draw_image_string_cg (f, gc, x, y, buf, nchars, bg_width)
1155 gx += advances[i].width; 1283 gx += advances[i].width;
1156 } 1284 }
1157#endif 1285#endif
1286#if USE_CG_DRAWING
1287 mac_end_cg_clip (f);
1288#else
1158 CGContextSynchronize (context); 1289 CGContextSynchronize (context);
1159 QDEndCGContext (port, &context); 1290 QDEndCGContext (port, &context);
1291#endif
1160 1292
1161 return 1; 1293 return 1;
1162} 1294}
@@ -1176,6 +1308,9 @@ mac_copy_area (src, f, gc, src_x, src_y, width, height, dest_x, dest_y)
1176{ 1308{
1177 Rect src_r, dest_r; 1309 Rect src_r, dest_r;
1178 1310
1311#if USE_CG_DRAWING
1312 mac_prepare_for_quickdraw (f);
1313#endif
1179 SetPortWindowPort (FRAME_MAC_WINDOW (f)); 1314 SetPortWindowPort (FRAME_MAC_WINDOW (f));
1180 1315
1181 SetRect (&src_r, src_x, src_y, src_x + width, src_y + height); 1316 SetRect (&src_r, src_x, src_y, src_x + width, src_y + height);
@@ -1220,6 +1355,9 @@ mac_copy_area_with_mask (src, mask, f, gc, src_x, src_y,
1220{ 1355{
1221 Rect src_r, dest_r; 1356 Rect src_r, dest_r;
1222 1357
1358#if USE_CG_DRAWING
1359 mac_prepare_for_quickdraw (f);
1360#endif
1223 SetPortWindowPort (FRAME_MAC_WINDOW (f)); 1361 SetPortWindowPort (FRAME_MAC_WINDOW (f));
1224 1362
1225 SetRect (&src_r, src_x, src_y, src_x + width, src_y + height); 1363 SetRect (&src_r, src_x, src_y, src_x + width, src_y + height);
@@ -1269,6 +1407,9 @@ mac_scroll_area (f, gc, src_x, src_y, width, height, dest_x, dest_y)
1269 RgnHandle dummy = NewRgn (); /* For avoiding update events. */ 1407 RgnHandle dummy = NewRgn (); /* For avoiding update events. */
1270 1408
1271 SetRect (&src_r, src_x, src_y, src_x + width, src_y + height); 1409 SetRect (&src_r, src_x, src_y, src_x + width, src_y + height);
1410#if USE_CG_DRAWING
1411 mac_prepare_for_quickdraw (f);
1412#endif
1272 ScrollWindowRect (FRAME_MAC_WINDOW (f), 1413 ScrollWindowRect (FRAME_MAC_WINDOW (f),
1273 &src_r, dest_x - src_x, dest_y - src_y, 1414 &src_r, dest_x - src_x, dest_y - src_y,
1274 kScrollWindowNoOptions, dummy); 1415 kScrollWindowNoOptions, dummy);
@@ -1527,6 +1668,9 @@ x_flush (f)
1527{ 1668{
1528#if TARGET_API_MAC_CARBON 1669#if TARGET_API_MAC_CARBON
1529 BLOCK_INPUT; 1670 BLOCK_INPUT;
1671#if USE_CG_DRAWING
1672 mac_prepare_for_quickdraw (f);
1673#endif
1530 if (f) 1674 if (f)
1531 QDFlushPortBuffer (GetWindowPort (FRAME_MAC_WINDOW (f)), NULL); 1675 QDFlushPortBuffer (GetWindowPort (FRAME_MAC_WINDOW (f)), NULL);
1532 else 1676 else
@@ -2436,7 +2580,7 @@ x_draw_glyph_string_foreground (s)
2436 { 2580 {
2437 struct glyph *g = s->first_glyph + i; 2581 struct glyph *g = s->first_glyph + i;
2438 mac_draw_rectangle (s->f, s->gc, x, s->y, 2582 mac_draw_rectangle (s->f, s->gc, x, s->y,
2439 g->pixel_width, s->height); 2583 g->pixel_width - 1, s->height - 1);
2440 x += g->pixel_width; 2584 x += g->pixel_width;
2441 } 2585 }
2442 } 2586 }
@@ -2515,7 +2659,7 @@ x_draw_composite_glyph_string_foreground (s)
2515 { 2659 {
2516 if (s->gidx == 0) 2660 if (s->gidx == 0)
2517 mac_draw_rectangle (s->f, s->gc, x, s->y, 2661 mac_draw_rectangle (s->f, s->gc, x, s->y,
2518 s->width, s->height); 2662 s->width - 1, s->height - 1);
2519 } 2663 }
2520 else 2664 else
2521 { 2665 {
@@ -3068,15 +3212,15 @@ x_draw_image_foreground (s)
3068 int r = s->img->relief; 3212 int r = s->img->relief;
3069 if (r < 0) r = -r; 3213 if (r < 0) r = -r;
3070 mac_draw_rectangle (s->f, s->gc, x - r, y - r, 3214 mac_draw_rectangle (s->f, s->gc, x - r, y - r,
3071 s->slice.width + r*2, 3215 s->slice.width + r*2 - 1,
3072 s->slice.height + r*2); 3216 s->slice.height + r*2 - 1);
3073 } 3217 }
3074 } 3218 }
3075 } 3219 }
3076 else 3220 else
3077 /* Draw a rectangle if image could not be loaded. */ 3221 /* Draw a rectangle if image could not be loaded. */
3078 mac_draw_rectangle (s->f, s->gc, x, y, 3222 mac_draw_rectangle (s->f, s->gc, x, y,
3079 s->slice.width, s->slice.height); 3223 s->slice.width - 1, s->slice.height - 1);
3080} 3224}
3081 3225
3082 3226
@@ -4593,6 +4737,9 @@ x_scroll_bar_create (w, top, left, width, height, disp_top, disp_height)
4593 r.right = left + width; 4737 r.right = left + width;
4594 r.bottom = disp_top + disp_height; 4738 r.bottom = disp_top + disp_height;
4595 4739
4740#if USE_CG_DRAWING
4741 mac_prepare_for_quickdraw (f);
4742#endif
4596#if TARGET_API_MAC_CARBON 4743#if TARGET_API_MAC_CARBON
4597 ch = NewControl (FRAME_MAC_WINDOW (f), &r, "\p", 4744 ch = NewControl (FRAME_MAC_WINDOW (f), &r, "\p",
4598#if USE_TOOLKIT_SCROLL_BARS 4745#if USE_TOOLKIT_SCROLL_BARS
@@ -4719,6 +4866,9 @@ x_scroll_bar_remove (bar)
4719 4866
4720 BLOCK_INPUT; 4867 BLOCK_INPUT;
4721 4868
4869#if USE_CG_DRAWING
4870 mac_prepare_for_quickdraw (f);
4871#endif
4722 /* Destroy the Mac scroll bar control */ 4872 /* Destroy the Mac scroll bar control */
4723 DisposeControl (SCROLL_BAR_CONTROL_HANDLE (bar)); 4873 DisposeControl (SCROLL_BAR_CONTROL_HANDLE (bar));
4724 4874
@@ -4815,6 +4965,9 @@ XTset_vertical_scroll_bar (w, portion, whole, position)
4815 for them on the frame, we have to clear "under" them. */ 4965 for them on the frame, we have to clear "under" them. */
4816 mac_clear_area (f, left, top, width, height); 4966 mac_clear_area (f, left, top, width, height);
4817 4967
4968#if USE_CG_DRAWING
4969 mac_prepare_for_quickdraw (f);
4970#endif
4818 HideControl (ch); 4971 HideControl (ch);
4819 MoveControl (ch, sb_left + VERTICAL_SCROLL_BAR_WIDTH_TRIM, disp_top); 4972 MoveControl (ch, sb_left + VERTICAL_SCROLL_BAR_WIDTH_TRIM, disp_top);
4820 SizeControl (ch, sb_width - VERTICAL_SCROLL_BAR_WIDTH_TRIM * 2, 4973 SizeControl (ch, sb_width - VERTICAL_SCROLL_BAR_WIDTH_TRIM * 2,
@@ -5245,7 +5398,7 @@ x_draw_hollow_cursor (w, row)
5245 /* Compute frame-relative coordinates for phys cursor. */ 5398 /* Compute frame-relative coordinates for phys cursor. */
5246 x = WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x); 5399 x = WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x);
5247 y = get_phys_cursor_geometry (w, row, cursor_glyph, &h); 5400 y = get_phys_cursor_geometry (w, row, cursor_glyph, &h);
5248 wd = w->phys_cursor_width + 1; 5401 wd = w->phys_cursor_width;
5249 5402
5250 /* The foreground of cursor_gc is typically the same as the normal 5403 /* The foreground of cursor_gc is typically the same as the normal
5251 background color, which can cause the cursor box to be invisible. */ 5404 background color, which can cause the cursor box to be invisible. */
@@ -5259,7 +5412,7 @@ x_draw_hollow_cursor (w, row)
5259 5412
5260 /* Set clipping, draw the rectangle, and reset clipping again. */ 5413 /* Set clipping, draw the rectangle, and reset clipping again. */
5261 x_clip_to_row (w, row, TEXT_AREA, gc); 5414 x_clip_to_row (w, row, TEXT_AREA, gc);
5262 mac_draw_rectangle (f, gc, x, y, wd, h); 5415 mac_draw_rectangle (f, gc, x, y, wd, h - 1);
5263 mac_reset_clip_rectangles (dpy, gc); 5416 mac_reset_clip_rectangles (dpy, gc);
5264} 5417}
5265 5418
@@ -5786,8 +5939,13 @@ x_set_window_size (f, change_gravity, cols, rows)
5786 SizeWindow (FRAME_MAC_WINDOW (f), pixelwidth, pixelheight, 0); 5939 SizeWindow (FRAME_MAC_WINDOW (f), pixelwidth, pixelheight, 0);
5787#if TARGET_API_MAC_CARBON 5940#if TARGET_API_MAC_CARBON
5788 if (f->output_data.mac->hourglass_control) 5941 if (f->output_data.mac->hourglass_control)
5789 MoveControl (f->output_data.mac->hourglass_control, 5942 {
5790 pixelwidth - HOURGLASS_WIDTH, 0); 5943#if USE_CG_DRAWING
5944 mac_prepare_for_quickdraw (f);
5945#endif
5946 MoveControl (f->output_data.mac->hourglass_control,
5947 pixelwidth - HOURGLASS_WIDTH, 0);
5948 }
5791#endif 5949#endif
5792 5950
5793 /* Now, strictly speaking, we can't be sure that this is accurate, 5951 /* Now, strictly speaking, we can't be sure that this is accurate,
@@ -9672,7 +9830,11 @@ XTread_socket (sd, expected, hold_quit)
9672#if USE_CARBON_EVENTS 9830#if USE_CARBON_EVENTS
9673 toolbox_dispatcher = GetEventDispatcherTarget (); 9831 toolbox_dispatcher = GetEventDispatcherTarget ();
9674 9832
9675 while (!ReceiveNextEvent (0, NULL, kEventDurationNoWait, 9833 while (
9834#if USE_CG_DRAWING
9835 mac_prepare_for_quickdraw (NULL),
9836#endif
9837 !ReceiveNextEvent (0, NULL, kEventDurationNoWait,
9676 kEventRemoveFromQueue, &eventRef)) 9838 kEventRemoveFromQueue, &eventRef))
9677#else /* !USE_CARBON_EVENTS */ 9839#else /* !USE_CARBON_EVENTS */
9678 while (mac_wait_next_event (&er, 0, true)) 9840 while (mac_wait_next_event (&er, 0, true))
diff --git a/src/macterm.h b/src/macterm.h
index 42020811e6c..f6807d93487 100644
--- a/src/macterm.h
+++ b/src/macterm.h
@@ -334,6 +334,11 @@ struct mac_output {
334 334
335 /* Hints for the size and the position of a window. */ 335 /* Hints for the size and the position of a window. */
336 XSizeHints *size_hints; 336 XSizeHints *size_hints;
337
338#if USE_CG_DRAWING
339 /* Quartz 2D graphics context. */
340 CGContextRef cg_context;
341#endif
337}; 342};
338 343
339typedef struct mac_output mac_output; 344typedef struct mac_output mac_output;
@@ -563,6 +568,9 @@ extern void mac_unload_font P_ ((struct mac_display_info *, XFontStruct *));
563extern OSErr install_window_handler P_ ((WindowPtr)); 568extern OSErr install_window_handler P_ ((WindowPtr));
564extern void remove_window_handler P_ ((WindowPtr)); 569extern void remove_window_handler P_ ((WindowPtr));
565extern Lisp_Object mac_make_lispy_event_code P_ ((int)); 570extern Lisp_Object mac_make_lispy_event_code P_ ((int));
571#if USE_CG_DRAWING
572extern void mac_prepare_for_quickdraw P_ ((struct frame *));
573#endif
566 574
567#define FONT_TYPE_FOR_UNIBYTE(font, ch) 0 575#define FONT_TYPE_FOR_UNIBYTE(font, ch) 0
568#define FONT_TYPE_FOR_MULTIBYTE(font, ch) 0 576#define FONT_TYPE_FOR_MULTIBYTE(font, ch) 0
diff --git a/src/w32fns.c b/src/w32fns.c
index c116c51603b..08b6ed8b1a4 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -2695,6 +2695,24 @@ w32_msg_worker (dw)
2695} 2695}
2696 2696
2697static void 2697static void
2698signal_user_input ()
2699{
2700 /* Interrupt any lisp that wants to be interrupted by input. */
2701 if (!NILP (Vthrow_on_input))
2702 {
2703 Vquit_flag = Vthrow_on_input;
2704 /* If we're inside a function that wants immediate quits,
2705 do it now. */
2706 if (immediate_quit && NILP (Vinhibit_quit))
2707 {
2708 immediate_quit = 0;
2709 QUIT;
2710 }
2711 }
2712}
2713
2714
2715static void
2698post_character_message (hwnd, msg, wParam, lParam, modifiers) 2716post_character_message (hwnd, msg, wParam, lParam, modifiers)
2699 HWND hwnd; 2717 HWND hwnd;
2700 UINT msg; 2718 UINT msg;
@@ -2751,6 +2769,8 @@ post_character_message (hwnd, msg, wParam, lParam, modifiers)
2751 to receive C-g to interrupt the lisp thread. */ 2769 to receive C-g to interrupt the lisp thread. */
2752 cancel_all_deferred_msgs (); 2770 cancel_all_deferred_msgs ();
2753 } 2771 }
2772 else
2773 signal_user_input ();
2754 } 2774 }
2755 2775
2756 my_post_msg (&wmsg, hwnd, msg, wParam, lParam); 2776 my_post_msg (&wmsg, hwnd, msg, wParam, lParam);
@@ -3270,6 +3290,7 @@ w32_wnd_proc (hwnd, msg, wParam, lParam)
3270 3290
3271 wmsg.dwModifiers = w32_get_modifiers (); 3291 wmsg.dwModifiers = w32_get_modifiers ();
3272 my_post_msg (&wmsg, hwnd, msg, wParam, lParam); 3292 my_post_msg (&wmsg, hwnd, msg, wParam, lParam);
3293 signal_user_input ();
3273 3294
3274 /* Need to return true for XBUTTON messages, false for others, 3295 /* Need to return true for XBUTTON messages, false for others,
3275 to indicate that we processed the message. */ 3296 to indicate that we processed the message. */
@@ -3324,11 +3345,13 @@ w32_wnd_proc (hwnd, msg, wParam, lParam)
3324 case WM_MOUSEWHEEL: 3345 case WM_MOUSEWHEEL:
3325 wmsg.dwModifiers = w32_get_modifiers (); 3346 wmsg.dwModifiers = w32_get_modifiers ();
3326 my_post_msg (&wmsg, hwnd, msg, wParam, lParam); 3347 my_post_msg (&wmsg, hwnd, msg, wParam, lParam);
3348 signal_user_input ();
3327 return 0; 3349 return 0;
3328 3350
3329 case WM_DROPFILES: 3351 case WM_DROPFILES:
3330 wmsg.dwModifiers = w32_get_modifiers (); 3352 wmsg.dwModifiers = w32_get_modifiers ();
3331 my_post_msg (&wmsg, hwnd, msg, wParam, lParam); 3353 my_post_msg (&wmsg, hwnd, msg, wParam, lParam);
3354 signal_user_input ();
3332 return 0; 3355 return 0;
3333 3356
3334 case WM_TIMER: 3357 case WM_TIMER:
@@ -3338,6 +3361,7 @@ w32_wnd_proc (hwnd, msg, wParam, lParam)
3338 if (saved_mouse_button_msg.msg.hwnd) 3361 if (saved_mouse_button_msg.msg.hwnd)
3339 { 3362 {
3340 post_msg (&saved_mouse_button_msg); 3363 post_msg (&saved_mouse_button_msg);
3364 signal_user_input ();
3341 saved_mouse_button_msg.msg.hwnd = 0; 3365 saved_mouse_button_msg.msg.hwnd = 0;
3342 } 3366 }
3343 KillTimer (hwnd, mouse_button_timer); 3367 KillTimer (hwnd, mouse_button_timer);
@@ -3840,6 +3864,7 @@ w32_wnd_proc (hwnd, msg, wParam, lParam)
3840 { 3864 {
3841 wmsg.dwModifiers = w32_get_modifiers (); 3865 wmsg.dwModifiers = w32_get_modifiers ();
3842 my_post_msg (&wmsg, hwnd, msg, wParam, lParam); 3866 my_post_msg (&wmsg, hwnd, msg, wParam, lParam);
3867 signal_user_input ();
3843 return 0; 3868 return 0;
3844 } 3869 }
3845 3870
@@ -4344,17 +4369,6 @@ This function is an internal primitive--use `make-frame' instead. */)
4344 x_wm_set_size_hint (f, window_prompting, 0); 4369 x_wm_set_size_hint (f, window_prompting, 0);
4345 UNBLOCK_INPUT; 4370 UNBLOCK_INPUT;
4346 4371
4347 /* Avoid a bug that causes the new frame to never become visible if
4348 an echo area message is displayed during the following call1. */
4349 specbind(Qredisplay_dont_pause, Qt);
4350
4351 /* Set up faces after all frame parameters are known. This call
4352 also merges in face attributes specified for new frames. If we
4353 don't do this, the `menu' face for instance won't have the right
4354 colors, and the menu bar won't appear in the specified colors for
4355 new frames. */
4356 call1 (Qface_set_after_frame_default, frame);
4357
4358 /* Make the window appear on the frame and enable display, unless 4372 /* Make the window appear on the frame and enable display, unless
4359 the caller says not to. However, with explicit parent, Emacs 4373 the caller says not to. However, with explicit parent, Emacs
4360 cannot control visibility, so don't try. */ 4374 cannot control visibility, so don't try. */
diff --git a/src/w32menu.c b/src/w32menu.c
index 57db01ac9e9..389e6c5b856 100644
--- a/src/w32menu.c
+++ b/src/w32menu.c
@@ -819,8 +819,10 @@ cached information about equivalent key sequences. */)
819 } 819 }
820 820
821#ifdef HAVE_MENUS 821#ifdef HAVE_MENUS
822 /* If resources from a previous popup menu exist yet, does nothing 822 /* If resources from a previous popup menu still exist, does nothing
823 until the `menu_free_timer' has freed them (see w32fns.c). 823 until the `menu_free_timer' has freed them (see w32fns.c). This
824 can occur if you press ESC or click outside a menu without selecting
825 a menu item.
824 */ 826 */
825 if (current_popup_menu) 827 if (current_popup_menu)
826 { 828 {
@@ -837,6 +839,8 @@ cached information about equivalent key sequences. */)
837 UNBLOCK_INPUT; 839 UNBLOCK_INPUT;
838 840
839 discard_menu_items (); 841 discard_menu_items ();
842 w32_free_menu_strings (FRAME_W32_WINDOW (f));
843
840#endif /* HAVE_MENUS */ 844#endif /* HAVE_MENUS */
841 845
842 UNGCPRO; 846 UNGCPRO;
diff --git a/src/w32term.c b/src/w32term.c
index bd04f0cb4b5..d7c9bc8c159 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -183,6 +183,7 @@ int last_scroll_bar_drag_pos;
183/* Where the mouse was last time we reported a mouse event. */ 183/* Where the mouse was last time we reported a mouse event. */
184 184
185static RECT last_mouse_glyph; 185static RECT last_mouse_glyph;
186static FRAME_PTR last_mouse_glyph_frame;
186static Lisp_Object last_mouse_press_frame; 187static Lisp_Object last_mouse_press_frame;
187 188
188int w32_num_mouse_buttons; 189int w32_num_mouse_buttons;
@@ -3221,11 +3222,13 @@ note_mouse_movement (frame, msg)
3221 frame->mouse_moved = 1; 3222 frame->mouse_moved = 1;
3222 last_mouse_scroll_bar = Qnil; 3223 last_mouse_scroll_bar = Qnil;
3223 note_mouse_highlight (frame, -1, -1); 3224 note_mouse_highlight (frame, -1, -1);
3225 last_mouse_glyph_frame = 0;
3224 return 1; 3226 return 1;
3225 } 3227 }
3226 3228
3227 /* Has the mouse moved off the glyph it was on at the last sighting? */ 3229 /* Has the mouse moved off the glyph it was on at the last sighting? */
3228 if (mouse_x < last_mouse_glyph.left 3230 if (frame != last_mouse_glyph_frame
3231 || mouse_x < last_mouse_glyph.left
3229 || mouse_x >= last_mouse_glyph.right 3232 || mouse_x >= last_mouse_glyph.right
3230 || mouse_y < last_mouse_glyph.top 3233 || mouse_y < last_mouse_glyph.top
3231 || mouse_y >= last_mouse_glyph.bottom) 3234 || mouse_y >= last_mouse_glyph.bottom)
@@ -3238,6 +3241,7 @@ note_mouse_movement (frame, msg)
3238 to keep track of the mouse for help_echo and highlighting at 3241 to keep track of the mouse for help_echo and highlighting at
3239 other times. */ 3242 other times. */
3240 remember_mouse_glyph (frame, mouse_x, mouse_y, &last_mouse_glyph); 3243 remember_mouse_glyph (frame, mouse_x, mouse_y, &last_mouse_glyph);
3244 last_mouse_glyph_frame = frame;
3241 return 1; 3245 return 1;
3242 } 3246 }
3243 3247
@@ -3361,19 +3365,9 @@ w32_mouse_position (fp, insist, bar_window, part, x, y, time)
3361 on it, i.e. into the same rectangles that matrices on 3365 on it, i.e. into the same rectangles that matrices on
3362 the frame are divided into. */ 3366 the frame are divided into. */
3363 3367
3364#if OLD_REDISPLAY_CODE
3365 int ignore1, ignore2;
3366
3367 ScreenToClient (FRAME_W32_WINDOW (f1), &pt);
3368
3369 pixel_to_glyph_coords (f1, pt.x, pt.y, &ignore1, &ignore2,
3370 &last_mouse_glyph,
3371 FRAME_W32_DISPLAY_INFO (f1)->grabbed
3372 || insist);
3373#else
3374 ScreenToClient (FRAME_W32_WINDOW (f1), &pt); 3368 ScreenToClient (FRAME_W32_WINDOW (f1), &pt);
3375 remember_mouse_glyph (f1, pt.x, pt.y, &last_mouse_glyph); 3369 remember_mouse_glyph (f1, pt.x, pt.y, &last_mouse_glyph);
3376#endif 3370 last_mouse_glyph_frame = f1;
3377 3371
3378 *bar_window = Qnil; 3372 *bar_window = Qnil;
3379 *part = 0; 3373 *part = 0;
diff --git a/src/xterm.c b/src/xterm.c
index 80b8c914f5b..378373fe791 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -7547,18 +7547,17 @@ x_uncatch_errors ()
7547{ 7547{
7548 struct x_error_message_stack *tmp; 7548 struct x_error_message_stack *tmp;
7549 7549
7550 BLOCK_INPUT;
7551
7550 /* The display may have been closed before this function is called. 7552 /* The display may have been closed before this function is called.
7551 Check if it is still open before calling XSync. */ 7553 Check if it is still open before calling XSync. */
7552 if (x_display_info_for_display (x_error_message->dpy) != 0) 7554 if (x_display_info_for_display (x_error_message->dpy) != 0)
7553 { 7555 XSync (x_error_message->dpy, False);
7554 BLOCK_INPUT;
7555 XSync (x_error_message->dpy, False);
7556 UNBLOCK_INPUT;
7557 }
7558 7556
7559 tmp = x_error_message; 7557 tmp = x_error_message;
7560 x_error_message = x_error_message->prev; 7558 x_error_message = x_error_message->prev;
7561 xfree (tmp); 7559 xfree (tmp);
7560 UNBLOCK_INPUT;
7562} 7561}
7563 7562
7564/* If any X protocol errors have arrived since the last call to 7563/* If any X protocol errors have arrived since the last call to