]> code.delx.au - gnu-emacs/blobdiff - src/macselect.c
(erc-match-syntax-table): Replace `legal' with `valid'.
[gnu-emacs] / src / macselect.c
index 67a28cf9e6467dce6df60a025084b0f842fa8284..f624c02145b7a0e86fbde15dda0851503f53f6c6 100644 (file)
@@ -1,11 +1,11 @@
 /* Selection processing for Emacs on Mac OS.
-   Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+   Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
 GNU Emacs is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
+the Free Software Foundation; either version 3, or (at your option)
 any later version.
 
 GNU Emacs is distributed in the hope that it will be useful,
@@ -31,15 +31,15 @@ typedef int ScrapRef;
 typedef ResType ScrapFlavorType;
 #endif /* !TARGET_API_MAC_CARBON */
 
-static OSErr get_scrap_from_symbol P_ ((Lisp_Object, int, ScrapRef *));
+static OSStatus get_scrap_from_symbol P_ ((Lisp_Object, int, ScrapRef *));
 static ScrapFlavorType get_flavor_type_from_symbol P_ ((Lisp_Object));
 static int valid_scrap_target_type_p P_ ((Lisp_Object));
-static OSErr clear_scrap P_ ((ScrapRef *));
-static OSErr put_scrap_string P_ ((ScrapRef, Lisp_Object, Lisp_Object));
-static OSErr put_scrap_private_timestamp P_ ((ScrapRef, unsigned long));
+static OSStatus clear_scrap P_ ((ScrapRef *));
+static OSStatus put_scrap_string P_ ((ScrapRef, Lisp_Object, Lisp_Object));
+static OSStatus put_scrap_private_timestamp P_ ((ScrapRef, unsigned long));
 static ScrapFlavorType scrap_has_target_type P_ ((ScrapRef, Lisp_Object));
 static Lisp_Object get_scrap_string P_ ((ScrapRef, Lisp_Object));
-static OSErr get_scrap_private_timestamp P_ ((ScrapRef, unsigned long *));
+static OSStatus get_scrap_private_timestamp P_ ((ScrapRef, unsigned long *));
 static Lisp_Object get_scrap_target_type_list P_ ((ScrapRef));
 static void x_own_selection P_ ((Lisp_Object, Lisp_Object));
 static Lisp_Object x_get_local_selection P_ ((Lisp_Object, Lisp_Object, int));
@@ -108,13 +108,13 @@ static Lisp_Object Vmac_service_selection;
    reference is set to *SCRAP, and it becomes NULL if there's no
    corresponding scrap.  Clear the scrap if CLEAR_P is non-zero.  */
 
