1 /* Functions for the X window system.
2 Copyright (C) 1989, 92, 93, 94, 95, 96, 97, 98, 99, 2000,01,02,03,04
3 Free Software Foundation.
5 This file is part of GNU Emacs.
7 GNU Emacs is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GNU Emacs is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU Emacs; see the file COPYING. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
31 /* This makes the fields of a Display accessible, in Xlib header files. */
33 #define XLIB_ILLEGAL_ACCESS
40 #include "intervals.h"
41 #include "dispextern.h"
43 #include "blockinput.h"
49 #include "termhooks.h"
56 #include <sys/types.h>
60 #if 1 /* Used to be #ifdef EMACS_BITMAP_FILES, but this should always work. */
61 #include "bitmaps/gray.xbm"
63 #include <X11/bitmaps/gray>
66 #include "[.bitmaps]gray.xbm"
74 #include <X11/Shell.h>
77 #include <X11/Xaw/Paned.h>
78 #include <X11/Xaw/Label.h>
79 #endif /* USE_MOTIF */
82 #undef USG /* ####KLUDGE for Solaris 2.2 and up */
91 #include "../lwlib/lwlib.h"
95 #include <Xm/DialogS.h>
96 #include <Xm/FileSB.h>
99 /* Do the EDITRES protocol if running X11R5
100 Exception: HP-UX (at least version A.09.05) has X11R5 without EditRes */
102 #if (XtSpecificationRelease >= 5) && !defined(NO_EDITRES)
104 extern void _XEditResCheckMessages ();
105 #endif /* R5 + Athena */
107 /* Unique id counter for widgets created by the Lucid Widget Library. */
109 extern LWLIB_ID widget_id_tick
;
112 /* This is part of a kludge--see lwlib/xlwmenu.c. */
113 extern XFontStruct
*xlwmenu_default_font
;
116 extern void free_frame_menubar ();
117 extern double atof ();
121 /* LessTif/Motif version info. */
123 static Lisp_Object Vmotif_version_string
;
125 #endif /* USE_MOTIF */
127 #endif /* USE_X_TOOLKIT */
131 /* GTK+ version info */
133 static Lisp_Object Vgtk_version_string
;
138 #define MAXREQUEST(dpy) (XMaxRequestSize (dpy))
140 #define MAXREQUEST(dpy) ((dpy)->max_request_size)
143 /* The gray bitmap `bitmaps/gray'. This is done because xterm.c uses
144 it, and including `bitmaps/gray' more than once is a problem when
145 config.h defines `static' as an empty replacement string. */
147 int gray_bitmap_width
= gray_width
;
148 int gray_bitmap_height
= gray_height
;
149 char *gray_bitmap_bits
= gray_bits
;
151 /* Non-zero means we're allowed to display an hourglass cursor. */
153 int display_hourglass_p
;
155 /* The background and shape of the mouse pointer, and shape when not
156 over text or in the modeline. */
158 Lisp_Object Vx_pointer_shape
, Vx_nontext_pointer_shape
, Vx_mode_pointer_shape
;
159 Lisp_Object Vx_hourglass_pointer_shape
;
161 /* The shape when over mouse-sensitive text. */
163 Lisp_Object Vx_sensitive_text_pointer_shape
;
165 /* If non-nil, the pointer shape to indicate that windows can be
166 dragged horizontally. */
168 Lisp_Object Vx_window_horizontal_drag_shape
;
170 /* Color of chars displayed in cursor box. */
172 Lisp_Object Vx_cursor_fore_pixel
;
174 /* Nonzero if using X. */
178 /* Non nil if no window manager is in use. */
180 Lisp_Object Vx_no_window_manager
;
182 /* Regexp matching a font name whose width is the same as `PIXEL_SIZE'. */
184 Lisp_Object Vx_pixel_size_width_font_regexp
;
187 Lisp_Object Qsuppress_icon
;
188 Lisp_Object Qundefined_color
;
189 Lisp_Object Qcompound_text
, Qcancel_timer
;
193 extern Lisp_Object Vwindow_system_version
;
195 /* The below are defined in frame.c. */
198 int image_cache_refcount
, dpyinfo_refcount
;
203 /* Error if we are not connected to X. */
209 error ("X windows are not in use or not initialized");
212 /* Nonzero if we can use mouse menus.
213 You should not call this unless HAVE_MENUS is defined. */
221 /* Extract a frame as a FRAME_PTR, defaulting to the selected frame
222 and checking validity for X. */
225 check_x_frame (frame
)
231 frame
= selected_frame
;
232 CHECK_LIVE_FRAME (frame
);
235 error ("Non-X frame used");
239 /* Let the user specify an X display with a frame.
240 nil stands for the selected frame--or, if that is not an X frame,
241 the first X display on the list. */
243 struct x_display_info
*
244 check_x_display_info (frame
)
247 struct x_display_info
*dpyinfo
= NULL
;
251 struct frame
*sf
= XFRAME (selected_frame
);
253 if (FRAME_X_P (sf
) && FRAME_LIVE_P (sf
))
254 dpyinfo
= FRAME_X_DISPLAY_INFO (sf
);
255 else if (x_display_list
!= 0)
256 dpyinfo
= x_display_list
;
258 error ("X windows are not in use or not initialized");
260 else if (STRINGP (frame
))
261 dpyinfo
= x_display_info_for_name (frame
);
264 FRAME_PTR f
= check_x_frame (frame
);
265 dpyinfo
= FRAME_X_DISPLAY_INFO (f
);
272 /* Return the Emacs frame-object corresponding to an X window.
273 It could be the frame's main window or an icon window. */
275 /* This function can be called during GC, so use GC_xxx type test macros. */
278 x_window_to_frame (dpyinfo
, wdesc
)
279 struct x_display_info
*dpyinfo
;
282 Lisp_Object tail
, frame
;
285 for (tail
= Vframe_list
; GC_CONSP (tail
); tail
= XCDR (tail
))
288 if (!GC_FRAMEP (frame
))
291 if (!FRAME_X_P (f
) || FRAME_X_DISPLAY_INFO (f
) != dpyinfo
)
293 if (f
->output_data
.x
->hourglass_window
== wdesc
)
296 if ((f
->output_data
.x
->edit_widget
297 && XtWindow (f
->output_data
.x
->edit_widget
) == wdesc
)
298 /* A tooltip frame? */
299 || (!f
->output_data
.x
->edit_widget
300 && FRAME_X_WINDOW (f
) == wdesc
)
301 || f
->output_data
.x
->icon_desc
== wdesc
)
303 #else /* not USE_X_TOOLKIT */
305 if (f
->output_data
.x
->edit_widget
)
307 GtkWidget
*gwdesc
= xg_win_to_widget (dpyinfo
->display
, wdesc
);
308 struct x_output
*x
= f
->output_data
.x
;
309 if (gwdesc
!= 0 && gwdesc
== x
->edit_widget
)
313 if (FRAME_X_WINDOW (f
) == wdesc
314 || f
->output_data
.x
->icon_desc
== wdesc
)
316 #endif /* not USE_X_TOOLKIT */
321 #if defined (USE_X_TOOLKIT) || defined (USE_GTK)
322 /* Like x_window_to_frame but also compares the window with the widget's
326 x_any_window_to_frame (dpyinfo
, wdesc
)
327 struct x_display_info
*dpyinfo
;
330 Lisp_Object tail
, frame
;
331 struct frame
*f
, *found
;
335 for (tail
= Vframe_list
; GC_CONSP (tail
) && !found
; tail
= XCDR (tail
))
338 if (!GC_FRAMEP (frame
))
342 if (FRAME_X_P (f
) && FRAME_X_DISPLAY_INFO (f
) == dpyinfo
)
344 /* This frame matches if the window is any of its widgets. */
345 x
= f
->output_data
.x
;
346 if (x
->hourglass_window
== wdesc
)
351 GtkWidget
*gwdesc
= xg_win_to_widget (dpyinfo
->display
, wdesc
);
353 && (gwdesc
== x
->widget
354 || gwdesc
== x
->edit_widget
355 || gwdesc
== x
->vbox_widget
356 || gwdesc
== x
->menubar_widget
))
359 if (wdesc
== XtWindow (x
->widget
)
360 || wdesc
== XtWindow (x
->column_widget
)
361 || wdesc
== XtWindow (x
->edit_widget
))
363 /* Match if the window is this frame's menubar. */
364 else if (lw_window_is_in_menubar (wdesc
, x
->menubar_widget
))
368 else if (FRAME_X_WINDOW (f
) == wdesc
)
369 /* A tooltip frame. */
377 /* Likewise, but exclude the menu bar widget. */
380 x_non_menubar_window_to_frame (dpyinfo
, wdesc
)
381 struct x_display_info
*dpyinfo
;
384 Lisp_Object tail
, frame
;
388 for (tail
= Vframe_list
; GC_CONSP (tail
); tail
= XCDR (tail
))
391 if (!GC_FRAMEP (frame
))
394 if (!FRAME_X_P (f
) || FRAME_X_DISPLAY_INFO (f
) != dpyinfo
)
396 x
= f
->output_data
.x
;
397 /* This frame matches if the window is any of its widgets. */
398 if (x
->hourglass_window
== wdesc
)
403 GtkWidget
*gwdesc
= xg_win_to_widget (dpyinfo
->display
, wdesc
);
405 && (gwdesc
== x
->widget
406 || gwdesc
== x
->edit_widget
407 || gwdesc
== x
->vbox_widget
))
410 if (wdesc
== XtWindow (x
->widget
)
411 || wdesc
== XtWindow (x
->column_widget
)
412 || wdesc
== XtWindow (x
->edit_widget
))
416 else if (FRAME_X_WINDOW (f
) == wdesc
)
417 /* A tooltip frame. */
423 /* Likewise, but consider only the menu bar widget. */
426 x_menubar_window_to_frame (dpyinfo
, wdesc
)
427 struct x_display_info
*dpyinfo
;
430 Lisp_Object tail
, frame
;
434 for (tail
= Vframe_list
; GC_CONSP (tail
); tail
= XCDR (tail
))
437 if (!GC_FRAMEP (frame
))
440 if (!FRAME_X_P (f
) || FRAME_X_DISPLAY_INFO (f
) != dpyinfo
)
442 x
= f
->output_data
.x
;
443 /* Match if the window is this frame's menubar. */
445 if (x
->menubar_widget
)
447 GtkWidget
*gwdesc
= xg_win_to_widget (dpyinfo
->display
, wdesc
);
452 && (gwdesc
== x
->menubar_widget
453 || gtk_widget_get_parent (gwdesc
) == x
->menubar_widget
))
459 if (x
->menubar_widget
460 && lw_window_is_in_menubar (wdesc
, x
->menubar_widget
))
467 /* Return the frame whose principal (outermost) window is WDESC.
468 If WDESC is some other (smaller) window, we return 0. */
471 x_top_window_to_frame (dpyinfo
, wdesc
)
472 struct x_display_info
*dpyinfo
;
475 Lisp_Object tail
, frame
;
479 for (tail
= Vframe_list
; GC_CONSP (tail
); tail
= XCDR (tail
))
482 if (!GC_FRAMEP (frame
))
485 if (!FRAME_X_P (f
) || FRAME_X_DISPLAY_INFO (f
) != dpyinfo
)
487 x
= f
->output_data
.x
;
491 /* This frame matches if the window is its topmost widget. */
493 GtkWidget
*gwdesc
= xg_win_to_widget (dpyinfo
->display
, wdesc
);
494 if (gwdesc
== x
->widget
)
497 if (wdesc
== XtWindow (x
->widget
))
499 #if 0 /* I don't know why it did this,
500 but it seems logically wrong,
501 and it causes trouble for MapNotify events. */
502 /* Match if the window is this frame's menubar. */
503 if (x
->menubar_widget
504 && wdesc
== XtWindow (x
->menubar_widget
))
509 else if (FRAME_X_WINDOW (f
) == wdesc
)
515 #endif /* USE_X_TOOLKIT || USE_GTK */
519 static Lisp_Object unwind_create_frame
P_ ((Lisp_Object
));
520 static Lisp_Object unwind_create_tip_frame
P_ ((Lisp_Object
));
522 void x_set_foreground_color
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
523 static void x_set_wait_for_wm
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
524 void x_set_background_color
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
525 void x_set_mouse_color
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
526 void x_set_cursor_color
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
527 void x_set_border_color
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
528 void x_set_cursor_type
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
529 void x_set_icon_type
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
530 void x_set_icon_name
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
531 void x_explicitly_set_name
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
532 void x_set_menu_bar_lines
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
533 void x_set_title
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
534 void x_set_tool_bar_lines
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
535 void x_set_scroll_bar_foreground
P_ ((struct frame
*, Lisp_Object
,
537 void x_set_scroll_bar_background
P_ ((struct frame
*, Lisp_Object
,
539 static Lisp_Object x_default_scroll_bar_color_parameter
P_ ((struct frame
*,
546 /* Store the screen positions of frame F into XPTR and YPTR.
547 These are the positions of the containing window manager window,
548 not Emacs's own window. */
551 x_real_positions (f
, xptr
, yptr
)
555 int win_x
, win_y
, outer_x
, outer_y
;
556 int real_x
= 0, real_y
= 0;
558 Window win
= f
->output_data
.x
->parent_desc
;
564 count
= x_catch_errors (FRAME_X_DISPLAY (f
));
566 if (win
== FRAME_X_DISPLAY_INFO (f
)->root_window
)
567 win
= FRAME_OUTER_WINDOW (f
);
569 /* This loop traverses up the containment tree until we hit the root
570 window. Window managers may intersect many windows between our window
571 and the root window. The window we find just before the root window
572 should be the outer WM window. */
575 Window wm_window
, rootw
;
576 Window
*tmp_children
;
577 unsigned int tmp_nchildren
;
580 success
= XQueryTree (FRAME_X_DISPLAY (f
), win
, &rootw
,
581 &wm_window
, &tmp_children
, &tmp_nchildren
);
583 had_errors
= x_had_errors_p (FRAME_X_DISPLAY (f
));
585 /* Don't free tmp_children if XQueryTree failed. */
589 XFree ((char *) tmp_children
);
591 if (wm_window
== rootw
|| had_errors
)
602 /* Get the real coordinates for the WM window upper left corner */
603 XGetGeometry (FRAME_X_DISPLAY (f
), win
,
604 &rootw
, &real_x
, &real_y
, &ign
, &ign
, &ign
, &ign
);
606 /* Translate real coordinates to coordinates relative to our
607 window. For our window, the upper left corner is 0, 0.
608 Since the upper left corner of the WM window is outside
609 our window, win_x and win_y will be negative:
611 ------------------ ---> x
613 | ----------------- v y
616 XTranslateCoordinates (FRAME_X_DISPLAY (f
),
618 /* From-window, to-window. */
619 FRAME_X_DISPLAY_INFO (f
)->root_window
,
622 /* From-position, to-position. */
623 real_x
, real_y
, &win_x
, &win_y
,
628 if (FRAME_X_WINDOW (f
) == FRAME_OUTER_WINDOW (f
))
635 XTranslateCoordinates (FRAME_X_DISPLAY (f
),
637 /* From-window, to-window. */
638 FRAME_X_DISPLAY_INFO (f
)->root_window
,
639 FRAME_OUTER_WINDOW (f
),
641 /* From-position, to-position. */
642 real_x
, real_y
, &outer_x
, &outer_y
,
648 had_errors
= x_had_errors_p (FRAME_X_DISPLAY (f
));
651 x_uncatch_errors (FRAME_X_DISPLAY (f
), count
);
655 if (had_errors
) return;
657 f
->x_pixels_diff
= -win_x
;
658 f
->y_pixels_diff
= -win_y
;
660 FRAME_X_OUTPUT (f
)->x_pixels_outer_diff
= -outer_x
;
661 FRAME_X_OUTPUT (f
)->y_pixels_outer_diff
= -outer_y
;
670 /* Gamma-correct COLOR on frame F. */
673 gamma_correct (f
, color
)
679 color
->red
= pow (color
->red
/ 65535.0, f
->gamma
) * 65535.0 + 0.5;
680 color
->green
= pow (color
->green
/ 65535.0, f
->gamma
) * 65535.0 + 0.5;
681 color
->blue
= pow (color
->blue
/ 65535.0, f
->gamma
) * 65535.0 + 0.5;
686 /* Decide if color named COLOR_NAME is valid for use on frame F. If
687 so, return the RGB values in COLOR. If ALLOC_P is non-zero,
688 allocate the color. Value is zero if COLOR_NAME is invalid, or
689 no color could be allocated. */
692 x_defined_color (f
, color_name
, color
, alloc_p
)
699 Display
*dpy
= FRAME_X_DISPLAY (f
);
700 Colormap cmap
= FRAME_X_COLORMAP (f
);
703 success_p
= XParseColor (dpy
, cmap
, color_name
, color
);
704 if (success_p
&& alloc_p
)
705 success_p
= x_alloc_nearest_color (f
, cmap
, color
);
712 /* Return the pixel color value for color COLOR_NAME on frame F. If F
713 is a monochrome frame, return MONO_COLOR regardless of what ARG says.
714 Signal an error if color can't be allocated. */
717 x_decode_color (f
, color_name
, mono_color
)
719 Lisp_Object color_name
;
724 CHECK_STRING (color_name
);
726 #if 0 /* Don't do this. It's wrong when we're not using the default
727 colormap, it makes freeing difficult, and it's probably not
728 an important optimization. */
729 if (strcmp (SDATA (color_name
), "black") == 0)
730 return BLACK_PIX_DEFAULT (f
);
731 else if (strcmp (SDATA (color_name
), "white") == 0)
732 return WHITE_PIX_DEFAULT (f
);
735 /* Return MONO_COLOR for monochrome frames. */
736 if (FRAME_X_DISPLAY_INFO (f
)->n_planes
== 1)
739 /* x_defined_color is responsible for coping with failures
740 by looking for a near-miss. */
741 if (x_defined_color (f
, SDATA (color_name
), &cdef
, 1))
744 Fsignal (Qerror
, Fcons (build_string ("Undefined color"),
745 Fcons (color_name
, Qnil
)));
751 /* Change the `wait-for-wm' frame parameter of frame F. OLD_VALUE is
752 the previous value of that parameter, NEW_VALUE is the new value.
753 See also the comment of wait_for_wm in struct x_output. */
756 x_set_wait_for_wm (f
, new_value
, old_value
)
758 Lisp_Object new_value
, old_value
;
760 f
->output_data
.x
->wait_for_wm
= !NILP (new_value
);
765 /* Set icon from FILE for frame F. By using GTK functions the icon
766 may be any format that GdkPixbuf knows about, i.e. not just bitmaps. */
769 xg_set_icon (f
, file
)
779 found
= x_find_image_file (file
);
787 filename
= SDATA (found
);
790 pixbuf
= gdk_pixbuf_new_from_file (filename
, &err
);
794 gtk_window_set_icon (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f
)),
796 g_object_unref (pixbuf
);
812 /* Functions called only from `x_set_frame_param'
813 to set individual parameters.
815 If FRAME_X_WINDOW (f) is 0,
816 the frame is being created and its X-window does not exist yet.
817 In that case, just record the parameter's new value
818 in the standard place; do not attempt to change the window. */
821 x_set_foreground_color (f
, arg
, oldval
)
823 Lisp_Object arg
, oldval
;
825 struct x_output
*x
= f
->output_data
.x
;
826 unsigned long fg
, old_fg
;
828 fg
= x_decode_color (f
, arg
, BLACK_PIX_DEFAULT (f
));
829 old_fg
= x
->foreground_pixel
;
830 x
->foreground_pixel
= fg
;
832 if (FRAME_X_WINDOW (f
) != 0)
834 Display
*dpy
= FRAME_X_DISPLAY (f
);
837 XSetForeground (dpy
, x
->normal_gc
, fg
);
838 XSetBackground (dpy
, x
->reverse_gc
, fg
);
840 if (x
->cursor_pixel
== old_fg
)
842 unload_color (f
, x
->cursor_pixel
);
843 x
->cursor_pixel
= x_copy_color (f
, fg
);
844 XSetBackground (dpy
, x
->cursor_gc
, x
->cursor_pixel
);
849 update_face_from_frame_parameter (f
, Qforeground_color
, arg
);
851 if (FRAME_VISIBLE_P (f
))
855 unload_color (f
, old_fg
);
859 x_set_background_color (f
, arg
, oldval
)
861 Lisp_Object arg
, oldval
;
863 struct x_output
*x
= f
->output_data
.x
;
866 bg
= x_decode_color (f
, arg
, WHITE_PIX_DEFAULT (f
));
867 unload_color (f
, x
->background_pixel
);
868 x
->background_pixel
= bg
;
870 if (FRAME_X_WINDOW (f
) != 0)
872 Display
*dpy
= FRAME_X_DISPLAY (f
);
875 XSetBackground (dpy
, x
->normal_gc
, bg
);
876 XSetForeground (dpy
, x
->reverse_gc
, bg
);
877 XSetWindowBackground (dpy
, FRAME_X_WINDOW (f
), bg
);
878 XSetForeground (dpy
, x
->cursor_gc
, bg
);
881 xg_set_background_color (f
, bg
);
884 #ifndef USE_TOOLKIT_SCROLL_BARS /* Turns out to be annoying with
885 toolkit scroll bars. */
888 for (bar
= FRAME_SCROLL_BARS (f
);
890 bar
= XSCROLL_BAR (bar
)->next
)
892 Window window
= SCROLL_BAR_X_WINDOW (XSCROLL_BAR (bar
));
893 XSetWindowBackground (dpy
, window
, bg
);
896 #endif /* USE_TOOLKIT_SCROLL_BARS */
899 update_face_from_frame_parameter (f
, Qbackground_color
, arg
);
901 if (FRAME_VISIBLE_P (f
))
907 x_set_mouse_color (f
, arg
, oldval
)
909 Lisp_Object arg
, oldval
;
911 struct x_output
*x
= f
->output_data
.x
;
912 Display
*dpy
= FRAME_X_DISPLAY (f
);
913 Cursor cursor
, nontext_cursor
, mode_cursor
, hand_cursor
;
914 Cursor hourglass_cursor
, horizontal_drag_cursor
;
916 unsigned long pixel
= x_decode_color (f
, arg
, BLACK_PIX_DEFAULT (f
));
917 unsigned long mask_color
= x
->background_pixel
;
919 /* Don't let pointers be invisible. */
920 if (mask_color
== pixel
)
922 x_free_colors (f
, &pixel
, 1);
923 pixel
= x_copy_color (f
, x
->foreground_pixel
);
926 unload_color (f
, x
->mouse_pixel
);
927 x
->mouse_pixel
= pixel
;
931 /* It's not okay to crash if the user selects a screwy cursor. */
932 count
= x_catch_errors (dpy
);
934 if (!NILP (Vx_pointer_shape
))
936 CHECK_NUMBER (Vx_pointer_shape
);
937 cursor
= XCreateFontCursor (dpy
, XINT (Vx_pointer_shape
));
940 cursor
= XCreateFontCursor (dpy
, XC_xterm
);
941 x_check_errors (dpy
, "bad text pointer cursor: %s");
943 if (!NILP (Vx_nontext_pointer_shape
))
945 CHECK_NUMBER (Vx_nontext_pointer_shape
);
947 = XCreateFontCursor (dpy
, XINT (Vx_nontext_pointer_shape
));
950 nontext_cursor
= XCreateFontCursor (dpy
, XC_left_ptr
);
951 x_check_errors (dpy
, "bad nontext pointer cursor: %s");
953 if (!NILP (Vx_hourglass_pointer_shape
))
955 CHECK_NUMBER (Vx_hourglass_pointer_shape
);
957 = XCreateFontCursor (dpy
, XINT (Vx_hourglass_pointer_shape
));
960 hourglass_cursor
= XCreateFontCursor (dpy
, XC_watch
);
961 x_check_errors (dpy
, "bad hourglass pointer cursor: %s");
963 if (!NILP (Vx_mode_pointer_shape
))
965 CHECK_NUMBER (Vx_mode_pointer_shape
);
966 mode_cursor
= XCreateFontCursor (dpy
, XINT (Vx_mode_pointer_shape
));
969 mode_cursor
= XCreateFontCursor (dpy
, XC_xterm
);
970 x_check_errors (dpy
, "bad modeline pointer cursor: %s");
972 if (!NILP (Vx_sensitive_text_pointer_shape
))
974 CHECK_NUMBER (Vx_sensitive_text_pointer_shape
);
976 = XCreateFontCursor (dpy
, XINT (Vx_sensitive_text_pointer_shape
));
979 hand_cursor
= XCreateFontCursor (dpy
, XC_hand2
);
981 if (!NILP (Vx_window_horizontal_drag_shape
))
983 CHECK_NUMBER (Vx_window_horizontal_drag_shape
);
984 horizontal_drag_cursor
985 = XCreateFontCursor (dpy
, XINT (Vx_window_horizontal_drag_shape
));
988 horizontal_drag_cursor
989 = XCreateFontCursor (dpy
, XC_sb_h_double_arrow
);
991 /* Check and report errors with the above calls. */
992 x_check_errors (dpy
, "can't set cursor shape: %s");
993 x_uncatch_errors (dpy
, count
);
996 XColor fore_color
, back_color
;
998 fore_color
.pixel
= x
->mouse_pixel
;
999 x_query_color (f
, &fore_color
);
1000 back_color
.pixel
= mask_color
;
1001 x_query_color (f
, &back_color
);
1003 XRecolorCursor (dpy
, cursor
, &fore_color
, &back_color
);
1004 XRecolorCursor (dpy
, nontext_cursor
, &fore_color
, &back_color
);
1005 XRecolorCursor (dpy
, mode_cursor
, &fore_color
, &back_color
);
1006 XRecolorCursor (dpy
, hand_cursor
, &fore_color
, &back_color
);
1007 XRecolorCursor (dpy
, hourglass_cursor
, &fore_color
, &back_color
);
1008 XRecolorCursor (dpy
, horizontal_drag_cursor
, &fore_color
, &back_color
);
1011 if (FRAME_X_WINDOW (f
) != 0)
1012 XDefineCursor (dpy
, FRAME_X_WINDOW (f
), cursor
);
1014 if (cursor
!= x
->text_cursor
1015 && x
->text_cursor
!= 0)
1016 XFreeCursor (dpy
, x
->text_cursor
);
1017 x
->text_cursor
= cursor
;
1019 if (nontext_cursor
!= x
->nontext_cursor
1020 && x
->nontext_cursor
!= 0)
1021 XFreeCursor (dpy
, x
->nontext_cursor
);
1022 x
->nontext_cursor
= nontext_cursor
;
1024 if (hourglass_cursor
!= x
->hourglass_cursor
1025 && x
->hourglass_cursor
!= 0)
1026 XFreeCursor (dpy
, x
->hourglass_cursor
);
1027 x
->hourglass_cursor
= hourglass_cursor
;
1029 if (mode_cursor
!= x
->modeline_cursor
1030 && x
->modeline_cursor
!= 0)
1031 XFreeCursor (dpy
, f
->output_data
.x
->modeline_cursor
);
1032 x
->modeline_cursor
= mode_cursor
;
1034 if (hand_cursor
!= x
->hand_cursor
1035 && x
->hand_cursor
!= 0)
1036 XFreeCursor (dpy
, x
->hand_cursor
);
1037 x
->hand_cursor
= hand_cursor
;
1039 if (horizontal_drag_cursor
!= x
->horizontal_drag_cursor
1040 && x
->horizontal_drag_cursor
!= 0)
1041 XFreeCursor (dpy
, x
->horizontal_drag_cursor
);
1042 x
->horizontal_drag_cursor
= horizontal_drag_cursor
;
1047 update_face_from_frame_parameter (f
, Qmouse_color
, arg
);
1051 x_set_cursor_color (f
, arg
, oldval
)
1053 Lisp_Object arg
, oldval
;
1055 unsigned long fore_pixel
, pixel
;
1056 int fore_pixel_allocated_p
= 0, pixel_allocated_p
= 0;
1057 struct x_output
*x
= f
->output_data
.x
;
1059 if (!NILP (Vx_cursor_fore_pixel
))
1061 fore_pixel
= x_decode_color (f
, Vx_cursor_fore_pixel
,
1062 WHITE_PIX_DEFAULT (f
));
1063 fore_pixel_allocated_p
= 1;
1066 fore_pixel
= x
->background_pixel
;
1068 pixel
= x_decode_color (f
, arg
, BLACK_PIX_DEFAULT (f
));
1069 pixel_allocated_p
= 1;
1071 /* Make sure that the cursor color differs from the background color. */
1072 if (pixel
== x
->background_pixel
)
1074 if (pixel_allocated_p
)
1076 x_free_colors (f
, &pixel
, 1);
1077 pixel_allocated_p
= 0;
1080 pixel
= x
->mouse_pixel
;
1081 if (pixel
== fore_pixel
)
1083 if (fore_pixel_allocated_p
)
1085 x_free_colors (f
, &fore_pixel
, 1);
1086 fore_pixel_allocated_p
= 0;
1088 fore_pixel
= x
->background_pixel
;
1092 unload_color (f
, x
->cursor_foreground_pixel
);
1093 if (!fore_pixel_allocated_p
)
1094 fore_pixel
= x_copy_color (f
, fore_pixel
);
1095 x
->cursor_foreground_pixel
= fore_pixel
;
1097 unload_color (f
, x
->cursor_pixel
);
1098 if (!pixel_allocated_p
)
1099 pixel
= x_copy_color (f
, pixel
);
1100 x
->cursor_pixel
= pixel
;
1102 if (FRAME_X_WINDOW (f
) != 0)
1105 XSetBackground (FRAME_X_DISPLAY (f
), x
->cursor_gc
, x
->cursor_pixel
);
1106 XSetForeground (FRAME_X_DISPLAY (f
), x
->cursor_gc
, fore_pixel
);
1109 if (FRAME_VISIBLE_P (f
))
1111 x_update_cursor (f
, 0);
1112 x_update_cursor (f
, 1);
1116 update_face_from_frame_parameter (f
, Qcursor_color
, arg
);
1119 /* Set the border-color of frame F to pixel value PIX.
1120 Note that this does not fully take effect if done before
1121 F has an x-window. */
1124 x_set_border_pixel (f
, pix
)
1128 unload_color (f
, f
->output_data
.x
->border_pixel
);
1129 f
->output_data
.x
->border_pixel
= pix
;
1131 if (FRAME_X_WINDOW (f
) != 0 && f
->border_width
> 0)
1134 XSetWindowBorder (FRAME_X_DISPLAY (f
), FRAME_X_WINDOW (f
),
1135 (unsigned long)pix
);
1138 if (FRAME_VISIBLE_P (f
))
1143 /* Set the border-color of frame F to value described by ARG.
1144 ARG can be a string naming a color.
1145 The border-color is used for the border that is drawn by the X server.
1146 Note that this does not fully take effect if done before
1147 F has an x-window; it must be redone when the window is created.
1149 Note: this is done in two routines because of the way X10 works.
1151 Note: under X11, this is normally the province of the window manager,
1152 and so emacs' border colors may be overridden. */
1155 x_set_border_color (f
, arg
, oldval
)
1157 Lisp_Object arg
, oldval
;
1162 pix
= x_decode_color (f
, arg
, BLACK_PIX_DEFAULT (f
));
1163 x_set_border_pixel (f
, pix
);
1164 update_face_from_frame_parameter (f
, Qborder_color
, arg
);
1169 x_set_cursor_type (f
, arg
, oldval
)
1171 Lisp_Object arg
, oldval
;
1173 set_frame_cursor_types (f
, arg
);
1175 /* Make sure the cursor gets redrawn. */
1176 cursor_type_changed
= 1;
1180 x_set_icon_type (f
, arg
, oldval
)
1182 Lisp_Object arg
, oldval
;
1188 if (STRINGP (oldval
) && EQ (Fstring_equal (oldval
, arg
), Qt
))
1191 else if (!STRINGP (oldval
) && EQ (oldval
, Qnil
) == EQ (arg
, Qnil
))
1196 result
= x_text_icon (f
,
1197 (char *) SDATA ((!NILP (f
->icon_name
)
1201 result
= x_bitmap_icon (f
, arg
);
1206 error ("No icon window available");
1209 XFlush (FRAME_X_DISPLAY (f
));
1214 x_set_icon_name (f
, arg
, oldval
)
1216 Lisp_Object arg
, oldval
;
1222 if (STRINGP (oldval
) && EQ (Fstring_equal (oldval
, arg
), Qt
))
1225 else if (!STRINGP (oldval
) && EQ (oldval
, Qnil
) == EQ (arg
, Qnil
))
1230 if (f
->output_data
.x
->icon_bitmap
!= 0)
1235 result
= x_text_icon (f
,
1236 (char *) SDATA ((!NILP (f
->icon_name
)
1245 error ("No icon window available");
1248 XFlush (FRAME_X_DISPLAY (f
));
1254 x_set_menu_bar_lines (f
, value
, oldval
)
1256 Lisp_Object value
, oldval
;
1259 #if ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)
1260 int olines
= FRAME_MENU_BAR_LINES (f
);
1263 /* Right now, menu bars don't work properly in minibuf-only frames;
1264 most of the commands try to apply themselves to the minibuffer
1265 frame itself, and get an error because you can't switch buffers
1266 in or split the minibuffer window. */
1267 if (FRAME_MINIBUF_ONLY_P (f
))
1270 if (INTEGERP (value
))
1271 nlines
= XINT (value
);
1275 /* Make sure we redisplay all windows in this frame. */
1276 windows_or_buffers_changed
++;
1278 #if defined (USE_X_TOOLKIT) || defined (USE_GTK)
1279 FRAME_MENU_BAR_LINES (f
) = 0;
1282 FRAME_EXTERNAL_MENU_BAR (f
) = 1;
1283 if (FRAME_X_P (f
) && f
->output_data
.x
->menubar_widget
== 0)
1284 /* Make sure next redisplay shows the menu bar. */
1285 XWINDOW (FRAME_SELECTED_WINDOW (f
))->update_mode_line
= Qt
;
1289 if (FRAME_EXTERNAL_MENU_BAR (f
) == 1)
1290 free_frame_menubar (f
);
1291 FRAME_EXTERNAL_MENU_BAR (f
) = 0;
1293 f
->output_data
.x
->menubar_widget
= 0;
1295 #else /* not USE_X_TOOLKIT && not USE_GTK */
1296 FRAME_MENU_BAR_LINES (f
) = nlines
;
1297 change_window_heights (f
->root_window
, nlines
- olines
);
1298 #endif /* not USE_X_TOOLKIT */
1303 /* Set the number of lines used for the tool bar of frame F to VALUE.
1304 VALUE not an integer, or < 0 means set the lines to zero. OLDVAL
1305 is the old number of tool bar lines. This function changes the
1306 height of all windows on frame F to match the new tool bar height.
1307 The frame's height doesn't change. */
1310 x_set_tool_bar_lines (f
, value
, oldval
)
1312 Lisp_Object value
, oldval
;
1314 int delta
, nlines
, root_height
;
1315 Lisp_Object root_window
;
1317 /* Treat tool bars like menu bars. */
1318 if (FRAME_MINIBUF_ONLY_P (f
))
1321 /* Use VALUE only if an integer >= 0. */
1322 if (INTEGERP (value
) && XINT (value
) >= 0)
1323 nlines
= XFASTINT (value
);
1328 FRAME_TOOL_BAR_LINES (f
) = 0;
1331 FRAME_EXTERNAL_TOOL_BAR (f
) = 1;
1332 if (FRAME_X_P (f
) && f
->output_data
.x
->toolbar_widget
== 0)
1333 /* Make sure next redisplay shows the tool bar. */
1334 XWINDOW (FRAME_SELECTED_WINDOW (f
))->update_mode_line
= Qt
;
1335 update_frame_tool_bar (f
);
1339 if (FRAME_EXTERNAL_TOOL_BAR (f
))
1340 free_frame_tool_bar (f
);
1341 FRAME_EXTERNAL_TOOL_BAR (f
) = 0;
1347 /* Make sure we redisplay all windows in this frame. */
1348 ++windows_or_buffers_changed
;
1350 delta
= nlines
- FRAME_TOOL_BAR_LINES (f
);
1352 /* Don't resize the tool-bar to more than we have room for. */
1353 root_window
= FRAME_ROOT_WINDOW (f
);
1354 root_height
= WINDOW_TOTAL_LINES (XWINDOW (root_window
));
1355 if (root_height
- delta
< 1)
1357 delta
= root_height
- 1;
1358 nlines
= FRAME_TOOL_BAR_LINES (f
) + delta
;
1361 FRAME_TOOL_BAR_LINES (f
) = nlines
;
1362 change_window_heights (root_window
, delta
);
1365 /* We also have to make sure that the internal border at the top of
1366 the frame, below the menu bar or tool bar, is redrawn when the
1367 tool bar disappears. This is so because the internal border is
1368 below the tool bar if one is displayed, but is below the menu bar
1369 if there isn't a tool bar. The tool bar draws into the area
1370 below the menu bar. */
1371 if (FRAME_X_WINDOW (f
) && FRAME_TOOL_BAR_LINES (f
) == 0)
1375 clear_current_matrices (f
);
1376 updating_frame
= NULL
;
1379 /* If the tool bar gets smaller, the internal border below it
1380 has to be cleared. It was formerly part of the display
1381 of the larger tool bar, and updating windows won't clear it. */
1384 int height
= FRAME_INTERNAL_BORDER_WIDTH (f
);
1385 int width
= FRAME_PIXEL_WIDTH (f
);
1386 int y
= nlines
* FRAME_LINE_HEIGHT (f
);
1389 x_clear_area (FRAME_X_DISPLAY (f
), FRAME_X_WINDOW (f
),
1390 0, y
, width
, height
, False
);
1393 if (WINDOWP (f
->tool_bar_window
))
1394 clear_glyph_matrix (XWINDOW (f
->tool_bar_window
)->current_matrix
);
1399 /* Set the foreground color for scroll bars on frame F to VALUE.
1400 VALUE should be a string, a color name. If it isn't a string or
1401 isn't a valid color name, do nothing. OLDVAL is the old value of
1402 the frame parameter. */
1405 x_set_scroll_bar_foreground (f
, value
, oldval
)
1407 Lisp_Object value
, oldval
;
1409 unsigned long pixel
;
1411 if (STRINGP (value
))
1412 pixel
= x_decode_color (f
, value
, BLACK_PIX_DEFAULT (f
));
1416 if (f
->output_data
.x
->scroll_bar_foreground_pixel
!= -1)
1417 unload_color (f
, f
->output_data
.x
->scroll_bar_foreground_pixel
);
1419 f
->output_data
.x
->scroll_bar_foreground_pixel
= pixel
;
1420 if (FRAME_X_WINDOW (f
) && FRAME_VISIBLE_P (f
))
1422 /* Remove all scroll bars because they have wrong colors. */
1423 if (FRAME_DISPLAY (f
)->condemn_scroll_bars_hook
)
1424 (*FRAME_DISPLAY (f
)->condemn_scroll_bars_hook
) (f
);
1425 if (FRAME_DISPLAY (f
)->judge_scroll_bars_hook
)
1426 (*FRAME_DISPLAY (f
)->judge_scroll_bars_hook
) (f
);
1428 update_face_from_frame_parameter (f
, Qscroll_bar_foreground
, value
);
1434 /* Set the background color for scroll bars on frame F to VALUE VALUE
1435 should be a string, a color name. If it isn't a string or isn't a
1436 valid color name, do nothing. OLDVAL is the old value of the frame
1440 x_set_scroll_bar_background (f
, value
, oldval
)
1442 Lisp_Object value
, oldval
;
1444 unsigned long pixel
;
1446 if (STRINGP (value
))
1447 pixel
= x_decode_color (f
, value
, WHITE_PIX_DEFAULT (f
));
1451 if (f
->output_data
.x
->scroll_bar_background_pixel
!= -1)
1452 unload_color (f
, f
->output_data
.x
->scroll_bar_background_pixel
);
1454 #ifdef USE_TOOLKIT_SCROLL_BARS
1455 /* Scrollbar shadow colors. */
1456 if (f
->output_data
.x
->scroll_bar_top_shadow_pixel
!= -1)
1458 unload_color (f
, f
->output_data
.x
->scroll_bar_top_shadow_pixel
);
1459 f
->output_data
.x
->scroll_bar_top_shadow_pixel
= -1;
1461 if (f
->output_data
.x
->scroll_bar_bottom_shadow_pixel
!= -1)
1463 unload_color (f
, f
->output_data
.x
->scroll_bar_bottom_shadow_pixel
);
1464 f
->output_data
.x
->scroll_bar_bottom_shadow_pixel
= -1;
1466 #endif /* USE_TOOLKIT_SCROLL_BARS */
1468 f
->output_data
.x
->scroll_bar_background_pixel
= pixel
;
1469 if (FRAME_X_WINDOW (f
) && FRAME_VISIBLE_P (f
))
1471 /* Remove all scroll bars because they have wrong colors. */
1472 if (FRAME_DISPLAY (f
)->condemn_scroll_bars_hook
)
1473 (*FRAME_DISPLAY (f
)->condemn_scroll_bars_hook
) (f
);
1474 if (FRAME_DISPLAY (f
)->judge_scroll_bars_hook
)
1475 (*FRAME_DISPLAY (f
)->judge_scroll_bars_hook
) (f
);
1477 update_face_from_frame_parameter (f
, Qscroll_bar_background
, value
);
1483 /* Encode Lisp string STRING as a text in a format appropriate for
1484 XICCC (X Inter Client Communication Conventions).
1486 If STRING contains only ASCII characters, do no conversion and
1487 return the string data of STRING. Otherwise, encode the text by
1488 CODING_SYSTEM, and return a newly allocated memory area which
1489 should be freed by `xfree' by a caller.
1491 SELECTIONP non-zero means the string is being encoded for an X
1492 selection, so it is safe to run pre-write conversions (which
1495 Store the byte length of resulting text in *TEXT_BYTES.
1497 If the text contains only ASCII and Latin-1, store 1 in *STRING_P,
1498 which means that the `encoding' of the result can be `STRING'.
1499 Otherwise store 0 in *STRINGP, which means that the `encoding' of
1500 the result should be `COMPOUND_TEXT'. */
1503 x_encode_text (string
, coding_system
, selectionp
, text_bytes
, stringp
)
1504 Lisp_Object string
, coding_system
;
1505 int *text_bytes
, *stringp
;
1508 unsigned char *str
= SDATA (string
);
1509 int chars
= SCHARS (string
);
1510 int bytes
= SBYTES (string
);
1514 struct coding_system coding
;
1515 extern Lisp_Object Qcompound_text_with_extensions
;
1517 charset_info
= find_charset_in_text (str
, chars
, bytes
, NULL
, Qnil
);
1518 if (charset_info
== 0)
1520 /* No multibyte character in OBJ. We need not encode it. */
1521 *text_bytes
= bytes
;
1526 setup_coding_system (coding_system
, &coding
);
1528 && SYMBOLP (coding
.pre_write_conversion
)
1529 && !NILP (Ffboundp (coding
.pre_write_conversion
)))
1531 string
= run_pre_post_conversion_on_str (string
, &coding
, 1);
1532 str
= SDATA (string
);
1533 chars
= SCHARS (string
);
1534 bytes
= SBYTES (string
);
1536 coding
.src_multibyte
= 1;
1537 coding
.dst_multibyte
= 0;
1538 coding
.mode
|= CODING_MODE_LAST_BLOCK
;
1539 if (coding
.type
== coding_type_iso2022
)
1540 coding
.flags
|= CODING_FLAG_ISO_SAFE
;
1541 /* We suppress producing escape sequences for composition. */
1542 coding
.composing
= COMPOSITION_DISABLED
;
1543 bufsize
= encoding_buffer_size (&coding
, bytes
);
1544 buf
= (unsigned char *) xmalloc (bufsize
);
1545 encode_coding (&coding
, str
, buf
, bytes
, bufsize
);
1546 *text_bytes
= coding
.produced
;
1547 *stringp
= (charset_info
== 1
1548 || (!EQ (coding_system
, Qcompound_text
)
1549 && !EQ (coding_system
, Qcompound_text_with_extensions
)));
1554 /* Change the name of frame F to NAME. If NAME is nil, set F's name to
1557 If EXPLICIT is non-zero, that indicates that lisp code is setting the
1558 name; if NAME is a string, set F's name to NAME and set
1559 F->explicit_name; if NAME is Qnil, then clear F->explicit_name.
1561 If EXPLICIT is zero, that indicates that Emacs redisplay code is
1562 suggesting a new name, which lisp code should override; if
1563 F->explicit_name is set, ignore the new name; otherwise, set it. */
1566 x_set_name (f
, name
, explicit)
1571 /* Make sure that requests from lisp code override requests from
1572 Emacs redisplay code. */
1575 /* If we're switching from explicit to implicit, we had better
1576 update the mode lines and thereby update the title. */
1577 if (f
->explicit_name
&& NILP (name
))
1578 update_mode_lines
= 1;
1580 f
->explicit_name
= ! NILP (name
);
1582 else if (f
->explicit_name
)
1585 /* If NAME is nil, set the name to the x_id_name. */
1588 /* Check for no change needed in this very common case
1589 before we do any consing. */
1590 if (!strcmp (FRAME_X_DISPLAY_INFO (f
)->x_id_name
,
1593 name
= build_string (FRAME_X_DISPLAY_INFO (f
)->x_id_name
);
1596 CHECK_STRING (name
);
1598 /* Don't change the name if it's already NAME. */
1599 if (! NILP (Fstring_equal (name
, f
->name
)))
1604 /* For setting the frame title, the title parameter should override
1605 the name parameter. */
1606 if (! NILP (f
->title
))
1609 if (FRAME_X_WINDOW (f
))
1614 XTextProperty text
, icon
;
1616 Lisp_Object coding_system
;
1618 /* Note: Encoding strategy
1620 We encode NAME by compound-text and use "COMPOUND-TEXT" in
1621 text.encoding. But, there are non-internationalized window
1622 managers which don't support that encoding. So, if NAME
1623 contains only ASCII and 8859-1 characters, encode it by
1624 iso-latin-1, and use "STRING" in text.encoding hoping that
1625 such window managers at least analyze this format correctly,
1626 i.e. treat 8-bit bytes as 8859-1 characters.
1628 We may also be able to use "UTF8_STRING" in text.encoding
1629 in the future which can encode all Unicode characters.
1630 But, for the moment, there's no way to know that the
1631 current window manager supports it or not. */
1632 coding_system
= Qcompound_text
;
1633 text
.value
= x_encode_text (name
, coding_system
, 0, &bytes
, &stringp
);
1634 text
.encoding
= (stringp
? XA_STRING
1635 : FRAME_X_DISPLAY_INFO (f
)->Xatom_COMPOUND_TEXT
);
1637 text
.nitems
= bytes
;
1639 if (NILP (f
->icon_name
))
1645 /* See the above comment "Note: Encoding strategy". */
1646 icon
.value
= x_encode_text (f
->icon_name
, coding_system
, 0,
1648 icon
.encoding
= (stringp
? XA_STRING
1649 : FRAME_X_DISPLAY_INFO (f
)->Xatom_COMPOUND_TEXT
);
1651 icon
.nitems
= bytes
;
1654 gtk_window_set_title (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f
)),
1656 #else /* not USE_GTK */
1657 XSetWMName (FRAME_X_DISPLAY (f
), FRAME_OUTER_WINDOW (f
), &text
);
1658 #endif /* not USE_GTK */
1660 XSetWMIconName (FRAME_X_DISPLAY (f
), FRAME_OUTER_WINDOW (f
), &icon
);
1662 if (!NILP (f
->icon_name
)
1663 && icon
.value
!= (unsigned char *) SDATA (f
->icon_name
))
1665 if (text
.value
!= (unsigned char *) SDATA (name
))
1668 #else /* not HAVE_X11R4 */
1669 XSetIconName (FRAME_X_DISPLAY (f
), FRAME_X_WINDOW (f
),
1671 XStoreName (FRAME_X_DISPLAY (f
), FRAME_X_WINDOW (f
),
1673 #endif /* not HAVE_X11R4 */
1678 /* This function should be called when the user's lisp code has
1679 specified a name for the frame; the name will override any set by the
1682 x_explicitly_set_name (f
, arg
, oldval
)
1684 Lisp_Object arg
, oldval
;
1686 x_set_name (f
, arg
, 1);
1689 /* This function should be called by Emacs redisplay code to set the
1690 name; names set this way will never override names set by the user's
1693 x_implicitly_set_name (f
, arg
, oldval
)
1695 Lisp_Object arg
, oldval
;
1697 x_set_name (f
, arg
, 0);
1700 /* Change the title of frame F to NAME.
1701 If NAME is nil, use the frame name as the title.
1703 If EXPLICIT is non-zero, that indicates that lisp code is setting the
1704 name; if NAME is a string, set F's name to NAME and set
1705 F->explicit_name; if NAME is Qnil, then clear F->explicit_name.
1707 If EXPLICIT is zero, that indicates that Emacs redisplay code is
1708 suggesting a new name, which lisp code should override; if
1709 F->explicit_name is set, ignore the new name; otherwise, set it. */
1712 x_set_title (f
, name
, old_name
)
1714 Lisp_Object name
, old_name
;
1716 /* Don't change the title if it's already NAME. */
1717 if (EQ (name
, f
->title
))
1720 update_mode_lines
= 1;
1727 CHECK_STRING (name
);
1729 if (FRAME_X_WINDOW (f
))
1734 XTextProperty text
, icon
;
1736 Lisp_Object coding_system
;
1738 coding_system
= Qcompound_text
;
1739 /* See the comment "Note: Encoding strategy" in x_set_name. */
1740 text
.value
= x_encode_text (name
, coding_system
, 0, &bytes
, &stringp
);
1741 text
.encoding
= (stringp
? XA_STRING
1742 : FRAME_X_DISPLAY_INFO (f
)->Xatom_COMPOUND_TEXT
);
1744 text
.nitems
= bytes
;
1746 if (NILP (f
->icon_name
))
1752 /* See the comment "Note: Encoding strategy" in x_set_name. */
1753 icon
.value
= x_encode_text (f
->icon_name
, coding_system
, 0,
1755 icon
.encoding
= (stringp
? XA_STRING
1756 : FRAME_X_DISPLAY_INFO (f
)->Xatom_COMPOUND_TEXT
);
1758 icon
.nitems
= bytes
;
1762 gtk_window_set_title (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f
)),
1764 #else /* not USE_GTK */
1765 XSetWMName (FRAME_X_DISPLAY (f
), FRAME_OUTER_WINDOW (f
), &text
);
1766 #endif /* not USE_GTK */
1768 XSetWMIconName (FRAME_X_DISPLAY (f
), FRAME_OUTER_WINDOW (f
),
1771 if (!NILP (f
->icon_name
)
1772 && icon
.value
!= (unsigned char *) SDATA (f
->icon_name
))
1774 if (text
.value
!= (unsigned char *) SDATA (name
))
1777 #else /* not HAVE_X11R4 */
1778 XSetIconName (FRAME_X_DISPLAY (f
), FRAME_X_WINDOW (f
),
1780 XStoreName (FRAME_X_DISPLAY (f
), FRAME_X_WINDOW (f
),
1782 #endif /* not HAVE_X11R4 */
1788 x_set_scroll_bar_default_width (f
)
1791 int wid
= FRAME_COLUMN_WIDTH (f
);
1793 #ifdef USE_TOOLKIT_SCROLL_BARS
1794 /* A minimum width of 14 doesn't look good for toolkit scroll bars. */
1795 int width
= 16 + 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM
;
1796 FRAME_CONFIG_SCROLL_BAR_COLS (f
) = (width
+ wid
- 1) / wid
;
1797 FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) = width
;
1799 /* Make the actual width at least 14 pixels and a multiple of a
1801 FRAME_CONFIG_SCROLL_BAR_COLS (f
) = (14 + wid
- 1) / wid
;
1803 /* Use all of that space (aside from required margins) for the
1805 FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) = 0;
1810 /* Record in frame F the specified or default value according to ALIST
1811 of the parameter named PROP (a Lisp symbol). If no value is
1812 specified for PROP, look for an X default for XPROP on the frame
1813 named NAME. If that is not found either, use the value DEFLT. */
1816 x_default_scroll_bar_color_parameter (f
, alist
, prop
, xprop
, xclass
,
1825 struct x_display_info
*dpyinfo
= FRAME_X_DISPLAY_INFO (f
);
1828 tem
= x_get_arg (dpyinfo
, alist
, prop
, xprop
, xclass
, RES_TYPE_STRING
);
1829 if (EQ (tem
, Qunbound
))
1831 #ifdef USE_TOOLKIT_SCROLL_BARS
1833 /* See if an X resource for the scroll bar color has been
1835 tem
= display_x_get_resource (dpyinfo
,
1836 build_string (foreground_p
1840 build_string ("verticalScrollBar"),
1844 /* If nothing has been specified, scroll bars will use a
1845 toolkit-dependent default. Because these defaults are
1846 difficult to get at without actually creating a scroll
1847 bar, use nil to indicate that no color has been
1852 #else /* not USE_TOOLKIT_SCROLL_BARS */
1856 #endif /* not USE_TOOLKIT_SCROLL_BARS */
1859 x_set_frame_parameters (f
, Fcons (Fcons (prop
, tem
), Qnil
));
1865 #if !defined (HAVE_X11R4) && !defined (HAVE_XSETWMPROTOCOLS)
1868 XSetWMProtocols (dpy
, w
, protocols
, count
)
1875 prop
= XInternAtom (dpy
, "WM_PROTOCOLS", False
);
1876 if (prop
== None
) return False
;
1877 XChangeProperty (dpy
, w
, prop
, XA_ATOM
, 32, PropModeReplace
,
1878 (unsigned char *) protocols
, count
);
1881 #endif /* not HAVE_X11R4 && not HAVE_XSETWMPROTOCOLS */
1883 #ifdef USE_X_TOOLKIT
1885 /* If the WM_PROTOCOLS property does not already contain WM_TAKE_FOCUS,
1886 WM_DELETE_WINDOW, and WM_SAVE_YOURSELF, then add them. (They may
1887 already be present because of the toolkit (Motif adds some of them,
1888 for example, but Xt doesn't). */
1891 hack_wm_protocols (f
, widget
)
1895 Display
*dpy
= XtDisplay (widget
);
1896 Window w
= XtWindow (widget
);
1897 int need_delete
= 1;
1903 Atom type
, *atoms
= 0;
1905 unsigned long nitems
= 0;
1906 unsigned long bytes_after
;
1908 if ((XGetWindowProperty (dpy
, w
,
1909 FRAME_X_DISPLAY_INFO (f
)->Xatom_wm_protocols
,
1910 (long)0, (long)100, False
, XA_ATOM
,
1911 &type
, &format
, &nitems
, &bytes_after
,
1912 (unsigned char **) &atoms
)
1914 && format
== 32 && type
== XA_ATOM
)
1918 if (atoms
[nitems
] == FRAME_X_DISPLAY_INFO (f
)->Xatom_wm_delete_window
)
1920 else if (atoms
[nitems
] == FRAME_X_DISPLAY_INFO (f
)->Xatom_wm_take_focus
)
1922 else if (atoms
[nitems
] == FRAME_X_DISPLAY_INFO (f
)->Xatom_wm_save_yourself
)
1925 if (atoms
) XFree ((char *) atoms
);
1931 props
[count
++] = FRAME_X_DISPLAY_INFO (f
)->Xatom_wm_delete_window
;
1933 props
[count
++] = FRAME_X_DISPLAY_INFO (f
)->Xatom_wm_take_focus
;
1935 props
[count
++] = FRAME_X_DISPLAY_INFO (f
)->Xatom_wm_save_yourself
;
1937 XChangeProperty (dpy
, w
, FRAME_X_DISPLAY_INFO (f
)->Xatom_wm_protocols
,
1938 XA_ATOM
, 32, PropModeAppend
,
1939 (unsigned char *) props
, count
);
1947 /* Support routines for XIC (X Input Context). */
1951 static XFontSet xic_create_xfontset
P_ ((struct frame
*, char *));
1952 static XIMStyle best_xim_style
P_ ((XIMStyles
*, XIMStyles
*));
1955 /* Supported XIM styles, ordered by preference. */
1957 static XIMStyle supported_xim_styles
[] =
1959 XIMPreeditPosition
| XIMStatusArea
,
1960 XIMPreeditPosition
| XIMStatusNothing
,
1961 XIMPreeditPosition
| XIMStatusNone
,
1962 XIMPreeditNothing
| XIMStatusArea
,
1963 XIMPreeditNothing
| XIMStatusNothing
,
1964 XIMPreeditNothing
| XIMStatusNone
,
1965 XIMPreeditNone
| XIMStatusArea
,
1966 XIMPreeditNone
| XIMStatusNothing
,
1967 XIMPreeditNone
| XIMStatusNone
,
1972 /* Create an X fontset on frame F with base font name
1976 xic_create_xfontset (f
, base_fontname
)
1978 char *base_fontname
;
1981 char **missing_list
;
1985 xfs
= XCreateFontSet (FRAME_X_DISPLAY (f
),
1986 base_fontname
, &missing_list
,
1987 &missing_count
, &def_string
);
1989 XFreeStringList (missing_list
);
1991 /* No need to free def_string. */
1996 /* Value is the best input style, given user preferences USER (already
1997 checked to be supported by Emacs), and styles supported by the
1998 input method XIM. */
2001 best_xim_style (user
, xim
)
2007 for (i
= 0; i
< user
->count_styles
; ++i
)
2008 for (j
= 0; j
< xim
->count_styles
; ++j
)
2009 if (user
->supported_styles
[i
] == xim
->supported_styles
[j
])
2010 return user
->supported_styles
[i
];
2012 /* Return the default style. */
2013 return XIMPreeditNothing
| XIMStatusNothing
;
2016 /* Create XIC for frame F. */
2018 static XIMStyle xic_style
;
2021 create_frame_xic (f
)
2026 XFontSet xfs
= NULL
;
2031 xim
= FRAME_X_XIM (f
);
2036 XVaNestedList preedit_attr
;
2037 XVaNestedList status_attr
;
2038 char *base_fontname
;
2041 s_area
.x
= 0; s_area
.y
= 0; s_area
.width
= 1; s_area
.height
= 1;
2042 spot
.x
= 0; spot
.y
= 1;
2043 /* Create X fontset. */
2044 fontset
= FRAME_FONTSET (f
);
2046 base_fontname
= "-*-*-*-r-normal--14-*-*-*-*-*-*-*";
2049 /* Determine the base fontname from the ASCII font name of
2051 char *ascii_font
= (char *) SDATA (fontset_ascii (fontset
));
2052 char *p
= ascii_font
;
2055 for (i
= 0; *p
; p
++)
2058 /* As the font name doesn't conform to XLFD, we can't
2059 modify it to get a suitable base fontname for the
2061 base_fontname
= "-*-*-*-r-normal--14-*-*-*-*-*-*-*";
2064 int len
= strlen (ascii_font
) + 1;
2067 for (i
= 0, p
= ascii_font
; i
< 8; p
++)
2076 base_fontname
= (char *) alloca (len
);
2077 bzero (base_fontname
, len
);
2078 strcpy (base_fontname
, "-*-*-");
2079 bcopy (p1
, base_fontname
+ 5, p
- p1
);
2080 strcat (base_fontname
, "*-*-*-*-*-*-*");
2083 xfs
= xic_create_xfontset (f
, base_fontname
);
2085 /* Determine XIC style. */
2088 XIMStyles supported_list
;
2089 supported_list
.count_styles
= (sizeof supported_xim_styles
2090 / sizeof supported_xim_styles
[0]);
2091 supported_list
.supported_styles
= supported_xim_styles
;
2092 xic_style
= best_xim_style (&supported_list
,
2093 FRAME_X_XIM_STYLES (f
));
2096 preedit_attr
= XVaCreateNestedList (0,
2099 FRAME_FOREGROUND_PIXEL (f
),
2101 FRAME_BACKGROUND_PIXEL (f
),
2102 (xic_style
& XIMPreeditPosition
2107 status_attr
= XVaCreateNestedList (0,
2113 FRAME_FOREGROUND_PIXEL (f
),
2115 FRAME_BACKGROUND_PIXEL (f
),
2118 xic
= XCreateIC (xim
,
2119 XNInputStyle
, xic_style
,
2120 XNClientWindow
, FRAME_X_WINDOW (f
),
2121 XNFocusWindow
, FRAME_X_WINDOW (f
),
2122 XNStatusAttributes
, status_attr
,
2123 XNPreeditAttributes
, preedit_attr
,
2125 XFree (preedit_attr
);
2126 XFree (status_attr
);
2129 FRAME_XIC (f
) = xic
;
2130 FRAME_XIC_STYLE (f
) = xic_style
;
2131 FRAME_XIC_FONTSET (f
) = xfs
;
2135 /* Destroy XIC and free XIC fontset of frame F, if any. */
2141 if (FRAME_XIC (f
) == NULL
)
2144 XDestroyIC (FRAME_XIC (f
));
2145 if (FRAME_XIC_FONTSET (f
))
2146 XFreeFontSet (FRAME_X_DISPLAY (f
), FRAME_XIC_FONTSET (f
));
2148 FRAME_XIC (f
) = NULL
;
2149 FRAME_XIC_FONTSET (f
) = NULL
;
2153 /* Place preedit area for XIC of window W's frame to specified
2154 pixel position X/Y. X and Y are relative to window W. */
2157 xic_set_preeditarea (w
, x
, y
)
2161 struct frame
*f
= XFRAME (w
->frame
);
2165 spot
.x
= WINDOW_TO_FRAME_PIXEL_X (w
, x
) + WINDOW_LEFT_FRINGE_WIDTH (w
);
2166 spot
.y
= WINDOW_TO_FRAME_PIXEL_Y (w
, y
) + FONT_BASE (FRAME_FONT (f
));
2167 attr
= XVaCreateNestedList (0, XNSpotLocation
, &spot
, NULL
);
2168 XSetICValues (FRAME_XIC (f
), XNPreeditAttributes
, attr
, NULL
);
2173 /* Place status area for XIC in bottom right corner of frame F.. */
2176 xic_set_statusarea (f
)
2179 XIC xic
= FRAME_XIC (f
);
2184 /* Negotiate geometry of status area. If input method has existing
2185 status area, use its current size. */
2186 area
.x
= area
.y
= area
.width
= area
.height
= 0;
2187 attr
= XVaCreateNestedList (0, XNAreaNeeded
, &area
, NULL
);
2188 XSetICValues (xic
, XNStatusAttributes
, attr
, NULL
);
2191 attr
= XVaCreateNestedList (0, XNAreaNeeded
, &needed
, NULL
);
2192 XGetICValues (xic
, XNStatusAttributes
, attr
, NULL
);
2195 if (needed
->width
== 0) /* Use XNArea instead of XNAreaNeeded */
2197 attr
= XVaCreateNestedList (0, XNArea
, &needed
, NULL
);
2198 XGetICValues (xic
, XNStatusAttributes
, attr
, NULL
);
2202 area
.width
= needed
->width
;
2203 area
.height
= needed
->height
;
2204 area
.x
= FRAME_PIXEL_WIDTH (f
) - area
.width
- FRAME_INTERNAL_BORDER_WIDTH (f
);
2205 area
.y
= (FRAME_PIXEL_HEIGHT (f
) - area
.height
2206 - FRAME_MENUBAR_HEIGHT (f
)
2207 - FRAME_TOOLBAR_HEIGHT (f
)
2208 - FRAME_INTERNAL_BORDER_WIDTH (f
));
2211 attr
= XVaCreateNestedList (0, XNArea
, &area
, NULL
);
2212 XSetICValues (xic
, XNStatusAttributes
, attr
, NULL
);
2217 /* Set X fontset for XIC of frame F, using base font name
2218 BASE_FONTNAME. Called when a new Emacs fontset is chosen. */
2221 xic_set_xfontset (f
, base_fontname
)
2223 char *base_fontname
;
2228 xfs
= xic_create_xfontset (f
, base_fontname
);
2230 attr
= XVaCreateNestedList (0, XNFontSet
, xfs
, NULL
);
2231 if (FRAME_XIC_STYLE (f
) & XIMPreeditPosition
)
2232 XSetICValues (FRAME_XIC (f
), XNPreeditAttributes
, attr
, NULL
);
2233 if (FRAME_XIC_STYLE (f
) & XIMStatusArea
)
2234 XSetICValues (FRAME_XIC (f
), XNStatusAttributes
, attr
, NULL
);
2237 if (FRAME_XIC_FONTSET (f
))
2238 XFreeFontSet (FRAME_X_DISPLAY (f
), FRAME_XIC_FONTSET (f
));
2239 FRAME_XIC_FONTSET (f
) = xfs
;
2242 #endif /* HAVE_X_I18N */
2246 #ifdef USE_X_TOOLKIT
2248 /* Create and set up the X widget for frame F. */
2251 x_window (f
, window_prompting
, minibuffer_only
)
2253 long window_prompting
;
2254 int minibuffer_only
;
2256 XClassHint class_hints
;
2257 XSetWindowAttributes attributes
;
2258 unsigned long attribute_mask
;
2259 Widget shell_widget
;
2261 Widget frame_widget
;
2267 /* Use the resource name as the top-level widget name
2268 for looking up resources. Make a non-Lisp copy
2269 for the window manager, so GC relocation won't bother it.
2271 Elsewhere we specify the window name for the window manager. */
2274 char *str
= (char *) SDATA (Vx_resource_name
);
2275 f
->namebuf
= (char *) xmalloc (strlen (str
) + 1);
2276 strcpy (f
->namebuf
, str
);
2280 XtSetArg (al
[ac
], XtNallowShellResize
, 1); ac
++;
2281 XtSetArg (al
[ac
], XtNinput
, 1); ac
++;
2282 XtSetArg (al
[ac
], XtNmappedWhenManaged
, 0); ac
++;
2283 XtSetArg (al
[ac
], XtNborderWidth
, f
->border_width
); ac
++;
2284 XtSetArg (al
[ac
], XtNvisual
, FRAME_X_VISUAL (f
)); ac
++;
2285 XtSetArg (al
[ac
], XtNdepth
, FRAME_X_DISPLAY_INFO (f
)->n_planes
); ac
++;
2286 XtSetArg (al
[ac
], XtNcolormap
, FRAME_X_COLORMAP (f
)); ac
++;
2287 shell_widget
= XtAppCreateShell (f
->namebuf
, EMACS_CLASS
,
2288 applicationShellWidgetClass
,
2289 FRAME_X_DISPLAY (f
), al
, ac
);
2291 f
->output_data
.x
->widget
= shell_widget
;
2292 /* maybe_set_screen_title_format (shell_widget); */
2294 pane_widget
= lw_create_widget ("main", "pane", widget_id_tick
++,
2295 (widget_value
*) NULL
,
2296 shell_widget
, False
,
2300 (lw_callback
) NULL
);
2303 XtSetArg (al
[ac
], XtNvisual
, FRAME_X_VISUAL (f
)); ac
++;
2304 XtSetArg (al
[ac
], XtNdepth
, FRAME_X_DISPLAY_INFO (f
)->n_planes
); ac
++;
2305 XtSetArg (al
[ac
], XtNcolormap
, FRAME_X_COLORMAP (f
)); ac
++;
2306 XtSetValues (pane_widget
, al
, ac
);
2307 f
->output_data
.x
->column_widget
= pane_widget
;
2309 /* mappedWhenManaged to false tells to the paned window to not map/unmap
2310 the emacs screen when changing menubar. This reduces flickering. */
2313 XtSetArg (al
[ac
], XtNmappedWhenManaged
, 0); ac
++;
2314 XtSetArg (al
[ac
], XtNshowGrip
, 0); ac
++;
2315 XtSetArg (al
[ac
], XtNallowResize
, 1); ac
++;
2316 XtSetArg (al
[ac
], XtNresizeToPreferred
, 1); ac
++;
2317 XtSetArg (al
[ac
], XtNemacsFrame
, f
); ac
++;
2318 XtSetArg (al
[ac
], XtNvisual
, FRAME_X_VISUAL (f
)); ac
++;
2319 XtSetArg (al
[ac
], XtNdepth
, FRAME_X_DISPLAY_INFO (f
)->n_planes
); ac
++;
2320 XtSetArg (al
[ac
], XtNcolormap
, FRAME_X_COLORMAP (f
)); ac
++;
2321 frame_widget
= XtCreateWidget (f
->namebuf
, emacsFrameClass
, pane_widget
,
2324 f
->output_data
.x
->edit_widget
= frame_widget
;
2326 XtManageChild (frame_widget
);
2328 /* Do some needed geometry management. */
2331 char *tem
, shell_position
[32];
2334 int extra_borders
= 0;
2336 = (f
->output_data
.x
->menubar_widget
2337 ? (f
->output_data
.x
->menubar_widget
->core
.height
2338 + f
->output_data
.x
->menubar_widget
->core
.border_width
)
2341 #if 0 /* Experimentally, we now get the right results
2342 for -geometry -0-0 without this. 24 Aug 96, rms. */
2343 if (FRAME_EXTERNAL_MENU_BAR (f
))
2346 XtVaGetValues (pane_widget
, XtNinternalBorderWidth
, &ibw
, NULL
);
2347 menubar_size
+= ibw
;
2351 f
->output_data
.x
->menubar_height
= menubar_size
;
2354 /* Motif seems to need this amount added to the sizes
2355 specified for the shell widget. The Athena/Lucid widgets don't.
2356 Both conclusions reached experimentally. -- rms. */
2357 XtVaGetValues (f
->output_data
.x
->edit_widget
, XtNinternalBorderWidth
,
2358 &extra_borders
, NULL
);
2362 /* Convert our geometry parameters into a geometry string
2364 Note that we do not specify here whether the position
2365 is a user-specified or program-specified one.
2366 We pass that information later, in x_wm_set_size_hints. */
2368 int left
= f
->left_pos
;
2369 int xneg
= window_prompting
& XNegative
;
2370 int top
= f
->top_pos
;
2371 int yneg
= window_prompting
& YNegative
;
2377 if (window_prompting
& USPosition
)
2378 sprintf (shell_position
, "=%dx%d%c%d%c%d",
2379 FRAME_PIXEL_WIDTH (f
) + extra_borders
,
2380 FRAME_PIXEL_HEIGHT (f
) + menubar_size
+ extra_borders
,
2381 (xneg
? '-' : '+'), left
,
2382 (yneg
? '-' : '+'), top
);
2385 sprintf (shell_position
, "=%dx%d",
2386 FRAME_PIXEL_WIDTH (f
) + extra_borders
,
2387 FRAME_PIXEL_HEIGHT (f
) + menubar_size
+ extra_borders
);
2389 /* Setting x and y when the position is not specified in
2390 the geometry string will set program position in the WM hints.
2391 If Emacs had just one program position, we could set it in
2392 fallback resources, but since each make-frame call can specify
2393 different program positions, this is easier. */
2394 XtSetArg (al
[ac
], XtNx
, left
); ac
++;
2395 XtSetArg (al
[ac
], XtNy
, top
); ac
++;
2399 len
= strlen (shell_position
) + 1;
2400 /* We don't free this because we don't know whether
2401 it is safe to free it while the frame exists.
2402 It isn't worth the trouble of arranging to free it
2403 when the frame is deleted. */
2404 tem
= (char *) xmalloc (len
);
2405 strncpy (tem
, shell_position
, len
);
2406 XtSetArg (al
[ac
], XtNgeometry
, tem
); ac
++;
2407 XtSetValues (shell_widget
, al
, ac
);
2410 XtManageChild (pane_widget
);
2411 XtRealizeWidget (shell_widget
);
2413 FRAME_X_WINDOW (f
) = XtWindow (frame_widget
);
2415 validate_x_resource_name ();
2417 class_hints
.res_name
= (char *) SDATA (Vx_resource_name
);
2418 class_hints
.res_class
= (char *) SDATA (Vx_resource_class
);
2419 XSetClassHint (FRAME_X_DISPLAY (f
), XtWindow (shell_widget
), &class_hints
);
2422 FRAME_XIC (f
) = NULL
;
2424 create_frame_xic (f
);
2427 f
->output_data
.x
->wm_hints
.input
= True
;
2428 f
->output_data
.x
->wm_hints
.flags
|= InputHint
;
2429 XSetWMHints (FRAME_X_DISPLAY (f
), FRAME_X_WINDOW (f
),
2430 &f
->output_data
.x
->wm_hints
);
2432 hack_wm_protocols (f
, shell_widget
);
2435 XtAddEventHandler (shell_widget
, 0, True
, _XEditResCheckMessages
, 0);
2438 /* Do a stupid property change to force the server to generate a
2439 PropertyNotify event so that the event_stream server timestamp will
2440 be initialized to something relevant to the time we created the window.
2442 XChangeProperty (XtDisplay (frame_widget
), XtWindow (frame_widget
),
2443 FRAME_X_DISPLAY_INFO (f
)->Xatom_wm_protocols
,
2444 XA_ATOM
, 32, PropModeAppend
,
2445 (unsigned char*) NULL
, 0);
2447 /* Make all the standard events reach the Emacs frame. */
2448 attributes
.event_mask
= STANDARD_EVENT_SET
;
2453 /* XIM server might require some X events. */
2454 unsigned long fevent
= NoEventMask
;
2455 XGetICValues (FRAME_XIC (f
), XNFilterEvents
, &fevent
, NULL
);
2456 attributes
.event_mask
|= fevent
;
2458 #endif /* HAVE_X_I18N */
2460 attribute_mask
= CWEventMask
;
2461 XChangeWindowAttributes (XtDisplay (shell_widget
), XtWindow (shell_widget
),
2462 attribute_mask
, &attributes
);
2464 XtMapWidget (frame_widget
);
2466 /* x_set_name normally ignores requests to set the name if the
2467 requested name is the same as the current name. This is the one
2468 place where that assumption isn't correct; f->name is set, but
2469 the X server hasn't been told. */
2472 int explicit = f
->explicit_name
;
2474 f
->explicit_name
= 0;
2477 x_set_name (f
, name
, explicit);
2480 XDefineCursor (FRAME_X_DISPLAY (f
), FRAME_X_WINDOW (f
),
2481 f
->output_data
.x
->text_cursor
);
2485 /* This is a no-op, except under Motif. Make sure main areas are
2486 set to something reasonable, in case we get an error later. */
2487 lw_set_main_areas (pane_widget
, 0, frame_widget
);
2490 #else /* not USE_X_TOOLKIT */
2496 if (! xg_create_frame_widgets (f
))
2497 error ("Unable to create window");
2500 FRAME_XIC (f
) = NULL
;
2504 create_frame_xic (f
);
2507 /* XIM server might require some X events. */
2508 unsigned long fevent
= NoEventMask
;
2509 XGetICValues (FRAME_XIC (f
), XNFilterEvents
, &fevent
, NULL
);
2511 if (fevent
!= NoEventMask
)
2513 XSetWindowAttributes attributes
;
2514 XWindowAttributes wattr
;
2515 unsigned long attribute_mask
;
2517 XGetWindowAttributes (FRAME_X_DISPLAY (f
), FRAME_X_WINDOW (f
),
2519 attributes
.event_mask
= wattr
.your_event_mask
| fevent
;
2520 attribute_mask
= CWEventMask
;
2521 XChangeWindowAttributes (FRAME_X_DISPLAY (f
), FRAME_X_WINDOW (f
),
2522 attribute_mask
, &attributes
);
2530 #else /*! USE_GTK */
2531 /* Create and set up the X window for frame F. */
2538 XClassHint class_hints
;
2539 XSetWindowAttributes attributes
;
2540 unsigned long attribute_mask
;
2542 attributes
.background_pixel
= f
->output_data
.x
->background_pixel
;
2543 attributes
.border_pixel
= f
->output_data
.x
->border_pixel
;
2544 attributes
.bit_gravity
= StaticGravity
;
2545 attributes
.backing_store
= NotUseful
;
2546 attributes
.save_under
= True
;
2547 attributes
.event_mask
= STANDARD_EVENT_SET
;
2548 attributes
.colormap
= FRAME_X_COLORMAP (f
);
2549 attribute_mask
= (CWBackPixel
| CWBorderPixel
| CWBitGravity
| CWEventMask
2554 = XCreateWindow (FRAME_X_DISPLAY (f
),
2555 f
->output_data
.x
->parent_desc
,
2558 FRAME_PIXEL_WIDTH (f
), FRAME_PIXEL_HEIGHT (f
),
2560 CopyFromParent
, /* depth */
2561 InputOutput
, /* class */
2563 attribute_mask
, &attributes
);
2568 create_frame_xic (f
);
2571 /* XIM server might require some X events. */
2572 unsigned long fevent
= NoEventMask
;
2573 XGetICValues (FRAME_XIC (f
), XNFilterEvents
, &fevent
, NULL
);
2574 attributes
.event_mask
|= fevent
;
2575 attribute_mask
= CWEventMask
;
2576 XChangeWindowAttributes (FRAME_X_DISPLAY (f
), FRAME_X_WINDOW (f
),
2577 attribute_mask
, &attributes
);
2580 #endif /* HAVE_X_I18N */
2582 validate_x_resource_name ();
2584 class_hints
.res_name
= (char *) SDATA (Vx_resource_name
);
2585 class_hints
.res_class
= (char *) SDATA (Vx_resource_class
);
2586 XSetClassHint (FRAME_X_DISPLAY (f
), FRAME_X_WINDOW (f
), &class_hints
);
2588 /* The menubar is part of the ordinary display;
2589 it does not count in addition to the height of the window. */
2590 f
->output_data
.x
->menubar_height
= 0;
2592 /* This indicates that we use the "Passive Input" input model.
2593 Unless we do this, we don't get the Focus{In,Out} events that we
2594 need to draw the cursor correctly. Accursed bureaucrats.
2595 XWhipsAndChains (FRAME_X_DISPLAY (f), IronMaiden, &TheRack); */
2597 f
->output_data
.x
->wm_hints
.input
= True
;
2598 f
->output_data
.x
->wm_hints
.flags
|= InputHint
;
2599 XSetWMHints (FRAME_X_DISPLAY (f
), FRAME_X_WINDOW (f
),
2600 &f
->output_data
.x
->wm_hints
);
2601 f
->output_data
.x
->wm_hints
.icon_pixmap
= None
;
2603 /* Request "save yourself" and "delete window" commands from wm. */
2606 protocols
[0] = FRAME_X_DISPLAY_INFO (f
)->Xatom_wm_delete_window
;
2607 protocols
[1] = FRAME_X_DISPLAY_INFO (f
)->Xatom_wm_save_yourself
;
2608 XSetWMProtocols (FRAME_X_DISPLAY (f
), FRAME_X_WINDOW (f
), protocols
, 2);
2611 /* x_set_name normally ignores requests to set the name if the
2612 requested name is the same as the current name. This is the one
2613 place where that assumption isn't correct; f->name is set, but
2614 the X server hasn't been told. */
2617 int explicit = f
->explicit_name
;
2619 f
->explicit_name
= 0;
2622 x_set_name (f
, name
, explicit);
2625 XDefineCursor (FRAME_X_DISPLAY (f
), FRAME_X_WINDOW (f
),
2626 f
->output_data
.x
->text_cursor
);
2630 if (FRAME_X_WINDOW (f
) == 0)
2631 error ("Unable to create window");
2634 #endif /* not USE_GTK */
2635 #endif /* not USE_X_TOOLKIT */
2637 /* Handle the icon stuff for this window. Perhaps later we might
2638 want an x_set_icon_position which can be called interactively as
2646 Lisp_Object icon_x
, icon_y
;
2647 struct x_display_info
*dpyinfo
= FRAME_X_DISPLAY_INFO (f
);
2649 /* Set the position of the icon. Note that twm groups all
2650 icons in an icon window. */
2651 icon_x
= x_frame_get_and_record_arg (f
, parms
, Qicon_left
, 0, 0, RES_TYPE_NUMBER
);
2652 icon_y
= x_frame_get_and_record_arg (f
, parms
, Qicon_top
, 0, 0, RES_TYPE_NUMBER
);
2653 if (!EQ (icon_x
, Qunbound
) && !EQ (icon_y
, Qunbound
))
2655 CHECK_NUMBER (icon_x
);
2656 CHECK_NUMBER (icon_y
);
2658 else if (!EQ (icon_x
, Qunbound
) || !EQ (icon_y
, Qunbound
))
2659 error ("Both left and top icon corners of icon must be specified");
2663 if (! EQ (icon_x
, Qunbound
))
2664 x_wm_set_icon_position (f
, XINT (icon_x
), XINT (icon_y
));
2666 /* Start up iconic or window? */
2667 x_wm_set_window_state
2668 (f
, (EQ (x_get_arg (dpyinfo
, parms
, Qvisibility
, 0, 0, RES_TYPE_SYMBOL
),
2673 x_text_icon (f
, (char *) SDATA ((!NILP (f
->icon_name
)
2680 /* Make the GCs needed for this window, setting the
2681 background, border and mouse colors; also create the
2682 mouse cursor and the gray border tile. */
2684 static char cursor_bits
[] =
2686 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2687 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2688 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2689 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
2696 XGCValues gc_values
;
2700 /* Create the GCs of this frame.
2701 Note that many default values are used. */
2704 gc_values
.font
= FRAME_FONT (f
)->fid
;
2705 gc_values
.foreground
= f
->output_data
.x
->foreground_pixel
;
2706 gc_values
.background
= f
->output_data
.x
->background_pixel
;
2707 gc_values
.line_width
= 0; /* Means 1 using fast algorithm. */
2708 f
->output_data
.x
->normal_gc
2709 = XCreateGC (FRAME_X_DISPLAY (f
),
2711 GCLineWidth
| GCFont
| GCForeground
| GCBackground
,
2714 /* Reverse video style. */
2715 gc_values
.foreground
= f
->output_data
.x
->background_pixel
;
2716 gc_values
.background
= f
->output_data
.x
->foreground_pixel
;
2717 f
->output_data
.x
->reverse_gc
2718 = XCreateGC (FRAME_X_DISPLAY (f
),
2720 GCFont
| GCForeground
| GCBackground
| GCLineWidth
,
2723 /* Cursor has cursor-color background, background-color foreground. */
2724 gc_values
.foreground
= f
->output_data
.x
->background_pixel
;
2725 gc_values
.background
= f
->output_data
.x
->cursor_pixel
;
2726 gc_values
.fill_style
= FillOpaqueStippled
;
2728 = XCreateBitmapFromData (FRAME_X_DISPLAY (f
),
2729 FRAME_X_DISPLAY_INFO (f
)->root_window
,
2730 cursor_bits
, 16, 16);
2731 f
->output_data
.x
->cursor_gc
2732 = XCreateGC (FRAME_X_DISPLAY (f
), FRAME_X_WINDOW (f
),
2733 (GCFont
| GCForeground
| GCBackground
2734 | GCFillStyle
/* | GCStipple */ | GCLineWidth
),
2738 f
->output_data
.x
->white_relief
.gc
= 0;
2739 f
->output_data
.x
->black_relief
.gc
= 0;
2741 /* Create the gray border tile used when the pointer is not in
2742 the frame. Since this depends on the frame's pixel values,
2743 this must be done on a per-frame basis. */
2744 f
->output_data
.x
->border_tile
2745 = (XCreatePixmapFromBitmapData
2746 (FRAME_X_DISPLAY (f
), FRAME_X_DISPLAY_INFO (f
)->root_window
,
2747 gray_bits
, gray_width
, gray_height
,
2748 f
->output_data
.x
->foreground_pixel
,
2749 f
->output_data
.x
->background_pixel
,
2750 DefaultDepth (FRAME_X_DISPLAY (f
), FRAME_X_SCREEN_NUMBER (f
))));
2756 /* Free what was was allocated in x_make_gc. */
2762 Display
*dpy
= FRAME_X_DISPLAY (f
);
2766 if (f
->output_data
.x
->normal_gc
)
2768 XFreeGC (dpy
, f
->output_data
.x
->normal_gc
);
2769 f
->output_data
.x
->normal_gc
= 0;
2772 if (f
->output_data
.x
->reverse_gc
)
2774 XFreeGC (dpy
, f
->output_data
.x
->reverse_gc
);
2775 f
->output_data
.x
->reverse_gc
= 0;
2778 if (f
->output_data
.x
->cursor_gc
)
2780 XFreeGC (dpy
, f
->output_data
.x
->cursor_gc
);
2781 f
->output_data
.x
->cursor_gc
= 0;
2784 if (f
->output_data
.x
->border_tile
)
2786 XFreePixmap (dpy
, f
->output_data
.x
->border_tile
);
2787 f
->output_data
.x
->border_tile
= 0;
2794 /* Handler for signals raised during x_create_frame and
2795 x_create_top_frame. FRAME is the frame which is partially
2799 unwind_create_frame (frame
)
2802 struct frame
*f
= XFRAME (frame
);
2804 /* If frame is ``official'', nothing to do. */
2805 if (!CONSP (Vframe_list
) || !EQ (XCAR (Vframe_list
), frame
))
2808 struct x_display_info
*dpyinfo
= FRAME_X_DISPLAY_INFO (f
);
2811 x_free_frame_resources (f
);
2813 /* Check that reference counts are indeed correct. */
2814 xassert (dpyinfo
->reference_count
== dpyinfo_refcount
);
2815 xassert (dpyinfo
->image_cache
->refcount
== image_cache_refcount
);
2823 DEFUN ("x-create-frame", Fx_create_frame
, Sx_create_frame
,
2825 doc
: /* Make a new X window, which is called a "frame" in Emacs terms.
2826 Returns an Emacs frame object.
2827 ALIST is an alist of frame parameters.
2828 If the parameters specify that the frame should not have a minibuffer,
2829 and do not specify a specific minibuffer window to use,
2830 then `default-minibuffer-frame' must be a frame whose minibuffer can
2831 be shared by the new frame.
2833 This function is an internal primitive--use `make-frame' instead. */)
2838 Lisp_Object frame
, tem
;
2840 int minibuffer_only
= 0;
2841 long window_prompting
= 0;
2843 int count
= SPECPDL_INDEX ();
2844 struct gcpro gcpro1
, gcpro2
, gcpro3
, gcpro4
;
2845 Lisp_Object display
;
2846 struct x_display_info
*dpyinfo
= NULL
;
2850 /* Use this general default value to start with
2851 until we know if this frame has a specified name. */
2852 Vx_resource_name
= Vinvocation_name
;
2854 display
= x_get_arg (dpyinfo
, parms
, Qdisplay
, 0, 0, RES_TYPE_STRING
);
2855 if (EQ (display
, Qunbound
))
2857 dpyinfo
= check_x_display_info (display
);
2859 kb
= dpyinfo
->kboard
;
2861 kb
= &the_only_kboard
;
2864 name
= x_get_arg (dpyinfo
, parms
, Qname
, "name", "Name", RES_TYPE_STRING
);
2866 && ! EQ (name
, Qunbound
)
2868 error ("Invalid frame name--not a string or nil");
2871 Vx_resource_name
= name
;
2873 /* See if parent window is specified. */
2874 parent
= x_get_arg (dpyinfo
, parms
, Qparent_id
, NULL
, NULL
, RES_TYPE_NUMBER
);
2875 if (EQ (parent
, Qunbound
))
2877 if (! NILP (parent
))
2878 CHECK_NUMBER (parent
);
2880 /* make_frame_without_minibuffer can run Lisp code and garbage collect. */
2881 /* No need to protect DISPLAY because that's not used after passing
2882 it to make_frame_without_minibuffer. */
2884 GCPRO4 (parms
, parent
, name
, frame
);
2885 tem
= x_get_arg (dpyinfo
, parms
, Qminibuffer
, "minibuffer", "Minibuffer",
2887 if (EQ (tem
, Qnone
) || NILP (tem
))
2888 f
= make_frame_without_minibuffer (Qnil
, kb
, display
);
2889 else if (EQ (tem
, Qonly
))
2891 f
= make_minibuffer_frame ();
2892 minibuffer_only
= 1;
2894 else if (WINDOWP (tem
))
2895 f
= make_frame_without_minibuffer (tem
, kb
, display
);
2899 XSETFRAME (frame
, f
);
2901 /* Note that X Windows does support scroll bars. */
2902 FRAME_CAN_HAVE_SCROLL_BARS (f
) = 1;
2904 f
->display
= dpyinfo
->frame_display
;
2905 f
->display
->reference_count
++;
2907 f
->output_method
= output_x_window
;
2908 f
->output_data
.x
= (struct x_output
*) xmalloc (sizeof (struct x_output
));
2909 bzero (f
->output_data
.x
, sizeof (struct x_output
));
2910 f
->output_data
.x
->icon_bitmap
= -1;
2911 FRAME_FONTSET (f
) = -1;
2912 f
->output_data
.x
->scroll_bar_foreground_pixel
= -1;
2913 f
->output_data
.x
->scroll_bar_background_pixel
= -1;
2914 #ifdef USE_TOOLKIT_SCROLL_BARS
2915 f
->output_data
.x
->scroll_bar_top_shadow_pixel
= -1;
2916 f
->output_data
.x
->scroll_bar_bottom_shadow_pixel
= -1;
2917 #endif /* USE_TOOLKIT_SCROLL_BARS */
2918 record_unwind_protect (unwind_create_frame
, frame
);
2921 = x_get_arg (dpyinfo
, parms
, Qicon_name
, "iconName", "Title",
2923 if (! STRINGP (f
->icon_name
))
2924 f
->icon_name
= Qnil
;
2926 FRAME_X_DISPLAY_INFO (f
) = dpyinfo
;
2928 image_cache_refcount
= FRAME_X_IMAGE_CACHE (f
)->refcount
;
2929 dpyinfo_refcount
= dpyinfo
->reference_count
;
2930 #endif /* GLYPH_DEBUG */
2932 FRAME_KBOARD (f
) = kb
;
2935 /* These colors will be set anyway later, but it's important
2936 to get the color reference counts right, so initialize them! */
2939 struct gcpro gcpro1
;
2941 /* Function x_decode_color can signal an error. Make
2942 sure to initialize color slots so that we won't try
2943 to free colors we haven't allocated. */
2944 f
->output_data
.x
->foreground_pixel
= -1;
2945 f
->output_data
.x
->background_pixel
= -1;
2946 f
->output_data
.x
->cursor_pixel
= -1;
2947 f
->output_data
.x
->cursor_foreground_pixel
= -1;
2948 f
->output_data
.x
->border_pixel
= -1;
2949 f
->output_data
.x
->mouse_pixel
= -1;
2951 black
= build_string ("black");
2953 f
->output_data
.x
->foreground_pixel
2954 = x_decode_color (f
, black
, BLACK_PIX_DEFAULT (f
));
2955 f
->output_data
.x
->background_pixel
2956 = x_decode_color (f
, black
, BLACK_PIX_DEFAULT (f
));
2957 f
->output_data
.x
->cursor_pixel
2958 = x_decode_color (f
, black
, BLACK_PIX_DEFAULT (f
));
2959 f
->output_data
.x
->cursor_foreground_pixel
2960 = x_decode_color (f
, black
, BLACK_PIX_DEFAULT (f
));
2961 f
->output_data
.x
->border_pixel
2962 = x_decode_color (f
, black
, BLACK_PIX_DEFAULT (f
));
2963 f
->output_data
.x
->mouse_pixel
2964 = x_decode_color (f
, black
, BLACK_PIX_DEFAULT (f
));
2968 /* Specify the parent under which to make this X window. */
2972 f
->output_data
.x
->parent_desc
= (Window
) XFASTINT (parent
);
2973 f
->output_data
.x
->explicit_parent
= 1;
2977 f
->output_data
.x
->parent_desc
= FRAME_X_DISPLAY_INFO (f
)->root_window
;
2978 f
->output_data
.x
->explicit_parent
= 0;
2981 /* Set the name; the functions to which we pass f expect the name to
2983 if (EQ (name
, Qunbound
) || NILP (name
))
2985 f
->name
= build_string (dpyinfo
->x_id_name
);
2986 f
->explicit_name
= 0;
2991 f
->explicit_name
= 1;
2992 /* use the frame's title when getting resources for this frame. */
2993 specbind (Qx_resource_name
, name
);
2996 Fmodify_frame_parameters (frame
, Fcons (Fcons (Qwindow_system
, Qx
), Qnil
));
2998 /* Extract the window parameters from the supplied values
2999 that are needed to determine window geometry. */
3003 font
= x_get_arg (dpyinfo
, parms
, Qfont
, "font", "Font", RES_TYPE_STRING
);
3006 /* First, try whatever font the caller has specified. */
3009 tem
= Fquery_fontset (font
, Qnil
);
3011 font
= x_new_fontset (f
, SDATA (tem
));
3013 font
= x_new_font (f
, SDATA (font
));
3016 /* Try out a font which we hope has bold and italic variations. */
3017 if (!STRINGP (font
))
3018 font
= x_new_font (f
, "-adobe-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-1");
3019 if (!STRINGP (font
))
3020 font
= x_new_font (f
, "-misc-fixed-medium-r-normal-*-*-140-*-*-c-*-iso8859-1");
3021 if (! STRINGP (font
))
3022 font
= x_new_font (f
, "-*-*-medium-r-normal-*-*-140-*-*-c-*-iso8859-1");
3023 if (! STRINGP (font
))
3024 /* This was formerly the first thing tried, but it finds too many fonts
3025 and takes too long. */
3026 font
= x_new_font (f
, "-*-*-medium-r-*-*-*-*-*-*-c-*-iso8859-1");
3027 /* If those didn't work, look for something which will at least work. */
3028 if (! STRINGP (font
))
3029 font
= x_new_font (f
, "-*-fixed-*-*-*-*-*-140-*-*-c-*-iso8859-1");
3031 if (! STRINGP (font
))
3032 font
= build_string ("fixed");
3034 x_default_parameter (f
, parms
, Qfont
, font
,
3035 "font", "Font", RES_TYPE_STRING
);
3039 /* Prevent lwlib/xlwmenu.c from crashing because of a bug
3040 whereby it fails to get any font. */
3041 xlwmenu_default_font
= FRAME_FONT (f
);
3044 x_default_parameter (f
, parms
, Qborder_width
, make_number (2),
3045 "borderWidth", "BorderWidth", RES_TYPE_NUMBER
);
3047 /* This defaults to 1 in order to match xterm. We recognize either
3048 internalBorderWidth or internalBorder (which is what xterm calls
3050 if (NILP (Fassq (Qinternal_border_width
, parms
)))
3054 value
= x_get_arg (dpyinfo
, parms
, Qinternal_border_width
,
3055 "internalBorder", "internalBorder", RES_TYPE_NUMBER
);
3056 if (! EQ (value
, Qunbound
))
3057 parms
= Fcons (Fcons (Qinternal_border_width
, value
),
3060 x_default_parameter (f
, parms
, Qinternal_border_width
, make_number (1),
3061 "internalBorderWidth", "internalBorderWidth",
3063 x_default_parameter (f
, parms
, Qvertical_scroll_bars
, Qleft
,
3064 "verticalScrollBars", "ScrollBars",
3067 /* Also do the stuff which must be set before the window exists. */
3068 x_default_parameter (f
, parms
, Qforeground_color
, build_string ("black"),
3069 "foreground", "Foreground", RES_TYPE_STRING
);
3070 x_default_parameter (f
, parms
, Qbackground_color
, build_string ("white"),
3071 "background", "Background", RES_TYPE_STRING
);
3072 x_default_parameter (f
, parms
, Qmouse_color
, build_string ("black"),
3073 "pointerColor", "Foreground", RES_TYPE_STRING
);
3074 x_default_parameter (f
, parms
, Qcursor_color
, build_string ("black"),
3075 "cursorColor", "Foreground", RES_TYPE_STRING
);
3076 x_default_parameter (f
, parms
, Qborder_color
, build_string ("black"),
3077 "borderColor", "BorderColor", RES_TYPE_STRING
);
3078 x_default_parameter (f
, parms
, Qscreen_gamma
, Qnil
,
3079 "screenGamma", "ScreenGamma", RES_TYPE_FLOAT
);
3080 x_default_parameter (f
, parms
, Qline_spacing
, Qnil
,
3081 "lineSpacing", "LineSpacing", RES_TYPE_NUMBER
);
3082 x_default_parameter (f
, parms
, Qleft_fringe
, Qnil
,
3083 "leftFringe", "LeftFringe", RES_TYPE_NUMBER
);
3084 x_default_parameter (f
, parms
, Qright_fringe
, Qnil
,
3085 "rightFringe", "RightFringe", RES_TYPE_NUMBER
);
3087 x_default_scroll_bar_color_parameter (f
, parms
, Qscroll_bar_foreground
,
3088 "scrollBarForeground",
3089 "ScrollBarForeground", 1);
3090 x_default_scroll_bar_color_parameter (f
, parms
, Qscroll_bar_background
,
3091 "scrollBarBackground",
3092 "ScrollBarBackground", 0);
3094 /* Init faces before x_default_parameter is called for scroll-bar
3095 parameters because that function calls x_set_scroll_bar_width,
3096 which calls change_frame_size, which calls Fset_window_buffer,
3097 which runs hooks, which call Fvertical_motion. At the end, we
3098 end up in init_iterator with a null face cache, which should not
3100 init_frame_faces (f
);
3102 x_default_parameter (f
, parms
, Qmenu_bar_lines
, make_number (1),
3103 "menuBar", "MenuBar", RES_TYPE_NUMBER
);
3104 x_default_parameter (f
, parms
, Qtool_bar_lines
, make_number (1),
3105 "toolBar", "ToolBar", RES_TYPE_NUMBER
);
3106 x_default_parameter (f
, parms
, Qbuffer_predicate
, Qnil
,
3107 "bufferPredicate", "BufferPredicate",
3109 x_default_parameter (f
, parms
, Qtitle
, Qnil
,
3110 "title", "Title", RES_TYPE_STRING
);
3111 x_default_parameter (f
, parms
, Qwait_for_wm
, Qt
,
3112 "waitForWM", "WaitForWM", RES_TYPE_BOOLEAN
);
3113 x_default_parameter (f
, parms
, Qfullscreen
, Qnil
,
3114 "fullscreen", "Fullscreen", RES_TYPE_SYMBOL
);
3116 f
->output_data
.x
->parent_desc
= FRAME_X_DISPLAY_INFO (f
)->root_window
;
3118 /* Compute the size of the X window. */
3119 window_prompting
= x_figure_window_size (f
, parms
, 1);
3121 tem
= x_get_arg (dpyinfo
, parms
, Qunsplittable
, 0, 0, RES_TYPE_BOOLEAN
);
3122 f
->no_split
= minibuffer_only
|| EQ (tem
, Qt
);
3124 /* Create the X widget or window. */
3125 #ifdef USE_X_TOOLKIT
3126 x_window (f
, window_prompting
, minibuffer_only
);
3134 /* Now consider the frame official. */
3135 FRAME_X_DISPLAY_INFO (f
)->reference_count
++;
3136 Vframe_list
= Fcons (frame
, Vframe_list
);
3138 /* We need to do this after creating the X window, so that the
3139 icon-creation functions can say whose icon they're describing. */
3140 x_default_parameter (f
, parms
, Qicon_type
, Qnil
,
3141 "bitmapIcon", "BitmapIcon", RES_TYPE_SYMBOL
);
3143 x_default_parameter (f
, parms
, Qauto_raise
, Qnil
,
3144 "autoRaise", "AutoRaiseLower", RES_TYPE_BOOLEAN
);
3145 x_default_parameter (f
, parms
, Qauto_lower
, Qnil
,
3146 "autoLower", "AutoRaiseLower", RES_TYPE_BOOLEAN
);
3147 x_default_parameter (f
, parms
, Qcursor_type
, Qbox
,
3148 "cursorType", "CursorType", RES_TYPE_SYMBOL
);
3149 x_default_parameter (f
, parms
, Qscroll_bar_width
, Qnil
,
3150 "scrollBarWidth", "ScrollBarWidth",
3153 /* Dimensions, especially FRAME_LINES (f), must be done via change_frame_size.
3154 Change will not be effected unless different from the current
3156 width
= FRAME_COLS (f
);
3157 height
= FRAME_LINES (f
);
3159 SET_FRAME_COLS (f
, 0);
3160 FRAME_LINES (f
) = 0;
3161 change_frame_size (f
, height
, width
, 1, 0, 0);
3163 #if defined (USE_X_TOOLKIT) || defined (USE_GTK)
3164 /* Create the menu bar. */
3165 if (!minibuffer_only
&& FRAME_EXTERNAL_MENU_BAR (f
))
3167 /* If this signals an error, we haven't set size hints for the
3168 frame and we didn't make it visible. */
3169 initialize_frame_menubar (f
);
3172 /* This is a no-op, except under Motif where it arranges the
3173 main window for the widgets on it. */
3174 lw_set_main_areas (f
->output_data
.x
->column_widget
,
3175 f
->output_data
.x
->menubar_widget
,
3176 f
->output_data
.x
->edit_widget
);
3177 #endif /* not USE_GTK */
3179 #endif /* USE_X_TOOLKIT || USE_GTK */
3181 /* Tell the server what size and position, etc, we want, and how
3182 badly we want them. This should be done after we have the menu
3183 bar so that its size can be taken into account. */
3185 x_wm_set_size_hint (f
, window_prompting
, 0);
3188 /* Make the window appear on the frame and enable display, unless
3189 the caller says not to. However, with explicit parent, Emacs
3190 cannot control visibility, so don't try. */
3191 if (! f
->output_data
.x
->explicit_parent
)
3193 Lisp_Object visibility
;
3195 visibility
= x_get_arg (dpyinfo
, parms
, Qvisibility
, 0, 0,
3197 if (EQ (visibility
, Qunbound
))
3200 if (EQ (visibility
, Qicon
))
3201 x_iconify_frame (f
);
3202 else if (! NILP (visibility
))
3203 x_make_frame_visible (f
);
3205 /* Must have been Qnil. */
3209 /* Set the WM leader property. GTK does this itself, so this is not
3210 needed when using GTK. */
3211 if (dpyinfo
->client_leader_window
!= 0)
3214 XChangeProperty (FRAME_X_DISPLAY (f
),
3215 FRAME_OUTER_WINDOW (f
),
3216 dpyinfo
->Xatom_wm_client_leader
,
3217 XA_WINDOW
, 32, PropModeReplace
,
3218 (char *) &dpyinfo
->client_leader_window
, 1);
3224 /* Make sure windows on this frame appear in calls to next-window
3225 and similar functions. */
3226 Vwindow_list
= Qnil
;
3228 return unbind_to (count
, frame
);
3232 /* FRAME is used only to get a handle on the X display. We don't pass the
3233 display info directly because we're called from frame.c, which doesn't
3234 know about that structure. */
3237 x_get_focus_frame (frame
)
3238 struct frame
*frame
;
3240 struct x_display_info
*dpyinfo
= FRAME_X_DISPLAY_INFO (frame
);
3242 if (! dpyinfo
->x_focus_frame
)
3245 XSETFRAME (xfocus
, dpyinfo
->x_focus_frame
);
3250 /* In certain situations, when the window manager follows a
3251 click-to-focus policy, there seems to be no way around calling
3252 XSetInputFocus to give another frame the input focus .
3254 In an ideal world, XSetInputFocus should generally be avoided so
3255 that applications don't interfere with the window manager's focus
3256 policy. But I think it's okay to use when it's clearly done
3257 following a user-command. */
3259 DEFUN ("x-focus-frame", Fx_focus_frame
, Sx_focus_frame
, 1, 1, 0,
3260 doc
: /* Set the input focus to FRAME.
3261 FRAME nil means use the selected frame. */)
3265 struct frame
*f
= check_x_frame (frame
);
3266 Display
*dpy
= FRAME_X_DISPLAY (f
);
3270 count
= x_catch_errors (dpy
);
3271 XSetInputFocus (FRAME_X_DISPLAY (f
), FRAME_X_WINDOW (f
),
3272 RevertToParent
, CurrentTime
);
3273 x_uncatch_errors (dpy
, count
);
3280 DEFUN ("xw-color-defined-p", Fxw_color_defined_p
, Sxw_color_defined_p
, 1, 2, 0,
3281 doc
: /* Internal function called by `color-defined-p', which see. */)
3283 Lisp_Object color
, frame
;
3286 FRAME_PTR f
= check_x_frame (frame
);
3288 CHECK_STRING (color
);
3290 if (x_defined_color (f
, SDATA (color
), &foo
, 0))
3296 DEFUN ("xw-color-values", Fxw_color_values
, Sxw_color_values
, 1, 2, 0,
3297 doc
: /* Internal function called by `color-values', which see. */)
3299 Lisp_Object color
, frame
;
3302 FRAME_PTR f
= check_x_frame (frame
);
3304 CHECK_STRING (color
);
3306 if (x_defined_color (f
, SDATA (color
), &foo
, 0))
3310 rgb
[0] = make_number (foo
.red
);
3311 rgb
[1] = make_number (foo
.green
);
3312 rgb
[2] = make_number (foo
.blue
);
3313 return Flist (3, rgb
);
3319 DEFUN ("xw-display-color-p", Fxw_display_color_p
, Sxw_display_color_p
, 0, 1, 0,
3320 doc
: /* Internal function called by `display-color-p', which see. */)
3322 Lisp_Object display
;
3324 struct x_display_info
*dpyinfo
= check_x_display_info (display
);
3326 if (dpyinfo
->n_planes
<= 2)
3329 switch (dpyinfo
->visual
->class)
3342 DEFUN ("x-display-grayscale-p", Fx_display_grayscale_p
, Sx_display_grayscale_p
,
3344 doc
: /* Return t if the X display supports shades of gray.
3345 Note that color displays do support shades of gray.
3346 The optional argument DISPLAY specifies which display to ask about.
3347 DISPLAY should be either a frame or a display name (a string).
3348 If omitted or nil, that stands for the selected frame's display. */)
3350 Lisp_Object display
;
3352 struct x_display_info
*dpyinfo
= check_x_display_info (display
);
3354 if (dpyinfo
->n_planes
<= 1)
3357 switch (dpyinfo
->visual
->class)
3372 DEFUN ("x-display-pixel-width", Fx_display_pixel_width
, Sx_display_pixel_width
,
3374 doc
: /* Returns the width in pixels of the X display DISPLAY.
3375 The optional argument DISPLAY specifies which display to ask about.
3376 DISPLAY should be either a frame or a display name (a string).
3377 If omitted or nil, that stands for the selected frame's display. */)
3379 Lisp_Object display
;
3381 struct x_display_info
*dpyinfo
= check_x_display_info (display
);
3383 return make_number (dpyinfo
->width
);
3386 DEFUN ("x-display-pixel-height", Fx_display_pixel_height
,
3387 Sx_display_pixel_height
, 0, 1, 0,
3388 doc
: /* Returns the height in pixels of the X display DISPLAY.
3389 The optional argument DISPLAY specifies which display to ask about.
3390 DISPLAY should be either a frame or a display name (a string).
3391 If omitted or nil, that stands for the selected frame's display. */)
3393 Lisp_Object display
;
3395 struct x_display_info
*dpyinfo
= check_x_display_info (display
);
3397 return make_number (dpyinfo
->height
);
3400 DEFUN ("x-display-planes", Fx_display_planes
, Sx_display_planes
,
3402 doc
: /* Returns the number of bitplanes of the X display DISPLAY.
3403 The optional argument DISPLAY specifies which display to ask about.
3404 DISPLAY should be either a frame or a display name (a string).
3405 If omitted or nil, that stands for the selected frame's display. */)
3407 Lisp_Object display
;
3409 struct x_display_info
*dpyinfo
= check_x_display_info (display
);
3411 return make_number (dpyinfo
->n_planes
);
3414 DEFUN ("x-display-color-cells", Fx_display_color_cells
, Sx_display_color_cells
,
3416 doc
: /* Returns the number of color cells of the X display DISPLAY.
3417 The optional argument DISPLAY specifies which display to ask about.
3418 DISPLAY should be either a frame or a display name (a string).
3419 If omitted or nil, that stands for the selected frame's display. */)
3421 Lisp_Object display
;
3423 struct x_display_info
*dpyinfo
= check_x_display_info (display
);
3425 int nr_planes
= DisplayPlanes (dpyinfo
->display
,
3426 XScreenNumberOfScreen (dpyinfo
->screen
));
3428 /* Truncate nr_planes to 24 to avoid integer overflow.
3429 Some displays says 32, but only 24 bits are actually significant.
3430 There are only very few and rare video cards that have more than
3431 24 significant bits. Also 24 bits is more than 16 million colors,
3432 it "should be enough for everyone". */
3433 if (nr_planes
> 24) nr_planes
= 24;
3435 return make_number (1 << nr_planes
);
3438 DEFUN ("x-server-max-request-size", Fx_server_max_request_size
,
3439 Sx_server_max_request_size
,
3441 doc
: /* Returns the maximum request size of the X server of display DISPLAY.
3442 The optional argument DISPLAY specifies which display to ask about.
3443 DISPLAY should be either a frame or a display name (a string).
3444 If omitted or nil, that stands for the selected frame's display. */)
3446 Lisp_Object display
;
3448 struct x_display_info
*dpyinfo
= check_x_display_info (display
);
3450 return make_number (MAXREQUEST (dpyinfo
->display
));
3453 DEFUN ("x-server-vendor", Fx_server_vendor
, Sx_server_vendor
, 0, 1, 0,
3454 doc
: /* Returns the vendor ID string of the X server of display DISPLAY.
3455 The optional argument DISPLAY specifies which display to ask about.
3456 DISPLAY should be either a frame or a display name (a string).
3457 If omitted or nil, that stands for the selected frame's display. */)
3459 Lisp_Object display
;
3461 struct x_display_info
*dpyinfo
= check_x_display_info (display
);
3462 char *vendor
= ServerVendor (dpyinfo
->display
);
3464 if (! vendor
) vendor
= "";
3465 return build_string (vendor
);
3468 DEFUN ("x-server-version", Fx_server_version
, Sx_server_version
, 0, 1, 0,
3469 doc
: /* Returns the version numbers of the X server of display DISPLAY.
3470 The value is a list of three integers: the major and minor
3471 version numbers of the X Protocol in use, and the vendor-specific release
3472 number. See also the function `x-server-vendor'.
3474 The optional argument DISPLAY specifies which display to ask about.
3475 DISPLAY should be either a frame or a display name (a string).
3476 If omitted or nil, that stands for the selected frame's display. */)
3478 Lisp_Object display
;
3480 struct x_display_info
*dpyinfo
= check_x_display_info (display
);
3481 Display
*dpy
= dpyinfo
->display
;
3483 return Fcons (make_number (ProtocolVersion (dpy
)),
3484 Fcons (make_number (ProtocolRevision (dpy
)),
3485 Fcons (make_number (VendorRelease (dpy
)), Qnil
)));
3488 DEFUN ("x-display-screens", Fx_display_screens
, Sx_display_screens
, 0, 1, 0,
3489 doc
: /* Return the number of screens on the X server of display DISPLAY.
3490 The optional argument DISPLAY specifies which display to ask about.
3491 DISPLAY should be either a frame or a display name (a string).
3492 If omitted or nil, that stands for the selected frame's display. */)
3494 Lisp_Object display
;
3496 struct x_display_info
*dpyinfo
= check_x_display_info (display
);
3498 return make_number (ScreenCount (dpyinfo
->display
));
3501 DEFUN ("x-display-mm-height", Fx_display_mm_height
, Sx_display_mm_height
, 0, 1, 0,
3502 doc
: /* Return the height in millimeters of the X display DISPLAY.
3503 The optional argument DISPLAY specifies which display to ask about.
3504 DISPLAY should be either a frame or a display name (a string).
3505 If omitted or nil, that stands for the selected frame's display. */)
3507 Lisp_Object display
;
3509 struct x_display_info
*dpyinfo
= check_x_display_info (display
);
3511 return make_number (HeightMMOfScreen (dpyinfo
->screen
));
3514 DEFUN ("x-display-mm-width", Fx_display_mm_width
, Sx_display_mm_width
, 0, 1, 0,
3515 doc
: /* Return the width in millimeters of the X display DISPLAY.
3516 The optional argument DISPLAY specifies which display to ask about.
3517 DISPLAY should be either a frame or a display name (a string).
3518 If omitted or nil, that stands for the selected frame's display. */)
3520 Lisp_Object display
;
3522 struct x_display_info
*dpyinfo
= check_x_display_info (display
);
3524 return make_number (WidthMMOfScreen (dpyinfo
->screen
));
3527 DEFUN ("x-display-backing-store", Fx_display_backing_store
,
3528 Sx_display_backing_store
, 0, 1, 0,
3529 doc
: /* Returns an indication of whether X display DISPLAY does backing store.
3530 The value may be `always', `when-mapped', or `not-useful'.
3531 The optional argument DISPLAY specifies which display to ask about.
3532 DISPLAY should be either a frame or a display name (a string).
3533 If omitted or nil, that stands for the selected frame's display. */)
3535 Lisp_Object display
;
3537 struct x_display_info
*dpyinfo
= check_x_display_info (display
);
3540 switch (DoesBackingStore (dpyinfo
->screen
))
3543 result
= intern ("always");
3547 result
= intern ("when-mapped");
3551 result
= intern ("not-useful");
3555 error ("Strange value for BackingStore parameter of screen");
3562 DEFUN ("x-display-visual-class", Fx_display_visual_class
,
3563 Sx_display_visual_class
, 0, 1, 0,
3564 doc
: /* Return the visual class of the X display DISPLAY.
3565 The value is one of the symbols `static-gray', `gray-scale',
3566 `static-color', `pseudo-color', `true-color', or `direct-color'.
3568 The optional argument DISPLAY specifies which display to ask about.
3569 DISPLAY should be either a frame or a display name (a string).
3570 If omitted or nil, that stands for the selected frame's display. */)
3572 Lisp_Object display
;
3574 struct x_display_info
*dpyinfo
= check_x_display_info (display
);
3577 switch (dpyinfo
->visual
->class)
3580 result
= intern ("static-gray");
3583 result
= intern ("gray-scale");
3586 result
= intern ("static-color");
3589 result
= intern ("pseudo-color");
3592 result
= intern ("true-color");
3595 result
= intern ("direct-color");
3598 error ("Display has an unknown visual class");
3605 DEFUN ("x-display-save-under", Fx_display_save_under
,
3606 Sx_display_save_under
, 0, 1, 0,
3607 doc
: /* Returns t if the X display DISPLAY supports the save-under feature.
3608 The optional argument DISPLAY specifies which display to ask about.
3609 DISPLAY should be either a frame or a display name (a string).
3610 If omitted or nil, that stands for the selected frame's display. */)
3612 Lisp_Object display
;
3614 struct x_display_info
*dpyinfo
= check_x_display_info (display
);
3616 if (DoesSaveUnders (dpyinfo
->screen
) == True
)
3624 register struct frame
*f
;
3626 return FRAME_PIXEL_WIDTH (f
);
3631 register struct frame
*f
;
3633 return FRAME_PIXEL_HEIGHT (f
);
3638 register struct frame
*f
;
3640 return FRAME_COLUMN_WIDTH (f
);
3645 register struct frame
*f
;
3647 return FRAME_LINE_HEIGHT (f
);
3652 register struct frame
*f
;
3654 return FRAME_X_DISPLAY_INFO (f
)->n_planes
;
3659 /************************************************************************
3661 ************************************************************************/
3664 /* Mapping visual names to visuals. */
3666 static struct visual_class
3673 {"StaticGray", StaticGray
},
3674 {"GrayScale", GrayScale
},
3675 {"StaticColor", StaticColor
},
3676 {"PseudoColor", PseudoColor
},
3677 {"TrueColor", TrueColor
},
3678 {"DirectColor", DirectColor
},
3683 #ifndef HAVE_XSCREENNUMBEROFSCREEN
3685 /* Value is the screen number of screen SCR. This is a substitute for
3686 the X function with the same name when that doesn't exist. */
3689 XScreenNumberOfScreen (scr
)
3690 register Screen
*scr
;
3692 Display
*dpy
= scr
->display
;
3695 for (i
= 0; i
< dpy
->nscreens
; ++i
)
3696 if (scr
== dpy
->screens
+ i
)
3702 #endif /* not HAVE_XSCREENNUMBEROFSCREEN */
3705 /* Select the visual that should be used on display DPYINFO. Set
3706 members of DPYINFO appropriately. Called from x_term_init. */
3709 select_visual (dpyinfo
)
3710 struct x_display_info
*dpyinfo
;
3712 Display
*dpy
= dpyinfo
->display
;
3713 Screen
*screen
= dpyinfo
->screen
;
3716 /* See if a visual is specified. */
3717 value
= display_x_get_resource (dpyinfo
,
3718 build_string ("visualClass"),
3719 build_string ("VisualClass"),
3721 if (STRINGP (value
))
3723 /* VALUE should be of the form CLASS-DEPTH, where CLASS is one
3724 of `PseudoColor', `TrueColor' etc. and DEPTH is the color
3725 depth, a decimal number. NAME is compared with case ignored. */
3726 char *s
= (char *) alloca (SBYTES (value
) + 1);
3731 strcpy (s
, SDATA (value
));
3732 dash
= index (s
, '-');
3735 dpyinfo
->n_planes
= atoi (dash
+ 1);
3739 /* We won't find a matching visual with depth 0, so that
3740 an error will be printed below. */
3741 dpyinfo
->n_planes
= 0;
3743 /* Determine the visual class. */
3744 for (i
= 0; visual_classes
[i
].name
; ++i
)
3745 if (xstricmp (s
, visual_classes
[i
].name
) == 0)
3747 class = visual_classes
[i
].class;
3751 /* Look up a matching visual for the specified class. */
3753 || !XMatchVisualInfo (dpy
, XScreenNumberOfScreen (screen
),
3754 dpyinfo
->n_planes
, class, &vinfo
))
3755 fatal ("Invalid visual specification `%s'", SDATA (value
));
3757 dpyinfo
->visual
= vinfo
.visual
;
3762 XVisualInfo
*vinfo
, vinfo_template
;
3764 dpyinfo
->visual
= DefaultVisualOfScreen (screen
);
3767 vinfo_template
.visualid
= XVisualIDFromVisual (dpyinfo
->visual
);
3769 vinfo_template
.visualid
= dpyinfo
->visual
->visualid
;
3771 vinfo_template
.screen
= XScreenNumberOfScreen (screen
);
3772 vinfo
= XGetVisualInfo (dpy
, VisualIDMask
| VisualScreenMask
,
3773 &vinfo_template
, &n_visuals
);
3775 fatal ("Can't get proper X visual info");
3777 dpyinfo
->n_planes
= vinfo
->depth
;
3778 XFree ((char *) vinfo
);
3783 /* Return the X display structure for the display named NAME.
3784 Open a new connection if necessary. */
3786 struct x_display_info
*
3787 x_display_info_for_name (name
)
3791 struct x_display_info
*dpyinfo
;
3793 CHECK_STRING (name
);
3796 if (! EQ (Vinitial_window_system
, intern ("x")))
3797 error ("Not using X Windows"); /* That doesn't stop us anymore. */
3800 for (dpyinfo
= x_display_list
, names
= x_display_name_list
;
3802 dpyinfo
= dpyinfo
->next
, names
= XCDR (names
))
3805 tem
= Fstring_equal (XCAR (XCAR (names
)), name
);
3810 /* Use this general default value to start with. */
3811 Vx_resource_name
= Vinvocation_name
;
3813 validate_x_resource_name ();
3815 dpyinfo
= x_term_init (name
, (char *)0,
3816 (char *) SDATA (Vx_resource_name
));
3819 error ("Cannot connect to X server %s", SDATA (name
));
3822 XSETFASTINT (Vwindow_system_version
, 11);
3828 DEFUN ("x-open-connection", Fx_open_connection
, Sx_open_connection
,
3830 doc
: /* Open a connection to an X server.
3831 DISPLAY is the name of the display to connect to.
3832 Optional second arg XRM-STRING is a string of resources in xrdb format.
3833 If the optional third arg MUST-SUCCEED is non-nil,
3834 terminate Emacs if we can't open the connection. */)
3835 (display
, xrm_string
, must_succeed
)
3836 Lisp_Object display
, xrm_string
, must_succeed
;
3838 unsigned char *xrm_option
;
3839 struct x_display_info
*dpyinfo
;
3841 CHECK_STRING (display
);
3842 if (! NILP (xrm_string
))
3843 CHECK_STRING (xrm_string
);
3846 if (! EQ (Vinitial_window_system
, intern ("x")))
3847 error ("Not using X Windows"); /* That doesn't stop us anymore. */
3850 if (! NILP (xrm_string
))
3851 xrm_option
= (unsigned char *) SDATA (xrm_string
);
3853 xrm_option
= (unsigned char *) 0;
3855 validate_x_resource_name ();
3857 /* This is what opens the connection and sets x_current_display.
3858 This also initializes many symbols, such as those used for input. */
3859 dpyinfo
= x_term_init (display
, xrm_option
,
3860 (char *) SDATA (Vx_resource_name
));
3864 if (!NILP (must_succeed
))
3865 fatal ("Cannot connect to X server %s.\n\
3866 Check the DISPLAY environment variable or use `-d'.\n\
3867 Also use the `xauth' program to verify that you have the proper\n\
3868 authorization information needed to connect the X server.\n\
3869 An insecure way to solve the problem may be to use `xhost'.\n",
3872 error ("Cannot connect to X server %s", SDATA (display
));
3877 XSETFASTINT (Vwindow_system_version
, 11);
3881 DEFUN ("x-close-connection", Fx_close_connection
,
3882 Sx_close_connection
, 1, 1, 0,
3883 doc
: /* Close the connection to DISPLAY's X server.
3884 For DISPLAY, specify either a frame or a display name (a string).
3885 If DISPLAY is nil, that stands for the selected frame's display. */)
3887 Lisp_Object display
;
3889 struct x_display_info
*dpyinfo
= check_x_display_info (display
);
3892 if (dpyinfo
->reference_count
> 0)
3893 error ("Display still has frames on it");
3896 /* Free the fonts in the font table. */
3897 for (i
= 0; i
< dpyinfo
->n_fonts
; i
++)
3898 if (dpyinfo
->font_table
[i
].name
)
3900 XFreeFont (dpyinfo
->display
, dpyinfo
->font_table
[i
].font
);
3903 x_destroy_all_bitmaps (dpyinfo
);
3904 XSetCloseDownMode (dpyinfo
->display
, DestroyAll
);
3906 #ifdef USE_X_TOOLKIT
3907 XtCloseDisplay (dpyinfo
->display
);
3909 XCloseDisplay (dpyinfo
->display
);
3912 x_delete_display (dpyinfo
);
3918 DEFUN ("x-display-list", Fx_display_list
, Sx_display_list
, 0, 0, 0,
3919 doc
: /* Return the list of display names that Emacs has connections to. */)
3922 Lisp_Object tail
, result
;
3925 for (tail
= x_display_name_list
; ! NILP (tail
); tail
= XCDR (tail
))
3926 result
= Fcons (XCAR (XCAR (tail
)), result
);
3931 DEFUN ("x-synchronize", Fx_synchronize
, Sx_synchronize
, 1, 2, 0,
3932 doc
: /* If ON is non-nil, report X errors as soon as the erring request is made.
3933 If ON is nil, allow buffering of requests.
3934 Turning on synchronization prohibits the Xlib routines from buffering
3935 requests and seriously degrades performance, but makes debugging much
3937 The optional second argument DISPLAY specifies which display to act on.
3938 DISPLAY should be either a frame or a display name (a string).
3939 If DISPLAY is omitted or nil, that stands for the selected frame's display. */)
3941 Lisp_Object display
, on
;
3943 struct x_display_info
*dpyinfo
= check_x_display_info (display
);
3945 XSynchronize (dpyinfo
->display
, !EQ (on
, Qnil
));
3950 /* Wait for responses to all X commands issued so far for frame F. */
3957 XSync (FRAME_X_DISPLAY (f
), False
);
3962 /***********************************************************************
3964 ***********************************************************************/
3966 DEFUN ("x-change-window-property", Fx_change_window_property
,
3967 Sx_change_window_property
, 2, 6, 0,
3968 doc
: /* Change window property PROP to VALUE on the X window of FRAME.
3969 PROP must be a string.
3970 VALUE may be a string or a list of conses, numbers and/or strings.
3971 If an element in the list is a string, it is converted to
3972 an Atom and the value of the Atom is used. If an element is a cons,
3973 it is converted to a 32 bit number where the car is the 16 top bits and the
3974 cdr is the lower 16 bits.
3975 FRAME nil or omitted means use the selected frame.
3976 If TYPE is given and non-nil, it is the name of the type of VALUE.
3977 If TYPE is not given or nil, the type is STRING.
3978 FORMAT gives the size in bits of each element if VALUE is a list.
3979 It must be one of 8, 16 or 32.
3980 If VALUE is a string or FORMAT is nil or not given, FORMAT defaults to 8.
3981 If OUTER_P is non-nil, the property is changed for the outer X window of
3982 FRAME. Default is to change on the edit X window.
3985 (prop
, value
, frame
, type
, format
, outer_p
)
3986 Lisp_Object prop
, value
, frame
, type
, format
, outer_p
;
3988 struct frame
*f
= check_x_frame (frame
);
3990 Atom target_type
= XA_STRING
;
3991 int element_format
= 8;
3992 unsigned char *data
;
3996 CHECK_STRING (prop
);
3998 if (! NILP (format
))
4000 CHECK_NUMBER (format
);
4001 element_format
= XFASTINT (format
);
4003 if (element_format
!= 8 && element_format
!= 16
4004 && element_format
!= 32)
4005 error ("FORMAT must be one of 8, 16 or 32");
4010 nelements
= x_check_property_data (value
);
4011 if (nelements
== -1)
4012 error ("Bad data in VALUE, must be number, string or cons");
4014 if (element_format
== 8)
4015 data
= (unsigned char *) xmalloc (nelements
);
4016 else if (element_format
== 16)
4017 data
= (unsigned char *) xmalloc (nelements
*2);
4019 data
= (unsigned char *) xmalloc (nelements
*4);
4021 x_fill_property_data (FRAME_X_DISPLAY (f
), value
, data
, element_format
);
4025 CHECK_STRING (value
);
4026 data
= SDATA (value
);
4027 nelements
= SCHARS (value
);
4031 prop_atom
= XInternAtom (FRAME_X_DISPLAY (f
), SDATA (prop
), False
);
4034 CHECK_STRING (type
);
4035 target_type
= XInternAtom (FRAME_X_DISPLAY (f
), SDATA (type
), False
);
4038 if (! NILP (outer_p
)) w
= FRAME_OUTER_WINDOW (f
);
4039 else w
= FRAME_X_WINDOW (f
);
4041 XChangeProperty (FRAME_X_DISPLAY (f
), w
,
4042 prop_atom
, target_type
, element_format
, PropModeReplace
,
4045 if (CONSP (value
)) xfree (data
);
4047 /* Make sure the property is set when we return. */
4048 XFlush (FRAME_X_DISPLAY (f
));
4055 DEFUN ("x-delete-window-property", Fx_delete_window_property
,
4056 Sx_delete_window_property
, 1, 2, 0,
4057 doc
: /* Remove window property PROP from X window of FRAME.
4058 FRAME nil or omitted means use the selected frame. Value is PROP. */)
4060 Lisp_Object prop
, frame
;
4062 struct frame
*f
= check_x_frame (frame
);
4065 CHECK_STRING (prop
);
4067 prop_atom
= XInternAtom (FRAME_X_DISPLAY (f
), SDATA (prop
), False
);
4068 XDeleteProperty (FRAME_X_DISPLAY (f
), FRAME_X_WINDOW (f
), prop_atom
);
4070 /* Make sure the property is removed when we return. */
4071 XFlush (FRAME_X_DISPLAY (f
));
4078 DEFUN ("x-window-property", Fx_window_property
, Sx_window_property
,
4080 doc
: /* Value is the value of window property PROP on FRAME.
4081 If FRAME is nil or omitted, use the selected frame.
4082 If TYPE is nil or omitted, get the property as a string. Otherwise TYPE
4083 is the name of the Atom that denotes the type expected.
4084 If SOURCE is non-nil, get the property on that window instead of from
4085 FRAME. The number 0 denotes the root window.
4086 If DELETE_P is non-nil, delete the property after retreiving it.
4087 If VECTOR_RET_P is non-nil, don't return a string but a vector of values.
4089 Value is nil if FRAME hasn't a property with name PROP or if PROP has
4090 no value of TYPE. */)
4091 (prop
, frame
, type
, source
, delete_p
, vector_ret_p
)
4092 Lisp_Object prop
, frame
, type
, source
, delete_p
, vector_ret_p
;
4094 struct frame
*f
= check_x_frame (frame
);
4097 Lisp_Object prop_value
= Qnil
;
4098 char *tmp_data
= NULL
;
4100 Atom target_type
= XA_STRING
;
4102 unsigned long actual_size
, bytes_remaining
;
4103 Window target_window
= FRAME_X_WINDOW (f
);
4104 struct gcpro gcpro1
;
4106 GCPRO1 (prop_value
);
4107 CHECK_STRING (prop
);
4109 if (! NILP (source
))
4111 if (NUMBERP (source
))
4113 if (FLOATP (source
))
4114 target_window
= (Window
) XFLOAT (source
);
4116 target_window
= XFASTINT (source
);
4118 if (target_window
== 0)
4119 target_window
= FRAME_X_DISPLAY_INFO (f
)->root_window
;
4121 else if (CONSP (source
))
4122 target_window
= cons_to_long (source
);
4128 if (strcmp ("AnyPropertyType", SDATA (type
)) == 0)
4129 target_type
= AnyPropertyType
;
4131 target_type
= XInternAtom (FRAME_X_DISPLAY (f
), SDATA (type
), False
);
4134 prop_atom
= XInternAtom (FRAME_X_DISPLAY (f
), SDATA (prop
), False
);
4135 rc
= XGetWindowProperty (FRAME_X_DISPLAY (f
), target_window
,
4136 prop_atom
, 0, 0, False
, target_type
,
4137 &actual_type
, &actual_format
, &actual_size
,
4138 &bytes_remaining
, (unsigned char **) &tmp_data
);
4141 int size
= bytes_remaining
;
4146 rc
= XGetWindowProperty (FRAME_X_DISPLAY (f
), target_window
,
4147 prop_atom
, 0, bytes_remaining
,
4148 ! NILP (delete_p
), target_type
,
4149 &actual_type
, &actual_format
,
4150 &actual_size
, &bytes_remaining
,
4151 (unsigned char **) &tmp_data
);
4152 if (rc
== Success
&& tmp_data
)
4154 if (NILP (vector_ret_p
))
4155 prop_value
= make_string (tmp_data
, size
);
4157 prop_value
= x_property_data_to_lisp (f
,
4158 (unsigned char *) tmp_data
,
4164 if (tmp_data
) XFree (tmp_data
);
4174 /***********************************************************************
4176 ***********************************************************************/
4178 /* If non-null, an asynchronous timer that, when it expires, displays
4179 an hourglass cursor on all frames. */
4181 static struct atimer
*hourglass_atimer
;
4183 /* Non-zero means an hourglass cursor is currently shown. */
4185 static int hourglass_shown_p
;
4187 /* Number of seconds to wait before displaying an hourglass cursor. */
4189 static Lisp_Object Vhourglass_delay
;
4191 /* Default number of seconds to wait before displaying an hourglass
4194 #define DEFAULT_HOURGLASS_DELAY 1
4196 /* Function prototypes. */
4198 static void show_hourglass
P_ ((struct atimer
*));
4199 static void hide_hourglass
P_ ((void));
4202 /* Cancel a currently active hourglass timer, and start a new one. */
4208 int secs
, usecs
= 0;
4210 cancel_hourglass ();
4212 if (INTEGERP (Vhourglass_delay
)
4213 && XINT (Vhourglass_delay
) > 0)
4214 secs
= XFASTINT (Vhourglass_delay
);
4215 else if (FLOATP (Vhourglass_delay
)
4216 && XFLOAT_DATA (Vhourglass_delay
) > 0)
4219 tem
= Ftruncate (Vhourglass_delay
, Qnil
);
4220 secs
= XFASTINT (tem
);
4221 usecs
= (XFLOAT_DATA (Vhourglass_delay
) - secs
) * 1000000;
4224 secs
= DEFAULT_HOURGLASS_DELAY
;
4226 EMACS_SET_SECS_USECS (delay
, secs
, usecs
);
4227 hourglass_atimer
= start_atimer (ATIMER_RELATIVE
, delay
,
4228 show_hourglass
, NULL
);
4232 /* Cancel the hourglass cursor timer if active, hide a busy cursor if
4238 if (hourglass_atimer
)
4240 cancel_atimer (hourglass_atimer
);
4241 hourglass_atimer
= NULL
;
4244 if (hourglass_shown_p
)
4249 /* Timer function of hourglass_atimer. TIMER is equal to
4252 Display an hourglass pointer on all frames by mapping the frames'
4253 hourglass_window. Set the hourglass_p flag in the frames'
4254 output_data.x structure to indicate that an hourglass cursor is
4255 shown on the frames. */
4258 show_hourglass (timer
)
4259 struct atimer
*timer
;
4261 /* The timer implementation will cancel this timer automatically
4262 after this function has run. Set hourglass_atimer to null
4263 so that we know the timer doesn't have to be canceled. */
4264 hourglass_atimer
= NULL
;
4266 if (!hourglass_shown_p
)
4268 Lisp_Object rest
, frame
;
4272 FOR_EACH_FRAME (rest
, frame
)
4274 struct frame
*f
= XFRAME (frame
);
4276 if (FRAME_LIVE_P (f
) && FRAME_X_P (f
) && FRAME_X_DISPLAY (f
))
4278 Display
*dpy
= FRAME_X_DISPLAY (f
);
4280 #ifdef USE_X_TOOLKIT
4281 if (f
->output_data
.x
->widget
)
4283 if (FRAME_OUTER_WINDOW (f
))
4286 f
->output_data
.x
->hourglass_p
= 1;
4288 if (!f
->output_data
.x
->hourglass_window
)
4290 unsigned long mask
= CWCursor
;
4291 XSetWindowAttributes attrs
;
4293 attrs
.cursor
= f
->output_data
.x
->hourglass_cursor
;
4295 f
->output_data
.x
->hourglass_window
4296 = XCreateWindow (dpy
, FRAME_OUTER_WINDOW (f
),
4297 0, 0, 32000, 32000, 0, 0,
4303 XMapRaised (dpy
, f
->output_data
.x
->hourglass_window
);
4309 hourglass_shown_p
= 1;
4315 /* Hide the hourglass pointer on all frames, if it is currently
4321 if (hourglass_shown_p
)
4323 Lisp_Object rest
, frame
;
4326 FOR_EACH_FRAME (rest
, frame
)
4328 struct frame
*f
= XFRAME (frame
);
4331 /* Watch out for newly created frames. */
4332 && f
->output_data
.x
->hourglass_window
)
4334 XUnmapWindow (FRAME_X_DISPLAY (f
),
4335 f
->output_data
.x
->hourglass_window
);
4336 /* Sync here because XTread_socket looks at the
4337 hourglass_p flag that is reset to zero below. */
4338 XSync (FRAME_X_DISPLAY (f
), False
);
4339 f
->output_data
.x
->hourglass_p
= 0;
4343 hourglass_shown_p
= 0;
4350 /***********************************************************************
4352 ***********************************************************************/
4354 static Lisp_Object x_create_tip_frame
P_ ((struct x_display_info
*,
4355 Lisp_Object
, Lisp_Object
));
4356 static void compute_tip_xy
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
,
4357 Lisp_Object
, int, int, int *, int *));
4359 /* The frame of a currently visible tooltip. */
4361 Lisp_Object tip_frame
;
4363 /* If non-nil, a timer started that hides the last tooltip when it
4366 Lisp_Object tip_timer
;
4369 /* If non-nil, a vector of 3 elements containing the last args
4370 with which x-show-tip was called. See there. */
4372 Lisp_Object last_show_tip_args
;
4374 /* Maximum size for tooltips; a cons (COLUMNS . ROWS). */
4376 Lisp_Object Vx_max_tooltip_size
;
4380 unwind_create_tip_frame (frame
)
4383 Lisp_Object deleted
;
4385 deleted
= unwind_create_frame (frame
);
4386 if (EQ (deleted
, Qt
))
4396 /* Create a frame for a tooltip on the display described by DPYINFO.
4397 PARMS is a list of frame parameters. TEXT is the string to
4398 display in the tip frame. Value is the frame.
4400 Note that functions called here, esp. x_default_parameter can
4401 signal errors, for instance when a specified color name is
4402 undefined. We have to make sure that we're in a consistent state
4403 when this happens. */
4406 x_create_tip_frame (dpyinfo
, parms
, text
)
4407 struct x_display_info
*dpyinfo
;
4408 Lisp_Object parms
, text
;
4411 Lisp_Object frame
, tem
;
4413 long window_prompting
= 0;
4415 int count
= SPECPDL_INDEX ();
4416 struct gcpro gcpro1
, gcpro2
, gcpro3
;
4418 int face_change_count_before
= face_change_count
;
4420 struct buffer
*old_buffer
;
4424 /* Use this general default value to start with until we know if
4425 this frame has a specified name. */
4426 Vx_resource_name
= Vinvocation_name
;
4429 kb
= dpyinfo
->kboard
;
4431 kb
= &the_only_kboard
;
4434 /* Get the name of the frame to use for resource lookup. */
4435 name
= x_get_arg (dpyinfo
, parms
, Qname
, "name", "Name", RES_TYPE_STRING
);
4437 && !EQ (name
, Qunbound
)
4439 error ("Invalid frame name--not a string or nil");
4440 Vx_resource_name
= name
;
4443 GCPRO3 (parms
, name
, frame
);
4445 XSETFRAME (frame
, f
);
4447 buffer
= Fget_buffer_create (build_string (" *tip*"));
4448 Fset_window_buffer (FRAME_ROOT_WINDOW (f
), buffer
, Qnil
);
4449 old_buffer
= current_buffer
;
4450 set_buffer_internal_1 (XBUFFER (buffer
));
4451 current_buffer
->truncate_lines
= Qnil
;
4454 set_buffer_internal_1 (old_buffer
);
4456 FRAME_CAN_HAVE_SCROLL_BARS (f
) = 0;
4457 record_unwind_protect (unwind_create_tip_frame
, frame
);
4459 f
->display
= dpyinfo
->frame_display
;
4460 f
->display
->reference_count
++;
4462 /* By setting the output method, we're essentially saying that
4463 the frame is live, as per FRAME_LIVE_P. If we get a signal
4464 from this point on, x_destroy_window might screw up reference
4466 f
->output_method
= output_x_window
;
4467 f
->output_data
.x
= (struct x_output
*) xmalloc (sizeof (struct x_output
));
4468 bzero (f
->output_data
.x
, sizeof (struct x_output
));
4469 f
->output_data
.x
->icon_bitmap
= -1;
4470 FRAME_FONTSET (f
) = -1;
4471 f
->output_data
.x
->scroll_bar_foreground_pixel
= -1;
4472 f
->output_data
.x
->scroll_bar_background_pixel
= -1;
4473 #ifdef USE_TOOLKIT_SCROLL_BARS
4474 f
->output_data
.x
->scroll_bar_top_shadow_pixel
= -1;
4475 f
->output_data
.x
->scroll_bar_bottom_shadow_pixel
= -1;
4476 #endif /* USE_TOOLKIT_SCROLL_BARS */
4477 f
->icon_name
= Qnil
;
4478 FRAME_X_DISPLAY_INFO (f
) = dpyinfo
;
4480 image_cache_refcount
= FRAME_X_IMAGE_CACHE (f
)->refcount
;
4481 dpyinfo_refcount
= dpyinfo
->reference_count
;
4482 #endif /* GLYPH_DEBUG */
4484 FRAME_KBOARD (f
) = kb
;
4486 f
->output_data
.x
->parent_desc
= FRAME_X_DISPLAY_INFO (f
)->root_window
;
4487 f
->output_data
.x
->explicit_parent
= 0;
4489 /* These colors will be set anyway later, but it's important
4490 to get the color reference counts right, so initialize them! */
4493 struct gcpro gcpro1
;
4495 black
= build_string ("black");
4497 f
->output_data
.x
->foreground_pixel
4498 = x_decode_color (f
, black
, BLACK_PIX_DEFAULT (f
));
4499 f
->output_data
.x
->background_pixel
4500 = x_decode_color (f
, black
, BLACK_PIX_DEFAULT (f
));
4501 f
->output_data
.x
->cursor_pixel
4502 = x_decode_color (f
, black
, BLACK_PIX_DEFAULT (f
));
4503 f
->output_data
.x
->cursor_foreground_pixel
4504 = x_decode_color (f
, black
, BLACK_PIX_DEFAULT (f
));
4505 f
->output_data
.x
->border_pixel
4506 = x_decode_color (f
, black
, BLACK_PIX_DEFAULT (f
));
4507 f
->output_data
.x
->mouse_pixel
4508 = x_decode_color (f
, black
, BLACK_PIX_DEFAULT (f
));
4512 /* Set the name; the functions to which we pass f expect the name to
4514 if (EQ (name
, Qunbound
) || NILP (name
))
4516 f
->name
= build_string (dpyinfo
->x_id_name
);
4517 f
->explicit_name
= 0;
4522 f
->explicit_name
= 1;
4523 /* use the frame's title when getting resources for this frame. */
4524 specbind (Qx_resource_name
, name
);
4527 /* Extract the window parameters from the supplied values that are
4528 needed to determine window geometry. */
4532 font
= x_get_arg (dpyinfo
, parms
, Qfont
, "font", "Font", RES_TYPE_STRING
);
4535 /* First, try whatever font the caller has specified. */
4538 tem
= Fquery_fontset (font
, Qnil
);
4540 font
= x_new_fontset (f
, SDATA (tem
));
4542 font
= x_new_font (f
, SDATA (font
));
4545 /* Try out a font which we hope has bold and italic variations. */
4546 if (!STRINGP (font
))
4547 font
= x_new_font (f
, "-adobe-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-1");
4548 if (!STRINGP (font
))
4549 font
= x_new_font (f
, "-misc-fixed-medium-r-normal-*-*-140-*-*-c-*-iso8859-1");
4550 if (! STRINGP (font
))
4551 font
= x_new_font (f
, "-*-*-medium-r-normal-*-*-140-*-*-c-*-iso8859-1");
4552 if (! STRINGP (font
))
4553 /* This was formerly the first thing tried, but it finds too many fonts
4554 and takes too long. */
4555 font
= x_new_font (f
, "-*-*-medium-r-*-*-*-*-*-*-c-*-iso8859-1");
4556 /* If those didn't work, look for something which will at least work. */
4557 if (! STRINGP (font
))
4558 font
= x_new_font (f
, "-*-fixed-*-*-*-*-*-140-*-*-c-*-iso8859-1");
4560 if (! STRINGP (font
))
4561 font
= build_string ("fixed");
4563 x_default_parameter (f
, parms
, Qfont
, font
,
4564 "font", "Font", RES_TYPE_STRING
);
4567 x_default_parameter (f
, parms
, Qborder_width
, make_number (2),
4568 "borderWidth", "BorderWidth", RES_TYPE_NUMBER
);
4570 /* This defaults to 2 in order to match xterm. We recognize either
4571 internalBorderWidth or internalBorder (which is what xterm calls
4573 if (NILP (Fassq (Qinternal_border_width
, parms
)))
4577 value
= x_get_arg (dpyinfo
, parms
, Qinternal_border_width
,
4578 "internalBorder", "internalBorder", RES_TYPE_NUMBER
);
4579 if (! EQ (value
, Qunbound
))
4580 parms
= Fcons (Fcons (Qinternal_border_width
, value
),
4584 x_default_parameter (f
, parms
, Qinternal_border_width
, make_number (1),
4585 "internalBorderWidth", "internalBorderWidth",
4588 /* Also do the stuff which must be set before the window exists. */
4589 x_default_parameter (f
, parms
, Qforeground_color
, build_string ("black"),
4590 "foreground", "Foreground", RES_TYPE_STRING
);
4591 x_default_parameter (f
, parms
, Qbackground_color
, build_string ("white"),
4592 "background", "Background", RES_TYPE_STRING
);
4593 x_default_parameter (f
, parms
, Qmouse_color
, build_string ("black"),
4594 "pointerColor", "Foreground", RES_TYPE_STRING
);
4595 x_default_parameter (f
, parms
, Qcursor_color
, build_string ("black"),
4596 "cursorColor", "Foreground", RES_TYPE_STRING
);
4597 x_default_parameter (f
, parms
, Qborder_color
, build_string ("black"),
4598 "borderColor", "BorderColor", RES_TYPE_STRING
);
4600 /* Init faces before x_default_parameter is called for scroll-bar
4601 parameters because that function calls x_set_scroll_bar_width,
4602 which calls change_frame_size, which calls Fset_window_buffer,
4603 which runs hooks, which call Fvertical_motion. At the end, we
4604 end up in init_iterator with a null face cache, which should not
4606 init_frame_faces (f
);
4608 f
->output_data
.x
->parent_desc
= FRAME_X_DISPLAY_INFO (f
)->root_window
;
4610 window_prompting
= x_figure_window_size (f
, parms
, 0);
4613 XSetWindowAttributes attrs
;
4617 mask
= CWBackPixel
| CWOverrideRedirect
| CWEventMask
;
4618 if (DoesSaveUnders (dpyinfo
->screen
))
4619 mask
|= CWSaveUnder
;
4621 /* Window managers look at the override-redirect flag to determine
4622 whether or net to give windows a decoration (Xlib spec, chapter
4624 attrs
.override_redirect
= True
;
4625 attrs
.save_under
= True
;
4626 attrs
.background_pixel
= FRAME_BACKGROUND_PIXEL (f
);
4627 /* Arrange for getting MapNotify and UnmapNotify events. */
4628 attrs
.event_mask
= StructureNotifyMask
;
4630 = FRAME_X_WINDOW (f
)
4631 = XCreateWindow (FRAME_X_DISPLAY (f
),
4632 FRAME_X_DISPLAY_INFO (f
)->root_window
,
4633 /* x, y, width, height */
4637 CopyFromParent
, InputOutput
, CopyFromParent
,
4644 x_default_parameter (f
, parms
, Qauto_raise
, Qnil
,
4645 "autoRaise", "AutoRaiseLower", RES_TYPE_BOOLEAN
);
4646 x_default_parameter (f
, parms
, Qauto_lower
, Qnil
,
4647 "autoLower", "AutoRaiseLower", RES_TYPE_BOOLEAN
);
4648 x_default_parameter (f
, parms
, Qcursor_type
, Qbox
,
4649 "cursorType", "CursorType", RES_TYPE_SYMBOL
);
4651 /* Dimensions, especially FRAME_LINES (f), must be done via change_frame_size.
4652 Change will not be effected unless different from the current
4654 width
= FRAME_COLS (f
);
4655 height
= FRAME_LINES (f
);
4656 SET_FRAME_COLS (f
, 0);
4657 FRAME_LINES (f
) = 0;
4658 change_frame_size (f
, height
, width
, 1, 0, 0);
4660 /* Add `tooltip' frame parameter's default value. */
4661 if (NILP (Fframe_parameter (frame
, intern ("tooltip"))))
4662 Fmodify_frame_parameters (frame
, Fcons (Fcons (intern ("tooltip"), Qt
),
4665 /* Set up faces after all frame parameters are known. This call
4666 also merges in face attributes specified for new frames.
4668 Frame parameters may be changed if .Xdefaults contains
4669 specifications for the default font. For example, if there is an
4670 `Emacs.default.attributeBackground: pink', the `background-color'
4671 attribute of the frame get's set, which let's the internal border
4672 of the tooltip frame appear in pink. Prevent this. */
4674 Lisp_Object bg
= Fframe_parameter (frame
, Qbackground_color
);
4676 /* Set tip_frame here, so that */
4678 call1 (Qface_set_after_frame_default
, frame
);
4680 if (!EQ (bg
, Fframe_parameter (frame
, Qbackground_color
)))
4681 Fmodify_frame_parameters (frame
, Fcons (Fcons (Qbackground_color
, bg
),
4685 Fmodify_frame_parameters (frame
, Fcons (Fcons (Qwindow_system
, Qx
), Qnil
));
4691 /* It is now ok to make the frame official even if we get an error
4692 below. And the frame needs to be on Vframe_list or making it
4693 visible won't work. */
4694 Vframe_list
= Fcons (frame
, Vframe_list
);
4696 /* Now that the frame is official, it counts as a reference to
4698 FRAME_X_DISPLAY_INFO (f
)->reference_count
++;
4700 /* Setting attributes of faces of the tooltip frame from resources
4701 and similar will increment face_change_count, which leads to the
4702 clearing of all current matrices. Since this isn't necessary
4703 here, avoid it by resetting face_change_count to the value it
4704 had before we created the tip frame. */
4705 face_change_count
= face_change_count_before
;
4707 /* Discard the unwind_protect. */
4708 return unbind_to (count
, frame
);
4712 /* Compute where to display tip frame F. PARMS is the list of frame
4713 parameters for F. DX and DY are specified offsets from the current
4714 location of the mouse. WIDTH and HEIGHT are the width and height
4715 of the tooltip. Return coordinates relative to the root window of
4716 the display in *ROOT_X, and *ROOT_Y. */
4719 compute_tip_xy (f
, parms
, dx
, dy
, width
, height
, root_x
, root_y
)
4721 Lisp_Object parms
, dx
, dy
;
4723 int *root_x
, *root_y
;
4725 Lisp_Object left
, top
;
4730 /* User-specified position? */
4731 left
= Fcdr (Fassq (Qleft
, parms
));
4732 top
= Fcdr (Fassq (Qtop
, parms
));
4734 /* Move the tooltip window where the mouse pointer is. Resize and
4736 if (!INTEGERP (left
) || !INTEGERP (top
))
4739 XQueryPointer (FRAME_X_DISPLAY (f
), FRAME_X_DISPLAY_INFO (f
)->root_window
,
4740 &root
, &child
, root_x
, root_y
, &win_x
, &win_y
, &pmask
);
4745 *root_y
= XINT (top
);
4746 else if (*root_y
+ XINT (dy
) - height
< 0)
4747 *root_y
-= XINT (dy
);
4751 *root_y
+= XINT (dy
);
4754 if (INTEGERP (left
))
4755 *root_x
= XINT (left
);
4756 else if (*root_x
+ XINT (dx
) + width
<= FRAME_X_DISPLAY_INFO (f
)->width
)
4757 /* It fits to the right of the pointer. */
4758 *root_x
+= XINT (dx
);
4759 else if (width
+ XINT (dx
) <= *root_x
)
4760 /* It fits to the left of the pointer. */
4761 *root_x
-= width
+ XINT (dx
);
4763 /* Put it left-justified on the screen--it ought to fit that way. */
4768 DEFUN ("x-show-tip", Fx_show_tip
, Sx_show_tip
, 1, 6, 0,
4769 doc
: /* Show STRING in a "tooltip" window on frame FRAME.
4770 A tooltip window is a small X window displaying a string.
4772 FRAME nil or omitted means use the selected frame.
4774 PARMS is an optional list of frame parameters which can be used to
4775 change the tooltip's appearance.
4777 Automatically hide the tooltip after TIMEOUT seconds. TIMEOUT nil
4778 means use the default timeout of 5 seconds.
4780 If the list of frame parameters PARAMS contains a `left' parameters,
4781 the tooltip is displayed at that x-position. Otherwise it is
4782 displayed at the mouse position, with offset DX added (default is 5 if
4783 DX isn't specified). Likewise for the y-position; if a `top' frame
4784 parameter is specified, it determines the y-position of the tooltip
4785 window, otherwise it is displayed at the mouse position, with offset
4786 DY added (default is -10).
4788 A tooltip's maximum size is specified by `x-max-tooltip-size'.
4789 Text larger than the specified size is clipped. */)
4790 (string
, frame
, parms
, timeout
, dx
, dy
)
4791 Lisp_Object string
, frame
, parms
, timeout
, dx
, dy
;
4796 struct buffer
*old_buffer
;
4797 struct text_pos pos
;
4798 int i
, width
, height
;
4799 struct gcpro gcpro1
, gcpro2
, gcpro3
, gcpro4
;
4800 int old_windows_or_buffers_changed
= windows_or_buffers_changed
;
4801 int count
= SPECPDL_INDEX ();
4803 specbind (Qinhibit_redisplay
, Qt
);
4805 GCPRO4 (string
, parms
, frame
, timeout
);
4807 CHECK_STRING (string
);
4808 f
= check_x_frame (frame
);
4810 timeout
= make_number (5);
4812 CHECK_NATNUM (timeout
);
4815 dx
= make_number (5);
4820 dy
= make_number (-10);
4824 if (NILP (last_show_tip_args
))
4825 last_show_tip_args
= Fmake_vector (make_number (3), Qnil
);
4827 if (!NILP (tip_frame
))
4829 Lisp_Object last_string
= AREF (last_show_tip_args
, 0);
4830 Lisp_Object last_frame
= AREF (last_show_tip_args
, 1);
4831 Lisp_Object last_parms
= AREF (last_show_tip_args
, 2);
4833 if (EQ (frame
, last_frame
)
4834 && !NILP (Fequal (last_string
, string
))
4835 && !NILP (Fequal (last_parms
, parms
)))
4837 struct frame
*f
= XFRAME (tip_frame
);
4839 /* Only DX and DY have changed. */
4840 if (!NILP (tip_timer
))
4842 Lisp_Object timer
= tip_timer
;
4844 call1 (Qcancel_timer
, timer
);
4848 compute_tip_xy (f
, parms
, dx
, dy
, FRAME_PIXEL_WIDTH (f
),
4849 FRAME_PIXEL_HEIGHT (f
), &root_x
, &root_y
);
4850 XMoveWindow (FRAME_X_DISPLAY (f
), FRAME_X_WINDOW (f
),
4857 /* Hide a previous tip, if any. */
4860 ASET (last_show_tip_args
, 0, string
);
4861 ASET (last_show_tip_args
, 1, frame
);
4862 ASET (last_show_tip_args
, 2, parms
);
4864 /* Add default values to frame parameters. */
4865 if (NILP (Fassq (Qname
, parms
)))
4866 parms
= Fcons (Fcons (Qname
, build_string ("tooltip")), parms
);
4867 if (NILP (Fassq (Qinternal_border_width
, parms
)))
4868 parms
= Fcons (Fcons (Qinternal_border_width
, make_number (3)), parms
);
4869 if (NILP (Fassq (Qborder_width
, parms
)))
4870 parms
= Fcons (Fcons (Qborder_width
, make_number (1)), parms
);
4871 if (NILP (Fassq (Qborder_color
, parms
)))
4872 parms
= Fcons (Fcons (Qborder_color
, build_string ("lightyellow")), parms
);
4873 if (NILP (Fassq (Qbackground_color
, parms
)))
4874 parms
= Fcons (Fcons (Qbackground_color
, build_string ("lightyellow")),
4877 /* Create a frame for the tooltip, and record it in the global
4878 variable tip_frame. */
4879 frame
= x_create_tip_frame (FRAME_X_DISPLAY_INFO (f
), parms
, string
);
4882 /* Set up the frame's root window. */
4883 w
= XWINDOW (FRAME_ROOT_WINDOW (f
));
4884 w
->left_col
= w
->top_line
= make_number (0);
4886 if (CONSP (Vx_max_tooltip_size
)
4887 && INTEGERP (XCAR (Vx_max_tooltip_size
))
4888 && XINT (XCAR (Vx_max_tooltip_size
)) > 0
4889 && INTEGERP (XCDR (Vx_max_tooltip_size
))
4890 && XINT (XCDR (Vx_max_tooltip_size
)) > 0)
4892 w
->total_cols
= XCAR (Vx_max_tooltip_size
);
4893 w
->total_lines
= XCDR (Vx_max_tooltip_size
);
4897 w
->total_cols
= make_number (80);
4898 w
->total_lines
= make_number (40);
4901 FRAME_TOTAL_COLS (f
) = XINT (w
->total_cols
);
4903 w
->pseudo_window_p
= 1;
4905 /* Display the tooltip text in a temporary buffer. */
4906 old_buffer
= current_buffer
;
4907 set_buffer_internal_1 (XBUFFER (XWINDOW (FRAME_ROOT_WINDOW (f
))->buffer
));
4908 current_buffer
->truncate_lines
= Qnil
;
4909 clear_glyph_matrix (w
->desired_matrix
);
4910 clear_glyph_matrix (w
->current_matrix
);
4911 SET_TEXT_POS (pos
, BEGV
, BEGV_BYTE
);
4912 try_window (FRAME_ROOT_WINDOW (f
), pos
);
4914 /* Compute width and height of the tooltip. */
4916 for (i
= 0; i
< w
->desired_matrix
->nrows
; ++i
)
4918 struct glyph_row
*row
= &w
->desired_matrix
->rows
[i
];
4922 /* Stop at the first empty row at the end. */
4923 if (!row
->enabled_p
|| !row
->displays_text_p
)
4926 /* Let the row go over the full width of the frame. */
4927 row
->full_width_p
= 1;
4929 /* There's a glyph at the end of rows that is used to place
4930 the cursor there. Don't include the width of this glyph. */
4931 if (row
->used
[TEXT_AREA
])
4933 last
= &row
->glyphs
[TEXT_AREA
][row
->used
[TEXT_AREA
] - 1];
4934 row_width
= row
->pixel_width
- last
->pixel_width
;
4937 row_width
= row
->pixel_width
;
4939 height
+= row
->height
;
4940 width
= max (width
, row_width
);
4943 /* Add the frame's internal border to the width and height the X
4944 window should have. */
4945 height
+= 2 * FRAME_INTERNAL_BORDER_WIDTH (f
);
4946 width
+= 2 * FRAME_INTERNAL_BORDER_WIDTH (f
);
4948 /* Move the tooltip window where the mouse pointer is. Resize and
4950 compute_tip_xy (f
, parms
, dx
, dy
, width
, height
, &root_x
, &root_y
);
4953 XMoveResizeWindow (FRAME_X_DISPLAY (f
), FRAME_X_WINDOW (f
),
4954 root_x
, root_y
, width
, height
);
4955 XMapRaised (FRAME_X_DISPLAY (f
), FRAME_X_WINDOW (f
));
4958 /* Draw into the window. */
4959 w
->must_be_updated_p
= 1;
4960 update_single_window (w
, 1);
4962 /* Restore original current buffer. */
4963 set_buffer_internal_1 (old_buffer
);
4964 windows_or_buffers_changed
= old_windows_or_buffers_changed
;
4967 /* Let the tip disappear after timeout seconds. */
4968 tip_timer
= call3 (intern ("run-at-time"), timeout
, Qnil
,
4969 intern ("x-hide-tip"));
4972 return unbind_to (count
, Qnil
);
4976 DEFUN ("x-hide-tip", Fx_hide_tip
, Sx_hide_tip
, 0, 0, 0,
4977 doc
: /* Hide the current tooltip window, if there is any.
4978 Value is t if tooltip was open, nil otherwise. */)
4982 Lisp_Object deleted
, frame
, timer
;
4983 struct gcpro gcpro1
, gcpro2
;
4985 /* Return quickly if nothing to do. */
4986 if (NILP (tip_timer
) && NILP (tip_frame
))
4991 GCPRO2 (frame
, timer
);
4992 tip_frame
= tip_timer
= deleted
= Qnil
;
4994 count
= SPECPDL_INDEX ();
4995 specbind (Qinhibit_redisplay
, Qt
);
4996 specbind (Qinhibit_quit
, Qt
);
4999 call1 (Qcancel_timer
, timer
);
5003 Fdelete_frame (frame
, Qnil
);
5007 /* Bloodcurdling hack alert: The Lucid menu bar widget's
5008 redisplay procedure is not called when a tip frame over menu
5009 items is unmapped. Redisplay the menu manually... */
5011 struct frame
*f
= SELECTED_FRAME ();
5012 Widget w
= f
->output_data
.x
->menubar_widget
;
5013 extern void xlwmenu_redisplay
P_ ((Widget
));
5015 if (!DoesSaveUnders (FRAME_X_DISPLAY_INFO (f
)->screen
)
5019 xlwmenu_redisplay (w
);
5023 #endif /* USE_LUCID */
5027 return unbind_to (count
, deleted
);
5032 /***********************************************************************
5033 File selection dialog
5034 ***********************************************************************/
5038 /* Callback for "OK" and "Cancel" on file selection dialog. */
5041 file_dialog_cb (widget
, client_data
, call_data
)
5043 XtPointer call_data
, client_data
;
5045 int *result
= (int *) client_data
;
5046 XmAnyCallbackStruct
*cb
= (XmAnyCallbackStruct
*) call_data
;
5047 *result
= cb
->reason
;
5051 /* Callback for unmapping a file selection dialog. This is used to
5052 capture the case where a dialog is closed via a window manager's
5053 closer button, for example. Using a XmNdestroyCallback didn't work
5057 file_dialog_unmap_cb (widget
, client_data
, call_data
)
5059 XtPointer call_data
, client_data
;
5061 int *result
= (int *) client_data
;
5062 *result
= XmCR_CANCEL
;
5066 DEFUN ("x-file-dialog", Fx_file_dialog
, Sx_file_dialog
, 2, 4, 0,
5067 doc
: /* Read file name, prompting with PROMPT in directory DIR.
5068 Use a file selection dialog.
5069 Select DEFAULT-FILENAME in the dialog's file selection box, if
5070 specified. Don't let the user enter a file name in the file
5071 selection dialog's entry field, if MUSTMATCH is non-nil. */)
5072 (prompt
, dir
, default_filename
, mustmatch
)
5073 Lisp_Object prompt
, dir
, default_filename
, mustmatch
;
5076 struct frame
*f
= SELECTED_FRAME ();
5077 Lisp_Object file
= Qnil
;
5078 Widget dialog
, text
, list
, help
;
5081 extern XtAppContext Xt_app_con
;
5082 XmString dir_xmstring
, pattern_xmstring
;
5083 int count
= SPECPDL_INDEX ();
5084 struct gcpro gcpro1
, gcpro2
, gcpro3
, gcpro4
, gcpro5
;
5086 GCPRO5 (prompt
, dir
, default_filename
, mustmatch
, file
);
5087 CHECK_STRING (prompt
);
5090 /* Prevent redisplay. */
5091 specbind (Qinhibit_redisplay
, Qt
);
5095 /* Create the dialog with PROMPT as title, using DIR as initial
5096 directory and using "*" as pattern. */
5097 dir
= Fexpand_file_name (dir
, Qnil
);
5098 dir_xmstring
= XmStringCreateLocalized (SDATA (dir
));
5099 pattern_xmstring
= XmStringCreateLocalized ("*");
5101 XtSetArg (al
[ac
], XmNtitle
, SDATA (prompt
)); ++ac
;
5102 XtSetArg (al
[ac
], XmNdirectory
, dir_xmstring
); ++ac
;
5103 XtSetArg (al
[ac
], XmNpattern
, pattern_xmstring
); ++ac
;
5104 XtSetArg (al
[ac
], XmNresizePolicy
, XmRESIZE_GROW
); ++ac
;
5105 XtSetArg (al
[ac
], XmNdialogStyle
, XmDIALOG_APPLICATION_MODAL
); ++ac
;
5106 dialog
= XmCreateFileSelectionDialog (f
->output_data
.x
->widget
,
5108 XmStringFree (dir_xmstring
);
5109 XmStringFree (pattern_xmstring
);
5111 /* Add callbacks for OK and Cancel. */
5112 XtAddCallback (dialog
, XmNokCallback
, file_dialog_cb
,
5113 (XtPointer
) &result
);
5114 XtAddCallback (dialog
, XmNcancelCallback
, file_dialog_cb
,
5115 (XtPointer
) &result
);
5116 XtAddCallback (dialog
, XmNunmapCallback
, file_dialog_unmap_cb
,
5117 (XtPointer
) &result
);
5119 /* Disable the help button since we can't display help. */
5120 help
= XmFileSelectionBoxGetChild (dialog
, XmDIALOG_HELP_BUTTON
);
5121 XtSetSensitive (help
, False
);
5123 /* Mark OK button as default. */
5124 XtVaSetValues (XmFileSelectionBoxGetChild (dialog
, XmDIALOG_OK_BUTTON
),
5125 XmNshowAsDefault
, True
, NULL
);
5127 /* If MUSTMATCH is non-nil, disable the file entry field of the
5128 dialog, so that the user must select a file from the files list
5129 box. We can't remove it because we wouldn't have a way to get at
5130 the result file name, then. */
5131 text
= XmFileSelectionBoxGetChild (dialog
, XmDIALOG_TEXT
);
5132 if (!NILP (mustmatch
))
5135 label
= XmFileSelectionBoxGetChild (dialog
, XmDIALOG_SELECTION_LABEL
);
5136 XtSetSensitive (text
, False
);
5137 XtSetSensitive (label
, False
);
5140 /* Manage the dialog, so that list boxes get filled. */
5141 XtManageChild (dialog
);
5143 /* Select DEFAULT_FILENAME in the files list box. DEFAULT_FILENAME
5144 must include the path for this to work. */
5145 list
= XmFileSelectionBoxGetChild (dialog
, XmDIALOG_LIST
);
5146 if (STRINGP (default_filename
))
5148 XmString default_xmstring
;
5152 = XmStringCreateLocalized (SDATA (default_filename
));
5154 if (!XmListItemExists (list
, default_xmstring
))
5156 /* Add a new item if DEFAULT_FILENAME is not in the list. */
5157 XmListAddItem (list
, default_xmstring
, 0);
5161 item_pos
= XmListItemPos (list
, default_xmstring
);
5162 XmStringFree (default_xmstring
);
5164 /* Select the item and scroll it into view. */
5165 XmListSelectPos (list
, item_pos
, True
);
5166 XmListSetPos (list
, item_pos
);
5169 /* Process events until the user presses Cancel or OK. */
5174 XtAppNextEvent (Xt_app_con
, &event
);
5175 (void) x_dispatch_event (&event
, FRAME_X_DISPLAY (f
) );
5178 /* Get the result. */
5179 if (result
== XmCR_OK
)
5184 XtVaGetValues (dialog
, XmNtextString
, &text
, NULL
);
5185 XmStringGetLtoR (text
, XmFONTLIST_DEFAULT_TAG
, &data
);
5186 XmStringFree (text
);
5187 file
= build_string (data
);
5194 XtUnmanageChild (dialog
);
5195 XtDestroyWidget (dialog
);
5199 /* Make "Cancel" equivalent to C-g. */
5201 Fsignal (Qquit
, Qnil
);
5203 return unbind_to (count
, file
);
5206 #endif /* USE_MOTIF */
5210 DEFUN ("x-file-dialog", Fx_file_dialog
, Sx_file_dialog
, 2, 4, 0,
5211 "Read file name, prompting with PROMPT in directory DIR.\n\
5212 Use a file selection dialog.\n\
5213 Select DEFAULT-FILENAME in the dialog's file selection box, if\n\
5214 specified. Don't let the user enter a file name in the file\n\
5215 selection dialog's entry field, if MUSTMATCH is non-nil.")
5216 (prompt
, dir
, default_filename
, mustmatch
)
5217 Lisp_Object prompt
, dir
, default_filename
, mustmatch
;
5219 FRAME_PTR f
= SELECTED_FRAME ();
5221 Lisp_Object file
= Qnil
;
5222 int count
= specpdl_ptr
- specpdl
;
5223 struct gcpro gcpro1
, gcpro2
, gcpro3
, gcpro4
, gcpro5
;
5226 GCPRO5 (prompt
, dir
, default_filename
, mustmatch
, file
);
5227 CHECK_STRING (prompt
);
5230 /* Prevent redisplay. */
5231 specbind (Qinhibit_redisplay
, Qt
);
5235 if (STRINGP (default_filename
))
5236 cdef_file
= SDATA (default_filename
);
5238 cdef_file
= SDATA (dir
);
5240 fn
= xg_get_file_name (f
, SDATA (prompt
), cdef_file
, ! NILP (mustmatch
));
5244 file
= build_string (fn
);
5251 /* Make "Cancel" equivalent to C-g. */
5253 Fsignal (Qquit
, Qnil
);
5255 return unbind_to (count
, file
);
5258 #endif /* USE_GTK */
5261 /***********************************************************************
5263 ***********************************************************************/
5265 #ifdef HAVE_XKBGETKEYBOARD
5266 #include <X11/XKBlib.h>
5267 #include <X11/keysym.h>
5270 DEFUN ("x-backspace-delete-keys-p", Fx_backspace_delete_keys_p
,
5271 Sx_backspace_delete_keys_p
, 0, 1, 0,
5272 doc
: /* Check if both Backspace and Delete keys are on the keyboard of FRAME.
5273 FRAME nil means use the selected frame.
5274 Value is t if we know that both keys are present, and are mapped to the
5275 usual X keysyms. */)
5279 #ifdef HAVE_XKBGETKEYBOARD
5281 struct frame
*f
= check_x_frame (frame
);
5282 Display
*dpy
= FRAME_X_DISPLAY (f
);
5283 Lisp_Object have_keys
;
5284 int major
, minor
, op
, event
, error
;
5288 /* Check library version in case we're dynamically linked. */
5289 major
= XkbMajorVersion
;
5290 minor
= XkbMinorVersion
;
5291 if (!XkbLibraryVersion (&major
, &minor
))
5297 /* Check that the server supports XKB. */
5298 major
= XkbMajorVersion
;
5299 minor
= XkbMinorVersion
;
5300 if (!XkbQueryExtension (dpy
, &op
, &event
, &error
, &major
, &minor
))
5307 kb
= XkbGetMap (dpy
, XkbAllMapComponentsMask
, XkbUseCoreKbd
);
5310 int delete_keycode
= 0, backspace_keycode
= 0, i
;
5312 if (XkbGetNames (dpy
, XkbAllNamesMask
, kb
) == Success
)
5314 for (i
= kb
->min_key_code
;
5315 (i
< kb
->max_key_code
5316 && (delete_keycode
== 0 || backspace_keycode
== 0));
5319 /* The XKB symbolic key names can be seen most easily in
5320 the PS file generated by `xkbprint -label name
5322 if (bcmp ("DELE", kb
->names
->keys
[i
].name
, 4) == 0)
5324 else if (bcmp ("BKSP", kb
->names
->keys
[i
].name
, 4) == 0)
5325 backspace_keycode
= i
;
5328 XkbFreeNames (kb
, 0, True
);
5331 XkbFreeClientMap (kb
, 0, True
);
5334 && backspace_keycode
5335 && XKeysymToKeycode (dpy
, XK_Delete
) == delete_keycode
5336 && XKeysymToKeycode (dpy
, XK_BackSpace
) == backspace_keycode
)
5341 #else /* not HAVE_XKBGETKEYBOARD */
5343 #endif /* not HAVE_XKBGETKEYBOARD */
5348 /***********************************************************************
5350 ***********************************************************************/
5352 /* Keep this list in the same order as frame_parms in frame.c.
5353 Use 0 for unsupported frame parameters. */
5355 frame_parm_handler x_frame_parm_handlers
[] =
5359 x_set_background_color
,
5365 x_set_foreground_color
,
5368 x_set_internal_border_width
,
5369 x_set_menu_bar_lines
,
5371 x_explicitly_set_name
,
5372 x_set_scroll_bar_width
,
5375 x_set_vertical_scroll_bars
,
5377 x_set_tool_bar_lines
,
5378 x_set_scroll_bar_foreground
,
5379 x_set_scroll_bar_background
,
5391 /* This is zero if not using X windows. */
5394 /* The section below is built by the lisp expression at the top of the file,
5395 just above where these variables are declared. */
5396 /*&&& init symbols here &&&*/
5397 Qnone
= intern ("none");
5399 Qsuppress_icon
= intern ("suppress-icon");
5400 staticpro (&Qsuppress_icon
);
5401 Qundefined_color
= intern ("undefined-color");
5402 staticpro (&Qundefined_color
);
5403 Qcompound_text
= intern ("compound-text");
5404 staticpro (&Qcompound_text
);
5405 Qcancel_timer
= intern ("cancel-timer");
5406 staticpro (&Qcancel_timer
);
5407 /* This is the end of symbol initialization. */
5409 /* Text property `display' should be nonsticky by default. */
5410 Vtext_property_default_nonsticky
5411 = Fcons (Fcons (Qdisplay
, Qt
), Vtext_property_default_nonsticky
);
5414 Fput (Qundefined_color
, Qerror_conditions
,
5415 Fcons (Qundefined_color
, Fcons (Qerror
, Qnil
)));
5416 Fput (Qundefined_color
, Qerror_message
,
5417 build_string ("Undefined color"));
5419 DEFVAR_LISP ("x-pointer-shape", &Vx_pointer_shape
,
5420 doc
: /* The shape of the pointer when over text.
5421 Changing the value does not affect existing frames
5422 unless you set the mouse color. */);
5423 Vx_pointer_shape
= Qnil
;
5425 #if 0 /* This doesn't really do anything. */
5426 DEFVAR_LISP ("x-nontext-pointer-shape", &Vx_nontext_pointer_shape
,
5427 doc
: /* The shape of the pointer when not over text.
5428 This variable takes effect when you create a new frame
5429 or when you set the mouse color. */);
5431 Vx_nontext_pointer_shape
= Qnil
;
5433 DEFVAR_LISP ("x-hourglass-pointer-shape", &Vx_hourglass_pointer_shape
,
5434 doc
: /* The shape of the pointer when Emacs is busy.
5435 This variable takes effect when you create a new frame
5436 or when you set the mouse color. */);
5437 Vx_hourglass_pointer_shape
= Qnil
;
5439 DEFVAR_BOOL ("display-hourglass", &display_hourglass_p
,
5440 doc
: /* Non-zero means Emacs displays an hourglass pointer on window systems. */);
5441 display_hourglass_p
= 1;
5443 DEFVAR_LISP ("hourglass-delay", &Vhourglass_delay
,
5444 doc
: /* *Seconds to wait before displaying an hourglass pointer.
5445 Value must be an integer or float. */);
5446 Vhourglass_delay
= make_number (DEFAULT_HOURGLASS_DELAY
);
5448 #if 0 /* This doesn't really do anything. */
5449 DEFVAR_LISP ("x-mode-pointer-shape", &Vx_mode_pointer_shape
,
5450 doc
: /* The shape of the pointer when over the mode line.
5451 This variable takes effect when you create a new frame
5452 or when you set the mouse color. */);
5454 Vx_mode_pointer_shape
= Qnil
;
5456 DEFVAR_LISP ("x-sensitive-text-pointer-shape",
5457 &Vx_sensitive_text_pointer_shape
,
5458 doc
: /* The shape of the pointer when over mouse-sensitive text.
5459 This variable takes effect when you create a new frame
5460 or when you set the mouse color. */);
5461 Vx_sensitive_text_pointer_shape
= Qnil
;
5463 DEFVAR_LISP ("x-window-horizontal-drag-cursor",
5464 &Vx_window_horizontal_drag_shape
,
5465 doc
: /* Pointer shape to use for indicating a window can be dragged horizontally.
5466 This variable takes effect when you create a new frame
5467 or when you set the mouse color. */);
5468 Vx_window_horizontal_drag_shape
= Qnil
;
5470 DEFVAR_LISP ("x-cursor-fore-pixel", &Vx_cursor_fore_pixel
,
5471 doc
: /* A string indicating the foreground color of the cursor box. */);
5472 Vx_cursor_fore_pixel
= Qnil
;
5474 DEFVAR_LISP ("x-max-tooltip-size", &Vx_max_tooltip_size
,
5475 doc
: /* Maximum size for tooltips. Value is a pair (COLUMNS . ROWS).
5476 Text larger than this is clipped. */);
5477 Vx_max_tooltip_size
= Fcons (make_number (80), make_number (40));
5479 DEFVAR_LISP ("x-no-window-manager", &Vx_no_window_manager
,
5480 doc
: /* Non-nil if no X window manager is in use.
5481 Emacs doesn't try to figure this out; this is always nil
5482 unless you set it to something else. */);
5483 /* We don't have any way to find this out, so set it to nil
5484 and maybe the user would like to set it to t. */
5485 Vx_no_window_manager
= Qnil
;
5487 DEFVAR_LISP ("x-pixel-size-width-font-regexp",
5488 &Vx_pixel_size_width_font_regexp
,
5489 doc
: /* Regexp matching a font name whose width is the same as `PIXEL_SIZE'.
5491 Since Emacs gets width of a font matching with this regexp from
5492 PIXEL_SIZE field of the name, font finding mechanism gets faster for
5493 such a font. This is especially effective for such large fonts as
5494 Chinese, Japanese, and Korean. */);
5495 Vx_pixel_size_width_font_regexp
= Qnil
;
5497 #ifdef USE_X_TOOLKIT
5498 Fprovide (intern ("x-toolkit"), Qnil
);
5500 Fprovide (intern ("motif"), Qnil
);
5502 DEFVAR_LISP ("motif-version-string", &Vmotif_version_string
,
5503 doc
: /* Version info for LessTif/Motif. */);
5504 Vmotif_version_string
= build_string (XmVERSION_STRING
);
5505 #endif /* USE_MOTIF */
5506 #endif /* USE_X_TOOLKIT */
5509 Fprovide (intern ("gtk"), Qnil
);
5511 DEFVAR_LISP ("gtk-version-string", &Vgtk_version_string
,
5512 doc
: /* Version info for GTK+. */);
5514 char gtk_version
[40];
5515 g_snprintf (gtk_version
, sizeof (gtk_version
), "%u.%u.%u",
5516 GTK_MAJOR_VERSION
, GTK_MINOR_VERSION
, GTK_MICRO_VERSION
);
5517 Vgtk_version_string
= build_string (gtk_version
);
5519 #endif /* USE_GTK */
5521 /* X window properties. */
5522 defsubr (&Sx_change_window_property
);
5523 defsubr (&Sx_delete_window_property
);
5524 defsubr (&Sx_window_property
);
5526 defsubr (&Sxw_display_color_p
);
5527 defsubr (&Sx_display_grayscale_p
);
5528 defsubr (&Sxw_color_defined_p
);
5529 defsubr (&Sxw_color_values
);
5530 defsubr (&Sx_server_max_request_size
);
5531 defsubr (&Sx_server_vendor
);
5532 defsubr (&Sx_server_version
);
5533 defsubr (&Sx_display_pixel_width
);
5534 defsubr (&Sx_display_pixel_height
);
5535 defsubr (&Sx_display_mm_width
);
5536 defsubr (&Sx_display_mm_height
);
5537 defsubr (&Sx_display_screens
);
5538 defsubr (&Sx_display_planes
);
5539 defsubr (&Sx_display_color_cells
);
5540 defsubr (&Sx_display_visual_class
);
5541 defsubr (&Sx_display_backing_store
);
5542 defsubr (&Sx_display_save_under
);
5543 defsubr (&Sx_create_frame
);
5544 defsubr (&Sx_open_connection
);
5545 defsubr (&Sx_close_connection
);
5546 defsubr (&Sx_display_list
);
5547 defsubr (&Sx_synchronize
);
5548 defsubr (&Sx_focus_frame
);
5549 defsubr (&Sx_backspace_delete_keys_p
);
5551 /* Setting callback functions for fontset handler. */
5552 get_font_info_func
= x_get_font_info
;
5554 #if 0 /* This function pointer doesn't seem to be used anywhere.
5555 And the pointer assigned has the wrong type, anyway. */
5556 list_fonts_func
= x_list_fonts
;
5559 load_font_func
= x_load_font
;
5560 find_ccl_program_func
= x_find_ccl_program
;
5561 query_font_func
= x_query_font
;
5562 set_frame_fontset_func
= x_set_font
;
5563 check_window_system_func
= check_x
;
5565 hourglass_atimer
= NULL
;
5566 hourglass_shown_p
= 0;
5568 defsubr (&Sx_show_tip
);
5569 defsubr (&Sx_hide_tip
);
5571 staticpro (&tip_timer
);
5573 staticpro (&tip_frame
);
5575 last_show_tip_args
= Qnil
;
5576 staticpro (&last_show_tip_args
);
5579 defsubr (&Sx_file_dialog
);
5583 #endif /* HAVE_X_WINDOWS */
5585 /* arch-tag: 55040d02-5485-4d58-8b22-95a7a05f3288
5586 (do not change this comment) */