aboutsummaryrefslogtreecommitdiffstats
path: root/src/macterm.c
diff options
context:
space:
mode:
authorYAMAMOTO Mitsuharu2007-04-13 08:14:23 +0000
committerYAMAMOTO Mitsuharu2007-04-13 08:14:23 +0000
commit19ee09cc776bc4db41ea272d092960cd4f2167f8 (patch)
tree85e1fe6f21448fadbf51f34935c4d87c7ee1503d /src/macterm.c
parentc8286c2ca4712ba47ef802394fa776bb1c34e3c5 (diff)
downloademacs-19ee09cc776bc4db41ea272d092960cd4f2167f8.tar.gz
emacs-19ee09cc776bc4db41ea272d092960cd4f2167f8.zip
[!TARGET_API_MAC_CARBON] Include Displays.h.
(mac_screen_config_changed): New variable. (mac_handle_dm_notification, init_dm_notification_handler) (mac_get_screen_info): New functions. [MAC_OS8] (main): Call init_dm_notification_handler. (mac_initialize) [MAC_OSX]: Likewise. (XTread_socket): Call mac_get_screen_info if screen config changed. (mac_initialized): Make static. (mac_initialize_display_info): Remove function. (mac_term_init): Call mac_get_screen_info. Add partial contents of mac_initialize_display_info.
Diffstat (limited to 'src/macterm.c')
-rw-r--r--src/macterm.c215
1 files changed, 127 insertions, 88 deletions
diff --git a/src/macterm.c b/src/macterm.c
index 9d190a3e4f6..bee1af5ab71 100644
--- a/src/macterm.c
+++ b/src/macterm.c
@@ -52,6 +52,7 @@ Boston, MA 02110-1301, USA. */
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
@@ -8869,6 +8870,9 @@ int mac_pass_control_to_system;
8869 Carbon/Apple event handlers. */ 8870 Carbon/Apple event handlers. */
8870static struct input_event *read_socket_inev = NULL; 8871static struct input_event *read_socket_inev = NULL;
8871 8872
8873/* Whether or not the screen configuration has changed. */
8874static int mac_screen_config_changed = 0;
8875
8872Point saved_menu_event_location; 8876Point saved_menu_event_location;
8873 8877
8874/* Apple Events */ 8878/* Apple Events */
@@ -10399,6 +10403,87 @@ remove_window_handler (window)
10399} 10403}
10400 10404
10401 10405
10406static pascal void
10407mac_handle_dm_notification (event)
10408 AppleEvent *event;
10409{
10410 mac_screen_config_changed = 1;
10411}
10412
10413static OSErr
10414init_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
10431static void
10432mac_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
10402#if __profile__ 10487#if __profile__
10403void 10488void
10404profiler_exit_proc () 10489profiler_exit_proc ()
@@ -10456,6 +10541,8 @@ main (void)
10456 10541
10457 init_apple_event_handler (); 10542 init_apple_event_handler ();
10458 10543
10544 init_dm_notification_handler ();
10545
10459 { 10546 {
10460 char **argv; 10547 char **argv;
10461 int argc = 0; 10548 int argc = 0;
@@ -11377,6 +11464,12 @@ XTread_socket (sd, expected, hold_quit)
11377 pending_autoraise_frame = 0; 11464 pending_autoraise_frame = 0;
11378 } 11465 }
11379 11466
11467 if (mac_screen_config_changed)
11468 {
11469 mac_get_screen_info (dpyinfo);
11470 mac_screen_config_changed = 0;
11471 }
11472
11380#if !USE_CARBON_EVENTS 11473#if !USE_CARBON_EVENTS
11381 /* Check which frames are still visible. We do this here because 11474 /* Check which frames are still visible. We do this here because
11382 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
@@ -11511,92 +11604,7 @@ make_mac_terminal_frame (struct frame *f)
11511 Initialization 11604 Initialization
11512 ***********************************************************************/ 11605 ***********************************************************************/
11513 11606
11514int mac_initialized = 0; 11607static int mac_initialized = 0;
11515
11516void
11517mac_initialize_display_info ()
11518{
11519 struct mac_display_info *dpyinfo = &one_mac_display_info;
11520
11521 bzero (dpyinfo, sizeof (*dpyinfo));
11522
11523#ifdef MAC_OSX
11524 dpyinfo->mac_id_name
11525 = (char *) xmalloc (SCHARS (Vinvocation_name)
11526 + SCHARS (Vsystem_name)
11527 + 2);
11528 sprintf (dpyinfo->mac_id_name, "%s@%s",
11529 SDATA (Vinvocation_name), SDATA (Vsystem_name));
11530#else
11531 dpyinfo->mac_id_name = (char *) xmalloc (strlen ("Mac Display") + 1);
11532 strcpy (dpyinfo->mac_id_name, "Mac Display");
11533#endif
11534
11535 dpyinfo->reference_count = 0;
11536 dpyinfo->resx = 72.0;
11537 dpyinfo->resy = 72.0;
11538#ifdef MAC_OSX
11539 /* HasDepth returns true if it is possible to have a 32 bit display,
11540 but this may not be what is actually used. Mac OSX can do better. */
11541 dpyinfo->color_p = CGDisplaySamplesPerPixel (kCGDirectMainDisplay) > 1;
11542 dpyinfo->n_planes = CGDisplayBitsPerPixel (kCGDirectMainDisplay);
11543 {
11544 CGDisplayErr err;
11545 CGDisplayCount ndisps;
11546 CGDirectDisplayID *displays;
11547
11548 err = CGGetActiveDisplayList (0, NULL, &ndisps);
11549 if (err == noErr)
11550 {
11551 displays = alloca (sizeof (CGDirectDisplayID) * ndisps);
11552 err = CGGetActiveDisplayList (ndisps, displays, &ndisps);
11553 }
11554 if (err == noErr)
11555 {
11556 CGRect bounds = CGRectZero;
11557
11558 while (ndisps-- > 0)
11559 bounds = CGRectUnion (bounds, CGDisplayBounds (displays[ndisps]));
11560 dpyinfo->height = CGRectGetHeight (bounds);
11561 dpyinfo->width = CGRectGetWidth (bounds);
11562 }
11563 else
11564 {
11565 dpyinfo->height = CGDisplayPixelsHigh (kCGDirectMainDisplay);
11566 dpyinfo->width = CGDisplayPixelsWide (kCGDirectMainDisplay);
11567 }
11568 }
11569#else
11570 {
11571 GDHandle gdh = GetMainDevice ();
11572 Rect rect = (**gdh).gdRect;
11573
11574 dpyinfo->color_p = TestDeviceAttribute (gdh, gdDevType);
11575 for (dpyinfo->n_planes = 32; dpyinfo->n_planes > 0; dpyinfo->n_planes >>= 1)
11576 if (HasDepth (gdh, dpyinfo->n_planes, gdDevType, dpyinfo->color_p))
11577 break;
11578
11579 for (gdh = GetDeviceList (); gdh; gdh = GetNextDevice (gdh))
11580 if (TestDeviceAttribute (gdh, screenDevice)
11581 && TestDeviceAttribute (gdh, screenActive))
11582 UnionRect (&rect, &(**gdh).gdRect, &rect);
11583
11584 dpyinfo->height = rect.bottom - rect.top;
11585 dpyinfo->width = rect.right - rect.left;
11586 }
11587#endif
11588 dpyinfo->grabbed = 0;
11589 dpyinfo->root_window = NULL;
11590 dpyinfo->image_cache = make_image_cache ();
11591
11592 dpyinfo->mouse_face_beg_row = dpyinfo->mouse_face_beg_col = -1;
11593 dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_end_col = -1;
11594 dpyinfo->mouse_face_face_id = DEFAULT_FACE_ID;
11595 dpyinfo->mouse_face_window = Qnil;
11596 dpyinfo->mouse_face_overlay = Qnil;
11597 dpyinfo->mouse_face_hidden = 0;
11598}
11599
11600 11608
11601static XrmDatabase 11609static XrmDatabase
11602mac_make_rdb (xrm_option) 11610mac_make_rdb (xrm_option)
@@ -11630,9 +11638,37 @@ mac_term_init (display_name, xrm_option, resource_name)
11630 if (x_display_list) 11638 if (x_display_list)
11631 error ("Sorry, this version can only handle one display"); 11639 error ("Sorry, this version can only handle one display");
11632 11640
11633 mac_initialize_display_info ();
11634
11635 dpyinfo = &one_mac_display_info; 11641 dpyinfo = &one_mac_display_info;
11642 bzero (dpyinfo, sizeof (*dpyinfo));
11643
11644#ifdef MAC_OSX
11645 dpyinfo->mac_id_name
11646 = (char *) xmalloc (SCHARS (Vinvocation_name)
11647 + SCHARS (Vsystem_name)
11648 + 2);
11649 sprintf (dpyinfo->mac_id_name, "%s@%s",
11650 SDATA (Vinvocation_name), SDATA (Vsystem_name));
11651#else
11652 dpyinfo->mac_id_name = (char *) xmalloc (strlen ("Mac Display") + 1);
11653 strcpy (dpyinfo->mac_id_name, "Mac Display");
11654#endif
11655
11656 dpyinfo->reference_count = 0;
11657 dpyinfo->resx = 72.0;
11658 dpyinfo->resy = 72.0;
11659
11660 mac_get_screen_info (dpyinfo);
11661
11662 dpyinfo->grabbed = 0;
11663 dpyinfo->root_window = NULL;
11664 dpyinfo->image_cache = make_image_cache ();
11665
11666 dpyinfo->mouse_face_beg_row = dpyinfo->mouse_face_beg_col = -1;
11667 dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_end_col = -1;
11668 dpyinfo->mouse_face_face_id = DEFAULT_FACE_ID;
11669 dpyinfo->mouse_face_window = Qnil;
11670 dpyinfo->mouse_face_overlay = Qnil;
11671 dpyinfo->mouse_face_hidden = 0;
11636 11672
11637 dpyinfo->xrdb = mac_make_rdb (xrm_option); 11673 dpyinfo->xrdb = mac_make_rdb (xrm_option);
11638 11674
@@ -11650,6 +11686,7 @@ mac_term_init (display_name, xrm_option, resource_name)
11650 11686
11651 return dpyinfo; 11687 return dpyinfo;
11652} 11688}
11689
11653/* Get rid of display DPYINFO, assuming all frames are already gone. */ 11690/* Get rid of display DPYINFO, assuming all frames are already gone. */
11654 11691
11655void 11692void
@@ -11869,6 +11906,8 @@ mac_initialize ()
11869 11906
11870 init_apple_event_handler (); 11907 init_apple_event_handler ();
11871 11908
11909 init_dm_notification_handler ();
11910
11872 if (!inhibit_window_system) 11911 if (!inhibit_window_system)
11873 { 11912 {
11874 static const ProcessSerialNumber psn = {0, kCurrentProcess}; 11913 static const ProcessSerialNumber psn = {0, kCurrentProcess};