changeset 80517:086b32514483

(Vmac_ts_script_language_on_focus) (saved_ts_script_language_on_focus) [USE_MAC_TSM]: Remove externs. (XTread_socket) [USE_MAC_TOOLBAR]: Select window if its structure part is clicked. (x_activate_menubar): Remove extern for saved_menu_event_location. (create_apple_event_from_drag_ref) [TARGET_API_MAC_CARBON]: Move from mac.c.
author YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
date Sat, 19 Apr 2008 01:25:28 +0000
parents 9b6c288d125e
children d55279d4ddcf
files src/mactoolbox.c
diffstat 1 files changed, 77 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/mactoolbox.c	Sat Apr 19 01:25:15 2008 +0000
+++ b/src/mactoolbox.c	Sat Apr 19 01:25:28 2008 +0000
@@ -120,8 +120,6 @@
 extern Lisp_Object Qupdate_active_input_area, Qunicode_for_key_event;
 extern Lisp_Object Vmac_ts_active_input_overlay;
 extern Lisp_Object Qbefore_string;
-extern Lisp_Object Vmac_ts_script_language_on_focus;
-extern Lisp_Object saved_ts_script_language_on_focus;
 #endif
 
 static int mac_event_to_emacs_modifiers P_ ((EventRef));
@@ -606,15 +604,15 @@
 #if USE_MAC_TSM
   if (err == noErr)
     {
-      static const EventTypeSpec spec[] =
+      static const EventTypeSpec specs[] =
 	{{kEventClassTextInput, kEventTextInputUpdateActiveInputArea},
 	 {kEventClassTextInput, kEventTextInputUnicodeForKeyEvent},
 	 {kEventClassTextInput, kEventTextInputOffsetToPos}};
 
       err = InstallApplicationEventHandler (NewEventHandlerUPP
 					    (mac_handle_text_input_event),
-					    GetEventTypeCount (spec),
-					    spec, NULL, NULL);
+					    GetEventTypeCount (specs),
+					    specs, NULL, NULL);
     }
 #endif
 
@@ -3009,8 +3007,8 @@
   GetEventParameter (eventRef, kEventParamKeyModifiers, typeUInt32, NULL,
 		    sizeof (UInt32), NULL, &mods);
   class = GetEventClass (eventRef);
-  if (!NILP (Vmac_emulate_three_button_mouse) &&
-      (class == kEventClassMouse || class == kEventClassCommand))
+  if (!NILP (Vmac_emulate_three_button_mouse)
+      && (class == kEventClassMouse || class == kEventClassCommand))
     {
       mods &= ~(optionKey | cmdKey);
     }
@@ -3560,6 +3558,9 @@
 		  OSStatus err;
 		  HIViewRef ch;
 
+		  if (FrontNonFloatingWindow () != window_ptr)
+		    SelectWindow (window_ptr);
+
 		  err = HIViewGetViewForMouseEvent (HIViewGetRoot (window_ptr),
 						    eventRef, &ch);
 		  /* This doesn't work on Mac OS X 10.2.  */
@@ -4248,7 +4249,6 @@
 {
   SInt32 menu_choice;
   SInt16 menu_id, menu_item;
-  extern Point saved_menu_event_location;
 
   set_frame_menubar (f, 0, 1);
   BLOCK_INPUT;
@@ -5704,6 +5704,75 @@
 static DragTrackingHandlerUPP mac_do_track_dragUPP = NULL;
 static DragReceiveHandlerUPP mac_do_receive_dragUPP = NULL;
 
+static OSErr
+create_apple_event_from_drag_ref (drag, num_types, types, result)
+     DragRef drag;
+     UInt32 num_types;
+     const FlavorType *types;
+     AppleEvent *result;
+{
+  OSErr err;
+  UInt16 num_items;
+  AppleEvent items;
+  long index;
+  char *buf = NULL;
+
+  err = CountDragItems (drag, &num_items);
+  if (err != noErr)
+    return err;
+  err = AECreateList (NULL, 0, false, &items);
+  if (err != noErr)
+    return err;
+
+  for (index = 1; index <= num_items; index++)
+    {
+      ItemReference item;
+      DescType desc_type = typeNull;
+      Size size;
+
+      err = GetDragItemReferenceNumber (drag, index, &item);
+      if (err == noErr)
+	{
+	  int i;
+
+	  for (i = 0; i < num_types; i++)
+	    {
+	      err = GetFlavorDataSize (drag, item, types[i], &size);
+	      if (err == noErr)
+		{
+		  buf = xrealloc (buf, size);
+		  err = GetFlavorData (drag, item, types[i], buf, &size, 0);
+		}
+	      if (err == noErr)
+		{
+		  desc_type = types[i];
+		  break;
+		}
+	    }
+	}
+      err = AEPutPtr (&items, index, desc_type,
+		      desc_type != typeNull ? buf : NULL,
+		      desc_type != typeNull ? size : 0);
+      if (err != noErr)
+	break;
+    }
+  if (buf)
+    xfree (buf);
+
+  if (err == noErr)
+    {
+      err = create_apple_event (0, 0, result); /* Dummy class and ID.  */
+      if (err == noErr)
+	err = AEPutParamDesc (result, keyDirectObject, &items);
+      if (err != noErr)
+	AEDisposeDesc (result);
+    }
+
+  AEDisposeDesc (&items);
+
+  return err;
+}
+
 static void
 mac_store_drag_event (window, mouse_pos, modifiers, desc)
      WindowRef window;