Commit f945b920 authored by Jim Blandy's avatar Jim Blandy

* xfns.c (x_set_name): Take new argument EXPLICIT, instead of

	OLDVAL.
	(x_explicitly_set_name, x_implicitly_set_name): New functions.
	(x_frame_parms): Use x_explicitly_set_name here.
	(x_window): Use x_implicitly_set_name here.

	* xfns.c (Fx_create_frame): Initialize f->display.x->wm_hints here.

	* xfns.c (x_set_name): Call x_set_text_property with a Lisp_Object
	string as an argument, rather than a pointer and a length.

	* xfns.c (x_get_arg): Accept a new type - symbol.  If we've
	retrieved a string from the xrdb database and the user wants a
	symbol, intern it.
	(Fx_create_frame): Use the symbol type here.

	* xfns.c (x_figure_window_size, x_icon, Fx_create_frame): Use
	values from enum resource_types for the last arg to x_get_arg,
	instead of passing numbers.

	* xfns.c (Fx_create_frame): When setting up the scroll bars, use
	the type parameter to x_default_parameter, rather than prefixing
	the resource name with a question mark.

	* xfns.c [not HAVE_X11] (Fx_create_frame): The resource which
	determines whether or not to use a bitmapped icon is called
	"IconType", not "BitmapIcon".  Update this.

	* xfns.c (x_set_name): Used x_set_text_property instead of XSetWMName and
	XSetWMIconName.

	* xfns.c (select_visual): Fetch the visual id directly from v;
    	don't call XVisualIDFromVisual, since that function is not
    	available in earlier versions of X.

	* xfns.c (x_make_gc): cursor_bits can't be local to the function;
	it's static.

	* xfns.c (Fx_create_frame): Make the default for the icon-type
    	parameter nil, not t.  It seems to cause problems with some X
    	servers.
