1 /* Functions for the X window system.
2 Copyright (C) 1989, 1992 Free Software Foundation.
4 This file is part of GNU Emacs.
6 GNU Emacs is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Emacs is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Emacs; see the file COPYING. If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
20 /* Completely rewritten by Richard Stallman. */
22 /* Rewritten for X11 by Joseph Arceneaux */
34 #include "dispextern.h"
35 #include "xscrollbar.h"
41 void x_set_frame_param ();
43 #define min(a,b) ((a) < (b) ? (a) : (b))
44 #define max(a,b) ((a) > (b) ? (a) : (b))
47 /* X Resource data base */
48 static XrmDatabase xrdb
;
50 /* The class of this X application. */
51 #define EMACS_CLASS "Emacs"
53 /* Title name and application name for X stuff. */
54 extern char *x_id_name
;
55 extern Lisp_Object invocation_name
;
57 /* The background and shape of the mouse pointer, and shape when not
58 over text or in the modeline. */
59 Lisp_Object Vx_pointer_shape
, Vx_nontext_pointer_shape
, Vx_mode_pointer_shape
;
61 /* Color of chars displayed in cursor box. */
62 Lisp_Object Vx_cursor_fore_pixel
;
64 /* If non-nil, use vertical bar cursor. */
65 Lisp_Object Vbar_cursor
;
67 /* The X Visual we are using for X windows (the default) */
68 Visual
*screen_visual
;
70 /* How many screens this X display has. */
73 /* The vendor supporting this X server. */
74 Lisp_Object Vx_vendor
;
76 /* The vendor's release number for this X server. */
79 /* Height of this X screen in pixels. */
82 /* Height of this X screen in millimeters. */
83 int x_screen_height_mm
;
85 /* Width of this X screen in pixels. */
88 /* Width of this X screen in millimeters. */
89 int x_screen_width_mm
;
91 /* Does this X screen do backing store? */
92 Lisp_Object Vx_backing_store
;
94 /* Does this X screen do save-unders? */
97 /* Number of planes for this screen. */
100 /* X Visual type of this screen. */
101 Lisp_Object Vx_screen_visual
;
103 /* Non nil if no window manager is in use. */
104 Lisp_Object Vx_no_window_manager
;
106 static char *x_visual_strings
[] =
116 /* `t' if a mouse button is depressed. */
118 Lisp_Object Vmouse_depressed
;
120 extern unsigned int x_mouse_x
, x_mouse_y
, x_mouse_grabbed
;
121 extern Lisp_Object unread_command_char
;
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
;
168 /* Communication with window managers. */
169 extern Atom Xatom_wm_protocols
;
171 /* Kinds of protocol things we may receive. */
172 extern Atom Xatom_wm_take_focus
;
173 extern Atom Xatom_wm_save_yourself
;
174 extern Atom Xatom_wm_delete_window
;
176 /* Other WM communication */
177 extern Atom Xatom_wm_configure_denied
; /* When our config request is denied */
178 extern Atom Xatom_wm_window_moved
; /* When the WM moves us. */
182 /* Default size of an Emacs window without scroll bar. */
183 static char *default_window
= "=80x24+0+0";
186 char iconidentity
[MAXICID
];
187 #define ICONTAG "emacs@"
188 char minibuffer_iconidentity
[MAXICID
];
189 #define MINIBUFFER_ICONTAG "minibuffer@"
193 /* The last 23 bits of the timestamp of the last mouse button event. */
194 Time mouse_timestamp
;
196 Lisp_Object Qundefined_color
;
197 Lisp_Object Qx_frame_parameter
;
199 extern Lisp_Object Vwindow_system_version
;
201 /* Mouse map for clicks in windows. */
202 extern Lisp_Object Vglobal_mouse_map
;
204 /* Points to table of defined typefaces. */
205 struct face
*x_face_table
[MAX_FACES_AND_GLYPHS
];
207 /* Return the Emacs frame-object corresponding to an X window.
208 It could be the frame's main window or an icon window. */
211 x_window_to_frame (wdesc
)
214 Lisp_Object tail
, frame
;
217 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
219 frame
= XCONS (tail
)->car
;
220 if (XTYPE (frame
) != Lisp_Frame
)
223 if (f
->display
.x
->window_desc
== wdesc
224 || f
->display
.x
->icon_desc
== wdesc
)
230 /* Map an X window that implements a scroll bar to the Emacs frame it
231 belongs to. Also store in *PART a symbol identifying which part of
232 the scroll bar it is. */
235 x_window_to_scrollbar (wdesc
, part_ptr
, prefix_ptr
)
237 Lisp_Object
*part_ptr
;
238 enum scroll_bar_prefix
*prefix_ptr
;
240 Lisp_Object tail
, frame
;
243 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
245 frame
= XCONS (tail
)->car
;
246 if (XTYPE (frame
) != Lisp_Frame
)
250 if (part_ptr
== 0 && prefix_ptr
== 0)
253 if (f
->display
.x
->v_scrollbar
== wdesc
)
255 *part_ptr
= Qvscrollbar_part
;
256 *prefix_ptr
= VSCROLL_BAR_PREFIX
;
259 else if (f
->display
.x
->v_slider
== wdesc
)
261 *part_ptr
= Qvslider_part
;
262 *prefix_ptr
= VSCROLL_SLIDER_PREFIX
;
265 else if (f
->display
.x
->v_thumbup
== wdesc
)
267 *part_ptr
= Qvthumbup_part
;
268 *prefix_ptr
= VSCROLL_THUMBUP_PREFIX
;
271 else if (f
->display
.x
->v_thumbdown
== wdesc
)
273 *part_ptr
= Qvthumbdown_part
;
274 *prefix_ptr
= VSCROLL_THUMBDOWN_PREFIX
;
277 else if (f
->display
.x
->h_scrollbar
== wdesc
)
279 *part_ptr
= Qhscrollbar_part
;
280 *prefix_ptr
= HSCROLL_BAR_PREFIX
;
283 else if (f
->display
.x
->h_slider
== wdesc
)
285 *part_ptr
= Qhslider_part
;
286 *prefix_ptr
= HSCROLL_SLIDER_PREFIX
;
289 else if (f
->display
.x
->h_thumbleft
== wdesc
)
291 *part_ptr
= Qhthumbleft_part
;
292 *prefix_ptr
= HSCROLL_THUMBLEFT_PREFIX
;
295 else if (f
->display
.x
->h_thumbright
== wdesc
)
297 *part_ptr
= Qhthumbright_part
;
298 *prefix_ptr
= HSCROLL_THUMBRIGHT_PREFIX
;
305 /* Connect the frame-parameter names for X frames
306 to the ways of passing the parameter values to the window system.
308 The name of a parameter, as a Lisp symbol,
309 has an `x-frame-parameter' property which is an integer in Lisp
310 but can be interpreted as an `enum x_frame_parm' in C. */
314 X_PARM_FOREGROUND_COLOR
,
315 X_PARM_BACKGROUND_COLOR
,
322 X_PARM_INTERNAL_BORDER_WIDTH
,
326 X_PARM_VERT_SCROLLBAR
,
327 X_PARM_HORIZ_SCROLLBAR
,
331 struct x_frame_parm_table
334 void (*setter
)( /* struct frame *frame, Lisp_Object val, oldval */ );
337 void x_set_foreground_color ();
338 void x_set_background_color ();
339 void x_set_mouse_color ();
340 void x_set_cursor_color ();
341 void x_set_border_color ();
342 void x_set_icon_type ();
344 void x_set_border_width ();
345 void x_set_internal_border_width ();
347 void x_set_autoraise ();
348 void x_set_autolower ();
349 void x_set_vertical_scrollbar ();
350 void x_set_horizontal_scrollbar ();
352 static struct x_frame_parm_table x_frame_parms
[] =
354 "foreground-color", x_set_foreground_color
,
355 "background-color", x_set_background_color
,
356 "mouse-color", x_set_mouse_color
,
357 "cursor-color", x_set_cursor_color
,
358 "border-color", x_set_border_color
,
359 "icon-type", x_set_icon_type
,
361 "border-width", x_set_border_width
,
362 "internal-border-width", x_set_internal_border_width
,
364 "autoraise", x_set_autoraise
,
365 "autolower", x_set_autolower
,
366 "vertical-scrollbar", x_set_vertical_scrollbar
,
367 "horizontal-scrollbar", x_set_horizontal_scrollbar
,
370 /* Attach the `x-frame-parameter' properties to
371 the Lisp symbol names of parameters relevant to X. */
373 init_x_parm_symbols ()
377 Qx_frame_parameter
= intern ("x-frame-parameter");
379 for (i
= 0; i
< sizeof (x_frame_parms
)/sizeof (x_frame_parms
[0]); i
++)
380 Fput (intern (x_frame_parms
[i
].name
), Qx_frame_parameter
,
384 /* Report to X that a frame parameter of frame F is being set or changed.
385 PARAM is the symbol that says which parameter.
386 VAL is the new value.
387 OLDVAL is the old value.
388 If the parameter is not specially recognized, do nothing;
389 otherwise the `x_set_...' function for this parameter. */
392 x_set_frame_param (f
, param
, val
, oldval
)
393 register struct frame
*f
;
395 register Lisp_Object val
;
396 register Lisp_Object oldval
;
398 register Lisp_Object tem
;
399 tem
= Fget (param
, Qx_frame_parameter
);
400 if (XTYPE (tem
) == Lisp_Int
402 && XINT (tem
) < sizeof (x_frame_parms
)/sizeof (x_frame_parms
[0]))
403 (*x_frame_parms
[XINT (tem
)].setter
)(f
, val
, oldval
);
406 /* Insert a description of internally-recorded parameters of frame X
407 into the parameter alist *ALISTPTR that is to be given to the user.
408 Only parameters that are specific to the X window system
409 and whose values are not correctly recorded in the frame's
410 param_alist need to be considered here. */
412 x_report_frame_params (f
, alistptr
)
414 Lisp_Object
*alistptr
;
418 store_in_alist (alistptr
, "left", make_number (f
->display
.x
->left_pos
));
419 store_in_alist (alistptr
, "top", make_number (f
->display
.x
->top_pos
));
420 store_in_alist (alistptr
, "border-width",
421 make_number (f
->display
.x
->border_width
));
422 store_in_alist (alistptr
, "internal-border-width",
423 make_number (f
->display
.x
->internal_border_width
));
424 sprintf (buf
, "%d", f
->display
.x
->window_desc
);
425 store_in_alist (alistptr
, "window-id",
429 /* Decide if color named COLOR is valid for the display
430 associated with the selected frame. */
432 defined_color (color
, color_def
)
437 Colormap screen_colormap
;
442 = DefaultColormap (x_current_display
, XDefaultScreen (x_current_display
));
444 foo
= XParseColor (x_current_display
, screen_colormap
,
446 && XAllocColor (x_current_display
, screen_colormap
, color_def
);
448 foo
= XParseColor (color
, color_def
) && XGetHardwareColor (color_def
);
449 #endif /* not HAVE_X11 */
458 /* Given a string ARG naming a color, compute a pixel value from it
459 suitable for screen F.
460 If F is not a color screen, return DEF (default) regardless of what
464 x_decode_color (arg
, def
)
470 CHECK_STRING (arg
, 0);
472 if (strcmp (XSTRING (arg
)->data
, "black") == 0)
473 return BLACK_PIX_DEFAULT
;
474 else if (strcmp (XSTRING (arg
)->data
, "white") == 0)
475 return WHITE_PIX_DEFAULT
;
478 if (XFASTINT (x_screen_planes
) == 1)
481 if (DISPLAY_CELLS
== 1)
485 if (defined_color (XSTRING (arg
)->data
, &cdef
))
488 Fsignal (Qundefined_color
, Fcons (arg
, Qnil
));
491 /* Functions called only from `x_set_frame_param'
492 to set individual parameters.
494 If f->display.x->window_desc is 0,
495 the frame is being created and its X-window does not exist yet.
496 In that case, just record the parameter's new value
497 in the standard place; do not attempt to change the window. */
500 x_set_foreground_color (f
, arg
, oldval
)
502 Lisp_Object arg
, oldval
;
504 f
->display
.x
->foreground_pixel
= x_decode_color (arg
, BLACK_PIX_DEFAULT
);
505 if (f
->display
.x
->window_desc
!= 0)
509 XSetForeground (x_current_display
, f
->display
.x
->normal_gc
,
510 f
->display
.x
->foreground_pixel
);
511 XSetBackground (x_current_display
, f
->display
.x
->reverse_gc
,
512 f
->display
.x
->foreground_pixel
);
513 if (f
->display
.x
->v_scrollbar
)
515 Pixmap up_arrow_pixmap
, down_arrow_pixmap
, slider_pixmap
;
517 XSetWindowBorder (x_current_display
, f
->display
.x
->v_scrollbar
,
518 f
->display
.x
->foreground_pixel
);
521 XCreatePixmapFromBitmapData (XDISPLAY f
->display
.x
->window_desc
,
523 f
->display
.x
->foreground_pixel
,
524 f
->display
.x
->background_pixel
,
525 DefaultDepth (x_current_display
,
526 XDefaultScreen (x_current_display
)));
528 XCreatePixmapFromBitmapData (XDISPLAY f
->display
.x
->window_desc
,
529 up_arrow_bits
, 16, 16,
530 f
->display
.x
->foreground_pixel
,
531 f
->display
.x
->background_pixel
,
532 DefaultDepth (x_current_display
,
533 XDefaultScreen (x_current_display
)));
535 XCreatePixmapFromBitmapData (XDISPLAY f
->display
.x
->window_desc
,
536 down_arrow_bits
, 16, 16,
537 f
->display
.x
->foreground_pixel
,
538 f
->display
.x
->background_pixel
,
539 DefaultDepth (x_current_display
,
540 XDefaultScreen (x_current_display
)));
542 XSetWindowBackgroundPixmap (XDISPLAY f
->display
.x
->v_thumbup
,
544 XSetWindowBackgroundPixmap (XDISPLAY f
->display
.x
->v_thumbdown
,
546 XSetWindowBackgroundPixmap (XDISPLAY f
->display
.x
->v_slider
,
549 XClearWindow (XDISPLAY f
->display
.x
->v_thumbup
);
550 XClearWindow (XDISPLAY f
->display
.x
->v_thumbdown
);
551 XClearWindow (XDISPLAY f
->display
.x
->v_slider
);
553 XFreePixmap (x_current_display
, down_arrow_pixmap
);
554 XFreePixmap (x_current_display
, up_arrow_pixmap
);
555 XFreePixmap (x_current_display
, slider_pixmap
);
557 if (f
->display
.x
->h_scrollbar
)
559 Pixmap left_arrow_pixmap
, right_arrow_pixmap
, slider_pixmap
;
561 XSetWindowBorder (x_current_display
, f
->display
.x
->h_scrollbar
,
562 f
->display
.x
->foreground_pixel
);
565 XCreatePixmapFromBitmapData (XDISPLAY f
->display
.x
->window_desc
,
567 f
->display
.x
->foreground_pixel
,
568 f
->display
.x
->background_pixel
,
569 DefaultDepth (x_current_display
,
570 XDefaultScreen (x_current_display
)));
573 XCreatePixmapFromBitmapData (XDISPLAY f
->display
.x
->window_desc
,
574 up_arrow_bits
, 16, 16,
575 f
->display
.x
->foreground_pixel
,
576 f
->display
.x
->background_pixel
,
577 DefaultDepth (x_current_display
,
578 XDefaultScreen (x_current_display
)));
580 XCreatePixmapFromBitmapData (XDISPLAY f
->display
.x
->window_desc
,
581 down_arrow_bits
, 16, 16,
582 f
->display
.x
->foreground_pixel
,
583 f
->display
.x
->background_pixel
,
584 DefaultDepth (x_current_display
,
585 XDefaultScreen (x_current_display
)));
587 XSetWindowBackgroundPixmap (XDISPLAY f
->display
.x
->h_slider
,
589 XSetWindowBackgroundPixmap (XDISPLAY f
->display
.x
->h_thumbleft
,
591 XSetWindowBackgroundPixmap (XDISPLAY f
->display
.x
->h_thumbright
,
594 XClearWindow (XDISPLAY f
->display
.x
->h_thumbleft
);
595 XClearWindow (XDISPLAY f
->display
.x
->h_thumbright
);
596 XClearWindow (XDISPLAY f
->display
.x
->h_slider
);
598 XFreePixmap (x_current_display
, slider_pixmap
);
599 XFreePixmap (x_current_display
, left_arrow_pixmap
);
600 XFreePixmap (x_current_display
, right_arrow_pixmap
);
603 #endif /* HAVE_X11 */
610 x_set_background_color (f
, arg
, oldval
)
612 Lisp_Object arg
, oldval
;
617 f
->display
.x
->background_pixel
= x_decode_color (arg
, WHITE_PIX_DEFAULT
);
619 if (f
->display
.x
->window_desc
!= 0)
623 /* The main frame area. */
624 XSetBackground (x_current_display
, f
->display
.x
->normal_gc
,
625 f
->display
.x
->background_pixel
);
626 XSetForeground (x_current_display
, f
->display
.x
->reverse_gc
,
627 f
->display
.x
->background_pixel
);
628 XSetWindowBackground (x_current_display
, f
->display
.x
->window_desc
,
629 f
->display
.x
->background_pixel
);
632 if (f
->display
.x
->v_scrollbar
)
634 Pixmap up_arrow_pixmap
, down_arrow_pixmap
, slider_pixmap
;
636 XSetWindowBackground (x_current_display
, f
->display
.x
->v_scrollbar
,
637 f
->display
.x
->background_pixel
);
640 XCreatePixmapFromBitmapData (XDISPLAY f
->display
.x
->window_desc
,
642 f
->display
.x
->foreground_pixel
,
643 f
->display
.x
->background_pixel
,
644 DefaultDepth (x_current_display
,
645 XDefaultScreen (x_current_display
)));
647 XCreatePixmapFromBitmapData (XDISPLAY f
->display
.x
->window_desc
,
648 up_arrow_bits
, 16, 16,
649 f
->display
.x
->foreground_pixel
,
650 f
->display
.x
->background_pixel
,
651 DefaultDepth (x_current_display
,
652 XDefaultScreen (x_current_display
)));
654 XCreatePixmapFromBitmapData (XDISPLAY f
->display
.x
->window_desc
,
655 down_arrow_bits
, 16, 16,
656 f
->display
.x
->foreground_pixel
,
657 f
->display
.x
->background_pixel
,
658 DefaultDepth (x_current_display
,
659 XDefaultScreen (x_current_display
)));
661 XSetWindowBackgroundPixmap (XDISPLAY f
->display
.x
->v_thumbup
,
663 XSetWindowBackgroundPixmap (XDISPLAY f
->display
.x
->v_thumbdown
,
665 XSetWindowBackgroundPixmap (XDISPLAY f
->display
.x
->v_slider
,
668 XClearWindow (XDISPLAY f
->display
.x
->v_thumbup
);
669 XClearWindow (XDISPLAY f
->display
.x
->v_thumbdown
);
670 XClearWindow (XDISPLAY f
->display
.x
->v_slider
);
672 XFreePixmap (x_current_display
, down_arrow_pixmap
);
673 XFreePixmap (x_current_display
, up_arrow_pixmap
);
674 XFreePixmap (x_current_display
, slider_pixmap
);
676 if (f
->display
.x
->h_scrollbar
)
678 Pixmap left_arrow_pixmap
, right_arrow_pixmap
, slider_pixmap
;
680 XSetWindowBackground (x_current_display
, f
->display
.x
->h_scrollbar
,
681 f
->display
.x
->background_pixel
);
684 XCreatePixmapFromBitmapData (XDISPLAY f
->display
.x
->window_desc
,
686 f
->display
.x
->foreground_pixel
,
687 f
->display
.x
->background_pixel
,
688 DefaultDepth (x_current_display
,
689 XDefaultScreen (x_current_display
)));
692 XCreatePixmapFromBitmapData (XDISPLAY f
->display
.x
->window_desc
,
693 up_arrow_bits
, 16, 16,
694 f
->display
.x
->foreground_pixel
,
695 f
->display
.x
->background_pixel
,
696 DefaultDepth (x_current_display
,
697 XDefaultScreen (x_current_display
)));
699 XCreatePixmapFromBitmapData (XDISPLAY f
->display
.x
->window_desc
,
700 down_arrow_bits
, 16, 16,
701 f
->display
.x
->foreground_pixel
,
702 f
->display
.x
->background_pixel
,
703 DefaultDepth (x_current_display
,
704 XDefaultScreen (x_current_display
)));
706 XSetWindowBackgroundPixmap (XDISPLAY f
->display
.x
->h_slider
,
708 XSetWindowBackgroundPixmap (XDISPLAY f
->display
.x
->h_thumbleft
,
710 XSetWindowBackgroundPixmap (XDISPLAY f
->display
.x
->h_thumbright
,
713 XClearWindow (XDISPLAY f
->display
.x
->h_thumbleft
);
714 XClearWindow (XDISPLAY f
->display
.x
->h_thumbright
);
715 XClearWindow (XDISPLAY f
->display
.x
->h_slider
);
717 XFreePixmap (x_current_display
, slider_pixmap
);
718 XFreePixmap (x_current_display
, left_arrow_pixmap
);
719 XFreePixmap (x_current_display
, right_arrow_pixmap
);
722 temp
= XMakeTile (f
->display
.x
->background_pixel
);
723 XChangeBackground (f
->display
.x
->window_desc
, temp
);
725 #endif /* not HAVE_X11 */
734 x_set_mouse_color (f
, arg
, oldval
)
736 Lisp_Object arg
, oldval
;
738 Cursor cursor
, nontext_cursor
, mode_cursor
;
742 f
->display
.x
->mouse_pixel
= x_decode_color (arg
, BLACK_PIX_DEFAULT
);
743 mask_color
= f
->display
.x
->background_pixel
;
744 /* No invisible pointers. */
745 if (mask_color
== f
->display
.x
->mouse_pixel
746 && mask_color
== f
->display
.x
->background_pixel
)
747 f
->display
.x
->mouse_pixel
= f
->display
.x
->foreground_pixel
;
751 if (!EQ (Qnil
, Vx_pointer_shape
))
753 CHECK_NUMBER (Vx_pointer_shape
, 0);
754 cursor
= XCreateFontCursor (x_current_display
, XINT (Vx_pointer_shape
));
757 cursor
= XCreateFontCursor (x_current_display
, XC_xterm
);
759 if (!EQ (Qnil
, Vx_nontext_pointer_shape
))
761 CHECK_NUMBER (Vx_nontext_pointer_shape
, 0);
762 nontext_cursor
= XCreateFontCursor (x_current_display
,
763 XINT (Vx_nontext_pointer_shape
));
766 nontext_cursor
= XCreateFontCursor (x_current_display
, XC_left_ptr
);
768 if (!EQ (Qnil
, Vx_mode_pointer_shape
))
770 CHECK_NUMBER (Vx_mode_pointer_shape
, 0);
771 mode_cursor
= XCreateFontCursor (x_current_display
,
772 XINT (Vx_mode_pointer_shape
));
775 mode_cursor
= XCreateFontCursor (x_current_display
, XC_xterm
);
778 XColor fore_color
, back_color
;
780 fore_color
.pixel
= f
->display
.x
->mouse_pixel
;
781 back_color
.pixel
= mask_color
;
782 XQueryColor (x_current_display
,
783 DefaultColormap (x_current_display
,
784 DefaultScreen (x_current_display
)),
786 XQueryColor (x_current_display
,
787 DefaultColormap (x_current_display
,
788 DefaultScreen (x_current_display
)),
790 XRecolorCursor (x_current_display
, cursor
,
791 &fore_color
, &back_color
);
792 XRecolorCursor (x_current_display
, nontext_cursor
,
793 &fore_color
, &back_color
);
794 XRecolorCursor (x_current_display
, mode_cursor
,
795 &fore_color
, &back_color
);
798 cursor
= XCreateCursor (16, 16, MouseCursor
, MouseMask
,
800 f
->display
.x
->mouse_pixel
,
801 f
->display
.x
->background_pixel
,
805 if (f
->display
.x
->window_desc
!= 0)
807 XDefineCursor (XDISPLAY f
->display
.x
->window_desc
, cursor
);
810 if (cursor
!= f
->display
.x
->text_cursor
&& f
->display
.x
->text_cursor
!= 0)
811 XFreeCursor (XDISPLAY f
->display
.x
->text_cursor
);
812 f
->display
.x
->text_cursor
= cursor
;
814 if (nontext_cursor
!= f
->display
.x
->nontext_cursor
815 && f
->display
.x
->nontext_cursor
!= 0)
816 XFreeCursor (XDISPLAY f
->display
.x
->nontext_cursor
);
817 f
->display
.x
->nontext_cursor
= nontext_cursor
;
819 if (mode_cursor
!= f
->display
.x
->modeline_cursor
820 && f
->display
.x
->modeline_cursor
!= 0)
821 XFreeCursor (XDISPLAY f
->display
.x
->modeline_cursor
);
822 f
->display
.x
->modeline_cursor
= mode_cursor
;
823 #endif /* HAVE_X11 */
830 x_set_cursor_color (f
, arg
, oldval
)
832 Lisp_Object arg
, oldval
;
834 unsigned long fore_pixel
;
836 if (!EQ (Vx_cursor_fore_pixel
, Qnil
))
837 fore_pixel
= x_decode_color (Vx_cursor_fore_pixel
, WHITE_PIX_DEFAULT
);
839 fore_pixel
= f
->display
.x
->background_pixel
;
840 f
->display
.x
->cursor_pixel
= x_decode_color (arg
, BLACK_PIX_DEFAULT
);
841 /* No invisible cursors */
842 if (f
->display
.x
->cursor_pixel
== f
->display
.x
->background_pixel
)
844 f
->display
.x
->cursor_pixel
== f
->display
.x
->mouse_pixel
;
845 if (f
->display
.x
->cursor_pixel
== fore_pixel
)
846 fore_pixel
= f
->display
.x
->background_pixel
;
849 if (f
->display
.x
->window_desc
!= 0)
853 XSetBackground (x_current_display
, f
->display
.x
->cursor_gc
,
854 f
->display
.x
->cursor_pixel
);
855 XSetForeground (x_current_display
, f
->display
.x
->cursor_gc
,
858 #endif /* HAVE_X11 */
862 x_display_cursor (f
, 0);
863 x_display_cursor (f
, 1);
868 /* Set the border-color of frame F to value described by ARG.
869 ARG can be a string naming a color.
870 The border-color is used for the border that is drawn by the X server.
871 Note that this does not fully take effect if done before
872 F has an x-window; it must be redone when the window is created.
874 Note: this is done in two routines because of the way X10 works.
876 Note: under X11, this is normally the province of the window manager,
877 and so emacs' border colors may be overridden. */
880 x_set_border_color (f
, arg
, oldval
)
882 Lisp_Object arg
, oldval
;
887 CHECK_STRING (arg
, 0);
888 str
= XSTRING (arg
)->data
;
891 if (!strcmp (str
, "grey") || !strcmp (str
, "Grey")
892 || !strcmp (str
, "gray") || !strcmp (str
, "Gray"))
897 pix
= x_decode_color (arg
, BLACK_PIX_DEFAULT
);
899 x_set_border_pixel (f
, pix
);
902 /* Set the border-color of frame F to pixel value PIX.
903 Note that this does not fully take effect if done before
904 F has an x-window. */
906 x_set_border_pixel (f
, pix
)
910 f
->display
.x
->border_pixel
= pix
;
912 if (f
->display
.x
->window_desc
!= 0 && f
->display
.x
->border_width
> 0)
919 XSetWindowBorder (x_current_display
, f
->display
.x
->window_desc
,
921 if (f
->display
.x
->h_scrollbar
)
922 XSetWindowBorder (x_current_display
, f
->display
.x
->h_slider
,
924 if (f
->display
.x
->v_scrollbar
)
925 XSetWindowBorder (x_current_display
, f
->display
.x
->v_slider
,
929 temp
= XMakePixmap ((Bitmap
) XStoreBitmap (16, 16, gray_bits
),
930 BLACK_PIX_DEFAULT
, WHITE_PIX_DEFAULT
);
932 temp
= XMakeTile (pix
);
933 XChangeBorder (f
->display
.x
->window_desc
, temp
);
934 XFreePixmap (XDISPLAY temp
);
935 #endif /* not HAVE_X11 */
944 x_set_icon_type (f
, arg
, oldval
)
946 Lisp_Object arg
, oldval
;
951 if (EQ (oldval
, Qnil
) == EQ (arg
, Qnil
))
956 result
= x_text_icon (f
, 0);
958 result
= x_bitmap_icon (f
, 0);
962 error ("No icon window available.");
966 /* If the window was unmapped (and its icon was mapped),
967 the new icon is not mapped, so map the window in its stead. */
969 XMapWindow (XDISPLAY f
->display
.x
->window_desc
);
976 x_set_font (f
, arg
, oldval
)
978 Lisp_Object arg
, oldval
;
983 CHECK_STRING (arg
, 1);
984 name
= XSTRING (arg
)->data
;
987 result
= x_new_font (f
, name
);
991 error ("Font \"%s\" is not defined", name
);
995 x_set_border_width (f
, arg
, oldval
)
997 Lisp_Object arg
, oldval
;
999 CHECK_NUMBER (arg
, 0);
1001 if (XINT (arg
) == f
->display
.x
->border_width
)
1004 if (f
->display
.x
->window_desc
!= 0)
1005 error ("Cannot change the border width of a window");
1007 f
->display
.x
->border_width
= XINT (arg
);
1011 x_set_internal_border_width (f
, arg
, oldval
)
1013 Lisp_Object arg
, oldval
;
1016 int old
= f
->display
.x
->internal_border_width
;
1018 CHECK_NUMBER (arg
, 0);
1019 f
->display
.x
->internal_border_width
= XINT (arg
);
1020 if (f
->display
.x
->internal_border_width
< 0)
1021 f
->display
.x
->internal_border_width
= 0;
1023 if (f
->display
.x
->internal_border_width
== old
)
1026 if (f
->display
.x
->window_desc
!= 0)
1029 x_set_window_size (f
, f
->width
, f
->height
);
1031 x_set_resize_hint (f
);
1035 SET_FRAME_GARBAGED (f
);
1040 x_set_name (f
, arg
, oldval
)
1042 Lisp_Object arg
, oldval
;
1044 CHECK_STRING (arg
, 0);
1046 /* Don't change the name if it's already ARG. */
1047 if (! NILP (Fstring_equal (arg
, f
->name
)))
1050 if (f
->display
.x
->window_desc
)
1054 prop
.value
= XSTRING (arg
)->data
;
1055 prop
.encoding
= XA_STRING
;
1057 prop
.nitems
= XSTRING (arg
)->size
;
1059 XSetWMName (XDISPLAY f
->display
.x
->window_desc
, &prop
);
1060 XSetWMIconName (XDISPLAY f
->display
.x
->window_desc
, &prop
);
1064 XStoreName (XDISPLAY f
->display
.x
->window_desc
,
1065 (char *) XSTRING (arg
)->data
);
1066 XSetIconName (XDISPLAY f
->display
.x
->window_desc
,
1067 (char *) XSTRING (arg
)->data
);
1076 x_set_autoraise (f
, arg
, oldval
)
1078 Lisp_Object arg
, oldval
;
1080 f
->auto_raise
= !EQ (Qnil
, arg
);
1084 x_set_autolower (f
, arg
, oldval
)
1086 Lisp_Object arg
, oldval
;
1088 f
->auto_lower
= !EQ (Qnil
, arg
);
1094 x_set_face (scr
, font
, background
, foreground
, stipple
)
1097 unsigned long background
, foreground
;
1100 XGCValues gc_values
;
1102 unsigned long gc_mask
;
1103 struct face
*new_face
;
1104 unsigned int width
= 16;
1105 unsigned int height
= 16;
1107 if (n_faces
== MAX_FACES_AND_GLYPHS
)
1110 /* Create the Graphics Context. */
1111 gc_values
.font
= font
->fid
;
1112 gc_values
.foreground
= foreground
;
1113 gc_values
.background
= background
;
1114 gc_values
.line_width
= 0;
1115 gc_mask
= GCLineWidth
| GCFont
| GCForeground
| GCBackground
;
1119 = XCreateBitmapFromData (x_current_display
, ROOT_WINDOW
,
1120 (char *) stipple
, width
, height
);
1121 gc_mask
|= GCStipple
;
1124 temp_gc
= XCreateGC (x_current_display
, scr
->display
.x
->window_desc
,
1125 gc_mask
, &gc_values
);
1128 new_face
= (struct face
*) xmalloc (sizeof (struct face
));
1131 XFreeGC (x_current_display
, temp_gc
);
1135 new_face
->font
= font
;
1136 new_face
->foreground
= foreground
;
1137 new_face
->background
= background
;
1138 new_face
->face_gc
= temp_gc
;
1140 new_face
->stipple
= gc_values
.stipple
;
1142 x_face_table
[++n_faces
] = new_face
;
1146 x_set_glyph (scr
, glyph
)
1151 DEFUN ("x-set-face-font", Fx_set_face_font
, Sx_set_face_font
, 4, 2, 0,
1152 "Specify face table entry FACE-CODE to be the font named by FONT,\n\
1153 in colors FOREGROUND and BACKGROUND.")
1154 (face_code
, font_name
, foreground
, background
)
1155 Lisp_Object face_code
;
1156 Lisp_Object font_name
;
1157 Lisp_Object foreground
;
1158 Lisp_Object background
;
1160 register struct face
*fp
; /* Current face info. */
1161 register int fn
; /* Face number. */
1162 register FONT_TYPE
*f
; /* Font data structure. */
1163 unsigned char *newname
;
1166 XGCValues gc_values
;
1168 /* Need to do something about this. */
1169 Drawable drawable
= selected_frame
->display
.x
->window_desc
;
1171 CHECK_NUMBER (face_code
, 1);
1172 CHECK_STRING (font_name
, 2);
1174 if (EQ (foreground
, Qnil
) || EQ (background
, Qnil
))
1176 fg
= selected_frame
->display
.x
->foreground_pixel
;
1177 bg
= selected_frame
->display
.x
->background_pixel
;
1181 CHECK_NUMBER (foreground
, 0);
1182 CHECK_NUMBER (background
, 1);
1184 fg
= x_decode_color (XINT (foreground
), BLACK_PIX_DEFAULT
);
1185 bg
= x_decode_color (XINT (background
), WHITE_PIX_DEFAULT
);
1188 fn
= XINT (face_code
);
1189 if ((fn
< 1) || (fn
> 255))
1190 error ("Invalid face code, %d", fn
);
1192 newname
= XSTRING (font_name
)->data
;
1194 f
= (*newname
== 0 ? 0 : XGetFont (newname
));
1197 error ("Font \"%s\" is not defined", newname
);
1199 fp
= x_face_table
[fn
];
1202 x_face_table
[fn
] = fp
= (struct face
*) xmalloc (sizeof (struct face
));
1203 bzero (fp
, sizeof (struct face
));
1204 fp
->face_type
= x_pixmap
;
1206 else if (FACE_IS_FONT (fn
))
1209 XFreeGC (FACE_FONT (fn
));
1212 else if (FACE_IS_IMAGE (fn
)) /* This should not happen... */
1215 XFreePixmap (x_current_display
, FACE_IMAGE (fn
));
1216 fp
->face_type
= x_font
;
1222 fp
->face_GLYPH
.font_desc
.font
= f
;
1223 gc_values
.font
= f
->fid
;
1224 gc_values
.foreground
= fg
;
1225 gc_values
.background
= bg
;
1226 fp
->face_GLYPH
.font_desc
.face_gc
= XCreateGC (x_current_display
,
1227 drawable
, GCFont
| GCForeground
1228 | GCBackground
, &gc_values
);
1229 fp
->face_GLYPH
.font_desc
.font_width
= FONT_WIDTH (f
);
1230 fp
->face_GLYPH
.font_desc
.font_height
= FONT_HEIGHT (f
);
1236 DEFUN ("x-set-face", Fx_set_face
, Sx_set_face
, 4, 4, 0,
1237 "Specify face table entry FACE-CODE to be the font named by FONT,\n\
1238 in colors FOREGROUND and BACKGROUND.")
1239 (face_code
, font_name
, foreground
, background
)
1240 Lisp_Object face_code
;
1241 Lisp_Object font_name
;
1242 Lisp_Object foreground
;
1243 Lisp_Object background
;
1245 register struct face
*fp
; /* Current face info. */
1246 register int fn
; /* Face number. */
1247 register FONT_TYPE
*f
; /* Font data structure. */
1248 unsigned char *newname
;
1250 CHECK_NUMBER (face_code
, 1);
1251 CHECK_STRING (font_name
, 2);
1253 fn
= XINT (face_code
);
1254 if ((fn
< 1) || (fn
> 255))
1255 error ("Invalid face code, %d", fn
);
1257 /* Ask the server to find the specified font. */
1258 newname
= XSTRING (font_name
)->data
;
1260 f
= (*newname
== 0 ? 0 : XGetFont (newname
));
1263 error ("Font \"%s\" is not defined", newname
);
1265 /* Get the face structure for face_code in the face table.
1266 Make sure it exists. */
1267 fp
= x_face_table
[fn
];
1270 x_face_table
[fn
] = fp
= (struct face
*) xmalloc (sizeof (struct face
));
1271 bzero (fp
, sizeof (struct face
));
1274 /* If this face code already exists, get rid of the old font. */
1275 if (fp
->font
!= 0 && fp
->font
!= f
)
1278 XLoseFont (fp
->font
);
1282 /* Store the specified information in FP. */
1283 fp
->fg
= x_decode_color (foreground
, BLACK_PIX_DEFAULT
);
1284 fp
->bg
= x_decode_color (background
, WHITE_PIX_DEFAULT
);
1292 /* This is excluded because there is no painless way
1293 to get or to remember the name of the font. */
1295 DEFUN ("x-get-face", Fx_get_face
, Sx_get_face
, 1, 1, 0,
1296 "Get data defining face code FACE. FACE is an integer.\n\
1297 The value is a list (FONT FG-COLOR BG-COLOR).")
1301 register struct face
*fp
; /* Current face info. */
1302 register int fn
; /* Face number. */
1304 CHECK_NUMBER (face
, 1);
1306 if ((fn
< 1) || (fn
> 255))
1307 error ("Invalid face code, %d", fn
);
1309 /* Make sure the face table exists and this face code is defined. */
1310 if (x_face_table
== 0 || x_face_table
[fn
] == 0)
1313 fp
= x_face_table
[fn
];
1315 return Fcons (build_string (fp
->name
),
1316 Fcons (make_number (fp
->fg
),
1317 Fcons (make_number (fp
->bg
), Qnil
)));
1321 /* Subroutines of creating an X frame. */
1324 extern char *x_get_string_resource ();
1325 extern XrmDatabase
x_load_resources ();
1327 DEFUN ("x-get-resource", Fx_get_resource
, Sx_get_resource
, 1, 3, 0,
1328 "Retrieve the value of ATTRIBUTE from the X defaults database. This\n\
1329 searches using a key of the form \"INSTANCE.ATTRIBUTE\", with class\n\
1330 \"Emacs\", where INSTANCE is the name under which Emacs was invoked.\n\
1332 Optional arguments COMPONENT and CLASS specify the component for which\n\
1333 we should look up ATTRIBUTE. When specified, Emacs searches using a\n\
1334 key of the form INSTANCE.COMPONENT.ATTRIBUTE, with class \"Emacs.CLASS\".")
1335 (attribute
, name
, class)
1336 Lisp_Object attribute
, name
, class;
1338 register char *value
;
1342 CHECK_STRING (attribute
, 0);
1344 CHECK_STRING (name
, 1);
1346 CHECK_STRING (class, 2);
1347 if (NILP (name
) != NILP (class))
1348 error ("x-get-resource: must specify both NAME and CLASS or neither");
1352 name_key
= (char *) alloca (XSTRING (invocation_name
)->size
+ 1
1353 + XSTRING (attribute
)->size
+ 1);
1355 sprintf (name_key
, "%s.%s",
1356 XSTRING (invocation_name
)->data
,
1357 XSTRING (attribute
)->data
);
1358 class_key
= EMACS_CLASS
;
1362 name_key
= (char *) alloca (XSTRING (invocation_name
)->size
+ 1
1363 + XSTRING (name
)->size
+ 1
1364 + XSTRING (attribute
)->size
+ 1);
1366 class_key
= (char *) alloca (sizeof (EMACS_CLASS
)
1367 + XSTRING (class)->size
+ 1);
1369 sprintf (name_key
, "%s.%s.%s",
1370 XSTRING (invocation_name
)->data
,
1371 XSTRING (name
)->data
,
1372 XSTRING (attribute
)->data
);
1373 sprintf (class_key
, "%s.%s",
1374 XSTRING (invocation_name
)->data
,
1375 XSTRING (class)->data
);
1378 value
= x_get_string_resource (xrdb
, name_key
, class_key
);
1380 if (value
!= (char *) 0)
1381 return build_string (value
);
1388 DEFUN ("x-get-default", Fx_get_default
, Sx_get_default
, 1, 1, 0,
1389 "Get X default ATTRIBUTE from the system, or nil if no default.\n\
1390 Value is a string (when not nil) and ATTRIBUTE is also a string.\n\
1391 The defaults are specified in the file `~/.Xdefaults'.")
1395 register unsigned char *value
;
1397 CHECK_STRING (arg
, 1);
1399 value
= (unsigned char *) XGetDefault (XDISPLAY
1400 XSTRING (invocation_name
)->data
,
1401 XSTRING (arg
)->data
);
1403 /* Try reversing last two args, in case this is the buggy version of X. */
1404 value
= (unsigned char *) XGetDefault (XDISPLAY
1405 XSTRING (arg
)->data
,
1406 XSTRING (invocation_name
)->data
);
1408 return build_string (value
);
1413 #define Fx_get_resource(attribute, name, class) Fx_get_default(attribute)
1417 /* Types we might convert a resource string into. */
1420 number
, boolean
, string
,
1423 /* Return the value of parameter PARAM.
1425 First search ALIST, then Vdefault_frame_alist, then the X defaults
1426 database, using ATTRIBUTE as the attribute name.
1428 Convert the resource to the type specified by desired_type.
1430 If no default is specified, return nil. */
1433 x_get_arg (alist
, param
, attribute
, type
)
1434 Lisp_Object alist
, param
;
1436 enum resource_types type
;
1438 register Lisp_Object tem
;
1440 tem
= Fassq (param
, alist
);
1442 tem
= Fassq (param
, Vdefault_frame_alist
);
1443 if (EQ (tem
, Qnil
) && attribute
)
1445 tem
= Fx_get_resource (build_string (attribute
), Qnil
, Qnil
);
1453 return make_number (atoi (XSTRING (tem
)->data
));
1456 tem
= Fdowncase (tem
);
1457 if (!strcmp (XSTRING (tem
)->data
, "on")
1458 || !strcmp (XSTRING (tem
)->data
, "true"))
1473 /* Record in frame F the specified or default value according to ALIST
1474 of the parameter named PARAM (a Lisp symbol).
1475 If no value is specified for PARAM, look for an X default for XPROP
1476 on the frame named NAME.
1477 If that is not found either, use the value DEFLT. */
1480 x_default_parameter (f
, alist
, propname
, deflt
, xprop
, type
)
1486 enum resource_types type
;
1488 Lisp_Object propsym
= intern (propname
);
1491 tem
= x_get_arg (alist
, propsym
, xprop
, type
);
1494 store_frame_param (f
, propsym
, tem
);
1495 x_set_frame_param (f
, propsym
, tem
, Qnil
);
1499 DEFUN ("x-geometry", Fx_geometry
, Sx_geometry
, 1, 1, 0,
1500 "Parse an X-style geometry string STRING.\n\
1501 Returns an alist of the form ((top . TOP), (left . LEFT) ... ).")
1505 unsigned int width
, height
;
1506 Lisp_Object values
[4];
1508 CHECK_STRING (string
, 0);
1510 geometry
= XParseGeometry ((char *) XSTRING (string
)->data
,
1511 &x
, &y
, &width
, &height
);
1513 switch (geometry
& 0xf) /* Mask out {X,Y}Negative */
1515 case (XValue
| YValue
):
1516 /* What's one pixel among friends?
1517 Perhaps fix this some day by returning symbol `extreme-top'... */
1518 if (x
== 0 && (geometry
& XNegative
))
1520 if (y
== 0 && (geometry
& YNegative
))
1522 values
[0] = Fcons (intern ("left"), make_number (x
));
1523 values
[1] = Fcons (intern ("top"), make_number (y
));
1524 return Flist (2, values
);
1527 case (WidthValue
| HeightValue
):
1528 values
[0] = Fcons (intern ("width"), make_number (width
));
1529 values
[1] = Fcons (intern ("height"), make_number (height
));
1530 return Flist (2, values
);
1533 case (XValue
| YValue
| WidthValue
| HeightValue
):
1534 if (x
== 0 && (geometry
& XNegative
))
1536 if (y
== 0 && (geometry
& YNegative
))
1538 values
[0] = Fcons (intern ("width"), make_number (width
));
1539 values
[1] = Fcons (intern ("height"), make_number (height
));
1540 values
[2] = Fcons (intern ("left"), make_number (x
));
1541 values
[3] = Fcons (intern ("top"), make_number (y
));
1542 return Flist (4, values
);
1549 error ("Must specify x and y value, and/or width and height");
1554 /* Calculate the desired size and position of this window,
1555 or set rubber-band prompting if none. */
1557 #define DEFAULT_ROWS 40
1558 #define DEFAULT_COLS 80
1561 x_figure_window_size (f
, parms
)
1565 register Lisp_Object tem0
, tem1
;
1566 int height
, width
, left
, top
;
1567 register int geometry
;
1568 long window_prompting
= 0;
1570 /* Default values if we fall through.
1571 Actually, if that happens we should get
1572 window manager prompting. */
1573 f
->width
= DEFAULT_COLS
;
1574 f
->height
= DEFAULT_ROWS
;
1575 f
->display
.x
->top_pos
= 1;
1576 f
->display
.x
->left_pos
= 1;
1578 tem0
= x_get_arg (parms
, intern ("height"), 0, 0);
1579 tem1
= x_get_arg (parms
, intern ("width"), 0, 0);
1580 if (! EQ (tem0
, Qnil
) && ! EQ (tem1
, Qnil
))
1582 CHECK_NUMBER (tem0
, 0);
1583 CHECK_NUMBER (tem1
, 0);
1584 f
->height
= XINT (tem0
);
1585 f
->width
= XINT (tem1
);
1586 window_prompting
|= USSize
;
1588 else if (! EQ (tem0
, Qnil
) || ! EQ (tem1
, Qnil
))
1589 error ("Must specify *both* height and width");
1591 f
->display
.x
->pixel_width
= (FONT_WIDTH (f
->display
.x
->font
) * f
->width
1592 + 2 * f
->display
.x
->internal_border_width
);
1593 f
->display
.x
->pixel_height
= (FONT_HEIGHT (f
->display
.x
->font
) * f
->height
1594 + 2 * f
->display
.x
->internal_border_width
);
1596 tem0
= x_get_arg (parms
, intern ("top"), 0, 0);
1597 tem1
= x_get_arg (parms
, intern ("left"), 0, 0);
1598 if (! EQ (tem0
, Qnil
) && ! EQ (tem1
, Qnil
))
1600 CHECK_NUMBER (tem0
, 0);
1601 CHECK_NUMBER (tem1
, 0);
1602 f
->display
.x
->top_pos
= XINT (tem0
);
1603 f
->display
.x
->left_pos
= XINT (tem1
);
1604 x_calc_absolute_position (f
);
1605 window_prompting
|= USPosition
;
1607 else if (! EQ (tem0
, Qnil
) || ! EQ (tem1
, Qnil
))
1608 error ("Must specify *both* top and left corners");
1610 switch (window_prompting
)
1612 case USSize
| USPosition
:
1613 return window_prompting
;
1616 case USSize
: /* Got the size, need the position. */
1617 window_prompting
|= PPosition
;
1618 return window_prompting
;
1621 case USPosition
: /* Got the position, need the size. */
1622 window_prompting
|= PSize
;
1623 return window_prompting
;
1626 case 0: /* Got nothing, take both from geometry. */
1627 window_prompting
|= PPosition
| PSize
;
1628 return window_prompting
;
1632 /* Somehow a bit got set in window_prompting that we didn't
1642 XSetWindowAttributes attributes
;
1643 unsigned long attribute_mask
;
1644 XClassHint class_hints
;
1646 attributes
.background_pixel
= f
->display
.x
->background_pixel
;
1647 attributes
.border_pixel
= f
->display
.x
->border_pixel
;
1648 attributes
.bit_gravity
= StaticGravity
;
1649 attributes
.backing_store
= NotUseful
;
1650 attributes
.save_under
= True
;
1651 attributes
.event_mask
= STANDARD_EVENT_SET
;
1652 attribute_mask
= (CWBackPixel
| CWBorderPixel
| CWBitGravity
1654 | CWBackingStore
| CWSaveUnder
1659 f
->display
.x
->window_desc
1660 = XCreateWindow (x_current_display
, ROOT_WINDOW
,
1661 f
->display
.x
->left_pos
,
1662 f
->display
.x
->top_pos
,
1663 PIXEL_WIDTH (f
), PIXEL_HEIGHT (f
),
1664 f
->display
.x
->border_width
,
1665 CopyFromParent
, /* depth */
1666 InputOutput
, /* class */
1667 screen_visual
, /* set in Fx_open_connection */
1668 attribute_mask
, &attributes
);
1670 class_hints
.res_name
= (char *) XSTRING (f
->name
)->data
;
1671 class_hints
.res_class
= EMACS_CLASS
;
1672 XSetClassHint (x_current_display
, f
->display
.x
->window_desc
, &class_hints
);
1674 XDefineCursor (XDISPLAY f
->display
.x
->window_desc
,
1675 f
->display
.x
->text_cursor
);
1678 if (f
->display
.x
->window_desc
== 0)
1679 error ("Unable to create window.");
1682 /* Handle the icon stuff for this window. Perhaps later we might
1683 want an x_set_icon_position which can be called interactively as
1691 register Lisp_Object tem0
,tem1
;
1694 /* Set the position of the icon. Note that twm groups all
1695 icons in an icon window. */
1696 tem0
= x_get_arg (parms
, intern ("icon-left"), 0, 0);
1697 tem1
= x_get_arg (parms
, intern ("icon-top"), 0, 0);
1698 if (!EQ (tem0
, Qnil
) && !EQ (tem1
, Qnil
))
1700 CHECK_NUMBER (tem0
, 0);
1701 CHECK_NUMBER (tem1
, 0);
1702 hints
.icon_x
= XINT (tem0
);
1703 hints
.icon_x
= XINT (tem0
);
1705 else if (!EQ (tem0
, Qnil
) || !EQ (tem1
, Qnil
))
1706 error ("Both left and top icon corners of icon must be specified");
1709 hints
.icon_x
= f
->display
.x
->left_pos
;
1710 hints
.icon_y
= f
->display
.x
->top_pos
;
1713 /* Start up iconic or window? */
1714 tem0
= x_get_arg (parms
, intern ("iconic-startup"), 0, 0);
1715 if (!EQ (tem0
, Qnil
))
1716 hints
.initial_state
= IconicState
;
1718 hints
.initial_state
= NormalState
; /* the default, actually. */
1719 hints
.input
= False
;
1722 hints
.flags
= StateHint
| IconPositionHint
| InputHint
;
1723 XSetWMHints (x_current_display
, f
->display
.x
->window_desc
, &hints
);
1727 /* Make the GC's needed for this window, setting the
1728 background, border and mouse colors; also create the
1729 mouse cursor and the gray border tile. */
1735 XGCValues gc_values
;
1738 static char cursor_bits
[] =
1740 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1741 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1742 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1743 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1746 /* Create the GC's of this frame.
1747 Note that many default values are used. */
1750 gc_values
.font
= f
->display
.x
->font
->fid
;
1751 gc_values
.foreground
= f
->display
.x
->foreground_pixel
;
1752 gc_values
.background
= f
->display
.x
->background_pixel
;
1753 gc_values
.line_width
= 0; /* Means 1 using fast algorithm. */
1754 f
->display
.x
->normal_gc
= XCreateGC (x_current_display
,
1755 f
->display
.x
->window_desc
,
1756 GCLineWidth
| GCFont
1757 | GCForeground
| GCBackground
,
1760 /* Reverse video style. */
1761 gc_values
.foreground
= f
->display
.x
->background_pixel
;
1762 gc_values
.background
= f
->display
.x
->foreground_pixel
;
1763 f
->display
.x
->reverse_gc
= XCreateGC (x_current_display
,
1764 f
->display
.x
->window_desc
,
1765 GCFont
| GCForeground
| GCBackground
1769 /* Cursor has cursor-color background, background-color foreground. */
1770 gc_values
.foreground
= f
->display
.x
->background_pixel
;
1771 gc_values
.background
= f
->display
.x
->cursor_pixel
;
1772 gc_values
.fill_style
= FillOpaqueStippled
;
1774 = XCreateBitmapFromData (x_current_display
, ROOT_WINDOW
,
1775 cursor_bits
, 16, 16);
1776 f
->display
.x
->cursor_gc
1777 = XCreateGC (x_current_display
, f
->display
.x
->window_desc
,
1778 (GCFont
| GCForeground
| GCBackground
1779 | GCFillStyle
| GCStipple
| GCLineWidth
),
1782 /* Create the gray border tile used when the pointer is not in
1783 the frame. Since this depends on the frame's pixel values,
1784 this must be done on a per-frame basis. */
1785 f
->display
.x
->border_tile
=
1786 XCreatePixmap (x_current_display
, ROOT_WINDOW
, 16, 16,
1787 DefaultDepth (x_current_display
,
1788 XDefaultScreen (x_current_display
)));
1789 gc_values
.foreground
= f
->display
.x
->foreground_pixel
;
1790 gc_values
.background
= f
->display
.x
->background_pixel
;
1791 temp_gc
= XCreateGC (x_current_display
,
1792 (Drawable
) f
->display
.x
->border_tile
,
1793 GCForeground
| GCBackground
, &gc_values
);
1795 /* These are things that should be determined by the server, in
1796 Fx_open_connection */
1797 tileimage
.height
= 16;
1798 tileimage
.width
= 16;
1799 tileimage
.xoffset
= 0;
1800 tileimage
.format
= XYBitmap
;
1801 tileimage
.data
= gray_bits
;
1802 tileimage
.byte_order
= LSBFirst
;
1803 tileimage
.bitmap_unit
= 8;
1804 tileimage
.bitmap_bit_order
= LSBFirst
;
1805 tileimage
.bitmap_pad
= 8;
1806 tileimage
.bytes_per_line
= (16 + 7) >> 3;
1807 tileimage
.depth
= 1;
1808 XPutImage (x_current_display
, f
->display
.x
->border_tile
, temp_gc
,
1809 &tileimage
, 0, 0, 0, 0, 16, 16);
1810 XFreeGC (x_current_display
, temp_gc
);
1812 #endif /* HAVE_X11 */
1814 DEFUN ("x-create-frame", Fx_create_frame
, Sx_create_frame
,
1816 "Make a new X window, which is called a \"frame\" in Emacs terms.\n\
1817 Return an Emacs frame object representing the X window.\n\
1818 ALIST is an alist of frame parameters.\n\
1819 If the parameters specify that the frame should not have a minibuffer,\n\
1820 and do not specify a specific minibuffer window to use,\n\
1821 then `default-minibuffer-frame' must be a frame whose minibuffer can\n\
1822 be shared by the new frame.")
1828 Lisp_Object frame
, tem
;
1830 int minibuffer_only
= 0;
1831 long window_prompting
= 0;
1834 if (x_current_display
== 0)
1835 error ("X windows are not in use or not initialized");
1837 name
= x_get_arg (parms
, intern ("name"), "Title", string
);
1839 name
= build_string (x_id_name
);
1840 if (XTYPE (name
) != Lisp_String
)
1841 error ("x-create-frame: name parameter must be a string");
1843 tem
= x_get_arg (parms
, intern ("minibuffer"), 0, 0);
1844 if (EQ (tem
, intern ("none")))
1845 f
= make_frame_without_minibuffer (Qnil
);
1846 else if (EQ (tem
, intern ("only")))
1848 f
= make_minibuffer_frame ();
1849 minibuffer_only
= 1;
1851 else if (EQ (tem
, Qnil
) || EQ (tem
, Qt
))
1854 f
= make_frame_without_minibuffer (tem
);
1856 /* Set the name; the functions to which we pass f expect the
1858 XSET (f
->name
, Lisp_String
, name
);
1860 XSET (frame
, Lisp_Frame
, f
);
1861 f
->output_method
= output_x_window
;
1862 f
->display
.x
= (struct x_display
*) xmalloc (sizeof (struct x_display
));
1863 bzero (f
->display
.x
, sizeof (struct x_display
));
1865 /* Note that the frame has no physical cursor right now. */
1866 f
->phys_cursor_x
= -1;
1868 /* Extract the window parameters from the supplied values
1869 that are needed to determine window geometry. */
1870 x_default_parameter (f
, parms
, "font",
1871 build_string ("9x15"), "font", string
);
1872 x_default_parameter (f
, parms
, "background-color",
1873 build_string ("white"), "background", string
);
1874 x_default_parameter (f
, parms
, "border-width",
1875 make_number (2), "BorderWidth", number
);
1876 /* This defaults to 2 in order to match XTerms. */
1877 x_default_parameter (f
, parms
, "internal-border-width",
1878 make_number (2), "InternalBorderWidth", number
);
1880 /* Also do the stuff which must be set before the window exists. */
1881 x_default_parameter (f
, parms
, "foreground-color",
1882 build_string ("black"), "foreground", string
);
1883 x_default_parameter (f
, parms
, "mouse-color",
1884 build_string ("black"), "mouse", string
);
1885 x_default_parameter (f
, parms
, "cursor-color",
1886 build_string ("black"), "cursor", string
);
1887 x_default_parameter (f
, parms
, "border-color",
1888 build_string ("black"), "border", string
);
1890 /* Need to do icon type, auto-raise, auto-lower. */
1892 f
->display
.x
->parent_desc
= ROOT_WINDOW
;
1893 window_prompting
= x_figure_window_size (f
, parms
);
1899 /* Dimensions, especially f->height, must be done via change_frame_size.
1900 Change will not be effected unless different from the current
1904 f
->height
= f
->width
= 0;
1905 change_frame_size (f
, height
, width
, 1);
1907 x_wm_set_size_hint (f
, window_prompting
);
1910 tem
= x_get_arg (parms
, intern ("unsplittable"), 0, 0);
1911 f
->no_split
= minibuffer_only
|| EQ (tem
, Qt
);
1913 /* Now handle the rest of the parameters. */
1914 x_default_parameter (f
, parms
, "horizontal-scroll-bar",
1915 Qnil
, "?HScrollBar", string
);
1916 x_default_parameter (f
, parms
, "vertical-scroll-bar",
1917 Qnil
, "?VScrollBar", string
);
1919 /* Make the window appear on the frame and enable display. */
1920 if (!EQ (x_get_arg (parms
, intern ("suppress-initial-map"), 0, 0), Qt
))
1921 x_make_frame_visible (f
);
1926 Lisp_Object frame
, tem
;
1928 int pixelwidth
, pixelheight
;
1933 int minibuffer_only
= 0;
1934 Lisp_Object vscroll
, hscroll
;
1936 if (x_current_display
== 0)
1937 error ("X windows are not in use or not initialized");
1939 name
= Fassq (intern ("name"), parms
);
1941 tem
= x_get_arg (parms
, intern ("minibuffer"), 0, 0);
1942 if (EQ (tem
, intern ("none")))
1943 f
= make_frame_without_minibuffer (Qnil
);
1944 else if (EQ (tem
, intern ("only")))
1946 f
= make_minibuffer_frame ();
1947 minibuffer_only
= 1;
1949 else if (! EQ (tem
, Qnil
))
1950 f
= make_frame_without_minibuffer (tem
);
1954 parent
= ROOT_WINDOW
;
1956 XSET (frame
, Lisp_Frame
, f
);
1957 f
->output_method
= output_x_window
;
1958 f
->display
.x
= (struct x_display
*) xmalloc (sizeof (struct x_display
));
1959 bzero (f
->display
.x
, sizeof (struct x_display
));
1961 /* Some temprorary default values for height and width. */
1964 f
->display
.x
->left_pos
= -1;
1965 f
->display
.x
->top_pos
= -1;
1967 /* Give the frame a default name (which may be overridden with PARMS). */
1969 strncpy (iconidentity
, ICONTAG
, MAXICID
);
1970 if (gethostname (&iconidentity
[sizeof (ICONTAG
) - 1],
1971 (MAXICID
- 1) - sizeof (ICONTAG
)))
1972 iconidentity
[sizeof (ICONTAG
) - 2] = '\0';
1973 f
->name
= build_string (iconidentity
);
1975 /* Extract some window parameters from the supplied values.
1976 These are the parameters that affect window geometry. */
1978 tem
= x_get_arg (parms
, intern ("font"), "BodyFont", string
);
1980 tem
= build_string ("9x15");
1981 x_set_font (f
, tem
);
1982 x_default_parameter (f
, parms
, "border-color",
1983 build_string ("black"), "Border", string
);
1984 x_default_parameter (f
, parms
, "background-color",
1985 build_string ("white"), "Background", string
);
1986 x_default_parameter (f
, parms
, "foreground-color",
1987 build_string ("black"), "Foreground", string
);
1988 x_default_parameter (f
, parms
, "mouse-color",
1989 build_string ("black"), "Mouse", string
);
1990 x_default_parameter (f
, parms
, "cursor-color",
1991 build_string ("black"), "Cursor", string
);
1992 x_default_parameter (f
, parms
, "border-width",
1993 make_number (2), "BorderWidth", number
);
1994 x_default_parameter (f
, parms
, "internal-border-width",
1995 make_number (4), "InternalBorderWidth", number
);
1996 x_default_parameter (f
, parms
, "auto-raise",
1997 Qnil
, "AutoRaise", boolean
);
1999 hscroll
= x_get_arg (parms
, intern ("horizontal-scroll-bar"), 0, 0);
2000 vscroll
= x_get_arg (parms
, intern ("vertical-scroll-bar"), 0, 0);
2002 if (f
->display
.x
->internal_border_width
< 0)
2003 f
->display
.x
->internal_border_width
= 0;
2005 tem
= x_get_arg (parms
, intern ("window-id"), 0, 0);
2006 if (!EQ (tem
, Qnil
))
2008 WINDOWINFO_TYPE wininfo
;
2010 Window
*children
, root
;
2012 CHECK_STRING (tem
, 0);
2013 f
->display
.x
->window_desc
= (Window
) atoi (XSTRING (tem
)->data
);
2016 XGetWindowInfo (f
->display
.x
->window_desc
, &wininfo
);
2017 XQueryTree (f
->display
.x
->window_desc
, &parent
, &nchildren
, &children
);
2021 height
= (wininfo
.height
- 2 * f
->display
.x
->internal_border_width
)
2022 / FONT_HEIGHT (f
->display
.x
->font
);
2023 width
= (wininfo
.width
- 2 * f
->display
.x
->internal_border_width
)
2024 / FONT_WIDTH (f
->display
.x
->font
);
2025 f
->display
.x
->left_pos
= wininfo
.x
;
2026 f
->display
.x
->top_pos
= wininfo
.y
;
2027 f
->visible
= wininfo
.mapped
!= 0;
2028 f
->display
.x
->border_width
= wininfo
.bdrwidth
;
2029 f
->display
.x
->parent_desc
= parent
;
2033 tem
= x_get_arg (parms
, intern ("parent-id"), 0, 0);
2034 if (!EQ (tem
, Qnil
))
2036 CHECK_STRING (tem
, 0);
2037 parent
= (Window
) atoi (XSTRING (tem
)->data
);
2039 f
->display
.x
->parent_desc
= parent
;
2040 tem
= x_get_arg (parms
, intern ("height"), 0, 0);
2043 tem
= x_get_arg (parms
, intern ("width"), 0, 0);
2046 tem
= x_get_arg (parms
, intern ("top"), 0, 0);
2048 tem
= x_get_arg (parms
, intern ("left"), 0, 0);
2051 /* Now TEM is nil if no edge or size was specified.
2052 In that case, we must do rubber-banding. */
2055 tem
= x_get_arg (parms
, intern ("geometry"), 0, 0);
2057 &f
->display
.x
->left_pos
, &f
->display
.x
->top_pos
,
2059 (XTYPE (tem
) == Lisp_String
2060 ? (char *) XSTRING (tem
)->data
: ""),
2061 XSTRING (f
->name
)->data
,
2062 !NILP (hscroll
), !NILP (vscroll
));
2066 /* Here if at least one edge or size was specified.
2067 Demand that they all were specified, and use them. */
2068 tem
= x_get_arg (parms
, intern ("height"), 0, 0);
2070 error ("Height not specified");
2071 CHECK_NUMBER (tem
, 0);
2072 height
= XINT (tem
);
2074 tem
= x_get_arg (parms
, intern ("width"), 0, 0);
2076 error ("Width not specified");
2077 CHECK_NUMBER (tem
, 0);
2080 tem
= x_get_arg (parms
, intern ("top"), 0, 0);
2082 error ("Top position not specified");
2083 CHECK_NUMBER (tem
, 0);
2084 f
->display
.x
->left_pos
= XINT (tem
);
2086 tem
= x_get_arg (parms
, intern ("left"), 0, 0);
2088 error ("Left position not specified");
2089 CHECK_NUMBER (tem
, 0);
2090 f
->display
.x
->top_pos
= XINT (tem
);
2093 pixelwidth
= (width
* FONT_WIDTH (f
->display
.x
->font
)
2094 + 2 * f
->display
.x
->internal_border_width
2095 + (!NILP (vscroll
) ? VSCROLL_WIDTH
: 0));
2096 pixelheight
= (height
* FONT_HEIGHT (f
->display
.x
->font
)
2097 + 2 * f
->display
.x
->internal_border_width
2098 + (!NILP (hscroll
) ? HSCROLL_HEIGHT
: 0));
2101 f
->display
.x
->window_desc
2102 = XCreateWindow (parent
,
2103 f
->display
.x
->left_pos
, /* Absolute horizontal offset */
2104 f
->display
.x
->top_pos
, /* Absolute Vertical offset */
2105 pixelwidth
, pixelheight
,
2106 f
->display
.x
->border_width
,
2107 BLACK_PIX_DEFAULT
, WHITE_PIX_DEFAULT
);
2109 if (f
->display
.x
->window_desc
== 0)
2110 error ("Unable to create window.");
2113 /* Install the now determined height and width
2114 in the windows and in phys_lines and desired_lines. */
2115 /* ??? jla version had 1 here instead of 0. */
2116 change_frame_size (f
, height
, width
, 1);
2117 XSelectInput (f
->display
.x
->window_desc
, KeyPressed
| ExposeWindow
2118 | ButtonPressed
| ButtonReleased
| ExposeRegion
| ExposeCopy
2119 | EnterWindow
| LeaveWindow
| UnmapWindow
);
2120 x_set_resize_hint (f
);
2122 /* Tell the server the window's default name. */
2126 prop
.value
= XSTRING (f
->name
)->data
;
2127 prop
.encoding
= XA_STRING
;
2129 prop
.nitems
= XSTRING (f
->name
)->size
;
2130 XSetWMName (XDISPLAY f
->display
.x
->window_desc
, &prop
);
2133 XStoreName (XDISPLAY f
->display
.x
->window_desc
, XSTRING (f
->name
)->data
);
2136 /* Now override the defaults with all the rest of the specified
2138 tem
= x_get_arg (parms
, intern ("unsplittable"), 0, 0);
2139 f
->no_split
= minibuffer_only
|| EQ (tem
, Qt
);
2141 /* Do not create an icon window if the caller says not to */
2142 if (!EQ (x_get_arg (parms
, intern ("suppress-icon"), 0, 0), Qt
)
2143 || f
->display
.x
->parent_desc
!= ROOT_WINDOW
)
2145 x_text_icon (f
, iconidentity
);
2146 x_default_parameter (f
, parms
, "icon-type", Qnil
,
2147 "BitmapIcon", boolean
);
2150 /* Tell the X server the previously set values of the
2151 background, border and mouse colors; also create the mouse cursor. */
2153 temp
= XMakeTile (f
->display
.x
->background_pixel
);
2154 XChangeBackground (f
->display
.x
->window_desc
, temp
);
2157 x_set_border_pixel (f
, f
->display
.x
->border_pixel
);
2159 x_set_mouse_color (f
, Qnil
, Qnil
);
2161 /* Now override the defaults with all the rest of the specified parms. */
2163 Fmodify_frame_parameters (frame
, parms
);
2165 if (!NILP (vscroll
))
2166 install_vertical_scrollbar (f
, pixelwidth
, pixelheight
);
2167 if (!NILP (hscroll
))
2168 install_horizontal_scrollbar (f
, pixelwidth
, pixelheight
);
2170 /* Make the window appear on the frame and enable display. */
2172 if (!EQ (x_get_arg (parms
, intern ("suppress-initial-map"), 0, 0), Qt
))
2173 x_make_window_visible (f
);
2180 DEFUN ("focus-frame", Ffocus_frame
, Sfocus_frame
, 1, 1, 0,
2181 "Set the focus on FRAME.")
2185 CHECK_LIVE_FRAME (frame
, 0);
2187 if (FRAME_IS_X (XFRAME (frame
)))
2190 x_focus_on_frame (XFRAME (frame
));
2198 DEFUN ("unfocus-frame", Funfocus_frame
, Sunfocus_frame
, 0, 0, 0,
2199 "If a frame has been focused, release it.")
2205 x_unfocus_frame (x_focus_frame
);
2213 /* Computes an X-window size and position either from geometry GEO
2216 F is a frame. It specifies an X window which is used to
2217 determine which display to compute for. Its font, borders
2218 and colors control how the rectangle will be displayed.
2220 X and Y are where to store the positions chosen.
2221 WIDTH and HEIGHT are where to store the sizes chosen.
2223 GEO is the geometry that may specify some of the info.
2224 STR is a prompt to display.
2225 HSCROLL and VSCROLL say whether we have horiz and vert scroll bars. */
2228 x_rubber_band (f
, x
, y
, width
, height
, geo
, str
, hscroll
, vscroll
)
2230 int *x
, *y
, *width
, *height
;
2233 int hscroll
, vscroll
;
2239 int background_color
;
2245 background_color
= f
->display
.x
->background_pixel
;
2246 border_color
= f
->display
.x
->border_pixel
;
2248 frame
.bdrwidth
= f
->display
.x
->border_width
;
2249 frame
.border
= XMakeTile (border_color
);
2250 frame
.background
= XMakeTile (background_color
);
2251 tempwindow
= XCreateTerm (str
, "emacs", geo
, default_window
, &frame
, 10, 5,
2252 (2 * f
->display
.x
->internal_border_width
2253 + (vscroll
? VSCROLL_WIDTH
: 0)),
2254 (2 * f
->display
.x
->internal_border_width
2255 + (hscroll
? HSCROLL_HEIGHT
: 0)),
2256 width
, height
, f
->display
.x
->font
,
2257 FONT_WIDTH (f
->display
.x
->font
),
2258 FONT_HEIGHT (f
->display
.x
->font
));
2259 XFreePixmap (frame
.border
);
2260 XFreePixmap (frame
.background
);
2262 if (tempwindow
!= 0)
2264 XQueryWindow (tempwindow
, &wininfo
);
2265 XDestroyWindow (tempwindow
);
2270 /* Coordinates we got are relative to the root window.
2271 Convert them to coordinates relative to desired parent window
2272 by scanning from there up to the root. */
2273 tempwindow
= f
->display
.x
->parent_desc
;
2274 while (tempwindow
!= ROOT_WINDOW
)
2278 XQueryWindow (tempwindow
, &wininfo
);
2281 XQueryTree (tempwindow
, &tempwindow
, &nchildren
, &children
);
2286 return tempwindow
!= 0;
2288 #endif /* not HAVE_X11 */
2290 /* Set whether frame F has a horizontal scroll bar.
2291 VAL is t or nil to specify it. */
2294 x_set_horizontal_scrollbar (f
, val
, oldval
)
2296 Lisp_Object val
, oldval
;
2300 if (f
->display
.x
->window_desc
!= 0)
2303 f
->display
.x
->h_scrollbar_height
= HSCROLL_HEIGHT
;
2304 x_set_window_size (f
, f
->width
, f
->height
);
2305 install_horizontal_scrollbar (f
);
2306 SET_FRAME_GARBAGED (f
);
2311 if (f
->display
.x
->h_scrollbar
)
2314 f
->display
.x
->h_scrollbar_height
= 0;
2315 XDestroyWindow (XDISPLAY f
->display
.x
->h_scrollbar
);
2316 f
->display
.x
->h_scrollbar
= 0;
2317 x_set_window_size (f
, f
->width
, f
->height
);
2324 /* Set whether frame F has a vertical scroll bar.
2325 VAL is t or nil to specify it. */
2328 x_set_vertical_scrollbar (f
, val
, oldval
)
2330 Lisp_Object val
, oldval
;
2334 if (f
->display
.x
->window_desc
!= 0)
2337 f
->display
.x
->v_scrollbar_width
= VSCROLL_WIDTH
;
2338 x_set_window_size (f
, f
->width
, f
->height
);
2339 install_vertical_scrollbar (f
);
2340 SET_FRAME_GARBAGED (f
);
2345 if (f
->display
.x
->v_scrollbar
!= 0)
2348 f
->display
.x
->v_scrollbar_width
= 0;
2349 XDestroyWindow (XDISPLAY f
->display
.x
->v_scrollbar
);
2350 f
->display
.x
->v_scrollbar
= 0;
2351 x_set_window_size (f
, f
->width
, f
->height
);
2352 SET_FRAME_GARBAGED (f
);
2357 /* Create the X windows for a vertical scroll bar
2358 for a frame X that already has an X window but no scroll bar. */
2361 install_vertical_scrollbar (f
)
2364 int ibw
= f
->display
.x
->internal_border_width
;
2366 XColor fore_color
, back_color
;
2367 Pixmap up_arrow_pixmap
, down_arrow_pixmap
, slider_pixmap
;
2368 int pix_x
, pix_y
, width
, height
, border
;
2370 height
= f
->display
.x
->pixel_height
- ibw
- 2;
2371 width
= VSCROLL_WIDTH
- 2;
2372 pix_x
= f
->display
.x
->pixel_width
- ibw
/2;
2378 XCreatePixmapFromBitmapData (x_current_display
, f
->display
.x
->window_desc
,
2379 up_arrow_bits
, 16, 16,
2380 f
->display
.x
->foreground_pixel
,
2381 f
->display
.x
->background_pixel
,
2382 DefaultDepth (x_current_display
,
2383 XDefaultScreen (x_current_display
)));
2386 XCreatePixmapFromBitmapData (x_current_display
, f
->display
.x
->window_desc
,
2387 down_arrow_bits
, 16, 16,
2388 f
->display
.x
->foreground_pixel
,
2389 f
->display
.x
->background_pixel
,
2390 DefaultDepth (x_current_display
,
2391 XDefaultScreen (x_current_display
)));
2394 XCreatePixmapFromBitmapData (x_current_display
, f
->display
.x
->window_desc
,
2396 f
->display
.x
->foreground_pixel
,
2397 f
->display
.x
->background_pixel
,
2398 DefaultDepth (x_current_display
,
2399 XDefaultScreen (x_current_display
)));
2401 /* These cursor shapes will be installed when the mouse enters
2402 the appropriate window. */
2404 up_arrow_cursor
= XCreateFontCursor (x_current_display
, XC_sb_up_arrow
);
2405 down_arrow_cursor
= XCreateFontCursor (x_current_display
, XC_sb_down_arrow
);
2406 v_double_arrow_cursor
= XCreateFontCursor (x_current_display
, XC_sb_v_double_arrow
);
2408 f
->display
.x
->v_scrollbar
=
2409 XCreateSimpleWindow (x_current_display
, f
->display
.x
->window_desc
,
2410 pix_x
, pix_y
, width
, height
, border
,
2411 f
->display
.x
->foreground_pixel
,
2412 f
->display
.x
->background_pixel
);
2413 XFlush (x_current_display
);
2414 XDefineCursor (x_current_display
, f
->display
.x
->v_scrollbar
,
2415 v_double_arrow_cursor
);
2417 /* Create slider window */
2418 f
->display
.x
->v_slider
=
2419 XCreateSimpleWindow (x_current_display
, f
->display
.x
->v_scrollbar
,
2420 0, VSCROLL_WIDTH
- 2,
2421 VSCROLL_WIDTH
- 4, VSCROLL_WIDTH
- 4,
2422 1, f
->display
.x
->border_pixel
,
2423 f
->display
.x
->foreground_pixel
);
2424 XFlush (x_current_display
);
2425 XDefineCursor (x_current_display
, f
->display
.x
->v_slider
,
2426 v_double_arrow_cursor
);
2427 XSetWindowBackgroundPixmap (x_current_display
, f
->display
.x
->v_slider
,
2430 f
->display
.x
->v_thumbup
=
2431 XCreateSimpleWindow (x_current_display
, f
->display
.x
->v_scrollbar
,
2433 VSCROLL_WIDTH
- 2, VSCROLL_WIDTH
- 2,
2434 0, f
->display
.x
->foreground_pixel
,
2435 f
->display
.x
-> background_pixel
);
2436 XFlush (x_current_display
);
2437 XDefineCursor (x_current_display
, f
->display
.x
->v_thumbup
,
2439 XSetWindowBackgroundPixmap (x_current_display
, f
->display
.x
->v_thumbup
,
2442 f
->display
.x
->v_thumbdown
=
2443 XCreateSimpleWindow (x_current_display
, f
->display
.x
->v_scrollbar
,
2444 0, height
- VSCROLL_WIDTH
+ 2,
2445 VSCROLL_WIDTH
- 2, VSCROLL_WIDTH
- 2,
2446 0, f
->display
.x
->foreground_pixel
,
2447 f
->display
.x
->background_pixel
);
2448 XFlush (x_current_display
);
2449 XDefineCursor (x_current_display
, f
->display
.x
->v_thumbdown
,
2451 XSetWindowBackgroundPixmap (x_current_display
, f
->display
.x
->v_thumbdown
,
2454 fore_color
.pixel
= f
->display
.x
->mouse_pixel
;
2455 back_color
.pixel
= f
->display
.x
->background_pixel
;
2456 XQueryColor (x_current_display
,
2457 DefaultColormap (x_current_display
,
2458 DefaultScreen (x_current_display
)),
2460 XQueryColor (x_current_display
,
2461 DefaultColormap (x_current_display
,
2462 DefaultScreen (x_current_display
)),
2464 XRecolorCursor (x_current_display
, up_arrow_cursor
,
2465 &fore_color
, &back_color
);
2466 XRecolorCursor (x_current_display
, down_arrow_cursor
,
2467 &fore_color
, &back_color
);
2468 XRecolorCursor (x_current_display
, v_double_arrow_cursor
,
2469 &fore_color
, &back_color
);
2471 XFreePixmap (x_current_display
, slider_pixmap
);
2472 XFreePixmap (x_current_display
, up_arrow_pixmap
);
2473 XFreePixmap (x_current_display
, down_arrow_pixmap
);
2474 XFlush (x_current_display
);
2476 XSelectInput (x_current_display
, f
->display
.x
->v_scrollbar
,
2477 ButtonPressMask
| ButtonReleaseMask
2478 | PointerMotionMask
| PointerMotionHintMask
2480 XSelectInput (x_current_display
, f
->display
.x
->v_slider
,
2481 ButtonPressMask
| ButtonReleaseMask
);
2482 XSelectInput (x_current_display
, f
->display
.x
->v_thumbdown
,
2483 ButtonPressMask
| ButtonReleaseMask
);
2484 XSelectInput (x_current_display
, f
->display
.x
->v_thumbup
,
2485 ButtonPressMask
| ButtonReleaseMask
);
2486 XFlush (x_current_display
);
2488 /* This should be done at the same time as the main window. */
2489 XMapWindow (x_current_display
, f
->display
.x
->v_scrollbar
);
2490 XMapSubwindows (x_current_display
, f
->display
.x
->v_scrollbar
);
2491 XFlush (x_current_display
);
2492 #else /* not HAVE_X11 */
2494 Pixmap fore_tile
, back_tile
, bord_tile
;
2495 static short up_arrow_bits
[] = {
2496 0x0000, 0x0180, 0x03c0, 0x07e0,
2497 0x0ff0, 0x1ff8, 0x3ffc, 0x7ffe,
2498 0x0180, 0x0180, 0x0180, 0x0180,
2499 0x0180, 0x0180, 0x0180, 0xffff};
2500 static short down_arrow_bits
[] = {
2501 0xffff, 0x0180, 0x0180, 0x0180,
2502 0x0180, 0x0180, 0x0180, 0x0180,
2503 0x7ffe, 0x3ffc, 0x1ff8, 0x0ff0,
2504 0x07e0, 0x03c0, 0x0180, 0x0000};
2506 fore_tile
= XMakeTile (f
->display
.x
->foreground_pixel
);
2507 back_tile
= XMakeTile (f
->display
.x
->background_pixel
);
2508 bord_tile
= XMakeTile (f
->display
.x
->border_pixel
);
2510 b
= XStoreBitmap (VSCROLL_WIDTH
- 2, VSCROLL_WIDTH
- 2, up_arrow_bits
);
2511 up_arrow_pixmap
= XMakePixmap (b
,
2512 f
->display
.x
->foreground_pixel
,
2513 f
->display
.x
->background_pixel
);
2516 b
= XStoreBitmap (VSCROLL_WIDTH
- 2, VSCROLL_WIDTH
- 2, down_arrow_bits
);
2517 down_arrow_pixmap
= XMakePixmap (b
,
2518 f
->display
.x
->foreground_pixel
,
2519 f
->display
.x
->background_pixel
);
2522 ibw
= f
->display
.x
->internal_border_width
;
2524 f
->display
.x
->v_scrollbar
= XCreateWindow (f
->display
.x
->window_desc
,
2525 width
- VSCROLL_WIDTH
- ibw
/2,
2529 1, bord_tile
, back_tile
);
2531 f
->display
.x
->v_scrollbar_width
= VSCROLL_WIDTH
;
2533 f
->display
.x
->v_thumbup
= XCreateWindow (f
->display
.x
->v_scrollbar
,
2537 0, 0, up_arrow_pixmap
);
2538 XTileAbsolute (f
->display
.x
->v_thumbup
);
2540 f
->display
.x
->v_thumbdown
= XCreateWindow (f
->display
.x
->v_scrollbar
,
2542 height
- ibw
- VSCROLL_WIDTH
,
2545 0, 0, down_arrow_pixmap
);
2546 XTileAbsolute (f
->display
.x
->v_thumbdown
);
2548 f
->display
.x
->v_slider
= XCreateWindow (f
->display
.x
->v_scrollbar
,
2549 0, VSCROLL_WIDTH
- 2,
2552 1, back_tile
, fore_tile
);
2554 XSelectInput (f
->display
.x
->v_scrollbar
,
2555 (ButtonPressed
| ButtonReleased
| KeyPressed
));
2556 XSelectInput (f
->display
.x
->v_thumbup
,
2557 (ButtonPressed
| ButtonReleased
| KeyPressed
));
2559 XSelectInput (f
->display
.x
->v_thumbdown
,
2560 (ButtonPressed
| ButtonReleased
| KeyPressed
));
2562 XMapWindow (f
->display
.x
->v_thumbup
);
2563 XMapWindow (f
->display
.x
->v_thumbdown
);
2564 XMapWindow (f
->display
.x
->v_slider
);
2565 XMapWindow (f
->display
.x
->v_scrollbar
);
2567 XFreePixmap (fore_tile
);
2568 XFreePixmap (back_tile
);
2569 XFreePixmap (up_arrow_pixmap
);
2570 XFreePixmap (down_arrow_pixmap
);
2571 #endif /* not HAVE_X11 */
2575 install_horizontal_scrollbar (f
)
2578 int ibw
= f
->display
.x
->internal_border_width
;
2580 Pixmap left_arrow_pixmap
, right_arrow_pixmap
, slider_pixmap
;
2585 pix_y
= PIXEL_HEIGHT (f
) - HSCROLL_HEIGHT
- ibw
;
2586 width
= PIXEL_WIDTH (f
) - 2 * ibw
;
2587 if (f
->display
.x
->v_scrollbar_width
)
2588 width
-= (f
->display
.x
->v_scrollbar_width
+ 1);
2592 XCreatePixmapFromBitmapData (x_current_display
, f
->display
.x
->window_desc
,
2593 left_arrow_bits
, 16, 16,
2594 f
->display
.x
->foreground_pixel
,
2595 f
->display
.x
->background_pixel
,
2596 DefaultDepth (x_current_display
,
2597 XDefaultScreen (x_current_display
)));
2599 right_arrow_pixmap
=
2600 XCreatePixmapFromBitmapData (x_current_display
, f
->display
.x
->window_desc
,
2601 right_arrow_bits
, 16, 16,
2602 f
->display
.x
->foreground_pixel
,
2603 f
->display
.x
->background_pixel
,
2604 DefaultDepth (x_current_display
,
2605 XDefaultScreen (x_current_display
)));
2608 XCreatePixmapFromBitmapData (x_current_display
, f
->display
.x
->window_desc
,
2610 f
->display
.x
->foreground_pixel
,
2611 f
->display
.x
->background_pixel
,
2612 DefaultDepth (x_current_display
,
2613 XDefaultScreen (x_current_display
)));
2615 left_arrow_cursor
= XCreateFontCursor (x_current_display
, XC_sb_left_arrow
);
2616 right_arrow_cursor
= XCreateFontCursor (x_current_display
, XC_sb_right_arrow
);
2617 h_double_arrow_cursor
= XCreateFontCursor (x_current_display
, XC_sb_h_double_arrow
);
2619 f
->display
.x
->h_scrollbar
=
2620 XCreateSimpleWindow (x_current_display
, f
->display
.x
->window_desc
,
2622 width
- ibw
- 2, HSCROLL_HEIGHT
- 2, 1,
2623 f
->display
.x
->foreground_pixel
,
2624 f
->display
.x
->background_pixel
);
2625 XDefineCursor (x_current_display
, f
->display
.x
->h_scrollbar
,
2626 h_double_arrow_cursor
);
2628 f
->display
.x
->h_slider
=
2629 XCreateSimpleWindow (x_current_display
, f
->display
.x
->h_scrollbar
,
2631 HSCROLL_HEIGHT
- 4, HSCROLL_HEIGHT
- 4,
2632 1, f
->display
.x
->foreground_pixel
,
2633 f
->display
.x
->background_pixel
);
2634 XDefineCursor (x_current_display
, f
->display
.x
->h_slider
,
2635 h_double_arrow_cursor
);
2636 XSetWindowBackgroundPixmap (x_current_display
, f
->display
.x
->h_slider
,
2639 f
->display
.x
->h_thumbleft
=
2640 XCreateSimpleWindow (x_current_display
, f
->display
.x
->h_scrollbar
,
2642 HSCROLL_HEIGHT
- 2, HSCROLL_HEIGHT
- 2,
2643 0, f
->display
.x
->foreground_pixel
,
2644 f
->display
.x
->background_pixel
);
2645 XDefineCursor (x_current_display
, f
->display
.x
->h_thumbleft
,
2647 XSetWindowBackgroundPixmap (x_current_display
, f
->display
.x
->h_thumbleft
,
2650 f
->display
.x
->h_thumbright
=
2651 XCreateSimpleWindow (x_current_display
, f
->display
.x
->h_scrollbar
,
2652 width
- ibw
- HSCROLL_HEIGHT
, 0,
2653 HSCROLL_HEIGHT
- 2, HSCROLL_HEIGHT
-2,
2654 0, f
->display
.x
->foreground_pixel
,
2655 f
->display
.x
->background_pixel
);
2656 XDefineCursor (x_current_display
, f
->display
.x
->h_thumbright
,
2657 right_arrow_cursor
);
2658 XSetWindowBackgroundPixmap (x_current_display
, f
->display
.x
->h_thumbright
,
2659 right_arrow_pixmap
);
2661 XFreePixmap (x_current_display
, slider_pixmap
);
2662 XFreePixmap (x_current_display
, left_arrow_pixmap
);
2663 XFreePixmap (x_current_display
, right_arrow_pixmap
);
2665 XSelectInput (x_current_display
, f
->display
.x
->h_scrollbar
,
2666 ButtonPressMask
| ButtonReleaseMask
2667 | PointerMotionMask
| PointerMotionHintMask
2669 XSelectInput (x_current_display
, f
->display
.x
->h_slider
,
2670 ButtonPressMask
| ButtonReleaseMask
);
2671 XSelectInput (x_current_display
, f
->display
.x
->h_thumbright
,
2672 ButtonPressMask
| ButtonReleaseMask
);
2673 XSelectInput (x_current_display
, f
->display
.x
->h_thumbleft
,
2674 ButtonPressMask
| ButtonReleaseMask
);
2676 XMapWindow (x_current_display
, f
->display
.x
->h_scrollbar
);
2677 XMapSubwindows (x_current_display
, f
->display
.x
->h_scrollbar
);
2678 #else /* not HAVE_X11 */
2680 Pixmap fore_tile
, back_tile
, bord_tile
;
2684 #ifndef HAVE_X11 /* X10 */
2685 #define XMoveResizeWindow XConfigureWindow
2686 #endif /* not HAVE_X11 */
2688 /* Adjust the displayed position in the scroll bar for window W. */
2691 adjust_scrollbars (f
)
2695 int first_char_in_window
, char_beyond_window
, chars_in_window
;
2696 int chars_in_buffer
, buffer_size
;
2697 struct window
*w
= XWINDOW (FRAME_SELECTED_WINDOW (f
));
2699 if (! FRAME_IS_X (f
))
2702 if (f
->display
.x
->v_scrollbar
!= 0)
2705 struct buffer
*b
= XBUFFER (w
->buffer
);
2707 buffer_size
= Z
- BEG
;
2708 chars_in_buffer
= ZV
- BEGV
;
2709 first_char_in_window
= marker_position (w
->start
);
2710 char_beyond_window
= buffer_size
+ 1 - XFASTINT (w
->window_end_pos
);
2711 chars_in_window
= char_beyond_window
- first_char_in_window
;
2713 /* Calculate height of scrollbar area */
2715 height
= f
->height
* FONT_HEIGHT (f
->display
.x
->font
)
2716 + f
->display
.x
->internal_border_width
2717 - 2 * (f
->display
.x
->v_scrollbar_width
);
2719 /* Figure starting position for the scrollbar slider */
2721 if (chars_in_buffer
<= 0)
2724 pos
= ((first_char_in_window
- BEGV
- BEG
) * height
2727 pos
= min (pos
, height
- 2);
2729 /* Figure length of the slider */
2731 if (chars_in_buffer
<= 0)
2734 h
= (chars_in_window
* height
) / chars_in_buffer
;
2735 h
= min (h
, height
- pos
);
2738 /* Add thumbup offset to starting position of slider */
2740 pos
+= (f
->display
.x
->v_scrollbar_width
- 2);
2742 XMoveResizeWindow (XDISPLAY
2743 f
->display
.x
->v_slider
,
2745 f
->display
.x
->v_scrollbar_width
- 4, h
);
2748 if (f
->display
.x
->h_scrollbar
!= 0)
2750 int l
, length
; /* Length of the scrollbar area */
2752 length
= f
->width
* FONT_WIDTH (f
->display
.x
->font
)
2753 + f
->display
.x
->internal_border_width
2754 - 2 * (f
->display
.x
->h_scrollbar_height
);
2756 /* Starting position for horizontal slider */
2760 pos
= (w
->hscroll
* length
) / (w
->hscroll
+ f
->width
);
2762 pos
= min (pos
, length
- 2);
2764 /* Length of slider */
2767 /* Add thumbup offset */
2768 pos
+= (f
->display
.x
->h_scrollbar_height
- 2);
2770 XMoveResizeWindow (XDISPLAY
2771 f
->display
.x
->h_slider
,
2773 l
, f
->display
.x
->h_scrollbar_height
- 4);
2777 /* Adjust the size of the scroll bars of frame F,
2778 when the frame size has changed. */
2781 x_resize_scrollbars (f
)
2784 int ibw
= f
->display
.x
->internal_border_width
;
2785 int pixelwidth
, pixelheight
;
2788 || f
->display
.x
== 0
2789 || (f
->display
.x
->v_scrollbar
== 0
2790 && f
->display
.x
->h_scrollbar
== 0))
2793 /* Get the size of the frame. */
2794 pixelwidth
= (f
->width
* FONT_WIDTH (f
->display
.x
->font
)
2795 + 2 * ibw
+ f
->display
.x
->v_scrollbar_width
);
2796 pixelheight
= (f
->height
* FONT_HEIGHT (f
->display
.x
->font
)
2797 + 2 * ibw
+ f
->display
.x
->h_scrollbar_height
);
2799 if (f
->display
.x
->v_scrollbar_width
&& f
->display
.x
->v_scrollbar
)
2802 XMoveResizeWindow (XDISPLAY
2803 f
->display
.x
->v_scrollbar
,
2804 pixelwidth
- f
->display
.x
->v_scrollbar_width
- ibw
/2,
2806 f
->display
.x
->v_scrollbar_width
- 2,
2807 pixelheight
- ibw
- 2);
2808 XMoveWindow (XDISPLAY
2809 f
->display
.x
->v_thumbdown
, 0,
2810 pixelheight
- ibw
- f
->display
.x
->v_scrollbar_width
);
2814 if (f
->display
.x
->h_scrollbar_height
&& f
->display
.x
->h_scrollbar
)
2816 if (f
->display
.x
->v_scrollbar_width
)
2817 pixelwidth
-= f
->display
.x
->v_scrollbar_width
+ 1;
2820 XMoveResizeWindow (XDISPLAY
2821 f
->display
.x
->h_scrollbar
,
2823 pixelheight
- f
->display
.x
->h_scrollbar_height
- ibw
/ 2,
2824 pixelwidth
- ibw
- 2,
2825 f
->display
.x
->h_scrollbar_height
- 2);
2826 XMoveWindow (XDISPLAY
2827 f
->display
.x
->h_thumbright
,
2828 pixelwidth
- ibw
- f
->display
.x
->h_scrollbar_height
, 0);
2834 register struct frame
*f
;
2836 return PIXEL_WIDTH (f
);
2840 register struct frame
*f
;
2842 return PIXEL_HEIGHT (f
);
2845 DEFUN ("x-defined-color", Fx_defined_color
, Sx_defined_color
, 1, 1, 0,
2846 "Return t if the current X display supports the color named COLOR.")
2852 CHECK_STRING (color
, 0);
2854 if (defined_color (XSTRING (color
)->data
, &foo
))
2860 DEFUN ("x-color-display-p", Fx_color_display_p
, Sx_color_display_p
, 0, 0, 0,
2861 "Return t if the X display used currently supports color.")
2864 if (XINT (x_screen_planes
) <= 2)
2867 switch (screen_visual
->class)
2880 DEFUN ("x-pixel-width", Fx_pixel_width
, Sx_pixel_width
, 1, 1, 0,
2881 "Return the width in pixels of FRAME.")
2885 CHECK_LIVE_FRAME (frame
, 0);
2886 return make_number (XFRAME (frame
)->display
.x
->pixel_width
);
2889 DEFUN ("x-pixel-height", Fx_pixel_height
, Sx_pixel_height
, 1, 1, 0,
2890 "Return the height in pixels of FRAME.")
2894 CHECK_LIVE_FRAME (frame
, 0);
2895 return make_number (XFRAME (frame
)->display
.x
->pixel_height
);
2898 #if 0 /* These no longer seem like the right way to do things. */
2900 /* Draw a rectangle on the frame with left top corner including
2901 the character specified by LEFT_CHAR and TOP_CHAR. The rectangle is
2902 CHARS by LINES wide and long and is the color of the cursor. */
2905 x_rectangle (f
, gc
, left_char
, top_char
, chars
, lines
)
2906 register struct frame
*f
;
2908 register int top_char
, left_char
, chars
, lines
;
2912 int left
= (left_char
* FONT_WIDTH (f
->display
.x
->font
)
2913 + f
->display
.x
->internal_border_width
);
2914 int top
= (top_char
* FONT_HEIGHT (f
->display
.x
->font
)
2915 + f
->display
.x
->internal_border_width
);
2918 width
= FONT_WIDTH (f
->display
.x
->font
) / 2;
2920 width
= FONT_WIDTH (f
->display
.x
->font
) * chars
;
2922 height
= FONT_HEIGHT (f
->display
.x
->font
) / 2;
2924 height
= FONT_HEIGHT (f
->display
.x
->font
) * lines
;
2926 XDrawRectangle (x_current_display
, f
->display
.x
->window_desc
,
2927 gc
, left
, top
, width
, height
);
2930 DEFUN ("x-draw-rectangle", Fx_draw_rectangle
, Sx_draw_rectangle
, 5, 5, 0,
2931 "Draw a rectangle on FRAME between coordinates specified by\n\
2932 numbers X0, Y0, X1, Y1 in the cursor pixel.")
2933 (frame
, X0
, Y0
, X1
, Y1
)
2934 register Lisp_Object frame
, X0
, X1
, Y0
, Y1
;
2936 register int x0
, y0
, x1
, y1
, top
, left
, n_chars
, n_lines
;
2938 CHECK_LIVE_FRAME (frame
, 0);
2939 CHECK_NUMBER (X0
, 0);
2940 CHECK_NUMBER (Y0
, 1);
2941 CHECK_NUMBER (X1
, 2);
2942 CHECK_NUMBER (Y1
, 3);
2952 n_lines
= y1
- y0
+ 1;
2957 n_lines
= y0
- y1
+ 1;
2963 n_chars
= x1
- x0
+ 1;
2968 n_chars
= x0
- x1
+ 1;
2972 x_rectangle (XFRAME (frame
), XFRAME (frame
)->display
.x
->cursor_gc
,
2973 left
, top
, n_chars
, n_lines
);
2979 DEFUN ("x-erase-rectangle", Fx_erase_rectangle
, Sx_erase_rectangle
, 5, 5, 0,
2980 "Draw a rectangle drawn on FRAME between coordinates\n\
2981 X0, Y0, X1, Y1 in the regular background-pixel.")
2982 (frame
, X0
, Y0
, X1
, Y1
)
2983 register Lisp_Object frame
, X0
, Y0
, X1
, Y1
;
2985 register int x0
, y0
, x1
, y1
, top
, left
, n_chars
, n_lines
;
2987 CHECK_FRAME (frame
, 0);
2988 CHECK_NUMBER (X0
, 0);
2989 CHECK_NUMBER (Y0
, 1);
2990 CHECK_NUMBER (X1
, 2);
2991 CHECK_NUMBER (Y1
, 3);
3001 n_lines
= y1
- y0
+ 1;
3006 n_lines
= y0
- y1
+ 1;
3012 n_chars
= x1
- x0
+ 1;
3017 n_chars
= x0
- x1
+ 1;
3021 x_rectangle (XFRAME (frame
), XFRAME (frame
)->display
.x
->reverse_gc
,
3022 left
, top
, n_chars
, n_lines
);
3028 /* Draw lines around the text region beginning at the character position
3029 TOP_X, TOP_Y and ending at BOTTOM_X and BOTTOM_Y. GC specifies the
3030 pixel and line characteristics. */
3032 #define line_len(line) (FRAME_CURRENT_GLYPHS (f)->used[(line)])
3035 outline_region (f
, gc
, top_x
, top_y
, bottom_x
, bottom_y
)
3036 register struct frame
*f
;
3038 int top_x
, top_y
, bottom_x
, bottom_y
;
3040 register int ibw
= f
->display
.x
->internal_border_width
;
3041 register int font_w
= FONT_WIDTH (f
->display
.x
->font
);
3042 register int font_h
= FONT_HEIGHT (f
->display
.x
->font
);
3044 int x
= line_len (y
);
3045 XPoint
*pixel_points
= (XPoint
*)
3046 alloca (((bottom_y
- top_y
+ 2) * 4) * sizeof (XPoint
));
3047 register XPoint
*this_point
= pixel_points
;
3049 /* Do the horizontal top line/lines */
3052 this_point
->x
= ibw
;
3053 this_point
->y
= ibw
+ (font_h
* top_y
);
3056 this_point
->x
= ibw
+ (font_w
/ 2); /* Half-size for newline chars. */
3058 this_point
->x
= ibw
+ (font_w
* x
);
3059 this_point
->y
= (this_point
- 1)->y
;
3063 this_point
->x
= ibw
;
3064 this_point
->y
= ibw
+ (font_h
* (top_y
+ 1));
3066 this_point
->x
= ibw
+ (font_w
* top_x
);
3067 this_point
->y
= (this_point
- 1)->y
;
3069 this_point
->x
= (this_point
- 1)->x
;
3070 this_point
->y
= ibw
+ (font_h
* top_y
);
3072 this_point
->x
= ibw
+ (font_w
* x
);
3073 this_point
->y
= (this_point
- 1)->y
;
3076 /* Now do the right side. */
3077 while (y
< bottom_y
)
3078 { /* Right vertical edge */
3080 this_point
->x
= (this_point
- 1)->x
;
3081 this_point
->y
= ibw
+ (font_h
* (y
+ 1));
3084 y
++; /* Horizontal connection to next line */
3087 this_point
->x
= ibw
+ (font_w
/ 2);
3089 this_point
->x
= ibw
+ (font_w
* x
);
3091 this_point
->y
= (this_point
- 1)->y
;
3094 /* Now do the bottom and connect to the top left point. */
3095 this_point
->x
= ibw
+ (font_w
* (bottom_x
+ 1));
3098 this_point
->x
= (this_point
- 1)->x
;
3099 this_point
->y
= ibw
+ (font_h
* (bottom_y
+ 1));
3101 this_point
->x
= ibw
;
3102 this_point
->y
= (this_point
- 1)->y
;
3104 this_point
->x
= pixel_points
->x
;
3105 this_point
->y
= pixel_points
->y
;
3107 XDrawLines (x_current_display
, f
->display
.x
->window_desc
,
3109 (this_point
- pixel_points
+ 1), CoordModeOrigin
);
3112 DEFUN ("x-contour-region", Fx_contour_region
, Sx_contour_region
, 1, 1, 0,
3113 "Highlight the region between point and the character under the mouse\n\
3116 register Lisp_Object event
;
3118 register int x0
, y0
, x1
, y1
;
3119 register struct frame
*f
= selected_frame
;
3120 register int p1
, p2
;
3122 CHECK_CONS (event
, 0);
3125 x0
= XINT (Fcar (Fcar (event
)));
3126 y0
= XINT (Fcar (Fcdr (Fcar (event
))));
3128 /* If the mouse is past the end of the line, don't that area. */
3129 /* ReWrite this... */
3134 if (y1
> y0
) /* point below mouse */
3135 outline_region (f
, f
->display
.x
->cursor_gc
,
3137 else if (y1
< y0
) /* point above mouse */
3138 outline_region (f
, f
->display
.x
->cursor_gc
,
3140 else /* same line: draw horizontal rectangle */
3143 x_rectangle (f
, f
->display
.x
->cursor_gc
,
3144 x0
, y0
, (x1
- x0
+ 1), 1);
3146 x_rectangle (f
, f
->display
.x
->cursor_gc
,
3147 x1
, y1
, (x0
- x1
+ 1), 1);
3150 XFlush (x_current_display
);
3156 DEFUN ("x-uncontour-region", Fx_uncontour_region
, Sx_uncontour_region
, 1, 1, 0,
3157 "Erase any highlighting of the region between point and the character\n\
3158 at X, Y on the selected frame.")
3160 register Lisp_Object event
;
3162 register int x0
, y0
, x1
, y1
;
3163 register struct frame
*f
= selected_frame
;
3166 x0
= XINT (Fcar (Fcar (event
)));
3167 y0
= XINT (Fcar (Fcdr (Fcar (event
))));
3171 if (y1
> y0
) /* point below mouse */
3172 outline_region (f
, f
->display
.x
->reverse_gc
,
3174 else if (y1
< y0
) /* point above mouse */
3175 outline_region (f
, f
->display
.x
->reverse_gc
,
3177 else /* same line: draw horizontal rectangle */
3180 x_rectangle (f
, f
->display
.x
->reverse_gc
,
3181 x0
, y0
, (x1
- x0
+ 1), 1);
3183 x_rectangle (f
, f
->display
.x
->reverse_gc
,
3184 x1
, y1
, (x0
- x1
+ 1), 1);
3192 int contour_begin_x
, contour_begin_y
;
3193 int contour_end_x
, contour_end_y
;
3194 int contour_npoints
;
3196 /* Clip the top part of the contour lines down (and including) line Y_POS.
3197 If X_POS is in the middle (rather than at the end) of the line, drop
3198 down a line at that character. */
3201 clip_contour_top (y_pos
, x_pos
)
3203 register XPoint
*begin
= contour_lines
[y_pos
].top_left
;
3204 register XPoint
*end
;
3205 register int npoints
;
3206 register struct display_line
*line
= selected_frame
->phys_lines
[y_pos
+ 1];
3208 if (x_pos
>= line
->len
- 1) /* Draw one, straight horizontal line. */
3210 end
= contour_lines
[y_pos
].top_right
;
3211 npoints
= (end
- begin
+ 1);
3212 XDrawLines (x_current_display
, contour_window
,
3213 contour_erase_gc
, begin_erase
, npoints
, CoordModeOrigin
);
3215 bcopy (end
, begin
+ 1, contour_last_point
- end
+ 1);
3216 contour_last_point
-= (npoints
- 2);
3217 XDrawLines (x_current_display
, contour_window
,
3218 contour_erase_gc
, begin
, 2, CoordModeOrigin
);
3219 XFlush (x_current_display
);
3221 /* Now, update contour_lines structure. */
3226 register XPoint
*p
= begin
+ 1;
3227 end
= contour_lines
[y_pos
].bottom_right
;
3228 npoints
= (end
- begin
+ 1);
3229 XDrawLines (x_current_display
, contour_window
,
3230 contour_erase_gc
, begin_erase
, npoints
, CoordModeOrigin
);
3233 p
->x
= ibw
+ (font_w
* (x_pos
+ 1));
3235 p
->y
= begin
->y
+ font_h
;
3237 bcopy (end
, begin
+ 3, contour_last_point
- end
+ 1);
3238 contour_last_point
-= (npoints
- 5);
3239 XDrawLines (x_current_display
, contour_window
,
3240 contour_erase_gc
, begin
, 4, CoordModeOrigin
);
3241 XFlush (x_current_display
);
3243 /* Now, update contour_lines structure. */
3247 /* Erase the top horzontal lines of the contour, and then extend
3248 the contour upwards. */
3251 extend_contour_top (line
)
3256 clip_contour_bottom (x_pos
, y_pos
)
3262 extend_contour_bottom (x_pos
, y_pos
)
3266 DEFUN ("x-select-region", Fx_select_region
, Sx_select_region
, 1, 1, "e",
3271 register struct frame
*f
= selected_frame
;
3272 register int point_x
= f
->cursor_x
;
3273 register int point_y
= f
->cursor_y
;
3274 register int mouse_below_point
;
3275 register Lisp_Object obj
;
3276 register int x_contour_x
, x_contour_y
;
3278 x_contour_x
= x_mouse_x
;
3279 x_contour_y
= x_mouse_y
;
3280 if (x_contour_y
> point_y
|| (x_contour_y
== point_y
3281 && x_contour_x
> point_x
))
3283 mouse_below_point
= 1;
3284 outline_region (f
, f
->display
.x
->cursor_gc
, point_x
, point_y
,
3285 x_contour_x
, x_contour_y
);
3289 mouse_below_point
= 0;
3290 outline_region (f
, f
->display
.x
->cursor_gc
, x_contour_x
, x_contour_y
,
3296 obj
= read_char (-1);
3297 if (XTYPE (obj
) != Lisp_Cons
)
3300 if (mouse_below_point
)
3302 if (x_mouse_y
<= point_y
) /* Flipped. */
3304 mouse_below_point
= 0;
3306 outline_region (f
, f
->display
.x
->reverse_gc
, point_x
, point_y
,
3307 x_contour_x
, x_contour_y
);
3308 outline_region (f
, f
->display
.x
->cursor_gc
, x_mouse_x
, x_mouse_y
,
3311 else if (x_mouse_y
< x_contour_y
) /* Bottom clipped. */
3313 clip_contour_bottom (x_mouse_y
);
3315 else if (x_mouse_y
> x_contour_y
) /* Bottom extended. */
3317 extend_bottom_contour (x_mouse_y
);
3320 x_contour_x
= x_mouse_x
;
3321 x_contour_y
= x_mouse_y
;
3323 else /* mouse above or same line as point */
3325 if (x_mouse_y
>= point_y
) /* Flipped. */
3327 mouse_below_point
= 1;
3329 outline_region (f
, f
->display
.x
->reverse_gc
,
3330 x_contour_x
, x_contour_y
, point_x
, point_y
);
3331 outline_region (f
, f
->display
.x
->cursor_gc
, point_x
, point_y
,
3332 x_mouse_x
, x_mouse_y
);
3334 else if (x_mouse_y
> x_contour_y
) /* Top clipped. */
3336 clip_contour_top (x_mouse_y
);
3338 else if (x_mouse_y
< x_contour_y
) /* Top extended. */
3340 extend_contour_top (x_mouse_y
);
3345 unread_command_char
= obj
;
3346 if (mouse_below_point
)
3348 contour_begin_x
= point_x
;
3349 contour_begin_y
= point_y
;
3350 contour_end_x
= x_contour_x
;
3351 contour_end_y
= x_contour_y
;
3355 contour_begin_x
= x_contour_x
;
3356 contour_begin_y
= x_contour_y
;
3357 contour_end_x
= point_x
;
3358 contour_end_y
= point_y
;
3363 DEFUN ("x-horizontal-line", Fx_horizontal_line
, Sx_horizontal_line
, 1, 1, "e",
3368 register Lisp_Object obj
;
3369 struct frame
*f
= selected_frame
;
3370 register struct window
*w
= XWINDOW (selected_window
);
3371 register GC line_gc
= f
->display
.x
->cursor_gc
;
3372 register GC erase_gc
= f
->display
.x
->reverse_gc
;
3374 char dash_list
[] = {6, 4, 6, 4};
3376 XGCValues gc_values
;
3378 register int previous_y
;
3379 register int line
= (x_mouse_y
+ 1) * FONT_HEIGHT (f
->display
.x
->font
)
3380 + f
->display
.x
->internal_border_width
;
3381 register int left
= f
->display
.x
->internal_border_width
3383 * FONT_WIDTH (f
->display
.x
->font
));
3384 register int right
= left
+ (w
->width
3385 * FONT_WIDTH (f
->display
.x
->font
))
3386 - f
->display
.x
->internal_border_width
;
3390 gc_values
.foreground
= f
->display
.x
->cursor_pixel
;
3391 gc_values
.background
= f
->display
.x
->background_pixel
;
3392 gc_values
.line_width
= 1;
3393 gc_values
.line_style
= LineOnOffDash
;
3394 gc_values
.cap_style
= CapRound
;
3395 gc_values
.join_style
= JoinRound
;
3397 line_gc
= XCreateGC (x_current_display
, f
->display
.x
->window_desc
,
3398 GCLineStyle
| GCJoinStyle
| GCCapStyle
3399 | GCLineWidth
| GCForeground
| GCBackground
,
3401 XSetDashes (x_current_display
, line_gc
, 0, dash_list
, dashes
);
3402 gc_values
.foreground
= f
->display
.x
->background_pixel
;
3403 gc_values
.background
= f
->display
.x
->foreground_pixel
;
3404 erase_gc
= XCreateGC (x_current_display
, f
->display
.x
->window_desc
,
3405 GCLineStyle
| GCJoinStyle
| GCCapStyle
3406 | GCLineWidth
| GCForeground
| GCBackground
,
3408 XSetDashes (x_current_display
, erase_gc
, 0, dash_list
, dashes
);
3414 if (x_mouse_y
>= XINT (w
->top
)
3415 && x_mouse_y
< XINT (w
->top
) + XINT (w
->height
) - 1)
3417 previous_y
= x_mouse_y
;
3418 line
= (x_mouse_y
+ 1) * FONT_HEIGHT (f
->display
.x
->font
)
3419 + f
->display
.x
->internal_border_width
;
3420 XDrawLine (x_current_display
, f
->display
.x
->window_desc
,
3421 line_gc
, left
, line
, right
, line
);
3428 obj
= read_char (-1);
3429 if ((XTYPE (obj
) != Lisp_Cons
)
3430 || (! EQ (Fcar (Fcdr (Fcdr (obj
))),
3431 intern ("vertical-scroll-bar")))
3435 XDrawLine (x_current_display
, f
->display
.x
->window_desc
,
3436 erase_gc
, left
, line
, right
, line
);
3438 unread_command_char
= obj
;
3440 XFreeGC (x_current_display
, line_gc
);
3441 XFreeGC (x_current_display
, erase_gc
);
3446 while (x_mouse_y
== previous_y
);
3449 XDrawLine (x_current_display
, f
->display
.x
->window_desc
,
3450 erase_gc
, left
, line
, right
, line
);
3456 /* Offset in buffer of character under the pointer, or 0. */
3457 int mouse_buffer_offset
;
3460 /* These keep track of the rectangle following the pointer. */
3461 int mouse_track_top
, mouse_track_left
, mouse_track_width
;
3463 DEFUN ("x-track-pointer", Fx_track_pointer
, Sx_track_pointer
, 0, 0, 0,
3464 "Track the pointer.")
3467 static Cursor current_pointer_shape
;
3468 FRAME_PTR f
= x_mouse_frame
;
3471 if (EQ (Vmouse_frame_part
, Qtext_part
)
3472 && (current_pointer_shape
!= f
->display
.x
->nontext_cursor
))
3477 current_pointer_shape
= f
->display
.x
->nontext_cursor
;
3478 XDefineCursor (x_current_display
,
3479 f
->display
.x
->window_desc
,
3480 current_pointer_shape
);
3482 buf
= XBUFFER (XWINDOW (Vmouse_window
)->buffer
);
3483 c
= *(BUF_CHAR_ADDRESS (buf
, mouse_buffer_offset
));
3485 else if (EQ (Vmouse_frame_part
, Qmodeline_part
)
3486 && (current_pointer_shape
!= f
->display
.x
->modeline_cursor
))
3488 current_pointer_shape
= f
->display
.x
->modeline_cursor
;
3489 XDefineCursor (x_current_display
,
3490 f
->display
.x
->window_desc
,
3491 current_pointer_shape
);
3500 DEFUN ("x-track-pointer", Fx_track_pointer
, Sx_track_pointer
, 1, 1, "e",
3501 "Draw rectangle around character under mouse pointer, if there is one.")
3505 struct window
*w
= XWINDOW (Vmouse_window
);
3506 struct frame
*f
= XFRAME (WINDOW_FRAME (w
));
3507 struct buffer
*b
= XBUFFER (w
->buffer
);
3510 if (! EQ (Vmouse_window
, selected_window
))
3513 if (EQ (event
, Qnil
))
3517 x_read_mouse_position (selected_frame
, &x
, &y
);
3521 mouse_track_width
= 0;
3522 mouse_track_left
= mouse_track_top
= -1;
3526 if ((x_mouse_x
!= mouse_track_left
3527 && (x_mouse_x
< mouse_track_left
3528 || x_mouse_x
> (mouse_track_left
+ mouse_track_width
)))
3529 || x_mouse_y
!= mouse_track_top
)
3531 int hp
= 0; /* Horizontal position */
3532 int len
= FRAME_CURRENT_GLYPHS (f
)->used
[x_mouse_y
];
3533 int p
= FRAME_CURRENT_GLYPHS (f
)->bufp
[x_mouse_y
];
3534 int tab_width
= XINT (b
->tab_width
);
3535 int ctl_arrow_p
= !NILP (b
->ctl_arrow
);
3537 int mode_line_vpos
= XFASTINT (w
->height
) + XFASTINT (w
->top
) - 1;
3538 int in_mode_line
= 0;
3540 if (! FRAME_CURRENT_GLYPHS (f
)->enable
[x_mouse_y
])
3543 /* Erase previous rectangle. */
3544 if (mouse_track_width
)
3546 x_rectangle (f
, f
->display
.x
->reverse_gc
,
3547 mouse_track_left
, mouse_track_top
,
3548 mouse_track_width
, 1);
3550 if ((mouse_track_left
== f
->phys_cursor_x
3551 || mouse_track_left
== f
->phys_cursor_x
- 1)
3552 && mouse_track_top
== f
->phys_cursor_y
)
3554 x_display_cursor (f
, 1);
3558 mouse_track_left
= x_mouse_x
;
3559 mouse_track_top
= x_mouse_y
;
3560 mouse_track_width
= 0;
3562 if (mouse_track_left
> len
) /* Past the end of line. */
3565 if (mouse_track_top
== mode_line_vpos
)
3571 if (tab_width
<= 0 || tab_width
> 20) tab_width
= 8;
3575 if (len
== f
->width
&& hp
== len
- 1 && c
!= '\n')
3581 mouse_track_width
= tab_width
- (hp
% tab_width
);
3583 hp
+= mouse_track_width
;
3586 mouse_track_left
= hp
- mouse_track_width
;
3592 mouse_track_width
= -1;
3596 if (ctl_arrow_p
&& (c
< 040 || c
== 0177))
3601 mouse_track_width
= 2;
3606 mouse_track_left
= hp
- mouse_track_width
;
3612 mouse_track_width
= 1;
3619 while (hp
<= x_mouse_x
);
3622 if (mouse_track_width
) /* Over text; use text pointer shape. */
3624 XDefineCursor (x_current_display
,
3625 f
->display
.x
->window_desc
,
3626 f
->display
.x
->text_cursor
);
3627 x_rectangle (f
, f
->display
.x
->cursor_gc
,
3628 mouse_track_left
, mouse_track_top
,
3629 mouse_track_width
, 1);
3631 else if (in_mode_line
)
3632 XDefineCursor (x_current_display
,
3633 f
->display
.x
->window_desc
,
3634 f
->display
.x
->modeline_cursor
);
3636 XDefineCursor (x_current_display
,
3637 f
->display
.x
->window_desc
,
3638 f
->display
.x
->nontext_cursor
);
3641 XFlush (x_current_display
);
3644 obj
= read_char (-1);
3647 while (XTYPE (obj
) == Lisp_Cons
/* Mouse event */
3648 && EQ (Fcar (Fcdr (Fcdr (obj
))), Qnil
) /* Not scrollbar */
3649 && EQ (Vmouse_depressed
, Qnil
) /* Only motion events */
3650 && EQ (Vmouse_window
, selected_window
) /* In this window */
3653 unread_command_char
= obj
;
3655 if (mouse_track_width
)
3657 x_rectangle (f
, f
->display
.x
->reverse_gc
,
3658 mouse_track_left
, mouse_track_top
,
3659 mouse_track_width
, 1);
3660 mouse_track_width
= 0;
3661 if ((mouse_track_left
== f
->phys_cursor_x
3662 || mouse_track_left
- 1 == f
->phys_cursor_x
)
3663 && mouse_track_top
== f
->phys_cursor_y
)
3665 x_display_cursor (f
, 1);
3668 XDefineCursor (x_current_display
,
3669 f
->display
.x
->window_desc
,
3670 f
->display
.x
->nontext_cursor
);
3671 XFlush (x_current_display
);
3681 /* Draw a pixmap specified by IMAGE_DATA of dimensions WIDTH and HEIGHT
3682 on the frame F at position X, Y. */
3684 x_draw_pixmap (f
, x
, y
, image_data
, width
, height
)
3686 int x
, y
, width
, height
;
3691 image
= XCreateBitmapFromData (x_current_display
,
3692 f
->display
.x
->window_desc
, image_data
,
3694 XCopyPlane (x_current_display
, image
, f
->display
.x
->window_desc
,
3695 f
->display
.x
->normal_gc
, 0, 0, width
, height
, x
, y
);
3702 #define XMouseEvent XEvent
3703 #define WhichMouseButton xbutton.button
3704 #define MouseWindow xbutton.window
3705 #define MouseX xbutton.x
3706 #define MouseY xbutton.y
3707 #define MouseTime xbutton.time
3708 #define ButtonReleased ButtonRelease
3709 #define ButtonPressed ButtonPress
3711 #define XMouseEvent XButtonEvent
3712 #define WhichMouseButton detail
3713 #define MouseWindow window
3716 #define MouseTime time
3719 DEFUN ("x-mouse-events", Fx_mouse_events
, Sx_mouse_events
, 0, 0, 0,
3720 "Return number of pending mouse events from X window system.")
3723 return make_number (queue_event_count (&x_mouse_queue
));
3726 /* Encode the mouse button events in the form expected by the
3727 mouse code in Lisp. For X11, this means moving the masks around. */
3730 encode_mouse_button (mouse_event
)
3731 XMouseEvent mouse_event
;
3733 register int event_code
;
3734 register char key_mask
;
3736 event_code
= mouse_event
.detail
& 3;
3737 key_mask
= (mouse_event
.detail
>> 8) & 0xf0;
3738 event_code
|= key_mask
>> 1;
3739 if (mouse_event
.type
== ButtonReleased
) event_code
|= 0x04;
3743 DEFUN ("x-get-mouse-event", Fx_get_mouse_event
, Sx_get_mouse_event
,
3745 "Get next mouse event out of mouse event buffer.\n\
3746 Optional ARG non-nil means return nil immediately if no pending event;\n\
3747 otherwise, wait for an event. Returns a four-part list:\n\
3748 ((X-POS Y-POS) WINDOW FRAME-PART KEYSEQ TIMESTAMP).\n\
3749 Normally X-POS and Y-POS are the position of the click on the frame\n\
3750 (measured in characters and lines), and WINDOW is the window clicked in.\n\
3751 KEYSEQ is a string, the key sequence to be looked up in the mouse maps.\n\
3752 If FRAME-PART is non-nil, the event was on a scrollbar;\n\
3753 then Y-POS is really the total length of the scrollbar, while X-POS is\n\
3754 the relative position of the scrollbar's value within that total length,\n\
3755 and a third element OFFSET appears in that list: the height of the thumb-up\n\
3756 area at the top of the scroll bar.\n\
3757 FRAME-PART is one of the following symbols:\n\
3758 `vertical-scrollbar', `vertical-thumbup', `vertical-thumbdown',\n\
3759 `horizontal-scrollbar', `horizontal-thumbleft', `horizontal-thumbright'.\n\
3760 TIMESTAMP is the lower 23 bits of the X-server's timestamp for\n\
3766 register int com_letter
;
3767 register Lisp_Object tempx
;
3768 register Lisp_Object tempy
;
3769 Lisp_Object part
, pos
, timestamp
;
3778 tem
= dequeue_event (&xrep
, &x_mouse_queue
);
3786 case ButtonReleased
:
3788 com_letter
= encode_mouse_button (xrep
);
3789 mouse_timestamp
= xrep
.MouseTime
;
3791 if ((f
= x_window_to_frame (xrep
.MouseWindow
)) != 0)
3795 if (f
->display
.x
->icon_desc
== xrep
.MouseWindow
)
3797 x_make_frame_visible (f
);
3801 XSET (tempx
, Lisp_Int
,
3802 min (f
->width
-1, max (0, (xrep
.MouseX
- f
->display
.x
->internal_border_width
)/FONT_WIDTH (f
->display
.x
->font
))));
3803 XSET (tempy
, Lisp_Int
,
3804 min (f
->height
-1, max (0, (xrep
.MouseY
- f
->display
.x
->internal_border_width
)/FONT_HEIGHT (f
->display
.x
->font
))));
3805 XSET (timestamp
, Lisp_Int
, (xrep
.MouseTime
& 0x7fffff));
3806 XSET (frame
, Lisp_Frame
, f
);
3808 pos
= Fcons (tempx
, Fcons (tempy
, Qnil
));
3810 = Flocate_window_from_coordinates (frame
, pos
);
3814 Fcons (Vmouse_window
,
3816 Fcons (Fchar_to_string (make_number (com_letter
)),
3817 Fcons (timestamp
, Qnil
)))));
3818 return Vmouse_event
;
3820 else if ((f
= x_window_to_scrollbar (xrep
.MouseWindow
, &part
, &prefix
)) != 0)
3826 keyseq
= concat2 (Fchar_to_string (make_number (prefix
)),
3827 Fchar_to_string (make_number (com_letter
)));
3829 pos
= xrep
.MouseY
- (f
->display
.x
->v_scrollbar_width
- 2);
3830 XSET (tempx
, Lisp_Int
, pos
);
3831 len
= ((FONT_HEIGHT (f
->display
.x
->font
) * f
->height
)
3832 + f
->display
.x
->internal_border_width
3833 - (2 * (f
->display
.x
->v_scrollbar_width
- 2)));
3834 XSET (tempy
, Lisp_Int
, len
);
3835 XSET (timestamp
, Lisp_Int
, (xrep
.MouseTime
& 0x7fffff));
3836 Vmouse_window
= f
->selected_window
;
3838 = Fcons (Fcons (tempx
, Fcons (tempy
,
3839 Fcons (make_number (f
->display
.x
->v_scrollbar_width
- 2),
3841 Fcons (Vmouse_window
,
3842 Fcons (intern (part
),
3843 Fcons (keyseq
, Fcons (timestamp
,
3845 return Vmouse_event
;
3853 com_letter
= x11_encode_mouse_button (xrep
);
3854 if ((f
= x_window_to_frame (xrep
.MouseWindow
)) != 0)
3858 XSET (tempx
, Lisp_Int
,
3860 max (0, (xrep
.MouseX
- f
->display
.x
->internal_border_width
)
3861 / FONT_WIDTH (f
->display
.x
->font
))));
3862 XSET (tempy
, Lisp_Int
,
3864 max (0, (xrep
.MouseY
- f
->display
.x
->internal_border_width
)
3865 / FONT_HEIGHT (f
->display
.x
->font
))));
3867 XSET (frame
, Lisp_Frame
, f
);
3868 XSET (timestamp
, Lisp_Int
, (xrep
.MouseTime
& 0x7fffff));
3870 pos
= Fcons (tempx
, Fcons (tempy
, Qnil
));
3872 = Flocate_window_from_coordinates (frame
, pos
);
3876 Fcons (Vmouse_window
,
3878 Fcons (Fchar_to_string (make_number (com_letter
)),
3879 Fcons (timestamp
, Qnil
)))));
3880 return Vmouse_event
;
3884 #endif /* HAVE_X11 */
3887 if (f
= x_window_to_frame (xrep
.MouseWindow
))
3888 Vmouse_window
= f
->selected_window
;
3889 else if (f
= x_window_to_scrollbar (xrep
.MouseWindow
, &part
, &prefix
))
3890 Vmouse_window
= f
->selected_window
;
3891 return Vmouse_event
= Qnil
;
3898 /* Wait till we get another mouse event. */
3899 wait_reading_process_input (0, 0, 2, 0);
3906 DEFUN ("x-store-cut-buffer", Fx_store_cut_buffer
, Sx_store_cut_buffer
,
3907 1, 1, "sStore text in cut buffer: ",
3908 "Store contents of STRING into the cut buffer of the X window system.")
3910 register Lisp_Object string
;
3914 CHECK_STRING (string
, 1);
3915 if (! FRAME_IS_X (selected_frame
))
3916 error ("Selected frame does not understand X protocol.");
3919 XStoreBytes ((char *) XSTRING (string
)->data
, XSTRING (string
)->size
);
3925 DEFUN ("x-get-cut-buffer", Fx_get_cut_buffer
, Sx_get_cut_buffer
, 0, 0, 0,
3926 "Return contents of cut buffer of the X window system, as a string.")
3930 register Lisp_Object string
;
3935 d
= XFetchBytes (&len
);
3936 string
= make_string (d
, len
);
3944 DEFUN ("x-rebind-key", Fx_rebind_key
, Sx_rebind_key
, 3, 3, 0,
3945 "Rebind X keysym KEYSYM, with MODIFIERS, to generate NEWSTRING.\n\
3946 KEYSYM is a string which conforms to the X keysym definitions found\n\
3947 in X11/keysymdef.h, sans the initial XK_. MODIFIERS is nil or a\n\
3948 list of strings specifying modifier keys such as Control_L, which must\n\
3949 also be depressed for NEWSTRING to appear.")
3950 (x_keysym
, modifiers
, newstring
)
3951 register Lisp_Object x_keysym
;
3952 register Lisp_Object modifiers
;
3953 register Lisp_Object newstring
;
3956 register KeySym keysym
;
3957 KeySym modifier_list
[16];
3959 CHECK_STRING (x_keysym
, 1);
3960 CHECK_STRING (newstring
, 3);
3962 keysym
= XStringToKeysym ((char *) XSTRING (x_keysym
)->data
);
3963 if (keysym
== NoSymbol
)
3964 error ("Keysym does not exist");
3966 if (NILP (modifiers
))
3967 XRebindKeysym (x_current_display
, keysym
, modifier_list
, 0,
3968 XSTRING (newstring
)->data
, XSTRING (newstring
)->size
);
3971 register Lisp_Object rest
, mod
;
3974 for (rest
= modifiers
; !NILP (rest
); rest
= Fcdr (rest
))
3977 error ("Can't have more than 16 modifiers");
3980 CHECK_STRING (mod
, 3);
3981 modifier_list
[i
] = XStringToKeysym ((char *) XSTRING (mod
)->data
);
3982 if (modifier_list
[i
] == NoSymbol
3983 || !IsModifierKey (modifier_list
[i
]))
3984 error ("Element is not a modifier keysym");
3988 XRebindKeysym (x_current_display
, keysym
, modifier_list
, i
,
3989 XSTRING (newstring
)->data
, XSTRING (newstring
)->size
);
3995 DEFUN ("x-rebind-keys", Fx_rebind_keys
, Sx_rebind_keys
, 2, 2, 0,
3996 "Rebind KEYCODE to list of strings STRINGS.\n\
3997 STRINGS should be a list of 16 elements, one for each shift combination.\n\
3998 nil as element means don't change.\n\
3999 See the documentation of `x-rebind-key' for more information.")
4001 register Lisp_Object keycode
;
4002 register Lisp_Object strings
;
4004 register Lisp_Object item
;
4005 register unsigned char *rawstring
;
4006 KeySym rawkey
, modifier
[1];
4008 register unsigned i
;
4010 CHECK_NUMBER (keycode
, 1);
4011 CHECK_CONS (strings
, 2);
4012 rawkey
= (KeySym
) ((unsigned) (XINT (keycode
))) & 255;
4013 for (i
= 0; i
<= 15; strings
= Fcdr (strings
), i
++)
4015 item
= Fcar (strings
);
4018 CHECK_STRING (item
, 2);
4019 strsize
= XSTRING (item
)->size
;
4020 rawstring
= (unsigned char *) xmalloc (strsize
);
4021 bcopy (XSTRING (item
)->data
, rawstring
, strsize
);
4022 modifier
[1] = 1 << i
;
4023 XRebindKeysym (x_current_display
, rawkey
, modifier
, 1,
4024 rawstring
, strsize
);
4030 DEFUN ("x-rebind-key", Fx_rebind_key
, Sx_rebind_key
, 3, 3, 0,
4031 "Rebind KEYCODE, with shift bits SHIFT-MASK, to new string NEWSTRING.\n\
4032 KEYCODE and SHIFT-MASK should be numbers representing the X keyboard code\n\
4033 and shift mask respectively. NEWSTRING is an arbitrary string of keystrokes.\n\
4034 If SHIFT-MASK is nil, then KEYCODE's key will be bound to NEWSTRING for\n\
4035 all shift combinations.\n\
4036 Shift Lock 1 Shift 2\n\
4039 For values of KEYCODE, see /usr/lib/Xkeymap.txt (remember that the codes\n\
4040 in that file are in octal!)\n\
4042 NOTE: due to an X bug, this function will not take effect unless one has\n\
4043 a `~/.Xkeymap' file. (See the documentation for the `keycomp' program.)\n\
4044 This problem will be fixed in X version 11.")
4046 (keycode
, shift_mask
, newstring
)
4047 register Lisp_Object keycode
;
4048 register Lisp_Object shift_mask
;
4049 register Lisp_Object newstring
;
4052 int keysym
, rawshift
;
4055 CHECK_NUMBER (keycode
, 1);
4056 if (!NILP (shift_mask
))
4057 CHECK_NUMBER (shift_mask
, 2);
4058 CHECK_STRING (newstring
, 3);
4059 strsize
= XSTRING (newstring
)->size
;
4060 rawstring
= (char *) xmalloc (strsize
);
4061 bcopy (XSTRING (newstring
)->data
, rawstring
, strsize
);
4063 keysym
= ((unsigned) (XINT (keycode
))) & 255;
4065 if (NILP (shift_mask
))
4067 for (i
= 0; i
<= 15; i
++)
4068 XRebindCode (keysym
, i
<<11, rawstring
, strsize
);
4072 rawshift
= (((unsigned) (XINT (shift_mask
))) & 15) << 11;
4073 XRebindCode (keysym
, rawshift
, rawstring
, strsize
);
4078 DEFUN ("x-rebind-keys", Fx_rebind_keys
, Sx_rebind_keys
, 2, 2, 0,
4079 "Rebind KEYCODE to list of strings STRINGS.\n\
4080 STRINGS should be a list of 16 elements, one for each shift combination.\n\
4081 nil as element means don't change.\n\
4082 See the documentation of `x-rebind-key' for more information.")
4084 register Lisp_Object keycode
;
4085 register Lisp_Object strings
;
4087 register Lisp_Object item
;
4088 register char *rawstring
;
4089 KeySym rawkey
, modifier
[1];
4091 register unsigned i
;
4093 CHECK_NUMBER (keycode
, 1);
4094 CHECK_CONS (strings
, 2);
4095 rawkey
= (KeySym
) ((unsigned) (XINT (keycode
))) & 255;
4096 for (i
= 0; i
<= 15; strings
= Fcdr (strings
), i
++)
4098 item
= Fcar (strings
);
4101 CHECK_STRING (item
, 2);
4102 strsize
= XSTRING (item
)->size
;
4103 rawstring
= (char *) xmalloc (strsize
);
4104 bcopy (XSTRING (item
)->data
, rawstring
, strsize
);
4105 XRebindCode (rawkey
, i
<< 11, rawstring
, strsize
);
4110 #endif /* not HAVE_X11 */
4114 select_visual (screen
, depth
)
4116 unsigned int *depth
;
4119 XVisualInfo
*vinfo
, vinfo_template
;
4122 v
= DefaultVisualOfScreen (screen
);
4123 vinfo_template
.visualid
= XVisualIDFromVisual (v
);
4124 vinfo
= XGetVisualInfo (x_current_display
, VisualIDMask
, &vinfo_template
,
4127 fatal ("Can't get proper X visual info");
4129 if ((1 << vinfo
->depth
) == vinfo
->colormap_size
)
4130 *depth
= vinfo
->depth
;
4134 int n
= vinfo
->colormap_size
- 1;
4143 XFree ((char *) vinfo
);
4146 #endif /* HAVE_X11 */
4148 DEFUN ("x-open-connection", Fx_open_connection
, Sx_open_connection
,
4149 1, 2, 0, "Open a connection to an X server.\n\
4150 DISPLAY is the name of the display to connect to. Optional second\n\
4151 arg XRM_STRING is a string of resources in xrdb format.")
4152 (display
, xrm_string
)
4153 Lisp_Object display
, xrm_string
;
4155 unsigned int n_planes
;
4156 register Screen
*x_screen
;
4157 unsigned char *xrm_option
;
4159 CHECK_STRING (display
, 0);
4160 if (x_current_display
!= 0)
4161 error ("X server connection is already initialized");
4163 /* This is what opens the connection and sets x_current_display.
4164 This also initializes many symbols, such as those used for input. */
4165 x_term_init (XSTRING (display
)->data
);
4168 XFASTINT (Vwindow_system_version
) = 11;
4170 if (!EQ (xrm_string
, Qnil
))
4172 CHECK_STRING (xrm_string
, 1);
4173 xrm_option
= (unsigned char *) XSTRING (xrm_string
);
4176 xrm_option
= (unsigned char *) 0;
4177 xrdb
= x_load_resources (x_current_display
, xrm_option
, EMACS_CLASS
);
4178 x_current_display
->db
= xrdb
;
4180 x_screen
= DefaultScreenOfDisplay (x_current_display
);
4182 x_screen_count
= make_number (ScreenCount (x_current_display
));
4183 Vx_vendor
= build_string (ServerVendor (x_current_display
));
4184 x_release
= make_number (VendorRelease (x_current_display
));
4186 x_screen_height
= make_number (HeightOfScreen (x_screen
));
4187 x_screen_height_mm
= make_number (HeightMMOfScreen (x_screen
));
4188 x_screen_width
= make_number (WidthOfScreen (x_screen
));
4189 x_screen_width_mm
= make_number (WidthMMOfScreen (x_screen
));
4191 switch (DoesBackingStore (x_screen
))
4194 Vx_backing_store
= intern ("Always");
4198 Vx_backing_store
= intern ("WhenMapped");
4202 Vx_backing_store
= intern ("NotUseful");
4206 error ("Strange value for BackingStore.");
4210 if (DoesSaveUnders (x_screen
) == True
)
4213 x_save_under
= Qnil
;
4215 screen_visual
= select_visual (x_screen
, &n_planes
);
4216 x_screen_planes
= make_number (n_planes
);
4217 Vx_screen_visual
= intern (x_visual_strings
[screen_visual
->class]);
4219 /* X Atoms used by emacs. */
4221 Xatom_emacs_selection
= XInternAtom (x_current_display
, "_EMACS_SELECTION_",
4223 Xatom_clipboard
= XInternAtom (x_current_display
, "CLIPBOARD",
4225 Xatom_clipboard_selection
= XInternAtom (x_current_display
, "_EMACS_CLIPBOARD_",
4227 Xatom_wm_change_state
= XInternAtom (x_current_display
, "WM_CHANGE_STATE",
4229 Xatom_incremental
= XInternAtom (x_current_display
, "INCR",
4231 Xatom_multiple
= XInternAtom (x_current_display
, "MULTIPLE",
4233 Xatom_targets
= XInternAtom (x_current_display
, "TARGETS",
4235 Xatom_timestamp
= XInternAtom (x_current_display
, "TIMESTAMP",
4237 Xatom_delete
= XInternAtom (x_current_display
, "DELETE",
4239 Xatom_insert_selection
= XInternAtom (x_current_display
, "INSERT_SELECTION",
4241 Xatom_pair
= XInternAtom (x_current_display
, "XA_ATOM_PAIR",
4243 Xatom_insert_property
= XInternAtom (x_current_display
, "INSERT_PROPERTY",
4245 Xatom_text
= XInternAtom (x_current_display
, "TEXT",
4247 Xatom_wm_protocols
= XInternAtom (x_current_display
, "WM_PROTOCOLS",
4249 Xatom_wm_take_focus
= XInternAtom (x_current_display
, "WM_TAKE_FOCUS",
4251 Xatom_wm_save_yourself
= XInternAtom (x_current_display
, "WM_SAVE_YOURSELF",
4253 Xatom_wm_delete_window
= XInternAtom (x_current_display
, "WM_DELETE_WINDOW",
4255 Xatom_wm_change_state
= XInternAtom (x_current_display
, "WM_CHANGE_STATE",
4257 Xatom_wm_configure_denied
= XInternAtom (x_current_display
,
4258 "WM_CONFIGURE_DENIED", False
);
4259 Xatom_wm_window_moved
= XInternAtom (x_current_display
, "WM_MOVED",
4262 #else /* not HAVE_X11 */
4263 XFASTINT (Vwindow_system_version
) = 10;
4264 #endif /* not HAVE_X11 */
4268 DEFUN ("x-close-current-connection", Fx_close_current_connection
,
4269 Sx_close_current_connection
,
4270 0, 0, 0, "Close the connection to the current X server.")
4274 /* This is ONLY used when killing emacs; For switching displays
4275 we'll have to take care of setting CloseDownMode elsewhere. */
4277 if (x_current_display
)
4280 XSetCloseDownMode (x_current_display
, DestroyAll
);
4281 XCloseDisplay (x_current_display
);
4284 fatal ("No current X display connection to close\n");
4289 DEFUN ("x-synchronize", Fx_synchronize
, Sx_synchronize
,
4290 1, 1, 0, "If ON is non-nil, report X errors as soon as the erring request is made.\n\
4291 If ON is nil, allow buffering of requests.\n\
4292 Turning on synchronization prohibits the Xlib routines from buffering\n\
4293 requests and seriously degrades performance, but makes debugging much\n\
4298 XSynchronize (x_current_display
, !EQ (on
, Qnil
));
4306 init_x_parm_symbols ();
4308 /* This is zero if not using X windows. */
4309 x_current_display
= 0;
4311 Qundefined_color
= intern ("undefined-color");
4312 Fput (Qundefined_color
, Qerror_conditions
,
4313 Fcons (Qundefined_color
, Fcons (Qerror
, Qnil
)));
4314 Fput (Qundefined_color
, Qerror_message
,
4315 build_string ("Undefined color"));
4317 DEFVAR_INT ("mouse-x-position", &x_mouse_x
,
4318 "The X coordinate of the mouse position, in characters.");
4321 DEFVAR_INT ("mouse-y-position", &x_mouse_y
,
4322 "The Y coordinate of the mouse position, in characters.");
4325 DEFVAR_INT ("mouse-buffer-offset", &mouse_buffer_offset
,
4326 "The buffer offset of the character under the pointer.");
4327 mouse_buffer_offset
= Qnil
;
4329 DEFVAR_INT ("x-pointer-shape", &Vx_pointer_shape
,
4330 "The shape of the pointer when over text.");
4331 Vx_pointer_shape
= Qnil
;
4333 DEFVAR_INT ("x-nontext-pointer-shape", &Vx_nontext_pointer_shape
,
4334 "The shape of the pointer when not over text.");
4335 Vx_nontext_pointer_shape
= Qnil
;
4337 DEFVAR_INT ("x-mode-pointer-shape", &Vx_mode_pointer_shape
,
4338 "The shape of the pointer when over the mode line.");
4339 Vx_mode_pointer_shape
= Qnil
;
4341 DEFVAR_LISP ("x-bar-cursor", &Vbar_cursor
,
4342 "*If non-nil, use a vertical bar cursor. Otherwise, use the traditional box.");
4345 DEFVAR_LISP ("x-cursor-fore-pixel", &Vx_cursor_fore_pixel
,
4346 "A string indicating the foreground color of the cursor box.");
4347 Vx_cursor_fore_pixel
= Qnil
;
4349 DEFVAR_LISP ("mouse-grabbed", &Vmouse_depressed
,
4350 "Non-nil if a mouse button is currently depressed.");
4351 Vmouse_depressed
= Qnil
;
4353 DEFVAR_INT ("x-screen-count", &x_screen_count
,
4354 "The number of screens associated with the current display.");
4355 DEFVAR_INT ("x-release", &x_release
,
4356 "The release number of the X server in use.");
4357 DEFVAR_LISP ("x-vendor", &Vx_vendor
,
4358 "The vendor supporting the X server in use.");
4359 DEFVAR_INT ("x-screen-height", &x_screen_height
,
4360 "The height of this X screen in pixels.");
4361 DEFVAR_INT ("x-screen-height-mm", &x_screen_height_mm
,
4362 "The height of this X screen in millimeters.");
4363 DEFVAR_INT ("x-screen-width", &x_screen_width
,
4364 "The width of this X screen in pixels.");
4365 DEFVAR_INT ("x-screen-width-mm", &x_screen_width_mm
,
4366 "The width of this X screen in millimeters.");
4367 DEFVAR_LISP ("x-backing-store", &Vx_backing_store
,
4368 "The backing store capability of this screen.\n\
4369 Values can be the symbols Always, WhenMapped, or NotUseful.");
4370 DEFVAR_BOOL ("x-save-under", &x_save_under
,
4371 "*Non-nil means this X screen supports the SaveUnder feature.");
4372 DEFVAR_INT ("x-screen-planes", &x_screen_planes
,
4373 "The number of planes this monitor supports.");
4374 DEFVAR_LISP ("x-screen-visual", &Vx_screen_visual
,
4375 "The default X visual for this X screen.");
4376 DEFVAR_LISP ("x-no-window-manager", &Vx_no_window_manager
,
4377 "t if no X window manager is in use.");
4380 defsubr (&Sx_get_resource
);
4381 defsubr (&Sx_pixel_width
);
4382 defsubr (&Sx_pixel_height
);
4384 defsubr (&Sx_draw_rectangle
);
4385 defsubr (&Sx_erase_rectangle
);
4386 defsubr (&Sx_contour_region
);
4387 defsubr (&Sx_uncontour_region
);
4389 defsubr (&Sx_color_display_p
);
4390 defsubr (&Sx_defined_color
);
4392 defsubr (&Sx_track_pointer
);
4393 defsubr (&Sx_grab_pointer
);
4394 defsubr (&Sx_ungrab_pointer
);
4397 defsubr (&Sx_get_default
);
4398 defsubr (&Sx_store_cut_buffer
);
4399 defsubr (&Sx_get_cut_buffer
);
4400 defsubr (&Sx_set_face
);
4402 defsubr (&Sx_geometry
);
4403 defsubr (&Sx_create_frame
);
4404 defsubr (&Sfocus_frame
);
4405 defsubr (&Sunfocus_frame
);
4407 defsubr (&Sx_horizontal_line
);
4409 defsubr (&Sx_rebind_key
);
4410 defsubr (&Sx_rebind_keys
);
4411 defsubr (&Sx_open_connection
);
4412 defsubr (&Sx_close_current_connection
);
4413 defsubr (&Sx_synchronize
);
4415 /* This was used in the old event interface which used a separate
4418 defsubr (&Sx_mouse_events
);
4419 defsubr (&Sx_get_mouse_event
);
4423 #endif /* HAVE_X_WINDOWS */