#include <alloca.h>
#endif
-#ifdef MAC_OSX
+#if TARGET_API_MAC_CARBON
/* USE_CARBON_EVENTS determines if the Carbon Event Manager is used to
obtain events from the event queue. If set to 0, WaitNextEvent is
used instead. */
#define USE_CARBON_EVENTS 1
-#else /* not MAC_OSX */
+#else /* not TARGET_API_MAC_CARBON */
#include <Quickdraw.h>
#include <ToolUtils.h>
#include <Sound.h>
#if __profile__
#include <profiler.h>
#endif
-#endif /* not MAC_OSX */
+#endif /* not TARGET_API_MAC_CARBON */
#include "systty.h"
#include "systime.h"
extern int inhibit_window_system;
-#if __MRC__
+#if __MRC__ && !TARGET_API_MAC_CARBON
QDGlobals qd; /* QuickDraw global information structure. */
#endif
BLOCK_INPUT;
+ if (wp != tip_window)
+ remove_window_handler (wp);
+
DisposeWindow (wp);
if (wp == tip_window)
/* Neither WaitNextEvent nor ReceiveNextEvent receives `window
\f
/* The Mac Event loop code */
-#ifndef MAC_OSX
+#if !TARGET_API_MAC_CARBON
#include <Events.h>
#include <Quickdraw.h>
#include <Balloons.h>
#if __MWERKS__
#include <unix.h>
#endif
-#endif /* ! MAC_OSX */
+#endif /* ! TARGET_API_MAC_CARBON */
#define M_APPLE 128
#define I_ABOUT 1
/* Drag and Drop */
static pascal OSErr mac_do_track_drag (DragTrackingMessage, WindowPtr, void*, DragReference);
static pascal OSErr mac_do_receive_drag (WindowPtr, void*, DragReference);
+static DragTrackingHandlerUPP mac_do_track_dragUPP = NULL;
+static DragReceiveHandlerUPP mac_do_receive_dragUPP = NULL;
#endif
#if USE_CARBON_EVENTS
+#ifdef MAC_OSX
/* Preliminary Support for the OSX Services Menu */
static OSStatus mac_handle_service_event (EventHandlerCallRef,EventRef,void*);
static void init_service_handler ();
+#endif
/* Window Event Handler */
static pascal OSStatus mac_handle_window_event (EventHandlerCallRef,
EventRef, void *);
}
#if USE_CARBON_EVENTS
-
+#ifdef MAC_OSX
void
init_service_handler ()
{
}
return err;
}
-
+#endif
static pascal OSStatus
mac_handle_window_event (next_handler, event, data)
NULL, NULL);
#endif
#if TARGET_API_MAC_CARBON
+ if (mac_do_track_dragUPP == NULL)
+ mac_do_track_dragUPP = NewDragTrackingHandlerUPP (mac_do_track_drag);
+ if (mac_do_receive_dragUPP == NULL)
+ mac_do_receive_dragUPP = NewDragReceiveHandlerUPP (mac_do_receive_drag);
+
if (err == noErr)
- err = InstallTrackingHandler (mac_do_track_drag, window, NULL);
+ err = InstallTrackingHandler (mac_do_track_dragUPP, window, NULL);
if (err == noErr)
- err = InstallReceiveHandler (mac_do_receive_drag, window, NULL);
+ err = InstallReceiveHandler (mac_do_receive_dragUPP, window, NULL);
#endif
return err;
}
+void
+remove_window_handler (window)
+ WindowPtr window;
+{
+#if TARGET_API_MAC_CARBON
+ if (mac_do_track_dragUPP)
+ RemoveTrackingHandler (mac_do_track_dragUPP, window);
+ if (mac_do_receive_dragUPP)
+ RemoveReceiveHandler (mac_do_receive_dragUPP, window);
+#endif
+}
/* Open Application Apple Event */
static pascal OSErr
/* AE file list is one based so just use that for indexing here. */
for (i = 1; i <= num_files_to_open; i++)
{
+ char unix_path_name[MAXPATHLEN];
#ifdef MAC_OSX
FSRef fref;
- char unix_path_name[MAXPATHLEN];
err = AEGetNthPtr (&the_desc, i, typeFSRef, &keyword,
&actual_type, &fref, sizeof (FSRef),
== noErr)
#else
FSSpec fs;
- Str255 path_name, unix_path_name;
err = AEGetNthPtr(&the_desc, i, typeFSS, &keyword, &actual_type,
(Ptr) &fs, sizeof (fs), &actual_size);
if (err != noErr) continue;
- if (path_from_vol_dir_name (path_name, 255, fs.vRefNum, fs.parID,
- fs.name) &&
- mac_to_posix_pathname (path_name, unix_path_name, 255))
+ if (fsspec_to_posix_pathname (&fs, unix_path_name,
+ sizeof (unix_path_name) - 1) == noErr)
#endif
/* x-dnd functions expect undecoded filenames. */
drag_and_drop_file_list =
{
#ifdef MAC_OSX
FSRef fref;
- char unix_path_name[MAXPATHLEN];
-#else
- Str255 path_name, unix_path_name;
#endif
+ char unix_path_name[MAXPATHLEN];
+
GetFlavorData (theDrag, theItem, flavorTypeHFS, &data, &size, 0L);
#ifdef MAC_OSX
/* Use Carbon routines, otherwise it converts the file name
FSpMakeFSRef (&data.fileSpec, &fref);
if (! FSRefMakePath (&fref, unix_path_name, sizeof (unix_path_name)));
#else
- if (path_from_vol_dir_name (path_name, 255, data.fileSpec.vRefNum,
- data.fileSpec.parID, data.fileSpec.name) &&
- mac_to_posix_pathname (path_name, unix_path_name, 255))
+ if (fsspec_to_posix_pathname (&data.fileSpec, unix_path_name,
+ sizeof (unix_path_name) - 1) == noErr)
#endif
/* x-dnd functions expect undecoded filenames. */
drag_and_drop_file_list =
hints and prompts in the minibuffer after the user stops typing for
a wait, etc. */
-#if !TARGET_API_MAC_CARBON
+#ifdef MAC_OS8
#undef main
int
main (void)
int keycode = (er.message & keyCodeMask) >> 8;
int xkeysym;
-#if USE_CARBON_EVENTS
+#if USE_CARBON_EVENTS && defined (MAC_OSX)
/* When using Carbon Events, we need to pass raw keyboard
events to the TSM ourselves. If TSM handles it, it
will pass back noErr, otherwise it will pass back
f->output_data.mac->mouse_pixel = 0xff00ff;
f->output_data.mac->cursor_foreground_pixel = 0x0000ff;
+#if TARGET_API_MAC_CARBON
+ f->output_data.mac->text_cursor = kThemeIBeamCursor;
+ f->output_data.mac->nontext_cursor = kThemeArrowCursor;
+ f->output_data.mac->modeline_cursor = kThemeArrowCursor;
+ f->output_data.mac->hand_cursor = kThemePointingHandCursor;
+ f->output_data.mac->hourglass_cursor = kThemeWatchCursor;
+ f->output_data.mac->horizontal_drag_cursor = kThemeResizeLeftRightCursor;
+#else
f->output_data.mac->text_cursor = GetCursor (iBeamCursor);
f->output_data.mac->nontext_cursor = &arrow_cursor;
f->output_data.mac->modeline_cursor = &arrow_cursor;
f->output_data.mac->hand_cursor = &arrow_cursor;
f->output_data.mac->hourglass_cursor = GetCursor (watchCursor);
f->output_data.mac->horizontal_drag_cursor = &arrow_cursor;
+#endif
FRAME_FONTSET (f) = -1;
f->output_data.mac->explicit_parent = 0;
#if TARGET_API_MAC_CARBON
init_required_apple_events ();
-#if USE_CARBON_EVENTS
+#if USE_CARBON_EVENTS && defined (MAC_OSX)
init_service_handler ();
init_quit_char_handler ();
DisableMenuCommand (NULL, kHICommandQuit);
+#ifdef MAC_OSX
if (!inhibit_window_system)
MakeMeTheFrontProcess ();
+#endif
#endif
UNBLOCK_INPUT;
}