/* Display module for Mac OS.
Copyright (C) 2000, 2001, 2002, 2003, 2004,
- 2005, 2006 Free Software Foundation, Inc.
+ 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
This file is part of GNU Emacs.
GNU Emacs is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
+the Free Software Foundation; either version 3, or (at your option)
any later version.
GNU Emacs is distributed in the hope that it will be useful,
#include "frame.h"
#define RGB_TO_ULONG(r, g, b) (((r) << 16) | ((g) << 8) | (b))
+#define ARGB_TO_ULONG(a, r, g, b) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
-#define RED_FROM_ULONG(color) ((color) >> 16)
+#define ALPHA_FROM_ULONG(color) ((color) >> 24)
+#define RED_FROM_ULONG(color) (((color) >> 16) & 0xff)
#define GREEN_FROM_ULONG(color) (((color) >> 8) & 0xff)
#define BLUE_FROM_ULONG(color) ((color) & 0xff)
#define FONT_BASE(f) ((f)->ascent)
#define FONT_DESCENT(f) ((f)->descent)
-#define FONT_MAX_WIDTH(f) FONT_WIDTH(f) /* fix later */
-
/* Structure recording bitmaps and reference count.
If REFCOUNT is 0 then this record is free to be reused. */
char *mac_id_name;
/* The number of fonts actually stored in the font table.
- font_table[n] is used and valid iff 0 <= n < n_fonts. 0 <=
+ font_table[n] is used and valid if 0 <= n < n_fonts. 0 <=
n_fonts <= font_table_size and font_table[i].name != 0. */
int n_fonts;
FONT-LIST-CACHE records previous values returned by x-list-fonts. */
extern Lisp_Object x_display_name_list;
-extern struct x_display_info *x_display_info_for_display P_ ((Display *));
extern struct x_display_info *x_display_info_for_name P_ ((Lisp_Object));
extern struct mac_display_info *mac_term_init P_ ((Lisp_Object, char *, char *));
};
/* The collection of data describing a window on the Mac. */
-struct mac_output {
+struct mac_output
+{
/* Placeholder for things accessed through output_data.x. Must
appear first. */
struct x_output x_compatible;
/* Nonzero means tried already to make this frame visible. */
char asked_for_visible;
- /* Nonzero means menubar is currently active. */
- char menubar_active;
-
/* Relief GCs, colors etc. */
struct relief
{
They are changed only when a different background is involved. */
unsigned long relief_background;
+ /* Width of the internal border. */
+ int internal_border_width;
+
/* Hints for the size and the position of a window. */
XSizeHints *size_hints;
-#if TARGET_API_MAC_CARBON
- /* File name for the proxy icon of this frame. Might be NULL. */
- char *file_name;
+#if USE_MAC_TOOLBAR
+ /* This variable records the gravity value of the window position if
+ the window has an external tool bar when it is created. The
+ position of the window is adjusted using this information when
+ the tool bar is first redisplayed. Once the tool bar is
+ redisplayed, it is set to 0 in order to avoid further
+ adjustment. */
+ int toolbar_win_gravity;
#endif
#if USE_CG_DRAWING
#define FRAME_SIZE_HINTS(f) ((f)->output_data.mac->size_hints)
-#define FRAME_FILE_NAME(f) ((f)->output_data.mac->file_name)
-
/* This gives the mac_display_info structure for the display F is on. */
#define FRAME_MAC_DISPLAY_INFO(f) (&one_mac_display_info)
#define FRAME_X_DISPLAY_INFO(f) (&one_mac_display_info)
/* The next and previous in the chain of scroll bars in this frame. */
Lisp_Object next, prev;
- /* The Mac control handle of this scroll bar. Since this is a full
- 32-bit quantity, we store it split into two 32-bit values. */
- Lisp_Object control_handle_low, control_handle_high;
+ /* The Mac control reference of this scroll bar. Since this is a
+ pointer value, we store it split into two Lisp integers. */
+ Lisp_Object control_ref_low, control_ref_high;
/* The position and size of the scroll bar in pixels, relative to the
frame. */
/* If the scroll bar handle is currently being dragged by the user,
this is the number of pixels from the top of the handle to the
- place where the user grabbed it. If the handle isn't currently
+ place where the user grabbed it. If the handle is pressed but
+ not dragged yet, this is a negative integer whose absolute value
+ is the number of pixels plus 1. If the handle isn't currently
being dragged, this is Qnil. */
Lisp_Object dragging;
+#ifdef MAC_OSX
+ /* t if the background of the fringe that is adjacent to a scroll
+ bar is extended to the gap between the fringe and the bar. */
+ Lisp_Object fringe_extended_p;
+#endif
+
+ /* t if redraw needed in the next XTset_vertical_scroll_bar call. */
+ Lisp_Object redraw_needed_p;
+
#ifdef USE_TOOLKIT_SCROLL_BARS
/* The position and size of the scroll bar handle track area in
pixels, relative to the frame. */
Lisp_Object track_top, track_height;
+
+ /* Minimum length of the scroll bar handle, in pixels. */
+ Lisp_Object min_handle;
#endif
};
#define XSCROLL_BAR(vec) ((struct scroll_bar *) XVECTOR (vec))
-/* Building a 32-bit C integer from two 16-bit lisp integers. */
+/* Building a C long integer from two lisp integers. */
#define SCROLL_BAR_PACK(low, high) (XINT (high) << 16 | XINT (low))
-/* Setting two lisp integers to the low and high words of a 32-bit C int. */
-#define SCROLL_BAR_UNPACK(low, high, int32) \
- (XSETINT ((low), (int32) & 0xffff), \
- XSETINT ((high), ((int32) >> 16) & 0xffff))
+/* Setting two lisp integers to two parts of a C unsigned long. */
+#define SCROLL_BAR_UNPACK(low, high, ulong) \
+ (XSETINT ((low), (ulong) & 0xffff), \
+ XSETINT ((high), (ulong) >> 16))
/* Extract the Mac control handle of the scroll bar from a struct
scroll_bar. */
-#define SCROLL_BAR_CONTROL_HANDLE(ptr) \
- ((ControlHandle) SCROLL_BAR_PACK ((ptr)->control_handle_low, \
- (ptr)->control_handle_high))
+#define SCROLL_BAR_CONTROL_REF(ptr) \
+ ((ControlRef) SCROLL_BAR_PACK ((ptr)->control_ref_low, \
+ (ptr)->control_ref_high))
/* Store a Mac control handle in a struct scroll_bar. */
-#define SET_SCROLL_BAR_CONTROL_HANDLE(ptr, id) \
- (SCROLL_BAR_UNPACK ((ptr)->control_handle_low, \
- (ptr)->control_handle_high, (int) id))
+#define SET_SCROLL_BAR_CONTROL_REF(ptr, ref) \
+ (SCROLL_BAR_UNPACK ((ptr)->control_ref_low, \
+ (ptr)->control_ref_high, (unsigned long) (ref)))
/* Return the inside width of a vertical scroll bar, given the outside
width. */
#define MAC_AQUA_SMALL_VERTICAL_SCROLL_BAR_WIDTH (11)
/* Size of hourglass controls */
-#define HOURGLASS_WIDTH 16
-#define HOURGLASS_HEIGHT 16
+#define HOURGLASS_WIDTH (15)
+#define HOURGLASS_HEIGHT (15)
+
+/* Some constants that are used locally. */
+/* Creator code for Emacs on Mac OS. */
+enum {
+ MAC_EMACS_CREATOR_CODE = 'EMAx'
+};
+
+/* Apple event descriptor types */
+enum {
+ TYPE_FILE_NAME = 'fNam'
+};
+
+/* Keywords for Apple event attributes */
+enum {
+ KEY_EMACS_SUSPENSION_ID_ATTR = 'esId' /* typeUInt32 */
+};
+
+/* Carbon event parameter names. */
+enum {
+ EVENT_PARAM_TEXT_INPUT_SEQUENCE_NUMBER = 'tsSn' /* typeUInt32 */
+};
+
+/* Some constants that are not defined in older versions. */
+#if MAC_OS_X_VERSION_MAX_ALLOWED < 1030
+/* Keywords for Apple event attributes */
+enum {
+ keyReplyRequestedAttr = 'repq'
+};
+#endif
+
+#if 0
+/* We can't determine the availability of these enumerators by
+ MAC_OS_X_VERSION_MAX_ALLOWED, because they are defined in
+ MacOSX10.3.9.sdk for Mac OS X 10.4, but not in Mac OS X 10.3. */
+#if MAC_OS_X_VERSION_MAX_ALLOWED < 1040
+/* Gestalt selectors */
+enum {
+ gestaltSystemVersionMajor = 'sys1',
+ gestaltSystemVersionMinor = 'sys2',
+ gestaltSystemVersionBugFix = 'sys3'
+};
+#endif
+#endif
+
+#ifdef MAC_OSX
+#if MAC_OS_X_VERSION_MAX_ALLOWED < 1020
+/* Apple event descriptor types */
+enum {
+ typeUTF8Text = 'utf8'
+};
+
+/* Carbon event parameter names */
+enum {
+ kEventParamWindowMouseLocation = 'wmou'
+};
+#endif
+#endif
struct frame;
struct face;
extern void x_set_window_size P_ ((struct frame *, int, int, int));
extern void x_set_mouse_position P_ ((struct frame *, int, int));
extern void x_set_mouse_pixel_position P_ ((struct frame *, int, int));
+extern void x_raise_frame P_ ((struct frame *));
+extern void x_lower_frame P_ ((struct frame *));
extern void x_make_frame_visible P_ ((struct frame *));
extern void x_make_frame_invisible P_ ((struct frame *));
extern void x_iconify_frame P_ ((struct frame *));
extern void x_wm_set_size_hint P_ ((struct frame *, long, int));
extern void x_delete_display P_ ((struct x_display_info *));
extern void mac_initialize P_ ((void));
-extern Pixmap XCreatePixmap P_ ((Display *, WindowPtr, unsigned int,
+extern Pixmap XCreatePixmap P_ ((Display *, Window, unsigned int,
unsigned int, unsigned int));
-extern Pixmap XCreatePixmapFromBitmapData P_ ((Display *, WindowPtr, char *,
+extern Pixmap XCreatePixmapFromBitmapData P_ ((Display *, Window, char *,
unsigned int, unsigned int,
unsigned long, unsigned long,
unsigned int));
extern void XFreePixmap P_ ((Display *, Pixmap));
-extern GC XCreateGC P_ ((Display *, Window, unsigned long, XGCValues *));
+extern GC XCreateGC P_ ((Display *, void *, unsigned long, XGCValues *));
extern void XFreeGC P_ ((Display *, GC));
extern void XSetForeground P_ ((Display *, GC, unsigned long));
extern void XSetBackground P_ ((Display *, GC, unsigned long));
-extern void XSetWindowBackground P_ ((Display *, WindowPtr, unsigned long));
-extern void mac_draw_line_to_pixmap P_ ((Display *, Pixmap, GC, int, int,
- int, int));
+extern void XDrawLine P_ ((Display *, Pixmap, GC, int, int, int, int));
extern void mac_clear_area P_ ((struct frame *, int, int,
unsigned int, unsigned int));
extern void mac_unload_font P_ ((struct mac_display_info *, XFontStruct *));
-extern OSStatus mac_set_font_info_for_selection P_ ((struct frame *, int, int));
-extern OSErr install_window_handler P_ ((WindowPtr));
-extern void remove_window_handler P_ ((WindowPtr));
-extern void do_menu_choice P_ ((SInt32));
extern OSStatus mac_post_mouse_moved_event P_ ((void));
-#if USE_CG_DRAWING
-extern void mac_prepare_for_quickdraw P_ ((struct frame *));
-#endif
+extern int mac_quit_char_key_p P_ ((UInt32, UInt32));
#define FONT_TYPE_FOR_UNIBYTE(font, ch) 0
#define FONT_TYPE_FOR_MULTIBYTE(font, ch) 0
-#define TYPE_FILE_NAME 'fNam'
+#if USE_MAC_IMAGE_IO
+extern CGColorSpaceRef mac_cg_color_space_rgb;
+#endif
/* Defined in macselect.c */
extern void x_clear_frame_selections P_ ((struct frame *));
+EXFUN (Fx_selection_owner_p, 1);
/* Defined in macfns.c */
extern void x_sync P_ ((struct frame *));
extern void x_set_tool_bar_lines P_ ((struct frame *, Lisp_Object, Lisp_Object));
extern void mac_update_title_bar P_ ((struct frame *, int));
-
-/* Defined in macmenu.c */
-
-extern void x_activate_menubar P_ ((struct frame *));
-extern void free_frame_menubar P_ ((struct frame *));
+extern Lisp_Object x_get_focus_frame P_ ((struct frame *));
/* Defined in mac.c. */
extern void mac_clear_font_name_table P_ ((void));
extern Lisp_Object mac_aedesc_to_lisp P_ ((const AEDesc *));
+extern OSErr mac_ae_put_lisp P_ ((AEDescList *, UInt32, Lisp_Object));
#if TARGET_API_MAC_CARBON
-extern OSErr create_apple_event_from_event_ref P_ ((EventRef, UInt32,
- EventParamName *,
- EventParamType *,
- AppleEvent *));
-extern OSErr create_apple_event_from_drag_ref P_ ((DragRef, UInt32,
- FlavorType *,
- AppleEvent *));
+extern OSErr create_apple_event P_ ((AEEventClass, AEEventID, AppleEvent *));
+extern Lisp_Object mac_event_parameters_to_lisp P_ ((EventRef, UInt32,
+ const EventParamName *,
+ const EventParamType *));
extern CFStringRef cfstring_create_with_utf8_cstring P_ ((const char *));
extern CFStringRef cfstring_create_with_string P_ ((Lisp_Object));
extern Lisp_Object cfdata_to_lisp P_ ((CFDataRef));
extern Lisp_Object cfboolean_to_lisp P_ ((CFBooleanRef));
extern Lisp_Object cfobject_desc_to_lisp P_ ((CFTypeRef));
extern Lisp_Object cfproperty_list_to_lisp P_ ((CFPropertyListRef, int, int));
+extern void mac_wakeup_from_rne P_ ((void));
#endif
-extern void xrm_merge_string_database P_ ((XrmDatabase, char *));
-extern Lisp_Object xrm_get_resource P_ ((XrmDatabase, char *, char *));
-extern XrmDatabase xrm_get_preference_database P_ ((char *));
+extern void xrm_merge_string_database P_ ((XrmDatabase, const char *));
+extern Lisp_Object xrm_get_resource P_ ((XrmDatabase, const char *,
+ const char *));
+extern XrmDatabase xrm_get_preference_database P_ ((const char *));
EXFUN (Fmac_get_preference, 4);
+/* Defined in mactoolbox.c. */
+
+extern void mac_alert_sound_play P_ ((void));
+extern OSStatus install_application_handler P_ ((void));
+extern void mac_get_window_bounds P_ ((struct frame *, Rect *, Rect *));
+extern Rect *mac_get_frame_bounds P_ ((struct frame *, Rect *));
+extern void mac_get_frame_mouse P_ ((struct frame *, Point *));
+extern void mac_convert_frame_point_to_global P_ ((struct frame *, int *,
+ int *));
+#if TARGET_API_MAC_CARBON
+extern void mac_update_proxy_icon P_ ((struct frame *));
+#endif
+extern void mac_set_frame_window_background P_ ((struct frame *,
+ unsigned long));
+extern void mac_update_begin P_ ((struct frame *));
+extern void mac_update_end P_ ((struct frame *));
+extern void mac_frame_up_to_date P_ ((struct frame *));
+extern void x_flush P_ ((struct frame *));
+extern void mac_create_frame_window P_ ((struct frame *, int));
+extern void mac_dispose_frame_window P_ ((struct frame *));
+#if USE_CG_DRAWING
+extern CGContextRef mac_begin_cg_clip P_ ((struct frame *, GC));
+extern void mac_end_cg_clip P_ ((struct frame *));
+#endif
+extern void mac_begin_clip P_ ((struct frame *, GC));
+extern void mac_end_clip P_ ((struct frame *, GC));
+extern void mac_create_scroll_bar P_ ((struct scroll_bar *, const Rect *,
+ Boolean));
+extern void mac_dispose_scroll_bar P_ ((struct scroll_bar *));
+extern void mac_set_scroll_bar_bounds P_ ((struct scroll_bar *, const Rect *));
+extern void mac_redraw_scroll_bar P_ ((struct scroll_bar *));
+#ifdef USE_TOOLKIT_SCROLL_BARS
+extern void x_set_toolkit_scroll_bar_thumb P_ ((struct scroll_bar *,
+ int, int, int));
+#else
+extern void x_scroll_bar_set_handle P_ ((scroll_bar *, int, int, int));
+#endif
+#if USE_MAC_FONT_PANEL
+extern int mac_font_panel_visible_p P_ ((void));
+extern OSStatus mac_show_hide_font_panel P_ ((void));
+extern OSStatus mac_set_font_info_for_selection P_ ((struct frame *, int, int));
+#endif
+#ifdef MAC_OSX
+extern Boolean mac_run_loop_run_once P_ ((EventTimeout));
+#endif
+#if USE_MAC_TOOLBAR
+extern void update_frame_tool_bar P_ ((FRAME_PTR f));
+extern void free_frame_tool_bar P_ ((FRAME_PTR f));
+#endif
+#if TARGET_API_MAC_CARBON
+extern void mac_show_hourglass P_ ((struct frame *));
+extern void mac_hide_hourglass P_ ((struct frame *));
+extern void mac_reposition_hourglass P_ ((struct frame *));
+extern Lisp_Object mac_file_dialog P_ ((Lisp_Object, Lisp_Object, Lisp_Object,
+ Lisp_Object, Lisp_Object));
+#endif
+extern void x_activate_menubar P_ ((struct frame *));
+extern void free_frame_menubar P_ ((struct frame *));
+extern void mac_fill_menubar P_ ((widget_value *, int));
+extern void create_and_show_popup_menu P_ ((FRAME_PTR, widget_value *,
+ int, int, int));
+#if TARGET_API_MAC_CARBON
+extern void create_and_show_dialog P_ ((FRAME_PTR, widget_value *));
+#else
+extern int mac_dialog P_ ((widget_value *));
+#endif
+extern OSStatus mac_get_selection_from_symbol P_ ((Lisp_Object, int,
+ Selection *));
+extern int mac_valid_selection_target_p P_ ((Lisp_Object));
+extern OSStatus mac_clear_selection P_ ((Selection *));
+extern Lisp_Object mac_get_selection_ownership_info P_ ((Selection));
+extern int mac_valid_selection_value_p P_ ((Lisp_Object, Lisp_Object));
+extern OSStatus mac_put_selection_value P_ ((Selection, Lisp_Object,
+ Lisp_Object));
+extern int mac_selection_has_target_p P_ ((Selection, Lisp_Object));
+extern Lisp_Object mac_get_selection_value P_ ((Selection, Lisp_Object));
+extern Lisp_Object mac_get_selection_target_list P_ ((Selection));
+#if TARGET_API_MAC_CARBON
+extern Lisp_Object mac_dnd_default_known_types P_ ((void));
+#endif
+
/* arch-tag: 6b4ca125-5bef-476d-8ee8-31ed808b7e79
(do not change this comment) */