1 /* Functions for the X window system.
2 Copyright (C) 1989, 1992, 1993 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"
40 #include <X11/bitmaps/gray>
42 #define min(a,b) ((a) < (b) ? (a) : (b))
43 #define max(a,b) ((a) > (b) ? (a) : (b))
46 /* X Resource data base */
47 static XrmDatabase xrdb
;
49 /* The class of this X application. */
50 #define EMACS_CLASS "Emacs"
52 /* Title name and application name for X stuff. */
53 extern char *x_id_name
;
55 /* The background and shape of the mouse pointer, and shape when not
56 over text or in the modeline. */
57 Lisp_Object Vx_pointer_shape
, Vx_nontext_pointer_shape
, Vx_mode_pointer_shape
;
59 /* Color of chars displayed in cursor box. */
60 Lisp_Object Vx_cursor_fore_pixel
;
62 /* The screen being used. */
63 static Screen
*x_screen
;
65 /* The X Visual we are using for X windows (the default) */
66 Visual
*screen_visual
;
68 /* Height of this X screen in pixels. */
71 /* Width of this X screen in pixels. */
74 /* Number of planes for this screen. */
77 /* Non nil if no window manager is in use. */
78 Lisp_Object Vx_no_window_manager
;
80 /* `t' if a mouse button is depressed. */
82 Lisp_Object Vmouse_depressed
;
84 extern unsigned int x_mouse_x
, x_mouse_y
, x_mouse_grabbed
;
86 /* Atom for indicating window state to the window manager. */
87 extern Atom Xatom_wm_change_state
;
89 /* Communication with window managers. */
90 extern Atom Xatom_wm_protocols
;
92 /* Kinds of protocol things we may receive. */
93 extern Atom Xatom_wm_take_focus
;
94 extern Atom Xatom_wm_save_yourself
;
95 extern Atom Xatom_wm_delete_window
;
97 /* Other WM communication */
98 extern Atom Xatom_wm_configure_denied
; /* When our config request is denied */
99 extern Atom Xatom_wm_window_moved
; /* When the WM moves us. */
103 /* Default size of an Emacs window. */
104 static char *default_window
= "=80x24+0+0";
107 char iconidentity
[MAXICID
];
108 #define ICONTAG "emacs@"
109 char minibuffer_iconidentity
[MAXICID
];
110 #define MINIBUFFER_ICONTAG "minibuffer@"
114 /* The last 23 bits of the timestamp of the last mouse button event. */
115 Time mouse_timestamp
;
117 /* Evaluate this expression to rebuild the section of syms_of_xfns
118 that initializes and staticpros the symbols declared below. Note
119 that Emacs 18 has a bug that keeps C-x C-e from being able to
120 evaluate this expression.
123 ;; Accumulate a list of the symbols we want to initialize from the
124 ;; declarations at the top of the file.
125 (goto-char (point-min))
126 (search-forward "/\*&&& symbols declared here &&&*\/\n")
128 (while (looking-at "Lisp_Object \\(Q[a-z_]+\\)")
130 (cons (buffer-substring (match-beginning 1) (match-end 1))
133 (setq symbol-list (nreverse symbol-list))
134 ;; Delete the section of syms_of_... where we initialize the symbols.
135 (search-forward "\n /\*&&& init symbols here &&&*\/\n")
136 (let ((start (point)))
137 (while (looking-at "^ Q")
139 (kill-region start (point)))
140 ;; Write a new symbol initialization section.
142 (insert (format " %s = intern (\"" (car symbol-list)))
143 (let ((start (point)))
144 (insert (substring (car symbol-list) 1))
145 (subst-char-in-region start (point) ?_ ?-))
146 (insert (format "\");\n staticpro (&%s);\n" (car symbol-list)))
147 (setq symbol-list (cdr symbol-list)))))
151 /*&&& symbols declared here &&&*/
152 Lisp_Object Qauto_raise
;
153 Lisp_Object Qauto_lower
;
154 Lisp_Object Qbackground_color
;
156 Lisp_Object Qborder_color
;
157 Lisp_Object Qborder_width
;
159 Lisp_Object Qcursor_color
;
160 Lisp_Object Qcursor_type
;
162 Lisp_Object Qforeground_color
;
163 Lisp_Object Qgeometry
;
165 Lisp_Object Qicon_left
;
166 Lisp_Object Qicon_top
;
167 Lisp_Object Qicon_type
;
168 Lisp_Object Qinternal_border_width
;
170 Lisp_Object Qmouse_color
;
172 Lisp_Object Qparent_id
;
174 Lisp_Object Qundefined_color
;
175 Lisp_Object Qvertical_scroll_bars
;
176 Lisp_Object Qvisibility
;
177 Lisp_Object Qwindow_id
;
178 Lisp_Object Qx_frame_parameter
;
180 /* The below are defined in frame.c. */
181 extern Lisp_Object Qheight
, Qminibuffer
, Qname
, Qonly
, Qwidth
;
182 extern Lisp_Object Qunsplittable
, Qmenu_bar_lines
, Qicon
;
184 extern Lisp_Object Vwindow_system_version
;
186 /* Mouse map for clicks in windows. */
187 extern Lisp_Object Vglobal_mouse_map
;
189 /* Points to table of defined typefaces. */
190 struct face
*x_face_table
[MAX_FACES_AND_GLYPHS
];
192 /* Return the Emacs frame-object corresponding to an X window.
193 It could be the frame's main window or an icon window. */
196 x_window_to_frame (wdesc
)
199 Lisp_Object tail
, frame
;
202 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
204 frame
= XCONS (tail
)->car
;
205 if (XTYPE (frame
) != Lisp_Frame
)
208 if (FRAME_X_WINDOW (f
) == wdesc
209 || f
->display
.x
->icon_desc
== wdesc
)
216 /* Connect the frame-parameter names for X frames
217 to the ways of passing the parameter values to the window system.
219 The name of a parameter, as a Lisp symbol,
220 has an `x-frame-parameter' property which is an integer in Lisp
221 but can be interpreted as an `enum x_frame_parm' in C. */
225 X_PARM_FOREGROUND_COLOR
,
226 X_PARM_BACKGROUND_COLOR
,
233 X_PARM_INTERNAL_BORDER_WIDTH
,
237 X_PARM_VERT_SCROLL_BAR
,
239 X_PARM_MENU_BAR_LINES
243 struct x_frame_parm_table
246 void (*setter
)( /* struct frame *frame, Lisp_Object val, oldval */ );
249 void x_set_foreground_color ();
250 void x_set_background_color ();
251 void x_set_mouse_color ();
252 void x_set_cursor_color ();
253 void x_set_border_color ();
254 void x_set_cursor_type ();
255 void x_set_icon_type ();
257 void x_set_border_width ();
258 void x_set_internal_border_width ();
259 void x_explicitly_set_name ();
260 void x_set_autoraise ();
261 void x_set_autolower ();
262 void x_set_vertical_scroll_bars ();
263 void x_set_visibility ();
264 void x_set_menu_bar_lines ();
266 static struct x_frame_parm_table x_frame_parms
[] =
268 "foreground-color", x_set_foreground_color
,
269 "background-color", x_set_background_color
,
270 "mouse-color", x_set_mouse_color
,
271 "cursor-color", x_set_cursor_color
,
272 "border-color", x_set_border_color
,
273 "cursor-type", x_set_cursor_type
,
274 "icon-type", x_set_icon_type
,
276 "border-width", x_set_border_width
,
277 "internal-border-width", x_set_internal_border_width
,
278 "name", x_explicitly_set_name
,
279 "auto-raise", x_set_autoraise
,
280 "auto-lower", x_set_autolower
,
281 "vertical-scroll-bars", x_set_vertical_scroll_bars
,
282 "visibility", x_set_visibility
,
283 "menu-bar-lines", x_set_menu_bar_lines
,
286 /* Attach the `x-frame-parameter' properties to
287 the Lisp symbol names of parameters relevant to X. */
289 init_x_parm_symbols ()
293 for (i
= 0; i
< sizeof (x_frame_parms
) / sizeof (x_frame_parms
[0]); i
++)
294 Fput (intern (x_frame_parms
[i
].name
), Qx_frame_parameter
,
298 /* Change the parameters of FRAME as specified by ALIST.
299 If a parameter is not specially recognized, do nothing;
300 otherwise call the `x_set_...' function for that parameter. */
303 x_set_frame_parameters (f
, alist
)
309 /* If both of these parameters are present, it's more efficient to
310 set them both at once. So we wait until we've looked at the
311 entire list before we set them. */
312 Lisp_Object width
, height
;
315 Lisp_Object left
, top
;
317 XSET (width
, Lisp_Int
, FRAME_WIDTH (f
));
318 XSET (height
, Lisp_Int
, FRAME_HEIGHT (f
));
320 XSET (top
, Lisp_Int
, f
->display
.x
->top_pos
);
321 XSET (left
, Lisp_Int
, f
->display
.x
->left_pos
);
323 for (tail
= alist
; CONSP (tail
); tail
= Fcdr (tail
))
325 Lisp_Object elt
, prop
, val
;
331 if (EQ (prop
, Qwidth
))
333 else if (EQ (prop
, Qheight
))
335 else if (EQ (prop
, Qtop
))
337 else if (EQ (prop
, Qleft
))
341 register Lisp_Object tem
;
342 tem
= Fget (prop
, Qx_frame_parameter
);
343 if (XTYPE (tem
) == Lisp_Int
345 && XINT (tem
) < sizeof (x_frame_parms
)/sizeof (x_frame_parms
[0]))
346 (*x_frame_parms
[XINT (tem
)].setter
)(f
, val
,
347 get_frame_param (f
, prop
));
348 store_frame_param (f
, prop
, val
);
352 /* Don't call these unless they've changed; the window may not actually
357 XSET (frame
, Lisp_Frame
, f
);
358 if (XINT (width
) != FRAME_WIDTH (f
)
359 || XINT (height
) != FRAME_HEIGHT (f
))
360 Fset_frame_size (frame
, width
, height
);
361 if (XINT (left
) != f
->display
.x
->left_pos
362 || XINT (top
) != f
->display
.x
->top_pos
)
363 Fset_frame_position (frame
, left
, top
);
367 /* Insert a description of internally-recorded parameters of frame X
368 into the parameter alist *ALISTPTR that is to be given to the user.
369 Only parameters that are specific to the X window system
370 and whose values are not correctly recorded in the frame's
371 param_alist need to be considered here. */
373 x_report_frame_params (f
, alistptr
)
375 Lisp_Object
*alistptr
;
379 store_in_alist (alistptr
, Qleft
, make_number (f
->display
.x
->left_pos
));
380 store_in_alist (alistptr
, Qtop
, make_number (f
->display
.x
->top_pos
));
381 store_in_alist (alistptr
, Qborder_width
,
382 make_number (f
->display
.x
->border_width
));
383 store_in_alist (alistptr
, Qinternal_border_width
,
384 make_number (f
->display
.x
->internal_border_width
));
385 sprintf (buf
, "%d", FRAME_X_WINDOW (f
));
386 store_in_alist (alistptr
, Qwindow_id
,
388 store_in_alist (alistptr
, Qvisibility
,
389 (FRAME_VISIBLE_P (f
) ? Qt
390 : FRAME_ICONIFIED_P (f
) ? Qicon
: Qnil
));
393 /* Decide if color named COLOR is valid for the display
394 associated with the selected frame. */
396 defined_color (color
, color_def
)
401 Colormap screen_colormap
;
406 = DefaultColormap (x_current_display
, XDefaultScreen (x_current_display
));
408 foo
= XParseColor (x_current_display
, screen_colormap
,
410 && XAllocColor (x_current_display
, screen_colormap
, color_def
);
412 foo
= XParseColor (color
, color_def
) && XGetHardwareColor (color_def
);
413 #endif /* not HAVE_X11 */
422 /* Given a string ARG naming a color, compute a pixel value from it
423 suitable for screen F.
424 If F is not a color screen, return DEF (default) regardless of what
428 x_decode_color (arg
, def
)
434 CHECK_STRING (arg
, 0);
436 if (strcmp (XSTRING (arg
)->data
, "black") == 0)
437 return BLACK_PIX_DEFAULT
;
438 else if (strcmp (XSTRING (arg
)->data
, "white") == 0)
439 return WHITE_PIX_DEFAULT
;
442 if (x_screen_planes
== 1)
445 if (DISPLAY_CELLS
== 1)
449 if (defined_color (XSTRING (arg
)->data
, &cdef
))
452 Fsignal (Qundefined_color
, Fcons (arg
, Qnil
));
455 /* Functions called only from `x_set_frame_param'
456 to set individual parameters.
458 If FRAME_X_WINDOW (f) is 0,
459 the frame is being created and its X-window does not exist yet.
460 In that case, just record the parameter's new value
461 in the standard place; do not attempt to change the window. */
464 x_set_foreground_color (f
, arg
, oldval
)
466 Lisp_Object arg
, oldval
;
468 f
->display
.x
->foreground_pixel
= x_decode_color (arg
, BLACK_PIX_DEFAULT
);
469 if (FRAME_X_WINDOW (f
) != 0)
473 XSetForeground (x_current_display
, f
->display
.x
->normal_gc
,
474 f
->display
.x
->foreground_pixel
);
475 XSetBackground (x_current_display
, f
->display
.x
->reverse_gc
,
476 f
->display
.x
->foreground_pixel
);
478 #endif /* HAVE_X11 */
479 if (FRAME_VISIBLE_P (f
))
485 x_set_background_color (f
, arg
, oldval
)
487 Lisp_Object arg
, oldval
;
492 f
->display
.x
->background_pixel
= x_decode_color (arg
, WHITE_PIX_DEFAULT
);
494 if (FRAME_X_WINDOW (f
) != 0)
498 /* The main frame area. */
499 XSetBackground (x_current_display
, f
->display
.x
->normal_gc
,
500 f
->display
.x
->background_pixel
);
501 XSetForeground (x_current_display
, f
->display
.x
->reverse_gc
,
502 f
->display
.x
->background_pixel
);
503 XSetWindowBackground (x_current_display
, FRAME_X_WINDOW (f
),
504 f
->display
.x
->background_pixel
);
507 temp
= XMakeTile (f
->display
.x
->background_pixel
);
508 XChangeBackground (FRAME_X_WINDOW (f
), temp
);
510 #endif /* not HAVE_X11 */
513 if (FRAME_VISIBLE_P (f
))
519 x_set_mouse_color (f
, arg
, oldval
)
521 Lisp_Object arg
, oldval
;
523 Cursor cursor
, nontext_cursor
, mode_cursor
;
527 f
->display
.x
->mouse_pixel
= x_decode_color (arg
, BLACK_PIX_DEFAULT
);
528 mask_color
= f
->display
.x
->background_pixel
;
529 /* No invisible pointers. */
530 if (mask_color
== f
->display
.x
->mouse_pixel
531 && mask_color
== f
->display
.x
->background_pixel
)
532 f
->display
.x
->mouse_pixel
= f
->display
.x
->foreground_pixel
;
537 /* It's not okay to crash if the user selects a screwey cursor. */
540 if (!EQ (Qnil
, Vx_pointer_shape
))
542 CHECK_NUMBER (Vx_pointer_shape
, 0);
543 cursor
= XCreateFontCursor (x_current_display
, XINT (Vx_pointer_shape
));
546 cursor
= XCreateFontCursor (x_current_display
, XC_xterm
);
547 x_check_errors ("bad text pointer cursor: %s");
549 if (!EQ (Qnil
, Vx_nontext_pointer_shape
))
551 CHECK_NUMBER (Vx_nontext_pointer_shape
, 0);
552 nontext_cursor
= XCreateFontCursor (x_current_display
,
553 XINT (Vx_nontext_pointer_shape
));
556 nontext_cursor
= XCreateFontCursor (x_current_display
, XC_left_ptr
);
557 x_check_errors ("bad nontext pointer cursor: %s");
559 if (!EQ (Qnil
, Vx_mode_pointer_shape
))
561 CHECK_NUMBER (Vx_mode_pointer_shape
, 0);
562 mode_cursor
= XCreateFontCursor (x_current_display
,
563 XINT (Vx_mode_pointer_shape
));
566 mode_cursor
= XCreateFontCursor (x_current_display
, XC_xterm
);
568 /* Check and report errors with the above calls. */
569 x_check_errors ("can't set cursor shape: %s");
573 XColor fore_color
, back_color
;
575 fore_color
.pixel
= f
->display
.x
->mouse_pixel
;
576 back_color
.pixel
= mask_color
;
577 XQueryColor (x_current_display
,
578 DefaultColormap (x_current_display
,
579 DefaultScreen (x_current_display
)),
581 XQueryColor (x_current_display
,
582 DefaultColormap (x_current_display
,
583 DefaultScreen (x_current_display
)),
585 XRecolorCursor (x_current_display
, cursor
,
586 &fore_color
, &back_color
);
587 XRecolorCursor (x_current_display
, nontext_cursor
,
588 &fore_color
, &back_color
);
589 XRecolorCursor (x_current_display
, mode_cursor
,
590 &fore_color
, &back_color
);
593 cursor
= XCreateCursor (16, 16, MouseCursor
, MouseMask
,
595 f
->display
.x
->mouse_pixel
,
596 f
->display
.x
->background_pixel
,
600 if (FRAME_X_WINDOW (f
) != 0)
602 XDefineCursor (XDISPLAY
FRAME_X_WINDOW (f
), cursor
);
605 if (cursor
!= f
->display
.x
->text_cursor
&& f
->display
.x
->text_cursor
!= 0)
606 XFreeCursor (XDISPLAY f
->display
.x
->text_cursor
);
607 f
->display
.x
->text_cursor
= cursor
;
609 if (nontext_cursor
!= f
->display
.x
->nontext_cursor
610 && f
->display
.x
->nontext_cursor
!= 0)
611 XFreeCursor (XDISPLAY f
->display
.x
->nontext_cursor
);
612 f
->display
.x
->nontext_cursor
= nontext_cursor
;
614 if (mode_cursor
!= f
->display
.x
->modeline_cursor
615 && f
->display
.x
->modeline_cursor
!= 0)
616 XFreeCursor (XDISPLAY f
->display
.x
->modeline_cursor
);
617 f
->display
.x
->modeline_cursor
= mode_cursor
;
618 #endif /* HAVE_X11 */
625 x_set_cursor_color (f
, arg
, oldval
)
627 Lisp_Object arg
, oldval
;
629 unsigned long fore_pixel
;
631 if (!EQ (Vx_cursor_fore_pixel
, Qnil
))
632 fore_pixel
= x_decode_color (Vx_cursor_fore_pixel
, WHITE_PIX_DEFAULT
);
634 fore_pixel
= f
->display
.x
->background_pixel
;
635 f
->display
.x
->cursor_pixel
= x_decode_color (arg
, BLACK_PIX_DEFAULT
);
637 /* Make sure that the cursor color differs from the background color. */
638 if (f
->display
.x
->cursor_pixel
== f
->display
.x
->background_pixel
)
640 f
->display
.x
->cursor_pixel
== f
->display
.x
->mouse_pixel
;
641 if (f
->display
.x
->cursor_pixel
== fore_pixel
)
642 fore_pixel
= f
->display
.x
->background_pixel
;
645 if (FRAME_X_WINDOW (f
) != 0)
649 XSetBackground (x_current_display
, f
->display
.x
->cursor_gc
,
650 f
->display
.x
->cursor_pixel
);
651 XSetForeground (x_current_display
, f
->display
.x
->cursor_gc
,
654 #endif /* HAVE_X11 */
656 if (FRAME_VISIBLE_P (f
))
658 x_display_cursor (f
, 0);
659 x_display_cursor (f
, 1);
664 /* Set the border-color of frame F to value described by ARG.
665 ARG can be a string naming a color.
666 The border-color is used for the border that is drawn by the X server.
667 Note that this does not fully take effect if done before
668 F has an x-window; it must be redone when the window is created.
670 Note: this is done in two routines because of the way X10 works.
672 Note: under X11, this is normally the province of the window manager,
673 and so emacs' border colors may be overridden. */
676 x_set_border_color (f
, arg
, oldval
)
678 Lisp_Object arg
, oldval
;
683 CHECK_STRING (arg
, 0);
684 str
= XSTRING (arg
)->data
;
687 if (!strcmp (str
, "grey") || !strcmp (str
, "Grey")
688 || !strcmp (str
, "gray") || !strcmp (str
, "Gray"))
693 pix
= x_decode_color (arg
, BLACK_PIX_DEFAULT
);
695 x_set_border_pixel (f
, pix
);
698 /* Set the border-color of frame F to pixel value PIX.
699 Note that this does not fully take effect if done before
700 F has an x-window. */
702 x_set_border_pixel (f
, pix
)
706 f
->display
.x
->border_pixel
= pix
;
708 if (FRAME_X_WINDOW (f
) != 0 && f
->display
.x
->border_width
> 0)
715 XSetWindowBorder (x_current_display
, FRAME_X_WINDOW (f
),
719 temp
= XMakePixmap ((Bitmap
) XStoreBitmap (gray_width
, gray_height
,
721 BLACK_PIX_DEFAULT
, WHITE_PIX_DEFAULT
);
723 temp
= XMakeTile (pix
);
724 XChangeBorder (FRAME_X_WINDOW (f
), temp
);
725 XFreePixmap (XDISPLAY temp
);
726 #endif /* not HAVE_X11 */
729 if (FRAME_VISIBLE_P (f
))
735 x_set_cursor_type (f
, arg
, oldval
)
737 Lisp_Object arg
, oldval
;
740 FRAME_DESIRED_CURSOR (f
) = bar_cursor
;
741 else if (EQ (arg
, Qbox
))
742 FRAME_DESIRED_CURSOR (f
) = filled_box_cursor
;
745 ("the `cursor-type' frame parameter should be either `bar' or `box'");
747 /* Make sure the cursor gets redrawn. This is overkill, but how
748 often do people change cursor types? */
753 x_set_icon_type (f
, arg
, oldval
)
755 Lisp_Object arg
, oldval
;
760 if (EQ (oldval
, Qnil
) == EQ (arg
, Qnil
))
765 result
= x_text_icon (f
, 0);
767 result
= x_bitmap_icon (f
);
772 error ("No icon window available.");
775 /* If the window was unmapped (and its icon was mapped),
776 the new icon is not mapped, so map the window in its stead. */
777 if (FRAME_VISIBLE_P (f
))
778 XMapWindow (XDISPLAY
FRAME_X_WINDOW (f
));
785 x_set_font (f
, arg
, oldval
)
787 Lisp_Object arg
, oldval
;
792 CHECK_STRING (arg
, 1);
793 name
= XSTRING (arg
)->data
;
796 result
= x_new_font (f
, name
);
800 error ("Font \"%s\" is not defined", name
);
804 x_set_border_width (f
, arg
, oldval
)
806 Lisp_Object arg
, oldval
;
808 CHECK_NUMBER (arg
, 0);
810 if (XINT (arg
) == f
->display
.x
->border_width
)
813 if (FRAME_X_WINDOW (f
) != 0)
814 error ("Cannot change the border width of a window");
816 f
->display
.x
->border_width
= XINT (arg
);
820 x_set_internal_border_width (f
, arg
, oldval
)
822 Lisp_Object arg
, oldval
;
825 int old
= f
->display
.x
->internal_border_width
;
827 CHECK_NUMBER (arg
, 0);
828 f
->display
.x
->internal_border_width
= XINT (arg
);
829 if (f
->display
.x
->internal_border_width
< 0)
830 f
->display
.x
->internal_border_width
= 0;
832 if (f
->display
.x
->internal_border_width
== old
)
835 if (FRAME_X_WINDOW (f
) != 0)
838 x_set_window_size (f
, f
->width
, f
->height
);
840 x_set_resize_hint (f
);
844 SET_FRAME_GARBAGED (f
);
849 x_set_visibility (f
, value
, oldval
)
851 Lisp_Object value
, oldval
;
854 XSET (frame
, Lisp_Frame
, f
);
857 Fmake_frame_invisible (frame
);
858 else if (EQ (value
, Qicon
))
859 Ficonify_frame (frame
);
861 Fmake_frame_visible (frame
);
865 x_set_menu_bar_lines_1 (window
, n
)
869 for (; !NILP (window
); window
= XWINDOW (window
)->next
)
871 struct window
*w
= XWINDOW (window
);
875 if (!NILP (w
->vchild
))
876 x_set_menu_bar_lines_1 (w
->vchild
);
878 if (!NILP (w
->hchild
))
879 x_set_menu_bar_lines_1 (w
->hchild
);
884 x_set_menu_bar_lines (f
, value
, oldval
)
886 Lisp_Object value
, oldval
;
889 int olines
= FRAME_MENU_BAR_LINES (f
);
891 if (XTYPE (value
) == Lisp_Int
)
892 nlines
= XINT (value
);
896 FRAME_MENU_BAR_LINES (f
) = nlines
;
897 x_set_menu_bar_lines_1 (f
->root_window
, nlines
- olines
);
898 x_set_window_size (f
, FRAME_WIDTH (f
),
899 FRAME_HEIGHT (f
) + nlines
- olines
);
902 /* Change the name of frame F to ARG. If ARG is nil, set F's name to
905 If EXPLICIT is non-zero, that indicates that lisp code is setting the
906 name; if ARG is a string, set F's name to ARG and set
907 F->explicit_name; if ARG is Qnil, then clear F->explicit_name.
909 If EXPLICIT is zero, that indicates that Emacs redisplay code is
910 suggesting a new name, which lisp code should override; if
911 F->explicit_name is set, ignore the new name; otherwise, set it. */
914 x_set_name (f
, name
, explicit)
919 /* Make sure that requests from lisp code override requests from
920 Emacs redisplay code. */
923 /* If we're switching from explicit to implicit, we had better
924 update the mode lines and thereby update the title. */
925 if (f
->explicit_name
&& NILP (name
))
926 update_mode_lines
= 1;
928 f
->explicit_name
= ! NILP (name
);
930 else if (f
->explicit_name
)
933 /* If NAME is nil, set the name to the x_id_name. */
935 name
= build_string (x_id_name
);
937 CHECK_STRING (name
, 0);
939 /* Don't change the name if it's already NAME. */
940 if (! NILP (Fstring_equal (name
, f
->name
)))
943 if (FRAME_X_WINDOW (f
))
950 text
.value
= XSTRING (name
)->data
;
951 text
.encoding
= XA_STRING
;
953 text
.nitems
= XSTRING (name
)->size
;
954 XSetWMName (x_current_display
, FRAME_X_WINDOW (f
), &text
);
955 XSetWMIconName (x_current_display
, FRAME_X_WINDOW (f
), &text
);
958 XSetIconName (XDISPLAY
FRAME_X_WINDOW (f
),
959 XSTRING (name
)->data
);
960 XStoreName (XDISPLAY
FRAME_X_WINDOW (f
),
961 XSTRING (name
)->data
);
970 /* This function should be called when the user's lisp code has
971 specified a name for the frame; the name will override any set by the
974 x_explicitly_set_name (f
, arg
, oldval
)
976 Lisp_Object arg
, oldval
;
978 x_set_name (f
, arg
, 1);
981 /* This function should be called by Emacs redisplay code to set the
982 name; names set this way will never override names set by the user's
985 x_implicitly_set_name (f
, arg
, oldval
)
987 Lisp_Object arg
, oldval
;
989 x_set_name (f
, arg
, 0);
993 x_set_autoraise (f
, arg
, oldval
)
995 Lisp_Object arg
, oldval
;
997 f
->auto_raise
= !EQ (Qnil
, arg
);
1001 x_set_autolower (f
, arg
, oldval
)
1003 Lisp_Object arg
, oldval
;
1005 f
->auto_lower
= !EQ (Qnil
, arg
);
1009 x_set_vertical_scroll_bars (f
, arg
, oldval
)
1011 Lisp_Object arg
, oldval
;
1013 if (NILP (arg
) != ! FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
1015 FRAME_HAS_VERTICAL_SCROLL_BARS (f
) = ! NILP (arg
);
1017 /* We set this parameter before creating the X window for the
1018 frame, so we can get the geometry right from the start.
1019 However, if the window hasn't been created yet, we shouldn't
1020 call x_set_window_size. */
1021 if (FRAME_X_WINDOW (f
))
1022 x_set_window_size (f
, FRAME_WIDTH (f
), FRAME_HEIGHT (f
));
1030 /* I believe this function is obsolete with respect to the new face display
1032 x_set_face (scr
, font
, background
, foreground
, stipple
)
1035 unsigned long background
, foreground
;
1038 XGCValues gc_values
;
1040 unsigned long gc_mask
;
1041 struct face
*new_face
;
1042 unsigned int width
= 16;
1043 unsigned int height
= 16;
1045 if (n_faces
== MAX_FACES_AND_GLYPHS
)
1048 /* Create the Graphics Context. */
1049 gc_values
.font
= font
->fid
;
1050 gc_values
.foreground
= foreground
;
1051 gc_values
.background
= background
;
1052 gc_values
.line_width
= 0;
1053 gc_mask
= GCLineWidth
| GCFont
| GCForeground
| GCBackground
;
1057 = XCreateBitmapFromData (x_current_display
, ROOT_WINDOW
,
1058 (char *) stipple
, width
, height
);
1059 gc_mask
|= GCStipple
;
1062 temp_gc
= XCreateGC (x_current_display
, FRAME_X_WINDOW (scr
),
1063 gc_mask
, &gc_values
);
1066 new_face
= (struct face
*) xmalloc (sizeof (struct face
));
1069 XFreeGC (x_current_display
, temp_gc
);
1073 new_face
->font
= font
;
1074 new_face
->foreground
= foreground
;
1075 new_face
->background
= background
;
1076 new_face
->face_gc
= temp_gc
;
1078 new_face
->stipple
= gc_values
.stipple
;
1080 x_face_table
[++n_faces
] = new_face
;
1085 x_set_glyph (scr
, glyph
)
1090 DEFUN ("x-set-face-font", Fx_set_face_font
, Sx_set_face_font
, 4, 2, 0,
1091 "Specify face table entry FACE-CODE to be the font named by FONT,\n\
1092 in colors FOREGROUND and BACKGROUND.")
1093 (face_code
, font_name
, foreground
, background
)
1094 Lisp_Object face_code
;
1095 Lisp_Object font_name
;
1096 Lisp_Object foreground
;
1097 Lisp_Object background
;
1099 register struct face
*fp
; /* Current face info. */
1100 register int fn
; /* Face number. */
1101 register FONT_TYPE
*f
; /* Font data structure. */
1102 unsigned char *newname
;
1105 XGCValues gc_values
;
1107 /* Need to do something about this. */
1108 Drawable drawable
= FRAME_X_WINDOW (selected_frame
);
1110 CHECK_NUMBER (face_code
, 1);
1111 CHECK_STRING (font_name
, 2);
1113 if (EQ (foreground
, Qnil
) || EQ (background
, Qnil
))
1115 fg
= selected_frame
->display
.x
->foreground_pixel
;
1116 bg
= selected_frame
->display
.x
->background_pixel
;
1120 CHECK_NUMBER (foreground
, 0);
1121 CHECK_NUMBER (background
, 1);
1123 fg
= x_decode_color (XINT (foreground
), BLACK_PIX_DEFAULT
);
1124 bg
= x_decode_color (XINT (background
), WHITE_PIX_DEFAULT
);
1127 fn
= XINT (face_code
);
1128 if ((fn
< 1) || (fn
> 255))
1129 error ("Invalid face code, %d", fn
);
1131 newname
= XSTRING (font_name
)->data
;
1133 f
= (*newname
== 0 ? 0 : XGetFont (newname
));
1136 error ("Font \"%s\" is not defined", newname
);
1138 fp
= x_face_table
[fn
];
1141 x_face_table
[fn
] = fp
= (struct face
*) xmalloc (sizeof (struct face
));
1142 bzero (fp
, sizeof (struct face
));
1143 fp
->face_type
= x_pixmap
;
1145 else if (FACE_IS_FONT (fn
))
1148 XFreeGC (FACE_FONT (fn
));
1151 else if (FACE_IS_IMAGE (fn
)) /* This should not happen... */
1154 XFreePixmap (x_current_display
, FACE_IMAGE (fn
));
1155 fp
->face_type
= x_font
;
1161 fp
->face_GLYPH
.font_desc
.font
= f
;
1162 gc_values
.font
= f
->fid
;
1163 gc_values
.foreground
= fg
;
1164 gc_values
.background
= bg
;
1165 fp
->face_GLYPH
.font_desc
.face_gc
= XCreateGC (x_current_display
,
1166 drawable
, GCFont
| GCForeground
1167 | GCBackground
, &gc_values
);
1168 fp
->face_GLYPH
.font_desc
.font_width
= FONT_WIDTH (f
);
1169 fp
->face_GLYPH
.font_desc
.font_height
= FONT_HEIGHT (f
);
1175 DEFUN ("x-set-face", Fx_set_face
, Sx_set_face
, 4, 4, 0,
1176 "Specify face table entry FACE-CODE to be the font named by FONT,\n\
1177 in colors FOREGROUND and BACKGROUND.")
1178 (face_code
, font_name
, foreground
, background
)
1179 Lisp_Object face_code
;
1180 Lisp_Object font_name
;
1181 Lisp_Object foreground
;
1182 Lisp_Object background
;
1184 register struct face
*fp
; /* Current face info. */
1185 register int fn
; /* Face number. */
1186 register FONT_TYPE
*f
; /* Font data structure. */
1187 unsigned char *newname
;
1189 CHECK_NUMBER (face_code
, 1);
1190 CHECK_STRING (font_name
, 2);
1192 fn
= XINT (face_code
);
1193 if ((fn
< 1) || (fn
> 255))
1194 error ("Invalid face code, %d", fn
);
1196 /* Ask the server to find the specified font. */
1197 newname
= XSTRING (font_name
)->data
;
1199 f
= (*newname
== 0 ? 0 : XGetFont (newname
));
1202 error ("Font \"%s\" is not defined", newname
);
1204 /* Get the face structure for face_code in the face table.
1205 Make sure it exists. */
1206 fp
= x_face_table
[fn
];
1209 x_face_table
[fn
] = fp
= (struct face
*) xmalloc (sizeof (struct face
));
1210 bzero (fp
, sizeof (struct face
));
1213 /* If this face code already exists, get rid of the old font. */
1214 if (fp
->font
!= 0 && fp
->font
!= f
)
1217 XLoseFont (fp
->font
);
1221 /* Store the specified information in FP. */
1222 fp
->fg
= x_decode_color (foreground
, BLACK_PIX_DEFAULT
);
1223 fp
->bg
= x_decode_color (background
, WHITE_PIX_DEFAULT
);
1231 /* This is excluded because there is no painless way
1232 to get or to remember the name of the font. */
1234 DEFUN ("x-get-face", Fx_get_face
, Sx_get_face
, 1, 1, 0,
1235 "Get data defining face code FACE. FACE is an integer.\n\
1236 The value is a list (FONT FG-COLOR BG-COLOR).")
1240 register struct face
*fp
; /* Current face info. */
1241 register int fn
; /* Face number. */
1243 CHECK_NUMBER (face
, 1);
1245 if ((fn
< 1) || (fn
> 255))
1246 error ("Invalid face code, %d", fn
);
1248 /* Make sure the face table exists and this face code is defined. */
1249 if (x_face_table
== 0 || x_face_table
[fn
] == 0)
1252 fp
= x_face_table
[fn
];
1254 return Fcons (build_string (fp
->name
),
1255 Fcons (make_number (fp
->fg
),
1256 Fcons (make_number (fp
->bg
), Qnil
)));
1260 /* Subroutines of creating an X frame. */
1263 extern char *x_get_string_resource ();
1264 extern XrmDatabase
x_load_resources ();
1266 DEFUN ("x-get-resource", Fx_get_resource
, Sx_get_resource
, 2, 4, 0,
1267 "Return the value of ATTRIBUTE, of class CLASS, from the X defaults database.\n\
1268 This uses `INSTANCE.ATTRIBUTE' as the key and `Emacs.CLASS' as the\n\
1269 class, where INSTANCE is the name under which Emacs was invoked.\n\
1271 The optional arguments COMPONENT and SUBCLASS add to the key and the\n\
1272 class, respectively. You must specify both of them or neither.\n\
1273 If you specify them, the key is `INSTANCE.COMPONENT.ATTRIBUTE'\n\
1274 and the class is `Emacs.CLASS.SUBCLASS'.")
1275 (attribute
, class, component
, subclass
)
1276 Lisp_Object attribute
, class, component
, subclass
;
1278 register char *value
;
1282 CHECK_STRING (attribute
, 0);
1283 CHECK_STRING (class, 0);
1285 if (!NILP (component
))
1286 CHECK_STRING (component
, 1);
1287 if (!NILP (subclass
))
1288 CHECK_STRING (subclass
, 2);
1289 if (NILP (component
) != NILP (subclass
))
1290 error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither");
1292 if (NILP (component
))
1294 /* Allocate space for the components, the dots which separate them,
1295 and the final '\0'. */
1296 name_key
= (char *) alloca (XSTRING (Vinvocation_name
)->size
1297 + XSTRING (attribute
)->size
1299 class_key
= (char *) alloca ((sizeof (EMACS_CLASS
) - 1)
1300 + XSTRING (class)->size
1303 sprintf (name_key
, "%s.%s",
1304 XSTRING (Vinvocation_name
)->data
,
1305 XSTRING (attribute
)->data
);
1306 sprintf (class_key
, "%s.%s",
1308 XSTRING (class)->data
);
1312 name_key
= (char *) alloca (XSTRING (Vinvocation_name
)->size
1313 + XSTRING (component
)->size
1314 + XSTRING (attribute
)->size
1317 class_key
= (char *) alloca ((sizeof (EMACS_CLASS
) - 1)
1318 + XSTRING (class)->size
1319 + XSTRING (subclass
)->size
1322 sprintf (name_key
, "%s.%s.%s",
1323 XSTRING (Vinvocation_name
)->data
,
1324 XSTRING (component
)->data
,
1325 XSTRING (attribute
)->data
);
1326 sprintf (class_key
, "%s.%s",
1328 XSTRING (class)->data
,
1329 XSTRING (subclass
)->data
);
1332 value
= x_get_string_resource (xrdb
, name_key
, class_key
);
1334 if (value
!= (char *) 0)
1335 return build_string (value
);
1342 DEFUN ("x-get-default", Fx_get_default
, Sx_get_default
, 1, 1, 0,
1343 "Get X default ATTRIBUTE from the system, or nil if no default.\n\
1344 Value is a string (when not nil) and ATTRIBUTE is also a string.\n\
1345 The defaults are specified in the file `~/.Xdefaults'.")
1349 register unsigned char *value
;
1351 CHECK_STRING (arg
, 1);
1353 value
= (unsigned char *) XGetDefault (XDISPLAY
1354 XSTRING (Vinvocation_name
)->data
,
1355 XSTRING (arg
)->data
);
1357 /* Try reversing last two args, in case this is the buggy version of X. */
1358 value
= (unsigned char *) XGetDefault (XDISPLAY
1359 XSTRING (arg
)->data
,
1360 XSTRING (Vinvocation_name
)->data
);
1362 return build_string (value
);
1367 #define Fx_get_resource(attribute, class, component, subclass) \
1368 Fx_get_default(attribute)
1372 /* Types we might convert a resource string into. */
1375 number
, boolean
, string
, symbol
,
1378 /* Return the value of parameter PARAM.
1380 First search ALIST, then Vdefault_frame_alist, then the X defaults
1381 database, using ATTRIBUTE as the attribute name and CLASS as its class.
1383 Convert the resource to the type specified by desired_type.
1385 If no default is specified, return Qunbound. If you call
1386 x_get_arg, make sure you deal with Qunbound in a reasonable way,
1387 and don't let it get stored in any lisp-visible variables! */
1390 x_get_arg (alist
, param
, attribute
, class, type
)
1391 Lisp_Object alist
, param
;
1394 enum resource_types type
;
1396 register Lisp_Object tem
;
1398 tem
= Fassq (param
, alist
);
1400 tem
= Fassq (param
, Vdefault_frame_alist
);
1406 tem
= Fx_get_resource (build_string (attribute
),
1407 build_string (class),
1416 return make_number (atoi (XSTRING (tem
)->data
));
1419 tem
= Fdowncase (tem
);
1420 if (!strcmp (XSTRING (tem
)->data
, "on")
1421 || !strcmp (XSTRING (tem
)->data
, "true"))
1430 /* As a special case, we map the values `true' and `on'
1431 to Qt, and `false' and `off' to Qnil. */
1433 Lisp_Object lower
= Fdowncase (tem
);
1434 if (!strcmp (XSTRING (tem
)->data
, "on")
1435 || !strcmp (XSTRING (tem
)->data
, "true"))
1437 else (!strcmp (XSTRING (tem
)->data
, "off")
1438 || !strcmp (XSTRING (tem
)->data
, "false"))
1441 return intern (tem
);
1454 /* Record in frame F the specified or default value according to ALIST
1455 of the parameter named PARAM (a Lisp symbol).
1456 If no value is specified for PARAM, look for an X default for XPROP
1457 on the frame named NAME.
1458 If that is not found either, use the value DEFLT. */
1461 x_default_parameter (f
, alist
, prop
, deflt
, xprop
, xclass
, type
)
1468 enum resource_types type
;
1472 tem
= x_get_arg (alist
, prop
, xprop
, xclass
, type
);
1473 if (EQ (tem
, Qunbound
))
1475 x_set_frame_parameters (f
, Fcons (Fcons (prop
, tem
), Qnil
));
1479 DEFUN ("x-geometry", Fx_geometry
, Sx_geometry
, 1, 1, 0,
1480 "Parse an X-style geometry string STRING.\n\
1481 Returns an alist of the form ((top . TOP), (left . LEFT) ... ).")
1486 unsigned int width
, height
;
1487 Lisp_Object values
[4];
1489 CHECK_STRING (string
, 0);
1491 geometry
= XParseGeometry ((char *) XSTRING (string
)->data
,
1492 &x
, &y
, &width
, &height
);
1494 switch (geometry
& 0xf) /* Mask out {X,Y}Negative */
1496 case (XValue
| YValue
):
1497 /* What's one pixel among friends?
1498 Perhaps fix this some day by returning symbol `extreme-top'... */
1499 if (x
== 0 && (geometry
& XNegative
))
1501 if (y
== 0 && (geometry
& YNegative
))
1503 values
[0] = Fcons (Qleft
, make_number (x
));
1504 values
[1] = Fcons (Qtop
, make_number (y
));
1505 return Flist (2, values
);
1508 case (WidthValue
| HeightValue
):
1509 values
[0] = Fcons (Qwidth
, make_number (width
));
1510 values
[1] = Fcons (Qheight
, make_number (height
));
1511 return Flist (2, values
);
1514 case (XValue
| YValue
| WidthValue
| HeightValue
):
1515 if (x
== 0 && (geometry
& XNegative
))
1517 if (y
== 0 && (geometry
& YNegative
))
1519 values
[0] = Fcons (Qwidth
, make_number (width
));
1520 values
[1] = Fcons (Qheight
, make_number (height
));
1521 values
[2] = Fcons (Qleft
, make_number (x
));
1522 values
[3] = Fcons (Qtop
, make_number (y
));
1523 return Flist (4, values
);
1530 error ("Must specify x and y value, and/or width and height");
1535 /* Calculate the desired size and position of this window,
1536 or set rubber-band prompting if none. */
1538 #define DEFAULT_ROWS 40
1539 #define DEFAULT_COLS 80
1542 x_figure_window_size (f
, parms
)
1546 register Lisp_Object tem0
, tem1
;
1547 int height
, width
, left
, top
;
1548 register int geometry
;
1549 long window_prompting
= 0;
1551 /* Default values if we fall through.
1552 Actually, if that happens we should get
1553 window manager prompting. */
1554 f
->width
= DEFAULT_COLS
;
1555 f
->height
= DEFAULT_ROWS
;
1556 f
->display
.x
->top_pos
= 1;
1557 f
->display
.x
->left_pos
= 1;
1559 tem0
= x_get_arg (parms
, Qheight
, 0, 0, number
);
1560 tem1
= x_get_arg (parms
, Qwidth
, 0, 0, number
);
1561 if (! EQ (tem0
, Qunbound
) && ! EQ (tem1
, Qunbound
))
1563 CHECK_NUMBER (tem0
, 0);
1564 CHECK_NUMBER (tem1
, 0);
1565 f
->height
= XINT (tem0
);
1566 f
->width
= XINT (tem1
);
1567 window_prompting
|= USSize
;
1569 else if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
1570 error ("Must specify *both* height and width");
1572 f
->display
.x
->vertical_scroll_bar_extra
=
1573 (FRAME_HAS_VERTICAL_SCROLL_BARS (f
)
1574 ? VERTICAL_SCROLL_BAR_PIXEL_WIDTH (f
)
1576 f
->display
.x
->pixel_width
= CHAR_TO_PIXEL_WIDTH (f
, f
->width
);
1577 f
->display
.x
->pixel_height
= CHAR_TO_PIXEL_HEIGHT (f
, f
->height
);
1579 tem0
= x_get_arg (parms
, Qtop
, 0, 0, number
);
1580 tem1
= x_get_arg (parms
, Qleft
, 0, 0, number
);
1581 if (! EQ (tem0
, Qunbound
) && ! EQ (tem1
, Qunbound
))
1583 CHECK_NUMBER (tem0
, 0);
1584 CHECK_NUMBER (tem1
, 0);
1585 f
->display
.x
->top_pos
= XINT (tem0
);
1586 f
->display
.x
->left_pos
= XINT (tem1
);
1587 x_calc_absolute_position (f
);
1588 window_prompting
|= USPosition
;
1590 else if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
1591 error ("Must specify *both* top and left corners");
1593 switch (window_prompting
)
1595 case USSize
| USPosition
:
1596 return window_prompting
;
1599 case USSize
: /* Got the size, need the position. */
1600 window_prompting
|= PPosition
;
1601 return window_prompting
;
1604 case USPosition
: /* Got the position, need the size. */
1605 window_prompting
|= PSize
;
1606 return window_prompting
;
1609 case 0: /* Got nothing, take both from geometry. */
1610 window_prompting
|= PPosition
| PSize
;
1611 return window_prompting
;
1615 /* Somehow a bit got set in window_prompting that we didn't
1625 XSetWindowAttributes attributes
;
1626 unsigned long attribute_mask
;
1627 XClassHint class_hints
;
1629 attributes
.background_pixel
= f
->display
.x
->background_pixel
;
1630 attributes
.border_pixel
= f
->display
.x
->border_pixel
;
1631 attributes
.bit_gravity
= StaticGravity
;
1632 attributes
.backing_store
= NotUseful
;
1633 attributes
.save_under
= True
;
1634 attributes
.event_mask
= STANDARD_EVENT_SET
;
1635 attribute_mask
= (CWBackPixel
| CWBorderPixel
| CWBitGravity
1637 | CWBackingStore
| CWSaveUnder
1643 = XCreateWindow (x_current_display
, ROOT_WINDOW
,
1644 f
->display
.x
->left_pos
,
1645 f
->display
.x
->top_pos
,
1646 PIXEL_WIDTH (f
), PIXEL_HEIGHT (f
),
1647 f
->display
.x
->border_width
,
1648 CopyFromParent
, /* depth */
1649 InputOutput
, /* class */
1650 screen_visual
, /* set in Fx_open_connection */
1651 attribute_mask
, &attributes
);
1653 class_hints
.res_name
= (char *) XSTRING (f
->name
)->data
;
1654 class_hints
.res_class
= EMACS_CLASS
;
1655 XSetClassHint (x_current_display
, FRAME_X_WINDOW (f
), &class_hints
);
1657 /* This indicates that we use the "Passive Input" input model.
1658 Unless we do this, we don't get the Focus{In,Out} events that we
1659 need to draw the cursor correctly. Accursed bureaucrats.
1660 XWhipsAndChains (x_current_display, IronMaiden, &TheRack); */
1662 f
->display
.x
->wm_hints
.input
= True
;
1663 f
->display
.x
->wm_hints
.flags
|= InputHint
;
1664 XSetWMHints (x_current_display
, FRAME_X_WINDOW (f
), &f
->display
.x
->wm_hints
);
1666 /* x_set_name normally ignores requests to set the name if the
1667 requested name is the same as the current name. This is the one
1668 place where that assumption isn't correct; f->name is set, but
1669 the X server hasn't been told. */
1671 Lisp_Object name
= f
->name
;
1672 int explicit = f
->explicit_name
;
1675 f
->explicit_name
= 0;
1676 x_set_name (f
, name
, explicit);
1679 XDefineCursor (XDISPLAY
FRAME_X_WINDOW (f
),
1680 f
->display
.x
->text_cursor
);
1683 if (FRAME_X_WINDOW (f
) == 0)
1684 error ("Unable to create window.");
1687 /* Handle the icon stuff for this window. Perhaps later we might
1688 want an x_set_icon_position which can be called interactively as
1696 Lisp_Object icon_x
, icon_y
;
1698 /* Set the position of the icon. Note that twm groups all
1699 icons in an icon window. */
1700 icon_x
= x_get_arg (parms
, Qicon_left
, 0, 0, number
);
1701 icon_y
= x_get_arg (parms
, Qicon_top
, 0, 0, number
);
1702 if (!EQ (icon_x
, Qunbound
) && !EQ (icon_y
, Qunbound
))
1704 CHECK_NUMBER (icon_x
, 0);
1705 CHECK_NUMBER (icon_y
, 0);
1707 else if (!EQ (icon_x
, Qunbound
) || !EQ (icon_y
, Qunbound
))
1708 error ("Both left and top icon corners of icon must be specified");
1712 if (! EQ (icon_x
, Qunbound
))
1713 x_wm_set_icon_position (f
, XINT (icon_x
), XINT (icon_y
));
1715 /* Start up iconic or window? */
1716 x_wm_set_window_state
1717 (f
, (EQ (x_get_arg (parms
, Qvisibility
, 0, 0, symbol
), Qicon
)
1724 /* Make the GC's needed for this window, setting the
1725 background, border and mouse colors; also create the
1726 mouse cursor and the gray border tile. */
1728 static char cursor_bits
[] =
1730 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1731 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1732 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1733 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1740 XGCValues gc_values
;
1744 /* Create the GC's of this frame.
1745 Note that many default values are used. */
1748 gc_values
.font
= f
->display
.x
->font
->fid
;
1749 gc_values
.foreground
= f
->display
.x
->foreground_pixel
;
1750 gc_values
.background
= f
->display
.x
->background_pixel
;
1751 gc_values
.line_width
= 0; /* Means 1 using fast algorithm. */
1752 f
->display
.x
->normal_gc
= XCreateGC (x_current_display
,
1754 GCLineWidth
| GCFont
1755 | GCForeground
| GCBackground
,
1758 /* Reverse video style. */
1759 gc_values
.foreground
= f
->display
.x
->background_pixel
;
1760 gc_values
.background
= f
->display
.x
->foreground_pixel
;
1761 f
->display
.x
->reverse_gc
= XCreateGC (x_current_display
,
1763 GCFont
| GCForeground
| GCBackground
1767 /* Cursor has cursor-color background, background-color foreground. */
1768 gc_values
.foreground
= f
->display
.x
->background_pixel
;
1769 gc_values
.background
= f
->display
.x
->cursor_pixel
;
1770 gc_values
.fill_style
= FillOpaqueStippled
;
1772 = XCreateBitmapFromData (x_current_display
, ROOT_WINDOW
,
1773 cursor_bits
, 16, 16);
1774 f
->display
.x
->cursor_gc
1775 = XCreateGC (x_current_display
, FRAME_X_WINDOW (f
),
1776 (GCFont
| GCForeground
| GCBackground
1777 | GCFillStyle
| GCStipple
| GCLineWidth
),
1780 /* Create the gray border tile used when the pointer is not in
1781 the frame. Since this depends on the frame's pixel values,
1782 this must be done on a per-frame basis. */
1783 f
->display
.x
->border_tile
1784 = (XCreatePixmapFromBitmapData
1785 (x_current_display
, ROOT_WINDOW
,
1786 gray_bits
, gray_width
, gray_height
,
1787 f
->display
.x
->foreground_pixel
,
1788 f
->display
.x
->background_pixel
,
1789 DefaultDepth (x_current_display
, XDefaultScreen (x_current_display
))));
1791 #endif /* HAVE_X11 */
1793 DEFUN ("x-create-frame", Fx_create_frame
, Sx_create_frame
,
1795 "Make a new X window, which is called a \"frame\" in Emacs terms.\n\
1796 Return an Emacs frame object representing the X window.\n\
1797 ALIST is an alist of frame parameters.\n\
1798 If the parameters specify that the frame should not have a minibuffer,\n\
1799 and do not specify a specific minibuffer window to use,\n\
1800 then `default-minibuffer-frame' must be a frame whose minibuffer can\n\
1801 be shared by the new frame.")
1807 Lisp_Object frame
, tem
;
1809 int minibuffer_only
= 0;
1810 long window_prompting
= 0;
1813 if (x_current_display
== 0)
1814 error ("X windows are not in use or not initialized");
1816 name
= x_get_arg (parms
, Qname
, "title", "Title", string
);
1817 if (XTYPE (name
) != Lisp_String
1818 && ! EQ (name
, Qunbound
)
1820 error ("x-create-frame: name parameter must be a string");
1822 tem
= x_get_arg (parms
, Qminibuffer
, 0, 0, symbol
);
1823 if (EQ (tem
, Qnone
) || NILP (tem
))
1824 f
= make_frame_without_minibuffer (Qnil
);
1825 else if (EQ (tem
, Qonly
))
1827 f
= make_minibuffer_frame ();
1828 minibuffer_only
= 1;
1830 else if (XTYPE (tem
) == Lisp_Window
)
1831 f
= make_frame_without_minibuffer (tem
);
1835 /* Note that X Windows does support scroll bars. */
1836 FRAME_CAN_HAVE_SCROLL_BARS (f
) = 1;
1838 /* Set the name; the functions to which we pass f expect the name to
1840 if (EQ (name
, Qunbound
) || NILP (name
))
1842 f
->name
= build_string (x_id_name
);
1843 f
->explicit_name
= 0;
1848 f
->explicit_name
= 1;
1851 XSET (frame
, Lisp_Frame
, f
);
1852 f
->output_method
= output_x_window
;
1853 f
->display
.x
= (struct x_display
*) xmalloc (sizeof (struct x_display
));
1854 bzero (f
->display
.x
, sizeof (struct x_display
));
1856 /* Note that the frame has no physical cursor right now. */
1857 f
->phys_cursor_x
= -1;
1859 /* Extract the window parameters from the supplied values
1860 that are needed to determine window geometry. */
1861 x_default_parameter (f
, parms
, Qfont
, build_string ("9x15"),
1862 "font", "Font", string
);
1863 x_default_parameter (f
, parms
, Qborder_width
, make_number (2),
1864 "borderwidth", "BorderWidth", number
);
1865 /* This defaults to 2 in order to match xterm. */
1866 x_default_parameter (f
, parms
, Qinternal_border_width
, make_number (2),
1867 "internalBorderWidth", "BorderWidth", number
);
1868 x_default_parameter (f
, parms
, Qvertical_scroll_bars
, Qt
,
1869 "verticalScrollBars", "ScrollBars", boolean
);
1871 /* Also do the stuff which must be set before the window exists. */
1872 x_default_parameter (f
, parms
, Qforeground_color
, build_string ("black"),
1873 "foreground", "Foreground", string
);
1874 x_default_parameter (f
, parms
, Qbackground_color
, build_string ("white"),
1875 "background", "Background", string
);
1876 x_default_parameter (f
, parms
, Qmouse_color
, build_string ("black"),
1877 "pointerColor", "Foreground", string
);
1878 x_default_parameter (f
, parms
, Qcursor_color
, build_string ("black"),
1879 "cursorColor", "Foreground", string
);
1880 x_default_parameter (f
, parms
, Qborder_color
, build_string ("black"),
1881 "borderColor", "BorderColor", string
);
1883 f
->display
.x
->parent_desc
= ROOT_WINDOW
;
1884 window_prompting
= x_figure_window_size (f
, parms
);
1890 /* We need to do this after creating the X window, so that the
1891 icon-creation functions can say whose icon they're describing. */
1892 x_default_parameter (f
, parms
, Qicon_type
, Qnil
,
1893 "iconType", "IconType", symbol
);
1895 x_default_parameter (f
, parms
, Qauto_raise
, Qnil
,
1896 "autoRaise", "AutoRaiseLower", boolean
);
1897 x_default_parameter (f
, parms
, Qauto_lower
, Qnil
,
1898 "autoLower", "AutoRaiseLower", boolean
);
1899 x_default_parameter (f
, parms
, Qcursor_type
, Qbox
,
1900 "cursorType", "CursorType", symbol
);
1902 /* Dimensions, especially f->height, must be done via change_frame_size.
1903 Change will not be effected unless different from the current
1907 f
->height
= f
->width
= 0;
1908 change_frame_size (f
, height
, width
, 1, 0);
1910 x_default_parameter (f
, parms
, Qmenu_bar_lines
, make_number (0),
1911 "menuBarLines", "MenuBarLines", number
);
1914 x_wm_set_size_hint (f
, window_prompting
);
1917 tem
= x_get_arg (parms
, Qunsplittable
, 0, 0, boolean
);
1918 f
->no_split
= minibuffer_only
|| EQ (tem
, Qt
);
1920 /* Make the window appear on the frame and enable display,
1921 unless the caller says not to. */
1923 Lisp_Object visibility
= x_get_arg (parms
, Qvisibility
, 0, 0, symbol
);
1925 if (EQ (visibility
, Qunbound
))
1928 if (EQ (visibility
, Qicon
))
1929 x_iconify_frame (f
);
1930 else if (! NILP (visibility
))
1931 x_make_frame_visible (f
);
1933 /* Must have been Qnil. */
1940 Lisp_Object frame
, tem
;
1942 int pixelwidth
, pixelheight
;
1947 int minibuffer_only
= 0;
1948 Lisp_Object vscroll
, hscroll
;
1950 if (x_current_display
== 0)
1951 error ("X windows are not in use or not initialized");
1953 name
= Fassq (Qname
, parms
);
1955 tem
= x_get_arg (parms
, Qminibuffer
, 0, 0, symbol
);
1956 if (EQ (tem
, Qnone
))
1957 f
= make_frame_without_minibuffer (Qnil
);
1958 else if (EQ (tem
, Qonly
))
1960 f
= make_minibuffer_frame ();
1961 minibuffer_only
= 1;
1963 else if (EQ (tem
, Qnil
) || EQ (tem
, Qunbound
))
1966 f
= make_frame_without_minibuffer (tem
);
1968 parent
= ROOT_WINDOW
;
1970 XSET (frame
, Lisp_Frame
, f
);
1971 f
->output_method
= output_x_window
;
1972 f
->display
.x
= (struct x_display
*) xmalloc (sizeof (struct x_display
));
1973 bzero (f
->display
.x
, sizeof (struct x_display
));
1975 /* Some temprorary default values for height and width. */
1978 f
->display
.x
->left_pos
= -1;
1979 f
->display
.x
->top_pos
= -1;
1981 /* Give the frame a default name (which may be overridden with PARMS). */
1983 strncpy (iconidentity
, ICONTAG
, MAXICID
);
1984 if (gethostname (&iconidentity
[sizeof (ICONTAG
) - 1],
1985 (MAXICID
- 1) - sizeof (ICONTAG
)))
1986 iconidentity
[sizeof (ICONTAG
) - 2] = '\0';
1987 f
->name
= build_string (iconidentity
);
1989 /* Extract some window parameters from the supplied values.
1990 These are the parameters that affect window geometry. */
1992 tem
= x_get_arg (parms
, Qfont
, "BodyFont", 0, string
);
1993 if (EQ (tem
, Qunbound
))
1994 tem
= build_string ("9x15");
1995 x_set_font (f
, tem
, Qnil
);
1996 x_default_parameter (f
, parms
, Qborder_color
,
1997 build_string ("black"), "Border", 0, string
);
1998 x_default_parameter (f
, parms
, Qbackground_color
,
1999 build_string ("white"), "Background", 0, string
);
2000 x_default_parameter (f
, parms
, Qforeground_color
,
2001 build_string ("black"), "Foreground", 0, string
);
2002 x_default_parameter (f
, parms
, Qmouse_color
,
2003 build_string ("black"), "Mouse", 0, string
);
2004 x_default_parameter (f
, parms
, Qcursor_color
,
2005 build_string ("black"), "Cursor", 0, string
);
2006 x_default_parameter (f
, parms
, Qborder_width
,
2007 make_number (2), "BorderWidth", 0, number
);
2008 x_default_parameter (f
, parms
, Qinternal_border_width
,
2009 make_number (4), "InternalBorderWidth", 0, number
);
2010 x_default_parameter (f
, parms
, Qauto_raise
,
2011 Qnil
, "AutoRaise", 0, boolean
);
2013 hscroll
= EQ (x_get_arg (parms
, Qhorizontal_scroll_bar
, 0, 0, boolean
), Qt
);
2014 vscroll
= EQ (x_get_arg (parms
, Qvertical_scroll_bar
, 0, 0, boolean
), Qt
);
2016 if (f
->display
.x
->internal_border_width
< 0)
2017 f
->display
.x
->internal_border_width
= 0;
2019 tem
= x_get_arg (parms
, Qwindow_id
, 0, 0, number
);
2020 if (!EQ (tem
, Qunbound
))
2022 WINDOWINFO_TYPE wininfo
;
2024 Window
*children
, root
;
2026 CHECK_NUMBER (tem
, 0);
2027 FRAME_X_WINDOW (f
) = (Window
) XINT (tem
);
2030 XGetWindowInfo (FRAME_X_WINDOW (f
), &wininfo
);
2031 XQueryTree (FRAME_X_WINDOW (f
), &parent
, &nchildren
, &children
);
2035 height
= PIXEL_TO_CHAR_HEIGHT (f
, wininfo
.height
);
2036 width
= PIXEL_TO_CHAR_WIDTH (f
, wininfo
.width
);
2037 f
->display
.x
->left_pos
= wininfo
.x
;
2038 f
->display
.x
->top_pos
= wininfo
.y
;
2039 FRAME_SET_VISIBILITY (f
, wininfo
.mapped
!= 0);
2040 f
->display
.x
->border_width
= wininfo
.bdrwidth
;
2041 f
->display
.x
->parent_desc
= parent
;
2045 tem
= x_get_arg (parms
, Qparent_id
, 0, 0, number
);
2046 if (!EQ (tem
, Qunbound
))
2048 CHECK_NUMBER (tem
, 0);
2049 parent
= (Window
) XINT (tem
);
2051 f
->display
.x
->parent_desc
= parent
;
2052 tem
= x_get_arg (parms
, Qheight
, 0, 0, number
);
2053 if (EQ (tem
, Qunbound
))
2055 tem
= x_get_arg (parms
, Qwidth
, 0, 0, number
);
2056 if (EQ (tem
, Qunbound
))
2058 tem
= x_get_arg (parms
, Qtop
, 0, 0, number
);
2059 if (EQ (tem
, Qunbound
))
2060 tem
= x_get_arg (parms
, Qleft
, 0, 0, number
);
2063 /* Now TEM is Qunbound if no edge or size was specified.
2064 In that case, we must do rubber-banding. */
2065 if (EQ (tem
, Qunbound
))
2067 tem
= x_get_arg (parms
, Qgeometry
, 0, 0, number
);
2069 &f
->display
.x
->left_pos
, &f
->display
.x
->top_pos
,
2071 (XTYPE (tem
) == Lisp_String
2072 ? (char *) XSTRING (tem
)->data
: ""),
2073 XSTRING (f
->name
)->data
,
2074 !NILP (hscroll
), !NILP (vscroll
));
2078 /* Here if at least one edge or size was specified.
2079 Demand that they all were specified, and use them. */
2080 tem
= x_get_arg (parms
, Qheight
, 0, 0, number
);
2081 if (EQ (tem
, Qunbound
))
2082 error ("Height not specified");
2083 CHECK_NUMBER (tem
, 0);
2084 height
= XINT (tem
);
2086 tem
= x_get_arg (parms
, Qwidth
, 0, 0, number
);
2087 if (EQ (tem
, Qunbound
))
2088 error ("Width not specified");
2089 CHECK_NUMBER (tem
, 0);
2092 tem
= x_get_arg (parms
, Qtop
, 0, 0, number
);
2093 if (EQ (tem
, Qunbound
))
2094 error ("Top position not specified");
2095 CHECK_NUMBER (tem
, 0);
2096 f
->display
.x
->left_pos
= XINT (tem
);
2098 tem
= x_get_arg (parms
, Qleft
, 0, 0, number
);
2099 if (EQ (tem
, Qunbound
))
2100 error ("Left position not specified");
2101 CHECK_NUMBER (tem
, 0);
2102 f
->display
.x
->top_pos
= XINT (tem
);
2105 pixelwidth
= CHAR_TO_PIXEL_WIDTH (f
, width
);
2106 pixelheight
= CHAR_TO_PIXEL_HEIGHT (f
, height
);
2110 = XCreateWindow (parent
,
2111 f
->display
.x
->left_pos
, /* Absolute horizontal offset */
2112 f
->display
.x
->top_pos
, /* Absolute Vertical offset */
2113 pixelwidth
, pixelheight
,
2114 f
->display
.x
->border_width
,
2115 BLACK_PIX_DEFAULT
, WHITE_PIX_DEFAULT
);
2117 if (FRAME_X_WINDOW (f
) == 0)
2118 error ("Unable to create window.");
2121 /* Install the now determined height and width
2122 in the windows and in phys_lines and desired_lines. */
2123 change_frame_size (f
, height
, width
, 1, 0);
2124 XSelectInput (FRAME_X_WINDOW (f
), KeyPressed
| ExposeWindow
2125 | ButtonPressed
| ButtonReleased
| ExposeRegion
| ExposeCopy
2126 | EnterWindow
| LeaveWindow
| UnmapWindow
);
2127 x_set_resize_hint (f
);
2129 /* Tell the server the window's default name. */
2130 XStoreName (XDISPLAY
FRAME_X_WINDOW (f
), XSTRING (f
->name
)->data
);
2132 /* Now override the defaults with all the rest of the specified
2134 tem
= x_get_arg (parms
, Qunsplittable
, 0, 0, boolean
);
2135 f
->no_split
= minibuffer_only
|| EQ (tem
, Qt
);
2137 /* Do not create an icon window if the caller says not to.
2138 I'm not sure that this code is right; how does X10 handle icons? */
2139 x_text_icon (f
, iconidentity
);
2140 x_default_parameter (f
, parms
, Qicon_type
, Qnil
,
2141 "BitmapIcon", 0, symbol
);
2143 /* Tell the X server the previously set values of the
2144 background, border and mouse colors; also create the mouse cursor. */
2146 temp
= XMakeTile (f
->display
.x
->background_pixel
);
2147 XChangeBackground (FRAME_X_WINDOW (f
), temp
);
2150 x_set_border_pixel (f
, f
->display
.x
->border_pixel
);
2152 x_set_mouse_color (f
, Qnil
, Qnil
);
2154 /* Now override the defaults with all the rest of the specified parms. */
2156 Fmodify_frame_parameters (frame
, parms
);
2158 /* Make the window appear on the frame and enable display. */
2160 Lisp_Object visibility
= x_get_arg (parms
, Qvisibility
, 0, 0, symbol
);
2162 if (EQ (visibility
, Qunbound
))
2165 if (! EQ (visibility
, Qicon
)
2166 && ! NILP (visibility
))
2167 x_make_window_visible (f
);
2170 SET_FRAME_GARBAGED (f
);
2176 DEFUN ("focus-frame", Ffocus_frame
, Sfocus_frame
, 1, 1, 0,
2177 "Set the focus on FRAME.")
2181 CHECK_LIVE_FRAME (frame
, 0);
2183 if (FRAME_X_P (XFRAME (frame
)))
2186 x_focus_on_frame (XFRAME (frame
));
2194 DEFUN ("unfocus-frame", Funfocus_frame
, Sunfocus_frame
, 0, 0, 0,
2195 "If a frame has been focused, release it.")
2201 x_unfocus_frame (x_focus_frame
);
2209 /* Computes an X-window size and position either from geometry GEO
2212 F is a frame. It specifies an X window which is used to
2213 determine which display to compute for. Its font, borders
2214 and colors control how the rectangle will be displayed.
2216 X and Y are where to store the positions chosen.
2217 WIDTH and HEIGHT are where to store the sizes chosen.
2219 GEO is the geometry that may specify some of the info.
2220 STR is a prompt to display.
2221 HSCROLL and VSCROLL say whether we have horiz and vert scroll bars. */
2224 x_rubber_band (f
, x
, y
, width
, height
, geo
, str
, hscroll
, vscroll
)
2226 int *x
, *y
, *width
, *height
;
2229 int hscroll
, vscroll
;
2235 int background_color
;
2241 background_color
= f
->display
.x
->background_pixel
;
2242 border_color
= f
->display
.x
->border_pixel
;
2244 frame
.bdrwidth
= f
->display
.x
->border_width
;
2245 frame
.border
= XMakeTile (border_color
);
2246 frame
.background
= XMakeTile (background_color
);
2247 tempwindow
= XCreateTerm (str
, "emacs", geo
, default_window
, &frame
, 10, 5,
2248 (2 * f
->display
.x
->internal_border_width
2249 + (vscroll
? VSCROLL_WIDTH
: 0)),
2250 (2 * f
->display
.x
->internal_border_width
2251 + (hscroll
? HSCROLL_HEIGHT
: 0)),
2252 width
, height
, f
->display
.x
->font
,
2253 FONT_WIDTH (f
->display
.x
->font
),
2254 FONT_HEIGHT (f
->display
.x
->font
));
2255 XFreePixmap (frame
.border
);
2256 XFreePixmap (frame
.background
);
2258 if (tempwindow
!= 0)
2260 XQueryWindow (tempwindow
, &wininfo
);
2261 XDestroyWindow (tempwindow
);
2266 /* Coordinates we got are relative to the root window.
2267 Convert them to coordinates relative to desired parent window
2268 by scanning from there up to the root. */
2269 tempwindow
= f
->display
.x
->parent_desc
;
2270 while (tempwindow
!= ROOT_WINDOW
)
2274 XQueryWindow (tempwindow
, &wininfo
);
2277 XQueryTree (tempwindow
, &tempwindow
, &nchildren
, &children
);
2282 return tempwindow
!= 0;
2284 #endif /* not HAVE_X11 */
2286 DEFUN ("x-defined-color", Fx_defined_color
, Sx_defined_color
, 1, 1, 0,
2287 "Return t if the current X display supports the color named COLOR.")
2293 CHECK_STRING (color
, 0);
2295 if (defined_color (XSTRING (color
)->data
, &foo
))
2301 DEFUN ("x-display-color-p", Fx_display_color_p
, Sx_display_color_p
, 0, 0, 0,
2302 "Return t if the X screen currently in use supports color.")
2305 if (x_screen_planes
<= 2)
2308 switch (screen_visual
->class)
2321 DEFUN ("x-display-pixel-width", Fx_display_pixel_width
, Sx_display_pixel_width
,
2323 "Returns the width in pixels of the display FRAME is on.")
2327 Display
*dpy
= x_current_display
;
2328 return make_number (DisplayWidth (dpy
, DefaultScreen (dpy
)));
2331 DEFUN ("x-display-pixel-height", Fx_display_pixel_height
,
2332 Sx_display_pixel_height
, 0, 1, 0,
2333 "Returns the height in pixels of the display FRAME is on.")
2337 Display
*dpy
= x_current_display
;
2338 return make_number (DisplayHeight (dpy
, DefaultScreen (dpy
)));
2341 DEFUN ("x-display-planes", Fx_display_planes
, Sx_display_planes
,
2343 "Returns the number of bitplanes of the display FRAME is on.")
2347 Display
*dpy
= x_current_display
;
2348 return make_number (DisplayPlanes (dpy
, DefaultScreen (dpy
)));
2351 DEFUN ("x-display-color-cells", Fx_display_color_cells
, Sx_display_color_cells
,
2353 "Returns the number of color cells of the display FRAME is on.")
2357 Display
*dpy
= x_current_display
;
2358 return make_number (DisplayCells (dpy
, DefaultScreen (dpy
)));
2361 DEFUN ("x-server-vendor", Fx_server_vendor
, Sx_server_vendor
, 0, 1, 0,
2362 "Returns the vendor ID string of the X server FRAME is on.")
2366 Display
*dpy
= x_current_display
;
2368 vendor
= ServerVendor (dpy
);
2369 if (! vendor
) vendor
= "";
2370 return build_string (vendor
);
2373 DEFUN ("x-server-version", Fx_server_version
, Sx_server_version
, 0, 1, 0,
2374 "Returns the version numbers of the X server in use.\n\
2375 The value is a list of three integers: the major and minor\n\
2376 version numbers of the X Protocol in use, and the vendor-specific release\n\
2377 number. See also the variable `x-server-vendor'.")
2381 Display
*dpy
= x_current_display
;
2382 return Fcons (make_number (ProtocolVersion (dpy
)),
2383 Fcons (make_number (ProtocolRevision (dpy
)),
2384 Fcons (make_number (VendorRelease (dpy
)), Qnil
)));
2387 DEFUN ("x-display-screens", Fx_display_screens
, Sx_display_screens
, 0, 1, 0,
2388 "Returns the number of screens on the X server FRAME is on.")
2392 return make_number (ScreenCount (x_current_display
));
2395 DEFUN ("x-display-mm-height", Fx_display_mm_height
, Sx_display_mm_height
, 0, 1, 0,
2396 "Returns the height in millimeters of the X screen FRAME is on.")
2400 return make_number (HeightMMOfScreen (x_screen
));
2403 DEFUN ("x-display-mm-width", Fx_display_mm_width
, Sx_display_mm_width
, 0, 1, 0,
2404 "Returns the width in millimeters of the X screen FRAME is on.")
2408 return make_number (WidthMMOfScreen (x_screen
));
2411 DEFUN ("x-display-backing-store", Fx_display_backing_store
,
2412 Sx_display_backing_store
, 0, 1, 0,
2413 "Returns an indication of whether the X screen FRAME is on does backing store.\n\
2414 The value may be `always', `when-mapped', or `not-useful'.")
2418 switch (DoesBackingStore (x_screen
))
2421 return intern ("always");
2424 return intern ("when-mapped");
2427 return intern ("not-useful");
2430 error ("Strange value for BackingStore parameter of screen");
2434 DEFUN ("x-display-visual-class", Fx_display_visual_class
,
2435 Sx_display_visual_class
, 0, 1, 0,
2436 "Returns the visual class of the display `screen' is on.\n\
2437 The value is one of the symbols `static-gray', `gray-scale',\n\
2438 `static-color', `pseudo-color', `true-color', or `direct-color'.")
2442 switch (screen_visual
->class)
2444 case StaticGray
: return (intern ("static-gray"));
2445 case GrayScale
: return (intern ("gray-scale"));
2446 case StaticColor
: return (intern ("static-color"));
2447 case PseudoColor
: return (intern ("pseudo-color"));
2448 case TrueColor
: return (intern ("true-color"));
2449 case DirectColor
: return (intern ("direct-color"));
2451 error ("Display has an unknown visual class");
2455 DEFUN ("x-display-save-under", Fx_display_save_under
,
2456 Sx_display_save_under
, 0, 1, 0,
2457 "Returns t if the X screen FRAME is on supports the save-under feature.")
2461 if (DoesSaveUnders (x_screen
) == True
)
2468 register struct frame
*f
;
2470 return PIXEL_WIDTH (f
);
2474 register struct frame
*f
;
2476 return PIXEL_HEIGHT (f
);
2480 register struct frame
*f
;
2482 return FONT_WIDTH (f
->display
.x
->font
);
2486 register struct frame
*f
;
2488 return FONT_HEIGHT (f
->display
.x
->font
);
2491 #if 0 /* These no longer seem like the right way to do things. */
2493 /* Draw a rectangle on the frame with left top corner including
2494 the character specified by LEFT_CHAR and TOP_CHAR. The rectangle is
2495 CHARS by LINES wide and long and is the color of the cursor. */
2498 x_rectangle (f
, gc
, left_char
, top_char
, chars
, lines
)
2499 register struct frame
*f
;
2501 register int top_char
, left_char
, chars
, lines
;
2505 int left
= (left_char
* FONT_WIDTH (f
->display
.x
->font
)
2506 + f
->display
.x
->internal_border_width
);
2507 int top
= (top_char
* FONT_HEIGHT (f
->display
.x
->font
)
2508 + f
->display
.x
->internal_border_width
);
2511 width
= FONT_WIDTH (f
->display
.x
->font
) / 2;
2513 width
= FONT_WIDTH (f
->display
.x
->font
) * chars
;
2515 height
= FONT_HEIGHT (f
->display
.x
->font
) / 2;
2517 height
= FONT_HEIGHT (f
->display
.x
->font
) * lines
;
2519 XDrawRectangle (x_current_display
, FRAME_X_WINDOW (f
),
2520 gc
, left
, top
, width
, height
);
2523 DEFUN ("x-draw-rectangle", Fx_draw_rectangle
, Sx_draw_rectangle
, 5, 5, 0,
2524 "Draw a rectangle on FRAME between coordinates specified by\n\
2525 numbers X0, Y0, X1, Y1 in the cursor pixel.")
2526 (frame
, X0
, Y0
, X1
, Y1
)
2527 register Lisp_Object frame
, X0
, X1
, Y0
, Y1
;
2529 register int x0
, y0
, x1
, y1
, top
, left
, n_chars
, n_lines
;
2531 CHECK_LIVE_FRAME (frame
, 0);
2532 CHECK_NUMBER (X0
, 0);
2533 CHECK_NUMBER (Y0
, 1);
2534 CHECK_NUMBER (X1
, 2);
2535 CHECK_NUMBER (Y1
, 3);
2545 n_lines
= y1
- y0
+ 1;
2550 n_lines
= y0
- y1
+ 1;
2556 n_chars
= x1
- x0
+ 1;
2561 n_chars
= x0
- x1
+ 1;
2565 x_rectangle (XFRAME (frame
), XFRAME (frame
)->display
.x
->cursor_gc
,
2566 left
, top
, n_chars
, n_lines
);
2572 DEFUN ("x-erase-rectangle", Fx_erase_rectangle
, Sx_erase_rectangle
, 5, 5, 0,
2573 "Draw a rectangle drawn on FRAME between coordinates\n\
2574 X0, Y0, X1, Y1 in the regular background-pixel.")
2575 (frame
, X0
, Y0
, X1
, Y1
)
2576 register Lisp_Object frame
, X0
, Y0
, X1
, Y1
;
2578 register int x0
, y0
, x1
, y1
, top
, left
, n_chars
, n_lines
;
2580 CHECK_FRAME (frame
, 0);
2581 CHECK_NUMBER (X0
, 0);
2582 CHECK_NUMBER (Y0
, 1);
2583 CHECK_NUMBER (X1
, 2);
2584 CHECK_NUMBER (Y1
, 3);
2594 n_lines
= y1
- y0
+ 1;
2599 n_lines
= y0
- y1
+ 1;
2605 n_chars
= x1
- x0
+ 1;
2610 n_chars
= x0
- x1
+ 1;
2614 x_rectangle (XFRAME (frame
), XFRAME (frame
)->display
.x
->reverse_gc
,
2615 left
, top
, n_chars
, n_lines
);
2621 /* Draw lines around the text region beginning at the character position
2622 TOP_X, TOP_Y and ending at BOTTOM_X and BOTTOM_Y. GC specifies the
2623 pixel and line characteristics. */
2625 #define line_len(line) (FRAME_CURRENT_GLYPHS (f)->used[(line)])
2628 outline_region (f
, gc
, top_x
, top_y
, bottom_x
, bottom_y
)
2629 register struct frame
*f
;
2631 int top_x
, top_y
, bottom_x
, bottom_y
;
2633 register int ibw
= f
->display
.x
->internal_border_width
;
2634 register int font_w
= FONT_WIDTH (f
->display
.x
->font
);
2635 register int font_h
= FONT_HEIGHT (f
->display
.x
->font
);
2637 int x
= line_len (y
);
2638 XPoint
*pixel_points
= (XPoint
*)
2639 alloca (((bottom_y
- top_y
+ 2) * 4) * sizeof (XPoint
));
2640 register XPoint
*this_point
= pixel_points
;
2642 /* Do the horizontal top line/lines */
2645 this_point
->x
= ibw
;
2646 this_point
->y
= ibw
+ (font_h
* top_y
);
2649 this_point
->x
= ibw
+ (font_w
/ 2); /* Half-size for newline chars. */
2651 this_point
->x
= ibw
+ (font_w
* x
);
2652 this_point
->y
= (this_point
- 1)->y
;
2656 this_point
->x
= ibw
;
2657 this_point
->y
= ibw
+ (font_h
* (top_y
+ 1));
2659 this_point
->x
= ibw
+ (font_w
* top_x
);
2660 this_point
->y
= (this_point
- 1)->y
;
2662 this_point
->x
= (this_point
- 1)->x
;
2663 this_point
->y
= ibw
+ (font_h
* top_y
);
2665 this_point
->x
= ibw
+ (font_w
* x
);
2666 this_point
->y
= (this_point
- 1)->y
;
2669 /* Now do the right side. */
2670 while (y
< bottom_y
)
2671 { /* Right vertical edge */
2673 this_point
->x
= (this_point
- 1)->x
;
2674 this_point
->y
= ibw
+ (font_h
* (y
+ 1));
2677 y
++; /* Horizontal connection to next line */
2680 this_point
->x
= ibw
+ (font_w
/ 2);
2682 this_point
->x
= ibw
+ (font_w
* x
);
2684 this_point
->y
= (this_point
- 1)->y
;
2687 /* Now do the bottom and connect to the top left point. */
2688 this_point
->x
= ibw
+ (font_w
* (bottom_x
+ 1));
2691 this_point
->x
= (this_point
- 1)->x
;
2692 this_point
->y
= ibw
+ (font_h
* (bottom_y
+ 1));
2694 this_point
->x
= ibw
;
2695 this_point
->y
= (this_point
- 1)->y
;
2697 this_point
->x
= pixel_points
->x
;
2698 this_point
->y
= pixel_points
->y
;
2700 XDrawLines (x_current_display
, FRAME_X_WINDOW (f
),
2702 (this_point
- pixel_points
+ 1), CoordModeOrigin
);
2705 DEFUN ("x-contour-region", Fx_contour_region
, Sx_contour_region
, 1, 1, 0,
2706 "Highlight the region between point and the character under the mouse\n\
2709 register Lisp_Object event
;
2711 register int x0
, y0
, x1
, y1
;
2712 register struct frame
*f
= selected_frame
;
2713 register int p1
, p2
;
2715 CHECK_CONS (event
, 0);
2718 x0
= XINT (Fcar (Fcar (event
)));
2719 y0
= XINT (Fcar (Fcdr (Fcar (event
))));
2721 /* If the mouse is past the end of the line, don't that area. */
2722 /* ReWrite this... */
2727 if (y1
> y0
) /* point below mouse */
2728 outline_region (f
, f
->display
.x
->cursor_gc
,
2730 else if (y1
< y0
) /* point above mouse */
2731 outline_region (f
, f
->display
.x
->cursor_gc
,
2733 else /* same line: draw horizontal rectangle */
2736 x_rectangle (f
, f
->display
.x
->cursor_gc
,
2737 x0
, y0
, (x1
- x0
+ 1), 1);
2739 x_rectangle (f
, f
->display
.x
->cursor_gc
,
2740 x1
, y1
, (x0
- x1
+ 1), 1);
2743 XFlush (x_current_display
);
2749 DEFUN ("x-uncontour-region", Fx_uncontour_region
, Sx_uncontour_region
, 1, 1, 0,
2750 "Erase any highlighting of the region between point and the character\n\
2751 at X, Y on the selected frame.")
2753 register Lisp_Object event
;
2755 register int x0
, y0
, x1
, y1
;
2756 register struct frame
*f
= selected_frame
;
2759 x0
= XINT (Fcar (Fcar (event
)));
2760 y0
= XINT (Fcar (Fcdr (Fcar (event
))));
2764 if (y1
> y0
) /* point below mouse */
2765 outline_region (f
, f
->display
.x
->reverse_gc
,
2767 else if (y1
< y0
) /* point above mouse */
2768 outline_region (f
, f
->display
.x
->reverse_gc
,
2770 else /* same line: draw horizontal rectangle */
2773 x_rectangle (f
, f
->display
.x
->reverse_gc
,
2774 x0
, y0
, (x1
- x0
+ 1), 1);
2776 x_rectangle (f
, f
->display
.x
->reverse_gc
,
2777 x1
, y1
, (x0
- x1
+ 1), 1);
2785 int contour_begin_x
, contour_begin_y
;
2786 int contour_end_x
, contour_end_y
;
2787 int contour_npoints
;
2789 /* Clip the top part of the contour lines down (and including) line Y_POS.
2790 If X_POS is in the middle (rather than at the end) of the line, drop
2791 down a line at that character. */
2794 clip_contour_top (y_pos
, x_pos
)
2796 register XPoint
*begin
= contour_lines
[y_pos
].top_left
;
2797 register XPoint
*end
;
2798 register int npoints
;
2799 register struct display_line
*line
= selected_frame
->phys_lines
[y_pos
+ 1];
2801 if (x_pos
>= line
->len
- 1) /* Draw one, straight horizontal line. */
2803 end
= contour_lines
[y_pos
].top_right
;
2804 npoints
= (end
- begin
+ 1);
2805 XDrawLines (x_current_display
, contour_window
,
2806 contour_erase_gc
, begin_erase
, npoints
, CoordModeOrigin
);
2808 bcopy (end
, begin
+ 1, contour_last_point
- end
+ 1);
2809 contour_last_point
-= (npoints
- 2);
2810 XDrawLines (x_current_display
, contour_window
,
2811 contour_erase_gc
, begin
, 2, CoordModeOrigin
);
2812 XFlush (x_current_display
);
2814 /* Now, update contour_lines structure. */
2819 register XPoint
*p
= begin
+ 1;
2820 end
= contour_lines
[y_pos
].bottom_right
;
2821 npoints
= (end
- begin
+ 1);
2822 XDrawLines (x_current_display
, contour_window
,
2823 contour_erase_gc
, begin_erase
, npoints
, CoordModeOrigin
);
2826 p
->x
= ibw
+ (font_w
* (x_pos
+ 1));
2828 p
->y
= begin
->y
+ font_h
;
2830 bcopy (end
, begin
+ 3, contour_last_point
- end
+ 1);
2831 contour_last_point
-= (npoints
- 5);
2832 XDrawLines (x_current_display
, contour_window
,
2833 contour_erase_gc
, begin
, 4, CoordModeOrigin
);
2834 XFlush (x_current_display
);
2836 /* Now, update contour_lines structure. */
2840 /* Erase the top horzontal lines of the contour, and then extend
2841 the contour upwards. */
2844 extend_contour_top (line
)
2849 clip_contour_bottom (x_pos
, y_pos
)
2855 extend_contour_bottom (x_pos
, y_pos
)
2859 DEFUN ("x-select-region", Fx_select_region
, Sx_select_region
, 1, 1, "e",
2864 register struct frame
*f
= selected_frame
;
2865 register int point_x
= f
->cursor_x
;
2866 register int point_y
= f
->cursor_y
;
2867 register int mouse_below_point
;
2868 register Lisp_Object obj
;
2869 register int x_contour_x
, x_contour_y
;
2871 x_contour_x
= x_mouse_x
;
2872 x_contour_y
= x_mouse_y
;
2873 if (x_contour_y
> point_y
|| (x_contour_y
== point_y
2874 && x_contour_x
> point_x
))
2876 mouse_below_point
= 1;
2877 outline_region (f
, f
->display
.x
->cursor_gc
, point_x
, point_y
,
2878 x_contour_x
, x_contour_y
);
2882 mouse_below_point
= 0;
2883 outline_region (f
, f
->display
.x
->cursor_gc
, x_contour_x
, x_contour_y
,
2889 obj
= read_char (-1, 0, 0, Qnil
, 0);
2890 if (XTYPE (obj
) != Lisp_Cons
)
2893 if (mouse_below_point
)
2895 if (x_mouse_y
<= point_y
) /* Flipped. */
2897 mouse_below_point
= 0;
2899 outline_region (f
, f
->display
.x
->reverse_gc
, point_x
, point_y
,
2900 x_contour_x
, x_contour_y
);
2901 outline_region (f
, f
->display
.x
->cursor_gc
, x_mouse_x
, x_mouse_y
,
2904 else if (x_mouse_y
< x_contour_y
) /* Bottom clipped. */
2906 clip_contour_bottom (x_mouse_y
);
2908 else if (x_mouse_y
> x_contour_y
) /* Bottom extended. */
2910 extend_bottom_contour (x_mouse_y
);
2913 x_contour_x
= x_mouse_x
;
2914 x_contour_y
= x_mouse_y
;
2916 else /* mouse above or same line as point */
2918 if (x_mouse_y
>= point_y
) /* Flipped. */
2920 mouse_below_point
= 1;
2922 outline_region (f
, f
->display
.x
->reverse_gc
,
2923 x_contour_x
, x_contour_y
, point_x
, point_y
);
2924 outline_region (f
, f
->display
.x
->cursor_gc
, point_x
, point_y
,
2925 x_mouse_x
, x_mouse_y
);
2927 else if (x_mouse_y
> x_contour_y
) /* Top clipped. */
2929 clip_contour_top (x_mouse_y
);
2931 else if (x_mouse_y
< x_contour_y
) /* Top extended. */
2933 extend_contour_top (x_mouse_y
);
2938 unread_command_event
= obj
;
2939 if (mouse_below_point
)
2941 contour_begin_x
= point_x
;
2942 contour_begin_y
= point_y
;
2943 contour_end_x
= x_contour_x
;
2944 contour_end_y
= x_contour_y
;
2948 contour_begin_x
= x_contour_x
;
2949 contour_begin_y
= x_contour_y
;
2950 contour_end_x
= point_x
;
2951 contour_end_y
= point_y
;
2956 DEFUN ("x-horizontal-line", Fx_horizontal_line
, Sx_horizontal_line
, 1, 1, "e",
2961 register Lisp_Object obj
;
2962 struct frame
*f
= selected_frame
;
2963 register struct window
*w
= XWINDOW (selected_window
);
2964 register GC line_gc
= f
->display
.x
->cursor_gc
;
2965 register GC erase_gc
= f
->display
.x
->reverse_gc
;
2967 char dash_list
[] = {6, 4, 6, 4};
2969 XGCValues gc_values
;
2971 register int previous_y
;
2972 register int line
= (x_mouse_y
+ 1) * FONT_HEIGHT (f
->display
.x
->font
)
2973 + f
->display
.x
->internal_border_width
;
2974 register int left
= f
->display
.x
->internal_border_width
2976 * FONT_WIDTH (f
->display
.x
->font
));
2977 register int right
= left
+ (w
->width
2978 * FONT_WIDTH (f
->display
.x
->font
))
2979 - f
->display
.x
->internal_border_width
;
2983 gc_values
.foreground
= f
->display
.x
->cursor_pixel
;
2984 gc_values
.background
= f
->display
.x
->background_pixel
;
2985 gc_values
.line_width
= 1;
2986 gc_values
.line_style
= LineOnOffDash
;
2987 gc_values
.cap_style
= CapRound
;
2988 gc_values
.join_style
= JoinRound
;
2990 line_gc
= XCreateGC (x_current_display
, FRAME_X_WINDOW (f
),
2991 GCLineStyle
| GCJoinStyle
| GCCapStyle
2992 | GCLineWidth
| GCForeground
| GCBackground
,
2994 XSetDashes (x_current_display
, line_gc
, 0, dash_list
, dashes
);
2995 gc_values
.foreground
= f
->display
.x
->background_pixel
;
2996 gc_values
.background
= f
->display
.x
->foreground_pixel
;
2997 erase_gc
= XCreateGC (x_current_display
, FRAME_X_WINDOW (f
),
2998 GCLineStyle
| GCJoinStyle
| GCCapStyle
2999 | GCLineWidth
| GCForeground
| GCBackground
,
3001 XSetDashes (x_current_display
, erase_gc
, 0, dash_list
, dashes
);
3007 if (x_mouse_y
>= XINT (w
->top
)
3008 && x_mouse_y
< XINT (w
->top
) + XINT (w
->height
) - 1)
3010 previous_y
= x_mouse_y
;
3011 line
= (x_mouse_y
+ 1) * FONT_HEIGHT (f
->display
.x
->font
)
3012 + f
->display
.x
->internal_border_width
;
3013 XDrawLine (x_current_display
, FRAME_X_WINDOW (f
),
3014 line_gc
, left
, line
, right
, line
);
3021 obj
= read_char (-1, 0, 0, Qnil
, 0);
3022 if ((XTYPE (obj
) != Lisp_Cons
)
3023 || (! EQ (Fcar (Fcdr (Fcdr (obj
))),
3024 Qvertical_scroll_bar
))
3028 XDrawLine (x_current_display
, FRAME_X_WINDOW (f
),
3029 erase_gc
, left
, line
, right
, line
);
3031 unread_command_event
= obj
;
3033 XFreeGC (x_current_display
, line_gc
);
3034 XFreeGC (x_current_display
, erase_gc
);
3039 while (x_mouse_y
== previous_y
);
3042 XDrawLine (x_current_display
, FRAME_X_WINDOW (f
),
3043 erase_gc
, left
, line
, right
, line
);
3049 /* Offset in buffer of character under the pointer, or 0. */
3050 int mouse_buffer_offset
;
3053 /* These keep track of the rectangle following the pointer. */
3054 int mouse_track_top
, mouse_track_left
, mouse_track_width
;
3056 DEFUN ("x-track-pointer", Fx_track_pointer
, Sx_track_pointer
, 0, 0, 0,
3057 "Track the pointer.")
3060 static Cursor current_pointer_shape
;
3061 FRAME_PTR f
= x_mouse_frame
;
3064 if (EQ (Vmouse_frame_part
, Qtext_part
)
3065 && (current_pointer_shape
!= f
->display
.x
->nontext_cursor
))
3070 current_pointer_shape
= f
->display
.x
->nontext_cursor
;
3071 XDefineCursor (x_current_display
,
3073 current_pointer_shape
);
3075 buf
= XBUFFER (XWINDOW (Vmouse_window
)->buffer
);
3076 c
= *(BUF_CHAR_ADDRESS (buf
, mouse_buffer_offset
));
3078 else if (EQ (Vmouse_frame_part
, Qmodeline_part
)
3079 && (current_pointer_shape
!= f
->display
.x
->modeline_cursor
))
3081 current_pointer_shape
= f
->display
.x
->modeline_cursor
;
3082 XDefineCursor (x_current_display
,
3084 current_pointer_shape
);
3093 DEFUN ("x-track-pointer", Fx_track_pointer
, Sx_track_pointer
, 1, 1, "e",
3094 "Draw rectangle around character under mouse pointer, if there is one.")
3098 struct window
*w
= XWINDOW (Vmouse_window
);
3099 struct frame
*f
= XFRAME (WINDOW_FRAME (w
));
3100 struct buffer
*b
= XBUFFER (w
->buffer
);
3103 if (! EQ (Vmouse_window
, selected_window
))
3106 if (EQ (event
, Qnil
))
3110 x_read_mouse_position (selected_frame
, &x
, &y
);
3114 mouse_track_width
= 0;
3115 mouse_track_left
= mouse_track_top
= -1;
3119 if ((x_mouse_x
!= mouse_track_left
3120 && (x_mouse_x
< mouse_track_left
3121 || x_mouse_x
> (mouse_track_left
+ mouse_track_width
)))
3122 || x_mouse_y
!= mouse_track_top
)
3124 int hp
= 0; /* Horizontal position */
3125 int len
= FRAME_CURRENT_GLYPHS (f
)->used
[x_mouse_y
];
3126 int p
= FRAME_CURRENT_GLYPHS (f
)->bufp
[x_mouse_y
];
3127 int tab_width
= XINT (b
->tab_width
);
3128 int ctl_arrow_p
= !NILP (b
->ctl_arrow
);
3130 int mode_line_vpos
= XFASTINT (w
->height
) + XFASTINT (w
->top
) - 1;
3131 int in_mode_line
= 0;
3133 if (! FRAME_CURRENT_GLYPHS (f
)->enable
[x_mouse_y
])
3136 /* Erase previous rectangle. */
3137 if (mouse_track_width
)
3139 x_rectangle (f
, f
->display
.x
->reverse_gc
,
3140 mouse_track_left
, mouse_track_top
,
3141 mouse_track_width
, 1);
3143 if ((mouse_track_left
== f
->phys_cursor_x
3144 || mouse_track_left
== f
->phys_cursor_x
- 1)
3145 && mouse_track_top
== f
->phys_cursor_y
)
3147 x_display_cursor (f
, 1);
3151 mouse_track_left
= x_mouse_x
;
3152 mouse_track_top
= x_mouse_y
;
3153 mouse_track_width
= 0;
3155 if (mouse_track_left
> len
) /* Past the end of line. */
3158 if (mouse_track_top
== mode_line_vpos
)
3164 if (tab_width
<= 0 || tab_width
> 20) tab_width
= 8;
3168 if (len
== f
->width
&& hp
== len
- 1 && c
!= '\n')
3174 mouse_track_width
= tab_width
- (hp
% tab_width
);
3176 hp
+= mouse_track_width
;
3179 mouse_track_left
= hp
- mouse_track_width
;
3185 mouse_track_width
= -1;
3189 if (ctl_arrow_p
&& (c
< 040 || c
== 0177))
3194 mouse_track_width
= 2;
3199 mouse_track_left
= hp
- mouse_track_width
;
3205 mouse_track_width
= 1;
3212 while (hp
<= x_mouse_x
);
3215 if (mouse_track_width
) /* Over text; use text pointer shape. */
3217 XDefineCursor (x_current_display
,
3219 f
->display
.x
->text_cursor
);
3220 x_rectangle (f
, f
->display
.x
->cursor_gc
,
3221 mouse_track_left
, mouse_track_top
,
3222 mouse_track_width
, 1);
3224 else if (in_mode_line
)
3225 XDefineCursor (x_current_display
,
3227 f
->display
.x
->modeline_cursor
);
3229 XDefineCursor (x_current_display
,
3231 f
->display
.x
->nontext_cursor
);
3234 XFlush (x_current_display
);
3237 obj
= read_char (-1, 0, 0, Qnil
, 0);
3240 while (XTYPE (obj
) == Lisp_Cons
/* Mouse event */
3241 && EQ (Fcar (Fcdr (Fcdr (obj
))), Qnil
) /* Not scroll bar */
3242 && EQ (Vmouse_depressed
, Qnil
) /* Only motion events */
3243 && EQ (Vmouse_window
, selected_window
) /* In this window */
3246 unread_command_event
= obj
;
3248 if (mouse_track_width
)
3250 x_rectangle (f
, f
->display
.x
->reverse_gc
,
3251 mouse_track_left
, mouse_track_top
,
3252 mouse_track_width
, 1);
3253 mouse_track_width
= 0;
3254 if ((mouse_track_left
== f
->phys_cursor_x
3255 || mouse_track_left
- 1 == f
->phys_cursor_x
)
3256 && mouse_track_top
== f
->phys_cursor_y
)
3258 x_display_cursor (f
, 1);
3261 XDefineCursor (x_current_display
,
3263 f
->display
.x
->nontext_cursor
);
3264 XFlush (x_current_display
);
3274 /* Draw a pixmap specified by IMAGE_DATA of dimensions WIDTH and HEIGHT
3275 on the frame F at position X, Y. */
3277 x_draw_pixmap (f
, x
, y
, image_data
, width
, height
)
3279 int x
, y
, width
, height
;
3284 image
= XCreateBitmapFromData (x_current_display
,
3285 FRAME_X_WINDOW (f
), image_data
,
3287 XCopyPlane (x_current_display
, image
, FRAME_X_WINDOW (f
),
3288 f
->display
.x
->normal_gc
, 0, 0, width
, height
, x
, y
);
3295 #define XMouseEvent XEvent
3296 #define WhichMouseButton xbutton.button
3297 #define MouseWindow xbutton.window
3298 #define MouseX xbutton.x
3299 #define MouseY xbutton.y
3300 #define MouseTime xbutton.time
3301 #define ButtonReleased ButtonRelease
3302 #define ButtonPressed ButtonPress
3304 #define XMouseEvent XButtonEvent
3305 #define WhichMouseButton detail
3306 #define MouseWindow window
3309 #define MouseTime time
3312 DEFUN ("x-mouse-events", Fx_mouse_events
, Sx_mouse_events
, 0, 0, 0,
3313 "Return number of pending mouse events from X window system.")
3316 return make_number (queue_event_count (&x_mouse_queue
));
3319 /* Encode the mouse button events in the form expected by the
3320 mouse code in Lisp. For X11, this means moving the masks around. */
3323 encode_mouse_button (mouse_event
)
3324 XMouseEvent mouse_event
;
3326 register int event_code
;
3327 register char key_mask
;
3329 event_code
= mouse_event
.detail
& 3;
3330 key_mask
= (mouse_event
.detail
>> 8) & 0xf0;
3331 event_code
|= key_mask
>> 1;
3332 if (mouse_event
.type
== ButtonReleased
) event_code
|= 0x04;
3336 DEFUN ("x-get-mouse-event", Fx_get_mouse_event
, Sx_get_mouse_event
,
3338 "Get next mouse event out of mouse event buffer.\n\
3339 Optional ARG non-nil means return nil immediately if no pending event;\n\
3340 otherwise, wait for an event. Returns a four-part list:\n\
3341 ((X-POS Y-POS) WINDOW FRAME-PART KEYSEQ TIMESTAMP).\n\
3342 Normally X-POS and Y-POS are the position of the click on the frame\n\
3343 (measured in characters and lines), and WINDOW is the window clicked in.\n\
3344 KEYSEQ is a string, the key sequence to be looked up in the mouse maps.\n\
3345 If FRAME-PART is non-nil, the event was on a scroll bar;\n\
3346 then Y-POS is really the total length of the scroll bar, while X-POS is\n\
3347 the relative position of the scroll bar's value within that total length,\n\
3348 and a third element OFFSET appears in that list: the height of the thumb-up\n\
3349 area at the top of the scroll bar.\n\
3350 FRAME-PART is one of the following symbols:\n\
3351 `vertical-scroll-bar', `vertical-thumbup', `vertical-thumbdown',\n\
3352 `horizontal-scroll-bar', `horizontal-thumbleft', `horizontal-thumbright'.\n\
3353 TIMESTAMP is the lower 23 bits of the X-server's timestamp for\n\
3359 register int com_letter
;
3360 register Lisp_Object tempx
;
3361 register Lisp_Object tempy
;
3362 Lisp_Object part
, pos
, timestamp
;
3371 tem
= dequeue_event (&xrep
, &x_mouse_queue
);
3379 case ButtonReleased
:
3381 com_letter
= encode_mouse_button (xrep
);
3382 mouse_timestamp
= xrep
.MouseTime
;
3384 if ((f
= x_window_to_frame (xrep
.MouseWindow
)) != 0)
3388 if (f
->display
.x
->icon_desc
== xrep
.MouseWindow
)
3390 x_make_frame_visible (f
);
3394 XSET (tempx
, Lisp_Int
,
3395 min (f
->width
-1, max (0, (xrep
.MouseX
- f
->display
.x
->internal_border_width
)/FONT_WIDTH (f
->display
.x
->font
))));
3396 XSET (tempy
, Lisp_Int
,
3397 min (f
->height
-1, max (0, (xrep
.MouseY
- f
->display
.x
->internal_border_width
)/FONT_HEIGHT (f
->display
.x
->font
))));
3398 XSET (timestamp
, Lisp_Int
, (xrep
.MouseTime
& 0x7fffff));
3399 XSET (frame
, Lisp_Frame
, f
);
3401 pos
= Fcons (tempx
, Fcons (tempy
, Qnil
));
3403 = Flocate_window_from_coordinates (frame
, pos
);
3407 Fcons (Vmouse_window
,
3409 Fcons (Fchar_to_string (make_number (com_letter
)),
3410 Fcons (timestamp
, Qnil
)))));
3411 return Vmouse_event
;
3413 else if ((f
= x_window_to_scroll_bar (xrep
.MouseWindow
, &part
, &prefix
)) != 0)
3419 keyseq
= concat2 (Fchar_to_string (make_number (prefix
)),
3420 Fchar_to_string (make_number (com_letter
)));
3422 pos
= xrep
.MouseY
- (f
->display
.x
->v_scroll_bar_width
- 2);
3423 XSET (tempx
, Lisp_Int
, pos
);
3424 len
= ((FONT_HEIGHT (f
->display
.x
->font
) * f
->height
)
3425 + f
->display
.x
->internal_border_width
3426 - (2 * (f
->display
.x
->v_scroll_bar_width
- 2)));
3427 XSET (tempy
, Lisp_Int
, len
);
3428 XSET (timestamp
, Lisp_Int
, (xrep
.MouseTime
& 0x7fffff));
3429 Vmouse_window
= f
->selected_window
;
3431 = Fcons (Fcons (tempx
, Fcons (tempy
,
3432 Fcons (make_number (f
->display
.x
->v_scroll_bar_width
- 2),
3434 Fcons (Vmouse_window
,
3435 Fcons (intern (part
),
3436 Fcons (keyseq
, Fcons (timestamp
,
3438 return Vmouse_event
;
3446 com_letter
= x11_encode_mouse_button (xrep
);
3447 if ((f
= x_window_to_frame (xrep
.MouseWindow
)) != 0)
3451 XSET (tempx
, Lisp_Int
,
3453 max (0, (xrep
.MouseX
- f
->display
.x
->internal_border_width
)
3454 / FONT_WIDTH (f
->display
.x
->font
))));
3455 XSET (tempy
, Lisp_Int
,
3457 max (0, (xrep
.MouseY
- f
->display
.x
->internal_border_width
)
3458 / FONT_HEIGHT (f
->display
.x
->font
))));
3460 XSET (frame
, Lisp_Frame
, f
);
3461 XSET (timestamp
, Lisp_Int
, (xrep
.MouseTime
& 0x7fffff));
3463 pos
= Fcons (tempx
, Fcons (tempy
, Qnil
));
3465 = Flocate_window_from_coordinates (frame
, pos
);
3469 Fcons (Vmouse_window
,
3471 Fcons (Fchar_to_string (make_number (com_letter
)),
3472 Fcons (timestamp
, Qnil
)))));
3473 return Vmouse_event
;
3477 #endif /* HAVE_X11 */
3480 if (f
= x_window_to_frame (xrep
.MouseWindow
))
3481 Vmouse_window
= f
->selected_window
;
3482 else if (f
= x_window_to_scroll_bar (xrep
.MouseWindow
, &part
, &prefix
))
3483 Vmouse_window
= f
->selected_window
;
3484 return Vmouse_event
= Qnil
;
3491 /* Wait till we get another mouse event. */
3492 wait_reading_process_input (0, 0, 2, 0);
3499 DEFUN ("x-store-cut-buffer", Fx_store_cut_buffer
, Sx_store_cut_buffer
,
3500 1, 1, "sStore text in cut buffer: ",
3501 "Store contents of STRING into the cut buffer of the X window system.")
3503 register Lisp_Object string
;
3507 CHECK_STRING (string
, 1);
3508 if (! FRAME_X_P (selected_frame
))
3509 error ("Selected frame does not understand X protocol.");
3512 XStoreBytes ((char *) XSTRING (string
)->data
, XSTRING (string
)->size
);
3518 DEFUN ("x-get-cut-buffer", Fx_get_cut_buffer
, Sx_get_cut_buffer
, 0, 0, 0,
3519 "Return contents of cut buffer of the X window system, as a string.")
3523 register Lisp_Object string
;
3528 d
= XFetchBytes (&len
);
3529 string
= make_string (d
, len
);
3537 DEFUN ("x-rebind-key", Fx_rebind_key
, Sx_rebind_key
, 3, 3, 0,
3538 "Rebind X keysym KEYSYM, with MODIFIERS, to generate NEWSTRING.\n\
3539 KEYSYM is a string which conforms to the X keysym definitions found\n\
3540 in X11/keysymdef.h, sans the initial XK_. MODIFIERS is nil or a\n\
3541 list of strings specifying modifier keys such as Control_L, which must\n\
3542 also be depressed for NEWSTRING to appear.")
3543 (x_keysym
, modifiers
, newstring
)
3544 register Lisp_Object x_keysym
;
3545 register Lisp_Object modifiers
;
3546 register Lisp_Object newstring
;
3549 register KeySym keysym
;
3550 KeySym modifier_list
[16];
3552 CHECK_STRING (x_keysym
, 1);
3553 CHECK_STRING (newstring
, 3);
3555 keysym
= XStringToKeysym ((char *) XSTRING (x_keysym
)->data
);
3556 if (keysym
== NoSymbol
)
3557 error ("Keysym does not exist");
3559 if (NILP (modifiers
))
3560 XRebindKeysym (x_current_display
, keysym
, modifier_list
, 0,
3561 XSTRING (newstring
)->data
, XSTRING (newstring
)->size
);
3564 register Lisp_Object rest
, mod
;
3567 for (rest
= modifiers
; !NILP (rest
); rest
= Fcdr (rest
))
3570 error ("Can't have more than 16 modifiers");
3573 CHECK_STRING (mod
, 3);
3574 modifier_list
[i
] = XStringToKeysym ((char *) XSTRING (mod
)->data
);
3575 if (modifier_list
[i
] == NoSymbol
3576 || !IsModifierKey (modifier_list
[i
]))
3577 error ("Element is not a modifier keysym");
3581 XRebindKeysym (x_current_display
, keysym
, modifier_list
, i
,
3582 XSTRING (newstring
)->data
, XSTRING (newstring
)->size
);
3588 DEFUN ("x-rebind-keys", Fx_rebind_keys
, Sx_rebind_keys
, 2, 2, 0,
3589 "Rebind KEYCODE to list of strings STRINGS.\n\
3590 STRINGS should be a list of 16 elements, one for each shift combination.\n\
3591 nil as element means don't change.\n\
3592 See the documentation of `x-rebind-key' for more information.")
3594 register Lisp_Object keycode
;
3595 register Lisp_Object strings
;
3597 register Lisp_Object item
;
3598 register unsigned char *rawstring
;
3599 KeySym rawkey
, modifier
[1];
3601 register unsigned i
;
3603 CHECK_NUMBER (keycode
, 1);
3604 CHECK_CONS (strings
, 2);
3605 rawkey
= (KeySym
) ((unsigned) (XINT (keycode
))) & 255;
3606 for (i
= 0; i
<= 15; strings
= Fcdr (strings
), i
++)
3608 item
= Fcar (strings
);
3611 CHECK_STRING (item
, 2);
3612 strsize
= XSTRING (item
)->size
;
3613 rawstring
= (unsigned char *) xmalloc (strsize
);
3614 bcopy (XSTRING (item
)->data
, rawstring
, strsize
);
3615 modifier
[1] = 1 << i
;
3616 XRebindKeysym (x_current_display
, rawkey
, modifier
, 1,
3617 rawstring
, strsize
);
3623 DEFUN ("x-rebind-key", Fx_rebind_key
, Sx_rebind_key
, 3, 3, 0,
3624 "Rebind KEYCODE, with shift bits SHIFT-MASK, to new string NEWSTRING.\n\
3625 KEYCODE and SHIFT-MASK should be numbers representing the X keyboard code\n\
3626 and shift mask respectively. NEWSTRING is an arbitrary string of keystrokes.\n\
3627 If SHIFT-MASK is nil, then KEYCODE's key will be bound to NEWSTRING for\n\
3628 all shift combinations.\n\
3629 Shift Lock 1 Shift 2\n\
3632 For values of KEYCODE, see /usr/lib/Xkeymap.txt (remember that the codes\n\
3633 in that file are in octal!)\n\
3635 NOTE: due to an X bug, this function will not take effect unless one has\n\
3636 a `~/.Xkeymap' file. (See the documentation for the `keycomp' program.)\n\
3637 This problem will be fixed in X version 11.")
3639 (keycode
, shift_mask
, newstring
)
3640 register Lisp_Object keycode
;
3641 register Lisp_Object shift_mask
;
3642 register Lisp_Object newstring
;
3645 int keysym
, rawshift
;
3648 CHECK_NUMBER (keycode
, 1);
3649 if (!NILP (shift_mask
))
3650 CHECK_NUMBER (shift_mask
, 2);
3651 CHECK_STRING (newstring
, 3);
3652 strsize
= XSTRING (newstring
)->size
;
3653 rawstring
= (char *) xmalloc (strsize
);
3654 bcopy (XSTRING (newstring
)->data
, rawstring
, strsize
);
3656 keysym
= ((unsigned) (XINT (keycode
))) & 255;
3658 if (NILP (shift_mask
))
3660 for (i
= 0; i
<= 15; i
++)
3661 XRebindCode (keysym
, i
<<11, rawstring
, strsize
);
3665 rawshift
= (((unsigned) (XINT (shift_mask
))) & 15) << 11;
3666 XRebindCode (keysym
, rawshift
, rawstring
, strsize
);
3671 DEFUN ("x-rebind-keys", Fx_rebind_keys
, Sx_rebind_keys
, 2, 2, 0,
3672 "Rebind KEYCODE to list of strings STRINGS.\n\
3673 STRINGS should be a list of 16 elements, one for each shift combination.\n\
3674 nil as element means don't change.\n\
3675 See the documentation of `x-rebind-key' for more information.")
3677 register Lisp_Object keycode
;
3678 register Lisp_Object strings
;
3680 register Lisp_Object item
;
3681 register char *rawstring
;
3682 KeySym rawkey
, modifier
[1];
3684 register unsigned i
;
3686 CHECK_NUMBER (keycode
, 1);
3687 CHECK_CONS (strings
, 2);
3688 rawkey
= (KeySym
) ((unsigned) (XINT (keycode
))) & 255;
3689 for (i
= 0; i
<= 15; strings
= Fcdr (strings
), i
++)
3691 item
= Fcar (strings
);
3694 CHECK_STRING (item
, 2);
3695 strsize
= XSTRING (item
)->size
;
3696 rawstring
= (char *) xmalloc (strsize
);
3697 bcopy (XSTRING (item
)->data
, rawstring
, strsize
);
3698 XRebindCode (rawkey
, i
<< 11, rawstring
, strsize
);
3703 #endif /* not HAVE_X11 */
3707 select_visual (screen
, depth
)
3709 unsigned int *depth
;
3712 XVisualInfo
*vinfo
, vinfo_template
;
3715 v
= DefaultVisualOfScreen (screen
);
3718 vinfo_template
.visualid
= XVisualIDFromVisual (v
);
3720 vinfo_template
.visualid
= x
->visualid
;
3723 vinfo
= XGetVisualInfo (x_current_display
, VisualIDMask
, &vinfo_template
,
3726 fatal ("Can't get proper X visual info");
3728 if ((1 << vinfo
->depth
) == vinfo
->colormap_size
)
3729 *depth
= vinfo
->depth
;
3733 int n
= vinfo
->colormap_size
- 1;
3742 XFree ((char *) vinfo
);
3745 #endif /* HAVE_X11 */
3747 DEFUN ("x-open-connection", Fx_open_connection
, Sx_open_connection
,
3748 1, 2, 0, "Open a connection to an X server.\n\
3749 DISPLAY is the name of the display to connect to. Optional second\n\
3750 arg XRM_STRING is a string of resources in xrdb format.")
3751 (display
, xrm_string
)
3752 Lisp_Object display
, xrm_string
;
3754 unsigned int n_planes
;
3755 unsigned char *xrm_option
;
3757 CHECK_STRING (display
, 0);
3758 if (x_current_display
!= 0)
3759 error ("X server connection is already initialized");
3761 /* This is what opens the connection and sets x_current_display.
3762 This also initializes many symbols, such as those used for input. */
3763 x_term_init (XSTRING (display
)->data
);
3766 XFASTINT (Vwindow_system_version
) = 11;
3768 if (!EQ (xrm_string
, Qnil
))
3770 CHECK_STRING (xrm_string
, 1);
3771 xrm_option
= (unsigned char *) XSTRING (xrm_string
);
3774 xrm_option
= (unsigned char *) 0;
3775 xrdb
= x_load_resources (x_current_display
, xrm_option
, EMACS_CLASS
);
3777 XrmSetDatabase (x_current_display
, xrdb
);
3779 x_current_display
->db
= xrdb
;
3782 x_screen
= DefaultScreenOfDisplay (x_current_display
);
3784 screen_visual
= select_visual (x_screen
, &n_planes
);
3785 x_screen_planes
= n_planes
;
3786 x_screen_height
= HeightOfScreen (x_screen
);
3787 x_screen_width
= WidthOfScreen (x_screen
);
3789 /* X Atoms used by emacs. */
3790 Xatoms_of_xselect ();
3792 Xatom_wm_protocols
= XInternAtom (x_current_display
, "WM_PROTOCOLS",
3794 Xatom_wm_take_focus
= XInternAtom (x_current_display
, "WM_TAKE_FOCUS",
3796 Xatom_wm_save_yourself
= XInternAtom (x_current_display
, "WM_SAVE_YOURSELF",
3798 Xatom_wm_delete_window
= XInternAtom (x_current_display
, "WM_DELETE_WINDOW",
3800 Xatom_wm_change_state
= XInternAtom (x_current_display
, "WM_CHANGE_STATE",
3802 Xatom_wm_configure_denied
= XInternAtom (x_current_display
,
3803 "WM_CONFIGURE_DENIED", False
);
3804 Xatom_wm_window_moved
= XInternAtom (x_current_display
, "WM_MOVED",
3807 #else /* not HAVE_X11 */
3808 XFASTINT (Vwindow_system_version
) = 10;
3809 #endif /* not HAVE_X11 */
3813 DEFUN ("x-close-current-connection", Fx_close_current_connection
,
3814 Sx_close_current_connection
,
3815 0, 0, 0, "Close the connection to the current X server.")
3819 /* This is ONLY used when killing emacs; For switching displays
3820 we'll have to take care of setting CloseDownMode elsewhere. */
3822 if (x_current_display
)
3825 XSetCloseDownMode (x_current_display
, DestroyAll
);
3826 XCloseDisplay (x_current_display
);
3829 fatal ("No current X display connection to close\n");
3834 DEFUN ("x-synchronize", Fx_synchronize
, Sx_synchronize
,
3835 1, 1, 0, "If ON is non-nil, report X errors as soon as the erring request is made.\n\
3836 If ON is nil, allow buffering of requests.\n\
3837 Turning on synchronization prohibits the Xlib routines from buffering\n\
3838 requests and seriously degrades performance, but makes debugging much\n\
3843 XSynchronize (x_current_display
, !EQ (on
, Qnil
));
3851 /* This is zero if not using X windows. */
3852 x_current_display
= 0;
3854 /* The section below is built by the lisp expression at the top of the file,
3855 just above where these variables are declared. */
3856 /*&&& init symbols here &&&*/
3857 Qauto_raise
= intern ("auto-raise");
3858 staticpro (&Qauto_raise
);
3859 Qauto_lower
= intern ("auto-lower");
3860 staticpro (&Qauto_lower
);
3861 Qbackground_color
= intern ("background-color");
3862 staticpro (&Qbackground_color
);
3863 Qbar
= intern ("bar");
3865 Qborder_color
= intern ("border-color");
3866 staticpro (&Qborder_color
);
3867 Qborder_width
= intern ("border-width");
3868 staticpro (&Qborder_width
);
3869 Qbox
= intern ("box");
3871 Qcursor_color
= intern ("cursor-color");
3872 staticpro (&Qcursor_color
);
3873 Qcursor_type
= intern ("cursor-type");
3874 staticpro (&Qcursor_type
);
3875 Qfont
= intern ("font");
3877 Qforeground_color
= intern ("foreground-color");
3878 staticpro (&Qforeground_color
);
3879 Qgeometry
= intern ("geometry");
3880 staticpro (&Qgeometry
);
3881 Qicon
= intern ("icon");
3883 Qicon_left
= intern ("icon-left");
3884 staticpro (&Qicon_left
);
3885 Qicon_top
= intern ("icon-top");
3886 staticpro (&Qicon_top
);
3887 Qicon_type
= intern ("icon-type");
3888 staticpro (&Qicon_type
);
3889 Qinternal_border_width
= intern ("internal-border-width");
3890 staticpro (&Qinternal_border_width
);
3891 Qleft
= intern ("left");
3893 Qmouse_color
= intern ("mouse-color");
3894 staticpro (&Qmouse_color
);
3895 Qnone
= intern ("none");
3897 Qparent_id
= intern ("parent-id");
3898 staticpro (&Qparent_id
);
3899 Qtop
= intern ("top");
3901 Qundefined_color
= intern ("undefined-color");
3902 staticpro (&Qundefined_color
);
3903 Qvertical_scroll_bars
= intern ("vertical-scroll-bars");
3904 staticpro (&Qvertical_scroll_bars
);
3905 Qvisibility
= intern ("visibility");
3906 staticpro (&Qvisibility
);
3907 Qwindow_id
= intern ("window-id");
3908 staticpro (&Qwindow_id
);
3909 Qx_frame_parameter
= intern ("x-frame-parameter");
3910 staticpro (&Qx_frame_parameter
);
3911 /* This is the end of symbol initialization. */
3913 Fput (Qundefined_color
, Qerror_conditions
,
3914 Fcons (Qundefined_color
, Fcons (Qerror
, Qnil
)));
3915 Fput (Qundefined_color
, Qerror_message
,
3916 build_string ("Undefined color"));
3918 init_x_parm_symbols ();
3920 DEFVAR_INT ("mouse-buffer-offset", &mouse_buffer_offset
,
3921 "The buffer offset of the character under the pointer.");
3922 mouse_buffer_offset
= 0;
3924 DEFVAR_INT ("x-pointer-shape", &Vx_pointer_shape
,
3925 "The shape of the pointer when over text.");
3926 Vx_pointer_shape
= Qnil
;
3928 DEFVAR_INT ("x-nontext-pointer-shape", &Vx_nontext_pointer_shape
,
3929 "The shape of the pointer when not over text.");
3930 Vx_nontext_pointer_shape
= Qnil
;
3932 DEFVAR_INT ("x-mode-pointer-shape", &Vx_mode_pointer_shape
,
3933 "The shape of the pointer when over the mode line.");
3934 Vx_mode_pointer_shape
= Qnil
;
3936 DEFVAR_LISP ("x-cursor-fore-pixel", &Vx_cursor_fore_pixel
,
3937 "A string indicating the foreground color of the cursor box.");
3938 Vx_cursor_fore_pixel
= Qnil
;
3940 DEFVAR_LISP ("mouse-grabbed", &Vmouse_depressed
,
3941 "Non-nil if a mouse button is currently depressed.");
3942 Vmouse_depressed
= Qnil
;
3944 DEFVAR_LISP ("x-no-window-manager", &Vx_no_window_manager
,
3945 "t if no X window manager is in use.");
3948 defsubr (&Sx_get_resource
);
3950 defsubr (&Sx_draw_rectangle
);
3951 defsubr (&Sx_erase_rectangle
);
3952 defsubr (&Sx_contour_region
);
3953 defsubr (&Sx_uncontour_region
);
3955 defsubr (&Sx_display_color_p
);
3956 defsubr (&Sx_defined_color
);
3957 defsubr (&Sx_server_vendor
);
3958 defsubr (&Sx_server_version
);
3959 defsubr (&Sx_display_pixel_width
);
3960 defsubr (&Sx_display_pixel_height
);
3961 defsubr (&Sx_display_mm_width
);
3962 defsubr (&Sx_display_mm_height
);
3963 defsubr (&Sx_display_screens
);
3964 defsubr (&Sx_display_planes
);
3965 defsubr (&Sx_display_color_cells
);
3966 defsubr (&Sx_display_visual_class
);
3967 defsubr (&Sx_display_backing_store
);
3968 defsubr (&Sx_display_save_under
);
3970 defsubr (&Sx_track_pointer
);
3971 defsubr (&Sx_grab_pointer
);
3972 defsubr (&Sx_ungrab_pointer
);
3975 defsubr (&Sx_get_default
);
3976 defsubr (&Sx_store_cut_buffer
);
3977 defsubr (&Sx_get_cut_buffer
);
3978 defsubr (&Sx_set_face
);
3980 defsubr (&Sx_geometry
);
3981 defsubr (&Sx_create_frame
);
3982 defsubr (&Sfocus_frame
);
3983 defsubr (&Sunfocus_frame
);
3985 defsubr (&Sx_horizontal_line
);
3987 defsubr (&Sx_rebind_key
);
3988 defsubr (&Sx_rebind_keys
);
3989 defsubr (&Sx_open_connection
);
3990 defsubr (&Sx_close_current_connection
);
3991 defsubr (&Sx_synchronize
);
3993 /* This was used in the old event interface which used a separate
3996 defsubr (&Sx_mouse_events
);
3997 defsubr (&Sx_get_mouse_event
);
4001 #endif /* HAVE_X_WINDOWS */