#include "keyboard.h"
#include "blockinput.h"
#include <paths.h>
+#include "charset.h"
+#include "fontset.h"
#ifdef HAVE_X_WINDOWS
extern void abort ();
#define MAXREQUEST(dpy) ((dpy)->max_request_size)
#endif
-/* The name we're using in resource queries. */
+/* The name we're using in resource queries. Most often "emacs". */
Lisp_Object Vx_resource_name;
+/* The application class we're using in resource queries.
+ Normally "Emacs". */
+Lisp_Object Vx_resource_class;
+
/* The background and shape of the mouse pointer, and shape when not
over text or in the modeline. */
Lisp_Object Vx_pointer_shape, Vx_nontext_pointer_shape, Vx_mode_pointer_shape;
/* Search path for bitmap files. */
Lisp_Object Vx_bitmap_file_path;
+/* Regexp matching a font name whose width is the same as `PIXEL_SIZE'. */
+Lisp_Object Vx_pixel_size_width_font_regexp;
+
/* Evaluate this expression to rebuild the section of syms_of_xfns
that initializes and staticpros the symbols declared below. Note
that Emacs 18 has a bug that keeps C-x C-e from being able to
while (1)
{
- x_catch_errors (FRAME_X_DISPLAY (f));
+ int count = x_catch_errors (FRAME_X_DISPLAY (f));
XQueryTree (FRAME_X_DISPLAY (f), outer, &tmp_root_window,
&f->output_data.x->parent_desc,
Detect that and try the whole thing over. */
if (! x_had_errors_p (FRAME_X_DISPLAY (f)))
{
- x_uncatch_errors (FRAME_X_DISPLAY (f));
+ x_uncatch_errors (FRAME_X_DISPLAY (f), count);
break;
}
- x_uncatch_errors (FRAME_X_DISPLAY (f));
+ x_uncatch_errors (FRAME_X_DISPLAY (f), count);
}
*xptr = f->output_data.x->left_pos - win_x;
Lisp_Object arg, oldval;
{
Cursor cursor, nontext_cursor, mode_cursor, cross_cursor;
+ int count;
int mask_color;
if (!EQ (Qnil, arg))
BLOCK_INPUT;
/* It's not okay to crash if the user selects a screwy cursor. */
- x_catch_errors (FRAME_X_DISPLAY (f));
+ count = x_catch_errors (FRAME_X_DISPLAY (f));
if (!EQ (Qnil, Vx_pointer_shape))
{
/* Check and report errors with the above calls. */
x_check_errors (FRAME_X_DISPLAY (f), "can't set cursor shape: %s");
- x_uncatch_errors (FRAME_X_DISPLAY (f));
+ x_uncatch_errors (FRAME_X_DISPLAY (f), count);
{
XColor fore_color, back_color;
Lisp_Object arg, oldval;
{
Lisp_Object result;
+ Lisp_Object fontset_name;
CHECK_STRING (arg, 1);
+ fontset_name = Fquery_fontset (arg);
+
BLOCK_INPUT;
- result = x_new_font (f, XSTRING (arg)->data);
+ result = (STRINGP (fontset_name)
+ ? x_new_fontset (f, XSTRING (fontset_name)->data)
+ : x_new_font (f, XSTRING (arg)->data));
UNBLOCK_INPUT;
if (EQ (result, Qnil))
if (f->output_data.x->internal_border_width < 0)
f->output_data.x->internal_border_width = 0;
+#ifdef USE_X_TOOLKIT
if (f->output_data.x->edit_widget)
widget_store_internal_border (f->output_data.x->edit_widget,
f->output_data.x->internal_border_width);
+#endif
if (f->output_data.x->internal_border_width == old)
return;
else
nlines = 0;
+ /* Make sure we redisplay all windows in this frame. */
+ windows_or_buffers_changed++;
+
#ifdef USE_X_TOOLKIT
FRAME_MENU_BAR_LINES (f) = 0;
if (nlines)
if (NILP (name))
name = f->name;
+ else
+ CHECK_STRING (name, 0);
if (FRAME_X_WINDOW (f))
{
&& XFASTINT (arg) != FRAME_SCROLL_BAR_PIXEL_WIDTH (f))
{
int wid = FONT_WIDTH (f->output_data.x->font);
+
+ if (XFASTINT (arg) <= 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM)
+ XSETINT (arg, 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM + 1);
+
FRAME_SCROLL_BAR_PIXEL_WIDTH (f) = XFASTINT (arg);
FRAME_SCROLL_BAR_COLS (f) = (XFASTINT (arg) + wid-1) / wid;
if (FRAME_X_WINDOW (f))
Lisp_Object new;
int i;
+ if (!STRINGP (Vx_resource_class))
+ Vx_resource_class = build_string (EMACS_CLASS);
+
if (STRINGP (Vx_resource_name))
{
unsigned char *p = XSTRING (Vx_resource_name)->data;
+ XSTRING (attribute)->size
+ 3);
- class_key = (char *) alloca ((sizeof (EMACS_CLASS) - 1)
+ class_key = (char *) alloca (XSTRING (Vx_resource_class)->size
+ XSTRING (class)->size
+ (STRINGP (subclass)
? XSTRING (subclass)->size : 0)
/* Start with emacs.FRAMENAME for the name (the specific one)
and with `Emacs' for the class key (the general one). */
strcpy (name_key, XSTRING (Vx_resource_name)->data);
- strcpy (class_key, EMACS_CLASS);
+ strcpy (class_key, XSTRING (Vx_resource_class)->data);
strcat (class_key, ".");
strcat (class_key, XSTRING (class)->data);
}
len = strlen (shell_position) + 1;
+ /* We don't free this because we don't know whether
+ it is safe to free it while the frame exists.
+ It isn't worth the trouble of arranging to free it
+ when the frame is deleted. */
tem = (char *) xmalloc (len);
strncpy (tem, shell_position, len);
XtSetArg (al[ac], XtNgeometry, tem); ac++;
validate_x_resource_name ();
class_hints.res_name = (char *) XSTRING (Vx_resource_name)->data;
- class_hints.res_class = EMACS_CLASS;
+ class_hints.res_class = (char *) XSTRING (Vx_resource_class)->data;
XSetClassHint (FRAME_X_DISPLAY (f), XtWindow (shell_widget), &class_hints);
#ifdef HAVE_X_I18N
validate_x_resource_name ();
class_hints.res_name = (char *) XSTRING (Vx_resource_name)->data;
- class_hints.res_class = EMACS_CLASS;
+ class_hints.res_class = (char *) XSTRING (Vx_resource_class)->data;
XSetClassHint (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), &class_hints);
/* The menubar is part of the ordinary display;
it to make_frame_without_minibuffer. */
frame = Qnil;
GCPRO4 (parms, parent, name, frame);
- tem = x_get_arg (parms, Qminibuffer, 0, 0, symbol);
+ tem = x_get_arg (parms, Qminibuffer, "minibuffer", "Minibuffer", symbol);
if (EQ (tem, Qnone) || NILP (tem))
f = make_frame_without_minibuffer (Qnil, kb, display);
else if (EQ (tem, Qonly))
specbind (Qx_resource_name, name);
}
+ /* 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);
+
/* Extract the window parameters from the supplied values
that are needed to determine window geometry. */
{
Lisp_Object font;
- font = x_get_arg (parms, Qfont, "font", "Font", string);
+ /* Determine font by the following priority.
+ 1. `font' parameter in parms.
+ 2. `font' parameter in Vdefault_frame_alist.
+ 3. X resource "font" ("Font").
+ 4. Select a plausible font be heuristics at least for ASCII. */
+ tem = Fassq (Qfont, parms);
+ if (NILP (tem))
+ tem = Fassq (Qfont, Vdefault_frame_alist);
+ if (!NILP (tem))
+ font = Fcdr (tem);
+ if (! STRINGP (font))
+ font = x_get_arg (parms, Qfont, "font", "Font", string);
+
BLOCK_INPUT;
/* First, try whatever font the caller has specified. */
if (STRINGP (font))
- font = x_new_font (f, XSTRING (font)->data);
+ {
+ tem = Fquery_fontset (font);
+ if (STRINGP (tem))
+ font = x_new_fontset (f, XSTRING (tem)->data);
+ else
+ font = x_new_font (f, XSTRING (font)->data);
+ }
/* Try out a font which we hope has bold and italic variations. */
if (!STRINGP (font))
font = x_new_font (f, "-misc-fixed-medium-r-normal-*-*-140-*-*-c-*-iso8859-1");
if (! STRINGP (font))
font = build_string ("fixed");
- x_default_parameter (f, parms, Qfont, font,
+ x_default_parameter (f, parms, Qfont, font,
"font", "Font", string);
}
return xfocus;
}
\f
+#if 1
+#include "x-list-font.c"
+#else
DEFUN ("x-list-fonts", Fx_list_fonts, Sx_list_fonts, 1, 4, 0,
"Return a list of the names of available fonts matching PATTERN.\n\
If optional arguments FACE and FRAME are specified, return only fonts\n\
FRAME_PTR f;
Lisp_Object key;
int maxnames;
+ int count;
check_x ();
CHECK_STRING (pattern, 0);
{
XFontStruct *thisinfo;
- x_catch_errors (FRAME_X_DISPLAY (f));
+ count = x_catch_errors (FRAME_X_DISPLAY (f));
thisinfo = XLoadQueryFont (FRAME_X_DISPLAY (f),
XSTRING (XCONS (tem)->car)->data);
x_check_errors (FRAME_X_DISPLAY (f), "XLoadQueryFont failure: %s");
- x_uncatch_errors (FRAME_X_DISPLAY (f));
+ x_uncatch_errors (FRAME_X_DISPLAY (f), count);
if (thisinfo && same_size_fonts (thisinfo, size_ref))
newlist = Fcons (XCONS (tem)->car, newlist);
BLOCK_INPUT;
- x_catch_errors (FRAME_X_DISPLAY (f));
+ count = x_catch_errors (FRAME_X_DISPLAY (f));
/* Solaris 2.3 has a bug in XListFontsWithInfo. */
#ifndef BROKEN_XLISTFONTSWITHINFO
&num_fonts); /* count_return */
x_check_errors (FRAME_X_DISPLAY (f), "XListFonts failure: %s");
- x_uncatch_errors (FRAME_X_DISPLAY (f));
+ x_uncatch_errors (FRAME_X_DISPLAY (f), count);
UNBLOCK_INPUT;
BLOCK_INPUT;
- x_catch_errors (FRAME_X_DISPLAY (f));
+ count = x_catch_errors (FRAME_X_DISPLAY (f));
thisinfo = XLoadQueryFont (FRAME_X_DISPLAY (f), names[i]);
x_check_errors (FRAME_X_DISPLAY (f),
"XLoadQueryFont failure: %s");
- x_uncatch_errors (FRAME_X_DISPLAY (f));
+ x_uncatch_errors (FRAME_X_DISPLAY (f), count);
UNBLOCK_INPUT;
return list;
}
+#endif
\f
DEFUN ("x-color-defined-p", Fx_color_defined_p, Sx_color_defined_p, 1, 2, 0,
if (tab_width <= 0 || tab_width > 20) tab_width = 8;
do
{
- c = FETCH_CHAR (p);
+ c = FETCH_BYTE (p);
if (len == f->width && hp == len - 1 && c != '\n')
goto draw_or_not;
Vx_pointer_shape = Qnil;
DEFVAR_LISP ("x-resource-name", &Vx_resource_name,
- "The name Emacs uses to look up X resources; for internal use only.\n\
+ "The name Emacs uses to look up X resources.\n\
`x-get-resource' uses this as the first component of the instance name\n\
when requesting resource values.\n\
Emacs initially sets `x-resource-name' to the name under which Emacs\n\
was invoked, or to the value specified with the `-name' or `-rn'\n\
-switches, if present.");
+switches, if present.\n\
+\n\
+It may be useful to bind this variable locally around a call\n\
+to `x-get-resource'. See also the variable `x-resource-class'.");
Vx_resource_name = Qnil;
+ DEFVAR_LISP ("x-resource-class", &Vx_resource_class,
+ "The class Emacs uses to look up X resources.\n\
+`x-get-resource' uses this as the first component of the instance class\n\
+when requesting resource values.\n\
+Emacs initially sets `x-resource-class' to \"Emacs\".\n\
+\n\
+Setting this variable permanently is not a reasonable thing to do,\n\
+but binding this variable locally around a call to `x-get-resource'\n\
+is a reasonabvle practice. See also the variable `x-resource-name'.");
+ Vx_resource_class = build_string (EMACS_CLASS);
+
#if 0 /* This doesn't really do anything. */
- DEFVAR_INT ("x-nontext-pointer-shape", &Vx_nontext_pointer_shape,
+ DEFVAR_LISP ("x-nontext-pointer-shape", &Vx_nontext_pointer_shape,
"The shape of the pointer when not over text.\n\
This variable takes effect when you create a new frame\n\
or when you set the mouse color.");
Vx_nontext_pointer_shape = Qnil;
#if 0 /* This doesn't really do anything. */
- DEFVAR_INT ("x-mode-pointer-shape", &Vx_mode_pointer_shape,
+ DEFVAR_LISP ("x-mode-pointer-shape", &Vx_mode_pointer_shape,
"The shape of the pointer when over the mode line.\n\
This variable takes effect when you create a new frame\n\
or when you set the mouse color.");
#endif
Vx_mode_pointer_shape = Qnil;
- DEFVAR_INT ("x-sensitive-text-pointer-shape",
+ DEFVAR_LISP ("x-sensitive-text-pointer-shape",
&Vx_sensitive_text_pointer_shape,
"The shape of the pointer when over mouse-sensitive text.\n\
This variable takes effect when you create a new frame\n\
and maybe the user would like to set it to t. */
Vx_no_window_manager = Qnil;
+ DEFVAR_LISP ("x-pixel-size-width-font-regexp",
+ &Vx_pixel_size_width_font_regexp,
+ "Regexp matching a font name whose width is the same as `PIXEL_SIZE'.\n\
+\n\
+Since Emacs gets width of a font matching with this regexp from\n\
+PIXEL_SIZE field of the name, font finding mechanism gets faster for\n\
+such a font. This is especially effective for such large fonts as\n\
+Chinese, Japanese, and Korean.");
+ Vx_pixel_size_width_font_regexp = Qnil;
+
#ifdef USE_X_TOOLKIT
Fprovide (intern ("x-toolkit"));
#endif
defsubr (&Sx_close_connection);
defsubr (&Sx_display_list);
defsubr (&Sx_synchronize);
+
+ /* Setting callback functions for fontset handler. */
+ get_font_info_func = x_get_font_info;
+ list_fonts_func = x_list_fonts;
+ load_font_func = x_load_font;
+ query_font_func = x_query_font;
+ set_frame_fontset_func = x_set_font;
+ check_window_system_func = check_x;
}
#endif /* HAVE_X_WINDOWS */