aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSteven Tamm2005-01-06 02:53:39 +0000
committerSteven Tamm2005-01-06 02:53:39 +0000
commite0e76ab914bc4d9e4933e11c622a43981be2a141 (patch)
treeadf6b13b1b9b51d99a6baa31fba96eb21fc3f524 /src
parent043bc640a7bf3719d83c8d4054905eb6492f84d6 (diff)
downloademacs-e0e76ab914bc4d9e4933e11c622a43981be2a141.tar.gz
emacs-e0e76ab914bc4d9e4933e11c622a43981be2a141.zip
* macfns.c: Include sys/param.h.
[TARGET_API_MAC_CARBON] (mac_nav_event_callback): New declaration and function. [TARGET_API_MAC_CARBON] (Fx_file_dialog): Use MAXPATHLEN for size of filename string. Set event callback function when creating dialog boxes. Add code conversions for filenames. Don't dispose apple event descriptor record if failed to create it. * macterm.c: Include sys/param.h. [USE_CARBON_EVENTS] (mac_handle_window_event): Add handler for kEventWindowUpdate. (install_window_handler) [USE_CARBON_EVENTS]: Register it. (do_ae_open_documents) [TARGET_API_MAC_CARBON]: Get FSRef instead of FSSpec from apple event descriptor record. (do_ae_open_documents) [TARGET_API_MAC_CARBON]: Use MAXPATHLEN for size of filename string. [TARGET_API_MAC_CARBON] (mac_do_receive_drag): Likewise. [TARGET_API_MAC_CARBON] (mac_do_receive_drag): Return error when a file dialog is in action. [TARGET_API_MAC_CARBON] (mac_do_track_drag): Likewise. Reject only when there are no filename items. Set background color before (un)highlighting the window below the dragged items. (XTread_socket) [!USE_CARBON_EVENTS]: Don't call do_window_update.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog26
-rw-r--r--src/macfns.c48
-rw-r--r--src/macterm.c67
3 files changed, 106 insertions, 35 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 977b239287f..d12787c92a3 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,29 @@
12005-01-05 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
2
3 * macfns.c: Include sys/param.h.
4 [TARGET_API_MAC_CARBON] (mac_nav_event_callback): New declaration
5 and function.
6 [TARGET_API_MAC_CARBON] (Fx_file_dialog): Use MAXPATHLEN for size
7 of filename string. Set event callback function when creating
8 dialog boxes. Add code conversions for filenames. Don't dispose
9 apple event descriptor record if failed to create it.
10
11 * macterm.c: Include sys/param.h.
12 [USE_CARBON_EVENTS] (mac_handle_window_event): Add handler for
13 kEventWindowUpdate.
14 (install_window_handler) [USE_CARBON_EVENTS]: Register it.
15 (do_ae_open_documents) [TARGET_API_MAC_CARBON]: Get FSRef instead
16 of FSSpec from apple event descriptor record.
17 (do_ae_open_documents) [TARGET_API_MAC_CARBON]: Use MAXPATHLEN for
18 size of filename string.
19 [TARGET_API_MAC_CARBON] (mac_do_receive_drag): Likewise.
20 [TARGET_API_MAC_CARBON] (mac_do_receive_drag): Return error when a
21 file dialog is in action.
22 [TARGET_API_MAC_CARBON] (mac_do_track_drag): Likewise. Reject
23 only when there are no filename items. Set background color
24 before (un)highlighting the window below the dragged items.
25 (XTread_socket) [!USE_CARBON_EVENTS]: Don't call do_window_update.
26
12005-01-05 Romain Francoise <romain@orebokech.com> 272005-01-05 Romain Francoise <romain@orebokech.com>
2 28
3 * term.c (encode_terminal_code): Fix buffer size computation. 29 * term.c (encode_terminal_code): Fix buffer size computation.
diff --git a/src/macfns.c b/src/macfns.c
index f40e8354f35..9a8382e413c 100644
--- a/src/macfns.c
+++ b/src/macfns.c
@@ -55,6 +55,7 @@ static unsigned char gray_bits[] = {
55#include <ctype.h> 55#include <ctype.h>
56#include <sys/types.h> 56#include <sys/types.h>
57#include <sys/stat.h> 57#include <sys/stat.h>
58#include <sys/param.h>
58 59
59#include <stdlib.h> 60#include <stdlib.h>
60#include <string.h> 61#include <string.h>
@@ -4237,6 +4238,9 @@ Value is t if tooltip was open, nil otherwise. */)
4237 File selection dialog 4238 File selection dialog
4238 ***********************************************************************/ 4239 ***********************************************************************/
4239 4240
4241static pascal void mac_nav_event_callback P_ ((NavEventCallbackMessage,
4242 NavCBRecPtr, void *));
4243
4240/** 4244/**
4241 There is a relatively standard way to do this using applescript to run 4245 There is a relatively standard way to do this using applescript to run
4242 a (choose file) method. However, this doesn't do "the right thing" 4246 a (choose file) method. However, this doesn't do "the right thing"
@@ -4261,8 +4265,9 @@ If ONLY-DIR-P is non-nil, the user can only select directories. */)
4261 Lisp_Object file = Qnil; 4265 Lisp_Object file = Qnil;
4262 int count = SPECPDL_INDEX (); 4266 int count = SPECPDL_INDEX ();
4263 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6; 4267 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6;
4264 char filename[1001]; 4268 char filename[MAXPATHLEN];
4265 int default_filter_index = 1; /* 1: All Files, 2: Directories only */ 4269 int default_filter_index = 1; /* 1: All Files, 2: Directories only */
4270 static NavEventUPP mac_nav_event_callbackUPP = NULL;
4266 4271
4267 GCPRO6 (prompt, dir, default_filename, mustmatch, file, only_dir_p); 4272 GCPRO6 (prompt, dir, default_filename, mustmatch, file, only_dir_p);
4268 CHECK_STRING (prompt); 4273 CHECK_STRING (prompt);
@@ -4290,16 +4295,20 @@ If ONLY-DIR-P is non-nil, the user can only select directories. */)
4290 options.optionFlags |= kNavSelectAllReadableItem; 4295 options.optionFlags |= kNavSelectAllReadableItem;
4291 if (!NILP(prompt)) 4296 if (!NILP(prompt))
4292 { 4297 {
4293 message = cfstring_create_with_utf8_cstring (SDATA (prompt)); 4298 message =
4299 cfstring_create_with_utf8_cstring (SDATA (ENCODE_UTF_8 (prompt)));
4294 options.message = message; 4300 options.message = message;
4295 } 4301 }
4296 /* Don't set the application, let it use default. 4302 /* Don't set the application, let it use default.
4297 options.clientName = CFSTR ("Emacs"); 4303 options.clientName = CFSTR ("Emacs");
4298 */ 4304 */
4299 4305
4306 if (mac_nav_event_callbackUPP == NULL)
4307 mac_nav_event_callbackUPP = NewNavEventUPP (mac_nav_event_callback);
4308
4300 if (!NILP (only_dir_p)) 4309 if (!NILP (only_dir_p))
4301 status = NavCreateChooseFolderDialog(&options, NULL, NULL, NULL, 4310 status = NavCreateChooseFolderDialog(&options, mac_nav_event_callbackUPP,
4302 &dialogRef); 4311 NULL, NULL, &dialogRef);
4303 else if (NILP (mustmatch)) 4312 else if (NILP (mustmatch))
4304 { 4313 {
4305 /* This is a save dialog */ 4314 /* This is a save dialog */
@@ -4310,20 +4319,22 @@ If ONLY-DIR-P is non-nil, the user can only select directories. */)
4310 if (!NILP(default_filename)) 4319 if (!NILP(default_filename))
4311 { 4320 {
4312 saveName = 4321 saveName =
4313 cfstring_create_with_utf8_cstring (SDATA (default_filename)); 4322 cfstring_create_with_utf8_cstring (SDATA (ENCODE_UTF_8
4323 (default_filename)));
4314 options.saveFileName = saveName; 4324 options.saveFileName = saveName;
4315 options.optionFlags |= kNavSelectDefaultLocation; 4325 options.optionFlags |= kNavSelectDefaultLocation;
4316 } 4326 }
4317 status = NavCreatePutFileDialog(&options, 4327 status = NavCreatePutFileDialog(&options,
4318 'TEXT', kNavGenericSignature, 4328 'TEXT', kNavGenericSignature,
4319 NULL, NULL, &dialogRef); 4329 mac_nav_event_callbackUPP, NULL,
4330 &dialogRef);
4320 } 4331 }
4321 else 4332 else
4322 { 4333 {
4323 /* This is an open dialog*/ 4334 /* This is an open dialog*/
4324 status = NavCreateChooseFileDialog(&options, fileTypes, 4335 status = NavCreateChooseFileDialog(&options, fileTypes,
4325 NULL, NULL, NULL, NULL, 4336 mac_nav_event_callbackUPP, NULL,
4326 &dialogRef); 4337 NULL, NULL, &dialogRef);
4327 } 4338 }
4328 4339
4329 /* Set the default location and continue*/ 4340 /* Set the default location and continue*/
@@ -4331,13 +4342,13 @@ If ONLY-DIR-P is non-nil, the user can only select directories. */)
4331 if (!NILP(dir)) { 4342 if (!NILP(dir)) {
4332 FSRef defLoc; 4343 FSRef defLoc;
4333 AEDesc defLocAed; 4344 AEDesc defLocAed;
4334 status = FSPathMakeRef(SDATA(dir), &defLoc, NULL); 4345 status = FSPathMakeRef(SDATA(ENCODE_FILE(dir)), &defLoc, NULL);
4335 if (status == noErr) 4346 if (status == noErr)
4336 { 4347 {
4337 AECreateDesc(typeFSRef, &defLoc, sizeof(FSRef), &defLocAed); 4348 AECreateDesc(typeFSRef, &defLoc, sizeof(FSRef), &defLocAed);
4338 NavCustomControl(dialogRef, kNavCtlSetLocation, (void*) &defLocAed); 4349 NavCustomControl(dialogRef, kNavCtlSetLocation, (void*) &defLocAed);
4350 AEDisposeDesc(&defLocAed);
4339 } 4351 }
4340 AEDisposeDesc(&defLocAed);
4341 } 4352 }
4342 4353
4343 status = NavDialogRun(dialogRef); 4354 status = NavDialogRun(dialogRef);
@@ -4363,7 +4374,7 @@ If ONLY-DIR-P is non-nil, the user can only select directories. */)
4363 status = NavDialogGetReply(dialogRef, &reply); 4374 status = NavDialogGetReply(dialogRef, &reply);
4364 AECoerceDesc(&reply.selection, typeFSRef, &aed); 4375 AECoerceDesc(&reply.selection, typeFSRef, &aed);
4365 AEGetDescData(&aed, (void *) &fsRef, sizeof (FSRef)); 4376 AEGetDescData(&aed, (void *) &fsRef, sizeof (FSRef));
4366 FSRefMakePath(&fsRef, (UInt8 *) filename, 1000); 4377 FSRefMakePath(&fsRef, (UInt8 *) filename, sizeof (filename));
4367 AEDisposeDesc(&aed); 4378 AEDisposeDesc(&aed);
4368 if (reply.saveFileName) 4379 if (reply.saveFileName)
4369 { 4380 {
@@ -4372,9 +4383,11 @@ If ONLY-DIR-P is non-nil, the user can only select directories. */)
4372 if (len && filename[len-1] != '/') 4383 if (len && filename[len-1] != '/')
4373 filename[len++] = '/'; 4384 filename[len++] = '/';
4374 CFStringGetCString(reply.saveFileName, filename+len, 4385 CFStringGetCString(reply.saveFileName, filename+len,
4375 1000-len, kCFStringEncodingUTF8); 4386 sizeof (filename) - len,
4387 kCFStringEncodingUTF8);
4376 } 4388 }
4377 file = DECODE_FILE(build_string (filename)); 4389 file = DECODE_FILE (make_unibyte_string (filename,
4390 strlen (filename)));
4378 NavDisposeReply(&reply); 4391 NavDisposeReply(&reply);
4379 } 4392 }
4380 break; 4393 break;
@@ -4400,6 +4413,15 @@ If ONLY-DIR-P is non-nil, the user can only select directories. */)
4400} 4413}
4401 4414
4402 4415
4416/* Need to register some event callback function for enabling drag and
4417 drop in Navigation Service dialogs. */
4418static pascal void
4419mac_nav_event_callback (selector, parms, data)
4420 NavEventCallbackMessage selector;
4421 NavCBRecPtr parms;
4422 void *data ;
4423{
4424}
4403#endif 4425#endif
4404 4426
4405/*********************************************************************** 4427/***********************************************************************
diff --git a/src/macterm.c b/src/macterm.c
index dda0cc8311f..4d80fbac5fa 100644
--- a/src/macterm.c
+++ b/src/macterm.c
@@ -69,6 +69,7 @@ Boston, MA 02111-1307, USA. */
69#include <errno.h> 69#include <errno.h>
70#include <setjmp.h> 70#include <setjmp.h>
71#include <sys/stat.h> 71#include <sys/stat.h>
72#include <sys/param.h>
72 73
73#include "keyboard.h" 74#include "keyboard.h"
74#include "frame.h" 75#include "frame.h"
@@ -7867,6 +7868,14 @@ mac_handle_window_event (next_handler, event, data)
7867 7868
7868 switch (GetEventKind (event)) 7869 switch (GetEventKind (event))
7869 { 7870 {
7871 case kEventWindowUpdate:
7872 result = CallNextEventHandler (next_handler, event);
7873 if (result != eventNotHandledErr)
7874 return result;
7875
7876 do_window_update (wp);
7877 break;
7878
7870 case kEventWindowBoundsChanging: 7879 case kEventWindowBoundsChanging:
7871 result = CallNextEventHandler (next_handler, event); 7880 result = CallNextEventHandler (next_handler, event);
7872 if (result != eventNotHandledErr) 7881 if (result != eventNotHandledErr)
@@ -7924,7 +7933,8 @@ install_window_handler (window)
7924{ 7933{
7925 OSErr err = noErr; 7934 OSErr err = noErr;
7926#if USE_CARBON_EVENTS 7935#if USE_CARBON_EVENTS
7927 EventTypeSpec specs[] = {{kEventClassWindow, kEventWindowBoundsChanging}}; 7936 EventTypeSpec specs[] = {{kEventClassWindow, kEventWindowUpdate},
7937 {kEventClassWindow, kEventWindowBoundsChanging}};
7928 static EventHandlerUPP handle_window_event_UPP = NULL; 7938 static EventHandlerUPP handle_window_event_UPP = NULL;
7929 7939
7930 if (handle_window_event_UPP == NULL) 7940 if (handle_window_event_UPP == NULL)
@@ -8019,24 +8029,28 @@ do_ae_open_documents(AppleEvent *message, AppleEvent *reply, long refcon)
8019 int i; 8029 int i;
8020 8030
8021 /* AE file list is one based so just use that for indexing here. */ 8031 /* AE file list is one based so just use that for indexing here. */
8022 for (i = 1; (err == noErr) && (i <= num_files_to_open); i++) 8032 for (i = 1; i <= num_files_to_open; i++)
8023 { 8033 {
8024 FSSpec fs;
8025 Str255 path_name, unix_path_name;
8026#ifdef MAC_OSX 8034#ifdef MAC_OSX
8027 FSRef fref; 8035 FSRef fref;
8028#endif 8036 char unix_path_name[MAXPATHLEN];
8037
8038 err = AEGetNthPtr (&the_desc, i, typeFSRef, &keyword,
8039 &actual_type, &fref, sizeof (FSRef),
8040 &actual_size);
8041 if (err != noErr || actual_type != typeFSRef)
8042 continue;
8043
8044 if (FSRefMakePath (&fref, unix_path_name, sizeof (unix_path_name))
8045 == noErr)
8046#else
8047 FSSpec fs;
8048 Str255 path_name, unix_path_name;
8029 8049
8030 err = AEGetNthPtr(&the_desc, i, typeFSS, &keyword, &actual_type, 8050 err = AEGetNthPtr(&the_desc, i, typeFSS, &keyword, &actual_type,
8031 (Ptr) &fs, sizeof (fs), &actual_size); 8051 (Ptr) &fs, sizeof (fs), &actual_size);
8032 if (err != noErr) break; 8052 if (err != noErr) continue;
8033
8034#ifdef MAC_OSX
8035 err = FSpMakeFSRef (&fs, &fref);
8036 if (err != noErr) break;
8037 8053
8038 if (FSRefMakePath (&fref, unix_path_name, 255) == noErr)
8039#else
8040 if (path_from_vol_dir_name (path_name, 255, fs.vRefNum, fs.parID, 8054 if (path_from_vol_dir_name (path_name, 255, fs.vRefNum, fs.parID,
8041 fs.name) && 8055 fs.name) &&
8042 mac_to_posix_pathname (path_name, unix_path_name, 255)) 8056 mac_to_posix_pathname (path_name, unix_path_name, 255))
@@ -8072,18 +8086,21 @@ mac_do_track_drag (DragTrackingMessage message, WindowPtr window,
8072 FlavorFlags theFlags; 8086 FlavorFlags theFlags;
8073 OSErr result; 8087 OSErr result;
8074 8088
8089 if (GetFrontWindowOfClass (kMovableModalWindowClass, false))
8090 return dragNotAcceptedErr;
8091
8075 switch (message) 8092 switch (message)
8076 { 8093 {
8077 case kDragTrackingEnterHandler: 8094 case kDragTrackingEnterHandler:
8078 CountDragItems (theDrag, &items); 8095 CountDragItems (theDrag, &items);
8079 can_accept = 1; 8096 can_accept = 0;
8080 for (index = 1; index <= items; index++) 8097 for (index = 1; index <= items; index++)
8081 { 8098 {
8082 GetDragItemReferenceNumber (theDrag, index, &theItem); 8099 GetDragItemReferenceNumber (theDrag, index, &theItem);
8083 result = GetFlavorFlags (theDrag, theItem, flavorTypeHFS, &theFlags); 8100 result = GetFlavorFlags (theDrag, theItem, flavorTypeHFS, &theFlags);
8084 if (result != noErr) 8101 if (result == noErr)
8085 { 8102 {
8086 can_accept = 0; 8103 can_accept = 1;
8087 break; 8104 break;
8088 } 8105 }
8089 } 8106 }
@@ -8094,7 +8111,9 @@ mac_do_track_drag (DragTrackingMessage message, WindowPtr window,
8094 { 8111 {
8095 RgnHandle hilite_rgn = NewRgn (); 8112 RgnHandle hilite_rgn = NewRgn ();
8096 Rect r; 8113 Rect r;
8114 struct frame *f = mac_window_to_frame (window);
8097 8115
8116 mac_set_backcolor (FRAME_BACKGROUND_PIXEL (f));
8098 GetWindowPortBounds (window, &r); 8117 GetWindowPortBounds (window, &r);
8099 OffsetRect (&r, -r.left, -r.top); 8118 OffsetRect (&r, -r.left, -r.top);
8100 RectRgn (hilite_rgn, &r); 8119 RectRgn (hilite_rgn, &r);
@@ -8110,6 +8129,9 @@ mac_do_track_drag (DragTrackingMessage message, WindowPtr window,
8110 case kDragTrackingLeaveWindow: 8129 case kDragTrackingLeaveWindow:
8111 if (can_accept) 8130 if (can_accept)
8112 { 8131 {
8132 struct frame *f = mac_window_to_frame (window);
8133
8134 mac_set_backcolor (FRAME_BACKGROUND_PIXEL (f));
8113 HideDragHilite (theDrag); 8135 HideDragHilite (theDrag);
8114 SetThemeCursor (kThemeArrowCursor); 8136 SetThemeCursor (kThemeArrowCursor);
8115 } 8137 }
@@ -8133,9 +8155,11 @@ mac_do_receive_drag (WindowPtr window, void *handlerRefCon,
8133 OSErr result; 8155 OSErr result;
8134 ItemReference theItem; 8156 ItemReference theItem;
8135 HFSFlavor data; 8157 HFSFlavor data;
8136 FSRef fref;
8137 Size size = sizeof (HFSFlavor); 8158 Size size = sizeof (HFSFlavor);
8138 8159
8160 if (GetFrontWindowOfClass (kMovableModalWindowClass, false))
8161 return dragNotAcceptedErr;
8162
8139 drag_and_drop_file_list = Qnil; 8163 drag_and_drop_file_list = Qnil;
8140 GetDragMouse (theDrag, &mouse, 0L); 8164 GetDragMouse (theDrag, &mouse, 0L);
8141 CountDragItems (theDrag, &items); 8165 CountDragItems (theDrag, &items);
@@ -8147,11 +8171,11 @@ mac_do_receive_drag (WindowPtr window, void *handlerRefCon,
8147 if (result == noErr) 8171 if (result == noErr)
8148 { 8172 {
8149#ifdef MAC_OSX 8173#ifdef MAC_OSX
8150 FSRef frref; 8174 FSRef fref;
8175 char unix_path_name[MAXPATHLEN];
8151#else 8176#else
8152 Str255 path_name; 8177 Str255 path_name, unix_path_name;
8153#endif 8178#endif
8154 Str255 unix_path_name;
8155 GetFlavorData (theDrag, theItem, flavorTypeHFS, &data, &size, 0L); 8179 GetFlavorData (theDrag, theItem, flavorTypeHFS, &data, &size, 0L);
8156#ifdef MAC_OSX 8180#ifdef MAC_OSX
8157 /* Use Carbon routines, otherwise it converts the file name 8181 /* Use Carbon routines, otherwise it converts the file name
@@ -8169,8 +8193,6 @@ mac_do_receive_drag (WindowPtr window, void *handlerRefCon,
8169 strlen (unix_path_name)), 8193 strlen (unix_path_name)),
8170 drag_and_drop_file_list); 8194 drag_and_drop_file_list);
8171 } 8195 }
8172 else
8173 continue;
8174 } 8196 }
8175 /* If there are items in the list, construct an event and post it to 8197 /* If there are items in the list, construct an event and post it to
8176 the queue like an interrupt using kbd_buffer_store_event. */ 8198 the queue like an interrupt using kbd_buffer_store_event. */
@@ -8730,8 +8752,9 @@ XTread_socket (sd, expected, hold_quit)
8730 if (SendEventToEventTarget (eventRef, toolbox_dispatcher) 8752 if (SendEventToEventTarget (eventRef, toolbox_dispatcher)
8731 != eventNotHandledErr) 8753 != eventNotHandledErr)
8732 break; 8754 break;
8733#endif 8755#else
8734 do_window_update ((WindowPtr) er.message); 8756 do_window_update ((WindowPtr) er.message);
8757#endif
8735 break; 8758 break;
8736 8759
8737 case osEvt: 8760 case osEvt: