changeset 56888:a81166121d93

(x_real_positions): Save the current window port and set a new one before obtaining the global coordinate. Use FRAME_MAC_WINDOW. (x_set_name, x_set_title): Encode title to UTF8. Use SetWindowTitleWithCFString. (Fx_server_version): Get correct OS version.
author Steven Tamm <steventamm@mac.com>
date Thu, 02 Sep 2004 17:00:12 +0000
parents 25a1d37d22fb
children ca08ff660c73
files src/macfns.c
diffstat 1 files changed, 36 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/src/macfns.c	Thu Sep 02 16:59:18 2004 +0000
+++ b/src/macfns.c	Thu Sep 02 17:00:12 2004 +0000
@@ -324,19 +324,21 @@
   Point pt;
   GrafPtr oldport;
 
-#ifdef TARGET_API_MAC_CARBON
+  GetPort (&oldport);
+  SetPortWindowPort (FRAME_MAC_WINDOW (f));
+
+#if TARGET_API_MAC_CARBON
   {
     Rect r;
 
-    GetWindowPortBounds (f->output_data.mac->mWP, &r);
+    GetWindowPortBounds (FRAME_MAC_WINDOW (f), &r);
     SetPt (&pt, r.left, r.top);
   }
 #else /* not TARGET_API_MAC_CARBON */
   SetPt (&pt,
-	 f->output_data.mac->mWP->portRect.left,
-	 f->output_data.mac->mWP->portRect.top);
+	 FRAME_MAC_WINDOW (f)->portRect.left,
+	 FRAME_MAC_WINDOW (f)->portRect.top);
 #endif /* not TARGET_API_MAC_CARBON */
-  GetPort (&oldport);
   LocalToGlobal (&pt);
   SetPort (oldport);
 
@@ -1934,8 +1936,8 @@
   if (FRAME_MAC_WINDOW (f))
     {
       if (STRING_MULTIBYTE (name))
-#if 0 /* MAC_TODO: encoding title string */
-	name = ENCODE_SYSTEM (name);
+#if TARGET_API_MAC_CARBON
+	name = ENCODE_UTF_8 (name);
 #else
         return;
 #endif
@@ -1943,6 +1945,14 @@
       BLOCK_INPUT;
 
       {
+#if TARGET_API_MAC_CARBON
+	CFStringRef windowTitle =
+	  CFStringCreateWithCString (NULL, SDATA (name),
+				     kCFStringEncodingUTF8);
+
+	SetWindowTitleWithCFString (FRAME_MAC_WINDOW (f), windowTitle);
+	CFRelease (windowTitle);
+#else
 	Str255 windowTitle;
 	if (strlen (SDATA (name)) < 255)
 	  {
@@ -1950,6 +1960,7 @@
 	    c2pstr (windowTitle);
 	    SetWTitle (FRAME_MAC_WINDOW (f), windowTitle);
 	  }
+#endif
       }
 
       UNBLOCK_INPUT;
@@ -2008,8 +2019,8 @@
   if (FRAME_MAC_WINDOW (f))
     {
       if (STRING_MULTIBYTE (name))
-#if 0 /* MAC_TODO: encoding title string */
-	name = ENCODE_SYSTEM (name);
+#if TARGET_API_MAC_CARBON
+	name = ENCODE_UTF_8 (name);
 #else
         return;
 #endif
@@ -2017,6 +2028,14 @@
       BLOCK_INPUT;
 
       {
+#if TARGET_API_MAC_CARBON
+	CFStringRef windowTitle =
+	  CFStringCreateWithCString (NULL, SDATA (name),
+				     kCFStringEncodingUTF8);
+
+	SetWindowTitleWithCFString (FRAME_MAC_WINDOW (f), windowTitle);
+	CFRelease (windowTitle);
+#else
 	Str255 windowTitle;
 	if (strlen (SDATA (name)) < 255)
 	  {
@@ -2024,6 +2043,7 @@
 	    c2pstr (windowTitle);
 	    SetWTitle (FRAME_MAC_WINDOW (f), windowTitle);
 	  }
+#endif
       }
 
       UNBLOCK_INPUT;
@@ -2981,17 +3001,20 @@
   (display)
      Lisp_Object display;
 {
-  int mac_major_version, mac_minor_version;
+  int mac_major_version;
   SInt32 response;
 
   if (Gestalt (gestaltSystemVersion, &response) != noErr)
     error ("Cannot get Mac OS version");
 
-  mac_major_version = (response >> 8) & 0xf;
-  mac_minor_version = (response >> 4) & 0xf;
+  mac_major_version = (response >> 8) & 0xff;
+  /* convert BCD to int */
+  mac_major_version -= (mac_major_version >> 4) * 6;
 
   return Fcons (make_number (mac_major_version),
-		Fcons (make_number (mac_minor_version), Qnil));
+		Fcons (make_number ((response >> 4) & 0xf),
+		       Fcons (make_number (response & 0xf),
+			      Qnil)));
 }
 
 DEFUN ("x-display-screens", Fx_display_screens, Sx_display_screens, 0, 1, 0,