parent 11e82b76
...@@ -403,7 +403,7 @@ void x_set_icon_type (); ...@@ -403,7 +403,7 @@ void x_set_icon_type ();
void x_set_font (); void x_set_font ();
void x_set_border_width (); void x_set_border_width ();
void x_set_internal_border_width (); void x_set_internal_border_width ();
void x_set_name (); void x_explicitly_set_name ();
void x_set_autoraise (); void x_set_autoraise ();
void x_set_autolower (); void x_set_autolower ();
void x_set_vertical_scrollbar (); void x_set_vertical_scrollbar ();
...@@ -420,7 +420,7 @@ static struct x_frame_parm_table x_frame_parms[] = ...@@ -420,7 +420,7 @@ static struct x_frame_parm_table x_frame_parms[] =
"font", x_set_font, "font", x_set_font,
"border-width", x_set_border_width, "border-width", x_set_border_width,
"internal-border-width", x_set_internal_border_width, "internal-border-width", x_set_internal_border_width,
"name", x_set_name, "name", x_explicitly_set_name,
"autoraise", x_set_autoraise, "autoraise", x_set_autoraise,
"autolower", x_set_autolower, "autolower", x_set_autolower,
"vertical-scrollbar", x_set_vertical_scrollbar, "vertical-scrollbar", x_set_vertical_scrollbar,
...@@ -1164,44 +1164,83 @@ x_set_internal_border_width (f, arg, oldval) ...@@ -1164,44 +1164,83 @@ x_set_internal_border_width (f, arg, oldval)
} }
} }
void void x_user_set_name (f, arg, oldval)
x_set_name (f, arg, oldval)
struct frame *f; struct frame *f;
Lisp_Object arg, oldval; Lisp_Object arg, oldval;
{ {
/* If ARG is nil, set the name to the x_id_name. */ }
if (NILP (arg))
arg = build_string (x_id_name); /* Change the name of frame F to ARG. If ARG is nil, set F's name to
x_id_name.
If EXPLICIT is non-zero, that indicates that lisp code is setting the
name; if ARG is a string, set F's name to ARG and set
F->explicit_name; if ARG is Qnil, then clear F->explicit_name.
If EXPLICIT is zero, that indicates that Emacs redisplay code is
suggesting a new name, which lisp code should override; if
F->explicit_name is set, ignore the new name; otherwise, set it. */
void
x_set_name (f, name, explicit)
struct frame *f;
Lisp_Object name;
int explicit;
{
/* Make sure that requests from lisp code override requests from
Emacs redisplay code. */
if (explicit)
{
/* If we're switching from explicit to implicit, we had better
update the mode lines and thereby update the title. */
if (f->explicit_name && NILP (name))
update_mode_lines;
f->explicit_name = ! NILP (name);
}
else if (f->explicit_name)
return;
/* If NAME is nil, set the name to the x_id_name. */
if (NILP (name))
name = build_string (x_id_name);
else else
CHECK_STRING (arg, 0); CHECK_STRING (name, 0);
/* Don't change the name if it's already ARG. */ /* Don't change the name if it's already NAME. */
if (! NILP (Fstring_equal (arg, f->name))) if (! NILP (Fstring_equal (name, f->name)))
return; return;
if (f->display.x->window_desc) if (f->display.x->window_desc)
{ {
#ifdef HAVE_X11
XTextProperty prop;
prop.value = XSTRING (arg)->data;
prop.encoding = XA_STRING;
prop.format = 8;
prop.nitems = XSTRING (arg)->size;
BLOCK_INPUT;
XSetWMName (XDISPLAY f->display.x->window_desc, &prop);
XSetWMIconName (XDISPLAY f->display.x->window_desc, &prop);
UNBLOCK_INPUT;
#else
BLOCK_INPUT; BLOCK_INPUT;
XStoreName (XDISPLAY f->display.x->window_desc, x_set_text_property (f, XA_WM_NAME, name);
(char *) XSTRING (arg)->data); x_set_text_property (f, XA_WM_ICON_NAME, name);
XSetIconName (XDISPLAY f->display.x->window_desc,
(char *) XSTRING (arg)->data);
UNBLOCK_INPUT; UNBLOCK_INPUT;
#endif
} }
f->name = arg; f->name = name;
}
/* This function should be called when the user's lisp code has
specified a name for the frame; the name will override any set by the
redisplay code. */
void
x_explicitly_set_name (f, arg, oldval)
FRAME_PTR f;
Lisp_Object arg, oldval;
{
x_set_name (f, arg, 1);
}
/* This function should be called by Emacs redisplay code to set the
name; names set this way will never override names set by the user's
lisp code. */
x_implicitly_set_name (f, arg, oldval)
FRAME_PTR f;
Lisp_Object arg, oldval;
{
x_set_name (f, arg, 0);
} }
void void
...@@ -1549,7 +1588,7 @@ The defaults are specified in the file `~/.Xdefaults'.") ...@@ -1549,7 +1588,7 @@ The defaults are specified in the file `~/.Xdefaults'.")
/* Types we might convert a resource string into. */ /* Types we might convert a resource string into. */
enum resource_types enum resource_types
{ {
number, boolean, string, number, boolean, string, symbol,
}; };
/* Return the value of parameter PARAM. /* Return the value of parameter PARAM.
...@@ -1600,6 +1639,9 @@ x_get_arg (alist, param, attribute, type) ...@@ -1600,6 +1639,9 @@ x_get_arg (alist, param, attribute, type)
case string: case string:
return tem; return tem;
case symbol:
return intern (tem);
default: default:
abort (); abort ();
} }
...@@ -1713,8 +1755,8 @@ x_figure_window_size (f, parms) ...@@ -1713,8 +1755,8 @@ x_figure_window_size (f, parms)
f->display.x->top_pos = 1; f->display.x->top_pos = 1;
f->display.x->left_pos = 1; f->display.x->left_pos = 1;
tem0 = x_get_arg (parms, Qheight, 0, 0); tem0 = x_get_arg (parms, Qheight, 0, number);
tem1 = x_get_arg (parms, Qwidth, 0, 0); tem1 = x_get_arg (parms, Qwidth, 0, number);
if (! EQ (tem0, Qunbound) && ! EQ (tem1, Qunbound)) if (! EQ (tem0, Qunbound) && ! EQ (tem1, Qunbound))
{ {
CHECK_NUMBER (tem0, 0); CHECK_NUMBER (tem0, 0);
...@@ -1731,8 +1773,8 @@ x_figure_window_size (f, parms) ...@@ -1731,8 +1773,8 @@ x_figure_window_size (f, parms)
f->display.x->pixel_height = (FONT_HEIGHT (f->display.x->font) * f->height f->display.x->pixel_height = (FONT_HEIGHT (f->display.x->font) * f->height
+ 2 * f->display.x->internal_border_width); + 2 * f->display.x->internal_border_width);
tem0 = x_get_arg (parms, Qtop, 0, 0); tem0 = x_get_arg (parms, Qtop, 0, number);
tem1 = x_get_arg (parms, Qleft, 0, 0); tem1 = x_get_arg (parms, Qleft, 0, number);
if (! EQ (tem0, Qunbound) && ! EQ (tem1, Qunbound)) if (! EQ (tem0, Qunbound) && ! EQ (tem1, Qunbound))
{ {
CHECK_NUMBER (tem0, 0); CHECK_NUMBER (tem0, 0);
...@@ -1817,7 +1859,7 @@ x_window (f) ...@@ -1817,7 +1859,7 @@ x_window (f)
Lisp_Object name = f->name; Lisp_Object name = f->name;
f->name = Qnil; f->name = Qnil;
x_set_name (f, name, Qnil); x_implicitly_set_name (f, name, Qnil);
} }
XDefineCursor (XDISPLAY f->display.x->window_desc, XDefineCursor (XDISPLAY f->display.x->window_desc,
...@@ -1841,8 +1883,8 @@ x_icon (f, parms) ...@@ -1841,8 +1883,8 @@ x_icon (f, parms)
/* Set the position of the icon. Note that twm groups all /* Set the position of the icon. Note that twm groups all
icons in an icon window. */ icons in an icon window. */
icon_x = x_get_arg (parms, Qicon_left, 0, 0); icon_x = x_get_arg (parms, Qicon_left, 0, number);
icon_y = x_get_arg (parms, Qicon_top, 0, 0); icon_y = x_get_arg (parms, Qicon_top, 0, number);
if (!EQ (icon_x, Qunbound) && !EQ (icon_y, Qunbound)) if (!EQ (icon_x, Qunbound) && !EQ (icon_y, Qunbound))
{ {
CHECK_NUMBER (icon_x, 0); CHECK_NUMBER (icon_x, 0);
...@@ -1861,9 +1903,11 @@ x_icon (f, parms) ...@@ -1861,9 +1903,11 @@ x_icon (f, parms)
x_wm_set_icon_position (f, XINT (icon_x), XINT (icon_y)); x_wm_set_icon_position (f, XINT (icon_x), XINT (icon_y));
/* Start up iconic or window? */ /* Start up iconic or window? */
x_wm_set_window_state (f, (EQ (x_get_arg (parms, Qiconic_startup, 0, 0), Qt) x_wm_set_window_state (f,
? IconicState (EQ (x_get_arg (parms, Qiconic_startup, 0, boolean),
: NormalState)); Qt)
? IconicState
: NormalState));
UNBLOCK_INPUT; UNBLOCK_INPUT;
} }
...@@ -1872,6 +1916,14 @@ x_icon (f, parms) ...@@ -1872,6 +1916,14 @@ x_icon (f, parms)
background, border and mouse colors; also create the background, border and mouse colors; also create the
mouse cursor and the gray border tile. */ mouse cursor and the gray border tile. */
static char cursor_bits[] =
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
static void static void
x_make_gc (f) x_make_gc (f)
struct frame *f; struct frame *f;
...@@ -1879,13 +1931,6 @@ x_make_gc (f) ...@@ -1879,13 +1931,6 @@ x_make_gc (f)
XGCValues gc_values; XGCValues gc_values;
GC temp_gc; GC temp_gc;
XImage tileimage; XImage tileimage;
static char cursor_bits[] =
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
/* Create the GC's of this frame. /* Create the GC's of this frame.
Note that many default values are used. */ Note that many default values are used. */
...@@ -1984,7 +2029,7 @@ be shared by the new frame.") ...@@ -1984,7 +2029,7 @@ be shared by the new frame.")
if (XTYPE (name) != Lisp_String) if (XTYPE (name) != Lisp_String)
error ("x-create-frame: name parameter must be a string"); error ("x-create-frame: name parameter must be a string");
tem = x_get_arg (parms, Qminibuffer, 0, 0); tem = x_get_arg (parms, Qminibuffer, 0, symbol);
if (EQ (tem, Qnone) || NILP (tem)) if (EQ (tem, Qnone) || NILP (tem))
f = make_frame_without_minibuffer (Qnil); f = make_frame_without_minibuffer (Qnil);
else if (EQ (tem, Qonly)) else if (EQ (tem, Qonly))
...@@ -2031,6 +2076,22 @@ be shared by the new frame.") ...@@ -2031,6 +2076,22 @@ be shared by the new frame.")
x_default_parameter (f, parms, Qborder_color, x_default_parameter (f, parms, Qborder_color,
build_string ("black"), "border", string); build_string ("black"), "border", string);
/* When XSetWMHints eventually gets called, this will indicate that
we use the "Passive Input" input model. Unless we do this, we
don't get the Focus{In,Out} events that we need to draw the
cursor correctly. Accursed bureaucrats.
We set this here and leave it, because we know, being decidedly
non-humble programmers (nay, weigh'd low by our hubris!), that
Fx_create_frame calls x_icon which begat x_wm_set_window_state
which begat XSetWMHints, which will get this information to the
right parties. -JimB
XWhipsAndChains (x_current_display, IronMaiden, &TheRack); */
f->display.x->wm_hints.input = True;
f->display.x->wm_hints.flags |= InputHint;
f->display.x->parent_desc = ROOT_WINDOW; f->display.x->parent_desc = ROOT_WINDOW;
window_prompting = x_figure_window_size (f, parms); window_prompting = x_figure_window_size (f, parms);
...@@ -2040,7 +2101,7 @@ be shared by the new frame.") ...@@ -2040,7 +2101,7 @@ be shared by the new frame.")
/* We need to do this after creating the X window, so that the /* We need to do this after creating the X window, so that the
icon-creation functions can say whose icon they're describing. */ icon-creation functions can say whose icon they're describing. */
x_default_parameter (f, parms, Qicon_type, Qt, "IconType", boolean); x_default_parameter (f, parms, Qicon_type, Qnil, "IconType", symbol);
x_default_parameter (f, parms, Qauto_raise, Qnil, "AutoRaise", boolean); x_default_parameter (f, parms, Qauto_raise, Qnil, "AutoRaise", boolean);
x_default_parameter (f, parms, Qauto_lower, Qnil, "AutoLower", boolean); x_default_parameter (f, parms, Qauto_lower, Qnil, "AutoLower", boolean);
...@@ -2056,17 +2117,17 @@ be shared by the new frame.") ...@@ -2056,17 +2117,17 @@ be shared by the new frame.")
x_wm_set_size_hint (f, window_prompting); x_wm_set_size_hint (f, window_prompting);
UNBLOCK_INPUT; UNBLOCK_INPUT;
tem = x_get_arg (parms, Qunsplittable, 0, 0); tem = x_get_arg (parms, Qunsplittable, 0, boolean);
f->no_split = minibuffer_only || EQ (tem, Qt); f->no_split = minibuffer_only || EQ (tem, Qt);
/* Now handle the rest of the parameters. */ /* Now handle the rest of the parameters. */
x_default_parameter (f, parms, Qhorizontal_scroll_bar, x_default_parameter (f, parms, Qhorizontal_scroll_bar,
Qnil, "?HScrollBar", string); Qnil, "HScrollBar", boolean);
x_default_parameter (f, parms, Qvertical_scroll_bar, x_default_parameter (f, parms, Qvertical_scroll_bar,
Qnil, "?VScrollBar", string); Qnil, "VScrollBar", boolean);
/* Make the window appear on the frame and enable display. */ /* Make the window appear on the frame and enable display. */
if (!EQ (x_get_arg (parms, Qsuppress_initial_map, 0, 0), Qt)) if (!EQ (x_get_arg (parms, Qsuppress_initial_map, 0, boolean), Qt))
x_make_frame_visible (f); x_make_frame_visible (f);
return frame; return frame;
...@@ -2087,9 +2148,7 @@ be shared by the new frame.") ...@@ -2087,9 +2148,7 @@ be shared by the new frame.")
name = Fassq (Qname, parms); name = Fassq (Qname, parms);
tem = x_get_arg (parms, Qminibuffer, 0, string); tem = x_get_arg (parms, Qminibuffer, 0, symbol);
if (XTYPE (tem) == Lisp_String)
tem = Fintern (tem, Qnil);
if (EQ (tem, Qnone)) if (EQ (tem, Qnone))
f = make_frame_without_minibuffer (Qnil); f = make_frame_without_minibuffer (Qnil);
else if (EQ (tem, Qonly)) else if (EQ (tem, Qonly))
...@@ -2181,29 +2240,29 @@ be shared by the new frame.") ...@@ -2181,29 +2240,29 @@ be shared by the new frame.")
} }
else else
{ {
tem = x_get_arg (parms, Qparent_id, 0, 0); tem = x_get_arg (parms, Qparent_id, 0, number);
if (!EQ (tem, Qunbound)) if (!EQ (tem, Qunbound))
{ {
CHECK_NUMBER (tem, 0); CHECK_NUMBER (tem, 0);
parent = (Window) XINT (tem); parent = (Window) XINT (tem);
} }
f->display.x->parent_desc = parent; f->display.x->parent_desc = parent;
tem = x_get_arg (parms, Qheight, 0, 0); tem = x_get_arg (parms, Qheight, 0, number);
if (EQ (tem, Qunbound)) if (EQ (tem, Qunbound))
{ {
tem = x_get_arg (parms, Qwidth, 0, 0); tem = x_get_arg (parms, Qwidth, 0, number);
if (EQ (tem, Qunbound)) if (EQ (tem, Qunbound))
{ {
tem = x_get_arg (parms, Qtop, 0, 0); tem = x_get_arg (parms, Qtop, 0, number);
if (EQ (tem, Qunbound)) if (EQ (tem, Qunbound))
tem = x_get_arg (parms, Qleft, 0, 0); tem = x_get_arg (parms, Qleft, 0, number);
} }
} }
/* Now TEM is Qunbound if no edge or size was specified. /* Now TEM is Qunbound if no edge or size was specified.
In that case, we must do rubber-banding. */ In that case, we must do rubber-banding. */
if (EQ (tem, Qunbound)) if (EQ (tem, Qunbound))
{ {
tem = x_get_arg (parms, Qgeometry, 0, 0); tem = x_get_arg (parms, Qgeometry, 0, number);
x_rubber_band (f, x_rubber_band (f,
&f->display.x->left_pos, &f->display.x->top_pos, &f->display.x->left_pos, &f->display.x->top_pos,
&width, &height, &width, &height,
...@@ -2216,25 +2275,25 @@ be shared by the new frame.") ...@@ -2216,25 +2275,25 @@ be shared by the new frame.")
{ {
/* Here if at least one edge or size was specified. /* Here if at least one edge or size was specified.
Demand that they all were specified, and use them. */ Demand that they all were specified, and use them. */
tem = x_get_arg (parms, Qheight, 0, 0); tem = x_get_arg (parms, Qheight, 0, number);
if (EQ (tem, Qunbound)) if (EQ (tem, Qunbound))
error ("Height not specified"); error ("Height not specified");
CHECK_NUMBER (tem, 0); CHECK_NUMBER (tem, 0);
height = XINT (tem); height = XINT (tem);
tem = x_get_arg (parms, Qwidth, 0, 0); tem = x_get_arg (parms, Qwidth, 0, number);
if (EQ (tem, Qunbound)) if (EQ (tem, Qunbound))
error ("Width not specified"); error ("Width not specified");
CHECK_NUMBER (tem, 0); CHECK_NUMBER (tem, 0);
width = XINT (tem); width = XINT (tem);
tem = x_get_arg (parms, Qtop, 0, 0); tem = x_get_arg (parms, Qtop, 0, number);
if (EQ (tem, Qunbound)) if (EQ (tem, Qunbound))
error ("Top position not specified"); error ("Top position not specified");
CHECK_NUMBER (tem, 0); CHECK_NUMBER (tem, 0);
f->display.x->left_pos = XINT (tem); f->display.x->left_pos = XINT (tem);
tem = x_get_arg (parms, Qleft, 0, 0); tem = x_get_arg (parms, Qleft, 0, number);
if (EQ (tem, Qunbound)) if (EQ (tem, Qunbound))
error ("Left position not specified"); error ("Left position not specified");
CHECK_NUMBER (tem, 0); CHECK_NUMBER (tem, 0);
...@@ -2274,16 +2333,16 @@ be shared by the new frame.") ...@@ -2274,16 +2333,16 @@ be shared by the new frame.")
/* Now override the defaults with all the rest of the specified /* Now override the defaults with all the rest of the specified
parms. */ parms. */
tem = x_get_arg (parms, Qunsplittable, 0, 0); tem = x_get_arg (parms, Qunsplittable, 0, boolean);
f->no_split = minibuffer_only || EQ (tem, Qt); f->no_split = minibuffer_only || EQ (tem, Qt);
/* Do not create an icon window if the caller says not to */ /* Do not create an icon window if the caller says not to */
if (!EQ (x_get_arg (parms, Qsuppress_icon, 0, 0), Qt) if (!EQ (x_get_arg (parms, Qsuppress_icon, 0, boolean), Qt)
|| f->display.x->parent_desc != ROOT_WINDOW) || f->display.x->parent_desc != ROOT_WINDOW)
{ {
x_text_icon (f, iconidentity); x_text_icon (f, iconidentity);
x_default_parameter (f, parms, Qicon_type, Qnil, x_default_parameter (f, parms, Qicon_type, Qnil,
"BitmapIcon", boolean); "BitmapIcon", symbol);
} }
/* Tell the X server the previously set values of the /* Tell the X server the previously set values of the
...@@ -2308,7 +2367,7 @@ be shared by the new frame.") ...@@ -2308,7 +2367,7 @@ be shared by the new frame.")
/* Make the window appear on the frame and enable display. */ /* Make the window appear on the frame and enable display. */
if (!EQ (x_get_arg (parms, Qsuppress_initial_map, 0, 0), Qt)) if (!EQ (x_get_arg (parms, Qsuppress_initial_map, 0, boolean), Qt))
x_make_window_visible (f); x_make_window_visible (f);
FRAME_GARBAGED (f); FRAME_GARBAGED (f);
...@@ -4259,7 +4318,10 @@ select_visual (screen, depth) ...@@ -4259,7 +4318,10 @@ select_visual (screen, depth)
int n_visuals; int n_visuals;
v = DefaultVisualOfScreen (screen); v = DefaultVisualOfScreen (screen);
vinfo_template.visualid = XVisualIDFromVisual (v); /* It may be a bad idea to fetch the visualid directly from the structure,
rather than using XVisualIDFromVisual, but I'll bet this is pretty
portable for the revisions of X we care about. */
vinfo_template.visualid = v->visualid;
vinfo = XGetVisualInfo (x_current_display, VisualIDMask, &vinfo_template, vinfo = XGetVisualInfo (x_current_display, VisualIDMask, &vinfo_template,
&n_visuals); &n_visuals);
if (n_visuals != 1) if (n_visuals != 1)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment