comparison src/xfns.c @ 1050:133bad38bde1

* xfns.c (x_icon): Don't call x_wm_set_icon_positions if the user hasn't specified the icon position. Let the window manager put the icon where it likes. * xfns.c (x_set_name): Use XSetWM{Name,IconName} when available [HAVE_X11R4], or XSetIconName and XStoreName otherwise. * xfns.c: Use the FRAME_X_WINDOW for readability. * xfns.c (x_set_mouse_color): Use x_catch_errors, x_check_errors, and x_uncatch errors to avoid crashing if the user selects an odd cursor. * xfns.c (select_visual): Use XVisualIDFromVisual when available [HAVE_X11R4].
author Jim Blandy <jimb@redhat.com>
date Sat, 29 Aug 1992 03:25:25 +0000
parents 5fd29acd3db7
children d79192bacdce
comparison
equal deleted inserted replaced
1049:25046e48ce9a 1050:133bad38bde1
278 { 278 {
279 frame = XCONS (tail)->car; 279 frame = XCONS (tail)->car;
280 if (XTYPE (frame) != Lisp_Frame) 280 if (XTYPE (frame) != Lisp_Frame)
281 continue; 281 continue;
282 f = XFRAME (frame); 282 f = XFRAME (frame);
283 if (f->display.x->window_desc == wdesc 283 if (FRAME_X_WINDOW (f) == wdesc
284 || f->display.x->icon_desc == wdesc) 284 || f->display.x->icon_desc == wdesc)
285 return f; 285 return f;
286 } 286 }
287 return 0; 287 return 0;
288 } 288 }
546 store_in_alist (alistptr, Qtop, make_number (f->display.x->top_pos)); 546 store_in_alist (alistptr, Qtop, make_number (f->display.x->top_pos));
547 store_in_alist (alistptr, Qborder_width, 547 store_in_alist (alistptr, Qborder_width,
548 make_number (f->display.x->border_width)); 548 make_number (f->display.x->border_width));
549 store_in_alist (alistptr, Qinternal_border_width, 549 store_in_alist (alistptr, Qinternal_border_width,
550 make_number (f->display.x->internal_border_width)); 550 make_number (f->display.x->internal_border_width));
551 sprintf (buf, "%d", f->display.x->window_desc); 551 sprintf (buf, "%d", FRAME_X_WINDOW (f));
552 store_in_alist (alistptr, Qwindow_id, 552 store_in_alist (alistptr, Qwindow_id,
553 build_string (buf)); 553 build_string (buf));
554 } 554 }
555 555
556 /* Decide if color named COLOR is valid for the display 556 /* Decide if color named COLOR is valid for the display
616 } 616 }
617 617
618 /* Functions called only from `x_set_frame_param' 618 /* Functions called only from `x_set_frame_param'
619 to set individual parameters. 619 to set individual parameters.
620 620
621 If f->display.x->window_desc is 0, 621 If FRAME_X_WINDOW (f) is 0,
622 the frame is being created and its X-window does not exist yet. 622 the frame is being created and its X-window does not exist yet.
623 In that case, just record the parameter's new value 623 In that case, just record the parameter's new value
624 in the standard place; do not attempt to change the window. */ 624 in the standard place; do not attempt to change the window. */
625 625
626 void 626 void
627 x_set_foreground_color (f, arg, oldval) 627 x_set_foreground_color (f, arg, oldval)
628 struct frame *f; 628 struct frame *f;
629 Lisp_Object arg, oldval; 629 Lisp_Object arg, oldval;
630 { 630 {
631 f->display.x->foreground_pixel = x_decode_color (arg, BLACK_PIX_DEFAULT); 631 f->display.x->foreground_pixel = x_decode_color (arg, BLACK_PIX_DEFAULT);
632 if (f->display.x->window_desc != 0) 632 if (FRAME_X_WINDOW (f) != 0)
633 { 633 {
634 #ifdef HAVE_X11 634 #ifdef HAVE_X11
635 BLOCK_INPUT; 635 BLOCK_INPUT;
636 XSetForeground (x_current_display, f->display.x->normal_gc, 636 XSetForeground (x_current_display, f->display.x->normal_gc,
637 f->display.x->foreground_pixel); 637 f->display.x->foreground_pixel);
643 643
644 XSetWindowBorder (x_current_display, f->display.x->v_scrollbar, 644 XSetWindowBorder (x_current_display, f->display.x->v_scrollbar,
645 f->display.x->foreground_pixel); 645 f->display.x->foreground_pixel);
646 646
647 slider_pixmap = 647 slider_pixmap =
648 XCreatePixmapFromBitmapData (XDISPLAY f->display.x->window_desc, 648 XCreatePixmapFromBitmapData (XDISPLAY FRAME_X_WINDOW (f),
649 gray_bits, 16, 16, 649 gray_bits, 16, 16,
650 f->display.x->foreground_pixel, 650 f->display.x->foreground_pixel,
651 f->display.x->background_pixel, 651 f->display.x->background_pixel,
652 DefaultDepth (x_current_display, 652 DefaultDepth (x_current_display,
653 XDefaultScreen (x_current_display))); 653 XDefaultScreen (x_current_display)));
654 up_arrow_pixmap = 654 up_arrow_pixmap =
655 XCreatePixmapFromBitmapData (XDISPLAY f->display.x->window_desc, 655 XCreatePixmapFromBitmapData (XDISPLAY FRAME_X_WINDOW (f),
656 up_arrow_bits, 16, 16, 656 up_arrow_bits, 16, 16,
657 f->display.x->foreground_pixel, 657 f->display.x->foreground_pixel,
658 f->display.x->background_pixel, 658 f->display.x->background_pixel,
659 DefaultDepth (x_current_display, 659 DefaultDepth (x_current_display,
660 XDefaultScreen (x_current_display))); 660 XDefaultScreen (x_current_display)));
661 down_arrow_pixmap = 661 down_arrow_pixmap =
662 XCreatePixmapFromBitmapData (XDISPLAY f->display.x->window_desc, 662 XCreatePixmapFromBitmapData (XDISPLAY FRAME_X_WINDOW (f),
663 down_arrow_bits, 16, 16, 663 down_arrow_bits, 16, 16,
664 f->display.x->foreground_pixel, 664 f->display.x->foreground_pixel,
665 f->display.x->background_pixel, 665 f->display.x->background_pixel,
666 DefaultDepth (x_current_display, 666 DefaultDepth (x_current_display,
667 XDefaultScreen (x_current_display))); 667 XDefaultScreen (x_current_display)));
687 687
688 XSetWindowBorder (x_current_display, f->display.x->h_scrollbar, 688 XSetWindowBorder (x_current_display, f->display.x->h_scrollbar,
689 f->display.x->foreground_pixel); 689 f->display.x->foreground_pixel);
690 690
691 slider_pixmap = 691 slider_pixmap =
692 XCreatePixmapFromBitmapData (XDISPLAY f->display.x->window_desc, 692 XCreatePixmapFromBitmapData (XDISPLAY FRAME_X_WINDOW (f),
693 gray_bits, 16, 16, 693 gray_bits, 16, 16,
694 f->display.x->foreground_pixel, 694 f->display.x->foreground_pixel,
695 f->display.x->background_pixel, 695 f->display.x->background_pixel,
696 DefaultDepth (x_current_display, 696 DefaultDepth (x_current_display,
697 XDefaultScreen (x_current_display))); 697 XDefaultScreen (x_current_display)));
698 698
699 left_arrow_pixmap = 699 left_arrow_pixmap =
700 XCreatePixmapFromBitmapData (XDISPLAY f->display.x->window_desc, 700 XCreatePixmapFromBitmapData (XDISPLAY FRAME_X_WINDOW (f),
701 up_arrow_bits, 16, 16, 701 up_arrow_bits, 16, 16,
702 f->display.x->foreground_pixel, 702 f->display.x->foreground_pixel,
703 f->display.x->background_pixel, 703 f->display.x->background_pixel,
704 DefaultDepth (x_current_display, 704 DefaultDepth (x_current_display,
705 XDefaultScreen (x_current_display))); 705 XDefaultScreen (x_current_display)));
706 right_arrow_pixmap = 706 right_arrow_pixmap =
707 XCreatePixmapFromBitmapData (XDISPLAY f->display.x->window_desc, 707 XCreatePixmapFromBitmapData (XDISPLAY FRAME_X_WINDOW (f),
708 down_arrow_bits, 16, 16, 708 down_arrow_bits, 16, 16,
709 f->display.x->foreground_pixel, 709 f->display.x->foreground_pixel,
710 f->display.x->background_pixel, 710 f->display.x->background_pixel,
711 DefaultDepth (x_current_display, 711 DefaultDepth (x_current_display,
712 XDefaultScreen (x_current_display))); 712 XDefaultScreen (x_current_display)));
741 Pixmap temp; 741 Pixmap temp;
742 int mask; 742 int mask;
743 743
744 f->display.x->background_pixel = x_decode_color (arg, WHITE_PIX_DEFAULT); 744 f->display.x->background_pixel = x_decode_color (arg, WHITE_PIX_DEFAULT);
745 745
746 if (f->display.x->window_desc != 0) 746 if (FRAME_X_WINDOW (f) != 0)
747 { 747 {
748 BLOCK_INPUT; 748 BLOCK_INPUT;
749 #ifdef HAVE_X11 749 #ifdef HAVE_X11
750 /* The main frame area. */ 750 /* The main frame area. */
751 XSetBackground (x_current_display, f->display.x->normal_gc, 751 XSetBackground (x_current_display, f->display.x->normal_gc,
752 f->display.x->background_pixel); 752 f->display.x->background_pixel);
753 XSetForeground (x_current_display, f->display.x->reverse_gc, 753 XSetForeground (x_current_display, f->display.x->reverse_gc,
754 f->display.x->background_pixel); 754 f->display.x->background_pixel);
755 XSetWindowBackground (x_current_display, f->display.x->window_desc, 755 XSetWindowBackground (x_current_display, FRAME_X_WINDOW (f),
756 f->display.x->background_pixel); 756 f->display.x->background_pixel);
757 757
758 /* Scroll bars. */ 758 /* Scroll bars. */
759 if (f->display.x->v_scrollbar) 759 if (f->display.x->v_scrollbar)
760 { 760 {
762 762
763 XSetWindowBackground (x_current_display, f->display.x->v_scrollbar, 763 XSetWindowBackground (x_current_display, f->display.x->v_scrollbar,
764 f->display.x->background_pixel); 764 f->display.x->background_pixel);
765 765
766 slider_pixmap = 766 slider_pixmap =
767 XCreatePixmapFromBitmapData (XDISPLAY f->display.x->window_desc, 767 XCreatePixmapFromBitmapData (XDISPLAY FRAME_X_WINDOW (f),
768 gray_bits, 16, 16, 768 gray_bits, 16, 16,
769 f->display.x->foreground_pixel, 769 f->display.x->foreground_pixel,
770 f->display.x->background_pixel, 770 f->display.x->background_pixel,
771 DefaultDepth (x_current_display, 771 DefaultDepth (x_current_display,
772 XDefaultScreen (x_current_display))); 772 XDefaultScreen (x_current_display)));
773 up_arrow_pixmap = 773 up_arrow_pixmap =
774 XCreatePixmapFromBitmapData (XDISPLAY f->display.x->window_desc, 774 XCreatePixmapFromBitmapData (XDISPLAY FRAME_X_WINDOW (f),
775 up_arrow_bits, 16, 16, 775 up_arrow_bits, 16, 16,
776 f->display.x->foreground_pixel, 776 f->display.x->foreground_pixel,
777 f->display.x->background_pixel, 777 f->display.x->background_pixel,
778 DefaultDepth (x_current_display, 778 DefaultDepth (x_current_display,
779 XDefaultScreen (x_current_display))); 779 XDefaultScreen (x_current_display)));
780 down_arrow_pixmap = 780 down_arrow_pixmap =
781 XCreatePixmapFromBitmapData (XDISPLAY f->display.x->window_desc, 781 XCreatePixmapFromBitmapData (XDISPLAY FRAME_X_WINDOW (f),
782 down_arrow_bits, 16, 16, 782 down_arrow_bits, 16, 16,
783 f->display.x->foreground_pixel, 783 f->display.x->foreground_pixel,
784 f->display.x->background_pixel, 784 f->display.x->background_pixel,
785 DefaultDepth (x_current_display, 785 DefaultDepth (x_current_display,
786 XDefaultScreen (x_current_display))); 786 XDefaultScreen (x_current_display)));
806 806
807 XSetWindowBackground (x_current_display, f->display.x->h_scrollbar, 807 XSetWindowBackground (x_current_display, f->display.x->h_scrollbar,
808 f->display.x->background_pixel); 808 f->display.x->background_pixel);
809 809
810 slider_pixmap = 810 slider_pixmap =
811 XCreatePixmapFromBitmapData (XDISPLAY f->display.x->window_desc, 811 XCreatePixmapFromBitmapData (XDISPLAY FRAME_X_WINDOW (f),
812 gray_bits, 16, 16, 812 gray_bits, 16, 16,
813 f->display.x->foreground_pixel, 813 f->display.x->foreground_pixel,
814 f->display.x->background_pixel, 814 f->display.x->background_pixel,
815 DefaultDepth (x_current_display, 815 DefaultDepth (x_current_display,
816 XDefaultScreen (x_current_display))); 816 XDefaultScreen (x_current_display)));
817 817
818 left_arrow_pixmap = 818 left_arrow_pixmap =
819 XCreatePixmapFromBitmapData (XDISPLAY f->display.x->window_desc, 819 XCreatePixmapFromBitmapData (XDISPLAY FRAME_X_WINDOW (f),
820 up_arrow_bits, 16, 16, 820 up_arrow_bits, 16, 16,
821 f->display.x->foreground_pixel, 821 f->display.x->foreground_pixel,
822 f->display.x->background_pixel, 822 f->display.x->background_pixel,
823 DefaultDepth (x_current_display, 823 DefaultDepth (x_current_display,
824 XDefaultScreen (x_current_display))); 824 XDefaultScreen (x_current_display)));
825 right_arrow_pixmap = 825 right_arrow_pixmap =
826 XCreatePixmapFromBitmapData (XDISPLAY f->display.x->window_desc, 826 XCreatePixmapFromBitmapData (XDISPLAY FRAME_X_WINDOW (f),
827 down_arrow_bits, 16, 16, 827 down_arrow_bits, 16, 16,
828 f->display.x->foreground_pixel, 828 f->display.x->foreground_pixel,
829 f->display.x->background_pixel, 829 f->display.x->background_pixel,
830 DefaultDepth (x_current_display, 830 DefaultDepth (x_current_display,
831 XDefaultScreen (x_current_display))); 831 XDefaultScreen (x_current_display)));
845 XFreePixmap (x_current_display, left_arrow_pixmap); 845 XFreePixmap (x_current_display, left_arrow_pixmap);
846 XFreePixmap (x_current_display, right_arrow_pixmap); 846 XFreePixmap (x_current_display, right_arrow_pixmap);
847 } 847 }
848 #else 848 #else
849 temp = XMakeTile (f->display.x->background_pixel); 849 temp = XMakeTile (f->display.x->background_pixel);
850 XChangeBackground (f->display.x->window_desc, temp); 850 XChangeBackground (FRAME_X_WINDOW (f), temp);
851 XFreePixmap (temp); 851 XFreePixmap (temp);
852 #endif /* not HAVE_X11 */ 852 #endif /* not HAVE_X11 */
853 UNBLOCK_INPUT; 853 UNBLOCK_INPUT;
854 854
855 if (f->visible) 855 if (f->visible)
873 && mask_color == f->display.x->background_pixel) 873 && mask_color == f->display.x->background_pixel)
874 f->display.x->mouse_pixel = f->display.x->foreground_pixel; 874 f->display.x->mouse_pixel = f->display.x->foreground_pixel;
875 875
876 BLOCK_INPUT; 876 BLOCK_INPUT;
877 #ifdef HAVE_X11 877 #ifdef HAVE_X11
878
879 /* It's not okay to crash if the user selects a screwey cursor. */
880 x_catch_errors ();
881
878 if (!EQ (Qnil, Vx_pointer_shape)) 882 if (!EQ (Qnil, Vx_pointer_shape))
879 { 883 {
880 CHECK_NUMBER (Vx_pointer_shape, 0); 884 CHECK_NUMBER (Vx_pointer_shape, 0);
881 cursor = XCreateFontCursor (x_current_display, XINT (Vx_pointer_shape)); 885 cursor = XCreateFontCursor (x_current_display, XINT (Vx_pointer_shape));
882 } 886 }
898 mode_cursor = XCreateFontCursor (x_current_display, 902 mode_cursor = XCreateFontCursor (x_current_display,
899 XINT (Vx_mode_pointer_shape)); 903 XINT (Vx_mode_pointer_shape));
900 } 904 }
901 else 905 else
902 mode_cursor = XCreateFontCursor (x_current_display, XC_xterm); 906 mode_cursor = XCreateFontCursor (x_current_display, XC_xterm);
907
908 /* Check and report errors with the above calls. */
909 x_check_errors ("can't set cursor shape: %s");
910 x_uncatch_errors ();
903 911
904 { 912 {
905 XColor fore_color, back_color; 913 XColor fore_color, back_color;
906 914
907 fore_color.pixel = f->display.x->mouse_pixel; 915 fore_color.pixel = f->display.x->mouse_pixel;
927 f->display.x->mouse_pixel, 935 f->display.x->mouse_pixel,
928 f->display.x->background_pixel, 936 f->display.x->background_pixel,
929 GXcopy); 937 GXcopy);
930 #endif /* X10 */ 938 #endif /* X10 */
931 939
932 if (f->display.x->window_desc != 0) 940 if (FRAME_X_WINDOW (f) != 0)
933 { 941 {
934 XDefineCursor (XDISPLAY f->display.x->window_desc, cursor); 942 XDefineCursor (XDISPLAY FRAME_X_WINDOW (f), cursor);
935 } 943 }
936 944
937 if (cursor != f->display.x->text_cursor && f->display.x->text_cursor != 0) 945 if (cursor != f->display.x->text_cursor && f->display.x->text_cursor != 0)
938 XFreeCursor (XDISPLAY f->display.x->text_cursor); 946 XFreeCursor (XDISPLAY f->display.x->text_cursor);
939 f->display.x->text_cursor = cursor; 947 f->display.x->text_cursor = cursor;
972 f->display.x->cursor_pixel == f->display.x->mouse_pixel; 980 f->display.x->cursor_pixel == f->display.x->mouse_pixel;
973 if (f->display.x->cursor_pixel == fore_pixel) 981 if (f->display.x->cursor_pixel == fore_pixel)
974 fore_pixel = f->display.x->background_pixel; 982 fore_pixel = f->display.x->background_pixel;
975 } 983 }
976 984
977 if (f->display.x->window_desc != 0) 985 if (FRAME_X_WINDOW (f) != 0)
978 { 986 {
979 #ifdef HAVE_X11 987 #ifdef HAVE_X11
980 BLOCK_INPUT; 988 BLOCK_INPUT;
981 XSetBackground (x_current_display, f->display.x->cursor_gc, 989 XSetBackground (x_current_display, f->display.x->cursor_gc,
982 f->display.x->cursor_pixel); 990 f->display.x->cursor_pixel);
1035 struct frame *f; 1043 struct frame *f;
1036 int pix; 1044 int pix;
1037 { 1045 {
1038 f->display.x->border_pixel = pix; 1046 f->display.x->border_pixel = pix;
1039 1047
1040 if (f->display.x->window_desc != 0 && f->display.x->border_width > 0) 1048 if (FRAME_X_WINDOW (f) != 0 && f->display.x->border_width > 0)
1041 { 1049 {
1042 Pixmap temp; 1050 Pixmap temp;
1043 int mask; 1051 int mask;
1044 1052
1045 BLOCK_INPUT; 1053 BLOCK_INPUT;
1046 #ifdef HAVE_X11 1054 #ifdef HAVE_X11
1047 XSetWindowBorder (x_current_display, f->display.x->window_desc, 1055 XSetWindowBorder (x_current_display, FRAME_X_WINDOW (f),
1048 pix); 1056 pix);
1049 if (f->display.x->h_scrollbar) 1057 if (f->display.x->h_scrollbar)
1050 XSetWindowBorder (x_current_display, f->display.x->h_slider, 1058 XSetWindowBorder (x_current_display, f->display.x->h_slider,
1051 pix); 1059 pix);
1052 if (f->display.x->v_scrollbar) 1060 if (f->display.x->v_scrollbar)
1056 if (pix < 0) 1064 if (pix < 0)
1057 temp = XMakePixmap ((Bitmap) XStoreBitmap (16, 16, gray_bits), 1065 temp = XMakePixmap ((Bitmap) XStoreBitmap (16, 16, gray_bits),
1058 BLACK_PIX_DEFAULT, WHITE_PIX_DEFAULT); 1066 BLACK_PIX_DEFAULT, WHITE_PIX_DEFAULT);
1059 else 1067 else
1060 temp = XMakeTile (pix); 1068 temp = XMakeTile (pix);
1061 XChangeBorder (f->display.x->window_desc, temp); 1069 XChangeBorder (FRAME_X_WINDOW (f), temp);
1062 XFreePixmap (XDISPLAY temp); 1070 XFreePixmap (XDISPLAY temp);
1063 #endif /* not HAVE_X11 */ 1071 #endif /* not HAVE_X11 */
1064 UNBLOCK_INPUT; 1072 UNBLOCK_INPUT;
1065 1073
1066 if (f->visible) 1074 if (f->visible)
1092 } 1100 }
1093 1101
1094 /* If the window was unmapped (and its icon was mapped), 1102 /* If the window was unmapped (and its icon was mapped),
1095 the new icon is not mapped, so map the window in its stead. */ 1103 the new icon is not mapped, so map the window in its stead. */
1096 if (f->visible) 1104 if (f->visible)
1097 XMapWindow (XDISPLAY f->display.x->window_desc); 1105 XMapWindow (XDISPLAY FRAME_X_WINDOW (f));
1098 1106
1099 XFlushQueue (); 1107 XFlushQueue ();
1100 UNBLOCK_INPUT; 1108 UNBLOCK_INPUT;
1101 } 1109 }
1102 1110
1127 CHECK_NUMBER (arg, 0); 1135 CHECK_NUMBER (arg, 0);
1128 1136
1129 if (XINT (arg) == f->display.x->border_width) 1137 if (XINT (arg) == f->display.x->border_width)
1130 return; 1138 return;
1131 1139
1132 if (f->display.x->window_desc != 0) 1140 if (FRAME_X_WINDOW (f) != 0)
1133 error ("Cannot change the border width of a window"); 1141 error ("Cannot change the border width of a window");
1134 1142
1135 f->display.x->border_width = XINT (arg); 1143 f->display.x->border_width = XINT (arg);
1136 } 1144 }
1137 1145
1149 f->display.x->internal_border_width = 0; 1157 f->display.x->internal_border_width = 0;
1150 1158
1151 if (f->display.x->internal_border_width == old) 1159 if (f->display.x->internal_border_width == old)
1152 return; 1160 return;
1153 1161
1154 if (f->display.x->window_desc != 0) 1162 if (FRAME_X_WINDOW (f) != 0)
1155 { 1163 {
1156 BLOCK_INPUT; 1164 BLOCK_INPUT;
1157 x_set_window_size (f, f->width, f->height); 1165 x_set_window_size (f, f->width, f->height);
1158 #if 0 1166 #if 0
1159 x_set_resize_hint (f); 1167 x_set_resize_hint (f);
1209 1217
1210 /* Don't change the name if it's already NAME. */ 1218 /* Don't change the name if it's already NAME. */
1211 if (! NILP (Fstring_equal (name, f->name))) 1219 if (! NILP (Fstring_equal (name, f->name)))
1212 return; 1220 return;
1213 1221
1214 if (f->display.x->window_desc) 1222 if (FRAME_X_WINDOW (f))
1215 { 1223 {
1216 BLOCK_INPUT; 1224 BLOCK_INPUT;
1217 x_set_text_property (f, XA_WM_NAME, name); 1225
1218 x_set_text_property (f, XA_WM_ICON_NAME, name); 1226 #ifdef HAVE_X11R4
1227 {
1228 XTextProperty text;
1229 text.value = XSTRING (name)->data;
1230 text.encoding = XA_STRING;
1231 text.format = 8;
1232 text.nitems = XSTRING (name)->size;
1233 XSetWMName (x_current_display, FRAME_X_WINDOW (f), &text);
1234 XSetWMIconName (x_current_display, FRAME_X_WINDOW (f), &text);
1235 }
1236 #else
1237 XSetIconName (XDISPLAY FRAME_X_WINDOW (f),
1238 XSTRING (name)->data);
1239 XStoreName (XDISPLAY FRAME_X_WINDOW (f),
1240 XSTRING (name)->data);
1241 #endif
1242
1219 UNBLOCK_INPUT; 1243 UNBLOCK_INPUT;
1220 } 1244 }
1221 1245
1222 f->name = name; 1246 f->name = name;
1223 } 1247 }
1290 = XCreateBitmapFromData (x_current_display, ROOT_WINDOW, 1314 = XCreateBitmapFromData (x_current_display, ROOT_WINDOW,
1291 (char *) stipple, width, height); 1315 (char *) stipple, width, height);
1292 gc_mask |= GCStipple; 1316 gc_mask |= GCStipple;
1293 } 1317 }
1294 1318
1295 temp_gc = XCreateGC (x_current_display, scr->display.x->window_desc, 1319 temp_gc = XCreateGC (x_current_display, FRAME_X_WINDOW (scr),
1296 gc_mask, &gc_values); 1320 gc_mask, &gc_values);
1297 if (!temp_gc) 1321 if (!temp_gc)
1298 return 1; 1322 return 1;
1299 new_face = (struct face *) xmalloc (sizeof (struct face)); 1323 new_face = (struct face *) xmalloc (sizeof (struct face));
1300 if (!new_face) 1324 if (!new_face)
1335 int fg, bg; 1359 int fg, bg;
1336 GC temp_gc; 1360 GC temp_gc;
1337 XGCValues gc_values; 1361 XGCValues gc_values;
1338 1362
1339 /* Need to do something about this. */ 1363 /* Need to do something about this. */
1340 Drawable drawable = selected_frame->display.x->window_desc; 1364 Drawable drawable = FRAME_X_WINDOW (selected_frame);
1341 1365
1342 CHECK_NUMBER (face_code, 1); 1366 CHECK_NUMBER (face_code, 1);
1343 CHECK_STRING (font_name, 2); 1367 CHECK_STRING (font_name, 2);
1344 1368
1345 if (EQ (foreground, Qnil) || EQ (background, Qnil)) 1369 if (EQ (foreground, Qnil) || EQ (background, Qnil))
1834 | CWBackingStore | CWSaveUnder 1858 | CWBackingStore | CWSaveUnder
1835 #endif 1859 #endif
1836 | CWEventMask); 1860 | CWEventMask);
1837 1861
1838 BLOCK_INPUT; 1862 BLOCK_INPUT;
1839 f->display.x->window_desc 1863 FRAME_X_WINDOW (f)
1840 = XCreateWindow (x_current_display, ROOT_WINDOW, 1864 = XCreateWindow (x_current_display, ROOT_WINDOW,
1841 f->display.x->left_pos, 1865 f->display.x->left_pos,
1842 f->display.x->top_pos, 1866 f->display.x->top_pos,
1843 PIXEL_WIDTH (f), PIXEL_HEIGHT (f), 1867 PIXEL_WIDTH (f), PIXEL_HEIGHT (f),
1844 f->display.x->border_width, 1868 f->display.x->border_width,
1847 screen_visual, /* set in Fx_open_connection */ 1871 screen_visual, /* set in Fx_open_connection */
1848 attribute_mask, &attributes); 1872 attribute_mask, &attributes);
1849 1873
1850 class_hints.res_name = (char *) XSTRING (f->name)->data; 1874 class_hints.res_name = (char *) XSTRING (f->name)->data;
1851 class_hints.res_class = EMACS_CLASS; 1875 class_hints.res_class = EMACS_CLASS;
1852 XSetClassHint (x_current_display, f->display.x->window_desc, &class_hints); 1876 XSetClassHint (x_current_display, FRAME_X_WINDOW (f), &class_hints);
1853 1877
1854 /* x_set_name normally ignores requests to set the name if the 1878 /* x_set_name normally ignores requests to set the name if the
1855 requested name is the same as the current name. This is the one 1879 requested name is the same as the current name. This is the one
1856 place where that assumption isn't correct; f->name is set, but 1880 place where that assumption isn't correct; f->name is set, but
1857 the X server hasn't been told. */ 1881 the X server hasn't been told. */
1860 1884
1861 f->name = Qnil; 1885 f->name = Qnil;
1862 x_implicitly_set_name (f, name, Qnil); 1886 x_implicitly_set_name (f, name, Qnil);
1863 } 1887 }
1864 1888
1865 XDefineCursor (XDISPLAY f->display.x->window_desc, 1889 XDefineCursor (XDISPLAY FRAME_X_WINDOW (f),
1866 f->display.x->text_cursor); 1890 f->display.x->text_cursor);
1867 UNBLOCK_INPUT; 1891 UNBLOCK_INPUT;
1868 1892
1869 if (f->display.x->window_desc == 0) 1893 if (FRAME_X_WINDOW (f) == 0)
1870 error ("Unable to create window."); 1894 error ("Unable to create window.");
1871 } 1895 }
1872 1896
1873 /* Handle the icon stuff for this window. Perhaps later we might 1897 /* Handle the icon stuff for this window. Perhaps later we might
1874 want an x_set_icon_position which can be called interactively as 1898 want an x_set_icon_position which can be called interactively as
1890 CHECK_NUMBER (icon_x, 0); 1914 CHECK_NUMBER (icon_x, 0);
1891 CHECK_NUMBER (icon_y, 0); 1915 CHECK_NUMBER (icon_y, 0);
1892 } 1916 }
1893 else if (!EQ (icon_x, Qunbound) || !EQ (icon_y, Qunbound)) 1917 else if (!EQ (icon_x, Qunbound) || !EQ (icon_y, Qunbound))
1894 error ("Both left and top icon corners of icon must be specified"); 1918 error ("Both left and top icon corners of icon must be specified");
1895 else
1896 {
1897 XSET (icon_x, Lisp_Int, f->display.x->left_pos);
1898 XSET (icon_y, Lisp_Int, f->display.x->top_pos);
1899 }
1900 1919
1901 BLOCK_INPUT; 1920 BLOCK_INPUT;
1902 1921
1903 x_wm_set_icon_position (f, XINT (icon_x), XINT (icon_y)); 1922 if (! EQ (icon_x, Qunbound))
1923 x_wm_set_icon_position (f, XINT (icon_x), XINT (icon_y));
1904 1924
1905 /* Start up iconic or window? */ 1925 /* Start up iconic or window? */
1906 x_wm_set_window_state (f, 1926 x_wm_set_window_state (f,
1907 (EQ (x_get_arg (parms, Qiconic_startup, 0, boolean), 1927 (EQ (x_get_arg (parms, Qiconic_startup, 0, boolean),
1908 Qt) 1928 Qt)
1939 gc_values.font = f->display.x->font->fid; 1959 gc_values.font = f->display.x->font->fid;
1940 gc_values.foreground = f->display.x->foreground_pixel; 1960 gc_values.foreground = f->display.x->foreground_pixel;
1941 gc_values.background = f->display.x->background_pixel; 1961 gc_values.background = f->display.x->background_pixel;
1942 gc_values.line_width = 0; /* Means 1 using fast algorithm. */ 1962 gc_values.line_width = 0; /* Means 1 using fast algorithm. */
1943 f->display.x->normal_gc = XCreateGC (x_current_display, 1963 f->display.x->normal_gc = XCreateGC (x_current_display,
1944 f->display.x->window_desc, 1964 FRAME_X_WINDOW (f),
1945 GCLineWidth | GCFont 1965 GCLineWidth | GCFont
1946 | GCForeground | GCBackground, 1966 | GCForeground | GCBackground,
1947 &gc_values); 1967 &gc_values);
1948 1968
1949 /* Reverse video style. */ 1969 /* Reverse video style. */
1950 gc_values.foreground = f->display.x->background_pixel; 1970 gc_values.foreground = f->display.x->background_pixel;
1951 gc_values.background = f->display.x->foreground_pixel; 1971 gc_values.background = f->display.x->foreground_pixel;
1952 f->display.x->reverse_gc = XCreateGC (x_current_display, 1972 f->display.x->reverse_gc = XCreateGC (x_current_display,
1953 f->display.x->window_desc, 1973 FRAME_X_WINDOW (f),
1954 GCFont | GCForeground | GCBackground 1974 GCFont | GCForeground | GCBackground
1955 | GCLineWidth, 1975 | GCLineWidth,
1956 &gc_values); 1976 &gc_values);
1957 1977
1958 /* Cursor has cursor-color background, background-color foreground. */ 1978 /* Cursor has cursor-color background, background-color foreground. */
1961 gc_values.fill_style = FillOpaqueStippled; 1981 gc_values.fill_style = FillOpaqueStippled;
1962 gc_values.stipple 1982 gc_values.stipple
1963 = XCreateBitmapFromData (x_current_display, ROOT_WINDOW, 1983 = XCreateBitmapFromData (x_current_display, ROOT_WINDOW,
1964 cursor_bits, 16, 16); 1984 cursor_bits, 16, 16);
1965 f->display.x->cursor_gc 1985 f->display.x->cursor_gc
1966 = XCreateGC (x_current_display, f->display.x->window_desc, 1986 = XCreateGC (x_current_display, FRAME_X_WINDOW (f),
1967 (GCFont | GCForeground | GCBackground 1987 (GCFont | GCForeground | GCBackground
1968 | GCFillStyle | GCStipple | GCLineWidth), 1988 | GCFillStyle | GCStipple | GCLineWidth),
1969 &gc_values); 1989 &gc_values);
1970 1990
1971 /* Create the gray border tile used when the pointer is not in 1991 /* Create the gray border tile used when the pointer is not in
2218 WINDOWINFO_TYPE wininfo; 2238 WINDOWINFO_TYPE wininfo;
2219 int nchildren; 2239 int nchildren;
2220 Window *children, root; 2240 Window *children, root;
2221 2241
2222 CHECK_NUMBER (tem, 0); 2242 CHECK_NUMBER (tem, 0);
2223 f->display.x->window_desc = (Window) XINT (tem); 2243 FRAME_X_WINDOW (f) = (Window) XINT (tem);
2224 2244
2225 BLOCK_INPUT; 2245 BLOCK_INPUT;
2226 XGetWindowInfo (f->display.x->window_desc, &wininfo); 2246 XGetWindowInfo (FRAME_X_WINDOW (f), &wininfo);
2227 XQueryTree (f->display.x->window_desc, &parent, &nchildren, &children); 2247 XQueryTree (FRAME_X_WINDOW (f), &parent, &nchildren, &children);
2228 free (children); 2248 free (children);
2229 UNBLOCK_INPUT; 2249 UNBLOCK_INPUT;
2230 2250
2231 height = (wininfo.height - 2 * f->display.x->internal_border_width) 2251 height = (wininfo.height - 2 * f->display.x->internal_border_width)
2232 / FONT_HEIGHT (f->display.x->font); 2252 / FONT_HEIGHT (f->display.x->font);
2306 pixelheight = (height * FONT_HEIGHT (f->display.x->font) 2326 pixelheight = (height * FONT_HEIGHT (f->display.x->font)
2307 + 2 * f->display.x->internal_border_width 2327 + 2 * f->display.x->internal_border_width
2308 + (!NILP (hscroll) ? HSCROLL_HEIGHT : 0)); 2328 + (!NILP (hscroll) ? HSCROLL_HEIGHT : 0));
2309 2329
2310 BLOCK_INPUT; 2330 BLOCK_INPUT;
2311 f->display.x->window_desc 2331 FRAME_X_WINDOW (f)
2312 = XCreateWindow (parent, 2332 = XCreateWindow (parent,
2313 f->display.x->left_pos, /* Absolute horizontal offset */ 2333 f->display.x->left_pos, /* Absolute horizontal offset */
2314 f->display.x->top_pos, /* Absolute Vertical offset */ 2334 f->display.x->top_pos, /* Absolute Vertical offset */
2315 pixelwidth, pixelheight, 2335 pixelwidth, pixelheight,
2316 f->display.x->border_width, 2336 f->display.x->border_width,
2317 BLACK_PIX_DEFAULT, WHITE_PIX_DEFAULT); 2337 BLACK_PIX_DEFAULT, WHITE_PIX_DEFAULT);
2318 UNBLOCK_INPUT; 2338 UNBLOCK_INPUT;
2319 if (f->display.x->window_desc == 0) 2339 if (FRAME_X_WINDOW (f) == 0)
2320 error ("Unable to create window."); 2340 error ("Unable to create window.");
2321 } 2341 }
2322 2342
2323 /* Install the now determined height and width 2343 /* Install the now determined height and width
2324 in the windows and in phys_lines and desired_lines. */ 2344 in the windows and in phys_lines and desired_lines. */
2325 change_frame_size (f, height, width, 1, 0); 2345 change_frame_size (f, height, width, 1, 0);
2326 XSelectInput (f->display.x->window_desc, KeyPressed | ExposeWindow 2346 XSelectInput (FRAME_X_WINDOW (f), KeyPressed | ExposeWindow
2327 | ButtonPressed | ButtonReleased | ExposeRegion | ExposeCopy 2347 | ButtonPressed | ButtonReleased | ExposeRegion | ExposeCopy
2328 | EnterWindow | LeaveWindow | UnmapWindow ); 2348 | EnterWindow | LeaveWindow | UnmapWindow );
2329 x_set_resize_hint (f); 2349 x_set_resize_hint (f);
2330 2350
2331 /* Tell the server the window's default name. */ 2351 /* Tell the server the window's default name. */
2332 XStoreName (XDISPLAY f->display.x->window_desc, XSTRING (f->name)->data); 2352 XStoreName (XDISPLAY FRAME_X_WINDOW (f), XSTRING (f->name)->data);
2333 2353
2334 /* Now override the defaults with all the rest of the specified 2354 /* Now override the defaults with all the rest of the specified
2335 parms. */ 2355 parms. */
2336 tem = x_get_arg (parms, Qunsplittable, 0, boolean); 2356 tem = x_get_arg (parms, Qunsplittable, 0, boolean);
2337 f->no_split = minibuffer_only || EQ (tem, Qt); 2357 f->no_split = minibuffer_only || EQ (tem, Qt);
2347 2367
2348 /* Tell the X server the previously set values of the 2368 /* Tell the X server the previously set values of the
2349 background, border and mouse colors; also create the mouse cursor. */ 2369 background, border and mouse colors; also create the mouse cursor. */
2350 BLOCK_INPUT; 2370 BLOCK_INPUT;
2351 temp = XMakeTile (f->display.x->background_pixel); 2371 temp = XMakeTile (f->display.x->background_pixel);
2352 XChangeBackground (f->display.x->window_desc, temp); 2372 XChangeBackground (FRAME_X_WINDOW (f), temp);
2353 XFreePixmap (temp); 2373 XFreePixmap (temp);
2354 UNBLOCK_INPUT; 2374 UNBLOCK_INPUT;
2355 x_set_border_pixel (f, f->display.x->border_pixel); 2375 x_set_border_pixel (f, f->display.x->border_pixel);
2356 2376
2357 x_set_mouse_color (f, Qnil, Qnil); 2377 x_set_mouse_color (f, Qnil, Qnil);
2493 struct frame *f; 2513 struct frame *f;
2494 Lisp_Object val, oldval; 2514 Lisp_Object val, oldval;
2495 { 2515 {
2496 if (!NILP (val)) 2516 if (!NILP (val))
2497 { 2517 {
2498 if (f->display.x->window_desc != 0) 2518 if (FRAME_X_WINDOW (f) != 0)
2499 { 2519 {
2500 BLOCK_INPUT; 2520 BLOCK_INPUT;
2501 f->display.x->h_scrollbar_height = HSCROLL_HEIGHT; 2521 f->display.x->h_scrollbar_height = HSCROLL_HEIGHT;
2502 x_set_window_size (f, f->width, f->height); 2522 x_set_window_size (f, f->width, f->height);
2503 install_horizontal_scrollbar (f); 2523 install_horizontal_scrollbar (f);
2527 struct frame *f; 2547 struct frame *f;
2528 Lisp_Object val, oldval; 2548 Lisp_Object val, oldval;
2529 { 2549 {
2530 if (!NILP (val)) 2550 if (!NILP (val))
2531 { 2551 {
2532 if (f->display.x->window_desc != 0) 2552 if (FRAME_X_WINDOW (f) != 0)
2533 { 2553 {
2534 BLOCK_INPUT; 2554 BLOCK_INPUT;
2535 f->display.x->v_scrollbar_width = VSCROLL_WIDTH; 2555 f->display.x->v_scrollbar_width = VSCROLL_WIDTH;
2536 x_set_window_size (f, f->width, f->height); 2556 x_set_window_size (f, f->width, f->height);
2537 install_vertical_scrollbar (f); 2557 install_vertical_scrollbar (f);
2571 pix_y = ibw / 2; 2591 pix_y = ibw / 2;
2572 border = 1; 2592 border = 1;
2573 2593
2574 #ifdef HAVE_X11 2594 #ifdef HAVE_X11
2575 up_arrow_pixmap = 2595 up_arrow_pixmap =
2576 XCreatePixmapFromBitmapData (x_current_display, f->display.x->window_desc, 2596 XCreatePixmapFromBitmapData (x_current_display, FRAME_X_WINDOW (f),
2577 up_arrow_bits, 16, 16, 2597 up_arrow_bits, 16, 16,
2578 f->display.x->foreground_pixel, 2598 f->display.x->foreground_pixel,
2579 f->display.x->background_pixel, 2599 f->display.x->background_pixel,
2580 DefaultDepth (x_current_display, 2600 DefaultDepth (x_current_display,
2581 XDefaultScreen (x_current_display))); 2601 XDefaultScreen (x_current_display)));
2582 2602
2583 down_arrow_pixmap = 2603 down_arrow_pixmap =
2584 XCreatePixmapFromBitmapData (x_current_display, f->display.x->window_desc, 2604 XCreatePixmapFromBitmapData (x_current_display, FRAME_X_WINDOW (f),
2585 down_arrow_bits, 16, 16, 2605 down_arrow_bits, 16, 16,
2586 f->display.x->foreground_pixel, 2606 f->display.x->foreground_pixel,
2587 f->display.x->background_pixel, 2607 f->display.x->background_pixel,
2588 DefaultDepth (x_current_display, 2608 DefaultDepth (x_current_display,
2589 XDefaultScreen (x_current_display))); 2609 XDefaultScreen (x_current_display)));
2590 2610
2591 slider_pixmap = 2611 slider_pixmap =
2592 XCreatePixmapFromBitmapData (x_current_display, f->display.x->window_desc, 2612 XCreatePixmapFromBitmapData (x_current_display, FRAME_X_WINDOW (f),
2593 gray_bits, 16, 16, 2613 gray_bits, 16, 16,
2594 f->display.x->foreground_pixel, 2614 f->display.x->foreground_pixel,
2595 f->display.x->background_pixel, 2615 f->display.x->background_pixel,
2596 DefaultDepth (x_current_display, 2616 DefaultDepth (x_current_display,
2597 XDefaultScreen (x_current_display))); 2617 XDefaultScreen (x_current_display)));
2602 up_arrow_cursor = XCreateFontCursor (x_current_display, XC_sb_up_arrow); 2622 up_arrow_cursor = XCreateFontCursor (x_current_display, XC_sb_up_arrow);
2603 down_arrow_cursor = XCreateFontCursor (x_current_display, XC_sb_down_arrow); 2623 down_arrow_cursor = XCreateFontCursor (x_current_display, XC_sb_down_arrow);
2604 v_double_arrow_cursor = XCreateFontCursor (x_current_display, XC_sb_v_double_arrow); 2624 v_double_arrow_cursor = XCreateFontCursor (x_current_display, XC_sb_v_double_arrow);
2605 2625
2606 f->display.x->v_scrollbar = 2626 f->display.x->v_scrollbar =
2607 XCreateSimpleWindow (x_current_display, f->display.x->window_desc, 2627 XCreateSimpleWindow (x_current_display, FRAME_X_WINDOW (f),
2608 pix_x, pix_y, width, height, border, 2628 pix_x, pix_y, width, height, border,
2609 f->display.x->foreground_pixel, 2629 f->display.x->foreground_pixel,
2610 f->display.x->background_pixel); 2630 f->display.x->background_pixel);
2611 XFlush (x_current_display); 2631 XFlush (x_current_display);
2612 XDefineCursor (x_current_display, f->display.x->v_scrollbar, 2632 XDefineCursor (x_current_display, f->display.x->v_scrollbar,
2717 f->display.x->background_pixel); 2737 f->display.x->background_pixel);
2718 XFreeBitmap (b); 2738 XFreeBitmap (b);
2719 2739
2720 ibw = f->display.x->internal_border_width; 2740 ibw = f->display.x->internal_border_width;
2721 2741
2722 f->display.x->v_scrollbar = XCreateWindow (f->display.x->window_desc, 2742 f->display.x->v_scrollbar = XCreateWindow (FRAME_X_WINDOW (f),
2723 width - VSCROLL_WIDTH - ibw/2, 2743 width - VSCROLL_WIDTH - ibw/2,
2724 ibw/2, 2744 ibw/2,
2725 VSCROLL_WIDTH - 2, 2745 VSCROLL_WIDTH - 2,
2726 height - ibw - 2, 2746 height - ibw - 2,
2727 1, bord_tile, back_tile); 2747 1, bord_tile, back_tile);
2785 if (f->display.x->v_scrollbar_width) 2805 if (f->display.x->v_scrollbar_width)
2786 width -= (f->display.x->v_scrollbar_width + 1); 2806 width -= (f->display.x->v_scrollbar_width + 1);
2787 2807
2788 #ifdef HAVE_X11 2808 #ifdef HAVE_X11
2789 left_arrow_pixmap = 2809 left_arrow_pixmap =
2790 XCreatePixmapFromBitmapData (x_current_display, f->display.x->window_desc, 2810 XCreatePixmapFromBitmapData (x_current_display, FRAME_X_WINDOW (f),
2791 left_arrow_bits, 16, 16, 2811 left_arrow_bits, 16, 16,
2792 f->display.x->foreground_pixel, 2812 f->display.x->foreground_pixel,
2793 f->display.x->background_pixel, 2813 f->display.x->background_pixel,
2794 DefaultDepth (x_current_display, 2814 DefaultDepth (x_current_display,
2795 XDefaultScreen (x_current_display))); 2815 XDefaultScreen (x_current_display)));
2796 2816
2797 right_arrow_pixmap = 2817 right_arrow_pixmap =
2798 XCreatePixmapFromBitmapData (x_current_display, f->display.x->window_desc, 2818 XCreatePixmapFromBitmapData (x_current_display, FRAME_X_WINDOW (f),
2799 right_arrow_bits, 16, 16, 2819 right_arrow_bits, 16, 16,
2800 f->display.x->foreground_pixel, 2820 f->display.x->foreground_pixel,
2801 f->display.x->background_pixel, 2821 f->display.x->background_pixel,
2802 DefaultDepth (x_current_display, 2822 DefaultDepth (x_current_display,
2803 XDefaultScreen (x_current_display))); 2823 XDefaultScreen (x_current_display)));
2804 2824
2805 slider_pixmap = 2825 slider_pixmap =
2806 XCreatePixmapFromBitmapData (x_current_display, f->display.x->window_desc, 2826 XCreatePixmapFromBitmapData (x_current_display, FRAME_X_WINDOW (f),
2807 gray_bits, 16, 16, 2827 gray_bits, 16, 16,
2808 f->display.x->foreground_pixel, 2828 f->display.x->foreground_pixel,
2809 f->display.x->background_pixel, 2829 f->display.x->background_pixel,
2810 DefaultDepth (x_current_display, 2830 DefaultDepth (x_current_display,
2811 XDefaultScreen (x_current_display))); 2831 XDefaultScreen (x_current_display)));
2813 left_arrow_cursor = XCreateFontCursor (x_current_display, XC_sb_left_arrow); 2833 left_arrow_cursor = XCreateFontCursor (x_current_display, XC_sb_left_arrow);
2814 right_arrow_cursor = XCreateFontCursor (x_current_display, XC_sb_right_arrow); 2834 right_arrow_cursor = XCreateFontCursor (x_current_display, XC_sb_right_arrow);
2815 h_double_arrow_cursor = XCreateFontCursor (x_current_display, XC_sb_h_double_arrow); 2835 h_double_arrow_cursor = XCreateFontCursor (x_current_display, XC_sb_h_double_arrow);
2816 2836
2817 f->display.x->h_scrollbar = 2837 f->display.x->h_scrollbar =
2818 XCreateSimpleWindow (x_current_display, f->display.x->window_desc, 2838 XCreateSimpleWindow (x_current_display, FRAME_X_WINDOW (f),
2819 pix_x, pix_y, 2839 pix_x, pix_y,
2820 width - ibw - 2, HSCROLL_HEIGHT - 2, 1, 2840 width - ibw - 2, HSCROLL_HEIGHT - 2, 1,
2821 f->display.x->foreground_pixel, 2841 f->display.x->foreground_pixel,
2822 f->display.x->background_pixel); 2842 f->display.x->background_pixel);
2823 XDefineCursor (x_current_display, f->display.x->h_scrollbar, 2843 XDefineCursor (x_current_display, f->display.x->h_scrollbar,
3119 if (lines < 0) 3139 if (lines < 0)
3120 height = FONT_HEIGHT (f->display.x->font) / 2; 3140 height = FONT_HEIGHT (f->display.x->font) / 2;
3121 else 3141 else
3122 height = FONT_HEIGHT (f->display.x->font) * lines; 3142 height = FONT_HEIGHT (f->display.x->font) * lines;
3123 3143
3124 XDrawRectangle (x_current_display, f->display.x->window_desc, 3144 XDrawRectangle (x_current_display, FRAME_X_WINDOW (f),
3125 gc, left, top, width, height); 3145 gc, left, top, width, height);
3126 } 3146 }
3127 3147
3128 DEFUN ("x-draw-rectangle", Fx_draw_rectangle, Sx_draw_rectangle, 5, 5, 0, 3148 DEFUN ("x-draw-rectangle", Fx_draw_rectangle, Sx_draw_rectangle, 5, 5, 0,
3129 "Draw a rectangle on FRAME between coordinates specified by\n\ 3149 "Draw a rectangle on FRAME between coordinates specified by\n\
3300 this_point->y = (this_point - 1)->y; 3320 this_point->y = (this_point - 1)->y;
3301 this_point++; 3321 this_point++;
3302 this_point->x = pixel_points->x; 3322 this_point->x = pixel_points->x;
3303 this_point->y = pixel_points->y; 3323 this_point->y = pixel_points->y;
3304 3324
3305 XDrawLines (x_current_display, f->display.x->window_desc, 3325 XDrawLines (x_current_display, FRAME_X_WINDOW (f),
3306 gc, pixel_points, 3326 gc, pixel_points,
3307 (this_point - pixel_points + 1), CoordModeOrigin); 3327 (this_point - pixel_points + 1), CoordModeOrigin);
3308 } 3328 }
3309 3329
3310 DEFUN ("x-contour-region", Fx_contour_region, Sx_contour_region, 1, 1, 0, 3330 DEFUN ("x-contour-region", Fx_contour_region, Sx_contour_region, 1, 1, 0,
3590 gc_values.line_width = 1; 3610 gc_values.line_width = 1;
3591 gc_values.line_style = LineOnOffDash; 3611 gc_values.line_style = LineOnOffDash;
3592 gc_values.cap_style = CapRound; 3612 gc_values.cap_style = CapRound;
3593 gc_values.join_style = JoinRound; 3613 gc_values.join_style = JoinRound;
3594 3614
3595 line_gc = XCreateGC (x_current_display, f->display.x->window_desc, 3615 line_gc = XCreateGC (x_current_display, FRAME_X_WINDOW (f),
3596 GCLineStyle | GCJoinStyle | GCCapStyle 3616 GCLineStyle | GCJoinStyle | GCCapStyle
3597 | GCLineWidth | GCForeground | GCBackground, 3617 | GCLineWidth | GCForeground | GCBackground,
3598 &gc_values); 3618 &gc_values);
3599 XSetDashes (x_current_display, line_gc, 0, dash_list, dashes); 3619 XSetDashes (x_current_display, line_gc, 0, dash_list, dashes);
3600 gc_values.foreground = f->display.x->background_pixel; 3620 gc_values.foreground = f->display.x->background_pixel;
3601 gc_values.background = f->display.x->foreground_pixel; 3621 gc_values.background = f->display.x->foreground_pixel;
3602 erase_gc = XCreateGC (x_current_display, f->display.x->window_desc, 3622 erase_gc = XCreateGC (x_current_display, FRAME_X_WINDOW (f),
3603 GCLineStyle | GCJoinStyle | GCCapStyle 3623 GCLineStyle | GCJoinStyle | GCCapStyle
3604 | GCLineWidth | GCForeground | GCBackground, 3624 | GCLineWidth | GCForeground | GCBackground,
3605 &gc_values); 3625 &gc_values);
3606 XSetDashes (x_current_display, erase_gc, 0, dash_list, dashes); 3626 XSetDashes (x_current_display, erase_gc, 0, dash_list, dashes);
3607 #endif 3627 #endif
3613 && x_mouse_y < XINT (w->top) + XINT (w->height) - 1) 3633 && x_mouse_y < XINT (w->top) + XINT (w->height) - 1)
3614 { 3634 {
3615 previous_y = x_mouse_y; 3635 previous_y = x_mouse_y;
3616 line = (x_mouse_y + 1) * FONT_HEIGHT (f->display.x->font) 3636 line = (x_mouse_y + 1) * FONT_HEIGHT (f->display.x->font)
3617 + f->display.x->internal_border_width; 3637 + f->display.x->internal_border_width;
3618 XDrawLine (x_current_display, f->display.x->window_desc, 3638 XDrawLine (x_current_display, FRAME_X_WINDOW (f),
3619 line_gc, left, line, right, line); 3639 line_gc, left, line, right, line);
3620 } 3640 }
3621 XFlushQueue (); 3641 XFlushQueue ();
3622 UNBLOCK_INPUT; 3642 UNBLOCK_INPUT;
3623 3643
3628 || (! EQ (Fcar (Fcdr (Fcdr (obj))), 3648 || (! EQ (Fcar (Fcdr (Fcdr (obj))),
3629 Qvertical_scroll_bar)) 3649 Qvertical_scroll_bar))
3630 || x_mouse_grabbed) 3650 || x_mouse_grabbed)
3631 { 3651 {
3632 BLOCK_INPUT; 3652 BLOCK_INPUT;
3633 XDrawLine (x_current_display, f->display.x->window_desc, 3653 XDrawLine (x_current_display, FRAME_X_WINDOW (f),
3634 erase_gc, left, line, right, line); 3654 erase_gc, left, line, right, line);
3635 UNBLOCK_INPUT; 3655 UNBLOCK_INPUT;
3636 unread_command_char = obj; 3656 unread_command_char = obj;
3637 #if 0 3657 #if 0
3638 XFreeGC (x_current_display, line_gc); 3658 XFreeGC (x_current_display, line_gc);
3642 } 3662 }
3643 } 3663 }
3644 while (x_mouse_y == previous_y); 3664 while (x_mouse_y == previous_y);
3645 3665
3646 BLOCK_INPUT; 3666 BLOCK_INPUT;
3647 XDrawLine (x_current_display, f->display.x->window_desc, 3667 XDrawLine (x_current_display, FRAME_X_WINDOW (f),
3648 erase_gc, left, line, right, line); 3668 erase_gc, left, line, right, line);
3649 UNBLOCK_INPUT; 3669 UNBLOCK_INPUT;
3650 } 3670 }
3651 } 3671 }
3652 #endif 3672 #endif
3672 unsigned char c; 3692 unsigned char c;
3673 struct buffer *buf; 3693 struct buffer *buf;
3674 3694
3675 current_pointer_shape = f->display.x->nontext_cursor; 3695 current_pointer_shape = f->display.x->nontext_cursor;
3676 XDefineCursor (x_current_display, 3696 XDefineCursor (x_current_display,
3677 f->display.x->window_desc, 3697 FRAME_X_WINDOW (f),
3678 current_pointer_shape); 3698 current_pointer_shape);
3679 3699
3680 buf = XBUFFER (XWINDOW (Vmouse_window)->buffer); 3700 buf = XBUFFER (XWINDOW (Vmouse_window)->buffer);
3681 c = *(BUF_CHAR_ADDRESS (buf, mouse_buffer_offset)); 3701 c = *(BUF_CHAR_ADDRESS (buf, mouse_buffer_offset));
3682 } 3702 }
3683 else if (EQ (Vmouse_frame_part, Qmodeline_part) 3703 else if (EQ (Vmouse_frame_part, Qmodeline_part)
3684 && (current_pointer_shape != f->display.x->modeline_cursor)) 3704 && (current_pointer_shape != f->display.x->modeline_cursor))
3685 { 3705 {
3686 current_pointer_shape = f->display.x->modeline_cursor; 3706 current_pointer_shape = f->display.x->modeline_cursor;
3687 XDefineCursor (x_current_display, 3707 XDefineCursor (x_current_display,
3688 f->display.x->window_desc, 3708 FRAME_X_WINDOW (f),
3689 current_pointer_shape); 3709 current_pointer_shape);
3690 } 3710 }
3691 3711
3692 XFlushQueue (); 3712 XFlushQueue ();
3693 UNBLOCK_INPUT; 3713 UNBLOCK_INPUT;
3818 3838
3819 draw_or_not: 3839 draw_or_not:
3820 if (mouse_track_width) /* Over text; use text pointer shape. */ 3840 if (mouse_track_width) /* Over text; use text pointer shape. */
3821 { 3841 {
3822 XDefineCursor (x_current_display, 3842 XDefineCursor (x_current_display,
3823 f->display.x->window_desc, 3843 FRAME_X_WINDOW (f),
3824 f->display.x->text_cursor); 3844 f->display.x->text_cursor);
3825 x_rectangle (f, f->display.x->cursor_gc, 3845 x_rectangle (f, f->display.x->cursor_gc,
3826 mouse_track_left, mouse_track_top, 3846 mouse_track_left, mouse_track_top,
3827 mouse_track_width, 1); 3847 mouse_track_width, 1);
3828 } 3848 }
3829 else if (in_mode_line) 3849 else if (in_mode_line)
3830 XDefineCursor (x_current_display, 3850 XDefineCursor (x_current_display,
3831 f->display.x->window_desc, 3851 FRAME_X_WINDOW (f),
3832 f->display.x->modeline_cursor); 3852 f->display.x->modeline_cursor);
3833 else 3853 else
3834 XDefineCursor (x_current_display, 3854 XDefineCursor (x_current_display,
3835 f->display.x->window_desc, 3855 FRAME_X_WINDOW (f),
3836 f->display.x->nontext_cursor); 3856 f->display.x->nontext_cursor);
3837 } 3857 }
3838 3858
3839 XFlush (x_current_display); 3859 XFlush (x_current_display);
3840 UNBLOCK_INPUT; 3860 UNBLOCK_INPUT;
3862 { 3882 {
3863 x_display_cursor (f, 1); 3883 x_display_cursor (f, 1);
3864 } 3884 }
3865 } 3885 }
3866 XDefineCursor (x_current_display, 3886 XDefineCursor (x_current_display,
3867 f->display.x->window_desc, 3887 FRAME_X_WINDOW (f),
3868 f->display.x->nontext_cursor); 3888 f->display.x->nontext_cursor);
3869 XFlush (x_current_display); 3889 XFlush (x_current_display);
3870 UNBLOCK_INPUT; 3890 UNBLOCK_INPUT;
3871 3891
3872 return Qnil; 3892 return Qnil;
3885 char *image_data; 3905 char *image_data;
3886 { 3906 {
3887 Pixmap image; 3907 Pixmap image;
3888 3908
3889 image = XCreateBitmapFromData (x_current_display, 3909 image = XCreateBitmapFromData (x_current_display,
3890 f->display.x->window_desc, image_data, 3910 FRAME_X_WINDOW (f), image_data,
3891 width, height); 3911 width, height);
3892 XCopyPlane (x_current_display, image, f->display.x->window_desc, 3912 XCopyPlane (x_current_display, image, FRAME_X_WINDOW (f),
3893 f->display.x->normal_gc, 0, 0, width, height, x, y); 3913 f->display.x->normal_gc, 0, 0, width, height, x, y);
3894 } 3914 }
3895 #endif 3915 #endif
3896 3916
3897 #if 0 3917 #if 0
4316 Visual *v; 4336 Visual *v;
4317 XVisualInfo *vinfo, vinfo_template; 4337 XVisualInfo *vinfo, vinfo_template;
4318 int n_visuals; 4338 int n_visuals;
4319 4339
4320 v = DefaultVisualOfScreen (screen); 4340 v = DefaultVisualOfScreen (screen);
4321 /* It may be a bad idea to fetch the visualid directly from the structure, 4341
4322 rather than using XVisualIDFromVisual, but I'll bet this is pretty 4342 #ifdef HAVE_X11R4
4323 portable for the revisions of X we care about. */ 4343 vinfo_template.visualid = XVisualIDFromVisual (v);
4324 vinfo_template.visualid = v->visualid; 4344 #else
4345 vinfo_template.visualid = x->visualid;
4346 #endif
4347
4325 vinfo = XGetVisualInfo (x_current_display, VisualIDMask, &vinfo_template, 4348 vinfo = XGetVisualInfo (x_current_display, VisualIDMask, &vinfo_template,
4326 &n_visuals); 4349 &n_visuals);
4327 if (n_visuals != 1) 4350 if (n_visuals != 1)
4328 fatal ("Can't get proper X visual info"); 4351 fatal ("Can't get proper X visual info");
4329 4352