1 /* Functions for the X window system.
2 Copyright (C) 1989, 1992, 1993, 1994 Free Software Foundation.
4 This file is part of GNU Emacs.
6 GNU Emacs is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Emacs is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Emacs; see the file COPYING. If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
20 /* Completely rewritten by Richard Stallman. */
22 /* Rewritten for X11 by Joseph Arceneaux */
27 /* This makes the fields of a Display accessible, in Xlib header files. */
28 #define XLIB_ILLEGAL_ACCESS
35 #include "dispextern.h"
37 #include "blockinput.h"
44 #if 1 /* Used to be #ifdef EMACS_BITMAP_FILES, but this should always work. */
45 #include "bitmaps/gray.xbm"
47 #include <X11/bitmaps/gray>
50 #include "[.bitmaps]gray.xbm"
54 #include <X11/Shell.h>
56 #include <X11/Xaw/Paned.h>
57 #include <X11/Xaw/Label.h>
60 #undef USG /* ####KLUDGE for Solaris 2.2 and up */
69 #include "../lwlib/lwlib.h"
71 /* Do the EDITRES protocol if running X11R5 */
72 #if (XtSpecificationRelease >= 5)
74 extern void _XEditResCheckMessages ();
75 #endif /* R5 + Athena */
77 /* Unique id counter for widgets created by the Lucid Widget
79 extern LWLIB_ID widget_id_tick
;
81 /* This is part of a kludge--see lwlib/xlwmenu.c. */
82 XFontStruct
*xlwmenu_default_font
;
84 extern void free_frame_menubar ();
85 #endif /* USE_X_TOOLKIT */
87 #define min(a,b) ((a) < (b) ? (a) : (b))
88 #define max(a,b) ((a) > (b) ? (a) : (b))
91 #define MAXREQUEST(dpy) (XMaxRequestSize (dpy))
93 #define MAXREQUEST(dpy) ((dpy)->max_request_size)
96 /* The name we're using in resource queries. */
97 Lisp_Object Vx_resource_name
;
99 /* The background and shape of the mouse pointer, and shape when not
100 over text or in the modeline. */
101 Lisp_Object Vx_pointer_shape
, Vx_nontext_pointer_shape
, Vx_mode_pointer_shape
;
102 /* The shape when over mouse-sensitive text. */
103 Lisp_Object Vx_sensitive_text_pointer_shape
;
105 /* Color of chars displayed in cursor box. */
106 Lisp_Object Vx_cursor_fore_pixel
;
108 /* Nonzero if using X. */
111 /* Non nil if no window manager is in use. */
112 Lisp_Object Vx_no_window_manager
;
114 /* Search path for bitmap files. */
115 Lisp_Object Vx_bitmap_file_path
;
117 /* Evaluate this expression to rebuild the section of syms_of_xfns
118 that initializes and staticpros the symbols declared below. Note
119 that Emacs 18 has a bug that keeps C-x C-e from being able to
120 evaluate this expression.
123 ;; Accumulate a list of the symbols we want to initialize from the
124 ;; declarations at the top of the file.
125 (goto-char (point-min))
126 (search-forward "/\*&&& symbols declared here &&&*\/\n")
128 (while (looking-at "Lisp_Object \\(Q[a-z_]+\\)")
130 (cons (buffer-substring (match-beginning 1) (match-end 1))
133 (setq symbol-list (nreverse symbol-list))
134 ;; Delete the section of syms_of_... where we initialize the symbols.
135 (search-forward "\n /\*&&& init symbols here &&&*\/\n")
136 (let ((start (point)))
137 (while (looking-at "^ Q")
139 (kill-region start (point)))
140 ;; Write a new symbol initialization section.
142 (insert (format " %s = intern (\"" (car symbol-list)))
143 (let ((start (point)))
144 (insert (substring (car symbol-list) 1))
145 (subst-char-in-region start (point) ?_ ?-))
146 (insert (format "\");\n staticpro (&%s);\n" (car symbol-list)))
147 (setq symbol-list (cdr symbol-list)))))
151 /*&&& symbols declared here &&&*/
152 Lisp_Object Qauto_raise
;
153 Lisp_Object Qauto_lower
;
154 Lisp_Object Qbackground_color
;
156 Lisp_Object Qborder_color
;
157 Lisp_Object Qborder_width
;
159 Lisp_Object Qcursor_color
;
160 Lisp_Object Qcursor_type
;
162 Lisp_Object Qforeground_color
;
163 Lisp_Object Qgeometry
;
164 Lisp_Object Qicon_left
;
165 Lisp_Object Qicon_top
;
166 Lisp_Object Qicon_type
;
167 Lisp_Object Qinternal_border_width
;
169 Lisp_Object Qmouse_color
;
171 Lisp_Object Qparent_id
;
172 Lisp_Object Qscroll_bar_width
;
173 Lisp_Object Qsuppress_icon
;
175 Lisp_Object Qundefined_color
;
176 Lisp_Object Qvertical_scroll_bars
;
177 Lisp_Object Qvisibility
;
178 Lisp_Object Qwindow_id
;
179 Lisp_Object Qx_frame_parameter
;
180 Lisp_Object Qx_resource_name
;
181 Lisp_Object Quser_position
;
182 Lisp_Object Quser_size
;
183 Lisp_Object Qdisplay
;
185 /* The below are defined in frame.c. */
186 extern Lisp_Object Qheight
, Qminibuffer
, Qname
, Qonly
, Qwidth
;
187 extern Lisp_Object Qunsplittable
, Qmenu_bar_lines
;
189 extern Lisp_Object Vwindow_system_version
;
192 /* Error if we are not connected to X. */
197 error ("X windows are not in use or not initialized");
200 /* Nonzero if using X for display. */
208 /* Extract a frame as a FRAME_PTR, defaulting to the selected frame
209 and checking validity for X. */
212 check_x_frame (frame
)
221 CHECK_LIVE_FRAME (frame
, 0);
225 error ("non-X frame used");
229 /* Let the user specify an X display with a frame.
230 nil stands for the selected frame--or, if that is not an X frame,
231 the first X display on the list. */
233 static struct x_display_info
*
234 check_x_display_info (frame
)
239 if (FRAME_X_P (selected_frame
))
240 return FRAME_X_DISPLAY_INFO (selected_frame
);
241 else if (x_display_list
!= 0)
242 return x_display_list
;
244 error ("X windows are not in use or not initialized");
246 else if (STRINGP (frame
))
247 return x_display_info_for_name (frame
);
252 CHECK_LIVE_FRAME (frame
, 0);
255 error ("non-X frame used");
256 return FRAME_X_DISPLAY_INFO (f
);
260 /* Return the Emacs frame-object corresponding to an X window.
261 It could be the frame's main window or an icon window. */
263 /* This function can be called during GC, so use GC_xxx type test macros. */
266 x_window_to_frame (wdesc
)
269 Lisp_Object tail
, frame
;
272 for (tail
= Vframe_list
; GC_CONSP (tail
); tail
= XCONS (tail
)->cdr
)
274 frame
= XCONS (tail
)->car
;
275 if (!GC_FRAMEP (frame
))
279 if (f
->display
.nothing
== 1)
281 if ((f
->display
.x
->edit_widget
282 && XtWindow (f
->display
.x
->edit_widget
) == wdesc
)
283 || f
->display
.x
->icon_desc
== wdesc
)
285 #else /* not USE_X_TOOLKIT */
286 if (FRAME_X_WINDOW (f
) == wdesc
287 || f
->display
.x
->icon_desc
== wdesc
)
289 #endif /* not USE_X_TOOLKIT */
295 /* Like x_window_to_frame but also compares the window with the widget's
299 x_any_window_to_frame (wdesc
)
302 Lisp_Object tail
, frame
;
306 for (tail
= Vframe_list
; GC_CONSP (tail
); tail
= XCONS (tail
)->cdr
)
308 frame
= XCONS (tail
)->car
;
309 if (!GC_FRAMEP (frame
))
312 if (f
->display
.nothing
== 1)
315 /* This frame matches if the window is any of its widgets. */
316 if (wdesc
== XtWindow (x
->widget
)
317 || wdesc
== XtWindow (x
->column_widget
)
318 || wdesc
== XtWindow (x
->edit_widget
))
320 /* Match if the window is this frame's menubar. */
321 if (lw_window_is_in_menubar (wdesc
, x
->menubar_widget
))
327 /* Return the frame whose principal (outermost) window is WDESC.
328 If WDESC is some other (smaller) window, we return 0. */
331 x_top_window_to_frame (wdesc
)
334 Lisp_Object tail
, frame
;
338 for (tail
= Vframe_list
; GC_CONSP (tail
); tail
= XCONS (tail
)->cdr
)
340 frame
= XCONS (tail
)->car
;
341 if (!GC_FRAMEP (frame
))
344 if (f
->display
.nothing
== 1)
347 /* This frame matches if the window is its topmost widget. */
348 if (wdesc
== XtWindow (x
->widget
))
350 /* Match if the window is this frame's menubar. */
351 if (x
->menubar_widget
352 && wdesc
== XtWindow (x
->menubar_widget
))
357 #endif /* USE_X_TOOLKIT */
361 /* Code to deal with bitmaps. Bitmaps are referenced by their bitmap
362 id, which is just an int that this section returns. Bitmaps are
363 reference counted so they can be shared among frames.
365 Bitmap indices are guaranteed to be > 0, so a negative number can
366 be used to indicate no bitmap.
368 If you use x_create_bitmap_from_data, then you must keep track of
369 the bitmaps yourself. That is, creating a bitmap from the same
370 data more than once will not be caught. */
373 /* Functions to access the contents of a bitmap, given an id. */
376 x_bitmap_height (f
, id
)
380 return FRAME_X_DISPLAY_INFO (f
)->bitmaps
[id
- 1].height
;
384 x_bitmap_width (f
, id
)
388 return FRAME_X_DISPLAY_INFO (f
)->bitmaps
[id
- 1].width
;
392 x_bitmap_pixmap (f
, id
)
396 return FRAME_X_DISPLAY_INFO (f
)->bitmaps
[id
- 1].pixmap
;
400 /* Allocate a new bitmap record. Returns index of new record. */
403 x_allocate_bitmap_record (f
)
406 struct x_display_info
*dpyinfo
= FRAME_X_DISPLAY_INFO (f
);
409 if (dpyinfo
->bitmaps
== NULL
)
411 dpyinfo
->bitmaps_size
= 10;
413 = (struct x_bitmap_record
*) xmalloc (dpyinfo
->bitmaps_size
* sizeof (struct x_bitmap_record
));
414 dpyinfo
->bitmaps_last
= 1;
418 if (dpyinfo
->bitmaps_last
< dpyinfo
->bitmaps_size
)
419 return ++dpyinfo
->bitmaps_last
;
421 for (i
= 0; i
< dpyinfo
->bitmaps_size
; ++i
)
422 if (dpyinfo
->bitmaps
[i
].refcount
== 0)
425 dpyinfo
->bitmaps_size
*= 2;
427 = (struct x_bitmap_record
*) xrealloc (dpyinfo
->bitmaps
,
428 dpyinfo
->bitmaps_size
* sizeof (struct x_bitmap_record
));
429 return ++dpyinfo
->bitmaps_last
;
432 /* Add one reference to the reference count of the bitmap with id ID. */
435 x_reference_bitmap (f
, id
)
439 ++FRAME_X_DISPLAY_INFO (f
)->bitmaps
[id
- 1].refcount
;
442 /* Create a bitmap for frame F from a HEIGHT x WIDTH array of bits at BITS. */
445 x_create_bitmap_from_data (f
, bits
, width
, height
)
448 unsigned int width
, height
;
450 struct x_display_info
*dpyinfo
= FRAME_X_DISPLAY_INFO (f
);
454 bitmap
= XCreateBitmapFromData (FRAME_X_DISPLAY (f
), FRAME_X_WINDOW (f
),
455 bits
, width
, height
);
460 id
= x_allocate_bitmap_record (f
);
461 dpyinfo
->bitmaps
[id
- 1].pixmap
= bitmap
;
462 dpyinfo
->bitmaps
[id
- 1].file
= NULL
;
463 dpyinfo
->bitmaps
[id
- 1].refcount
= 1;
464 dpyinfo
->bitmaps
[id
- 1].depth
= 1;
465 dpyinfo
->bitmaps
[id
- 1].height
= height
;
466 dpyinfo
->bitmaps
[id
- 1].width
= width
;
471 /* Create bitmap from file FILE for frame F. */
474 x_create_bitmap_from_file (f
, file
)
478 struct x_display_info
*dpyinfo
= FRAME_X_DISPLAY_INFO (f
);
479 unsigned int width
, height
;
481 int xhot
, yhot
, result
, id
;
486 /* Look for an existing bitmap with the same name. */
487 for (id
= 0; id
< dpyinfo
->bitmaps_last
; ++id
)
489 if (dpyinfo
->bitmaps
[id
].refcount
490 && dpyinfo
->bitmaps
[id
].file
491 && !strcmp (dpyinfo
->bitmaps
[id
].file
, (char *) XSTRING (file
)->data
))
493 ++dpyinfo
->bitmaps
[id
].refcount
;
498 /* Search bitmap-file-path for the file, if appropriate. */
499 fd
= openp (Vx_bitmap_file_path
, file
, "", &found
, 0);
504 filename
= (char *) XSTRING (found
)->data
;
506 result
= XReadBitmapFile (FRAME_X_DISPLAY (f
), FRAME_X_WINDOW (f
),
507 filename
, &width
, &height
, &bitmap
, &xhot
, &yhot
);
508 if (result
!= BitmapSuccess
)
511 id
= x_allocate_bitmap_record (f
);
512 dpyinfo
->bitmaps
[id
- 1].pixmap
= bitmap
;
513 dpyinfo
->bitmaps
[id
- 1].refcount
= 1;
514 dpyinfo
->bitmaps
[id
- 1].file
= (char *) xmalloc (XSTRING (file
)->size
+ 1);
515 dpyinfo
->bitmaps
[id
- 1].depth
= 1;
516 dpyinfo
->bitmaps
[id
- 1].height
= height
;
517 dpyinfo
->bitmaps
[id
- 1].width
= width
;
518 strcpy (dpyinfo
->bitmaps
[id
- 1].file
, XSTRING (file
)->data
);
523 /* Remove reference to bitmap with id number ID. */
526 x_destroy_bitmap (f
, id
)
530 struct x_display_info
*dpyinfo
= FRAME_X_DISPLAY_INFO (f
);
534 --dpyinfo
->bitmaps
[id
- 1].refcount
;
535 if (dpyinfo
->bitmaps
[id
- 1].refcount
== 0)
537 XFreePixmap (FRAME_X_DISPLAY (f
), dpyinfo
->bitmaps
[id
- 1].pixmap
);
538 if (dpyinfo
->bitmaps
[id
- 1].file
)
540 free (dpyinfo
->bitmaps
[id
- 1].file
);
541 dpyinfo
->bitmaps
[id
- 1].file
= NULL
;
547 /* Free all the bitmaps for the display specified by DPYINFO. */
550 x_destroy_all_bitmaps (dpyinfo
)
551 struct x_display_info
*dpyinfo
;
554 for (i
= 0; i
< dpyinfo
->bitmaps_last
; i
++)
555 if (dpyinfo
->bitmaps
[i
].refcount
> 0)
557 XFreePixmap (dpyinfo
->display
, dpyinfo
->bitmaps
[i
].pixmap
);
558 if (dpyinfo
->bitmaps
[i
].file
)
559 free (dpyinfo
->bitmaps
[i
].file
);
561 dpyinfo
->bitmaps_last
= 0;
564 /* Connect the frame-parameter names for X frames
565 to the ways of passing the parameter values to the window system.
567 The name of a parameter, as a Lisp symbol,
568 has an `x-frame-parameter' property which is an integer in Lisp
569 but can be interpreted as an `enum x_frame_parm' in C. */
573 X_PARM_FOREGROUND_COLOR
,
574 X_PARM_BACKGROUND_COLOR
,
581 X_PARM_INTERNAL_BORDER_WIDTH
,
585 X_PARM_VERT_SCROLL_BAR
,
587 X_PARM_MENU_BAR_LINES
591 struct x_frame_parm_table
594 void (*setter
)( /* struct frame *frame, Lisp_Object val, oldval */ );
597 void x_set_foreground_color ();
598 void x_set_background_color ();
599 void x_set_mouse_color ();
600 void x_set_cursor_color ();
601 void x_set_border_color ();
602 void x_set_cursor_type ();
603 void x_set_icon_type ();
605 void x_set_border_width ();
606 void x_set_internal_border_width ();
607 void x_explicitly_set_name ();
608 void x_set_autoraise ();
609 void x_set_autolower ();
610 void x_set_vertical_scroll_bars ();
611 void x_set_visibility ();
612 void x_set_menu_bar_lines ();
613 void x_set_scroll_bar_width ();
614 void x_set_unsplittable ();
616 static struct x_frame_parm_table x_frame_parms
[] =
618 "foreground-color", x_set_foreground_color
,
619 "background-color", x_set_background_color
,
620 "mouse-color", x_set_mouse_color
,
621 "cursor-color", x_set_cursor_color
,
622 "border-color", x_set_border_color
,
623 "cursor-type", x_set_cursor_type
,
624 "icon-type", x_set_icon_type
,
626 "border-width", x_set_border_width
,
627 "internal-border-width", x_set_internal_border_width
,
628 "name", x_explicitly_set_name
,
629 "auto-raise", x_set_autoraise
,
630 "auto-lower", x_set_autolower
,
631 "vertical-scroll-bars", x_set_vertical_scroll_bars
,
632 "visibility", x_set_visibility
,
633 "menu-bar-lines", x_set_menu_bar_lines
,
634 "scroll-bar-width", x_set_scroll_bar_width
,
635 "unsplittable", x_set_unsplittable
,
638 /* Attach the `x-frame-parameter' properties to
639 the Lisp symbol names of parameters relevant to X. */
641 init_x_parm_symbols ()
645 for (i
= 0; i
< sizeof (x_frame_parms
) / sizeof (x_frame_parms
[0]); i
++)
646 Fput (intern (x_frame_parms
[i
].name
), Qx_frame_parameter
,
650 /* Change the parameters of FRAME as specified by ALIST.
651 If a parameter is not specially recognized, do nothing;
652 otherwise call the `x_set_...' function for that parameter. */
655 x_set_frame_parameters (f
, alist
)
661 /* If both of these parameters are present, it's more efficient to
662 set them both at once. So we wait until we've looked at the
663 entire list before we set them. */
664 Lisp_Object width
, height
;
667 Lisp_Object left
, top
;
669 /* Same with these. */
670 Lisp_Object icon_left
, icon_top
;
672 /* Record in these vectors all the parms specified. */
676 int left_no_change
= 0, top_no_change
= 0;
677 int icon_left_no_change
= 0, icon_top_no_change
= 0;
680 for (tail
= alist
; CONSP (tail
); tail
= Fcdr (tail
))
683 parms
= (Lisp_Object
*) alloca (i
* sizeof (Lisp_Object
));
684 values
= (Lisp_Object
*) alloca (i
* sizeof (Lisp_Object
));
686 /* Extract parm names and values into those vectors. */
689 for (tail
= alist
; CONSP (tail
); tail
= Fcdr (tail
))
691 Lisp_Object elt
, prop
, val
;
694 parms
[i
] = Fcar (elt
);
695 values
[i
] = Fcdr (elt
);
699 width
= height
= top
= left
= Qunbound
;
700 icon_left
= icon_top
= Qunbound
;
702 /* Now process them in reverse of specified order. */
703 for (i
--; i
>= 0; i
--)
705 Lisp_Object prop
, val
;
710 if (EQ (prop
, Qwidth
))
712 else if (EQ (prop
, Qheight
))
714 else if (EQ (prop
, Qtop
))
716 else if (EQ (prop
, Qleft
))
718 else if (EQ (prop
, Qicon_top
))
720 else if (EQ (prop
, Qicon_left
))
724 register Lisp_Object param_index
, old_value
;
726 param_index
= Fget (prop
, Qx_frame_parameter
);
727 old_value
= get_frame_param (f
, prop
);
728 store_frame_param (f
, prop
, val
);
729 if (NATNUMP (param_index
)
730 && (XFASTINT (param_index
)
731 < sizeof (x_frame_parms
)/sizeof (x_frame_parms
[0])))
732 (*x_frame_parms
[XINT (param_index
)].setter
)(f
, val
, old_value
);
736 /* Don't die if just one of these was set. */
737 if (EQ (left
, Qunbound
))
740 if (f
->display
.x
->left_pos
< 0)
741 left
= Fcons (Qplus
, Fcons (make_number (f
->display
.x
->left_pos
), Qnil
));
743 XSETINT (left
, f
->display
.x
->left_pos
);
745 if (EQ (top
, Qunbound
))
748 if (f
->display
.x
->top_pos
< 0)
749 top
= Fcons (Qplus
, Fcons (make_number (f
->display
.x
->top_pos
), Qnil
));
751 XSETINT (top
, f
->display
.x
->top_pos
);
754 /* If one of the icon positions was not set, preserve or default it. */
755 if (EQ (icon_left
, Qunbound
) || ! INTEGERP (icon_left
))
757 icon_left_no_change
= 1;
758 icon_left
= Fcdr (Fassq (Qicon_left
, f
->param_alist
));
759 if (NILP (icon_left
))
760 XSETINT (icon_left
, 0);
762 if (EQ (icon_top
, Qunbound
) || ! INTEGERP (icon_top
))
764 icon_top_no_change
= 1;
765 icon_top
= Fcdr (Fassq (Qicon_top
, f
->param_alist
));
767 XSETINT (icon_top
, 0);
770 /* Don't die if just one of these was set. */
771 if (EQ (width
, Qunbound
))
772 XSETINT (width
, FRAME_WIDTH (f
));
773 if (EQ (height
, Qunbound
))
774 XSETINT (height
, FRAME_HEIGHT (f
));
776 /* Don't set these parameters these unless they've been explicitly
777 specified. The window might be mapped or resized while we're in
778 this function, and we don't want to override that unless the lisp
779 code has asked for it.
781 Don't set these parameters unless they actually differ from the
782 window's current parameters; the window may not actually exist
787 check_frame_size (f
, &height
, &width
);
789 XSETFRAME (frame
, f
);
791 if ((NUMBERP (width
) && XINT (width
) != FRAME_WIDTH (f
))
792 || (NUMBERP (height
) && XINT (height
) != FRAME_HEIGHT (f
)))
793 Fset_frame_size (frame
, width
, height
);
795 if ((!NILP (left
) || !NILP (top
))
796 && ! (left_no_change
&& top_no_change
)
797 && ! (NUMBERP (left
) && XINT (left
) == f
->display
.x
->left_pos
798 && NUMBERP (top
) && XINT (top
) == f
->display
.x
->top_pos
))
803 /* Record the signs. */
804 f
->display
.x
->size_hint_flags
&= ~ (XNegative
| YNegative
);
805 if (EQ (left
, Qminus
))
806 f
->display
.x
->size_hint_flags
|= XNegative
;
807 else if (INTEGERP (left
))
809 leftpos
= XINT (left
);
811 f
->display
.x
->size_hint_flags
|= XNegative
;
813 else if (CONSP (left
) && EQ (XCONS (left
)->car
, Qminus
)
814 && CONSP (XCONS (left
)->cdr
)
815 && INTEGERP (XCONS (XCONS (left
)->cdr
)->car
))
817 leftpos
= - XINT (XCONS (XCONS (left
)->cdr
)->car
);
818 f
->display
.x
->size_hint_flags
|= XNegative
;
820 else if (CONSP (left
) && EQ (XCONS (left
)->car
, Qplus
)
821 && CONSP (XCONS (left
)->cdr
)
822 && INTEGERP (XCONS (XCONS (left
)->cdr
)->car
))
824 leftpos
= XINT (XCONS (XCONS (left
)->cdr
)->car
);
827 if (EQ (top
, Qminus
))
828 f
->display
.x
->size_hint_flags
|= YNegative
;
829 else if (INTEGERP (top
))
833 f
->display
.x
->size_hint_flags
|= YNegative
;
835 else if (CONSP (top
) && EQ (XCONS (top
)->car
, Qminus
)
836 && CONSP (XCONS (top
)->cdr
)
837 && INTEGERP (XCONS (XCONS (top
)->cdr
)->car
))
839 toppos
= - XINT (XCONS (XCONS (top
)->cdr
)->car
);
840 f
->display
.x
->size_hint_flags
|= YNegative
;
842 else if (CONSP (top
) && EQ (XCONS (top
)->car
, Qplus
)
843 && CONSP (XCONS (top
)->cdr
)
844 && INTEGERP (XCONS (XCONS (top
)->cdr
)->car
))
846 toppos
= XINT (XCONS (XCONS (top
)->cdr
)->car
);
850 /* Store the numeric value of the position. */
851 f
->display
.x
->top_pos
= toppos
;
852 f
->display
.x
->left_pos
= leftpos
;
854 f
->display
.x
->win_gravity
= NorthWestGravity
;
856 /* Actually set that position, and convert to absolute. */
857 x_set_offset (f
, leftpos
, toppos
, 0);
860 if ((!NILP (icon_left
) || !NILP (icon_top
))
861 && ! (icon_left_no_change
&& icon_top_no_change
))
862 x_wm_set_icon_position (f
, XINT (icon_left
), XINT (icon_top
));
866 /* Store the screen positions of frame F into XPTR and YPTR.
867 These are the positions of the containing window manager window,
868 not Emacs's own window. */
871 x_real_positions (f
, xptr
, yptr
)
878 /* This is pretty gross, but seems to be the easiest way out of
879 the problem that arises when restarting window-managers. */
882 Window outer
= XtWindow (f
->display
.x
->widget
);
884 Window outer
= f
->display
.x
->window_desc
;
886 Window tmp_root_window
;
887 Window
*tmp_children
;
890 x_catch_errors (FRAME_X_DISPLAY (f
));
893 XQueryTree (FRAME_X_DISPLAY (f
), outer
, &tmp_root_window
,
894 &f
->display
.x
->parent_desc
,
895 &tmp_children
, &tmp_nchildren
);
896 xfree (tmp_children
);
900 /* Find the position of the outside upper-left corner of
901 the inner window, with respect to the outer window. */
902 if (f
->display
.x
->parent_desc
!= FRAME_X_DISPLAY_INFO (f
)->root_window
)
904 XTranslateCoordinates (FRAME_X_DISPLAY (f
),
906 /* From-window, to-window. */
908 XtWindow (f
->display
.x
->widget
),
910 f
->display
.x
->window_desc
,
912 f
->display
.x
->parent_desc
,
914 /* From-position, to-position. */
915 0, 0, &win_x
, &win_y
,
920 win_x
+= f
->display
.x
->border_width
;
921 win_y
+= f
->display
.x
->border_width
;
924 /* It is possible for the window returned by the XQueryNotify
925 to become invalid by the time we call XTranslateCoordinates.
926 That can happen when you restart some window managers.
927 If so, we get an error in XTranslateCoordinates.
928 Detect that and try the whole thing over. */
929 if (! x_had_errors_p (FRAME_X_DISPLAY (f
)))
933 x_uncatch_errors (FRAME_X_DISPLAY (f
));
935 *xptr
= f
->display
.x
->left_pos
- win_x
;
936 *yptr
= f
->display
.x
->top_pos
- win_y
;
939 /* Insert a description of internally-recorded parameters of frame X
940 into the parameter alist *ALISTPTR that is to be given to the user.
941 Only parameters that are specific to the X window system
942 and whose values are not correctly recorded in the frame's
943 param_alist need to be considered here. */
945 x_report_frame_params (f
, alistptr
)
947 Lisp_Object
*alistptr
;
951 store_in_alist (alistptr
, Qleft
, make_number (f
->display
.x
->left_pos
));
952 store_in_alist (alistptr
, Qtop
, make_number (f
->display
.x
->top_pos
));
953 store_in_alist (alistptr
, Qborder_width
,
954 make_number (f
->display
.x
->border_width
));
955 store_in_alist (alistptr
, Qinternal_border_width
,
956 make_number (f
->display
.x
->internal_border_width
));
957 sprintf (buf
, "%ld", (long) FRAME_X_WINDOW (f
));
958 store_in_alist (alistptr
, Qwindow_id
,
960 FRAME_SAMPLE_VISIBILITY (f
);
961 store_in_alist (alistptr
, Qvisibility
,
962 (FRAME_VISIBLE_P (f
) ? Qt
963 : FRAME_ICONIFIED_P (f
) ? Qicon
: Qnil
));
967 /* Decide if color named COLOR is valid for the display associated with
968 the selected frame; if so, return the rgb values in COLOR_DEF.
969 If ALLOC is nonzero, allocate a new colormap cell. */
972 defined_color (f
, color
, color_def
, alloc
)
979 Colormap screen_colormap
;
980 Display
*display
= FRAME_X_DISPLAY (f
);
983 screen_colormap
= DefaultColormap (display
, XDefaultScreen (display
));
985 status
= XParseColor (display
, screen_colormap
, color
, color_def
);
988 status
= XAllocColor (display
, screen_colormap
, color_def
);
991 /* If we got to this point, the colormap is full, so we're
992 going to try and get the next closest color.
993 The algorithm used is a least-squares matching, which is
994 what X uses for closest color matching with StaticColor visuals. */
999 long nearest_delta
, trial_delta
;
1002 no_cells
= XDisplayCells (display
, XDefaultScreen (display
));
1003 cells
= (XColor
*) alloca (sizeof (XColor
) * no_cells
);
1005 for (x
= 0; x
< no_cells
; x
++)
1008 XQueryColors (display
, screen_colormap
, cells
, no_cells
);
1010 /* I'm assuming CSE so I'm not going to condense this. */
1011 nearest_delta
= ((((color_def
->red
>> 8) - (cells
[0].red
>> 8))
1012 * ((color_def
->red
>> 8) - (cells
[0].red
>> 8)))
1014 (((color_def
->green
>> 8) - (cells
[0].green
>> 8))
1015 * ((color_def
->green
>> 8) - (cells
[0].green
>> 8)))
1017 (((color_def
->blue
>> 8) - (cells
[0].blue
>> 8))
1018 * ((color_def
->blue
>> 8) - (cells
[0].blue
>> 8))));
1019 for (x
= 1; x
< no_cells
; x
++)
1021 trial_delta
= ((((color_def
->red
>> 8) - (cells
[x
].red
>> 8))
1022 * ((color_def
->red
>> 8) - (cells
[x
].red
>> 8)))
1024 (((color_def
->green
>> 8) - (cells
[x
].green
>> 8))
1025 * ((color_def
->green
>> 8) - (cells
[x
].green
>> 8))) +
1027 (((color_def
->blue
>> 8) - (cells
[x
].blue
>> 8))
1028 * ((color_def
->blue
>> 8) - (cells
[x
].blue
>> 8))));
1029 if (trial_delta
< nearest_delta
)
1032 nearest_delta
= trial_delta
;
1035 color_def
->red
= cells
[nearest
].red
;
1036 color_def
->green
= cells
[nearest
].green
;
1037 color_def
->blue
= cells
[nearest
].blue
;
1038 status
= XAllocColor (display
, screen_colormap
, color_def
);
1049 /* Given a string ARG naming a color, compute a pixel value from it
1050 suitable for screen F.
1051 If F is not a color screen, return DEF (default) regardless of what
1055 x_decode_color (f
, arg
, def
)
1062 CHECK_STRING (arg
, 0);
1064 if (strcmp (XSTRING (arg
)->data
, "black") == 0)
1065 return BLACK_PIX_DEFAULT (f
);
1066 else if (strcmp (XSTRING (arg
)->data
, "white") == 0)
1067 return WHITE_PIX_DEFAULT (f
);
1069 if (FRAME_X_DISPLAY_INFO (f
)->n_planes
== 1)
1072 /* defined_color is responsible for coping with failures
1073 by looking for a near-miss. */
1074 if (defined_color (f
, XSTRING (arg
)->data
, &cdef
, 1))
1077 /* defined_color failed; return an ultimate default. */
1081 /* Functions called only from `x_set_frame_param'
1082 to set individual parameters.
1084 If FRAME_X_WINDOW (f) is 0,
1085 the frame is being created and its X-window does not exist yet.
1086 In that case, just record the parameter's new value
1087 in the standard place; do not attempt to change the window. */
1090 x_set_foreground_color (f
, arg
, oldval
)
1092 Lisp_Object arg
, oldval
;
1094 f
->display
.x
->foreground_pixel
1095 = x_decode_color (f
, arg
, BLACK_PIX_DEFAULT (f
));
1096 if (FRAME_X_WINDOW (f
) != 0)
1099 XSetForeground (FRAME_X_DISPLAY (f
), f
->display
.x
->normal_gc
,
1100 f
->display
.x
->foreground_pixel
);
1101 XSetBackground (FRAME_X_DISPLAY (f
), f
->display
.x
->reverse_gc
,
1102 f
->display
.x
->foreground_pixel
);
1104 recompute_basic_faces (f
);
1105 if (FRAME_VISIBLE_P (f
))
1111 x_set_background_color (f
, arg
, oldval
)
1113 Lisp_Object arg
, oldval
;
1118 f
->display
.x
->background_pixel
1119 = x_decode_color (f
, arg
, WHITE_PIX_DEFAULT (f
));
1121 if (FRAME_X_WINDOW (f
) != 0)
1124 /* The main frame area. */
1125 XSetBackground (FRAME_X_DISPLAY (f
), f
->display
.x
->normal_gc
,
1126 f
->display
.x
->background_pixel
);
1127 XSetForeground (FRAME_X_DISPLAY (f
), f
->display
.x
->reverse_gc
,
1128 f
->display
.x
->background_pixel
);
1129 XSetForeground (FRAME_X_DISPLAY (f
), f
->display
.x
->cursor_gc
,
1130 f
->display
.x
->background_pixel
);
1131 XSetWindowBackground (FRAME_X_DISPLAY (f
), FRAME_X_WINDOW (f
),
1132 f
->display
.x
->background_pixel
);
1135 for (bar
= FRAME_SCROLL_BARS (f
); !NILP (bar
);
1136 bar
= XSCROLL_BAR (bar
)->next
)
1137 XSetWindowBackground (FRAME_X_DISPLAY (f
),
1138 SCROLL_BAR_X_WINDOW (XSCROLL_BAR (bar
)),
1139 f
->display
.x
->background_pixel
);
1143 recompute_basic_faces (f
);
1145 if (FRAME_VISIBLE_P (f
))
1151 x_set_mouse_color (f
, arg
, oldval
)
1153 Lisp_Object arg
, oldval
;
1155 Cursor cursor
, nontext_cursor
, mode_cursor
, cross_cursor
;
1158 if (!EQ (Qnil
, arg
))
1159 f
->display
.x
->mouse_pixel
1160 = x_decode_color (f
, arg
, BLACK_PIX_DEFAULT (f
));
1161 mask_color
= f
->display
.x
->background_pixel
;
1162 /* No invisible pointers. */
1163 if (mask_color
== f
->display
.x
->mouse_pixel
1164 && mask_color
== f
->display
.x
->background_pixel
)
1165 f
->display
.x
->mouse_pixel
= f
->display
.x
->foreground_pixel
;
1169 /* It's not okay to crash if the user selects a screwy cursor. */
1170 x_catch_errors (FRAME_X_DISPLAY (f
));
1172 if (!EQ (Qnil
, Vx_pointer_shape
))
1174 CHECK_NUMBER (Vx_pointer_shape
, 0);
1175 cursor
= XCreateFontCursor (FRAME_X_DISPLAY (f
), XINT (Vx_pointer_shape
));
1178 cursor
= XCreateFontCursor (FRAME_X_DISPLAY (f
), XC_xterm
);
1179 x_check_errors (FRAME_X_DISPLAY (f
), "bad text pointer cursor: %s");
1181 if (!EQ (Qnil
, Vx_nontext_pointer_shape
))
1183 CHECK_NUMBER (Vx_nontext_pointer_shape
, 0);
1184 nontext_cursor
= XCreateFontCursor (FRAME_X_DISPLAY (f
),
1185 XINT (Vx_nontext_pointer_shape
));
1188 nontext_cursor
= XCreateFontCursor (FRAME_X_DISPLAY (f
), XC_left_ptr
);
1189 x_check_errors (FRAME_X_DISPLAY (f
), "bad nontext pointer cursor: %s");
1191 if (!EQ (Qnil
, Vx_mode_pointer_shape
))
1193 CHECK_NUMBER (Vx_mode_pointer_shape
, 0);
1194 mode_cursor
= XCreateFontCursor (FRAME_X_DISPLAY (f
),
1195 XINT (Vx_mode_pointer_shape
));
1198 mode_cursor
= XCreateFontCursor (FRAME_X_DISPLAY (f
), XC_xterm
);
1199 x_check_errors (FRAME_X_DISPLAY (f
), "bad modeline pointer cursor: %s");
1201 if (!EQ (Qnil
, Vx_sensitive_text_pointer_shape
))
1203 CHECK_NUMBER (Vx_sensitive_text_pointer_shape
, 0);
1205 = XCreateFontCursor (FRAME_X_DISPLAY (f
),
1206 XINT (Vx_sensitive_text_pointer_shape
));
1209 cross_cursor
= XCreateFontCursor (FRAME_X_DISPLAY (f
), XC_crosshair
);
1211 /* Check and report errors with the above calls. */
1212 x_check_errors (FRAME_X_DISPLAY (f
), "can't set cursor shape: %s");
1213 x_uncatch_errors (FRAME_X_DISPLAY (f
));
1216 XColor fore_color
, back_color
;
1218 fore_color
.pixel
= f
->display
.x
->mouse_pixel
;
1219 back_color
.pixel
= mask_color
;
1220 XQueryColor (FRAME_X_DISPLAY (f
),
1221 DefaultColormap (FRAME_X_DISPLAY (f
),
1222 DefaultScreen (FRAME_X_DISPLAY (f
))),
1224 XQueryColor (FRAME_X_DISPLAY (f
),
1225 DefaultColormap (FRAME_X_DISPLAY (f
),
1226 DefaultScreen (FRAME_X_DISPLAY (f
))),
1228 XRecolorCursor (FRAME_X_DISPLAY (f
), cursor
,
1229 &fore_color
, &back_color
);
1230 XRecolorCursor (FRAME_X_DISPLAY (f
), nontext_cursor
,
1231 &fore_color
, &back_color
);
1232 XRecolorCursor (FRAME_X_DISPLAY (f
), mode_cursor
,
1233 &fore_color
, &back_color
);
1234 XRecolorCursor (FRAME_X_DISPLAY (f
), cross_cursor
,
1235 &fore_color
, &back_color
);
1238 if (FRAME_X_WINDOW (f
) != 0)
1240 XDefineCursor (FRAME_X_DISPLAY (f
), FRAME_X_WINDOW (f
), cursor
);
1243 if (cursor
!= f
->display
.x
->text_cursor
&& f
->display
.x
->text_cursor
!= 0)
1244 XFreeCursor (FRAME_X_DISPLAY (f
), f
->display
.x
->text_cursor
);
1245 f
->display
.x
->text_cursor
= cursor
;
1247 if (nontext_cursor
!= f
->display
.x
->nontext_cursor
1248 && f
->display
.x
->nontext_cursor
!= 0)
1249 XFreeCursor (FRAME_X_DISPLAY (f
), f
->display
.x
->nontext_cursor
);
1250 f
->display
.x
->nontext_cursor
= nontext_cursor
;
1252 if (mode_cursor
!= f
->display
.x
->modeline_cursor
1253 && f
->display
.x
->modeline_cursor
!= 0)
1254 XFreeCursor (FRAME_X_DISPLAY (f
), f
->display
.x
->modeline_cursor
);
1255 f
->display
.x
->modeline_cursor
= mode_cursor
;
1256 if (cross_cursor
!= f
->display
.x
->cross_cursor
1257 && f
->display
.x
->cross_cursor
!= 0)
1258 XFreeCursor (FRAME_X_DISPLAY (f
), f
->display
.x
->cross_cursor
);
1259 f
->display
.x
->cross_cursor
= cross_cursor
;
1261 XFlush (FRAME_X_DISPLAY (f
));
1266 x_set_cursor_color (f
, arg
, oldval
)
1268 Lisp_Object arg
, oldval
;
1270 unsigned long fore_pixel
;
1272 if (!EQ (Vx_cursor_fore_pixel
, Qnil
))
1273 fore_pixel
= x_decode_color (f
, Vx_cursor_fore_pixel
,
1274 WHITE_PIX_DEFAULT (f
));
1276 fore_pixel
= f
->display
.x
->background_pixel
;
1277 f
->display
.x
->cursor_pixel
= x_decode_color (f
, arg
, BLACK_PIX_DEFAULT (f
));
1279 /* Make sure that the cursor color differs from the background color. */
1280 if (f
->display
.x
->cursor_pixel
== f
->display
.x
->background_pixel
)
1282 f
->display
.x
->cursor_pixel
= f
->display
.x
->mouse_pixel
;
1283 if (f
->display
.x
->cursor_pixel
== fore_pixel
)
1284 fore_pixel
= f
->display
.x
->background_pixel
;
1286 f
->display
.x
->cursor_foreground_pixel
= fore_pixel
;
1288 if (FRAME_X_WINDOW (f
) != 0)
1291 XSetBackground (FRAME_X_DISPLAY (f
), f
->display
.x
->cursor_gc
,
1292 f
->display
.x
->cursor_pixel
);
1293 XSetForeground (FRAME_X_DISPLAY (f
), f
->display
.x
->cursor_gc
,
1297 if (FRAME_VISIBLE_P (f
))
1299 x_display_cursor (f
, 0);
1300 x_display_cursor (f
, 1);
1305 /* Set the border-color of frame F to value described by ARG.
1306 ARG can be a string naming a color.
1307 The border-color is used for the border that is drawn by the X server.
1308 Note that this does not fully take effect if done before
1309 F has an x-window; it must be redone when the window is created.
1311 Note: this is done in two routines because of the way X10 works.
1313 Note: under X11, this is normally the province of the window manager,
1314 and so emacs' border colors may be overridden. */
1317 x_set_border_color (f
, arg
, oldval
)
1319 Lisp_Object arg
, oldval
;
1324 CHECK_STRING (arg
, 0);
1325 str
= XSTRING (arg
)->data
;
1327 pix
= x_decode_color (f
, arg
, BLACK_PIX_DEFAULT (f
));
1329 x_set_border_pixel (f
, pix
);
1332 /* Set the border-color of frame F to pixel value PIX.
1333 Note that this does not fully take effect if done before
1334 F has an x-window. */
1336 x_set_border_pixel (f
, pix
)
1340 f
->display
.x
->border_pixel
= pix
;
1342 if (FRAME_X_WINDOW (f
) != 0 && f
->display
.x
->border_width
> 0)
1348 XSetWindowBorder (FRAME_X_DISPLAY (f
), FRAME_X_WINDOW (f
),
1352 if (FRAME_VISIBLE_P (f
))
1358 x_set_cursor_type (f
, arg
, oldval
)
1360 Lisp_Object arg
, oldval
;
1364 FRAME_DESIRED_CURSOR (f
) = bar_cursor
;
1365 f
->display
.x
->cursor_width
= 2;
1367 else if (CONSP (arg
) && EQ (XCONS (arg
)->car
, Qbar
)
1368 && INTEGERP (XCONS (arg
)->cdr
))
1370 FRAME_DESIRED_CURSOR (f
) = bar_cursor
;
1371 f
->display
.x
->cursor_width
= XINT (XCONS (arg
)->cdr
);
1374 /* Treat anything unknown as "box cursor".
1375 It was bad to signal an error; people have trouble fixing
1376 .Xdefaults with Emacs, when it has something bad in it. */
1377 FRAME_DESIRED_CURSOR (f
) = filled_box_cursor
;
1379 /* Make sure the cursor gets redrawn. This is overkill, but how
1380 often do people change cursor types? */
1381 update_mode_lines
++;
1385 x_set_icon_type (f
, arg
, oldval
)
1387 Lisp_Object arg
, oldval
;
1394 if (STRINGP (oldval
) && EQ (Fstring_equal (oldval
, arg
), Qt
))
1397 else if (!STRINGP (oldval
) && EQ (oldval
, Qnil
) == EQ (arg
, Qnil
))
1402 result
= x_text_icon (f
, 0);
1404 result
= x_bitmap_icon (f
, arg
);
1409 error ("No icon window available");
1412 /* If the window was unmapped (and its icon was mapped),
1413 the new icon is not mapped, so map the window in its stead. */
1414 if (FRAME_VISIBLE_P (f
))
1416 #ifdef USE_X_TOOLKIT
1417 XtPopup (f
->display
.x
->widget
, XtGrabNone
);
1419 XMapWindow (FRAME_X_DISPLAY (f
), FRAME_X_WINDOW (f
));
1422 XFlush (FRAME_X_DISPLAY (f
));
1426 /* Return non-nil if frame F wants a bitmap icon. */
1434 tem
= assq_no_quit (Qicon_type
, f
->param_alist
);
1436 return XCONS (tem
)->cdr
;
1441 extern Lisp_Object
x_new_font ();
1444 x_set_font (f
, arg
, oldval
)
1446 Lisp_Object arg
, oldval
;
1450 CHECK_STRING (arg
, 1);
1453 result
= x_new_font (f
, XSTRING (arg
)->data
);
1456 if (EQ (result
, Qnil
))
1457 error ("Font \"%s\" is not defined", XSTRING (arg
)->data
);
1458 else if (EQ (result
, Qt
))
1459 error ("the characters of the given font have varying widths");
1460 else if (STRINGP (result
))
1462 recompute_basic_faces (f
);
1463 store_frame_param (f
, Qfont
, result
);
1470 x_set_border_width (f
, arg
, oldval
)
1472 Lisp_Object arg
, oldval
;
1474 CHECK_NUMBER (arg
, 0);
1476 if (XINT (arg
) == f
->display
.x
->border_width
)
1479 if (FRAME_X_WINDOW (f
) != 0)
1480 error ("Cannot change the border width of a window");
1482 f
->display
.x
->border_width
= XINT (arg
);
1486 x_set_internal_border_width (f
, arg
, oldval
)
1488 Lisp_Object arg
, oldval
;
1491 int old
= f
->display
.x
->internal_border_width
;
1493 CHECK_NUMBER (arg
, 0);
1494 f
->display
.x
->internal_border_width
= XINT (arg
);
1495 if (f
->display
.x
->internal_border_width
< 0)
1496 f
->display
.x
->internal_border_width
= 0;
1498 if (f
->display
.x
->internal_border_width
== old
)
1501 if (FRAME_X_WINDOW (f
) != 0)
1504 x_set_window_size (f
, 0, f
->width
, f
->height
);
1506 x_set_resize_hint (f
);
1508 XFlush (FRAME_X_DISPLAY (f
));
1510 SET_FRAME_GARBAGED (f
);
1515 x_set_visibility (f
, value
, oldval
)
1517 Lisp_Object value
, oldval
;
1520 XSETFRAME (frame
, f
);
1523 Fmake_frame_invisible (frame
, Qt
);
1524 else if (EQ (value
, Qicon
))
1525 Ficonify_frame (frame
);
1527 Fmake_frame_visible (frame
);
1531 x_set_menu_bar_lines_1 (window
, n
)
1535 struct window
*w
= XWINDOW (window
);
1537 XSETFASTINT (w
->top
, XFASTINT (w
->top
) + n
);
1538 XSETFASTINT (w
->height
, XFASTINT (w
->height
) - n
);
1540 /* Handle just the top child in a vertical split. */
1541 if (!NILP (w
->vchild
))
1542 x_set_menu_bar_lines_1 (w
->vchild
, n
);
1544 /* Adjust all children in a horizontal split. */
1545 for (window
= w
->hchild
; !NILP (window
); window
= w
->next
)
1547 w
= XWINDOW (window
);
1548 x_set_menu_bar_lines_1 (window
, n
);
1553 x_set_menu_bar_lines (f
, value
, oldval
)
1555 Lisp_Object value
, oldval
;
1558 int olines
= FRAME_MENU_BAR_LINES (f
);
1560 /* Right now, menu bars don't work properly in minibuf-only frames;
1561 most of the commands try to apply themselves to the minibuffer
1562 frame itslef, and get an error because you can't switch buffers
1563 in or split the minibuffer window. */
1564 if (FRAME_MINIBUF_ONLY_P (f
))
1567 if (INTEGERP (value
))
1568 nlines
= XINT (value
);
1572 #ifdef USE_X_TOOLKIT
1573 FRAME_MENU_BAR_LINES (f
) = 0;
1575 FRAME_EXTERNAL_MENU_BAR (f
) = 1;
1578 if (FRAME_EXTERNAL_MENU_BAR (f
) == 1)
1579 free_frame_menubar (f
);
1580 FRAME_EXTERNAL_MENU_BAR (f
) = 0;
1581 f
->display
.x
->menubar_widget
= 0;
1583 #else /* not USE_X_TOOLKIT */
1584 FRAME_MENU_BAR_LINES (f
) = nlines
;
1585 x_set_menu_bar_lines_1 (f
->root_window
, nlines
- olines
);
1586 #endif /* not USE_X_TOOLKIT */
1589 /* Change the name of frame F to NAME. If NAME is nil, set F's name to
1592 If EXPLICIT is non-zero, that indicates that lisp code is setting the
1593 name; if NAME is a string, set F's name to NAME and set
1594 F->explicit_name; if NAME is Qnil, then clear F->explicit_name.
1596 If EXPLICIT is zero, that indicates that Emacs redisplay code is
1597 suggesting a new name, which lisp code should override; if
1598 F->explicit_name is set, ignore the new name; otherwise, set it. */
1601 x_set_name (f
, name
, explicit)
1606 /* Make sure that requests from lisp code override requests from
1607 Emacs redisplay code. */
1610 /* If we're switching from explicit to implicit, we had better
1611 update the mode lines and thereby update the title. */
1612 if (f
->explicit_name
&& NILP (name
))
1613 update_mode_lines
= 1;
1615 f
->explicit_name
= ! NILP (name
);
1617 else if (f
->explicit_name
)
1620 /* If NAME is nil, set the name to the x_id_name. */
1623 /* Check for no change needed in this very common case
1624 before we do any consing. */
1625 if (!strcmp (FRAME_X_DISPLAY_INFO (f
)->x_id_name
,
1626 XSTRING (f
->name
)->data
))
1628 name
= build_string (FRAME_X_DISPLAY_INFO (f
)->x_id_name
);
1631 CHECK_STRING (name
, 0);
1633 /* Don't change the name if it's already NAME. */
1634 if (! NILP (Fstring_equal (name
, f
->name
)))
1637 if (FRAME_X_WINDOW (f
))
1643 text
.value
= XSTRING (name
)->data
;
1644 text
.encoding
= XA_STRING
;
1646 text
.nitems
= XSTRING (name
)->size
;
1647 #ifdef USE_X_TOOLKIT
1648 XSetWMName (FRAME_X_DISPLAY (f
),
1649 XtWindow (f
->display
.x
->widget
), &text
);
1650 XSetWMIconName (FRAME_X_DISPLAY (f
), XtWindow (f
->display
.x
->widget
),
1652 #else /* not USE_X_TOOLKIT */
1653 XSetWMName (FRAME_X_DISPLAY (f
), FRAME_X_WINDOW (f
), &text
);
1654 XSetWMIconName (FRAME_X_DISPLAY (f
), FRAME_X_WINDOW (f
), &text
);
1655 #endif /* not USE_X_TOOLKIT */
1657 #else /* not HAVE_X11R4 */
1658 XSetIconName (FRAME_X_DISPLAY (f
), FRAME_X_WINDOW (f
),
1659 XSTRING (name
)->data
);
1660 XStoreName (FRAME_X_DISPLAY (f
), FRAME_X_WINDOW (f
),
1661 XSTRING (name
)->data
);
1662 #endif /* not HAVE_X11R4 */
1669 /* This function should be called when the user's lisp code has
1670 specified a name for the frame; the name will override any set by the
1673 x_explicitly_set_name (f
, arg
, oldval
)
1675 Lisp_Object arg
, oldval
;
1677 x_set_name (f
, arg
, 1);
1680 /* This function should be called by Emacs redisplay code to set the
1681 name; names set this way will never override names set by the user's
1684 x_implicitly_set_name (f
, arg
, oldval
)
1686 Lisp_Object arg
, oldval
;
1688 x_set_name (f
, arg
, 0);
1692 x_set_autoraise (f
, arg
, oldval
)
1694 Lisp_Object arg
, oldval
;
1696 f
->auto_raise
= !EQ (Qnil
, arg
);
1700 x_set_autolower (f
, arg
, oldval
)
1702 Lisp_Object arg
, oldval
;
1704 f
->auto_lower
= !EQ (Qnil
, arg
);
1708 x_set_unsplittable (f
, arg
, oldval
)
1710 Lisp_Object arg
, oldval
;
1712 f
->no_split
= !NILP (arg
);
1716 x_set_vertical_scroll_bars (f
, arg
, oldval
)
1718 Lisp_Object arg
, oldval
;
1720 if (NILP (arg
) != ! FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
1722 FRAME_HAS_VERTICAL_SCROLL_BARS (f
) = ! NILP (arg
);
1724 /* We set this parameter before creating the X window for the
1725 frame, so we can get the geometry right from the start.
1726 However, if the window hasn't been created yet, we shouldn't
1727 call x_set_window_size. */
1728 if (FRAME_X_WINDOW (f
))
1729 x_set_window_size (f
, 0, FRAME_WIDTH (f
), FRAME_HEIGHT (f
));
1734 x_set_scroll_bar_width (f
, arg
, oldval
)
1736 Lisp_Object arg
, oldval
;
1740 FRAME_SCROLL_BAR_PIXEL_WIDTH (f
) = 0;
1741 FRAME_SCROLL_BAR_COLS (f
) = 2;
1743 else if (INTEGERP (arg
) && XINT (arg
) > 0
1744 && XFASTINT (arg
) != FRAME_SCROLL_BAR_PIXEL_WIDTH (f
))
1746 int wid
= FONT_WIDTH (f
->display
.x
->font
);
1747 FRAME_SCROLL_BAR_PIXEL_WIDTH (f
) = XFASTINT (arg
);
1748 FRAME_SCROLL_BAR_COLS (f
) = (XFASTINT (arg
) + wid
-1) / wid
;
1749 if (FRAME_X_WINDOW (f
))
1750 x_set_window_size (f
, 0, FRAME_WIDTH (f
), FRAME_HEIGHT (f
));
1754 /* Subroutines of creating an X frame. */
1756 /* Make sure that Vx_resource_name is set to a reasonable value. */
1758 validate_x_resource_name ()
1760 if (STRINGP (Vx_resource_name
))
1762 int len
= XSTRING (Vx_resource_name
)->size
;
1763 unsigned char *p
= XSTRING (Vx_resource_name
)->data
;
1766 /* Allow only letters, digits, - and _,
1767 because those are all that X allows. */
1768 for (i
= 0; i
< len
; i
++)
1771 if (! ((c
>= 'a' && c
<= 'z')
1772 || (c
>= 'A' && c
<= 'Z')
1773 || (c
>= '0' && c
<= '9')
1774 || c
== '-' || c
== '_'))
1780 Vx_resource_name
= make_string ("emacs", 5);
1784 extern char *x_get_string_resource ();
1786 DEFUN ("x-get-resource", Fx_get_resource
, Sx_get_resource
, 2, 4, 0,
1787 "Return the value of ATTRIBUTE, of class CLASS, from the X defaults database.\n\
1788 This uses `INSTANCE.ATTRIBUTE' as the key and `Emacs.CLASS' as the\n\
1789 class, where INSTANCE is the name under which Emacs was invoked, or\n\
1790 the name specified by the `-name' or `-rn' command-line arguments.\n\
1792 The optional arguments COMPONENT and SUBCLASS add to the key and the\n\
1793 class, respectively. You must specify both of them or neither.\n\
1794 If you specify them, the key is `INSTANCE.COMPONENT.ATTRIBUTE'\n\
1795 and the class is `Emacs.CLASS.SUBCLASS'.")
1796 (attribute
, class, component
, subclass
)
1797 Lisp_Object attribute
, class, component
, subclass
;
1799 register char *value
;
1802 Lisp_Object resname
;
1806 CHECK_STRING (attribute
, 0);
1807 CHECK_STRING (class, 0);
1809 if (!NILP (component
))
1810 CHECK_STRING (component
, 1);
1811 if (!NILP (subclass
))
1812 CHECK_STRING (subclass
, 2);
1813 if (NILP (component
) != NILP (subclass
))
1814 error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither");
1816 validate_x_resource_name ();
1817 resname
= Vx_resource_name
;
1819 if (NILP (component
))
1821 /* Allocate space for the components, the dots which separate them,
1822 and the final '\0'. */
1823 name_key
= (char *) alloca (XSTRING (resname
)->size
1824 + XSTRING (attribute
)->size
1826 class_key
= (char *) alloca ((sizeof (EMACS_CLASS
) - 1)
1827 + XSTRING (class)->size
1830 sprintf (name_key
, "%s.%s",
1831 XSTRING (resname
)->data
,
1832 XSTRING (attribute
)->data
);
1833 sprintf (class_key
, "%s.%s",
1835 XSTRING (class)->data
);
1839 name_key
= (char *) alloca (XSTRING (resname
)->size
1840 + XSTRING (component
)->size
1841 + XSTRING (attribute
)->size
1844 class_key
= (char *) alloca ((sizeof (EMACS_CLASS
) - 1)
1845 + XSTRING (class)->size
1846 + XSTRING (subclass
)->size
1849 sprintf (name_key
, "%s.%s.%s",
1850 XSTRING (resname
)->data
,
1851 XSTRING (component
)->data
,
1852 XSTRING (attribute
)->data
);
1853 sprintf (class_key
, "%s.%s.%s",
1855 XSTRING (class)->data
,
1856 XSTRING (subclass
)->data
);
1859 value
= x_get_string_resource (check_x_display_info (Qnil
)->xrdb
,
1860 name_key
, class_key
);
1862 if (value
!= (char *) 0)
1863 return build_string (value
);
1868 /* Used when C code wants a resource value. */
1871 x_get_resource_string (attribute
, class)
1872 char *attribute
, *class;
1874 register char *value
;
1878 /* Allocate space for the components, the dots which separate them,
1879 and the final '\0'. */
1880 name_key
= (char *) alloca (XSTRING (Vinvocation_name
)->size
1881 + strlen (attribute
) + 2);
1882 class_key
= (char *) alloca ((sizeof (EMACS_CLASS
) - 1)
1883 + strlen (class) + 2);
1885 sprintf (name_key
, "%s.%s",
1886 XSTRING (Vinvocation_name
)->data
,
1888 sprintf (class_key
, "%s.%s", EMACS_CLASS
, class);
1890 return x_get_string_resource (FRAME_X_DISPLAY_INFO (selected_frame
)->xrdb
,
1891 name_key
, class_key
);
1894 /* Types we might convert a resource string into. */
1897 number
, boolean
, string
, symbol
1900 /* Return the value of parameter PARAM.
1902 First search ALIST, then Vdefault_frame_alist, then the X defaults
1903 database, using ATTRIBUTE as the attribute name and CLASS as its class.
1905 Convert the resource to the type specified by desired_type.
1907 If no default is specified, return Qunbound. If you call
1908 x_get_arg, make sure you deal with Qunbound in a reasonable way,
1909 and don't let it get stored in any Lisp-visible variables! */
1912 x_get_arg (alist
, param
, attribute
, class, type
)
1913 Lisp_Object alist
, param
;
1916 enum resource_types type
;
1918 register Lisp_Object tem
;
1920 tem
= Fassq (param
, alist
);
1922 tem
= Fassq (param
, Vdefault_frame_alist
);
1928 tem
= Fx_get_resource (build_string (attribute
),
1929 build_string (class),
1938 return make_number (atoi (XSTRING (tem
)->data
));
1941 tem
= Fdowncase (tem
);
1942 if (!strcmp (XSTRING (tem
)->data
, "on")
1943 || !strcmp (XSTRING (tem
)->data
, "true"))
1952 /* As a special case, we map the values `true' and `on'
1953 to Qt, and `false' and `off' to Qnil. */
1956 lower
= Fdowncase (tem
);
1957 if (!strcmp (XSTRING (lower
)->data
, "on")
1958 || !strcmp (XSTRING (lower
)->data
, "true"))
1960 else if (!strcmp (XSTRING (lower
)->data
, "off")
1961 || !strcmp (XSTRING (lower
)->data
, "false"))
1964 return Fintern (tem
, Qnil
);
1977 /* Record in frame F the specified or default value according to ALIST
1978 of the parameter named PARAM (a Lisp symbol).
1979 If no value is specified for PARAM, look for an X default for XPROP
1980 on the frame named NAME.
1981 If that is not found either, use the value DEFLT. */
1984 x_default_parameter (f
, alist
, prop
, deflt
, xprop
, xclass
, type
)
1991 enum resource_types type
;
1995 tem
= x_get_arg (alist
, prop
, xprop
, xclass
, type
);
1996 if (EQ (tem
, Qunbound
))
1998 x_set_frame_parameters (f
, Fcons (Fcons (prop
, tem
), Qnil
));
2002 DEFUN ("x-parse-geometry", Fx_parse_geometry
, Sx_parse_geometry
, 1, 1, 0,
2003 "Parse an X-style geometry string STRING.\n\
2004 Returns an alist of the form ((top . TOP), (left . LEFT) ... ).\n\
2005 The properties returned may include `top', `left', `height', and `width'.\n\
2006 The value of `left' or `top' may be an integer,\n\
2007 or a list (+ N) meaning N pixels relative to top/left corner,\n\
2008 or a list (- N) meaning -N pixels relative to bottom/right corner.")
2013 unsigned int width
, height
;
2016 CHECK_STRING (string
, 0);
2018 geometry
= XParseGeometry ((char *) XSTRING (string
)->data
,
2019 &x
, &y
, &width
, &height
);
2022 if (!!(geometry
& XValue
) != !!(geometry
& YValue
))
2023 error ("Must specify both x and y position, or neither");
2027 if (geometry
& XValue
)
2029 Lisp_Object element
;
2031 if (x
>= 0 && (geometry
& XNegative
))
2032 element
= Fcons (Qleft
, Fcons (Qminus
, Fcons (make_number (-x
), Qnil
)));
2033 else if (x
< 0 && ! (geometry
& XNegative
))
2034 element
= Fcons (Qleft
, Fcons (Qplus
, Fcons (make_number (x
), Qnil
)));
2036 element
= Fcons (Qleft
, make_number (x
));
2037 result
= Fcons (element
, result
);
2040 if (geometry
& YValue
)
2042 Lisp_Object element
;
2044 if (y
>= 0 && (geometry
& YNegative
))
2045 element
= Fcons (Qtop
, Fcons (Qminus
, Fcons (make_number (-y
), Qnil
)));
2046 else if (y
< 0 && ! (geometry
& YNegative
))
2047 element
= Fcons (Qtop
, Fcons (Qplus
, Fcons (make_number (y
), Qnil
)));
2049 element
= Fcons (Qtop
, make_number (y
));
2050 result
= Fcons (element
, result
);
2053 if (geometry
& WidthValue
)
2054 result
= Fcons (Fcons (Qwidth
, make_number (width
)), result
);
2055 if (geometry
& HeightValue
)
2056 result
= Fcons (Fcons (Qheight
, make_number (height
)), result
);
2061 /* Calculate the desired size and position of this window,
2062 and return the flags saying which aspects were specified.
2064 This function does not make the coordinates positive. */
2066 #define DEFAULT_ROWS 40
2067 #define DEFAULT_COLS 80
2070 x_figure_window_size (f
, parms
)
2074 register Lisp_Object tem0
, tem1
, tem2
;
2075 int height
, width
, left
, top
;
2076 register int geometry
;
2077 long window_prompting
= 0;
2079 /* Default values if we fall through.
2080 Actually, if that happens we should get
2081 window manager prompting. */
2082 f
->width
= DEFAULT_COLS
;
2083 f
->height
= DEFAULT_ROWS
;
2084 /* Window managers expect that if program-specified
2085 positions are not (0,0), they're intentional, not defaults. */
2086 f
->display
.x
->top_pos
= 0;
2087 f
->display
.x
->left_pos
= 0;
2089 tem0
= x_get_arg (parms
, Qheight
, 0, 0, number
);
2090 tem1
= x_get_arg (parms
, Qwidth
, 0, 0, number
);
2091 tem2
= x_get_arg (parms
, Quser_size
, 0, 0, number
);
2092 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
2094 if (!EQ (tem0
, Qunbound
))
2096 CHECK_NUMBER (tem0
, 0);
2097 f
->height
= XINT (tem0
);
2099 if (!EQ (tem1
, Qunbound
))
2101 CHECK_NUMBER (tem1
, 0);
2102 f
->width
= XINT (tem1
);
2104 if (!NILP (tem2
) && !EQ (tem2
, Qunbound
))
2105 window_prompting
|= USSize
;
2107 window_prompting
|= PSize
;
2110 f
->display
.x
->vertical_scroll_bar_extra
2111 = (!FRAME_HAS_VERTICAL_SCROLL_BARS (f
)
2113 : FRAME_SCROLL_BAR_PIXEL_WIDTH (f
) > 0
2114 ? FRAME_SCROLL_BAR_PIXEL_WIDTH (f
)
2115 : (FRAME_SCROLL_BAR_COLS (f
) * FONT_WIDTH (f
->display
.x
->font
)));
2116 f
->display
.x
->pixel_width
= CHAR_TO_PIXEL_WIDTH (f
, f
->width
);
2117 f
->display
.x
->pixel_height
= CHAR_TO_PIXEL_HEIGHT (f
, f
->height
);
2119 tem0
= x_get_arg (parms
, Qtop
, 0, 0, number
);
2120 tem1
= x_get_arg (parms
, Qleft
, 0, 0, number
);
2121 tem2
= x_get_arg (parms
, Quser_position
, 0, 0, number
);
2122 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
2124 if (EQ (tem0
, Qminus
))
2126 f
->display
.x
->top_pos
= 0;
2127 window_prompting
|= YNegative
;
2129 else if (CONSP (tem0
) && EQ (XCONS (tem0
)->car
, Qminus
)
2130 && CONSP (XCONS (tem0
)->cdr
)
2131 && INTEGERP (XCONS (XCONS (tem0
)->cdr
)->car
))
2133 f
->display
.x
->top_pos
= - XINT (XCONS (XCONS (tem0
)->cdr
)->car
);
2134 window_prompting
|= YNegative
;
2136 else if (CONSP (tem0
) && EQ (XCONS (tem0
)->car
, Qplus
)
2137 && CONSP (XCONS (tem0
)->cdr
)
2138 && INTEGERP (XCONS (XCONS (tem0
)->cdr
)->car
))
2140 f
->display
.x
->top_pos
= XINT (XCONS (XCONS (tem0
)->cdr
)->car
);
2142 else if (EQ (tem0
, Qunbound
))
2143 f
->display
.x
->top_pos
= 0;
2146 CHECK_NUMBER (tem0
, 0);
2147 f
->display
.x
->top_pos
= XINT (tem0
);
2148 if (f
->display
.x
->top_pos
< 0)
2149 window_prompting
|= YNegative
;
2152 if (EQ (tem1
, Qminus
))
2154 f
->display
.x
->left_pos
= 0;
2155 window_prompting
|= XNegative
;
2157 else if (CONSP (tem1
) && EQ (XCONS (tem1
)->car
, Qminus
)
2158 && CONSP (XCONS (tem1
)->cdr
)
2159 && INTEGERP (XCONS (XCONS (tem1
)->cdr
)->car
))
2161 f
->display
.x
->left_pos
= - XINT (XCONS (XCONS (tem1
)->cdr
)->car
);
2162 window_prompting
|= XNegative
;
2164 else if (CONSP (tem1
) && EQ (XCONS (tem1
)->car
, Qplus
)
2165 && CONSP (XCONS (tem1
)->cdr
)
2166 && INTEGERP (XCONS (XCONS (tem1
)->cdr
)->car
))
2168 f
->display
.x
->left_pos
= XINT (XCONS (XCONS (tem1
)->cdr
)->car
);
2170 else if (EQ (tem1
, Qunbound
))
2171 f
->display
.x
->left_pos
= 0;
2174 CHECK_NUMBER (tem1
, 0);
2175 f
->display
.x
->left_pos
= XINT (tem1
);
2176 if (f
->display
.x
->left_pos
< 0)
2177 window_prompting
|= XNegative
;
2180 if (!NILP (tem2
) && ! EQ (tem2
, Qunbound
))
2181 window_prompting
|= USPosition
;
2183 window_prompting
|= PPosition
;
2186 return window_prompting
;
2189 #if !defined (HAVE_X11R4) && !defined (HAVE_XSETWMPROTOCOLS)
2192 XSetWMProtocols (dpy
, w
, protocols
, count
)
2199 prop
= XInternAtom (dpy
, "WM_PROTOCOLS", False
);
2200 if (prop
== None
) return False
;
2201 XChangeProperty (dpy
, w
, prop
, XA_ATOM
, 32, PropModeReplace
,
2202 (unsigned char *) protocols
, count
);
2205 #endif /* not HAVE_X11R4 && not HAVE_XSETWMPROTOCOLS */
2207 #ifdef USE_X_TOOLKIT
2209 /* If the WM_PROTOCOLS property does not already contain WM_TAKE_FOCUS,
2210 WM_DELETE_WINDOW, and WM_SAVE_YOURSELF, then add them. (They may
2211 already be present because of the toolkit (Motif adds some of them,
2212 for example, but Xt doesn't). */
2215 hack_wm_protocols (f
, widget
)
2219 Display
*dpy
= XtDisplay (widget
);
2220 Window w
= XtWindow (widget
);
2221 int need_delete
= 1;
2227 Atom type
, *atoms
= 0;
2229 unsigned long nitems
= 0;
2230 unsigned long bytes_after
;
2232 if (Success
== XGetWindowProperty (dpy
, w
,
2233 FRAME_X_DISPLAY_INFO (f
)->Xatom_wm_protocols
,
2234 0, 100, False
, XA_ATOM
,
2235 &type
, &format
, &nitems
, &bytes_after
,
2236 (unsigned char **) &atoms
)
2237 && format
== 32 && type
== XA_ATOM
)
2241 if (atoms
[nitems
] == FRAME_X_DISPLAY_INFO (f
)->Xatom_wm_delete_window
)
2243 else if (atoms
[nitems
] == FRAME_X_DISPLAY_INFO (f
)->Xatom_wm_take_focus
)
2245 else if (atoms
[nitems
] == FRAME_X_DISPLAY_INFO (f
)->Xatom_wm_save_yourself
)
2248 if (atoms
) XFree ((char *) atoms
);
2254 props
[count
++] = FRAME_X_DISPLAY_INFO (f
)->Xatom_wm_delete_window
;
2256 props
[count
++] = FRAME_X_DISPLAY_INFO (f
)->Xatom_wm_take_focus
;
2258 props
[count
++] = FRAME_X_DISPLAY_INFO (f
)->Xatom_wm_save_yourself
;
2260 XChangeProperty (dpy
, w
, FRAME_X_DISPLAY_INFO (f
)->Xatom_wm_protocols
,
2261 XA_ATOM
, 32, PropModeAppend
,
2262 (unsigned char *) props
, count
);
2268 #ifdef USE_X_TOOLKIT
2270 /* Create and set up the X widget for frame F. */
2273 x_window (f
, window_prompting
, minibuffer_only
)
2275 long window_prompting
;
2276 int minibuffer_only
;
2278 XClassHint class_hints
;
2279 XSetWindowAttributes attributes
;
2280 unsigned long attribute_mask
;
2282 Widget shell_widget
;
2284 Widget frame_widget
;
2291 if (STRINGP (f
->name
))
2292 name
= (char*) XSTRING (f
->name
)->data
;
2297 XtSetArg (al
[ac
], XtNallowShellResize
, 1); ac
++;
2298 XtSetArg (al
[ac
], XtNinput
, 1); ac
++;
2299 shell_widget
= XtAppCreateShell (name
, EMACS_CLASS
,
2300 topLevelShellWidgetClass
,
2301 FRAME_X_DISPLAY (f
), al
, ac
);
2303 f
->display
.x
->widget
= shell_widget
;
2304 /* maybe_set_screen_title_format (shell_widget); */
2306 pane_widget
= lw_create_widget ("main", "pane", widget_id_tick
++,
2307 (widget_value
*) NULL
,
2308 shell_widget
, False
,
2311 (lw_callback
) NULL
);
2313 f
->display
.x
->column_widget
= pane_widget
;
2315 if (!minibuffer_only
&& FRAME_EXTERNAL_MENU_BAR (f
))
2316 initialize_frame_menubar (f
);
2318 /* mappedWhenManaged to false tells to the paned window to not map/unmap
2319 the emacs screen when changing menubar. This reduces flickering. */
2322 XtSetArg (al
[ac
], XtNmappedWhenManaged
, 0); ac
++;
2323 XtSetArg (al
[ac
], XtNshowGrip
, 0); ac
++;
2324 XtSetArg (al
[ac
], XtNallowResize
, 1); ac
++;
2325 XtSetArg (al
[ac
], XtNresizeToPreferred
, 1); ac
++;
2326 XtSetArg (al
[ac
], XtNemacsFrame
, f
); ac
++;
2327 frame_widget
= XtCreateWidget (name
,
2329 pane_widget
, al
, ac
);
2330 lw_set_main_areas (pane_widget
, f
->display
.x
->menubar_widget
, frame_widget
);
2332 f
->display
.x
->edit_widget
= frame_widget
;
2334 if (f
->display
.x
->menubar_widget
)
2335 XtManageChild (f
->display
.x
->menubar_widget
);
2336 XtManageChild (frame_widget
);
2338 /* Do some needed geometry management. */
2341 char *tem
, shell_position
[32];
2345 = (f
->display
.x
->menubar_widget
2346 ? (f
->display
.x
->menubar_widget
->core
.height
2347 + f
->display
.x
->menubar_widget
->core
.border_width
)
2350 if (FRAME_EXTERNAL_MENU_BAR (f
))
2353 XtVaGetValues (pane_widget
, XtNinternalBorderWidth
, &ibw
, NULL
);
2354 menubar_size
+= ibw
;
2357 if (window_prompting
& USPosition
)
2359 int left
= f
->display
.x
->left_pos
;
2360 int xneg
= window_prompting
& XNegative
;
2361 int top
= f
->display
.x
->top_pos
;
2362 int yneg
= window_prompting
& YNegative
;
2367 sprintf (shell_position
, "=%dx%d%c%d%c%d", PIXEL_WIDTH (f
),
2368 PIXEL_HEIGHT (f
) + menubar_size
,
2369 (xneg
? '-' : '+'), left
,
2370 (yneg
? '-' : '+'), top
);
2373 sprintf (shell_position
, "=%dx%d", PIXEL_WIDTH (f
),
2374 PIXEL_HEIGHT (f
) + menubar_size
);
2375 len
= strlen (shell_position
) + 1;
2376 tem
= (char *) xmalloc (len
);
2377 strncpy (tem
, shell_position
, len
);
2378 XtSetArg (al
[ac
], XtNgeometry
, tem
); ac
++;
2379 XtSetValues (shell_widget
, al
, ac
);
2382 x_calc_absolute_position (f
);
2384 XtManageChild (pane_widget
);
2385 XtRealizeWidget (shell_widget
);
2387 FRAME_X_WINDOW (f
) = XtWindow (frame_widget
);
2389 validate_x_resource_name ();
2390 class_hints
.res_name
= (char *) XSTRING (Vx_resource_name
)->data
;
2391 class_hints
.res_class
= EMACS_CLASS
;
2392 XSetClassHint (FRAME_X_DISPLAY (f
), XtWindow (shell_widget
), &class_hints
);
2394 f
->display
.x
->wm_hints
.input
= True
;
2395 f
->display
.x
->wm_hints
.flags
|= InputHint
;
2396 XSetWMHints (FRAME_X_DISPLAY (f
), FRAME_X_WINDOW (f
),
2397 &f
->display
.x
->wm_hints
);
2399 hack_wm_protocols (f
, shell_widget
);
2402 XtAddEventHandler (shell_widget
, 0, True
, _XEditResCheckMessages
, 0);
2405 /* Do a stupid property change to force the server to generate a
2406 propertyNotify event so that the event_stream server timestamp will
2407 be initialized to something relevant to the time we created the window.
2409 XChangeProperty (XtDisplay (frame_widget
), XtWindow (frame_widget
),
2410 FRAME_X_DISPLAY_INFO (f
)->Xatom_wm_protocols
,
2411 XA_ATOM
, 32, PropModeAppend
,
2412 (unsigned char*) NULL
, 0);
2414 /* Make all the standard events reach the Emacs frame. */
2415 attributes
.event_mask
= STANDARD_EVENT_SET
;
2416 attribute_mask
= CWEventMask
;
2417 XChangeWindowAttributes (XtDisplay (shell_widget
), XtWindow (shell_widget
),
2418 attribute_mask
, &attributes
);
2420 XtMapWidget (frame_widget
);
2422 /* x_set_name normally ignores requests to set the name if the
2423 requested name is the same as the current name. This is the one
2424 place where that assumption isn't correct; f->name is set, but
2425 the X server hasn't been told. */
2428 int explicit = f
->explicit_name
;
2430 f
->explicit_name
= 0;
2433 x_set_name (f
, name
, explicit);
2436 XDefineCursor (FRAME_X_DISPLAY (f
), FRAME_X_WINDOW (f
),
2437 f
->display
.x
->text_cursor
);
2441 if (FRAME_X_WINDOW (f
) == 0)
2442 error ("Unable to create window");
2445 #else /* not USE_X_TOOLKIT */
2447 /* Create and set up the X window for frame F. */
2453 XClassHint class_hints
;
2454 XSetWindowAttributes attributes
;
2455 unsigned long attribute_mask
;
2457 attributes
.background_pixel
= f
->display
.x
->background_pixel
;
2458 attributes
.border_pixel
= f
->display
.x
->border_pixel
;
2459 attributes
.bit_gravity
= StaticGravity
;
2460 attributes
.backing_store
= NotUseful
;
2461 attributes
.save_under
= True
;
2462 attributes
.event_mask
= STANDARD_EVENT_SET
;
2463 attribute_mask
= (CWBackPixel
| CWBorderPixel
| CWBitGravity
2465 | CWBackingStore
| CWSaveUnder
2471 = XCreateWindow (FRAME_X_DISPLAY (f
),
2472 f
->display
.x
->parent_desc
,
2473 f
->display
.x
->left_pos
,
2474 f
->display
.x
->top_pos
,
2475 PIXEL_WIDTH (f
), PIXEL_HEIGHT (f
),
2476 f
->display
.x
->border_width
,
2477 CopyFromParent
, /* depth */
2478 InputOutput
, /* class */
2479 FRAME_X_DISPLAY_INFO (f
)->visual
,
2480 attribute_mask
, &attributes
);
2482 validate_x_resource_name ();
2483 class_hints
.res_name
= (char *) XSTRING (Vx_resource_name
)->data
;
2484 class_hints
.res_class
= EMACS_CLASS
;
2485 XSetClassHint (FRAME_X_DISPLAY (f
), FRAME_X_WINDOW (f
), &class_hints
);
2487 /* This indicates that we use the "Passive Input" input model.
2488 Unless we do this, we don't get the Focus{In,Out} events that we
2489 need to draw the cursor correctly. Accursed bureaucrats.
2490 XWhipsAndChains (FRAME_X_DISPLAY (f), IronMaiden, &TheRack); */
2492 f
->display
.x
->wm_hints
.input
= True
;
2493 f
->display
.x
->wm_hints
.flags
|= InputHint
;
2494 XSetWMHints (FRAME_X_DISPLAY (f
), FRAME_X_WINDOW (f
),
2495 &f
->display
.x
->wm_hints
);
2497 /* Request "save yourself" and "delete window" commands from wm. */
2500 protocols
[0] = FRAME_X_DISPLAY_INFO (f
)->Xatom_wm_delete_window
;
2501 protocols
[1] = FRAME_X_DISPLAY_INFO (f
)->Xatom_wm_save_yourself
;
2502 XSetWMProtocols (FRAME_X_DISPLAY (f
), FRAME_X_WINDOW (f
), protocols
, 2);
2505 /* x_set_name normally ignores requests to set the name if the
2506 requested name is the same as the current name. This is the one
2507 place where that assumption isn't correct; f->name is set, but
2508 the X server hasn't been told. */
2511 int explicit = f
->explicit_name
;
2513 f
->explicit_name
= 0;
2516 x_set_name (f
, name
, explicit);
2519 XDefineCursor (FRAME_X_DISPLAY (f
), FRAME_X_WINDOW (f
),
2520 f
->display
.x
->text_cursor
);
2524 if (FRAME_X_WINDOW (f
) == 0)
2525 error ("Unable to create window");
2528 #endif /* not USE_X_TOOLKIT */
2530 /* Handle the icon stuff for this window. Perhaps later we might
2531 want an x_set_icon_position which can be called interactively as
2539 Lisp_Object icon_x
, icon_y
;
2541 /* Set the position of the icon. Note that twm groups all
2542 icons in an icon window. */
2543 icon_x
= x_get_arg (parms
, Qicon_left
, 0, 0, number
);
2544 icon_y
= x_get_arg (parms
, Qicon_top
, 0, 0, number
);
2545 if (!EQ (icon_x
, Qunbound
) && !EQ (icon_y
, Qunbound
))
2547 CHECK_NUMBER (icon_x
, 0);
2548 CHECK_NUMBER (icon_y
, 0);
2550 else if (!EQ (icon_x
, Qunbound
) || !EQ (icon_y
, Qunbound
))
2551 error ("Both left and top icon corners of icon must be specified");
2555 if (! EQ (icon_x
, Qunbound
))
2556 x_wm_set_icon_position (f
, XINT (icon_x
), XINT (icon_y
));
2558 /* Start up iconic or window? */
2559 x_wm_set_window_state
2560 (f
, (EQ (x_get_arg (parms
, Qvisibility
, 0, 0, symbol
), Qicon
)
2567 /* Make the GC's needed for this window, setting the
2568 background, border and mouse colors; also create the
2569 mouse cursor and the gray border tile. */
2571 static char cursor_bits
[] =
2573 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2574 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2575 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2576 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
2583 XGCValues gc_values
;
2589 /* Create the GC's of this frame.
2590 Note that many default values are used. */
2593 gc_values
.font
= f
->display
.x
->font
->fid
;
2594 gc_values
.foreground
= f
->display
.x
->foreground_pixel
;
2595 gc_values
.background
= f
->display
.x
->background_pixel
;
2596 gc_values
.line_width
= 0; /* Means 1 using fast algorithm. */
2597 f
->display
.x
->normal_gc
= XCreateGC (FRAME_X_DISPLAY (f
),
2599 GCLineWidth
| GCFont
2600 | GCForeground
| GCBackground
,
2603 /* Reverse video style. */
2604 gc_values
.foreground
= f
->display
.x
->background_pixel
;
2605 gc_values
.background
= f
->display
.x
->foreground_pixel
;
2606 f
->display
.x
->reverse_gc
= XCreateGC (FRAME_X_DISPLAY (f
),
2608 GCFont
| GCForeground
| GCBackground
2612 /* Cursor has cursor-color background, background-color foreground. */
2613 gc_values
.foreground
= f
->display
.x
->background_pixel
;
2614 gc_values
.background
= f
->display
.x
->cursor_pixel
;
2615 gc_values
.fill_style
= FillOpaqueStippled
;
2617 = XCreateBitmapFromData (FRAME_X_DISPLAY (f
),
2618 FRAME_X_DISPLAY_INFO (f
)->root_window
,
2619 cursor_bits
, 16, 16);
2620 f
->display
.x
->cursor_gc
2621 = XCreateGC (FRAME_X_DISPLAY (f
), FRAME_X_WINDOW (f
),
2622 (GCFont
| GCForeground
| GCBackground
2623 | GCFillStyle
| GCStipple
| GCLineWidth
),
2626 /* Create the gray border tile used when the pointer is not in
2627 the frame. Since this depends on the frame's pixel values,
2628 this must be done on a per-frame basis. */
2629 f
->display
.x
->border_tile
2630 = (XCreatePixmapFromBitmapData
2631 (FRAME_X_DISPLAY (f
), FRAME_X_DISPLAY_INFO (f
)->root_window
,
2632 gray_bits
, gray_width
, gray_height
,
2633 f
->display
.x
->foreground_pixel
,
2634 f
->display
.x
->background_pixel
,
2635 DefaultDepth (FRAME_X_DISPLAY (f
),
2636 XScreenNumberOfScreen (FRAME_X_SCREEN (f
)))));
2641 DEFUN ("x-create-frame", Fx_create_frame
, Sx_create_frame
,
2643 "Make a new X window, which is called a \"frame\" in Emacs terms.\n\
2644 Returns an Emacs frame object.\n\
2645 ALIST is an alist of frame parameters.\n\
2646 If the parameters specify that the frame should not have a minibuffer,\n\
2647 and do not specify a specific minibuffer window to use,\n\
2648 then `default-minibuffer-frame' must be a frame whose minibuffer can\n\
2649 be shared by the new frame.\n\
2651 This function is an internal primitive--use `make-frame' instead.")
2656 Lisp_Object frame
, tem
;
2658 int minibuffer_only
= 0;
2659 long window_prompting
= 0;
2661 int count
= specpdl_ptr
- specpdl
;
2662 struct gcpro gcpro1
;
2663 Lisp_Object display
;
2664 struct x_display_info
*dpyinfo
;
2669 display
= x_get_arg (parms
, Qdisplay
, 0, 0, 0);
2670 if (EQ (display
, Qunbound
))
2672 dpyinfo
= check_x_display_info (display
);
2674 name
= x_get_arg (parms
, Qname
, "title", "Title", string
);
2676 && ! EQ (name
, Qunbound
)
2678 error ("Invalid frame name--not a string or nil");
2680 /* See if parent window is specified. */
2681 parent
= x_get_arg (parms
, Qparent_id
, NULL
, NULL
, number
);
2682 if (EQ (parent
, Qunbound
))
2684 if (! NILP (parent
))
2685 CHECK_NUMBER (parent
, 0);
2687 tem
= x_get_arg (parms
, Qminibuffer
, 0, 0, symbol
);
2688 if (EQ (tem
, Qnone
) || NILP (tem
))
2689 f
= make_frame_without_minibuffer (Qnil
);
2690 else if (EQ (tem
, Qonly
))
2692 f
= make_minibuffer_frame ();
2693 minibuffer_only
= 1;
2695 else if (WINDOWP (tem
))
2696 f
= make_frame_without_minibuffer (tem
);
2700 /* Note that X Windows does support scroll bars. */
2701 FRAME_CAN_HAVE_SCROLL_BARS (f
) = 1;
2703 XSETFRAME (frame
, f
);
2706 f
->output_method
= output_x_window
;
2707 f
->display
.x
= (struct x_display
*) xmalloc (sizeof (struct x_display
));
2708 bzero (f
->display
.x
, sizeof (struct x_display
));
2709 f
->display
.x
->icon_bitmap
= -1;
2711 FRAME_X_DISPLAY_INFO (f
) = dpyinfo
;
2713 FRAME_KBOARD (f
) = dpyinfo
->kboard
;
2716 /* Specify the parent under which to make this X window. */
2720 f
->display
.x
->parent_desc
= parent
;
2721 f
->display
.x
->explicit_parent
= 1;
2725 f
->display
.x
->parent_desc
= FRAME_X_DISPLAY_INFO (f
)->root_window
;
2726 f
->display
.x
->explicit_parent
= 0;
2729 /* Note that the frame has no physical cursor right now. */
2730 f
->phys_cursor_x
= -1;
2732 /* Set the name; the functions to which we pass f expect the name to
2734 if (EQ (name
, Qunbound
) || NILP (name
))
2736 f
->name
= build_string (dpyinfo
->x_id_name
);
2737 f
->explicit_name
= 0;
2742 f
->explicit_name
= 1;
2743 /* use the frame's title when getting resources for this frame. */
2744 specbind (Qx_resource_name
, name
);
2747 /* Extract the window parameters from the supplied values
2748 that are needed to determine window geometry. */
2752 font
= x_get_arg (parms
, Qfont
, "font", "Font", string
);
2754 /* First, try whatever font the caller has specified. */
2756 font
= x_new_font (f
, XSTRING (font
)->data
);
2757 /* Try out a font which we hope has bold and italic variations. */
2758 if (!STRINGP (font
))
2759 font
= x_new_font (f
, "-misc-fixed-medium-r-normal-*-*-140-*-*-c-*-iso8859-1");
2760 if (! STRINGP (font
))
2761 font
= x_new_font (f
, "-*-*-medium-r-normal-*-*-140-*-*-c-*-iso8859-1");
2762 if (! STRINGP (font
))
2763 /* This was formerly the first thing tried, but it finds too many fonts
2764 and takes too long. */
2765 font
= x_new_font (f
, "-*-*-medium-r-*-*-*-*-*-*-c-*-iso8859-1");
2766 /* If those didn't work, look for something which will at least work. */
2767 if (! STRINGP (font
))
2768 font
= x_new_font (f
, "-*-fixed-*-*-*-*-*-140-*-*-c-*-iso8859-1");
2770 if (! STRINGP (font
))
2771 font
= build_string ("fixed");
2773 x_default_parameter (f
, parms
, Qfont
, font
,
2774 "font", "Font", string
);
2777 #ifdef USE_X_TOOLKIT
2778 /* Prevent lwlib/xlwmenu.c from crashing because of a bug
2779 whereby it fails to get any font. */
2780 xlwmenu_default_font
= f
->display
.x
->font
;
2783 x_default_parameter (f
, parms
, Qborder_width
, make_number (2),
2784 "borderwidth", "BorderWidth", number
);
2785 /* This defaults to 2 in order to match xterm. We recognize either
2786 internalBorderWidth or internalBorder (which is what xterm calls
2788 if (NILP (Fassq (Qinternal_border_width
, parms
)))
2792 value
= x_get_arg (parms
, Qinternal_border_width
,
2793 "internalBorder", "BorderWidth", number
);
2794 if (! EQ (value
, Qunbound
))
2795 parms
= Fcons (Fcons (Qinternal_border_width
, value
),
2798 x_default_parameter (f
, parms
, Qinternal_border_width
, make_number (2),
2799 "internalBorderWidth", "BorderWidth", number
);
2800 x_default_parameter (f
, parms
, Qvertical_scroll_bars
, Qt
,
2801 "verticalScrollBars", "ScrollBars", boolean
);
2803 /* Also do the stuff which must be set before the window exists. */
2804 x_default_parameter (f
, parms
, Qforeground_color
, build_string ("black"),
2805 "foreground", "Foreground", string
);
2806 x_default_parameter (f
, parms
, Qbackground_color
, build_string ("white"),
2807 "background", "Background", string
);
2808 x_default_parameter (f
, parms
, Qmouse_color
, build_string ("black"),
2809 "pointerColor", "Foreground", string
);
2810 x_default_parameter (f
, parms
, Qcursor_color
, build_string ("black"),
2811 "cursorColor", "Foreground", string
);
2812 x_default_parameter (f
, parms
, Qborder_color
, build_string ("black"),
2813 "borderColor", "BorderColor", string
);
2815 x_default_parameter (f
, parms
, Qmenu_bar_lines
, make_number (1),
2816 "menuBar", "MenuBar", number
);
2817 x_default_parameter (f
, parms
, Qscroll_bar_width
, Qnil
,
2818 "scrollBarWidth", "ScrollBarWidth", number
);
2820 f
->display
.x
->parent_desc
= FRAME_X_DISPLAY_INFO (f
)->root_window
;
2821 window_prompting
= x_figure_window_size (f
, parms
);
2823 if (window_prompting
& XNegative
)
2825 if (window_prompting
& YNegative
)
2826 f
->display
.x
->win_gravity
= SouthEastGravity
;
2828 f
->display
.x
->win_gravity
= NorthEastGravity
;
2832 if (window_prompting
& YNegative
)
2833 f
->display
.x
->win_gravity
= SouthWestGravity
;
2835 f
->display
.x
->win_gravity
= NorthWestGravity
;
2838 f
->display
.x
->size_hint_flags
= window_prompting
;
2840 #ifdef USE_X_TOOLKIT
2841 x_window (f
, window_prompting
, minibuffer_only
);
2847 init_frame_faces (f
);
2849 /* We need to do this after creating the X window, so that the
2850 icon-creation functions can say whose icon they're describing. */
2851 x_default_parameter (f
, parms
, Qicon_type
, Qnil
,
2852 "bitmapIcon", "BitmapIcon", symbol
);
2854 x_default_parameter (f
, parms
, Qauto_raise
, Qnil
,
2855 "autoRaise", "AutoRaiseLower", boolean
);
2856 x_default_parameter (f
, parms
, Qauto_lower
, Qnil
,
2857 "autoLower", "AutoRaiseLower", boolean
);
2858 x_default_parameter (f
, parms
, Qcursor_type
, Qbox
,
2859 "cursorType", "CursorType", symbol
);
2861 /* Dimensions, especially f->height, must be done via change_frame_size.
2862 Change will not be effected unless different from the current
2866 f
->height
= f
->width
= 0;
2867 change_frame_size (f
, height
, width
, 1, 0);
2869 /* With the toolkit, the geometry management is done in x_window. */
2870 #ifndef USE_X_TOOLKIT
2872 x_wm_set_size_hint (f
, window_prompting
, 0);
2874 #endif /* USE_X_TOOLKIT */
2876 tem
= x_get_arg (parms
, Qunsplittable
, 0, 0, boolean
);
2877 f
->no_split
= minibuffer_only
|| EQ (tem
, Qt
);
2881 /* It is now ok to make the frame official
2882 even if we get an error below.
2883 And the frame needs to be on Vframe_list
2884 or making it visible won't work. */
2885 Vframe_list
= Fcons (frame
, Vframe_list
);
2887 /* Now that the frame is official, it counts as a reference to
2889 FRAME_X_DISPLAY_INFO (f
)->reference_count
++;
2891 /* Make the window appear on the frame and enable display,
2892 unless the caller says not to. However, with explicit parent,
2893 Emacs cannot control visibility, so don't try. */
2894 if (! f
->display
.x
->explicit_parent
)
2896 Lisp_Object visibility
;
2898 visibility
= x_get_arg (parms
, Qvisibility
, 0, 0, symbol
);
2899 if (EQ (visibility
, Qunbound
))
2902 if (EQ (visibility
, Qicon
))
2903 x_iconify_frame (f
);
2904 else if (! NILP (visibility
))
2905 x_make_frame_visible (f
);
2907 /* Must have been Qnil. */
2911 return unbind_to (count
, frame
);
2915 x_get_focus_frame ()
2918 if (! x_focus_frame
)
2921 XSETFRAME (xfocus
, x_focus_frame
);
2925 DEFUN ("focus-frame", Ffocus_frame
, Sfocus_frame
, 1, 1, 0,
2926 "Set the focus on FRAME.")
2930 CHECK_LIVE_FRAME (frame
, 0);
2932 if (FRAME_X_P (XFRAME (frame
)))
2935 x_focus_on_frame (XFRAME (frame
));
2943 DEFUN ("unfocus-frame", Funfocus_frame
, Sunfocus_frame
, 0, 0, 0,
2944 "If a frame has been focused, release it.")
2950 x_unfocus_frame (x_focus_frame
);
2957 DEFUN ("x-list-fonts", Fx_list_fonts
, Sx_list_fonts
, 1, 3, 0,
2958 "Return a list of the names of available fonts matching PATTERN.\n\
2959 If optional arguments FACE and FRAME are specified, return only fonts\n\
2960 the same size as FACE on FRAME.\n\
2962 PATTERN is a string, perhaps with wildcard characters;\n\
2963 the * character matches any substring, and\n\
2964 the ? character matches any single character.\n\
2965 PATTERN is case-insensitive.\n\
2966 FACE is a face name--a symbol.\n\
2968 The return value is a list of strings, suitable as arguments to\n\
2971 Fonts Emacs can't use (i.e. proportional fonts) may or may not be excluded\n\
2972 even if they match PATTERN and FACE.")
2973 (pattern
, face
, frame
)
2974 Lisp_Object pattern
, face
, frame
;
2978 #ifndef BROKEN_XLISTFONTSWITHINFO
2981 XFontStruct
*size_ref
;
2986 CHECK_STRING (pattern
, 0);
2988 CHECK_SYMBOL (face
, 1);
2990 f
= check_x_frame (frame
);
2992 /* Determine the width standard for comparison with the fonts we find. */
3000 /* Don't die if we get called with a terminal frame. */
3001 if (! FRAME_X_P (f
))
3002 error ("non-X frame used in `x-list-fonts'");
3004 face_id
= face_name_id_number (f
, face
);
3006 if (face_id
< 0 || face_id
>= FRAME_N_PARAM_FACES (f
)
3007 || FRAME_PARAM_FACES (f
) [face_id
] == 0)
3008 size_ref
= f
->display
.x
->font
;
3011 size_ref
= FRAME_PARAM_FACES (f
) [face_id
]->font
;
3012 if (size_ref
== (XFontStruct
*) (~0))
3013 size_ref
= f
->display
.x
->font
;
3017 /* See if we cached the result for this particular query. */
3018 list
= Fassoc (pattern
,
3019 XCONS (FRAME_X_DISPLAY_INFO (f
)->name_list_element
)->cdr
);
3021 /* We have info in the cache for this PATTERN. */
3024 Lisp_Object tem
, newlist
;
3026 /* We have info about this pattern. */
3027 list
= XCONS (list
)->cdr
;
3034 /* Filter the cached info and return just the fonts that match FACE. */
3036 for (tem
= list
; CONSP (tem
); tem
= XCONS (tem
)->cdr
)
3038 XFontStruct
*thisinfo
;
3040 thisinfo
= XLoadQueryFont (FRAME_X_DISPLAY (f
),
3041 XSTRING (XCONS (tem
)->car
)->data
);
3043 if (thisinfo
&& same_size_fonts (thisinfo
, size_ref
))
3044 newlist
= Fcons (XCONS (tem
)->car
, newlist
);
3046 XFreeFont (FRAME_X_DISPLAY (f
), thisinfo
);
3056 /* Solaris 2.3 has a bug in XListFontsWithInfo. */
3057 #ifndef BROKEN_XLISTFONTSWITHINFO
3059 names
= XListFontsWithInfo (FRAME_X_DISPLAY (f
),
3060 XSTRING (pattern
)->data
,
3061 2000, /* maxnames */
3062 &num_fonts
, /* count_return */
3063 &info
); /* info_return */
3066 names
= XListFonts (FRAME_X_DISPLAY (f
),
3067 XSTRING (pattern
)->data
,
3068 2000, /* maxnames */
3069 &num_fonts
); /* count_return */
3078 Lisp_Object full_list
;
3080 /* Make a list of all the fonts we got back.
3081 Store that in the font cache for the display. */
3083 for (i
= 0; i
< num_fonts
; i
++)
3084 full_list
= Fcons (build_string (names
[i
]), full_list
);
3085 XCONS (FRAME_X_DISPLAY_INFO (f
)->name_list_element
)->cdr
3086 = Fcons (Fcons (pattern
, full_list
),
3087 XCONS (FRAME_X_DISPLAY_INFO (f
)->name_list_element
)->cdr
);
3089 /* Make a list of the fonts that have the right width. */
3091 for (i
= 0; i
< num_fonts
; i
++)
3099 #ifdef BROKEN_XLISTFONTSWITHINFO
3100 XFontStruct
*thisinfo
;
3103 thisinfo
= XLoadQueryFont (FRAME_X_DISPLAY (f
), names
[i
]);
3106 keeper
= thisinfo
&& same_size_fonts (thisinfo
, size_ref
);
3108 keeper
= same_size_fonts (&info
[i
], size_ref
);
3112 list
= Fcons (build_string (names
[i
]), list
);
3114 list
= Fnreverse (list
);
3117 #ifndef BROKEN_XLISTFONTSWITHINFO
3119 XFreeFontInfo (names
, info
, num_fonts
);
3122 XFreeFontNames (names
);
3130 DEFUN ("x-color-defined-p", Fx_color_defined_p
, Sx_color_defined_p
, 1, 2, 0,
3131 "Return non-nil color COLOR is supported on frame FRAME.\n\
3132 If FRAME is omitted or nil, use the selected frame.")
3134 Lisp_Object color
, frame
;
3137 FRAME_PTR f
= check_x_frame (frame
);
3139 CHECK_STRING (color
, 1);
3141 if (defined_color (f
, XSTRING (color
)->data
, &foo
, 0))
3147 DEFUN ("x-color-values", Fx_color_values
, Sx_color_values
, 1, 2, 0,
3148 "Return a description of the color named COLOR on frame FRAME.\n\
3149 The value is a list of integer RGB values--(RED GREEN BLUE).\n\
3150 These values appear to range from 0 to 65280 or 65535, depending\n\
3151 on the system; white is (65280 65280 65280) or (65535 65535 65535).\n\
3152 If FRAME is omitted or nil, use the selected frame.")
3154 Lisp_Object color
, frame
;
3157 FRAME_PTR f
= check_x_frame (frame
);
3159 CHECK_STRING (color
, 1);
3161 if (defined_color (f
, XSTRING (color
)->data
, &foo
, 0))
3165 rgb
[0] = make_number (foo
.red
);
3166 rgb
[1] = make_number (foo
.green
);
3167 rgb
[2] = make_number (foo
.blue
);
3168 return Flist (3, rgb
);
3174 DEFUN ("x-display-color-p", Fx_display_color_p
, Sx_display_color_p
, 0, 1, 0,
3175 "Return t if the X display supports color.\n\
3176 The optional argument DISPLAY specifies which display to ask about.\n\
3177 DISPLAY should be either a frame or a display name (a string).\n\
3178 If omitted or nil, that stands for the selected frame's display.")
3180 Lisp_Object display
;
3182 struct x_display_info
*dpyinfo
= check_x_display_info (display
);
3184 if (dpyinfo
->n_planes
<= 2)
3187 switch (dpyinfo
->visual
->class)
3200 DEFUN ("x-display-grayscale-p", Fx_display_grayscale_p
, Sx_display_grayscale_p
,
3202 "Return t if the X display supports shades of gray.\n\
3203 The optional argument DISPLAY specifies which display to ask about.\n\
3204 DISPLAY should be either a frame or a display name (a string).\n\
3205 If omitted or nil, that stands for the selected frame's display.")
3207 Lisp_Object display
;
3209 struct x_display_info
*dpyinfo
= check_x_display_info (display
);
3211 if (dpyinfo
->n_planes
<= 2)
3214 return (dpyinfo
->n_planes
> 1
3215 && (dpyinfo
->visual
->class == StaticGray
3216 || dpyinfo
->visual
->class == GrayScale
));
3219 DEFUN ("x-display-pixel-width", Fx_display_pixel_width
, Sx_display_pixel_width
,
3221 "Returns the width in pixels of the X display DISPLAY.\n\
3222 The optional argument DISPLAY specifies which display to ask about.\n\
3223 DISPLAY should be either a frame or a display name (a string).\n\
3224 If omitted or nil, that stands for the selected frame's display.")
3226 Lisp_Object display
;
3228 struct x_display_info
*dpyinfo
= check_x_display_info (display
);
3230 return make_number (dpyinfo
->width
);
3233 DEFUN ("x-display-pixel-height", Fx_display_pixel_height
,
3234 Sx_display_pixel_height
, 0, 1, 0,
3235 "Returns the height in pixels of the X display DISPLAY.\n\
3236 The optional argument DISPLAY specifies which display to ask about.\n\
3237 DISPLAY should be either a frame or a display name (a string).\n\
3238 If omitted or nil, that stands for the selected frame's display.")
3240 Lisp_Object display
;
3242 struct x_display_info
*dpyinfo
= check_x_display_info (display
);
3244 return make_number (dpyinfo
->height
);
3247 DEFUN ("x-display-planes", Fx_display_planes
, Sx_display_planes
,
3249 "Returns the number of bitplanes of the X display DISPLAY.\n\
3250 The optional argument DISPLAY specifies which display to ask about.\n\
3251 DISPLAY should be either a frame or a display name (a string).\n\
3252 If omitted or nil, that stands for the selected frame's display.")
3254 Lisp_Object display
;
3256 struct x_display_info
*dpyinfo
= check_x_display_info (display
);
3258 return make_number (dpyinfo
->n_planes
);
3261 DEFUN ("x-display-color-cells", Fx_display_color_cells
, Sx_display_color_cells
,
3263 "Returns the number of color cells of the X display DISPLAY.\n\
3264 The optional argument DISPLAY specifies which display to ask about.\n\
3265 DISPLAY should be either a frame or a display name (a string).\n\
3266 If omitted or nil, that stands for the selected frame's display.")
3268 Lisp_Object display
;
3270 struct x_display_info
*dpyinfo
= check_x_display_info (display
);
3272 return make_number (DisplayCells (dpyinfo
->display
,
3273 XScreenNumberOfScreen (dpyinfo
->screen
)));
3276 DEFUN ("x-server-max-request-size", Fx_server_max_request_size
,
3277 Sx_server_max_request_size
,
3279 "Returns the maximum request size of the X server of display DISPLAY.\n\
3280 The optional argument DISPLAY specifies which display to ask about.\n\
3281 DISPLAY should be either a frame or a display name (a string).\n\
3282 If omitted or nil, that stands for the selected frame's display.")
3284 Lisp_Object display
;
3286 struct x_display_info
*dpyinfo
= check_x_display_info (display
);
3288 return make_number (MAXREQUEST (dpyinfo
->display
));
3291 DEFUN ("x-server-vendor", Fx_server_vendor
, Sx_server_vendor
, 0, 1, 0,
3292 "Returns the vendor ID string of the X server of display DISPLAY.\n\
3293 The optional argument DISPLAY specifies which display to ask about.\n\
3294 DISPLAY should be either a frame or a display name (a string).\n\
3295 If omitted or nil, that stands for the selected frame's display.")
3297 Lisp_Object display
;
3299 struct x_display_info
*dpyinfo
= check_x_display_info (display
);
3300 char *vendor
= ServerVendor (dpyinfo
->display
);
3302 if (! vendor
) vendor
= "";
3303 return build_string (vendor
);
3306 DEFUN ("x-server-version", Fx_server_version
, Sx_server_version
, 0, 1, 0,
3307 "Returns the version numbers of the X server of display DISPLAY.\n\
3308 The value is a list of three integers: the major and minor\n\
3309 version numbers of the X Protocol in use, and the vendor-specific release\n\
3310 number. See also the function `x-server-vendor'.\n\n\
3311 The optional argument DISPLAY specifies which display to ask about.\n\
3312 DISPLAY should be either a frame or a display name (a string).\n\
3313 If omitted or nil, that stands for the selected frame's display.")
3315 Lisp_Object display
;
3317 struct x_display_info
*dpyinfo
= check_x_display_info (display
);
3318 Display
*dpy
= dpyinfo
->display
;
3320 return Fcons (make_number (ProtocolVersion (dpy
)),
3321 Fcons (make_number (ProtocolRevision (dpy
)),
3322 Fcons (make_number (VendorRelease (dpy
)), Qnil
)));
3325 DEFUN ("x-display-screens", Fx_display_screens
, Sx_display_screens
, 0, 1, 0,
3326 "Returns the number of screens on the X server of display DISPLAY.\n\
3327 The optional argument DISPLAY specifies which display to ask about.\n\
3328 DISPLAY should be either a frame or a display name (a string).\n\
3329 If omitted or nil, that stands for the selected frame's display.")
3331 Lisp_Object display
;
3333 struct x_display_info
*dpyinfo
= check_x_display_info (display
);
3335 return make_number (ScreenCount (dpyinfo
->display
));
3338 DEFUN ("x-display-mm-height", Fx_display_mm_height
, Sx_display_mm_height
, 0, 1, 0,
3339 "Returns the height in millimeters of the X display DISPLAY.\n\
3340 The optional argument DISPLAY specifies which display to ask about.\n\
3341 DISPLAY should be either a frame or a display name (a string).\n\
3342 If omitted or nil, that stands for the selected frame's display.")
3344 Lisp_Object display
;
3346 struct x_display_info
*dpyinfo
= check_x_display_info (display
);
3348 return make_number (HeightMMOfScreen (dpyinfo
->screen
));
3351 DEFUN ("x-display-mm-width", Fx_display_mm_width
, Sx_display_mm_width
, 0, 1, 0,
3352 "Returns the width in millimeters of the X display DISPLAY.\n\
3353 The optional argument DISPLAY specifies which display to ask about.\n\
3354 DISPLAY should be either a frame or a display name (a string).\n\
3355 If omitted or nil, that stands for the selected frame's display.")
3357 Lisp_Object display
;
3359 struct x_display_info
*dpyinfo
= check_x_display_info (display
);
3361 return make_number (WidthMMOfScreen (dpyinfo
->screen
));
3364 DEFUN ("x-display-backing-store", Fx_display_backing_store
,
3365 Sx_display_backing_store
, 0, 1, 0,
3366 "Returns an indication of whether X display DISPLAY does backing store.\n\
3367 The value may be `always', `when-mapped', or `not-useful'.\n\
3368 The optional argument DISPLAY specifies which display to ask about.\n\
3369 DISPLAY should be either a frame or a display name (a string).\n\
3370 If omitted or nil, that stands for the selected frame's display.")
3372 Lisp_Object display
;
3374 struct x_display_info
*dpyinfo
= check_x_display_info (display
);
3376 switch (DoesBackingStore (dpyinfo
->screen
))
3379 return intern ("always");
3382 return intern ("when-mapped");
3385 return intern ("not-useful");
3388 error ("Strange value for BackingStore parameter of screen");
3392 DEFUN ("x-display-visual-class", Fx_display_visual_class
,
3393 Sx_display_visual_class
, 0, 1, 0,
3394 "Returns the visual class of the X display DISPLAY.\n\
3395 The value is one of the symbols `static-gray', `gray-scale',\n\
3396 `static-color', `pseudo-color', `true-color', or `direct-color'.\n\n\
3397 The optional argument DISPLAY specifies which display to ask about.\n\
3398 DISPLAY should be either a frame or a display name (a string).\n\
3399 If omitted or nil, that stands for the selected frame's display.")
3401 Lisp_Object display
;
3403 struct x_display_info
*dpyinfo
= check_x_display_info (display
);
3405 switch (dpyinfo
->visual
->class)
3407 case StaticGray
: return (intern ("static-gray"));
3408 case GrayScale
: return (intern ("gray-scale"));
3409 case StaticColor
: return (intern ("static-color"));
3410 case PseudoColor
: return (intern ("pseudo-color"));
3411 case TrueColor
: return (intern ("true-color"));
3412 case DirectColor
: return (intern ("direct-color"));
3414 error ("Display has an unknown visual class");
3418 DEFUN ("x-display-save-under", Fx_display_save_under
,
3419 Sx_display_save_under
, 0, 1, 0,
3420 "Returns t if the X display DISPLAY supports the save-under feature.\n\
3421 The optional argument DISPLAY specifies which display to ask about.\n\
3422 DISPLAY should be either a frame or a display name (a string).\n\
3423 If omitted or nil, that stands for the selected frame's display.")
3425 Lisp_Object display
;
3427 struct x_display_info
*dpyinfo
= check_x_display_info (display
);
3429 if (DoesSaveUnders (dpyinfo
->screen
) == True
)
3437 register struct frame
*f
;
3439 return PIXEL_WIDTH (f
);
3444 register struct frame
*f
;
3446 return PIXEL_HEIGHT (f
);
3451 register struct frame
*f
;
3453 return FONT_WIDTH (f
->display
.x
->font
);
3458 register struct frame
*f
;
3460 return f
->display
.x
->line_height
;
3464 x_screen_planes (frame
)
3467 return FRAME_X_DISPLAY_INFO (XFRAME (frame
))->n_planes
;
3470 #if 0 /* These no longer seem like the right way to do things. */
3472 /* Draw a rectangle on the frame with left top corner including
3473 the character specified by LEFT_CHAR and TOP_CHAR. The rectangle is
3474 CHARS by LINES wide and long and is the color of the cursor. */
3477 x_rectangle (f
, gc
, left_char
, top_char
, chars
, lines
)
3478 register struct frame
*f
;
3480 register int top_char
, left_char
, chars
, lines
;
3484 int left
= (left_char
* FONT_WIDTH (f
->display
.x
->font
)
3485 + f
->display
.x
->internal_border_width
);
3486 int top
= (top_char
* f
->display
.x
->line_height
3487 + f
->display
.x
->internal_border_width
);
3490 width
= FONT_WIDTH (f
->display
.x
->font
) / 2;
3492 width
= FONT_WIDTH (f
->display
.x
->font
) * chars
;
3494 height
= f
->display
.x
->line_height
/ 2;
3496 height
= f
->display
.x
->line_height
* lines
;
3498 XDrawRectangle (FRAME_X_DISPLAY (f
), FRAME_X_WINDOW (f
),
3499 gc
, left
, top
, width
, height
);
3502 DEFUN ("x-draw-rectangle", Fx_draw_rectangle
, Sx_draw_rectangle
, 5, 5, 0,
3503 "Draw a rectangle on FRAME between coordinates specified by\n\
3504 numbers X0, Y0, X1, Y1 in the cursor pixel.")
3505 (frame
, X0
, Y0
, X1
, Y1
)
3506 register Lisp_Object frame
, X0
, X1
, Y0
, Y1
;
3508 register int x0
, y0
, x1
, y1
, top
, left
, n_chars
, n_lines
;
3510 CHECK_LIVE_FRAME (frame
, 0);
3511 CHECK_NUMBER (X0
, 0);
3512 CHECK_NUMBER (Y0
, 1);
3513 CHECK_NUMBER (X1
, 2);
3514 CHECK_NUMBER (Y1
, 3);
3524 n_lines
= y1
- y0
+ 1;
3529 n_lines
= y0
- y1
+ 1;
3535 n_chars
= x1
- x0
+ 1;
3540 n_chars
= x0
- x1
+ 1;
3544 x_rectangle (XFRAME (frame
), XFRAME (frame
)->display
.x
->cursor_gc
,
3545 left
, top
, n_chars
, n_lines
);
3551 DEFUN ("x-erase-rectangle", Fx_erase_rectangle
, Sx_erase_rectangle
, 5, 5, 0,
3552 "Draw a rectangle drawn on FRAME between coordinates\n\
3553 X0, Y0, X1, Y1 in the regular background-pixel.")
3554 (frame
, X0
, Y0
, X1
, Y1
)
3555 register Lisp_Object frame
, X0
, Y0
, X1
, Y1
;
3557 register int x0
, y0
, x1
, y1
, top
, left
, n_chars
, n_lines
;
3559 CHECK_LIVE_FRAME (frame
, 0);
3560 CHECK_NUMBER (X0
, 0);
3561 CHECK_NUMBER (Y0
, 1);
3562 CHECK_NUMBER (X1
, 2);
3563 CHECK_NUMBER (Y1
, 3);
3573 n_lines
= y1
- y0
+ 1;
3578 n_lines
= y0
- y1
+ 1;
3584 n_chars
= x1
- x0
+ 1;
3589 n_chars
= x0
- x1
+ 1;
3593 x_rectangle (XFRAME (frame
), XFRAME (frame
)->display
.x
->reverse_gc
,
3594 left
, top
, n_chars
, n_lines
);
3600 /* Draw lines around the text region beginning at the character position
3601 TOP_X, TOP_Y and ending at BOTTOM_X and BOTTOM_Y. GC specifies the
3602 pixel and line characteristics. */
3604 #define line_len(line) (FRAME_CURRENT_GLYPHS (f)->used[(line)])
3607 outline_region (f
, gc
, top_x
, top_y
, bottom_x
, bottom_y
)
3608 register struct frame
*f
;
3610 int top_x
, top_y
, bottom_x
, bottom_y
;
3612 register int ibw
= f
->display
.x
->internal_border_width
;
3613 register int font_w
= FONT_WIDTH (f
->display
.x
->font
);
3614 register int font_h
= f
->display
.x
->line_height
;
3616 int x
= line_len (y
);
3617 XPoint
*pixel_points
3618 = (XPoint
*) alloca (((bottom_y
- top_y
+ 2) * 4) * sizeof (XPoint
));
3619 register XPoint
*this_point
= pixel_points
;
3621 /* Do the horizontal top line/lines */
3624 this_point
->x
= ibw
;
3625 this_point
->y
= ibw
+ (font_h
* top_y
);
3628 this_point
->x
= ibw
+ (font_w
/ 2); /* Half-size for newline chars. */
3630 this_point
->x
= ibw
+ (font_w
* x
);
3631 this_point
->y
= (this_point
- 1)->y
;
3635 this_point
->x
= ibw
;
3636 this_point
->y
= ibw
+ (font_h
* (top_y
+ 1));
3638 this_point
->x
= ibw
+ (font_w
* top_x
);
3639 this_point
->y
= (this_point
- 1)->y
;
3641 this_point
->x
= (this_point
- 1)->x
;
3642 this_point
->y
= ibw
+ (font_h
* top_y
);
3644 this_point
->x
= ibw
+ (font_w
* x
);
3645 this_point
->y
= (this_point
- 1)->y
;
3648 /* Now do the right side. */
3649 while (y
< bottom_y
)
3650 { /* Right vertical edge */
3652 this_point
->x
= (this_point
- 1)->x
;
3653 this_point
->y
= ibw
+ (font_h
* (y
+ 1));
3656 y
++; /* Horizontal connection to next line */
3659 this_point
->x
= ibw
+ (font_w
/ 2);
3661 this_point
->x
= ibw
+ (font_w
* x
);
3663 this_point
->y
= (this_point
- 1)->y
;
3666 /* Now do the bottom and connect to the top left point. */
3667 this_point
->x
= ibw
+ (font_w
* (bottom_x
+ 1));
3670 this_point
->x
= (this_point
- 1)->x
;
3671 this_point
->y
= ibw
+ (font_h
* (bottom_y
+ 1));
3673 this_point
->x
= ibw
;
3674 this_point
->y
= (this_point
- 1)->y
;
3676 this_point
->x
= pixel_points
->x
;
3677 this_point
->y
= pixel_points
->y
;
3679 XDrawLines (FRAME_X_DISPLAY (f
), FRAME_X_WINDOW (f
),
3681 (this_point
- pixel_points
+ 1), CoordModeOrigin
);
3684 DEFUN ("x-contour-region", Fx_contour_region
, Sx_contour_region
, 1, 1, 0,
3685 "Highlight the region between point and the character under the mouse\n\
3688 register Lisp_Object event
;
3690 register int x0
, y0
, x1
, y1
;
3691 register struct frame
*f
= selected_frame
;
3692 register int p1
, p2
;
3694 CHECK_CONS (event
, 0);
3697 x0
= XINT (Fcar (Fcar (event
)));
3698 y0
= XINT (Fcar (Fcdr (Fcar (event
))));
3700 /* If the mouse is past the end of the line, don't that area. */
3701 /* ReWrite this... */
3706 if (y1
> y0
) /* point below mouse */
3707 outline_region (f
, f
->display
.x
->cursor_gc
,
3709 else if (y1
< y0
) /* point above mouse */
3710 outline_region (f
, f
->display
.x
->cursor_gc
,
3712 else /* same line: draw horizontal rectangle */
3715 x_rectangle (f
, f
->display
.x
->cursor_gc
,
3716 x0
, y0
, (x1
- x0
+ 1), 1);
3718 x_rectangle (f
, f
->display
.x
->cursor_gc
,
3719 x1
, y1
, (x0
- x1
+ 1), 1);
3722 XFlush (FRAME_X_DISPLAY (f
));
3728 DEFUN ("x-uncontour-region", Fx_uncontour_region
, Sx_uncontour_region
, 1, 1, 0,
3729 "Erase any highlighting of the region between point and the character\n\
3730 at X, Y on the selected frame.")
3732 register Lisp_Object event
;
3734 register int x0
, y0
, x1
, y1
;
3735 register struct frame
*f
= selected_frame
;
3738 x0
= XINT (Fcar (Fcar (event
)));
3739 y0
= XINT (Fcar (Fcdr (Fcar (event
))));
3743 if (y1
> y0
) /* point below mouse */
3744 outline_region (f
, f
->display
.x
->reverse_gc
,
3746 else if (y1
< y0
) /* point above mouse */
3747 outline_region (f
, f
->display
.x
->reverse_gc
,
3749 else /* same line: draw horizontal rectangle */
3752 x_rectangle (f
, f
->display
.x
->reverse_gc
,
3753 x0
, y0
, (x1
- x0
+ 1), 1);
3755 x_rectangle (f
, f
->display
.x
->reverse_gc
,
3756 x1
, y1
, (x0
- x1
+ 1), 1);
3764 int contour_begin_x
, contour_begin_y
;
3765 int contour_end_x
, contour_end_y
;
3766 int contour_npoints
;
3768 /* Clip the top part of the contour lines down (and including) line Y_POS.
3769 If X_POS is in the middle (rather than at the end) of the line, drop
3770 down a line at that character. */
3773 clip_contour_top (y_pos
, x_pos
)
3775 register XPoint
*begin
= contour_lines
[y_pos
].top_left
;
3776 register XPoint
*end
;
3777 register int npoints
;
3778 register struct display_line
*line
= selected_frame
->phys_lines
[y_pos
+ 1];
3780 if (x_pos
>= line
->len
- 1) /* Draw one, straight horizontal line. */
3782 end
= contour_lines
[y_pos
].top_right
;
3783 npoints
= (end
- begin
+ 1);
3784 XDrawLines (x_current_display
, contour_window
,
3785 contour_erase_gc
, begin_erase
, npoints
, CoordModeOrigin
);
3787 bcopy (end
, begin
+ 1, contour_last_point
- end
+ 1);
3788 contour_last_point
-= (npoints
- 2);
3789 XDrawLines (x_current_display
, contour_window
,
3790 contour_erase_gc
, begin
, 2, CoordModeOrigin
);
3791 XFlush (x_current_display
);
3793 /* Now, update contour_lines structure. */
3798 register XPoint
*p
= begin
+ 1;
3799 end
= contour_lines
[y_pos
].bottom_right
;
3800 npoints
= (end
- begin
+ 1);
3801 XDrawLines (x_current_display
, contour_window
,
3802 contour_erase_gc
, begin_erase
, npoints
, CoordModeOrigin
);
3805 p
->x
= ibw
+ (font_w
* (x_pos
+ 1));
3807 p
->y
= begin
->y
+ font_h
;
3809 bcopy (end
, begin
+ 3, contour_last_point
- end
+ 1);
3810 contour_last_point
-= (npoints
- 5);
3811 XDrawLines (x_current_display
, contour_window
,
3812 contour_erase_gc
, begin
, 4, CoordModeOrigin
);
3813 XFlush (x_current_display
);
3815 /* Now, update contour_lines structure. */
3819 /* Erase the top horizontal lines of the contour, and then extend
3820 the contour upwards. */
3823 extend_contour_top (line
)
3828 clip_contour_bottom (x_pos
, y_pos
)
3834 extend_contour_bottom (x_pos
, y_pos
)
3838 DEFUN ("x-select-region", Fx_select_region
, Sx_select_region
, 1, 1, "e",
3843 register struct frame
*f
= selected_frame
;
3844 register int point_x
= f
->cursor_x
;
3845 register int point_y
= f
->cursor_y
;
3846 register int mouse_below_point
;
3847 register Lisp_Object obj
;
3848 register int x_contour_x
, x_contour_y
;
3850 x_contour_x
= x_mouse_x
;
3851 x_contour_y
= x_mouse_y
;
3852 if (x_contour_y
> point_y
|| (x_contour_y
== point_y
3853 && x_contour_x
> point_x
))
3855 mouse_below_point
= 1;
3856 outline_region (f
, f
->display
.x
->cursor_gc
, point_x
, point_y
,
3857 x_contour_x
, x_contour_y
);
3861 mouse_below_point
= 0;
3862 outline_region (f
, f
->display
.x
->cursor_gc
, x_contour_x
, x_contour_y
,
3868 obj
= read_char (-1, 0, 0, Qnil
, 0);
3872 if (mouse_below_point
)
3874 if (x_mouse_y
<= point_y
) /* Flipped. */
3876 mouse_below_point
= 0;
3878 outline_region (f
, f
->display
.x
->reverse_gc
, point_x
, point_y
,
3879 x_contour_x
, x_contour_y
);
3880 outline_region (f
, f
->display
.x
->cursor_gc
, x_mouse_x
, x_mouse_y
,
3883 else if (x_mouse_y
< x_contour_y
) /* Bottom clipped. */
3885 clip_contour_bottom (x_mouse_y
);
3887 else if (x_mouse_y
> x_contour_y
) /* Bottom extended. */
3889 extend_bottom_contour (x_mouse_y
);
3892 x_contour_x
= x_mouse_x
;
3893 x_contour_y
= x_mouse_y
;
3895 else /* mouse above or same line as point */
3897 if (x_mouse_y
>= point_y
) /* Flipped. */
3899 mouse_below_point
= 1;
3901 outline_region (f
, f
->display
.x
->reverse_gc
,
3902 x_contour_x
, x_contour_y
, point_x
, point_y
);
3903 outline_region (f
, f
->display
.x
->cursor_gc
, point_x
, point_y
,
3904 x_mouse_x
, x_mouse_y
);
3906 else if (x_mouse_y
> x_contour_y
) /* Top clipped. */
3908 clip_contour_top (x_mouse_y
);
3910 else if (x_mouse_y
< x_contour_y
) /* Top extended. */
3912 extend_contour_top (x_mouse_y
);
3917 unread_command_event
= obj
;
3918 if (mouse_below_point
)
3920 contour_begin_x
= point_x
;
3921 contour_begin_y
= point_y
;
3922 contour_end_x
= x_contour_x
;
3923 contour_end_y
= x_contour_y
;
3927 contour_begin_x
= x_contour_x
;
3928 contour_begin_y
= x_contour_y
;
3929 contour_end_x
= point_x
;
3930 contour_end_y
= point_y
;
3935 DEFUN ("x-horizontal-line", Fx_horizontal_line
, Sx_horizontal_line
, 1, 1, "e",
3940 register Lisp_Object obj
;
3941 struct frame
*f
= selected_frame
;
3942 register struct window
*w
= XWINDOW (selected_window
);
3943 register GC line_gc
= f
->display
.x
->cursor_gc
;
3944 register GC erase_gc
= f
->display
.x
->reverse_gc
;
3946 char dash_list
[] = {6, 4, 6, 4};
3948 XGCValues gc_values
;
3950 register int previous_y
;
3951 register int line
= (x_mouse_y
+ 1) * f
->display
.x
->line_height
3952 + f
->display
.x
->internal_border_width
;
3953 register int left
= f
->display
.x
->internal_border_width
3955 * FONT_WIDTH (f
->display
.x
->font
));
3956 register int right
= left
+ (w
->width
3957 * FONT_WIDTH (f
->display
.x
->font
))
3958 - f
->display
.x
->internal_border_width
;
3962 gc_values
.foreground
= f
->display
.x
->cursor_pixel
;
3963 gc_values
.background
= f
->display
.x
->background_pixel
;
3964 gc_values
.line_width
= 1;
3965 gc_values
.line_style
= LineOnOffDash
;
3966 gc_values
.cap_style
= CapRound
;
3967 gc_values
.join_style
= JoinRound
;
3969 line_gc
= XCreateGC (FRAME_X_DISPLAY (f
), FRAME_X_WINDOW (f
),
3970 GCLineStyle
| GCJoinStyle
| GCCapStyle
3971 | GCLineWidth
| GCForeground
| GCBackground
,
3973 XSetDashes (FRAME_X_DISPLAY (f
), line_gc
, 0, dash_list
, dashes
);
3974 gc_values
.foreground
= f
->display
.x
->background_pixel
;
3975 gc_values
.background
= f
->display
.x
->foreground_pixel
;
3976 erase_gc
= XCreateGC (FRAME_X_DISPLAY (f
), FRAME_X_WINDOW (f
),
3977 GCLineStyle
| GCJoinStyle
| GCCapStyle
3978 | GCLineWidth
| GCForeground
| GCBackground
,
3980 XSetDashes (FRAME_X_DISPLAY (f
), erase_gc
, 0, dash_list
, dashes
);
3986 if (x_mouse_y
>= XINT (w
->top
)
3987 && x_mouse_y
< XINT (w
->top
) + XINT (w
->height
) - 1)
3989 previous_y
= x_mouse_y
;
3990 line
= (x_mouse_y
+ 1) * f
->display
.x
->line_height
3991 + f
->display
.x
->internal_border_width
;
3992 XDrawLine (FRAME_X_DISPLAY (f
), FRAME_X_WINDOW (f
),
3993 line_gc
, left
, line
, right
, line
);
3995 XFlush (FRAME_X_DISPLAY (f
));
4000 obj
= read_char (-1, 0, 0, Qnil
, 0);
4002 || (! EQ (Fcar (Fcdr (Fcdr (obj
))),
4003 Qvertical_scroll_bar
))
4007 XDrawLine (FRAME_X_DISPLAY (f
), FRAME_X_WINDOW (f
),
4008 erase_gc
, left
, line
, right
, line
);
4010 unread_command_event
= obj
;
4012 XFreeGC (FRAME_X_DISPLAY (f
), line_gc
);
4013 XFreeGC (FRAME_X_DISPLAY (f
), erase_gc
);
4018 while (x_mouse_y
== previous_y
);
4021 XDrawLine (FRAME_X_DISPLAY (f
), FRAME_X_WINDOW (f
),
4022 erase_gc
, left
, line
, right
, line
);
4029 /* These keep track of the rectangle following the pointer. */
4030 int mouse_track_top
, mouse_track_left
, mouse_track_width
;
4032 /* Offset in buffer of character under the pointer, or 0. */
4033 int mouse_buffer_offset
;
4035 DEFUN ("x-track-pointer", Fx_track_pointer
, Sx_track_pointer
, 0, 0, 0,
4036 "Track the pointer.")
4039 static Cursor current_pointer_shape
;
4040 FRAME_PTR f
= x_mouse_frame
;
4043 if (EQ (Vmouse_frame_part
, Qtext_part
)
4044 && (current_pointer_shape
!= f
->display
.x
->nontext_cursor
))
4049 current_pointer_shape
= f
->display
.x
->nontext_cursor
;
4050 XDefineCursor (FRAME_X_DISPLAY (f
),
4052 current_pointer_shape
);
4054 buf
= XBUFFER (XWINDOW (Vmouse_window
)->buffer
);
4055 c
= *(BUF_CHAR_ADDRESS (buf
, mouse_buffer_offset
));
4057 else if (EQ (Vmouse_frame_part
, Qmodeline_part
)
4058 && (current_pointer_shape
!= f
->display
.x
->modeline_cursor
))
4060 current_pointer_shape
= f
->display
.x
->modeline_cursor
;
4061 XDefineCursor (FRAME_X_DISPLAY (f
),
4063 current_pointer_shape
);
4066 XFlush (FRAME_X_DISPLAY (f
));
4072 DEFUN ("x-track-pointer", Fx_track_pointer
, Sx_track_pointer
, 1, 1, "e",
4073 "Draw rectangle around character under mouse pointer, if there is one.")
4077 struct window
*w
= XWINDOW (Vmouse_window
);
4078 struct frame
*f
= XFRAME (WINDOW_FRAME (w
));
4079 struct buffer
*b
= XBUFFER (w
->buffer
);
4082 if (! EQ (Vmouse_window
, selected_window
))
4085 if (EQ (event
, Qnil
))
4089 x_read_mouse_position (selected_frame
, &x
, &y
);
4093 mouse_track_width
= 0;
4094 mouse_track_left
= mouse_track_top
= -1;
4098 if ((x_mouse_x
!= mouse_track_left
4099 && (x_mouse_x
< mouse_track_left
4100 || x_mouse_x
> (mouse_track_left
+ mouse_track_width
)))
4101 || x_mouse_y
!= mouse_track_top
)
4103 int hp
= 0; /* Horizontal position */
4104 int len
= FRAME_CURRENT_GLYPHS (f
)->used
[x_mouse_y
];
4105 int p
= FRAME_CURRENT_GLYPHS (f
)->bufp
[x_mouse_y
];
4106 int tab_width
= XINT (b
->tab_width
);
4107 int ctl_arrow_p
= !NILP (b
->ctl_arrow
);
4109 int mode_line_vpos
= XFASTINT (w
->height
) + XFASTINT (w
->top
) - 1;
4110 int in_mode_line
= 0;
4112 if (! FRAME_CURRENT_GLYPHS (f
)->enable
[x_mouse_y
])
4115 /* Erase previous rectangle. */
4116 if (mouse_track_width
)
4118 x_rectangle (f
, f
->display
.x
->reverse_gc
,
4119 mouse_track_left
, mouse_track_top
,
4120 mouse_track_width
, 1);
4122 if ((mouse_track_left
== f
->phys_cursor_x
4123 || mouse_track_left
== f
->phys_cursor_x
- 1)
4124 && mouse_track_top
== f
->phys_cursor_y
)
4126 x_display_cursor (f
, 1);
4130 mouse_track_left
= x_mouse_x
;
4131 mouse_track_top
= x_mouse_y
;
4132 mouse_track_width
= 0;
4134 if (mouse_track_left
> len
) /* Past the end of line. */
4137 if (mouse_track_top
== mode_line_vpos
)
4143 if (tab_width
<= 0 || tab_width
> 20) tab_width
= 8;
4147 if (len
== f
->width
&& hp
== len
- 1 && c
!= '\n')
4153 mouse_track_width
= tab_width
- (hp
% tab_width
);
4155 hp
+= mouse_track_width
;
4158 mouse_track_left
= hp
- mouse_track_width
;
4164 mouse_track_width
= -1;
4168 if (ctl_arrow_p
&& (c
< 040 || c
== 0177))
4173 mouse_track_width
= 2;
4178 mouse_track_left
= hp
- mouse_track_width
;
4184 mouse_track_width
= 1;
4191 while (hp
<= x_mouse_x
);
4194 if (mouse_track_width
) /* Over text; use text pointer shape. */
4196 XDefineCursor (FRAME_X_DISPLAY (f
),
4198 f
->display
.x
->text_cursor
);
4199 x_rectangle (f
, f
->display
.x
->cursor_gc
,
4200 mouse_track_left
, mouse_track_top
,
4201 mouse_track_width
, 1);
4203 else if (in_mode_line
)
4204 XDefineCursor (FRAME_X_DISPLAY (f
),
4206 f
->display
.x
->modeline_cursor
);
4208 XDefineCursor (FRAME_X_DISPLAY (f
),
4210 f
->display
.x
->nontext_cursor
);
4213 XFlush (FRAME_X_DISPLAY (f
));
4216 obj
= read_char (-1, 0, 0, Qnil
, 0);
4219 while (CONSP (obj
) /* Mouse event */
4220 && EQ (Fcar (Fcdr (Fcdr (obj
))), Qnil
) /* Not scroll bar */
4221 && EQ (Vmouse_depressed
, Qnil
) /* Only motion events */
4222 && EQ (Vmouse_window
, selected_window
) /* In this window */
4225 unread_command_event
= obj
;
4227 if (mouse_track_width
)
4229 x_rectangle (f
, f
->display
.x
->reverse_gc
,
4230 mouse_track_left
, mouse_track_top
,
4231 mouse_track_width
, 1);
4232 mouse_track_width
= 0;
4233 if ((mouse_track_left
== f
->phys_cursor_x
4234 || mouse_track_left
- 1 == f
->phys_cursor_x
)
4235 && mouse_track_top
== f
->phys_cursor_y
)
4237 x_display_cursor (f
, 1);
4240 XDefineCursor (FRAME_X_DISPLAY (f
),
4242 f
->display
.x
->nontext_cursor
);
4243 XFlush (FRAME_X_DISPLAY (f
));
4253 /* Draw a pixmap specified by IMAGE_DATA of dimensions WIDTH and HEIGHT
4254 on the frame F at position X, Y. */
4256 x_draw_pixmap (f
, x
, y
, image_data
, width
, height
)
4258 int x
, y
, width
, height
;
4263 image
= XCreateBitmapFromData (FRAME_X_DISPLAY (f
),
4264 FRAME_X_WINDOW (f
), image_data
,
4266 XCopyPlane (FRAME_X_DISPLAY (f
), image
, FRAME_X_WINDOW (f
),
4267 f
->display
.x
->normal_gc
, 0, 0, width
, height
, x
, y
);
4271 #if 0 /* I'm told these functions are superfluous
4272 given the ability to bind function keys. */
4275 DEFUN ("x-rebind-key", Fx_rebind_key
, Sx_rebind_key
, 3, 3, 0,
4276 "Rebind X keysym KEYSYM, with MODIFIERS, to generate NEWSTRING.\n\
4277 KEYSYM is a string which conforms to the X keysym definitions found\n\
4278 in X11/keysymdef.h, sans the initial XK_. MODIFIERS is nil or a\n\
4279 list of strings specifying modifier keys such as Control_L, which must\n\
4280 also be depressed for NEWSTRING to appear.")
4281 (x_keysym
, modifiers
, newstring
)
4282 register Lisp_Object x_keysym
;
4283 register Lisp_Object modifiers
;
4284 register Lisp_Object newstring
;
4287 register KeySym keysym
;
4288 KeySym modifier_list
[16];
4291 CHECK_STRING (x_keysym
, 1);
4292 CHECK_STRING (newstring
, 3);
4294 keysym
= XStringToKeysym ((char *) XSTRING (x_keysym
)->data
);
4295 if (keysym
== NoSymbol
)
4296 error ("Keysym does not exist");
4298 if (NILP (modifiers
))
4299 XRebindKeysym (x_current_display
, keysym
, modifier_list
, 0,
4300 XSTRING (newstring
)->data
, XSTRING (newstring
)->size
);
4303 register Lisp_Object rest
, mod
;
4306 for (rest
= modifiers
; !NILP (rest
); rest
= Fcdr (rest
))
4309 error ("Can't have more than 16 modifiers");
4312 CHECK_STRING (mod
, 3);
4313 modifier_list
[i
] = XStringToKeysym ((char *) XSTRING (mod
)->data
);
4315 if (modifier_list
[i
] == NoSymbol
4316 || !(IsModifierKey (modifier_list
[i
])
4317 || ((unsigned)(modifier_list
[i
]) == XK_Mode_switch
)
4318 || ((unsigned)(modifier_list
[i
]) == XK_Num_Lock
)))
4320 if (modifier_list
[i
] == NoSymbol
4321 || !IsModifierKey (modifier_list
[i
]))
4323 error ("Element is not a modifier keysym");
4327 XRebindKeysym (x_current_display
, keysym
, modifier_list
, i
,
4328 XSTRING (newstring
)->data
, XSTRING (newstring
)->size
);
4334 DEFUN ("x-rebind-keys", Fx_rebind_keys
, Sx_rebind_keys
, 2, 2, 0,
4335 "Rebind KEYCODE to list of strings STRINGS.\n\
4336 STRINGS should be a list of 16 elements, one for each shift combination.\n\
4337 nil as element means don't change.\n\
4338 See the documentation of `x-rebind-key' for more information.")
4340 register Lisp_Object keycode
;
4341 register Lisp_Object strings
;
4343 register Lisp_Object item
;
4344 register unsigned char *rawstring
;
4345 KeySym rawkey
, modifier
[1];
4347 register unsigned i
;
4350 CHECK_NUMBER (keycode
, 1);
4351 CHECK_CONS (strings
, 2);
4352 rawkey
= (KeySym
) ((unsigned) (XINT (keycode
))) & 255;
4353 for (i
= 0; i
<= 15; strings
= Fcdr (strings
), i
++)
4355 item
= Fcar (strings
);
4358 CHECK_STRING (item
, 2);
4359 strsize
= XSTRING (item
)->size
;
4360 rawstring
= (unsigned char *) xmalloc (strsize
);
4361 bcopy (XSTRING (item
)->data
, rawstring
, strsize
);
4362 modifier
[1] = 1 << i
;
4363 XRebindKeysym (x_current_display
, rawkey
, modifier
, 1,
4364 rawstring
, strsize
);
4369 #endif /* HAVE_X11 */
4372 #ifndef HAVE_XSCREENNUMBEROFSCREEN
4374 XScreenNumberOfScreen (scr
)
4375 register Screen
*scr
;
4377 register Display
*dpy
;
4378 register Screen
*dpyscr
;
4382 dpyscr
= dpy
->screens
;
4384 for (i
= 0; i
< dpy
->nscreens
; i
++, dpyscr
++)
4390 #endif /* not HAVE_XSCREENNUMBEROFSCREEN */
4393 select_visual (dpy
, screen
, depth
)
4396 unsigned int *depth
;
4399 XVisualInfo
*vinfo
, vinfo_template
;
4402 v
= DefaultVisualOfScreen (screen
);
4405 vinfo_template
.visualid
= XVisualIDFromVisual (v
);
4407 vinfo_template
.visualid
= v
->visualid
;
4410 vinfo_template
.screen
= XScreenNumberOfScreen (screen
);
4412 vinfo
= XGetVisualInfo (dpy
,
4413 VisualIDMask
| VisualScreenMask
, &vinfo_template
,
4416 fatal ("Can't get proper X visual info");
4418 if ((1 << vinfo
->depth
) == vinfo
->colormap_size
)
4419 *depth
= vinfo
->depth
;
4423 int n
= vinfo
->colormap_size
- 1;
4432 XFree ((char *) vinfo
);
4436 /* Return the X display structure for the display named NAME.
4437 Open a new connection if necessary. */
4439 struct x_display_info
*
4440 x_display_info_for_name (name
)
4444 struct x_display_info
*dpyinfo
;
4446 CHECK_STRING (name
, 0);
4448 for (dpyinfo
= x_display_list
, names
= x_display_name_list
;
4450 dpyinfo
= dpyinfo
->next
, names
= XCONS (names
)->cdr
)
4453 tem
= Fstring_equal (XCONS (XCONS (names
)->car
)->car
, name
);
4458 validate_x_resource_name ();
4460 dpyinfo
= x_term_init (name
, (unsigned char *)0,
4461 XSTRING (Vx_resource_name
)->data
);
4464 error ("X server %s not responding", XSTRING (name
)->data
);
4467 XSETFASTINT (Vwindow_system_version
, 11);
4472 DEFUN ("x-open-connection", Fx_open_connection
, Sx_open_connection
,
4473 1, 3, 0, "Open a connection to an X server.\n\
4474 DISPLAY is the name of the display to connect to.\n\
4475 Optional second arg XRM-STRING is a string of resources in xrdb format.\n\
4476 If the optional third arg MUST-SUCCEED is non-nil,\n\
4477 terminate Emacs if we can't open the connection.")
4478 (display
, xrm_string
, must_succeed
)
4479 Lisp_Object display
, xrm_string
, must_succeed
;
4481 unsigned int n_planes
;
4482 unsigned char *xrm_option
;
4483 struct x_display_info
*dpyinfo
;
4485 CHECK_STRING (display
, 0);
4486 if (! NILP (xrm_string
))
4487 CHECK_STRING (xrm_string
, 1);
4489 if (! NILP (xrm_string
))
4490 xrm_option
= (unsigned char *) XSTRING (xrm_string
)->data
;
4492 xrm_option
= (unsigned char *) 0;
4494 validate_x_resource_name ();
4496 /* This is what opens the connection and sets x_current_display.
4497 This also initializes many symbols, such as those used for input. */
4498 dpyinfo
= x_term_init (display
, xrm_option
,
4499 XSTRING (Vx_resource_name
)->data
);
4503 if (!NILP (must_succeed
))
4504 fatal ("X server %s not responding.\n\
4505 Check the DISPLAY environment variable or use \"-d\"\n",
4506 XSTRING (display
)->data
);
4508 error ("X server %s not responding", XSTRING (display
)->data
);
4513 XSETFASTINT (Vwindow_system_version
, 11);
4517 DEFUN ("x-close-connection", Fx_close_connection
,
4518 Sx_close_connection
, 1, 1, 0,
4519 "Close the connection to DISPLAY's X server.\n\
4520 For DISPLAY, specify either a frame or a display name (a string).\n\
4521 If DISPLAY is nil, that stands for the selected frame's display.")
4523 Lisp_Object display
;
4525 struct x_display_info
*dpyinfo
= check_x_display_info (display
);
4526 struct x_display_info
*tail
;
4529 if (dpyinfo
->reference_count
> 0)
4530 error ("Display still has frames on it");
4533 /* Free the fonts in the font table. */
4534 for (i
= 0; i
< dpyinfo
->n_fonts
; i
++)
4536 if (dpyinfo
->font_table
[i
].name
)
4537 free (dpyinfo
->font_table
[i
].name
);
4538 /* Don't free the full_name string;
4539 it is always shared with something else. */
4540 XFreeFont (dpyinfo
->display
, dpyinfo
->font_table
[i
].font
);
4542 x_destroy_all_bitmaps (dpyinfo
);
4543 XSetCloseDownMode (dpyinfo
->display
, DestroyAll
);
4545 #ifdef USE_X_TOOLKIT
4546 XtCloseDisplay (dpyinfo
->display
);
4548 XCloseDisplay (dpyinfo
->display
);
4551 x_delete_display (dpyinfo
);
4557 DEFUN ("x-display-list", Fx_display_list
, Sx_display_list
, 0, 0, 0,
4558 "Return the list of display names that Emacs has connections to.")
4561 Lisp_Object tail
, result
;
4564 for (tail
= x_display_name_list
; ! NILP (tail
); tail
= XCONS (tail
)->cdr
)
4565 result
= Fcons (XCONS (XCONS (tail
)->car
)->car
, result
);
4570 DEFUN ("x-synchronize", Fx_synchronize
, Sx_synchronize
, 1, 2, 0,
4571 "If ON is non-nil, report X errors as soon as the erring request is made.\n\
4572 If ON is nil, allow buffering of requests.\n\
4573 Turning on synchronization prohibits the Xlib routines from buffering\n\
4574 requests and seriously degrades performance, but makes debugging much\n\
4576 The optional second argument DISPLAY specifies which display to act on.\n\
4577 DISPLAY should be either a frame or a display name (a string).\n\
4578 If DISPLAY is omitted or nil, that stands for the selected frame's display.")
4580 Lisp_Object display
, on
;
4582 struct x_display_info
*dpyinfo
= check_x_display_info (display
);
4584 XSynchronize (dpyinfo
->display
, !EQ (on
, Qnil
));
4589 /* Wait for responses to all X commands issued so far for frame F. */
4596 XSync (FRAME_X_DISPLAY (f
), False
);
4602 /* This is zero if not using X windows. */
4605 /* The section below is built by the lisp expression at the top of the file,
4606 just above where these variables are declared. */
4607 /*&&& init symbols here &&&*/
4608 Qauto_raise
= intern ("auto-raise");
4609 staticpro (&Qauto_raise
);
4610 Qauto_lower
= intern ("auto-lower");
4611 staticpro (&Qauto_lower
);
4612 Qbackground_color
= intern ("background-color");
4613 staticpro (&Qbackground_color
);
4614 Qbar
= intern ("bar");
4616 Qborder_color
= intern ("border-color");
4617 staticpro (&Qborder_color
);
4618 Qborder_width
= intern ("border-width");
4619 staticpro (&Qborder_width
);
4620 Qbox
= intern ("box");
4622 Qcursor_color
= intern ("cursor-color");
4623 staticpro (&Qcursor_color
);
4624 Qcursor_type
= intern ("cursor-type");
4625 staticpro (&Qcursor_type
);
4626 Qfont
= intern ("font");
4628 Qforeground_color
= intern ("foreground-color");
4629 staticpro (&Qforeground_color
);
4630 Qgeometry
= intern ("geometry");
4631 staticpro (&Qgeometry
);
4632 Qicon_left
= intern ("icon-left");
4633 staticpro (&Qicon_left
);
4634 Qicon_top
= intern ("icon-top");
4635 staticpro (&Qicon_top
);
4636 Qicon_type
= intern ("icon-type");
4637 staticpro (&Qicon_type
);
4638 Qinternal_border_width
= intern ("internal-border-width");
4639 staticpro (&Qinternal_border_width
);
4640 Qleft
= intern ("left");
4642 Qmouse_color
= intern ("mouse-color");
4643 staticpro (&Qmouse_color
);
4644 Qnone
= intern ("none");
4646 Qparent_id
= intern ("parent-id");
4647 staticpro (&Qparent_id
);
4648 Qscroll_bar_width
= intern ("scroll-bar-width");
4649 staticpro (&Qscroll_bar_width
);
4650 Qsuppress_icon
= intern ("suppress-icon");
4651 staticpro (&Qsuppress_icon
);
4652 Qtop
= intern ("top");
4654 Qundefined_color
= intern ("undefined-color");
4655 staticpro (&Qundefined_color
);
4656 Qvertical_scroll_bars
= intern ("vertical-scroll-bars");
4657 staticpro (&Qvertical_scroll_bars
);
4658 Qvisibility
= intern ("visibility");
4659 staticpro (&Qvisibility
);
4660 Qwindow_id
= intern ("window-id");
4661 staticpro (&Qwindow_id
);
4662 Qx_frame_parameter
= intern ("x-frame-parameter");
4663 staticpro (&Qx_frame_parameter
);
4664 Qx_resource_name
= intern ("x-resource-name");
4665 staticpro (&Qx_resource_name
);
4666 Quser_position
= intern ("user-position");
4667 staticpro (&Quser_position
);
4668 Quser_size
= intern ("user-size");
4669 staticpro (&Quser_size
);
4670 Qdisplay
= intern ("display");
4671 staticpro (&Qdisplay
);
4672 /* This is the end of symbol initialization. */
4674 Fput (Qundefined_color
, Qerror_conditions
,
4675 Fcons (Qundefined_color
, Fcons (Qerror
, Qnil
)));
4676 Fput (Qundefined_color
, Qerror_message
,
4677 build_string ("Undefined color"));
4679 init_x_parm_symbols ();
4681 DEFVAR_LISP ("x-bitmap-file-path", &Vx_bitmap_file_path
,
4682 "List of directories to search for bitmap files for X.");
4683 Vx_bitmap_file_path
= Fcons (build_string (PATH_BITMAPS
), Qnil
);
4685 DEFVAR_LISP ("x-pointer-shape", &Vx_pointer_shape
,
4686 "The shape of the pointer when over text.\n\
4687 Changing the value does not affect existing frames\n\
4688 unless you set the mouse color.");
4689 Vx_pointer_shape
= Qnil
;
4691 DEFVAR_LISP ("x-resource-name", &Vx_resource_name
,
4692 "The name Emacs uses to look up X resources; for internal use only.\n\
4693 `x-get-resource' uses this as the first component of the instance name\n\
4694 when requesting resource values.\n\
4695 Emacs initially sets `x-resource-name' to the name under which Emacs\n\
4696 was invoked, or to the value specified with the `-name' or `-rn'\n\
4697 switches, if present.");
4698 Vx_resource_name
= Qnil
;
4700 #if 0 /* This doesn't really do anything. */
4701 DEFVAR_INT ("x-nontext-pointer-shape", &Vx_nontext_pointer_shape
,
4702 "The shape of the pointer when not over text.\n\
4703 This variable takes effect when you create a new frame\n\
4704 or when you set the mouse color.");
4706 Vx_nontext_pointer_shape
= Qnil
;
4708 #if 0 /* This doesn't really do anything. */
4709 DEFVAR_INT ("x-mode-pointer-shape", &Vx_mode_pointer_shape
,
4710 "The shape of the pointer when over the mode line.\n\
4711 This variable takes effect when you create a new frame\n\
4712 or when you set the mouse color.");
4714 Vx_mode_pointer_shape
= Qnil
;
4716 DEFVAR_INT ("x-sensitive-text-pointer-shape",
4717 &Vx_sensitive_text_pointer_shape
,
4718 "The shape of the pointer when over mouse-sensitive text.\n\
4719 This variable takes effect when you create a new frame\n\
4720 or when you set the mouse color.");
4721 Vx_sensitive_text_pointer_shape
= Qnil
;
4723 DEFVAR_LISP ("x-cursor-fore-pixel", &Vx_cursor_fore_pixel
,
4724 "A string indicating the foreground color of the cursor box.");
4725 Vx_cursor_fore_pixel
= Qnil
;
4727 DEFVAR_LISP ("x-no-window-manager", &Vx_no_window_manager
,
4728 "Non-nil if no X window manager is in use.");
4730 #ifdef USE_X_TOOLKIT
4731 Fprovide (intern ("x-toolkit"));
4734 defsubr (&Sx_get_resource
);
4736 defsubr (&Sx_draw_rectangle
);
4737 defsubr (&Sx_erase_rectangle
);
4738 defsubr (&Sx_contour_region
);
4739 defsubr (&Sx_uncontour_region
);
4741 defsubr (&Sx_list_fonts
);
4742 defsubr (&Sx_display_color_p
);
4743 defsubr (&Sx_display_grayscale_p
);
4744 defsubr (&Sx_color_defined_p
);
4745 defsubr (&Sx_color_values
);
4746 defsubr (&Sx_server_max_request_size
);
4747 defsubr (&Sx_server_vendor
);
4748 defsubr (&Sx_server_version
);
4749 defsubr (&Sx_display_pixel_width
);
4750 defsubr (&Sx_display_pixel_height
);
4751 defsubr (&Sx_display_mm_width
);
4752 defsubr (&Sx_display_mm_height
);
4753 defsubr (&Sx_display_screens
);
4754 defsubr (&Sx_display_planes
);
4755 defsubr (&Sx_display_color_cells
);
4756 defsubr (&Sx_display_visual_class
);
4757 defsubr (&Sx_display_backing_store
);
4758 defsubr (&Sx_display_save_under
);
4760 defsubr (&Sx_rebind_key
);
4761 defsubr (&Sx_rebind_keys
);
4762 defsubr (&Sx_track_pointer
);
4763 defsubr (&Sx_grab_pointer
);
4764 defsubr (&Sx_ungrab_pointer
);
4766 defsubr (&Sx_parse_geometry
);
4767 defsubr (&Sx_create_frame
);
4768 defsubr (&Sfocus_frame
);
4769 defsubr (&Sunfocus_frame
);
4771 defsubr (&Sx_horizontal_line
);
4773 defsubr (&Sx_open_connection
);
4774 defsubr (&Sx_close_connection
);
4775 defsubr (&Sx_display_list
);
4776 defsubr (&Sx_synchronize
);
4779 #endif /* HAVE_X_WINDOWS */