#include "buffer.h"
#include "dispextern.h"
#include "keyboard.h"
+#include "blockinput.h"
#ifdef HAVE_X_WINDOWS
extern void abort ();
+#ifndef VMS
#include <X11/bitmaps/gray>
+#else
+#include "[.bitmaps]gray.xbm"
+#endif
#define min(a,b) ((a) < (b) ? (a) : (b))
#define max(a,b) ((a) > (b) ? (a) : (b))
/* Title name and application name for X stuff. */
extern char *x_id_name;
-extern Lisp_Object invocation_name;
/* The background and shape of the mouse pointer, and shape when not
over text or in the modeline. */
Lisp_Object Qfont;
Lisp_Object Qforeground_color;
Lisp_Object Qgeometry;
+Lisp_Object Qicon;
Lisp_Object Qicon_left;
Lisp_Object Qicon_top;
Lisp_Object Qicon_type;
-Lisp_Object Qiconic_startup;
Lisp_Object Qinternal_border_width;
Lisp_Object Qleft;
Lisp_Object Qmouse_color;
Lisp_Object Qnone;
Lisp_Object Qparent_id;
Lisp_Object Qsuppress_icon;
-Lisp_Object Qsuppress_initial_map;
Lisp_Object Qtop;
Lisp_Object Qundefined_color;
Lisp_Object Qvertical_scroll_bars;
+Lisp_Object Qvisibility;
Lisp_Object Qwindow_id;
Lisp_Object Qx_frame_parameter;
-Lisp_Object Qvisibility;
/* The below are defined in frame.c. */
extern Lisp_Object Qheight, Qminibuffer, Qname, Qonly, Qwidth;
/* Return the Emacs frame-object corresponding to an X window.
It could be the frame's main window or an icon window. */
+/* This function can be called during GC, so use XGCTYPE. */
+
struct frame *
x_window_to_frame (wdesc)
int wdesc;
Lisp_Object tail, frame;
struct frame *f;
- for (tail = Vframe_list; CONSP (tail); tail = XCONS (tail)->cdr)
+ for (tail = Vframe_list; XGCTYPE (tail) == Lisp_Cons;
+ tail = XCONS (tail)->cdr)
{
frame = XCONS (tail)->car;
- if (XTYPE (frame) != Lisp_Frame)
+ if (XGCTYPE (frame) != Lisp_Frame)
continue;
f = XFRAME (frame);
if (FRAME_X_WINDOW (f) == wdesc
if (f->display.x->cursor_pixel == fore_pixel)
fore_pixel = f->display.x->background_pixel;
}
+ f->display.x->cursor_foreground_pixel = fore_pixel;
if (FRAME_X_WINDOW (f) != 0)
{
if (NILP (value))
Fmake_frame_invisible (frame);
- else if (EQ (value, Qt))
- Fmake_frame_visible (frame);
- else
+ else if (EQ (value, Qicon))
Ficonify_frame (frame);
+ else
+ Fmake_frame_visible (frame);
}
static void
int nlines;
int olines = FRAME_MENU_BAR_LINES (f);
+ /* Right now, menu bars don't work properly in minibuf-only frames;
+ most of the commands try to apply themselves to the minibuffer
+ frame itslef, and get an error because you can't switch buffers
+ in or split the minibuffer window. */
+ if (FRAME_MINIBUF_ONLY_P (f))
+ return;
+
if (XTYPE (value) == Lisp_Int)
nlines = XINT (value);
else
{
/* Allocate space for the components, the dots which separate them,
and the final '\0'. */
- name_key = (char *) alloca (XSTRING (invocation_name)->size
+ name_key = (char *) alloca (XSTRING (Vinvocation_name)->size
+ XSTRING (attribute)->size
+ 2);
class_key = (char *) alloca ((sizeof (EMACS_CLASS) - 1)
+ 2);
sprintf (name_key, "%s.%s",
- XSTRING (invocation_name)->data,
+ XSTRING (Vinvocation_name)->data,
XSTRING (attribute)->data);
sprintf (class_key, "%s.%s",
EMACS_CLASS,
}
else
{
- name_key = (char *) alloca (XSTRING (invocation_name)->size
+ name_key = (char *) alloca (XSTRING (Vinvocation_name)->size
+ XSTRING (component)->size
+ XSTRING (attribute)->size
+ 3);
+ 3);
sprintf (name_key, "%s.%s.%s",
- XSTRING (invocation_name)->data,
+ XSTRING (Vinvocation_name)->data,
XSTRING (component)->data,
XSTRING (attribute)->data);
sprintf (class_key, "%s.%s",
CHECK_STRING (arg, 1);
value = (unsigned char *) XGetDefault (XDISPLAY
- XSTRING (invocation_name)->data,
+ XSTRING (Vinvocation_name)->data,
XSTRING (arg)->data);
if (value == 0)
/* Try reversing last two args, in case this is the buggy version of X. */
value = (unsigned char *) XGetDefault (XDISPLAY
XSTRING (arg)->data,
- XSTRING (invocation_name)->data);
+ XSTRING (Vinvocation_name)->data);
if (value != 0)
return build_string (value);
else
return tem;
case symbol:
- return intern (tem);
+ /* As a special case, we map the values `true' and `on'
+ to Qt, and `false' and `off' to Qnil. */
+ {
+ Lisp_Object lower = Fdowncase (tem);
+ if (!strcmp (XSTRING (tem)->data, "on")
+ || !strcmp (XSTRING (tem)->data, "true"))
+ return Qt;
+ else if (!strcmp (XSTRING (tem)->data, "off")
+ || !strcmp (XSTRING (tem)->data, "false"))
+ return Qnil;
+ else
+ return Fintern (tem, Qnil);
+ }
default:
abort ();
return tem;
}
\f
-DEFUN ("x-geometry", Fx_geometry, Sx_geometry, 1, 1, 0,
+DEFUN ("x-parse-geometry", Fx_parse_geometry, Sx_parse_geometry, 1, 1, 0,
"Parse an X-style geometry string STRING.\n\
Returns an alist of the form ((top . TOP), (left . LEFT) ... ).")
(string)
x_wm_set_icon_position (f, XINT (icon_x), XINT (icon_y));
/* Start up iconic or window? */
- x_wm_set_window_state (f,
- (EQ (x_get_arg (parms, Qiconic_startup,
- 0, 0, boolean),
- Qt)
- ? IconicState
- : NormalState));
+ x_wm_set_window_state
+ (f, (EQ (x_get_arg (parms, Qvisibility, 0, 0, symbol), Qicon)
+ ? IconicState
+ : NormalState));
UNBLOCK_INPUT;
}
GC temp_gc;
XImage tileimage;
+ BLOCK_INPUT;
+
/* Create the GC's of this frame.
Note that many default values are used. */
f->display.x->foreground_pixel,
f->display.x->background_pixel,
DefaultDepth (x_current_display, XDefaultScreen (x_current_display))));
+
+ init_frame_faces (f);
+
+ UNBLOCK_INPUT;
}
#endif /* HAVE_X11 */
/* Extract the window parameters from the supplied values
that are needed to determine window geometry. */
- x_default_parameter (f, parms, Qfont, build_string ("9x15"),
+ x_default_parameter (f, parms, Qfont,
+ build_string
+ /* If we use an XLFD name for this font, the lisp code
+ knows how to find variants which are bold, italic,
+ etcetera. */
+ ("-*-fixed-*-*-*-*-*-120-*-*-c-*-iso8859-1"),
"font", "Font", string);
x_default_parameter (f, parms, Qborder_width, make_number (2),
"borderwidth", "BorderWidth", number);
/* Make the window appear on the frame and enable display,
unless the caller says not to. */
- if (!EQ (x_get_arg (parms, Qsuppress_initial_map, 0, 0, boolean), Qt))
- {
- tem = x_get_arg (parms, Qvisibility, 0, 0, boolean);
- if (EQ (tem, Qicon))
- x_iconify_frame (f);
- /* Note that the default is Qunbound,
- so by default we do make visible. */
- else if (!EQ (tem, Qnil))
- x_make_frame_visible (f);
- }
+ {
+ Lisp_Object visibility = x_get_arg (parms, Qvisibility, 0, 0, symbol);
+
+ if (EQ (visibility, Qunbound))
+ visibility = Qt;
+
+ if (EQ (visibility, Qicon))
+ x_iconify_frame (f);
+ else if (! NILP (visibility))
+ x_make_frame_visible (f);
+ else
+ /* Must have been Qnil. */
+ ;
+ }
return frame;
#else /* X10 */
BLOCK_INPUT;
XGetWindowInfo (FRAME_X_WINDOW (f), &wininfo);
XQueryTree (FRAME_X_WINDOW (f), &parent, &nchildren, &children);
- free (children);
+ xfree (children);
UNBLOCK_INPUT;
height = PIXEL_TO_CHAR_HEIGHT (f, wininfo.height);
Fmodify_frame_parameters (frame, parms);
/* Make the window appear on the frame and enable display. */
+ {
+ Lisp_Object visibility = x_get_arg (parms, Qvisibility, 0, 0, symbol);
+
+ if (EQ (visibility, Qunbound))
+ visibility = Qt;
+
+ if (! EQ (visibility, Qicon)
+ && ! NILP (visibility))
+ x_make_window_visible (f);
+ }
- if (!EQ (x_get_arg (parms, Qsuppress_initial_map, 0, 0, boolean), Qt))
- x_make_window_visible (f);
SET_FRAME_GARBAGED (f);
return frame;
*x -= wininfo.x;
*y -= wininfo.y;
XQueryTree (tempwindow, &tempwindow, &nchildren, &children);
- free (children);
+ xfree (children);
}
UNBLOCK_INPUT;
}
#endif /* not HAVE_X11 */
\f
-DEFUN ("x-defined-color", Fx_defined_color, Sx_defined_color, 1, 1, 0,
+DEFUN ("x-color-defined-p", Fx_color_defined_p, Sx_color_defined_p, 1, 1, 0,
"Return t if the current X display supports the color named COLOR.")
(color)
Lisp_Object color;
f->display.x->normal_gc, 0, 0, width, height, x, y);
}
#endif
-\f
-#if 0
-
-#ifdef HAVE_X11
-#define XMouseEvent XEvent
-#define WhichMouseButton xbutton.button
-#define MouseWindow xbutton.window
-#define MouseX xbutton.x
-#define MouseY xbutton.y
-#define MouseTime xbutton.time
-#define ButtonReleased ButtonRelease
-#define ButtonPressed ButtonPress
-#else
-#define XMouseEvent XButtonEvent
-#define WhichMouseButton detail
-#define MouseWindow window
-#define MouseX x
-#define MouseY y
-#define MouseTime time
-#endif /* X11 */
-
-DEFUN ("x-mouse-events", Fx_mouse_events, Sx_mouse_events, 0, 0, 0,
- "Return number of pending mouse events from X window system.")
- ()
-{
- return make_number (queue_event_count (&x_mouse_queue));
-}
-
-/* Encode the mouse button events in the form expected by the
- mouse code in Lisp. For X11, this means moving the masks around. */
-
-static int
-encode_mouse_button (mouse_event)
- XMouseEvent mouse_event;
-{
- register int event_code;
- register char key_mask;
-
- event_code = mouse_event.detail & 3;
- key_mask = (mouse_event.detail >> 8) & 0xf0;
- event_code |= key_mask >> 1;
- if (mouse_event.type == ButtonReleased) event_code |= 0x04;
- return event_code;
-}
-
-DEFUN ("x-get-mouse-event", Fx_get_mouse_event, Sx_get_mouse_event,
- 0, 1, 0,
- "Get next mouse event out of mouse event buffer.\n\
-Optional ARG non-nil means return nil immediately if no pending event;\n\
-otherwise, wait for an event. Returns a four-part list:\n\
- ((X-POS Y-POS) WINDOW FRAME-PART KEYSEQ TIMESTAMP).\n\
-Normally X-POS and Y-POS are the position of the click on the frame\n\
- (measured in characters and lines), and WINDOW is the window clicked in.\n\
-KEYSEQ is a string, the key sequence to be looked up in the mouse maps.\n\
-If FRAME-PART is non-nil, the event was on a scroll bar;\n\
-then Y-POS is really the total length of the scroll bar, while X-POS is\n\
-the relative position of the scroll bar's value within that total length,\n\
-and a third element OFFSET appears in that list: the height of the thumb-up\n\
-area at the top of the scroll bar.\n\
-FRAME-PART is one of the following symbols:\n\
- `vertical-scroll-bar', `vertical-thumbup', `vertical-thumbdown',\n\
- `horizontal-scroll-bar', `horizontal-thumbleft', `horizontal-thumbright'.\n\
-TIMESTAMP is the lower 23 bits of the X-server's timestamp for\n\
-the mouse event.")
- (arg)
- Lisp_Object arg;
-{
- XMouseEvent xrep;
- register int com_letter;
- register Lisp_Object tempx;
- register Lisp_Object tempy;
- Lisp_Object part, pos, timestamp;
- int prefix;
- struct frame *f;
-
- int tem;
-
- while (1)
- {
- BLOCK_INPUT;
- tem = dequeue_event (&xrep, &x_mouse_queue);
- UNBLOCK_INPUT;
-
- if (tem)
- {
- switch (xrep.type)
- {
- case ButtonPressed:
- case ButtonReleased:
-
- com_letter = encode_mouse_button (xrep);
- mouse_timestamp = xrep.MouseTime;
-
- if ((f = x_window_to_frame (xrep.MouseWindow)) != 0)
- {
- Lisp_Object frame;
-
- if (f->display.x->icon_desc == xrep.MouseWindow)
- {
- x_make_frame_visible (f);
- continue;
- }
-
- XSET (tempx, Lisp_Int,
- min (f->width-1, max (0, (xrep.MouseX - f->display.x->internal_border_width)/FONT_WIDTH (f->display.x->font))));
- XSET (tempy, Lisp_Int,
- min (f->height-1, max (0, (xrep.MouseY - f->display.x->internal_border_width)/FONT_HEIGHT (f->display.x->font))));
- XSET (timestamp, Lisp_Int, (xrep.MouseTime & 0x7fffff));
- XSET (frame, Lisp_Frame, f);
-
- pos = Fcons (tempx, Fcons (tempy, Qnil));
- Vmouse_window
- = Flocate_window_from_coordinates (frame, pos);
-
- Vmouse_event
- = Fcons (pos,
- Fcons (Vmouse_window,
- Fcons (Qnil,
- Fcons (Fchar_to_string (make_number (com_letter)),
- Fcons (timestamp, Qnil)))));
- return Vmouse_event;
- }
- else if ((f = x_window_to_scroll_bar (xrep.MouseWindow, &part, &prefix)) != 0)
- {
- int pos, len;
- Lisp_Object keyseq;
- char *partname;
-
- keyseq = concat2 (Fchar_to_string (make_number (prefix)),
- Fchar_to_string (make_number (com_letter)));
-
- pos = xrep.MouseY - (f->display.x->v_scroll_bar_width - 2);
- XSET (tempx, Lisp_Int, pos);
- len = ((FONT_HEIGHT (f->display.x->font) * f->height)
- + f->display.x->internal_border_width
- - (2 * (f->display.x->v_scroll_bar_width - 2)));
- XSET (tempy, Lisp_Int, len);
- XSET (timestamp, Lisp_Int, (xrep.MouseTime & 0x7fffff));
- Vmouse_window = f->selected_window;
- Vmouse_event
- = Fcons (Fcons (tempx, Fcons (tempy,
- Fcons (make_number (f->display.x->v_scroll_bar_width - 2),
- Qnil))),
- Fcons (Vmouse_window,
- Fcons (intern (part),
- Fcons (keyseq, Fcons (timestamp,
- Qnil)))));
- return Vmouse_event;
- }
- else
- continue;
-
-#ifdef HAVE_X11
- case MotionNotify:
-
- com_letter = x11_encode_mouse_button (xrep);
- if ((f = x_window_to_frame (xrep.MouseWindow)) != 0)
- {
- Lisp_Object frame;
-
- XSET (tempx, Lisp_Int,
- min (f->width-1,
- max (0, (xrep.MouseX - f->display.x->internal_border_width)
- / FONT_WIDTH (f->display.x->font))));
- XSET (tempy, Lisp_Int,
- min (f->height-1,
- max (0, (xrep.MouseY - f->display.x->internal_border_width)
- / FONT_HEIGHT (f->display.x->font))));
-
- XSET (frame, Lisp_Frame, f);
- XSET (timestamp, Lisp_Int, (xrep.MouseTime & 0x7fffff));
-
- pos = Fcons (tempx, Fcons (tempy, Qnil));
- Vmouse_window
- = Flocate_window_from_coordinates (frame, pos);
-
- Vmouse_event
- = Fcons (pos,
- Fcons (Vmouse_window,
- Fcons (Qnil,
- Fcons (Fchar_to_string (make_number (com_letter)),
- Fcons (timestamp, Qnil)))));
- return Vmouse_event;
- }
-
- break;
-#endif /* HAVE_X11 */
-
- default:
- if (f = x_window_to_frame (xrep.MouseWindow))
- Vmouse_window = f->selected_window;
- else if (f = x_window_to_scroll_bar (xrep.MouseWindow, &part, &prefix))
- Vmouse_window = f->selected_window;
- return Vmouse_event = Qnil;
- }
- }
-
- if (!NILP (arg))
- return Qnil;
-
- /* Wait till we get another mouse event. */
- wait_reading_process_input (0, 0, 2, 0);
- }
-}
-#endif
-
\f
#ifndef HAVE_X11
DEFUN ("x-store-cut-buffer", Fx_store_cut_buffer, Sx_store_cut_buffer,
#ifdef HAVE_X11R4
vinfo_template.visualid = XVisualIDFromVisual (v);
#else
- vinfo_template.visualid = x->visualid;
+ vinfo_template.visualid = v->visualid;
#endif
vinfo = XGetVisualInfo (x_current_display, VisualIDMask, &vinfo_template,
else
xrm_option = (unsigned char *) 0;
xrdb = x_load_resources (x_current_display, xrm_option, EMACS_CLASS);
+#ifdef HAVE_X11R5
+ XrmSetDatabase (x_current_display, xrdb);
+#else
x_current_display->db = xrdb;
+#endif
x_screen = DefaultScreenOfDisplay (x_current_display);
staticpro (&Qforeground_color);
Qgeometry = intern ("geometry");
staticpro (&Qgeometry);
+ Qicon = intern ("icon");
+ staticpro (&Qicon);
Qicon_left = intern ("icon-left");
staticpro (&Qicon_left);
Qicon_top = intern ("icon-top");
staticpro (&Qicon_top);
Qicon_type = intern ("icon-type");
staticpro (&Qicon_type);
- Qiconic_startup = intern ("iconic-startup");
- staticpro (&Qiconic_startup);
Qinternal_border_width = intern ("internal-border-width");
staticpro (&Qinternal_border_width);
Qleft = intern ("left");
staticpro (&Qparent_id);
Qsuppress_icon = intern ("suppress-icon");
staticpro (&Qsuppress_icon);
- Qsuppress_initial_map = intern ("suppress-initial-map");
- staticpro (&Qsuppress_initial_map);
Qtop = intern ("top");
staticpro (&Qtop);
Qundefined_color = intern ("undefined-color");
staticpro (&Qundefined_color);
Qvertical_scroll_bars = intern ("vertical-scroll-bars");
staticpro (&Qvertical_scroll_bars);
+ Qvisibility = intern ("visibility");
+ staticpro (&Qvisibility);
Qwindow_id = intern ("window-id");
staticpro (&Qwindow_id);
Qx_frame_parameter = intern ("x-frame-parameter");
staticpro (&Qx_frame_parameter);
/* This is the end of symbol initialization. */
- Qvisibility = intern ("visibility");
- staticpro (&Qvisibility);
Fput (Qundefined_color, Qerror_conditions,
Fcons (Qundefined_color, Fcons (Qerror, Qnil)));
mouse_buffer_offset = 0;
DEFVAR_INT ("x-pointer-shape", &Vx_pointer_shape,
- "The shape of the pointer when over text.");
+ "The shape of the pointer when over text.\n\
+Changing the value does not affect existing frames\n\
+unless you set the mouse color.");
Vx_pointer_shape = Qnil;
+#if 0
DEFVAR_INT ("x-nontext-pointer-shape", &Vx_nontext_pointer_shape,
"The shape of the pointer when not over text.");
+#endif
Vx_nontext_pointer_shape = Qnil;
+#if 0
DEFVAR_INT ("x-mode-pointer-shape", &Vx_mode_pointer_shape,
"The shape of the pointer when over the mode line.");
+#endif
Vx_mode_pointer_shape = Qnil;
DEFVAR_LISP ("x-cursor-fore-pixel", &Vx_cursor_fore_pixel,
defsubr (&Sx_uncontour_region);
#endif
defsubr (&Sx_display_color_p);
- defsubr (&Sx_defined_color);
+ defsubr (&Sx_color_defined_p);
defsubr (&Sx_server_vendor);
defsubr (&Sx_server_version);
defsubr (&Sx_display_pixel_width);
defsubr (&Sx_get_cut_buffer);
defsubr (&Sx_set_face);
#endif
- defsubr (&Sx_geometry);
+ defsubr (&Sx_parse_geometry);
defsubr (&Sx_create_frame);
defsubr (&Sfocus_frame);
defsubr (&Sunfocus_frame);
defsubr (&Sx_open_connection);
defsubr (&Sx_close_current_connection);
defsubr (&Sx_synchronize);
-
- /* This was used in the old event interface which used a separate
- event queue.*/
-#if 0
- defsubr (&Sx_mouse_events);
- defsubr (&Sx_get_mouse_event);
-#endif
}
#endif /* HAVE_X_WINDOWS */