Boston, MA 02111-1307, USA. */
/* Image support (XBM, XPM, PBM, JPEG, TIFF, GIF, PNG, GS). tooltips,
- toolbars, busy-cursor, file selection dialog added by Gerd
+ tool-bars, busy-cursor, file selection dialog added by Gerd
Moellmann <gerd@gnu.org>. */
/* Completely rewritten by Richard Stallman. */
/* Rewritten for X11 by Joseph Arceneaux */
-#include <signal.h>
#include <config.h>
+#include <signal.h>
#include <stdio.h>
#include <math.h>
#ifdef HAVE_X_WINDOWS
-#ifdef STDC_HEADERS
-#include <stdlib.h>
-#else
-extern void abort ();
-#endif
#include <ctype.h>
/* On some systems, the character-composition stuff is broken in X11R5. */
Lisp_Object Qx_resource_name;
Lisp_Object Quser_position;
Lisp_Object Quser_size;
-Lisp_Object Qdisplay;
+extern Lisp_Object Qdisplay;
Lisp_Object Qscroll_bar_foreground, Qscroll_bar_background;
Lisp_Object Qscreen_gamma;
extern Lisp_Object Qheight, Qminibuffer, Qname, Qonly, Qwidth;
extern Lisp_Object Qunsplittable, Qmenu_bar_lines, Qbuffer_predicate, Qtitle;
-extern Lisp_Object Qtoolbar_lines;
+extern Lisp_Object Qtool_bar_lines;
extern Lisp_Object Vwindow_system_version;
FRAME_PTR f;
if (NILP (frame))
- f = selected_frame;
- else
- {
- CHECK_LIVE_FRAME (frame, 0);
- f = XFRAME (frame);
- }
+ frame = selected_frame;
+ CHECK_LIVE_FRAME (frame, 0);
+ f = XFRAME (frame);
if (! FRAME_X_P (f))
error ("Non-X frame used");
return f;
{
if (NILP (frame))
{
- if (FRAME_X_P (selected_frame)
- && FRAME_LIVE_P (selected_frame))
- return FRAME_X_DISPLAY_INFO (selected_frame);
+ struct frame *sf = XFRAME (selected_frame);
+
+ if (FRAME_X_P (sf) && FRAME_LIVE_P (sf))
+ return FRAME_X_DISPLAY_INFO (sf);
else if (x_display_list != 0)
return x_display_list;
else
Lisp_Object tail, frame;
struct frame *f;
- for (tail = Vframe_list; GC_CONSP (tail); tail = XCONS (tail)->cdr)
+ for (tail = Vframe_list; GC_CONSP (tail); tail = XCDR (tail))
{
- frame = XCONS (tail)->car;
+ frame = XCAR (tail);
if (!GC_FRAMEP (frame))
continue;
f = XFRAME (frame);
- if (f->output_data.nothing == 1 || FRAME_X_DISPLAY_INFO (f) != dpyinfo)
+ if (!FRAME_X_P (f) || FRAME_X_DISPLAY_INFO (f) != dpyinfo)
continue;
#ifdef USE_X_TOOLKIT
if ((f->output_data.x->edit_widget
struct frame *f;
struct x_output *x;
- for (tail = Vframe_list; GC_CONSP (tail); tail = XCONS (tail)->cdr)
+ for (tail = Vframe_list; GC_CONSP (tail); tail = XCDR (tail))
{
- frame = XCONS (tail)->car;
+ frame = XCAR (tail);
if (!GC_FRAMEP (frame))
continue;
f = XFRAME (frame);
- if (f->output_data.nothing == 1 || FRAME_X_DISPLAY_INFO (f) != dpyinfo)
+ if (!FRAME_X_P (f) || FRAME_X_DISPLAY_INFO (f) != dpyinfo)
continue;
x = f->output_data.x;
/* This frame matches if the window is any of its widgets. */
struct frame *f;
struct x_output *x;
- for (tail = Vframe_list; GC_CONSP (tail); tail = XCONS (tail)->cdr)
+ for (tail = Vframe_list; GC_CONSP (tail); tail = XCDR (tail))
{
- frame = XCONS (tail)->car;
+ frame = XCAR (tail);
if (!GC_FRAMEP (frame))
continue;
f = XFRAME (frame);
- if (f->output_data.nothing == 1 || FRAME_X_DISPLAY_INFO (f) != dpyinfo)
+ if (!FRAME_X_P (f) || FRAME_X_DISPLAY_INFO (f) != dpyinfo)
continue;
x = f->output_data.x;
/* This frame matches if the window is any of its widgets. */
struct frame *f;
struct x_output *x;
- for (tail = Vframe_list; GC_CONSP (tail); tail = XCONS (tail)->cdr)
+ for (tail = Vframe_list; GC_CONSP (tail); tail = XCDR (tail))
{
- frame = XCONS (tail)->car;
+ frame = XCAR (tail);
if (!GC_FRAMEP (frame))
continue;
f = XFRAME (frame);
- if (f->output_data.nothing == 1 || FRAME_X_DISPLAY_INFO (f) != dpyinfo)
+ if (!FRAME_X_P (f) || FRAME_X_DISPLAY_INFO (f) != dpyinfo)
continue;
x = f->output_data.x;
/* Match if the window is this frame's menubar. */
struct frame *f;
struct x_output *x;
- for (tail = Vframe_list; GC_CONSP (tail); tail = XCONS (tail)->cdr)
+ for (tail = Vframe_list; GC_CONSP (tail); tail = XCDR (tail))
{
- frame = XCONS (tail)->car;
+ frame = XCAR (tail);
if (!GC_FRAMEP (frame))
continue;
f = XFRAME (frame);
- if (f->output_data.nothing == 1 || FRAME_X_DISPLAY_INFO (f) != dpyinfo)
+ if (!FRAME_X_P (f) || FRAME_X_DISPLAY_INFO (f) != dpyinfo)
continue;
x = f->output_data.x;
/* XReadBitmapFile won't handle magic file names. */
if (fd == 0)
return -1;
- close (fd);
+ emacs_close (fd);
filename = (char *) XSTRING (found)->data;
void x_set_scroll_bar_width P_ ((struct frame *, Lisp_Object, Lisp_Object));
void x_set_title P_ ((struct frame *, Lisp_Object, Lisp_Object));
void x_set_unsplittable P_ ((struct frame *, Lisp_Object, Lisp_Object));
-void x_set_toolbar_lines P_ ((struct frame *, Lisp_Object, Lisp_Object));
+void x_set_tool_bar_lines P_ ((struct frame *, Lisp_Object, Lisp_Object));
void x_set_scroll_bar_foreground P_ ((struct frame *, Lisp_Object,
Lisp_Object));
void x_set_scroll_bar_background P_ ((struct frame *, Lisp_Object,
"unsplittable", x_set_unsplittable,
"vertical-scroll-bars", x_set_vertical_scroll_bars,
"visibility", x_set_visibility,
- "toolbar-lines", x_set_toolbar_lines,
+ "tool-bar-lines", x_set_tool_bar_lines,
"scroll-bar-foreground", x_set_scroll_bar_foreground,
"scroll-bar-background", x_set_scroll_bar_background,
"screen-gamma", x_set_screen_gamma
if (leftpos < 0)
f->output_data.x->size_hint_flags |= XNegative;
}
- else if (CONSP (left) && EQ (XCONS (left)->car, Qminus)
- && CONSP (XCONS (left)->cdr)
- && INTEGERP (XCONS (XCONS (left)->cdr)->car))
+ else if (CONSP (left) && EQ (XCAR (left), Qminus)
+ && CONSP (XCDR (left))
+ && INTEGERP (XCAR (XCDR (left))))
{
- leftpos = - XINT (XCONS (XCONS (left)->cdr)->car);
+ leftpos = - XINT (XCAR (XCDR (left)));
f->output_data.x->size_hint_flags |= XNegative;
}
- else if (CONSP (left) && EQ (XCONS (left)->car, Qplus)
- && CONSP (XCONS (left)->cdr)
- && INTEGERP (XCONS (XCONS (left)->cdr)->car))
+ else if (CONSP (left) && EQ (XCAR (left), Qplus)
+ && CONSP (XCDR (left))
+ && INTEGERP (XCAR (XCDR (left))))
{
- leftpos = XINT (XCONS (XCONS (left)->cdr)->car);
+ leftpos = XINT (XCAR (XCDR (left)));
}
if (EQ (top, Qminus))
if (toppos < 0)
f->output_data.x->size_hint_flags |= YNegative;
}
- else if (CONSP (top) && EQ (XCONS (top)->car, Qminus)
- && CONSP (XCONS (top)->cdr)
- && INTEGERP (XCONS (XCONS (top)->cdr)->car))
+ else if (CONSP (top) && EQ (XCAR (top), Qminus)
+ && CONSP (XCDR (top))
+ && INTEGERP (XCAR (XCDR (top))))
{
- toppos = - XINT (XCONS (XCONS (top)->cdr)->car);
+ toppos = - XINT (XCAR (XCDR (top)));
f->output_data.x->size_hint_flags |= YNegative;
}
- else if (CONSP (top) && EQ (XCONS (top)->car, Qplus)
- && CONSP (XCONS (top)->cdr)
- && INTEGERP (XCONS (XCONS (top)->cdr)->car))
+ else if (CONSP (top) && EQ (XCAR (top), Qplus)
+ && CONSP (XCDR (top))
+ && INTEGERP (XCAR (XCDR (top))))
{
- toppos = XINT (XCONS (XCONS (top)->cdr)->car);
+ toppos = XINT (XCAR (XCDR (top)));
}
(FRAME_VISIBLE_P (f) ? Qt
: FRAME_ICONIFIED_P (f) ? Qicon : Qnil));
store_in_alist (alistptr, Qdisplay,
- XCONS (FRAME_X_DISPLAY_INFO (f)->name_list_element)->car);
+ XCAR (FRAME_X_DISPLAY_INFO (f)->name_list_element));
if (f->output_data.x->parent_desc == FRAME_X_DISPLAY_INFO (f)->root_window)
tem = Qnil;
If ALLOC is nonzero, allocate a new colormap cell. */
int
-defined_color (f, color, color_def, alloc)
+x_defined_color (f, color, color_def, alloc)
FRAME_PTR f;
char *color;
XColor *color_def;
if (FRAME_X_DISPLAY_INFO (f)->n_planes == 1)
return def;
- /* defined_color is responsible for coping with failures
+ /* x_defined_color is responsible for coping with failures
by looking for a near-miss. */
- if (defined_color (f, XSTRING (arg)->data, &cdef, 1))
+ if (x_defined_color (f, XSTRING (arg)->data, &cdef, 1))
return cdef.pixel;
Fsignal (Qerror, Fcons (build_string ("undefined color"),
XSetBackground (FRAME_X_DISPLAY (f), f->output_data.x->reverse_gc,
f->output_data.x->foreground_pixel);
UNBLOCK_INPUT;
- recompute_basic_faces (f);
+ update_face_from_frame_parameter (f, Qforeground_color, arg);
if (FRAME_VISIBLE_P (f))
redraw_frame (f);
}
struct frame *f;
Lisp_Object arg, oldval;
{
- Pixmap temp;
- int mask;
-
unsigned long pixel
= x_decode_color (f, arg, WHITE_PIX_DEFAULT (f));
}
UNBLOCK_INPUT;
- recompute_basic_faces (f);
+ update_face_from_frame_parameter (f, Qbackground_color, arg);
if (FRAME_VISIBLE_P (f))
redraw_frame (f);
XFlush (FRAME_X_DISPLAY (f));
UNBLOCK_INPUT;
+
+ update_face_from_frame_parameter (f, Qmouse_color, arg);
}
void
x_update_cursor (f, 1);
}
}
+
+ update_face_from_frame_parameter (f, Qcursor_color, arg);
}
\f
/* Set the border-color of frame F to value described by ARG.
struct frame *f;
Lisp_Object arg, oldval;
{
- unsigned char *str;
int pix;
CHECK_STRING (arg, 0);
- str = XSTRING (arg)->data;
-
pix = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f));
-
x_set_border_pixel (f, pix);
+ update_face_from_frame_parameter (f, Qborder_color, arg);
}
/* Set the border-color of frame F to pixel value PIX.
if (FRAME_X_WINDOW (f) != 0 && f->output_data.x->border_width > 0)
{
- Pixmap temp;
- int mask;
-
BLOCK_INPUT;
XSetWindowBorder (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
(unsigned long)pix);
FRAME_DESIRED_CURSOR (f) = BAR_CURSOR;
f->output_data.x->cursor_width = 2;
}
- else if (CONSP (arg) && EQ (XCONS (arg)->car, Qbar)
- && INTEGERP (XCONS (arg)->cdr))
+ else if (CONSP (arg) && EQ (XCAR (arg), Qbar)
+ && INTEGERP (XCDR (arg)))
{
FRAME_DESIRED_CURSOR (f) = BAR_CURSOR;
- f->output_data.x->cursor_width = XINT (XCONS (arg)->cdr);
+ f->output_data.x->cursor_width = XINT (XCDR (arg));
}
else
/* Treat anything unknown as "box cursor".
tem = assq_no_quit (Qicon_type, f->param_alist);
if (CONSP (tem))
- return XCONS (tem)->cdr;
+ return XCDR (tem);
else
return Qnil;
}
Lisp_Object value, oldval;
{
int nlines;
+#ifndef USE_X_TOOLKIT
int olines = FRAME_MENU_BAR_LINES (f);
+#endif
/* Right now, menu bars don't work properly in minibuf-only frames;
most of the commands try to apply themselves to the minibuffer
The frame's height doesn't change. */
void
-x_set_toolbar_lines (f, value, oldval)
+x_set_tool_bar_lines (f, value, oldval)
struct frame *f;
Lisp_Object value, oldval;
{
/* Make sure we redisplay all windows in this frame. */
++windows_or_buffers_changed;
- delta = nlines - FRAME_TOOLBAR_LINES (f);
- FRAME_TOOLBAR_LINES (f) = nlines;
+ delta = nlines - FRAME_TOOL_BAR_LINES (f);
+ FRAME_TOOL_BAR_LINES (f) = nlines;
x_set_menu_bar_lines_1 (FRAME_ROOT_WINDOW (f), delta);
adjust_glyphs (f);
}
(*condemn_scroll_bars_hook) (f);
if (judge_scroll_bars_hook)
(*judge_scroll_bars_hook) (f);
-
+
+ update_face_from_frame_parameter (f, Qscroll_bar_foreground, value);
redraw_frame (f);
}
}
if (judge_scroll_bars_hook)
(*judge_scroll_bars_hook) (f);
+ update_face_from_frame_parameter (f, Qscroll_bar_background, value);
redraw_frame (f);
}
}
{
char *name_key;
char *class_key;
+ struct frame *sf = SELECTED_FRAME ();
/* Allocate space for the components, the dots which separate them,
and the final '\0'. */
attribute);
sprintf (class_key, "%s.%s", EMACS_CLASS, class);
- return x_get_string_resource (FRAME_X_DISPLAY_INFO (selected_frame)->xrdb,
+ return x_get_string_resource (FRAME_X_DISPLAY_INFO (sf)->xrdb,
name_key, class_key);
}
Lisp_Object parms;
{
register Lisp_Object tem0, tem1, tem2;
- int height, width, left, top;
- register int geometry;
long window_prompting = 0;
struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
f->output_data.x->top_pos = 0;
window_prompting |= YNegative;
}
- else if (CONSP (tem0) && EQ (XCONS (tem0)->car, Qminus)
- && CONSP (XCONS (tem0)->cdr)
- && INTEGERP (XCONS (XCONS (tem0)->cdr)->car))
+ else if (CONSP (tem0) && EQ (XCAR (tem0), Qminus)
+ && CONSP (XCDR (tem0))
+ && INTEGERP (XCAR (XCDR (tem0))))
{
- f->output_data.x->top_pos = - XINT (XCONS (XCONS (tem0)->cdr)->car);
+ f->output_data.x->top_pos = - XINT (XCAR (XCDR (tem0)));
window_prompting |= YNegative;
}
- else if (CONSP (tem0) && EQ (XCONS (tem0)->car, Qplus)
- && CONSP (XCONS (tem0)->cdr)
- && INTEGERP (XCONS (XCONS (tem0)->cdr)->car))
+ else if (CONSP (tem0) && EQ (XCAR (tem0), Qplus)
+ && CONSP (XCDR (tem0))
+ && INTEGERP (XCAR (XCDR (tem0))))
{
- f->output_data.x->top_pos = XINT (XCONS (XCONS (tem0)->cdr)->car);
+ f->output_data.x->top_pos = XINT (XCAR (XCDR (tem0)));
}
else if (EQ (tem0, Qunbound))
f->output_data.x->top_pos = 0;
f->output_data.x->left_pos = 0;
window_prompting |= XNegative;
}
- else if (CONSP (tem1) && EQ (XCONS (tem1)->car, Qminus)
- && CONSP (XCONS (tem1)->cdr)
- && INTEGERP (XCONS (XCONS (tem1)->cdr)->car))
+ else if (CONSP (tem1) && EQ (XCAR (tem1), Qminus)
+ && CONSP (XCDR (tem1))
+ && INTEGERP (XCAR (XCDR (tem1))))
{
- f->output_data.x->left_pos = - XINT (XCONS (XCONS (tem1)->cdr)->car);
+ f->output_data.x->left_pos = - XINT (XCAR (XCDR (tem1)));
window_prompting |= XNegative;
}
- else if (CONSP (tem1) && EQ (XCONS (tem1)->car, Qplus)
- && CONSP (XCONS (tem1)->cdr)
- && INTEGERP (XCONS (XCONS (tem1)->cdr)->car))
+ else if (CONSP (tem1) && EQ (XCAR (tem1), Qplus)
+ && CONSP (XCDR (tem1))
+ && INTEGERP (XCAR (XCDR (tem1))))
{
- f->output_data.x->left_pos = XINT (XCONS (XCONS (tem1)->cdr)->car);
+ f->output_data.x->left_pos = XINT (XCAR (XCDR (tem1)));
}
else if (EQ (tem1, Qunbound))
f->output_data.x->left_pos = 0;
? (f->output_data.x->menubar_widget->core.height
+ f->output_data.x->menubar_widget->core.border_width)
: 0);
- extern char *lwlib_toolkit_type;
#if 0 /* Experimentally, we now get the right results
for -geometry -0-0 without this. 24 Aug 96, rms. */
}
/* Create fontsets from `global_fontset_alist' before handling fonts. */
- for (tem = Vglobal_fontset_alist; CONSP (tem); tem = XCONS (tem)->cdr)
- fs_register_fontset (f, XCONS (tem)->car);
+ for (tem = Vglobal_fontset_alist; CONSP (tem); tem = XCDR (tem))
+ fs_register_fontset (f, XCAR (tem));
/* Extract the window parameters from the supplied values
that are needed to determine window geometry. */
x_default_parameter (f, parms, Qmenu_bar_lines, make_number (1),
"menuBar", "MenuBar", RES_TYPE_NUMBER);
- x_default_parameter (f, parms, Qtoolbar_lines, make_number (0),
+ x_default_parameter (f, parms, Qtool_bar_lines, make_number (0),
"toolBar", "ToolBar", RES_TYPE_NUMBER);
x_default_parameter (f, parms, Qscroll_bar_width, Qnil,
"scrollBarWidth", "ScrollBarWidth",
tem = x_get_arg (dpyinfo, parms, Qunsplittable, 0, 0, RES_TYPE_BOOLEAN);
f->no_split = minibuffer_only || EQ (tem, Qt);
- /* Create the X widget or window. Add the toolbar height to the
+ /* Create the X widget or window. Add the tool-bar height to the
initial frame height so that the user gets a text display area of
the size he specified with -g or via .Xdefaults. Later changes
- of the toolbar height don't change the frame size. This is done
+ of the tool-bar height don't change the frame size. This is done
so that users can create tall Emacs frames without having to
- guess how tall the toolbar will get. */
- f->height += FRAME_TOOLBAR_LINES (f);
+ guess how tall the tool-bar will get. */
+ f->height += FRAME_TOOL_BAR_LINES (f);
#ifdef USE_X_TOOLKIT
x_window (f, window_prompting, minibuffer_only);
/* Set up faces after all frame parameters are known. */
call1 (Qface_set_after_frame_default, frame);
-
+
#ifdef USE_X_TOOLKIT
/* Create the menu bar. */
if (!minibuffer_only && FRAME_EXTERNAL_MENU_BAR (f))
}
\f
-DEFUN ("x-color-defined-p", Fx_color_defined_p, Sx_color_defined_p, 1, 2, 0,
- "Return non-nil if color COLOR is supported on frame FRAME.\n\
-If FRAME is omitted or nil, use the selected frame.")
+DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, 1, 2, 0,
+ "Internal function called by `color-defined-p', which see.")
(color, frame)
Lisp_Object color, frame;
{
CHECK_STRING (color, 1);
- if (defined_color (f, XSTRING (color)->data, &foo, 0))
+ if (x_defined_color (f, XSTRING (color)->data, &foo, 0))
return Qt;
else
return Qnil;
}
-DEFUN ("x-color-values", Fx_color_values, Sx_color_values, 1, 2, 0,
- "Return a description of the color named COLOR on frame FRAME.\n\
-The value is a list of integer RGB values--(RED GREEN BLUE).\n\
-These values appear to range from 0 to 65280 or 65535, depending\n\
-on the system; white is (65280 65280 65280) or (65535 65535 65535).\n\
-If FRAME is omitted or nil, use the selected frame.")
+DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2, 0,
+ "Internal function called by `color-values', which see.")
(color, frame)
Lisp_Object color, frame;
{
CHECK_STRING (color, 1);
- if (defined_color (f, XSTRING (color)->data, &foo, 0))
+ if (x_defined_color (f, XSTRING (color)->data, &foo, 0))
{
Lisp_Object rgb[3];
return Qnil;
}
-DEFUN ("x-display-color-p", Fx_display_color_p, Sx_display_color_p, 0, 1, 0,
- "Return t if the X display supports color.\n\
-The optional argument DISPLAY specifies which display to ask about.\n\
-DISPLAY should be either a frame or a display name (a string).\n\
-If omitted or nil, that stands for the selected frame's display.")
+DEFUN ("xw-display-color-p", Fxw_display_color_p, Sxw_display_color_p, 0, 1, 0,
+ "Internal function called by `display-color-p', which see.")
(display)
Lisp_Object display;
{
for (dpyinfo = x_display_list, names = x_display_name_list;
dpyinfo;
- dpyinfo = dpyinfo->next, names = XCONS (names)->cdr)
+ dpyinfo = dpyinfo->next, names = XCDR (names))
{
Lisp_Object tem;
- tem = Fstring_equal (XCONS (XCONS (names)->car)->car, name);
+ tem = Fstring_equal (XCAR (XCAR (names)), name);
if (!NILP (tem))
return dpyinfo;
}
Lisp_Object tail, result;
result = Qnil;
- for (tail = x_display_name_list; ! NILP (tail); tail = XCONS (tail)->cdr)
- result = Fcons (XCONS (XCONS (tail)->car)->car, result);
+ for (tail = x_display_name_list; ! NILP (tail); tail = XCDR (tail))
+ result = Fcons (XCAR (XCAR (tail)), result);
return result;
}
/* Keywords. */
-Lisp_Object QCtype, QCdata, QCfile, QCascent, QCmargin, QCrelief;
-extern Lisp_Object QCwidth, QCheight, QCforeground, QCbackground;
+Lisp_Object QCtype, QCdata, QCascent, QCmargin, QCrelief;
+extern Lisp_Object QCwidth, QCheight, QCforeground, QCbackground, QCfile;
Lisp_Object QCalgorithm, QCcolor_symbols, QCheuristic_mask;
-extern Lisp_Object QCimage;
+Lisp_Object QCindex;
/* Other symbols. */
/* Time in seconds after which images should be removed from the cache
if not displayed. */
-Lisp_Object Vimage_eviction_seconds;
+Lisp_Object Vimage_cache_eviction_delay;
/* Function prototypes. */
}
-/* Display an error message with format string FORMAT and argument
- ARG. Signaling an error, e.g. when an image cannot be loaded,
- is not a good idea because this would interrupt redisplay, and
- the error message display would lead to another redisplay. This
- function therefore simply displays a message. */
+/* Log error message with format string FORMAT and argument ARG.
+ Signaling an error, e.g. when an image cannot be loaded, is not a
+ good idea because this would interrupt redisplay, and the error
+ message display would lead to another redisplay. This function
+ therefore simply displays a message. */
static void
image_error (format, arg1, arg2)
char *format;
Lisp_Object arg1, arg2;
{
- Lisp_Object args[3];
-
- args[0] = build_string (format);
- args[1] = arg1;
- args[2] = arg2;
- Fmessage (make_number (DIM (args)), args);
+ add_to_log (format, arg1, arg2);
}
};
-static int parse_image_spec P_ ((Lisp_Object spec,
- struct image_keyword *keywords,
- int nkeywords, Lisp_Object type,
- int allow_other_keys_p));
+static int parse_image_spec P_ ((Lisp_Object, struct image_keyword *,
+ int, Lisp_Object));
static Lisp_Object image_spec_value P_ ((Lisp_Object, Lisp_Object, int *));
has the format (image KEYWORD VALUE ...). One of the keyword/
value pairs must be `:type TYPE'. KEYWORDS is a vector of
image_keywords structures of size NKEYWORDS describing other
- allowed keyword/value pairs. ALLOW_OTHER_KEYS_P non-zero means
- allow KEYWORD/VALUE pairs other than those described by KEYWORDS
- without checking them. Value is non-zero if SPEC is valid. */
+ allowed keyword/value pairs. Value is non-zero if SPEC is valid. */
static int
-parse_image_spec (spec, keywords, nkeywords, type, allow_other_keys_p)
+parse_image_spec (spec, keywords, nkeywords, type)
Lisp_Object spec;
struct image_keyword *keywords;
int nkeywords;
Lisp_Object type;
- int allow_other_keys_p;
{
int i;
Lisp_Object plist;
break;
if (i == nkeywords)
- {
- if (!allow_other_keys_p)
- return 0;
- continue;
- }
+ continue;
/* Record that we recognized the keyword. If a keywords
was found more than once, it's an error. */
/* If IMG doesn't have a pixmap yet, load it now, using the image
type dependent loader function. */
- if (img->pixmap == 0)
- img->type->load (f, img);
+ if (img->pixmap == 0 && !img->load_failed_p)
+ img->load_failed_p = img->type->load (f, img) == 0;
}
xassert (STRINGP (color_name));
- if (defined_color (f, XSTRING (color_name)->data, &color, 1))
+ if (x_defined_color (f, XSTRING (color_name)->data, &color, 1))
{
/* This isn't called frequently so we get away with simply
reallocating the color vector to the needed size, here. */
{
struct image_cache *c = FRAME_X_IMAGE_CACHE (f);
- if (c && INTEGERP (Vimage_eviction_seconds))
+ if (c && INTEGERP (Vimage_cache_eviction_delay))
{
EMACS_TIME t;
unsigned long old;
int i, any_freed_p = 0;
EMACS_GET_TIME (t);
- old = EMACS_SECS (t) - XFASTINT (Vimage_eviction_seconds);
+ old = EMACS_SECS (t) - XFASTINT (Vimage_cache_eviction_delay);
for (i = 0; i < c->used; ++i)
{
int i;
unsigned hash;
struct gcpro gcpro1;
+ EMACS_TIME now;
/* F must be a window-system frame, and SPEC must be a valid image
specification. */
/* If not found, create a new image and cache it. */
if (img == NULL)
{
- extern Lisp_Object QCenable, QCselect;
- Lisp_Object tem;
- int loading_failed_p;
-
img = make_image (spec, hash);
cache_image (f, img);
- loading_failed_p = img->type->load (f, img) == 0;
+ img->load_failed_p = img->type->load (f, img) == 0;
+ xassert (!interrupt_input_blocked);
/* If we can't load the image, and we don't have a width and
height, use some arbitrary width and height so that we can
draw a rectangle for it. */
- if (loading_failed_p)
+ if (img->load_failed_p)
{
Lisp_Object value;
}
}
+ /* We're using IMG, so set its timestamp to `now'. */
+ EMACS_GET_TIME (now);
+ img->timestamp = EMACS_SECS (now);
+
UNGCPRO;
/* Value is the image id. */
/* Put XImage XIMG into pixmap PIXMAP on frame F. WIDTH and HEIGHT
are width and height of both the image and pixmap. */
-void
+static void
x_put_x_image (f, ximg, pixmap, width, height)
struct frame *f;
XImage *ximg;
static int xbm_image_p P_ ((Lisp_Object object));
static int xbm_read_bitmap_file_data P_ ((char *, int *, int *,
unsigned char **));
-static int xbm_read_hexint P_ ((FILE *));
/* Indices of image specification fields in xbm_format, below. */
struct image_keyword kw[XBM_LAST];
bcopy (xbm_format, kw, sizeof kw);
- if (!parse_image_spec (object, kw, XBM_LAST, Qxbm, 0))
+ if (!parse_image_spec (object, kw, XBM_LAST, Qxbm))
return 0;
xassert (EQ (kw[XBM_TYPE].value, Qxbm));
/* Parse defines for width, height and hot-spots. */
while (LA1 == '#')
{
- char *p;
-
match ();
expect_ident ("define");
expect (XBM_TK_IDENT);
/* Parse the list specification. */
bcopy (xbm_format, fmt, sizeof fmt);
- parsed_p = parse_image_spec (img->spec, fmt, XBM_LAST, Qxbm, 0);
+ parsed_p = parse_image_spec (img->spec, fmt, XBM_LAST, Qxbm);
xassert (parsed_p);
/* Get specified width, and height. */
{
struct image_keyword fmt[XPM_LAST];
bcopy (xpm_format, fmt, sizeof fmt);
- return (parse_image_spec (object, fmt, XPM_LAST, Qxpm, 0)
+ return (parse_image_spec (object, fmt, XPM_LAST, Qxpm)
/* Either `:file' or `:data' must be present. */
&& fmt[XPM_FILE].count + fmt[XPM_DATA].count == 1
/* Either no `:color-symbols' or it's a list of conses
if (!STRINGP (file))
{
image_error ("Cannot find image file %s", specified_file, Qnil);
+ UNBLOCK_INPUT;
return 0;
}
/* Build a mask for image IMG which is used on frame F. FILE is the
name of an image file, for error messages. HOW determines how to
- determine the background color of IMG. If it is an integer, take
- that as the pixel value of the background. Otherwise, determine
- the background color of IMG heuristically. Value is non-zero
- if successful. */
+ determine the background color of IMG. If it is a list '(R G B)',
+ with R, G, and B being integers >= 0, take that as the color of the
+ background. Otherwise, determine the background color of IMG
+ heuristically. Value is non-zero if successful. */
static int
x_build_heuristic_mask (f, file, img, how)
Lisp_Object how;
{
Display *dpy = FRAME_X_DISPLAY (f);
- Window win = FRAME_X_WINDOW (f);
XImage *ximg, *mask_img;
- int x, y, rc;
+ int x, y, rc, look_at_corners_p;
unsigned long bg;
BLOCK_INPUT;
ximg = XGetImage (dpy, img->pixmap, 0, 0, img->width, img->height,
~0, ZPixmap);
- /* Determine the background color of ximg. If HOW is an integer,
- take that as a pixel color. Otherwise, try to determine the
- color heuristically. */
- if (NATNUMP (how))
- bg = XFASTINT (how);
- else
+ /* Determine the background color of ximg. If HOW is `(R G B)'
+ take that as color. Otherwise, try to determine the color
+ heuristically. */
+ look_at_corners_p = 1;
+
+ if (CONSP (how))
+ {
+ int rgb[3], i = 0;
+
+ while (i < 3
+ && CONSP (how)
+ && NATNUMP (XCAR (how)))
+ {
+ rgb[i] = XFASTINT (XCAR (how)) & 0xffff;
+ how = XCDR (how);
+ }
+
+ if (i == 3 && NILP (how))
+ {
+ char color_name[30];
+ XColor exact, color;
+ Colormap cmap;
+
+ sprintf (color_name, "#%04x%04x%04x", rgb[0], rgb[1], rgb[2]);
+
+ cmap = DefaultColormapOfScreen (FRAME_X_SCREEN (f));
+ if (XLookupColor (dpy, cmap, color_name, &exact, &color))
+ {
+ bg = color.pixel;
+ look_at_corners_p = 0;
+ }
+ }
+ }
+
+ if (look_at_corners_p)
{
unsigned long corners[4];
int i, best_count;
bcopy (pbm_format, fmt, sizeof fmt);
- if (!parse_image_spec (object, fmt, PBM_LAST, Qpbm, 0)
+ if (!parse_image_spec (object, fmt, PBM_LAST, Qpbm)
|| (fmt[PBM_ASCENT].count
&& XFASTINT (fmt[PBM_ASCENT].value) > 100))
return 0;
FILE *fp;
char magic[2];
int raw_p, x, y;
- int width, height, max_color_idx = 0, value;
+ int width, height, max_color_idx = 0;
XImage *ximg;
Lisp_Object file, specified_file;
enum {PBM_MONO, PBM_GRAY, PBM_COLOR} type;
{":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}
};
-/* Structure describing the image type `gif'. */
+/* Structure describing the image type `png'. */
static struct image_type png_type =
{
struct image_keyword fmt[PNG_LAST];
bcopy (png_format, fmt, sizeof fmt);
- if (!parse_image_spec (object, fmt, PNG_LAST, Qpng, 1)
+ if (!parse_image_spec (object, fmt, PNG_LAST, Qpng)
|| (fmt[PNG_ASCENT].count
&& XFASTINT (fmt[PNG_ASCENT].value) > 100))
return 0;
struct image *img;
{
Lisp_Object file, specified_file;
- int rc, x, y, i;
+ int x, y, i;
XImage *ximg, *mask_img = NULL;
struct gcpro gcpro1;
png_struct *png_ptr = NULL;
/* Tell the PNG lib to handle gamma correction for us. */
+#if defined(PNG_READ_sRGB_SUPPORTED) || defined(PNG_WRITE_sRGB_SUPPORTED)
if (png_get_sRGB (png_ptr, info_ptr, &intent))
/* There is a special chunk in the image specifying the gamma. */
png_set_sRGB (png_ptr, info_ptr, intent);
- else if (png_get_gAMA (png_ptr, info_ptr, &image_gamma))
+ else
+#endif
+ if (png_get_gAMA (png_ptr, info_ptr, &image_gamma))
/* Image contains gamma information. */
png_set_gamma (png_ptr, screen_gamma, image_gamma);
else
bcopy (jpeg_format, fmt, sizeof fmt);
- if (!parse_image_spec (object, fmt, JPEG_LAST, Qjpeg, 0)
+ if (!parse_image_spec (object, fmt, JPEG_LAST, Qjpeg)
|| (fmt[JPEG_ASCENT].count
&& XFASTINT (fmt[JPEG_ASCENT].value) > 100))
return 0;
JSAMPARRAY buffer;
int row_stride, x, y;
XImage *ximg = NULL;
- int rc, value;
+ int rc;
unsigned long *colors;
int width, height;
struct gcpro gcpro1;
struct image_keyword fmt[TIFF_LAST];
bcopy (tiff_format, fmt, sizeof fmt);
- if (!parse_image_spec (object, fmt, TIFF_LAST, Qtiff, 1)
+ if (!parse_image_spec (object, fmt, TIFF_LAST, Qtiff)
|| (fmt[TIFF_ASCENT].count
&& XFASTINT (fmt[TIFF_ASCENT].value) > 100))
return 0;
struct image_keyword fmt[GIF_LAST];
bcopy (gif_format, fmt, sizeof fmt);
- if (!parse_image_spec (object, fmt, GIF_LAST, Qgif, 1)
+ if (!parse_image_spec (object, fmt, GIF_LAST, Qgif)
|| (fmt[GIF_ASCENT].count
&& XFASTINT (fmt[GIF_ASCENT].value) > 100))
return 0;
struct gcpro gcpro1;
Lisp_Object image;
int ino, image_left, image_top, image_width, image_height;
- int bg;
specified_file = image_spec_value (img->spec, QCfile, NULL);
file = x_find_image_file (specified_file);
return 0;
}
- image = image_spec_value (img->spec, QCimage, NULL);
+ image = image_spec_value (img->spec, QCindex, NULL);
ino = INTEGERP (image) ? XFASTINT (image) : 0;
if (ino >= gif->ImageCount)
{
static int interlace_start[] = {0, 4, 2, 1};
static int interlace_increment[] = {8, 8, 4, 2};
int pass, inc;
+ int row = interlace_start[0];
- for (pass = 0; pass < 4; ++pass)
+ pass = 0;
+
+ for (y = 0; y < image_height; y++)
{
- inc = interlace_increment[pass];
- for (y = interlace_start[pass]; y < image_height; y += inc)
- for (x = 0; x < image_width; ++x)
- {
- unsigned i = gif->SavedImages[ino].RasterBits[y * image_width + x];
- XPutPixel (ximg, x + image_left, y + image_top,
- pixel_colors[i]);
- }
+ if (row >= image_height)
+ {
+ row = interlace_start[++pass];
+ while (row >= image_height)
+ row = interlace_start[++pass];
+ }
+
+ for (x = 0; x < image_width; x++)
+ {
+ unsigned int i
+ = gif->SavedImages[ino].RasterBits[(y * image_width) + x];
+ XPutPixel (ximg, x + image_left, row + image_top,
+ pixel_colors[i]);
+ }
+
+ row += interlace_increment[pass];
}
}
else
static int gs_load P_ ((struct frame *f, struct image *img));
static void gs_clear_image P_ ((struct frame *f, struct image *img));
-/* The symbol `ghostscript' identifying images of this type. */
+/* The symbol `postscript' identifying images of this type. */
-Lisp_Object Qghostscript;
+Lisp_Object Qpostscript;
/* Keyword symbols. */
static struct image_type gs_type =
{
- &Qghostscript,
+ &Qpostscript,
gs_image_p,
gs_load,
gs_clear_image,
bcopy (gs_format, fmt, sizeof fmt);
- if (!parse_image_spec (object, fmt, GS_LAST, Qghostscript, 1)
+ if (!parse_image_spec (object, fmt, GS_LAST, Qpostscript)
|| (fmt[GS_ASCENT].count
&& XFASTINT (fmt[GS_ASCENT].value) > 100))
return 0;
Sx_show_busy_cursor, 0, 0, 0,
"Show a busy cursor, if not already shown.\n\
Each call to this function must be matched by a call to\n\
-x-undisplay-busy-cursor to make the busy pointer disappear again.")
+`x-hide-busy-cursor' to make the busy pointer disappear again.")
()
{
++busy_count;
XSetWindowAttributes attrs;
attrs.cursor = f->output_data.x->busy_cursor;
+
f->output_data.x->busy_window
= XCreateWindow (FRAME_X_DISPLAY (f),
FRAME_OUTER_WINDOW (f),
0, 0, 32000, 32000, 0, 0,
- InputOnly, CopyFromParent,
+ InputOnly,
+ CopyFromParent,
mask, &attrs);
}
Sx_hide_busy_cursor, 0, 1, 0,
"Hide a busy-cursor.\n\
A busy-cursor will actually be undisplayed when a matching\n\
-`x-undisplay-busy-cursor' is called for each `x-display-busy-cursor'\n\
-issued. FORCE non-nil means undisplay the busy-cursor forcibly,\n\
+`x-hide-busy-cursor' is called for each `x-show-busy-cursor'\n\
+issued. FORCE non-nil means hide the busy-cursor forcibly,\n\
not counting calls.")
(force)
Lisp_Object force;
struct frame *f;
Lisp_Object frame, tem;
Lisp_Object name;
- int minibuffer_only = 0;
long window_prompting = 0;
int width, height;
int count = specpdl_ptr - specpdl;
- struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
+ struct gcpro gcpro1, gcpro2, gcpro3;
struct kboard *kb;
check_x ();
}
/* Create fontsets from `global_fontset_alist' before handling fonts. */
- for (tem = Vglobal_fontset_alist; CONSP (tem); tem = XCONS (tem)->cdr)
- fs_register_fontset (f, XCONS (tem)->car);
+ for (tem = Vglobal_fontset_alist; CONSP (tem); tem = XCDR (tem))
+ fs_register_fontset (f, XCAR (tem));
/* Extract the window parameters from the supplied values
that are needed to determine window geometry. */
DEFUN ("x-show-tip", Fx_show_tip, Sx_show_tip, 1, 4, 0,
- "Show tooltip STRING on frame FRAME.\n\
+ "Show STRING in a \"tooltip\" window on frame FRAME.\n\
+A tooltip window is a small X window displaying STRING at\n\
+the current mouse position.\n\
FRAME nil or omitted means use the selected frame.\n\
PARMS is an optional list of frame parameters which can be\n\
used to change the tooltip's appearance.\n\
Automatically hide the tooltip after TIMEOUT seconds.\n\
TIMEOUT nil means use the default timeout of 5 seconds.")
(string, frame, parms, timeout)
- Lisp_Object string, frame, parms;
+ Lisp_Object string, frame, parms, timeout;
{
struct frame *f;
struct window *w;
Window root, child;
- struct it it;
Lisp_Object buffer;
struct buffer *old_buffer;
struct text_pos pos;
DEFUN ("x-hide-tip", Fx_hide_tip, Sx_hide_tip, 0, 0, 0,
- "Hide the current tooltip, if there is any.\n\
+ "Hide the current tooltip window, if there is any.\n\
Value is t is tooltip was open, nil otherwise.")
()
{
Lisp_Object prompt, dir, default_filename, mustmatch;
{
int result;
- struct frame *f = selected_frame;
+ struct frame *f = SELECTED_FRAME ();
Lisp_Object file = Qnil;
Widget dialog, text, list, help;
Arg al[10];
int id = -1;
if (valid_image_p (spec))
- id = lookup_image (selected_frame, spec);
+ id = lookup_image (SELECTED_FRAME (), spec);
debug_print (spec);
return make_number (id);
staticpro (&Quser_position);
Quser_size = intern ("user-size");
staticpro (&Quser_size);
- Qdisplay = intern ("display");
- staticpro (&Qdisplay);
Qscroll_bar_foreground = intern ("scroll-bar-foreground");
staticpro (&Qscroll_bar_foreground);
Qscroll_bar_background = intern ("scroll-bar-background");
Chinese, Japanese, and Korean.");
Vx_pixel_size_width_font_regexp = Qnil;
- DEFVAR_LISP ("image-eviction-seconds", &Vimage_eviction_seconds,
+ DEFVAR_LISP ("image-cache-eviction-delay", &Vimage_cache_eviction_delay,
"Time after which cached images are removed from the cache.\n\
When an image has not been displayed this many seconds, remove it\n\
from the image cache. Value must be an integer or nil with nil\n\
meaning don't clear the cache.");
- Vimage_eviction_seconds = make_number (30 * 60);
+ Vimage_cache_eviction_delay = make_number (30 * 60);
DEFVAR_LISP ("image-types", &Vimage_types,
"List of supported image types.\n\
defsubr (&Sx_contour_region);
defsubr (&Sx_uncontour_region);
#endif
- defsubr (&Sx_display_color_p);
+ defsubr (&Sxw_display_color_p);
defsubr (&Sx_display_grayscale_p);
- defsubr (&Sx_color_defined_p);
- defsubr (&Sx_color_values);
+ defsubr (&Sxw_color_defined_p);
+ defsubr (&Sxw_color_values);
defsubr (&Sx_server_max_request_size);
defsubr (&Sx_server_vendor);
defsubr (&Sx_server_version);
staticpro (&Qxbm);
QCtype = intern (":type");
staticpro (&QCtype);
- QCfile = intern (":file");
- staticpro (&QCfile);
QCalgorithm = intern (":algorithm");
staticpro (&QCalgorithm);
QCheuristic_mask = intern (":heuristic-mask");
staticpro (&QCmargin);
QCrelief = intern (":relief");
staticpro (&QCrelief);
- Qghostscript = intern ("ghostscript");
- staticpro (&Qghostscript);
+ Qpostscript = intern ("postscript");
+ staticpro (&Qpostscript);
QCloader = intern (":loader");
staticpro (&QCloader);
QCbounding_box = intern (":bounding-box");
staticpro (&QCpt_width);
QCpt_height = intern (":pt-height");
staticpro (&QCpt_height);
+ QCindex = intern (":index");
+ staticpro (&QCindex);
Qpbm = intern ("pbm");
staticpro (&Qpbm);