-static OSErr
+static OSStatus
 get_scrap_from_symbol (sym, clear_p, scrap)
      Lisp_Object sym;
      int clear_p;
      ScrapRef *scrap;
 {
-  OSErr err = noErr;
+  OSStatus err = noErr;
   Lisp_Object str = Fget (sym, Qmac_scrap_name);
 
   if (!STRINGP (str))
@@ -172,7 +172,7 @@ valid_scrap_target_type_p (sym)
 
 /* Clear the scrap whose reference is *SCRAP. */
 
-static INLINE OSErr
+static INLINE OSStatus
 clear_scrap (scrap)
      ScrapRef *scrap;
 {
@@ -190,7 +190,7 @@ clear_scrap (scrap)
 /* Put Lisp String STR to the scrap SCRAP.  The target type is
    specified by TYPE. */
 
-static OSErr
+static OSStatus
 put_scrap_string (scrap, type, str)
      ScrapRef scrap;
      Lisp_Object type, str;
@@ -211,7 +211,7 @@ put_scrap_string (scrap, type, str)
 /* Put TIMESTAMP to the scrap SCRAP.  The timestamp is used for
    checking if the scrap is owned by the process.  */
 
-static INLINE OSErr
+static INLINE OSStatus
 put_scrap_private_timestamp (scrap, timestamp)
      ScrapRef scrap;
      unsigned long timestamp;
@@ -233,7 +233,7 @@ scrap_has_target_type (scrap, type)
      ScrapRef scrap;
      Lisp_Object type;
 {
-  OSErr err;
+  OSStatus err;
   ScrapFlavorType flavor_type = get_flavor_type_from_symbol (type);
 
   if (flavor_type)
@@ -264,7 +264,7 @@ get_scrap_string (scrap, type)
      ScrapRef scrap;
      Lisp_Object type;
 {
-  OSErr err;
+  OSStatus err;
   Lisp_Object result = Qnil;
   ScrapFlavorType flavor_type = get_flavor_type_from_symbol (type);
 #if TARGET_API_MAC_CARBON
@@ -310,12 +310,12 @@ get_scrap_string (scrap, type)
 
 /* Get timestamp from the scrap SCRAP and set to *TIMPSTAMP.  */
 
-static OSErr
+static OSStatus
 get_scrap_private_timestamp (scrap, timestamp)
      ScrapRef scrap;
      unsigned long *timestamp;
 {
-  OSErr err = noErr;
+  OSStatus err = noErr;
 #if TARGET_API_MAC_CARBON
   ScrapFlavorFlags flags;
 
@@ -365,7 +365,7 @@ get_scrap_target_type_list (scrap)
 {
   Lisp_Object result = Qnil, rest, target_type;
 #if TARGET_API_MAC_CARBON
-  OSErr err;
+  OSStatus err;
   UInt32 count, i, type;
   ScrapFlavorInfo *flavor_info = NULL;
   Lisp_Object strings = Qnil;
@@ -386,7 +386,9 @@ get_scrap_target_type_list (scrap)
     {
       ScrapFlavorType flavor_type = 0;
 
-      if (CONSP (XCAR (rest)) && SYMBOLP (target_type = XCAR (XCAR (rest)))
+      if (CONSP (XCAR (rest))
+         && (target_type = XCAR (XCAR (rest)),
+             SYMBOLP (target_type))
          && (flavor_type = scrap_has_target_type (scrap, target_type)))
        {
          result = Fcons (target_type, result);
@@ -425,7 +427,7 @@ static void
 x_own_selection (selection_name, selection_value)
      Lisp_Object selection_name, selection_value;
 {
-  OSErr err;
+  OSStatus err;
   ScrapRef scrap;
   struct gcpro gcpro1, gcpro2;
   Lisp_Object rest, handler_fn, value, type;
@@ -449,9 +451,11 @@ x_own_selection (selection_name, selection_value)
       for (rest = Vselection_converter_alist; CONSP (rest); rest = XCDR (rest))
        {
          if (!(CONSP (XCAR (rest))
-               && SYMBOLP (type = XCAR (XCAR (rest)))
+               && (type = XCAR (XCAR (rest)),
+                   SYMBOLP (type))
                && valid_scrap_target_type_p (type)
-               && SYMBOLP (handler_fn = XCDR (XCAR (rest)))))
+               && (handler_fn = XCDR (XCAR (rest)),
+                   SYMBOLP (handler_fn))))
            continue;
 
          if (!NILP (handler_fn))
@@ -671,7 +675,7 @@ static Lisp_Object
 x_get_foreign_selection (selection_symbol, target_type, time_stamp)
      Lisp_Object selection_symbol, target_type, time_stamp;
 {
-  OSErr err;
+  OSStatus err;
   ScrapRef scrap;
   Lisp_Object result = Qnil;
 
@@ -765,7 +769,7 @@ Disowning it means there is no such selection.  */)
      Lisp_Object selection;
      Lisp_Object time;
 {
-  OSErr err;
+  OSStatus err;
   ScrapRef scrap;
   Lisp_Object local_selection_data;
 
@@ -828,7 +832,7 @@ and t is the same as `SECONDARY'.  */)
      (selection)
      Lisp_Object selection;
 {
-  OSErr err;
+  OSStatus err;
   ScrapRef scrap;
   Lisp_Object result = Qnil, local_selection_data;
 
@@ -873,7 +877,7 @@ and t is the same as `SECONDARY'.  */)
      (selection)
      Lisp_Object selection;
 {
-  OSErr err;
+  OSStatus err;
   ScrapRef scrap;
   Lisp_Object result = Qnil, rest;
 
@@ -931,7 +935,7 @@ struct suspended_ae_info
   struct suspended_ae_info *next;
 };
 
-/* List of deferred apple events at the startup time.  */
+/* List of apple events deferred at the startup time.  */
 static struct suspended_ae_info *deferred_apple_events = NULL;
 
 /* List of suspended apple events, in order of expiration_tick.  */
@@ -1390,7 +1394,7 @@ nil, which means the event is already resumed or expired.  */)
       ae = *p;
       *p = (*p)->next;
       if (INTEGERP (error_code)
-         && ae->apple_event.descriptorType != typeNull)
+         && ae->reply.descriptorType != typeNull)
        {
          SInt32 errn = XINT (error_code);
 
@@ -1562,13 +1566,19 @@ mac_do_receive_drag (window, refcon, drag)
       GlobalToLocal (&mouse_pos);
       err = GetDragModifiers (drag, NULL, NULL, &modifiers);
     }
+  if (err == noErr)
+    {
+      UInt32 key_modifiers = modifiers;
+
+      err = AEPutParamPtr (&apple_event, kEventParamKeyModifiers,
+                          typeUInt32, &key_modifiers, sizeof (UInt32));
+    }
 
   if (err == noErr)
     {
-      mac_store_drag_event (window, mouse_pos, modifiers, &apple_event);
+      mac_store_drag_event (window, mouse_pos, 0, &apple_event);
       AEDisposeDesc (&apple_event);
-      /* Post a harmless event so as to wake up from ReceiveNextEvent.  */
-      mac_post_mouse_moved_event ();
+      mac_wakeup_from_rne ();
       return noErr;
     }
   else
@@ -1616,10 +1626,11 @@ remove_drag_handler (window)
 void
 init_service_handler ()
 {
-  EventTypeSpec specs[] = {{kEventClassService, kEventServiceGetTypes},
-                          {kEventClassService, kEventServiceCopy},
-                          {kEventClassService, kEventServicePaste},
-                          {kEventClassService, kEventServicePerform}};
+  static const EventTypeSpec specs[] =
+    {{kEventClassService, kEventServiceGetTypes},
+     {kEventClassService, kEventServiceCopy},
+     {kEventClassService, kEventServicePaste},
+     {kEventClassService, kEventServicePerform}};
   InstallApplicationEventHandler (NewEventHandlerUPP (mac_handle_service_event),
                                  GetEventTypeCount (specs), specs, NULL, NULL);
 }
@@ -1845,10 +1856,7 @@ and the local selection value (whatever was given to `x-own-selection').
 
 The function should return the value to send to the Scrap Manager
 \(must be a string).  A return value of nil
-means that the conversion could not be done.
-A return value which is the symbol `NULL'
-means that a side-effect was executed,
-and there is no meaningful selection value.  */);
+means that the conversion could not be done.  */);
   Vselection_converter_alist = Qnil;
 
   DEFVAR_LISP ("x-lost-selection-functions", &Vx_lost_selection_functions,