#include <alloca.h>
#endif
-#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 TARGET_API_MAC_CARBON */
+#if !TARGET_API_MAC_CARBON
#include <Quickdraw.h>
#include <ToolUtils.h>
#include <Sound.h>
Lisp_Object *, Lisp_Object *,
unsigned long *));
-static int is_emacs_window P_ ((WindowPtr));
+static int is_emacs_window P_ ((WindowRef));
static XCharStruct *mac_per_char_metric P_ ((XFontStruct *, XChar2b *, int));
static void XSetFont P_ ((Display *, GC, XFontStruct *));
Pixmap
XCreatePixmap (display, w, width, height, depth)
Display *display; /* not used */
- WindowPtr w;
+ WindowRef w;
unsigned int width, height;
unsigned int depth;
{
Pixmap
XCreatePixmapFromBitmapData (display, w, data, width, height, fg, bg, depth)
Display *display; /* not used */
- WindowPtr w;
+ WindowRef w;
char *data;
unsigned int width, height;
unsigned long fg, bg;
DisposeRgn (dummy);
#else /* not TARGET_API_MAC_CARBON */
Rect src_r, dest_r;
- WindowPtr w = FRAME_MAC_WINDOW (f);
+ WindowRef w = FRAME_MAC_WINDOW (f);
SetPort (w);
void
XSetWindowBackground (display, w, color)
Display *display;
- WindowPtr w;
+ WindowRef w;
unsigned long color;
{
#if !TARGET_API_MAC_CARBON
{
struct frame *frame;
- frame = mac_window_to_frame ((WindowPtr) event->message);
+ frame = mac_window_to_frame ((WindowRef) event->message);
if (! frame)
return;
static int control_part_code_to_scroll_bar_part P_ ((ControlPartCode));
static void construct_scroll_bar_click P_ ((struct scroll_bar *, int,
struct input_event *));
-static OSStatus get_control_part_bounds P_ ((ControlHandle, ControlPartCode,
+static OSStatus get_control_part_bounds P_ ((ControlRef, ControlPartCode,
Rect *));
static void x_scroll_bar_handle_press P_ ((struct scroll_bar *,
ControlPartCode, Point,
struct input_event *));
static void x_scroll_bar_handle_release P_ ((struct scroll_bar *,
struct input_event *));
-static void x_scroll_bar_handle_drag P_ ((WindowPtr, struct scroll_bar *,
+static void x_scroll_bar_handle_drag P_ ((WindowRef, struct scroll_bar *,
Point, struct input_event *));
static void x_set_toolkit_scroll_bar_thumb P_ ((struct scroll_bar *,
int, int, int));
static OSStatus
get_control_part_bounds (ch, part_code, rect)
- ControlHandle ch;
+ ControlRef ch;
ControlPartCode part_code;
Rect *rect;
{
if (part != scroll_bar_handle)
{
construct_scroll_bar_click (bar, part, bufp);
- HiliteControl (SCROLL_BAR_CONTROL_HANDLE (bar), part_code);
+ HiliteControl (SCROLL_BAR_CONTROL_REF (bar), part_code);
set_scroll_bar_timer (SCROLL_BAR_FIRST_DELAY);
bar->dragging = Qnil;
}
{
Rect r;
- get_control_part_bounds (SCROLL_BAR_CONTROL_HANDLE (bar),
+ get_control_part_bounds (SCROLL_BAR_CONTROL_REF (bar),
kControlIndicatorPart, &r);
XSETINT (bar->dragging, - (mouse_pos.v - r.top) - 1);
}
|| (INTEGERP (bar->dragging) && XINT (bar->dragging) >= 0))
construct_scroll_bar_click (bar, scroll_bar_end_scroll, bufp);
- HiliteControl (SCROLL_BAR_CONTROL_HANDLE (bar), 0);
+ HiliteControl (SCROLL_BAR_CONTROL_REF (bar), 0);
set_scroll_bar_timer (kEventDurationForever);
last_scroll_bar_part = -1;
static void
x_scroll_bar_handle_drag (win, bar, mouse_pos, bufp)
- WindowPtr win;
+ WindowRef win;
struct scroll_bar *bar;
Point mouse_pos;
struct input_event *bufp;
{
- ControlHandle ch = SCROLL_BAR_CONTROL_HANDLE (bar);
+ ControlRef ch = SCROLL_BAR_CONTROL_REF (bar);
if (last_scroll_bar_part == scroll_bar_handle)
{
int top, top_range;
Rect r;
- get_control_part_bounds (SCROLL_BAR_CONTROL_HANDLE (bar),
+ get_control_part_bounds (SCROLL_BAR_CONTROL_REF (bar),
kControlIndicatorPart, &r);
if (INTEGERP (bar->dragging) && XINT (bar->dragging) < 0)
}
if (unhilite_p)
- HiliteControl (SCROLL_BAR_CONTROL_HANDLE (bar), 0);
+ HiliteControl (SCROLL_BAR_CONTROL_REF (bar), 0);
else if (part != last_scroll_bar_part
|| scroll_bar_timer_event_posted_p)
{
construct_scroll_bar_click (bar, part, bufp);
last_scroll_bar_part = part;
- HiliteControl (SCROLL_BAR_CONTROL_HANDLE (bar), part_code);
+ HiliteControl (SCROLL_BAR_CONTROL_REF (bar), part_code);
set_scroll_bar_timer (SCROLL_BAR_CONTINUOUS_DELAY);
}
}
struct scroll_bar *bar;
int portion, position, whole;
{
- ControlHandle ch = SCROLL_BAR_CONTROL_HANDLE (bar);
+ ControlRef ch = SCROLL_BAR_CONTROL_REF (bar);
int value, viewsize, maximum;
if (XINT (bar->track_height) == 0)
struct scroll_bar *bar
= XSCROLL_BAR (Fmake_vector (make_number (SCROLL_BAR_VEC_SIZE), Qnil));
Rect r;
- ControlHandle ch;
+ ControlRef ch;
BLOCK_INPUT;
ch = NewControl (FRAME_MAC_WINDOW (f), &r, "\p", width < disp_height,
0, 0, 0, scrollBarProc, (long) bar);
#endif
- SET_SCROLL_BAR_CONTROL_HANDLE (bar, ch);
+ SET_SCROLL_BAR_CONTROL_REF (bar, ch);
XSETWINDOW (bar->window, w);
XSETINT (bar->top, top);
int rebuild;
{
int dragging = ! NILP (bar->dragging);
- ControlHandle ch = SCROLL_BAR_CONTROL_HANDLE (bar);
+ ControlRef ch = SCROLL_BAR_CONTROL_REF (bar);
FRAME_PTR f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window)));
int top_range = VERTICAL_SCROLL_BAR_TOP_RANGE (f, XINT (bar->height));
int length = end - start;
mac_prepare_for_quickdraw (f);
#endif
/* Destroy the Mac scroll bar control */
- DisposeControl (SCROLL_BAR_CONTROL_HANDLE (bar));
+ DisposeControl (SCROLL_BAR_CONTROL_REF (bar));
/* Disassociate this scroll bar from its window. */
XWINDOW (bar->window)->vertical_scroll_bar = Qnil;
else
{
/* It may just need to be moved and resized. */
- ControlHandle ch;
+ ControlRef ch;
bar = XSCROLL_BAR (w->vertical_scroll_bar);
- ch = SCROLL_BAR_CONTROL_HANDLE (bar);
+ ch = SCROLL_BAR_CONTROL_REF (bar);
BLOCK_INPUT;
}
else
{
- ControlHandle ch = SCROLL_BAR_CONTROL_HANDLE (bar);
+ ControlRef ch = SCROLL_BAR_CONTROL_REF (bar);
Rect r0, r1;
BLOCK_INPUT;
unsigned long *time;
{
struct scroll_bar *bar = XSCROLL_BAR (last_mouse_scroll_bar);
- ControlHandle ch = SCROLL_BAR_CONTROL_HANDLE (bar);
+ ControlRef ch = SCROLL_BAR_CONTROL_REF (bar);
#if TARGET_API_MAC_CARBON
- WindowPtr wp = GetControlOwner (ch);
+ WindowRef wp = GetControlOwner (ch);
#else
- WindowPtr wp = (*ch)->contrlOwner;
+ WindowRef wp = (*ch)->contrlOwner;
#endif
Point mouse_pos;
struct frame *f = mac_window_to_frame (wp);
ConstrainWindowToScreen (FRAME_MAC_WINDOW (f), kWindowTitleBarRgn,
kWindowConstrainMoveRegardlessOfFit
| kWindowConstrainAllowPartial, NULL, NULL);
-#if USE_CARBON_EVENTS
if (!NILP (tip_frame) && XFRAME (tip_frame) == f)
-#endif
mac_handle_origin_change (f);
#else
{
SizeWindow (FRAME_MAC_WINDOW (f), pixelwidth, pixelheight, 0);
-#if USE_CARBON_EVENTS
+#if TARGET_API_MAC_CARBON
if (!NILP (tip_frame) && f == XFRAME (tip_frame))
#endif
mac_handle_size_change (f, pixelwidth, pixelheight);
mac_handle_visibility_change (f)
struct frame *f;
{
- WindowPtr wp = FRAME_MAC_WINDOW (f);
+ WindowRef wp = FRAME_MAC_WINDOW (f);
int visible = 0, iconified = 0;
struct input_event buf;
kWindowCascadeOnParentWindowScreen
#endif
);
-#if USE_CARBON_EVENTS
if (!NILP (tip_frame) && f == XFRAME (tip_frame))
-#endif
mac_handle_origin_change (f);
}
else
UNBLOCK_INPUT;
-#if !USE_CARBON_EVENTS
+#if !TARGET_API_MAC_CARBON
mac_handle_visibility_change (f);
#endif
}
if (err != noErr)
error ("Can't notify window manager of iconification");
-#if !USE_CARBON_EVENTS
+#if !TARGET_API_MAC_CARBON
mac_handle_visibility_change (f);
#endif
}
struct frame *f;
{
struct mac_display_info *dpyinfo = FRAME_MAC_DISPLAY_INFO (f);
- WindowPtr wp = FRAME_MAC_WINDOW (f);
+ WindowRef wp = FRAME_MAC_WINDOW (f);
BLOCK_INPUT;
a three button mouse */
Lisp_Object Vmac_emulate_three_button_mouse;
-#if USE_CARBON_EVENTS
+#if TARGET_API_MAC_CARBON
/* Non-zero if the mouse wheel button (i.e. button 4) should map to
mouse-2, instead of mouse-3. */
int mac_wheel_button_is_mouse_2;
Point saved_menu_event_location;
/* Apple Events */
-#if USE_CARBON_EVENTS
+#if TARGET_API_MAC_CARBON
static Lisp_Object Qhi_command;
#ifdef MAC_OSX
extern Lisp_Object Qwindow;
extern void remove_drag_handler P_ ((WindowRef));
/* Showing help echo string during menu tracking */
-extern OSStatus install_menu_target_item_handler P_ ((WindowPtr));
+extern OSStatus install_menu_target_item_handler P_ ((WindowRef));
-#if USE_CARBON_EVENTS
+#if TARGET_API_MAC_CARBON
#ifdef MAC_OSX
extern void init_service_handler ();
static Lisp_Object Qservice, Qpaste, Qperform;
static pascal OSStatus mac_handle_window_event (EventHandlerCallRef,
EventRef, void *);
#endif
-OSStatus install_window_handler (WindowPtr);
+OSStatus install_window_handler (WindowRef);
extern void init_emacs_passwd_dir ();
extern int emacs_main (int, char **, char **);
#endif /* MAC_OSX */
static int
-#if USE_CARBON_EVENTS
+#if TARGET_API_MAC_CARBON
mac_to_emacs_modifiers (UInt32 mods)
#else
mac_to_emacs_modifiers (EventModifiers mods)
}
#endif
-#if USE_CARBON_EVENTS
+#if TARGET_API_MAC_CARBON
/* Obtains the event modifiers from the event ref and then calls
mac_to_emacs_modifiers. */
static int
do_get_menus (void)
{
Handle menubar_handle;
- MenuHandle menu_handle;
+ MenuRef menu;
menubar_handle = GetNewMBar (128);
if(menubar_handle == NULL)
DrawMenuBar ();
#if !TARGET_API_MAC_CARBON
- menu_handle = GetMenuHandle (M_APPLE);
- if(menu_handle != NULL)
- AppendResMenu (menu_handle,'DRVR');
+ menu = GetMenuRef (M_APPLE);
+ if (menu != NULL)
+ AppendResMenu (menu, 'DRVR');
else
abort ();
#endif
#endif /* MAC_OS8 */
static void
-do_window_update (WindowPtr win)
+do_window_update (WindowRef win)
{
struct frame *f = mac_window_to_frame (win);
}
static int
-is_emacs_window (WindowPtr win)
+is_emacs_window (WindowRef win)
{
Lisp_Object tail, frame;
NoteAlert (ABOUT_ALERT_ID, NULL);
else
{
- GetMenuItemText (GetMenuHandle (M_APPLE), menu_item, item_name);
+ GetMenuItemText (GetMenuRef (M_APPLE), menu_item, item_name);
da_driver_refnum = OpenDeskAcc (item_name);
}
}
static void
do_grow_window (w, e)
- WindowPtr w;
+ WindowRef w;
const EventRecord *e;
{
Rect limit_rect;
struct frame *f;
{
struct mac_display_info *dpyinfo = FRAME_MAC_DISPLAY_INFO (f);
- WindowPtr w = FRAME_MAC_WINDOW (f);
+ WindowRef w = FRAME_MAC_WINDOW (f);
Point ideal_size;
Rect standard_rect;
int height, width, columns, rows;
wide (DEFAULT_NUM_COLS) and as tall as will fit on the screen. */
static void
-do_zoom_window (WindowPtr w, int zoom_in_or_out)
+do_zoom_window (WindowRef w, int zoom_in_or_out)
{
Rect zoom_rect, port_rect;
int width, height;
SetPort (save_port);
#endif /* not TARGET_API_MAC_CARBON */
-#if !USE_CARBON_EVENTS
+#if !TARGET_API_MAC_CARBON
/* retrieve window size and update application values */
-#if TARGET_API_MAC_CARBON
- GetWindowPortBounds (w, &port_rect);
-#else
port_rect = w->portRect;
-#endif
height = port_rect.bottom - port_rect.top;
width = port_rect.right - port_rect.left;
buf.arg = mac_aedesc_to_lisp (desc);
kbd_buffer_store_event (&buf);
}
-#endif
-#if USE_CARBON_EVENTS
static pascal OSStatus
mac_handle_command_event (next_handler, event, data)
EventHandlerCallRef next_handler;
EventRef event;
void *data;
{
- WindowPtr wp;
+ WindowRef wp;
OSStatus result, err;
struct frame *f;
UInt32 attributes;
XSizeHints *size_hints;
err = GetEventParameter (event, kEventParamDirectObject, typeWindowRef,
- NULL, sizeof (WindowPtr), NULL, &wp);
+ NULL, sizeof (WindowRef), NULL, &wp);
if (err != noErr)
return eventNotHandledErr;
{
case kEventMouseWheelMoved:
{
- WindowPtr wp;
+ WindowRef wp;
struct frame *f;
EventMouseWheelAxis axis;
SInt32 delta;
return err;
}
#endif /* MAC_OSX */
-#endif /* USE_CARBON_EVENTS */
+#endif /* TARGET_API_MAC_CARBON */
OSStatus
install_window_handler (window)
- WindowPtr window;
+ WindowRef window;
{
OSStatus err = noErr;
-#if USE_CARBON_EVENTS
+#if TARGET_API_MAC_CARBON
static const EventTypeSpec specs_window[] =
{{kEventClassWindow, kEventWindowUpdate},
{kEventClassWindow, kEventWindowGetIdealSize},
void
remove_window_handler (window)
- WindowPtr window;
+ WindowRef window;
{
remove_drag_handler (window);
}
}
#endif
-#if !USE_CARBON_EVENTS
+#if !TARGET_API_MAC_CARBON
static RgnHandle mouse_region = NULL;
Boolean
er_buf.what = nullEvent;
return true;
}
-#endif /* not USE_CARBON_EVENTS */
+#endif /* not TARGET_API_MAC_CARBON */
#if TARGET_API_MAC_CARBON
OSStatus
{
struct input_event inev;
int count = 0;
-#if USE_CARBON_EVENTS
+#if TARGET_API_MAC_CARBON
EventRef eventRef;
EventTargetRef toolbox_dispatcher;
#endif
++handling_signal;
-#if USE_CARBON_EVENTS
+#if TARGET_API_MAC_CARBON
toolbox_dispatcher = GetEventDispatcherTarget ();
while (
#endif
!ReceiveNextEvent (0, NULL, kEventDurationNoWait,
kEventRemoveFromQueue, &eventRef))
-#else /* !USE_CARBON_EVENTS */
+#else /* !TARGET_API_MAC_CARBON */
while (mac_wait_next_event (&er, 0, true))
-#endif /* !USE_CARBON_EVENTS */
+#endif /* !TARGET_API_MAC_CARBON */
{
int do_help = 0;
struct frame *f;
inev.kind = NO_EVENT;
inev.arg = Qnil;
-#if USE_CARBON_EVENTS
+#if TARGET_API_MAC_CARBON
timestamp = GetEventTime (eventRef) / kEventDurationMillisecond;
#else
timestamp = er.when * (1000 / 60); /* ticks to milliseconds */
#endif
-#if USE_CARBON_EVENTS
+#if TARGET_API_MAC_CARBON
/* Handle new events */
if (!mac_convert_event_ref (eventRef, &er))
{
read_socket_inev = NULL;
}
else
-#endif /* USE_CARBON_EVENTS */
+#endif /* TARGET_API_MAC_CARBON */
switch (er.what)
{
case mouseDown:
case mouseUp:
{
- WindowPtr window_ptr;
+ WindowRef window_ptr;
ControlPartCode part_code;
int tool_bar_p = 0;
-#if USE_CARBON_EVENTS
+#if TARGET_API_MAC_CARBON
/* This is needed to send mouse events like aqua window
buttons to the correct handler. */
if (SendEventToEventTarget (eventRef, toolbox_dispatcher)
else
{
ControlPartCode control_part_code;
- ControlHandle ch;
+ ControlRef ch;
Point mouse_loc = er.where;
#ifdef MAC_OSX
ControlKind control_kind;
&ch);
#endif
-#if USE_CARBON_EVENTS
+#if TARGET_API_MAC_CARBON
inev.code = mac_get_mouse_btn (eventRef);
inev.modifiers = mac_event_to_emacs_modifiers (eventRef);
#else
DragWindow (window_ptr, er.where, NULL);
#else /* not TARGET_API_MAC_CARBON */
DragWindow (window_ptr, er.where, &qd.screenBits.bounds);
-#endif /* not TARGET_API_MAC_CARBON */
/* Update the frame parameters. */
-#if !USE_CARBON_EVENTS
{
struct frame *f = mac_window_to_frame (window_ptr);
if (f && !f->async_iconified)
mac_handle_origin_change (f);
}
-#endif
+#endif /* not TARGET_API_MAC_CARBON */
break;
case inGoAway:
break;
case updateEvt:
-#if USE_CARBON_EVENTS
+#if TARGET_API_MAC_CARBON
if (SendEventToEventTarget (eventRef, toolbox_dispatcher)
!= eventNotHandledErr)
break;
#else
- do_window_update ((WindowPtr) er.message);
+ do_window_update ((WindowRef) er.message);
#endif
break;
case osEvt:
-#if USE_CARBON_EVENTS
+#if TARGET_API_MAC_CARBON
if (SendEventToEventTarget (eventRef, toolbox_dispatcher)
!= eventNotHandledErr)
break;
break;
case mouseMovedMessage:
-#if !USE_CARBON_EVENTS
+#if !TARGET_API_MAC_CARBON
SetRectRgn (mouse_region, er.where.h, er.where.v,
er.where.h + 1, er.where.v + 1);
#endif
if (f)
{
- WindowPtr wp = FRAME_MAC_WINDOW (f);
+ WindowRef wp = FRAME_MAC_WINDOW (f);
Point mouse_pos = er.where;
SetPortWindowPort (wp);
case activateEvt:
{
- WindowPtr window_ptr = (WindowPtr) er.message;
+ WindowRef window_ptr = (WindowRef) er.message;
-#if USE_CARBON_EVENTS
+#if TARGET_API_MAC_CARBON
if (SendEventToEventTarget (eventRef, toolbox_dispatcher)
!= eventNotHandledErr)
break;
SInt16 current_key_script;
UInt32 modifiers = er.modifiers, mapped_modifiers;
-#if USE_CARBON_EVENTS && defined (MAC_OSX)
+#ifdef MAC_OSX
GetEventParameter (eventRef, kEventParamKeyModifiers,
typeUInt32, NULL,
sizeof (UInt32), NULL, &modifiers);
#endif
mapped_modifiers = mac_mapped_modifiers (modifiers);
-#if USE_CARBON_EVENTS && (defined (MAC_OSX) || USE_MAC_TSM)
+#if defined (MAC_OSX) || USE_MAC_TSM
/* 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
default:
break;
}
-#if USE_CARBON_EVENTS
+#if TARGET_API_MAC_CARBON
ReleaseEvent (eventRef);
#endif
mac_screen_config_changed = 0;
}
-#if !USE_CARBON_EVENTS
+#if !TARGET_API_MAC_CARBON
/* Check which frames are still visible. We do this here because
there doesn't seem to be any direct notification from the Window
Manager that the visibility of a window has changed (at least,
if (!(FRAME_MAC_WINDOW (f) =
NewCWindow (NULL, &r, "\p", true, dBoxProc,
- (WindowPtr) -1, 1, (long) f->output_data.mac)))
+ (WindowRef) -1, 1, (long) f->output_data.mac)))
abort ();
/* so that update events can find this mac_output struct */
f->output_data.mac->mFP = f; /* point back to emacs frame */
&menu, &menu_index);
if (err == noErr)
SetMenuItemCommandKey (menu, menu_index, false, 0);
-#if USE_CARBON_EVENTS
EnableMenuCommand (NULL, kHICommandPreferences);
err = GetIndMenuItemWithCommandID (NULL, kHICommandPreferences, 1,
&menu, &menu_index);
InsertMenuItemTextWithCFString (menu, CFSTR ("About Emacs"),
0, 0, kHICommandAbout);
}
-#endif /* USE_CARBON_EVENTS */
#else /* !MAC_OSX */
-#if USE_CARBON_EVENTS
- SetMenuItemCommandID (GetMenuHandle (M_APPLE), I_ABOUT, kHICommandAbout);
+#if TARGET_API_MAC_CARBON
+ SetMenuItemCommandID (GetMenuRef (M_APPLE), I_ABOUT, kHICommandAbout);
#endif
#endif
}
#if TARGET_API_MAC_CARBON
-#if USE_CARBON_EVENTS
#ifdef MAC_OSX
init_service_handler ();
#endif /* MAC_OSX */
#if USE_MAC_TSM
init_tsm ();
#endif
-#endif /* USE_CARBON_EVENTS */
#ifdef MAC_OSX
init_coercion_handler ();
Fput (Qhyper, Qmodifier_value, make_number (hyper_modifier));
Fput (Qsuper, Qmodifier_value, make_number (super_modifier));
-#if USE_CARBON_EVENTS
+#if TARGET_API_MAC_CARBON
Qhi_command = intern ("hi-command"); staticpro (&Qhi_command);
#ifdef MAC_OSX
Qtoolbar_switch_mode = intern ("toolbar-switch-mode");
mouse-3 and the command-key will register for mouse-2. */);
Vmac_emulate_three_button_mouse = Qnil;
-#if USE_CARBON_EVENTS
+#if TARGET_API_MAC_CARBON
DEFVAR_BOOL ("mac-wheel-button-is-mouse-2", &mac_wheel_button_is_mouse_2,
doc: /* *Non-nil if the wheel button is mouse-2 and the right click mouse-3.
Otherwise, the right click will be treated as mouse-2 and the wheel