Mercurial > emacs
comparison src/xfns.c @ 28044:88db4c84b6fd
Remove a buch of really old code in #if 0.
(Fx_focus_frame): New function.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Tue, 07 Mar 2000 23:29:38 +0000 |
parents | 5e3c139838a6 |
children | 79a67f9da183 |
comparison
equal
deleted
inserted
replaced
28043:6070092c3b29 | 28044:88db4c84b6fd |
---|---|
4204 | 4204 |
4205 XSETFRAME (xfocus, dpyinfo->x_focus_frame); | 4205 XSETFRAME (xfocus, dpyinfo->x_focus_frame); |
4206 return xfocus; | 4206 return xfocus; |
4207 } | 4207 } |
4208 | 4208 |
4209 | |
4210 /* In certain situations, when the window manager follows a | |
4211 click-to-focus policy, there seems to be no way around calling | |
4212 XSetInputFocus to give another frame the input focus . | |
4213 | |
4214 In an ideal world, XSetInputFocus should generally be avoided so | |
4215 that applications don't interfere with the window manager's focus | |
4216 policy. But I think it's okay to use when it's clearly done | |
4217 following a user-command. */ | |
4218 | |
4219 DEFUN ("x-focus-frame", Fx_focus_frame, Sx_focus_frame, 1, 1, 0, | |
4220 "Set the input focus to FRAME.\n\ | |
4221 FRAME nil means use the selected frame.") | |
4222 (frame) | |
4223 Lisp_Object frame; | |
4224 { | |
4225 struct frame *f = check_x_frame (frame); | |
4226 Display *dpy = FRAME_X_DISPLAY (f); | |
4227 int count; | |
4228 | |
4229 BLOCK_INPUT; | |
4230 count = x_catch_errors (dpy); | |
4231 XSetInputFocus (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), | |
4232 RevertToParent, CurrentTime); | |
4233 x_uncatch_errors (dpy, count); | |
4234 UNBLOCK_INPUT; | |
4235 | |
4236 return Qnil; | |
4237 } | |
4238 | |
4209 | 4239 |
4210 DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, 1, 2, 0, | 4240 DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, 1, 2, 0, |
4211 "Internal function called by `color-defined-p', which see.") | 4241 "Internal function called by `color-defined-p', which see.") |
4212 (color, frame) | 4242 (color, frame) |
4213 Lisp_Object color, frame; | 4243 Lisp_Object color, frame; |
4547 x_screen_planes (f) | 4577 x_screen_planes (f) |
4548 register struct frame *f; | 4578 register struct frame *f; |
4549 { | 4579 { |
4550 return FRAME_X_DISPLAY_INFO (f)->n_planes; | 4580 return FRAME_X_DISPLAY_INFO (f)->n_planes; |
4551 } | 4581 } |
4552 | 4582 |
4553 #if 0 /* These no longer seem like the right way to do things. */ | |
4554 | |
4555 /* Draw a rectangle on the frame with left top corner including | |
4556 the character specified by LEFT_CHAR and TOP_CHAR. The rectangle is | |
4557 CHARS by LINES wide and long and is the color of the cursor. */ | |
4558 | |
4559 void | |
4560 x_rectangle (f, gc, left_char, top_char, chars, lines) | |
4561 register struct frame *f; | |
4562 GC gc; | |
4563 register int top_char, left_char, chars, lines; | |
4564 { | |
4565 int width; | |
4566 int height; | |
4567 int left = (left_char * FONT_WIDTH (f->output_data.x->font) | |
4568 + f->output_data.x->internal_border_width); | |
4569 int top = (top_char * f->output_data.x->line_height | |
4570 + f->output_data.x->internal_border_width); | |
4571 | |
4572 if (chars < 0) | |
4573 width = FONT_WIDTH (f->output_data.x->font) / 2; | |
4574 else | |
4575 width = FONT_WIDTH (f->output_data.x->font) * chars; | |
4576 if (lines < 0) | |
4577 height = f->output_data.x->line_height / 2; | |
4578 else | |
4579 height = f->output_data.x->line_height * lines; | |
4580 | |
4581 XDrawRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), | |
4582 gc, left, top, width, height); | |
4583 } | |
4584 | |
4585 DEFUN ("x-draw-rectangle", Fx_draw_rectangle, Sx_draw_rectangle, 5, 5, 0, | |
4586 "Draw a rectangle on FRAME between coordinates specified by\n\ | |
4587 numbers X0, Y0, X1, Y1 in the cursor pixel.") | |
4588 (frame, X0, Y0, X1, Y1) | |
4589 register Lisp_Object frame, X0, X1, Y0, Y1; | |
4590 { | |
4591 register int x0, y0, x1, y1, top, left, n_chars, n_lines; | |
4592 | |
4593 CHECK_LIVE_FRAME (frame, 0); | |
4594 CHECK_NUMBER (X0, 0); | |
4595 CHECK_NUMBER (Y0, 1); | |
4596 CHECK_NUMBER (X1, 2); | |
4597 CHECK_NUMBER (Y1, 3); | |
4598 | |
4599 x0 = XINT (X0); | |
4600 x1 = XINT (X1); | |
4601 y0 = XINT (Y0); | |
4602 y1 = XINT (Y1); | |
4603 | |
4604 if (y1 > y0) | |
4605 { | |
4606 top = y0; | |
4607 n_lines = y1 - y0 + 1; | |
4608 } | |
4609 else | |
4610 { | |
4611 top = y1; | |
4612 n_lines = y0 - y1 + 1; | |
4613 } | |
4614 | |
4615 if (x1 > x0) | |
4616 { | |
4617 left = x0; | |
4618 n_chars = x1 - x0 + 1; | |
4619 } | |
4620 else | |
4621 { | |
4622 left = x1; | |
4623 n_chars = x0 - x1 + 1; | |
4624 } | |
4625 | |
4626 BLOCK_INPUT; | |
4627 x_rectangle (XFRAME (frame), XFRAME (frame)->output_data.x->cursor_gc, | |
4628 left, top, n_chars, n_lines); | |
4629 UNBLOCK_INPUT; | |
4630 | |
4631 return Qt; | |
4632 } | |
4633 | |
4634 DEFUN ("x-erase-rectangle", Fx_erase_rectangle, Sx_erase_rectangle, 5, 5, 0, | |
4635 "Draw a rectangle drawn on FRAME between coordinates\n\ | |
4636 X0, Y0, X1, Y1 in the regular background-pixel.") | |
4637 (frame, X0, Y0, X1, Y1) | |
4638 register Lisp_Object frame, X0, Y0, X1, Y1; | |
4639 { | |
4640 register int x0, y0, x1, y1, top, left, n_chars, n_lines; | |
4641 | |
4642 CHECK_LIVE_FRAME (frame, 0); | |
4643 CHECK_NUMBER (X0, 0); | |
4644 CHECK_NUMBER (Y0, 1); | |
4645 CHECK_NUMBER (X1, 2); | |
4646 CHECK_NUMBER (Y1, 3); | |
4647 | |
4648 x0 = XINT (X0); | |
4649 x1 = XINT (X1); | |
4650 y0 = XINT (Y0); | |
4651 y1 = XINT (Y1); | |
4652 | |
4653 if (y1 > y0) | |
4654 { | |
4655 top = y0; | |
4656 n_lines = y1 - y0 + 1; | |
4657 } | |
4658 else | |
4659 { | |
4660 top = y1; | |
4661 n_lines = y0 - y1 + 1; | |
4662 } | |
4663 | |
4664 if (x1 > x0) | |
4665 { | |
4666 left = x0; | |
4667 n_chars = x1 - x0 + 1; | |
4668 } | |
4669 else | |
4670 { | |
4671 left = x1; | |
4672 n_chars = x0 - x1 + 1; | |
4673 } | |
4674 | |
4675 BLOCK_INPUT; | |
4676 x_rectangle (XFRAME (frame), XFRAME (frame)->output_data.x->reverse_gc, | |
4677 left, top, n_chars, n_lines); | |
4678 UNBLOCK_INPUT; | |
4679 | |
4680 return Qt; | |
4681 } | |
4682 | |
4683 /* Draw lines around the text region beginning at the character position | |
4684 TOP_X, TOP_Y and ending at BOTTOM_X and BOTTOM_Y. GC specifies the | |
4685 pixel and line characteristics. */ | |
4686 | |
4687 #define line_len(line) (FRAME_CURRENT_GLYPHS (f)->used[(line)]) | |
4688 | |
4689 static void | |
4690 outline_region (f, gc, top_x, top_y, bottom_x, bottom_y) | |
4691 register struct frame *f; | |
4692 GC gc; | |
4693 int top_x, top_y, bottom_x, bottom_y; | |
4694 { | |
4695 register int ibw = f->output_data.x->internal_border_width; | |
4696 register int font_w = FONT_WIDTH (f->output_data.x->font); | |
4697 register int font_h = f->output_data.x->line_height; | |
4698 int y = top_y; | |
4699 int x = line_len (y); | |
4700 XPoint *pixel_points | |
4701 = (XPoint *) alloca (((bottom_y - top_y + 2) * 4) * sizeof (XPoint)); | |
4702 register XPoint *this_point = pixel_points; | |
4703 | |
4704 /* Do the horizontal top line/lines */ | |
4705 if (top_x == 0) | |
4706 { | |
4707 this_point->x = ibw; | |
4708 this_point->y = ibw + (font_h * top_y); | |
4709 this_point++; | |
4710 if (x == 0) | |
4711 this_point->x = ibw + (font_w / 2); /* Half-size for newline chars. */ | |
4712 else | |
4713 this_point->x = ibw + (font_w * x); | |
4714 this_point->y = (this_point - 1)->y; | |
4715 } | |
4716 else | |
4717 { | |
4718 this_point->x = ibw; | |
4719 this_point->y = ibw + (font_h * (top_y + 1)); | |
4720 this_point++; | |
4721 this_point->x = ibw + (font_w * top_x); | |
4722 this_point->y = (this_point - 1)->y; | |
4723 this_point++; | |
4724 this_point->x = (this_point - 1)->x; | |
4725 this_point->y = ibw + (font_h * top_y); | |
4726 this_point++; | |
4727 this_point->x = ibw + (font_w * x); | |
4728 this_point->y = (this_point - 1)->y; | |
4729 } | |
4730 | |
4731 /* Now do the right side. */ | |
4732 while (y < bottom_y) | |
4733 { /* Right vertical edge */ | |
4734 this_point++; | |
4735 this_point->x = (this_point - 1)->x; | |
4736 this_point->y = ibw + (font_h * (y + 1)); | |
4737 this_point++; | |
4738 | |
4739 y++; /* Horizontal connection to next line */ | |
4740 x = line_len (y); | |
4741 if (x == 0) | |
4742 this_point->x = ibw + (font_w / 2); | |
4743 else | |
4744 this_point->x = ibw + (font_w * x); | |
4745 | |
4746 this_point->y = (this_point - 1)->y; | |
4747 } | |
4748 | |
4749 /* Now do the bottom and connect to the top left point. */ | |
4750 this_point->x = ibw + (font_w * (bottom_x + 1)); | |
4751 | |
4752 this_point++; | |
4753 this_point->x = (this_point - 1)->x; | |
4754 this_point->y = ibw + (font_h * (bottom_y + 1)); | |
4755 this_point++; | |
4756 this_point->x = ibw; | |
4757 this_point->y = (this_point - 1)->y; | |
4758 this_point++; | |
4759 this_point->x = pixel_points->x; | |
4760 this_point->y = pixel_points->y; | |
4761 | |
4762 XDrawLines (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), | |
4763 gc, pixel_points, | |
4764 (this_point - pixel_points + 1), CoordModeOrigin); | |
4765 } | |
4766 | |
4767 DEFUN ("x-contour-region", Fx_contour_region, Sx_contour_region, 1, 1, 0, | |
4768 "Highlight the region between point and the character under the mouse\n\ | |
4769 selected frame.") | |
4770 (event) | |
4771 register Lisp_Object event; | |
4772 { | |
4773 register int x0, y0, x1, y1; | |
4774 register struct frame *f = selected_frame; | |
4775 struct window *w = XWINDOW (FRAME_SELECTED_WINDOW (f)); | |
4776 register int p1, p2; | |
4777 | |
4778 CHECK_CONS (event, 0); | |
4779 | |
4780 BLOCK_INPUT; | |
4781 x0 = XINT (Fcar (Fcar (event))); | |
4782 y0 = XINT (Fcar (Fcdr (Fcar (event)))); | |
4783 | |
4784 /* If the mouse is past the end of the line, don't that area. */ | |
4785 /* ReWrite this... */ | |
4786 | |
4787 /* Where the cursor is. */ | |
4788 x1 = WINDOW_TO_FRAME_PIXEL_X (w, w->cursor.x); | |
4789 y1 = WINDOW_TO_FRAME_PIXEL_Y (w, w->cursor.y); | |
4790 | |
4791 if (y1 > y0) /* point below mouse */ | |
4792 outline_region (f, f->output_data.x->cursor_gc, | |
4793 x0, y0, x1, y1); | |
4794 else if (y1 < y0) /* point above mouse */ | |
4795 outline_region (f, f->output_data.x->cursor_gc, | |
4796 x1, y1, x0, y0); | |
4797 else /* same line: draw horizontal rectangle */ | |
4798 { | |
4799 if (x1 > x0) | |
4800 x_rectangle (f, f->output_data.x->cursor_gc, | |
4801 x0, y0, (x1 - x0 + 1), 1); | |
4802 else if (x1 < x0) | |
4803 x_rectangle (f, f->output_data.x->cursor_gc, | |
4804 x1, y1, (x0 - x1 + 1), 1); | |
4805 } | |
4806 | |
4807 XFlush (FRAME_X_DISPLAY (f)); | |
4808 UNBLOCK_INPUT; | |
4809 | |
4810 return Qnil; | |
4811 } | |
4812 | |
4813 DEFUN ("x-uncontour-region", Fx_uncontour_region, Sx_uncontour_region, 1, 1, 0, | |
4814 "Erase any highlighting of the region between point and the character\n\ | |
4815 at X, Y on the selected frame.") | |
4816 (event) | |
4817 register Lisp_Object event; | |
4818 { | |
4819 register int x0, y0, x1, y1; | |
4820 register struct frame *f = selected_frame; | |
4821 struct window *w = XWINDOW (FRAME_SELECTED_WINDOW (f)); | |
4822 | |
4823 BLOCK_INPUT; | |
4824 x0 = XINT (Fcar (Fcar (event))); | |
4825 y0 = XINT (Fcar (Fcdr (Fcar (event)))); | |
4826 x1 = WINDOW_TO_FRAME_PIXEL_X (w, w->cursor.x); | |
4827 y1 = WINDOW_TO_FRAME_PIXEL_Y (w, w->cursor.y); | |
4828 | |
4829 if (y1 > y0) /* point below mouse */ | |
4830 outline_region (f, f->output_data.x->reverse_gc, | |
4831 x0, y0, x1, y1); | |
4832 else if (y1 < y0) /* point above mouse */ | |
4833 outline_region (f, f->output_data.x->reverse_gc, | |
4834 x1, y1, x0, y0); | |
4835 else /* same line: draw horizontal rectangle */ | |
4836 { | |
4837 if (x1 > x0) | |
4838 x_rectangle (f, f->output_data.x->reverse_gc, | |
4839 x0, y0, (x1 - x0 + 1), 1); | |
4840 else if (x1 < x0) | |
4841 x_rectangle (f, f->output_data.x->reverse_gc, | |
4842 x1, y1, (x0 - x1 + 1), 1); | |
4843 } | |
4844 UNBLOCK_INPUT; | |
4845 | |
4846 return Qnil; | |
4847 } | |
4848 | |
4849 #if 0 | |
4850 int contour_begin_x, contour_begin_y; | |
4851 int contour_end_x, contour_end_y; | |
4852 int contour_npoints; | |
4853 | |
4854 /* Clip the top part of the contour lines down (and including) line Y_POS. | |
4855 If X_POS is in the middle (rather than at the end) of the line, drop | |
4856 down a line at that character. */ | |
4857 | |
4858 static void | |
4859 clip_contour_top (y_pos, x_pos) | |
4860 { | |
4861 register XPoint *begin = contour_lines[y_pos].top_left; | |
4862 register XPoint *end; | |
4863 register int npoints; | |
4864 register struct display_line *line = selected_frame->phys_lines[y_pos + 1]; | |
4865 | |
4866 if (x_pos >= line->len - 1) /* Draw one, straight horizontal line. */ | |
4867 { | |
4868 end = contour_lines[y_pos].top_right; | |
4869 npoints = (end - begin + 1); | |
4870 XDrawLines (x_current_display, contour_window, | |
4871 contour_erase_gc, begin_erase, npoints, CoordModeOrigin); | |
4872 | |
4873 bcopy (end, begin + 1, contour_last_point - end + 1); | |
4874 contour_last_point -= (npoints - 2); | |
4875 XDrawLines (x_current_display, contour_window, | |
4876 contour_erase_gc, begin, 2, CoordModeOrigin); | |
4877 XFlush (x_current_display); | |
4878 | |
4879 /* Now, update contour_lines structure. */ | |
4880 } | |
4881 /* ______. */ | |
4882 else /* |________*/ | |
4883 { | |
4884 register XPoint *p = begin + 1; | |
4885 end = contour_lines[y_pos].bottom_right; | |
4886 npoints = (end - begin + 1); | |
4887 XDrawLines (x_current_display, contour_window, | |
4888 contour_erase_gc, begin_erase, npoints, CoordModeOrigin); | |
4889 | |
4890 p->y = begin->y; | |
4891 p->x = ibw + (font_w * (x_pos + 1)); | |
4892 p++; | |
4893 p->y = begin->y + font_h; | |
4894 p->x = (p - 1)->x; | |
4895 bcopy (end, begin + 3, contour_last_point - end + 1); | |
4896 contour_last_point -= (npoints - 5); | |
4897 XDrawLines (x_current_display, contour_window, | |
4898 contour_erase_gc, begin, 4, CoordModeOrigin); | |
4899 XFlush (x_current_display); | |
4900 | |
4901 /* Now, update contour_lines structure. */ | |
4902 } | |
4903 } | |
4904 | |
4905 /* Erase the top horizontal lines of the contour, and then extend | |
4906 the contour upwards. */ | |
4907 | |
4908 static void | |
4909 extend_contour_top (line) | |
4910 { | |
4911 } | |
4912 | |
4913 static void | |
4914 clip_contour_bottom (x_pos, y_pos) | |
4915 int x_pos, y_pos; | |
4916 { | |
4917 } | |
4918 | |
4919 static void | |
4920 extend_contour_bottom (x_pos, y_pos) | |
4921 { | |
4922 } | |
4923 | |
4924 DEFUN ("x-select-region", Fx_select_region, Sx_select_region, 1, 1, "e", | |
4925 "") | |
4926 (event) | |
4927 Lisp_Object event; | |
4928 { | |
4929 register struct frame *f = selected_frame; | |
4930 struct window *w = XWINDOW (FRAME_SELECTED_WINDOW (f)); | |
4931 register int point_x = WINDOW_TO_FRAME_PIXEL_X (w, w->cursor.x); | |
4932 register int point_y = WINDOW_TO_FRAME_PIXEL_Y (w, w->cursor.y); | |
4933 register int mouse_below_point; | |
4934 register Lisp_Object obj; | |
4935 register int x_contour_x, x_contour_y; | |
4936 | |
4937 x_contour_x = x_mouse_x; | |
4938 x_contour_y = x_mouse_y; | |
4939 if (x_contour_y > point_y || (x_contour_y == point_y | |
4940 && x_contour_x > point_x)) | |
4941 { | |
4942 mouse_below_point = 1; | |
4943 outline_region (f, f->output_data.x->cursor_gc, point_x, point_y, | |
4944 x_contour_x, x_contour_y); | |
4945 } | |
4946 else | |
4947 { | |
4948 mouse_below_point = 0; | |
4949 outline_region (f, f->output_data.x->cursor_gc, x_contour_x, x_contour_y, | |
4950 point_x, point_y); | |
4951 } | |
4952 | |
4953 while (1) | |
4954 { | |
4955 obj = read_char (-1, 0, 0, Qnil, 0); | |
4956 if (!CONSP (obj)) | |
4957 break; | |
4958 | |
4959 if (mouse_below_point) | |
4960 { | |
4961 if (x_mouse_y <= point_y) /* Flipped. */ | |
4962 { | |
4963 mouse_below_point = 0; | |
4964 | |
4965 outline_region (f, f->output_data.x->reverse_gc, point_x, point_y, | |
4966 x_contour_x, x_contour_y); | |
4967 outline_region (f, f->output_data.x->cursor_gc, x_mouse_x, x_mouse_y, | |
4968 point_x, point_y); | |
4969 } | |
4970 else if (x_mouse_y < x_contour_y) /* Bottom clipped. */ | |
4971 { | |
4972 clip_contour_bottom (x_mouse_y); | |
4973 } | |
4974 else if (x_mouse_y > x_contour_y) /* Bottom extended. */ | |
4975 { | |
4976 extend_bottom_contour (x_mouse_y); | |
4977 } | |
4978 | |
4979 x_contour_x = x_mouse_x; | |
4980 x_contour_y = x_mouse_y; | |
4981 } | |
4982 else /* mouse above or same line as point */ | |
4983 { | |
4984 if (x_mouse_y >= point_y) /* Flipped. */ | |
4985 { | |
4986 mouse_below_point = 1; | |
4987 | |
4988 outline_region (f, f->output_data.x->reverse_gc, | |
4989 x_contour_x, x_contour_y, point_x, point_y); | |
4990 outline_region (f, f->output_data.x->cursor_gc, point_x, point_y, | |
4991 x_mouse_x, x_mouse_y); | |
4992 } | |
4993 else if (x_mouse_y > x_contour_y) /* Top clipped. */ | |
4994 { | |
4995 clip_contour_top (x_mouse_y); | |
4996 } | |
4997 else if (x_mouse_y < x_contour_y) /* Top extended. */ | |
4998 { | |
4999 extend_contour_top (x_mouse_y); | |
5000 } | |
5001 } | |
5002 } | |
5003 | |
5004 unread_command_event = obj; | |
5005 if (mouse_below_point) | |
5006 { | |
5007 contour_begin_x = point_x; | |
5008 contour_begin_y = point_y; | |
5009 contour_end_x = x_contour_x; | |
5010 contour_end_y = x_contour_y; | |
5011 } | |
5012 else | |
5013 { | |
5014 contour_begin_x = x_contour_x; | |
5015 contour_begin_y = x_contour_y; | |
5016 contour_end_x = point_x; | |
5017 contour_end_y = point_y; | |
5018 } | |
5019 } | |
5020 #endif | |
5021 | |
5022 DEFUN ("x-horizontal-line", Fx_horizontal_line, Sx_horizontal_line, 1, 1, "e", | |
5023 "") | |
5024 (event) | |
5025 Lisp_Object event; | |
5026 { | |
5027 register Lisp_Object obj; | |
5028 struct frame *f = selected_frame; | |
5029 register struct window *w = XWINDOW (selected_window); | |
5030 register GC line_gc = f->output_data.x->cursor_gc; | |
5031 register GC erase_gc = f->output_data.x->reverse_gc; | |
5032 #if 0 | |
5033 char dash_list[] = {6, 4, 6, 4}; | |
5034 int dashes = 4; | |
5035 XGCValues gc_values; | |
5036 #endif | |
5037 register int previous_y; | |
5038 register int line = (x_mouse_y + 1) * f->output_data.x->line_height | |
5039 + f->output_data.x->internal_border_width; | |
5040 register int left = f->output_data.x->internal_border_width | |
5041 + (WINDOW_LEFT_MARGIN (w) | |
5042 * FONT_WIDTH (f->output_data.x->font)); | |
5043 register int right = left + (w->width | |
5044 * FONT_WIDTH (f->output_data.x->font)) | |
5045 - f->output_data.x->internal_border_width; | |
5046 | |
5047 #if 0 | |
5048 BLOCK_INPUT; | |
5049 gc_values.foreground = f->output_data.x->cursor_pixel; | |
5050 gc_values.background = f->output_data.x->background_pixel; | |
5051 gc_values.line_width = 1; | |
5052 gc_values.line_style = LineOnOffDash; | |
5053 gc_values.cap_style = CapRound; | |
5054 gc_values.join_style = JoinRound; | |
5055 | |
5056 line_gc = XCreateGC (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), | |
5057 GCLineStyle | GCJoinStyle | GCCapStyle | |
5058 | GCLineWidth | GCForeground | GCBackground, | |
5059 &gc_values); | |
5060 XSetDashes (FRAME_X_DISPLAY (f), line_gc, 0, dash_list, dashes); | |
5061 gc_values.foreground = f->output_data.x->background_pixel; | |
5062 gc_values.background = f->output_data.x->foreground_pixel; | |
5063 erase_gc = XCreateGC (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), | |
5064 GCLineStyle | GCJoinStyle | GCCapStyle | |
5065 | GCLineWidth | GCForeground | GCBackground, | |
5066 &gc_values); | |
5067 XSetDashes (FRAME_X_DISPLAY (f), erase_gc, 0, dash_list, dashes); | |
5068 UNBLOCK_INPUT; | |
5069 #endif | |
5070 | |
5071 while (1) | |
5072 { | |
5073 BLOCK_INPUT; | |
5074 if (x_mouse_y >= XINT (w->top) | |
5075 && x_mouse_y < XINT (w->top) + XINT (w->height) - 1) | |
5076 { | |
5077 previous_y = x_mouse_y; | |
5078 line = (x_mouse_y + 1) * f->output_data.x->line_height | |
5079 + f->output_data.x->internal_border_width; | |
5080 XDrawLine (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), | |
5081 line_gc, left, line, right, line); | |
5082 } | |
5083 XFlush (FRAME_X_DISPLAY (f)); | |
5084 UNBLOCK_INPUT; | |
5085 | |
5086 do | |
5087 { | |
5088 obj = read_char (-1, 0, 0, Qnil, 0); | |
5089 if (!CONSP (obj) | |
5090 || (! EQ (Fcar (Fcdr (Fcdr (obj))), | |
5091 Qvertical_scroll_bar)) | |
5092 || x_mouse_grabbed) | |
5093 { | |
5094 BLOCK_INPUT; | |
5095 XDrawLine (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), | |
5096 erase_gc, left, line, right, line); | |
5097 unread_command_event = obj; | |
5098 #if 0 | |
5099 XFreeGC (FRAME_X_DISPLAY (f), line_gc); | |
5100 XFreeGC (FRAME_X_DISPLAY (f), erase_gc); | |
5101 #endif | |
5102 UNBLOCK_INPUT; | |
5103 return Qnil; | |
5104 } | |
5105 } | |
5106 while (x_mouse_y == previous_y); | |
5107 | |
5108 BLOCK_INPUT; | |
5109 XDrawLine (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), | |
5110 erase_gc, left, line, right, line); | |
5111 UNBLOCK_INPUT; | |
5112 } | |
5113 } | |
5114 #endif | |
5115 | |
5116 #if 0 | |
5117 /* These keep track of the rectangle following the pointer. */ | |
5118 int mouse_track_top, mouse_track_left, mouse_track_width; | |
5119 | |
5120 /* Offset in buffer of character under the pointer, or 0. */ | |
5121 int mouse_buffer_offset; | |
5122 | |
5123 DEFUN ("x-track-pointer", Fx_track_pointer, Sx_track_pointer, 0, 0, 0, | |
5124 "Track the pointer.") | |
5125 () | |
5126 { | |
5127 static Cursor current_pointer_shape; | |
5128 FRAME_PTR f = x_mouse_frame; | |
5129 | |
5130 BLOCK_INPUT; | |
5131 if (EQ (Vmouse_frame_part, Qtext_part) | |
5132 && (current_pointer_shape != f->output_data.x->nontext_cursor)) | |
5133 { | |
5134 unsigned char c; | |
5135 struct buffer *buf; | |
5136 | |
5137 current_pointer_shape = f->output_data.x->nontext_cursor; | |
5138 XDefineCursor (FRAME_X_DISPLAY (f), | |
5139 FRAME_X_WINDOW (f), | |
5140 current_pointer_shape); | |
5141 | |
5142 buf = XBUFFER (XWINDOW (Vmouse_window)->buffer); | |
5143 c = *(BUF_CHAR_ADDRESS (buf, mouse_buffer_offset)); | |
5144 } | |
5145 else if (EQ (Vmouse_frame_part, Qmodeline_part) | |
5146 && (current_pointer_shape != f->output_data.x->modeline_cursor)) | |
5147 { | |
5148 current_pointer_shape = f->output_data.x->modeline_cursor; | |
5149 XDefineCursor (FRAME_X_DISPLAY (f), | |
5150 FRAME_X_WINDOW (f), | |
5151 current_pointer_shape); | |
5152 } | |
5153 | |
5154 XFlush (FRAME_X_DISPLAY (f)); | |
5155 UNBLOCK_INPUT; | |
5156 } | |
5157 #endif | |
5158 | |
5159 #if 0 | |
5160 DEFUN ("x-track-pointer", Fx_track_pointer, Sx_track_pointer, 1, 1, "e", | |
5161 "Draw rectangle around character under mouse pointer, if there is one.") | |
5162 (event) | |
5163 Lisp_Object event; | |
5164 { | |
5165 struct window *w = XWINDOW (Vmouse_window); | |
5166 struct frame *f = XFRAME (WINDOW_FRAME (w)); | |
5167 struct buffer *b = XBUFFER (w->buffer); | |
5168 Lisp_Object obj; | |
5169 | |
5170 if (! EQ (Vmouse_window, selected_window)) | |
5171 return Qnil; | |
5172 | |
5173 if (EQ (event, Qnil)) | |
5174 { | |
5175 int x, y; | |
5176 | |
5177 x_read_mouse_position (selected_frame, &x, &y); | |
5178 } | |
5179 | |
5180 BLOCK_INPUT; | |
5181 mouse_track_width = 0; | |
5182 mouse_track_left = mouse_track_top = -1; | |
5183 | |
5184 do | |
5185 { | |
5186 if ((x_mouse_x != mouse_track_left | |
5187 && (x_mouse_x < mouse_track_left | |
5188 || x_mouse_x > (mouse_track_left + mouse_track_width))) | |
5189 || x_mouse_y != mouse_track_top) | |
5190 { | |
5191 int hp = 0; /* Horizontal position */ | |
5192 int len = FRAME_CURRENT_GLYPHS (f)->used[x_mouse_y]; | |
5193 int p = FRAME_CURRENT_GLYPHS (f)->bufp[x_mouse_y]; | |
5194 int tab_width = XINT (b->tab_width); | |
5195 int ctl_arrow_p = !NILP (b->ctl_arrow); | |
5196 unsigned char c; | |
5197 int mode_line_vpos = XFASTINT (w->height) + XFASTINT (w->top) - 1; | |
5198 int in_mode_line = 0; | |
5199 | |
5200 if (! FRAME_CURRENT_GLYPHS (f)->enable[x_mouse_y]) | |
5201 break; | |
5202 | |
5203 /* Erase previous rectangle. */ | |
5204 if (mouse_track_width) | |
5205 { | |
5206 x_rectangle (f, f->output_data.x->reverse_gc, | |
5207 mouse_track_left, mouse_track_top, | |
5208 mouse_track_width, 1); | |
5209 | |
5210 if ((mouse_track_left == f->phys_cursor_x | |
5211 || mouse_track_left == f->phys_cursor_x - 1) | |
5212 && mouse_track_top == f->phys_cursor_y) | |
5213 { | |
5214 x_display_cursor (f, 1); | |
5215 } | |
5216 } | |
5217 | |
5218 mouse_track_left = x_mouse_x; | |
5219 mouse_track_top = x_mouse_y; | |
5220 mouse_track_width = 0; | |
5221 | |
5222 if (mouse_track_left > len) /* Past the end of line. */ | |
5223 goto draw_or_not; | |
5224 | |
5225 if (mouse_track_top == mode_line_vpos) | |
5226 { | |
5227 in_mode_line = 1; | |
5228 goto draw_or_not; | |
5229 } | |
5230 | |
5231 if (tab_width <= 0 || tab_width > 20) tab_width = 8; | |
5232 do | |
5233 { | |
5234 c = FETCH_BYTE (p); | |
5235 if (len == f->width && hp == len - 1 && c != '\n') | |
5236 goto draw_or_not; | |
5237 | |
5238 switch (c) | |
5239 { | |
5240 case '\t': | |
5241 mouse_track_width = tab_width - (hp % tab_width); | |
5242 p++; | |
5243 hp += mouse_track_width; | |
5244 if (hp > x_mouse_x) | |
5245 { | |
5246 mouse_track_left = hp - mouse_track_width; | |
5247 goto draw_or_not; | |
5248 } | |
5249 continue; | |
5250 | |
5251 case '\n': | |
5252 mouse_track_width = -1; | |
5253 goto draw_or_not; | |
5254 | |
5255 default: | |
5256 if (ctl_arrow_p && (c < 040 || c == 0177)) | |
5257 { | |
5258 if (p > ZV) | |
5259 goto draw_or_not; | |
5260 | |
5261 mouse_track_width = 2; | |
5262 p++; | |
5263 hp +=2; | |
5264 if (hp > x_mouse_x) | |
5265 { | |
5266 mouse_track_left = hp - mouse_track_width; | |
5267 goto draw_or_not; | |
5268 } | |
5269 } | |
5270 else | |
5271 { | |
5272 mouse_track_width = 1; | |
5273 p++; | |
5274 hp++; | |
5275 } | |
5276 continue; | |
5277 } | |
5278 } | |
5279 while (hp <= x_mouse_x); | |
5280 | |
5281 draw_or_not: | |
5282 if (mouse_track_width) /* Over text; use text pointer shape. */ | |
5283 { | |
5284 XDefineCursor (FRAME_X_DISPLAY (f), | |
5285 FRAME_X_WINDOW (f), | |
5286 f->output_data.x->text_cursor); | |
5287 x_rectangle (f, f->output_data.x->cursor_gc, | |
5288 mouse_track_left, mouse_track_top, | |
5289 mouse_track_width, 1); | |
5290 } | |
5291 else if (in_mode_line) | |
5292 XDefineCursor (FRAME_X_DISPLAY (f), | |
5293 FRAME_X_WINDOW (f), | |
5294 f->output_data.x->modeline_cursor); | |
5295 else | |
5296 XDefineCursor (FRAME_X_DISPLAY (f), | |
5297 FRAME_X_WINDOW (f), | |
5298 f->output_data.x->nontext_cursor); | |
5299 } | |
5300 | |
5301 XFlush (FRAME_X_DISPLAY (f)); | |
5302 UNBLOCK_INPUT; | |
5303 | |
5304 obj = read_char (-1, 0, 0, Qnil, 0); | |
5305 BLOCK_INPUT; | |
5306 } | |
5307 while (CONSP (obj) /* Mouse event */ | |
5308 && EQ (Fcar (Fcdr (Fcdr (obj))), Qnil) /* Not scroll bar */ | |
5309 && EQ (Vmouse_depressed, Qnil) /* Only motion events */ | |
5310 && EQ (Vmouse_window, selected_window) /* In this window */ | |
5311 && x_mouse_frame); | |
5312 | |
5313 unread_command_event = obj; | |
5314 | |
5315 if (mouse_track_width) | |
5316 { | |
5317 x_rectangle (f, f->output_data.x->reverse_gc, | |
5318 mouse_track_left, mouse_track_top, | |
5319 mouse_track_width, 1); | |
5320 mouse_track_width = 0; | |
5321 if ((mouse_track_left == f->phys_cursor_x | |
5322 || mouse_track_left - 1 == f->phys_cursor_x) | |
5323 && mouse_track_top == f->phys_cursor_y) | |
5324 { | |
5325 x_display_cursor (f, 1); | |
5326 } | |
5327 } | |
5328 XDefineCursor (FRAME_X_DISPLAY (f), | |
5329 FRAME_X_WINDOW (f), | |
5330 f->output_data.x->nontext_cursor); | |
5331 XFlush (FRAME_X_DISPLAY (f)); | |
5332 UNBLOCK_INPUT; | |
5333 | |
5334 return Qnil; | |
5335 } | |
5336 #endif | |
5337 | |
5338 #if 0 | |
5339 #include "glyphs.h" | |
5340 | |
5341 /* Draw a pixmap specified by IMAGE_DATA of dimensions WIDTH and HEIGHT | |
5342 on the frame F at position X, Y. */ | |
5343 | |
5344 x_draw_pixmap (f, x, y, image_data, width, height) | |
5345 struct frame *f; | |
5346 int x, y, width, height; | |
5347 char *image_data; | |
5348 { | |
5349 Pixmap image; | |
5350 | |
5351 image = XCreateBitmapFromData (FRAME_X_DISPLAY (f), | |
5352 FRAME_X_WINDOW (f), image_data, | |
5353 width, height); | |
5354 XCopyPlane (FRAME_X_DISPLAY (f), image, FRAME_X_WINDOW (f), | |
5355 f->output_data.x->normal_gc, 0, 0, width, height, x, y); | |
5356 } | |
5357 #endif | |
5358 | |
5359 #if 0 /* I'm told these functions are superfluous | |
5360 given the ability to bind function keys. */ | |
5361 | |
5362 #ifdef HAVE_X11 | |
5363 DEFUN ("x-rebind-key", Fx_rebind_key, Sx_rebind_key, 3, 3, 0, | |
5364 "Rebind X keysym KEYSYM, with MODIFIERS, to generate NEWSTRING.\n\ | |
5365 KEYSYM is a string which conforms to the X keysym definitions found\n\ | |
5366 in X11/keysymdef.h, sans the initial XK_. MODIFIERS is nil or a\n\ | |
5367 list of strings specifying modifier keys such as Control_L, which must\n\ | |
5368 also be depressed for NEWSTRING to appear.") | |
5369 (x_keysym, modifiers, newstring) | |
5370 register Lisp_Object x_keysym; | |
5371 register Lisp_Object modifiers; | |
5372 register Lisp_Object newstring; | |
5373 { | |
5374 char *rawstring; | |
5375 register KeySym keysym; | |
5376 KeySym modifier_list[16]; | |
5377 | |
5378 check_x (); | |
5379 CHECK_STRING (x_keysym, 1); | |
5380 CHECK_STRING (newstring, 3); | |
5381 | |
5382 keysym = XStringToKeysym ((char *) XSTRING (x_keysym)->data); | |
5383 if (keysym == NoSymbol) | |
5384 error ("Keysym does not exist"); | |
5385 | |
5386 if (NILP (modifiers)) | |
5387 XRebindKeysym (x_current_display, keysym, modifier_list, 0, | |
5388 XSTRING (newstring)->data, | |
5389 STRING_BYTES (XSTRING (newstring))); | |
5390 else | |
5391 { | |
5392 register Lisp_Object rest, mod; | |
5393 register int i = 0; | |
5394 | |
5395 for (rest = modifiers; !NILP (rest); rest = Fcdr (rest)) | |
5396 { | |
5397 if (i == 16) | |
5398 error ("Can't have more than 16 modifiers"); | |
5399 | |
5400 mod = Fcar (rest); | |
5401 CHECK_STRING (mod, 3); | |
5402 modifier_list[i] = XStringToKeysym ((char *) XSTRING (mod)->data); | |
5403 #ifndef HAVE_X11R5 | |
5404 if (modifier_list[i] == NoSymbol | |
5405 || !(IsModifierKey (modifier_list[i]) | |
5406 || ((unsigned)(modifier_list[i]) == XK_Mode_switch) | |
5407 || ((unsigned)(modifier_list[i]) == XK_Num_Lock))) | |
5408 #else | |
5409 if (modifier_list[i] == NoSymbol | |
5410 || !IsModifierKey (modifier_list[i])) | |
5411 #endif | |
5412 error ("Element is not a modifier keysym"); | |
5413 i++; | |
5414 } | |
5415 | |
5416 XRebindKeysym (x_current_display, keysym, modifier_list, i, | |
5417 XSTRING (newstring)->data, | |
5418 STRING_BYTES (XSTRING (newstring))); | |
5419 } | |
5420 | |
5421 return Qnil; | |
5422 } | |
5423 | |
5424 DEFUN ("x-rebind-keys", Fx_rebind_keys, Sx_rebind_keys, 2, 2, 0, | |
5425 "Rebind KEYCODE to list of strings STRINGS.\n\ | |
5426 STRINGS should be a list of 16 elements, one for each shift combination.\n\ | |
5427 nil as element means don't change.\n\ | |
5428 See the documentation of `x-rebind-key' for more information.") | |
5429 (keycode, strings) | |
5430 register Lisp_Object keycode; | |
5431 register Lisp_Object strings; | |
5432 { | |
5433 register Lisp_Object item; | |
5434 register unsigned char *rawstring; | |
5435 KeySym rawkey, modifier[1]; | |
5436 int strsize; | |
5437 register unsigned i; | |
5438 | |
5439 check_x (); | |
5440 CHECK_NUMBER (keycode, 1); | |
5441 CHECK_CONS (strings, 2); | |
5442 rawkey = (KeySym) ((unsigned) (XINT (keycode))) & 255; | |
5443 for (i = 0; i <= 15; strings = Fcdr (strings), i++) | |
5444 { | |
5445 item = Fcar (strings); | |
5446 if (!NILP (item)) | |
5447 { | |
5448 CHECK_STRING (item, 2); | |
5449 strsize = STRING_BYTES (XSTRING (item)); | |
5450 rawstring = (unsigned char *) xmalloc (strsize); | |
5451 bcopy (XSTRING (item)->data, rawstring, strsize); | |
5452 modifier[1] = 1 << i; | |
5453 XRebindKeysym (x_current_display, rawkey, modifier, 1, | |
5454 rawstring, strsize); | |
5455 } | |
5456 } | |
5457 return Qnil; | |
5458 } | |
5459 #endif /* HAVE_X11 */ | |
5460 #endif /* 0 */ | |
5461 | 4583 |
5462 | 4584 |
5463 /************************************************************************ | 4585 /************************************************************************ |
5464 X Displays | 4586 X Displays |
5465 ************************************************************************/ | 4587 ************************************************************************/ |
11164 /* X window properties. */ | 10286 /* X window properties. */ |
11165 defsubr (&Sx_change_window_property); | 10287 defsubr (&Sx_change_window_property); |
11166 defsubr (&Sx_delete_window_property); | 10288 defsubr (&Sx_delete_window_property); |
11167 defsubr (&Sx_window_property); | 10289 defsubr (&Sx_window_property); |
11168 | 10290 |
11169 #if 0 | |
11170 defsubr (&Sx_draw_rectangle); | |
11171 defsubr (&Sx_erase_rectangle); | |
11172 defsubr (&Sx_contour_region); | |
11173 defsubr (&Sx_uncontour_region); | |
11174 #endif | |
11175 defsubr (&Sxw_display_color_p); | 10291 defsubr (&Sxw_display_color_p); |
11176 defsubr (&Sx_display_grayscale_p); | 10292 defsubr (&Sx_display_grayscale_p); |
11177 defsubr (&Sxw_color_defined_p); | 10293 defsubr (&Sxw_color_defined_p); |
11178 defsubr (&Sxw_color_values); | 10294 defsubr (&Sxw_color_values); |
11179 defsubr (&Sx_server_max_request_size); | 10295 defsubr (&Sx_server_max_request_size); |
11187 defsubr (&Sx_display_planes); | 10303 defsubr (&Sx_display_planes); |
11188 defsubr (&Sx_display_color_cells); | 10304 defsubr (&Sx_display_color_cells); |
11189 defsubr (&Sx_display_visual_class); | 10305 defsubr (&Sx_display_visual_class); |
11190 defsubr (&Sx_display_backing_store); | 10306 defsubr (&Sx_display_backing_store); |
11191 defsubr (&Sx_display_save_under); | 10307 defsubr (&Sx_display_save_under); |
11192 #if 0 | |
11193 defsubr (&Sx_rebind_key); | |
11194 defsubr (&Sx_rebind_keys); | |
11195 defsubr (&Sx_track_pointer); | |
11196 defsubr (&Sx_grab_pointer); | |
11197 defsubr (&Sx_ungrab_pointer); | |
11198 #endif | |
11199 defsubr (&Sx_parse_geometry); | 10308 defsubr (&Sx_parse_geometry); |
11200 defsubr (&Sx_create_frame); | 10309 defsubr (&Sx_create_frame); |
11201 #if 0 | |
11202 defsubr (&Sx_horizontal_line); | |
11203 #endif | |
11204 defsubr (&Sx_open_connection); | 10310 defsubr (&Sx_open_connection); |
11205 defsubr (&Sx_close_connection); | 10311 defsubr (&Sx_close_connection); |
11206 defsubr (&Sx_display_list); | 10312 defsubr (&Sx_display_list); |
11207 defsubr (&Sx_synchronize); | 10313 defsubr (&Sx_synchronize); |
10314 defsubr (&Sx_focus_frame); | |
11208 | 10315 |
11209 /* Setting callback functions for fontset handler. */ | 10316 /* Setting callback functions for fontset handler. */ |
11210 get_font_info_func = x_get_font_info; | 10317 get_font_info_func = x_get_font_info; |
11211 | 10318 |
11212 #if 0 /* This function pointer doesn't seem to be used anywhere. | 10319 #if 0 /* This function pointer doesn't seem to be used anywhere. |