return xfocus;
}
+
+/* In certain situations, when the window manager follows a
+ click-to-focus policy, there seems to be no way around calling
+ XSetInputFocus to give another frame the input focus .
+
+ In an ideal world, XSetInputFocus should generally be avoided so
+ that applications don't interfere with the window manager's focus
+ policy. But I think it's okay to use when it's clearly done
+ following a user-command. */
+
+DEFUN ("x-focus-frame", Fx_focus_frame, Sx_focus_frame, 1, 1, 0,
+ "Set the input focus to FRAME.\n\
+FRAME nil means use the selected frame.")
+ (frame)
+ Lisp_Object frame;
+{
+ struct frame *f = check_x_frame (frame);
+ Display *dpy = FRAME_X_DISPLAY (f);
+ int count;
+
+ BLOCK_INPUT;
+ count = x_catch_errors (dpy);
+ XSetInputFocus (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
+ RevertToParent, CurrentTime);
+ x_uncatch_errors (dpy, count);
+ UNBLOCK_INPUT;
+
+ return Qnil;
+}
+
\f
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.")
{
return FRAME_X_DISPLAY_INFO (f)->n_planes;
}
-\f
-#if 0 /* These no longer seem like the right way to do things. */
-
-/* Draw a rectangle on the frame with left top corner including
- the character specified by LEFT_CHAR and TOP_CHAR. The rectangle is
- CHARS by LINES wide and long and is the color of the cursor. */
-
-void
-x_rectangle (f, gc, left_char, top_char, chars, lines)
- register struct frame *f;
- GC gc;
- register int top_char, left_char, chars, lines;
-{
- int width;
- int height;
- int left = (left_char * FONT_WIDTH (f->output_data.x->font)
- + f->output_data.x->internal_border_width);
- int top = (top_char * f->output_data.x->line_height
- + f->output_data.x->internal_border_width);
-
- if (chars < 0)
- width = FONT_WIDTH (f->output_data.x->font) / 2;
- else
- width = FONT_WIDTH (f->output_data.x->font) * chars;
- if (lines < 0)
- height = f->output_data.x->line_height / 2;
- else
- height = f->output_data.x->line_height * lines;
-
- XDrawRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
- gc, left, top, width, height);
-}
-
-DEFUN ("x-draw-rectangle", Fx_draw_rectangle, Sx_draw_rectangle, 5, 5, 0,
- "Draw a rectangle on FRAME between coordinates specified by\n\
-numbers X0, Y0, X1, Y1 in the cursor pixel.")
- (frame, X0, Y0, X1, Y1)
- register Lisp_Object frame, X0, X1, Y0, Y1;
-{
- register int x0, y0, x1, y1, top, left, n_chars, n_lines;
-
- CHECK_LIVE_FRAME (frame, 0);
- CHECK_NUMBER (X0, 0);
- CHECK_NUMBER (Y0, 1);
- CHECK_NUMBER (X1, 2);
- CHECK_NUMBER (Y1, 3);
-
- x0 = XINT (X0);
- x1 = XINT (X1);
- y0 = XINT (Y0);
- y1 = XINT (Y1);
-
- if (y1 > y0)
- {
- top = y0;
- n_lines = y1 - y0 + 1;
- }
- else
- {
- top = y1;
- n_lines = y0 - y1 + 1;
- }
-
- if (x1 > x0)
- {
- left = x0;
- n_chars = x1 - x0 + 1;
- }
- else
- {
- left = x1;
- n_chars = x0 - x1 + 1;
- }
-
- BLOCK_INPUT;
- x_rectangle (XFRAME (frame), XFRAME (frame)->output_data.x->cursor_gc,
- left, top, n_chars, n_lines);
- UNBLOCK_INPUT;
-
- return Qt;
-}
-
-DEFUN ("x-erase-rectangle", Fx_erase_rectangle, Sx_erase_rectangle, 5, 5, 0,
- "Draw a rectangle drawn on FRAME between coordinates\n\
-X0, Y0, X1, Y1 in the regular background-pixel.")
- (frame, X0, Y0, X1, Y1)
- register Lisp_Object frame, X0, Y0, X1, Y1;
-{
- register int x0, y0, x1, y1, top, left, n_chars, n_lines;
-
- CHECK_LIVE_FRAME (frame, 0);
- CHECK_NUMBER (X0, 0);
- CHECK_NUMBER (Y0, 1);
- CHECK_NUMBER (X1, 2);
- CHECK_NUMBER (Y1, 3);
-
- x0 = XINT (X0);
- x1 = XINT (X1);
- y0 = XINT (Y0);
- y1 = XINT (Y1);
-
- if (y1 > y0)
- {
- top = y0;
- n_lines = y1 - y0 + 1;
- }
- else
- {
- top = y1;
- n_lines = y0 - y1 + 1;
- }
-
- if (x1 > x0)
- {
- left = x0;
- n_chars = x1 - x0 + 1;
- }
- else
- {
- left = x1;
- n_chars = x0 - x1 + 1;
- }
-
- BLOCK_INPUT;
- x_rectangle (XFRAME (frame), XFRAME (frame)->output_data.x->reverse_gc,
- left, top, n_chars, n_lines);
- UNBLOCK_INPUT;
-
- return Qt;
-}
-
-/* Draw lines around the text region beginning at the character position
- TOP_X, TOP_Y and ending at BOTTOM_X and BOTTOM_Y. GC specifies the
- pixel and line characteristics. */
-
-#define line_len(line) (FRAME_CURRENT_GLYPHS (f)->used[(line)])
-
-static void
-outline_region (f, gc, top_x, top_y, bottom_x, bottom_y)
- register struct frame *f;
- GC gc;
- int top_x, top_y, bottom_x, bottom_y;
-{
- register int ibw = f->output_data.x->internal_border_width;
- register int font_w = FONT_WIDTH (f->output_data.x->font);
- register int font_h = f->output_data.x->line_height;
- int y = top_y;
- int x = line_len (y);
- XPoint *pixel_points
- = (XPoint *) alloca (((bottom_y - top_y + 2) * 4) * sizeof (XPoint));
- register XPoint *this_point = pixel_points;
-
- /* Do the horizontal top line/lines */
- if (top_x == 0)
- {
- this_point->x = ibw;
- this_point->y = ibw + (font_h * top_y);
- this_point++;
- if (x == 0)
- this_point->x = ibw + (font_w / 2); /* Half-size for newline chars. */
- else
- this_point->x = ibw + (font_w * x);
- this_point->y = (this_point - 1)->y;
- }
- else
- {
- this_point->x = ibw;
- this_point->y = ibw + (font_h * (top_y + 1));
- this_point++;
- this_point->x = ibw + (font_w * top_x);
- this_point->y = (this_point - 1)->y;
- this_point++;
- this_point->x = (this_point - 1)->x;
- this_point->y = ibw + (font_h * top_y);
- this_point++;
- this_point->x = ibw + (font_w * x);
- this_point->y = (this_point - 1)->y;
- }
-
- /* Now do the right side. */
- while (y < bottom_y)
- { /* Right vertical edge */
- this_point++;
- this_point->x = (this_point - 1)->x;
- this_point->y = ibw + (font_h * (y + 1));
- this_point++;
-
- y++; /* Horizontal connection to next line */
- x = line_len (y);
- if (x == 0)
- this_point->x = ibw + (font_w / 2);
- else
- this_point->x = ibw + (font_w * x);
-
- this_point->y = (this_point - 1)->y;
- }
-
- /* Now do the bottom and connect to the top left point. */
- this_point->x = ibw + (font_w * (bottom_x + 1));
-
- this_point++;
- this_point->x = (this_point - 1)->x;
- this_point->y = ibw + (font_h * (bottom_y + 1));
- this_point++;
- this_point->x = ibw;
- this_point->y = (this_point - 1)->y;
- this_point++;
- this_point->x = pixel_points->x;
- this_point->y = pixel_points->y;
-
- XDrawLines (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
- gc, pixel_points,
- (this_point - pixel_points + 1), CoordModeOrigin);
-}
-
-DEFUN ("x-contour-region", Fx_contour_region, Sx_contour_region, 1, 1, 0,
- "Highlight the region between point and the character under the mouse\n\
-selected frame.")
- (event)
- register Lisp_Object event;
-{
- register int x0, y0, x1, y1;
- register struct frame *f = selected_frame;
- struct window *w = XWINDOW (FRAME_SELECTED_WINDOW (f));
- register int p1, p2;
-
- CHECK_CONS (event, 0);
-
- BLOCK_INPUT;
- x0 = XINT (Fcar (Fcar (event)));
- y0 = XINT (Fcar (Fcdr (Fcar (event))));
-
- /* If the mouse is past the end of the line, don't that area. */
- /* ReWrite this... */
-
- /* Where the cursor is. */
- x1 = WINDOW_TO_FRAME_PIXEL_X (w, w->cursor.x);
- y1 = WINDOW_TO_FRAME_PIXEL_Y (w, w->cursor.y);
-
- if (y1 > y0) /* point below mouse */
- outline_region (f, f->output_data.x->cursor_gc,
- x0, y0, x1, y1);
- else if (y1 < y0) /* point above mouse */
- outline_region (f, f->output_data.x->cursor_gc,
- x1, y1, x0, y0);
- else /* same line: draw horizontal rectangle */
- {
- if (x1 > x0)
- x_rectangle (f, f->output_data.x->cursor_gc,
- x0, y0, (x1 - x0 + 1), 1);
- else if (x1 < x0)
- x_rectangle (f, f->output_data.x->cursor_gc,
- x1, y1, (x0 - x1 + 1), 1);
- }
-
- XFlush (FRAME_X_DISPLAY (f));
- UNBLOCK_INPUT;
-
- return Qnil;
-}
-
-DEFUN ("x-uncontour-region", Fx_uncontour_region, Sx_uncontour_region, 1, 1, 0,
- "Erase any highlighting of the region between point and the character\n\
-at X, Y on the selected frame.")
- (event)
- register Lisp_Object event;
-{
- register int x0, y0, x1, y1;
- register struct frame *f = selected_frame;
- struct window *w = XWINDOW (FRAME_SELECTED_WINDOW (f));
-
- BLOCK_INPUT;
- x0 = XINT (Fcar (Fcar (event)));
- y0 = XINT (Fcar (Fcdr (Fcar (event))));
- x1 = WINDOW_TO_FRAME_PIXEL_X (w, w->cursor.x);
- y1 = WINDOW_TO_FRAME_PIXEL_Y (w, w->cursor.y);
-
- if (y1 > y0) /* point below mouse */
- outline_region (f, f->output_data.x->reverse_gc,
- x0, y0, x1, y1);
- else if (y1 < y0) /* point above mouse */
- outline_region (f, f->output_data.x->reverse_gc,
- x1, y1, x0, y0);
- else /* same line: draw horizontal rectangle */
- {
- if (x1 > x0)
- x_rectangle (f, f->output_data.x->reverse_gc,
- x0, y0, (x1 - x0 + 1), 1);
- else if (x1 < x0)
- x_rectangle (f, f->output_data.x->reverse_gc,
- x1, y1, (x0 - x1 + 1), 1);
- }
- UNBLOCK_INPUT;
-
- return Qnil;
-}
-
-#if 0
-int contour_begin_x, contour_begin_y;
-int contour_end_x, contour_end_y;
-int contour_npoints;
-
-/* Clip the top part of the contour lines down (and including) line Y_POS.
- If X_POS is in the middle (rather than at the end) of the line, drop
- down a line at that character. */
-
-static void
-clip_contour_top (y_pos, x_pos)
-{
- register XPoint *begin = contour_lines[y_pos].top_left;
- register XPoint *end;
- register int npoints;
- register struct display_line *line = selected_frame->phys_lines[y_pos + 1];
-
- if (x_pos >= line->len - 1) /* Draw one, straight horizontal line. */
- {
- end = contour_lines[y_pos].top_right;
- npoints = (end - begin + 1);
- XDrawLines (x_current_display, contour_window,
- contour_erase_gc, begin_erase, npoints, CoordModeOrigin);
-
- bcopy (end, begin + 1, contour_last_point - end + 1);
- contour_last_point -= (npoints - 2);
- XDrawLines (x_current_display, contour_window,
- contour_erase_gc, begin, 2, CoordModeOrigin);
- XFlush (x_current_display);
-
- /* Now, update contour_lines structure. */
- }
- /* ______. */
- else /* |________*/
- {
- register XPoint *p = begin + 1;
- end = contour_lines[y_pos].bottom_right;
- npoints = (end - begin + 1);
- XDrawLines (x_current_display, contour_window,
- contour_erase_gc, begin_erase, npoints, CoordModeOrigin);
-
- 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
/************************************************************************
defsubr (&Sx_delete_window_property);
defsubr (&Sx_window_property);
-#if 0
- defsubr (&Sx_draw_rectangle);
- defsubr (&Sx_erase_rectangle);
- defsubr (&Sx_contour_region);
- defsubr (&Sx_uncontour_region);
-#endif
defsubr (&Sxw_display_color_p);
defsubr (&Sx_display_grayscale_p);
defsubr (&Sxw_color_defined_p);
defsubr (&Sx_display_visual_class);
defsubr (&Sx_display_backing_store);
defsubr (&Sx_display_save_under);
-#if 0
- defsubr (&Sx_rebind_key);
- defsubr (&Sx_rebind_keys);
- defsubr (&Sx_track_pointer);
- defsubr (&Sx_grab_pointer);
- defsubr (&Sx_ungrab_pointer);
-#endif
defsubr (&Sx_parse_geometry);
defsubr (&Sx_create_frame);
-#if 0
- defsubr (&Sx_horizontal_line);
-#endif
defsubr (&Sx_open_connection);
defsubr (&Sx_close_connection);
defsubr (&Sx_display_list);
defsubr (&Sx_synchronize);
+ defsubr (&Sx_focus_frame);
/* Setting callback functions for fontset handler. */
get_font_info_func = x_get_font_info;