aboutsummaryrefslogtreecommitdiffstats
path: root/src/macterm.c
diff options
context:
space:
mode:
authorKaroly Lorentey2005-01-06 15:00:09 +0000
committerKaroly Lorentey2005-01-06 15:00:09 +0000
commit0feecea9fb7079a2c1fbfee32a992449a22cf478 (patch)
tree0826d68e3dc2ce370c7bd4dae7db3cffc3568321 /src/macterm.c
parent17d51b68fb4e7da4f18eff72c589b7ffc4f9c22c (diff)
parent1a63439b34c3455a317feda5c271dfdb7af0296b (diff)
downloademacs-0feecea9fb7079a2c1fbfee32a992449a22cf478.tar.gz
emacs-0feecea9fb7079a2c1fbfee32a992449a22cf478.zip
Merged in changes from CVS trunk.
Patches applied: * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-747 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-748 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-749 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-751 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-752 Update from CVS * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-78 Merge from emacs--cvs-trunk--0 * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-79 Update from CVS * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-80 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-278
Diffstat (limited to 'src/macterm.c')
-rw-r--r--src/macterm.c748
1 files changed, 496 insertions, 252 deletions
diff --git a/src/macterm.c b/src/macterm.c
index da3dcb15ee8..382400d1d85 100644
--- a/src/macterm.c
+++ b/src/macterm.c
@@ -1178,7 +1178,17 @@ static void
1178x_update_begin (f) 1178x_update_begin (f)
1179 struct frame *f; 1179 struct frame *f;
1180{ 1180{
1181 /* Nothing to do. */ 1181#if TARGET_API_MAC_CARBON
1182 /* During update of a frame, availability of input events is
1183 periodically checked with ReceiveNextEvent if
1184 redisplay-dont-pause is nil. That normally flushes window buffer
1185 changes for every check, and thus screen update looks waving even
1186 if no input is available. So we disable screen updates during
1187 update of a frame. */
1188 BLOCK_INPUT;
1189 DisableScreenUpdates ();
1190 UNBLOCK_INPUT;
1191#endif
1182} 1192}
1183 1193
1184 1194
@@ -1263,7 +1273,7 @@ mac_draw_vertical_window_border (w, x, y0, y1)
1263 make sure that the mouse-highlight is properly redrawn. 1273 make sure that the mouse-highlight is properly redrawn.
1264 1274
1265 W may be a menu bar pseudo-window in case we don't have X toolkit 1275 W may be a menu bar pseudo-window in case we don't have X toolkit
1266 support. Such windows don't have a cursor, so don't display it 1276 support. Such windows don't have a cursor, so don't display it
1267 here. */ 1277 here. */
1268 1278
1269static void 1279static void
@@ -1327,6 +1337,9 @@ x_update_end (f)
1327 1337
1328 mac_set_backcolor (FRAME_BACKGROUND_PIXEL (f)); 1338 mac_set_backcolor (FRAME_BACKGROUND_PIXEL (f));
1329 1339
1340#if TARGET_API_MAC_CARBON
1341 EnableScreenUpdates ();
1342#endif
1330 XFlush (FRAME_MAC_DISPLAY (f)); 1343 XFlush (FRAME_MAC_DISPLAY (f));
1331 UNBLOCK_INPUT; 1344 UNBLOCK_INPUT;
1332} 1345}
@@ -1983,7 +1996,7 @@ x_draw_glyph_string_background (s, force_p)
1983 } 1996 }
1984 else 1997 else
1985#endif 1998#endif
1986#if 0 /* defined(MAC_OS8)*/ 1999#ifdef MAC_OS8
1987 if (FONT_HEIGHT (s->font) < s->height - 2 * box_line_width 2000 if (FONT_HEIGHT (s->font) < s->height - 2 * box_line_width
1988 || s->font_not_found_p 2001 || s->font_not_found_p
1989 || s->extends_to_end_of_line_p 2002 || s->extends_to_end_of_line_p
@@ -2041,7 +2054,7 @@ x_draw_glyph_string_foreground (s)
2041 for (i = 0; i < s->nchars; ++i) 2054 for (i = 0; i < s->nchars; ++i)
2042 char1b[i] = s->char2b[i].byte2; 2055 char1b[i] = s->char2b[i].byte2;
2043 2056
2044#if 0 /* defined(MAC_OS8) */ 2057#ifdef MAC_OS8
2045 /* Draw text with XDrawString if background has already been 2058 /* Draw text with XDrawString if background has already been
2046 filled. Otherwise, use XDrawImageString. (Note that 2059 filled. Otherwise, use XDrawImageString. (Note that
2047 XDrawImageString is usually faster than XDrawString.) Always 2060 XDrawImageString is usually faster than XDrawString.) Always
@@ -2059,7 +2072,7 @@ x_draw_glyph_string_foreground (s)
2059 XDrawString (s->display, s->window, s->gc, x, 2072 XDrawString (s->display, s->window, s->gc, x,
2060 s->ybase - boff, char1b, s->nchars); 2073 s->ybase - boff, char1b, s->nchars);
2061 } 2074 }
2062#if 0 /* defined(MAC_OS8)*/ 2075#ifdef MAC_OS8
2063 else 2076 else
2064 { 2077 {
2065 if (s->two_byte_p) 2078 if (s->two_byte_p)
@@ -3652,6 +3665,7 @@ x_get_keysym_name (keysym)
3652 3665
3653 3666
3654 3667
3668#if 0
3655/* Mouse clicks and mouse movement. Rah. */ 3669/* Mouse clicks and mouse movement. Rah. */
3656 3670
3657/* Prepare a mouse-event in *RESULT for placement in the input queue. 3671/* Prepare a mouse-event in *RESULT for placement in the input queue.
@@ -3685,6 +3699,7 @@ construct_mouse_click (result, event, f)
3685 result->arg = Qnil; 3699 result->arg = Qnil;
3686 return Qnil; 3700 return Qnil;
3687} 3701}
3702#endif
3688 3703
3689 3704
3690/* Function to report a mouse movement to the mainstream Emacs code. 3705/* Function to report a mouse movement to the mainstream Emacs code.
@@ -3754,8 +3769,6 @@ int disable_mouse_highlight;
3754 3769
3755static struct scroll_bar *x_window_to_scroll_bar (); 3770static struct scroll_bar *x_window_to_scroll_bar ();
3756static void x_scroll_bar_report_motion (); 3771static void x_scroll_bar_report_motion ();
3757static void x_check_fullscreen P_ ((struct frame *));
3758static void x_check_fullscreen_move P_ ((struct frame *));
3759static int glyph_rect P_ ((struct frame *f, int, int, Rect *)); 3772static int glyph_rect P_ ((struct frame *f, int, int, Rect *));
3760 3773
3761 3774
@@ -4017,7 +4030,7 @@ x_scroll_bar_create (w, top, left, width, height, disp_top, disp_height)
4017 r.right = left + width; 4030 r.right = left + width;
4018 r.bottom = disp_top + disp_height; 4031 r.bottom = disp_top + disp_height;
4019 4032
4020#ifdef TARGET_API_MAC_CARBON 4033#if TARGET_API_MAC_CARBON
4021 ch = NewControl (FRAME_MAC_WINDOW (f), &r, "\p", 1, 0, 0, 0, 4034 ch = NewControl (FRAME_MAC_WINDOW (f), &r, "\p", 1, 0, 0, 0,
4022 kControlScrollBarProc, 0L); 4035 kControlScrollBarProc, 0L);
4023#else 4036#else
@@ -4395,7 +4408,7 @@ activate_scroll_bars (frame)
4395 while (! NILP (bar)) 4408 while (! NILP (bar))
4396 { 4409 {
4397 ch = SCROLL_BAR_CONTROL_HANDLE (XSCROLL_BAR (bar)); 4410 ch = SCROLL_BAR_CONTROL_HANDLE (XSCROLL_BAR (bar));
4398#ifdef TARGET_API_MAC_CARBON 4411#if 1 /* TARGET_API_MAC_CARBON */
4399 ActivateControl (ch); 4412 ActivateControl (ch);
4400#else 4413#else
4401 SetControlMaximum (ch, 4414 SetControlMaximum (ch,
@@ -4419,10 +4432,10 @@ deactivate_scroll_bars (frame)
4419 while (! NILP (bar)) 4432 while (! NILP (bar))
4420 { 4433 {
4421 ch = SCROLL_BAR_CONTROL_HANDLE (XSCROLL_BAR (bar)); 4434 ch = SCROLL_BAR_CONTROL_HANDLE (XSCROLL_BAR (bar));
4422#ifdef TARGET_API_MAC_CARBON 4435#if 1 /* TARGET_API_MAC_CARBON */
4423 DeactivateControl (ch); 4436 DeactivateControl (ch);
4424#else 4437#else
4425 SetControlMaximum (ch, XINT (-1)); 4438 SetControlMaximum (ch, -1);
4426#endif 4439#endif
4427 bar = XSCROLL_BAR (bar)->next; 4440 bar = XSCROLL_BAR (bar)->next;
4428 } 4441 }
@@ -4466,7 +4479,7 @@ x_scroll_bar_handle_click (bar, part_code, er, bufp)
4466 case kControlPageDownPart: 4479 case kControlPageDownPart:
4467 bufp->part = scroll_bar_below_handle; 4480 bufp->part = scroll_bar_below_handle;
4468 break; 4481 break;
4469#ifdef TARGET_API_MAC_CARBON 4482#if TARGET_API_MAC_CARBON
4470 default: 4483 default:
4471#else 4484#else
4472 case kControlIndicatorPart: 4485 case kControlIndicatorPart:
@@ -4974,13 +4987,16 @@ x_new_font (f, fontname)
4974 XSetFont (FRAME_MAC_DISPLAY (f), f->output_data.mac->cursor_gc, 4987 XSetFont (FRAME_MAC_DISPLAY (f), f->output_data.mac->cursor_gc,
4975 FRAME_FONT (f)); 4988 FRAME_FONT (f));
4976 4989
4990 /* Don't change the size of a tip frame; there's no point in
4991 doing it because it's done in Fx_show_tip, and it leads to
4992 problems because the tip frame has no widget. */
4977 if (NILP (tip_frame) || XFRAME (tip_frame) != f) 4993 if (NILP (tip_frame) || XFRAME (tip_frame) != f)
4978 x_set_window_size (f, 0, FRAME_COLS (f), FRAME_LINES (f)); 4994 x_set_window_size (f, 0, FRAME_COLS (f), FRAME_LINES (f));
4979 } 4995 }
4980 4996
4981 return build_string (fontp->full_name); 4997 return build_string (fontp->full_name);
4982} 4998}
4983 4999
4984/* Give frame F the fontset named FONTSETNAME as its default font, and 5000/* Give frame F the fontset named FONTSETNAME as its default font, and
4985 return the full name of that fontset. FONTSETNAME may be a wildcard 5001 return the full name of that fontset. FONTSETNAME may be a wildcard
4986 pattern; in that case, we choose some fontset that fits the pattern. 5002 pattern; in that case, we choose some fontset that fits the pattern.
@@ -5369,6 +5385,25 @@ x_make_frame_visible (f)
5369 5385
5370 f->output_data.mac->asked_for_visible = 1; 5386 f->output_data.mac->asked_for_visible = 1;
5371 5387
5388#if TARGET_API_MAC_CARBON
5389 if (!(FRAME_SIZE_HINTS (f)->flags & (USPosition | PPosition)))
5390 {
5391 struct frame *sf = SELECTED_FRAME ();
5392 if (!FRAME_MAC_P (sf))
5393 RepositionWindow (FRAME_MAC_WINDOW (f), NULL,
5394 kWindowCenterOnMainScreen);
5395 else
5396 RepositionWindow (FRAME_MAC_WINDOW (f),
5397 FRAME_MAC_WINDOW (sf),
5398#ifdef MAC_OS_X_VERSION_10_2
5399 kWindowCascadeStartAtParentWindowScreen
5400#else
5401 kWindowCascadeOnParentWindowScreen
5402#endif
5403 );
5404 x_real_positions (f, &f->left_pos, &f->top_pos);
5405 }
5406#endif
5372 ShowWindow (FRAME_MAC_WINDOW (f)); 5407 ShowWindow (FRAME_MAC_WINDOW (f));
5373 } 5408 }
5374 5409
@@ -5496,6 +5531,9 @@ x_free_frame_resources (f)
5496 5531
5497 x_free_gcs (f); 5532 x_free_gcs (f);
5498 5533
5534 if (FRAME_SIZE_HINTS (f))
5535 xfree (FRAME_SIZE_HINTS (f));
5536
5499 xfree (f->output_data.mac); 5537 xfree (f->output_data.mac);
5500 f->output_data.mac = NULL; 5538 f->output_data.mac = NULL;
5501 5539
@@ -5548,143 +5586,39 @@ x_wm_set_size_hint (f, flags, user_position)
5548 long flags; 5586 long flags;
5549 int user_position; 5587 int user_position;
5550{ 5588{
5551#if 0 /* MAC_TODO: connect this to the Appearance Manager */ 5589 int base_width, base_height, width_inc, height_inc;
5552 XSizeHints size_hints; 5590 int min_rows = 0, min_cols = 0;
5553 5591 XSizeHints *size_hints;
5554#ifdef USE_X_TOOLKIT
5555 Arg al[2];
5556 int ac = 0;
5557 Dimension widget_width, widget_height;
5558 Window window = XtWindow (f->output_data.x->widget);
5559#else /* not USE_X_TOOLKIT */
5560 Window window = FRAME_X_WINDOW (f);
5561#endif /* not USE_X_TOOLKIT */
5562
5563 /* Setting PMaxSize caused various problems. */
5564 size_hints.flags = PResizeInc | PMinSize /* | PMaxSize */;
5565
5566 size_hints.x = f->left_pos;
5567 size_hints.y = f->top_pos;
5568
5569#ifdef USE_X_TOOLKIT
5570 XtSetArg (al[ac], XtNwidth, &widget_width); ac++;
5571 XtSetArg (al[ac], XtNheight, &widget_height); ac++;
5572 XtGetValues (f->output_data.x->widget, al, ac);
5573 size_hints.height = widget_height;
5574 size_hints.width = widget_width;
5575#else /* not USE_X_TOOLKIT */
5576 size_hints.height = FRAME_PIXEL_HEIGHT (f);
5577 size_hints.width = FRAME_PIXEL_WIDTH (f);
5578#endif /* not USE_X_TOOLKIT */
5579
5580 size_hints.width_inc = FRAME_COLUMN_WIDTH (f);
5581 size_hints.height_inc = FRAME_LINE_HEIGHT (f);
5582 size_hints.max_width
5583 = FRAME_X_DISPLAY_INFO (f)->width - FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, 0);
5584 size_hints.max_height
5585 = FRAME_X_DISPLAY_INFO (f)->height - FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, 0);
5586
5587 /* Calculate the base and minimum sizes.
5588
5589 (When we use the X toolkit, we don't do it here.
5590 Instead we copy the values that the widgets are using, below.) */
5591#ifndef USE_X_TOOLKIT
5592 {
5593 int base_width, base_height;
5594 int min_rows = 0, min_cols = 0;
5595
5596 base_width = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, 0);
5597 base_height = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, 0);
5598 5592
5599 check_frame_size (f, &min_rows, &min_cols); 5593 base_width = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, 0);
5594 base_height = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, 0);
5595 width_inc = FRAME_COLUMN_WIDTH (f);
5596 height_inc = FRAME_LINE_HEIGHT (f);
5600 5597
5601 /* The window manager uses the base width hints to calculate the 5598 check_frame_size (f, &min_rows, &min_cols);
5602 current number of rows and columns in the frame while
5603 resizing; min_width and min_height aren't useful for this
5604 purpose, since they might not give the dimensions for a
5605 zero-row, zero-column frame.
5606 5599
5607 We use the base_width and base_height members if we have 5600 size_hints = FRAME_SIZE_HINTS (f);
5608 them; otherwise, we set the min_width and min_height members 5601 if (size_hints == NULL)
5609 to the size for a zero x zero frame. */
5610
5611#ifdef HAVE_X11R4
5612 size_hints.flags |= PBaseSize;
5613 size_hints.base_width = base_width;
5614 size_hints.base_height = base_height;
5615 size_hints.min_width = base_width + min_cols * size_hints.width_inc;
5616 size_hints.min_height = base_height + min_rows * size_hints.height_inc;
5617#else
5618 size_hints.min_width = base_width;
5619 size_hints.min_height = base_height;
5620#endif
5621 }
5622
5623 /* If we don't need the old flags, we don't need the old hint at all. */
5624 if (flags)
5625 { 5602 {
5626 size_hints.flags |= flags; 5603 size_hints = FRAME_SIZE_HINTS (f) = xmalloc (sizeof (XSizeHints));
5627 goto no_read; 5604 bzero (size_hints, sizeof (XSizeHints));
5628 } 5605 }
5629#endif /* not USE_X_TOOLKIT */
5630
5631 {
5632 XSizeHints hints; /* Sometimes I hate X Windows... */
5633 long supplied_return;
5634 int value;
5635
5636#ifdef HAVE_X11R4
5637 value = XGetWMNormalHints (FRAME_X_DISPLAY (f), window, &hints,
5638 &supplied_return);
5639#else
5640 value = XGetNormalHints (FRAME_X_DISPLAY (f), window, &hints);
5641#endif
5642
5643#ifdef USE_X_TOOLKIT
5644 size_hints.base_height = hints.base_height;
5645 size_hints.base_width = hints.base_width;
5646 size_hints.min_height = hints.min_height;
5647 size_hints.min_width = hints.min_width;
5648#endif
5649
5650 if (flags)
5651 size_hints.flags |= flags;
5652 else
5653 {
5654 if (value == 0)
5655 hints.flags = 0;
5656 if (hints.flags & PSize)
5657 size_hints.flags |= PSize;
5658 if (hints.flags & PPosition)
5659 size_hints.flags |= PPosition;
5660 if (hints.flags & USPosition)
5661 size_hints.flags |= USPosition;
5662 if (hints.flags & USSize)
5663 size_hints.flags |= USSize;
5664 }
5665 }
5666
5667#ifndef USE_X_TOOLKIT
5668 no_read:
5669#endif
5670 5606
5671#ifdef PWinGravity 5607 size_hints->flags |= PResizeInc | PMinSize | PBaseSize ;
5672 size_hints.win_gravity = f->win_gravity; 5608 size_hints->width_inc = width_inc;
5673 size_hints.flags |= PWinGravity; 5609 size_hints->height_inc = height_inc;
5610 size_hints->min_width = base_width + min_cols * width_inc;
5611 size_hints->min_height = base_height + min_rows * height_inc;
5612 size_hints->base_width = base_width;
5613 size_hints->base_height = base_height;
5674 5614
5675 if (user_position) 5615 if (flags)
5616 size_hints->flags = flags;
5617 else if (user_position)
5676 { 5618 {
5677 size_hints.flags &= ~ PPosition; 5619 size_hints->flags &= ~ PPosition;
5678 size_hints.flags |= USPosition; 5620 size_hints->flags |= USPosition;
5679 } 5621 }
5680#endif /* PWinGravity */
5681
5682#ifdef HAVE_X11R4
5683 XSetWMNormalHints (FRAME_X_DISPLAY (f), window, &size_hints);
5684#else
5685 XSetNormalHints (FRAME_X_DISPLAY (f), window, &size_hints);
5686#endif
5687#endif /* MAC_TODO */
5688} 5622}
5689 5623
5690#if 0 /* MAC_TODO: hide application instead of iconify? */ 5624#if 0 /* MAC_TODO: hide application instead of iconify? */
@@ -6120,7 +6054,7 @@ init_font_name_table ()
6120 break; 6054 break;
6121 sc = GetTextEncodingBase (encoding); 6055 sc = GetTextEncodingBase (encoding);
6122 decode_mac_font_name (name, sizeof (name), sc); 6056 decode_mac_font_name (name, sizeof (name), sc);
6123 6057
6124 /* Point the instance iterator at the current font family. */ 6058 /* Point the instance iterator at the current font family. */
6125 if (FMResetFontFamilyInstanceIterator (ff, &ffii) != noErr) 6059 if (FMResetFontFamilyInstanceIterator (ff, &ffii) != noErr)
6126 break; 6060 break;
@@ -6259,6 +6193,19 @@ init_font_name_table ()
6259} 6193}
6260 6194
6261 6195
6196void
6197mac_clear_font_name_table ()
6198{
6199 int i;
6200
6201 for (i = 0; i < font_name_count; i++)
6202 xfree (font_name_table[i]);
6203 xfree (font_name_table);
6204 font_name_table = NULL;
6205 font_name_table_size = font_name_count = 0;
6206}
6207
6208
6262enum xlfd_scalable_field_index 6209enum xlfd_scalable_field_index
6263 { 6210 {
6264 XLFD_SCL_PIXEL_SIZE, 6211 XLFD_SCL_PIXEL_SIZE,
@@ -6311,6 +6258,9 @@ mac_do_list_fonts (pattern, maxnames)
6311 char *longest_start, *cur_start, *nonspecial; 6258 char *longest_start, *cur_start, *nonspecial;
6312 int longest_len, cur_len, exact; 6259 int longest_len, cur_len, exact;
6313 6260
6261 if (font_name_table == NULL) /* Initialize when first used. */
6262 init_font_name_table ();
6263
6314 for (i = 0; i < XLFD_SCL_LAST; i++) 6264 for (i = 0; i < XLFD_SCL_LAST; i++)
6315 scl_val[i] = -1; 6265 scl_val[i] = -1;
6316 6266
@@ -6471,9 +6421,6 @@ x_list_fonts (struct frame *f,
6471 Lisp_Object newlist = Qnil, tem, key; 6421 Lisp_Object newlist = Qnil, tem, key;
6472 struct mac_display_info *dpyinfo = f ? FRAME_MAC_DISPLAY_INFO (f) : NULL; 6422 struct mac_display_info *dpyinfo = f ? FRAME_MAC_DISPLAY_INFO (f) : NULL;
6473 6423
6474 if (font_name_table == NULL) /* Initialize when first used. */
6475 init_font_name_table ();
6476
6477 if (dpyinfo) 6424 if (dpyinfo)
6478 { 6425 {
6479 tem = XCDR (dpyinfo->name_list_element); 6426 tem = XCDR (dpyinfo->name_list_element);
@@ -6487,7 +6434,9 @@ x_list_fonts (struct frame *f,
6487 } 6434 }
6488 } 6435 }
6489 6436
6437 BLOCK_INPUT;
6490 newlist = mac_do_list_fonts (SDATA (pattern), maxnames); 6438 newlist = mac_do_list_fonts (SDATA (pattern), maxnames);
6439 UNBLOCK_INPUT;
6491 6440
6492 /* MAC_TODO: add code for matching outline fonts here */ 6441 /* MAC_TODO: add code for matching outline fonts here */
6493 6442
@@ -6791,6 +6740,18 @@ XLoadQueryFont (Display *dpy, char *fontname)
6791} 6740}
6792 6741
6793 6742
6743void
6744mac_unload_font (dpyinfo, font)
6745 struct mac_display_info *dpyinfo;
6746 XFontStruct *font;
6747{
6748 xfree (font->fontname);
6749 if (font->per_char)
6750 xfree (font->per_char);
6751 xfree (font);
6752}
6753
6754
6794/* Load font named FONTNAME of the size SIZE for frame F, and return a 6755/* Load font named FONTNAME of the size SIZE for frame F, and return a
6795 pointer to the structure font_info while allocating it dynamically. 6756 pointer to the structure font_info while allocating it dynamically.
6796 If SIZE is 0, load any size of font. 6757 If SIZE is 0, load any size of font.
@@ -6841,7 +6802,9 @@ x_load_font (f, fontname, size)
6841 if (size > 0 && !NILP (font_names)) 6802 if (size > 0 && !NILP (font_names))
6842 fontname = (char *) SDATA (XCAR (font_names)); 6803 fontname = (char *) SDATA (XCAR (font_names));
6843 6804
6805 BLOCK_INPUT;
6844 font = (MacFontStruct *) XLoadQueryFont (FRAME_MAC_DISPLAY (f), fontname); 6806 font = (MacFontStruct *) XLoadQueryFont (FRAME_MAC_DISPLAY (f), fontname);
6807 UNBLOCK_INPUT;
6845 if (!font) 6808 if (!font)
6846 return NULL; 6809 return NULL;
6847 6810
@@ -7121,15 +7084,21 @@ do_ae_print_documents (const AppleEvent *, AppleEvent *, long);
7121static pascal OSErr do_ae_open_documents (AppleEvent *, AppleEvent *, long); 7084static pascal OSErr do_ae_open_documents (AppleEvent *, AppleEvent *, long);
7122static pascal OSErr do_ae_quit_application (AppleEvent *, AppleEvent *, long); 7085static pascal OSErr do_ae_quit_application (AppleEvent *, AppleEvent *, long);
7123 7086
7087#if TARGET_API_MAC_CARBON
7124/* Drag and Drop */ 7088/* Drag and Drop */
7125static OSErr init_mac_drag_n_drop (); 7089static OSErr init_mac_drag_n_drop ();
7126static pascal OSErr mac_do_receive_drag (WindowPtr, void*, DragReference); 7090static pascal OSErr mac_do_receive_drag (WindowPtr, void*, DragReference);
7091#endif
7127 7092
7128#if USE_CARBON_EVENTS 7093#if USE_CARBON_EVENTS
7129/* Preliminary Support for the OSX Services Menu */ 7094/* Preliminary Support for the OSX Services Menu */
7130static OSStatus mac_handle_service_event (EventHandlerCallRef,EventRef,void*); 7095static OSStatus mac_handle_service_event (EventHandlerCallRef,EventRef,void*);
7131static void init_service_handler (); 7096static void init_service_handler ();
7097/* Window Event Handler */
7098static pascal OSStatus mac_handle_window_event (EventHandlerCallRef,
7099 EventRef, void *);
7132#endif 7100#endif
7101void install_window_handler (WindowPtr);
7133 7102
7134extern void init_emacs_passwd_dir (); 7103extern void init_emacs_passwd_dir ();
7135extern int emacs_main (int, char **, char **); 7104extern int emacs_main (int, char **, char **);
@@ -7336,12 +7305,11 @@ do_window_update (WindowPtr win)
7336{ 7305{
7337 struct frame *f = mac_window_to_frame (win); 7306 struct frame *f = mac_window_to_frame (win);
7338 7307
7339 if (win == tip_window) 7308 BeginUpdate (win);
7340 /* The tooltip has been drawn already. Avoid the
7341 SET_FRAME_GARBAGED below. */
7342 return;
7343 7309
7344 if (f) 7310 /* The tooltip has been drawn already. Avoid the SET_FRAME_GARBAGED
7311 below. */
7312 if (win != tip_window)
7345 { 7313 {
7346 if (f->async_visible == 0) 7314 if (f->async_visible == 0)
7347 { 7315 {
@@ -7358,17 +7326,30 @@ do_window_update (WindowPtr win)
7358 } 7326 }
7359 else 7327 else
7360 { 7328 {
7361 BeginUpdate (win); 7329 Rect r;
7330
7362 handling_window_update = 1; 7331 handling_window_update = 1;
7363 7332
7364 XClearWindow (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f)); 7333#if TARGET_API_MAC_CARBON
7334 {
7335 RgnHandle region = NewRgn ();
7365 7336
7366 expose_frame (f, 0, 0, 0, 0); 7337 GetPortVisibleRegion (GetWindowPort (win), region);
7338 UpdateControls (win, region);
7339 GetRegionBounds (region, &r);
7340 DisposeRgn (region);
7341 }
7342#else
7343 UpdateControls (win, win->visRgn);
7344 r = (*win->visRgn)->rgnBBox;
7345#endif
7346 expose_frame (f, r.left, r.top, r.right - r.left, r.bottom - r.top);
7367 7347
7368 handling_window_update = 0; 7348 handling_window_update = 0;
7369 EndUpdate (win);
7370 } 7349 }
7371 } 7350 }
7351
7352 EndUpdate (win);
7372} 7353}
7373 7354
7374static int 7355static int
@@ -7530,20 +7511,43 @@ do_menu_choice (SInt32 menu_choice)
7530static void 7511static void
7531do_grow_window (WindowPtr w, EventRecord *e) 7512do_grow_window (WindowPtr w, EventRecord *e)
7532{ 7513{
7533 long grow_size;
7534 Rect limit_rect; 7514 Rect limit_rect;
7535 int rows, columns; 7515 int rows, columns, width, height;
7536 struct frame *f = mac_window_to_frame (w); 7516 struct frame *f = mac_window_to_frame (w);
7517 XSizeHints *size_hints = FRAME_SIZE_HINTS (f);
7518 int min_width = MIN_DOC_SIZE, min_height = MIN_DOC_SIZE;
7519#if TARGET_API_MAC_CARBON
7520 Rect new_rect;
7521#else
7522 long grow_size;
7523#endif
7537 7524
7538 SetRect(&limit_rect, MIN_DOC_SIZE, MIN_DOC_SIZE, MAX_DOC_SIZE, MAX_DOC_SIZE); 7525 if (size_hints->flags & PMinSize)
7526 {
7527 min_width = size_hints->min_width;
7528 min_height = size_hints->min_height;
7529 }
7530 SetRect (&limit_rect, min_width, min_height, MAX_DOC_SIZE, MAX_DOC_SIZE);
7539 7531
7532#if TARGET_API_MAC_CARBON
7533 if (!ResizeWindow (w, e->where, &limit_rect, &new_rect))
7534 return;
7535 height = new_rect.bottom - new_rect.top;
7536 width = new_rect.right - new_rect.left;
7537#else
7540 grow_size = GrowWindow (w, e->where, &limit_rect); 7538 grow_size = GrowWindow (w, e->where, &limit_rect);
7541
7542 /* see if it really changed size */ 7539 /* see if it really changed size */
7543 if (grow_size != 0) 7540 if (grow_size == 0)
7541 return;
7542 height = HiWord (grow_size);
7543 width = LoWord (grow_size);
7544#endif
7545
7546 if (width != FRAME_PIXEL_WIDTH (f)
7547 || height != FRAME_PIXEL_HEIGHT (f))
7544 { 7548 {
7545 rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, HiWord (grow_size)); 7549 rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, height);
7546 columns = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, LoWord (grow_size)); 7550 columns = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, width);
7547 7551
7548 x_set_window_size (f, 0, columns, rows); 7552 x_set_window_size (f, 0, columns, rows);
7549 } 7553 }
@@ -7561,7 +7565,7 @@ do_zoom_window (WindowPtr w, int zoom_in_or_out)
7561 GrafPtr save_port; 7565 GrafPtr save_port;
7562 Rect zoom_rect, port_rect; 7566 Rect zoom_rect, port_rect;
7563 Point top_left; 7567 Point top_left;
7564 int w_title_height, columns, rows; 7568 int w_title_height, columns, rows, width, height;
7565 struct frame *f = mac_window_to_frame (w); 7569 struct frame *f = mac_window_to_frame (w);
7566 7570
7567#if TARGET_API_MAC_CARBON 7571#if TARGET_API_MAC_CARBON
@@ -7636,12 +7640,26 @@ do_zoom_window (WindowPtr w, int zoom_in_or_out)
7636#else 7640#else
7637 port_rect = w->portRect; 7641 port_rect = w->portRect;
7638#endif 7642#endif
7639 rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, port_rect.bottom - port_rect.top); 7643 height = port_rect.bottom - port_rect.top;
7640 columns = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, port_rect.right - port_rect.left); 7644 width = port_rect.right - port_rect.left;
7641 x_set_window_size (f, 0, columns, rows); 7645
7646 if (width != FRAME_PIXEL_WIDTH (f)
7647 || height != FRAME_PIXEL_HEIGHT (f))
7648 {
7649 rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, height);
7650 columns = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, width);
7651
7652 change_frame_size (f, rows, columns, 0, 1, 0);
7653 SET_FRAME_GARBAGED (f);
7654 cancel_mouse_face (f);
7655
7656 FRAME_PIXEL_WIDTH (f) = width;
7657 FRAME_PIXEL_HEIGHT (f) = height;
7658 }
7642 x_real_positions (f, &f->left_pos, &f->top_pos); 7659 x_real_positions (f, &f->left_pos, &f->top_pos);
7643} 7660}
7644 7661
7662#if TARGET_API_MAC_CARBON
7645/* Initialize Drag And Drop to allow files to be dropped onto emacs frames */ 7663/* Initialize Drag And Drop to allow files to be dropped onto emacs frames */
7646static OSErr 7664static OSErr
7647init_mac_drag_n_drop () 7665init_mac_drag_n_drop ()
@@ -7649,6 +7667,7 @@ init_mac_drag_n_drop ()
7649 OSErr result = InstallReceiveHandler (mac_do_receive_drag, 0L, NULL); 7667 OSErr result = InstallReceiveHandler (mac_do_receive_drag, 0L, NULL);
7650 return result; 7668 return result;
7651} 7669}
7670#endif
7652 7671
7653/* Intialize AppleEvent dispatcher table for the required events. */ 7672/* Intialize AppleEvent dispatcher table for the required events. */
7654void 7673void
@@ -7819,7 +7838,93 @@ mac_handle_service_event (EventHandlerCallRef callRef,
7819 } 7838 }
7820 return err; 7839 return err;
7821} 7840}
7841
7842
7843static pascal OSStatus
7844mac_handle_window_event (next_handler, event, data)
7845 EventHandlerCallRef next_handler;
7846 EventRef event;
7847 void *data;
7848{
7849 extern Lisp_Object Qcontrol;
7850
7851 WindowPtr wp;
7852 OSStatus result;
7853 UInt32 attributes;
7854 XSizeHints *size_hints;
7855
7856 GetEventParameter (event, kEventParamDirectObject, typeWindowRef,
7857 NULL, sizeof (WindowPtr), NULL, &wp);
7858
7859 switch (GetEventKind (event))
7860 {
7861 case kEventWindowBoundsChanging:
7862 result = CallNextEventHandler (next_handler, event);
7863 if (result != eventNotHandledErr)
7864 return result;
7865
7866 GetEventParameter (event, kEventParamAttributes, typeUInt32,
7867 NULL, sizeof (UInt32), NULL, &attributes);
7868 size_hints = FRAME_SIZE_HINTS (mac_window_to_frame (wp));
7869 if ((attributes & kWindowBoundsChangeUserResize)
7870 && ((size_hints->flags & (PResizeInc | PBaseSize | PMinSize))
7871 == (PResizeInc | PBaseSize | PMinSize)))
7872 {
7873 Rect bounds;
7874 int width, height;
7875
7876 GetEventParameter (event, kEventParamCurrentBounds,
7877 typeQDRectangle,
7878 NULL, sizeof (Rect), NULL, &bounds);
7879 width = bounds.right - bounds.left;
7880 height = bounds.bottom - bounds.top;
7881
7882 if (width < size_hints->min_width)
7883 width = size_hints->min_width;
7884 else
7885 width = size_hints->base_width
7886 + (int) ((width - size_hints->base_width)
7887 / (float) size_hints->width_inc + .5)
7888 * size_hints->width_inc;
7889
7890 if (height < size_hints->min_height)
7891 height = size_hints->min_height;
7892 else
7893 height = size_hints->base_height
7894 + (int) ((height - size_hints->base_height)
7895 / (float) size_hints->height_inc + .5)
7896 * size_hints->height_inc;
7897
7898 bounds.right = bounds.left + width;
7899 bounds.bottom = bounds.top + height;
7900 SetEventParameter (event, kEventParamCurrentBounds,
7901 typeQDRectangle, sizeof (Rect), &bounds);
7902 return noErr;
7903 }
7904 break;
7905 }
7906
7907 return eventNotHandledErr;
7908}
7909#endif /* USE_CARBON_EVENTS */
7910
7911
7912void
7913install_window_handler (window)
7914 WindowPtr window;
7915{
7916#if USE_CARBON_EVENTS
7917 EventTypeSpec specs[] = {{kEventClassWindow, kEventWindowBoundsChanging}};
7918 static EventHandlerUPP handle_window_event_UPP = NULL;
7919
7920 if (handle_window_event_UPP == NULL)
7921 handle_window_event_UPP = NewEventHandlerUPP (mac_handle_window_event);
7922
7923 InstallWindowEventHandler (window, handle_window_event_UPP,
7924 GetEventTypeCount (specs), specs, NULL, NULL);
7822#endif 7925#endif
7926}
7927
7823 7928
7824/* Open Application Apple Event */ 7929/* Open Application Apple Event */
7825static pascal OSErr 7930static pascal OSErr
@@ -7915,6 +8020,7 @@ descriptor_error_exit:
7915} 8020}
7916 8021
7917 8022
8023#if TARGET_API_MAC_CARBON
7918static pascal OSErr 8024static pascal OSErr
7919mac_do_receive_drag (WindowPtr window, void *handlerRefCon, 8025mac_do_receive_drag (WindowPtr window, void *handlerRefCon,
7920 DragReference theDrag) 8026 DragReference theDrag)
@@ -7991,6 +8097,7 @@ mac_do_receive_drag (WindowPtr window, void *handlerRefCon,
7991 } 8097 }
7992 } 8098 }
7993} 8099}
8100#endif
7994 8101
7995 8102
7996/* Print Document Apple Event */ 8103/* Print Document Apple Event */
@@ -8140,6 +8247,45 @@ keycode_to_xkeysym (int keyCode, int *xKeySym)
8140 return *xKeySym != 0; 8247 return *xKeySym != 0;
8141} 8248}
8142 8249
8250#if !USE_CARBON_EVENTS
8251static RgnHandle mouse_region = NULL;
8252
8253Boolean
8254mac_wait_next_event (er, sleep_time, dequeue)
8255 EventRecord *er;
8256 UInt32 sleep_time;
8257 Boolean dequeue;
8258{
8259 static EventRecord er_buf = {nullEvent};
8260 UInt32 target_tick, current_tick;
8261 EventMask event_mask;
8262
8263 if (mouse_region == NULL)
8264 mouse_region = NewRgn ();
8265
8266 event_mask = everyEvent;
8267 if (NILP (Fboundp (Qmac_ready_for_drag_n_drop)))
8268 event_mask -= highLevelEventMask;
8269
8270 current_tick = TickCount ();
8271 target_tick = current_tick + sleep_time;
8272
8273 if (er_buf.what == nullEvent)
8274 while (!WaitNextEvent (event_mask, &er_buf,
8275 target_tick - current_tick, mouse_region))
8276 {
8277 current_tick = TickCount ();
8278 if (target_tick <= current_tick)
8279 return false;
8280 }
8281
8282 *er = er_buf;
8283 if (dequeue)
8284 er_buf.what = nullEvent;
8285 return true;
8286}
8287#endif /* not USE_CARBON_EVENTS */
8288
8143/* Emacs calls this whenever it wants to read an input event from the 8289/* Emacs calls this whenever it wants to read an input event from the
8144 user. */ 8290 user. */
8145int 8291int
@@ -8151,9 +8297,7 @@ XTread_socket (sd, expected, hold_quit)
8151 int count = 0; 8297 int count = 0;
8152#if USE_CARBON_EVENTS 8298#if USE_CARBON_EVENTS
8153 EventRef eventRef; 8299 EventRef eventRef;
8154 EventTargetRef toolbox_dispatcher = GetEventDispatcherTarget (); 8300 EventTargetRef toolbox_dispatcher;
8155#else
8156 EventMask event_mask;
8157#endif 8301#endif
8158 EventRecord er; 8302 EventRecord er;
8159 struct mac_display_info *dpyinfo = &one_mac_display_info; 8303 struct mac_display_info *dpyinfo = &one_mac_display_info;
@@ -8184,16 +8328,14 @@ XTread_socket (sd, expected, hold_quit)
8184 if (terminate_flag) 8328 if (terminate_flag)
8185 Fkill_emacs (make_number (1)); 8329 Fkill_emacs (make_number (1));
8186 8330
8187#if !USE_CARBON_EVENTS 8331#if USE_CARBON_EVENTS
8188 event_mask = everyEvent; 8332 toolbox_dispatcher = GetEventDispatcherTarget ();
8189 if (NILP (Fboundp (Qmac_ready_for_drag_n_drop)))
8190 event_mask -= highLevelEventMask;
8191 8333
8192 while (WaitNextEvent (event_mask, &er, 0L, NULL))
8193#else /* USE_CARBON_EVENTS */
8194 while (!ReceiveNextEvent (0, NULL, kEventDurationNoWait, 8334 while (!ReceiveNextEvent (0, NULL, kEventDurationNoWait,
8195 kEventRemoveFromQueue, &eventRef)) 8335 kEventRemoveFromQueue, &eventRef))
8196#endif /* USE_CARBON_EVENTS */ 8336#else /* !USE_CARBON_EVENTS */
8337 while (mac_wait_next_event (&er, 0, true))
8338#endif /* !USE_CARBON_EVENTS */
8197 { 8339 {
8198 int do_help = 0; 8340 int do_help = 0;
8199 struct frame *f; 8341 struct frame *f;
@@ -8260,6 +8402,7 @@ XTread_socket (sd, expected, hold_quit)
8260 SendEventToEventTarget (eventRef, toolbox_dispatcher); 8402 SendEventToEventTarget (eventRef, toolbox_dispatcher);
8261 8403
8262 break; 8404 break;
8405
8263 default: 8406 default:
8264 /* Send the event to the appropriate receiver. */ 8407 /* Send the event to the appropriate receiver. */
8265 SendEventToEventTarget (eventRef, toolbox_dispatcher); 8408 SendEventToEventTarget (eventRef, toolbox_dispatcher);
@@ -8497,6 +8640,10 @@ XTread_socket (sd, expected, hold_quit)
8497 break; 8640 break;
8498 8641
8499 case mouseMovedMessage: 8642 case mouseMovedMessage:
8643#if !USE_CARBON_EVENTS
8644 SetRectRgn (mouse_region, er.where.h, er.where.v,
8645 er.where.h + 1, er.where.v + 1);
8646#endif
8500 previous_help_echo_string = help_echo_string; 8647 previous_help_echo_string = help_echo_string;
8501 help_echo_string = help_echo_object = help_echo_window = Qnil; 8648 help_echo_string = help_echo_object = help_echo_window = Qnil;
8502 help_echo_pos = -1; 8649 help_echo_pos = -1;
@@ -8697,21 +8844,21 @@ XTread_socket (sd, expected, hold_quit)
8697 unsigned char ch = inev.code; 8844 unsigned char ch = inev.code;
8698 ByteCount actual_input_length, actual_output_length; 8845 ByteCount actual_input_length, actual_output_length;
8699 unsigned char outbuf[32]; 8846 unsigned char outbuf[32];
8700 8847
8701 convert_status = TECConvertText (converter, &ch, 1, 8848 convert_status = TECConvertText (converter, &ch, 1,
8702 &actual_input_length, 8849 &actual_input_length,
8703 outbuf, 1, 8850 outbuf, 1,
8704 &actual_output_length); 8851 &actual_output_length);
8705 if (convert_status == noErr 8852 if (convert_status == noErr
8706 && actual_input_length == 1 8853 && actual_input_length == 1
8707 && actual_output_length == 1) 8854 && actual_output_length == 1)
8708 inev.code = *outbuf; 8855 inev.code = *outbuf;
8709 8856
8710 /* Reset internal states of the converter object. 8857 /* Reset internal states of the converter object.
8711 If it fails, create another one. */ 8858 If it fails, create another one. */
8712 convert_status = TECFlushText (converter, outbuf, 8859 convert_status = TECFlushText (converter, outbuf,
8713 sizeof (outbuf), 8860 sizeof (outbuf),
8714 &actual_output_length); 8861 &actual_output_length);
8715 if (convert_status != noErr) 8862 if (convert_status != noErr)
8716 { 8863 {
8717 TECDisposeConverter (converter); 8864 TECDisposeConverter (converter);
@@ -8719,7 +8866,7 @@ XTread_socket (sd, expected, hold_quit)
8719 kTextEncodingMacRoman, 8866 kTextEncodingMacRoman,
8720 mac_keyboard_text_encoding); 8867 mac_keyboard_text_encoding);
8721 } 8868 }
8722 } 8869 }
8723 } 8870 }
8724 8871
8725#if USE_CARBON_EVENTS 8872#if USE_CARBON_EVENTS
@@ -8864,59 +9011,12 @@ __convert_from_newlines (unsigned char * p, size_t * n)
8864} 9011}
8865#endif 9012#endif
8866 9013
8867 9014#ifdef MAC_OS8
8868/* Initialize the struct pointed to by MW to represent a new COLS x
8869 ROWS Macintosh window, using font with name FONTNAME and size
8870 FONTSIZE. */
8871void
8872make_mac_frame (FRAME_PTR fp)
8873{
8874 mac_output *mwp;
8875#if TARGET_API_MAC_CARBON
8876 static int making_terminal_window = 0;
8877#else
8878 static int making_terminal_window = 1;
8879#endif
8880
8881 mwp = fp->output_data.mac;
8882
8883 BLOCK_INPUT;
8884 if (making_terminal_window)
8885 {
8886 if (!(mwp->mWP = GetNewCWindow (TERM_WINDOW_RESOURCE, NULL,
8887 (WindowPtr) -1)))
8888 abort ();
8889 making_terminal_window = 0;
8890 }
8891 else
8892 {
8893#if TARGET_API_MAC_CARBON
8894 Rect r;
8895
8896 SetRect (&r, 0, 0, 1, 1);
8897 if (CreateNewWindow (kDocumentWindowClass,
8898 kWindowStandardDocumentAttributes
8899 /* | kWindowToolbarButtonAttribute */,
8900 &r, &mwp->mWP) != noErr)
8901#else
8902 if (!(mwp->mWP = GetNewCWindow (WINDOW_RESOURCE, NULL, (WindowPtr) -1)))
8903#endif
8904 abort ();
8905 }
8906
8907 SetWRefCon (mwp->mWP, (long) mwp);
8908 /* so that update events can find this mac_output struct */
8909 mwp->mFP = fp; /* point back to emacs frame */
8910
8911 SizeWindow (mwp->mWP, FRAME_PIXEL_WIDTH (fp), FRAME_PIXEL_HEIGHT (fp), false);
8912 UNBLOCK_INPUT;
8913}
8914
8915
8916void 9015void
8917make_mac_terminal_frame (struct frame *f) 9016make_mac_terminal_frame (struct frame *f)
8918{ 9017{
8919 Lisp_Object frame; 9018 Lisp_Object frame;
9019 Rect r;
8920 9020
8921 XSETFRAME (frame, f); 9021 XSETFRAME (frame, f);
8922 9022
@@ -8940,10 +9040,17 @@ make_mac_terminal_frame (struct frame *f)
8940 f->output_data.mac->mouse_pixel = 0xff00ff; 9040 f->output_data.mac->mouse_pixel = 0xff00ff;
8941 f->output_data.mac->cursor_foreground_pixel = 0x0000ff; 9041 f->output_data.mac->cursor_foreground_pixel = 0x0000ff;
8942 9042
9043 f->output_data.mac->text_cursor = GetCursor (iBeamCursor);
9044 f->output_data.mac->nontext_cursor = &arrow_cursor;
9045 f->output_data.mac->modeline_cursor = &arrow_cursor;
9046 f->output_data.mac->hand_cursor = &arrow_cursor;
9047 f->output_data.mac->hourglass_cursor = GetCursor (watchCursor);
9048 f->output_data.mac->horizontal_drag_cursor = &arrow_cursor;
9049
8943 FRAME_FONTSET (f) = -1; 9050 FRAME_FONTSET (f) = -1;
8944 f->output_data.mac->explicit_parent = 0; 9051 f->output_data.mac->explicit_parent = 0;
8945 f->left_pos = 4; 9052 f->left_pos = 8;
8946 f->top_pos = 4; 9053 f->top_pos = 32;
8947 f->border_width = 0; 9054 f->border_width = 0;
8948 9055
8949 f->internal_border_width = 0; 9056 f->internal_border_width = 0;
@@ -8954,7 +9061,20 @@ make_mac_terminal_frame (struct frame *f)
8954 f->new_text_cols = 0; 9061 f->new_text_cols = 0;
8955 f->new_text_lines = 0; 9062 f->new_text_lines = 0;
8956 9063
8957 make_mac_frame (f); 9064 SetRect (&r, f->left_pos, f->top_pos,
9065 f->left_pos + FRAME_PIXEL_WIDTH (f),
9066 f->top_pos + FRAME_PIXEL_HEIGHT (f));
9067
9068 BLOCK_INPUT;
9069
9070 if (!(FRAME_MAC_WINDOW (f) =
9071 NewCWindow (NULL, &r, "\p", true, dBoxProc,
9072 (WindowPtr) -1, 1, (long) f->output_data.mac)))
9073 abort ();
9074 /* so that update events can find this mac_output struct */
9075 f->output_data.mac->mFP = f; /* point back to emacs frame */
9076
9077 UNBLOCK_INPUT;
8958 9078
8959 x_make_gc (f); 9079 x_make_gc (f);
8960 9080
@@ -8970,9 +9090,8 @@ make_mac_terminal_frame (struct frame *f)
8970 Fmodify_frame_parameters (frame, 9090 Fmodify_frame_parameters (frame,
8971 Fcons (Fcons (Qbackground_color, 9091 Fcons (Fcons (Qbackground_color,
8972 build_string ("white")), Qnil)); 9092 build_string ("white")), Qnil));
8973
8974 ShowWindow (f->output_data.mac->mWP);
8975} 9093}
9094#endif
8976 9095
8977 9096
8978/*********************************************************************** 9097/***********************************************************************
@@ -8989,12 +9108,7 @@ mac_initialize_display_info ()
8989 9108
8990 bzero (dpyinfo, sizeof (*dpyinfo)); 9109 bzero (dpyinfo, sizeof (*dpyinfo));
8991 9110
8992 /* Put it on x_display_name_list. */ 9111#ifdef MAC_OSX
8993 x_display_name_list = Fcons (Fcons (build_string ("Mac"), Qnil),
8994 x_display_name_list);
8995 dpyinfo->name_list_element = XCAR (x_display_name_list);
8996
8997#if 0
8998 dpyinfo->mac_id_name 9112 dpyinfo->mac_id_name
8999 = (char *) xmalloc (SCHARS (Vinvocation_name) 9113 = (char *) xmalloc (SCHARS (Vinvocation_name)
9000 + SCHARS (Vsystem_name) 9114 + SCHARS (Vsystem_name)
@@ -9049,6 +9163,61 @@ mac_initialize_display_info ()
9049 dpyinfo->mouse_face_hidden = 0; 9163 dpyinfo->mouse_face_hidden = 0;
9050} 9164}
9051 9165
9166/* Create an xrdb-style database of resources to supercede registry settings.
9167 The database is just a concatenation of C strings, finished by an additional
9168 \0. The string are submitted to some basic normalization, so
9169
9170 [ *]option[ *]:[ *]value...
9171
9172 becomes
9173
9174 option:value...
9175
9176 but any whitespace following value is not removed. */
9177
9178static char *
9179mac_make_rdb (xrm_option)
9180 char *xrm_option;
9181{
9182 char *buffer = xmalloc (strlen (xrm_option) + 2);
9183 char *current = buffer;
9184 char ch;
9185 int in_option = 1;
9186 int before_value = 0;
9187
9188 do {
9189 ch = *xrm_option++;
9190
9191 if (ch == '\n')
9192 {
9193 *current++ = '\0';
9194 in_option = 1;
9195 before_value = 0;
9196 }
9197 else if (ch != ' ')
9198 {
9199 *current++ = ch;
9200 if (in_option && (ch == ':'))
9201 {
9202 in_option = 0;
9203 before_value = 1;
9204 }
9205 else if (before_value)
9206 {
9207 before_value = 0;
9208 }
9209 }
9210 else if (!(in_option || before_value))
9211 {
9212 *current++ = ch;
9213 }
9214 } while (ch);
9215
9216 *current = '\0';
9217
9218 return buffer;
9219}
9220
9052struct mac_display_info * 9221struct mac_display_info *
9053mac_term_init (display_name, xrm_option, resource_name) 9222mac_term_init (display_name, xrm_option, resource_name)
9054 Lisp_Object display_name; 9223 Lisp_Object display_name;
@@ -9056,7 +9225,8 @@ mac_term_init (display_name, xrm_option, resource_name)
9056 char *resource_name; 9225 char *resource_name;
9057{ 9226{
9058 struct mac_display_info *dpyinfo; 9227 struct mac_display_info *dpyinfo;
9059 GDHandle main_device_handle; 9228
9229 BLOCK_INPUT;
9060 9230
9061 if (!mac_initialized) 9231 if (!mac_initialized)
9062 { 9232 {
@@ -9064,17 +9234,90 @@ mac_term_init (display_name, xrm_option, resource_name)
9064 mac_initialized = 1; 9234 mac_initialized = 1;
9065 } 9235 }
9066 9236
9067 mac_initialize_display_info (display_name); 9237 if (x_display_list)
9238 error ("Sorry, this version can only handle one display");
9239
9240 mac_initialize_display_info ();
9068 9241
9069 dpyinfo = &one_mac_display_info; 9242 dpyinfo = &one_mac_display_info;
9070 9243
9071 main_device_handle = LMGetMainDevice(); 9244 dpyinfo->xrdb = xrm_option ? mac_make_rdb (xrm_option) : NULL;
9072 9245
9073 dpyinfo->height = (**main_device_handle).gdRect.bottom; 9246 /* Put this display on the chain. */
9074 dpyinfo->width = (**main_device_handle).gdRect.right; 9247 dpyinfo->next = x_display_list;
9248 x_display_list = dpyinfo;
9249
9250 /* Put it on x_display_name_list. */
9251 x_display_name_list = Fcons (Fcons (display_name, Qnil),
9252 x_display_name_list);
9253 dpyinfo->name_list_element = XCAR (x_display_name_list);
9254
9255 UNBLOCK_INPUT;
9075 9256
9076 return dpyinfo; 9257 return dpyinfo;
9077} 9258}
9259/* Get rid of display DPYINFO, assuming all frames are already gone. */
9260
9261void
9262x_delete_display (dpyinfo)
9263 struct mac_display_info *dpyinfo;
9264{
9265 int i;
9266
9267 /* Discard this display from x_display_name_list and x_display_list.
9268 We can't use Fdelq because that can quit. */
9269 if (! NILP (x_display_name_list)
9270 && EQ (XCAR (x_display_name_list), dpyinfo->name_list_element))
9271 x_display_name_list = XCDR (x_display_name_list);
9272 else
9273 {
9274 Lisp_Object tail;
9275
9276 tail = x_display_name_list;
9277 while (CONSP (tail) && CONSP (XCDR (tail)))
9278 {
9279 if (EQ (XCAR (XCDR (tail)), dpyinfo->name_list_element))
9280 {
9281 XSETCDR (tail, XCDR (XCDR (tail)));
9282 break;
9283 }
9284 tail = XCDR (tail);
9285 }
9286 }
9287
9288 if (x_display_list == dpyinfo)
9289 x_display_list = dpyinfo->next;
9290 else
9291 {
9292 struct x_display_info *tail;
9293
9294 for (tail = x_display_list; tail; tail = tail->next)
9295 if (tail->next == dpyinfo)
9296 tail->next = tail->next->next;
9297 }
9298
9299 /* Free the font names in the font table. */
9300 for (i = 0; i < dpyinfo->n_fonts; i++)
9301 if (dpyinfo->font_table[i].name)
9302 {
9303 if (dpyinfo->font_table[i].name != dpyinfo->font_table[i].full_name)
9304 xfree (dpyinfo->font_table[i].full_name);
9305 xfree (dpyinfo->font_table[i].name);
9306 }
9307
9308 if (dpyinfo->font_table->font_encoder)
9309 xfree (dpyinfo->font_table->font_encoder);
9310
9311 xfree (dpyinfo->font_table);
9312 xfree (dpyinfo->mac_id_name);
9313
9314 if (x_display_list == 0)
9315 {
9316 mac_clear_font_name_table ();
9317 bzero (dpyinfo, sizeof (*dpyinfo));
9318 }
9319}
9320
9078 9321
9079#ifdef MAC_OSX 9322#ifdef MAC_OSX
9080void 9323void
@@ -9334,7 +9577,6 @@ mac_initialize ()
9334#endif 9577#endif
9335 9578
9336 BLOCK_INPUT; 9579 BLOCK_INPUT;
9337 mac_initialize_display_info ();
9338 9580
9339#if TARGET_API_MAC_CARBON 9581#if TARGET_API_MAC_CARBON
9340 init_required_apple_events (); 9582 init_required_apple_events ();
@@ -9372,7 +9614,9 @@ syms_of_macterm ()
9372 Qsuper = intern ("super"); 9614 Qsuper = intern ("super");
9373 Fput (Qsuper, Qmodifier_value, make_number (super_modifier)); 9615 Fput (Qsuper, Qmodifier_value, make_number (super_modifier));
9374 9616
9617#ifdef MAC_OSX
9375 Fprovide (intern ("mac-carbon"), Qnil); 9618 Fprovide (intern ("mac-carbon"), Qnil);
9619#endif
9376 9620
9377 staticpro (&Qreverse); 9621 staticpro (&Qreverse);
9378 Qreverse = intern ("reverse"); 9622 Qreverse = intern ("reverse");