- p->y = begin->y;
- p->x = ibw + (font_w * (x_pos + 1));
- p++;
- p->y = begin->y + font_h;
- p->x = (p - 1)->x;
- bcopy (end, begin + 3, contour_last_point - end + 1);
- contour_last_point -= (npoints - 5);
- XDrawLines (x_current_display, contour_window,
- contour_erase_gc, begin, 4, CoordModeOrigin);
- XFlush (x_current_display);
-
- /* Now, update contour_lines structure. */
- }
-}
-
-/* Erase the top horizontal lines of the contour, and then extend
- the contour upwards. */
-
-static void
-extend_contour_top (line)
-{
-}
-
-static void
-clip_contour_bottom (x_pos, y_pos)
- int x_pos, y_pos;
-{
-}
-
-static void
-extend_contour_bottom (x_pos, y_pos)
-{
-}
-
-DEFUN ("x-select-region", Fx_select_region, Sx_select_region, 1, 1, "e",
- "")
- (event)
- Lisp_Object event;
-{
- register struct frame *f = selected_frame;
- struct window *w = XWINDOW (FRAME_SELECTED_WINDOW (f));
- register int point_x = WINDOW_TO_FRAME_PIXEL_X (w, w->cursor.x);
- register int point_y = WINDOW_TO_FRAME_PIXEL_Y (w, w->cursor.y);
- register int mouse_below_point;
- register Lisp_Object obj;
- register int x_contour_x, x_contour_y;
-
- x_contour_x = x_mouse_x;
- x_contour_y = x_mouse_y;
- if (x_contour_y > point_y || (x_contour_y == point_y
- && x_contour_x > point_x))
- {
- mouse_below_point = 1;
- outline_region (f, f->output_data.x->cursor_gc, point_x, point_y,
- x_contour_x, x_contour_y);
- }
- else
- {
- mouse_below_point = 0;
- outline_region (f, f->output_data.x->cursor_gc, x_contour_x, x_contour_y,
- point_x, point_y);
- }
-
- while (1)
- {
- obj = read_char (-1, 0, 0, Qnil, 0);
- if (!CONSP (obj))
- break;
-
- if (mouse_below_point)
- {
- if (x_mouse_y <= point_y) /* Flipped. */
- {
- mouse_below_point = 0;
-
- outline_region (f, f->output_data.x->reverse_gc, point_x, point_y,
- x_contour_x, x_contour_y);
- outline_region (f, f->output_data.x->cursor_gc, x_mouse_x, x_mouse_y,
- point_x, point_y);
- }
- else if (x_mouse_y < x_contour_y) /* Bottom clipped. */
- {
- clip_contour_bottom (x_mouse_y);
- }
- else if (x_mouse_y > x_contour_y) /* Bottom extended. */
- {
- extend_bottom_contour (x_mouse_y);
- }
-
- x_contour_x = x_mouse_x;
- x_contour_y = x_mouse_y;
- }
- else /* mouse above or same line as point */
- {
- if (x_mouse_y >= point_y) /* Flipped. */
- {
- mouse_below_point = 1;
-
- outline_region (f, f->output_data.x->reverse_gc,
- x_contour_x, x_contour_y, point_x, point_y);
- outline_region (f, f->output_data.x->cursor_gc, point_x, point_y,
- x_mouse_x, x_mouse_y);
- }
- else if (x_mouse_y > x_contour_y) /* Top clipped. */
- {
- clip_contour_top (x_mouse_y);
- }
- else if (x_mouse_y < x_contour_y) /* Top extended. */
- {
- extend_contour_top (x_mouse_y);
- }
- }
- }
-
- unread_command_event = obj;
- if (mouse_below_point)
- {
- contour_begin_x = point_x;
- contour_begin_y = point_y;
- contour_end_x = x_contour_x;
- contour_end_y = x_contour_y;
- }
- else
- {
- contour_begin_x = x_contour_x;
- contour_begin_y = x_contour_y;
- contour_end_x = point_x;
- contour_end_y = point_y;
- }
-}
-#endif
-
-DEFUN ("x-horizontal-line", Fx_horizontal_line, Sx_horizontal_line, 1, 1, "e",
- "")
- (event)
- Lisp_Object event;
-{
- register Lisp_Object obj;
- struct frame *f = selected_frame;
- register struct window *w = XWINDOW (selected_window);
- register GC line_gc = f->output_data.x->cursor_gc;
- register GC erase_gc = f->output_data.x->reverse_gc;
-#if 0
- char dash_list[] = {6, 4, 6, 4};
- int dashes = 4;
- XGCValues gc_values;
-#endif
- register int previous_y;
- register int line = (x_mouse_y + 1) * f->output_data.x->line_height
- + f->output_data.x->internal_border_width;
- register int left = f->output_data.x->internal_border_width
- + (WINDOW_LEFT_MARGIN (w)
- * FONT_WIDTH (f->output_data.x->font));
- register int right = left + (w->width
- * FONT_WIDTH (f->output_data.x->font))
- - f->output_data.x->internal_border_width;
-
-#if 0
- BLOCK_INPUT;
- gc_values.foreground = f->output_data.x->cursor_pixel;
- gc_values.background = f->output_data.x->background_pixel;
- gc_values.line_width = 1;
- gc_values.line_style = LineOnOffDash;
- gc_values.cap_style = CapRound;
- gc_values.join_style = JoinRound;
-
- line_gc = XCreateGC (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
- GCLineStyle | GCJoinStyle | GCCapStyle
- | GCLineWidth | GCForeground | GCBackground,
- &gc_values);
- XSetDashes (FRAME_X_DISPLAY (f), line_gc, 0, dash_list, dashes);
- gc_values.foreground = f->output_data.x->background_pixel;
- gc_values.background = f->output_data.x->foreground_pixel;
- erase_gc = XCreateGC (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
- GCLineStyle | GCJoinStyle | GCCapStyle
- | GCLineWidth | GCForeground | GCBackground,
- &gc_values);
- XSetDashes (FRAME_X_DISPLAY (f), erase_gc, 0, dash_list, dashes);
- UNBLOCK_INPUT;
-#endif
-
- while (1)
- {
- BLOCK_INPUT;
- if (x_mouse_y >= XINT (w->top)
- && x_mouse_y < XINT (w->top) + XINT (w->height) - 1)
- {
- previous_y = x_mouse_y;
- line = (x_mouse_y + 1) * f->output_data.x->line_height
- + f->output_data.x->internal_border_width;
- XDrawLine (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
- line_gc, left, line, right, line);
- }
- XFlush (FRAME_X_DISPLAY (f));
- UNBLOCK_INPUT;
-
- do
- {
- obj = read_char (-1, 0, 0, Qnil, 0);
- if (!CONSP (obj)
- || (! EQ (Fcar (Fcdr (Fcdr (obj))),
- Qvertical_scroll_bar))
- || x_mouse_grabbed)
- {
- BLOCK_INPUT;
- XDrawLine (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
- erase_gc, left, line, right, line);
- unread_command_event = obj;
-#if 0
- XFreeGC (FRAME_X_DISPLAY (f), line_gc);
- XFreeGC (FRAME_X_DISPLAY (f), erase_gc);
-#endif
- UNBLOCK_INPUT;
- return Qnil;
- }
- }
- while (x_mouse_y == previous_y);
-
- BLOCK_INPUT;
- XDrawLine (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
- erase_gc, left, line, right, line);
- UNBLOCK_INPUT;
- }
-}
-#endif
-\f
-#if 0
-/* These keep track of the rectangle following the pointer. */
-int mouse_track_top, mouse_track_left, mouse_track_width;
-
-/* Offset in buffer of character under the pointer, or 0. */
-int mouse_buffer_offset;
-
-DEFUN ("x-track-pointer", Fx_track_pointer, Sx_track_pointer, 0, 0, 0,
- "Track the pointer.")
- ()
-{
- static Cursor current_pointer_shape;
- FRAME_PTR f = x_mouse_frame;
-
- BLOCK_INPUT;
- if (EQ (Vmouse_frame_part, Qtext_part)
- && (current_pointer_shape != f->output_data.x->nontext_cursor))
- {
- unsigned char c;
- struct buffer *buf;
-
- current_pointer_shape = f->output_data.x->nontext_cursor;
- XDefineCursor (FRAME_X_DISPLAY (f),
- FRAME_X_WINDOW (f),
- current_pointer_shape);
-
- buf = XBUFFER (XWINDOW (Vmouse_window)->buffer);
- c = *(BUF_CHAR_ADDRESS (buf, mouse_buffer_offset));
- }
- else if (EQ (Vmouse_frame_part, Qmodeline_part)
- && (current_pointer_shape != f->output_data.x->modeline_cursor))
- {
- current_pointer_shape = f->output_data.x->modeline_cursor;
- XDefineCursor (FRAME_X_DISPLAY (f),
- FRAME_X_WINDOW (f),
- current_pointer_shape);
- }
-
- XFlush (FRAME_X_DISPLAY (f));
- UNBLOCK_INPUT;
-}
-#endif
-
-#if 0
-DEFUN ("x-track-pointer", Fx_track_pointer, Sx_track_pointer, 1, 1, "e",
- "Draw rectangle around character under mouse pointer, if there is one.")
- (event)
- Lisp_Object event;
-{
- struct window *w = XWINDOW (Vmouse_window);
- struct frame *f = XFRAME (WINDOW_FRAME (w));
- struct buffer *b = XBUFFER (w->buffer);
- Lisp_Object obj;
-
- if (! EQ (Vmouse_window, selected_window))
- return Qnil;
-
- if (EQ (event, Qnil))
- {
- int x, y;
-
- x_read_mouse_position (selected_frame, &x, &y);
- }
-
- BLOCK_INPUT;
- mouse_track_width = 0;
- mouse_track_left = mouse_track_top = -1;
-
- do
- {
- if ((x_mouse_x != mouse_track_left
- && (x_mouse_x < mouse_track_left
- || x_mouse_x > (mouse_track_left + mouse_track_width)))
- || x_mouse_y != mouse_track_top)
- {
- int hp = 0; /* Horizontal position */
- int len = FRAME_CURRENT_GLYPHS (f)->used[x_mouse_y];
- int p = FRAME_CURRENT_GLYPHS (f)->bufp[x_mouse_y];
- int tab_width = XINT (b->tab_width);
- int ctl_arrow_p = !NILP (b->ctl_arrow);
- unsigned char c;
- int mode_line_vpos = XFASTINT (w->height) + XFASTINT (w->top) - 1;
- int in_mode_line = 0;
-
- if (! FRAME_CURRENT_GLYPHS (f)->enable[x_mouse_y])
- break;
-
- /* Erase previous rectangle. */
- if (mouse_track_width)
- {
- x_rectangle (f, f->output_data.x->reverse_gc,
- mouse_track_left, mouse_track_top,
- mouse_track_width, 1);
-
- if ((mouse_track_left == f->phys_cursor_x
- || mouse_track_left == f->phys_cursor_x - 1)
- && mouse_track_top == f->phys_cursor_y)
- {
- x_display_cursor (f, 1);
- }
- }
-
- mouse_track_left = x_mouse_x;
- mouse_track_top = x_mouse_y;
- mouse_track_width = 0;
-
- if (mouse_track_left > len) /* Past the end of line. */
- goto draw_or_not;
-
- if (mouse_track_top == mode_line_vpos)
- {
- in_mode_line = 1;
- goto draw_or_not;
- }
-
- if (tab_width <= 0 || tab_width > 20) tab_width = 8;
- do
- {
- c = FETCH_BYTE (p);
- if (len == f->width && hp == len - 1 && c != '\n')
- goto draw_or_not;
-
- switch (c)
- {
- case '\t':
- mouse_track_width = tab_width - (hp % tab_width);
- p++;
- hp += mouse_track_width;
- if (hp > x_mouse_x)
- {
- mouse_track_left = hp - mouse_track_width;
- goto draw_or_not;
- }
- continue;
-
- case '\n':
- mouse_track_width = -1;
- goto draw_or_not;
-
- default:
- if (ctl_arrow_p && (c < 040 || c == 0177))
- {
- if (p > ZV)
- goto draw_or_not;
-
- mouse_track_width = 2;
- p++;
- hp +=2;
- if (hp > x_mouse_x)
- {
- mouse_track_left = hp - mouse_track_width;
- goto draw_or_not;
- }
- }
- else
- {
- mouse_track_width = 1;
- p++;
- hp++;
- }
- continue;
- }
- }
- while (hp <= x_mouse_x);
-
- draw_or_not:
- if (mouse_track_width) /* Over text; use text pointer shape. */
- {
- XDefineCursor (FRAME_X_DISPLAY (f),
- FRAME_X_WINDOW (f),
- f->output_data.x->text_cursor);
- x_rectangle (f, f->output_data.x->cursor_gc,
- mouse_track_left, mouse_track_top,
- mouse_track_width, 1);
- }
- else if (in_mode_line)
- XDefineCursor (FRAME_X_DISPLAY (f),
- FRAME_X_WINDOW (f),
- f->output_data.x->modeline_cursor);
- else
- XDefineCursor (FRAME_X_DISPLAY (f),
- FRAME_X_WINDOW (f),
- f->output_data.x->nontext_cursor);
- }
-
- XFlush (FRAME_X_DISPLAY (f));
- UNBLOCK_INPUT;
-
- obj = read_char (-1, 0, 0, Qnil, 0);
- BLOCK_INPUT;
- }
- while (CONSP (obj) /* Mouse event */
- && EQ (Fcar (Fcdr (Fcdr (obj))), Qnil) /* Not scroll bar */
- && EQ (Vmouse_depressed, Qnil) /* Only motion events */
- && EQ (Vmouse_window, selected_window) /* In this window */
- && x_mouse_frame);
-
- unread_command_event = obj;
-
- if (mouse_track_width)
- {
- x_rectangle (f, f->output_data.x->reverse_gc,
- mouse_track_left, mouse_track_top,
- mouse_track_width, 1);
- mouse_track_width = 0;
- if ((mouse_track_left == f->phys_cursor_x
- || mouse_track_left - 1 == f->phys_cursor_x)
- && mouse_track_top == f->phys_cursor_y)
- {
- x_display_cursor (f, 1);
- }
- }
- XDefineCursor (FRAME_X_DISPLAY (f),
- FRAME_X_WINDOW (f),
- f->output_data.x->nontext_cursor);
- XFlush (FRAME_X_DISPLAY (f));
- UNBLOCK_INPUT;
-
- return Qnil;
-}
-#endif
-\f
-#if 0
-#include "glyphs.h"
-
-/* Draw a pixmap specified by IMAGE_DATA of dimensions WIDTH and HEIGHT
- on the frame F at position X, Y. */
-
-x_draw_pixmap (f, x, y, image_data, width, height)
- struct frame *f;
- int x, y, width, height;
- char *image_data;
-{
- Pixmap image;
-
- image = XCreateBitmapFromData (FRAME_X_DISPLAY (f),
- FRAME_X_WINDOW (f), image_data,
- width, height);
- XCopyPlane (FRAME_X_DISPLAY (f), image, FRAME_X_WINDOW (f),
- f->output_data.x->normal_gc, 0, 0, width, height, x, y);
-}
-#endif
-\f
-#if 0 /* I'm told these functions are superfluous
- given the ability to bind function keys. */
-
-#ifdef HAVE_X11
-DEFUN ("x-rebind-key", Fx_rebind_key, Sx_rebind_key, 3, 3, 0,
-"Rebind X keysym KEYSYM, with MODIFIERS, to generate NEWSTRING.\n\
-KEYSYM is a string which conforms to the X keysym definitions found\n\
-in X11/keysymdef.h, sans the initial XK_. MODIFIERS is nil or a\n\
-list of strings specifying modifier keys such as Control_L, which must\n\
-also be depressed for NEWSTRING to appear.")
- (x_keysym, modifiers, newstring)
- register Lisp_Object x_keysym;
- register Lisp_Object modifiers;
- register Lisp_Object newstring;
-{
- char *rawstring;
- register KeySym keysym;
- KeySym modifier_list[16];
-
- check_x ();
- CHECK_STRING (x_keysym, 1);
- CHECK_STRING (newstring, 3);
-
- keysym = XStringToKeysym ((char *) XSTRING (x_keysym)->data);
- if (keysym == NoSymbol)
- error ("Keysym does not exist");
-
- if (NILP (modifiers))
- XRebindKeysym (x_current_display, keysym, modifier_list, 0,
- XSTRING (newstring)->data,
- STRING_BYTES (XSTRING (newstring)));
- else
- {
- register Lisp_Object rest, mod;
- register int i = 0;
-
- for (rest = modifiers; !NILP (rest); rest = Fcdr (rest))
- {
- if (i == 16)
- error ("Can't have more than 16 modifiers");
-
- mod = Fcar (rest);
- CHECK_STRING (mod, 3);
- modifier_list[i] = XStringToKeysym ((char *) XSTRING (mod)->data);
-#ifndef HAVE_X11R5
- if (modifier_list[i] == NoSymbol
- || !(IsModifierKey (modifier_list[i])
- || ((unsigned)(modifier_list[i]) == XK_Mode_switch)
- || ((unsigned)(modifier_list[i]) == XK_Num_Lock)))
-#else
- if (modifier_list[i] == NoSymbol
- || !IsModifierKey (modifier_list[i]))
-#endif
- error ("Element is not a modifier keysym");
- i++;
- }
-
- XRebindKeysym (x_current_display, keysym, modifier_list, i,
- XSTRING (newstring)->data,
- STRING_BYTES (XSTRING (newstring)));
- }
-
- return Qnil;
-}
-
-DEFUN ("x-rebind-keys", Fx_rebind_keys, Sx_rebind_keys, 2, 2, 0,
- "Rebind KEYCODE to list of strings STRINGS.\n\
-STRINGS should be a list of 16 elements, one for each shift combination.\n\
-nil as element means don't change.\n\
-See the documentation of `x-rebind-key' for more information.")
- (keycode, strings)
- register Lisp_Object keycode;
- register Lisp_Object strings;
-{
- register Lisp_Object item;
- register unsigned char *rawstring;
- KeySym rawkey, modifier[1];
- int strsize;
- register unsigned i;
-
- check_x ();
- CHECK_NUMBER (keycode, 1);
- CHECK_CONS (strings, 2);
- rawkey = (KeySym) ((unsigned) (XINT (keycode))) & 255;
- for (i = 0; i <= 15; strings = Fcdr (strings), i++)
- {
- item = Fcar (strings);
- if (!NILP (item))
- {
- CHECK_STRING (item, 2);
- strsize = STRING_BYTES (XSTRING (item));
- rawstring = (unsigned char *) xmalloc (strsize);
- bcopy (XSTRING (item)->data, rawstring, strsize);
- modifier[1] = 1 << i;
- XRebindKeysym (x_current_display, rawkey, modifier, 1,
- rawstring, strsize);
- }
- }
- return Qnil;
-}
-#endif /* HAVE_X11 */
-#endif /* 0 */
-\f
-#ifndef HAVE_XSCREENNUMBEROFSCREEN
-int
-XScreenNumberOfScreen (scr)
- register Screen *scr;
-{
- register Display *dpy;
- register Screen *dpyscr;
- register int i;
-
- dpy = scr->display;
- dpyscr = dpy->screens;
-
- for (i = 0; i < dpy->nscreens; i++, dpyscr++)
- if (scr == dpyscr)
- return i;
-
- return -1;
-}
-#endif /* not HAVE_XSCREENNUMBEROFSCREEN */
-
-Visual *
-select_visual (dpy, screen, depth)
- Display *dpy;
- Screen *screen;
- unsigned int *depth;
-{
- Visual *v;
- XVisualInfo *vinfo, vinfo_template;
- int n_visuals;
-
- v = DefaultVisualOfScreen (screen);
-
-#ifdef HAVE_X11R4
- vinfo_template.visualid = XVisualIDFromVisual (v);
-#else
- vinfo_template.visualid = v->visualid;
-#endif
-
- vinfo_template.screen = XScreenNumberOfScreen (screen);
-
- vinfo = XGetVisualInfo (dpy,
- VisualIDMask | VisualScreenMask, &vinfo_template,
- &n_visuals);
- if (n_visuals != 1)
- fatal ("Can't get proper X visual info");
-
- if ((1 << vinfo->depth) == vinfo->colormap_size)
- *depth = vinfo->depth;
- else
- {
- int i = 0;
- int n = vinfo->colormap_size - 1;
- while (n)
- {
- n = n >> 1;
- i++;
- }
- *depth = i;
- }
-
- XFree ((char *) vinfo);
- return v;
-}
-
-/* Return the X display structure for the display named NAME.
- Open a new connection if necessary. */
-
-struct x_display_info *
-x_display_info_for_name (name)
- Lisp_Object name;
-{
- Lisp_Object names;
- struct x_display_info *dpyinfo;
-
- CHECK_STRING (name, 0);
-
- if (! EQ (Vwindow_system, intern ("x")))
- error ("Not using X Windows");
-
- for (dpyinfo = x_display_list, names = x_display_name_list;
- dpyinfo;
- dpyinfo = dpyinfo->next, names = XCDR (names))
- {
- Lisp_Object tem;
- tem = Fstring_equal (XCAR (XCAR (names)), name);
- if (!NILP (tem))
- return dpyinfo;
- }
-
- /* Use this general default value to start with. */
- Vx_resource_name = Vinvocation_name;
-
- validate_x_resource_name ();
-
- dpyinfo = x_term_init (name, (unsigned char *)0,
- (char *) XSTRING (Vx_resource_name)->data);
-
- if (dpyinfo == 0)
- error ("Cannot connect to X server %s", XSTRING (name)->data);
-
- x_in_use = 1;
- XSETFASTINT (Vwindow_system_version, 11);
-
- return dpyinfo;
-}
-
-DEFUN ("x-open-connection", Fx_open_connection, Sx_open_connection,
- 1, 3, 0, "Open a connection to an X server.\n\
-DISPLAY is the name of the display to connect to.\n\
-Optional second arg XRM-STRING is a string of resources in xrdb format.\n\
-If the optional third arg MUST-SUCCEED is non-nil,\n\
-terminate Emacs if we can't open the connection.")
- (display, xrm_string, must_succeed)
- Lisp_Object display, xrm_string, must_succeed;
-{
- unsigned char *xrm_option;
- struct x_display_info *dpyinfo;
-
- CHECK_STRING (display, 0);
- if (! NILP (xrm_string))
- CHECK_STRING (xrm_string, 1);
-
- if (! EQ (Vwindow_system, intern ("x")))
- error ("Not using X Windows");
-
- if (! NILP (xrm_string))
- xrm_option = (unsigned char *) XSTRING (xrm_string)->data;
- else
- xrm_option = (unsigned char *) 0;
-
- validate_x_resource_name ();