/* Functions for the X window system.
-Copyright (C) 1989, 1992-2011 Free Software Foundation, Inc.
+Copyright (C) 1989, 1992-2012 Free Software Foundation, Inc.
This file is part of GNU Emacs.
#define MAXREQUEST(dpy) (XMaxRequestSize (dpy))
-/* The gray bitmap `bitmaps/gray'. This is done because xterm.c uses
- it, and including `bitmaps/gray' more than once is a problem when
- config.h defines `static' as an empty replacement string. */
-
-int gray_bitmap_width = gray_width;
-int gray_bitmap_height = gray_height;
-char *gray_bitmap_bits = gray_bits;
-
/* Nonzero if using X. */
-static int x_in_use;
+int x_in_use;
static Lisp_Object Qnone;
static Lisp_Object Qsuppress_icon;
FRAME_EXTERNAL_MENU_BAR (f) = 1;
if (FRAME_X_P (f) && f->output_data.x->menubar_widget == 0)
/* Make sure next redisplay shows the menu bar. */
- XWINDOW (FRAME_SELECTED_WINDOW (f))->update_mode_line = Qt;
+ XWINDOW (FRAME_SELECTED_WINDOW (f))->update_mode_line = 1;
}
else
{
FRAME_EXTERNAL_TOOL_BAR (f) = 1;
if (FRAME_X_P (f) && f->output_data.x->toolbar_widget == 0)
/* Make sure next redisplay shows the tool bar. */
- XWINDOW (FRAME_SELECTED_WINDOW (f))->update_mode_line = Qt;
+ XWINDOW (FRAME_SELECTED_WINDOW (f))->update_mode_line = 1;
update_frame_tool_bar (f);
}
else
#if defined HAVE_X_WINDOWS && defined USE_X_TOOLKIT
/* Create an X fontset on frame F with base font name BASE_FONTNAME. */
-static const char xic_defaut_fontset[] = "-*-*-*-r-normal--14-*-*-*-*-*-*-*";
+static const char xic_default_fontset[] = "-*-*-*-r-normal--14-*-*-*-*-*-*-*";
/* Create an Xt fontset spec from the name of a base font.
If `motif' is True use the Motif syntax. */
char *fontsetname;
/* Make a fontset name from the base font name. */
- if (xic_defaut_fontset == base_fontname)
+ if (xic_default_fontset == base_fontname)
{ /* There is no base font name, use the default. */
ptrdiff_t len = strlen (base_fontname) + 2;
fontsetname = xmalloc (len);
modify it to generalize it to allcs and allfamilies.
Use the specified font plus the default. */
ptrdiff_t len =
- strlen (base_fontname) + strlen (xic_defaut_fontset) + 3;
+ strlen (base_fontname) + strlen (xic_default_fontset) + 3;
fontsetname = xmalloc (len);
memset (fontsetname, 0, len);
strcpy (fontsetname, base_fontname);
strcat (fontsetname, sep);
- strcat (fontsetname, xic_defaut_fontset);
+ strcat (fontsetname, xic_default_fontset);
}
else
{
/* Do some needed geometry management. */
{
- ptrdiff_t len;
char *tem, shell_position[sizeof "=x++" + 4 * INT_STRLEN_BOUND (int)];
Arg gal[10];
int gac = 0;
}
}
- len = strlen (shell_position) + 1;
/* We don't free this because we don't know whether
it is safe to free it while the frame exists.
It isn't worth the trouble of arranging to free it
when the frame is deleted. */
- tem = (char *) xmalloc (len);
- strncpy (tem, shell_position, len);
+ tem = (char *) xstrdup (shell_position);
XtSetArg (gal[gac], XtNgeometry, tem); gac++;
XtSetValues (shell_widget, gal, gac);
}
/* Handler for signals raised during x_create_frame and
- x_create_top_frame. FRAME is the frame which is partially
+ x_create_tip_frame. FRAME is the frame which is partially
constructed. */
static Lisp_Object
return Qnil;
/* If frame is ``official'', nothing to do. */
- if (!CONSP (Vframe_list) || !EQ (XCAR (Vframe_list), frame))
+ if (NILP (Fmemq (frame, Vframe_list)))
{
#if GLYPH_DEBUG && XASSERTS
struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
#endif
x_free_frame_resources (f);
+ free_glyphs (f);
#if GLYPH_DEBUG
/* Check that reference counts are indeed correct. */
return Qnil;
}
+static Lisp_Object
+unwind_create_frame_1 (Lisp_Object val)
+{
+ inhibit_lisp_code = val;
+ return Qnil;
+}
static void
x_default_font_parameter (struct frame *f, Lisp_Object parms)
if (NILP (font_param))
{
- /* System font should take precedendce over X resources. We suggest this
+ /* System font should take precedence over X resources. We suggest this
regardless of font-use-system-font because .emacs may not have been
read yet. */
const char *system_font = xsettings_get_system_font ();
FRAME_CAN_HAVE_SCROLL_BARS (f) = 1;
f->terminal = dpyinfo->terminal;
- f->terminal->reference_count++;
f->output_method = output_x_window;
f->output_data.x = (struct x_output *) xmalloc (sizeof (struct x_output));
to get the color reference counts right, so initialize them! */
{
Lisp_Object black;
- struct gcpro inner_gcpro1;
+ struct gcpro gcpro1;
/* Function x_decode_color can signal an error. Make
sure to initialize color slots so that we won't try
f->output_data.x->mouse_pixel = -1;
black = build_string ("black");
- GCPRO1_VAR (black, inner_gcpro);
+ GCPRO1 (black);
FRAME_FOREGROUND_PIXEL (f)
= x_decode_color (f, black, BLACK_PIX_DEFAULT (f));
FRAME_BACKGROUND_PIXEL (f)
= x_decode_color (f, black, BLACK_PIX_DEFAULT (f));
f->output_data.x->mouse_pixel
= x_decode_color (f, black, BLACK_PIX_DEFAULT (f));
- UNGCPRO_VAR (inner_gcpro);
+ UNGCPRO;
}
/* Specify the parent under which to make this X window. */
"scrollBarBackground",
"ScrollBarBackground", 0);
+#if GLYPH_DEBUG
+ image_cache_refcount =
+ FRAME_IMAGE_CACHE (f) ? FRAME_IMAGE_CACHE (f)->refcount : 0;
+ dpyinfo_refcount = dpyinfo->reference_count;
+#endif /* GLYPH_DEBUG */
+
/* Init faces before x_default_parameter is called for scroll-bar
parameters because that function calls x_set_scroll_bar_width,
which calls change_frame_size, which calls Fset_window_buffer,
happen. */
init_frame_faces (f);
-#if GLYPH_DEBUG
- image_cache_refcount = FRAME_IMAGE_CACHE (f)->refcount;
- dpyinfo_refcount = dpyinfo->reference_count;
-#endif /* GLYPH_DEBUG */
+ /* Set the menu-bar-lines and tool-bar-lines parameters. We don't
+ look up the X resources controlling the menu-bar and tool-bar
+ here; they are processed specially at startup, and reflected in
+ the values of the mode variables.
- /* The X resources controlling the menu-bar and tool-bar are
- processed specially at startup, and reflected in the mode
- variables; ignore them here. */
- x_default_parameter (f, parms, Qmenu_bar_lines,
- NILP (Vmenu_bar_mode)
- ? make_number (0) : make_number (1),
- NULL, NULL, RES_TYPE_NUMBER);
- x_default_parameter (f, parms, Qtool_bar_lines,
- NILP (Vtool_bar_mode)
- ? make_number (0) : make_number (1),
- NULL, NULL, RES_TYPE_NUMBER);
+ Avoid calling window-configuration-change-hook; otherwise we
+ could get an infloop in next_frame since the frame is not yet in
+ Vframe_list. */
+ {
+ ptrdiff_t count2 = SPECPDL_INDEX ();
+ record_unwind_protect (unwind_create_frame_1, inhibit_lisp_code);
+ inhibit_lisp_code = Qt;
+
+ x_default_parameter (f, parms, Qmenu_bar_lines,
+ NILP (Vmenu_bar_mode)
+ ? make_number (0) : make_number (1),
+ NULL, NULL, RES_TYPE_NUMBER);
+ x_default_parameter (f, parms, Qtool_bar_lines,
+ NILP (Vtool_bar_mode)
+ ? make_number (0) : make_number (1),
+ NULL, NULL, RES_TYPE_NUMBER);
+
+ unbind_to (count2, Qnil);
+ }
x_default_parameter (f, parms, Qbuffer_predicate, Qnil,
"bufferPredicate", "BufferPredicate",
x_make_gc (f);
/* Now consider the frame official. */
+ f->terminal->reference_count++;
FRAME_X_DISPLAY_INFO (f)->reference_count++;
Vframe_list = Fcons (frame, Vframe_list);
BLOCK_INPUT;
x_catch_errors (dpy);
- XSetInputFocus (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
- RevertToParent, CurrentTime);
- x_ewmh_activate_frame (f);
+
+ if (FRAME_X_EMBEDDED_P (f))
+ {
+ /* For Xembedded frames, normally the embedder forwards key
+ events. See XEmbed Protocol Specification at
+ http://freedesktop.org/wiki/Specifications/xembed-spec */
+ xembed_request_focus (f);
+ }
+ else
+ {
+ XSetInputFocus (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
+ RevertToParent, CurrentTime);
+ x_ewmh_activate_frame (f);
+ }
+
x_uncatch_errors ();
UNBLOCK_INPUT;
DEFUN ("x-server-vendor", Fx_server_vendor, Sx_server_vendor, 0, 1, 0,
doc: /* Return the "vendor ID" string of the X server of display TERMINAL.
-\(Labelling every distributor as a "vendor" embodies the false assumption
+\(Labeling every distributor as a "vendor" embodies the false assumption
that operating systems cannot be developed and distributed noncommercially.)
The optional argument TERMINAL specifies which display to ask about.
TERMINAL should be a terminal object, a frame or a display name (a string).
Otherwise TYPE is the name of the atom that denotes the type expected.
If SOURCE is non-nil, get the property on that window instead of from
FRAME. The number 0 denotes the root window.
-If DELETE_P is non-nil, delete the property after retreiving it.
+If DELETE_P is non-nil, delete the property after retrieving it.
If VECTOR_RET_P is non-nil, don't return a string but a vector of values.
Value is nil if FRAME hasn't a property with name PROP or if PROP has
record_unwind_protect (unwind_create_tip_frame, frame);
f->terminal = dpyinfo->terminal;
- f->terminal->reference_count++;
/* By setting the output method, we're essentially saying that
the frame is live, as per FRAME_LIVE_P. If we get a signal
to get the color reference counts right, so initialize them! */
{
Lisp_Object black;
- struct gcpro inner_gcpro1;
+ struct gcpro gcpro1;
/* Function x_decode_color can signal an error. Make
sure to initialize color slots so that we won't try
f->output_data.x->mouse_pixel = -1;
black = build_string ("black");
- GCPRO1_VAR (black, inner_gcpro);
+ GCPRO1 (black);
FRAME_FOREGROUND_PIXEL (f)
= x_decode_color (f, black, BLACK_PIX_DEFAULT (f));
FRAME_BACKGROUND_PIXEL (f)
= x_decode_color (f, black, BLACK_PIX_DEFAULT (f));
f->output_data.x->mouse_pixel
= x_decode_color (f, black, BLACK_PIX_DEFAULT (f));
- UNGCPRO_VAR (inner_gcpro);
+ UNGCPRO;
}
/* Set the name; the functions to which we pass f expect the name to
x_default_parameter (f, parms, Qborder_color, build_string ("black"),
"borderColor", "BorderColor", RES_TYPE_STRING);
+#if GLYPH_DEBUG
+ image_cache_refcount =
+ FRAME_IMAGE_CACHE (f) ? FRAME_IMAGE_CACHE (f)->refcount : 0;
+ dpyinfo_refcount = dpyinfo->reference_count;
+#endif /* GLYPH_DEBUG */
+
/* Init faces before x_default_parameter is called for scroll-bar
parameters because that function calls x_set_scroll_bar_width,
which calls change_frame_size, which calls Fset_window_buffer,
happen. */
init_frame_faces (f);
-#if GLYPH_DEBUG
- image_cache_refcount = FRAME_IMAGE_CACHE (f)->refcount;
- dpyinfo_refcount = dpyinfo->reference_count;
-#endif /* GLYPH_DEBUG */
-
f->output_data.x->parent_desc = FRAME_X_DISPLAY_INFO (f)->root_window;
x_figure_window_size (f, parms, 0);
UNGCPRO;
+ /* Now that the frame will be official, it counts as a reference to
+ its display and terminal. */
+ FRAME_X_DISPLAY_INFO (f)->reference_count++;
+ f->terminal->reference_count++;
+
/* It is now ok to make the frame official even if we get an error
below. And the frame needs to be on Vframe_list or making it
visible won't work. */
Vframe_list = Fcons (frame, Vframe_list);
- /* Now that the frame is official, it counts as a reference to
- its display. */
- FRAME_X_DISPLAY_INFO (f)->reference_count++;
/* Setting attributes of faces of the tooltip frame from resources
and similar will increment face_change_count, which leads to the
/* This is not ifdef:ed, so other builds than GTK can customize it. */
DEFVAR_BOOL ("x-gtk-use-old-file-dialog", x_gtk_use_old_file_dialog,
- doc: /* *Non-nil means prompt with the old GTK file selection dialog.
+ doc: /* Non-nil means prompt with the old GTK file selection dialog.
If nil or if the file selection dialog is not available, the new GTK file
chooser is used instead. To turn off all file dialogs set the
variable `use-file-dialog'. */);
x_gtk_use_old_file_dialog = 0;
DEFVAR_BOOL ("x-gtk-show-hidden-files", x_gtk_show_hidden_files,
- doc: /* *If non-nil, the GTK file chooser will by default show hidden files.
+ doc: /* If non-nil, the GTK file chooser will by default show hidden files.
Note that this is just the default, there is a toggle button on the file
chooser to show or not show hidden files on a case by case basis. */);
x_gtk_show_hidden_files = 0;
DEFVAR_BOOL ("x-gtk-file-dialog-help-text", x_gtk_file_dialog_help_text,
- doc: /* *If non-nil, the GTK file chooser will show additional help text.
+ doc: /* If non-nil, the GTK file chooser will show additional help text.
If more space for files in the file chooser dialog is wanted, set this to nil
to turn the additional text off. */);
x_gtk_file_dialog_help_text = 1;
DEFVAR_BOOL ("x-gtk-whole-detached-tool-bar", x_gtk_whole_detached_tool_bar,
- doc: /* *If non-nil, a detached tool bar is shown in full.
+ doc: /* If non-nil, a detached tool bar is shown in full.
The default is to just show an arrow and pressing on that arrow shows
the tool bar buttons. */);
x_gtk_whole_detached_tool_bar = 0;
DEFVAR_BOOL ("x-gtk-use-system-tooltips", x_gtk_use_system_tooltips,
- doc: /* *If non-nil with a Gtk+ built Emacs, the Gtk+ toolip is used.
+ doc: /* If non-nil with a Gtk+ built Emacs, the Gtk+ tooltip is used.
Otherwise use Emacs own tooltip implementation.
When using Gtk+ tooltips, the tooltip face is not used. */);
x_gtk_use_system_tooltips = 1;