aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Blandy1992-08-29 03:25:25 +0000
committerJim Blandy1992-08-29 03:25:25 +0000
commitfe24a618befa69ef62f1d82f97d3d6c7a434367a (patch)
tree139104b4d2a3f9e242a329b4e5470df0be4db7f2
parent05c2896ac5b24f1c7f7ca18e76f59eb2291b9049 (diff)
downloademacs-fe24a618befa69ef62f1d82f97d3d6c7a434367a.tar.gz
emacs-fe24a618befa69ef62f1d82f97d3d6c7a434367a.zip
* 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].
-rw-r--r--src/xfns.c191
1 files changed, 107 insertions, 84 deletions
diff --git a/src/xfns.c b/src/xfns.c
index bedb229336f..d6db6e68747 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -280,7 +280,7 @@ x_window_to_frame (wdesc)
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 }
@@ -548,7 +548,7 @@ x_report_frame_params (f, alistptr)
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}
@@ -618,7 +618,7 @@ x_decode_color (arg, def)
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. */
@@ -629,7 +629,7 @@ x_set_foreground_color (f, arg, oldval)
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;
@@ -645,21 +645,21 @@ x_set_foreground_color (f, arg, oldval)
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,
@@ -689,7 +689,7 @@ x_set_foreground_color (f, arg, oldval)
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,
@@ -697,14 +697,14 @@ x_set_foreground_color (f, arg, oldval)
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,
@@ -743,7 +743,7 @@ x_set_background_color (f, arg, oldval)
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
@@ -752,7 +752,7 @@ x_set_background_color (f, arg, oldval)
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. */
@@ -764,21 +764,21 @@ x_set_background_color (f, arg, oldval)
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,
@@ -808,7 +808,7 @@ x_set_background_color (f, arg, oldval)
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,
@@ -816,14 +816,14 @@ x_set_background_color (f, arg, oldval)
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,
@@ -847,7 +847,7 @@ x_set_background_color (f, arg, oldval)
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;
@@ -875,6 +875,10 @@ x_set_mouse_color (f, arg, oldval)
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);
@@ -901,6 +905,10 @@ x_set_mouse_color (f, arg, oldval)
901 else 905 else
902 mode_cursor = XCreateFontCursor (x_current_display, XC_xterm); 906 mode_cursor = XCreateFontCursor (x_current_display, XC_xterm);
903 907
908 /* Check and report errors with the above calls. */
909 x_check_errors ("can't set cursor shape: %s");
910 x_uncatch_errors ();
911
904 { 912 {
905 XColor fore_color, back_color; 913 XColor fore_color, back_color;
906 914
@@ -929,9 +937,9 @@ x_set_mouse_color (f, arg, oldval)
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)
@@ -974,7 +982,7 @@ x_set_cursor_color (f, arg, oldval)
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;
@@ -1037,14 +1045,14 @@ x_set_border_pixel (f, 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,
@@ -1058,7 +1066,7 @@ x_set_border_pixel (f, pix)
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;
@@ -1094,7 +1102,7 @@ x_set_icon_type (f, arg, oldval)
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;
@@ -1129,7 +1137,7 @@ x_set_border_width (f, arg, oldval)
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);
@@ -1151,7 +1159,7 @@ x_set_internal_border_width (f, arg, oldval)
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);
@@ -1211,11 +1219,27 @@ x_set_name (f, name, explicit)
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
@@ -1292,7 +1316,7 @@ x_set_face (scr, font, background, foreground, stipple)
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;
@@ -1337,7 +1361,7 @@ DEFUN ("x-set-face-font", Fx_set_face_font, Sx_set_face_font, 4, 2, 0,
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);
@@ -1836,7 +1860,7 @@ x_window (f)
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,
@@ -1849,7 +1873,7 @@ x_window (f)
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
@@ -1862,11 +1886,11 @@ x_window (f)
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
@@ -1892,15 +1916,11 @@ x_icon (f, parms)
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,
@@ -1941,7 +1961,7 @@ x_make_gc (f)
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);
@@ -1950,7 +1970,7 @@ x_make_gc (f)
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);
@@ -1963,7 +1983,7 @@ x_make_gc (f)
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);
@@ -2220,11 +2240,11 @@ be shared by the new frame.")
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
@@ -2308,7 +2328,7 @@ be shared by the new frame.")
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 */
@@ -2316,20 +2336,20 @@ be shared by the new frame.")
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. */
@@ -2349,7 +2369,7 @@ be shared by the new frame.")
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);
@@ -2495,7 +2515,7 @@ x_set_horizontal_scrollbar (f, 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;
@@ -2529,7 +2549,7 @@ x_set_vertical_scrollbar (f, 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;
@@ -2573,7 +2593,7 @@ install_vertical_scrollbar (f)
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,
@@ -2581,7 +2601,7 @@ install_vertical_scrollbar (f)
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,
@@ -2589,7 +2609,7 @@ install_vertical_scrollbar (f)
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,
@@ -2604,7 +2624,7 @@ install_vertical_scrollbar (f)
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);
@@ -2719,7 +2739,7 @@ install_vertical_scrollbar (f)
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,
@@ -2787,7 +2807,7 @@ install_horizontal_scrollbar (f)
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,
@@ -2795,7 +2815,7 @@ install_horizontal_scrollbar (f)
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,
@@ -2803,7 +2823,7 @@ install_horizontal_scrollbar (f)
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,
@@ -2815,7 +2835,7 @@ install_horizontal_scrollbar (f)
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,
@@ -3121,7 +3141,7 @@ x_rectangle (f, gc, left_char, top_char, chars, lines)
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
@@ -3302,7 +3322,7 @@ outline_region (f, gc, top_x, top_y, bottom_x, bottom_y)
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}
@@ -3592,14 +3612,14 @@ DEFUN ("x-horizontal-line", Fx_horizontal_line, Sx_horizontal_line, 1, 1, "e",
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);
@@ -3615,7 +3635,7 @@ DEFUN ("x-horizontal-line", Fx_horizontal_line, Sx_horizontal_line, 1, 1, "e",
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 ();
@@ -3630,7 +3650,7 @@ DEFUN ("x-horizontal-line", Fx_horizontal_line, Sx_horizontal_line, 1, 1, "e",
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;
@@ -3644,7 +3664,7 @@ DEFUN ("x-horizontal-line", Fx_horizontal_line, Sx_horizontal_line, 1, 1, "e",
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 }
@@ -3674,7 +3694,7 @@ DEFUN ("x-track-pointer", Fx_track_pointer, Sx_track_pointer, 0, 0, 0,
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);
@@ -3685,7 +3705,7 @@ DEFUN ("x-track-pointer", Fx_track_pointer, Sx_track_pointer, 0, 0, 0,
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
@@ -3820,7 +3840,7 @@ DEFUN ("x-track-pointer", Fx_track_pointer, Sx_track_pointer, 1, 1, "e",
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,
@@ -3828,11 +3848,11 @@ DEFUN ("x-track-pointer", Fx_track_pointer, Sx_track_pointer, 1, 1, "e",
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
@@ -3864,7 +3884,7 @@ DEFUN ("x-track-pointer", Fx_track_pointer, Sx_track_pointer, 1, 1, "e",
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;
@@ -3887,9 +3907,9 @@ x_draw_pixmap (f, x, y, image_data, width, height)
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
@@ -4318,10 +4338,13 @@ select_visual (screen, depth)
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)