comparison src/macterm.c @ 83408:39bb10ce301a

Merged in changes from CVS trunk. Patches applied: * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-667 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-668 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-669 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-670 Update from CVS * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-157 Merge from emacs--cvs-trunk--0 * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-158 Update from CVS * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-159 Update from CVS * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-160 Update from CVS * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-161 Update from CVS * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-162 Update from CVS * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-163 Update from CVS * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-164 Update from CVS * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-165 Update from CVS: texi/message.texi: Fix default values. * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-166 Update from CVS * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-167 Update from CVS * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-168 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-448
author Karoly Lorentey <lorentey@elte.hu>
date Sun, 11 Dec 2005 22:42:40 +0000
parents 1955a4462bf9 e6e566aad553
children fe870a866ce7
comparison
equal deleted inserted replaced
83407:37d0562504bf 83408:39bb10ce301a
620 UniCharCount lengths[] = {kATSUToTextEnd}; 620 UniCharCount lengths[] = {kATSUToTextEnd};
621 ATSUAttributeTag tags[] = {kATSULineLayoutOptionsTag}; 621 ATSUAttributeTag tags[] = {kATSULineLayoutOptionsTag};
622 ByteCount sizes[] = {sizeof (ATSLineLayoutOptions)}; 622 ByteCount sizes[] = {sizeof (ATSLineLayoutOptions)};
623 static ATSLineLayoutOptions line_layout = 623 static ATSLineLayoutOptions line_layout =
624 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020 624 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
625 kATSLineDisableAllLayoutOperations | kATSLineUseDeviceMetrics 625 kATSLineDisableAllLayoutOperations | kATSLineUseDeviceMetrics
626 #else 626 #else
627 kATSLineIsDisplayOnly | kATSLineFractDisable 627 kATSLineIsDisplayOnly | kATSLineFractDisable
628 #endif 628 #endif
629 ; 629 ;
630 ATSUAttributeValuePtr values[] = {&line_layout}; 630 ATSUAttributeValuePtr values[] = {&line_layout};
8125 /* Points to the variable `inev' in the function XTread_socket. It is 8125 /* Points to the variable `inev' in the function XTread_socket. It is
8126 used for passing an input event to the function back from 8126 used for passing an input event to the function back from
8127 Carbon/Apple event handlers. */ 8127 Carbon/Apple event handlers. */
8128 static struct input_event *read_socket_inev = NULL; 8128 static struct input_event *read_socket_inev = NULL;
8129 8129
8130 /* Set in term/mac-win.el to indicate that event loop can now generate
8131 drag and drop events. */
8132 Lisp_Object Qmac_ready_for_drag_n_drop;
8133
8134 Point saved_menu_event_location; 8130 Point saved_menu_event_location;
8135 8131
8136 /* Apple Events */ 8132 /* Apple Events */
8137 static void init_required_apple_events (void); 8133 #if USE_CARBON_EVENTS
8138 static pascal OSErr 8134 static Lisp_Object Qhicommand;
8139 do_ae_open_application (const AppleEvent *, AppleEvent *, long); 8135 #endif
8140 static pascal OSErr 8136 extern int mac_ready_for_apple_events;
8141 do_ae_print_documents (const AppleEvent *, AppleEvent *, long); 8137 extern Lisp_Object Qundefined;
8142 static pascal OSErr do_ae_open_documents (AppleEvent *, AppleEvent *, long); 8138 extern void init_apple_event_handler P_ ((void));
8143 static pascal OSErr do_ae_quit_application (AppleEvent *, AppleEvent *, long); 8139 extern void mac_find_apple_event_spec P_ ((AEEventClass, AEEventID,
8140 Lisp_Object *, Lisp_Object *,
8141 Lisp_Object *));
8144 8142
8145 #if TARGET_API_MAC_CARBON 8143 #if TARGET_API_MAC_CARBON
8146 /* Drag and Drop */ 8144 /* Drag and Drop */
8147 static pascal OSErr mac_do_track_drag (DragTrackingMessage, WindowPtr, void*, DragReference); 8145 static pascal OSErr mac_do_track_drag (DragTrackingMessage, WindowPtr, void*, DragReference);
8148 static pascal OSErr mac_do_receive_drag (WindowPtr, void*, DragReference); 8146 static pascal OSErr mac_do_receive_drag (WindowPtr, void*, DragReference);
8149 static DragTrackingHandlerUPP mac_do_track_dragUPP = NULL; 8147 static DragTrackingHandlerUPP mac_do_track_dragUPP = NULL;
8150 static DragReceiveHandlerUPP mac_do_receive_dragUPP = NULL; 8148 static DragReceiveHandlerUPP mac_do_receive_dragUPP = NULL;
8151 #endif 8149 #endif
8152 8150
8153 static Lisp_Object Qapplication, Qabout;
8154 #if USE_CARBON_EVENTS 8151 #if USE_CARBON_EVENTS
8155 #ifdef MAC_OSX 8152 #ifdef MAC_OSX
8156 extern void init_service_handler (); 8153 extern void init_service_handler ();
8157 static Lisp_Object Qpreferences, Qservices, Qpaste, Qperform; 8154 static Lisp_Object Qservices, Qpaste, Qperform;
8158 #endif 8155 #endif
8159 /* Window Event Handler */ 8156 /* Window Event Handler */
8160 static pascal OSStatus mac_handle_window_event (EventHandlerCallRef, 8157 static pascal OSStatus mac_handle_window_event (EventHandlerCallRef,
8161 EventRef, void *); 8158 EventRef, void *);
8162 #endif 8159 #endif
8697 FRAME_PIXEL_HEIGHT (f) = height; 8694 FRAME_PIXEL_HEIGHT (f) = height;
8698 } 8695 }
8699 x_real_positions (f, &f->left_pos, &f->top_pos); 8696 x_real_positions (f, &f->left_pos, &f->top_pos);
8700 } 8697 }
8701 8698
8702 /* Intialize AppleEvent dispatcher table for the required events. */ 8699 OSErr
8703 void 8700 mac_store_apple_event (class, id, desc)
8704 init_required_apple_events () 8701 Lisp_Object class, id;
8705 { 8702 const AEDesc *desc;
8706 OSErr err; 8703 {
8707 long result; 8704 OSErr err = noErr;
8708
8709 /* Make sure we have apple events before starting. */
8710 err = Gestalt (gestaltAppleEventsAttr, &result);
8711 if (err != noErr)
8712 abort ();
8713
8714 if (!(result & (1 << gestaltAppleEventsPresent)))
8715 abort ();
8716
8717 #if TARGET_API_MAC_CARBON
8718 err = AEInstallEventHandler(kCoreEventClass, kAEOpenApplication,
8719 NewAEEventHandlerUPP
8720 ((AEEventHandlerProcPtr) do_ae_open_application),
8721 0L, false);
8722 #else
8723 err = AEInstallEventHandler(kCoreEventClass, kAEOpenApplication,
8724 NewAEEventHandlerProc
8725 ((AEEventHandlerProcPtr) do_ae_open_application),
8726 0L, false);
8727 #endif
8728 if (err != noErr)
8729 abort ();
8730
8731 #if TARGET_API_MAC_CARBON
8732 err = AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments,
8733 NewAEEventHandlerUPP
8734 ((AEEventHandlerProcPtr) do_ae_open_documents),
8735 0L, false);
8736 #else
8737 err = AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments,
8738 NewAEEventHandlerProc
8739 ((AEEventHandlerProcPtr) do_ae_open_documents),
8740 0L, false);
8741 #endif
8742 if (err != noErr)
8743 abort ();
8744
8745 #if TARGET_API_MAC_CARBON
8746 err = AEInstallEventHandler(kCoreEventClass, kAEPrintDocuments,
8747 NewAEEventHandlerUPP
8748 ((AEEventHandlerProcPtr) do_ae_print_documents),
8749 0L, false);
8750 #else
8751 err = AEInstallEventHandler(kCoreEventClass, kAEPrintDocuments,
8752 NewAEEventHandlerProc
8753 ((AEEventHandlerProcPtr) do_ae_print_documents),
8754 0L, false);
8755 #endif
8756 if (err != noErr)
8757 abort ();
8758
8759 #if TARGET_API_MAC_CARBON
8760 err = AEInstallEventHandler(kCoreEventClass, kAEQuitApplication,
8761 NewAEEventHandlerUPP
8762 ((AEEventHandlerProcPtr) do_ae_quit_application),
8763 0L, false);
8764 #else
8765 err = AEInstallEventHandler(kCoreEventClass, kAEQuitApplication,
8766 NewAEEventHandlerProc
8767 ((AEEventHandlerProcPtr) do_ae_quit_application),
8768 0L, false);
8769 #endif
8770 if (err != noErr)
8771 abort ();
8772 }
8773
8774 void
8775 mac_store_application_menu_event (event)
8776 #if USE_CARBON_EVENTS
8777 EventRef event;
8778 #else
8779 UInt32 event;
8780 #endif
8781 {
8782 struct input_event buf; 8705 struct input_event buf;
8783 Lisp_Object frame, entry; 8706 AEDesc *desc_copy;
8784 8707
8785 EVENT_INIT (buf); 8708 desc_copy = xmalloc (sizeof (AEDesc));
8786 8709 if (desc_copy == NULL)
8787 XSETFRAME (frame, mac_focus_frame (&one_mac_display_info)); 8710 err = memFullErr;
8788 buf.kind = MENU_BAR_EVENT; 8711 else
8789 buf.frame_or_window = frame; 8712 err = AEDuplicateDesc (desc, desc_copy);
8790 buf.arg = frame; 8713 if (err == noErr)
8791 kbd_buffer_store_event (&buf); 8714 {
8792 8715 EVENT_INIT (buf);
8793 buf.arg = Qapplication; 8716
8794 kbd_buffer_store_event (&buf); 8717 buf.kind = MAC_APPLE_EVENT;
8795 8718 buf.x = class;
8796 #if USE_CARBON_EVENTS 8719 buf.y = id;
8797 switch (GetEventClass (event)) 8720 buf.code = (int)desc_copy;
8798 { 8721 XSETFRAME (buf.frame_or_window,
8799 #ifdef MAC_OSX 8722 mac_focus_frame (&one_mac_display_info));
8800 case kEventClassService: 8723 buf.arg = Qnil;
8801 buf.arg = Qservices;
8802 kbd_buffer_store_event (&buf); 8724 kbd_buffer_store_event (&buf);
8803 switch (GetEventKind (event)) 8725 }
8804 { 8726
8805 case kEventServicePaste: 8727 return err;
8806 entry = Qpaste; 8728 }
8807 break; 8729
8808 8730 Lisp_Object
8809 case kEventServicePerform: 8731 mac_make_lispy_event_code (code)
8810 { 8732 int code;
8811 OSErr err; 8733 {
8812 CFStringRef message; 8734 AEDesc *desc = (AEDesc *)code;
8813 8735 Lisp_Object obj;
8814 err = GetEventParameter (event, kEventParamServiceMessageName, 8736
8815 typeCFStringRef, NULL, 8737 obj = mac_aedesc_to_lisp (desc);
8816 sizeof (CFStringRef), NULL, &message); 8738 AEDisposeDesc (desc);
8817 buf.arg = Qperform; 8739 xfree (desc);
8818 kbd_buffer_store_event (&buf); 8740
8819 if (err == noErr && message) 8741 return obj;
8820 entry = intern (SDATA (cfstring_to_lisp (message)));
8821 else
8822 entry = Qnil;
8823 }
8824 break;
8825
8826 default:
8827 abort ();
8828 }
8829 break;
8830 #endif /* MAC_OSX */
8831 case kEventClassCommand:
8832 {
8833 HICommand command;
8834
8835 GetEventParameter(event, kEventParamDirectObject, typeHICommand,
8836 NULL, sizeof (HICommand), NULL, &command);
8837 switch (command.commandID)
8838 {
8839 case kHICommandAbout:
8840 entry = Qabout;
8841 break;
8842 #ifdef MAC_OSX
8843 case kHICommandPreferences:
8844 entry = Qpreferences;
8845 break;
8846 #endif /* MAC_OSX */
8847 case kHICommandQuit:
8848 entry = Qquit;
8849 break;
8850 default:
8851 abort ();
8852 }
8853 }
8854 break;
8855
8856 default:
8857 abort ();
8858 }
8859 #else /* USE_CARBON_EVENTS */
8860 switch (event)
8861 {
8862 case kHICommandAbout:
8863 entry = Qabout;
8864 break;
8865 case kHICommandQuit:
8866 entry = Qquit;
8867 break;
8868 default:
8869 abort ();
8870 }
8871 #endif
8872
8873 buf.arg = entry;
8874 kbd_buffer_store_event (&buf);
8875 } 8742 }
8876 8743
8877 #if USE_CARBON_EVENTS 8744 #if USE_CARBON_EVENTS
8878 static pascal OSStatus 8745 static pascal OSStatus
8879 mac_handle_command_event (next_handler, event, data) 8746 mac_handle_command_event (next_handler, event, data)
8880 EventHandlerCallRef next_handler; 8747 EventHandlerCallRef next_handler;
8881 EventRef event; 8748 EventRef event;
8882 void *data; 8749 void *data;
8883 { 8750 {
8751 OSStatus result;
8752 OSErr err;
8884 HICommand command; 8753 HICommand command;
8885 OSErr result; 8754 Lisp_Object class_key, id_key, binding;
8886 8755
8887 GetEventParameter(event, kEventParamDirectObject, typeHICommand, NULL, 8756 result = CallNextEventHandler (next_handler, event);
8888 sizeof (HICommand), NULL, &command); 8757 if (result != eventNotHandledErr)
8889 8758 return result;
8890 switch (command.commandID) 8759
8891 { 8760 GetEventParameter (event, kEventParamDirectObject, typeHICommand, NULL,
8892 case kHICommandAbout: 8761 sizeof (HICommand), NULL, &command);
8893 #ifdef MAC_OSX 8762
8894 case kHICommandPreferences: 8763 if (command.commandID == 0)
8895 #endif /* MAC_OSX */ 8764 return eventNotHandledErr;
8896 result = CallNextEventHandler (next_handler, event); 8765
8897 if (result != eventNotHandledErr) 8766 /* A HICommand event is mapped to an Apple event whose event class
8898 return result; 8767 symbol is `hicommand' and event ID is its command ID. */
8899 8768 class_key = Qhicommand;
8900 mac_store_application_menu_event (event); 8769 mac_find_apple_event_spec (0, command.commandID,
8901 return noErr; 8770 &class_key, &id_key, &binding);
8902 8771 if (!NILP (binding) && !EQ (binding, Qundefined))
8903 default: 8772 if (INTEGERP (binding))
8904 break; 8773 return XINT (binding);
8905 } 8774 else
8775 {
8776 AppleEvent apple_event;
8777 UInt32 modifiers;
8778 static EventParamName names[] = {kEventParamDirectObject,
8779 kEventParamKeyModifiers};
8780 static EventParamType types[] = {typeHICommand,
8781 typeUInt32};
8782 static UInt32 sizes[] = {sizeof (HICommand),
8783 sizeof (UInt32)};
8784 err = create_apple_event_from_event_ref (event, 2, names, types,
8785 sizes, &apple_event);
8786 if (err == noErr)
8787 {
8788 err = mac_store_apple_event (class_key, id_key, &apple_event);
8789 AEDisposeDesc (&apple_event);
8790 }
8791 if (err == noErr)
8792 return noErr;
8793 }
8906 8794
8907 return eventNotHandledErr; 8795 return eventNotHandledErr;
8908 } 8796 }
8909 8797
8910 static OSErr 8798 static OSErr
9062 break; 8950 break;
9063 } 8951 }
9064 8952
9065 return eventNotHandledErr; 8953 return eventNotHandledErr;
9066 } 8954 }
8955
8956 #ifdef MAC_OSX
8957 OSErr
8958 mac_store_services_event (event)
8959 EventRef event;
8960 {
8961 OSErr err;
8962 AppleEvent apple_event;
8963 Lisp_Object id_key;
8964
8965 switch (GetEventKind (event))
8966 {
8967 case kEventServicePaste:
8968 id_key = Qpaste;
8969 err = create_apple_event_from_event_ref (event, 0, NULL,
8970 NULL, NULL, &apple_event);
8971 break;
8972
8973 case kEventServicePerform:
8974 {
8975 static EventParamName names[] = {kEventParamServiceMessageName,
8976 kEventParamServiceUserData};
8977 static EventParamType types[] = {typeCFStringRef,
8978 typeCFStringRef};
8979 static UInt32 sizes[] = {sizeof (CFStringRef),
8980 sizeof (CFStringRef)};
8981
8982 id_key = Qperform;
8983 err = create_apple_event_from_event_ref (event, 2, names, types,
8984 sizes, &apple_event);
8985 }
8986 break;
8987
8988 default:
8989 abort ();
8990 }
8991
8992 if (err == noErr)
8993 {
8994 err = mac_store_apple_event (Qservices, id_key, &apple_event);
8995 AEDisposeDesc (&apple_event);
8996 }
8997
8998 return err;
8999 }
9000 #endif /* MAC_OSX */
9067 #endif /* USE_CARBON_EVENTS */ 9001 #endif /* USE_CARBON_EVENTS */
9068 9002
9069 9003
9070 OSErr 9004 OSErr
9071 install_window_handler (window) 9005 install_window_handler (window)
9119 RemoveTrackingHandler (mac_do_track_dragUPP, window); 9053 RemoveTrackingHandler (mac_do_track_dragUPP, window);
9120 if (mac_do_receive_dragUPP) 9054 if (mac_do_receive_dragUPP)
9121 RemoveReceiveHandler (mac_do_receive_dragUPP, window); 9055 RemoveReceiveHandler (mac_do_receive_dragUPP, window);
9122 #endif 9056 #endif
9123 } 9057 }
9124
9125 /* Open Application Apple Event */
9126 static pascal OSErr
9127 do_ae_open_application(const AppleEvent *pae, AppleEvent *preply, long prefcon)
9128 {
9129 return noErr;
9130 }
9131
9132
9133 /* Called when we receive an AppleEvent with an ID of
9134 "kAEOpenDocuments". This routine gets the direct parameter,
9135 extracts the FSSpecs in it, and puts their names on a list. */
9136 #pragma options align=mac68k
9137 typedef struct SelectionRange {
9138 short unused1; // 0 (not used)
9139 short lineNum; // line to select (<0 to specify range)
9140 long startRange; // start of selection range (if line < 0)
9141 long endRange; // end of selection range (if line < 0)
9142 long unused2; // 0 (not used)
9143 long theDate; // modification date/time
9144 } SelectionRange;
9145 #pragma options align=reset
9146
9147 static pascal OSErr
9148 do_ae_open_documents(AppleEvent *message, AppleEvent *reply, long refcon)
9149 {
9150 OSErr err, err2;
9151 AEDesc the_desc;
9152 AEKeyword keyword;
9153 DescType actual_type;
9154 Size actual_size;
9155 SelectionRange position;
9156 Lisp_Object file_list = Qnil;
9157
9158 xassert (read_socket_inev);
9159
9160 err = AEGetParamDesc (message, keyDirectObject, typeAEList, &the_desc);
9161 if (err != noErr)
9162 goto descriptor_error_exit;
9163
9164 err = AEGetParamPtr (message, keyAEPosition, typeChar, &actual_type, &position, sizeof(SelectionRange), &actual_size);
9165 if (err == noErr)
9166 file_list = Fcons (list3 (make_number (position.lineNum + 1),
9167 make_number (position.startRange + 1),
9168 make_number (position.endRange + 1)),
9169 file_list);
9170
9171 /* Check to see that we got all of the required parameters from the
9172 event descriptor. For an 'odoc' event this should just be the
9173 file list. */
9174 err = AEGetAttributePtr(message, keyMissedKeywordAttr, typeWildCard,
9175 &actual_type, (Ptr) &keyword,
9176 sizeof (keyword), &actual_size);
9177 /* No error means that we found some unused parameters.
9178 errAEDescNotFound means that there are no more parameters. If we
9179 get an error code other than that, flag it. */
9180 if ((err == noErr) || (err != errAEDescNotFound))
9181 {
9182 err = errAEEventNotHandled;
9183 goto error_exit;
9184 }
9185 err = noErr;
9186
9187 /* Got all the parameters we need. Now, go through the direct
9188 object list and parse it up. */
9189 {
9190 long num_files_to_open;
9191
9192 err = AECountItems (&the_desc, &num_files_to_open);
9193 if (err == noErr)
9194 {
9195 int i;
9196
9197 /* AE file list is one based so just use that for indexing here. */
9198 for (i = 1; i <= num_files_to_open; i++)
9199 {
9200 char unix_path_name[MAXPATHLEN];
9201 #ifdef MAC_OSX
9202 FSRef fref;
9203
9204 err = AEGetNthPtr (&the_desc, i, typeFSRef, &keyword,
9205 &actual_type, &fref, sizeof (FSRef),
9206 &actual_size);
9207 if (err != noErr || actual_type != typeFSRef)
9208 continue;
9209
9210 if (FSRefMakePath (&fref, unix_path_name, sizeof (unix_path_name))
9211 == noErr)
9212 #else
9213 FSSpec fs;
9214
9215 err = AEGetNthPtr(&the_desc, i, typeFSS, &keyword, &actual_type,
9216 (Ptr) &fs, sizeof (fs), &actual_size);
9217 if (err != noErr) continue;
9218
9219 if (fsspec_to_posix_pathname (&fs, unix_path_name,
9220 sizeof (unix_path_name) - 1) == noErr)
9221 #endif
9222 /* x-dnd functions expect undecoded filenames. */
9223 file_list = Fcons (make_unibyte_string (unix_path_name,
9224 strlen (unix_path_name)),
9225 file_list);
9226 }
9227 }
9228
9229 /* Build a DRAG_N_DROP_EVENT type event as is done in
9230 constuct_drag_n_drop in w32term.c. */
9231 if (!NILP (file_list))
9232 {
9233 struct frame *f = mac_focus_frame (&one_mac_display_info);
9234 WindowPtr wp;
9235 Lisp_Object frame;
9236
9237 read_socket_inev->kind = DRAG_N_DROP_EVENT;
9238 read_socket_inev->code = 0;
9239 read_socket_inev->modifiers = 0;
9240
9241 XSETINT (read_socket_inev->x, 0);
9242 XSETINT (read_socket_inev->y, 0);
9243
9244 XSETFRAME (frame, f);
9245 read_socket_inev->frame_or_window = Fcons (frame, file_list);
9246
9247 #if 0
9248 /* Regardless of whether Emacs was suspended or in the
9249 foreground, ask it to redraw its entire screen. Otherwise
9250 parts of the screen can be left in an inconsistent
9251 state. */
9252 wp = FRAME_MAC_WINDOW (f);
9253 if (wp)
9254 #if TARGET_API_MAC_CARBON
9255 {
9256 Rect r;
9257
9258 GetWindowPortBounds (wp, &r);
9259 InvalWindowRect (wp, &r);
9260 }
9261 #else /* not TARGET_API_MAC_CARBON */
9262 InvalRect (&(wp->portRect));
9263 #endif /* not TARGET_API_MAC_CARBON */
9264 #endif
9265 }
9266 }
9267
9268 error_exit:
9269 /* Nuke the coerced file list in any case */
9270 err2 = AEDisposeDesc(&the_desc);
9271
9272 descriptor_error_exit:
9273 /* InvalRect(&(gFrontMacWindowP->mWP->portRect)); */
9274 return err;
9275 }
9276
9277 9058
9278 #if TARGET_API_MAC_CARBON 9059 #if TARGET_API_MAC_CARBON
9279 static pascal OSErr 9060 static pascal OSErr
9280 mac_do_track_drag (DragTrackingMessage message, WindowPtr window, 9061 mac_do_track_drag (DragTrackingMessage message, WindowPtr window,
9281 void *handlerRefCon, DragReference theDrag) 9062 void *handlerRefCon, DragReference theDrag)
9427 return dragNotAcceptedErr; 9208 return dragNotAcceptedErr;
9428 } 9209 }
9429 #endif 9210 #endif
9430 9211
9431 9212
9432 /* Print Document Apple Event */
9433 static pascal OSErr
9434 do_ae_print_documents (const AppleEvent *pAE, AppleEvent *reply, long refcon)
9435 {
9436 return errAEEventNotHandled;
9437 }
9438
9439
9440 static pascal OSErr
9441 do_ae_quit_application (AppleEvent* message, AppleEvent *reply, long refcon)
9442 {
9443 #if USE_CARBON_EVENTS
9444 OSErr err;
9445 EventRef event = NULL;
9446 static const HICommand quit_command = {kEventAttributeNone, kHICommandQuit};
9447
9448 err = CreateEvent (NULL, kEventClassCommand, kEventCommandProcess, 0,
9449 kEventAttributeUserEvent, &event);
9450 if (err == noErr)
9451 err = SetEventParameter (event, kEventParamDirectObject, typeHICommand,
9452 sizeof (HICommand), &quit_command);
9453 if (err == noErr)
9454 mac_store_application_menu_event (event);
9455 if (event)
9456 ReleaseEvent (event);
9457
9458 if (err == noErr)
9459 return noErr;
9460 else
9461 return errAEEventNotHandled;
9462 #else
9463 mac_store_application_menu_event (kHICommandQuit);
9464
9465 return noErr;
9466 #endif
9467 }
9468
9469
9470 #if __profile__ 9213 #if __profile__
9471 void 9214 void
9472 profiler_exit_proc () 9215 profiler_exit_proc ()
9473 { 9216 {
9474 ProfilerDump ("\pEmacs.prof"); 9217 ProfilerDump ("\pEmacs.prof");
9518 9261
9519 init_environ (); 9262 init_environ ();
9520 9263
9521 initialize_applescript (); 9264 initialize_applescript ();
9522 9265
9523 init_required_apple_events (); 9266 init_apple_event_handler ();
9524 9267
9525 { 9268 {
9526 char **argv; 9269 char **argv;
9527 int argc = 0; 9270 int argc = 0;
9528 9271
9722 9465
9723 if (mouse_region == NULL) 9466 if (mouse_region == NULL)
9724 mouse_region = NewRgn (); 9467 mouse_region = NewRgn ();
9725 9468
9726 event_mask = everyEvent; 9469 event_mask = everyEvent;
9727 if (NILP (Fboundp (Qmac_ready_for_drag_n_drop))) 9470 if (!mac_ready_for_apple_events)
9728 event_mask -= highLevelEventMask; 9471 event_mask -= highLevelEventMask;
9729 9472
9730 current_tick = TickCount (); 9473 current_tick = TickCount ();
9731 target_tick = current_tick + sleep_time; 9474 target_tick = current_tick + sleep_time;
9732 9475
10890 Fset_input_mode (Qt, Qnil, Qt, Qnil); 10633 Fset_input_mode (Qt, Qnil, Qt, Qnil);
10891 10634
10892 BLOCK_INPUT; 10635 BLOCK_INPUT;
10893 10636
10894 #if TARGET_API_MAC_CARBON 10637 #if TARGET_API_MAC_CARBON
10895 init_required_apple_events ();
10896 10638
10897 #if USE_CARBON_EVENTS 10639 #if USE_CARBON_EVENTS
10898 #ifdef MAC_OSX 10640 #ifdef MAC_OSX
10899 init_service_handler (); 10641 init_service_handler ();
10900 10642
10905 10647
10906 init_menu_bar (); 10648 init_menu_bar ();
10907 #endif /* USE_CARBON_EVENTS */ 10649 #endif /* USE_CARBON_EVENTS */
10908 10650
10909 #ifdef MAC_OSX 10651 #ifdef MAC_OSX
10652 init_apple_event_handler ();
10653
10910 if (!inhibit_window_system) 10654 if (!inhibit_window_system)
10911 MakeMeTheFrontProcess (); 10655 MakeMeTheFrontProcess ();
10912 #endif 10656 #endif
10913 #endif 10657 #endif
10914 UNBLOCK_INPUT; 10658 UNBLOCK_INPUT;
10935 Fput (Qmeta, Qmodifier_value, make_number (meta_modifier)); 10679 Fput (Qmeta, Qmodifier_value, make_number (meta_modifier));
10936 Fput (Qalt, Qmodifier_value, make_number (alt_modifier)); 10680 Fput (Qalt, Qmodifier_value, make_number (alt_modifier));
10937 Fput (Qhyper, Qmodifier_value, make_number (hyper_modifier)); 10681 Fput (Qhyper, Qmodifier_value, make_number (hyper_modifier));
10938 Fput (Qsuper, Qmodifier_value, make_number (super_modifier)); 10682 Fput (Qsuper, Qmodifier_value, make_number (super_modifier));
10939 10683
10940 Qapplication = intern ("application"); staticpro (&Qapplication); 10684 #if USE_CARBON_EVENTS
10941 Qabout = intern ("about"); staticpro (&Qabout); 10685 Qhicommand = intern ("hicommand"); staticpro (&Qhicommand);
10942 10686 #ifdef MAC_OSX
10943 #if USE_CARBON_EVENTS && defined (MAC_OSX)
10944 Qpreferences = intern ("preferences"); staticpro (&Qpreferences);
10945 Qservices = intern ("services"); staticpro (&Qservices); 10687 Qservices = intern ("services"); staticpro (&Qservices);
10946 Qpaste = intern ("paste"); staticpro (&Qpaste); 10688 Qpaste = intern ("paste"); staticpro (&Qpaste);
10947 Qperform = intern ("perform"); staticpro (&Qperform); 10689 Qperform = intern ("perform"); staticpro (&Qperform);
10948 #endif 10690 #endif
10691 #endif
10949 10692
10950 #ifdef MAC_OSX 10693 #ifdef MAC_OSX
10951 Fprovide (intern ("mac-carbon"), Qnil); 10694 Fprovide (intern ("mac-carbon"), Qnil);
10952 #endif 10695 #endif
10953 10696
10954 staticpro (&Qreverse); 10697 staticpro (&Qreverse);
10955 Qreverse = intern ("reverse"); 10698 Qreverse = intern ("reverse");
10956
10957 staticpro (&Qmac_ready_for_drag_n_drop);
10958 Qmac_ready_for_drag_n_drop = intern ("mac-ready-for-drag-n-drop");
10959 10699
10960 staticpro (&x_display_name_list); 10700 staticpro (&x_display_name_list);
10961 x_display_name_list = Qnil; 10701 x_display_name_list = Qnil;
10962 10702
10963 staticpro (&last_mouse_scroll_bar); 10703 staticpro (&last_mouse_scroll_bar);