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
;
164 Lisp_Object Qicon_left
;
165 Lisp_Object Qicon_top
;
166 Lisp_Object Qicon_type
;
167 Lisp_Object Qiconic_startup
;
168 Lisp_Object Qinternal_border_width
;
170 Lisp_Object Qmouse_color
;
172 Lisp_Object Qparent_id
;
173 Lisp_Object Qsuppress_icon
;
174 Lisp_Object Qsuppress_initial_map
;
176 Lisp_Object Qundefined_color
;
177 Lisp_Object Qvertical_scroll_bars
;
178 Lisp_Object Qwindow_id
;
179 Lisp_Object Qx_frame_parameter
;
180 Lisp_Object Qvisibility
;
182 /* The below are defined in frame.c. */
183 extern Lisp_Object Qheight
, Qminibuffer
, Qname
, Qonly
, Qwidth
;
184 extern Lisp_Object Qunsplittable
, Qmenu_bar_lines
, Qicon
;
186 extern Lisp_Object Vwindow_system_version
;
188 /* Mouse map for clicks in windows. */
189 extern Lisp_Object Vglobal_mouse_map
;
191 /* Points to table of defined typefaces. */
192 struct face
*x_face_table
[MAX_FACES_AND_GLYPHS
];
194 /* Return the Emacs frame-object corresponding to an X window.
195 It could be the frame's main window or an icon window. */
198 x_window_to_frame (wdesc
)
201 Lisp_Object tail
, frame
;
204 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
206 frame
= XCONS (tail
)->car
;
207 if (XTYPE (frame
) != Lisp_Frame
)
210 if (FRAME_X_WINDOW (f
) == wdesc
211 || f
->display
.x
->icon_desc
== wdesc
)
218 /* Connect the frame-parameter names for X frames
219 to the ways of passing the parameter values to the window system.
221 The name of a parameter, as a Lisp symbol,
222 has an `x-frame-parameter' property which is an integer in Lisp
223 but can be interpreted as an `enum x_frame_parm' in C. */
227 X_PARM_FOREGROUND_COLOR
,
228 X_PARM_BACKGROUND_COLOR
,
235 X_PARM_INTERNAL_BORDER_WIDTH
,
239 X_PARM_VERT_SCROLL_BAR
,
241 X_PARM_MENU_BAR_LINES
245 struct x_frame_parm_table
248 void (*setter
)( /* struct frame *frame, Lisp_Object val, oldval */ );
251 void x_set_foreground_color ();
252 void x_set_background_color ();
253 void x_set_mouse_color ();
254 void x_set_cursor_color ();
255 void x_set_border_color ();
256 void x_set_cursor_type ();
257 void x_set_icon_type ();
259 void x_set_border_width ();
260 void x_set_internal_border_width ();
261 void x_explicitly_set_name ();
262 void x_set_autoraise ();
263 void x_set_autolower ();
264 void x_set_vertical_scroll_bars ();
265 void x_set_visibility ();
266 void x_set_menu_bar_lines ();
268 static struct x_frame_parm_table x_frame_parms
[] =
270 "foreground-color", x_set_foreground_color
,
271 "background-color", x_set_background_color
,
272 "mouse-color", x_set_mouse_color
,
273 "cursor-color", x_set_cursor_color
,
274 "border-color", x_set_border_color
,
275 "cursor-type", x_set_cursor_type
,
276 "icon-type", x_set_icon_type
,
278 "border-width", x_set_border_width
,
279 "internal-border-width", x_set_internal_border_width
,
280 "name", x_explicitly_set_name
,
281 "auto-raise", x_set_autoraise
,
282 "auto-lower", x_set_autolower
,
283 "vertical-scroll-bars", x_set_vertical_scroll_bars
,
284 "visibility", x_set_visibility
,
285 "menu-bar-lines", x_set_menu_bar_lines
,
288 /* Attach the `x-frame-parameter' properties to
289 the Lisp symbol names of parameters relevant to X. */
291 init_x_parm_symbols ()
295 for (i
= 0; i
< sizeof (x_frame_parms
) / sizeof (x_frame_parms
[0]); i
++)
296 Fput (intern (x_frame_parms
[i
].name
), Qx_frame_parameter
,
300 /* Change the parameters of FRAME as specified by ALIST.
301 If a parameter is not specially recognized, do nothing;
302 otherwise call the `x_set_...' function for that parameter. */
305 x_set_frame_parameters (f
, alist
)
311 /* If both of these parameters are present, it's more efficient to
312 set them both at once. So we wait until we've looked at the
313 entire list before we set them. */
314 Lisp_Object width
, height
;
317 Lisp_Object left
, top
;
319 XSET (width
, Lisp_Int
, FRAME_WIDTH (f
));
320 XSET (height
, Lisp_Int
, FRAME_HEIGHT (f
));
322 XSET (top
, Lisp_Int
, f
->display
.x
->top_pos
);
323 XSET (left
, Lisp_Int
, f
->display
.x
->left_pos
);
325 for (tail
= alist
; CONSP (tail
); tail
= Fcdr (tail
))
327 Lisp_Object elt
, prop
, val
;
333 if (EQ (prop
, Qwidth
))
335 else if (EQ (prop
, Qheight
))
337 else if (EQ (prop
, Qtop
))
339 else if (EQ (prop
, Qleft
))
343 register Lisp_Object tem
;
344 tem
= Fget (prop
, Qx_frame_parameter
);
345 if (XTYPE (tem
) == Lisp_Int
347 && XINT (tem
) < sizeof (x_frame_parms
)/sizeof (x_frame_parms
[0]))
348 (*x_frame_parms
[XINT (tem
)].setter
)(f
, val
,
349 get_frame_param (f
, prop
));
350 store_frame_param (f
, prop
, val
);
354 /* Don't call these unless they've changed; the window may not actually
359 XSET (frame
, Lisp_Frame
, f
);
360 if (XINT (width
) != FRAME_WIDTH (f
)
361 || XINT (height
) != FRAME_HEIGHT (f
))
362 Fset_frame_size (frame
, width
, height
);
363 if (XINT (left
) != f
->display
.x
->left_pos
364 || XINT (top
) != f
->display
.x
->top_pos
)
365 Fset_frame_position (frame
, left
, top
);
369 /* Insert a description of internally-recorded parameters of frame X
370 into the parameter alist *ALISTPTR that is to be given to the user.
371 Only parameters that are specific to the X window system
372 and whose values are not correctly recorded in the frame's
373 param_alist need to be considered here. */
375 x_report_frame_params (f
, alistptr
)
377 Lisp_Object
*alistptr
;
381 store_in_alist (alistptr
, Qleft
, make_number (f
->display
.x
->left_pos
));
382 store_in_alist (alistptr
, Qtop
, make_number (f
->display
.x
->top_pos
));
383 store_in_alist (alistptr
, Qborder_width
,
384 make_number (f
->display
.x
->border_width
));
385 store_in_alist (alistptr
, Qinternal_border_width
,
386 make_number (f
->display
.x
->internal_border_width
));
387 sprintf (buf
, "%d", FRAME_X_WINDOW (f
));
388 store_in_alist (alistptr
, Qwindow_id
,
390 store_in_alist (alistptr
, Qvisibility
,
391 (FRAME_VISIBLE_P (f
) ? Qt
392 : FRAME_ICONIFIED_P (f
) ? Qicon
: Qnil
));
395 /* Decide if color named COLOR is valid for the display
396 associated with the selected frame. */
398 defined_color (color
, color_def
)
403 Colormap screen_colormap
;
408 = DefaultColormap (x_current_display
, XDefaultScreen (x_current_display
));
410 foo
= XParseColor (x_current_display
, screen_colormap
,
412 && XAllocColor (x_current_display
, screen_colormap
, color_def
);
414 foo
= XParseColor (color
, color_def
) && XGetHardwareColor (color_def
);
415 #endif /* not HAVE_X11 */
424 /* Given a string ARG naming a color, compute a pixel value from it
425 suitable for screen F.
426 If F is not a color screen, return DEF (default) regardless of what
430 x_decode_color (arg
, def
)
436 CHECK_STRING (arg
, 0);
438 if (strcmp (XSTRING (arg
)->data
, "black") == 0)
439 return BLACK_PIX_DEFAULT
;
440 else if (strcmp (XSTRING (arg
)->data
, "white") == 0)
441 return WHITE_PIX_DEFAULT
;
444 if (x_screen_planes
== 1)
447 if (DISPLAY_CELLS
== 1)
451 if (defined_color (XSTRING (arg
)->data
, &cdef
))
454 Fsignal (Qundefined_color
, Fcons (arg
, Qnil
));
457 /* Functions called only from `x_set_frame_param'
458 to set individual parameters.
460 If FRAME_X_WINDOW (f) is 0,
461 the frame is being created and its X-window does not exist yet.
462 In that case, just record the parameter's new value
463 in the standard place; do not attempt to change the window. */
466 x_set_foreground_color (f
, arg
, oldval
)
468 Lisp_Object arg
, oldval
;
470 f
->display
.x
->foreground_pixel
= x_decode_color (arg
, BLACK_PIX_DEFAULT
);
471 if (FRAME_X_WINDOW (f
) != 0)
475 XSetForeground (x_current_display
, f
->display
.x
->normal_gc
,
476 f
->display
.x
->foreground_pixel
);
477 XSetBackground (x_current_display
, f
->display
.x
->reverse_gc
,
478 f
->display
.x
->foreground_pixel
);
480 #endif /* HAVE_X11 */
481 if (FRAME_VISIBLE_P (f
))
487 x_set_background_color (f
, arg
, oldval
)
489 Lisp_Object arg
, oldval
;
494 f
->display
.x
->background_pixel
= x_decode_color (arg
, WHITE_PIX_DEFAULT
);
496 if (FRAME_X_WINDOW (f
) != 0)
500 /* The main frame area. */
501 XSetBackground (x_current_display
, f
->display
.x
->normal_gc
,
502 f
->display
.x
->background_pixel
);
503 XSetForeground (x_current_display
, f
->display
.x
->reverse_gc
,
504 f
->display
.x
->background_pixel
);
505 XSetWindowBackground (x_current_display
, FRAME_X_WINDOW (f
),
506 f
->display
.x
->background_pixel
);
509 temp
= XMakeTile (f
->display
.x
->background_pixel
);
510 XChangeBackground (FRAME_X_WINDOW (f
), temp
);
512 #endif /* not HAVE_X11 */
515 if (FRAME_VISIBLE_P (f
))
521 x_set_mouse_color (f
, arg
, oldval
)
523 Lisp_Object arg
, oldval
;
525 Cursor cursor
, nontext_cursor
, mode_cursor
;
529 f
->display
.x
->mouse_pixel
= x_decode_color (arg
, BLACK_PIX_DEFAULT
);
530 mask_color
= f
->display
.x
->background_pixel
;
531 /* No invisible pointers. */
532 if (mask_color
== f
->display
.x
->mouse_pixel
533 && mask_color
== f
->display
.x
->background_pixel
)
534 f
->display
.x
->mouse_pixel
= f
->display
.x
->foreground_pixel
;
539 /* It's not okay to crash if the user selects a screwey cursor. */
542 if (!EQ (Qnil
, Vx_pointer_shape
))
544 CHECK_NUMBER (Vx_pointer_shape
, 0);
545 cursor
= XCreateFontCursor (x_current_display
, XINT (Vx_pointer_shape
));
548 cursor
= XCreateFontCursor (x_current_display
, XC_xterm
);
549 x_check_errors ("bad text pointer cursor: %s");
551 if (!EQ (Qnil
, Vx_nontext_pointer_shape
))
553 CHECK_NUMBER (Vx_nontext_pointer_shape
, 0);
554 nontext_cursor
= XCreateFontCursor (x_current_display
,
555 XINT (Vx_nontext_pointer_shape
));
558 nontext_cursor
= XCreateFontCursor (x_current_display
, XC_left_ptr
);
559 x_check_errors ("bad nontext pointer cursor: %s");
561 if (!EQ (Qnil
, Vx_mode_pointer_shape
))
563 CHECK_NUMBER (Vx_mode_pointer_shape
, 0);
564 mode_cursor
= XCreateFontCursor (x_current_display
,
565 XINT (Vx_mode_pointer_shape
));
568 mode_cursor
= XCreateFontCursor (x_current_display
, XC_xterm
);
570 /* Check and report errors with the above calls. */
571 x_check_errors ("can't set cursor shape: %s");
575 XColor fore_color
, back_color
;
577 fore_color
.pixel
= f
->display
.x
->mouse_pixel
;
578 back_color
.pixel
= mask_color
;
579 XQueryColor (x_current_display
,
580 DefaultColormap (x_current_display
,
581 DefaultScreen (x_current_display
)),
583 XQueryColor (x_current_display
,
584 DefaultColormap (x_current_display
,
585 DefaultScreen (x_current_display
)),
587 XRecolorCursor (x_current_display
, cursor
,
588 &fore_color
, &back_color
);
589 XRecolorCursor (x_current_display
, nontext_cursor
,
590 &fore_color
, &back_color
);
591 XRecolorCursor (x_current_display
, mode_cursor
,
592 &fore_color
, &back_color
);
595 cursor
= XCreateCursor (16, 16, MouseCursor
, MouseMask
,
597 f
->display
.x
->mouse_pixel
,
598 f
->display
.x
->background_pixel
,
602 if (FRAME_X_WINDOW (f
) != 0)
604 XDefineCursor (XDISPLAY
FRAME_X_WINDOW (f
), cursor
);
607 if (cursor
!= f
->display
.x
->text_cursor
&& f
->display
.x
->text_cursor
!= 0)
608 XFreeCursor (XDISPLAY f
->display
.x
->text_cursor
);
609 f
->display
.x
->text_cursor
= cursor
;
611 if (nontext_cursor
!= f
->display
.x
->nontext_cursor
612 && f
->display
.x
->nontext_cursor
!= 0)
613 XFreeCursor (XDISPLAY f
->display
.x
->nontext_cursor
);
614 f
->display
.x
->nontext_cursor
= nontext_cursor
;
616 if (mode_cursor
!= f
->display
.x
->modeline_cursor
617 && f
->display
.x
->modeline_cursor
!= 0)
618 XFreeCursor (XDISPLAY f
->display
.x
->modeline_cursor
);
619 f
->display
.x
->modeline_cursor
= mode_cursor
;
620 #endif /* HAVE_X11 */
627 x_set_cursor_color (f
, arg
, oldval
)
629 Lisp_Object arg
, oldval
;
631 unsigned long fore_pixel
;
633 if (!EQ (Vx_cursor_fore_pixel
, Qnil
))
634 fore_pixel
= x_decode_color (Vx_cursor_fore_pixel
, WHITE_PIX_DEFAULT
);
636 fore_pixel
= f
->display
.x
->background_pixel
;
637 f
->display
.x
->cursor_pixel
= x_decode_color (arg
, BLACK_PIX_DEFAULT
);
639 /* Make sure that the cursor color differs from the background color. */
640 if (f
->display
.x
->cursor_pixel
== f
->display
.x
->background_pixel
)
642 f
->display
.x
->cursor_pixel
== f
->display
.x
->mouse_pixel
;
643 if (f
->display
.x
->cursor_pixel
== fore_pixel
)
644 fore_pixel
= f
->display
.x
->background_pixel
;
647 if (FRAME_X_WINDOW (f
) != 0)
651 XSetBackground (x_current_display
, f
->display
.x
->cursor_gc
,
652 f
->display
.x
->cursor_pixel
);
653 XSetForeground (x_current_display
, f
->display
.x
->cursor_gc
,
656 #endif /* HAVE_X11 */
658 if (FRAME_VISIBLE_P (f
))
660 x_display_cursor (f
, 0);
661 x_display_cursor (f
, 1);
666 /* Set the border-color of frame F to value described by ARG.
667 ARG can be a string naming a color.
668 The border-color is used for the border that is drawn by the X server.
669 Note that this does not fully take effect if done before
670 F has an x-window; it must be redone when the window is created.
672 Note: this is done in two routines because of the way X10 works.
674 Note: under X11, this is normally the province of the window manager,
675 and so emacs' border colors may be overridden. */
678 x_set_border_color (f
, arg
, oldval
)
680 Lisp_Object arg
, oldval
;
685 CHECK_STRING (arg
, 0);
686 str
= XSTRING (arg
)->data
;
689 if (!strcmp (str
, "grey") || !strcmp (str
, "Grey")
690 || !strcmp (str
, "gray") || !strcmp (str
, "Gray"))
695 pix
= x_decode_color (arg
, BLACK_PIX_DEFAULT
);
697 x_set_border_pixel (f
, pix
);
700 /* Set the border-color of frame F to pixel value PIX.
701 Note that this does not fully take effect if done before
702 F has an x-window. */
704 x_set_border_pixel (f
, pix
)
708 f
->display
.x
->border_pixel
= pix
;
710 if (FRAME_X_WINDOW (f
) != 0 && f
->display
.x
->border_width
> 0)
717 XSetWindowBorder (x_current_display
, FRAME_X_WINDOW (f
),
721 temp
= XMakePixmap ((Bitmap
) XStoreBitmap (gray_width
, gray_height
,
723 BLACK_PIX_DEFAULT
, WHITE_PIX_DEFAULT
);
725 temp
= XMakeTile (pix
);
726 XChangeBorder (FRAME_X_WINDOW (f
), temp
);
727 XFreePixmap (XDISPLAY temp
);
728 #endif /* not HAVE_X11 */
731 if (FRAME_VISIBLE_P (f
))
737 x_set_cursor_type (f
, arg
, oldval
)
739 Lisp_Object arg
, oldval
;
742 FRAME_DESIRED_CURSOR (f
) = bar_cursor
;
743 else if (EQ (arg
, Qbox
))
744 FRAME_DESIRED_CURSOR (f
) = filled_box_cursor
;
747 ("the `cursor-type' frame parameter should be either `bar' or `box'");
749 /* Make sure the cursor gets redrawn. This is overkill, but how
750 often do people change cursor types? */
755 x_set_icon_type (f
, arg
, oldval
)
757 Lisp_Object arg
, oldval
;
762 if (EQ (oldval
, Qnil
) == EQ (arg
, Qnil
))
767 result
= x_text_icon (f
, 0);
769 result
= x_bitmap_icon (f
);
774 error ("No icon window available.");
777 /* If the window was unmapped (and its icon was mapped),
778 the new icon is not mapped, so map the window in its stead. */
779 if (FRAME_VISIBLE_P (f
))
780 XMapWindow (XDISPLAY
FRAME_X_WINDOW (f
));
787 x_set_font (f
, arg
, oldval
)
789 Lisp_Object arg
, oldval
;
794 CHECK_STRING (arg
, 1);
795 name
= XSTRING (arg
)->data
;
798 result
= x_new_font (f
, name
);
802 error ("Font \"%s\" is not defined", name
);
806 x_set_border_width (f
, arg
, oldval
)
808 Lisp_Object arg
, oldval
;
810 CHECK_NUMBER (arg
, 0);
812 if (XINT (arg
) == f
->display
.x
->border_width
)
815 if (FRAME_X_WINDOW (f
) != 0)
816 error ("Cannot change the border width of a window");
818 f
->display
.x
->border_width
= XINT (arg
);
822 x_set_internal_border_width (f
, arg
, oldval
)
824 Lisp_Object arg
, oldval
;
827 int old
= f
->display
.x
->internal_border_width
;
829 CHECK_NUMBER (arg
, 0);
830 f
->display
.x
->internal_border_width
= XINT (arg
);
831 if (f
->display
.x
->internal_border_width
< 0)
832 f
->display
.x
->internal_border_width
= 0;
834 if (f
->display
.x
->internal_border_width
== old
)
837 if (FRAME_X_WINDOW (f
) != 0)
840 x_set_window_size (f
, f
->width
, f
->height
);
842 x_set_resize_hint (f
);
846 SET_FRAME_GARBAGED (f
);
851 x_set_visibility (f
, value
, oldval
)
853 Lisp_Object value
, oldval
;
856 XSET (frame
, Lisp_Frame
, f
);
859 Fmake_frame_invisible (frame
);
860 else if (EQ (value
, Qt
))
861 Fmake_frame_visible (frame
);
863 Ficonify_frame (frame
);
867 x_set_menu_bar_lines_1 (window
, n
)
871 for (; !NILP (window
); window
= XWINDOW (window
)->next
)
873 struct window
*w
= XWINDOW (window
);
877 if (!NILP (w
->vchild
))
878 x_set_menu_bar_lines_1 (w
->vchild
);
880 if (!NILP (w
->hchild
))
881 x_set_menu_bar_lines_1 (w
->hchild
);
886 x_set_menu_bar_lines (f
, value
, oldval
)
888 Lisp_Object value
, oldval
;
891 int olines
= FRAME_MENU_BAR_LINES (f
);
893 if (XTYPE (value
) == Lisp_Int
)
894 nlines
= XINT (value
);
898 FRAME_MENU_BAR_LINES (f
) = nlines
;
899 x_set_menu_bar_lines_1 (f
->root_window
, nlines
- olines
);
900 x_set_window_size (f
, FRAME_WIDTH (f
),
901 FRAME_HEIGHT (f
) + nlines
- olines
);
904 /* Change the name of frame F to ARG. If ARG is nil, set F's name to
907 If EXPLICIT is non-zero, that indicates that lisp code is setting the
908 name; if ARG is a string, set F's name to ARG and set
909 F->explicit_name; if ARG is Qnil, then clear F->explicit_name.
911 If EXPLICIT is zero, that indicates that Emacs redisplay code is
912 suggesting a new name, which lisp code should override; if
913 F->explicit_name is set, ignore the new name; otherwise, set it. */
916 x_set_name (f
, name
, explicit)
921 /* Make sure that requests from lisp code override requests from
922 Emacs redisplay code. */
925 /* If we're switching from explicit to implicit, we had better
926 update the mode lines and thereby update the title. */
927 if (f
->explicit_name
&& NILP (name
))
928 update_mode_lines
= 1;
930 f
->explicit_name
= ! NILP (name
);
932 else if (f
->explicit_name
)
935 /* If NAME is nil, set the name to the x_id_name. */
937 name
= build_string (x_id_name
);
939 CHECK_STRING (name
, 0);
941 /* Don't change the name if it's already NAME. */
942 if (! NILP (Fstring_equal (name
, f
->name
)))
945 if (FRAME_X_WINDOW (f
))
952 text
.value
= XSTRING (name
)->data
;
953 text
.encoding
= XA_STRING
;
955 text
.nitems
= XSTRING (name
)->size
;
956 XSetWMName (x_current_display
, FRAME_X_WINDOW (f
), &text
);
957 XSetWMIconName (x_current_display
, FRAME_X_WINDOW (f
), &text
);
960 XSetIconName (XDISPLAY
FRAME_X_WINDOW (f
),
961 XSTRING (name
)->data
);
962 XStoreName (XDISPLAY
FRAME_X_WINDOW (f
),
963 XSTRING (name
)->data
);
972 /* This function should be called when the user's lisp code has
973 specified a name for the frame; the name will override any set by the
976 x_explicitly_set_name (f
, arg
, oldval
)
978 Lisp_Object arg
, oldval
;
980 x_set_name (f
, arg
, 1);
983 /* This function should be called by Emacs redisplay code to set the
984 name; names set this way will never override names set by the user's
987 x_implicitly_set_name (f
, arg
, oldval
)
989 Lisp_Object arg
, oldval
;
991 x_set_name (f
, arg
, 0);
995 x_set_autoraise (f
, arg
, oldval
)
997 Lisp_Object arg
, oldval
;
999 f
->auto_raise
= !EQ (Qnil
, arg
);
1003 x_set_autolower (f
, arg
, oldval
)
1005 Lisp_Object arg
, oldval
;
1007 f
->auto_lower
= !EQ (Qnil
, arg
);
1011 x_set_vertical_scroll_bars (f
, arg
, oldval
)
1013 Lisp_Object arg
, oldval
;
1015 if (NILP (arg
) != ! FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
1017 FRAME_HAS_VERTICAL_SCROLL_BARS (f
) = ! NILP (arg
);
1019 /* We set this parameter before creating the X window for the
1020 frame, so we can get the geometry right from the start.
1021 However, if the window hasn't been created yet, we shouldn't
1022 call x_set_window_size. */
1023 if (FRAME_X_WINDOW (f
))
1024 x_set_window_size (f
, FRAME_WIDTH (f
), FRAME_HEIGHT (f
));
1032 /* I believe this function is obsolete with respect to the new face display
1034 x_set_face (scr
, font
, background
, foreground
, stipple
)
1037 unsigned long background
, foreground
;
1040 XGCValues gc_values
;
1042 unsigned long gc_mask
;
1043 struct face
*new_face
;
1044 unsigned int width
= 16;
1045 unsigned int height
= 16;
1047 if (n_faces
== MAX_FACES_AND_GLYPHS
)
1050 /* Create the Graphics Context. */
1051 gc_values
.font
= font
->fid
;
1052 gc_values
.foreground
= foreground
;
1053 gc_values
.background
= background
;
1054 gc_values
.line_width
= 0;
1055 gc_mask
= GCLineWidth
| GCFont
| GCForeground
| GCBackground
;
1059 = XCreateBitmapFromData (x_current_display
, ROOT_WINDOW
,
1060 (char *) stipple
, width
, height
);
1061 gc_mask
|= GCStipple
;
1064 temp_gc
= XCreateGC (x_current_display
, FRAME_X_WINDOW (scr
),
1065 gc_mask
, &gc_values
);
1068 new_face
= (struct face
*) xmalloc (sizeof (struct face
));
1071 XFreeGC (x_current_display
, temp_gc
);
1075 new_face
->font
= font
;
1076 new_face
->foreground
= foreground
;
1077 new_face
->background
= background
;
1078 new_face
->face_gc
= temp_gc
;
1080 new_face
->stipple
= gc_values
.stipple
;
1082 x_face_table
[++n_faces
] = new_face
;
1087 x_set_glyph (scr
, glyph
)
1092 DEFUN ("x-set-face-font", Fx_set_face_font
, Sx_set_face_font
, 4, 2, 0,
1093 "Specify face table entry FACE-CODE to be the font named by FONT,\n\
1094 in colors FOREGROUND and BACKGROUND.")
1095 (face_code
, font_name
, foreground
, background
)
1096 Lisp_Object face_code
;
1097 Lisp_Object font_name
;
1098 Lisp_Object foreground
;
1099 Lisp_Object background
;
1101 register struct face
*fp
; /* Current face info. */
1102 register int fn
; /* Face number. */
1103 register FONT_TYPE
*f
; /* Font data structure. */
1104 unsigned char *newname
;
1107 XGCValues gc_values
;
1109 /* Need to do something about this. */
1110 Drawable drawable
= FRAME_X_WINDOW (selected_frame
);
1112 CHECK_NUMBER (face_code
, 1);
1113 CHECK_STRING (font_name
, 2);
1115 if (EQ (foreground
, Qnil
) || EQ (background
, Qnil
))
1117 fg
= selected_frame
->display
.x
->foreground_pixel
;
1118 bg
= selected_frame
->display
.x
->background_pixel
;
1122 CHECK_NUMBER (foreground
, 0);
1123 CHECK_NUMBER (background
, 1);
1125 fg
= x_decode_color (XINT (foreground
), BLACK_PIX_DEFAULT
);
1126 bg
= x_decode_color (XINT (background
), WHITE_PIX_DEFAULT
);
1129 fn
= XINT (face_code
);
1130 if ((fn
< 1) || (fn
> 255))
1131 error ("Invalid face code, %d", fn
);
1133 newname
= XSTRING (font_name
)->data
;
1135 f
= (*newname
== 0 ? 0 : XGetFont (newname
));
1138 error ("Font \"%s\" is not defined", newname
);
1140 fp
= x_face_table
[fn
];
1143 x_face_table
[fn
] = fp
= (struct face
*) xmalloc (sizeof (struct face
));
1144 bzero (fp
, sizeof (struct face
));
1145 fp
->face_type
= x_pixmap
;
1147 else if (FACE_IS_FONT (fn
))
1150 XFreeGC (FACE_FONT (fn
));
1153 else if (FACE_IS_IMAGE (fn
)) /* This should not happen... */
1156 XFreePixmap (x_current_display
, FACE_IMAGE (fn
));
1157 fp
->face_type
= x_font
;
1163 fp
->face_GLYPH
.font_desc
.font
= f
;
1164 gc_values
.font
= f
->fid
;
1165 gc_values
.foreground
= fg
;
1166 gc_values
.background
= bg
;
1167 fp
->face_GLYPH
.font_desc
.face_gc
= XCreateGC (x_current_display
,
1168 drawable
, GCFont
| GCForeground
1169 | GCBackground
, &gc_values
);
1170 fp
->face_GLYPH
.font_desc
.font_width
= FONT_WIDTH (f
);
1171 fp
->face_GLYPH
.font_desc
.font_height
= FONT_HEIGHT (f
);
1177 DEFUN ("x-set-face", Fx_set_face
, Sx_set_face
, 4, 4, 0,
1178 "Specify face table entry FACE-CODE to be the font named by FONT,\n\
1179 in colors FOREGROUND and BACKGROUND.")
1180 (face_code
, font_name
, foreground
, background
)
1181 Lisp_Object face_code
;
1182 Lisp_Object font_name
;
1183 Lisp_Object foreground
;
1184 Lisp_Object background
;
1186 register struct face
*fp
; /* Current face info. */
1187 register int fn
; /* Face number. */
1188 register FONT_TYPE
*f
; /* Font data structure. */
1189 unsigned char *newname
;
1191 CHECK_NUMBER (face_code
, 1);
1192 CHECK_STRING (font_name
, 2);
1194 fn
= XINT (face_code
);
1195 if ((fn
< 1) || (fn
> 255))
1196 error ("Invalid face code, %d", fn
);
1198 /* Ask the server to find the specified font. */
1199 newname
= XSTRING (font_name
)->data
;
1201 f
= (*newname
== 0 ? 0 : XGetFont (newname
));
1204 error ("Font \"%s\" is not defined", newname
);
1206 /* Get the face structure for face_code in the face table.
1207 Make sure it exists. */
1208 fp
= x_face_table
[fn
];
1211 x_face_table
[fn
] = fp
= (struct face
*) xmalloc (sizeof (struct face
));
1212 bzero (fp
, sizeof (struct face
));
1215 /* If this face code already exists, get rid of the old font. */
1216 if (fp
->font
!= 0 && fp
->font
!= f
)
1219 XLoseFont (fp
->font
);
1223 /* Store the specified information in FP. */
1224 fp
->fg
= x_decode_color (foreground
, BLACK_PIX_DEFAULT
);
1225 fp
->bg
= x_decode_color (background
, WHITE_PIX_DEFAULT
);
1233 /* This is excluded because there is no painless way
1234 to get or to remember the name of the font. */
1236 DEFUN ("x-get-face", Fx_get_face
, Sx_get_face
, 1, 1, 0,
1237 "Get data defining face code FACE. FACE is an integer.\n\
1238 The value is a list (FONT FG-COLOR BG-COLOR).")
1242 register struct face
*fp
; /* Current face info. */
1243 register int fn
; /* Face number. */
1245 CHECK_NUMBER (face
, 1);
1247 if ((fn
< 1) || (fn
> 255))
1248 error ("Invalid face code, %d", fn
);
1250 /* Make sure the face table exists and this face code is defined. */
1251 if (x_face_table
== 0 || x_face_table
[fn
] == 0)
1254 fp
= x_face_table
[fn
];
1256 return Fcons (build_string (fp
->name
),
1257 Fcons (make_number (fp
->fg
),
1258 Fcons (make_number (fp
->bg
), Qnil
)));
1262 /* Subroutines of creating an X frame. */
1265 extern char *x_get_string_resource ();
1266 extern XrmDatabase
x_load_resources ();
1268 DEFUN ("x-get-resource", Fx_get_resource
, Sx_get_resource
, 2, 4, 0,
1269 "Return the value of ATTRIBUTE, of class CLASS, from the X defaults database.\n\
1270 This uses `INSTANCE.ATTRIBUTE' as the key and `Emacs.CLASS' as the\n\
1271 class, where INSTANCE is the name under which Emacs was invoked.\n\
1273 The optional arguments COMPONENT and SUBCLASS add to the key and the\n\
1274 class, respectively. You must specify both of them or neither.\n\
1275 If you specify them, the key is `INSTANCE.COMPONENT.ATTRIBUTE'\n\
1276 and the class is `Emacs.CLASS.SUBCLASS'.")
1277 (attribute
, class, component
, subclass
)
1278 Lisp_Object attribute
, class, component
, subclass
;
1280 register char *value
;
1284 CHECK_STRING (attribute
, 0);
1285 CHECK_STRING (class, 0);
1287 if (!NILP (component
))
1288 CHECK_STRING (component
, 1);
1289 if (!NILP (subclass
))
1290 CHECK_STRING (subclass
, 2);
1291 if (NILP (component
) != NILP (subclass
))
1292 error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither");
1294 if (NILP (component
))
1296 /* Allocate space for the components, the dots which separate them,
1297 and the final '\0'. */
1298 name_key
= (char *) alloca (XSTRING (Vinvocation_name
)->size
1299 + XSTRING (attribute
)->size
1301 class_key
= (char *) alloca ((sizeof (EMACS_CLASS
) - 1)
1302 + XSTRING (class)->size
1305 sprintf (name_key
, "%s.%s",
1306 XSTRING (Vinvocation_name
)->data
,
1307 XSTRING (attribute
)->data
);
1308 sprintf (class_key
, "%s.%s",
1310 XSTRING (class)->data
);
1314 name_key
= (char *) alloca (XSTRING (Vinvocation_name
)->size
1315 + XSTRING (component
)->size
1316 + XSTRING (attribute
)->size
1319 class_key
= (char *) alloca ((sizeof (EMACS_CLASS
) - 1)
1320 + XSTRING (class)->size
1321 + XSTRING (subclass
)->size
1324 sprintf (name_key
, "%s.%s.%s",
1325 XSTRING (Vinvocation_name
)->data
,
1326 XSTRING (component
)->data
,
1327 XSTRING (attribute
)->data
);
1328 sprintf (class_key
, "%s.%s",
1330 XSTRING (class)->data
,
1331 XSTRING (subclass
)->data
);
1334 value
= x_get_string_resource (xrdb
, name_key
, class_key
);
1336 if (value
!= (char *) 0)
1337 return build_string (value
);
1344 DEFUN ("x-get-default", Fx_get_default
, Sx_get_default
, 1, 1, 0,
1345 "Get X default ATTRIBUTE from the system, or nil if no default.\n\
1346 Value is a string (when not nil) and ATTRIBUTE is also a string.\n\
1347 The defaults are specified in the file `~/.Xdefaults'.")
1351 register unsigned char *value
;
1353 CHECK_STRING (arg
, 1);
1355 value
= (unsigned char *) XGetDefault (XDISPLAY
1356 XSTRING (Vinvocation_name
)->data
,
1357 XSTRING (arg
)->data
);
1359 /* Try reversing last two args, in case this is the buggy version of X. */
1360 value
= (unsigned char *) XGetDefault (XDISPLAY
1361 XSTRING (arg
)->data
,
1362 XSTRING (Vinvocation_name
)->data
);
1364 return build_string (value
);
1369 #define Fx_get_resource(attribute, class, component, subclass) \
1370 Fx_get_default(attribute)
1374 /* Types we might convert a resource string into. */
1377 number
, boolean
, string
, symbol
,
1380 /* Return the value of parameter PARAM.
1382 First search ALIST, then Vdefault_frame_alist, then the X defaults
1383 database, using ATTRIBUTE as the attribute name and CLASS as its class.
1385 Convert the resource to the type specified by desired_type.
1387 If no default is specified, return Qunbound. If you call
1388 x_get_arg, make sure you deal with Qunbound in a reasonable way,
1389 and don't let it get stored in any lisp-visible variables! */
1392 x_get_arg (alist
, param
, attribute
, class, type
)
1393 Lisp_Object alist
, param
;
1396 enum resource_types type
;
1398 register Lisp_Object tem
;
1400 tem
= Fassq (param
, alist
);
1402 tem
= Fassq (param
, Vdefault_frame_alist
);
1408 tem
= Fx_get_resource (build_string (attribute
),
1409 build_string (class),
1418 return make_number (atoi (XSTRING (tem
)->data
));
1421 tem
= Fdowncase (tem
);
1422 if (!strcmp (XSTRING (tem
)->data
, "on")
1423 || !strcmp (XSTRING (tem
)->data
, "true"))
1432 return intern (tem
);
1444 /* Record in frame F the specified or default value according to ALIST
1445 of the parameter named PARAM (a Lisp symbol).
1446 If no value is specified for PARAM, look for an X default for XPROP
1447 on the frame named NAME.
1448 If that is not found either, use the value DEFLT. */
1451 x_default_parameter (f
, alist
, prop
, deflt
, xprop
, xclass
, type
)
1458 enum resource_types type
;
1462 tem
= x_get_arg (alist
, prop
, xprop
, xclass
, type
);
1463 if (EQ (tem
, Qunbound
))
1465 x_set_frame_parameters (f
, Fcons (Fcons (prop
, tem
), Qnil
));
1469 DEFUN ("x-geometry", Fx_geometry
, Sx_geometry
, 1, 1, 0,
1470 "Parse an X-style geometry string STRING.\n\
1471 Returns an alist of the form ((top . TOP), (left . LEFT) ... ).")
1476 unsigned int width
, height
;
1477 Lisp_Object values
[4];
1479 CHECK_STRING (string
, 0);
1481 geometry
= XParseGeometry ((char *) XSTRING (string
)->data
,
1482 &x
, &y
, &width
, &height
);
1484 switch (geometry
& 0xf) /* Mask out {X,Y}Negative */
1486 case (XValue
| YValue
):
1487 /* What's one pixel among friends?
1488 Perhaps fix this some day by returning symbol `extreme-top'... */
1489 if (x
== 0 && (geometry
& XNegative
))
1491 if (y
== 0 && (geometry
& YNegative
))
1493 values
[0] = Fcons (Qleft
, make_number (x
));
1494 values
[1] = Fcons (Qtop
, make_number (y
));
1495 return Flist (2, values
);
1498 case (WidthValue
| HeightValue
):
1499 values
[0] = Fcons (Qwidth
, make_number (width
));
1500 values
[1] = Fcons (Qheight
, make_number (height
));
1501 return Flist (2, values
);
1504 case (XValue
| YValue
| WidthValue
| HeightValue
):
1505 if (x
== 0 && (geometry
& XNegative
))
1507 if (y
== 0 && (geometry
& YNegative
))
1509 values
[0] = Fcons (Qwidth
, make_number (width
));
1510 values
[1] = Fcons (Qheight
, make_number (height
));
1511 values
[2] = Fcons (Qleft
, make_number (x
));
1512 values
[3] = Fcons (Qtop
, make_number (y
));
1513 return Flist (4, values
);
1520 error ("Must specify x and y value, and/or width and height");
1525 /* Calculate the desired size and position of this window,
1526 or set rubber-band prompting if none. */
1528 #define DEFAULT_ROWS 40
1529 #define DEFAULT_COLS 80
1532 x_figure_window_size (f
, parms
)
1536 register Lisp_Object tem0
, tem1
;
1537 int height
, width
, left
, top
;
1538 register int geometry
;
1539 long window_prompting
= 0;
1541 /* Default values if we fall through.
1542 Actually, if that happens we should get
1543 window manager prompting. */
1544 f
->width
= DEFAULT_COLS
;
1545 f
->height
= DEFAULT_ROWS
;
1546 f
->display
.x
->top_pos
= 1;
1547 f
->display
.x
->left_pos
= 1;
1549 tem0
= x_get_arg (parms
, Qheight
, 0, 0, number
);
1550 tem1
= x_get_arg (parms
, Qwidth
, 0, 0, number
);
1551 if (! EQ (tem0
, Qunbound
) && ! EQ (tem1
, Qunbound
))
1553 CHECK_NUMBER (tem0
, 0);
1554 CHECK_NUMBER (tem1
, 0);
1555 f
->height
= XINT (tem0
);
1556 f
->width
= XINT (tem1
);
1557 window_prompting
|= USSize
;
1559 else if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
1560 error ("Must specify *both* height and width");
1562 f
->display
.x
->vertical_scroll_bar_extra
=
1563 (FRAME_HAS_VERTICAL_SCROLL_BARS (f
)
1564 ? VERTICAL_SCROLL_BAR_PIXEL_WIDTH (f
)
1566 f
->display
.x
->pixel_width
= CHAR_TO_PIXEL_WIDTH (f
, f
->width
);
1567 f
->display
.x
->pixel_height
= CHAR_TO_PIXEL_HEIGHT (f
, f
->height
);
1569 tem0
= x_get_arg (parms
, Qtop
, 0, 0, number
);
1570 tem1
= x_get_arg (parms
, Qleft
, 0, 0, number
);
1571 if (! EQ (tem0
, Qunbound
) && ! EQ (tem1
, Qunbound
))
1573 CHECK_NUMBER (tem0
, 0);
1574 CHECK_NUMBER (tem1
, 0);
1575 f
->display
.x
->top_pos
= XINT (tem0
);
1576 f
->display
.x
->left_pos
= XINT (tem1
);
1577 x_calc_absolute_position (f
);
1578 window_prompting
|= USPosition
;
1580 else if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
1581 error ("Must specify *both* top and left corners");
1583 switch (window_prompting
)
1585 case USSize
| USPosition
:
1586 return window_prompting
;
1589 case USSize
: /* Got the size, need the position. */
1590 window_prompting
|= PPosition
;
1591 return window_prompting
;
1594 case USPosition
: /* Got the position, need the size. */
1595 window_prompting
|= PSize
;
1596 return window_prompting
;
1599 case 0: /* Got nothing, take both from geometry. */
1600 window_prompting
|= PPosition
| PSize
;
1601 return window_prompting
;
1605 /* Somehow a bit got set in window_prompting that we didn't
1615 XSetWindowAttributes attributes
;
1616 unsigned long attribute_mask
;
1617 XClassHint class_hints
;
1619 attributes
.background_pixel
= f
->display
.x
->background_pixel
;
1620 attributes
.border_pixel
= f
->display
.x
->border_pixel
;
1621 attributes
.bit_gravity
= StaticGravity
;
1622 attributes
.backing_store
= NotUseful
;
1623 attributes
.save_under
= True
;
1624 attributes
.event_mask
= STANDARD_EVENT_SET
;
1625 attribute_mask
= (CWBackPixel
| CWBorderPixel
| CWBitGravity
1627 | CWBackingStore
| CWSaveUnder
1633 = XCreateWindow (x_current_display
, ROOT_WINDOW
,
1634 f
->display
.x
->left_pos
,
1635 f
->display
.x
->top_pos
,
1636 PIXEL_WIDTH (f
), PIXEL_HEIGHT (f
),
1637 f
->display
.x
->border_width
,
1638 CopyFromParent
, /* depth */
1639 InputOutput
, /* class */
1640 screen_visual
, /* set in Fx_open_connection */
1641 attribute_mask
, &attributes
);
1643 class_hints
.res_name
= (char *) XSTRING (f
->name
)->data
;
1644 class_hints
.res_class
= EMACS_CLASS
;
1645 XSetClassHint (x_current_display
, FRAME_X_WINDOW (f
), &class_hints
);
1647 /* This indicates that we use the "Passive Input" input model.
1648 Unless we do this, we don't get the Focus{In,Out} events that we
1649 need to draw the cursor correctly. Accursed bureaucrats.
1650 XWhipsAndChains (x_current_display, IronMaiden, &TheRack); */
1652 f
->display
.x
->wm_hints
.input
= True
;
1653 f
->display
.x
->wm_hints
.flags
|= InputHint
;
1654 XSetWMHints (x_current_display
, FRAME_X_WINDOW (f
), &f
->display
.x
->wm_hints
);
1656 /* x_set_name normally ignores requests to set the name if the
1657 requested name is the same as the current name. This is the one
1658 place where that assumption isn't correct; f->name is set, but
1659 the X server hasn't been told. */
1661 Lisp_Object name
= f
->name
;
1662 int explicit = f
->explicit_name
;
1665 f
->explicit_name
= 0;
1666 x_set_name (f
, name
, explicit);
1669 XDefineCursor (XDISPLAY
FRAME_X_WINDOW (f
),
1670 f
->display
.x
->text_cursor
);
1673 if (FRAME_X_WINDOW (f
) == 0)
1674 error ("Unable to create window.");
1677 /* Handle the icon stuff for this window. Perhaps later we might
1678 want an x_set_icon_position which can be called interactively as
1686 Lisp_Object icon_x
, icon_y
;
1688 /* Set the position of the icon. Note that twm groups all
1689 icons in an icon window. */
1690 icon_x
= x_get_arg (parms
, Qicon_left
, 0, 0, number
);
1691 icon_y
= x_get_arg (parms
, Qicon_top
, 0, 0, number
);
1692 if (!EQ (icon_x
, Qunbound
) && !EQ (icon_y
, Qunbound
))
1694 CHECK_NUMBER (icon_x
, 0);
1695 CHECK_NUMBER (icon_y
, 0);
1697 else if (!EQ (icon_x
, Qunbound
) || !EQ (icon_y
, Qunbound
))
1698 error ("Both left and top icon corners of icon must be specified");
1702 if (! EQ (icon_x
, Qunbound
))
1703 x_wm_set_icon_position (f
, XINT (icon_x
), XINT (icon_y
));
1705 /* Start up iconic or window? */
1706 x_wm_set_window_state (f
,
1707 (EQ (x_get_arg (parms
, Qiconic_startup
,
1716 /* Make the GC's needed for this window, setting the
1717 background, border and mouse colors; also create the
1718 mouse cursor and the gray border tile. */
1720 static char cursor_bits
[] =
1722 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1723 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1724 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1725 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1732 XGCValues gc_values
;
1736 /* Create the GC's of this frame.
1737 Note that many default values are used. */
1740 gc_values
.font
= f
->display
.x
->font
->fid
;
1741 gc_values
.foreground
= f
->display
.x
->foreground_pixel
;
1742 gc_values
.background
= f
->display
.x
->background_pixel
;
1743 gc_values
.line_width
= 0; /* Means 1 using fast algorithm. */
1744 f
->display
.x
->normal_gc
= XCreateGC (x_current_display
,
1746 GCLineWidth
| GCFont
1747 | GCForeground
| GCBackground
,
1750 /* Reverse video style. */
1751 gc_values
.foreground
= f
->display
.x
->background_pixel
;
1752 gc_values
.background
= f
->display
.x
->foreground_pixel
;
1753 f
->display
.x
->reverse_gc
= XCreateGC (x_current_display
,
1755 GCFont
| GCForeground
| GCBackground
1759 /* Cursor has cursor-color background, background-color foreground. */
1760 gc_values
.foreground
= f
->display
.x
->background_pixel
;
1761 gc_values
.background
= f
->display
.x
->cursor_pixel
;
1762 gc_values
.fill_style
= FillOpaqueStippled
;
1764 = XCreateBitmapFromData (x_current_display
, ROOT_WINDOW
,
1765 cursor_bits
, 16, 16);
1766 f
->display
.x
->cursor_gc
1767 = XCreateGC (x_current_display
, FRAME_X_WINDOW (f
),
1768 (GCFont
| GCForeground
| GCBackground
1769 | GCFillStyle
| GCStipple
| GCLineWidth
),
1772 /* Create the gray border tile used when the pointer is not in
1773 the frame. Since this depends on the frame's pixel values,
1774 this must be done on a per-frame basis. */
1775 f
->display
.x
->border_tile
1776 = (XCreatePixmapFromBitmapData
1777 (x_current_display
, ROOT_WINDOW
,
1778 gray_bits
, gray_width
, gray_height
,
1779 f
->display
.x
->foreground_pixel
,
1780 f
->display
.x
->background_pixel
,
1781 DefaultDepth (x_current_display
, XDefaultScreen (x_current_display
))));
1783 #endif /* HAVE_X11 */
1785 DEFUN ("x-create-frame", Fx_create_frame
, Sx_create_frame
,
1787 "Make a new X window, which is called a \"frame\" in Emacs terms.\n\
1788 Return an Emacs frame object representing the X window.\n\
1789 ALIST is an alist of frame parameters.\n\
1790 If the parameters specify that the frame should not have a minibuffer,\n\
1791 and do not specify a specific minibuffer window to use,\n\
1792 then `default-minibuffer-frame' must be a frame whose minibuffer can\n\
1793 be shared by the new frame.")
1799 Lisp_Object frame
, tem
;
1801 int minibuffer_only
= 0;
1802 long window_prompting
= 0;
1805 if (x_current_display
== 0)
1806 error ("X windows are not in use or not initialized");
1808 name
= x_get_arg (parms
, Qname
, "title", "Title", string
);
1809 if (XTYPE (name
) != Lisp_String
1810 && ! EQ (name
, Qunbound
)
1812 error ("x-create-frame: name parameter must be a string");
1814 tem
= x_get_arg (parms
, Qminibuffer
, 0, 0, symbol
);
1815 if (EQ (tem
, Qnone
) || NILP (tem
))
1816 f
= make_frame_without_minibuffer (Qnil
);
1817 else if (EQ (tem
, Qonly
))
1819 f
= make_minibuffer_frame ();
1820 minibuffer_only
= 1;
1822 else if (XTYPE (tem
) == Lisp_Window
)
1823 f
= make_frame_without_minibuffer (tem
);
1827 /* Note that X Windows does support scroll bars. */
1828 FRAME_CAN_HAVE_SCROLL_BARS (f
) = 1;
1830 /* Set the name; the functions to which we pass f expect the name to
1832 if (EQ (name
, Qunbound
) || NILP (name
))
1834 f
->name
= build_string (x_id_name
);
1835 f
->explicit_name
= 0;
1840 f
->explicit_name
= 1;
1843 XSET (frame
, Lisp_Frame
, f
);
1844 f
->output_method
= output_x_window
;
1845 f
->display
.x
= (struct x_display
*) xmalloc (sizeof (struct x_display
));
1846 bzero (f
->display
.x
, sizeof (struct x_display
));
1848 /* Note that the frame has no physical cursor right now. */
1849 f
->phys_cursor_x
= -1;
1851 /* Extract the window parameters from the supplied values
1852 that are needed to determine window geometry. */
1853 x_default_parameter (f
, parms
, Qfont
, build_string ("9x15"),
1854 "font", "Font", string
);
1855 x_default_parameter (f
, parms
, Qborder_width
, make_number (2),
1856 "borderwidth", "BorderWidth", number
);
1857 /* This defaults to 2 in order to match xterm. */
1858 x_default_parameter (f
, parms
, Qinternal_border_width
, make_number (2),
1859 "internalBorderWidth", "BorderWidth", number
);
1860 x_default_parameter (f
, parms
, Qvertical_scroll_bars
, Qt
,
1861 "verticalScrollBars", "ScrollBars", boolean
);
1863 /* Also do the stuff which must be set before the window exists. */
1864 x_default_parameter (f
, parms
, Qforeground_color
, build_string ("black"),
1865 "foreground", "Foreground", string
);
1866 x_default_parameter (f
, parms
, Qbackground_color
, build_string ("white"),
1867 "background", "Background", string
);
1868 x_default_parameter (f
, parms
, Qmouse_color
, build_string ("black"),
1869 "pointerColor", "Foreground", string
);
1870 x_default_parameter (f
, parms
, Qcursor_color
, build_string ("black"),
1871 "cursorColor", "Foreground", string
);
1872 x_default_parameter (f
, parms
, Qborder_color
, build_string ("black"),
1873 "borderColor", "BorderColor", string
);
1875 f
->display
.x
->parent_desc
= ROOT_WINDOW
;
1876 window_prompting
= x_figure_window_size (f
, parms
);
1882 /* We need to do this after creating the X window, so that the
1883 icon-creation functions can say whose icon they're describing. */
1884 x_default_parameter (f
, parms
, Qicon_type
, Qnil
,
1885 "iconType", "IconType", symbol
);
1887 x_default_parameter (f
, parms
, Qauto_raise
, Qnil
,
1888 "autoRaise", "AutoRaiseLower", boolean
);
1889 x_default_parameter (f
, parms
, Qauto_lower
, Qnil
,
1890 "autoLower", "AutoRaiseLower", boolean
);
1891 x_default_parameter (f
, parms
, Qcursor_type
, Qbox
,
1892 "cursorType", "CursorType", symbol
);
1894 /* Dimensions, especially f->height, must be done via change_frame_size.
1895 Change will not be effected unless different from the current
1899 f
->height
= f
->width
= 0;
1900 change_frame_size (f
, height
, width
, 1, 0);
1902 x_default_parameter (f
, parms
, Qmenu_bar_lines
, make_number (0),
1903 "menuBarLines", "MenuBarLines", number
);
1906 x_wm_set_size_hint (f
, window_prompting
);
1909 tem
= x_get_arg (parms
, Qunsplittable
, 0, 0, boolean
);
1910 f
->no_split
= minibuffer_only
|| EQ (tem
, Qt
);
1912 /* Make the window appear on the frame and enable display,
1913 unless the caller says not to. */
1914 if (!EQ (x_get_arg (parms
, Qsuppress_initial_map
, 0, 0, boolean
), Qt
))
1916 tem
= x_get_arg (parms
, Qvisibility
, 0, 0, boolean
);
1917 if (EQ (tem
, Qicon
))
1918 x_iconify_frame (f
);
1919 /* Note that the default is Qunbound,
1920 so by default we do make visible. */
1921 else if (!EQ (tem
, Qnil
))
1922 x_make_frame_visible (f
);
1928 Lisp_Object frame
, tem
;
1930 int pixelwidth
, pixelheight
;
1935 int minibuffer_only
= 0;
1936 Lisp_Object vscroll
, hscroll
;
1938 if (x_current_display
== 0)
1939 error ("X windows are not in use or not initialized");
1941 name
= Fassq (Qname
, parms
);
1943 tem
= x_get_arg (parms
, Qminibuffer
, 0, 0, symbol
);
1944 if (EQ (tem
, Qnone
))
1945 f
= make_frame_without_minibuffer (Qnil
);
1946 else if (EQ (tem
, Qonly
))
1948 f
= make_minibuffer_frame ();
1949 minibuffer_only
= 1;
1951 else if (EQ (tem
, Qnil
) || EQ (tem
, Qunbound
))
1954 f
= make_frame_without_minibuffer (tem
);
1956 parent
= ROOT_WINDOW
;
1958 XSET (frame
, Lisp_Frame
, f
);
1959 f
->output_method
= output_x_window
;
1960 f
->display
.x
= (struct x_display
*) xmalloc (sizeof (struct x_display
));
1961 bzero (f
->display
.x
, sizeof (struct x_display
));
1963 /* Some temprorary default values for height and width. */
1966 f
->display
.x
->left_pos
= -1;
1967 f
->display
.x
->top_pos
= -1;
1969 /* Give the frame a default name (which may be overridden with PARMS). */
1971 strncpy (iconidentity
, ICONTAG
, MAXICID
);
1972 if (gethostname (&iconidentity
[sizeof (ICONTAG
) - 1],
1973 (MAXICID
- 1) - sizeof (ICONTAG
)))
1974 iconidentity
[sizeof (ICONTAG
) - 2] = '\0';
1975 f
->name
= build_string (iconidentity
);
1977 /* Extract some window parameters from the supplied values.
1978 These are the parameters that affect window geometry. */
1980 tem
= x_get_arg (parms
, Qfont
, "BodyFont", 0, string
);
1981 if (EQ (tem
, Qunbound
))
1982 tem
= build_string ("9x15");
1983 x_set_font (f
, tem
, Qnil
);
1984 x_default_parameter (f
, parms
, Qborder_color
,
1985 build_string ("black"), "Border", 0, string
);
1986 x_default_parameter (f
, parms
, Qbackground_color
,
1987 build_string ("white"), "Background", 0, string
);
1988 x_default_parameter (f
, parms
, Qforeground_color
,
1989 build_string ("black"), "Foreground", 0, string
);
1990 x_default_parameter (f
, parms
, Qmouse_color
,
1991 build_string ("black"), "Mouse", 0, string
);
1992 x_default_parameter (f
, parms
, Qcursor_color
,
1993 build_string ("black"), "Cursor", 0, string
);
1994 x_default_parameter (f
, parms
, Qborder_width
,
1995 make_number (2), "BorderWidth", 0, number
);
1996 x_default_parameter (f
, parms
, Qinternal_border_width
,
1997 make_number (4), "InternalBorderWidth", 0, number
);
1998 x_default_parameter (f
, parms
, Qauto_raise
,
1999 Qnil
, "AutoRaise", 0, boolean
);
2001 hscroll
= EQ (x_get_arg (parms
, Qhorizontal_scroll_bar
, 0, 0, boolean
), Qt
);
2002 vscroll
= EQ (x_get_arg (parms
, Qvertical_scroll_bar
, 0, 0, boolean
), Qt
);
2004 if (f
->display
.x
->internal_border_width
< 0)
2005 f
->display
.x
->internal_border_width
= 0;
2007 tem
= x_get_arg (parms
, Qwindow_id
, 0, 0, number
);
2008 if (!EQ (tem
, Qunbound
))
2010 WINDOWINFO_TYPE wininfo
;
2012 Window
*children
, root
;
2014 CHECK_NUMBER (tem
, 0);
2015 FRAME_X_WINDOW (f
) = (Window
) XINT (tem
);
2018 XGetWindowInfo (FRAME_X_WINDOW (f
), &wininfo
);
2019 XQueryTree (FRAME_X_WINDOW (f
), &parent
, &nchildren
, &children
);
2023 height
= PIXEL_TO_CHAR_HEIGHT (f
, wininfo
.height
);
2024 width
= PIXEL_TO_CHAR_WIDTH (f
, wininfo
.width
);
2025 f
->display
.x
->left_pos
= wininfo
.x
;
2026 f
->display
.x
->top_pos
= wininfo
.y
;
2027 FRAME_SET_VISIBILITY (f
, wininfo
.mapped
!= 0);
2028 f
->display
.x
->border_width
= wininfo
.bdrwidth
;
2029 f
->display
.x
->parent_desc
= parent
;
2033 tem
= x_get_arg (parms
, Qparent_id
, 0, 0, number
);
2034 if (!EQ (tem
, Qunbound
))
2036 CHECK_NUMBER (tem
, 0);
2037 parent
= (Window
) XINT (tem
);
2039 f
->display
.x
->parent_desc
= parent
;
2040 tem
= x_get_arg (parms
, Qheight
, 0, 0, number
);
2041 if (EQ (tem
, Qunbound
))
2043 tem
= x_get_arg (parms
, Qwidth
, 0, 0, number
);
2044 if (EQ (tem
, Qunbound
))
2046 tem
= x_get_arg (parms
, Qtop
, 0, 0, number
);
2047 if (EQ (tem
, Qunbound
))
2048 tem
= x_get_arg (parms
, Qleft
, 0, 0, number
);
2051 /* Now TEM is Qunbound if no edge or size was specified.
2052 In that case, we must do rubber-banding. */
2053 if (EQ (tem
, Qunbound
))
2055 tem
= x_get_arg (parms
, Qgeometry
, 0, 0, number
);
2057 &f
->display
.x
->left_pos
, &f
->display
.x
->top_pos
,
2059 (XTYPE (tem
) == Lisp_String
2060 ? (char *) XSTRING (tem
)->data
: ""),
2061 XSTRING (f
->name
)->data
,
2062 !NILP (hscroll
), !NILP (vscroll
));
2066 /* Here if at least one edge or size was specified.
2067 Demand that they all were specified, and use them. */
2068 tem
= x_get_arg (parms
, Qheight
, 0, 0, number
);
2069 if (EQ (tem
, Qunbound
))
2070 error ("Height not specified");
2071 CHECK_NUMBER (tem
, 0);
2072 height
= XINT (tem
);
2074 tem
= x_get_arg (parms
, Qwidth
, 0, 0, number
);
2075 if (EQ (tem
, Qunbound
))
2076 error ("Width not specified");
2077 CHECK_NUMBER (tem
, 0);
2080 tem
= x_get_arg (parms
, Qtop
, 0, 0, number
);
2081 if (EQ (tem
, Qunbound
))
2082 error ("Top position not specified");
2083 CHECK_NUMBER (tem
, 0);
2084 f
->display
.x
->left_pos
= XINT (tem
);
2086 tem
= x_get_arg (parms
, Qleft
, 0, 0, number
);
2087 if (EQ (tem
, Qunbound
))
2088 error ("Left position not specified");
2089 CHECK_NUMBER (tem
, 0);
2090 f
->display
.x
->top_pos
= XINT (tem
);
2093 pixelwidth
= CHAR_TO_PIXEL_WIDTH (f
, width
);
2094 pixelheight
= CHAR_TO_PIXEL_HEIGHT (f
, height
);
2098 = XCreateWindow (parent
,
2099 f
->display
.x
->left_pos
, /* Absolute horizontal offset */
2100 f
->display
.x
->top_pos
, /* Absolute Vertical offset */
2101 pixelwidth
, pixelheight
,
2102 f
->display
.x
->border_width
,
2103 BLACK_PIX_DEFAULT
, WHITE_PIX_DEFAULT
);
2105 if (FRAME_X_WINDOW (f
) == 0)
2106 error ("Unable to create window.");
2109 /* Install the now determined height and width
2110 in the windows and in phys_lines and desired_lines. */
2111 change_frame_size (f
, height
, width
, 1, 0);
2112 XSelectInput (FRAME_X_WINDOW (f
), KeyPressed
| ExposeWindow
2113 | ButtonPressed
| ButtonReleased
| ExposeRegion
| ExposeCopy
2114 | EnterWindow
| LeaveWindow
| UnmapWindow
);
2115 x_set_resize_hint (f
);
2117 /* Tell the server the window's default name. */
2118 XStoreName (XDISPLAY
FRAME_X_WINDOW (f
), XSTRING (f
->name
)->data
);
2120 /* Now override the defaults with all the rest of the specified
2122 tem
= x_get_arg (parms
, Qunsplittable
, 0, 0, boolean
);
2123 f
->no_split
= minibuffer_only
|| EQ (tem
, Qt
);
2125 /* Do not create an icon window if the caller says not to */
2126 if (!EQ (x_get_arg (parms
, Qsuppress_icon
, 0, 0, boolean
), Qt
)
2127 || f
->display
.x
->parent_desc
!= ROOT_WINDOW
)
2129 x_text_icon (f
, iconidentity
);
2130 x_default_parameter (f
, parms
, Qicon_type
, Qnil
,
2131 "BitmapIcon", 0, symbol
);
2134 /* Tell the X server the previously set values of the
2135 background, border and mouse colors; also create the mouse cursor. */
2137 temp
= XMakeTile (f
->display
.x
->background_pixel
);
2138 XChangeBackground (FRAME_X_WINDOW (f
), temp
);
2141 x_set_border_pixel (f
, f
->display
.x
->border_pixel
);
2143 x_set_mouse_color (f
, Qnil
, Qnil
);
2145 /* Now override the defaults with all the rest of the specified parms. */
2147 Fmodify_frame_parameters (frame
, parms
);
2149 /* Make the window appear on the frame and enable display. */
2151 if (!EQ (x_get_arg (parms
, Qsuppress_initial_map
, 0, 0, boolean
), Qt
))
2152 x_make_window_visible (f
);
2153 SET_FRAME_GARBAGED (f
);
2159 DEFUN ("focus-frame", Ffocus_frame
, Sfocus_frame
, 1, 1, 0,
2160 "Set the focus on FRAME.")
2164 CHECK_LIVE_FRAME (frame
, 0);
2166 if (FRAME_X_P (XFRAME (frame
)))
2169 x_focus_on_frame (XFRAME (frame
));
2177 DEFUN ("unfocus-frame", Funfocus_frame
, Sunfocus_frame
, 0, 0, 0,
2178 "If a frame has been focused, release it.")
2184 x_unfocus_frame (x_focus_frame
);
2192 /* Computes an X-window size and position either from geometry GEO
2195 F is a frame. It specifies an X window which is used to
2196 determine which display to compute for. Its font, borders
2197 and colors control how the rectangle will be displayed.
2199 X and Y are where to store the positions chosen.
2200 WIDTH and HEIGHT are where to store the sizes chosen.
2202 GEO is the geometry that may specify some of the info.
2203 STR is a prompt to display.
2204 HSCROLL and VSCROLL say whether we have horiz and vert scroll bars. */
2207 x_rubber_band (f
, x
, y
, width
, height
, geo
, str
, hscroll
, vscroll
)
2209 int *x
, *y
, *width
, *height
;
2212 int hscroll
, vscroll
;
2218 int background_color
;
2224 background_color
= f
->display
.x
->background_pixel
;
2225 border_color
= f
->display
.x
->border_pixel
;
2227 frame
.bdrwidth
= f
->display
.x
->border_width
;
2228 frame
.border
= XMakeTile (border_color
);
2229 frame
.background
= XMakeTile (background_color
);
2230 tempwindow
= XCreateTerm (str
, "emacs", geo
, default_window
, &frame
, 10, 5,
2231 (2 * f
->display
.x
->internal_border_width
2232 + (vscroll
? VSCROLL_WIDTH
: 0)),
2233 (2 * f
->display
.x
->internal_border_width
2234 + (hscroll
? HSCROLL_HEIGHT
: 0)),
2235 width
, height
, f
->display
.x
->font
,
2236 FONT_WIDTH (f
->display
.x
->font
),
2237 FONT_HEIGHT (f
->display
.x
->font
));
2238 XFreePixmap (frame
.border
);
2239 XFreePixmap (frame
.background
);
2241 if (tempwindow
!= 0)
2243 XQueryWindow (tempwindow
, &wininfo
);
2244 XDestroyWindow (tempwindow
);
2249 /* Coordinates we got are relative to the root window.
2250 Convert them to coordinates relative to desired parent window
2251 by scanning from there up to the root. */
2252 tempwindow
= f
->display
.x
->parent_desc
;
2253 while (tempwindow
!= ROOT_WINDOW
)
2257 XQueryWindow (tempwindow
, &wininfo
);
2260 XQueryTree (tempwindow
, &tempwindow
, &nchildren
, &children
);
2265 return tempwindow
!= 0;
2267 #endif /* not HAVE_X11 */
2269 DEFUN ("x-defined-color", Fx_defined_color
, Sx_defined_color
, 1, 1, 0,
2270 "Return t if the current X display supports the color named COLOR.")
2276 CHECK_STRING (color
, 0);
2278 if (defined_color (XSTRING (color
)->data
, &foo
))
2284 DEFUN ("x-display-color-p", Fx_display_color_p
, Sx_display_color_p
, 0, 0, 0,
2285 "Return t if the X screen currently in use supports color.")
2288 if (x_screen_planes
<= 2)
2291 switch (screen_visual
->class)
2304 DEFUN ("x-display-pixel-width", Fx_display_pixel_width
, Sx_display_pixel_width
,
2306 "Returns the width in pixels of the display FRAME is on.")
2310 Display
*dpy
= x_current_display
;
2311 return make_number (DisplayWidth (dpy
, DefaultScreen (dpy
)));
2314 DEFUN ("x-display-pixel-height", Fx_display_pixel_height
,
2315 Sx_display_pixel_height
, 0, 1, 0,
2316 "Returns the height in pixels of the display FRAME is on.")
2320 Display
*dpy
= x_current_display
;
2321 return make_number (DisplayHeight (dpy
, DefaultScreen (dpy
)));
2324 DEFUN ("x-display-planes", Fx_display_planes
, Sx_display_planes
,
2326 "Returns the number of bitplanes of the display FRAME is on.")
2330 Display
*dpy
= x_current_display
;
2331 return make_number (DisplayPlanes (dpy
, DefaultScreen (dpy
)));
2334 DEFUN ("x-display-color-cells", Fx_display_color_cells
, Sx_display_color_cells
,
2336 "Returns the number of color cells of the display FRAME is on.")
2340 Display
*dpy
= x_current_display
;
2341 return make_number (DisplayCells (dpy
, DefaultScreen (dpy
)));
2344 DEFUN ("x-server-vendor", Fx_server_vendor
, Sx_server_vendor
, 0, 1, 0,
2345 "Returns the vendor ID string of the X server FRAME is on.")
2349 Display
*dpy
= x_current_display
;
2351 vendor
= ServerVendor (dpy
);
2352 if (! vendor
) vendor
= "";
2353 return build_string (vendor
);
2356 DEFUN ("x-server-version", Fx_server_version
, Sx_server_version
, 0, 1, 0,
2357 "Returns the version numbers of the X server in use.\n\
2358 The value is a list of three integers: the major and minor\n\
2359 version numbers of the X Protocol in use, and the vendor-specific release\n\
2360 number. See also the variable `x-server-vendor'.")
2364 Display
*dpy
= x_current_display
;
2365 return Fcons (make_number (ProtocolVersion (dpy
)),
2366 Fcons (make_number (ProtocolRevision (dpy
)),
2367 Fcons (make_number (VendorRelease (dpy
)), Qnil
)));
2370 DEFUN ("x-display-screens", Fx_display_screens
, Sx_display_screens
, 0, 1, 0,
2371 "Returns the number of screens on the X server FRAME is on.")
2375 return make_number (ScreenCount (x_current_display
));
2378 DEFUN ("x-display-mm-height", Fx_display_mm_height
, Sx_display_mm_height
, 0, 1, 0,
2379 "Returns the height in millimeters of the X screen FRAME is on.")
2383 return make_number (HeightMMOfScreen (x_screen
));
2386 DEFUN ("x-display-mm-width", Fx_display_mm_width
, Sx_display_mm_width
, 0, 1, 0,
2387 "Returns the width in millimeters of the X screen FRAME is on.")
2391 return make_number (WidthMMOfScreen (x_screen
));
2394 DEFUN ("x-display-backing-store", Fx_display_backing_store
,
2395 Sx_display_backing_store
, 0, 1, 0,
2396 "Returns an indication of whether the X screen FRAME is on does backing store.\n\
2397 The value may be `always', `when-mapped', or `not-useful'.")
2401 switch (DoesBackingStore (x_screen
))
2404 return intern ("always");
2407 return intern ("when-mapped");
2410 return intern ("not-useful");
2413 error ("Strange value for BackingStore parameter of screen");
2417 DEFUN ("x-display-visual-class", Fx_display_visual_class
,
2418 Sx_display_visual_class
, 0, 1, 0,
2419 "Returns the visual class of the display `screen' is on.\n\
2420 The value is one of the symbols `static-gray', `gray-scale',\n\
2421 `static-color', `pseudo-color', `true-color', or `direct-color'.")
2425 switch (screen_visual
->class)
2427 case StaticGray
: return (intern ("static-gray"));
2428 case GrayScale
: return (intern ("gray-scale"));
2429 case StaticColor
: return (intern ("static-color"));
2430 case PseudoColor
: return (intern ("pseudo-color"));
2431 case TrueColor
: return (intern ("true-color"));
2432 case DirectColor
: return (intern ("direct-color"));
2434 error ("Display has an unknown visual class");
2438 DEFUN ("x-display-save-under", Fx_display_save_under
,
2439 Sx_display_save_under
, 0, 1, 0,
2440 "Returns t if the X screen FRAME is on supports the save-under feature.")
2444 if (DoesSaveUnders (x_screen
) == True
)
2451 register struct frame
*f
;
2453 return PIXEL_WIDTH (f
);
2457 register struct frame
*f
;
2459 return PIXEL_HEIGHT (f
);
2463 register struct frame
*f
;
2465 return FONT_WIDTH (f
->display
.x
->font
);
2469 register struct frame
*f
;
2471 return FONT_HEIGHT (f
->display
.x
->font
);
2474 #if 0 /* These no longer seem like the right way to do things. */
2476 /* Draw a rectangle on the frame with left top corner including
2477 the character specified by LEFT_CHAR and TOP_CHAR. The rectangle is
2478 CHARS by LINES wide and long and is the color of the cursor. */
2481 x_rectangle (f
, gc
, left_char
, top_char
, chars
, lines
)
2482 register struct frame
*f
;
2484 register int top_char
, left_char
, chars
, lines
;
2488 int left
= (left_char
* FONT_WIDTH (f
->display
.x
->font
)
2489 + f
->display
.x
->internal_border_width
);
2490 int top
= (top_char
* FONT_HEIGHT (f
->display
.x
->font
)
2491 + f
->display
.x
->internal_border_width
);
2494 width
= FONT_WIDTH (f
->display
.x
->font
) / 2;
2496 width
= FONT_WIDTH (f
->display
.x
->font
) * chars
;
2498 height
= FONT_HEIGHT (f
->display
.x
->font
) / 2;
2500 height
= FONT_HEIGHT (f
->display
.x
->font
) * lines
;
2502 XDrawRectangle (x_current_display
, FRAME_X_WINDOW (f
),
2503 gc
, left
, top
, width
, height
);
2506 DEFUN ("x-draw-rectangle", Fx_draw_rectangle
, Sx_draw_rectangle
, 5, 5, 0,
2507 "Draw a rectangle on FRAME between coordinates specified by\n\
2508 numbers X0, Y0, X1, Y1 in the cursor pixel.")
2509 (frame
, X0
, Y0
, X1
, Y1
)
2510 register Lisp_Object frame
, X0
, X1
, Y0
, Y1
;
2512 register int x0
, y0
, x1
, y1
, top
, left
, n_chars
, n_lines
;
2514 CHECK_LIVE_FRAME (frame
, 0);
2515 CHECK_NUMBER (X0
, 0);
2516 CHECK_NUMBER (Y0
, 1);
2517 CHECK_NUMBER (X1
, 2);
2518 CHECK_NUMBER (Y1
, 3);
2528 n_lines
= y1
- y0
+ 1;
2533 n_lines
= y0
- y1
+ 1;
2539 n_chars
= x1
- x0
+ 1;
2544 n_chars
= x0
- x1
+ 1;
2548 x_rectangle (XFRAME (frame
), XFRAME (frame
)->display
.x
->cursor_gc
,
2549 left
, top
, n_chars
, n_lines
);
2555 DEFUN ("x-erase-rectangle", Fx_erase_rectangle
, Sx_erase_rectangle
, 5, 5, 0,
2556 "Draw a rectangle drawn on FRAME between coordinates\n\
2557 X0, Y0, X1, Y1 in the regular background-pixel.")
2558 (frame
, X0
, Y0
, X1
, Y1
)
2559 register Lisp_Object frame
, X0
, Y0
, X1
, Y1
;
2561 register int x0
, y0
, x1
, y1
, top
, left
, n_chars
, n_lines
;
2563 CHECK_FRAME (frame
, 0);
2564 CHECK_NUMBER (X0
, 0);
2565 CHECK_NUMBER (Y0
, 1);
2566 CHECK_NUMBER (X1
, 2);
2567 CHECK_NUMBER (Y1
, 3);
2577 n_lines
= y1
- y0
+ 1;
2582 n_lines
= y0
- y1
+ 1;
2588 n_chars
= x1
- x0
+ 1;
2593 n_chars
= x0
- x1
+ 1;
2597 x_rectangle (XFRAME (frame
), XFRAME (frame
)->display
.x
->reverse_gc
,
2598 left
, top
, n_chars
, n_lines
);
2604 /* Draw lines around the text region beginning at the character position
2605 TOP_X, TOP_Y and ending at BOTTOM_X and BOTTOM_Y. GC specifies the
2606 pixel and line characteristics. */
2608 #define line_len(line) (FRAME_CURRENT_GLYPHS (f)->used[(line)])
2611 outline_region (f
, gc
, top_x
, top_y
, bottom_x
, bottom_y
)
2612 register struct frame
*f
;
2614 int top_x
, top_y
, bottom_x
, bottom_y
;
2616 register int ibw
= f
->display
.x
->internal_border_width
;
2617 register int font_w
= FONT_WIDTH (f
->display
.x
->font
);
2618 register int font_h
= FONT_HEIGHT (f
->display
.x
->font
);
2620 int x
= line_len (y
);
2621 XPoint
*pixel_points
= (XPoint
*)
2622 alloca (((bottom_y
- top_y
+ 2) * 4) * sizeof (XPoint
));
2623 register XPoint
*this_point
= pixel_points
;
2625 /* Do the horizontal top line/lines */
2628 this_point
->x
= ibw
;
2629 this_point
->y
= ibw
+ (font_h
* top_y
);
2632 this_point
->x
= ibw
+ (font_w
/ 2); /* Half-size for newline chars. */
2634 this_point
->x
= ibw
+ (font_w
* x
);
2635 this_point
->y
= (this_point
- 1)->y
;
2639 this_point
->x
= ibw
;
2640 this_point
->y
= ibw
+ (font_h
* (top_y
+ 1));
2642 this_point
->x
= ibw
+ (font_w
* top_x
);
2643 this_point
->y
= (this_point
- 1)->y
;
2645 this_point
->x
= (this_point
- 1)->x
;
2646 this_point
->y
= ibw
+ (font_h
* top_y
);
2648 this_point
->x
= ibw
+ (font_w
* x
);
2649 this_point
->y
= (this_point
- 1)->y
;
2652 /* Now do the right side. */
2653 while (y
< bottom_y
)
2654 { /* Right vertical edge */
2656 this_point
->x
= (this_point
- 1)->x
;
2657 this_point
->y
= ibw
+ (font_h
* (y
+ 1));
2660 y
++; /* Horizontal connection to next line */
2663 this_point
->x
= ibw
+ (font_w
/ 2);
2665 this_point
->x
= ibw
+ (font_w
* x
);
2667 this_point
->y
= (this_point
- 1)->y
;
2670 /* Now do the bottom and connect to the top left point. */
2671 this_point
->x
= ibw
+ (font_w
* (bottom_x
+ 1));
2674 this_point
->x
= (this_point
- 1)->x
;
2675 this_point
->y
= ibw
+ (font_h
* (bottom_y
+ 1));
2677 this_point
->x
= ibw
;
2678 this_point
->y
= (this_point
- 1)->y
;
2680 this_point
->x
= pixel_points
->x
;
2681 this_point
->y
= pixel_points
->y
;
2683 XDrawLines (x_current_display
, FRAME_X_WINDOW (f
),
2685 (this_point
- pixel_points
+ 1), CoordModeOrigin
);
2688 DEFUN ("x-contour-region", Fx_contour_region
, Sx_contour_region
, 1, 1, 0,
2689 "Highlight the region between point and the character under the mouse\n\
2692 register Lisp_Object event
;
2694 register int x0
, y0
, x1
, y1
;
2695 register struct frame
*f
= selected_frame
;
2696 register int p1
, p2
;
2698 CHECK_CONS (event
, 0);
2701 x0
= XINT (Fcar (Fcar (event
)));
2702 y0
= XINT (Fcar (Fcdr (Fcar (event
))));
2704 /* If the mouse is past the end of the line, don't that area. */
2705 /* ReWrite this... */
2710 if (y1
> y0
) /* point below mouse */
2711 outline_region (f
, f
->display
.x
->cursor_gc
,
2713 else if (y1
< y0
) /* point above mouse */
2714 outline_region (f
, f
->display
.x
->cursor_gc
,
2716 else /* same line: draw horizontal rectangle */
2719 x_rectangle (f
, f
->display
.x
->cursor_gc
,
2720 x0
, y0
, (x1
- x0
+ 1), 1);
2722 x_rectangle (f
, f
->display
.x
->cursor_gc
,
2723 x1
, y1
, (x0
- x1
+ 1), 1);
2726 XFlush (x_current_display
);
2732 DEFUN ("x-uncontour-region", Fx_uncontour_region
, Sx_uncontour_region
, 1, 1, 0,
2733 "Erase any highlighting of the region between point and the character\n\
2734 at X, Y on the selected frame.")
2736 register Lisp_Object event
;
2738 register int x0
, y0
, x1
, y1
;
2739 register struct frame
*f
= selected_frame
;
2742 x0
= XINT (Fcar (Fcar (event
)));
2743 y0
= XINT (Fcar (Fcdr (Fcar (event
))));
2747 if (y1
> y0
) /* point below mouse */
2748 outline_region (f
, f
->display
.x
->reverse_gc
,
2750 else if (y1
< y0
) /* point above mouse */
2751 outline_region (f
, f
->display
.x
->reverse_gc
,
2753 else /* same line: draw horizontal rectangle */
2756 x_rectangle (f
, f
->display
.x
->reverse_gc
,
2757 x0
, y0
, (x1
- x0
+ 1), 1);
2759 x_rectangle (f
, f
->display
.x
->reverse_gc
,
2760 x1
, y1
, (x0
- x1
+ 1), 1);
2768 int contour_begin_x
, contour_begin_y
;
2769 int contour_end_x
, contour_end_y
;
2770 int contour_npoints
;
2772 /* Clip the top part of the contour lines down (and including) line Y_POS.
2773 If X_POS is in the middle (rather than at the end) of the line, drop
2774 down a line at that character. */
2777 clip_contour_top (y_pos
, x_pos
)
2779 register XPoint
*begin
= contour_lines
[y_pos
].top_left
;
2780 register XPoint
*end
;
2781 register int npoints
;
2782 register struct display_line
*line
= selected_frame
->phys_lines
[y_pos
+ 1];
2784 if (x_pos
>= line
->len
- 1) /* Draw one, straight horizontal line. */
2786 end
= contour_lines
[y_pos
].top_right
;
2787 npoints
= (end
- begin
+ 1);
2788 XDrawLines (x_current_display
, contour_window
,
2789 contour_erase_gc
, begin_erase
, npoints
, CoordModeOrigin
);
2791 bcopy (end
, begin
+ 1, contour_last_point
- end
+ 1);
2792 contour_last_point
-= (npoints
- 2);
2793 XDrawLines (x_current_display
, contour_window
,
2794 contour_erase_gc
, begin
, 2, CoordModeOrigin
);
2795 XFlush (x_current_display
);
2797 /* Now, update contour_lines structure. */
2802 register XPoint
*p
= begin
+ 1;
2803 end
= contour_lines
[y_pos
].bottom_right
;
2804 npoints
= (end
- begin
+ 1);
2805 XDrawLines (x_current_display
, contour_window
,
2806 contour_erase_gc
, begin_erase
, npoints
, CoordModeOrigin
);
2809 p
->x
= ibw
+ (font_w
* (x_pos
+ 1));
2811 p
->y
= begin
->y
+ font_h
;
2813 bcopy (end
, begin
+ 3, contour_last_point
- end
+ 1);
2814 contour_last_point
-= (npoints
- 5);
2815 XDrawLines (x_current_display
, contour_window
,
2816 contour_erase_gc
, begin
, 4, CoordModeOrigin
);
2817 XFlush (x_current_display
);
2819 /* Now, update contour_lines structure. */
2823 /* Erase the top horzontal lines of the contour, and then extend
2824 the contour upwards. */
2827 extend_contour_top (line
)
2832 clip_contour_bottom (x_pos
, y_pos
)
2838 extend_contour_bottom (x_pos
, y_pos
)
2842 DEFUN ("x-select-region", Fx_select_region
, Sx_select_region
, 1, 1, "e",
2847 register struct frame
*f
= selected_frame
;
2848 register int point_x
= f
->cursor_x
;
2849 register int point_y
= f
->cursor_y
;
2850 register int mouse_below_point
;
2851 register Lisp_Object obj
;
2852 register int x_contour_x
, x_contour_y
;
2854 x_contour_x
= x_mouse_x
;
2855 x_contour_y
= x_mouse_y
;
2856 if (x_contour_y
> point_y
|| (x_contour_y
== point_y
2857 && x_contour_x
> point_x
))
2859 mouse_below_point
= 1;
2860 outline_region (f
, f
->display
.x
->cursor_gc
, point_x
, point_y
,
2861 x_contour_x
, x_contour_y
);
2865 mouse_below_point
= 0;
2866 outline_region (f
, f
->display
.x
->cursor_gc
, x_contour_x
, x_contour_y
,
2872 obj
= read_char (-1, 0, 0, Qnil
, 0);
2873 if (XTYPE (obj
) != Lisp_Cons
)
2876 if (mouse_below_point
)
2878 if (x_mouse_y
<= point_y
) /* Flipped. */
2880 mouse_below_point
= 0;
2882 outline_region (f
, f
->display
.x
->reverse_gc
, point_x
, point_y
,
2883 x_contour_x
, x_contour_y
);
2884 outline_region (f
, f
->display
.x
->cursor_gc
, x_mouse_x
, x_mouse_y
,
2887 else if (x_mouse_y
< x_contour_y
) /* Bottom clipped. */
2889 clip_contour_bottom (x_mouse_y
);
2891 else if (x_mouse_y
> x_contour_y
) /* Bottom extended. */
2893 extend_bottom_contour (x_mouse_y
);
2896 x_contour_x
= x_mouse_x
;
2897 x_contour_y
= x_mouse_y
;
2899 else /* mouse above or same line as point */
2901 if (x_mouse_y
>= point_y
) /* Flipped. */
2903 mouse_below_point
= 1;
2905 outline_region (f
, f
->display
.x
->reverse_gc
,
2906 x_contour_x
, x_contour_y
, point_x
, point_y
);
2907 outline_region (f
, f
->display
.x
->cursor_gc
, point_x
, point_y
,
2908 x_mouse_x
, x_mouse_y
);
2910 else if (x_mouse_y
> x_contour_y
) /* Top clipped. */
2912 clip_contour_top (x_mouse_y
);
2914 else if (x_mouse_y
< x_contour_y
) /* Top extended. */
2916 extend_contour_top (x_mouse_y
);
2921 unread_command_event
= obj
;
2922 if (mouse_below_point
)
2924 contour_begin_x
= point_x
;
2925 contour_begin_y
= point_y
;
2926 contour_end_x
= x_contour_x
;
2927 contour_end_y
= x_contour_y
;
2931 contour_begin_x
= x_contour_x
;
2932 contour_begin_y
= x_contour_y
;
2933 contour_end_x
= point_x
;
2934 contour_end_y
= point_y
;
2939 DEFUN ("x-horizontal-line", Fx_horizontal_line
, Sx_horizontal_line
, 1, 1, "e",
2944 register Lisp_Object obj
;
2945 struct frame
*f
= selected_frame
;
2946 register struct window
*w
= XWINDOW (selected_window
);
2947 register GC line_gc
= f
->display
.x
->cursor_gc
;
2948 register GC erase_gc
= f
->display
.x
->reverse_gc
;
2950 char dash_list
[] = {6, 4, 6, 4};
2952 XGCValues gc_values
;
2954 register int previous_y
;
2955 register int line
= (x_mouse_y
+ 1) * FONT_HEIGHT (f
->display
.x
->font
)
2956 + f
->display
.x
->internal_border_width
;
2957 register int left
= f
->display
.x
->internal_border_width
2959 * FONT_WIDTH (f
->display
.x
->font
));
2960 register int right
= left
+ (w
->width
2961 * FONT_WIDTH (f
->display
.x
->font
))
2962 - f
->display
.x
->internal_border_width
;
2966 gc_values
.foreground
= f
->display
.x
->cursor_pixel
;
2967 gc_values
.background
= f
->display
.x
->background_pixel
;
2968 gc_values
.line_width
= 1;
2969 gc_values
.line_style
= LineOnOffDash
;
2970 gc_values
.cap_style
= CapRound
;
2971 gc_values
.join_style
= JoinRound
;
2973 line_gc
= XCreateGC (x_current_display
, FRAME_X_WINDOW (f
),
2974 GCLineStyle
| GCJoinStyle
| GCCapStyle
2975 | GCLineWidth
| GCForeground
| GCBackground
,
2977 XSetDashes (x_current_display
, line_gc
, 0, dash_list
, dashes
);
2978 gc_values
.foreground
= f
->display
.x
->background_pixel
;
2979 gc_values
.background
= f
->display
.x
->foreground_pixel
;
2980 erase_gc
= XCreateGC (x_current_display
, FRAME_X_WINDOW (f
),
2981 GCLineStyle
| GCJoinStyle
| GCCapStyle
2982 | GCLineWidth
| GCForeground
| GCBackground
,
2984 XSetDashes (x_current_display
, erase_gc
, 0, dash_list
, dashes
);
2990 if (x_mouse_y
>= XINT (w
->top
)
2991 && x_mouse_y
< XINT (w
->top
) + XINT (w
->height
) - 1)
2993 previous_y
= x_mouse_y
;
2994 line
= (x_mouse_y
+ 1) * FONT_HEIGHT (f
->display
.x
->font
)
2995 + f
->display
.x
->internal_border_width
;
2996 XDrawLine (x_current_display
, FRAME_X_WINDOW (f
),
2997 line_gc
, left
, line
, right
, line
);
3004 obj
= read_char (-1, 0, 0, Qnil
, 0);
3005 if ((XTYPE (obj
) != Lisp_Cons
)
3006 || (! EQ (Fcar (Fcdr (Fcdr (obj
))),
3007 Qvertical_scroll_bar
))
3011 XDrawLine (x_current_display
, FRAME_X_WINDOW (f
),
3012 erase_gc
, left
, line
, right
, line
);
3014 unread_command_event
= obj
;
3016 XFreeGC (x_current_display
, line_gc
);
3017 XFreeGC (x_current_display
, erase_gc
);
3022 while (x_mouse_y
== previous_y
);
3025 XDrawLine (x_current_display
, FRAME_X_WINDOW (f
),
3026 erase_gc
, left
, line
, right
, line
);
3032 /* Offset in buffer of character under the pointer, or 0. */
3033 int mouse_buffer_offset
;
3036 /* These keep track of the rectangle following the pointer. */
3037 int mouse_track_top
, mouse_track_left
, mouse_track_width
;
3039 DEFUN ("x-track-pointer", Fx_track_pointer
, Sx_track_pointer
, 0, 0, 0,
3040 "Track the pointer.")
3043 static Cursor current_pointer_shape
;
3044 FRAME_PTR f
= x_mouse_frame
;
3047 if (EQ (Vmouse_frame_part
, Qtext_part
)
3048 && (current_pointer_shape
!= f
->display
.x
->nontext_cursor
))
3053 current_pointer_shape
= f
->display
.x
->nontext_cursor
;
3054 XDefineCursor (x_current_display
,
3056 current_pointer_shape
);
3058 buf
= XBUFFER (XWINDOW (Vmouse_window
)->buffer
);
3059 c
= *(BUF_CHAR_ADDRESS (buf
, mouse_buffer_offset
));
3061 else if (EQ (Vmouse_frame_part
, Qmodeline_part
)
3062 && (current_pointer_shape
!= f
->display
.x
->modeline_cursor
))
3064 current_pointer_shape
= f
->display
.x
->modeline_cursor
;
3065 XDefineCursor (x_current_display
,
3067 current_pointer_shape
);
3076 DEFUN ("x-track-pointer", Fx_track_pointer
, Sx_track_pointer
, 1, 1, "e",
3077 "Draw rectangle around character under mouse pointer, if there is one.")
3081 struct window
*w
= XWINDOW (Vmouse_window
);
3082 struct frame
*f
= XFRAME (WINDOW_FRAME (w
));
3083 struct buffer
*b
= XBUFFER (w
->buffer
);
3086 if (! EQ (Vmouse_window
, selected_window
))
3089 if (EQ (event
, Qnil
))
3093 x_read_mouse_position (selected_frame
, &x
, &y
);
3097 mouse_track_width
= 0;
3098 mouse_track_left
= mouse_track_top
= -1;
3102 if ((x_mouse_x
!= mouse_track_left
3103 && (x_mouse_x
< mouse_track_left
3104 || x_mouse_x
> (mouse_track_left
+ mouse_track_width
)))
3105 || x_mouse_y
!= mouse_track_top
)
3107 int hp
= 0; /* Horizontal position */
3108 int len
= FRAME_CURRENT_GLYPHS (f
)->used
[x_mouse_y
];
3109 int p
= FRAME_CURRENT_GLYPHS (f
)->bufp
[x_mouse_y
];
3110 int tab_width
= XINT (b
->tab_width
);
3111 int ctl_arrow_p
= !NILP (b
->ctl_arrow
);
3113 int mode_line_vpos
= XFASTINT (w
->height
) + XFASTINT (w
->top
) - 1;
3114 int in_mode_line
= 0;
3116 if (! FRAME_CURRENT_GLYPHS (f
)->enable
[x_mouse_y
])
3119 /* Erase previous rectangle. */
3120 if (mouse_track_width
)
3122 x_rectangle (f
, f
->display
.x
->reverse_gc
,
3123 mouse_track_left
, mouse_track_top
,
3124 mouse_track_width
, 1);
3126 if ((mouse_track_left
== f
->phys_cursor_x
3127 || mouse_track_left
== f
->phys_cursor_x
- 1)
3128 && mouse_track_top
== f
->phys_cursor_y
)
3130 x_display_cursor (f
, 1);
3134 mouse_track_left
= x_mouse_x
;
3135 mouse_track_top
= x_mouse_y
;
3136 mouse_track_width
= 0;
3138 if (mouse_track_left
> len
) /* Past the end of line. */
3141 if (mouse_track_top
== mode_line_vpos
)
3147 if (tab_width
<= 0 || tab_width
> 20) tab_width
= 8;
3151 if (len
== f
->width
&& hp
== len
- 1 && c
!= '\n')
3157 mouse_track_width
= tab_width
- (hp
% tab_width
);
3159 hp
+= mouse_track_width
;
3162 mouse_track_left
= hp
- mouse_track_width
;
3168 mouse_track_width
= -1;
3172 if (ctl_arrow_p
&& (c
< 040 || c
== 0177))
3177 mouse_track_width
= 2;
3182 mouse_track_left
= hp
- mouse_track_width
;
3188 mouse_track_width
= 1;
3195 while (hp
<= x_mouse_x
);
3198 if (mouse_track_width
) /* Over text; use text pointer shape. */
3200 XDefineCursor (x_current_display
,
3202 f
->display
.x
->text_cursor
);
3203 x_rectangle (f
, f
->display
.x
->cursor_gc
,
3204 mouse_track_left
, mouse_track_top
,
3205 mouse_track_width
, 1);
3207 else if (in_mode_line
)
3208 XDefineCursor (x_current_display
,
3210 f
->display
.x
->modeline_cursor
);
3212 XDefineCursor (x_current_display
,
3214 f
->display
.x
->nontext_cursor
);
3217 XFlush (x_current_display
);
3220 obj
= read_char (-1, 0, 0, Qnil
, 0);
3223 while (XTYPE (obj
) == Lisp_Cons
/* Mouse event */
3224 && EQ (Fcar (Fcdr (Fcdr (obj
))), Qnil
) /* Not scroll bar */
3225 && EQ (Vmouse_depressed
, Qnil
) /* Only motion events */
3226 && EQ (Vmouse_window
, selected_window
) /* In this window */
3229 unread_command_event
= obj
;
3231 if (mouse_track_width
)
3233 x_rectangle (f
, f
->display
.x
->reverse_gc
,
3234 mouse_track_left
, mouse_track_top
,
3235 mouse_track_width
, 1);
3236 mouse_track_width
= 0;
3237 if ((mouse_track_left
== f
->phys_cursor_x
3238 || mouse_track_left
- 1 == f
->phys_cursor_x
)
3239 && mouse_track_top
== f
->phys_cursor_y
)
3241 x_display_cursor (f
, 1);
3244 XDefineCursor (x_current_display
,
3246 f
->display
.x
->nontext_cursor
);
3247 XFlush (x_current_display
);
3257 /* Draw a pixmap specified by IMAGE_DATA of dimensions WIDTH and HEIGHT
3258 on the frame F at position X, Y. */
3260 x_draw_pixmap (f
, x
, y
, image_data
, width
, height
)
3262 int x
, y
, width
, height
;
3267 image
= XCreateBitmapFromData (x_current_display
,
3268 FRAME_X_WINDOW (f
), image_data
,
3270 XCopyPlane (x_current_display
, image
, FRAME_X_WINDOW (f
),
3271 f
->display
.x
->normal_gc
, 0, 0, width
, height
, x
, y
);
3278 #define XMouseEvent XEvent
3279 #define WhichMouseButton xbutton.button
3280 #define MouseWindow xbutton.window
3281 #define MouseX xbutton.x
3282 #define MouseY xbutton.y
3283 #define MouseTime xbutton.time
3284 #define ButtonReleased ButtonRelease
3285 #define ButtonPressed ButtonPress
3287 #define XMouseEvent XButtonEvent
3288 #define WhichMouseButton detail
3289 #define MouseWindow window
3292 #define MouseTime time
3295 DEFUN ("x-mouse-events", Fx_mouse_events
, Sx_mouse_events
, 0, 0, 0,
3296 "Return number of pending mouse events from X window system.")
3299 return make_number (queue_event_count (&x_mouse_queue
));
3302 /* Encode the mouse button events in the form expected by the
3303 mouse code in Lisp. For X11, this means moving the masks around. */
3306 encode_mouse_button (mouse_event
)
3307 XMouseEvent mouse_event
;
3309 register int event_code
;
3310 register char key_mask
;
3312 event_code
= mouse_event
.detail
& 3;
3313 key_mask
= (mouse_event
.detail
>> 8) & 0xf0;
3314 event_code
|= key_mask
>> 1;
3315 if (mouse_event
.type
== ButtonReleased
) event_code
|= 0x04;
3319 DEFUN ("x-get-mouse-event", Fx_get_mouse_event
, Sx_get_mouse_event
,
3321 "Get next mouse event out of mouse event buffer.\n\
3322 Optional ARG non-nil means return nil immediately if no pending event;\n\
3323 otherwise, wait for an event. Returns a four-part list:\n\
3324 ((X-POS Y-POS) WINDOW FRAME-PART KEYSEQ TIMESTAMP).\n\
3325 Normally X-POS and Y-POS are the position of the click on the frame\n\
3326 (measured in characters and lines), and WINDOW is the window clicked in.\n\
3327 KEYSEQ is a string, the key sequence to be looked up in the mouse maps.\n\
3328 If FRAME-PART is non-nil, the event was on a scroll bar;\n\
3329 then Y-POS is really the total length of the scroll bar, while X-POS is\n\
3330 the relative position of the scroll bar's value within that total length,\n\
3331 and a third element OFFSET appears in that list: the height of the thumb-up\n\
3332 area at the top of the scroll bar.\n\
3333 FRAME-PART is one of the following symbols:\n\
3334 `vertical-scroll-bar', `vertical-thumbup', `vertical-thumbdown',\n\
3335 `horizontal-scroll-bar', `horizontal-thumbleft', `horizontal-thumbright'.\n\
3336 TIMESTAMP is the lower 23 bits of the X-server's timestamp for\n\
3342 register int com_letter
;
3343 register Lisp_Object tempx
;
3344 register Lisp_Object tempy
;
3345 Lisp_Object part
, pos
, timestamp
;
3354 tem
= dequeue_event (&xrep
, &x_mouse_queue
);
3362 case ButtonReleased
:
3364 com_letter
= encode_mouse_button (xrep
);
3365 mouse_timestamp
= xrep
.MouseTime
;
3367 if ((f
= x_window_to_frame (xrep
.MouseWindow
)) != 0)
3371 if (f
->display
.x
->icon_desc
== xrep
.MouseWindow
)
3373 x_make_frame_visible (f
);
3377 XSET (tempx
, Lisp_Int
,
3378 min (f
->width
-1, max (0, (xrep
.MouseX
- f
->display
.x
->internal_border_width
)/FONT_WIDTH (f
->display
.x
->font
))));
3379 XSET (tempy
, Lisp_Int
,
3380 min (f
->height
-1, max (0, (xrep
.MouseY
- f
->display
.x
->internal_border_width
)/FONT_HEIGHT (f
->display
.x
->font
))));
3381 XSET (timestamp
, Lisp_Int
, (xrep
.MouseTime
& 0x7fffff));
3382 XSET (frame
, Lisp_Frame
, f
);
3384 pos
= Fcons (tempx
, Fcons (tempy
, Qnil
));
3386 = Flocate_window_from_coordinates (frame
, pos
);
3390 Fcons (Vmouse_window
,
3392 Fcons (Fchar_to_string (make_number (com_letter
)),
3393 Fcons (timestamp
, Qnil
)))));
3394 return Vmouse_event
;
3396 else if ((f
= x_window_to_scroll_bar (xrep
.MouseWindow
, &part
, &prefix
)) != 0)
3402 keyseq
= concat2 (Fchar_to_string (make_number (prefix
)),
3403 Fchar_to_string (make_number (com_letter
)));
3405 pos
= xrep
.MouseY
- (f
->display
.x
->v_scroll_bar_width
- 2);
3406 XSET (tempx
, Lisp_Int
, pos
);
3407 len
= ((FONT_HEIGHT (f
->display
.x
->font
) * f
->height
)
3408 + f
->display
.x
->internal_border_width
3409 - (2 * (f
->display
.x
->v_scroll_bar_width
- 2)));
3410 XSET (tempy
, Lisp_Int
, len
);
3411 XSET (timestamp
, Lisp_Int
, (xrep
.MouseTime
& 0x7fffff));
3412 Vmouse_window
= f
->selected_window
;
3414 = Fcons (Fcons (tempx
, Fcons (tempy
,
3415 Fcons (make_number (f
->display
.x
->v_scroll_bar_width
- 2),
3417 Fcons (Vmouse_window
,
3418 Fcons (intern (part
),
3419 Fcons (keyseq
, Fcons (timestamp
,
3421 return Vmouse_event
;
3429 com_letter
= x11_encode_mouse_button (xrep
);
3430 if ((f
= x_window_to_frame (xrep
.MouseWindow
)) != 0)
3434 XSET (tempx
, Lisp_Int
,
3436 max (0, (xrep
.MouseX
- f
->display
.x
->internal_border_width
)
3437 / FONT_WIDTH (f
->display
.x
->font
))));
3438 XSET (tempy
, Lisp_Int
,
3440 max (0, (xrep
.MouseY
- f
->display
.x
->internal_border_width
)
3441 / FONT_HEIGHT (f
->display
.x
->font
))));
3443 XSET (frame
, Lisp_Frame
, f
);
3444 XSET (timestamp
, Lisp_Int
, (xrep
.MouseTime
& 0x7fffff));
3446 pos
= Fcons (tempx
, Fcons (tempy
, Qnil
));
3448 = Flocate_window_from_coordinates (frame
, pos
);
3452 Fcons (Vmouse_window
,
3454 Fcons (Fchar_to_string (make_number (com_letter
)),
3455 Fcons (timestamp
, Qnil
)))));
3456 return Vmouse_event
;
3460 #endif /* HAVE_X11 */
3463 if (f
= x_window_to_frame (xrep
.MouseWindow
))
3464 Vmouse_window
= f
->selected_window
;
3465 else if (f
= x_window_to_scroll_bar (xrep
.MouseWindow
, &part
, &prefix
))
3466 Vmouse_window
= f
->selected_window
;
3467 return Vmouse_event
= Qnil
;
3474 /* Wait till we get another mouse event. */
3475 wait_reading_process_input (0, 0, 2, 0);
3482 DEFUN ("x-store-cut-buffer", Fx_store_cut_buffer
, Sx_store_cut_buffer
,
3483 1, 1, "sStore text in cut buffer: ",
3484 "Store contents of STRING into the cut buffer of the X window system.")
3486 register Lisp_Object string
;
3490 CHECK_STRING (string
, 1);
3491 if (! FRAME_X_P (selected_frame
))
3492 error ("Selected frame does not understand X protocol.");
3495 XStoreBytes ((char *) XSTRING (string
)->data
, XSTRING (string
)->size
);
3501 DEFUN ("x-get-cut-buffer", Fx_get_cut_buffer
, Sx_get_cut_buffer
, 0, 0, 0,
3502 "Return contents of cut buffer of the X window system, as a string.")
3506 register Lisp_Object string
;
3511 d
= XFetchBytes (&len
);
3512 string
= make_string (d
, len
);
3520 DEFUN ("x-rebind-key", Fx_rebind_key
, Sx_rebind_key
, 3, 3, 0,
3521 "Rebind X keysym KEYSYM, with MODIFIERS, to generate NEWSTRING.\n\
3522 KEYSYM is a string which conforms to the X keysym definitions found\n\
3523 in X11/keysymdef.h, sans the initial XK_. MODIFIERS is nil or a\n\
3524 list of strings specifying modifier keys such as Control_L, which must\n\
3525 also be depressed for NEWSTRING to appear.")
3526 (x_keysym
, modifiers
, newstring
)
3527 register Lisp_Object x_keysym
;
3528 register Lisp_Object modifiers
;
3529 register Lisp_Object newstring
;
3532 register KeySym keysym
;
3533 KeySym modifier_list
[16];
3535 CHECK_STRING (x_keysym
, 1);
3536 CHECK_STRING (newstring
, 3);
3538 keysym
= XStringToKeysym ((char *) XSTRING (x_keysym
)->data
);
3539 if (keysym
== NoSymbol
)
3540 error ("Keysym does not exist");
3542 if (NILP (modifiers
))
3543 XRebindKeysym (x_current_display
, keysym
, modifier_list
, 0,
3544 XSTRING (newstring
)->data
, XSTRING (newstring
)->size
);
3547 register Lisp_Object rest
, mod
;
3550 for (rest
= modifiers
; !NILP (rest
); rest
= Fcdr (rest
))
3553 error ("Can't have more than 16 modifiers");
3556 CHECK_STRING (mod
, 3);
3557 modifier_list
[i
] = XStringToKeysym ((char *) XSTRING (mod
)->data
);
3558 if (modifier_list
[i
] == NoSymbol
3559 || !IsModifierKey (modifier_list
[i
]))
3560 error ("Element is not a modifier keysym");
3564 XRebindKeysym (x_current_display
, keysym
, modifier_list
, i
,
3565 XSTRING (newstring
)->data
, XSTRING (newstring
)->size
);
3571 DEFUN ("x-rebind-keys", Fx_rebind_keys
, Sx_rebind_keys
, 2, 2, 0,
3572 "Rebind KEYCODE to list of strings STRINGS.\n\
3573 STRINGS should be a list of 16 elements, one for each shift combination.\n\
3574 nil as element means don't change.\n\
3575 See the documentation of `x-rebind-key' for more information.")
3577 register Lisp_Object keycode
;
3578 register Lisp_Object strings
;
3580 register Lisp_Object item
;
3581 register unsigned char *rawstring
;
3582 KeySym rawkey
, modifier
[1];
3584 register unsigned i
;
3586 CHECK_NUMBER (keycode
, 1);
3587 CHECK_CONS (strings
, 2);
3588 rawkey
= (KeySym
) ((unsigned) (XINT (keycode
))) & 255;
3589 for (i
= 0; i
<= 15; strings
= Fcdr (strings
), i
++)
3591 item
= Fcar (strings
);
3594 CHECK_STRING (item
, 2);
3595 strsize
= XSTRING (item
)->size
;
3596 rawstring
= (unsigned char *) xmalloc (strsize
);
3597 bcopy (XSTRING (item
)->data
, rawstring
, strsize
);
3598 modifier
[1] = 1 << i
;
3599 XRebindKeysym (x_current_display
, rawkey
, modifier
, 1,
3600 rawstring
, strsize
);
3606 DEFUN ("x-rebind-key", Fx_rebind_key
, Sx_rebind_key
, 3, 3, 0,
3607 "Rebind KEYCODE, with shift bits SHIFT-MASK, to new string NEWSTRING.\n\
3608 KEYCODE and SHIFT-MASK should be numbers representing the X keyboard code\n\
3609 and shift mask respectively. NEWSTRING is an arbitrary string of keystrokes.\n\
3610 If SHIFT-MASK is nil, then KEYCODE's key will be bound to NEWSTRING for\n\
3611 all shift combinations.\n\
3612 Shift Lock 1 Shift 2\n\
3615 For values of KEYCODE, see /usr/lib/Xkeymap.txt (remember that the codes\n\
3616 in that file are in octal!)\n\
3618 NOTE: due to an X bug, this function will not take effect unless one has\n\
3619 a `~/.Xkeymap' file. (See the documentation for the `keycomp' program.)\n\
3620 This problem will be fixed in X version 11.")
3622 (keycode
, shift_mask
, newstring
)
3623 register Lisp_Object keycode
;
3624 register Lisp_Object shift_mask
;
3625 register Lisp_Object newstring
;
3628 int keysym
, rawshift
;
3631 CHECK_NUMBER (keycode
, 1);
3632 if (!NILP (shift_mask
))
3633 CHECK_NUMBER (shift_mask
, 2);
3634 CHECK_STRING (newstring
, 3);
3635 strsize
= XSTRING (newstring
)->size
;
3636 rawstring
= (char *) xmalloc (strsize
);
3637 bcopy (XSTRING (newstring
)->data
, rawstring
, strsize
);
3639 keysym
= ((unsigned) (XINT (keycode
))) & 255;
3641 if (NILP (shift_mask
))
3643 for (i
= 0; i
<= 15; i
++)
3644 XRebindCode (keysym
, i
<<11, rawstring
, strsize
);
3648 rawshift
= (((unsigned) (XINT (shift_mask
))) & 15) << 11;
3649 XRebindCode (keysym
, rawshift
, rawstring
, strsize
);
3654 DEFUN ("x-rebind-keys", Fx_rebind_keys
, Sx_rebind_keys
, 2, 2, 0,
3655 "Rebind KEYCODE to list of strings STRINGS.\n\
3656 STRINGS should be a list of 16 elements, one for each shift combination.\n\
3657 nil as element means don't change.\n\
3658 See the documentation of `x-rebind-key' for more information.")
3660 register Lisp_Object keycode
;
3661 register Lisp_Object strings
;
3663 register Lisp_Object item
;
3664 register char *rawstring
;
3665 KeySym rawkey
, modifier
[1];
3667 register unsigned i
;
3669 CHECK_NUMBER (keycode
, 1);
3670 CHECK_CONS (strings
, 2);
3671 rawkey
= (KeySym
) ((unsigned) (XINT (keycode
))) & 255;
3672 for (i
= 0; i
<= 15; strings
= Fcdr (strings
), i
++)
3674 item
= Fcar (strings
);
3677 CHECK_STRING (item
, 2);
3678 strsize
= XSTRING (item
)->size
;
3679 rawstring
= (char *) xmalloc (strsize
);
3680 bcopy (XSTRING (item
)->data
, rawstring
, strsize
);
3681 XRebindCode (rawkey
, i
<< 11, rawstring
, strsize
);
3686 #endif /* not HAVE_X11 */
3690 select_visual (screen
, depth
)
3692 unsigned int *depth
;
3695 XVisualInfo
*vinfo
, vinfo_template
;
3698 v
= DefaultVisualOfScreen (screen
);
3701 vinfo_template
.visualid
= XVisualIDFromVisual (v
);
3703 vinfo_template
.visualid
= x
->visualid
;
3706 vinfo
= XGetVisualInfo (x_current_display
, VisualIDMask
, &vinfo_template
,
3709 fatal ("Can't get proper X visual info");
3711 if ((1 << vinfo
->depth
) == vinfo
->colormap_size
)
3712 *depth
= vinfo
->depth
;
3716 int n
= vinfo
->colormap_size
- 1;
3725 XFree ((char *) vinfo
);
3728 #endif /* HAVE_X11 */
3730 DEFUN ("x-open-connection", Fx_open_connection
, Sx_open_connection
,
3731 1, 2, 0, "Open a connection to an X server.\n\
3732 DISPLAY is the name of the display to connect to. Optional second\n\
3733 arg XRM_STRING is a string of resources in xrdb format.")
3734 (display
, xrm_string
)
3735 Lisp_Object display
, xrm_string
;
3737 unsigned int n_planes
;
3738 unsigned char *xrm_option
;
3740 CHECK_STRING (display
, 0);
3741 if (x_current_display
!= 0)
3742 error ("X server connection is already initialized");
3744 /* This is what opens the connection and sets x_current_display.
3745 This also initializes many symbols, such as those used for input. */
3746 x_term_init (XSTRING (display
)->data
);
3749 XFASTINT (Vwindow_system_version
) = 11;
3751 if (!EQ (xrm_string
, Qnil
))
3753 CHECK_STRING (xrm_string
, 1);
3754 xrm_option
= (unsigned char *) XSTRING (xrm_string
);
3757 xrm_option
= (unsigned char *) 0;
3758 xrdb
= x_load_resources (x_current_display
, xrm_option
, EMACS_CLASS
);
3759 x_current_display
->db
= xrdb
;
3761 x_screen
= DefaultScreenOfDisplay (x_current_display
);
3763 screen_visual
= select_visual (x_screen
, &n_planes
);
3764 x_screen_planes
= n_planes
;
3765 x_screen_height
= HeightOfScreen (x_screen
);
3766 x_screen_width
= WidthOfScreen (x_screen
);
3768 /* X Atoms used by emacs. */
3769 Xatoms_of_xselect ();
3771 Xatom_wm_protocols
= XInternAtom (x_current_display
, "WM_PROTOCOLS",
3773 Xatom_wm_take_focus
= XInternAtom (x_current_display
, "WM_TAKE_FOCUS",
3775 Xatom_wm_save_yourself
= XInternAtom (x_current_display
, "WM_SAVE_YOURSELF",
3777 Xatom_wm_delete_window
= XInternAtom (x_current_display
, "WM_DELETE_WINDOW",
3779 Xatom_wm_change_state
= XInternAtom (x_current_display
, "WM_CHANGE_STATE",
3781 Xatom_wm_configure_denied
= XInternAtom (x_current_display
,
3782 "WM_CONFIGURE_DENIED", False
);
3783 Xatom_wm_window_moved
= XInternAtom (x_current_display
, "WM_MOVED",
3786 #else /* not HAVE_X11 */
3787 XFASTINT (Vwindow_system_version
) = 10;
3788 #endif /* not HAVE_X11 */
3792 DEFUN ("x-close-current-connection", Fx_close_current_connection
,
3793 Sx_close_current_connection
,
3794 0, 0, 0, "Close the connection to the current X server.")
3798 /* This is ONLY used when killing emacs; For switching displays
3799 we'll have to take care of setting CloseDownMode elsewhere. */
3801 if (x_current_display
)
3804 XSetCloseDownMode (x_current_display
, DestroyAll
);
3805 XCloseDisplay (x_current_display
);
3808 fatal ("No current X display connection to close\n");
3813 DEFUN ("x-synchronize", Fx_synchronize
, Sx_synchronize
,
3814 1, 1, 0, "If ON is non-nil, report X errors as soon as the erring request is made.\n\
3815 If ON is nil, allow buffering of requests.\n\
3816 Turning on synchronization prohibits the Xlib routines from buffering\n\
3817 requests and seriously degrades performance, but makes debugging much\n\
3822 XSynchronize (x_current_display
, !EQ (on
, Qnil
));
3830 /* This is zero if not using X windows. */
3831 x_current_display
= 0;
3833 /* The section below is built by the lisp expression at the top of the file,
3834 just above where these variables are declared. */
3835 /*&&& init symbols here &&&*/
3836 Qauto_raise
= intern ("auto-raise");
3837 staticpro (&Qauto_raise
);
3838 Qauto_lower
= intern ("auto-lower");
3839 staticpro (&Qauto_lower
);
3840 Qbackground_color
= intern ("background-color");
3841 staticpro (&Qbackground_color
);
3842 Qbar
= intern ("bar");
3844 Qborder_color
= intern ("border-color");
3845 staticpro (&Qborder_color
);
3846 Qborder_width
= intern ("border-width");
3847 staticpro (&Qborder_width
);
3848 Qbox
= intern ("box");
3850 Qcursor_color
= intern ("cursor-color");
3851 staticpro (&Qcursor_color
);
3852 Qcursor_type
= intern ("cursor-type");
3853 staticpro (&Qcursor_type
);
3854 Qfont
= intern ("font");
3856 Qforeground_color
= intern ("foreground-color");
3857 staticpro (&Qforeground_color
);
3858 Qgeometry
= intern ("geometry");
3859 staticpro (&Qgeometry
);
3860 Qicon_left
= intern ("icon-left");
3861 staticpro (&Qicon_left
);
3862 Qicon_top
= intern ("icon-top");
3863 staticpro (&Qicon_top
);
3864 Qicon_type
= intern ("icon-type");
3865 staticpro (&Qicon_type
);
3866 Qiconic_startup
= intern ("iconic-startup");
3867 staticpro (&Qiconic_startup
);
3868 Qinternal_border_width
= intern ("internal-border-width");
3869 staticpro (&Qinternal_border_width
);
3870 Qleft
= intern ("left");
3872 Qmouse_color
= intern ("mouse-color");
3873 staticpro (&Qmouse_color
);
3874 Qnone
= intern ("none");
3876 Qparent_id
= intern ("parent-id");
3877 staticpro (&Qparent_id
);
3878 Qsuppress_icon
= intern ("suppress-icon");
3879 staticpro (&Qsuppress_icon
);
3880 Qsuppress_initial_map
= intern ("suppress-initial-map");
3881 staticpro (&Qsuppress_initial_map
);
3882 Qtop
= intern ("top");
3884 Qundefined_color
= intern ("undefined-color");
3885 staticpro (&Qundefined_color
);
3886 Qvertical_scroll_bars
= intern ("vertical-scroll-bars");
3887 staticpro (&Qvertical_scroll_bars
);
3888 Qwindow_id
= intern ("window-id");
3889 staticpro (&Qwindow_id
);
3890 Qx_frame_parameter
= intern ("x-frame-parameter");
3891 staticpro (&Qx_frame_parameter
);
3892 /* This is the end of symbol initialization. */
3893 Qvisibility
= intern ("visibility");
3894 staticpro (&Qvisibility
);
3896 Fput (Qundefined_color
, Qerror_conditions
,
3897 Fcons (Qundefined_color
, Fcons (Qerror
, Qnil
)));
3898 Fput (Qundefined_color
, Qerror_message
,
3899 build_string ("Undefined color"));
3901 init_x_parm_symbols ();
3903 DEFVAR_INT ("mouse-buffer-offset", &mouse_buffer_offset
,
3904 "The buffer offset of the character under the pointer.");
3905 mouse_buffer_offset
= 0;
3907 DEFVAR_INT ("x-pointer-shape", &Vx_pointer_shape
,
3908 "The shape of the pointer when over text.");
3909 Vx_pointer_shape
= Qnil
;
3911 DEFVAR_INT ("x-nontext-pointer-shape", &Vx_nontext_pointer_shape
,
3912 "The shape of the pointer when not over text.");
3913 Vx_nontext_pointer_shape
= Qnil
;
3915 DEFVAR_INT ("x-mode-pointer-shape", &Vx_mode_pointer_shape
,
3916 "The shape of the pointer when over the mode line.");
3917 Vx_mode_pointer_shape
= Qnil
;
3919 DEFVAR_LISP ("x-cursor-fore-pixel", &Vx_cursor_fore_pixel
,
3920 "A string indicating the foreground color of the cursor box.");
3921 Vx_cursor_fore_pixel
= Qnil
;
3923 DEFVAR_LISP ("mouse-grabbed", &Vmouse_depressed
,
3924 "Non-nil if a mouse button is currently depressed.");
3925 Vmouse_depressed
= Qnil
;
3927 DEFVAR_LISP ("x-no-window-manager", &Vx_no_window_manager
,
3928 "t if no X window manager is in use.");
3931 defsubr (&Sx_get_resource
);
3933 defsubr (&Sx_draw_rectangle
);
3934 defsubr (&Sx_erase_rectangle
);
3935 defsubr (&Sx_contour_region
);
3936 defsubr (&Sx_uncontour_region
);
3938 defsubr (&Sx_display_color_p
);
3939 defsubr (&Sx_defined_color
);
3940 defsubr (&Sx_server_vendor
);
3941 defsubr (&Sx_server_version
);
3942 defsubr (&Sx_display_pixel_width
);
3943 defsubr (&Sx_display_pixel_height
);
3944 defsubr (&Sx_display_mm_width
);
3945 defsubr (&Sx_display_mm_height
);
3946 defsubr (&Sx_display_screens
);
3947 defsubr (&Sx_display_planes
);
3948 defsubr (&Sx_display_color_cells
);
3949 defsubr (&Sx_display_visual_class
);
3950 defsubr (&Sx_display_backing_store
);
3951 defsubr (&Sx_display_save_under
);
3953 defsubr (&Sx_track_pointer
);
3954 defsubr (&Sx_grab_pointer
);
3955 defsubr (&Sx_ungrab_pointer
);
3958 defsubr (&Sx_get_default
);
3959 defsubr (&Sx_store_cut_buffer
);
3960 defsubr (&Sx_get_cut_buffer
);
3961 defsubr (&Sx_set_face
);
3963 defsubr (&Sx_geometry
);
3964 defsubr (&Sx_create_frame
);
3965 defsubr (&Sfocus_frame
);
3966 defsubr (&Sunfocus_frame
);
3968 defsubr (&Sx_horizontal_line
);
3970 defsubr (&Sx_rebind_key
);
3971 defsubr (&Sx_rebind_keys
);
3972 defsubr (&Sx_open_connection
);
3973 defsubr (&Sx_close_current_connection
);
3974 defsubr (&Sx_synchronize
);
3976 /* This was used in the old event interface which used a separate
3979 defsubr (&Sx_mouse_events
);
3980 defsubr (&Sx_get_mouse_event
);
3984 #endif /* HAVE_X_WINDOWS */