summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog73
-rw-r--r--src/editfns.c38
-rw-r--r--src/gtkutil.c80
-rw-r--r--src/gtkutil.h2
-rw-r--r--src/indent.c19
-rw-r--r--src/mac.c8
-rw-r--r--src/macgui.h8
-rw-r--r--src/macmenu.c78
-rw-r--r--src/macterm.c170
-rw-r--r--src/macterm.h5
-rw-r--r--src/minibuf.c2
-rw-r--r--src/window.c3
12 files changed, 397 insertions, 89 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 3dc5a094d4a..97c9d4cbeb9 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,76 @@
+2007-01-05 Kim F. Storm <storm@cua.dk>
+
+ * indent.c (Fvertical_motion): Fix it overshoot check for overlay
+ strings without embedded newlines immediately followed by newline.
+
+2007-01-05 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
+
+ * editfns.c (Fformat_time_string, Fdecode_time, Fencode_time)
+ (Fcurrent_time_string, Fcurrent_time_zone): Add BLOCK_INPUT around
+ gmtime/localtime/emacs_memftimeu/mktime.
+
+ * mac.c (Fmac_set_file_creator): Use MAC_EMACS_CREATOR_CODE
+ instead of 'EMAx'.
+ [!MAC_OSX] (sys_open, sys_creat, sys_fopen): Likewise.
+
+ * macgui.h (struct _XGC) [USE_CG_DRAWING
+ && MAC_OS_X_VERSION_MAX_ALLOWED >= 1030]: New members cg_fore_color
+ and cg_back_color.
+
+ * macmenu.c (Vshow_help_function) [TARGET_API_MAC_CARBON]: Add extern.
+ (restore_show_help_function, menu_target_item_handler)
+ [TARGET_API_MAC_CARBON]: New functions.
+ (install_menu_target_item_handler): New function.
+ (add_menu_item) [TARGET_API_MAC_CARBON]: Set help string as menu
+ item property.
+
+ * macterm.c (CG_SET_FILL_COLOR_MAYBE_WITH_CGCOLOR)
+ (CG_SET_FILL_COLOR_WITH_GC_FOREGROUND)
+ (CG_SET_FILL_COLOR_WITH_GC_BACKGROUND)
+ (CG_SET_STROKE_COLOR_MAYBE_WITH_CGCOLOR)
+ (CG_SET_STROKE_COLOR_WITH_GC_FOREGROUND): New macros.
+ (mac_cg_color_space_rgb) [USE_CG_DRAWING]: New variable.
+ (mac_cg_color_black) [USE_CG_DRAWING
+ && MAC_OS_X_VERSION_MAX_ALLOWED >= 1030]: New variable.
+ (init_cg_color) [USE_CG_DRAWING]: New function.
+ (mac_draw_line, mac_draw_rectangle) [USE_CG_DRAWING]: Use
+ CG_SET_STROKE_COLOR_WITH_GC_FOREGROUND instead of CG_SET_STROKE_COLOR.
+ (mac_erase_rectangle, mac_clear_window, mac_draw_cg_image)
+ (mac_fill_rectangle, mac_draw_image_string_cg) [USE_CG_DRAWING]:
+ Use CG_SET_FILL_COLOR_WITH_GC_FOREGROUND or
+ CG_SET_FILL_COLOR_WITH_GC_BACKGROUND instead of CG_SET_FILL_COLOR.
+ (mac_draw_string_common) [MAC_OSX && USE_ATSUI]: Likewise.
+ (XCreateGC, XFreeGC, XSetForeground, XSetBackground) [USE_CG_DRAWING
+ && MAC_OS_X_VERSION_MAX_ALLOWED >= 1030]: Use gc->cg_fore_color and/or
+ gc->cg_back_color.
+ (install_drag_handler, remove_drag_handler): Make extern.
+ (install_menu_target_item_handler): Add extern.
+ (install_window_handler): Call install_menu_target_item_handler.
+ [MAC_OS8] (main): Use MAC_EMACS_CREATOR_CODE instead of 'EMAx'.
+ (mac_initialize) [USE_CG_DRAWING]: Call init_cg_color.
+
+ * macterm.h (MAC_EMACS_CREATOR_CODE): New enumerator.
+
+2007-01-04 Juanma Barranquero <lekktu@gmail.com>
+
+ * window.c (Fwindow_end): Fix use of >= operator.
+
+2007-01-03 Richard Stallman <rms@gnu.org>
+
+ * window.c (Fwindow_end): Check BUF_OVERLAY_MODIFF like BUF_MODIFF.
+
+2007-01-02 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
+
+ * gtkutil.h (xg_menu_item_cb_data_): Remove highlight_id and
+ unhighlight_id.
+
+ * gtkutil.c (menuitem_highlight_callback): Invoked widget is the
+ parent of the menu item. Get menu item widget from event.
+ (xg_create_one_menuitem, xg_update_menu_item): highlight_id and
+ unhighlight_id has been removed.
+ (create_menus): Connect enter/leave-notify-event to the menu instead
+ of individual items.
+
2006-12-31 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
* gtkutil.c (update_frame_tool_bar): Connect create-menu-proxy with
diff --git a/src/editfns.c b/src/editfns.c
index 39f8f87c673..6089ee9a2e2 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -1678,7 +1678,9 @@ For example, to produce full ISO 8601 format, use "%Y-%m-%dT%T%z". */)
/* This is probably enough. */
size = SBYTES (format_string) * 6 + 50;
+ BLOCK_INPUT;
tm = ut ? gmtime (&value) : localtime (&value);
+ UNBLOCK_INPUT;
if (! tm)
error ("Specified time is not representable");
@@ -1690,18 +1692,22 @@ For example, to produce full ISO 8601 format, use "%Y-%m-%dT%T%z". */)
int result;
buf[0] = '\1';
+ BLOCK_INPUT;
result = emacs_memftimeu (buf, size, SDATA (format_string),
SBYTES (format_string),
tm, ut);
+ UNBLOCK_INPUT;
if ((result > 0 && result < size) || (result == 0 && buf[0] == '\0'))
return code_convert_string_norecord (make_unibyte_string (buf, result),
Vlocale_coding_system, 0);
/* If buffer was too small, make it bigger and try again. */
+ BLOCK_INPUT;
result = emacs_memftimeu (NULL, (size_t) -1,
SDATA (format_string),
SBYTES (format_string),
tm, ut);
+ UNBLOCK_INPUT;
size = result + 1;
}
}
@@ -1732,7 +1738,9 @@ DOW and ZONE.) */)
if (! lisp_time_argument (specified_time, &time_spec, NULL))
error ("Invalid time specification");
+ BLOCK_INPUT;
decoded_time = localtime (&time_spec);
+ UNBLOCK_INPUT;
if (! decoded_time)
error ("Specified time is not representable");
XSETFASTINT (list_args[0], decoded_time->tm_sec);
@@ -1748,7 +1756,9 @@ DOW and ZONE.) */)
/* Make a copy, in case gmtime modifies the struct. */
save_tm = *decoded_time;
+ BLOCK_INPUT;
decoded_time = gmtime (&time_spec);
+ UNBLOCK_INPUT;
if (decoded_time == 0)
list_args[8] = Qnil;
else
@@ -1804,7 +1814,11 @@ usage: (encode-time SECOND MINUTE HOUR DAY MONTH YEAR &optional ZONE) */)
if (CONSP (zone))
zone = Fcar (zone);
if (NILP (zone))
- time = mktime (&tm);
+ {
+ BLOCK_INPUT;
+ time = mktime (&tm);
+ UNBLOCK_INPUT;
+ }
else
{
char tzbuf[100];
@@ -1829,7 +1843,9 @@ usage: (encode-time SECOND MINUTE HOUR DAY MONTH YEAR &optional ZONE) */)
value doesn't suffice, since that would mishandle leap seconds. */
set_time_zone_rule (tzstring);
+ BLOCK_INPUT;
time = mktime (&tm);
+ UNBLOCK_INPUT;
/* Restore TZ to previous value. */
newenv = environ;
@@ -1873,7 +1889,9 @@ but this is considered obsolete. */)
/* Convert to a string, checking for out-of-range time stamps.
Don't use 'ctime', as that might dump core if VALUE is out of
range. */
+ BLOCK_INPUT;
tm = localtime (&value);
+ UNBLOCK_INPUT;
if (! (tm && TM_YEAR_IN_ASCTIME_RANGE (tm->tm_year) && (tem = asctime (tm))))
error ("Specified time is not representable");
@@ -1929,9 +1947,21 @@ the data it can't find. */)
struct tm *t;
struct tm gmt;
- if (lisp_time_argument (specified_time, &value, NULL)
- && (t = gmtime (&value)) != 0
- && (gmt = *t, t = localtime (&value)) != 0)
+ if (!lisp_time_argument (specified_time, &value, NULL))
+ t = NULL;
+ else
+ {
+ BLOCK_INPUT;
+ t = gmtime (&value);
+ if (t)
+ {
+ gmt = *t;
+ t = localtime (&value);
+ }
+ UNBLOCK_INPUT;
+ }
+
+ if (t)
{
int offset = tm_diff (t, &gmt);
char *s = 0;
diff --git a/src/gtkutil.c b/src/gtkutil.c
index d136dbe0fce..d57a0b56c0c 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -1718,9 +1718,9 @@ menuitem_destroy_callback (w, client_data)
}
/* Callback called when the pointer enters/leaves a menu item.
- W is the menu item.
+ W is the parent of the menu item.
EVENT is either an enter event or leave event.
- CLIENT_DATA points to the xg_menu_item_cb_data associated with the W.
+ CLIENT_DATA is not used.
Returns FALSE to tell GTK to keep processing this event. */
@@ -1730,15 +1730,21 @@ menuitem_highlight_callback (w, event, client_data)
GdkEventCrossing *event;
gpointer client_data;
{
- if (client_data)
- {
- xg_menu_item_cb_data *data = (xg_menu_item_cb_data*) client_data;
- gpointer call_data = event->type == GDK_LEAVE_NOTIFY ? 0 : client_data;
+ GdkEvent ev;
+ GtkWidget *subwidget;
+ xg_menu_item_cb_data *data;
+ ev.crossing = *event;
+ subwidget = gtk_get_event_widget (&ev);
+ data = (xg_menu_item_cb_data *) g_object_get_data (G_OBJECT (subwidget),
+ XG_ITEM_DATA);
+ if (data)
+ {
if (! NILP (data->help) && data->cl_data->highlight_cb)
{
+ gpointer call_data = event->type == GDK_LEAVE_NOTIFY ? 0 : data;
GtkCallback func = (GtkCallback) data->cl_data->highlight_cb;
- (*func) (w, call_data);
+ (*func) (subwidget, call_data);
}
}
@@ -2004,7 +2010,7 @@ xg_create_one_menuitem (item, f, select_cb, highlight_cb, cl_data, group)
xg_list_insert (&xg_menu_item_cb_list, &cb_data->ptrs);
- cb_data->unhighlight_id = cb_data->highlight_id = cb_data->select_id = 0;
+ cb_data->select_id = 0;
cb_data->help = item->help;
cb_data->cl_data = cl_data;
cb_data->call_data = item->call_data;
@@ -2025,22 +2031,6 @@ xg_create_one_menuitem (item, f, select_cb, highlight_cb, cl_data, group)
= g_signal_connect (G_OBJECT (w), "activate", select_cb, cb_data);
}
- if (! NILP (item->help) && highlight_cb)
- {
- /* We use enter/leave notify instead of select/deselect because
- select/deselect doesn't go well with detached menus. */
- cb_data->highlight_id
- = g_signal_connect (G_OBJECT (w),
- "enter-notify-event",
- G_CALLBACK (menuitem_highlight_callback),
- cb_data);
- cb_data->unhighlight_id
- = g_signal_connect (G_OBJECT (w),
- "leave-notify-event",
- G_CALLBACK (menuitem_highlight_callback),
- cb_data);
- }
-
return w;
}
@@ -2123,6 +2113,17 @@ create_menus (data, f, select_cb, deactivate_cb, highlight_cb,
{
wmenu = gtk_menu_new ();
xg_set_screen (wmenu, f);
+ /* Connect this to the menu instead of items so we get enter/leave for
+ disabled items also. TODO: Still does not get enter/leave for
+ disabled items in detached menus. */
+ g_signal_connect (G_OBJECT (wmenu),
+ "enter-notify-event",
+ G_CALLBACK (menuitem_highlight_callback),
+ NULL);
+ g_signal_connect (G_OBJECT (wmenu),
+ "leave-notify-event",
+ G_CALLBACK (menuitem_highlight_callback),
+ NULL);
}
else wmenu = gtk_menu_bar_new ();
@@ -2619,37 +2620,6 @@ xg_update_menu_item (val, w, select_cb, highlight_cb, cl_data)
g_signal_handler_disconnect (w, cb_data->select_id);
cb_data->select_id = 0;
}
-
- if (NILP (cb_data->help))
- {
- /* Shall not have help. Remove if any existed previously. */
- if (cb_data->highlight_id)
- {
- g_signal_handler_disconnect (G_OBJECT (w),
- cb_data->highlight_id);
- cb_data->highlight_id = 0;
- }
- if (cb_data->unhighlight_id)
- {
- g_signal_handler_disconnect (G_OBJECT (w),
- cb_data->unhighlight_id);
- cb_data->unhighlight_id = 0;
- }
- }
- else if (! cb_data->highlight_id && highlight_cb)
- {
- /* Have help now, but didn't previously. Add callback. */
- cb_data->highlight_id
- = g_signal_connect (G_OBJECT (w),
- "enter-notify-event",
- G_CALLBACK (menuitem_highlight_callback),
- cb_data);
- cb_data->unhighlight_id
- = g_signal_connect (G_OBJECT (w),
- "leave-notify-event",
- G_CALLBACK (menuitem_highlight_callback),
- cb_data);
- }
}
}
diff --git a/src/gtkutil.h b/src/gtkutil.h
index 742e3ecb1e5..c3957223a18 100644
--- a/src/gtkutil.h
+++ b/src/gtkutil.h
@@ -79,8 +79,6 @@ typedef struct xg_menu_item_cb_data_
{
xg_list_node ptrs;
- gulong highlight_id;
- gulong unhighlight_id;
gulong select_id;
Lisp_Object help;
gpointer call_data;
diff --git a/src/indent.c b/src/indent.c
index e84059972f3..af556bc38e3 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -2076,7 +2076,7 @@ whether or not it is currently displayed in some window. */)
{
int it_start;
int oselective;
- int it_overshoot_expected_p;
+ int it_overshoot_expected;
SET_TEXT_POS (pt, PT, PT_BYTE);
start_display (&it, w, pt);
@@ -2102,12 +2102,16 @@ whether or not it is currently displayed in some window. */)
while (s < e && *s != '\n')
++s;
- it_overshoot_expected_p = (s == e);
+ /* If there is no newline in the string, we need to check
+ whether there is a newline immediately after the string
+ in move_it_to below. This may happen if there is an
+ overlay with an after-string just before the newline. */
+ it_overshoot_expected = (s == e) ? -1 : 0;
}
else
- it_overshoot_expected_p = (it.method == GET_FROM_IMAGE
- || it.method == GET_FROM_STRETCH
- || it.method == GET_FROM_COMPOSITION);
+ it_overshoot_expected = (it.method == GET_FROM_IMAGE
+ || it.method == GET_FROM_STRETCH
+ || it.method == GET_FROM_COMPOSITION);
reseat_at_previous_visible_line_start (&it);
it.current_x = it.hpos = 0;
@@ -2121,7 +2125,10 @@ whether or not it is currently displayed in some window. */)
truncate-lines is on and PT is beyond right margin.
Don't go back if the overshoot is expected (see above). */
if (IT_CHARPOS (it) > it_start && XINT (lines) > 0
- && !it_overshoot_expected_p)
+ && (!it_overshoot_expected
+ || (it_overshoot_expected < 0
+ && it.method == GET_FROM_BUFFER
+ && it.c == '\n')))
move_it_by_lines (&it, -1, 0);
it.vpos = 0;
diff --git a/src/mac.c b/src/mac.c
index 7a08d828725..d834bfb8de4 100644
--- a/src/mac.c
+++ b/src/mac.c
@@ -2261,7 +2261,7 @@ sys_open (const char *path, int oflag)
int res = open (mac_pathname, oflag);
/* if (oflag == O_WRONLY || oflag == O_RDWR) */
if (oflag & O_CREAT)
- fsetfileinfo (mac_pathname, 'EMAx', 'TEXT');
+ fsetfileinfo (mac_pathname, MAC_EMACS_CREATOR_CODE, 'TEXT');
return res;
#else /* not __MRC__ */
return open (mac_pathname, oflag);
@@ -2287,7 +2287,7 @@ sys_creat (const char *path, mode_t mode)
{
#ifdef __MRC__
int result = creat (mac_pathname);
- fsetfileinfo (mac_pathname, 'EMAx', 'TEXT');
+ fsetfileinfo (mac_pathname, MAC_EMACS_CREATOR_CODE, 'TEXT');
return result;
#else /* not __MRC__ */
return creat (mac_pathname, mode);
@@ -2415,7 +2415,7 @@ sys_fopen (const char *name, const char *mode)
{
#ifdef __MRC__
if (mode[0] == 'w' || mode[0] == 'a')
- fsetfileinfo (mac_pathname, 'EMAx', 'TEXT');
+ fsetfileinfo (mac_pathname, MAC_EMACS_CREATOR_CODE, 'TEXT');
#endif /* not __MRC__ */
return fopen (mac_pathname, mode);
}
@@ -4316,7 +4316,7 @@ assumed. Return non-nil if successful. */)
OSType cCode;
CHECK_STRING (filename);
- cCode = mac_get_code_from_arg(code, 'EMAx');
+ cCode = mac_get_code_from_arg(code, MAC_EMACS_CREATOR_CODE);
if (NILP(Ffile_exists_p(filename)) || !NILP(Ffile_directory_p(filename))) {
return Qnil;
diff --git a/src/macgui.h b/src/macgui.h
index 1ea53af59be..3a9913181de 100644
--- a/src/macgui.h
+++ b/src/macgui.h
@@ -244,6 +244,14 @@ typedef struct _XGC
/* QuickDraw background color. */
RGBColor back_color;
+#if USE_CG_DRAWING && MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
+ /* Quartz 2D foreground color. */
+ CGColorRef cg_fore_color;
+
+ /* Quartz 2D background color. */
+ CGColorRef cg_back_color;
+#endif
+
#define MAX_CLIP_RECTS 2
/* Number of clipping rectangles. */
int n_clip_rects;
diff --git a/src/macmenu.c b/src/macmenu.c
index 14bfe92cb25..9981250979a 100644
--- a/src/macmenu.c
+++ b/src/macmenu.c
@@ -1450,6 +1450,80 @@ update_submenu_strings (first_wv)
}
+#if TARGET_API_MAC_CARBON
+extern Lisp_Object Vshow_help_function;
+
+static Lisp_Object
+restore_show_help_function (old_show_help_function)
+ Lisp_Object old_show_help_function;
+{
+ Vshow_help_function = old_show_help_function;
+
+ return Qnil;
+}
+
+static pascal OSStatus
+menu_target_item_handler (next_handler, event, data)
+ EventHandlerCallRef next_handler;
+ EventRef event;
+ void *data;
+{
+ OSStatus err, result;
+ MenuRef menu;
+ MenuItemIndex menu_item;
+ Lisp_Object help;
+ GrafPtr port;
+ int specpdl_count = SPECPDL_INDEX ();
+
+ result = CallNextEventHandler (next_handler, event);
+
+ err = GetEventParameter (event, kEventParamDirectObject, typeMenuRef,
+ NULL, sizeof (MenuRef), NULL, &menu);
+ if (err == noErr)
+ err = GetEventParameter (event, kEventParamMenuItemIndex,
+ typeMenuItemIndex, NULL,
+ sizeof (MenuItemIndex), NULL, &menu_item);
+ if (err == noErr)
+ err = GetMenuItemProperty (menu, menu_item,
+ MAC_EMACS_CREATOR_CODE, 'help',
+ sizeof (Lisp_Object), NULL, &help);
+ if (err != noErr)
+ help = Qnil;
+
+ /* Temporarily bind Vshow_help_function to Qnil because we don't
+ want tooltips during menu tracking. */
+ record_unwind_protect (restore_show_help_function, Vshow_help_function);
+ Vshow_help_function = Qnil;
+ GetPort (&port);
+ show_help_echo (help, Qnil, Qnil, Qnil, 1);
+ SetPort (port);
+ unbind_to (specpdl_count, Qnil);
+
+ return err == noErr ? noErr : result;
+}
+#endif
+
+OSStatus
+install_menu_target_item_handler (window)
+ WindowPtr window;
+{
+ OSStatus err = noErr;
+#if TARGET_API_MAC_CARBON
+ static const EventTypeSpec specs[] =
+ {{kEventClassMenu, kEventMenuTargetItem}};
+ static EventHandlerUPP menu_target_item_handlerUPP = NULL;
+
+ if (menu_target_item_handlerUPP == NULL)
+ menu_target_item_handlerUPP =
+ NewEventHandlerUPP (menu_target_item_handler);
+
+ err = InstallWindowEventHandler (window, menu_target_item_handlerUPP,
+ GetEventTypeCount (specs), specs,
+ NULL, NULL);
+#endif
+ return err;
+}
+
/* Event handler function that pops down a menu on C-g. We can only pop
down menus if CancelMenuTracking is present (OSX 10.3 or later). */
@@ -2485,6 +2559,10 @@ add_menu_item (menu, pos, wv)
EnableMenuItem (menu, pos);
else
DisableMenuItem (menu, pos);
+
+ if (STRINGP (wv->help))
+ SetMenuItemProperty (menu, pos, MAC_EMACS_CREATOR_CODE, 'help',
+ sizeof (Lisp_Object), &wv->help);
#else /* ! TARGET_API_MAC_CARBON */
item_name[sizeof (item_name) - 1] = '\0';
strncpy (item_name, wv->name, sizeof (item_name) - 1);
diff --git a/src/macterm.c b/src/macterm.c
index 6eaf549ba85..7c3f036f1ba 100644
--- a/src/macterm.c
+++ b/src/macterm.c
@@ -270,16 +270,63 @@ static void XSetFont P_ ((Display *, GC, XFontStruct *));
#define GC_BACK_COLOR(gc) (&(gc)->back_color)
#define GC_FONT(gc) ((gc)->xgcv.font)
#define FRAME_NORMAL_GC(f) ((f)->output_data.mac->normal_gc)
-#define CG_SET_FILL_COLOR(context, color) \
+
+#define CG_SET_FILL_COLOR(context, color) \
CGContextSetRGBFillColor (context, \
RED_FROM_ULONG (color) / 255.0f, \
GREEN_FROM_ULONG (color) / 255.0f, \
BLUE_FROM_ULONG (color) / 255.0f, 1.0f)
-#define CG_SET_STROKE_COLOR(context, color) \
+#if USE_CG_DRAWING && MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
+#if MAC_OS_X_VERSION_MIN_REQUIRED == 1020
+#define CG_SET_FILL_COLOR_MAYBE_WITH_CGCOLOR(context, color, cg_color) \
+ do { \
+ if (CGColorGetTypeID != NULL) \
+ CGContextSetFillColorWithColor (context, cg_color); \
+ else \
+ CG_SET_FILL_COLOR (context, color); \
+ } while (0)
+#else
+#define CG_SET_FILL_COLOR_MAYBE_WITH_CGCOLOR(context, color, cg_color) \
+ CGContextSetFillColorWithColor (context, cg_color)
+#endif
+#else
+#define CG_SET_FILL_COLOR_MAYBE_WITH_CGCOLOR(context, color, cg_color) \
+ CG_SET_FILL_COLOR (context, color)
+#endif
+#define CG_SET_FILL_COLOR_WITH_GC_FOREGROUND(context, gc) \
+ CG_SET_FILL_COLOR_MAYBE_WITH_CGCOLOR (context, (gc)->xgcv.foreground, \
+ (gc)->cg_fore_color)
+#define CG_SET_FILL_COLOR_WITH_GC_BACKGROUND(context, gc) \
+ CG_SET_FILL_COLOR_MAYBE_WITH_CGCOLOR (context, (gc)->xgcv.background, \
+ (gc)->cg_back_color)
+
+
+#define CG_SET_STROKE_COLOR(context, color) \
CGContextSetRGBStrokeColor (context, \
RED_FROM_ULONG (color) / 255.0f, \
GREEN_FROM_ULONG (color) / 255.0f, \
BLUE_FROM_ULONG (color) / 255.0f, 1.0f)
+#if USE_CG_DRAWING && MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
+#if MAC_OS_X_VERSION_MIN_REQUIRED == 1020
+#define CG_SET_STROKE_COLOR_MAYBE_WITH_CGCOLOR(context, color, cg_color) \
+ do { \
+ if (CGColorGetTypeID != NULL) \
+ CGContextSetStrokeColorWithColor (context, cg_color); \
+ else \
+ CG_SET_STROKE_COLOR (context, color); \
+ } while (0)
+#else
+#define CG_SET_STROKE_COLOR_MAYBE_WITH_CGCOLOR(context, color, cg_color) \
+ CGContextSetStrokeColorWithColor (context, cg_color)
+#endif
+#else
+#define CG_SET_STROKE_COLOR_MAYBE_WITH_CGCOLOR(context, color, cg_color) \
+ CG_SET_STROKE_COLOR (context, color)
+#endif
+#define CG_SET_STROKE_COLOR_WITH_GC_FOREGROUND(context, gc) \
+ CG_SET_STROKE_COLOR_MAYBE_WITH_CGCOLOR (context, (gc)->xgcv.foreground, \
+ (gc)->cg_fore_color)
+
#if USE_CG_DRAWING
#define FRAME_CG_CONTEXT(f) ((f)->output_data.mac->cg_context)
@@ -288,6 +335,29 @@ static void XSetFont P_ ((Display *, GC, XFontStruct *));
static int max_fringe_bmp = 0;
static CGImageRef *fringe_bmp = 0;
+static CGColorSpaceRef mac_cg_color_space_rgb;
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
+static CGColorRef mac_cg_color_black;
+#endif
+
+static void
+init_cg_color ()
+{
+ mac_cg_color_space_rgb = CGColorSpaceCreateDeviceRGB ();
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
+#if MAC_OS_X_VERSION_MIN_REQUIRED == 1020
+ /* Don't check the availability of CGColorCreate; this symbol is
+ defined even in Mac OS X 10.1. */
+ if (CGColorGetTypeID != NULL)
+#endif
+ {
+ float rgba[] = {0.0f, 0.0f, 0.0f, 1.0f};
+
+ mac_cg_color_black = CGColorCreate (mac_cg_color_space_rgb, rgba);
+ }
+#endif
+}
+
static CGContextRef
mac_begin_cg_clip (f, gc)
struct frame *f;
@@ -401,7 +471,7 @@ mac_draw_line (f, gc, x1, y1, x2, y2)
gy1 += 0.5f, gy2 += 0.5f;
context = mac_begin_cg_clip (f, gc);
- CG_SET_STROKE_COLOR (context, gc->xgcv.foreground);
+ CG_SET_STROKE_COLOR_WITH_GC_FOREGROUND (context, gc);
CGContextBeginPath (context);
CGContextMoveToPoint (context, gx1, gy1);
CGContextAddLineToPoint (context, gx2, gy2);
@@ -485,7 +555,7 @@ mac_erase_rectangle (f, gc, x, y, width, height)
CGContextRef context;
context = mac_begin_cg_clip (f, gc);
- CG_SET_FILL_COLOR (context, gc->xgcv.background);
+ CG_SET_FILL_COLOR_WITH_GC_BACKGROUND (context, gc);
CGContextFillRect (context, CGRectMake (x, y, width, height));
mac_end_cg_clip (f);
#else
@@ -527,7 +597,7 @@ mac_clear_window (f)
GC gc = FRAME_NORMAL_GC (f);
context = mac_begin_cg_clip (f, NULL);
- CG_SET_FILL_COLOR (context, gc->xgcv.background);
+ CG_SET_FILL_COLOR_WITH_GC_BACKGROUND (context, gc);
CGContextFillRect (context, CGRectMake (0, 0, FRAME_PIXEL_WIDTH (f),
FRAME_PIXEL_HEIGHT (f)));
mac_end_cg_clip (f);
@@ -570,14 +640,14 @@ mac_draw_cg_image (image, f, gc, src_x, src_y, width, height,
context = mac_begin_cg_clip (f, gc);
if (!overlay_p)
{
- CG_SET_FILL_COLOR (context, gc->xgcv.background);
+ CG_SET_FILL_COLOR_WITH_GC_BACKGROUND (context, gc);
CGContextFillRect (context, dest_rect);
}
CGContextClipToRect (context, dest_rect);
CGContextScaleCTM (context, 1, -1);
CGContextTranslateCTM (context, 0, -port_height);
if (CGImageIsMask (image))
- CG_SET_FILL_COLOR (context, gc->xgcv.foreground);
+ CG_SET_FILL_COLOR_WITH_GC_FOREGROUND (context, gc);
CGContextDrawImage (context,
CGRectMake (dest_x - src_x,
port_height - (dest_y - src_y
@@ -764,7 +834,7 @@ mac_fill_rectangle (f, gc, x, y, width, height)
CGContextRef context;
context = mac_begin_cg_clip (f, gc);
- CG_SET_FILL_COLOR (context, gc->xgcv.foreground);
+ CG_SET_FILL_COLOR_WITH_GC_FOREGROUND (context, gc);
CGContextFillRect (context, CGRectMake (x, y, width, height));
mac_end_cg_clip (f);
#else
@@ -795,7 +865,7 @@ mac_draw_rectangle (f, gc, x, y, width, height)
CGContextRef context;
context = mac_begin_cg_clip (f, gc);
- CG_SET_STROKE_COLOR (context, gc->xgcv.foreground);
+ CG_SET_STROKE_COLOR_WITH_GC_FOREGROUND (context, gc);
CGContextStrokeRect (context,
CGRectMake (x + 0.5f, y + 0.5f, width, height));
mac_end_cg_clip (f);
@@ -982,7 +1052,7 @@ mac_draw_string_common (f, gc, x, y, buf, nchars, bg_width,
#endif
if (bg_width)
{
- CG_SET_FILL_COLOR (context, gc->xgcv.background);
+ CG_SET_FILL_COLOR_WITH_GC_BACKGROUND (context, gc);
CGContextFillRect
(context,
CGRectMake (x, y - FONT_BASE (GC_FONT (gc)),
@@ -993,7 +1063,7 @@ mac_draw_string_common (f, gc, x, y, buf, nchars, bg_width,
#if !USE_CG_DRAWING
}
#endif
- CG_SET_FILL_COLOR (context, gc->xgcv.foreground);
+ CG_SET_FILL_COLOR_WITH_GC_FOREGROUND (context, gc);
err = ATSUSetLayoutControls (text_layout,
sizeof (tags) / sizeof (tags[0]),
tags, sizes, values);
@@ -1344,7 +1414,7 @@ mac_draw_image_string_cg (f, gc, x, y, buf, nchars, bg_width, overstrike_p)
#endif
if (bg_width)
{
- CG_SET_FILL_COLOR (context, gc->xgcv.background);
+ CG_SET_FILL_COLOR_WITH_GC_BACKGROUND (context, gc);
CGContextFillRect
(context,
CGRectMake (gx, y - FONT_BASE (GC_FONT (gc)),
@@ -1355,7 +1425,7 @@ mac_draw_image_string_cg (f, gc, x, y, buf, nchars, bg_width, overstrike_p)
#if !USE_CG_DRAWING
}
#endif
- CG_SET_FILL_COLOR (context, gc->xgcv.foreground);
+ CG_SET_FILL_COLOR_WITH_GC_FOREGROUND (context, gc);
CGContextSetFont (context, GC_FONT (gc)->cg_font);
CGContextSetFontSize (context, GC_FONT (gc)->mac_fontsize);
if (GC_FONT (gc)->mac_fontsize <= cg_text_anti_aliasing_threshold)
@@ -1567,6 +1637,16 @@ XCreateGC (display, window, mask, xgcv)
GC gc = xmalloc (sizeof (*gc));
bzero (gc, sizeof (*gc));
+#if USE_CG_DRAWING && MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
+#if MAC_OS_X_VERSION_MIN_REQUIRED == 1020
+ if (CGColorGetTypeID != NULL)
+#endif
+ {
+ gc->cg_fore_color = gc->cg_back_color = mac_cg_color_black;
+ CGColorRetain (gc->cg_fore_color);
+ CGColorRetain (gc->cg_back_color);
+ }
+#endif
XChangeGC (display, gc, mask, xgcv);
return gc;
@@ -1582,6 +1662,10 @@ XFreeGC (display, gc)
{
if (gc->clip_region)
DisposeRgn (gc->clip_region);
+#if USE_CG_DRAWING && MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
+ CGColorRelease (gc->cg_fore_color);
+ CGColorRelease (gc->cg_back_color);
+#endif
xfree (gc);
}
@@ -1618,6 +1702,29 @@ XSetForeground (display, gc, color)
gc->fore_color.red = RED16_FROM_ULONG (color);
gc->fore_color.green = GREEN16_FROM_ULONG (color);
gc->fore_color.blue = BLUE16_FROM_ULONG (color);
+#if USE_CG_DRAWING && MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
+#if MAC_OS_X_VERSION_MIN_REQUIRED == 1020
+ if (CGColorGetTypeID != NULL)
+#endif
+ {
+ CGColorRelease (gc->cg_fore_color);
+ if (color == 0)
+ {
+ gc->cg_fore_color = mac_cg_color_black;
+ CGColorRetain (gc->cg_fore_color);
+ }
+ else
+ {
+ float rgba[4];
+
+ rgba[0] = gc->fore_color.red / 65535.0f;
+ rgba[1] = gc->fore_color.green / 65535.0f;
+ rgba[2] = gc->fore_color.blue / 65535.0f;
+ rgba[3] = 1.0f;
+ gc->cg_fore_color = CGColorCreate (mac_cg_color_space_rgb, rgba);
+ }
+ }
+#endif
}
}
@@ -1636,6 +1743,29 @@ XSetBackground (display, gc, color)
gc->back_color.red = RED16_FROM_ULONG (color);
gc->back_color.green = GREEN16_FROM_ULONG (color);
gc->back_color.blue = BLUE16_FROM_ULONG (color);
+#if USE_CG_DRAWING && MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
+#if MAC_OS_X_VERSION_MIN_REQUIRED == 1020
+ if (CGColorGetTypeID != NULL)
+#endif
+ {
+ CGColorRelease (gc->cg_back_color);
+ if (color == 0)
+ {
+ gc->cg_back_color = mac_cg_color_black;
+ CGColorRetain (gc->cg_back_color);
+ }
+ else
+ {
+ float rgba[4];
+
+ rgba[0] = gc->back_color.red / 65535.0f;
+ rgba[1] = gc->back_color.green / 65535.0f;
+ rgba[2] = gc->back_color.blue / 65535.0f;
+ rgba[3] = 1.0f;
+ gc->cg_back_color = CGColorCreate (mac_cg_color_space_rgb, rgba);
+ }
+ }
+#endif
}
}
@@ -8738,14 +8868,18 @@ extern void mac_find_apple_event_spec P_ ((AEEventClass, AEEventID,
extern OSErr init_coercion_handler P_ ((void));
/* Drag and Drop */
-OSErr install_drag_handler P_ ((WindowRef));
-void remove_drag_handler P_ ((WindowRef));
+extern OSErr install_drag_handler P_ ((WindowRef));
+extern void remove_drag_handler P_ ((WindowRef));
+
+/* Showing help echo string during menu tracking */
+extern OSStatus install_menu_target_item_handler P_ ((WindowPtr));
#if USE_CARBON_EVENTS
#ifdef MAC_OSX
extern void init_service_handler ();
static Lisp_Object Qservice, Qpaste, Qperform;
#endif
+
/* Window Event Handler */
static pascal OSStatus mac_handle_window_event (EventHandlerCallRef,
EventRef, void *);
@@ -10168,6 +10302,8 @@ install_window_handler (window)
#endif
if (err == noErr)
err = install_drag_handler (window);
+ if (err == noErr)
+ err = install_menu_target_item_handler (window);
return err;
}
@@ -10215,7 +10351,7 @@ main (void)
#if __MWERKS__
/* set creator and type for files created by MSL */
- _fcreator = 'EMAx';
+ _fcreator = MAC_EMACS_CREATOR_CODE;
_ftype = 'TEXT';
#endif
@@ -11692,6 +11828,8 @@ mac_initialize ()
#endif
#if USE_CG_DRAWING
+ init_cg_color ();
+
mac_init_fringe ();
#endif
diff --git a/src/macterm.h b/src/macterm.h
index a7e4ccff775..c941fafb690 100644
--- a/src/macterm.h
+++ b/src/macterm.h
@@ -528,6 +528,11 @@ struct scroll_bar {
#define HOURGLASS_HEIGHT 16
/* 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'
diff --git a/src/minibuf.c b/src/minibuf.c
index 7b276a2e925..3778d185e97 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -989,7 +989,7 @@ POSITION in the minibuffer. Any integer value less than or equal to
one puts point at the beginning of the string. *Note* that this
behavior differs from the way such arguments are used in `completing-read'
and some related functions, which use zero-indexing for POSITION. */)
-(prompt, initial_contents, keymap, read, hist, default_value, inherit_input_method)
+ (prompt, initial_contents, keymap, read, hist, default_value, inherit_input_method)
Lisp_Object prompt, initial_contents, keymap, read, hist, default_value;
Lisp_Object inherit_input_method;
{
diff --git a/src/window.c b/src/window.c
index b34cc3659c1..00a2e06bdeb 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1184,7 +1184,8 @@ if it isn't already recorded. */)
if (! NILP (update)
&& ! (! NILP (w->window_end_valid)
- && XFASTINT (w->last_modified) >= BUF_MODIFF (b))
+ && XFASTINT (w->last_modified) >= BUF_MODIFF (b)
+ && XFASTINT (w->last_overlay_modified) >= BUF_OVERLAY_MODIFF (b))
&& !noninteractive)
{
struct text_pos startp;