Mercurial > emacs
comparison src/macterm.c @ 59146:9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
(struct glyph_string): Likewise.
* emacs.c (main) [MAC_OS8]: Call mac_term_init instead of
mac_initialize.
* fileio.c (Fnext_read_file_uses_dialog_p, Fread_file_name):
Change TARGET_API_MAC_CARBON to HAVE_CARBON.
* fns.c (vector): Change MAC_OSX to MAC_OS.
* frame.c (x_set_frame_parameters, x_report_frame_params)
(x_set_fullscreen): Remove #ifndef HAVE_CARBON.
(x_set_border_width, Vdefault_frame_scroll_bars): Change
HAVE_CARBON to MAC_OS.
* image.c [MAC_OS]: Include sys/stat.h.
[MAC_OS && !MAC_OSX]: Include sys/param.h, ImageCompression.h, and
QuickTimeComponents.h.
* mac.c [!MAC_OSX] (mac_wait_next_event): Add extern.
[!MAC_OSX] (select): Use mac_wait_next_event.
[!MAC_OSX] (run_mac_command): Change EXEC_SUFFIXES to
Vexec_suffixes.
[!MAC_OSX] (select, run_mac_command): Change `#ifdef
TARGET_API_MAC_CARBON' to `#if TARGET_API_MAC_CARBON'.
(mac_clear_font_name_table): Add extern.
(Fmac_clear_font_name_table): New defun.
(syms_of_mac): Defsubr it.
[MAC_OSX] (SELECT_POLLING_PERIOD_USEC): New define.
[MAC_OSX] (select_and_poll_event): New function.
[MAC_OSX] (sys_select): Use it.
[MAC_OSX && SELECT_USE_CFSOCKET] (socket_callback): New function.
[MAC_OSX && SELECT_USE_CFSOCKET]
(SELECT_TIMEOUT_THRESHOLD_RUNLOOP, EVENT_CLASS_SOCK): New defines.
[MAC_OSX] (sys_select) [SELECT_USE_CFSOCKET]: Use CFSocket and
RunLoop for simultaneously monitoring two kinds of inputs, window
events and process outputs, without periodically polling.
* macfns.c (mac_initialized): Remove extern.
(stricmp): Put in #if 0. All callers changed to use xstricmp in
xfaces.c.
(strnicmp): Decrement `n' at the end of each loop, not the
beginning.
(check_mac): Use the term "Mac native windows" instead of "Mac
OS".
(check_x_display_info, x_display_info_for_name): Sync with xfns.c.
(mac_get_rdb_resource): New function (from w32reg.c).
(x_get_string_resource): Use it.
(install_window_handler): Add extern.
(mac_window): New function.
(Fx_create_frame): Use it instead of make_mac_frame. Set
parameter for Qfullscreen. Call x_wm_set_size_hint.
(Fx_open_connection, Fx_close_connection): New defuns.
(syms_of_macfns): Defsubr them.
(x_create_tip_frame) [TARGET_API_MAC_CARBON]: Add
kWindowNoUpdatesAttribute to the window attribute.
(x_create_tip_frame) [!TARGET_API_MAC_CARBON]: Use NewCWindow.
(x_create_tip_frame): Don't call ShowWindow.
(Fx_show_tip): Call ShowWindow.
(Fx_file_dialog): Change `#ifdef TARGET_API_MAC_CARBON' to `#if
TARGET_API_MAC_CARBON'.
(mac_frame_parm_handlers): Set handlers for Qfullscreen.
(syms_of_macfns) [MAC_OSX]: Initialize mac_in_use to 0.
* macgui.h [!MAC_OSX]: Don't include Controls.h. Include
Windows.h.
(Window): Typedef to WindowPtr and move outside `#if
TARGET_API_MAC_CARBON'.
(XSizeHints): New struct.
* macterm.c (x_update_begin, x_update_end)
[TARGET_API_MAC_CARBON]: Disable screen updates during update of a
frame.
(x_draw_glyph_string_background, x_draw_glyph_string_foreground)
[MAC_OS8]: Use XDrawImageString/XDrawImageString16.
(construct_mouse_click): Put in #if 0.
(x_check_fullscreen, x_check_fullscreen_move): Remove decls.
(x_scroll_bar_create, x_scroll_bar_handle_click): Change `#ifdef
TARGET_API_MAC_CARBON' to `#if TARGET_API_MAC_CARBON'.
(activate_scroll_bars, deactivate_scroll_bars)
[!TARGET_API_MAC_CARBON]: Use ActivateControl/DeactivateControl.
(x_make_frame_visible) [TARGET_API_MAC_CARBON]: Reposition window
if the position is neither user-specified nor program-specified.
(x_free_frame_resources): Free size_hints.
(x_wm_set_size_hint): Allocate size_hints if needed. Set
size_hints.
(mac_clear_font_name_table): New function.
(mac_do_list_fonts): Initialize font_name_table if needed.
(x_list_fonts): Don't initialize font_name_table. Add BLOCK_INPUT
around mac_do_list_fonts.
(mac_unload_font): New function.
(x_load_font): Add BLOCK_INPUT around XLoadQueryFont.
(init_mac_drag_n_drop, mac_do_receive_drag): Enclose declarations
and definitions with #if TARGET_API_MAC_CARBON.
[USE_CARBON_EVENTS] (mac_handle_window_event): Add decl.
(install_window_handler): Add decl.
(do_window_update): Add BeginUpdate/EndUpdate for the tooltip
window. Use UpdateControls. Get the rectangle that should be
updated and restrict the target of expose_frame to it.
(do_grow_window): Set minimum height/width according to
size_hints.
(do_grow_window) [TARGET_API_MAC_CARBON]: Use ResizeWindow.
(do_zoom_window): Don't use x_set_window_size.
[USE_CARBON_EVENTS] (mac_handle_window_event): New function.
(install_window_handler): New function.
[!USE_CARBON_EVENTS] (mouse_region): New variable.
[!USE_CARBON_EVENTS] (mac_wait_next_event): New function.
(XTread_socket) [USE_CARBON_EVENTS]: Move call to
GetEventDispatcherTarget inside BLOCK_INPUT.
(XTread_socket) [!USE_CARBON_EVENTS]: Use mac_wait_next_event.
Update mouse_region when mouse is moved.
(make_mac_frame): Remove.
(make_mac_terminal_frame): Put in #ifdef MAC_OS8. Initialize
mouse pointer shapes. Change values of f->left_pos and
f->top_pos. Don't use make_mac_frame. Use NewCWindow. Don't
call ShowWindow.
(mac_initialize_display_info) [MAC_OSX]: Create mac_id_name from
Vinvocation_name and Vsystem_name.
(mac_make_rdb): New function (from w32term.c).
(mac_term_init): Use it. Add BLOCK_INPUT. Error if display has
already been opened. Don't pass argument to
mac_initialize_display_info. Don't set dpyinfo->height/width.
Add entries to x_display_list and x_display_name_list.
(x_delete_display): New function.
(mac_initialize): Don't call mac_initialize_display_info.
(syms_of_macterm) [!MAC_OSX]: Don't call Fprovide.
* macterm.h (check_mac): Add extern.
(struct mac_output): New member size_hints.
(FRAME_SIZE_HINTS): New macro.
(mac_unload_font): Add extern.
* xdisp.c (expose_window, expose_frame): Remove kludges for Mac.
* xfaces.c (clear_font_table) [MAC_OS]: call mac_unload_font.
author | Steven Tamm <steventamm@mac.com> |
---|---|
date | Mon, 27 Dec 2004 17:27:30 +0000 |
parents | b978ab01b88e |
children | 60ffced08532 223c12363c0c |
comparison
equal
deleted
inserted
replaced
59145:c331d9c412f2 | 59146:9bde7721ad0f |
---|---|
1176 | 1176 |
1177 static void | 1177 static void |
1178 x_update_begin (f) | 1178 x_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 |
1185 /* Start update of window W. Set the global variable updated_window | 1195 /* Start update of window W. Set the global variable updated_window |
1186 to the window being updated and set output_cursor to the cursor | 1196 to the window being updated and set output_cursor to the cursor |
1261 MOUSE_FACE_OVERWRITTEN_P non-zero means that some row containing | 1271 MOUSE_FACE_OVERWRITTEN_P non-zero means that some row containing |
1262 glyphs in mouse-face were overwritten. In that case we have to | 1272 glyphs in mouse-face were overwritten. In that case we have to |
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 |
1269 static void | 1279 static void |
1270 x_update_window_end (w, cursor_on_p, mouse_face_overwritten_p) | 1280 x_update_window_end (w, cursor_on_p, mouse_face_overwritten_p) |
1271 struct window *w; | 1281 struct window *w; |
1325 an update event is generated. */ | 1335 an update event is generated. */ |
1326 SetPortWindowPort (FRAME_MAC_WINDOW (f)); | 1336 SetPortWindowPort (FRAME_MAC_WINDOW (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 } |
1333 | 1346 |
1334 | 1347 |
1981 XSetFillStyle (s->display, s->gc, FillSolid); | 1994 XSetFillStyle (s->display, s->gc, FillSolid); |
1982 s->background_filled_p = 1; | 1995 s->background_filled_p = 1; |
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 |
1990 || force_p) | 2003 || force_p) |
1991 #endif | 2004 #endif |
2039 /* If we can use 8-bit functions, condense S->char2b. */ | 2052 /* If we can use 8-bit functions, condense S->char2b. */ |
2040 if (!s->two_byte_p) | 2053 if (!s->two_byte_p) |
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 |
2048 use XDrawImageString when drawing the cursor so that there is | 2061 use XDrawImageString when drawing the cursor so that there is |
2049 no chance that characters under a box cursor are invisible. */ | 2062 no chance that characters under a box cursor are invisible. */ |
2057 s->ybase - boff, s->char2b, s->nchars); | 2070 s->ybase - boff, s->char2b, s->nchars); |
2058 else | 2071 else |
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) |
2066 XDrawImageString16 (s->display, s->window, s->gc, x, | 2079 XDrawImageString16 (s->display, s->window, s->gc, x, |
2067 s->ybase - boff, s->char2b, s->nchars); | 2080 s->ybase - boff, s->char2b, s->nchars); |
3650 return value; | 3663 return value; |
3651 } | 3664 } |
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. |
3658 | 3672 |
3659 If the event is a button press, then note that we have grabbed | 3673 If the event is a button press, then note that we have grabbed |
3683 XSETFRAME (result->frame_or_window, f); | 3697 XSETFRAME (result->frame_or_window, f); |
3684 | 3698 |
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. |
3691 The input handler calls this. | 3706 The input handler calls this. |
3692 | 3707 |
3752 Mouse Face | 3767 Mouse Face |
3753 ************************************************************************/ | 3768 ************************************************************************/ |
3754 | 3769 |
3755 static struct scroll_bar *x_window_to_scroll_bar (); | 3770 static struct scroll_bar *x_window_to_scroll_bar (); |
3756 static void x_scroll_bar_report_motion (); | 3771 static void x_scroll_bar_report_motion (); |
3757 static void x_check_fullscreen P_ ((struct frame *)); | |
3758 static void x_check_fullscreen_move P_ ((struct frame *)); | |
3759 static int glyph_rect P_ ((struct frame *f, int, int, Rect *)); | 3772 static int glyph_rect P_ ((struct frame *f, int, int, Rect *)); |
3760 | 3773 |
3761 | 3774 |
3762 /* MAC TODO: This should be called from somewhere (or removed) ++KFS */ | 3775 /* MAC TODO: This should be called from somewhere (or removed) ++KFS */ |
3763 | 3776 |
4015 r.left = left; | 4028 r.left = left; |
4016 r.top = disp_top; | 4029 r.top = disp_top; |
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 |
4024 ch = NewControl (FRAME_MAC_WINDOW (f), &r, "\p", 1, 0, 0, 0, scrollBarProc, | 4037 ch = NewControl (FRAME_MAC_WINDOW (f), &r, "\p", 1, 0, 0, 0, scrollBarProc, |
4025 0L); | 4038 0L); |
4393 | 4406 |
4394 bar = FRAME_SCROLL_BARS (frame); | 4407 bar = FRAME_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, |
4402 VERTICAL_SCROLL_BAR_TOP_RANGE (frame, | 4415 VERTICAL_SCROLL_BAR_TOP_RANGE (frame, |
4403 XINT (XSCROLL_BAR (bar) | 4416 XINT (XSCROLL_BAR (bar) |
4417 | 4430 |
4418 bar = FRAME_SCROLL_BARS (frame); | 4431 bar = FRAME_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 } |
4429 } | 4442 } |
4430 | 4443 |
4464 bufp->part = scroll_bar_above_handle; | 4477 bufp->part = scroll_bar_above_handle; |
4465 break; | 4478 break; |
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: |
4473 #endif | 4486 #endif |
4474 if (er->what == mouseDown) | 4487 if (er->what == mouseDown) |
4972 XSetFont (FRAME_MAC_DISPLAY (f), f->output_data.mac->reverse_gc, | 4985 XSetFont (FRAME_MAC_DISPLAY (f), f->output_data.mac->reverse_gc, |
4973 FRAME_FONT (f)); | 4986 FRAME_FONT (f)); |
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. |
4987 The return value shows which fontset we chose. */ | 5003 The return value shows which fontset we chose. */ |
4988 | 5004 |
5367 && ! f->output_data.mac->asked_for_visible) | 5383 && ! f->output_data.mac->asked_for_visible) |
5368 x_set_offset (f, f->left_pos, f->top_pos, 0); | 5384 x_set_offset (f, f->left_pos, f->top_pos, 0); |
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 |
5375 XFlush (FRAME_MAC_DISPLAY (f)); | 5410 XFlush (FRAME_MAC_DISPLAY (f)); |
5376 | 5411 |
5494 if (FRAME_FACE_CACHE (f)) | 5529 if (FRAME_FACE_CACHE (f)) |
5495 free_frame_faces (f); | 5530 free_frame_faces (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 |
5502 if (f == dpyinfo->x_focus_frame) | 5540 if (f == dpyinfo->x_focus_frame) |
5503 dpyinfo->x_focus_frame = 0; | 5541 dpyinfo->x_focus_frame = 0; |
5546 x_wm_set_size_hint (f, flags, user_position) | 5584 x_wm_set_size_hint (f, flags, user_position) |
5547 struct frame *f; | 5585 struct frame *f; |
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 | 5592 |
5555 Arg al[2]; | 5593 base_width = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, 0); |
5556 int ac = 0; | 5594 base_height = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, 0); |
5557 Dimension widget_width, widget_height; | 5595 width_inc = FRAME_COLUMN_WIDTH (f); |
5558 Window window = XtWindow (f->output_data.x->widget); | 5596 height_inc = FRAME_LINE_HEIGHT (f); |
5559 #else /* not USE_X_TOOLKIT */ | 5597 |
5560 Window window = FRAME_X_WINDOW (f); | 5598 check_frame_size (f, &min_rows, &min_cols); |
5561 #endif /* not USE_X_TOOLKIT */ | 5599 |
5562 | 5600 size_hints = FRAME_SIZE_HINTS (f); |
5563 /* Setting PMaxSize caused various problems. */ | 5601 if (size_hints == NULL) |
5564 size_hints.flags = PResizeInc | PMinSize /* | PMaxSize */; | 5602 { |
5565 | 5603 size_hints = FRAME_SIZE_HINTS (f) = xmalloc (sizeof (XSizeHints)); |
5566 size_hints.x = f->left_pos; | 5604 bzero (size_hints, sizeof (XSizeHints)); |
5567 size_hints.y = f->top_pos; | 5605 } |
5568 | 5606 |
5569 #ifdef USE_X_TOOLKIT | 5607 size_hints->flags |= PResizeInc | PMinSize | PBaseSize ; |
5570 XtSetArg (al[ac], XtNwidth, &widget_width); ac++; | 5608 size_hints->width_inc = width_inc; |
5571 XtSetArg (al[ac], XtNheight, &widget_height); ac++; | 5609 size_hints->height_inc = height_inc; |
5572 XtGetValues (f->output_data.x->widget, al, ac); | 5610 size_hints->min_width = base_width + min_cols * width_inc; |
5573 size_hints.height = widget_height; | 5611 size_hints->min_height = base_height + min_rows * height_inc; |
5574 size_hints.width = widget_width; | 5612 size_hints->base_width = base_width; |
5575 #else /* not USE_X_TOOLKIT */ | 5613 size_hints->base_height = base_height; |
5576 size_hints.height = FRAME_PIXEL_HEIGHT (f); | 5614 |
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 | |
5599 check_frame_size (f, &min_rows, &min_cols); | |
5600 | |
5601 /* The window manager uses the base width hints to calculate the | |
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 | |
5607 We use the base_width and base_height members if we have | |
5608 them; otherwise, we set the min_width and min_height members | |
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) | 5615 if (flags) |
5625 { | 5616 size_hints->flags = flags; |
5626 size_hints.flags |= flags; | 5617 else if (user_position) |
5627 goto no_read; | 5618 { |
5628 } | 5619 size_hints->flags &= ~ PPosition; |
5629 #endif /* not USE_X_TOOLKIT */ | 5620 size_hints->flags |= USPosition; |
5630 | 5621 } |
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 | |
5671 #ifdef PWinGravity | |
5672 size_hints.win_gravity = f->win_gravity; | |
5673 size_hints.flags |= PWinGravity; | |
5674 | |
5675 if (user_position) | |
5676 { | |
5677 size_hints.flags &= ~ PPosition; | |
5678 size_hints.flags |= USPosition; | |
5679 } | |
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? */ |
5691 /* Used for IconicState or NormalState */ | 5625 /* Used for IconicState or NormalState */ |
5692 | 5626 |
6118 | 6052 |
6119 if (FMGetFontFamilyTextEncoding (ff, &encoding) != noErr) | 6053 if (FMGetFontFamilyTextEncoding (ff, &encoding) != noErr) |
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; |
6127 | 6061 |
6128 while (FMGetNextFontFamilyInstance (&ffii, &font, &style, &size) | 6062 while (FMGetNextFontFamilyInstance (&ffii, &font, &style, &size) |
6257 } | 6191 } |
6258 #endif /* TARGET_API_MAC_CARBON */ | 6192 #endif /* TARGET_API_MAC_CARBON */ |
6259 } | 6193 } |
6260 | 6194 |
6261 | 6195 |
6196 void | |
6197 mac_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 | |
6262 enum xlfd_scalable_field_index | 6209 enum xlfd_scalable_field_index |
6263 { | 6210 { |
6264 XLFD_SCL_PIXEL_SIZE, | 6211 XLFD_SCL_PIXEL_SIZE, |
6265 XLFD_SCL_POINT_SIZE, | 6212 XLFD_SCL_POINT_SIZE, |
6266 XLFD_SCL_AVGWIDTH, | 6213 XLFD_SCL_AVGWIDTH, |
6308 char scaled[256]; | 6255 char scaled[256]; |
6309 char *ptr; | 6256 char *ptr; |
6310 int scl_val[XLFD_SCL_LAST], *field, *val; | 6257 int scl_val[XLFD_SCL_LAST], *field, *val; |
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; |
6260 | |
6261 if (font_name_table == NULL) /* Initialize when first used. */ | |
6262 init_font_name_table (); | |
6313 | 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 |
6317 /* If the pattern contains 14 dashes and one of PIXEL_SIZE, | 6267 /* If the pattern contains 14 dashes and one of PIXEL_SIZE, |
6469 int maxnames) | 6419 int maxnames) |
6470 { | 6420 { |
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); |
6480 key = Fcons (pattern, make_number (maxnames)); | 6427 key = Fcons (pattern, make_number (maxnames)); |
6481 | 6428 |
6485 newlist = Fcdr_safe (newlist); | 6432 newlist = Fcdr_safe (newlist); |
6486 goto label_cached; | 6433 goto label_cached; |
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 |
6494 if (dpyinfo) | 6443 if (dpyinfo) |
6495 { | 6444 { |
6789 | 6738 |
6790 return font; | 6739 return font; |
6791 } | 6740 } |
6792 | 6741 |
6793 | 6742 |
6743 void | |
6744 mac_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. |
6797 If loading is failed, return NULL. */ | 6758 If loading is failed, return NULL. */ |
6798 | 6759 |
6839 a bug of not finding a font even if the font surely exists and | 6800 a bug of not finding a font even if the font surely exists and |
6840 is loadable by XLoadQueryFont. */ | 6801 is loadable by XLoadQueryFont. */ |
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 |
6848 /* Find a free slot in the font table. */ | 6811 /* Find a free slot in the font table. */ |
6849 for (i = 0; i < dpyinfo->n_fonts; ++i) | 6812 for (i = 0; i < dpyinfo->n_fonts; ++i) |
7119 static pascal OSErr | 7082 static pascal OSErr |
7120 do_ae_print_documents (const AppleEvent *, AppleEvent *, long); | 7083 do_ae_print_documents (const AppleEvent *, AppleEvent *, long); |
7121 static pascal OSErr do_ae_open_documents (AppleEvent *, AppleEvent *, long); | 7084 static pascal OSErr do_ae_open_documents (AppleEvent *, AppleEvent *, long); |
7122 static pascal OSErr do_ae_quit_application (AppleEvent *, AppleEvent *, long); | 7085 static 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 */ |
7125 static OSErr init_mac_drag_n_drop (); | 7089 static OSErr init_mac_drag_n_drop (); |
7126 static pascal OSErr mac_do_receive_drag (WindowPtr, void*, DragReference); | 7090 static 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 */ |
7130 static OSStatus mac_handle_service_event (EventHandlerCallRef,EventRef,void*); | 7095 static OSStatus mac_handle_service_event (EventHandlerCallRef,EventRef,void*); |
7131 static void init_service_handler (); | 7096 static void init_service_handler (); |
7132 #endif | 7097 /* Window Event Handler */ |
7098 static pascal OSStatus mac_handle_window_event (EventHandlerCallRef, | |
7099 EventRef, void *); | |
7100 #endif | |
7101 void install_window_handler (WindowPtr); | |
7133 | 7102 |
7134 extern void init_emacs_passwd_dir (); | 7103 extern void init_emacs_passwd_dir (); |
7135 extern int emacs_main (int, char **, char **); | 7104 extern int emacs_main (int, char **, char **); |
7136 extern void check_alarm (); | 7105 extern void check_alarm (); |
7137 | 7106 |
7334 static void | 7303 static void |
7335 do_window_update (WindowPtr win) | 7304 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 | 7309 |
7341 SET_FRAME_GARBAGED below. */ | 7310 /* The tooltip has been drawn already. Avoid the SET_FRAME_GARBAGED |
7342 return; | 7311 below. */ |
7343 | 7312 if (win != tip_window) |
7344 if (f) | |
7345 { | 7313 { |
7346 if (f->async_visible == 0) | 7314 if (f->async_visible == 0) |
7347 { | 7315 { |
7348 f->async_visible = 1; | 7316 f->async_visible = 1; |
7349 f->async_iconified = 0; | 7317 f->async_iconified = 0; |
7356 frame titles in case this is the second frame. */ | 7324 frame titles in case this is the second frame. */ |
7357 record_asynch_buffer_change (); | 7325 record_asynch_buffer_change (); |
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 |
7365 | 7334 { |
7366 expose_frame (f, 0, 0, 0, 0); | 7335 RgnHandle region = NewRgn (); |
7336 | |
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 |
7374 static int | 7355 static int |
7375 is_emacs_window (WindowPtr win) | 7356 is_emacs_window (WindowPtr win) |
7376 { | 7357 { |
7528 Mesander and IM - Window Manager A. */ | 7509 Mesander and IM - Window Manager A. */ |
7529 | 7510 |
7530 static void | 7511 static void |
7531 do_grow_window (WindowPtr w, EventRecord *e) | 7512 do_grow_window (WindowPtr w, EventRecord *e) |
7532 { | 7513 { |
7514 Rect limit_rect; | |
7515 int rows, columns, width, height; | |
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 | |
7533 long grow_size; | 7522 long grow_size; |
7534 Rect limit_rect; | 7523 #endif |
7535 int rows, columns; | 7524 |
7536 struct frame *f = mac_window_to_frame (w); | 7525 if (size_hints->flags & PMinSize) |
7537 | 7526 { |
7538 SetRect(&limit_rect, MIN_DOC_SIZE, MIN_DOC_SIZE, MAX_DOC_SIZE, MAX_DOC_SIZE); | 7527 min_width = size_hints->min_width; |
7539 | 7528 min_height = size_hints->min_height; |
7529 } | |
7530 SetRect (&limit_rect, min_width, min_height, MAX_DOC_SIZE, MAX_DOC_SIZE); | |
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) |
7544 { | 7541 return; |
7545 rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, HiWord (grow_size)); | 7542 height = HiWord (grow_size); |
7546 columns = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, LoWord (grow_size)); | 7543 width = LoWord (grow_size); |
7544 #endif | |
7545 | |
7546 if (width != FRAME_PIXEL_WIDTH (f) | |
7547 || height != FRAME_PIXEL_HEIGHT (f)) | |
7548 { | |
7549 rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, height); | |
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 } |
7550 } | 7554 } |
7551 | 7555 |
7559 do_zoom_window (WindowPtr w, int zoom_in_or_out) | 7563 do_zoom_window (WindowPtr w, int zoom_in_or_out) |
7560 { | 7564 { |
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 |
7568 { | 7572 { |
7569 Point standard_size; | 7573 Point standard_size; |
7634 #if TARGET_API_MAC_CARBON | 7638 #if TARGET_API_MAC_CARBON |
7635 GetWindowPortBounds (w, &port_rect); | 7639 GetWindowPortBounds (w, &port_rect); |
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 */ |
7646 static OSErr | 7664 static OSErr |
7647 init_mac_drag_n_drop () | 7665 init_mac_drag_n_drop () |
7648 { | 7666 { |
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. */ |
7654 void | 7673 void |
7655 init_required_apple_events () | 7674 init_required_apple_events () |
7656 { | 7675 { |
7817 */ | 7836 */ |
7818 } | 7837 } |
7819 } | 7838 } |
7820 return err; | 7839 return err; |
7821 } | 7840 } |
7822 #endif | 7841 |
7842 | |
7843 static pascal OSStatus | |
7844 mac_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 | |
7912 void | |
7913 install_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); | |
7925 #endif | |
7926 } | |
7927 | |
7823 | 7928 |
7824 /* Open Application Apple Event */ | 7929 /* Open Application Apple Event */ |
7825 static pascal OSErr | 7930 static pascal OSErr |
7826 do_ae_open_application(const AppleEvent *pae, AppleEvent *preply, long prefcon) | 7931 do_ae_open_application(const AppleEvent *pae, AppleEvent *preply, long prefcon) |
7827 { | 7932 { |
7913 /* InvalRect(&(gFrontMacWindowP->mWP->portRect)); */ | 8018 /* InvalRect(&(gFrontMacWindowP->mWP->portRect)); */ |
7914 return err; | 8019 return err; |
7915 } | 8020 } |
7916 | 8021 |
7917 | 8022 |
8023 #if TARGET_API_MAC_CARBON | |
7918 static pascal OSErr | 8024 static pascal OSErr |
7919 mac_do_receive_drag (WindowPtr window, void *handlerRefCon, | 8025 mac_do_receive_drag (WindowPtr window, void *handlerRefCon, |
7920 DragReference theDrag) | 8026 DragReference theDrag) |
7921 { | 8027 { |
7922 short items; | 8028 short items; |
7989 GetCurrentProcess (&psn); | 8095 GetCurrentProcess (&psn); |
7990 SetFrontProcess (&psn); | 8096 SetFrontProcess (&psn); |
7991 } | 8097 } |
7992 } | 8098 } |
7993 } | 8099 } |
8100 #endif | |
7994 | 8101 |
7995 | 8102 |
7996 /* Print Document Apple Event */ | 8103 /* Print Document Apple Event */ |
7997 static pascal OSErr | 8104 static pascal OSErr |
7998 do_ae_print_documents (const AppleEvent *pAE, AppleEvent *reply, long refcon) | 8105 do_ae_print_documents (const AppleEvent *pAE, AppleEvent *reply, long refcon) |
8138 { | 8245 { |
8139 *xKeySym = keycode_to_xkeysym_table [keyCode & 0x7f]; | 8246 *xKeySym = keycode_to_xkeysym_table [keyCode & 0x7f]; |
8140 return *xKeySym != 0; | 8247 return *xKeySym != 0; |
8141 } | 8248 } |
8142 | 8249 |
8250 #if !USE_CARBON_EVENTS | |
8251 static RgnHandle mouse_region = NULL; | |
8252 | |
8253 Boolean | |
8254 mac_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. */ |
8145 int | 8291 int |
8146 XTread_socket (sd, expected, hold_quit) | 8292 XTread_socket (sd, expected, hold_quit) |
8147 int sd, expected; | 8293 int sd, expected; |
8149 { | 8295 { |
8150 struct input_event inev; | 8296 struct input_event inev; |
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; |
8160 | 8304 |
8161 if (interrupt_input_blocked) | 8305 if (interrupt_input_blocked) |
8182 } | 8326 } |
8183 | 8327 |
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))) | 8333 |
8190 event_mask -= highLevelEventMask; | |
8191 | |
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; |
8200 | 8342 |
8201 /* It is necessary to set this (additional) argument slot of an | 8343 /* It is necessary to set this (additional) argument slot of an |
8258 } | 8400 } |
8259 else | 8401 else |
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); |
8266 } | 8409 } |
8267 else | 8410 else |
8495 else | 8638 else |
8496 do_app_suspend (); | 8639 do_app_suspend (); |
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; |
8503 | 8650 |
8504 do_mouse_moved (er.where, &f); | 8651 do_mouse_moved (er.where, &f); |
8695 if (the_err == noErr) | 8842 if (the_err == noErr) |
8696 { | 8843 { |
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); |
8718 TECCreateConverter (&converter, | 8865 TECCreateConverter (&converter, |
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 |
8726 inev.modifiers = mac_event_to_emacs_modifiers (eventRef); | 8873 inev.modifiers = mac_event_to_emacs_modifiers (eventRef); |
8727 #else | 8874 #else |
8862 { | 9009 { |
8863 #pragma unused(p,n) | 9010 #pragma unused(p,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. */ | |
8871 void | |
8872 make_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 | |
8916 void | 9015 void |
8917 make_mac_terminal_frame (struct frame *f) | 9016 make_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 |
8923 f->output_method = output_mac; | 9023 f->output_method = output_mac; |
8924 f->output_data.mac = (struct mac_output *) | 9024 f->output_data.mac = (struct mac_output *) |
8938 f->output_data.mac->cursor_pixel = 0; | 9038 f->output_data.mac->cursor_pixel = 0; |
8939 f->output_data.mac->border_pixel = 0x00ff00; | 9039 f->output_data.mac->border_pixel = 0x00ff00; |
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; |
8950 | 9057 |
8951 f->auto_raise = 1; | 9058 f->auto_raise = 1; |
8952 f->auto_lower = 1; | 9059 f->auto_lower = 1; |
8953 | 9060 |
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 |
8961 /* Need to be initialized for unshow_buffer in window.c. */ | 9081 /* Need to be initialized for unshow_buffer in window.c. */ |
8962 selected_window = f->selected_window; | 9082 selected_window = f->selected_window; |
8968 Fcons (Fcons (Qforeground_color, | 9088 Fcons (Fcons (Qforeground_color, |
8969 build_string ("black")), Qnil)); | 9089 build_string ("black")), Qnil)); |
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 | 9093 } |
8974 ShowWindow (f->output_data.mac->mWP); | 9094 #endif |
8975 } | |
8976 | 9095 |
8977 | 9096 |
8978 /*********************************************************************** | 9097 /*********************************************************************** |
8979 Initialization | 9098 Initialization |
8980 ***********************************************************************/ | 9099 ***********************************************************************/ |
8987 struct mac_display_info *dpyinfo = &one_mac_display_info; | 9106 struct mac_display_info *dpyinfo = &one_mac_display_info; |
8988 GDHandle main_device_handle; | 9107 GDHandle main_device_handle; |
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) |
9001 + 2); | 9115 + 2); |
9002 sprintf (dpyinfo->mac_id_name, "%s@%s", | 9116 sprintf (dpyinfo->mac_id_name, "%s@%s", |
9047 dpyinfo->mouse_face_window = Qnil; | 9161 dpyinfo->mouse_face_window = Qnil; |
9048 dpyinfo->mouse_face_overlay = Qnil; | 9162 dpyinfo->mouse_face_overlay = Qnil; |
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 | |
9178 static char * | |
9179 mac_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 | |
9052 struct mac_display_info * | 9221 struct mac_display_info * |
9053 mac_term_init (display_name, xrm_option, resource_name) | 9222 mac_term_init (display_name, xrm_option, resource_name) |
9054 Lisp_Object display_name; | 9223 Lisp_Object display_name; |
9055 char *xrm_option; | 9224 char *xrm_option; |
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 { |
9063 mac_initialize (); | 9233 mac_initialize (); |
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 | |
9261 void | |
9262 x_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 |
9080 void | 9323 void |
9081 mac_check_bundle() | 9324 mac_check_bundle() |
9082 { | 9325 { |
9331 | 9574 |
9332 signal (SIGPIPE, x_connection_signal); | 9575 signal (SIGPIPE, x_connection_signal); |
9333 #endif | 9576 #endif |
9334 | 9577 |
9335 BLOCK_INPUT; | 9578 BLOCK_INPUT; |
9336 mac_initialize_display_info (); | |
9337 | 9579 |
9338 #if TARGET_API_MAC_CARBON | 9580 #if TARGET_API_MAC_CARBON |
9339 init_required_apple_events (); | 9581 init_required_apple_events (); |
9340 | 9582 |
9341 init_mac_drag_n_drop (); | 9583 init_mac_drag_n_drop (); |
9369 Qhyper = intern ("hyper"); | 9611 Qhyper = intern ("hyper"); |
9370 Fput (Qhyper, Qmodifier_value, make_number (hyper_modifier)); | 9612 Fput (Qhyper, Qmodifier_value, make_number (hyper_modifier)); |
9371 Qsuper = intern ("super"); | 9613 Qsuper = intern ("super"); |
9372 Fput (Qsuper, Qmodifier_value, make_number (super_modifier)); | 9614 Fput (Qsuper, Qmodifier_value, make_number (super_modifier)); |
9373 | 9615 |
9616 #ifdef MAC_OSX | |
9374 Fprovide (intern ("mac-carbon"), Qnil); | 9617 Fprovide (intern ("mac-carbon"), Qnil); |
9618 #endif | |
9375 | 9619 |
9376 staticpro (&Qreverse); | 9620 staticpro (&Qreverse); |
9377 Qreverse = intern ("reverse"); | 9621 Qreverse = intern ("reverse"); |
9378 | 9622 |
9379 staticpro (&x_display_name_list); | 9623 staticpro (&x_display_name_list); |