1 /* Functions for the X window system.
2 Copyright (C) 1989 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 1, 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 */
34 #include "dispextern.h"
35 #include "xscrollbar.h"
40 void x_set_screen_param ();
42 #define min(a,b) ((a) < (b) ? (a) : (b))
43 #define max(a,b) ((a) > (b) ? (a) : (b))
46 /* X Resource data base */
47 static XrmDatabase xrdb
;
49 /* The class of this X application. */
50 #define EMACS_CLASS "Emacs"
52 /* The class of Emacs screens. */
53 #define SCREEN_CLASS "Screen"
54 Lisp_Object screen_class
;
56 /* Title name and application name for X stuff. */
57 extern char *x_id_name
;
58 extern Lisp_Object invocation_name
;
60 /* The background and shape of the mouse pointer, and shape when not
61 over text or in the modeline. */
62 Lisp_Object Vx_pointer_shape
, Vx_nontext_pointer_shape
, Vx_mode_pointer_shape
;
64 /* Color of chars displayed in cursor box. */
65 Lisp_Object Vx_cursor_fore_pixel
;
67 /* If non-nil, use vertical bar cursor. */
68 Lisp_Object Vbar_cursor
;
70 /* The X Visual we are using for X windows (the default) */
71 Visual
*screen_visual
;
73 /* How many screens this X display has. */
76 /* The vendor supporting this X server. */
77 Lisp_Object Vx_vendor
;
79 /* The vendor's release number for this X server. */
82 /* Height of this X screen in pixels. */
85 /* Height of this X screen in millimeters. */
86 int x_screen_height_mm
;
88 /* Width of this X screen in pixels. */
91 /* Width of this X screen in millimeters. */
92 int x_screen_width_mm
;
94 /* Does this X screen do backing store? */
95 Lisp_Object Vx_backing_store
;
97 /* Does this X screen do save-unders? */
100 /* Number of planes for this screen. */
103 /* X Visual type of this screen. */
104 Lisp_Object Vx_screen_visual
;
106 /* Non nil if no window manager is in use. */
107 Lisp_Object Vx_no_window_manager
;
109 static char *x_visual_strings
[] =
119 /* `t' if a mouse button is depressed. */
121 Lisp_Object Vmouse_depressed
;
123 /* Atom for indicating window state to the window manager. */
124 Atom Xatom_wm_change_state
;
126 /* When emacs became the selection owner. */
127 extern Time x_begin_selection_own
;
129 /* The value of the current emacs selection. */
130 extern Lisp_Object Vx_selection_value
;
132 /* Emacs' selection property identifier. */
133 extern Atom Xatom_emacs_selection
;
135 /* Clipboard selection atom. */
136 extern Atom Xatom_clipboard_selection
;
138 /* Clipboard atom. */
139 extern Atom Xatom_clipboard
;
141 /* Atom for indicating incremental selection transfer. */
142 extern Atom Xatom_incremental
;
144 /* Atom for indicating multiple selection request list */
145 extern Atom Xatom_multiple
;
147 /* Atom for what targets emacs handles. */
148 extern Atom Xatom_targets
;
150 /* Atom for indicating timstamp selection request */
151 extern Atom Xatom_timestamp
;
153 /* Atom requesting we delete our selection. */
154 extern Atom Xatom_delete
;
156 /* Selection magic. */
157 extern Atom Xatom_insert_selection
;
159 /* Type of property for INSERT_SELECTION. */
160 extern Atom Xatom_pair
;
162 /* More selection magic. */
163 extern Atom Xatom_insert_property
;
165 /* Atom for indicating property type TEXT */
166 extern Atom Xatom_text
;
170 /* Default size of an Emacs window without scroll bar. */
171 static char *default_window
= "=80x24+0+0";
174 char iconidentity
[MAXICID
];
175 #define ICONTAG "emacs@"
176 char minibuffer_iconidentity
[MAXICID
];
177 #define MINIBUFFER_ICONTAG "minibuffer@"
181 /* The last 23 bits of the timestamp of the last mouse button event. */
182 Time mouse_timestamp
;
184 Lisp_Object Qundefined_color
;
185 Lisp_Object Qx_screen_parameter
;
187 extern Lisp_Object Vwindow_system_version
;
189 /* Mouse map for clicks in windows. */
190 extern Lisp_Object Vglobal_mouse_map
;
192 /* Points to table of defined typefaces. */
193 struct face
*x_face_table
[MAX_FACES_AND_GLYPHS
];
195 /* Return the Emacs screen-object corresponding to an X window.
196 It could be the screen's main window or an icon window. */
199 x_window_to_screen (wdesc
)
202 Lisp_Object tail
, screen
;
205 for (tail
= Vscreen_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
207 screen
= XCONS (tail
)->car
;
208 if (XTYPE (screen
) != Lisp_Screen
)
210 s
= XSCREEN (screen
);
211 if (s
->display
.x
->window_desc
== wdesc
212 || s
->display
.x
->icon_desc
== wdesc
)
218 /* A symbol indicating which part of the screen the mouse is in. */
219 Lisp_Object Vmouse_screen_part
;
221 Lisp_Object Qtext_part
;
222 Lisp_Object Qmodeline_part
;
224 Lisp_Object Qvscrollbar_part
;
225 Lisp_Object Qvslider_part
;
226 Lisp_Object Qvthumbup_part
;
227 Lisp_Object Qvthumbdown_part
;
229 Lisp_Object Qhscrollbar_part
;
230 Lisp_Object Qhslider_part
;
231 Lisp_Object Qhthumbleft_part
;
232 Lisp_Object Qhthumbright_part
;
234 /* Map an X window that implements a scroll bar to the Emacs screen it
235 belongs to. Also store in *PART a symbol identifying which part of
236 the scroll bar it is. */
239 x_window_to_scrollbar (wdesc
, part_ptr
, prefix_ptr
)
241 Lisp_Object
*part_ptr
;
242 enum scroll_bar_prefix
*prefix_ptr
;
244 Lisp_Object tail
, screen
;
247 for (tail
= Vscreen_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
249 screen
= XCONS (tail
)->car
;
250 if (XTYPE (screen
) != Lisp_Screen
)
253 s
= XSCREEN (screen
);
254 if (part_ptr
== 0 && prefix_ptr
== 0)
257 if (s
->display
.x
->v_scrollbar
== wdesc
)
259 *part_ptr
= Qvscrollbar_part
;
260 *prefix_ptr
= VSCROLL_BAR_PREFIX
;
263 else if (s
->display
.x
->v_slider
== wdesc
)
265 *part_ptr
= Qvslider_part
;
266 *prefix_ptr
= VSCROLL_SLIDER_PREFIX
;
269 else if (s
->display
.x
->v_thumbup
== wdesc
)
271 *part_ptr
= Qvthumbup_part
;
272 *prefix_ptr
= VSCROLL_THUMBUP_PREFIX
;
275 else if (s
->display
.x
->v_thumbdown
== wdesc
)
277 *part_ptr
= Qvthumbdown_part
;
278 *prefix_ptr
= VSCROLL_THUMBDOWN_PREFIX
;
281 else if (s
->display
.x
->h_scrollbar
== wdesc
)
283 *part_ptr
= Qhscrollbar_part
;
284 *prefix_ptr
= HSCROLL_BAR_PREFIX
;
287 else if (s
->display
.x
->h_slider
== wdesc
)
289 *part_ptr
= Qhslider_part
;
290 *prefix_ptr
= HSCROLL_SLIDER_PREFIX
;
293 else if (s
->display
.x
->h_thumbleft
== wdesc
)
295 *part_ptr
= Qhthumbleft_part
;
296 *prefix_ptr
= HSCROLL_THUMBLEFT_PREFIX
;
299 else if (s
->display
.x
->h_thumbright
== wdesc
)
301 *part_ptr
= Qhthumbright_part
;
302 *prefix_ptr
= HSCROLL_THUMBRIGHT_PREFIX
;
309 /* Connect the screen-parameter names for X screens
310 to the ways of passing the parameter values to the window system.
312 The name of a parameter, as a Lisp symbol,
313 has an `x-screen-parameter' property which is an integer in Lisp
314 but can be interpreted as an `enum x_screen_parm' in C. */
318 X_PARM_FOREGROUND_COLOR
,
319 X_PARM_BACKGROUND_COLOR
,
326 X_PARM_INTERNAL_BORDER_WIDTH
,
330 X_PARM_VERT_SCROLLBAR
,
331 X_PARM_HORIZ_SCROLLBAR
,
335 struct x_screen_parm_table
338 void (*setter
)( /* struct screen *screen, Lisp_Object val, oldval */ );
341 void x_set_foreground_color ();
342 void x_set_background_color ();
343 void x_set_mouse_color ();
344 void x_set_cursor_color ();
345 void x_set_border_color ();
346 void x_set_icon_type ();
348 void x_set_border_width ();
349 void x_set_internal_border_width ();
351 void x_set_autoraise ();
352 void x_set_autolower ();
353 void x_set_vertical_scrollbar ();
354 void x_set_horizontal_scrollbar ();
356 static struct x_screen_parm_table x_screen_parms
[] =
358 "foreground-color", x_set_foreground_color
,
359 "background-color", x_set_background_color
,
360 "mouse-color", x_set_mouse_color
,
361 "cursor-color", x_set_cursor_color
,
362 "border-color", x_set_border_color
,
363 "icon-type", x_set_icon_type
,
365 "border-width", x_set_border_width
,
366 "internal-border-width", x_set_internal_border_width
,
368 "autoraise", x_set_autoraise
,
369 "autolower", x_set_autolower
,
370 "vertical-scrollbar", x_set_vertical_scrollbar
,
371 "horizontal-scrollbar", x_set_horizontal_scrollbar
,
374 /* Attach the `x-screen-parameter' properties to
375 the Lisp symbol names of parameters relevant to X. */
377 init_x_parm_symbols ()
381 Qx_screen_parameter
= intern ("x-screen-parameter");
383 for (i
= 0; i
< sizeof (x_screen_parms
)/sizeof (x_screen_parms
[0]); i
++)
384 Fput (intern (x_screen_parms
[i
].name
), Qx_screen_parameter
,
388 /* Report to X that a screen parameter of screen S is being set or changed.
389 PARAM is the symbol that says which parameter.
390 VAL is the new value.
391 OLDVAL is the old value.
392 If the parameter is not specially recognized, do nothing;
393 otherwise the `x_set_...' function for this parameter. */
396 x_set_screen_param (s
, param
, val
, oldval
)
397 register struct screen
*s
;
399 register Lisp_Object val
;
400 register Lisp_Object oldval
;
402 register Lisp_Object tem
;
403 tem
= Fget (param
, Qx_screen_parameter
);
404 if (XTYPE (tem
) == Lisp_Int
406 && XINT (tem
) < sizeof (x_screen_parms
)/sizeof (x_screen_parms
[0]))
407 (*x_screen_parms
[XINT (tem
)].setter
)(s
, val
, oldval
);
410 /* Insert a description of internally-recorded parameters of screen X
411 into the parameter alist *ALISTPTR that is to be given to the user.
412 Only parameters that are specific to the X window system
413 and whose values are not correctly recorded in the screen's
414 param_alist need to be considered here. */
416 x_report_screen_params (s
, alistptr
)
418 Lisp_Object
*alistptr
;
422 store_in_alist (alistptr
, "left", make_number (s
->display
.x
->left_pos
));
423 store_in_alist (alistptr
, "top", make_number (s
->display
.x
->top_pos
));
424 store_in_alist (alistptr
, "border-width",
425 make_number (s
->display
.x
->border_width
));
426 store_in_alist (alistptr
, "internal-border-width",
427 make_number (s
->display
.x
->internal_border_width
));
428 sprintf (buf
, "%d", s
->display
.x
->window_desc
);
429 store_in_alist (alistptr
, "window-id",
433 /* Decide if color named COLOR is valid for the display
434 associated with the selected screen. */
436 defined_color (color
, color_def
)
441 Colormap screen_colormap
;
446 = DefaultColormap (x_current_display
, XDefaultScreen (x_current_display
));
448 foo
= XParseColor (x_current_display
, screen_colormap
,
450 && XAllocColor (x_current_display
, screen_colormap
, color_def
);
452 foo
= XParseColor (color
, color_def
) && XGetHardwareColor (color_def
);
453 #endif /* not HAVE_X11 */
462 /* Given a string ARG naming a color, compute a pixel value from it
463 suitable for screen S.
464 If S is not a color screen, return DEF (default) regardless of what
468 x_decode_color (arg
, def
)
474 CHECK_STRING (arg
, 0);
476 if (strcmp (XSTRING (arg
)->data
, "black") == 0)
477 return BLACK_PIX_DEFAULT
;
478 else if (strcmp (XSTRING (arg
)->data
, "white") == 0)
479 return WHITE_PIX_DEFAULT
;
482 if (XFASTINT (x_screen_planes
) <= 2)
485 if (DISPLAY_CELLS
<= 2)
489 if (defined_color (XSTRING (arg
)->data
, &cdef
))
492 Fsignal (Qundefined_color
, Fcons (arg
, Qnil
));
495 /* Functions called only from `x_set_screen_param'
496 to set individual parameters.
498 If s->display.x->window_desc is 0,
499 the screen is being created and its X-window does not exist yet.
500 In that case, just record the parameter's new value
501 in the standard place; do not attempt to change the window. */
504 x_set_foreground_color (s
, arg
, oldval
)
506 Lisp_Object arg
, oldval
;
508 s
->display
.x
->foreground_pixel
= x_decode_color (arg
, BLACK_PIX_DEFAULT
);
509 if (s
->display
.x
->window_desc
!= 0)
513 XSetForeground (x_current_display
, s
->display
.x
->normal_gc
,
514 s
->display
.x
->foreground_pixel
);
515 XSetBackground (x_current_display
, s
->display
.x
->reverse_gc
,
516 s
->display
.x
->foreground_pixel
);
517 if (s
->display
.x
->v_scrollbar
)
519 Pixmap up_arrow_pixmap
, down_arrow_pixmap
, slider_pixmap
;
521 XSetWindowBorder (x_current_display
, s
->display
.x
->v_scrollbar
,
522 s
->display
.x
->foreground_pixel
);
525 XCreatePixmapFromBitmapData (XDISPLAY s
->display
.x
->window_desc
,
527 s
->display
.x
->foreground_pixel
,
528 s
->display
.x
->background_pixel
,
529 DefaultDepth (x_current_display
,
530 XDefaultScreen (x_current_display
)));
532 XCreatePixmapFromBitmapData (XDISPLAY s
->display
.x
->window_desc
,
533 up_arrow_bits
, 16, 16,
534 s
->display
.x
->foreground_pixel
,
535 s
->display
.x
->background_pixel
,
536 DefaultDepth (x_current_display
,
537 XDefaultScreen (x_current_display
)));
539 XCreatePixmapFromBitmapData (XDISPLAY s
->display
.x
->window_desc
,
540 down_arrow_bits
, 16, 16,
541 s
->display
.x
->foreground_pixel
,
542 s
->display
.x
->background_pixel
,
543 DefaultDepth (x_current_display
,
544 XDefaultScreen (x_current_display
)));
546 XSetWindowBackgroundPixmap (XDISPLAY s
->display
.x
->v_thumbup
,
548 XSetWindowBackgroundPixmap (XDISPLAY s
->display
.x
->v_thumbdown
,
550 XSetWindowBackgroundPixmap (XDISPLAY s
->display
.x
->v_slider
,
553 XClearWindow (XDISPLAY s
->display
.x
->v_thumbup
);
554 XClearWindow (XDISPLAY s
->display
.x
->v_thumbdown
);
555 XClearWindow (XDISPLAY s
->display
.x
->v_slider
);
557 XFreePixmap (x_current_display
, down_arrow_pixmap
);
558 XFreePixmap (x_current_display
, up_arrow_pixmap
);
559 XFreePixmap (x_current_display
, slider_pixmap
);
561 if (s
->display
.x
->h_scrollbar
)
563 Pixmap left_arrow_pixmap
, right_arrow_pixmap
, slider_pixmap
;
565 XSetWindowBorder (x_current_display
, s
->display
.x
->h_scrollbar
,
566 s
->display
.x
->foreground_pixel
);
569 XCreatePixmapFromBitmapData (XDISPLAY s
->display
.x
->window_desc
,
571 s
->display
.x
->foreground_pixel
,
572 s
->display
.x
->background_pixel
,
573 DefaultDepth (x_current_display
,
574 XDefaultScreen (x_current_display
)));
577 XCreatePixmapFromBitmapData (XDISPLAY s
->display
.x
->window_desc
,
578 up_arrow_bits
, 16, 16,
579 s
->display
.x
->foreground_pixel
,
580 s
->display
.x
->background_pixel
,
581 DefaultDepth (x_current_display
,
582 XDefaultScreen (x_current_display
)));
584 XCreatePixmapFromBitmapData (XDISPLAY s
->display
.x
->window_desc
,
585 down_arrow_bits
, 16, 16,
586 s
->display
.x
->foreground_pixel
,
587 s
->display
.x
->background_pixel
,
588 DefaultDepth (x_current_display
,
589 XDefaultScreen (x_current_display
)));
591 XSetWindowBackgroundPixmap (XDISPLAY s
->display
.x
->h_slider
,
593 XSetWindowBackgroundPixmap (XDISPLAY s
->display
.x
->h_thumbleft
,
595 XSetWindowBackgroundPixmap (XDISPLAY s
->display
.x
->h_thumbright
,
598 XClearWindow (XDISPLAY s
->display
.x
->h_thumbleft
);
599 XClearWindow (XDISPLAY s
->display
.x
->h_thumbright
);
600 XClearWindow (XDISPLAY s
->display
.x
->h_slider
);
602 XFreePixmap (x_current_display
, slider_pixmap
);
603 XFreePixmap (x_current_display
, left_arrow_pixmap
);
604 XFreePixmap (x_current_display
, right_arrow_pixmap
);
607 #endif /* HAVE_X11 */
614 x_set_background_color (s
, arg
, oldval
)
616 Lisp_Object arg
, oldval
;
621 s
->display
.x
->background_pixel
= x_decode_color (arg
, WHITE_PIX_DEFAULT
);
623 if (s
->display
.x
->window_desc
!= 0)
627 /* The main screen. */
628 XSetBackground (x_current_display
, s
->display
.x
->normal_gc
,
629 s
->display
.x
->background_pixel
);
630 XSetForeground (x_current_display
, s
->display
.x
->reverse_gc
,
631 s
->display
.x
->background_pixel
);
632 XSetWindowBackground (x_current_display
, s
->display
.x
->window_desc
,
633 s
->display
.x
->background_pixel
);
636 if (s
->display
.x
->v_scrollbar
)
638 Pixmap up_arrow_pixmap
, down_arrow_pixmap
, slider_pixmap
;
640 XSetWindowBackground (x_current_display
, s
->display
.x
->v_scrollbar
,
641 s
->display
.x
->background_pixel
);
644 XCreatePixmapFromBitmapData (XDISPLAY s
->display
.x
->window_desc
,
646 s
->display
.x
->foreground_pixel
,
647 s
->display
.x
->background_pixel
,
648 DefaultDepth (x_current_display
,
649 XDefaultScreen (x_current_display
)));
651 XCreatePixmapFromBitmapData (XDISPLAY s
->display
.x
->window_desc
,
652 up_arrow_bits
, 16, 16,
653 s
->display
.x
->foreground_pixel
,
654 s
->display
.x
->background_pixel
,
655 DefaultDepth (x_current_display
,
656 XDefaultScreen (x_current_display
)));
658 XCreatePixmapFromBitmapData (XDISPLAY s
->display
.x
->window_desc
,
659 down_arrow_bits
, 16, 16,
660 s
->display
.x
->foreground_pixel
,
661 s
->display
.x
->background_pixel
,
662 DefaultDepth (x_current_display
,
663 XDefaultScreen (x_current_display
)));
665 XSetWindowBackgroundPixmap (XDISPLAY s
->display
.x
->v_thumbup
,
667 XSetWindowBackgroundPixmap (XDISPLAY s
->display
.x
->v_thumbdown
,
669 XSetWindowBackgroundPixmap (XDISPLAY s
->display
.x
->v_slider
,
672 XClearWindow (XDISPLAY s
->display
.x
->v_thumbup
);
673 XClearWindow (XDISPLAY s
->display
.x
->v_thumbdown
);
674 XClearWindow (XDISPLAY s
->display
.x
->v_slider
);
676 XFreePixmap (x_current_display
, down_arrow_pixmap
);
677 XFreePixmap (x_current_display
, up_arrow_pixmap
);
678 XFreePixmap (x_current_display
, slider_pixmap
);
680 if (s
->display
.x
->h_scrollbar
)
682 Pixmap left_arrow_pixmap
, right_arrow_pixmap
, slider_pixmap
;
684 XSetWindowBackground (x_current_display
, s
->display
.x
->h_scrollbar
,
685 s
->display
.x
->background_pixel
);
688 XCreatePixmapFromBitmapData (XDISPLAY s
->display
.x
->window_desc
,
690 s
->display
.x
->foreground_pixel
,
691 s
->display
.x
->background_pixel
,
692 DefaultDepth (x_current_display
,
693 XDefaultScreen (x_current_display
)));
696 XCreatePixmapFromBitmapData (XDISPLAY s
->display
.x
->window_desc
,
697 up_arrow_bits
, 16, 16,
698 s
->display
.x
->foreground_pixel
,
699 s
->display
.x
->background_pixel
,
700 DefaultDepth (x_current_display
,
701 XDefaultScreen (x_current_display
)));
703 XCreatePixmapFromBitmapData (XDISPLAY s
->display
.x
->window_desc
,
704 down_arrow_bits
, 16, 16,
705 s
->display
.x
->foreground_pixel
,
706 s
->display
.x
->background_pixel
,
707 DefaultDepth (x_current_display
,
708 XDefaultScreen (x_current_display
)));
710 XSetWindowBackgroundPixmap (XDISPLAY s
->display
.x
->h_slider
,
712 XSetWindowBackgroundPixmap (XDISPLAY s
->display
.x
->h_thumbleft
,
714 XSetWindowBackgroundPixmap (XDISPLAY s
->display
.x
->h_thumbright
,
717 XClearWindow (XDISPLAY s
->display
.x
->h_thumbleft
);
718 XClearWindow (XDISPLAY s
->display
.x
->h_thumbright
);
719 XClearWindow (XDISPLAY s
->display
.x
->h_slider
);
721 XFreePixmap (x_current_display
, slider_pixmap
);
722 XFreePixmap (x_current_display
, left_arrow_pixmap
);
723 XFreePixmap (x_current_display
, right_arrow_pixmap
);
726 temp
= XMakeTile (s
->display
.x
->background_pixel
);
727 XChangeBackground (s
->display
.x
->window_desc
, temp
);
729 #endif /* not HAVE_X11 */
738 x_set_mouse_color (s
, arg
, oldval
)
740 Lisp_Object arg
, oldval
;
742 Cursor cursor
, nontext_cursor
, mode_cursor
;
746 s
->display
.x
->mouse_pixel
= x_decode_color (arg
, BLACK_PIX_DEFAULT
);
747 mask_color
= s
->display
.x
->background_pixel
;
748 /* No invisible pointers. */
749 if (mask_color
== s
->display
.x
->mouse_pixel
750 && mask_color
== s
->display
.x
->background_pixel
)
751 s
->display
.x
->mouse_pixel
= s
->display
.x
->foreground_pixel
;
755 if (!EQ (Qnil
, Vx_pointer_shape
))
757 CHECK_NUMBER (Vx_pointer_shape
, 0);
758 cursor
= XCreateFontCursor (x_current_display
, XINT (Vx_pointer_shape
));
761 cursor
= XCreateFontCursor (x_current_display
, XC_xterm
);
763 if (!EQ (Qnil
, Vx_nontext_pointer_shape
))
765 CHECK_NUMBER (Vx_nontext_pointer_shape
, 0);
766 nontext_cursor
= XCreateFontCursor (x_current_display
,
767 XINT (Vx_nontext_pointer_shape
));
770 nontext_cursor
= XCreateFontCursor (x_current_display
, XC_left_ptr
);
772 if (!EQ (Qnil
, Vx_mode_pointer_shape
))
774 CHECK_NUMBER (Vx_mode_pointer_shape
, 0);
775 mode_cursor
= XCreateFontCursor (x_current_display
,
776 XINT (Vx_mode_pointer_shape
));
779 mode_cursor
= XCreateFontCursor (x_current_display
, XC_xterm
);
782 XColor fore_color
, back_color
;
784 fore_color
.pixel
= s
->display
.x
->mouse_pixel
;
785 back_color
.pixel
= mask_color
;
786 XQueryColor (x_current_display
,
787 DefaultColormap (x_current_display
,
788 DefaultScreen (x_current_display
)),
790 XQueryColor (x_current_display
,
791 DefaultColormap (x_current_display
,
792 DefaultScreen (x_current_display
)),
794 XRecolorCursor (x_current_display
, cursor
,
795 &fore_color
, &back_color
);
796 XRecolorCursor (x_current_display
, nontext_cursor
,
797 &fore_color
, &back_color
);
798 XRecolorCursor (x_current_display
, mode_cursor
,
799 &fore_color
, &back_color
);
802 cursor
= XCreateCursor (16, 16, MouseCursor
, MouseMask
,
804 s
->display
.x
->mouse_pixel
,
805 s
->display
.x
->background_pixel
,
809 if (s
->display
.x
->window_desc
!= 0)
811 XDefineCursor (XDISPLAY s
->display
.x
->window_desc
, cursor
);
814 if (cursor
!= s
->display
.x
->text_cursor
&& s
->display
.x
->text_cursor
!= 0)
815 XFreeCursor (XDISPLAY s
->display
.x
->text_cursor
);
816 s
->display
.x
->text_cursor
= cursor
;
818 if (nontext_cursor
!= s
->display
.x
->nontext_cursor
819 && s
->display
.x
->nontext_cursor
!= 0)
820 XFreeCursor (XDISPLAY s
->display
.x
->nontext_cursor
);
821 s
->display
.x
->nontext_cursor
= nontext_cursor
;
823 if (mode_cursor
!= s
->display
.x
->modeline_cursor
824 && s
->display
.x
->modeline_cursor
!= 0)
825 XFreeCursor (XDISPLAY s
->display
.x
->modeline_cursor
);
826 s
->display
.x
->modeline_cursor
= mode_cursor
;
827 #endif /* HAVE_X11 */
834 x_set_cursor_color (s
, arg
, oldval
)
836 Lisp_Object arg
, oldval
;
838 unsigned long fore_pixel
;
840 if (!EQ (Vx_cursor_fore_pixel
, Qnil
))
841 fore_pixel
= x_decode_color (Vx_cursor_fore_pixel
, WHITE_PIX_DEFAULT
);
843 fore_pixel
= s
->display
.x
->background_pixel
;
844 s
->display
.x
->cursor_pixel
= x_decode_color (arg
, BLACK_PIX_DEFAULT
);
845 /* No invisible cursors */
846 if (s
->display
.x
->cursor_pixel
== s
->display
.x
->background_pixel
)
848 s
->display
.x
->cursor_pixel
== s
->display
.x
->mouse_pixel
;
849 if (s
->display
.x
->cursor_pixel
== fore_pixel
)
850 fore_pixel
= s
->display
.x
->background_pixel
;
853 if (s
->display
.x
->window_desc
!= 0)
857 XSetBackground (x_current_display
, s
->display
.x
->cursor_gc
,
858 s
->display
.x
->cursor_pixel
);
859 XSetForeground (x_current_display
, s
->display
.x
->cursor_gc
,
862 #endif /* HAVE_X11 */
866 x_display_cursor (s
, 0);
867 x_display_cursor (s
, 1);
872 /* Set the border-color of screen S to value described by ARG.
873 ARG can be a string naming a color.
874 The border-color is used for the border that is drawn by the X server.
875 Note that this does not fully take effect if done before
876 S has an x-window; it must be redone when the window is created.
878 Note: this is done in two routines because of the way X10 works.
880 Note: under X11, this is normally the province of the window manager,
881 and so emacs' border colors may be overridden. */
884 x_set_border_color (s
, arg
, oldval
)
886 Lisp_Object arg
, oldval
;
891 CHECK_STRING (arg
, 0);
892 str
= XSTRING (arg
)->data
;
895 if (!strcmp (str
, "grey") || !strcmp (str
, "Grey")
896 || !strcmp (str
, "gray") || !strcmp (str
, "Gray"))
901 pix
= x_decode_color (arg
, BLACK_PIX_DEFAULT
);
903 x_set_border_pixel (s
, pix
);
906 /* Set the border-color of screen S to pixel value PIX.
907 Note that this does not fully take effect if done before
908 S has an x-window. */
910 x_set_border_pixel (s
, pix
)
914 s
->display
.x
->border_pixel
= pix
;
916 if (s
->display
.x
->window_desc
!= 0 && s
->display
.x
->border_width
> 0)
923 XSetWindowBorder (x_current_display
, s
->display
.x
->window_desc
,
925 if (s
->display
.x
->h_scrollbar
)
926 XSetWindowBorder (x_current_display
, s
->display
.x
->h_slider
,
928 if (s
->display
.x
->v_scrollbar
)
929 XSetWindowBorder (x_current_display
, s
->display
.x
->v_slider
,
933 temp
= XMakePixmap ((Bitmap
) XStoreBitmap (16, 16, gray_bits
),
934 BLACK_PIX_DEFAULT
, WHITE_PIX_DEFAULT
);
936 temp
= XMakeTile (pix
);
937 XChangeBorder (s
->display
.x
->window_desc
, temp
);
938 XFreePixmap (XDISPLAY temp
);
939 #endif /* not HAVE_X11 */
948 x_set_icon_type (s
, arg
, oldval
)
950 Lisp_Object arg
, oldval
;
955 if (EQ (oldval
, Qnil
) == EQ (arg
, Qnil
))
960 result
= x_text_icon (s
, 0);
962 result
= x_bitmap_icon (s
, 0);
966 error ("No icon window available.");
970 /* If the window was unmapped (and its icon was mapped),
971 the new icon is not mapped, so map the window in its stead. */
973 XMapWindow (XDISPLAY s
->display
.x
->window_desc
);
980 x_set_font (s
, arg
, oldval
)
982 Lisp_Object arg
, oldval
;
987 CHECK_STRING (arg
, 1);
988 name
= XSTRING (arg
)->data
;
991 result
= x_new_font (s
, name
);
995 error ("Font \"%s\" is not defined", name
);
999 x_set_border_width (s
, arg
, oldval
)
1001 Lisp_Object arg
, oldval
;
1003 CHECK_NUMBER (arg
, 0);
1005 if (XINT (arg
) == s
->display
.x
->border_width
)
1008 if (s
->display
.x
->window_desc
!= 0)
1009 error ("Cannot change the border width of a window");
1011 s
->display
.x
->border_width
= XINT (arg
);
1015 x_set_internal_border_width (s
, arg
, oldval
)
1017 Lisp_Object arg
, oldval
;
1020 int old
= s
->display
.x
->internal_border_width
;
1022 CHECK_NUMBER (arg
, 0);
1023 s
->display
.x
->internal_border_width
= XINT (arg
);
1024 if (s
->display
.x
->internal_border_width
< 0)
1025 s
->display
.x
->internal_border_width
= 0;
1027 if (s
->display
.x
->internal_border_width
== old
)
1030 if (s
->display
.x
->window_desc
!= 0)
1033 x_set_window_size (s
, s
->width
, s
->height
);
1035 x_set_resize_hint (s
);
1039 SET_SCREEN_GARBAGED (s
);
1044 x_set_name (s
, arg
, oldval
)
1046 Lisp_Object arg
, oldval
;
1048 CHECK_STRING (arg
, 0);
1050 if (s
->display
.x
->window_desc
)
1054 XStoreName (XDISPLAY s
->display
.x
->window_desc
,
1055 (char *) XSTRING (arg
)->data
);
1056 XSetIconName (XDISPLAY s
->display
.x
->window_desc
,
1057 (char *) XSTRING (arg
)->data
);
1063 x_set_autoraise (s
, arg
, oldval
)
1065 Lisp_Object arg
, oldval
;
1067 s
->auto_raise
= !EQ (Qnil
, arg
);
1071 x_set_autolower (s
, arg
, oldval
)
1073 Lisp_Object arg
, oldval
;
1075 s
->auto_lower
= !EQ (Qnil
, arg
);
1081 x_set_face (scr
, font
, background
, foreground
, stipple
)
1084 unsigned long background
, foreground
;
1087 XGCValues gc_values
;
1089 unsigned long gc_mask
;
1090 struct face
*new_face
;
1091 unsigned int width
= 16;
1092 unsigned int height
= 16;
1094 if (n_faces
== MAX_FACES_AND_GLYPHS
)
1097 /* Create the Graphics Context. */
1098 gc_values
.font
= font
->fid
;
1099 gc_values
.foreground
= foreground
;
1100 gc_values
.background
= background
;
1101 gc_values
.line_width
= 0;
1102 gc_mask
= GCLineWidth
| GCFont
| GCForeground
| GCBackground
;
1106 = XCreateBitmapFromData (x_current_display
, ROOT_WINDOW
,
1107 (char *) stipple
, width
, height
);
1108 gc_mask
|= GCStipple
;
1111 temp_gc
= XCreateGC (x_current_display
, scr
->display
.x
->window_desc
,
1112 gc_mask
, &gc_values
);
1115 new_face
= (struct face
*) xmalloc (sizeof (struct face
));
1118 XFreeGC (x_current_display
, temp_gc
);
1122 new_face
->font
= font
;
1123 new_face
->foreground
= foreground
;
1124 new_face
->background
= background
;
1125 new_face
->face_gc
= temp_gc
;
1127 new_face
->stipple
= gc_values
.stipple
;
1129 x_face_table
[++n_faces
] = new_face
;
1133 x_set_glyph (scr
, glyph
)
1138 DEFUN ("x-set-face-font", Fx_set_face_font
, Sx_set_face_font
, 4, 2, 0,
1139 "Specify face table entry FACE-CODE to be the font named by FONT,\n\
1140 in colors FOREGROUND and BACKGROUND.")
1141 (face_code
, font_name
, foreground
, background
)
1142 Lisp_Object face_code
;
1143 Lisp_Object font_name
;
1144 Lisp_Object foreground
;
1145 Lisp_Object background
;
1147 register struct face
*fp
; /* Current face info. */
1148 register int fn
; /* Face number. */
1149 register FONT_TYPE
*f
; /* Font data structure. */
1150 unsigned char *newname
;
1153 XGCValues gc_values
;
1155 /* Need to do something about this. */
1156 Drawable drawable
= selected_screen
->display
.x
->window_desc
;
1158 CHECK_NUMBER (face_code
, 1);
1159 CHECK_STRING (font_name
, 2);
1161 if (EQ (foreground
, Qnil
) || EQ (background
, Qnil
))
1163 fg
= selected_screen
->display
.x
->foreground_pixel
;
1164 bg
= selected_screen
->display
.x
->background_pixel
;
1168 CHECK_NUMBER (foreground
, 0);
1169 CHECK_NUMBER (background
, 1);
1171 fg
= x_decode_color (XINT (foreground
), BLACK_PIX_DEFAULT
);
1172 bg
= x_decode_color (XINT (background
), WHITE_PIX_DEFAULT
);
1175 fn
= XINT (face_code
);
1176 if ((fn
< 1) || (fn
> 255))
1177 error ("Invalid face code, %d", fn
);
1179 newname
= XSTRING (font_name
)->data
;
1181 f
= (*newname
== 0 ? 0 : XGetFont (newname
));
1184 error ("Font \"%s\" is not defined", newname
);
1186 fp
= x_face_table
[fn
];
1189 x_face_table
[fn
] = fp
= (struct face
*) xmalloc (sizeof (struct face
));
1190 bzero (fp
, sizeof (struct face
));
1191 fp
->face_type
= x_pixmap
;
1193 else if (FACE_IS_FONT (fn
))
1196 XFreeGC (FACE_FONT (fn
));
1199 else if (FACE_IS_IMAGE (fn
)) /* This should not happen... */
1202 XFreePixmap (x_current_display
, FACE_IMAGE (fn
));
1203 fp
->face_type
= x_font
;
1209 fp
->face_GLYPH
.font_desc
.font
= f
;
1210 gc_values
.font
= f
->fid
;
1211 gc_values
.foreground
= fg
;
1212 gc_values
.background
= bg
;
1213 fp
->face_GLYPH
.font_desc
.face_gc
= XCreateGC (x_current_display
,
1214 drawable
, GCFont
| GCForeground
1215 | GCBackground
, &gc_values
);
1216 fp
->face_GLYPH
.font_desc
.font_width
= FONT_WIDTH (f
);
1217 fp
->face_GLYPH
.font_desc
.font_height
= FONT_HEIGHT (f
);
1223 DEFUN ("x-set-face", Fx_set_face
, Sx_set_face
, 4, 4, 0,
1224 "Specify face table entry FACE-CODE to be the font named by FONT,\n\
1225 in colors FOREGROUND and BACKGROUND.")
1226 (face_code
, font_name
, foreground
, background
)
1227 Lisp_Object face_code
;
1228 Lisp_Object font_name
;
1229 Lisp_Object foreground
;
1230 Lisp_Object background
;
1232 register struct face
*fp
; /* Current face info. */
1233 register int fn
; /* Face number. */
1234 register FONT_TYPE
*f
; /* Font data structure. */
1235 unsigned char *newname
;
1237 CHECK_NUMBER (face_code
, 1);
1238 CHECK_STRING (font_name
, 2);
1240 fn
= XINT (face_code
);
1241 if ((fn
< 1) || (fn
> 255))
1242 error ("Invalid face code, %d", fn
);
1244 /* Ask the server to find the specified font. */
1245 newname
= XSTRING (font_name
)->data
;
1247 f
= (*newname
== 0 ? 0 : XGetFont (newname
));
1250 error ("Font \"%s\" is not defined", newname
);
1252 /* Get the face structure for face_code in the face table.
1253 Make sure it exists. */
1254 fp
= x_face_table
[fn
];
1257 x_face_table
[fn
] = fp
= (struct face
*) xmalloc (sizeof (struct face
));
1258 bzero (fp
, sizeof (struct face
));
1261 /* If this face code already exists, get rid of the old font. */
1262 if (fp
->font
!= 0 && fp
->font
!= f
)
1265 XLoseFont (fp
->font
);
1269 /* Store the specified information in FP. */
1270 fp
->fg
= x_decode_color (foreground
, BLACK_PIX_DEFAULT
);
1271 fp
->bg
= x_decode_color (background
, WHITE_PIX_DEFAULT
);
1279 /* This is excluded because there is no painless way
1280 to get or to remember the name of the font. */
1282 DEFUN ("x-get-face", Fx_get_face
, Sx_get_face
, 1, 1, 0,
1283 "Get data defining face code FACE. FACE is an integer.\n\
1284 The value is a list (FONT FG-COLOR BG-COLOR).")
1288 register struct face
*fp
; /* Current face info. */
1289 register int fn
; /* Face number. */
1291 CHECK_NUMBER (face
, 1);
1293 if ((fn
< 1) || (fn
> 255))
1294 error ("Invalid face code, %d", fn
);
1296 /* Make sure the face table exists and this face code is defined. */
1297 if (x_face_table
== 0 || x_face_table
[fn
] == 0)
1300 fp
= x_face_table
[fn
];
1302 return Fcons (build_string (fp
->name
),
1303 Fcons (make_number (fp
->fg
),
1304 Fcons (make_number (fp
->bg
), Qnil
)));
1308 /* Subroutines of creating an X screen. */
1311 extern char *x_get_string_resource ();
1312 extern XrmDatabase
x_load_resources ();
1314 DEFUN ("x-get-resource", Fx_get_resource
, Sx_get_resource
, 1, 3, 0,
1315 "Retrieve the value of ATTRIBUTE from the X defaults database. This\n\
1316 searches using a key of the form \"INSTANCE.ATTRIBUTE\", with class\n\
1317 \"Emacs\", where INSTANCE is the name under which Emacs was invoked.\n\
1319 Optional arguments COMPONENT and CLASS specify the component for which\n\
1320 we should look up ATTRIBUTE. When specified, Emacs searches using a\n\
1321 key of the form INSTANCE.COMPONENT.ATTRIBUTE, with class \"Emacs.CLASS\".")
1322 (attribute
, name
, class)
1323 Lisp_Object attribute
, name
, class;
1325 register char *value
;
1329 CHECK_STRING (attribute
, 0);
1331 CHECK_STRING (name
, 1);
1333 CHECK_STRING (class, 2);
1334 if (NULL (name
) != NULL (class))
1335 error ("x-get-resource: must specify both NAME and CLASS or neither");
1339 name_key
= (char *) alloca (XSTRING (invocation_name
)->size
+ 1
1340 + XSTRING (attribute
)->size
+ 1);
1342 sprintf (name_key
, "%s.%s",
1343 XSTRING (invocation_name
)->data
,
1344 XSTRING (attribute
)->data
);
1345 class_key
= EMACS_CLASS
;
1349 name_key
= (char *) alloca (XSTRING (invocation_name
)->size
+ 1
1350 + XSTRING (name
)->size
+ 1
1351 + XSTRING (attribute
)->size
+ 1);
1353 class_key
= (char *) alloca (sizeof (EMACS_CLASS
)
1354 + XSTRING (class)->size
+ 1);
1356 sprintf (name_key
, "%s.%s.%s",
1357 XSTRING (invocation_name
)->data
,
1358 XSTRING (name
)->data
,
1359 XSTRING (attribute
)->data
);
1360 sprintf (class_key
, "%s.%s",
1361 XSTRING (invocation_name
)->data
,
1362 XSTRING (class)->data
);
1365 value
= x_get_string_resource (xrdb
, name_key
, class_key
);
1367 if (value
!= (char *) 0)
1368 return build_string (value
);
1375 DEFUN ("x-get-default", Fx_get_default
, Sx_get_default
, 1, 1, 0,
1376 "Get X default ATTRIBUTE from the system, or nil if no default.\n\
1377 Value is a string (when not nil) and ATTRIBUTE is also a string.\n\
1378 The defaults are specified in the file `~/.Xdefaults'.")
1382 register unsigned char *value
;
1384 CHECK_STRING (arg
, 1);
1386 value
= (unsigned char *) XGetDefault (XDISPLAY
1387 XSTRING (invocation_name
)->data
,
1388 XSTRING (arg
)->data
);
1390 /* Try reversing last two args, in case this is the buggy version of X. */
1391 value
= (unsigned char *) XGetDefault (XDISPLAY
1392 XSTRING (arg
)->data
,
1393 XSTRING (invocation_name
)->data
);
1395 return build_string (value
);
1400 #define Fx_get_resource(attribute, name, class) Fx_get_default(attribute)
1404 /* Types we might convert a resource string into. */
1407 number
, boolean
, string
,
1410 /* Return the value of parameter PARAM.
1412 First search ALIST, then Vdefault_screen_alist, then the X defaults
1413 database, using SCREEN_NAME as the subcomponent of emacs and
1414 ATTRIBUTE as the attribute name.
1416 Convert the resource to the type specified by desired_type.
1418 If no default is specified, return nil. */
1421 x_get_arg (alist
, param
, screen_name
, attribute
, type
)
1422 Lisp_Object alist
, param
, screen_name
;
1424 enum resource_types type
;
1426 register Lisp_Object tem
;
1428 tem
= Fassq (param
, alist
);
1430 tem
= Fassq (param
, Vdefault_screen_alist
);
1431 if (EQ (tem
, Qnil
) && attribute
)
1433 Lisp_Object sterile_name
;
1435 /* Build a version of screen name that is safe to use as a
1437 if (XTYPE (screen_name
) == Lisp_String
)
1439 sterile_name
= make_uninit_string (XSTRING (screen_name
)->size
);
1441 for (i
= 0; i
< XSTRING (sterile_name
)->size
; i
++)
1443 int c
= XSTRING (screen_name
)->data
[i
];
1444 if (c
== ':' || c
== '.' || c
== '*' || isspace (c
))
1446 XSTRING (sterile_name
)->data
[i
] = c
;
1450 sterile_name
= Qnil
;
1452 tem
= Fx_get_resource (build_string (attribute
),
1454 (NULL (sterile_name
) ? Qnil
: screen_class
));
1462 return make_number (atoi (XSTRING (tem
)->data
));
1465 tem
= Fdowncase (tem
);
1466 if (!strcmp (XSTRING (tem
)->data
, "on")
1467 || !strcmp (XSTRING (tem
)->data
, "true"))
1482 /* Record in screen S the specified or default value according to ALIST
1483 of the parameter named PARAM (a Lisp symbol).
1484 If no value is specified for PARAM, look for an X default for XPROP
1485 on the screen named NAME.
1486 If that is not found either, use the value DEFLT. */
1489 x_default_parameter (s
, alist
, propname
, deflt
, xprop
, type
)
1495 enum resource_types type
;
1497 Lisp_Object propsym
= intern (propname
);
1500 tem
= x_get_arg (alist
, propsym
, s
->name
, xprop
, type
);
1503 store_screen_param (s
, propsym
, tem
);
1504 x_set_screen_param (s
, propsym
, tem
, Qnil
);
1508 DEFUN ("x-geometry", Fx_geometry
, Sx_geometry
, 1, 1, 0,
1509 "Parse an X-style geometry string STRING.\n\
1510 Returns an alist of the form ((top . TOP), (left . LEFT) ... ).")
1514 unsigned int width
, height
;
1515 Lisp_Object values
[4];
1517 CHECK_STRING (string
, 0);
1519 geometry
= XParseGeometry ((char *) XSTRING (string
)->data
,
1520 &x
, &y
, &width
, &height
);
1522 switch (geometry
& 0xf) /* Mask out {X,Y}Negative */
1524 case (XValue
| YValue
):
1525 /* What's one pixel among friends?
1526 Perhaps fix this some day by returning symbol `extreme-top'... */
1527 if (x
== 0 && (geometry
& XNegative
))
1529 if (y
== 0 && (geometry
& YNegative
))
1531 values
[0] = Fcons (intern ("left"), make_number (x
));
1532 values
[1] = Fcons (intern ("top"), make_number (y
));
1533 return Flist (2, values
);
1536 case (WidthValue
| HeightValue
):
1537 values
[0] = Fcons (intern ("width"), make_number (width
));
1538 values
[1] = Fcons (intern ("height"), make_number (height
));
1539 return Flist (2, values
);
1542 case (XValue
| YValue
| WidthValue
| HeightValue
):
1543 if (x
== 0 && (geometry
& XNegative
))
1545 if (y
== 0 && (geometry
& YNegative
))
1547 values
[0] = Fcons (intern ("width"), make_number (width
));
1548 values
[1] = Fcons (intern ("height"), make_number (height
));
1549 values
[2] = Fcons (intern ("left"), make_number (x
));
1550 values
[3] = Fcons (intern ("top"), make_number (y
));
1551 return Flist (4, values
);
1558 error ("Must specify x and y value, and/or width and height");
1563 /* Calculate the desired size and position of this window,
1564 or set rubber-band prompting if none. */
1566 #define DEFAULT_ROWS 40
1567 #define DEFAULT_COLS 80
1570 x_figure_window_size (s
, parms
)
1574 register Lisp_Object tem0
, tem1
;
1575 int height
, width
, left
, top
;
1576 register int geometry
;
1577 long window_prompting
= 0;
1579 /* Default values if we fall through.
1580 Actually, if that happens we should get
1581 window manager prompting. */
1582 s
->width
= DEFAULT_COLS
;
1583 s
->height
= DEFAULT_ROWS
;
1584 s
->display
.x
->top_pos
= 1;
1585 s
->display
.x
->left_pos
= 1;
1587 tem0
= x_get_arg (parms
, intern ("height"), s
->name
, 0, 0);
1588 tem1
= x_get_arg (parms
, intern ("width"), s
->name
, 0, 0);
1589 if (! EQ (tem0
, Qnil
) && ! EQ (tem1
, Qnil
))
1591 CHECK_NUMBER (tem0
, 0);
1592 CHECK_NUMBER (tem1
, 0);
1593 s
->height
= XINT (tem0
);
1594 s
->width
= XINT (tem1
);
1595 window_prompting
|= USSize
;
1597 else if (! EQ (tem0
, Qnil
) || ! EQ (tem1
, Qnil
))
1598 error ("Must specify *both* height and width");
1600 s
->display
.x
->pixel_width
= (FONT_WIDTH (s
->display
.x
->font
) * s
->width
1601 + 2 * s
->display
.x
->internal_border_width
);
1602 s
->display
.x
->pixel_height
= (FONT_HEIGHT (s
->display
.x
->font
) * s
->height
1603 + 2 * s
->display
.x
->internal_border_width
);
1605 tem0
= x_get_arg (parms
, intern ("top"), s
->name
, 0, 0);
1606 tem1
= x_get_arg (parms
, intern ("left"), s
->name
, 0, 0);
1607 if (! EQ (tem0
, Qnil
) && ! EQ (tem1
, Qnil
))
1609 CHECK_NUMBER (tem0
, 0);
1610 CHECK_NUMBER (tem1
, 0);
1611 s
->display
.x
->top_pos
= XINT (tem0
);
1612 s
->display
.x
->left_pos
= XINT (tem1
);
1613 x_calc_absolute_position (s
);
1614 window_prompting
|= USPosition
;
1616 else if (! EQ (tem0
, Qnil
) || ! EQ (tem1
, Qnil
))
1617 error ("Must specify *both* top and left corners");
1619 switch (window_prompting
)
1621 case USSize
| USPosition
:
1622 return window_prompting
;
1625 case USSize
: /* Got the size, need the position. */
1626 window_prompting
|= PPosition
;
1627 return window_prompting
;
1630 case USPosition
: /* Got the position, need the size. */
1631 window_prompting
|= PSize
;
1632 return window_prompting
;
1635 case 0: /* Got nothing, take both from geometry. */
1636 window_prompting
|= PPosition
| PSize
;
1637 return window_prompting
;
1641 /* Somehow a bit got set in window_prompting that we didn't
1651 XSetWindowAttributes attributes
;
1652 unsigned long attribute_mask
;
1653 XClassHint class_hints
;
1655 attributes
.background_pixel
= s
->display
.x
->background_pixel
;
1656 attributes
.border_pixel
= s
->display
.x
->border_pixel
;
1657 attributes
.bit_gravity
= StaticGravity
;
1658 attributes
.backing_store
= NotUseful
;
1659 attributes
.save_under
= True
;
1660 attributes
.event_mask
= STANDARD_EVENT_SET
;
1661 attribute_mask
= (CWBackPixel
| CWBorderPixel
| CWBitGravity
1663 | CWBackingStore
| CWSaveUnder
1668 s
->display
.x
->window_desc
1669 = XCreateWindow (x_current_display
, ROOT_WINDOW
,
1670 s
->display
.x
->left_pos
,
1671 s
->display
.x
->top_pos
,
1672 PIXEL_WIDTH (s
), PIXEL_HEIGHT (s
),
1673 s
->display
.x
->border_width
,
1674 CopyFromParent
, /* depth */
1675 InputOutput
, /* class */
1676 screen_visual
, /* set in Fx_open_connection */
1677 attribute_mask
, &attributes
);
1679 class_hints
.res_name
= s
->name
;
1680 class_hints
.res_class
= EMACS_CLASS
;
1681 XSetClassHint (x_current_display
, s
->display
.x
->window_desc
, &class_hints
);
1683 XDefineCursor (XDISPLAY s
->display
.x
->window_desc
,
1684 s
->display
.x
->text_cursor
);
1687 if (s
->display
.x
->window_desc
== 0)
1688 error ("Unable to create window.");
1691 /* Handle the icon stuff for this window. Perhaps later we might
1692 want an x_set_icon_position which can be called interactively as
1700 register Lisp_Object tem0
,tem1
;
1703 /* Set the position of the icon. Note that twm groups all
1704 icons in an icon window. */
1705 tem0
= x_get_arg (parms
, intern ("icon-left"), s
->name
, 0, 0);
1706 tem1
= x_get_arg (parms
, intern ("icon-top"), s
->name
, 0, 0);
1707 if (!EQ (tem0
, Qnil
) && !EQ (tem1
, Qnil
))
1709 CHECK_NUMBER (tem0
, 0);
1710 CHECK_NUMBER (tem1
, 0);
1711 hints
.icon_x
= XINT (tem0
);
1712 hints
.icon_x
= XINT (tem0
);
1714 else if (!EQ (tem0
, Qnil
) || !EQ (tem1
, Qnil
))
1715 error ("Both left and top icon corners of icon must be specified");
1718 hints
.icon_x
= s
->display
.x
->left_pos
;
1719 hints
.icon_y
= s
->display
.x
->top_pos
;
1722 /* Start up iconic or window? */
1723 tem0
= x_get_arg (parms
, intern ("iconic-startup"), s
->name
, 0, 0);
1724 if (!EQ (tem0
, Qnil
))
1725 hints
.initial_state
= IconicState
;
1727 hints
.initial_state
= NormalState
; /* the default, actually. */
1728 hints
.input
= False
;
1731 hints
.flags
= StateHint
| IconPositionHint
| InputHint
;
1732 XSetWMHints (x_current_display
, s
->display
.x
->window_desc
, &hints
);
1736 /* Make the GC's needed for this window, setting the
1737 background, border and mouse colors; also create the
1738 mouse cursor and the gray border tile. */
1744 XGCValues gc_values
;
1747 static char cursor_bits
[] =
1749 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1750 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1751 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1752 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1755 /* Create the GC's of this screen.
1756 Note that many default values are used. */
1759 gc_values
.font
= s
->display
.x
->font
->fid
;
1760 gc_values
.foreground
= s
->display
.x
->foreground_pixel
;
1761 gc_values
.background
= s
->display
.x
->background_pixel
;
1762 gc_values
.line_width
= 0; /* Means 1 using fast algorithm. */
1763 s
->display
.x
->normal_gc
= XCreateGC (x_current_display
,
1764 s
->display
.x
->window_desc
,
1765 GCLineWidth
| GCFont
1766 | GCForeground
| GCBackground
,
1769 /* Reverse video style. */
1770 gc_values
.foreground
= s
->display
.x
->background_pixel
;
1771 gc_values
.background
= s
->display
.x
->foreground_pixel
;
1772 s
->display
.x
->reverse_gc
= XCreateGC (x_current_display
,
1773 s
->display
.x
->window_desc
,
1774 GCFont
| GCForeground
| GCBackground
1778 /* Cursor has cursor-color background, background-color foreground. */
1779 gc_values
.foreground
= s
->display
.x
->background_pixel
;
1780 gc_values
.background
= s
->display
.x
->cursor_pixel
;
1781 gc_values
.fill_style
= FillOpaqueStippled
;
1783 = XCreateBitmapFromData (x_current_display
, ROOT_WINDOW
,
1784 cursor_bits
, 16, 16);
1785 s
->display
.x
->cursor_gc
1786 = XCreateGC (x_current_display
, s
->display
.x
->window_desc
,
1787 (GCFont
| GCForeground
| GCBackground
1788 | GCFillStyle
| GCStipple
| GCLineWidth
),
1791 /* Create the gray border tile used when the pointer is not in
1792 the screen. Since this depends on the screen's pixel values,
1793 this must be done on a per-screen basis. */
1794 s
->display
.x
->border_tile
=
1795 XCreatePixmap (x_current_display
, ROOT_WINDOW
, 16, 16,
1796 DefaultDepth (x_current_display
,
1797 XDefaultScreen (x_current_display
)));
1798 gc_values
.foreground
= s
->display
.x
->foreground_pixel
;
1799 gc_values
.background
= s
->display
.x
->background_pixel
;
1800 temp_gc
= XCreateGC (x_current_display
,
1801 (Drawable
) s
->display
.x
->border_tile
,
1802 GCForeground
| GCBackground
, &gc_values
);
1804 /* These are things that should be determined by the server, in
1805 Fx_open_connection */
1806 tileimage
.height
= 16;
1807 tileimage
.width
= 16;
1808 tileimage
.xoffset
= 0;
1809 tileimage
.format
= XYBitmap
;
1810 tileimage
.data
= gray_bits
;
1811 tileimage
.byte_order
= LSBFirst
;
1812 tileimage
.bitmap_unit
= 8;
1813 tileimage
.bitmap_bit_order
= LSBFirst
;
1814 tileimage
.bitmap_pad
= 8;
1815 tileimage
.bytes_per_line
= (16 + 7) >> 3;
1816 tileimage
.depth
= 1;
1817 XPutImage (x_current_display
, s
->display
.x
->border_tile
, temp_gc
,
1818 &tileimage
, 0, 0, 0, 0, 16, 16);
1819 XFreeGC (x_current_display
, temp_gc
);
1821 #endif /* HAVE_X11 */
1823 DEFUN ("x-create-screen", Fx_create_screen
, Sx_create_screen
,
1825 "Make a new X window, which is considered a \"screen\" in Emacs terms.\n\
1826 Return an Emacs screen object representing the X window.\n\
1827 ALIST is an alist of screen parameters.\n\
1828 The value of ``x-screen-defaults'' is an additional alist\n\
1829 of default parameters which apply when not overridden by ALIST.\n\
1830 If the parameters specify that the screen should not have a minibuffer,\n\
1831 then ``global-minibuffer-screen'' must be a screen whose minibuffer can\n\
1832 be shared by the new screen.")
1838 Lisp_Object screen
, tem
;
1840 int minibuffer_only
= 0;
1841 long window_prompting
= 0;
1844 if (x_current_display
== 0)
1845 error ("X windows are not in use or not initialized");
1847 name
= x_get_arg (parms
, intern ("name"), Qnil
, "Title", string
);
1849 name
= build_string (x_id_name
);
1850 if (XTYPE (name
) != Lisp_String
)
1851 error ("x-create-screen: name parameter must be a string");
1853 tem
= x_get_arg (parms
, intern ("minibuffer"), name
, 0, 0);
1854 if (EQ (tem
, intern ("none")))
1855 s
= make_screen_without_minibuffer (Qnil
);
1856 else if (EQ (tem
, intern ("only")))
1858 s
= make_minibuffer_screen ();
1859 minibuffer_only
= 1;
1861 else if (! EQ (tem
, Qnil
))
1862 s
= make_screen_without_minibuffer (tem
);
1864 s
= make_screen (1);
1866 /* Set the name; the functions to which we pass s expect the
1868 XSET (s
->name
, Lisp_String
, name
);
1870 XSET (screen
, Lisp_Screen
, s
);
1871 s
->output_method
= output_x_window
;
1872 s
->display
.x
= (struct x_display
*) xmalloc (sizeof (struct x_display
));
1873 bzero (s
->display
.x
, sizeof (struct x_display
));
1875 /* Extract the window parameters from the supplied values
1876 that are needed to determine window geometry. */
1877 x_default_parameter (s
, parms
, "font",
1878 build_string ("9x15"), "font", string
);
1879 x_default_parameter (s
, parms
, "background-color",
1880 build_string ("white"), "background", string
);
1881 x_default_parameter (s
, parms
, "border-width",
1882 make_number (2), "BorderWidth", number
);
1883 x_default_parameter (s
, parms
, "internal-border-width",
1884 make_number (4), "InternalBorderWidth", number
);
1886 /* Also do the stuff which must be set before the window exists. */
1887 x_default_parameter (s
, parms
, "foreground-color",
1888 build_string ("black"), "foreground", string
);
1889 x_default_parameter (s
, parms
, "mouse-color",
1890 build_string ("black"), "mouse", string
);
1891 x_default_parameter (s
, parms
, "cursor-color",
1892 build_string ("black"), "cursor", string
);
1893 x_default_parameter (s
, parms
, "border-color",
1894 build_string ("black"), "border", string
);
1896 /* Need to do icon type, auto-raise, auto-lower. */
1898 s
->display
.x
->parent_desc
= ROOT_WINDOW
;
1899 window_prompting
= x_figure_window_size (s
, parms
);
1905 /* Dimensions, especially s->height, must be done via change_screen_size.
1906 Change will not be effected unless different from the current
1910 s
->height
= s
->width
= 0;
1911 change_screen_size (s
, height
, width
, 1);
1913 x_wm_set_size_hint (s
, window_prompting
);
1916 tem
= x_get_arg (parms
, intern ("unsplittable"), name
, 0, 0);
1917 s
->no_split
= minibuffer_only
|| EQ (tem
, Qt
);
1919 /* Now handle the rest of the parameters. */
1920 x_default_parameter (s
, parms
, "horizontal-scroll-bar",
1921 Qnil
, "?HScrollBar", string
);
1922 x_default_parameter (s
, parms
, "vertical-scroll-bar",
1923 Qnil
, "?VScrollBar", string
);
1925 /* Make the window appear on the screen and enable display. */
1926 if (!EQ (x_get_arg (parms
, intern ("suppress-initial-map"), name
, 0, 0), Qt
))
1927 x_make_screen_visible (s
);
1932 Lisp_Object screen
, tem
;
1934 int pixelwidth
, pixelheight
;
1939 int minibuffer_only
= 0;
1940 Lisp_Object vscroll
, hscroll
;
1942 if (x_current_display
== 0)
1943 error ("X windows are not in use or not initialized");
1945 name
= Fassq (intern ("name"), parms
);
1947 tem
= x_get_arg (parms
, intern ("minibuffer"), name
, 0, 0);
1948 if (EQ (tem
, intern ("none")))
1949 s
= make_screen_without_minibuffer (Qnil
);
1950 else if (EQ (tem
, intern ("only")))
1952 s
= make_minibuffer_screen ();
1953 minibuffer_only
= 1;
1955 else if (! EQ (tem
, Qnil
))
1956 s
= make_screen_without_minibuffer (tem
);
1958 s
= make_screen (1);
1960 parent
= ROOT_WINDOW
;
1962 XSET (screen
, Lisp_Screen
, s
);
1963 s
->output_method
= output_x_window
;
1964 s
->display
.x
= (struct x_display
*) xmalloc (sizeof (struct x_display
));
1965 bzero (s
->display
.x
, sizeof (struct x_display
));
1967 /* Some temprorary default values for height and width. */
1970 s
->display
.x
->left_pos
= -1;
1971 s
->display
.x
->top_pos
= -1;
1973 /* Give the screen a default name (which may be overridden with PARMS). */
1975 strncpy (iconidentity
, ICONTAG
, MAXICID
);
1976 if (gethostname (&iconidentity
[sizeof (ICONTAG
) - 1],
1977 (MAXICID
- 1) - sizeof (ICONTAG
)))
1978 iconidentity
[sizeof (ICONTAG
) - 2] = '\0';
1979 s
->name
= build_string (iconidentity
);
1981 /* Extract some window parameters from the supplied values.
1982 These are the parameters that affect window geometry. */
1984 tem
= x_get_arg (parms
, intern ("font"), name
, "BodyFont", string
);
1986 tem
= build_string ("9x15");
1987 x_set_font (s
, tem
);
1988 x_default_parameter (s
, parms
, "border-color",
1989 build_string ("black"), "Border", string
);
1990 x_default_parameter (s
, parms
, "background-color",
1991 build_string ("white"), "Background", string
);
1992 x_default_parameter (s
, parms
, "foreground-color",
1993 build_string ("black"), "Foreground", string
);
1994 x_default_parameter (s
, parms
, "mouse-color",
1995 build_string ("black"), "Mouse", string
);
1996 x_default_parameter (s
, parms
, "cursor-color",
1997 build_string ("black"), "Cursor", string
);
1998 x_default_parameter (s
, parms
, "border-width",
1999 make_number (2), "BorderWidth", number
);
2000 x_default_parameter (s
, parms
, "internal-border-width",
2001 make_number (4), "InternalBorderWidth", number
);
2002 x_default_parameter (s
, parms
, "auto-raise",
2003 Qnil
, "AutoRaise", boolean
);
2005 hscroll
= x_get_arg (parms
, intern ("horizontal-scroll-bar"), name
, 0, 0);
2006 vscroll
= x_get_arg (parms
, intern ("vertical-scroll-bar"), name
, 0, 0);
2008 if (s
->display
.x
->internal_border_width
< 0)
2009 s
->display
.x
->internal_border_width
= 0;
2011 tem
= x_get_arg (parms
, intern ("window-id"), name
, 0, 0);
2012 if (!EQ (tem
, Qnil
))
2014 WINDOWINFO_TYPE wininfo
;
2016 Window
*children
, root
;
2018 CHECK_STRING (tem
, 0);
2019 s
->display
.x
->window_desc
= (Window
) atoi (XSTRING (tem
)->data
);
2022 XGetWindowInfo (s
->display
.x
->window_desc
, &wininfo
);
2023 XQueryTree (s
->display
.x
->window_desc
, &parent
, &nchildren
, &children
);
2027 height
= (wininfo
.height
- 2 * s
->display
.x
->internal_border_width
)
2028 / FONT_HEIGHT (s
->display
.x
->font
);
2029 width
= (wininfo
.width
- 2 * s
->display
.x
->internal_border_width
)
2030 / FONT_WIDTH (s
->display
.x
->font
);
2031 s
->display
.x
->left_pos
= wininfo
.x
;
2032 s
->display
.x
->top_pos
= wininfo
.y
;
2033 s
->visible
= wininfo
.mapped
!= 0;
2034 s
->display
.x
->border_width
= wininfo
.bdrwidth
;
2035 s
->display
.x
->parent_desc
= parent
;
2039 tem
= x_get_arg (parms
, intern ("parent-id"), name
, 0, 0);
2040 if (!EQ (tem
, Qnil
))
2042 CHECK_STRING (tem
, 0);
2043 parent
= (Window
) atoi (XSTRING (tem
)->data
);
2045 s
->display
.x
->parent_desc
= parent
;
2046 tem
= x_get_arg (parms
, intern ("height"), name
, 0, 0);
2049 tem
= x_get_arg (parms
, intern ("width"), name
, 0, 0);
2052 tem
= x_get_arg (parms
, intern ("top"), name
, 0, 0);
2054 tem
= x_get_arg (parms
, intern ("left"), name
, 0, 0);
2057 /* Now TEM is nil if no edge or size was specified.
2058 In that case, we must do rubber-banding. */
2061 tem
= x_get_arg (parms
, intern ("geometry"), name
, 0, 0);
2063 &s
->display
.x
->left_pos
, &s
->display
.x
->top_pos
,
2065 (XTYPE (tem
) == Lisp_String
2066 ? (char *) XSTRING (tem
)->data
: ""),
2067 XSTRING (s
->name
)->data
,
2068 !NULL (hscroll
), !NULL (vscroll
));
2072 /* Here if at least one edge or size was specified.
2073 Demand that they all were specified, and use them. */
2074 tem
= x_get_arg (parms
, intern ("height"), name
, 0, 0);
2076 error ("Height not specified");
2077 CHECK_NUMBER (tem
, 0);
2078 height
= XINT (tem
);
2080 tem
= x_get_arg (parms
, intern ("width"), name
, 0, 0);
2082 error ("Width not specified");
2083 CHECK_NUMBER (tem
, 0);
2086 tem
= x_get_arg (parms
, intern ("top"), name
, 0, 0);
2088 error ("Top position not specified");
2089 CHECK_NUMBER (tem
, 0);
2090 s
->display
.x
->left_pos
= XINT (tem
);
2092 tem
= x_get_arg (parms
, intern ("left"), name
, 0, 0);
2094 error ("Left position not specified");
2095 CHECK_NUMBER (tem
, 0);
2096 s
->display
.x
->top_pos
= XINT (tem
);
2099 pixelwidth
= (width
* FONT_WIDTH (s
->display
.x
->font
)
2100 + 2 * s
->display
.x
->internal_border_width
2101 + (!NULL (vscroll
) ? VSCROLL_WIDTH
: 0));
2102 pixelheight
= (height
* FONT_HEIGHT (s
->display
.x
->font
)
2103 + 2 * s
->display
.x
->internal_border_width
2104 + (!NULL (hscroll
) ? HSCROLL_HEIGHT
: 0));
2107 s
->display
.x
->window_desc
2108 = XCreateWindow (parent
,
2109 s
->display
.x
->left_pos
, /* Absolute horizontal offset */
2110 s
->display
.x
->top_pos
, /* Absolute Vertical offset */
2111 pixelwidth
, pixelheight
,
2112 s
->display
.x
->border_width
,
2113 BLACK_PIX_DEFAULT
, WHITE_PIX_DEFAULT
);
2115 if (s
->display
.x
->window_desc
== 0)
2116 error ("Unable to create window.");
2119 /* Install the now determined height and width
2120 in the windows and in phys_lines and desired_lines. */
2121 /* ??? jla version had 1 here instead of 0. */
2122 change_screen_size (s
, height
, width
, 1);
2123 XSelectInput (s
->display
.x
->window_desc
, KeyPressed
| ExposeWindow
2124 | ButtonPressed
| ButtonReleased
| ExposeRegion
| ExposeCopy
2125 | EnterWindow
| LeaveWindow
| UnmapWindow
);
2126 x_set_resize_hint (s
);
2128 /* Tell the server the window's default name. */
2130 XStoreName (XDISPLAY s
->display
.x
->window_desc
, XSTRING (s
->name
)->data
);
2131 /* Now override the defaults with all the rest of the specified
2133 tem
= x_get_arg (parms
, intern ("unsplittable"), name
, 0, 0);
2134 s
->no_split
= minibuffer_only
|| EQ (tem
, Qt
);
2136 /* Do not create an icon window if the caller says not to */
2137 if (!EQ (x_get_arg (parms
, intern ("suppress-icon"), name
, 0, 0), Qt
)
2138 || s
->display
.x
->parent_desc
!= ROOT_WINDOW
)
2140 x_text_icon (s
, iconidentity
);
2141 x_default_parameter (s
, parms
, "icon-type", Qnil
,
2142 "BitmapIcon", boolean
);
2145 /* Tell the X server the previously set values of the
2146 background, border and mouse colors; also create the mouse cursor. */
2148 temp
= XMakeTile (s
->display
.x
->background_pixel
);
2149 XChangeBackground (s
->display
.x
->window_desc
, temp
);
2152 x_set_border_pixel (s
, s
->display
.x
->border_pixel
);
2154 x_set_mouse_color (s
, Qnil
, Qnil
);
2156 /* Now override the defaults with all the rest of the specified parms. */
2158 Fmodify_screen_parameters (screen
, parms
);
2160 if (!NULL (vscroll
))
2161 install_vertical_scrollbar (s
, pixelwidth
, pixelheight
);
2162 if (!NULL (hscroll
))
2163 install_horizontal_scrollbar (s
, pixelwidth
, pixelheight
);
2165 /* Make the window appear on the screen and enable display. */
2167 if (!EQ (x_get_arg (parms
, intern ("suppress-initial-map"), name
, 0, 0), Qt
))
2168 x_make_window_visible (s
);
2169 SCREEN_GARBAGED (s
);
2175 DEFUN ("focus-screen", Ffocus_screen
, Sfocus_screen
, 1, 1, 0,
2176 "Set the focus on SCREEN.")
2180 CHECK_SCREEN (screen
, 0);
2182 if (SCREEN_IS_X (XSCREEN (screen
)))
2185 x_focus_on_screen (XSCREEN (screen
));
2193 DEFUN ("unfocus-screen", Funfocus_screen
, Sunfocus_screen
, 0, 0, 0,
2194 "If a screen has been focused, release it.")
2200 x_unfocus_screen (x_focus_screen
);
2208 /* Computes an X-window size and position either from geometry GEO
2211 S is a screen. It specifies an X window which is used to
2212 determine which display to compute for. Its font, borders
2213 and colors control how the rectangle will be displayed.
2215 X and Y are where to store the positions chosen.
2216 WIDTH and HEIGHT are where to store the sizes chosen.
2218 GEO is the geometry that may specify some of the info.
2219 STR is a prompt to display.
2220 HSCROLL and VSCROLL say whether we have horiz and vert scroll bars. */
2223 x_rubber_band (s
, x
, y
, width
, height
, geo
, str
, hscroll
, vscroll
)
2225 int *x
, *y
, *width
, *height
;
2228 int hscroll
, vscroll
;
2234 int background_color
;
2240 background_color
= s
->display
.x
->background_pixel
;
2241 border_color
= s
->display
.x
->border_pixel
;
2243 frame
.bdrwidth
= s
->display
.x
->border_width
;
2244 frame
.border
= XMakeTile (border_color
);
2245 frame
.background
= XMakeTile (background_color
);
2246 tempwindow
= XCreateTerm (str
, "emacs", geo
, default_window
, &frame
, 10, 5,
2247 (2 * s
->display
.x
->internal_border_width
2248 + (vscroll
? VSCROLL_WIDTH
: 0)),
2249 (2 * s
->display
.x
->internal_border_width
2250 + (hscroll
? HSCROLL_HEIGHT
: 0)),
2251 width
, height
, s
->display
.x
->font
,
2252 FONT_WIDTH (s
->display
.x
->font
),
2253 FONT_HEIGHT (s
->display
.x
->font
));
2254 XFreePixmap (frame
.border
);
2255 XFreePixmap (frame
.background
);
2257 if (tempwindow
!= 0)
2259 XQueryWindow (tempwindow
, &wininfo
);
2260 XDestroyWindow (tempwindow
);
2265 /* Coordinates we got are relative to the root window.
2266 Convert them to coordinates relative to desired parent window
2267 by scanning from there up to the root. */
2268 tempwindow
= s
->display
.x
->parent_desc
;
2269 while (tempwindow
!= ROOT_WINDOW
)
2273 XQueryWindow (tempwindow
, &wininfo
);
2276 XQueryTree (tempwindow
, &tempwindow
, &nchildren
, &children
);
2281 return tempwindow
!= 0;
2283 #endif /* not HAVE_X11 */
2285 /* Set whether screen S has a horizontal scroll bar.
2286 VAL is t or nil to specify it. */
2289 x_set_horizontal_scrollbar (s
, val
, oldval
)
2291 Lisp_Object val
, oldval
;
2295 if (s
->display
.x
->window_desc
!= 0)
2298 s
->display
.x
->h_scrollbar_height
= HSCROLL_HEIGHT
;
2299 x_set_window_size (s
, s
->width
, s
->height
);
2300 install_horizontal_scrollbar (s
);
2301 SET_SCREEN_GARBAGED (s
);
2306 if (s
->display
.x
->h_scrollbar
)
2309 s
->display
.x
->h_scrollbar_height
= 0;
2310 XDestroyWindow (XDISPLAY s
->display
.x
->h_scrollbar
);
2311 s
->display
.x
->h_scrollbar
= 0;
2312 x_set_window_size (s
, s
->width
, s
->height
);
2319 /* Set whether screen S has a vertical scroll bar.
2320 VAL is t or nil to specify it. */
2323 x_set_vertical_scrollbar (s
, val
, oldval
)
2325 Lisp_Object val
, oldval
;
2329 if (s
->display
.x
->window_desc
!= 0)
2332 s
->display
.x
->v_scrollbar_width
= VSCROLL_WIDTH
;
2333 x_set_window_size (s
, s
->width
, s
->height
);
2334 install_vertical_scrollbar (s
);
2335 SET_SCREEN_GARBAGED (s
);
2340 if (s
->display
.x
->v_scrollbar
!= 0)
2343 s
->display
.x
->v_scrollbar_width
= 0;
2344 XDestroyWindow (XDISPLAY s
->display
.x
->v_scrollbar
);
2345 s
->display
.x
->v_scrollbar
= 0;
2346 x_set_window_size (s
, s
->width
, s
->height
);
2347 SET_SCREEN_GARBAGED (s
);
2352 /* Create the X windows for a vertical scroll bar
2353 for a screen X that already has an X window but no scroll bar. */
2356 install_vertical_scrollbar (s
)
2359 int ibw
= s
->display
.x
->internal_border_width
;
2361 XColor fore_color
, back_color
;
2362 Pixmap up_arrow_pixmap
, down_arrow_pixmap
, slider_pixmap
;
2363 int pix_x
, pix_y
, width
, height
, border
;
2365 height
= s
->display
.x
->pixel_height
- ibw
- 2;
2366 width
= VSCROLL_WIDTH
- 2;
2367 pix_x
= s
->display
.x
->pixel_width
- ibw
/2;
2373 XCreatePixmapFromBitmapData (x_current_display
, s
->display
.x
->window_desc
,
2374 up_arrow_bits
, 16, 16,
2375 s
->display
.x
->foreground_pixel
,
2376 s
->display
.x
->background_pixel
,
2377 DefaultDepth (x_current_display
,
2378 XDefaultScreen (x_current_display
)));
2381 XCreatePixmapFromBitmapData (x_current_display
, s
->display
.x
->window_desc
,
2382 down_arrow_bits
, 16, 16,
2383 s
->display
.x
->foreground_pixel
,
2384 s
->display
.x
->background_pixel
,
2385 DefaultDepth (x_current_display
,
2386 XDefaultScreen (x_current_display
)));
2389 XCreatePixmapFromBitmapData (x_current_display
, s
->display
.x
->window_desc
,
2391 s
->display
.x
->foreground_pixel
,
2392 s
->display
.x
->background_pixel
,
2393 DefaultDepth (x_current_display
,
2394 XDefaultScreen (x_current_display
)));
2396 /* These cursor shapes will be installed when the mouse enters
2397 the appropriate window. */
2399 up_arrow_cursor
= XCreateFontCursor (x_current_display
, XC_sb_up_arrow
);
2400 down_arrow_cursor
= XCreateFontCursor (x_current_display
, XC_sb_down_arrow
);
2401 v_double_arrow_cursor
= XCreateFontCursor (x_current_display
, XC_sb_v_double_arrow
);
2403 s
->display
.x
->v_scrollbar
=
2404 XCreateSimpleWindow (x_current_display
, s
->display
.x
->window_desc
,
2405 pix_x
, pix_y
, width
, height
, border
,
2406 s
->display
.x
->foreground_pixel
,
2407 s
->display
.x
->background_pixel
);
2408 XFlush (x_current_display
);
2409 XDefineCursor (x_current_display
, s
->display
.x
->v_scrollbar
,
2410 v_double_arrow_cursor
);
2412 /* Create slider window */
2413 s
->display
.x
->v_slider
=
2414 XCreateSimpleWindow (x_current_display
, s
->display
.x
->v_scrollbar
,
2415 0, VSCROLL_WIDTH
- 2,
2416 VSCROLL_WIDTH
- 4, VSCROLL_WIDTH
- 4,
2417 1, s
->display
.x
->border_pixel
,
2418 s
->display
.x
->foreground_pixel
);
2419 XFlush (x_current_display
);
2420 XDefineCursor (x_current_display
, s
->display
.x
->v_slider
,
2421 v_double_arrow_cursor
);
2422 XSetWindowBackgroundPixmap (x_current_display
, s
->display
.x
->v_slider
,
2425 s
->display
.x
->v_thumbup
=
2426 XCreateSimpleWindow (x_current_display
, s
->display
.x
->v_scrollbar
,
2428 VSCROLL_WIDTH
- 2, VSCROLL_WIDTH
- 2,
2429 0, s
->display
.x
->foreground_pixel
,
2430 s
->display
.x
-> background_pixel
);
2431 XFlush (x_current_display
);
2432 XDefineCursor (x_current_display
, s
->display
.x
->v_thumbup
,
2434 XSetWindowBackgroundPixmap (x_current_display
, s
->display
.x
->v_thumbup
,
2437 s
->display
.x
->v_thumbdown
=
2438 XCreateSimpleWindow (x_current_display
, s
->display
.x
->v_scrollbar
,
2439 0, height
- VSCROLL_WIDTH
+ 2,
2440 VSCROLL_WIDTH
- 2, VSCROLL_WIDTH
- 2,
2441 0, s
->display
.x
->foreground_pixel
,
2442 s
->display
.x
->background_pixel
);
2443 XFlush (x_current_display
);
2444 XDefineCursor (x_current_display
, s
->display
.x
->v_thumbdown
,
2446 XSetWindowBackgroundPixmap (x_current_display
, s
->display
.x
->v_thumbdown
,
2449 fore_color
.pixel
= s
->display
.x
->mouse_pixel
;
2450 back_color
.pixel
= s
->display
.x
->background_pixel
;
2451 XQueryColor (x_current_display
,
2452 DefaultColormap (x_current_display
,
2453 DefaultScreen (x_current_display
)),
2455 XQueryColor (x_current_display
,
2456 DefaultColormap (x_current_display
,
2457 DefaultScreen (x_current_display
)),
2459 XRecolorCursor (x_current_display
, up_arrow_cursor
,
2460 &fore_color
, &back_color
);
2461 XRecolorCursor (x_current_display
, down_arrow_cursor
,
2462 &fore_color
, &back_color
);
2463 XRecolorCursor (x_current_display
, v_double_arrow_cursor
,
2464 &fore_color
, &back_color
);
2466 XFreePixmap (x_current_display
, slider_pixmap
);
2467 XFreePixmap (x_current_display
, up_arrow_pixmap
);
2468 XFreePixmap (x_current_display
, down_arrow_pixmap
);
2469 XFlush (x_current_display
);
2471 XSelectInput (x_current_display
, s
->display
.x
->v_scrollbar
,
2472 ButtonPressMask
| ButtonReleaseMask
2473 | PointerMotionMask
| PointerMotionHintMask
2475 XSelectInput (x_current_display
, s
->display
.x
->v_slider
,
2476 ButtonPressMask
| ButtonReleaseMask
);
2477 XSelectInput (x_current_display
, s
->display
.x
->v_thumbdown
,
2478 ButtonPressMask
| ButtonReleaseMask
);
2479 XSelectInput (x_current_display
, s
->display
.x
->v_thumbup
,
2480 ButtonPressMask
| ButtonReleaseMask
);
2481 XFlush (x_current_display
);
2483 /* This should be done at the same time as the main window. */
2484 XMapWindow (x_current_display
, s
->display
.x
->v_scrollbar
);
2485 XMapSubwindows (x_current_display
, s
->display
.x
->v_scrollbar
);
2486 XFlush (x_current_display
);
2487 #else /* not HAVE_X11 */
2489 Pixmap fore_tile
, back_tile
, bord_tile
;
2490 static short up_arrow_bits
[] = {
2491 0x0000, 0x0180, 0x03c0, 0x07e0,
2492 0x0ff0, 0x1ff8, 0x3ffc, 0x7ffe,
2493 0x0180, 0x0180, 0x0180, 0x0180,
2494 0x0180, 0x0180, 0x0180, 0xffff};
2495 static short down_arrow_bits
[] = {
2496 0xffff, 0x0180, 0x0180, 0x0180,
2497 0x0180, 0x0180, 0x0180, 0x0180,
2498 0x7ffe, 0x3ffc, 0x1ff8, 0x0ff0,
2499 0x07e0, 0x03c0, 0x0180, 0x0000};
2501 fore_tile
= XMakeTile (s
->display
.x
->foreground_pixel
);
2502 back_tile
= XMakeTile (s
->display
.x
->background_pixel
);
2503 bord_tile
= XMakeTile (s
->display
.x
->border_pixel
);
2505 b
= XStoreBitmap (VSCROLL_WIDTH
- 2, VSCROLL_WIDTH
- 2, up_arrow_bits
);
2506 up_arrow_pixmap
= XMakePixmap (b
,
2507 s
->display
.x
->foreground_pixel
,
2508 s
->display
.x
->background_pixel
);
2511 b
= XStoreBitmap (VSCROLL_WIDTH
- 2, VSCROLL_WIDTH
- 2, down_arrow_bits
);
2512 down_arrow_pixmap
= XMakePixmap (b
,
2513 s
->display
.x
->foreground_pixel
,
2514 s
->display
.x
->background_pixel
);
2517 ibw
= s
->display
.x
->internal_border_width
;
2519 s
->display
.x
->v_scrollbar
= XCreateWindow (s
->display
.x
->window_desc
,
2520 width
- VSCROLL_WIDTH
- ibw
/2,
2524 1, bord_tile
, back_tile
);
2526 s
->display
.x
->v_scrollbar_width
= VSCROLL_WIDTH
;
2528 s
->display
.x
->v_thumbup
= XCreateWindow (s
->display
.x
->v_scrollbar
,
2532 0, 0, up_arrow_pixmap
);
2533 XTileAbsolute (s
->display
.x
->v_thumbup
);
2535 s
->display
.x
->v_thumbdown
= XCreateWindow (s
->display
.x
->v_scrollbar
,
2537 height
- ibw
- VSCROLL_WIDTH
,
2540 0, 0, down_arrow_pixmap
);
2541 XTileAbsolute (s
->display
.x
->v_thumbdown
);
2543 s
->display
.x
->v_slider
= XCreateWindow (s
->display
.x
->v_scrollbar
,
2544 0, VSCROLL_WIDTH
- 2,
2547 1, back_tile
, fore_tile
);
2549 XSelectInput (s
->display
.x
->v_scrollbar
,
2550 (ButtonPressed
| ButtonReleased
| KeyPressed
));
2551 XSelectInput (s
->display
.x
->v_thumbup
,
2552 (ButtonPressed
| ButtonReleased
| KeyPressed
));
2554 XSelectInput (s
->display
.x
->v_thumbdown
,
2555 (ButtonPressed
| ButtonReleased
| KeyPressed
));
2557 XMapWindow (s
->display
.x
->v_thumbup
);
2558 XMapWindow (s
->display
.x
->v_thumbdown
);
2559 XMapWindow (s
->display
.x
->v_slider
);
2560 XMapWindow (s
->display
.x
->v_scrollbar
);
2562 XFreePixmap (fore_tile
);
2563 XFreePixmap (back_tile
);
2564 XFreePixmap (up_arrow_pixmap
);
2565 XFreePixmap (down_arrow_pixmap
);
2566 #endif /* not HAVE_X11 */
2570 install_horizontal_scrollbar (s
)
2573 int ibw
= s
->display
.x
->internal_border_width
;
2575 Pixmap left_arrow_pixmap
, right_arrow_pixmap
, slider_pixmap
;
2580 pix_y
= PIXEL_HEIGHT (s
) - HSCROLL_HEIGHT
- ibw
;
2581 width
= PIXEL_WIDTH (s
) - 2 * ibw
;
2582 if (s
->display
.x
->v_scrollbar_width
)
2583 width
-= (s
->display
.x
->v_scrollbar_width
+ 1);
2587 XCreatePixmapFromBitmapData (x_current_display
, s
->display
.x
->window_desc
,
2588 left_arrow_bits
, 16, 16,
2589 s
->display
.x
->foreground_pixel
,
2590 s
->display
.x
->background_pixel
,
2591 DefaultDepth (x_current_display
,
2592 XDefaultScreen (x_current_display
)));
2594 right_arrow_pixmap
=
2595 XCreatePixmapFromBitmapData (x_current_display
, s
->display
.x
->window_desc
,
2596 right_arrow_bits
, 16, 16,
2597 s
->display
.x
->foreground_pixel
,
2598 s
->display
.x
->background_pixel
,
2599 DefaultDepth (x_current_display
,
2600 XDefaultScreen (x_current_display
)));
2603 XCreatePixmapFromBitmapData (x_current_display
, s
->display
.x
->window_desc
,
2605 s
->display
.x
->foreground_pixel
,
2606 s
->display
.x
->background_pixel
,
2607 DefaultDepth (x_current_display
,
2608 XDefaultScreen (x_current_display
)));
2610 left_arrow_cursor
= XCreateFontCursor (x_current_display
, XC_sb_left_arrow
);
2611 right_arrow_cursor
= XCreateFontCursor (x_current_display
, XC_sb_right_arrow
);
2612 h_double_arrow_cursor
= XCreateFontCursor (x_current_display
, XC_sb_h_double_arrow
);
2614 s
->display
.x
->h_scrollbar
=
2615 XCreateSimpleWindow (x_current_display
, s
->display
.x
->window_desc
,
2617 width
- ibw
- 2, HSCROLL_HEIGHT
- 2, 1,
2618 s
->display
.x
->foreground_pixel
,
2619 s
->display
.x
->background_pixel
);
2620 XDefineCursor (x_current_display
, s
->display
.x
->h_scrollbar
,
2621 h_double_arrow_cursor
);
2623 s
->display
.x
->h_slider
=
2624 XCreateSimpleWindow (x_current_display
, s
->display
.x
->h_scrollbar
,
2626 HSCROLL_HEIGHT
- 4, HSCROLL_HEIGHT
- 4,
2627 1, s
->display
.x
->foreground_pixel
,
2628 s
->display
.x
->background_pixel
);
2629 XDefineCursor (x_current_display
, s
->display
.x
->h_slider
,
2630 h_double_arrow_cursor
);
2631 XSetWindowBackgroundPixmap (x_current_display
, s
->display
.x
->h_slider
,
2634 s
->display
.x
->h_thumbleft
=
2635 XCreateSimpleWindow (x_current_display
, s
->display
.x
->h_scrollbar
,
2637 HSCROLL_HEIGHT
- 2, HSCROLL_HEIGHT
- 2,
2638 0, s
->display
.x
->foreground_pixel
,
2639 s
->display
.x
->background_pixel
);
2640 XDefineCursor (x_current_display
, s
->display
.x
->h_thumbleft
,
2642 XSetWindowBackgroundPixmap (x_current_display
, s
->display
.x
->h_thumbleft
,
2645 s
->display
.x
->h_thumbright
=
2646 XCreateSimpleWindow (x_current_display
, s
->display
.x
->h_scrollbar
,
2647 width
- ibw
- HSCROLL_HEIGHT
, 0,
2648 HSCROLL_HEIGHT
- 2, HSCROLL_HEIGHT
-2,
2649 0, s
->display
.x
->foreground_pixel
,
2650 s
->display
.x
->background_pixel
);
2651 XDefineCursor (x_current_display
, s
->display
.x
->h_thumbright
,
2652 right_arrow_cursor
);
2653 XSetWindowBackgroundPixmap (x_current_display
, s
->display
.x
->h_thumbright
,
2654 right_arrow_pixmap
);
2656 XFreePixmap (x_current_display
, slider_pixmap
);
2657 XFreePixmap (x_current_display
, left_arrow_pixmap
);
2658 XFreePixmap (x_current_display
, right_arrow_pixmap
);
2660 XSelectInput (x_current_display
, s
->display
.x
->h_scrollbar
,
2661 ButtonPressMask
| ButtonReleaseMask
2662 | PointerMotionMask
| PointerMotionHintMask
2664 XSelectInput (x_current_display
, s
->display
.x
->h_slider
,
2665 ButtonPressMask
| ButtonReleaseMask
);
2666 XSelectInput (x_current_display
, s
->display
.x
->h_thumbright
,
2667 ButtonPressMask
| ButtonReleaseMask
);
2668 XSelectInput (x_current_display
, s
->display
.x
->h_thumbleft
,
2669 ButtonPressMask
| ButtonReleaseMask
);
2671 XMapWindow (x_current_display
, s
->display
.x
->h_scrollbar
);
2672 XMapSubwindows (x_current_display
, s
->display
.x
->h_scrollbar
);
2673 #else /* not HAVE_X11 */
2675 Pixmap fore_tile
, back_tile
, bord_tile
;
2679 #ifndef HAVE_X11 /* X10 */
2680 #define XMoveResizeWindow XConfigureWindow
2681 #endif /* not HAVE_X11 */
2683 /* Adjust the displayed position in the scroll bar for window W. */
2686 adjust_scrollbars (s
)
2690 int first_char_in_window
, char_beyond_window
, chars_in_window
;
2691 int chars_in_buffer
, buffer_size
;
2692 struct window
*w
= XWINDOW (SCREEN_SELECTED_WINDOW (s
));
2694 if (s
->output_method
!= output_x_window
)
2697 if (s
->display
.x
->v_scrollbar
!= 0)
2700 struct buffer
*b
= XBUFFER (w
->buffer
);
2702 buffer_size
= Z
- BEG
;
2703 chars_in_buffer
= ZV
- BEGV
;
2704 first_char_in_window
= marker_position (w
->start
);
2705 char_beyond_window
= buffer_size
+ 1 - XFASTINT (w
->window_end_pos
);
2706 chars_in_window
= char_beyond_window
- first_char_in_window
;
2708 /* Calculate height of scrollbar area */
2710 height
= s
->height
* FONT_HEIGHT (s
->display
.x
->font
)
2711 + s
->display
.x
->internal_border_width
2712 - 2 * (s
->display
.x
->v_scrollbar_width
);
2714 /* Figure starting position for the scrollbar slider */
2716 if (chars_in_buffer
<= 0)
2719 pos
= ((first_char_in_window
- BEGV
- BEG
) * height
2722 pos
= min (pos
, height
- 2);
2724 /* Figure length of the slider */
2726 if (chars_in_buffer
<= 0)
2729 h
= (chars_in_window
* height
) / chars_in_buffer
;
2730 h
= min (h
, height
- pos
);
2733 /* Add thumbup offset to starting position of slider */
2735 pos
+= (s
->display
.x
->v_scrollbar_width
- 2);
2737 XMoveResizeWindow (XDISPLAY
2738 s
->display
.x
->v_slider
,
2740 s
->display
.x
->v_scrollbar_width
- 4, h
);
2743 if (s
->display
.x
->h_scrollbar
!= 0)
2745 int l
, length
; /* Length of the scrollbar area */
2747 length
= s
->width
* FONT_WIDTH (s
->display
.x
->font
)
2748 + s
->display
.x
->internal_border_width
2749 - 2 * (s
->display
.x
->h_scrollbar_height
);
2751 /* Starting position for horizontal slider */
2755 pos
= (w
->hscroll
* length
) / (w
->hscroll
+ s
->width
);
2757 pos
= min (pos
, length
- 2);
2759 /* Length of slider */
2762 /* Add thumbup offset */
2763 pos
+= (s
->display
.x
->h_scrollbar_height
- 2);
2765 XMoveResizeWindow (XDISPLAY
2766 s
->display
.x
->h_slider
,
2768 l
, s
->display
.x
->h_scrollbar_height
- 4);
2772 /* Adjust the size of the scroll bars of screen S,
2773 when the screen size has changed. */
2776 x_resize_scrollbars (s
)
2779 int ibw
= s
->display
.x
->internal_border_width
;
2780 int pixelwidth
, pixelheight
;
2783 || s
->display
.x
== 0
2784 || (s
->display
.x
->v_scrollbar
== 0
2785 && s
->display
.x
->h_scrollbar
== 0))
2788 /* Get the size of the screen. */
2789 pixelwidth
= (s
->width
* FONT_WIDTH (s
->display
.x
->font
)
2790 + 2 * ibw
+ s
->display
.x
->v_scrollbar_width
);
2791 pixelheight
= (s
->height
* FONT_HEIGHT (s
->display
.x
->font
)
2792 + 2 * ibw
+ s
->display
.x
->h_scrollbar_height
);
2794 if (s
->display
.x
->v_scrollbar_width
&& s
->display
.x
->v_scrollbar
)
2797 XMoveResizeWindow (XDISPLAY
2798 s
->display
.x
->v_scrollbar
,
2799 pixelwidth
- s
->display
.x
->v_scrollbar_width
- ibw
/2,
2801 s
->display
.x
->v_scrollbar_width
- 2,
2802 pixelheight
- ibw
- 2);
2803 XMoveWindow (XDISPLAY
2804 s
->display
.x
->v_thumbdown
, 0,
2805 pixelheight
- ibw
- s
->display
.x
->v_scrollbar_width
);
2809 if (s
->display
.x
->h_scrollbar_height
&& s
->display
.x
->h_scrollbar
)
2811 if (s
->display
.x
->v_scrollbar_width
)
2812 pixelwidth
-= s
->display
.x
->v_scrollbar_width
+ 1;
2815 XMoveResizeWindow (XDISPLAY
2816 s
->display
.x
->h_scrollbar
,
2818 pixelheight
- s
->display
.x
->h_scrollbar_height
- ibw
/ 2,
2819 pixelwidth
- ibw
- 2,
2820 s
->display
.x
->h_scrollbar_height
- 2);
2821 XMoveWindow (XDISPLAY
2822 s
->display
.x
->h_thumbright
,
2823 pixelwidth
- ibw
- s
->display
.x
->h_scrollbar_height
, 0);
2829 register struct screen
*s
;
2831 return PIXEL_WIDTH (s
);
2835 register struct screen
*s
;
2837 return PIXEL_HEIGHT (s
);
2840 DEFUN ("x-defined-color", Fx_defined_color
, Sx_defined_color
, 1, 1, 0,
2841 "Return t if the current X display supports the color named COLOR.")
2847 CHECK_STRING (color
, 0);
2849 if (defined_color (XSTRING (color
)->data
, &foo
))
2855 DEFUN ("x-color-display-p", Fx_color_display_p
, Sx_color_display_p
, 0, 0, 0,
2856 "Return t if the X display used currently supports color.")
2859 if (XINT (x_screen_planes
) <= 2)
2862 switch (screen_visual
->class)
2875 DEFUN ("x-pixel-width", Fx_pixel_width
, Sx_pixel_width
, 1, 1, 0,
2876 "Return the width in pixels of screen S.")
2880 CHECK_SCREEN (screen
, 0);
2881 return make_number (XSCREEN (screen
)->display
.x
->pixel_width
);
2884 DEFUN ("x-pixel-height", Fx_pixel_height
, Sx_pixel_height
, 1, 1, 0,
2885 "Return the height in pixels of screen S.")
2889 CHECK_SCREEN (screen
, 0);
2890 return make_number (XSCREEN (screen
)->display
.x
->pixel_height
);
2893 /* Draw a rectangle on the screen with left top corner including
2894 the character specified by LEFT_CHAR and TOP_CHAR. The rectangle is
2895 CHARS by LINES wide and long and is the color of the cursor. */
2898 x_rectangle (s
, gc
, left_char
, top_char
, chars
, lines
)
2899 register struct screen
*s
;
2901 register int top_char
, left_char
, chars
, lines
;
2905 int left
= (left_char
* FONT_WIDTH (s
->display
.x
->font
)
2906 + s
->display
.x
->internal_border_width
);
2907 int top
= (top_char
* FONT_HEIGHT (s
->display
.x
->font
)
2908 + s
->display
.x
->internal_border_width
);
2911 width
= FONT_WIDTH (s
->display
.x
->font
) / 2;
2913 width
= FONT_WIDTH (s
->display
.x
->font
) * chars
;
2915 height
= FONT_HEIGHT (s
->display
.x
->font
) / 2;
2917 height
= FONT_HEIGHT (s
->display
.x
->font
) * lines
;
2919 XDrawRectangle (x_current_display
, s
->display
.x
->window_desc
,
2920 gc
, left
, top
, width
, height
);
2923 DEFUN ("x-draw-rectangle", Fx_draw_rectangle
, Sx_draw_rectangle
, 5, 5, 0,
2924 "Draw a rectangle on SCREEN between coordinates specified by\n\
2925 numbers X0, Y0, X1, Y1 in the cursor pixel.")
2926 (screen
, X0
, Y0
, X1
, Y1
)
2927 register Lisp_Object screen
, X0
, X1
, Y0
, Y1
;
2929 register int x0
, y0
, x1
, y1
, top
, left
, n_chars
, n_lines
;
2931 CHECK_SCREEN (screen
, 0);
2932 CHECK_NUMBER (X0
, 0);
2933 CHECK_NUMBER (Y0
, 1);
2934 CHECK_NUMBER (X1
, 2);
2935 CHECK_NUMBER (Y1
, 3);
2945 n_lines
= y1
- y0
+ 1;
2950 n_lines
= y0
- y1
+ 1;
2956 n_chars
= x1
- x0
+ 1;
2961 n_chars
= x0
- x1
+ 1;
2965 x_rectangle (XSCREEN (screen
), XSCREEN (screen
)->display
.x
->cursor_gc
,
2966 left
, top
, n_chars
, n_lines
);
2972 DEFUN ("x-erase-rectangle", Fx_erase_rectangle
, Sx_erase_rectangle
, 5, 5, 0,
2973 "Draw a rectangle drawn on SCREEN between coordinates\n\
2974 X0, Y0, X1, Y1 in the regular background-pixel.")
2975 (screen
, X0
, Y0
, X1
, Y1
)
2976 register Lisp_Object screen
, X0
, Y0
, X1
, Y1
;
2978 register int x0
, y0
, x1
, y1
, top
, left
, n_chars
, n_lines
;
2980 CHECK_SCREEN (screen
, 0);
2981 CHECK_NUMBER (X0
, 0);
2982 CHECK_NUMBER (Y0
, 1);
2983 CHECK_NUMBER (X1
, 2);
2984 CHECK_NUMBER (Y1
, 3);
2994 n_lines
= y1
- y0
+ 1;
2999 n_lines
= y0
- y1
+ 1;
3005 n_chars
= x1
- x0
+ 1;
3010 n_chars
= x0
- x1
+ 1;
3014 x_rectangle (XSCREEN (screen
), XSCREEN (screen
)->display
.x
->reverse_gc
,
3015 left
, top
, n_chars
, n_lines
);
3021 /* Draw lines around the text region beginning at the character position
3022 TOP_X, TOP_Y and ending at BOTTOM_X and BOTTOM_Y. GC specifies the
3023 pixel and line characteristics. */
3025 #define line_len(line) (SCREEN_CURRENT_GLYPHS (s)->used[(line)])
3028 outline_region (s
, gc
, top_x
, top_y
, bottom_x
, bottom_y
)
3029 register struct screen
*s
;
3031 int top_x
, top_y
, bottom_x
, bottom_y
;
3033 register int ibw
= s
->display
.x
->internal_border_width
;
3034 register int font_w
= FONT_WIDTH (s
->display
.x
->font
);
3035 register int font_h
= FONT_HEIGHT (s
->display
.x
->font
);
3037 int x
= line_len (y
);
3038 XPoint
*pixel_points
= (XPoint
*)
3039 alloca (((bottom_y
- top_y
+ 2) * 4) * sizeof (XPoint
));
3040 register XPoint
*this_point
= pixel_points
;
3042 /* Do the horizontal top line/lines */
3045 this_point
->x
= ibw
;
3046 this_point
->y
= ibw
+ (font_h
* top_y
);
3049 this_point
->x
= ibw
+ (font_w
/ 2); /* Half-size for newline chars. */
3051 this_point
->x
= ibw
+ (font_w
* x
);
3052 this_point
->y
= (this_point
- 1)->y
;
3056 this_point
->x
= ibw
;
3057 this_point
->y
= ibw
+ (font_h
* (top_y
+ 1));
3059 this_point
->x
= ibw
+ (font_w
* top_x
);
3060 this_point
->y
= (this_point
- 1)->y
;
3062 this_point
->x
= (this_point
- 1)->x
;
3063 this_point
->y
= ibw
+ (font_h
* top_y
);
3065 this_point
->x
= ibw
+ (font_w
* x
);
3066 this_point
->y
= (this_point
- 1)->y
;
3069 /* Now do the right side. */
3070 while (y
< bottom_y
)
3071 { /* Right vertical edge */
3073 this_point
->x
= (this_point
- 1)->x
;
3074 this_point
->y
= ibw
+ (font_h
* (y
+ 1));
3077 y
++; /* Horizontal connection to next line */
3080 this_point
->x
= ibw
+ (font_w
/ 2);
3082 this_point
->x
= ibw
+ (font_w
* x
);
3084 this_point
->y
= (this_point
- 1)->y
;
3087 /* Now do the bottom and connect to the top left point. */
3088 this_point
->x
= ibw
+ (font_w
* (bottom_x
+ 1));
3091 this_point
->x
= (this_point
- 1)->x
;
3092 this_point
->y
= ibw
+ (font_h
* (bottom_y
+ 1));
3094 this_point
->x
= ibw
;
3095 this_point
->y
= (this_point
- 1)->y
;
3097 this_point
->x
= pixel_points
->x
;
3098 this_point
->y
= pixel_points
->y
;
3100 XDrawLines (x_current_display
, s
->display
.x
->window_desc
,
3102 (this_point
- pixel_points
+ 1), CoordModeOrigin
);
3105 DEFUN ("x-contour-region", Fx_contour_region
, Sx_contour_region
, 1, 1, 0,
3106 "Highlight the region between point and the character under the mouse\n\
3109 register Lisp_Object event
;
3111 register int x0
, y0
, x1
, y1
;
3112 register struct screen
*s
= selected_screen
;
3113 register int p1
, p2
;
3115 CHECK_CONS (event
, 0);
3118 x0
= XINT (Fcar (Fcar (event
)));
3119 y0
= XINT (Fcar (Fcdr (Fcar (event
))));
3121 /* If the mouse is past the end of the line, don't that area. */
3122 /* ReWrite this... */
3127 if (y1
> y0
) /* point below mouse */
3128 outline_region (s
, s
->display
.x
->cursor_gc
,
3130 else if (y1
< y0
) /* point above mouse */
3131 outline_region (s
, s
->display
.x
->cursor_gc
,
3133 else /* same line: draw horizontal rectangle */
3136 x_rectangle (s
, s
->display
.x
->cursor_gc
,
3137 x0
, y0
, (x1
- x0
+ 1), 1);
3139 x_rectangle (s
, s
->display
.x
->cursor_gc
,
3140 x1
, y1
, (x0
- x1
+ 1), 1);
3143 XFlush (x_current_display
);
3149 DEFUN ("x-uncontour-region", Fx_uncontour_region
, Sx_uncontour_region
, 1, 1, 0,
3150 "Erase any highlighting of the region between point and the character\n\
3151 at X, Y on the selected screen.")
3153 register Lisp_Object event
;
3155 register int x0
, y0
, x1
, y1
;
3156 register struct screen
*s
= selected_screen
;
3159 x0
= XINT (Fcar (Fcar (event
)));
3160 y0
= XINT (Fcar (Fcdr (Fcar (event
))));
3164 if (y1
> y0
) /* point below mouse */
3165 outline_region (s
, s
->display
.x
->reverse_gc
,
3167 else if (y1
< y0
) /* point above mouse */
3168 outline_region (s
, s
->display
.x
->reverse_gc
,
3170 else /* same line: draw horizontal rectangle */
3173 x_rectangle (s
, s
->display
.x
->reverse_gc
,
3174 x0
, y0
, (x1
- x0
+ 1), 1);
3176 x_rectangle (s
, s
->display
.x
->reverse_gc
,
3177 x1
, y1
, (x0
- x1
+ 1), 1);
3184 extern unsigned int x_mouse_x
, x_mouse_y
, x_mouse_grabbed
;
3185 extern Lisp_Object unread_command_char
;
3188 int contour_begin_x
, contour_begin_y
;
3189 int contour_end_x
, contour_end_y
;
3190 int contour_npoints
;
3192 /* Clip the top part of the contour lines down (and including) line Y_POS.
3193 If X_POS is in the middle (rather than at the end) of the line, drop
3194 down a line at that character. */
3197 clip_contour_top (y_pos
, x_pos
)
3199 register XPoint
*begin
= contour_lines
[y_pos
].top_left
;
3200 register XPoint
*end
;
3201 register int npoints
;
3202 register struct display_line
*line
= selected_screen
->phys_lines
[y_pos
+ 1];
3204 if (x_pos
>= line
->len
- 1) /* Draw one, straight horizontal line. */
3206 end
= contour_lines
[y_pos
].top_right
;
3207 npoints
= (end
- begin
+ 1);
3208 XDrawLines (x_current_display
, contour_window
,
3209 contour_erase_gc
, begin_erase
, npoints
, CoordModeOrigin
);
3211 bcopy (end
, begin
+ 1, contour_last_point
- end
+ 1);
3212 contour_last_point
-= (npoints
- 2);
3213 XDrawLines (x_current_display
, contour_window
,
3214 contour_erase_gc
, begin
, 2, CoordModeOrigin
);
3215 XFlush (x_current_display
);
3217 /* Now, update contour_lines structure. */
3222 register XPoint
*p
= begin
+ 1;
3223 end
= contour_lines
[y_pos
].bottom_right
;
3224 npoints
= (end
- begin
+ 1);
3225 XDrawLines (x_current_display
, contour_window
,
3226 contour_erase_gc
, begin_erase
, npoints
, CoordModeOrigin
);
3229 p
->x
= ibw
+ (font_w
* (x_pos
+ 1));
3231 p
->y
= begin
->y
+ font_h
;
3233 bcopy (end
, begin
+ 3, contour_last_point
- end
+ 1);
3234 contour_last_point
-= (npoints
- 5);
3235 XDrawLines (x_current_display
, contour_window
,
3236 contour_erase_gc
, begin
, 4, CoordModeOrigin
);
3237 XFlush (x_current_display
);
3239 /* Now, update contour_lines structure. */
3243 /* Erase the top horzontal lines of the contour, and then extend
3244 the contour upwards. */
3247 extend_contour_top (line
)
3252 clip_contour_bottom (x_pos
, y_pos
)
3258 extend_contour_bottom (x_pos
, y_pos
)
3262 DEFUN ("x-select-region", Fx_select_region
, Sx_select_region
, 1, 1, "e",
3267 register struct screen
*s
= selected_screen
;
3268 register int point_x
= s
->cursor_x
;
3269 register int point_y
= s
->cursor_y
;
3270 register int mouse_below_point
;
3271 register Lisp_Object obj
;
3272 register int x_contour_x
, x_contour_y
;
3274 x_contour_x
= x_mouse_x
;
3275 x_contour_y
= x_mouse_y
;
3276 if (x_contour_y
> point_y
|| (x_contour_y
== point_y
3277 && x_contour_x
> point_x
))
3279 mouse_below_point
= 1;
3280 outline_region (s
, s
->display
.x
->cursor_gc
, point_x
, point_y
,
3281 x_contour_x
, x_contour_y
);
3285 mouse_below_point
= 0;
3286 outline_region (s
, s
->display
.x
->cursor_gc
, x_contour_x
, x_contour_y
,
3292 obj
= read_char (-1);
3293 if (XTYPE (obj
) != Lisp_Cons
)
3296 if (mouse_below_point
)
3298 if (x_mouse_y
<= point_y
) /* Flipped. */
3300 mouse_below_point
= 0;
3302 outline_region (s
, s
->display
.x
->reverse_gc
, point_x
, point_y
,
3303 x_contour_x
, x_contour_y
);
3304 outline_region (s
, s
->display
.x
->cursor_gc
, x_mouse_x
, x_mouse_y
,
3307 else if (x_mouse_y
< x_contour_y
) /* Bottom clipped. */
3309 clip_contour_bottom (x_mouse_y
);
3311 else if (x_mouse_y
> x_contour_y
) /* Bottom extended. */
3313 extend_bottom_contour (x_mouse_y
);
3316 x_contour_x
= x_mouse_x
;
3317 x_contour_y
= x_mouse_y
;
3319 else /* mouse above or same line as point */
3321 if (x_mouse_y
>= point_y
) /* Flipped. */
3323 mouse_below_point
= 1;
3325 outline_region (s
, s
->display
.x
->reverse_gc
,
3326 x_contour_x
, x_contour_y
, point_x
, point_y
);
3327 outline_region (s
, s
->display
.x
->cursor_gc
, point_x
, point_y
,
3328 x_mouse_x
, x_mouse_y
);
3330 else if (x_mouse_y
> x_contour_y
) /* Top clipped. */
3332 clip_contour_top (x_mouse_y
);
3334 else if (x_mouse_y
< x_contour_y
) /* Top extended. */
3336 extend_contour_top (x_mouse_y
);
3341 unread_command_char
= obj
;
3342 if (mouse_below_point
)
3344 contour_begin_x
= point_x
;
3345 contour_begin_y
= point_y
;
3346 contour_end_x
= x_contour_x
;
3347 contour_end_y
= x_contour_y
;
3351 contour_begin_x
= x_contour_x
;
3352 contour_begin_y
= x_contour_y
;
3353 contour_end_x
= point_x
;
3354 contour_end_y
= point_y
;
3359 DEFUN ("x-horizontal-line", Fx_horizontal_line
, Sx_horizontal_line
, 1, 1, "e",
3364 register Lisp_Object obj
;
3365 struct screen
*s
= selected_screen
;
3366 register struct window
*w
= XWINDOW (selected_window
);
3367 register GC line_gc
= s
->display
.x
->cursor_gc
;
3368 register GC erase_gc
= s
->display
.x
->reverse_gc
;
3370 char dash_list
[] = {6, 4, 6, 4};
3372 XGCValues gc_values
;
3374 register int previous_y
;
3375 register int line
= (x_mouse_y
+ 1) * FONT_HEIGHT (s
->display
.x
->font
)
3376 + s
->display
.x
->internal_border_width
;
3377 register int left
= s
->display
.x
->internal_border_width
3379 * FONT_WIDTH (s
->display
.x
->font
));
3380 register int right
= left
+ (w
->width
3381 * FONT_WIDTH (s
->display
.x
->font
))
3382 - s
->display
.x
->internal_border_width
;
3386 gc_values
.foreground
= s
->display
.x
->cursor_pixel
;
3387 gc_values
.background
= s
->display
.x
->background_pixel
;
3388 gc_values
.line_width
= 1;
3389 gc_values
.line_style
= LineOnOffDash
;
3390 gc_values
.cap_style
= CapRound
;
3391 gc_values
.join_style
= JoinRound
;
3393 line_gc
= XCreateGC (x_current_display
, s
->display
.x
->window_desc
,
3394 GCLineStyle
| GCJoinStyle
| GCCapStyle
3395 | GCLineWidth
| GCForeground
| GCBackground
,
3397 XSetDashes (x_current_display
, line_gc
, 0, dash_list
, dashes
);
3398 gc_values
.foreground
= s
->display
.x
->background_pixel
;
3399 gc_values
.background
= s
->display
.x
->foreground_pixel
;
3400 erase_gc
= XCreateGC (x_current_display
, s
->display
.x
->window_desc
,
3401 GCLineStyle
| GCJoinStyle
| GCCapStyle
3402 | GCLineWidth
| GCForeground
| GCBackground
,
3404 XSetDashes (x_current_display
, erase_gc
, 0, dash_list
, dashes
);
3410 if (x_mouse_y
>= XINT (w
->top
)
3411 && x_mouse_y
< XINT (w
->top
) + XINT (w
->height
) - 1)
3413 previous_y
= x_mouse_y
;
3414 line
= (x_mouse_y
+ 1) * FONT_HEIGHT (s
->display
.x
->font
)
3415 + s
->display
.x
->internal_border_width
;
3416 XDrawLine (x_current_display
, s
->display
.x
->window_desc
,
3417 line_gc
, left
, line
, right
, line
);
3424 obj
= read_char (-1);
3425 if ((XTYPE (obj
) != Lisp_Cons
)
3426 || (! EQ (Fcar (Fcdr (Fcdr (obj
))),
3427 intern ("vertical-scroll-bar")))
3431 XDrawLine (x_current_display
, s
->display
.x
->window_desc
,
3432 erase_gc
, left
, line
, right
, line
);
3434 unread_command_char
= obj
;
3436 XFreeGC (x_current_display
, line_gc
);
3437 XFreeGC (x_current_display
, erase_gc
);
3442 while (x_mouse_y
== previous_y
);
3445 XDrawLine (x_current_display
, s
->display
.x
->window_desc
,
3446 erase_gc
, left
, line
, right
, line
);
3451 /* Offset in buffer of character under the pointer, or 0. */
3452 int mouse_buffer_offset
;
3455 /* These keep track of the rectangle following the pointer. */
3456 int mouse_track_top
, mouse_track_left
, mouse_track_width
;
3458 DEFUN ("x-track-pointer", Fx_track_pointer
, Sx_track_pointer
, 0, 0, 0,
3459 "Track the pointer.")
3462 static Cursor current_pointer_shape
;
3463 SCREEN_PTR s
= x_mouse_screen
;
3466 if (EQ (Vmouse_screen_part
, Qtext_part
)
3467 && (current_pointer_shape
!= s
->display
.x
->nontext_cursor
))
3472 current_pointer_shape
= s
->display
.x
->nontext_cursor
;
3473 XDefineCursor (x_current_display
,
3474 s
->display
.x
->window_desc
,
3475 current_pointer_shape
);
3477 buf
= XBUFFER (XWINDOW (Vmouse_window
)->buffer
);
3478 c
= *(BUF_CHAR_ADDRESS (buf
, mouse_buffer_offset
));
3480 else if (EQ (Vmouse_screen_part
, Qmodeline_part
)
3481 && (current_pointer_shape
!= s
->display
.x
->modeline_cursor
))
3483 current_pointer_shape
= s
->display
.x
->modeline_cursor
;
3484 XDefineCursor (x_current_display
,
3485 s
->display
.x
->window_desc
,
3486 current_pointer_shape
);
3495 DEFUN ("x-track-pointer", Fx_track_pointer
, Sx_track_pointer
, 1, 1, "e",
3496 "Draw rectangle around character under mouse pointer, if there is one.")
3500 struct window
*w
= XWINDOW (Vmouse_window
);
3501 struct screen
*s
= XSCREEN (WINDOW_SCREEN (w
));
3502 struct buffer
*b
= XBUFFER (w
->buffer
);
3505 if (! EQ (Vmouse_window
, selected_window
))
3508 if (EQ (event
, Qnil
))
3512 x_read_mouse_position (selected_screen
, &x
, &y
);
3516 mouse_track_width
= 0;
3517 mouse_track_left
= mouse_track_top
= -1;
3521 if ((x_mouse_x
!= mouse_track_left
3522 && (x_mouse_x
< mouse_track_left
3523 || x_mouse_x
> (mouse_track_left
+ mouse_track_width
)))
3524 || x_mouse_y
!= mouse_track_top
)
3526 int hp
= 0; /* Horizontal position */
3527 int len
= SCREEN_CURRENT_GLYPHS (s
)->used
[x_mouse_y
];
3528 int p
= SCREEN_CURRENT_GLYPHS (s
)->bufp
[x_mouse_y
];
3529 int tab_width
= XINT (b
->tab_width
);
3530 int ctl_arrow_p
= !NULL (b
->ctl_arrow
);
3532 int mode_line_vpos
= XFASTINT (w
->height
) + XFASTINT (w
->top
) - 1;
3533 int in_mode_line
= 0;
3535 if (! SCREEN_CURRENT_GLYPHS (s
)->enable
[x_mouse_y
])
3538 /* Erase previous rectangle. */
3539 if (mouse_track_width
)
3541 x_rectangle (s
, s
->display
.x
->reverse_gc
,
3542 mouse_track_left
, mouse_track_top
,
3543 mouse_track_width
, 1);
3545 if ((mouse_track_left
== s
->phys_cursor_x
3546 || mouse_track_left
== s
->phys_cursor_x
- 1)
3547 && mouse_track_top
== s
->phys_cursor_y
)
3549 x_display_cursor (s
, 1);
3553 mouse_track_left
= x_mouse_x
;
3554 mouse_track_top
= x_mouse_y
;
3555 mouse_track_width
= 0;
3557 if (mouse_track_left
> len
) /* Past the end of line. */
3560 if (mouse_track_top
== mode_line_vpos
)
3566 if (tab_width
<= 0 || tab_width
> 20) tab_width
= 8;
3570 if (len
== s
->width
&& hp
== len
- 1 && c
!= '\n')
3576 mouse_track_width
= tab_width
- (hp
% tab_width
);
3578 hp
+= mouse_track_width
;
3581 mouse_track_left
= hp
- mouse_track_width
;
3587 mouse_track_width
= -1;
3591 if (ctl_arrow_p
&& (c
< 040 || c
== 0177))
3596 mouse_track_width
= 2;
3601 mouse_track_left
= hp
- mouse_track_width
;
3607 mouse_track_width
= 1;
3614 while (hp
<= x_mouse_x
);
3617 if (mouse_track_width
) /* Over text; use text pointer shape. */
3619 XDefineCursor (x_current_display
,
3620 s
->display
.x
->window_desc
,
3621 s
->display
.x
->text_cursor
);
3622 x_rectangle (s
, s
->display
.x
->cursor_gc
,
3623 mouse_track_left
, mouse_track_top
,
3624 mouse_track_width
, 1);
3626 else if (in_mode_line
)
3627 XDefineCursor (x_current_display
,
3628 s
->display
.x
->window_desc
,
3629 s
->display
.x
->modeline_cursor
);
3631 XDefineCursor (x_current_display
,
3632 s
->display
.x
->window_desc
,
3633 s
->display
.x
->nontext_cursor
);
3636 XFlush (x_current_display
);
3639 obj
= read_char (-1);
3642 while (XTYPE (obj
) == Lisp_Cons
/* Mouse event */
3643 && EQ (Fcar (Fcdr (Fcdr (obj
))), Qnil
) /* Not scrollbar */
3644 && EQ (Vmouse_depressed
, Qnil
) /* Only motion events */
3645 && EQ (Vmouse_window
, selected_window
) /* In this window */
3648 unread_command_char
= obj
;
3650 if (mouse_track_width
)
3652 x_rectangle (s
, s
->display
.x
->reverse_gc
,
3653 mouse_track_left
, mouse_track_top
,
3654 mouse_track_width
, 1);
3655 mouse_track_width
= 0;
3656 if ((mouse_track_left
== s
->phys_cursor_x
3657 || mouse_track_left
- 1 == s
->phys_cursor_x
)
3658 && mouse_track_top
== s
->phys_cursor_y
)
3660 x_display_cursor (s
, 1);
3663 XDefineCursor (x_current_display
,
3664 s
->display
.x
->window_desc
,
3665 s
->display
.x
->nontext_cursor
);
3666 XFlush (x_current_display
);
3676 /* Draw a pixmap specified by IMAGE_DATA of dimensions WIDTH and HEIGHT
3677 on the screen S at position X, Y. */
3679 x_draw_pixmap (s
, x
, y
, image_data
, width
, height
)
3681 int x
, y
, width
, height
;
3686 image
= XCreateBitmapFromData (x_current_display
,
3687 s
->display
.x
->window_desc
, image_data
,
3689 XCopyPlane (x_current_display
, image
, s
->display
.x
->window_desc
,
3690 s
->display
.x
->normal_gc
, 0, 0, width
, height
, x
, y
);
3694 x_read_mouse_position (s
, x
, y
)
3700 int ibw
= s
->display
.x
->internal_border_width
;
3705 unsigned int keys_and_buttons
;
3708 if (XQueryPointer (x_current_display
, s
->display
.x
->window_desc
,
3709 &root_window
, &w
, &root_x
, &root_y
, &ix
, &iy
,
3710 &keys_and_buttons
) == False
)
3713 error ("Pointer not on same screen as window.");
3718 XQueryMouse (s
->display
.x
->window_desc
, &ix
, &iy
, &w
);
3720 #endif /* not HAVE_X11 */
3722 x_mouse_x
= *x
= (ix
- ibw
) / FONT_WIDTH (s
->display
.x
->font
);
3723 x_mouse_y
= *y
= (iy
- ibw
) / FONT_HEIGHT (s
->display
.x
->font
);
3729 #define XMouseEvent XEvent
3730 #define WhichMouseButton xbutton.button
3731 #define MouseWindow xbutton.window
3732 #define MouseX xbutton.x
3733 #define MouseY xbutton.y
3734 #define MouseTime xbutton.time
3735 #define ButtonReleased ButtonRelease
3736 #define ButtonPressed ButtonPress
3738 #define XMouseEvent XButtonEvent
3739 #define WhichMouseButton detail
3740 #define MouseWindow window
3743 #define MouseTime time
3746 DEFUN ("x-mouse-events", Fx_mouse_events
, Sx_mouse_events
, 0, 0, 0,
3747 "Return number of pending mouse events from X window system.")
3750 return make_number (queue_event_count (&x_mouse_queue
));
3753 /* Encode the mouse button events in the form expected by the
3754 mouse code in Lisp. For X11, this means moving the masks around. */
3757 encode_mouse_button (mouse_event
)
3758 XMouseEvent mouse_event
;
3760 register int event_code
;
3761 register char key_mask
;
3763 event_code
= mouse_event
.detail
& 3;
3764 key_mask
= (mouse_event
.detail
>> 8) & 0xf0;
3765 event_code
|= key_mask
>> 1;
3766 if (mouse_event
.type
== ButtonReleased
) event_code
|= 0x04;
3770 DEFUN ("x-get-mouse-event", Fx_get_mouse_event
, Sx_get_mouse_event
,
3772 "Get next mouse event out of mouse event buffer.\n\
3773 Optional ARG non-nil means return nil immediately if no pending event;\n\
3774 otherwise, wait for an event. Returns a four-part list:\n\
3775 ((X-POS Y-POS) WINDOW SCREEN-PART KEYSEQ TIMESTAMP).\n\
3776 Normally X-POS and Y-POS are the position of the click on the screen\n\
3777 (measured in characters and lines), and WINDOW is the window clicked in.\n\
3778 KEYSEQ is a string, the key sequence to be looked up in the mouse maps.\n\
3779 If SCREEN-PART is non-nil, the event was on a scrollbar;\n\
3780 then Y-POS is really the total length of the scrollbar, while X-POS is\n\
3781 the relative position of the scrollbar's value within that total length,\n\
3782 and a third element OFFSET appears in that list: the height of the thumb-up\n\
3783 area at the top of the scroll bar.\n\
3784 SCREEN-PART is one of the following symbols:\n\
3785 `vertical-scrollbar', `vertical-thumbup', `vertical-thumbdown',\n\
3786 `horizontal-scrollbar', `horizontal-thumbleft', `horizontal-thumbright'.\n\
3787 TIMESTAMP is the lower 23 bits of the X-server's timestamp for\n\
3793 register int com_letter
;
3794 register Lisp_Object tempx
;
3795 register Lisp_Object tempy
;
3796 Lisp_Object part
, pos
, timestamp
;
3805 tem
= dequeue_event (&xrep
, &x_mouse_queue
);
3813 case ButtonReleased
:
3815 com_letter
= encode_mouse_button (xrep
);
3816 mouse_timestamp
= xrep
.MouseTime
;
3818 if ((s
= x_window_to_screen (xrep
.MouseWindow
)) != 0)
3822 if (s
->display
.x
->icon_desc
== xrep
.MouseWindow
)
3824 x_make_screen_visible (s
);
3828 XSET (tempx
, Lisp_Int
,
3829 min (s
->width
-1, max (0, (xrep
.MouseX
- s
->display
.x
->internal_border_width
)/FONT_WIDTH (s
->display
.x
->font
))));
3830 XSET (tempy
, Lisp_Int
,
3831 min (s
->height
-1, max (0, (xrep
.MouseY
- s
->display
.x
->internal_border_width
)/FONT_HEIGHT (s
->display
.x
->font
))));
3832 XSET (timestamp
, Lisp_Int
, (xrep
.MouseTime
& 0x7fffff));
3833 XSET (screen
, Lisp_Screen
, s
);
3835 pos
= Fcons (tempx
, Fcons (tempy
, Qnil
));
3837 = Flocate_window_from_coordinates (screen
, pos
);
3841 Fcons (Vmouse_window
,
3843 Fcons (Fchar_to_string (make_number (com_letter
)),
3844 Fcons (timestamp
, Qnil
)))));
3845 return Vmouse_event
;
3847 else if ((s
= x_window_to_scrollbar (xrep
.MouseWindow
, &part
, &prefix
)) != 0)
3853 keyseq
= concat2 (Fchar_to_string (make_number (prefix
)),
3854 Fchar_to_string (make_number (com_letter
)));
3856 pos
= xrep
.MouseY
- (s
->display
.x
->v_scrollbar_width
- 2);
3857 XSET (tempx
, Lisp_Int
, pos
);
3858 len
= ((FONT_HEIGHT (s
->display
.x
->font
) * s
->height
)
3859 + s
->display
.x
->internal_border_width
3860 - (2 * (s
->display
.x
->v_scrollbar_width
- 2)));
3861 XSET (tempy
, Lisp_Int
, len
);
3862 XSET (timestamp
, Lisp_Int
, (xrep
.MouseTime
& 0x7fffff));
3863 Vmouse_window
= s
->selected_window
;
3865 = Fcons (Fcons (tempx
, Fcons (tempy
,
3866 Fcons (make_number (s
->display
.x
->v_scrollbar_width
- 2),
3868 Fcons (Vmouse_window
,
3869 Fcons (intern (part
),
3870 Fcons (keyseq
, Fcons (timestamp
,
3872 return Vmouse_event
;
3880 com_letter
= x11_encode_mouse_button (xrep
);
3881 if ((s
= x_window_to_screen (xrep
.MouseWindow
)) != 0)
3885 XSET (tempx
, Lisp_Int
,
3887 max (0, (xrep
.MouseX
- s
->display
.x
->internal_border_width
)
3888 / FONT_WIDTH (s
->display
.x
->font
))));
3889 XSET (tempy
, Lisp_Int
,
3891 max (0, (xrep
.MouseY
- s
->display
.x
->internal_border_width
)
3892 / FONT_HEIGHT (s
->display
.x
->font
))));
3894 XSET (screen
, Lisp_Screen
, s
);
3895 XSET (timestamp
, Lisp_Int
, (xrep
.MouseTime
& 0x7fffff));
3897 pos
= Fcons (tempx
, Fcons (tempy
, Qnil
));
3899 = Flocate_window_from_coordinates (screen
, pos
);
3903 Fcons (Vmouse_window
,
3905 Fcons (Fchar_to_string (make_number (com_letter
)),
3906 Fcons (timestamp
, Qnil
)))));
3907 return Vmouse_event
;
3911 #endif /* HAVE_X11 */
3914 if (s
= x_window_to_screen (xrep
.MouseWindow
))
3915 Vmouse_window
= s
->selected_window
;
3916 else if (s
= x_window_to_scrollbar (xrep
.MouseWindow
, &part
, &prefix
))
3917 Vmouse_window
= s
->selected_window
;
3918 return Vmouse_event
= Qnil
;
3925 /* Wait till we get another mouse event. */
3926 wait_reading_process_input (0, 0, 2, 0);
3933 DEFUN ("x-store-cut-buffer", Fx_store_cut_buffer
, Sx_store_cut_buffer
,
3934 1, 1, "sStore text in cut buffer: ",
3935 "Store contents of STRING into the cut buffer of the X window system.")
3937 register Lisp_Object string
;
3941 CHECK_STRING (string
, 1);
3942 if (selected_screen
->output_method
!= output_x_window
)
3943 error ("Selected screen does not understand X protocol.");
3946 XStoreBytes ((char *) XSTRING (string
)->data
, XSTRING (string
)->size
);
3952 DEFUN ("x-get-cut-buffer", Fx_get_cut_buffer
, Sx_get_cut_buffer
, 0, 0, 0,
3953 "Return contents of cut buffer of the X window system, as a string.")
3957 register Lisp_Object string
;
3962 d
= XFetchBytes (&len
);
3963 string
= make_string (d
, len
);
3971 DEFUN ("x-rebind-key", Fx_rebind_key
, Sx_rebind_key
, 3, 3, 0,
3972 "Rebind X keysym KEYSYM, with MODIFIERS, to generate NEWSTRING.\n\
3973 KEYSYM is a string which conforms to the X keysym definitions found\n\
3974 in X11/keysymdef.h, sans the initial XK_. MODIFIERS is nil or a\n\
3975 list of strings specifying modifier keys such as Control_L, which must\n\
3976 also be depressed for NEWSTRING to appear.")
3977 (x_keysym
, modifiers
, newstring
)
3978 register Lisp_Object x_keysym
;
3979 register Lisp_Object modifiers
;
3980 register Lisp_Object newstring
;
3983 register KeySym keysym
, modifier_list
[16];
3985 CHECK_STRING (x_keysym
, 1);
3986 CHECK_STRING (newstring
, 3);
3988 keysym
= XStringToKeysym ((char *) XSTRING (x_keysym
)->data
);
3989 if (keysym
== NoSymbol
)
3990 error ("Keysym does not exist");
3992 if (NULL (modifiers
))
3993 XRebindKeysym (x_current_display
, keysym
, modifier_list
, 0,
3994 XSTRING (newstring
)->data
, XSTRING (newstring
)->size
);
3997 register Lisp_Object rest
, mod
;
4000 for (rest
= modifiers
; !NULL (rest
); rest
= Fcdr (rest
))
4003 error ("Can't have more than 16 modifiers");
4006 CHECK_STRING (mod
, 3);
4007 modifier_list
[i
] = XStringToKeysym ((char *) XSTRING (mod
)->data
);
4008 if (modifier_list
[i
] == NoSymbol
4009 || !IsModifierKey (modifier_list
[i
]))
4010 error ("Element is not a modifier keysym");
4014 XRebindKeysym (x_current_display
, keysym
, modifier_list
, i
,
4015 XSTRING (newstring
)->data
, XSTRING (newstring
)->size
);
4021 DEFUN ("x-rebind-keys", Fx_rebind_keys
, Sx_rebind_keys
, 2, 2, 0,
4022 "Rebind KEYCODE to list of strings STRINGS.\n\
4023 STRINGS should be a list of 16 elements, one for each shift combination.\n\
4024 nil as element means don't change.\n\
4025 See the documentation of `x-rebind-key' for more information.")
4027 register Lisp_Object keycode
;
4028 register Lisp_Object strings
;
4030 register Lisp_Object item
;
4031 register unsigned char *rawstring
;
4032 KeySym rawkey
, modifier
[1];
4034 register unsigned i
;
4036 CHECK_NUMBER (keycode
, 1);
4037 CHECK_CONS (strings
, 2);
4038 rawkey
= (KeySym
) ((unsigned) (XINT (keycode
))) & 255;
4039 for (i
= 0; i
<= 15; strings
= Fcdr (strings
), i
++)
4041 item
= Fcar (strings
);
4044 CHECK_STRING (item
, 2);
4045 strsize
= XSTRING (item
)->size
;
4046 rawstring
= (unsigned char *) xmalloc (strsize
);
4047 bcopy (XSTRING (item
)->data
, rawstring
, strsize
);
4048 modifier
[1] = 1 << i
;
4049 XRebindKeysym (x_current_display
, rawkey
, modifier
, 1,
4050 rawstring
, strsize
);
4056 DEFUN ("x-rebind-key", Fx_rebind_key
, Sx_rebind_key
, 3, 3, 0,
4057 "Rebind KEYCODE, with shift bits SHIFT-MASK, to new string NEWSTRING.\n\
4058 KEYCODE and SHIFT-MASK should be numbers representing the X keyboard code\n\
4059 and shift mask respectively. NEWSTRING is an arbitrary string of keystrokes.\n\
4060 If SHIFT-MASK is nil, then KEYCODE's key will be bound to NEWSTRING for\n\
4061 all shift combinations.\n\
4062 Shift Lock 1 Shift 2\n\
4065 For values of KEYCODE, see /usr/lib/Xkeymap.txt (remember that the codes\n\
4066 in that file are in octal!)\n\
4068 NOTE: due to an X bug, this function will not take effect unless one has\n\
4069 a `~/.Xkeymap' file. (See the documentation for the `keycomp' program.)\n\
4070 This problem will be fixed in X version 11.")
4072 (keycode
, shift_mask
, newstring
)
4073 register Lisp_Object keycode
;
4074 register Lisp_Object shift_mask
;
4075 register Lisp_Object newstring
;
4078 int keysym
, rawshift
;
4081 CHECK_NUMBER (keycode
, 1);
4082 if (!NULL (shift_mask
))
4083 CHECK_NUMBER (shift_mask
, 2);
4084 CHECK_STRING (newstring
, 3);
4085 strsize
= XSTRING (newstring
)->size
;
4086 rawstring
= (char *) xmalloc (strsize
);
4087 bcopy (XSTRING (newstring
)->data
, rawstring
, strsize
);
4089 keysym
= ((unsigned) (XINT (keycode
))) & 255;
4091 if (NULL (shift_mask
))
4093 for (i
= 0; i
<= 15; i
++)
4094 XRebindCode (keysym
, i
<<11, rawstring
, strsize
);
4098 rawshift
= (((unsigned) (XINT (shift_mask
))) & 15) << 11;
4099 XRebindCode (keysym
, rawshift
, rawstring
, strsize
);
4104 DEFUN ("x-rebind-keys", Fx_rebind_keys
, Sx_rebind_keys
, 2, 2, 0,
4105 "Rebind KEYCODE to list of strings STRINGS.\n\
4106 STRINGS should be a list of 16 elements, one for each shift combination.\n\
4107 nil as element means don't change.\n\
4108 See the documentation of `x-rebind-key' for more information.")
4110 register Lisp_Object keycode
;
4111 register Lisp_Object strings
;
4113 register Lisp_Object item
;
4114 register char *rawstring
;
4115 KeySym rawkey
, modifier
[1];
4117 register unsigned i
;
4119 CHECK_NUMBER (keycode
, 1);
4120 CHECK_CONS (strings
, 2);
4121 rawkey
= (KeySym
) ((unsigned) (XINT (keycode
))) & 255;
4122 for (i
= 0; i
<= 15; strings
= Fcdr (strings
), i
++)
4124 item
= Fcar (strings
);
4127 CHECK_STRING (item
, 2);
4128 strsize
= XSTRING (item
)->size
;
4129 rawstring
= (char *) xmalloc (strsize
);
4130 bcopy (XSTRING (item
)->data
, rawstring
, strsize
);
4131 XRebindCode (rawkey
, i
<< 11, rawstring
, strsize
);
4136 #endif /* not HAVE_X11 */
4140 select_visual (screen
, depth
)
4142 unsigned int *depth
;
4145 XVisualInfo
*vinfo
, vinfo_template
;
4148 v
= DefaultVisualOfScreen (screen
);
4149 vinfo_template
.visualid
= XVisualIDFromVisual (v
);
4150 vinfo
= XGetVisualInfo (x_current_display
, VisualIDMask
, &vinfo_template
,
4153 fatal ("Can't get proper X visual info");
4155 if ((1 << vinfo
->depth
) == vinfo
->colormap_size
)
4156 *depth
= vinfo
->depth
;
4160 int n
= vinfo
->colormap_size
- 1;
4169 XFree ((char *) vinfo
);
4172 #endif /* HAVE_X11 */
4174 DEFUN ("x-open-connection", Fx_open_connection
, Sx_open_connection
,
4175 1, 2, 0, "Open a connection to an X server.\n\
4176 DISPLAY is the name of the display to connect to. Optional second\n\
4177 arg XRM_STRING is a string of resources in xrdb format.")
4178 (display
, xrm_string
)
4179 Lisp_Object display
, xrm_string
;
4181 unsigned int n_planes
;
4182 register Screen
*x_screen
;
4183 unsigned char *xrm_option
;
4185 CHECK_STRING (display
, 0);
4186 if (x_current_display
!= 0)
4187 error ("X server connection is already initialized");
4189 /* This is what opens the connection and sets x_current_display.
4190 This also initializes many symbols, such as those used for input. */
4191 x_term_init (XSTRING (display
)->data
);
4193 Qtext_part
= intern ("text-part");
4194 Qmodeline_part
= intern ("modeline-part");
4195 Qvscrollbar_part
= intern ("vscrollbar-part");
4196 Qvslider_part
= intern ("vslider-part");
4197 Qvthumbup_part
= intern ("vthumbup-part");
4198 Qvthumbdown_part
= intern ("vthumbdown-part");
4199 Qhscrollbar_part
= intern ("hscrollbar-part");
4200 Qhslider_part
= intern ("hslider-part");
4201 Qhthumbleft_part
= intern ("hthumbleft-part");
4202 Qhthumbright_part
= intern ("hthumbright-part");
4205 XFASTINT (Vwindow_system_version
) = 11;
4207 if (!EQ (xrm_string
, Qnil
))
4209 CHECK_STRING (xrm_string
, 1);
4210 xrm_option
= (unsigned char *) XSTRING (xrm_string
);
4213 xrm_option
= (unsigned char *) 0;
4214 xrdb
= x_load_resources (x_current_display
, xrm_option
, EMACS_CLASS
);
4215 x_current_display
->db
= xrdb
;
4217 x_screen
= DefaultScreenOfDisplay (x_current_display
);
4219 x_screen_count
= make_number (ScreenCount (x_current_display
));
4220 Vx_vendor
= build_string (ServerVendor (x_current_display
));
4221 x_release
= make_number (VendorRelease (x_current_display
));
4223 x_screen_height
= make_number (HeightOfScreen (x_screen
));
4224 x_screen_height_mm
= make_number (HeightMMOfScreen (x_screen
));
4225 x_screen_width
= make_number (WidthOfScreen (x_screen
));
4226 x_screen_width_mm
= make_number (WidthMMOfScreen (x_screen
));
4228 switch (DoesBackingStore (x_screen
))
4231 Vx_backing_store
= intern ("Always");
4235 Vx_backing_store
= intern ("WhenMapped");
4239 Vx_backing_store
= intern ("NotUseful");
4243 error ("Strange value for BackingStore.");
4247 if (DoesSaveUnders (x_screen
) == True
)
4250 x_save_under
= Qnil
;
4252 screen_visual
= select_visual (x_screen
, &n_planes
);
4253 x_screen_planes
= make_number (n_planes
);
4254 Vx_screen_visual
= intern (x_visual_strings
[screen_visual
->class]);
4256 /* X Atoms used by emacs. */
4258 Xatom_emacs_selection
= XInternAtom (x_current_display
, "_EMACS_SELECTION_",
4260 Xatom_clipboard
= XInternAtom (x_current_display
, "CLIPBOARD",
4262 Xatom_clipboard_selection
= XInternAtom (x_current_display
, "_EMACS_CLIPBOARD_",
4264 Xatom_wm_change_state
= XInternAtom (x_current_display
, "WM_CHANGE_STATE",
4266 Xatom_incremental
= XInternAtom (x_current_display
, "INCR",
4268 Xatom_multiple
= XInternAtom (x_current_display
, "MULTIPLE",
4270 Xatom_targets
= XInternAtom (x_current_display
, "TARGETS",
4272 Xatom_timestamp
= XInternAtom (x_current_display
, "TIMESTAMP",
4274 Xatom_delete
= XInternAtom (x_current_display
, "DELETE",
4276 Xatom_insert_selection
= XInternAtom (x_current_display
, "INSERT_SELECTION",
4278 Xatom_pair
= XInternAtom (x_current_display
, "XA_ATOM_PAIR",
4280 Xatom_insert_property
= XInternAtom (x_current_display
, "INSERT_PROPERTY",
4282 Xatom_text
= XInternAtom (x_current_display
, "TEXT",
4285 #else /* not HAVE_X11 */
4286 XFASTINT (Vwindow_system_version
) = 10;
4287 #endif /* not HAVE_X11 */
4291 DEFUN ("x-close-current-connection", Fx_close_current_connection
,
4292 Sx_close_current_connection
,
4293 0, 0, 0, "Close the connection to the current X server.")
4297 /* This is ONLY used when killing emacs; For switching displays
4298 we'll have to take care of setting CloseDownMode elsewhere. */
4300 if (x_current_display
)
4303 XSetCloseDownMode (x_current_display
, DestroyAll
);
4304 XCloseDisplay (x_current_display
);
4307 fatal ("No current X display connection to close\n");
4312 DEFUN ("x-synchronize", Fx_synchronize
, Sx_synchronize
,
4313 1, 1, 0, "If ON is non-nil, report X errors as soon as the erring request is made.\n\
4314 If ON is nil, allow buffering of requests.\n\
4315 Turning on synchronization prohibits the Xlib routines from buffering\n\
4316 requests and seriously degrades performance, but makes debugging much\n\
4321 XSynchronize (x_current_display
, !EQ (on
, Qnil
));
4329 init_x_parm_symbols ();
4331 /* This is zero if not using X windows. */
4332 x_current_display
= 0;
4334 Qundefined_color
= intern ("undefined-color");
4335 Fput (Qundefined_color
, Qerror_conditions
,
4336 Fcons (Qundefined_color
, Fcons (Qerror
, Qnil
)));
4337 Fput (Qundefined_color
, Qerror_message
,
4338 build_string ("Undefined color"));
4340 screen_class
= make_pure_string (SCREEN_CLASS
, sizeof (SCREEN_CLASS
)-1);
4342 DEFVAR_INT ("mouse-x-position", &x_mouse_x
,
4343 "The X coordinate of the mouse position, in characters.");
4346 DEFVAR_INT ("mouse-y-position", &x_mouse_y
,
4347 "The Y coordinate of the mouse position, in characters.");
4350 DEFVAR_INT ("mouse-buffer-offset", &mouse_buffer_offset
,
4351 "The buffer offset of the character under the pointer.");
4352 mouse_buffer_offset
= Qnil
;
4354 DEFVAR_LISP ("mouse-screen-part", &Vmouse_screen_part
,
4355 "A symbol indicating the part of the screen the mouse is in.");
4356 Vmouse_screen_part
= Qnil
;
4358 DEFVAR_INT ("x-pointer-shape", &Vx_pointer_shape
,
4359 "The shape of the pointer when over text.");
4360 Vx_pointer_shape
= Qnil
;
4362 DEFVAR_INT ("x-nontext-pointer-shape", &Vx_nontext_pointer_shape
,
4363 "The shape of the pointer when not over text.");
4364 Vx_nontext_pointer_shape
= Qnil
;
4366 DEFVAR_INT ("x-mode-pointer-shape", &Vx_mode_pointer_shape
,
4367 "The shape of the pointer when not over text.");
4368 Vx_mode_pointer_shape
= Qnil
;
4370 DEFVAR_LISP ("x-bar-cursor", &Vbar_cursor
,
4371 "*If non-nil, use a vertical bar cursor. Otherwise, use the traditional box.");
4374 DEFVAR_LISP ("x-cursor-fore-pixel", &Vx_cursor_fore_pixel
,
4375 "A string indicating the foreground color of the cursor box.");
4376 Vx_cursor_fore_pixel
= Qnil
;
4378 DEFVAR_LISP ("mouse-grabbed", &Vmouse_depressed
,
4379 "Non-nil if a mouse button is currently depressed.");
4380 Vmouse_depressed
= Qnil
;
4382 DEFVAR_INT ("x-screen-count", &x_screen_count
,
4383 "The number of screens associated with the current display.");
4384 DEFVAR_INT ("x-release", &x_release
,
4385 "The release number of the X server in use.");
4386 DEFVAR_LISP ("x-vendor", &Vx_vendor
,
4387 "The vendor supporting the X server in use.");
4388 DEFVAR_INT ("x-screen-height", &x_screen_height
,
4389 "The height of this X screen in pixels.");
4390 DEFVAR_INT ("x-screen-height-mm", &x_screen_height_mm
,
4391 "The height of this X screen in millimeters.");
4392 DEFVAR_INT ("x-screen-width", &x_screen_width
,
4393 "The width of this X screen in pixels.");
4394 DEFVAR_INT ("x-screen-width-mm", &x_screen_width_mm
,
4395 "The width of this X screen in millimeters.");
4396 DEFVAR_LISP ("x-backing-store", &Vx_backing_store
,
4397 "The backing store capability of this screen.\n\
4398 Values can be the symbols Always, WhenMapped, or NotUseful.");
4399 DEFVAR_BOOL ("x-save-under", &x_save_under
,
4400 "*Non-nil means this X screen supports the SaveUnder feature.");
4401 DEFVAR_INT ("x-screen-planes", &x_screen_planes
,
4402 "The number of planes this monitor supports.");
4403 DEFVAR_LISP ("x-screen-visual", &Vx_screen_visual
,
4404 "The default X visual for this X screen.");
4405 DEFVAR_LISP ("x-no-window-manager", &Vx_no_window_manager
,
4406 "t if no X window manager is in use.");
4409 defsubr (&Sx_get_resource
);
4410 defsubr (&Sx_pixel_width
);
4411 defsubr (&Sx_pixel_height
);
4412 defsubr (&Sx_draw_rectangle
);
4413 defsubr (&Sx_erase_rectangle
);
4414 defsubr (&Sx_contour_region
);
4415 defsubr (&Sx_uncontour_region
);
4416 defsubr (&Sx_color_display_p
);
4417 defsubr (&Sx_defined_color
);
4419 defsubr (&Sx_track_pointer
);
4421 defsubr (&Sx_grab_pointer
);
4422 defsubr (&Sx_ungrab_pointer
);
4424 defsubr (&Sx_get_default
);
4425 defsubr (&Sx_store_cut_buffer
);
4426 defsubr (&Sx_get_cut_buffer
);
4427 defsubr (&Sx_set_face
);
4429 defsubr (&Sx_geometry
);
4430 defsubr (&Sx_create_screen
);
4431 defsubr (&Sfocus_screen
);
4432 defsubr (&Sunfocus_screen
);
4433 defsubr (&Sx_horizontal_line
);
4434 defsubr (&Sx_rebind_key
);
4435 defsubr (&Sx_rebind_keys
);
4436 defsubr (&Sx_open_connection
);
4437 defsubr (&Sx_close_current_connection
);
4438 defsubr (&Sx_synchronize
);
4440 /* This was used in the old event interface which used a separate
4443 defsubr (&Sx_mouse_events
);
4444 defsubr (&Sx_get_mouse_event
);
4448 #endif /* HAVE_X_WINDOWS */