summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog125
-rw-r--r--src/buffer.c3
-rw-r--r--src/ccl.c1
-rw-r--r--src/emacs.c2
-rw-r--r--src/fileio.c1
-rw-r--r--src/image.c109
-rw-r--r--src/lread.c38
-rw-r--r--src/mac.c40
-rw-r--r--src/macfns.c21
-rw-r--r--src/macterm.c671
-rw-r--r--src/macterm.h2
-rw-r--r--src/minibuf.c42
-rw-r--r--src/search.c4
-rw-r--r--src/syssignal.h5
-rw-r--r--src/term.c4
-rw-r--r--src/unexelf.c14
-rw-r--r--src/window.c1
-rw-r--r--src/xterm.c1
18 files changed, 535 insertions, 549 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 3feb061a654..00b66dbd06f 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,119 @@
+2005-10-21 Richard M. Stallman <rms@gnu.org>
+
+ * lread.c (Fload): Simplify gcpro structure.
+ Gcpro FOUND as well as FILE, but not EFOUND.
+ Unless preloading, record FOUND instead of FILE in Vload_history.
+ Rename repeat local FILE to MSG_FILE.
+ (syms_of_lread) <load-history>: Doc fix.
+
+2005-10-21 Kenichi Handa <handa@m17n.org>
+
+ * search.c (boyer_moore): Surround the '||' part of expression in
+ `if' condition by parentheses explicitly.
+
+2005-10-20 Kim F. Storm <storm@cua.dk>
+
+ * buffer.c (clone_per_buffer_values): Remove unused var tem.
+ (init_buffer): Remove unused vars dotstat, pwdstat.
+
+ * ccl.c (check_ccl_update): Remove unused var vp.
+
+ * fileio.c (auto_save_error): Call SAFE_FREE.
+
+ * fns.c (Fchar_table_range): Remove unused var i.
+
+ * minibuf.c (display_completion_list_1): New wrapper function
+ for Fdisplay_completion_list.
+ (Fminibuffer_completion_help): Use it.
+
+ * term.c (encode_terminal_code): Remove unused var src_start.
+
+ * window.c (Fwindow_tree): Remove unused var alist.
+
+ * xterm.c (x_calc_absolute_position): Remove unused vars win_x, win_y.
+
+2005-10-20 Aubrey Jaffer <agj@alum.mit.edu> (tiny change)
+
+ * unexelf.c (unexec): Fix calls to `fatal' with less than 3
+ arguments.
+
+2005-10-20 Olli Savia <ops@iki.fi> (tiny change)
+
+ * syssignal.h [__Lynx__]: Undef SIGPOLL along with SIGIO.
+
+2005-10-20 Andreas Schwab <schwab@suse.de>
+
+ * minibuf.c (Fdisplay_completion_list): Doc fix.
+
+2005-10-19 Kim F. Storm <storm@cua.dk>
+
+ * image.c (check_image_size): Handle integer Vmax_image_size value
+ directly as max pixel value. Use default frame size for null frame.
+ (syms_of_image) <max-image-size>: Describe integer value.
+
+2005-10-19 Romain Francoise <romain@orebokech.com>
+
+ * emacs.c (main): Update copyright year.
+
+2005-10-18 Chong Yidong <cyd@stupidchicken.com>
+
+ * image.c (Vmax_image_size): New variable.
+ (check_image_size): New function.
+ (xbm_read_bitmap_data, pbm_load, png_load, jpeg_load, tiff_load)
+ (gif_load, gs_load): Use it.
+ (lookup_image): Try loading again if previous load failed.
+ (xbm_read_bitmap_data): Add a new argument, a pointer to the frame
+ to display in, NULL if none.
+ (xbm_load_image, xbm_file_p): Pass xbm_read_bitmap_data the new
+ argument.
+
+2005-10-18 Richard M. Stallman <rms@gnu.org>
+
+ * search.c (Fstring_match): Doc fix.
+
+2005-10-18 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
+
+ * macterm.c (note_mouse_movement): Use PtInRect.
+ (XTread_socket): Also ignore mouse motion just before a button
+ release event. Don't process button release event when mouse is
+ not grabbed.
+
+2005-10-16 Masatake YAMATO <jet@gyve.org>
+
+ * minibuf.c (Fdisplay_completion_list): Add new optional
+ argument COMMON_SUBSTRING. Bind `completion-common-substring'
+ to the optional argument during running `completion-setup-hook'.
+
+2005-10-16 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
+
+ * mac.c [TARGET_API_MAC_CARBON] (get_cfstring_encoding_from_lisp):
+ Allow nil as argument.
+ [TARGET_API_MAC_CARBON] (Fmac_code_convert_string): Regard nil
+ for encoding arguments as UTF-16 in native byte order, no BOM.
+
+ * macfns.c (Fx_create_frame): Add debugging code.
+ (Fx_show_tip): Set frame pixel width and height.
+
+ * macterm.c (MAC_WINDOW_NORMAL_GC): Remove macro.
+ (FRAME_NORMAL_GC): New macro.
+ (mac_draw_line, mac_clear_area, mac_clear_window)
+ (mac_fill_rectangle, mac_draw_string, mac_draw_string_16)
+ (mac_draw_image_string, mac_draw_image_string_16): Rename from
+ XDrawLine, XClearArea, XClearWindow, XFillRectangle, XDrawString,
+ XDrawString16, XDrawImageString, and XDrawImageString16, respectively.
+ All uses changed.
+ (mac_draw_line, mac_erase_rectangle, mac_clear_area)
+ (mac_clear_window, mac_draw_bitmap, mac_draw_rectangle)
+ (mac_invert_rectangle, mac_draw_string_common, mac_draw_string)
+ (mac_draw_string_16, mac_draw_image_string)
+ (mac_draw_image_string_16, mac_copy_area, mac_copy_area_with_mask)
+ (mac_scroll_area): Drawing functions now take frame as destination.
+ All uses changed.
+ (mac_draw_string_common): Get port height with FRAME_PIXEL_HEIGHT.
+ (x_draw_fringe_bitmap): Set clipping area in face->gc.
+
+ * macterm.h (mac_clear_area): Add extern.
+
2005-10-14 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
* macterm.c (note_mouse_movement, XTread_socket): Apply 2005-10-14
@@ -193,7 +309,7 @@
(FRAME_MAC_WINDOW, FRAME_X_WINDOW): Use window_desc.
* xfaces.c (x_create_gc, x_free_gc) [MAC_OS]: Add BLOCK_INPUT.
- Add debug code.
+ Add debugging code.
2005-10-08 Kim F. Storm <storm@cua.dk>
@@ -237,6 +353,11 @@
* xterm.c, w32term.c, macterm.c: Rename member for_overlaps_p in
struct glyph_string to for_overlaps.
+2005-10-04 Richard M. Stallman <rms@gnu.org>
+
+ * alloc.c (refill_memory_reserve): Conditionalize the body,
+ not the function's existence.
+
2005-10-04 Kim F. Storm <storm@cua.dk>
* window.c (window_split_tree): New function.
@@ -278,7 +399,7 @@
* keyboard.c (init_keyboard) [MAC_OSX]: Don't install SIGINT handler.
* macfns.c (start_hourglass): Apply 2005-05-07 change for xfns.c.
- (x_create_tip_frame) [GLYPH_DEBUG]: Uncomment debug code.
+ (x_create_tip_frame) [GLYPH_DEBUG]: Uncomment debugging code.
(Fx_create_frame, x_create_tip_frame) [USE_ATSUI]:
Try ATSUI-compatible 12pt Monaco font first.
diff --git a/src/buffer.c b/src/buffer.c
index e8a45f42342..2c02ffacc1d 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -486,7 +486,7 @@ static void
clone_per_buffer_values (from, to)
struct buffer *from, *to;
{
- Lisp_Object to_buffer, tem;
+ Lisp_Object to_buffer;
int offset;
XSETBUFFER (to_buffer, to);
@@ -5128,7 +5128,6 @@ void
init_buffer ()
{
char *pwd;
- struct stat dotstat, pwdstat;
Lisp_Object temp;
int len;
diff --git a/src/ccl.c b/src/ccl.c
index a785707295c..7f6ec1a7aa3 100644
--- a/src/ccl.c
+++ b/src/ccl.c
@@ -1940,7 +1940,6 @@ int
check_ccl_update (ccl)
struct ccl_program *ccl;
{
- struct Lisp_Vector *vp;
Lisp_Object slot, ccl_prog;
if (ccl->idx < 0)
diff --git a/src/emacs.c b/src/emacs.c
index 0149bec6d5e..0193043ed2d 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -896,7 +896,7 @@ main (argc, argv
else
{
printf ("GNU Emacs %s\n", SDATA (tem));
- printf ("Copyright (C) 2004 Free Software Foundation, Inc.\n");
+ printf ("Copyright (C) 2005 Free Software Foundation, Inc.\n");
printf ("GNU Emacs comes with ABSOLUTELY NO WARRANTY.\n");
printf ("You may redistribute copies of Emacs\n");
printf ("under the terms of the GNU General Public License.\n");
diff --git a/src/fileio.c b/src/fileio.c
index 16eb0475a2b..2e63a60fdb9 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -5711,6 +5711,7 @@ auto_save_error (error)
Fsleep_for (make_number (1), Qnil);
}
+ SAFE_FREE ();
UNGCPRO;
return Qnil;
}
diff --git a/src/image.c b/src/image.c
index 2463c24a33a..1996d8477e9 100644
--- a/src/image.c
+++ b/src/image.c
@@ -1099,7 +1099,10 @@ or omitted means use the selected frame. */)
static struct image *make_image P_ ((Lisp_Object spec, unsigned hash));
static void free_image P_ ((struct frame *f, struct image *img));
+static int check_image_size P_ ((struct frame *f, int width, int height));
+#define MAX_IMAGE_SIZE 6.0
+Lisp_Object Vmax_image_size;
/* Allocate and return a new image structure for image specification
SPEC. SPEC has a hash value of HASH. */
@@ -1151,6 +1154,39 @@ free_image (f, img)
}
}
+/* Return 1 if the given widths and heights are valid for display;
+ otherwise, return 0. */
+
+int
+check_image_size (f, width, height)
+ struct frame *f;
+ int width;
+ int height;
+{
+ int w, h;
+
+ if (width <= 0 || height <= 0)
+ return 0;
+
+ if (INTEGERP (Vmax_image_size))
+ w = h = XINT (Vmax_image_size);
+ else if (FLOATP (Vmax_image_size))
+ {
+ if (f != NULL)
+ {
+ w = FRAME_PIXEL_WIDTH (f);
+ h = FRAME_PIXEL_HEIGHT (f);
+ }
+ else
+ w = h = 1024; /* Arbitrary size for unknown frame. */
+ w = (int) (XFLOAT_DATA (Vmax_image_size) * w);
+ h = (int) (XFLOAT_DATA (Vmax_image_size) * h);
+ }
+ else
+ return 1;
+
+ return (width <= w && height <= h);
+}
/* Prepare image IMG for display on frame F. Must be called before
drawing an image. */
@@ -1708,6 +1744,12 @@ lookup_image (f, spec)
if (img->hash == hash && !NILP (Fequal (img->spec, spec)))
break;
+ if (img && img->load_failed_p)
+ {
+ free_image (f, img);
+ img = NULL;
+ }
+
/* If not found, create a new image and cache it. */
if (img == NULL)
{
@@ -2551,7 +2593,8 @@ static int xbm_load P_ ((struct frame *f, struct image *img));
static int xbm_load_image P_ ((struct frame *f, struct image *img,
unsigned char *, unsigned char *));
static int xbm_image_p P_ ((Lisp_Object object));
-static int xbm_read_bitmap_data P_ ((unsigned char *, unsigned char *,
+static int xbm_read_bitmap_data P_ ((struct frame *f,
+ unsigned char *, unsigned char *,
int *, int *, unsigned char **));
static int xbm_file_p P_ ((Lisp_Object));
@@ -2939,7 +2982,8 @@ Create_Pixmap_From_Bitmap_Data(f, img, data, fg, bg, non_default_colors)
CONTENTS looks like an in-memory XBM file. */
static int
-xbm_read_bitmap_data (contents, end, width, height, data)
+xbm_read_bitmap_data (f, contents, end, width, height, data)
+ struct frame *f;
unsigned char *contents, *end;
int *width, *height;
unsigned char **data;
@@ -2992,7 +3036,7 @@ xbm_read_bitmap_data (contents, end, width, height, data)
expect (XBM_TK_NUMBER);
}
- if (*width < 0 || *height < 0)
+ if (!check_image_size (f, *width, *height))
goto failure;
else if (data == NULL)
goto success;
@@ -3096,7 +3140,7 @@ xbm_load_image (f, img, contents, end)
unsigned char *data;
int success_p = 0;
- rc = xbm_read_bitmap_data (contents, end, &img->width, &img->height, &data);
+ rc = xbm_read_bitmap_data (f, contents, end, &img->width, &img->height, &data);
if (rc)
{
unsigned long foreground = FRAME_FOREGROUND_PIXEL (f);
@@ -3150,7 +3194,7 @@ xbm_file_p (data)
{
int w, h;
return (STRINGP (data)
- && xbm_read_bitmap_data (SDATA (data),
+ && xbm_read_bitmap_data (NULL, SDATA (data),
(SDATA (data)
+ SBYTES (data)),
&w, &h, NULL));
@@ -5465,8 +5509,7 @@ pbm_load (f, img)
max_color_idx = 255;
}
- if (width < 0
- || height < 0
+ if (!check_image_size (f, width, height)
|| (type != PBM_MONO && max_color_idx < 0))
goto error;
@@ -5966,6 +6009,9 @@ png_load (f, img)
fn_png_get_IHDR (png_ptr, info_ptr, &width, &height, &bit_depth, &color_type,
&interlace_type, NULL, NULL);
+ if (!check_image_size (f, width, height))
+ goto error;
+
/* If image contains simply transparency data, we prefer to
construct a clipping mask. */
if (fn_png_get_valid (png_ptr, info_ptr, PNG_INFO_tRNS))
@@ -6726,6 +6772,12 @@ jpeg_load (f, img)
width = img->width = cinfo.output_width;
height = img->height = cinfo.output_height;
+ if (!check_image_size (f, width, height))
+ {
+ image_error ("Invalid image size", Qnil, Qnil);
+ longjmp (mgr.setjmp_buffer, 2);
+ }
+
/* Create X image and pixmap. */
if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg, &img->pixmap))
longjmp (mgr.setjmp_buffer, 2);
@@ -7155,6 +7207,14 @@ tiff_load (f, img)
of width x height 32-bit values. */
fn_TIFFGetField (tiff, TIFFTAG_IMAGEWIDTH, &width);
fn_TIFFGetField (tiff, TIFFTAG_IMAGELENGTH, &height);
+
+ if (!check_image_size (f, width, height))
+ {
+ image_error ("Invalid image size", Qnil, Qnil);
+ UNGCPRO;
+ return 0;
+ }
+
buf = (uint32 *) xmalloc (width * height * sizeof *buf);
rc = fn_TIFFReadRGBAImage (tiff, width, height, buf, 0);
@@ -7459,6 +7519,15 @@ gif_load (f, img)
}
}
+ /* Before reading entire contents, check the declared image size. */
+ if (!check_image_size (f, gif->SWidth, gif->SHeight))
+ {
+ image_error ("Invalid image size", Qnil, Qnil);
+ fn_DGifCloseFile (gif);
+ UNGCPRO;
+ return 0;
+ }
+
/* Read entire contents. */
rc = fn_DGifSlurp (gif);
if (rc == GIF_ERROR)
@@ -7492,6 +7561,14 @@ gif_load (f, img)
max (gif->Image.Top + gif->Image.Height,
image_top + image_height));
+ if (!check_image_size (f, width, height))
+ {
+ image_error ("Invalid image size", Qnil, Qnil);
+ fn_DGifCloseFile (gif);
+ UNGCPRO;
+ return 0;
+ }
+
/* Create the X image and pixmap. */
if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg, &img->pixmap))
{
@@ -7944,6 +8021,12 @@ gs_load (f, img)
in_height = XFASTINT (pt_height) / 72.0;
img->height = in_height * FRAME_X_DISPLAY_INFO (f)->resy;
+ if (!check_image_size (f, img->width, img->height))
+ {
+ image_error ("Invalid image size", Qnil, Qnil);
+ return 0;
+ }
+
/* Create the pixmap. */
xassert (img->pixmap == NO_PIXMAP);
@@ -8217,6 +8300,18 @@ listed; they're always supported. */);
Vimage_library_alist = Qnil;
Fput (intern ("image-library-alist"), Qrisky_local_variable, Qt);
+ DEFVAR_LISP ("max-image-size", &Vmax_image_size,
+ doc: /* Maximum size of images.
+Emacs will not load an image into memory if its pixel width or
+pixel height exceeds this limit.
+
+If the value is an integer, it directly specifies the maximum
+image height and width, measured in pixels. If it is a floating
+point number, it specifies the maximum image height and width
+as a ratio to the frame height and width. If the value is
+non-numeric, there is no explicit limit on the size of images. */);
+ Vmax_image_size = make_float (MAX_IMAGE_SIZE);
+
Vimage_type_cache = Qnil;
staticpro (&Vimage_type_cache);
diff --git a/src/lread.c b/src/lread.c
index 7b91260cda9..5778a9d3a0c 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -848,6 +848,11 @@ If optional fourth arg NOSUFFIX is non-nil, don't try adding
If optional fifth arg MUST-SUFFIX is non-nil, insist on
the suffix `.elc' or `.el'; don't accept just FILE unless
it ends in one of those suffixes or includes a directory name.
+
+Loading a file records its definitions, and its `provide' and
+`require' calls, in an element of `load-history' whose
+car is the file name loaded. See `load-history'.
+
Return t if file exists. */)
(file, noerror, nomessage, nosuffix, must_suffix)
Lisp_Object file, noerror, nomessage, nosuffix, must_suffix;
@@ -856,7 +861,7 @@ Return t if file exists. */)
register int fd = -1;
int count = SPECPDL_INDEX ();
Lisp_Object temp;
- struct gcpro gcpro1;
+ struct gcpro gcpro1, gcpro2;
Lisp_Object found, efound;
/* 1 means we printed the ".el is newer" message. */
int newer = 0;
@@ -905,7 +910,8 @@ Return t if file exists. */)
int size = SBYTES (file);
Lisp_Object tmp[2];
- GCPRO1 (file);
+ found = Qnil;
+ GCPRO2 (file, found);
if (! NILP (must_suffix))
{
@@ -994,6 +1000,8 @@ Return t if file exists. */)
struct stat s1, s2;
int result;
+ GCPRO2 (file, found);
+
if (version < 0
&& ! (version = safe_to_load_p (fd)))
{
@@ -1011,7 +1019,6 @@ Return t if file exists. */)
compiled = 1;
- GCPRO1 (efound);
efound = ENCODE_FILE (found);
#ifdef DOS_NT
@@ -1021,7 +1028,6 @@ Return t if file exists. */)
SSET (efound, SBYTES (efound) - 1, 0);
result = stat ((char *)SDATA (efound), &s2);
SSET (efound, SBYTES (efound) - 1, 'c');
- UNGCPRO;
if (result >= 0 && (unsigned) s1.st_mtime < (unsigned) s2.st_mtime)
{
@@ -1031,12 +1037,13 @@ Return t if file exists. */)
/* If we won't print another message, mention this anyway. */
if (!NILP (nomessage))
{
- Lisp_Object file;
- file = Fsubstring (found, make_number (0), make_number (-1));
+ Lisp_Object msg_file;
+ msg_file = Fsubstring (found, make_number (0), make_number (-1));
message_with_string ("Source file `%s' newer than byte-compiled file",
- file, 1);
+ msg_file, 1);
}
}
+ UNGCPRO;
}
}
else
@@ -1055,12 +1062,12 @@ Return t if file exists. */)
}
}
+ GCPRO2 (file, found);
+
#ifdef WINDOWSNT
emacs_close (fd);
- GCPRO1 (efound);
efound = ENCODE_FILE (found);
stream = fopen ((char *) SDATA (efound), fmode);
- UNGCPRO;
#else /* not WINDOWSNT */
stream = fdopen (fd, fmode);
#endif /* not WINDOWSNT */
@@ -1087,7 +1094,6 @@ Return t if file exists. */)
message_with_string ("Loading %s...", file, 1);
}
- GCPRO1 (file);
record_unwind_protect (load_unwind, make_save_value (stream, 0));
record_unwind_protect (load_descriptor_unwind, load_descriptor_list);
specbind (Qload_file_name, found);
@@ -1096,8 +1102,9 @@ Return t if file exists. */)
= Fcons (make_number (fileno (stream)), load_descriptor_list);
load_in_progress++;
if (! version || version >= 22)
- readevalloop (Qget_file_char, stream, file, Feval,
- 0, Qnil, Qnil, Qnil, Qnil);
+ readevalloop (Qget_file_char, stream,
+ (! NILP (Vpurify_flag) ? file : found),
+ Feval, 0, Qnil, Qnil, Qnil, Qnil);
else
{
/* We can't handle a file which was compiled with
@@ -4017,7 +4024,7 @@ when the corresponding call to `provide' is made. */);
Vafter_load_alist = Qnil;
DEFVAR_LISP ("load-history", &Vload_history,
- doc: /* Alist mapping source file names to symbols and features.
+ doc: /* Alist mapping file names to symbols and features.
Each alist element is a list that starts with a file name,
except for one element (optional) that starts with nil and describes
definitions evaluated from buffers not visiting files.
@@ -4026,7 +4033,10 @@ and cons cells of the form `(provide . FEATURE)', `(require . FEATURE)',
`(defun . FUNCTION)', `(autoload . SYMBOL)', and `(t . SYMBOL)'.
An element `(t . SYMBOL)' precedes an entry `(defun . FUNCTION)',
and means that SYMBOL was an autoload before this file redefined it
-as a function. */);
+as a function.
+
+For a preloaded file, the file name recorded is relative to the main Lisp
+directory. These names are converted to absolute by `file-loadhist-lookup'. */);
Vload_history = Qnil;
DEFVAR_LISP ("load-file-name", &Vload_file_name,
diff --git a/src/mac.c b/src/mac.c
index 0d8c99ffb1e..4c8e78ade25 100644
--- a/src/mac.c
+++ b/src/mac.c
@@ -3411,7 +3411,7 @@ terminate_applescript()
}
/* Convert a lisp string to the 4 byte character code. */
-
+
OSType
mac_get_code_from_arg(Lisp_Object arg, OSType defCode)
{
@@ -3419,7 +3419,7 @@ mac_get_code_from_arg(Lisp_Object arg, OSType defCode)
if (NILP(arg))
{
result = defCode;
- }
+ }
else
{
/* check type string */
@@ -3483,7 +3483,7 @@ DEFUN ("mac-get-file-creator", Fmac_get_file_creator, Smac_get_file_creator, 1,
status = FSpGetFInfo (&fss, &finder_info);
#endif
- if (status == noErr)
+ if (status == noErr)
{
#ifdef MAC_OSX
result = mac_get_object_from_code(((FileInfo*)&catalogInfo.finderInfo)->fileCreator);
@@ -3538,7 +3538,7 @@ DEFUN ("mac-get-file-type", Fmac_get_file_type, Smac_get_file_type, 1, 1, 0,
status = FSpGetFInfo (&fss, &finder_info);
#endif
- if (status == noErr)
+ if (status == noErr)
{
#ifdef MAC_OSX
result = mac_get_object_from_code(((FileInfo*)&catalogInfo.finderInfo)->fileType);
@@ -3596,7 +3596,7 @@ assumed. Return non-nil if successful. */)
status = FSpGetFInfo (&fss, &finder_info);
#endif
- if (status == noErr)
+ if (status == noErr)
{
#ifdef MAC_OSX
((FileInfo*)&catalogInfo.finderInfo)->fileCreator = cCode;
@@ -3656,7 +3656,7 @@ CODE must be a 4-character string. Return non-nil if successful. */)
status = FSpGetFInfo (&fss, &finder_info);
#endif
- if (status == noErr)
+ if (status == noErr)
{
#ifdef MAC_OSX
((FileInfo*)&catalogInfo.finderInfo)->fileType = cCode;
@@ -3968,10 +3968,13 @@ get_cfstring_encoding_from_lisp (obj)
CFStringRef iana_name;
CFStringEncoding encoding = kCFStringEncodingInvalidId;
+ if (NILP (obj))
+ return kCFStringEncodingUnicode;
+
if (INTEGERP (obj))
return XINT (obj);
- if (SYMBOLP (obj) && !NILP (obj) && !NILP (Fcoding_system_p (obj)))
+ if (SYMBOLP (obj) && !NILP (Fcoding_system_p (obj)))
{
Lisp_Object coding_spec, plist;
@@ -4115,7 +4118,8 @@ DEFUN ("mac-code-convert-string", Fmac_code_convert_string, Smac_code_convert_st
doc: /* Convert STRING from SOURCE encoding to TARGET encoding.
The conversion is performed using the converter provided by the system.
Each encoding is specified by either a coding system symbol, a mime
-charset string, or an integer as a CFStringEncoding value.
+charset string, or an integer as a CFStringEncoding value. Nil for
+encoding means UTF-16 in native byte order, no byte order marker.
On Mac OS X 10.2 and later, you can do Unicode Normalization by
specifying the optional argument NORMALIZATION-FORM with a symbol NFD,
NFKD, NFC, NFKC, HFS+D, or HFS+C.
@@ -4126,7 +4130,6 @@ On successful conversion, return the result string, else return nil. */)
Lisp_Object result = Qnil;
CFStringEncoding src_encoding, tgt_encoding;
CFStringRef str = NULL;
- CFDataRef data = NULL;
CHECK_STRING (string);
if (!INTEGERP (source) && !STRINGP (source))
@@ -4148,7 +4151,7 @@ On successful conversion, return the result string, else return nil. */)
if (src_encoding != kCFStringEncodingInvalidId
&& tgt_encoding != kCFStringEncodingInvalidId)
str = CFStringCreateWithBytes (NULL, SDATA (string), SBYTES (string),
- src_encoding, true);
+ src_encoding, !NILP (source));
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
if (str)
{
@@ -4160,15 +4163,18 @@ On successful conversion, return the result string, else return nil. */)
#endif
if (str)
{
- data = CFStringCreateExternalRepresentation (NULL, str,
- tgt_encoding, '\0');
+ CFIndex str_len, buf_len;
+
+ str_len = CFStringGetLength (str);
+ if (CFStringGetBytes (str, CFRangeMake (0, str_len), tgt_encoding, 0,
+ !NILP (target), NULL, 0, &buf_len) == str_len)
+ {
+ result = make_uninit_string (buf_len);
+ CFStringGetBytes (str, CFRangeMake (0, str_len), tgt_encoding, 0,
+ !NILP (target), SDATA (result), buf_len, NULL);
+ }
CFRelease (str);
}
- if (data)
- {
- result = cfdata_to_lisp (data);
- CFRelease (data);
- }
UNBLOCK_INPUT;
diff --git a/src/macfns.c b/src/macfns.c
index ecee09189f5..8071974c6d4 100644
--- a/src/macfns.c
+++ b/src/macfns.c
@@ -1745,8 +1745,7 @@ x_set_tool_bar_lines (f, value, oldval)
int y = nlines * FRAME_LINE_HEIGHT (f);
BLOCK_INPUT;
- XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
- 0, y, width, height, 0);
+ mac_clear_area (f, 0, y, width, height);
UNBLOCK_INPUT;
if (WINDOWP (f->tool_bar_window))
@@ -2439,7 +2438,7 @@ This function is an internal primitive--use `make-frame' instead. */)
frame = Qnil;
GCPRO4 (parms, parent, name, frame);
tem = mac_get_arg (parms, Qminibuffer, "minibuffer", "Minibuffer",
- RES_TYPE_SYMBOL);
+ RES_TYPE_SYMBOL);
if (EQ (tem, Qnone) || NILP (tem))
f = make_frame_without_minibuffer (Qnil, kb, display);
else if (EQ (tem, Qonly))
@@ -2480,7 +2479,11 @@ This function is an internal primitive--use `make-frame' instead. */)
if (! STRINGP (f->icon_name))
f->icon_name = Qnil;
-/* FRAME_W32_DISPLAY_INFO (f) = dpyinfo; */
+/* FRAME_MAC_DISPLAY_INFO (f) = dpyinfo; */
+#if GLYPH_DEBUG
+ image_cache_refcount = FRAME_X_IMAGE_CACHE (f)->refcount;
+ dpyinfo_refcount = dpyinfo->reference_count;
+#endif /* GLYPH_DEBUG */
#ifdef MULTI_KBOARD
FRAME_KBOARD (f) = kb;
#endif
@@ -2606,9 +2609,10 @@ This function is an internal primitive--use `make-frame' instead. */)
x_default_parameter (f, parms, Qmenu_bar_lines, make_number (1),
"menuBar", "MenuBar", RES_TYPE_NUMBER);
x_default_parameter (f, parms, Qtool_bar_lines, make_number (1),
- "toolBar", "ToolBar", RES_TYPE_NUMBER);
+ "toolBar", "ToolBar", RES_TYPE_NUMBER);
x_default_parameter (f, parms, Qbuffer_predicate, Qnil,
- "bufferPredicate", "BufferPredicate", RES_TYPE_SYMBOL);
+ "bufferPredicate", "BufferPredicate",
+ RES_TYPE_SYMBOL);
x_default_parameter (f, parms, Qtitle, Qnil,
"title", "Title", RES_TYPE_STRING);
x_default_parameter (f, parms, Qfullscreen, Qnil,
@@ -3593,7 +3597,7 @@ x_create_tip_frame (dpyinfo, parms, text)
FRAME_FONTSET (f) = -1;
f->icon_name = Qnil;
-
+/* FRAME_X_DISPLAY_INFO (f) = dpyinfo; */
#if GLYPH_DEBUG
image_cache_refcount = FRAME_X_IMAGE_CACHE (f)->refcount;
dpyinfo_refcount = dpyinfo->reference_count;
@@ -4047,6 +4051,9 @@ Text larger than the specified size is clipped. */)
BringToFront (FRAME_MAC_WINDOW (f));
UNBLOCK_INPUT;
+ FRAME_PIXEL_WIDTH (f) = width;
+ FRAME_PIXEL_HEIGHT (f) = height;
+
/* Draw into the window. */
w->must_be_updated_p = 1;
update_single_window (w, 1);
diff --git a/src/macterm.c b/src/macterm.c
index 02dcbf5e04f..f0574c9078f 100644
--- a/src/macterm.c
+++ b/src/macterm.c
@@ -273,7 +273,7 @@ extern void menubar_selection_callback (FRAME_PTR, int);
#define GC_BACK_COLOR(gc) (&(gc)->back_color)
#define GC_FONT(gc) ((gc)->xgcv.font)
#define GC_CLIP_REGION(gc) ((gc)->clip_region)
-#define MAC_WINDOW_NORMAL_GC(w) (((mac_output *) GetWRefCon (w))->normal_gc)
+#define FRAME_NORMAL_GC(f) ((f)->output_data.mac->normal_gc)
static RgnHandle saved_port_clip_region = NULL;
@@ -319,13 +319,12 @@ XFreePixmap (display, pixmap)
/* Mac version of XDrawLine. */
static void
-XDrawLine (display, w, gc, x1, y1, x2, y2)
- Display *display;
- WindowPtr w;
+mac_draw_line (f, gc, x1, y1, x2, y2)
+ struct frame *f;
GC gc;
int x1, y1, x2, y2;
{
- SetPortWindowPort (w);
+ SetPortWindowPort (FRAME_MAC_WINDOW (f));
RGBForeColor (GC_FORE_COLOR (gc));
@@ -360,15 +359,15 @@ mac_draw_line_to_pixmap (display, p, gc, x1, y1, x2, y2)
static void
-mac_erase_rectangle (w, gc, x, y, width, height)
- WindowPtr w;
+mac_erase_rectangle (f, gc, x, y, width, height)
+ struct frame *f;
GC gc;
int x, y;
unsigned int width, height;
{
Rect r;
- SetPortWindowPort (w);
+ SetPortWindowPort (FRAME_MAC_WINDOW (f));
RGBBackColor (GC_BACK_COLOR (gc));
SetRect (&r, x, y, x + width, y + height);
@@ -377,43 +376,40 @@ mac_erase_rectangle (w, gc, x, y, width, height)
EraseRect (&r);
mac_end_clip (GC_CLIP_REGION (gc));
- RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (w)));
+ RGBBackColor (GC_BACK_COLOR (FRAME_NORMAL_GC (f)));
}
/* Mac version of XClearArea. */
void
-XClearArea (display, w, x, y, width, height, exposures)
- Display *display;
- WindowPtr w;
+mac_clear_area (f, x, y, width, height)
+ struct frame *f;
int x, y;
unsigned int width, height;
- int exposures;
{
- mac_erase_rectangle (w, MAC_WINDOW_NORMAL_GC (w), x, y, width, height);
+ mac_erase_rectangle (f, FRAME_NORMAL_GC (f), x, y, width, height);
}
/* Mac version of XClearWindow. */
static void
-XClearWindow (display, w)
- Display *display;
- WindowPtr w;
+mac_clear_window (f)
+ struct frame *f;
{
- SetPortWindowPort (w);
+ SetPortWindowPort (FRAME_MAC_WINDOW (f));
- RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (w)));
+ RGBBackColor (GC_BACK_COLOR (FRAME_NORMAL_GC (f)));
#if TARGET_API_MAC_CARBON
{
Rect r;
- GetWindowPortBounds (w, &r);
+ GetWindowPortBounds (FRAME_MAC_WINDOW (f), &r);
EraseRect (&r);
}
#else /* not TARGET_API_MAC_CARBON */
- EraseRect (&(w->portRect));
+ EraseRect (&(FRAME_MAC_WINDOW (f)->portRect));
#endif /* not TARGET_API_MAC_CARBON */
}
@@ -421,9 +417,8 @@ XClearWindow (display, w)
/* Mac replacement for XCopyArea. */
static void
-mac_draw_bitmap (display, w, gc, x, y, width, height, bits, overlay_p)
- Display *display;
- WindowPtr w;
+mac_draw_bitmap (f, gc, x, y, width, height, bits, overlay_p)
+ struct frame *f;
GC gc;
int x, y, width, height;
unsigned short *bits;
@@ -436,7 +431,7 @@ mac_draw_bitmap (display, w, gc, x, y, width, height, bits, overlay_p)
bitmap.baseAddr = (char *)bits;
SetRect (&(bitmap.bounds), 0, 0, width, height);
- SetPortWindowPort (w);
+ SetPortWindowPort (FRAME_MAC_WINDOW (f));
RGBForeColor (GC_FORE_COLOR (gc));
RGBBackColor (GC_BACK_COLOR (gc));
@@ -444,17 +439,22 @@ mac_draw_bitmap (display, w, gc, x, y, width, height, bits, overlay_p)
mac_begin_clip (GC_CLIP_REGION (gc));
#if TARGET_API_MAC_CARBON
- LockPortBits (GetWindowPort (w));
- CopyBits (&bitmap, GetPortBitMapForCopyBits (GetWindowPort (w)),
- &(bitmap.bounds), &r, overlay_p ? srcOr : srcCopy, 0);
- UnlockPortBits (GetWindowPort (w));
+ {
+ CGrafPtr port;
+
+ GetPort (&port);
+ LockPortBits (port);
+ CopyBits (&bitmap, GetPortBitMapForCopyBits (port),
+ &(bitmap.bounds), &r, overlay_p ? srcOr : srcCopy, 0);
+ UnlockPortBits (port);
+ }
#else /* not TARGET_API_MAC_CARBON */
- CopyBits (&bitmap, &(w->portBits), &(bitmap.bounds), &r,
+ CopyBits (&bitmap, &(FRAME_MAC_WINDOW (f)->portBits), &(bitmap.bounds), &r,
overlay_p ? srcOr : srcCopy, 0);
#endif /* not TARGET_API_MAC_CARBON */
mac_end_clip (GC_CLIP_REGION (gc));
- RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (w)));
+ RGBBackColor (GC_BACK_COLOR (FRAME_NORMAL_GC (f)));
}
@@ -571,16 +571,15 @@ XCreatePixmapFromBitmapData (display, w, data, width, height, fg, bg, depth)
/* Mac replacement for XFillRectangle. */
static void
-XFillRectangle (display, w, gc, x, y, width, height)
- Display *display;
- WindowPtr w;
+mac_fill_rectangle (f, gc, x, y, width, height)
+ struct frame *f;
GC gc;
int x, y;
unsigned int width, height;
{
Rect r;
- SetPortWindowPort (w);
+ SetPortWindowPort (FRAME_MAC_WINDOW (f));
RGBForeColor (GC_FORE_COLOR (gc));
SetRect (&r, x, y, x + width, y + height);
@@ -591,46 +590,18 @@ XFillRectangle (display, w, gc, x, y, width, height)
}
-#if 0 /* TODO: figure out if we need to do this on Mac. */
-static void
-mac_fill_rectangle_to_pixmap (display, p, gc, x, y, width, height)
- Display *display;
- Pixmap p;
- GC gc;
- int x, y;
- unsigned int width, height;
-{
- CGrafPtr old_port;
- GDHandle old_gdh;
- Rect r;
-
- GetGWorld (&old_port, &old_gdh);
- SetGWorld (p, NULL);
- RGBForeColor (GC_FORE_COLOR (gc));
- SetRect (&r, x, y, x + width, y + height);
-
- LockPixels (GetGWorldPixMap (p));
- PaintRect (&r); /* using foreground color of gc */
- UnlockPixels (GetGWorldPixMap (p));
-
- SetGWorld (old_port, old_gdh);
-}
-#endif
-
-
/* Mac replacement for XDrawRectangle: dest is a window. */
static void
-mac_draw_rectangle (display, w, gc, x, y, width, height)
- Display *display;
- WindowPtr w;
+mac_draw_rectangle (f, gc, x, y, width, height)
+ struct frame *f;
GC gc;
int x, y;
unsigned int width, height;
{
Rect r;
- SetPortWindowPort (w);
+ SetPortWindowPort (FRAME_MAC_WINDOW (f));
RGBForeColor (GC_FORE_COLOR (gc));
SetRect (&r, x, y, x + width + 1, y + height + 1);
@@ -641,35 +612,6 @@ mac_draw_rectangle (display, w, gc, x, y, width, height)
}
-#if 0 /* TODO: figure out if we need to do this on Mac. */
-/* Mac replacement for XDrawRectangle: dest is a Pixmap. */
-
-static void
-mac_draw_rectangle_to_pixmap (display, p, gc, x, y, width, height)
- Display *display;
- Pixmap p;
- GC gc;
- int x, y;
- unsigned int width, height;
-{
- CGrafPtr old_port;
- GDHandle old_gdh;
- Rect r;
-
- GetGWorld (&old_port, &old_gdh);
- SetGWorld (p, NULL);
- RGBForeColor (GC_FORE_COLOR (gc));
- SetRect (&r, x, y, x + width + 1, y + height + 1);
-
- LockPixels (GetGWorldPixMap (p));
- FrameRect (&r); /* using foreground color of gc */
- UnlockPixels (GetGWorldPixMap (p));
-
- SetGWorld (old_port, old_gdh);
-}
-#endif
-
-
#if USE_ATSUI
static OSStatus
atsu_get_text_layout_with_text_ptr (text, text_length, style, text_layout)
@@ -726,16 +668,16 @@ atsu_get_text_layout_with_text_ptr (text, text_length, style, text_layout)
}
#endif
+
static void
-mac_invert_rectangle (display, w, x, y, width, height)
- Display *display;
- WindowPtr w;
+mac_invert_rectangle (f, x, y, width, height)
+ struct frame *f;
int x, y;
unsigned int width, height;
{
Rect r;
- SetPortWindowPort (w);
+ SetPortWindowPort (FRAME_MAC_WINDOW (f));
SetRect (&r, x, y, x + width, y + height);
@@ -744,10 +686,8 @@ mac_invert_rectangle (display, w, x, y, width, height)
static void
-mac_draw_string_common (display, w, gc, x, y, buf, nchars, mode,
- bytes_per_char)
- Display *display;
- WindowPtr w;
+mac_draw_string_common (f, gc, x, y, buf, nchars, mode, bytes_per_char)
+ struct frame *f;
GC gc;
int x, y;
char *buf;
@@ -761,7 +701,7 @@ mac_draw_string_common (display, w, gc, x, y, buf, nchars, mode,
}
#endif
- SetPortWindowPort (w);
+ SetPortWindowPort (FRAME_MAC_WINDOW (f));
RGBForeColor (GC_FORE_COLOR (gc));
if (mode != srcOr)
@@ -806,16 +746,13 @@ mac_draw_string_common (display, w, gc, x, y, buf, nchars, mode,
{
CGrafPtr port;
CGContextRef context;
- Rect rect;
- float port_height;
+ float port_height = FRAME_PIXEL_HEIGHT (f);
ATSUAttributeTag tags[] = {kATSUCGContextTag};
ByteCount sizes[] = {sizeof (CGContextRef)};
ATSUAttributeValuePtr values[] = {&context};
GetPort (&port);
QDBeginCGContext (port, &context);
- GetPortBounds (port, &rect);
- port_height = rect.bottom - rect.top;
if (gc->n_clip_rects)
{
CGContextTranslateCTM (context, 0, port_height);
@@ -864,7 +801,7 @@ mac_draw_string_common (display, w, gc, x, y, buf, nchars, mode,
#endif
if (mode != srcOr)
- RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (w)));
+ RGBBackColor (GC_BACK_COLOR (FRAME_NORMAL_GC (f)));
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
if (!NILP(Vmac_use_core_graphics))
SwapQDTextFlags(savedFlags);
@@ -875,73 +812,65 @@ mac_draw_string_common (display, w, gc, x, y, buf, nchars, mode,
/* Mac replacement for XDrawString. */
static void
-XDrawString (display, w, gc, x, y, buf, nchars)
- Display *display;
- WindowPtr w;
+mac_draw_string (f, gc, x, y, buf, nchars)
+ struct frame *f;
GC gc;
int x, y;
char *buf;
int nchars;
{
- mac_draw_string_common (display, w, gc, x, y, buf, nchars, srcOr, 1);
+ mac_draw_string_common (f, gc, x, y, buf, nchars, srcOr, 1);
}
/* Mac replacement for XDrawString16. */
static void
-XDrawString16 (display, w, gc, x, y, buf, nchars)
- Display *display;
- WindowPtr w;
+mac_draw_string_16 (f, gc, x, y, buf, nchars)
+ struct frame *f;
GC gc;
int x, y;
XChar2b *buf;
int nchars;
{
- mac_draw_string_common (display, w, gc, x, y, (char *) buf, nchars, srcOr,
- 2);
+ mac_draw_string_common (f, gc, x, y, (char *) buf, nchars, srcOr, 2);
}
/* Mac replacement for XDrawImageString. */
static void
-XDrawImageString (display, w, gc, x, y, buf, nchars)
- Display *display;
- WindowPtr w;
+mac_draw_image_string (f, gc, x, y, buf, nchars)
+ struct frame *f;
GC gc;
int x, y;
char *buf;
int nchars;
{
- mac_draw_string_common (display, w, gc, x, y, buf, nchars, srcCopy, 1);
+ mac_draw_string_common (f, gc, x, y, buf, nchars, srcCopy, 1);
}
/* Mac replacement for XDrawString16. */
static void
-XDrawImageString16 (display, w, gc, x, y, buf, nchars)
- Display *display;
- WindowPtr w;
+mac_draw_image_string_16 (f, gc, x, y, buf, nchars)
+ struct frame *f;
GC gc;
int x, y;
XChar2b *buf;
int nchars;
{
- mac_draw_string_common (display, w, gc, x, y, (char *) buf, nchars, srcCopy,
- 2);
+ mac_draw_string_common (f, gc, x, y, (char *) buf, nchars, srcCopy, 2);
}
/* Mac replacement for XCopyArea: dest must be window. */
static void
-mac_copy_area (display, src, dest, gc, src_x, src_y, width, height, dest_x,
- dest_y)
- Display *display;
+mac_copy_area (src, f, gc, src_x, src_y, width, height, dest_x, dest_y)
Pixmap src;
- WindowPtr dest;
+ struct frame *f;
GC gc;
int src_x, src_y;
unsigned int width, height;
@@ -949,7 +878,7 @@ mac_copy_area (display, src, dest, gc, src_x, src_y, width, height, dest_x,
{
Rect src_r, dest_r;
- SetPortWindowPort (dest);
+ SetPortWindowPort (FRAME_MAC_WINDOW (f));
SetRect (&src_r, src_x, src_y, src_x + width, src_y + height);
SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height);
@@ -960,28 +889,32 @@ mac_copy_area (display, src, dest, gc, src_x, src_y, width, height, dest_x,
mac_begin_clip (GC_CLIP_REGION (gc));
LockPixels (GetGWorldPixMap (src));
#if TARGET_API_MAC_CARBON
- LockPortBits (GetWindowPort (dest));
- CopyBits (GetPortBitMapForCopyBits (src),
- GetPortBitMapForCopyBits (GetWindowPort (dest)),
- &src_r, &dest_r, srcCopy, 0);
- UnlockPortBits (GetWindowPort (dest));
+ {
+ CGrafPtr port;
+
+ GetPort (&port);
+ LockPortBits (port);
+ CopyBits (GetPortBitMapForCopyBits (src),
+ GetPortBitMapForCopyBits (port),
+ &src_r, &dest_r, srcCopy, 0);
+ UnlockPortBits (port);
+ }
#else /* not TARGET_API_MAC_CARBON */
- CopyBits (&(((GrafPtr)src)->portBits), &(dest->portBits),
+ CopyBits (&(((GrafPtr)src)->portBits), &(FRAME_MAC_WINDOW (f)->portBits),
&src_r, &dest_r, srcCopy, 0);
#endif /* not TARGET_API_MAC_CARBON */
UnlockPixels (GetGWorldPixMap (src));
mac_end_clip (GC_CLIP_REGION (gc));
- RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (dest)));
+ RGBBackColor (GC_BACK_COLOR (FRAME_NORMAL_GC (f)));
}
static void
-mac_copy_area_with_mask (display, src, mask, dest, gc, src_x, src_y,
+mac_copy_area_with_mask (src, mask, f, gc, src_x, src_y,
width, height, dest_x, dest_y)
- Display *display;
Pixmap src, mask;
- WindowPtr dest;
+ struct frame *f;
GC gc;
int src_x, src_y;
unsigned int width, height;
@@ -989,7 +922,7 @@ mac_copy_area_with_mask (display, src, mask, dest, gc, src_x, src_y,
{
Rect src_r, dest_r;
- SetPortWindowPort (dest);
+ SetPortWindowPort (FRAME_MAC_WINDOW (f));
SetRect (&src_r, src_x, src_y, src_x + width, src_y + height);
SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height);
@@ -1001,29 +934,33 @@ mac_copy_area_with_mask (display, src, mask, dest, gc, src_x, src_y,
LockPixels (GetGWorldPixMap (src));
LockPixels (GetGWorldPixMap (mask));
#if TARGET_API_MAC_CARBON
- LockPortBits (GetWindowPort (dest));
- CopyMask (GetPortBitMapForCopyBits (src), GetPortBitMapForCopyBits (mask),
- GetPortBitMapForCopyBits (GetWindowPort (dest)),
- &src_r, &src_r, &dest_r);
- UnlockPortBits (GetWindowPort (dest));
+ {
+ CGrafPtr port;
+
+ GetPort (&port);
+ LockPortBits (port);
+ CopyMask (GetPortBitMapForCopyBits (src), GetPortBitMapForCopyBits (mask),
+ GetPortBitMapForCopyBits (port),
+ &src_r, &src_r, &dest_r);
+ UnlockPortBits (port);
+ }
#else /* not TARGET_API_MAC_CARBON */
CopyMask (&(((GrafPtr)src)->portBits), &(((GrafPtr)mask)->portBits),
- &(dest->portBits), &src_r, &src_r, &dest_r);
+ &(FRAME_MAC_WINDOW (f)->portBits), &src_r, &src_r, &dest_r);
#endif /* not TARGET_API_MAC_CARBON */
UnlockPixels (GetGWorldPixMap (mask));
UnlockPixels (GetGWorldPixMap (src));
mac_end_clip (GC_CLIP_REGION (gc));
- RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (dest)));
+ RGBBackColor (GC_BACK_COLOR (FRAME_NORMAL_GC (f)));
}
/* Mac replacement for XCopyArea: used only for scrolling. */
static void
-mac_scroll_area (display, w, gc, src_x, src_y, width, height, dest_x, dest_y)
- Display *display;
- WindowPtr w;
+mac_scroll_area (f, gc, src_x, src_y, width, height, dest_x, dest_y)
+ struct frame *f;
GC gc;
int src_x, src_y;
unsigned int width, height;
@@ -1034,11 +971,13 @@ mac_scroll_area (display, w, gc, src_x, src_y, width, height, dest_x, dest_y)
RgnHandle dummy = NewRgn (); /* For avoiding update events. */
SetRect (&src_r, src_x, src_y, src_x + width, src_y + height);
- ScrollWindowRect (w, &src_r, dest_x - src_x, dest_y - src_y,
+ ScrollWindowRect (FRAME_MAC_WINDOW (f),
+ &src_r, dest_x - src_x, dest_y - src_y,
kScrollWindowNoOptions, dummy);
DisposeRgn (dummy);
#else /* not TARGET_API_MAC_CARBON */
Rect src_r, dest_r;
+ WindowPtr w = FRAME_MAC_WINDOW (f);
SetPort (w);
@@ -1053,93 +992,11 @@ mac_scroll_area (display, w, gc, src_x, src_y, width, height, dest_x, dest_y)
CopyBits (&(w->portBits), &(w->portBits), &src_r, &dest_r, srcCopy, 0);
mac_end_clip (GC_CLIP_REGION (gc));
- RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (w)));
+ RGBBackColor (GC_BACK_COLOR (FRAME_NORMAL_GC (f)));
#endif /* not TARGET_API_MAC_CARBON */
}
-#if 0 /* TODO: figure out if we need to do this on Mac. */
-/* Mac replacement for XCopyArea: dest must be Pixmap. */
-
-static void
-mac_copy_area_to_pixmap (display, src, dest, gc, src_x, src_y, width, height,
- dest_x, dest_y)
- Display *display;
- Pixmap src, dest;
- GC gc;
- int src_x, src_y;
- unsigned int width, height;
- int dest_x, dest_y;
-{
- CGrafPtr old_port;
- GDHandle old_gdh;
- Rect src_r, dest_r;
-
- GetGWorld (&old_port, &old_gdh);
- SetGWorld (dest, NULL);
- ForeColor (blackColor);
- BackColor (whiteColor);
-
- SetRect (&src_r, src_x, src_y, src_x + width, src_y + height);
- SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height);
-
- LockPixels (GetGWorldPixMap (src));
- LockPixels (GetGWorldPixMap (dest));
-#if TARGET_API_MAC_CARBON
- CopyBits (GetPortBitMapForCopyBits (src), GetPortBitMapForCopyBits (dest),
- &src_r, &dest_r, srcCopy, 0);
-#else /* not TARGET_API_MAC_CARBON */
- CopyBits (&(((GrafPtr)src)->portBits), &(((GrafPtr)dest)->portBits),
- &src_r, &dest_r, srcCopy, 0);
-#endif /* not TARGET_API_MAC_CARBON */
- UnlockPixels (GetGWorldPixMap (dest));
- UnlockPixels (GetGWorldPixMap (src));
-
- SetGWorld (old_port, old_gdh);
-}
-
-
-static void
-mac_copy_area_with_mask_to_pixmap (display, src, mask, dest, gc, src_x, src_y,
- width, height, dest_x, dest_y)
- Display *display;
- Pixmap src, mask, dest;
- GC gc;
- int src_x, src_y;
- unsigned int width, height;
- int dest_x, dest_y;
-{
- CGrafPtr old_port;
- GDHandle old_gdh;
- Rect src_r, dest_r;
-
- GetGWorld (&old_port, &old_gdh);
- SetGWorld (dest, NULL);
- ForeColor (blackColor);
- BackColor (whiteColor);
-
- SetRect (&src_r, src_x, src_y, src_x + width, src_y + height);
- SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height);
-
- LockPixels (GetGWorldPixMap (src));
- LockPixels (GetGWorldPixMap (mask));
- LockPixels (GetGWorldPixMap (dest));
-#if TARGET_API_MAC_CARBON
- CopyMask (GetPortBitMapForCopyBits (src), GetPortBitMapForCopyBits (mask),
- GetPortBitMapForCopyBits (dest), &src_r, &src_r, &dest_r);
-#else /* not TARGET_API_MAC_CARBON */
- CopyMask (&(((GrafPtr)src)->portBits), &(((GrafPtr)mask)->portBits),
- &(((GrafPtr)dest)->portBits), &src_r, &src_r, &dest_r);
-#endif /* not TARGET_API_MAC_CARBON */
- UnlockPixels (GetGWorldPixMap (dest));
- UnlockPixels (GetGWorldPixMap (mask));
- UnlockPixels (GetGWorldPixMap (src));
-
- SetGWorld (old_port, old_gdh);
-}
-#endif
-
-
/* Mac replacement for XChangeGC. */
static void
@@ -1511,8 +1368,7 @@ mac_draw_vertical_window_border (w, x, y0, y1)
XSetForeground (FRAME_MAC_DISPLAY (f), f->output_data.mac->normal_gc,
face->foreground);
- XDrawLine (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
- f->output_data.mac->normal_gc, x, y0, x, y1);
+ mac_draw_line (f, f->output_data.mac->normal_gc, x, y0, x, y1);
}
/* End update of window W (which is equal to updated_window).
@@ -1651,11 +1507,8 @@ x_after_update_window_line (desired_row)
y -= width;
BLOCK_INPUT;
- XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
- 0, y, width, height, 0);
- XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
- FRAME_PIXEL_WIDTH (f) - width, y,
- width, height, 0);
+ mac_clear_area (f, 0, y, width, height);
+ mac_clear_area (f, FRAME_PIXEL_WIDTH (f) - width, y, width, height);
UNBLOCK_INPUT;
}
}
@@ -1674,8 +1527,6 @@ x_draw_fringe_bitmap (w, row, p)
{
struct frame *f = XFRAME (WINDOW_FRAME (w));
Display *display = FRAME_MAC_DISPLAY (f);
- WindowPtr window = FRAME_MAC_WINDOW (f);
- GC gc = f->output_data.mac->normal_gc;
struct face *face = p->face;
int rowY;
@@ -1689,12 +1540,12 @@ x_draw_fringe_bitmap (w, row, p)
int oldVH = row->visible_height;
row->visible_height = p->h;
row->y -= rowY - p->y;
- x_clip_to_row (w, row, -1, gc);
+ x_clip_to_row (w, row, -1, face->gc);
row->y = oldY;
row->visible_height = oldVH;
}
else
- x_clip_to_row (w, row, -1, gc);
+ x_clip_to_row (w, row, -1, face->gc);
if (p->bx >= 0 && !p->overlay_p)
{
@@ -1709,7 +1560,7 @@ x_draw_fringe_bitmap (w, row, p)
XSetForeground (FRAME_X_DISPLAY (f), face->gc, face->background);
#endif
- mac_erase_rectangle (window, face->gc, p->bx, p->by, p->nx, p->ny);
+ mac_erase_rectangle (f, face->gc, p->bx, p->by, p->nx, p->ny);
#if 0 /* MAC_TODO: stipple */
if (!face->stipple)
@@ -1728,12 +1579,12 @@ x_draw_fringe_bitmap (w, row, p)
? (p->overlay_p ? face->background
: f->output_data.mac->cursor_pixel)
: face->foreground));
- mac_draw_bitmap (display, window, face->gc, p->x, p->y,
+ mac_draw_bitmap (f, face->gc, p->x, p->y,
p->wd, p->h, bits, p->overlay_p);
XSetForeground (display, face->gc, gcv.foreground);
}
- mac_reset_clip_rectangles (display, gc);
+ mac_reset_clip_rectangles (display, face->gc);
}
@@ -2284,7 +2135,7 @@ x_clear_glyph_string_rect (s, x, y, w, h)
struct glyph_string *s;
int x, y, w, h;
{
- mac_erase_rectangle (s->window, s->gc, x, y, w, h);
+ mac_erase_rectangle (s->f, s->gc, x, y, w, h);
}
@@ -2366,9 +2217,8 @@ x_draw_glyph_string_foreground (s)
for (i = 0; i < s->nchars; ++i)
{
struct glyph *g = s->first_glyph + i;
- mac_draw_rectangle (s->display, s->window,
- s->gc, x, s->y, g->pixel_width - 1,
- s->height - 1);
+ mac_draw_rectangle (s->f, s->gc, x, s->y,
+ g->pixel_width - 1, s->height - 1);
x += g->pixel_width;
}
}
@@ -2405,21 +2255,21 @@ x_draw_glyph_string_foreground (s)
|| GC_FONT (s->gc)->mac_style
#endif
)
- XDrawString16 (s->display, s->window, s->gc, x,
- s->ybase - boff, s->char2b, s->nchars);
+ mac_draw_string_16 (s->f, s->gc, x, s->ybase - boff,
+ s->char2b, s->nchars);
else
- XDrawString (s->display, s->window, s->gc, x,
- s->ybase - boff, char1b, s->nchars);
+ mac_draw_string (s->f, s->gc, x, s->ybase - boff,
+ char1b, s->nchars);
}
#if defined (MAC_OS8) && !USE_ATSUI
else
{
if (s->two_byte_p)
- XDrawImageString16 (s->display, s->window, s->gc, x,
- s->ybase - boff, s->char2b, s->nchars);
+ mac_draw_image_string_16 (s->f, s->gc, x, s->ybase - boff,
+ s->char2b, s->nchars);
else
- XDrawImageString (s->display, s->window, s->gc, x,
- s->ybase - boff, char1b, s->nchars);
+ mac_draw_image_string (s->f, s->gc, x, s->ybase - boff,
+ char1b, s->nchars);
}
#endif
}
@@ -2451,16 +2301,16 @@ x_draw_composite_glyph_string_foreground (s)
if (s->font_not_found_p)
{
if (s->gidx == 0)
- mac_draw_rectangle (s->display, s->window, s->gc, x, s->y,
- s->width - 1, s->height - 1);
+ mac_draw_rectangle (s->f, s->gc, x, s->y,
+ s->width - 1, s->height - 1);
}
else
{
for (i = 0; i < s->nchars; i++, ++s->gidx)
- XDrawString16 (s->display, s->window, s->gc,
- x + s->cmp->offsets[s->gidx * 2],
- s->ybase - s->cmp->offsets[s->gidx * 2 + 1],
- s->char2b + i, 1);
+ mac_draw_string_16 (s->f, s->gc,
+ x + s->cmp->offsets[s->gidx * 2],
+ s->ybase - s->cmp->offsets[s->gidx * 2 + 1],
+ s->char2b + i, 1);
}
}
@@ -2816,7 +2666,6 @@ x_draw_relief_rect (f, left_x, top_y, right_x, bottom_y, width,
Rect *clip_rect;
{
Display *dpy = FRAME_MAC_DISPLAY (f);
- Window window = FRAME_MAC_WINDOW (f);
int i;
GC gc;
@@ -2829,15 +2678,15 @@ x_draw_relief_rect (f, left_x, top_y, right_x, bottom_y, width,
/* Top. */
if (top_p)
for (i = 0; i < width; ++i)
- XDrawLine (dpy, window, gc,
- left_x + i * left_p, top_y + i,
- right_x - i * right_p, top_y + i);
+ mac_draw_line (f, gc,
+ left_x + i * left_p, top_y + i,
+ right_x - i * right_p, top_y + i);
/* Left. */
if (left_p)
for (i = 0; i < width; ++i)
- XDrawLine (dpy, window, gc,
- left_x + i, top_y + i, left_x + i, bottom_y - i);
+ mac_draw_line (f, gc,
+ left_x + i, top_y + i, left_x + i, bottom_y - i);
mac_reset_clip_rectangles (dpy, gc);
if (raised_p)
@@ -2849,15 +2698,15 @@ x_draw_relief_rect (f, left_x, top_y, right_x, bottom_y, width,
/* Bottom. */
if (bot_p)
for (i = 0; i < width; ++i)
- XDrawLine (dpy, window, gc,
- left_x + i * left_p, bottom_y - i,
- right_x - i * right_p, bottom_y - i);
+ mac_draw_line (f, gc,
+ left_x + i * left_p, bottom_y - i,
+ right_x - i * right_p, bottom_y - i);
/* Right. */
if (right_p)
for (i = 0; i < width; ++i)
- XDrawLine (dpy, window, gc,
- right_x - i, top_y + i + 1, right_x - i, bottom_y - i - 1);
+ mac_draw_line (f, gc,
+ right_x - i, top_y + i + 1, right_x - i, bottom_y - i - 1);
mac_reset_clip_rectangles (dpy, gc);
}
@@ -2884,22 +2733,22 @@ x_draw_box_rect (s, left_x, top_y, right_x, bottom_y, width,
mac_set_clip_rectangles (s->display, s->gc, clip_rect, 1);
/* Top. */
- XFillRectangle (s->display, s->window, s->gc,
- left_x, top_y, right_x - left_x + 1, width);
+ mac_fill_rectangle (s->f, s->gc, left_x, top_y,
+ right_x - left_x + 1, width);
/* Left. */
if (left_p)
- XFillRectangle (s->display, s->window, s->gc,
- left_x, top_y, width, bottom_y - top_y + 1);
+ mac_fill_rectangle (s->f, s->gc, left_x, top_y,
+ width, bottom_y - top_y + 1);
/* Bottom. */
- XFillRectangle (s->display, s->window, s->gc,
- left_x, bottom_y - width + 1, right_x - left_x + 1, width);
+ mac_fill_rectangle (s->f, s->gc, left_x, bottom_y - width + 1,
+ right_x - left_x + 1, width);
/* Right. */
if (right_p)
- XFillRectangle (s->display, s->window, s->gc,
- right_x - width + 1, top_y, width, bottom_y - top_y + 1);
+ mac_fill_rectangle (s->f, s->gc, right_x - width + 1,
+ top_y, width, bottom_y - top_y + 1);
XSetForeground (s->display, s->gc, xgcv.foreground);
mac_reset_clip_rectangles (s->display, s->gc);
@@ -2986,13 +2835,13 @@ x_draw_image_foreground (s)
x_set_glyph_string_clipping (s);
if (s->img->mask)
- mac_copy_area_with_mask (s->display, s->img->pixmap, s->img->mask,
- s->window, s->gc, s->slice.x, s->slice.y,
+ mac_copy_area_with_mask (s->img->pixmap, s->img->mask,
+ s->f, s->gc, s->slice.x, s->slice.y,
s->slice.width, s->slice.height, x, y);
else
{
- mac_copy_area (s->display, s->img->pixmap,
- s->window, s->gc, s->slice.x, s->slice.y,
+ mac_copy_area (s->img->pixmap,
+ s->f, s->gc, s->slice.x, s->slice.y,
s->slice.width, s->slice.height, x, y);
/* When the image has a mask, we can expect that at
@@ -3005,8 +2854,7 @@ x_draw_image_foreground (s)
{
int r = s->img->relief;
if (r < 0) r = -r;
- mac_draw_rectangle (s->display, s->window, s->gc,
- x - r, y - r,
+ mac_draw_rectangle (s->f, s->gc, x - r, y - r,
s->slice.width + r*2 - 1,
s->slice.height + r*2 - 1);
}
@@ -3014,7 +2862,7 @@ x_draw_image_foreground (s)
}
else
/* Draw a rectangle if image could not be loaded. */
- mac_draw_rectangle (s->display, s->window, s->gc, x, y,
+ mac_draw_rectangle (s->f, s->gc, x, y,
s->slice.width - 1, s->slice.height - 1);
}
@@ -3072,70 +2920,6 @@ x_draw_image_relief (s)
}
-#if 0 /* TODO: figure out if we need to do this on Mac. */
-/* Draw the foreground of image glyph string S to PIXMAP. */
-
-static void
-x_draw_image_foreground_1 (s, pixmap)
- struct glyph_string *s;
- Pixmap pixmap;
-{
- int x = 0;
- int y = s->ybase - s->y - image_ascent (s->img, s->face, &s->slice);
-
- /* If first glyph of S has a left box line, start drawing it to the
- right of that line. */
- if (s->face->box != FACE_NO_BOX
- && s->first_glyph->left_box_line_p
- && s->slice.x == 0)
- x += abs (s->face->box_line_width);
-
- /* If there is a margin around the image, adjust x- and y-position
- by that margin. */
- if (s->slice.x == 0)
- x += s->img->hmargin;
- if (s->slice.y == 0)
- y += s->img->vmargin;
-
- if (s->img->pixmap)
- {
- if (s->img->mask)
- mac_copy_area_with_mask_to_pixmap (s->display, s->img->pixmap,
- s->img->mask, pixmap, s->gc,
- s->slice.x, s->slice.y,
- s->slice.width, s->slice.height,
- x, y);
- else
- {
- mac_copy_area_to_pixmap (s->display, s->img->pixmap, pixmap, s->gc,
- s->slice.x, s->slice.y,
- s->slice.width, s->slice.height,
- x, y);
-
- /* When the image has a mask, we can expect that at
- least part of a mouse highlight or a block cursor will
- be visible. If the image doesn't have a mask, make
- a block cursor visible by drawing a rectangle around
- the image. I believe it's looking better if we do
- nothing here for mouse-face. */
- if (s->hl == DRAW_CURSOR)
- {
- int r = s->img->relief;
- if (r < 0) r = -r;
- mac_draw_rectangle (s->display, s->window, s->gc, x - r, y - r,
- s->slice.width + r*2 - 1,
- s->slice.height + r*2 - 1);
- }
- }
- }
- else
- /* Draw a rectangle if image could not be loaded. */
- mac_draw_rectangle_to_pixmap (s->display, pixmap, s->gc, x, y,
- s->slice.width - 1, s->slice.height - 1);
-}
-#endif
-
-
/* Draw part of the background of glyph string S. X, Y, W, and H
give the rectangle to draw. */
@@ -3205,62 +2989,13 @@ x_draw_image_glyph_string (s)
if (s->slice.y == 0)
y += box_line_vwidth;
-#if 0 /* TODO: figure out if we need to do this on Mac. */
- if (s->img->mask)
- {
- /* Create a pixmap as large as the glyph string. Fill it
- with the background color. Copy the image to it, using
- its mask. Copy the temporary pixmap to the display. */
- int depth = one_mac_display_info.n_planes;
-
- /* Create a pixmap as large as the glyph string. */
- pixmap = XCreatePixmap (s->display, s->window,
- s->background_width,
- s->height, depth);
-
- /* Fill the pixmap with the background color/stipple. */
-#if 0 /* TODO: stipple */
- if (s->stippled_p)
- {
- /* Fill background with a stipple pattern. */
- XSetFillStyle (s->display, s->gc, FillOpaqueStippled);
- XFillRectangle (s->display, pixmap, s->gc,
- 0, 0, s->background_width, s->height);
- XSetFillStyle (s->display, s->gc, FillSolid);
- }
- else
-#endif
- {
- XGCValues xgcv;
- XGetGCValues (s->display, s->gc, GCForeground | GCBackground,
- &xgcv);
- XSetForeground (s->display, s->gc, xgcv.background);
- mac_fill_rectangle_to_pixmap (s->display, pixmap, s->gc,
- 0, 0, s->background_width,
- s->height);
- XSetForeground (s->display, s->gc, xgcv.foreground);
- }
- }
- else
-#endif
- x_draw_glyph_string_bg_rect (s, x, y, s->background_width, height);
+ x_draw_glyph_string_bg_rect (s, x, y, s->background_width, height);
s->background_filled_p = 1;
}
/* Draw the foreground. */
-#if 0 /* TODO: figure out if we need to do this on Mac. */
- if (pixmap != 0)
- {
- x_draw_image_foreground_1 (s, pixmap);
- x_set_glyph_string_clipping (s);
- mac_copy_area (s->display, pixmap, s->window, s->gc,
- 0, 0, s->background_width, s->height, s->x, s->y);
- XFreePixmap (s->display, pixmap);
- }
- else
-#endif
- x_draw_image_foreground (s);
+ x_draw_image_foreground (s);
/* If we must draw a relief around the image, do it. */
if (s->img->relief
@@ -3319,7 +3054,7 @@ x_draw_stretch_glyph_string (s)
}
else
#endif /* MAC_TODO */
- mac_erase_rectangle (s->window, gc, x, y, w, h);
+ mac_erase_rectangle (s->f, gc, x, y, w, h);
}
}
else if (!s->background_filled_p)
@@ -3410,15 +3145,15 @@ x_draw_glyph_string (s)
unsigned long dy = s->height - h;
if (s->face->underline_defaulted_p)
- XFillRectangle (s->display, s->window, s->gc, s->x, s->y + dy,
- s->width, h);
+ mac_fill_rectangle (s->f, s->gc, s->x, s->y + dy,
+ s->width, h);
else
{
XGCValues xgcv;
XGetGCValues (s->display, s->gc, GCForeground, &xgcv);
XSetForeground (s->display, s->gc, s->face->underline_color);
- XFillRectangle (s->display, s->window, s->gc, s->x, s->y + dy,
- s->width, h);
+ mac_fill_rectangle (s->f, s->gc, s->x, s->y + dy,
+ s->width, h);
XSetForeground (s->display, s->gc, xgcv.foreground);
}
}
@@ -3429,15 +3164,15 @@ x_draw_glyph_string (s)
unsigned long dy = 0, h = 1;
if (s->face->overline_color_defaulted_p)
- XFillRectangle (s->display, s->window, s->gc, s->x, s->y + dy,
- s->width, h);
+ mac_fill_rectangle (s->f, s->gc, s->x, s->y + dy,
+ s->width, h);
else
{
XGCValues xgcv;
XGetGCValues (s->display, s->gc, GCForeground, &xgcv);
XSetForeground (s->display, s->gc, s->face->overline_color);
- XFillRectangle (s->display, s->window, s->gc, s->x, s->y + dy,
- s->width, h);
+ mac_fill_rectangle (s->f, s->gc, s->x, s->y + dy,
+ s->width, h);
XSetForeground (s->display, s->gc, xgcv.foreground);
}
}
@@ -3449,15 +3184,15 @@ x_draw_glyph_string (s)
unsigned long dy = (s->height - h) / 2;
if (s->face->strike_through_color_defaulted_p)
- XFillRectangle (s->display, s->window, s->gc, s->x, s->y + dy,
- s->width, h);
+ mac_fill_rectangle (s->f, s->gc, s->x, s->y + dy,
+ s->width, h);
else
{
XGCValues xgcv;
XGetGCValues (s->display, s->gc, GCForeground, &xgcv);
XSetForeground (s->display, s->gc, s->face->strike_through_color);
- XFillRectangle (s->display, s->window, s->gc, s->x, s->y + dy,
- s->width, h);
+ mac_fill_rectangle (s->f, s->gc, s->x, s->y + dy,
+ s->width, h);
XSetForeground (s->display, s->gc, xgcv.foreground);
}
}
@@ -3478,8 +3213,7 @@ mac_shift_glyphs_for_insert (f, x, y, width, height, shift_by)
struct frame *f;
int x, y, width, height, shift_by;
{
- mac_scroll_area (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
- f->output_data.mac->normal_gc,
+ mac_scroll_area (f, f->output_data.mac->normal_gc,
x, y, width, height,
x + shift_by, y);
}
@@ -3517,7 +3251,7 @@ x_clear_frame ()
/* We don't set the output cursor here because there will always
follow an explicit cursor_to. */
BLOCK_INPUT;
- XClearWindow (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f));
+ mac_clear_window (f);
/* We have to clear the scroll bars, too. If we have changed
colors or something like that, then they should be notified. */
@@ -3607,21 +3341,18 @@ XTflash (f)
/* If window is tall, flash top and bottom line. */
if (height > 3 * FRAME_LINE_HEIGHT (f))
{
- mac_invert_rectangle (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
- flash_left,
+ mac_invert_rectangle (f, flash_left,
(FRAME_INTERNAL_BORDER_WIDTH (f)
+ FRAME_TOOL_BAR_LINES (f) * FRAME_LINE_HEIGHT (f)),
width, flash_height);
- mac_invert_rectangle (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
- flash_left,
+ mac_invert_rectangle (f, flash_left,
(height - flash_height
- FRAME_INTERNAL_BORDER_WIDTH (f)),
width, flash_height);
}
else
/* If it is short, flash it all. */
- mac_invert_rectangle (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
- flash_left, FRAME_INTERNAL_BORDER_WIDTH (f),
+ mac_invert_rectangle (f, flash_left, FRAME_INTERNAL_BORDER_WIDTH (f),
width, height - 2 * FRAME_INTERNAL_BORDER_WIDTH (f));
x_flush (f);
@@ -3661,21 +3392,18 @@ XTflash (f)
/* If window is tall, flash top and bottom line. */
if (height > 3 * FRAME_LINE_HEIGHT (f))
{
- mac_invert_rectangle (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
- flash_left,
+ mac_invert_rectangle (f, flash_left,
(FRAME_INTERNAL_BORDER_WIDTH (f)
+ FRAME_TOOL_BAR_LINES (f) * FRAME_LINE_HEIGHT (f)),
width, flash_height);
- mac_invert_rectangle (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
- flash_left,
+ mac_invert_rectangle (f, flash_left,
(height - flash_height
- FRAME_INTERNAL_BORDER_WIDTH (f)),
width, flash_height);
}
else
/* If it is short, flash it all. */
- mac_invert_rectangle (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
- flash_left, FRAME_INTERNAL_BORDER_WIDTH (f),
+ mac_invert_rectangle (f, flash_left, FRAME_INTERNAL_BORDER_WIDTH (f),
width, height - 2 * FRAME_INTERNAL_BORDER_WIDTH (f));
x_flush (f);
@@ -3780,11 +3508,10 @@ x_scroll_run (w, run)
updated_window = w;
x_clear_cursor (w);
- mac_scroll_area (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
- f->output_data.mac->normal_gc,
- x, from_y,
- width, height,
- x, to_y);
+ mac_scroll_area (f, f->output_data.mac->normal_gc,
+ x, from_y,
+ width, height,
+ x, to_y);
UNBLOCK_INPUT;
}
@@ -4185,10 +3912,7 @@ note_mouse_movement (frame, pos)
return 1;
}
/* Has the mouse moved off the glyph it was on at the last sighting? */
- if (pos->h < last_mouse_glyph.left
- || pos->h >= last_mouse_glyph.right
- || pos->v < last_mouse_glyph.top
- || pos->v >= last_mouse_glyph.bottom)
+ if (!PtInRect (*pos, &last_mouse_glyph))
{
frame->mouse_moved = 1;
last_mouse_scroll_bar = Qnil;
@@ -4831,8 +4555,7 @@ XTset_vertical_scroll_bar (w, portion, whole, position)
if (NILP (w->vertical_scroll_bar))
{
BLOCK_INPUT;
- XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
- left, top, width, height, 0);
+ mac_clear_area (f, left, top, width, height);
UNBLOCK_INPUT;
bar = x_scroll_bar_create (w, top, sb_left, sb_width, height, disp_top,
disp_height);
@@ -4856,14 +4579,7 @@ XTset_vertical_scroll_bar (w, portion, whole, position)
{
/* Since toolkit scroll bars are smaller than the space reserved
for them on the frame, we have to clear "under" them. */
- XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
- left, top, width, height, 0);
-
-#if 0
- if (sb_left + sb_width >= FRAME_PIXEL_WIDTH (f))
- XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
- sb_left - 1, top, 1, height, 0);
-#endif
+ mac_clear_area (f, left, top, width, height);
HideControl (ch);
MoveControl (ch, sb_left + VERTICAL_SCROLL_BAR_WIDTH_TRIM, disp_top);
@@ -5296,7 +5012,7 @@ x_draw_hollow_cursor (w, row)
/* Set clipping, draw the rectangle, and reset clipping again. */
x_clip_to_row (w, row, TEXT_AREA, gc);
- mac_draw_rectangle (dpy, FRAME_MAC_WINDOW (f), gc, x, y, wd, h);
+ mac_draw_rectangle (f, gc, x, y, wd, h);
mac_reset_clip_rectangles (dpy, gc);
}
@@ -5369,17 +5085,17 @@ x_draw_bar_cursor (w, row, width, kind)
x_clip_to_row (w, row, TEXT_AREA, gc);
if (kind == BAR_CURSOR)
- XFillRectangle (dpy, window, gc,
- WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x),
- WINDOW_TO_FRAME_PIXEL_Y (w, w->phys_cursor.y),
- width, row->height);
+ mac_fill_rectangle (f, gc,
+ WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x),
+ WINDOW_TO_FRAME_PIXEL_Y (w, w->phys_cursor.y),
+ width, row->height);
else
- XFillRectangle (dpy, window, gc,
- WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x),
- WINDOW_TO_FRAME_PIXEL_Y (w, w->phys_cursor.y +
- row->height - width),
- cursor_glyph->pixel_width,
- width);
+ mac_fill_rectangle (f, gc,
+ WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x),
+ WINDOW_TO_FRAME_PIXEL_Y (w, w->phys_cursor.y +
+ row->height - width),
+ cursor_glyph->pixel_width,
+ width);
mac_reset_clip_rectangles (dpy, gc);
}
@@ -5404,8 +5120,7 @@ mac_clear_frame_area (f, x, y, width, height)
struct frame *f;
int x, y, width, height;
{
- XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
- x, y, width, height, 0);
+ mac_clear_area (f, x, y, width, height);
}
@@ -9824,7 +9539,8 @@ XTread_socket (sd, expected, hold_quit)
}
}
- if (er.what != mouseDown && part_code != inContent)
+ if (er.what != mouseDown &&
+ (part_code != inContent || dpyinfo->grabbed == 0))
break;
switch (part_code)
@@ -9947,12 +9663,6 @@ XTread_socket (sd, expected, hold_quit)
{
dpyinfo->grabbed |= (1 << inev.code);
last_mouse_frame = f;
- /* Ignore any mouse motion that happened
- before this event; any subsequent
- mouse-movement Emacs events should reflect
- only motion after the ButtonPress. */
- if (f != 0)
- f->mouse_moved = 0;
if (!tool_bar_p)
last_tool_bar_item = -1;
@@ -9968,6 +9678,13 @@ XTread_socket (sd, expected, hold_quit)
dpyinfo->grabbed &= ~(1 << inev.code);
}
+ /* Ignore any mouse motion that happened before
+ this event; any subsequent mouse-movement Emacs
+ events should reflect only motion after the
+ ButtonPress. */
+ if (f != 0)
+ f->mouse_moved = 0;
+
#ifdef USE_TOOLKIT_SCROLL_BARS
if (inev.kind == MOUSE_CLICK_EVENT)
#endif
diff --git a/src/macterm.h b/src/macterm.h
index e7a5fc2450e..277fd2051c6 100644
--- a/src/macterm.h
+++ b/src/macterm.h
@@ -562,6 +562,8 @@ 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 mac_clear_area P_ ((struct frame *, int, int,
+ unsigned int, unsigned int));
extern void mac_unload_font P_ ((struct mac_display_info *, XFontStruct *));
extern OSErr install_window_handler P_ ((WindowPtr));
extern void remove_window_handler P_ ((WindowPtr));
diff --git a/src/minibuf.c b/src/minibuf.c
index b7f9fd4838c..74d55a8abfd 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -2342,7 +2342,7 @@ Return nil if there is no valid completion, else t. */)
}
DEFUN ("display-completion-list", Fdisplay_completion_list, Sdisplay_completion_list,
- 1, 1, 0,
+ 1, 2, 0,
doc: /* Display the list of completions, COMPLETIONS, using `standard-output'.
Each element may be just a symbol or string
or may be a list of two strings to be printed as if concatenated.
@@ -2352,14 +2352,23 @@ alternative, the second serves as annotation.
The actual completion alternatives, as inserted, are given `mouse-face'
properties of `highlight'.
At the end, this runs the normal hook `completion-setup-hook'.
-It can find the completion buffer in `standard-output'. */)
- (completions)
+It can find the completion buffer in `standard-output'.
+The optional second arg COMMON-SUBSTRING is a string.
+It is used to put faces, `completions-first-difference` and
+`completions-common-part' on the completion buffer. The
+`completions-common-part' face is put on the common substring
+specified by COMMON-SUBSTRING. If COMMON-SUBSTRING is nil,
+the faces are not put.
+Internally, COMMON-SUBSTRING is bound to `completion-common-substring'
+during running `completion-setup-hook'. */)
+ (completions, common_substring)
Lisp_Object completions;
+ Lisp_Object common_substring;
{
Lisp_Object tail, elt;
register int i;
int column = 0;
- struct gcpro gcpro1, gcpro2;
+ struct gcpro gcpro1, gcpro2, gcpro3;
struct buffer *old = current_buffer;
int first = 1;
@@ -2368,7 +2377,7 @@ It can find the completion buffer in `standard-output'. */)
except for ELT. ELT can be pointing to a string
when terpri or Findent_to calls a change hook. */
elt = Qnil;
- GCPRO2 (completions, elt);
+ GCPRO3 (completions, elt, common_substring);
if (BUFFERP (Vstandard_output))
set_buffer_internal (XBUFFER (Vstandard_output));
@@ -2517,17 +2526,32 @@ It can find the completion buffer in `standard-output'. */)
}
}
- UNGCPRO;
-
if (BUFFERP (Vstandard_output))
set_buffer_internal (old);
if (!NILP (Vrun_hooks))
- call1 (Vrun_hooks, intern ("completion-setup-hook"));
+ {
+ int count1 = SPECPDL_INDEX ();
+
+ specbind (intern ("completion-common-substring"), common_substring);
+ call1 (Vrun_hooks, intern ("completion-setup-hook"));
+
+ unbind_to (count1, Qnil);
+ }
+
+ UNGCPRO;
return Qnil;
}
+
+static Lisp_Object
+display_completion_list_1 (list)
+ Lisp_Object list;
+{
+ return Fdisplay_completion_list (list, Qnil);
+}
+
DEFUN ("minibuffer-completion-help", Fminibuffer_completion_help, Sminibuffer_completion_help,
0, 0, "",
doc: /* Display a list of possible completions of the current minibuffer contents. */)
@@ -2549,7 +2573,7 @@ DEFUN ("minibuffer-completion-help", Fminibuffer_completion_help, Sminibuffer_co
}
else
internal_with_output_to_temp_buffer ("*Completions*",
- Fdisplay_completion_list,
+ display_completion_list_1,
Fsort (completions, Qstring_lessp));
return Qnil;
}
diff --git a/src/search.c b/src/search.c
index 0a28085308a..346c0e589fa 100644
--- a/src/search.c
+++ b/src/search.c
@@ -395,7 +395,7 @@ string_match_1 (regexp, string, start, posix)
DEFUN ("string-match", Fstring_match, Sstring_match, 2, 3, 0,
doc: /* Return index of start of first match for REGEXP in STRING, or nil.
-Case is ignored if `case-fold-search' is non-nil in the current buffer.
+Matching ignores case if `case-fold-search' is non-nil.
If third arg START is non-nil, start search at that index in STRING.
For index of first char beyond the match, do (match-end 0).
`match-end' and `match-beginning' also give indices of substrings
@@ -1687,7 +1687,7 @@ boyer_moore (n, base_pat, len, len_byte, trt, inverse_trt,
if (ASCII_BYTE_P (*ptr) || ! multibyte)
ch = *ptr;
else if (char_base
- && (pat_end - ptr) == 1 || CHAR_HEAD_P (ptr[1]))
+ && ((pat_end - ptr) == 1 || CHAR_HEAD_P (ptr[1])))
{
unsigned char *charstart = ptr - 1;
diff --git a/src/syssignal.h b/src/syssignal.h
index 6a5cd39bde9..43e8847cea5 100644
--- a/src/syssignal.h
+++ b/src/syssignal.h
@@ -146,7 +146,10 @@ extern SIGMASKTYPE sigprocmask_set;
#undef SIGINFO
#endif
#if defined (SIGIO) && defined (BROKEN_SIGIO)
-#undef SIGIO
+# undef SIGIO
+# if defined (__Lynx__)
+# undef SIGPOLL /* Defined as SIGIO on LynxOS */
+# endif
#endif
#if defined (SIGPOLL) && defined (BROKEN_SIGPOLL)
#undef SIGPOLL
diff --git a/src/term.c b/src/term.c
index eb575c1792e..0a409931fc1 100644
--- a/src/term.c
+++ b/src/term.c
@@ -820,7 +820,7 @@ encode_terminal_code (src, src_len, coding)
int src_len;
struct coding_system *coding;
{
- struct glyph *src_start = src, *src_end = src + src_len;
+ struct glyph *src_end = src + src_len;
register GLYPH g;
unsigned char *buf;
int nchars, nbytes, required;
@@ -1836,7 +1836,7 @@ produce_stretch_glyph (it)
&& calc_pixel_width_or_height (&tem, it, prop, 0, 1, &align_to))
{
if (it->glyph_row == NULL || !it->glyph_row->mode_line_p)
- align_to = (align_to < 0
+ align_to = (align_to < 0
? 0
: align_to - window_box_left_offset (it->w, TEXT_AREA));
else if (align_to < 0)
diff --git a/src/unexelf.c b/src/unexelf.c
index e33a9a1aeb3..f50e849fdcf 100644
--- a/src/unexelf.c
+++ b/src/unexelf.c
@@ -702,7 +702,7 @@ unexec (new_name, old_name, data_start, bss_start, entry_address)
#if MAP_ANON == 0
mmap_fd = open ("/dev/zero", O_RDONLY);
if (mmap_fd < 0)
- fatal ("Can't open /dev/zero for reading: errno %d\n", errno);
+ fatal ("Can't open /dev/zero for reading: errno %d\n", errno, 0);
#endif
/* We cannot use malloc here because that may use sbrk. If it does,
@@ -713,7 +713,7 @@ unexec (new_name, old_name, data_start, bss_start, entry_address)
old_base = mmap (NULL, old_file_size, PROT_READ | PROT_WRITE,
MAP_ANON | MAP_PRIVATE, mmap_fd, 0);
if (old_base == MAP_FAILED)
- fatal ("Can't allocate buffer for %s\n", old_name);
+ fatal ("Can't allocate buffer for %s\n", old_name, 0);
if (read (old_file, old_base, stat_buf.st_size) != stat_buf.st_size)
fatal ("Didn't read all of %s: errno %d\n", old_name, errno);
@@ -802,7 +802,7 @@ unexec (new_name, old_name, data_start, bss_start, entry_address)
new_base = mmap (NULL, new_file_size, PROT_READ | PROT_WRITE,
MAP_ANON | MAP_PRIVATE, mmap_fd, 0);
if (new_base == MAP_FAILED)
- fatal ("Can't allocate buffer for %s\n", old_name);
+ fatal ("Can't allocate buffer for %s\n", old_name, 0);
new_file_h = (ElfW(Ehdr) *) new_base;
new_program_h = (ElfW(Phdr) *) ((byte *) new_base + old_file_h->e_phoff);
@@ -1079,7 +1079,7 @@ unexec (new_name, old_name, data_start, bss_start, entry_address)
&& old_mdebug_index != -1)
{
int diff = NEW_SECTION_H(nn).sh_offset
- - OLD_SECTION_H(old_mdebug_index).sh_offset;
+ - OLD_SECTION_H(old_mdebug_index).sh_offset;
HDRR *phdr = (HDRR *)(NEW_SECTION_H (nn).sh_offset + new_base);
if (diff)
@@ -1257,9 +1257,13 @@ unexec (new_name, old_name, data_start, bss_start, entry_address)
/* Write out new_file, and free the buffers. */
if (write (new_file, new_base, new_file_size) != new_file_size)
+#ifndef emacs
+ fatal ("Didn't write %d bytes: errno %d\n",
+ new_file_size, errno);
+#else
fatal ("Didn't write %d bytes to %s: errno %d\n",
new_file_size, new_base, errno);
-
+#endif
munmap (old_base, old_file_size);
munmap (new_base, new_file_size);
diff --git a/src/window.c b/src/window.c
index 50212b0c114..be3ecaa2b0b 100644
--- a/src/window.c
+++ b/src/window.c
@@ -6293,7 +6293,6 @@ selected frame. */)
(frame)
Lisp_Object frame;
{
- Lisp_Object alist;
FRAME_PTR f;
if (NILP (frame))
diff --git a/src/xterm.c b/src/xterm.c
index ce46bd16f42..e20935f0be4 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -8100,7 +8100,6 @@ void
x_calc_absolute_position (f)
struct frame *f;
{
- int win_x = 0, win_y = 0;
int flags = f->size_hint_flags;
/* We have nothing to do if the current position