diff options
| author | Karoly Lorentey | 2006-05-10 15:04:01 +0000 |
|---|---|---|
| committer | Karoly Lorentey | 2006-05-10 15:04:01 +0000 |
| commit | 8dadeb1e1f78c7be07db5ae78aa9eed58d272a4e (patch) | |
| tree | 6262988e87d6b347a8c90fcc3c5b49f9bb5b36e1 /src/macselect.c | |
| parent | f6cf85ac95e469835a2643024f995b471a4c5d52 (diff) | |
| parent | 9a4d87c8d5f4503d67d5155eae6d543cc31f86d0 (diff) | |
| download | emacs-8dadeb1e1f78c7be07db5ae78aa9eed58d272a4e.tar.gz emacs-8dadeb1e1f78c7be07db5ae78aa9eed58d272a4e.zip | |
Merged from emacs@sv.gnu.org
Patches applied:
* emacs@sv.gnu.org/emacs--devo--0--patch-266
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-267
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-268
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-269
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-270
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-271
Rename "field-at-point" to "field-at-pos"
* emacs@sv.gnu.org/emacs--devo--0--patch-272
(comint-insert-input): Remove redundant calls to setq and goto-char
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-556
Diffstat (limited to 'src/macselect.c')
| -rw-r--r-- | src/macselect.c | 216 |
1 files changed, 209 insertions, 7 deletions
diff --git a/src/macselect.c b/src/macselect.c index fe4a7c8eccc..dd96102e19b 100644 --- a/src/macselect.c +++ b/src/macselect.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* Selection processing for Emacs on Mac OS. | 1 | /* Selection processing for Emacs on Mac OS. |
| 2 | Copyright (C) 2005 Free Software Foundation, Inc. | 2 | Copyright (C) 2005, 2006 Free Software Foundation, Inc. |
| 3 | 3 | ||
| 4 | This file is part of GNU Emacs. | 4 | This file is part of GNU Emacs. |
| 5 | 5 | ||
| @@ -918,8 +918,8 @@ static struct | |||
| 918 | int size, count; | 918 | int size, count; |
| 919 | } deferred_apple_events; | 919 | } deferred_apple_events; |
| 920 | extern Lisp_Object Qundefined; | 920 | extern Lisp_Object Qundefined; |
| 921 | extern OSErr mac_store_apple_event P_ ((Lisp_Object, Lisp_Object, | 921 | extern void mac_store_apple_event P_ ((Lisp_Object, Lisp_Object, |
| 922 | const AEDesc *)); | 922 | const AEDesc *)); |
| 923 | 923 | ||
| 924 | struct apple_event_binding | 924 | struct apple_event_binding |
| 925 | { | 925 | { |
| @@ -1079,9 +1079,8 @@ mac_handle_apple_event (apple_event, reply, refcon) | |||
| 1079 | { | 1079 | { |
| 1080 | if (INTEGERP (binding)) | 1080 | if (INTEGERP (binding)) |
| 1081 | return XINT (binding); | 1081 | return XINT (binding); |
| 1082 | err = mac_store_apple_event (class_key, id_key, apple_event); | 1082 | mac_store_apple_event (class_key, id_key, apple_event); |
| 1083 | if (err == noErr) | 1083 | return noErr; |
| 1084 | return noErr; | ||
| 1085 | } | 1084 | } |
| 1086 | } | 1085 | } |
| 1087 | return errAEEventNotHandled; | 1086 | return errAEEventNotHandled; |
| @@ -1146,6 +1145,198 @@ DEFUN ("mac-process-deferred-apple-events", Fmac_process_deferred_apple_events, | |||
| 1146 | } | 1145 | } |
| 1147 | 1146 | ||
| 1148 | 1147 | ||
| 1148 | #if TARGET_API_MAC_CARBON | ||
| 1149 | static Lisp_Object Vmac_dnd_known_types; | ||
| 1150 | static pascal OSErr mac_do_track_drag P_ ((DragTrackingMessage, WindowRef, | ||
| 1151 | void *, DragRef)); | ||
| 1152 | static pascal OSErr mac_do_receive_drag P_ ((WindowRef, void *, DragRef)); | ||
| 1153 | static DragTrackingHandlerUPP mac_do_track_dragUPP = NULL; | ||
| 1154 | static DragReceiveHandlerUPP mac_do_receive_dragUPP = NULL; | ||
| 1155 | |||
| 1156 | extern void mac_store_drag_event P_ ((WindowRef, Point, SInt16, | ||
| 1157 | const AEDesc *)); | ||
| 1158 | |||
| 1159 | static pascal OSErr | ||
| 1160 | mac_do_track_drag (message, window, refcon, drag) | ||
| 1161 | DragTrackingMessage message; | ||
| 1162 | WindowRef window; | ||
| 1163 | void *refcon; | ||
| 1164 | DragRef drag; | ||
| 1165 | { | ||
| 1166 | OSErr err = noErr; | ||
| 1167 | static int can_accept; | ||
| 1168 | UInt16 num_items, index; | ||
| 1169 | |||
| 1170 | if (GetFrontWindowOfClass (kMovableModalWindowClass, false)) | ||
| 1171 | return dragNotAcceptedErr; | ||
| 1172 | |||
| 1173 | switch (message) | ||
| 1174 | { | ||
| 1175 | case kDragTrackingEnterHandler: | ||
| 1176 | err = CountDragItems (drag, &num_items); | ||
| 1177 | if (err != noErr) | ||
| 1178 | break; | ||
| 1179 | can_accept = 0; | ||
| 1180 | for (index = 1; index <= num_items; index++) | ||
| 1181 | { | ||
| 1182 | ItemReference item; | ||
| 1183 | FlavorFlags flags; | ||
| 1184 | Lisp_Object rest; | ||
| 1185 | |||
| 1186 | err = GetDragItemReferenceNumber (drag, index, &item); | ||
| 1187 | if (err != noErr) | ||
| 1188 | continue; | ||
| 1189 | for (rest = Vmac_dnd_known_types; CONSP (rest); rest = XCDR (rest)) | ||
| 1190 | { | ||
| 1191 | Lisp_Object str; | ||
| 1192 | FlavorType type; | ||
| 1193 | |||
| 1194 | str = XCAR (rest); | ||
| 1195 | if (!(STRINGP (str) && SBYTES (str) == 4)) | ||
| 1196 | continue; | ||
| 1197 | type = EndianU32_BtoN (*((UInt32 *) SDATA (str))); | ||
| 1198 | |||
| 1199 | err = GetFlavorFlags (drag, item, type, &flags); | ||
| 1200 | if (err == noErr) | ||
| 1201 | { | ||
| 1202 | can_accept = 1; | ||
| 1203 | break; | ||
| 1204 | } | ||
| 1205 | } | ||
| 1206 | } | ||
| 1207 | break; | ||
| 1208 | |||
| 1209 | case kDragTrackingEnterWindow: | ||
| 1210 | if (can_accept) | ||
| 1211 | { | ||
| 1212 | RgnHandle hilite_rgn = NewRgn (); | ||
| 1213 | |||
| 1214 | if (hilite_rgn) | ||
| 1215 | { | ||
| 1216 | Rect r; | ||
| 1217 | |||
| 1218 | GetWindowPortBounds (window, &r); | ||
| 1219 | OffsetRect (&r, -r.left, -r.top); | ||
| 1220 | RectRgn (hilite_rgn, &r); | ||
| 1221 | ShowDragHilite (drag, hilite_rgn, true); | ||
| 1222 | DisposeRgn (hilite_rgn); | ||
| 1223 | } | ||
| 1224 | SetThemeCursor (kThemeCopyArrowCursor); | ||
| 1225 | } | ||
| 1226 | break; | ||
| 1227 | |||
| 1228 | case kDragTrackingInWindow: | ||
| 1229 | break; | ||
| 1230 | |||
| 1231 | case kDragTrackingLeaveWindow: | ||
| 1232 | if (can_accept) | ||
| 1233 | { | ||
| 1234 | HideDragHilite (drag); | ||
| 1235 | SetThemeCursor (kThemeArrowCursor); | ||
| 1236 | } | ||
| 1237 | break; | ||
| 1238 | |||
| 1239 | case kDragTrackingLeaveHandler: | ||
| 1240 | break; | ||
| 1241 | } | ||
| 1242 | |||
| 1243 | if (err != noErr) | ||
| 1244 | return dragNotAcceptedErr; | ||
| 1245 | return noErr; | ||
| 1246 | } | ||
| 1247 | |||
| 1248 | static pascal OSErr | ||
| 1249 | mac_do_receive_drag (window, refcon, drag) | ||
| 1250 | WindowRef window; | ||
| 1251 | void *refcon; | ||
| 1252 | DragRef drag; | ||
| 1253 | { | ||
| 1254 | OSErr err; | ||
| 1255 | int num_types, i; | ||
| 1256 | Lisp_Object rest, str; | ||
| 1257 | FlavorType *types; | ||
| 1258 | AppleEvent apple_event; | ||
| 1259 | Point mouse_pos; | ||
| 1260 | SInt16 modifiers; | ||
| 1261 | |||
| 1262 | if (GetFrontWindowOfClass (kMovableModalWindowClass, false)) | ||
| 1263 | return dragNotAcceptedErr; | ||
| 1264 | |||
| 1265 | num_types = 0; | ||
| 1266 | for (rest = Vmac_dnd_known_types; CONSP (rest); rest = XCDR (rest)) | ||
| 1267 | { | ||
| 1268 | str = XCAR (rest); | ||
| 1269 | if (STRINGP (str) && SBYTES (str) == 4) | ||
| 1270 | num_types++; | ||
| 1271 | } | ||
| 1272 | |||
| 1273 | types = xmalloc (sizeof (FlavorType) * num_types); | ||
| 1274 | i = 0; | ||
| 1275 | for (rest = Vmac_dnd_known_types; CONSP (rest); rest = XCDR (rest)) | ||
| 1276 | { | ||
| 1277 | str = XCAR (rest); | ||
| 1278 | if (STRINGP (str) && SBYTES (str) == 4) | ||
| 1279 | types[i++] = EndianU32_BtoN (*((UInt32 *) SDATA (str))); | ||
| 1280 | } | ||
| 1281 | |||
| 1282 | err = create_apple_event_from_drag_ref (drag, num_types, types, | ||
| 1283 | &apple_event); | ||
| 1284 | xfree (types); | ||
| 1285 | |||
| 1286 | if (err == noErr) | ||
| 1287 | err = GetDragMouse (drag, &mouse_pos, NULL); | ||
| 1288 | if (err == noErr) | ||
| 1289 | { | ||
| 1290 | GlobalToLocal (&mouse_pos); | ||
| 1291 | err = GetDragModifiers (drag, NULL, NULL, &modifiers); | ||
| 1292 | } | ||
| 1293 | |||
| 1294 | if (err == noErr) | ||
| 1295 | { | ||
| 1296 | mac_store_drag_event (window, mouse_pos, modifiers, &apple_event); | ||
| 1297 | AEDisposeDesc (&apple_event); | ||
| 1298 | /* Post a harmless event so as to wake up from ReceiveNextEvent. */ | ||
| 1299 | mac_post_mouse_moved_event (); | ||
| 1300 | return noErr; | ||
| 1301 | } | ||
| 1302 | else | ||
| 1303 | return dragNotAcceptedErr; | ||
| 1304 | } | ||
| 1305 | #endif /* TARGET_API_MAC_CARBON */ | ||
| 1306 | |||
| 1307 | OSErr | ||
| 1308 | install_drag_handler (window) | ||
| 1309 | WindowRef window; | ||
| 1310 | { | ||
| 1311 | OSErr err = noErr; | ||
| 1312 | |||
| 1313 | #if TARGET_API_MAC_CARBON | ||
| 1314 | if (mac_do_track_dragUPP == NULL) | ||
| 1315 | mac_do_track_dragUPP = NewDragTrackingHandlerUPP (mac_do_track_drag); | ||
| 1316 | if (mac_do_receive_dragUPP == NULL) | ||
| 1317 | mac_do_receive_dragUPP = NewDragReceiveHandlerUPP (mac_do_receive_drag); | ||
| 1318 | |||
| 1319 | err = InstallTrackingHandler (mac_do_track_dragUPP, window, NULL); | ||
| 1320 | if (err == noErr) | ||
| 1321 | err = InstallReceiveHandler (mac_do_receive_dragUPP, window, NULL); | ||
| 1322 | #endif | ||
| 1323 | |||
| 1324 | return err; | ||
| 1325 | } | ||
| 1326 | |||
| 1327 | void | ||
| 1328 | remove_drag_handler (window) | ||
| 1329 | WindowRef window; | ||
| 1330 | { | ||
| 1331 | #if TARGET_API_MAC_CARBON | ||
| 1332 | if (mac_do_track_dragUPP) | ||
| 1333 | RemoveTrackingHandler (mac_do_track_dragUPP, window); | ||
| 1334 | if (mac_do_receive_dragUPP) | ||
| 1335 | RemoveReceiveHandler (mac_do_receive_dragUPP, window); | ||
| 1336 | #endif | ||
| 1337 | } | ||
| 1338 | |||
| 1339 | |||
| 1149 | #ifdef MAC_OSX | 1340 | #ifdef MAC_OSX |
| 1150 | void | 1341 | void |
| 1151 | init_service_handler () | 1342 | init_service_handler () |
| @@ -1158,7 +1349,7 @@ init_service_handler () | |||
| 1158 | GetEventTypeCount (specs), specs, NULL, NULL); | 1349 | GetEventTypeCount (specs), specs, NULL, NULL); |
| 1159 | } | 1350 | } |
| 1160 | 1351 | ||
| 1161 | extern OSErr mac_store_services_event P_ ((EventRef)); | 1352 | extern OSStatus mac_store_services_event P_ ((EventRef)); |
| 1162 | 1353 | ||
| 1163 | static OSStatus | 1354 | static OSStatus |
| 1164 | copy_scrap_flavor_data (from_scrap, to_scrap, flavor_type) | 1355 | copy_scrap_flavor_data (from_scrap, to_scrap, flavor_type) |
| @@ -1408,6 +1599,17 @@ set to nil. */); | |||
| 1408 | doc: /* Keymap for Apple events handled by Emacs. */); | 1599 | doc: /* Keymap for Apple events handled by Emacs. */); |
| 1409 | Vmac_apple_event_map = Qnil; | 1600 | Vmac_apple_event_map = Qnil; |
| 1410 | 1601 | ||
| 1602 | #if TARGET_API_MAC_CARBON | ||
| 1603 | DEFVAR_LISP ("mac-dnd-known-types", &Vmac_dnd_known_types, | ||
| 1604 | doc: /* The types accepted by default for dropped data. | ||
| 1605 | The types are chosen in the order they appear in the list. */); | ||
| 1606 | Vmac_dnd_known_types = list4 (build_string ("hfs "), build_string ("utxt"), | ||
| 1607 | build_string ("TEXT"), build_string ("TIFF")); | ||
| 1608 | #ifdef MAC_OSX | ||
| 1609 | Vmac_dnd_known_types = Fcons (build_string ("furl"), Vmac_dnd_known_types); | ||
| 1610 | #endif | ||
| 1611 | #endif | ||
| 1612 | |||
| 1411 | #ifdef MAC_OSX | 1613 | #ifdef MAC_OSX |
| 1412 | DEFVAR_LISP ("mac-services-selection", &Vmac_services_selection, | 1614 | DEFVAR_LISP ("mac-services-selection", &Vmac_services_selection, |
| 1413 | doc: /* Selection name for communication via Services menu. */); | 1615 | doc: /* Selection name for communication via Services menu. */); |