Mercurial > emacs
comparison src/macterm.c @ 83561:dc002877ce12
Merged from emacs@sv.gnu.org
Patches applied:
* emacs@sv.gnu.org/emacs--devo--0--patch-674
Merge from gnus--rel--5.10
* emacs@sv.gnu.org/emacs--devo--0--patch-675
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-676
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-677
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-678
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-679
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-680
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-681
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-682
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-683
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-684
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-685
Merge from gnus--rel--5.10
* emacs@sv.gnu.org/emacs--devo--0--patch-686
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-687
Release ERC 5.2.
* emacs@sv.gnu.org/emacs--devo--0--patch-688
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-689
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-690
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-691
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-692
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-693
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-694
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-695
Merge from gnus--rel--5.10
* emacs@sv.gnu.org/emacs--devo--0--patch-696
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-697
Merge from gnus--rel--5.10
* emacs@sv.gnu.org/emacs--devo--0--patch-698
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-699
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-700
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-701
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-209
Merge from emacs--devo--0
* emacs@sv.gnu.org/gnus--rel--5.10--patch-210
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-211
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-212
Merge from emacs--devo--0
* emacs@sv.gnu.org/gnus--rel--5.10--patch-213
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-214
Merge from emacs--devo--0
* emacs@sv.gnu.org/gnus--rel--5.10--patch-215
Update from CVS
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-601
author | Karoly Lorentey <karoly@lorentey.hu> |
---|---|
date | Sun, 22 Apr 2007 12:42:47 +0000 |
parents | 738ce3540ffb f48e3a655e3d |
children | 5da6a46ddbd6 |
comparison
equal
deleted
inserted
replaced
83560:738ce3540ffb | 83561:dc002877ce12 |
---|---|
50 #include <Fonts.h> | 50 #include <Fonts.h> |
51 #include <TextUtils.h> | 51 #include <TextUtils.h> |
52 #include <LowMem.h> | 52 #include <LowMem.h> |
53 #include <Controls.h> | 53 #include <Controls.h> |
54 #include <Windows.h> | 54 #include <Windows.h> |
55 #include <Displays.h> | |
55 #if defined (__MRC__) || (__MSL__ >= 0x6000) | 56 #if defined (__MRC__) || (__MSL__ >= 0x6000) |
56 #include <ControlDefinitions.h> | 57 #include <ControlDefinitions.h> |
57 #endif | 58 #endif |
58 | 59 |
59 #if __profile__ | 60 #if __profile__ |
7170 Lisp_Object charset_info = XCAR (rest); | 7171 Lisp_Object charset_info = XCAR (rest); |
7171 Lisp_Object charset, coding_system, text_encoding; | 7172 Lisp_Object charset, coding_system, text_encoding; |
7172 Lisp_Object existing_info; | 7173 Lisp_Object existing_info; |
7173 | 7174 |
7174 if (!(CONSP (charset_info) | 7175 if (!(CONSP (charset_info) |
7175 && STRINGP (charset = XCAR (charset_info)) | 7176 && (charset = XCAR (charset_info), |
7177 STRINGP (charset)) | |
7176 && CONSP (XCDR (charset_info)) | 7178 && CONSP (XCDR (charset_info)) |
7177 && INTEGERP (text_encoding = XCAR (XCDR (charset_info))) | 7179 && (text_encoding = XCAR (XCDR (charset_info)), |
7180 INTEGERP (text_encoding)) | |
7178 && CONSP (XCDR (XCDR (charset_info))) | 7181 && CONSP (XCDR (XCDR (charset_info))) |
7179 && SYMBOLP (coding_system = XCAR (XCDR (XCDR (charset_info)))))) | 7182 && (coding_system = XCAR (XCDR (XCDR (charset_info))), |
7183 SYMBOLP (coding_system)))) | |
7180 continue; | 7184 continue; |
7181 | 7185 |
7182 existing_info = assq_no_quit (text_encoding, result); | 7186 existing_info = assq_no_quit (text_encoding, result); |
7183 if (NILP (existing_info)) | 7187 if (NILP (existing_info)) |
7184 result = Fcons (list3 (text_encoding, coding_system, charset), | 7188 result = Fcons (list3 (text_encoding, coding_system, charset), |
8864 /* Points to the variable `inev' in the function XTread_socket. It is | 8868 /* Points to the variable `inev' in the function XTread_socket. It is |
8865 used for passing an input event to the function back from | 8869 used for passing an input event to the function back from |
8866 Carbon/Apple event handlers. */ | 8870 Carbon/Apple event handlers. */ |
8867 static struct input_event *read_socket_inev = NULL; | 8871 static struct input_event *read_socket_inev = NULL; |
8868 | 8872 |
8873 /* Whether or not the screen configuration has changed. */ | |
8874 static int mac_screen_config_changed = 0; | |
8875 | |
8869 Point saved_menu_event_location; | 8876 Point saved_menu_event_location; |
8870 | 8877 |
8871 /* Apple Events */ | 8878 /* Apple Events */ |
8872 #if USE_CARBON_EVENTS | 8879 #if USE_CARBON_EVENTS |
8873 static Lisp_Object Qhi_command; | 8880 static Lisp_Object Qhi_command; |
10394 { | 10401 { |
10395 remove_drag_handler (window); | 10402 remove_drag_handler (window); |
10396 } | 10403 } |
10397 | 10404 |
10398 | 10405 |
10406 static pascal void | |
10407 mac_handle_dm_notification (event) | |
10408 AppleEvent *event; | |
10409 { | |
10410 mac_screen_config_changed = 1; | |
10411 } | |
10412 | |
10413 static OSErr | |
10414 init_dm_notification_handler () | |
10415 { | |
10416 OSErr err; | |
10417 static DMNotificationUPP handle_dm_notificationUPP = NULL; | |
10418 ProcessSerialNumber psn; | |
10419 | |
10420 if (handle_dm_notificationUPP == NULL) | |
10421 handle_dm_notificationUPP = | |
10422 NewDMNotificationUPP (mac_handle_dm_notification); | |
10423 | |
10424 err = GetCurrentProcess (&psn); | |
10425 if (err == noErr) | |
10426 err = DMRegisterNotifyProc (handle_dm_notificationUPP, &psn); | |
10427 | |
10428 return err; | |
10429 } | |
10430 | |
10431 static void | |
10432 mac_get_screen_info (dpyinfo) | |
10433 struct mac_display_info *dpyinfo; | |
10434 { | |
10435 #ifdef MAC_OSX | |
10436 /* HasDepth returns true if it is possible to have a 32 bit display, | |
10437 but this may not be what is actually used. Mac OSX can do better. */ | |
10438 dpyinfo->color_p = CGDisplaySamplesPerPixel (kCGDirectMainDisplay) > 1; | |
10439 dpyinfo->n_planes = CGDisplayBitsPerPixel (kCGDirectMainDisplay); | |
10440 { | |
10441 CGDisplayErr err; | |
10442 CGDisplayCount ndisps; | |
10443 CGDirectDisplayID *displays; | |
10444 | |
10445 err = CGGetActiveDisplayList (0, NULL, &ndisps); | |
10446 if (err == noErr) | |
10447 { | |
10448 displays = alloca (sizeof (CGDirectDisplayID) * ndisps); | |
10449 err = CGGetActiveDisplayList (ndisps, displays, &ndisps); | |
10450 } | |
10451 if (err == noErr) | |
10452 { | |
10453 CGRect bounds = CGRectZero; | |
10454 | |
10455 while (ndisps-- > 0) | |
10456 bounds = CGRectUnion (bounds, CGDisplayBounds (displays[ndisps])); | |
10457 dpyinfo->height = CGRectGetHeight (bounds); | |
10458 dpyinfo->width = CGRectGetWidth (bounds); | |
10459 } | |
10460 else | |
10461 { | |
10462 dpyinfo->height = CGDisplayPixelsHigh (kCGDirectMainDisplay); | |
10463 dpyinfo->width = CGDisplayPixelsWide (kCGDirectMainDisplay); | |
10464 } | |
10465 } | |
10466 #else /* !MAC_OSX */ | |
10467 { | |
10468 GDHandle gdh = GetMainDevice (); | |
10469 Rect rect = (**gdh).gdRect; | |
10470 | |
10471 dpyinfo->color_p = TestDeviceAttribute (gdh, gdDevType); | |
10472 for (dpyinfo->n_planes = 32; dpyinfo->n_planes > 0; dpyinfo->n_planes >>= 1) | |
10473 if (HasDepth (gdh, dpyinfo->n_planes, gdDevType, dpyinfo->color_p)) | |
10474 break; | |
10475 | |
10476 for (gdh = DMGetFirstScreenDevice (dmOnlyActiveDisplays); gdh; | |
10477 gdh = DMGetNextScreenDevice (gdh, dmOnlyActiveDisplays)) | |
10478 UnionRect (&rect, &(**gdh).gdRect, &rect); | |
10479 | |
10480 dpyinfo->height = rect.bottom - rect.top; | |
10481 dpyinfo->width = rect.right - rect.left; | |
10482 } | |
10483 #endif /* !MAC_OSX */ | |
10484 } | |
10485 | |
10486 | |
10399 #if __profile__ | 10487 #if __profile__ |
10400 void | 10488 void |
10401 profiler_exit_proc () | 10489 profiler_exit_proc () |
10402 { | 10490 { |
10403 ProfilerDump ("\pEmacs.prof"); | 10491 ProfilerDump ("\pEmacs.prof"); |
10451 | 10539 |
10452 initialize_applescript (); | 10540 initialize_applescript (); |
10453 | 10541 |
10454 init_apple_event_handler (); | 10542 init_apple_event_handler (); |
10455 | 10543 |
10544 init_dm_notification_handler (); | |
10545 | |
10456 { | 10546 { |
10457 char **argv; | 10547 char **argv; |
10458 int argc = 0; | 10548 int argc = 0; |
10459 | 10549 |
10460 /* set up argv array from STR# resource */ | 10550 /* set up argv array from STR# resource */ |
10528 kEventAttributeNone, &event); | 10618 kEventAttributeNone, &event); |
10529 if (err == noErr) | 10619 if (err == noErr) |
10530 { | 10620 { |
10531 Point mouse_pos; | 10621 Point mouse_pos; |
10532 | 10622 |
10533 GetMouse (&mouse_pos); | 10623 GetGlobalMouse (&mouse_pos); |
10534 LocalToGlobal (&mouse_pos); | |
10535 err = SetEventParameter (event, kEventParamMouseLocation, typeQDPoint, | 10624 err = SetEventParameter (event, kEventParamMouseLocation, typeQDPoint, |
10536 sizeof (Point), &mouse_pos); | 10625 sizeof (Point), &mouse_pos); |
10537 } | 10626 } |
10538 if (err == noErr) | 10627 if (err == noErr) |
10539 { | 10628 { |
11373 { | 11462 { |
11374 x_raise_frame (pending_autoraise_frame); | 11463 x_raise_frame (pending_autoraise_frame); |
11375 pending_autoraise_frame = 0; | 11464 pending_autoraise_frame = 0; |
11376 } | 11465 } |
11377 | 11466 |
11467 if (mac_screen_config_changed) | |
11468 { | |
11469 mac_get_screen_info (dpyinfo); | |
11470 mac_screen_config_changed = 0; | |
11471 } | |
11472 | |
11378 #if !USE_CARBON_EVENTS | 11473 #if !USE_CARBON_EVENTS |
11379 /* Check which frames are still visible. We do this here because | 11474 /* Check which frames are still visible. We do this here because |
11380 there doesn't seem to be any direct notification from the Window | 11475 there doesn't seem to be any direct notification from the Window |
11381 Manager that the visibility of a window has changed (at least, | 11476 Manager that the visibility of a window has changed (at least, |
11382 not in all cases). */ | 11477 not in all cases). */ |
11507 | 11602 |
11508 /*********************************************************************** | 11603 /*********************************************************************** |
11509 Initialization | 11604 Initialization |
11510 ***********************************************************************/ | 11605 ***********************************************************************/ |
11511 | 11606 |
11512 int mac_initialized = 0; | 11607 static int mac_initialized = 0; |
11513 | 11608 |
11514 void | 11609 static XrmDatabase |
11515 mac_initialize_display_info () | 11610 mac_make_rdb (xrm_option) |
11516 { | 11611 const char *xrm_option; |
11517 struct mac_display_info *dpyinfo = &one_mac_display_info; | 11612 { |
11518 | 11613 XrmDatabase database; |
11614 | |
11615 database = xrm_get_preference_database (NULL); | |
11616 if (xrm_option) | |
11617 xrm_merge_string_database (database, xrm_option); | |
11618 | |
11619 return database; | |
11620 } | |
11621 | |
11622 struct mac_display_info * | |
11623 mac_term_init (display_name, xrm_option, resource_name) | |
11624 Lisp_Object display_name; | |
11625 char *xrm_option; | |
11626 char *resource_name; | |
11627 { | |
11628 struct mac_display_info *dpyinfo; | |
11629 | |
11630 BLOCK_INPUT; | |
11631 | |
11632 if (!mac_initialized) | |
11633 { | |
11634 mac_initialize (); | |
11635 mac_initialized = 1; | |
11636 } | |
11637 | |
11638 if (x_display_list) | |
11639 error ("Sorry, this version can only handle one display"); | |
11640 | |
11641 dpyinfo = &one_mac_display_info; | |
11519 bzero (dpyinfo, sizeof (*dpyinfo)); | 11642 bzero (dpyinfo, sizeof (*dpyinfo)); |
11520 | 11643 |
11521 #ifdef MAC_OSX | 11644 #ifdef MAC_OSX |
11522 dpyinfo->mac_id_name | 11645 dpyinfo->mac_id_name |
11523 = (char *) xmalloc (SCHARS (Vinvocation_name) | 11646 = (char *) xmalloc (SCHARS (Vinvocation_name) |
11531 #endif | 11654 #endif |
11532 | 11655 |
11533 dpyinfo->reference_count = 0; | 11656 dpyinfo->reference_count = 0; |
11534 dpyinfo->resx = 72.0; | 11657 dpyinfo->resx = 72.0; |
11535 dpyinfo->resy = 72.0; | 11658 dpyinfo->resy = 72.0; |
11536 #ifdef MAC_OSX | 11659 |
11537 /* HasDepth returns true if it is possible to have a 32 bit display, | 11660 mac_get_screen_info (dpyinfo); |
11538 but this may not be what is actually used. Mac OSX can do better. */ | 11661 |
11539 dpyinfo->color_p = CGDisplaySamplesPerPixel (kCGDirectMainDisplay) > 1; | |
11540 dpyinfo->n_planes = CGDisplayBitsPerPixel (kCGDirectMainDisplay); | |
11541 dpyinfo->height = CGDisplayPixelsHigh (kCGDirectMainDisplay); | |
11542 dpyinfo->width = CGDisplayPixelsWide (kCGDirectMainDisplay); | |
11543 #else | |
11544 { | |
11545 GDHandle main_device_handle = LMGetMainDevice(); | |
11546 | |
11547 dpyinfo->color_p = TestDeviceAttribute (main_device_handle, gdDevType); | |
11548 for (dpyinfo->n_planes = 32; dpyinfo->n_planes > 0; dpyinfo->n_planes >>= 1) | |
11549 if (HasDepth (main_device_handle, dpyinfo->n_planes, | |
11550 gdDevType, dpyinfo->color_p)) | |
11551 break; | |
11552 dpyinfo->height = (**main_device_handle).gdRect.bottom; | |
11553 dpyinfo->width = (**main_device_handle).gdRect.right; | |
11554 } | |
11555 #endif | |
11556 dpyinfo->grabbed = 0; | 11662 dpyinfo->grabbed = 0; |
11557 dpyinfo->root_window = NULL; | 11663 dpyinfo->root_window = NULL; |
11558 dpyinfo->image_cache = make_image_cache (); | 11664 dpyinfo->image_cache = make_image_cache (); |
11559 | 11665 |
11560 dpyinfo->mouse_face_beg_row = dpyinfo->mouse_face_beg_col = -1; | 11666 dpyinfo->mouse_face_beg_row = dpyinfo->mouse_face_beg_col = -1; |
11561 dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_end_col = -1; | 11667 dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_end_col = -1; |
11562 dpyinfo->mouse_face_face_id = DEFAULT_FACE_ID; | 11668 dpyinfo->mouse_face_face_id = DEFAULT_FACE_ID; |
11563 dpyinfo->mouse_face_window = Qnil; | 11669 dpyinfo->mouse_face_window = Qnil; |
11564 dpyinfo->mouse_face_overlay = Qnil; | 11670 dpyinfo->mouse_face_overlay = Qnil; |
11565 dpyinfo->mouse_face_hidden = 0; | 11671 dpyinfo->mouse_face_hidden = 0; |
11566 } | |
11567 | |
11568 | |
11569 static XrmDatabase | |
11570 mac_make_rdb (xrm_option) | |
11571 const char *xrm_option; | |
11572 { | |
11573 XrmDatabase database; | |
11574 | |
11575 database = xrm_get_preference_database (NULL); | |
11576 if (xrm_option) | |
11577 xrm_merge_string_database (database, xrm_option); | |
11578 | |
11579 return database; | |
11580 } | |
11581 | |
11582 struct mac_display_info * | |
11583 mac_term_init (display_name, xrm_option, resource_name) | |
11584 Lisp_Object display_name; | |
11585 char *xrm_option; | |
11586 char *resource_name; | |
11587 { | |
11588 struct mac_display_info *dpyinfo; | |
11589 | |
11590 BLOCK_INPUT; | |
11591 | |
11592 if (!mac_initialized) | |
11593 { | |
11594 mac_initialize (); | |
11595 mac_initialized = 1; | |
11596 } | |
11597 | |
11598 if (x_display_list) | |
11599 error ("Sorry, this version can only handle one display"); | |
11600 | |
11601 mac_initialize_display_info (); | |
11602 | |
11603 dpyinfo = &one_mac_display_info; | |
11604 | 11672 |
11605 dpyinfo->xrdb = mac_make_rdb (xrm_option); | 11673 dpyinfo->xrdb = mac_make_rdb (xrm_option); |
11606 | 11674 |
11607 /* Put this display on the chain. */ | 11675 /* Put this display on the chain. */ |
11608 dpyinfo->next = x_display_list; | 11676 dpyinfo->next = x_display_list; |
11616 | 11684 |
11617 UNBLOCK_INPUT; | 11685 UNBLOCK_INPUT; |
11618 | 11686 |
11619 return dpyinfo; | 11687 return dpyinfo; |
11620 } | 11688 } |
11689 | |
11621 /* Get rid of display DPYINFO, assuming all frames are already gone. */ | 11690 /* Get rid of display DPYINFO, assuming all frames are already gone. */ |
11622 | 11691 |
11623 void | 11692 void |
11624 x_delete_display (dpyinfo) | 11693 x_delete_display (dpyinfo) |
11625 struct mac_display_info *dpyinfo; | 11694 struct mac_display_info *dpyinfo; |
11836 #ifdef MAC_OSX | 11905 #ifdef MAC_OSX |
11837 init_coercion_handler (); | 11906 init_coercion_handler (); |
11838 | 11907 |
11839 init_apple_event_handler (); | 11908 init_apple_event_handler (); |
11840 | 11909 |
11910 init_dm_notification_handler (); | |
11911 | |
11841 if (!inhibit_window_system) | 11912 if (!inhibit_window_system) |
11842 { | 11913 { |
11843 static const ProcessSerialNumber psn = {0, kCurrentProcess}; | 11914 static const ProcessSerialNumber psn = {0, kCurrentProcess}; |
11844 | 11915 |
11845 SetFrontProcess (&psn); | 11916 SetFrontProcess (&psn); |