changeset 70563:fc3c18e2c3b9

(Qservice) [MAC_OSX]: Rename from Qservices. All uses changed. [MAC_OSX] (mac_store_service_event): Rename from mac_store_services_event. All callers changed. [USE_MAC_FONT_PANEL] (mac_set_font_info_for_selection): Add args FACE_ID and C. All callers changed. (x_free_frame_resources) [USE_MAC_FONT_PANEL]: Call mac_set_font_info_for_selection when focus frame is destroyed. (XTread_socket): Revert to FrontNonFloatingWindow/FrontWindow.
author YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
date Wed, 10 May 2006 08:24:49 +0000
parents e2bd086e6902
children aa63a41cac4d
files src/macterm.c
diffstat 1 files changed, 44 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/src/macterm.c	Wed May 10 08:24:09 2006 +0000
+++ b/src/macterm.c	Wed May 10 08:24:49 2006 +0000
@@ -4100,7 +4100,7 @@
 
 #if USE_MAC_FONT_PANEL
       if (frame)
-	mac_set_font_info_for_selection (frame);
+	mac_set_font_info_for_selection (frame, DEFAULT_FACE_ID, 0);
 #endif
     }
 
@@ -6348,7 +6348,12 @@
   f->output_data.mac = NULL;
 
   if (f == dpyinfo->x_focus_frame)
-    dpyinfo->x_focus_frame = 0;
+    {
+      dpyinfo->x_focus_frame = 0;
+#if USE_MAC_FONT_PANEL
+      mac_set_font_info_for_selection (NULL, DEFAULT_FACE_ID, 0);
+#endif
+    }
   if (f == dpyinfo->x_focus_event_frame)
     dpyinfo->x_focus_event_frame = 0;
   if (f == dpyinfo->x_highlight_frame)
@@ -8316,27 +8321,40 @@
 
 #if USE_MAC_FONT_PANEL
 OSStatus
-mac_set_font_info_for_selection (f)
+mac_set_font_info_for_selection (f, face_id, c)
      struct frame *f;
+     int face_id, c;
 {
   OSStatus err;
-
-  if (f == NULL)
-    err = SetFontInfoForSelection (kFontSelectionATSUIType, 0, NULL, NULL);
+  EventTargetRef target = NULL;
+  XFontStruct *font = NULL;
+
+  if (f)
+    {
+      target = GetWindowEventTarget (FRAME_MAC_WINDOW (f));
+
+      if (FRAME_FACE_CACHE (f) && CHAR_VALID_P (c, 0))
+	{
+	  struct face *face;
+
+	  face_id = FACE_FOR_CHAR (f, FACE_FROM_ID (f, face_id), c);
+	  face = FACE_FROM_ID (f, face_id);
+	  font = face->font;
+	}
+    }
+
+  if (font == NULL)
+    err = SetFontInfoForSelection (kFontSelectionATSUIType, 0, NULL, target);
   else
     {
-      struct face *default_face = FACE_FROM_ID (f, DEFAULT_FACE_ID);
-      XFontStruct *ascii_font = default_face->ascii_face->font;
-      EventTargetRef target = GetWindowEventTarget (FRAME_MAC_WINDOW (f));
-
-      if (ascii_font->mac_fontnum != -1)
+      if (font->mac_fontnum != -1)
 	{
 	  FontSelectionQDStyle qd_style;
 
 	  qd_style.version = kFontSelectionQDStyleVersionZero;
-	  qd_style.instance.fontFamily = ascii_font->mac_fontnum;
-	  qd_style.instance.fontStyle = ascii_font->mac_fontface;
-	  qd_style.size = ascii_font->mac_fontsize;
+	  qd_style.instance.fontFamily = font->mac_fontnum;
+	  qd_style.instance.fontStyle = font->mac_fontface;
+	  qd_style.size = font->mac_fontsize;
 	  qd_style.hasColor = false;
 
 	  err = SetFontInfoForSelection (kFontSelectionQDType,
@@ -8344,7 +8362,7 @@
 	}
       else
 	err = SetFontInfoForSelection (kFontSelectionATSUIType,
-				       1, &ascii_font->mac_style, target);
+				       1, &font->mac_style, target);
     }
 
   return err;
@@ -8461,7 +8479,7 @@
 #if USE_CARBON_EVENTS
 #ifdef MAC_OSX
 extern void init_service_handler ();
-static Lisp_Object Qservices, Qpaste, Qperform;
+static Lisp_Object Qservice, Qpaste, Qperform;
 #endif
 /* Window Event Handler */
 static pascal OSStatus mac_handle_window_event (EventHandlerCallRef,
@@ -9379,7 +9397,7 @@
 
 #ifdef MAC_OSX
 OSStatus
-mac_store_services_event (event)
+mac_store_service_event (event)
      EventRef event;
 {
   OSStatus err;
@@ -9412,7 +9430,7 @@
       abort ();
     }
 
-  err = mac_store_event_ref_as_apple_event (0, 0, Qservices, id_key,
+  err = mac_store_event_ref_as_apple_event (0, 0, Qservice, id_key,
 					    event, num_params,
 					    names, types);
 
@@ -9930,8 +9948,13 @@
 		break;
 
 	      case inContent:
-		if (dpyinfo->x_focus_frame == NULL
-		    || window_ptr != FRAME_MAC_WINDOW (dpyinfo->x_focus_frame))
+		if (
+#if TARGET_API_MAC_CARBON
+		    FrontNonFloatingWindow ()
+#else
+		    FrontWindow ()
+#endif
+		    != window_ptr)
 		  SelectWindow (window_ptr);
 		else
 		  {
@@ -11034,7 +11057,7 @@
   Qselection    = intern ("selection");     staticpro (&Qselection);
 #endif
 
-  Qservices    = intern ("services");	  staticpro (&Qservices);
+  Qservice     = intern ("service");	  staticpro (&Qservice);
   Qpaste       = intern ("paste");	  staticpro (&Qpaste);
   Qperform     = intern ("perform");	  staticpro (&Qperform);
 #endif