69 |
#include <errno.h> |
#include <errno.h> |
70 |
#include <setjmp.h> |
#include <setjmp.h> |
71 |
#include <sys/stat.h> |
#include <sys/stat.h> |
72 |
|
#include <sys/param.h> |
73 |
|
|
74 |
#include "keyboard.h" |
#include "keyboard.h" |
75 |
#include "frame.h" |
#include "frame.h" |
7868 |
|
|
7869 |
switch (GetEventKind (event)) |
switch (GetEventKind (event)) |
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 |
|
|
7879 |
case kEventWindowBoundsChanging: |
case kEventWindowBoundsChanging: |
7880 |
result = CallNextEventHandler (next_handler, event); |
result = CallNextEventHandler (next_handler, event); |
7881 |
if (result != eventNotHandledErr) |
if (result != eventNotHandledErr) |
7933 |
{ |
{ |
7934 |
OSErr err = noErr; |
OSErr err = noErr; |
7935 |
#if USE_CARBON_EVENTS |
#if USE_CARBON_EVENTS |
7936 |
EventTypeSpec specs[] = {{kEventClassWindow, kEventWindowBoundsChanging}}; |
EventTypeSpec specs[] = {{kEventClassWindow, kEventWindowUpdate}, |
7937 |
|
{kEventClassWindow, kEventWindowBoundsChanging}}; |
7938 |
static EventHandlerUPP handle_window_event_UPP = NULL; |
static EventHandlerUPP handle_window_event_UPP = NULL; |
7939 |
|
|
7940 |
if (handle_window_event_UPP == NULL) |
if (handle_window_event_UPP == NULL) |
8029 |
int i; |
int i; |
8030 |
|
|
8031 |
/* AE file list is one based so just use that for indexing here. */ |
/* AE file list is one based so just use that for indexing here. */ |
8032 |
for (i = 1; (err == noErr) && (i <= num_files_to_open); i++) |
for (i = 1; i <= num_files_to_open; i++) |
8033 |
{ |
{ |
|
FSSpec fs; |
|
|
Str255 path_name, unix_path_name; |
|
8034 |
#ifdef MAC_OSX |
#ifdef MAC_OSX |
8035 |
FSRef fref; |
FSRef fref; |
8036 |
#endif |
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; |
8049 |
|
|
8050 |
err = AEGetNthPtr(&the_desc, i, typeFSS, &keyword, &actual_type, |
err = AEGetNthPtr(&the_desc, i, typeFSS, &keyword, &actual_type, |
8051 |
(Ptr) &fs, sizeof (fs), &actual_size); |
(Ptr) &fs, sizeof (fs), &actual_size); |
8052 |
if (err != noErr) break; |
if (err != noErr) continue; |
|
|
|
|
#ifdef MAC_OSX |
|
|
err = FSpMakeFSRef (&fs, &fref); |
|
|
if (err != noErr) break; |
|
8053 |
|
|
|
if (FSRefMakePath (&fref, unix_path_name, 255) == noErr) |
|
|
#else |
|
8054 |
if (path_from_vol_dir_name (path_name, 255, fs.vRefNum, fs.parID, |
if (path_from_vol_dir_name (path_name, 255, fs.vRefNum, fs.parID, |
8055 |
fs.name) && |
fs.name) && |
8056 |
mac_to_posix_pathname (path_name, unix_path_name, 255)) |
mac_to_posix_pathname (path_name, unix_path_name, 255)) |
8086 |
FlavorFlags theFlags; |
FlavorFlags theFlags; |
8087 |
OSErr result; |
OSErr result; |
8088 |
|
|
8089 |
|
if (GetFrontWindowOfClass (kMovableModalWindowClass, false)) |
8090 |
|
return dragNotAcceptedErr; |
8091 |
|
|
8092 |
switch (message) |
switch (message) |
8093 |
{ |
{ |
8094 |
case kDragTrackingEnterHandler: |
case kDragTrackingEnterHandler: |
8095 |
CountDragItems (theDrag, &items); |
CountDragItems (theDrag, &items); |
8096 |
can_accept = 1; |
can_accept = 0; |
8097 |
for (index = 1; index <= items; index++) |
for (index = 1; index <= items; index++) |
8098 |
{ |
{ |
8099 |
GetDragItemReferenceNumber (theDrag, index, &theItem); |
GetDragItemReferenceNumber (theDrag, index, &theItem); |
8100 |
result = GetFlavorFlags (theDrag, theItem, flavorTypeHFS, &theFlags); |
result = GetFlavorFlags (theDrag, theItem, flavorTypeHFS, &theFlags); |
8101 |
if (result != noErr) |
if (result == noErr) |
8102 |
{ |
{ |
8103 |
can_accept = 0; |
can_accept = 1; |
8104 |
break; |
break; |
8105 |
} |
} |
8106 |
} |
} |
8111 |
{ |
{ |
8112 |
RgnHandle hilite_rgn = NewRgn (); |
RgnHandle hilite_rgn = NewRgn (); |
8113 |
Rect r; |
Rect r; |
8114 |
|
struct frame *f = mac_window_to_frame (window); |
8115 |
|
|
8116 |
|
mac_set_backcolor (FRAME_BACKGROUND_PIXEL (f)); |
8117 |
GetWindowPortBounds (window, &r); |
GetWindowPortBounds (window, &r); |
8118 |
OffsetRect (&r, -r.left, -r.top); |
OffsetRect (&r, -r.left, -r.top); |
8119 |
RectRgn (hilite_rgn, &r); |
RectRgn (hilite_rgn, &r); |
8129 |
case kDragTrackingLeaveWindow: |
case kDragTrackingLeaveWindow: |
8130 |
if (can_accept) |
if (can_accept) |
8131 |
{ |
{ |
8132 |
|
struct frame *f = mac_window_to_frame (window); |
8133 |
|
|
8134 |
|
mac_set_backcolor (FRAME_BACKGROUND_PIXEL (f)); |
8135 |
HideDragHilite (theDrag); |
HideDragHilite (theDrag); |
8136 |
SetThemeCursor (kThemeArrowCursor); |
SetThemeCursor (kThemeArrowCursor); |
8137 |
} |
} |
8155 |
OSErr result; |
OSErr result; |
8156 |
ItemReference theItem; |
ItemReference theItem; |
8157 |
HFSFlavor data; |
HFSFlavor data; |
|
FSRef fref; |
|
8158 |
Size size = sizeof (HFSFlavor); |
Size size = sizeof (HFSFlavor); |
8159 |
|
|
8160 |
|
if (GetFrontWindowOfClass (kMovableModalWindowClass, false)) |
8161 |
|
return dragNotAcceptedErr; |
8162 |
|
|
8163 |
drag_and_drop_file_list = Qnil; |
drag_and_drop_file_list = Qnil; |
8164 |
GetDragMouse (theDrag, &mouse, 0L); |
GetDragMouse (theDrag, &mouse, 0L); |
8165 |
CountDragItems (theDrag, &items); |
CountDragItems (theDrag, &items); |
8171 |
if (result == noErr) |
if (result == noErr) |
8172 |
{ |
{ |
8173 |
#ifdef MAC_OSX |
#ifdef MAC_OSX |
8174 |
FSRef frref; |
FSRef fref; |
8175 |
|
char unix_path_name[MAXPATHLEN]; |
8176 |
#else |
#else |
8177 |
Str255 path_name; |
Str255 path_name, unix_path_name; |
8178 |
#endif |
#endif |
|
Str255 unix_path_name; |
|
8179 |
GetFlavorData (theDrag, theItem, flavorTypeHFS, &data, &size, 0L); |
GetFlavorData (theDrag, theItem, flavorTypeHFS, &data, &size, 0L); |
8180 |
#ifdef MAC_OSX |
#ifdef MAC_OSX |
8181 |
/* Use Carbon routines, otherwise it converts the file name |
/* Use Carbon routines, otherwise it converts the file name |
8193 |
strlen (unix_path_name)), |
strlen (unix_path_name)), |
8194 |
drag_and_drop_file_list); |
drag_and_drop_file_list); |
8195 |
} |
} |
|
else |
|
|
continue; |
|
8196 |
} |
} |
8197 |
/* If there are items in the list, construct an event and post it to |
/* If there are items in the list, construct an event and post it to |
8198 |
the queue like an interrupt using kbd_buffer_store_event. */ |
the queue like an interrupt using kbd_buffer_store_event. */ |
8752 |
if (SendEventToEventTarget (eventRef, toolbox_dispatcher) |
if (SendEventToEventTarget (eventRef, toolbox_dispatcher) |
8753 |
!= eventNotHandledErr) |
!= eventNotHandledErr) |
8754 |
break; |
break; |
8755 |
#endif |
#else |
8756 |
do_window_update ((WindowPtr) er.message); |
do_window_update ((WindowPtr) er.message); |
8757 |
|
#endif |
8758 |
break; |
break; |
8759 |
|
|
8760 |
case osEvt: |
case osEvt: |