/* Functions for the X window system.
Copyright (C) 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
- 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+ 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
Free Software Foundation, Inc.
This file is part of GNU Emacs.
#include <config.h>
#include <stdio.h>
#include <math.h>
+#include <setjmp.h>
+#include <ctype.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#include <X11/bitmaps/gray>
#endif
+#include "xsettings.h"
+
#ifdef USE_GTK
#include "gtkutil.h"
#endif
#include <Xm/FileSB.h>
#endif
-/* Do the EDITRES protocol if running X11R5
- Exception: HP-UX (at least version A.09.05) has X11R5 without EditRes */
-
-#if (XtSpecificationRelease >= 5) && !defined(NO_EDITRES)
+#if !defined(NO_EDITRES)
#define HACK_EDITRES
extern void _XEditResCheckMessages ();
-#endif /* R5 + Athena */
+#endif /* not defined NO_EDITRES */
/* Unique id counter for widgets created by the Lucid Widget Library. */
extern LWLIB_ID widget_id_tick;
-#ifdef USE_LUCID
-/* This is part of a kludge--see lwlib/xlwmenu.c. */
-extern XFontStruct *xlwmenu_default_font;
-#endif
-
extern void free_frame_menubar ();
extern double atof ();
Lisp_Object Qsuppress_icon;
Lisp_Object Qundefined_color;
Lisp_Object Qcompound_text, Qcancel_timer;
-static Lisp_Object Qfont_param;
+Lisp_Object Qfont_param;
/* In dispnew.c */
extern Lisp_Object Vwindow_system_version;
+/* In editfns.c */
+
+extern Lisp_Object Vsystem_name;
+
/* The below are defined in frame.c. */
+extern Lisp_Object Vmenu_bar_mode, Vtool_bar_mode;
+
#if GLYPH_DEBUG
int image_cache_refcount, dpyinfo_refcount;
#endif
/* Error if we are not connected to X. */
void
-check_x ()
+check_x (void)
{
if (! x_in_use)
error ("X windows are not in use or not initialized");
You should not call this unless HAVE_MENUS is defined. */
int
-have_menus_p ()
+have_menus_p (void)
{
return x_in_use;
}
and checking validity for X. */
FRAME_PTR
-check_x_frame (frame)
- Lisp_Object frame;
+check_x_frame (Lisp_Object frame)
{
FRAME_PTR f;
the first X display on the list. */
struct x_display_info *
-check_x_display_info (object)
- Lisp_Object object;
+check_x_display_info (Lisp_Object object)
{
struct x_display_info *dpyinfo = NULL;
/* This function can be called during GC, so use GC_xxx type test macros. */
struct frame *
-x_window_to_frame (dpyinfo, wdesc)
- struct x_display_info *dpyinfo;
- int wdesc;
+x_window_to_frame (struct x_display_info *dpyinfo, int wdesc)
{
Lisp_Object tail, frame;
struct frame *f;
windows. */
struct frame *
-x_any_window_to_frame (dpyinfo, wdesc)
- struct x_display_info *dpyinfo;
- int wdesc;
+x_any_window_to_frame (struct x_display_info *dpyinfo, int wdesc)
{
Lisp_Object tail, frame;
struct frame *f, *found;
/* Likewise, but consider only the menu bar widget. */
struct frame *
-x_menubar_window_to_frame (dpyinfo, wdesc)
- struct x_display_info *dpyinfo;
- int wdesc;
+x_menubar_window_to_frame (struct x_display_info *dpyinfo, int wdesc)
{
Lisp_Object tail, frame;
struct frame *f;
If WDESC is some other (smaller) window, we return 0. */
struct frame *
-x_top_window_to_frame (dpyinfo, wdesc)
- struct x_display_info *dpyinfo;
- int wdesc;
+x_top_window_to_frame (struct x_display_info *dpyinfo, int wdesc)
{
Lisp_Object tail, frame;
struct frame *f;
\f
-static void x_default_font_parameter P_ ((struct frame *, Lisp_Object));
-
-static Lisp_Object unwind_create_frame P_ ((Lisp_Object));
-static Lisp_Object unwind_create_tip_frame P_ ((Lisp_Object));
-
-void x_set_foreground_color P_ ((struct frame *, Lisp_Object, Lisp_Object));
-static void x_set_wait_for_wm P_ ((struct frame *, Lisp_Object, Lisp_Object));
-void x_set_background_color P_ ((struct frame *, Lisp_Object, Lisp_Object));
-void x_set_mouse_color P_ ((struct frame *, Lisp_Object, Lisp_Object));
-void x_set_cursor_color P_ ((struct frame *, Lisp_Object, Lisp_Object));
-void x_set_border_color P_ ((struct frame *, Lisp_Object, Lisp_Object));
-void x_set_cursor_type P_ ((struct frame *, Lisp_Object, Lisp_Object));
-void x_set_icon_type P_ ((struct frame *, Lisp_Object, Lisp_Object));
-void x_set_icon_name P_ ((struct frame *, Lisp_Object, Lisp_Object));
-void x_explicitly_set_name P_ ((struct frame *, Lisp_Object, Lisp_Object));
-void x_set_menu_bar_lines P_ ((struct frame *, Lisp_Object, Lisp_Object));
-void x_set_title P_ ((struct frame *, Lisp_Object, Lisp_Object));
-void x_set_tool_bar_lines P_ ((struct frame *, Lisp_Object, Lisp_Object));
-void x_set_scroll_bar_foreground P_ ((struct frame *, Lisp_Object,
- Lisp_Object));
-void x_set_scroll_bar_background P_ ((struct frame *, Lisp_Object,
- Lisp_Object));
-static Lisp_Object x_default_scroll_bar_color_parameter P_ ((struct frame *,
- Lisp_Object,
- Lisp_Object,
- char *, char *,
- int));
+static void x_default_font_parameter (struct frame *, Lisp_Object);
+
+static Lisp_Object unwind_create_frame (Lisp_Object);
+static Lisp_Object unwind_create_tip_frame (Lisp_Object);
+
+void x_set_foreground_color (struct frame *, Lisp_Object, Lisp_Object);
+static void x_set_wait_for_wm (struct frame *, Lisp_Object, Lisp_Object);
+void x_set_background_color (struct frame *, Lisp_Object, Lisp_Object);
+void x_set_mouse_color (struct frame *, Lisp_Object, Lisp_Object);
+void x_set_cursor_color (struct frame *, Lisp_Object, Lisp_Object);
+void x_set_border_color (struct frame *, Lisp_Object, Lisp_Object);
+void x_set_cursor_type (struct frame *, Lisp_Object, Lisp_Object);
+void x_set_icon_type (struct frame *, Lisp_Object, Lisp_Object);
+void x_set_icon_name (struct frame *, Lisp_Object, Lisp_Object);
+void x_explicitly_set_name (struct frame *, Lisp_Object, Lisp_Object);
+void x_set_menu_bar_lines (struct frame *, Lisp_Object, Lisp_Object);
+void x_set_title (struct frame *, Lisp_Object, Lisp_Object);
+void x_set_tool_bar_lines (struct frame *, Lisp_Object, Lisp_Object);
+void x_set_scroll_bar_foreground (struct frame *, Lisp_Object,
+ Lisp_Object);
+void x_set_scroll_bar_background (struct frame *, Lisp_Object,
+ Lisp_Object);
+static Lisp_Object x_default_scroll_bar_color_parameter (struct frame *,
+ Lisp_Object,
+ Lisp_Object,
+ char *, char *,
+ int);
\f
/* Store the screen positions of frame F into XPTR and YPTR.
not Emacs's own window. */
void
-x_real_positions (f, xptr, yptr)
- FRAME_PTR f;
- int *xptr, *yptr;
+x_real_positions (FRAME_PTR f, int *xptr, int *yptr)
{
int win_x, win_y, outer_x, outer_y;
int real_x = 0, real_y = 0;
/* Gamma-correct COLOR on frame F. */
void
-gamma_correct (f, color)
- struct frame *f;
- XColor *color;
+gamma_correct (struct frame *f, XColor *color)
{
if (f->gamma)
{
no color could be allocated. */
int
-x_defined_color (f, color_name, color, alloc_p)
- struct frame *f;
- char *color_name;
- XColor *color;
- int alloc_p;
+x_defined_color (struct frame *f, char *color_name, XColor *color, int alloc_p)
{
int success_p;
Display *dpy = FRAME_X_DISPLAY (f);
Signal an error if color can't be allocated. */
int
-x_decode_color (f, color_name, mono_color)
- FRAME_PTR f;
- Lisp_Object color_name;
- int mono_color;
+x_decode_color (FRAME_PTR f, Lisp_Object color_name, int mono_color)
{
XColor cdef;
See also the comment of wait_for_wm in struct x_output. */
static void
-x_set_wait_for_wm (f, new_value, old_value)
- struct frame *f;
- Lisp_Object new_value, old_value;
+x_set_wait_for_wm (struct frame *f, Lisp_Object new_value, Lisp_Object old_value)
{
f->output_data.x->wait_for_wm = !NILP (new_value);
}
may be any format that GdkPixbuf knows about, i.e. not just bitmaps. */
int
-xg_set_icon (f, file)
- FRAME_PTR f;
- Lisp_Object file;
+xg_set_icon (FRAME_PTR f, Lisp_Object file)
{
int result = 0;
Lisp_Object found;
}
int
-xg_set_icon_from_xpm_data (f, data)
- FRAME_PTR f;
- char **data;
+xg_set_icon_from_xpm_data (FRAME_PTR f, char **data)
{
int result = 0;
GdkPixbuf *pixbuf = gdk_pixbuf_new_from_xpm_data ((const char **) data);
in the standard place; do not attempt to change the window. */
void
-x_set_foreground_color (f, arg, oldval)
- struct frame *f;
- Lisp_Object arg, oldval;
+x_set_foreground_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
{
struct x_output *x = f->output_data.x;
unsigned long fg, old_fg;
}
void
-x_set_background_color (f, arg, oldval)
- struct frame *f;
- Lisp_Object arg, oldval;
+x_set_background_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
{
struct x_output *x = f->output_data.x;
unsigned long bg;
}
static Cursor
-make_invisible_cursor (f)
- struct frame *f;
+make_invisible_cursor (struct frame *f)
{
Display *dpy = FRAME_X_DISPLAY (f);
static char const no_data[] = { 0 };
}
void
-x_set_mouse_color (f, arg, oldval)
- struct frame *f;
- Lisp_Object arg, oldval;
+x_set_mouse_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
{
struct x_output *x = f->output_data.x;
Display *dpy = FRAME_X_DISPLAY (f);
}
void
-x_set_cursor_color (f, arg, oldval)
- struct frame *f;
- Lisp_Object arg, oldval;
+x_set_cursor_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
{
unsigned long fore_pixel, pixel;
int fore_pixel_allocated_p = 0, pixel_allocated_p = 0;
F has an x-window. */
void
-x_set_border_pixel (f, pix)
- struct frame *f;
- int pix;
+x_set_border_pixel (struct frame *f, int pix)
{
unload_color (f, f->output_data.x->border_pixel);
f->output_data.x->border_pixel = pix;
and so emacs' border colors may be overridden. */
void
-x_set_border_color (f, arg, oldval)
- struct frame *f;
- Lisp_Object arg, oldval;
+x_set_border_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
{
int pix;
void
-x_set_cursor_type (f, arg, oldval)
- FRAME_PTR f;
- Lisp_Object arg, oldval;
+x_set_cursor_type (FRAME_PTR f, Lisp_Object arg, Lisp_Object oldval)
{
set_frame_cursor_types (f, arg);
}
\f
void
-x_set_icon_type (f, arg, oldval)
- struct frame *f;
- Lisp_Object arg, oldval;
+x_set_icon_type (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
{
int result;
}
void
-x_set_icon_name (f, arg, oldval)
- struct frame *f;
- Lisp_Object arg, oldval;
+x_set_icon_name (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
{
int result;
\f
void
-x_set_menu_bar_lines (f, value, oldval)
- struct frame *f;
- Lisp_Object value, oldval;
+x_set_menu_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
{
int nlines;
#if ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)
#else /* not USE_X_TOOLKIT && not USE_GTK */
FRAME_MENU_BAR_LINES (f) = nlines;
change_window_heights (f->root_window, nlines - olines);
-#endif /* not USE_X_TOOLKIT */
+
+ /* If the menu bar height gets changed, the internal border below
+ the top margin has to be cleared. Also, if the menu bar gets
+ larger, the area for the added lines has to be cleared except for
+ the first menu bar line that is to be drawn later. */
+ if (nlines != olines)
+ {
+ int height = FRAME_INTERNAL_BORDER_WIDTH (f);
+ int width = FRAME_PIXEL_WIDTH (f);
+ int y;
+
+ /* height can be zero here. */
+ if (height > 0 && width > 0)
+ {
+ y = FRAME_TOP_MARGIN_HEIGHT (f);
+
+ BLOCK_INPUT;
+ x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
+ 0, y, width, height, False);
+ UNBLOCK_INPUT;
+ }
+
+ if (nlines > 1 && nlines > olines)
+ {
+ y = (olines == 0 ? 1 : olines) * FRAME_LINE_HEIGHT (f);
+ height = nlines * FRAME_LINE_HEIGHT (f) - y;
+
+ BLOCK_INPUT;
+ x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
+ 0, y, width, height, False);
+ UNBLOCK_INPUT;
+ }
+
+ if (nlines == 0 && WINDOWP (f->menu_bar_window))
+ clear_glyph_matrix (XWINDOW (f->menu_bar_window)->current_matrix);
+ }
+#endif /* not USE_X_TOOLKIT && not USE_GTK */
adjust_glyphs (f);
}
The frame's height doesn't change. */
void
-x_set_tool_bar_lines (f, value, oldval)
- struct frame *f;
- Lisp_Object value, oldval;
+x_set_tool_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
{
int delta, nlines, root_height;
Lisp_Object root_window;
{
int height = FRAME_INTERNAL_BORDER_WIDTH (f);
int width = FRAME_PIXEL_WIDTH (f);
- int y = nlines * FRAME_LINE_HEIGHT (f);
+ int y = (FRAME_MENU_BAR_LINES (f) + nlines) * FRAME_LINE_HEIGHT (f);
/* height can be zero here. */
if (height > 0 && width > 0)
the frame parameter. */
void
-x_set_scroll_bar_foreground (f, value, oldval)
- struct frame *f;
- Lisp_Object value, oldval;
+x_set_scroll_bar_foreground (struct frame *f, Lisp_Object value, Lisp_Object oldval)
{
unsigned long pixel;
parameter. */
void
-x_set_scroll_bar_background (f, value, oldval)
- struct frame *f;
- Lisp_Object value, oldval;
+x_set_scroll_bar_background (struct frame *f, Lisp_Object value, Lisp_Object oldval)
{
unsigned long pixel;
the result should be `COMPOUND_TEXT'. */
static unsigned char *
-x_encode_text (string, coding_system, selectionp, text_bytes, stringp, freep)
- Lisp_Object string, coding_system;
- int *text_bytes, *stringp;
- int selectionp;
- int *freep;
+x_encode_text (Lisp_Object string, Lisp_Object coding_system, int selectionp, int *text_bytes, int *stringp, int *freep)
{
int result = string_xstring_p (string);
struct coding_system coding;
icon name to NAME. */
static void
-x_set_name_internal (f, name)
- FRAME_PTR f;
- Lisp_Object name;
+x_set_name_internal (FRAME_PTR f, Lisp_Object name)
{
if (FRAME_X_WINDOW (f))
{
int bytes, stringp;
int do_free_icon_value = 0, do_free_text_value = 0;
Lisp_Object coding_system;
-#ifdef USE_GTK
Lisp_Object encoded_name;
+ Lisp_Object encoded_icon_name;
struct gcpro gcpro1;
/* As ENCODE_UTF_8 may cause GC and relocation of string data,
GCPRO1 (name);
encoded_name = ENCODE_UTF_8 (name);
UNGCPRO;
-#endif
coding_system = Qcompound_text;
/* Note: Encoding strategy
We may also be able to use "UTF8_STRING" in text.encoding
in the future which can encode all Unicode characters.
But, for the moment, there's no way to know that the
- current window manager supports it or not. */
+ current window manager supports it or not.
+
+ Either way, we also set the _NET_WM_NAME and _NET_WM_ICON_NAME
+ properties. Per the EWMH specification, those two properties
+ are always UTF8_STRING. This matches what gtk_window_set_title()
+ does in the USE_GTK case. */
text.value = x_encode_text (name, coding_system, 0, &bytes, &stringp,
&do_free_text_value);
text.encoding = (stringp ? XA_STRING
if (!STRINGP (f->icon_name))
{
icon = text;
+ encoded_icon_name = encoded_name;
}
else
{
: FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT);
icon.format = 8;
icon.nitems = bytes;
+
+ encoded_icon_name = ENCODE_UTF_8 (f->icon_name);
}
#ifdef USE_GTK
(char *) SDATA (encoded_name));
#else /* not USE_GTK */
XSetWMName (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), &text);
+ XChangeProperty (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f),
+ FRAME_X_DISPLAY_INFO (f)->Xatom_net_wm_name,
+ FRAME_X_DISPLAY_INFO (f)->Xatom_UTF8_STRING,
+ 8, PropModeReplace,
+ (char *) SDATA (encoded_name),
+ SBYTES (encoded_name));
#endif /* not USE_GTK */
XSetWMIconName (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), &icon);
+ XChangeProperty (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f),
+ FRAME_X_DISPLAY_INFO (f)->Xatom_net_wm_icon_name,
+ FRAME_X_DISPLAY_INFO (f)->Xatom_UTF8_STRING,
+ 8, PropModeReplace,
+ (char *) SDATA (encoded_icon_name),
+ SBYTES (encoded_icon_name));
if (do_free_icon_value)
xfree (icon.value);
F->explicit_name is set, ignore the new name; otherwise, set it. */
void
-x_set_name (f, name, explicit)
- struct frame *f;
- Lisp_Object name;
- int explicit;
+x_set_name (struct frame *f, Lisp_Object name, int explicit)
{
/* Make sure that requests from lisp code override requests from
Emacs redisplay code. */
specified a name for the frame; the name will override any set by the
redisplay code. */
void
-x_explicitly_set_name (f, arg, oldval)
- FRAME_PTR f;
- Lisp_Object arg, oldval;
+x_explicitly_set_name (FRAME_PTR f, Lisp_Object arg, Lisp_Object oldval)
{
x_set_name (f, arg, 1);
}
name; names set this way will never override names set by the user's
lisp code. */
void
-x_implicitly_set_name (f, arg, oldval)
- FRAME_PTR f;
- Lisp_Object arg, oldval;
+x_implicitly_set_name (FRAME_PTR f, Lisp_Object arg, Lisp_Object oldval)
{
x_set_name (f, arg, 0);
}
If NAME is nil, use the frame name as the title. */
void
-x_set_title (f, name, old_name)
- struct frame *f;
- Lisp_Object name, old_name;
+x_set_title (struct frame *f, Lisp_Object name, Lisp_Object old_name)
{
/* Don't change the title if it's already NAME. */
if (EQ (name, f->title))
}
void
-x_set_scroll_bar_default_width (f)
- struct frame *f;
+x_set_scroll_bar_default_width (struct frame *f)
{
int wid = FRAME_COLUMN_WIDTH (f);
#ifdef HAVE_X_I18N
-static XFontSet xic_create_xfontset P_ ((struct frame *));
-static XIMStyle best_xim_style P_ ((XIMStyles *, XIMStyles *));
+static XFontSet xic_create_xfontset (struct frame *);
+static XIMStyle best_xim_style (XIMStyles *, XIMStyles *);
/* Supported XIM styles, ordered by preference. */
/* Create an Xt fontset spec from the name of a base font.
If `motif' is True use the Motif syntax. */
char *
-xic_create_fontsetname (base_fontname, motif)
- char *base_fontname;
- Bool motif;
+xic_create_fontsetname (char *base_fontname, int motif)
{
const char *sep = motif ? ";" : ",";
char *fontsetname;
#endif
static XFontSet
-xic_create_xfontset (f)
- struct frame *f;
+xic_create_xfontset (struct frame *f)
{
XFontSet xfs = NULL;
struct font *font = FRAME_FONT (f);
/* Free the X fontset of frame F if it is the last frame using it. */
void
-xic_free_xfontset (f)
- struct frame *f;
+xic_free_xfontset (struct frame *f)
{
Lisp_Object rest, frame;
int shared_p = 0;
input method XIM. */
static XIMStyle
-best_xim_style (user, xim)
- XIMStyles *user;
- XIMStyles *xim;
+best_xim_style (XIMStyles *user, XIMStyles *xim)
{
int i, j;
static XIMStyle xic_style;
void
-create_frame_xic (f)
- struct frame *f;
+create_frame_xic (struct frame *f)
{
XIM xim;
XIC xic = NULL;
/* Destroy XIC and free XIC fontset of frame F, if any. */
void
-free_frame_xic (f)
- struct frame *f;
+free_frame_xic (struct frame *f)
{
if (FRAME_XIC (f) == NULL)
return;
pixel position X/Y. X and Y are relative to window W. */
void
-xic_set_preeditarea (w, x, y)
- struct window *w;
- int x, y;
+xic_set_preeditarea (struct window *w, int x, int y)
{
struct frame *f = XFRAME (w->frame);
XVaNestedList attr;
/* Place status area for XIC in bottom right corner of frame F.. */
void
-xic_set_statusarea (f)
- struct frame *f;
+xic_set_statusarea (struct frame *f)
{
XIC xic = FRAME_XIC (f);
XVaNestedList attr;
BASE_FONTNAME. Called when a new Emacs fontset is chosen. */
void
-xic_set_xfontset (f, base_fontname)
- struct frame *f;
- char *base_fontname;
+xic_set_xfontset (struct frame *f, char *base_fontname)
{
XVaNestedList attr;
XFontSet xfs;
#else /* not USE_X_TOOLKIT */
#ifdef USE_GTK
void
-x_window (f)
- FRAME_PTR f;
+x_window (FRAME_PTR f)
{
if (! xg_create_frame_widgets (f))
error ("Unable to create window");
/* Verify that the icon position args for this window are valid. */
static void
-x_icon_verify (f, parms)
- struct frame *f;
- Lisp_Object parms;
+x_icon_verify (struct frame *f, Lisp_Object parms)
{
Lisp_Object icon_x, icon_y;
well. */
static void
-x_icon (f, parms)
- struct frame *f;
- Lisp_Object parms;
+x_icon (struct frame *f, Lisp_Object parms)
{
Lisp_Object icon_x, icon_y;
#if 0
background, border and mouse colors; also create the
mouse cursor and the gray border tile. */
-static char cursor_bits[] =
- {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
- };
-
static void
-x_make_gc (f)
- struct frame *f;
+x_make_gc (struct frame *f)
{
XGCValues gc_values;
/* Free what was allocated in x_make_gc. */
void
-x_free_gcs (f)
- struct frame *f;
+x_free_gcs (struct frame *f)
{
Display *dpy = FRAME_X_DISPLAY (f);
constructed. */
static Lisp_Object
-unwind_create_frame (frame)
- Lisp_Object frame;
+unwind_create_frame (Lisp_Object frame)
{
struct frame *f = XFRAME (frame);
static void
-x_default_font_parameter (f, parms)
- struct frame *f;
- Lisp_Object parms;
+x_default_font_parameter (struct frame *f, Lisp_Object parms)
{
struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
Lisp_Object font_param = x_get_arg (dpyinfo, parms, Qfont, NULL, NULL,
- RES_TYPE_STRING);
- Lisp_Object font;
+ RES_TYPE_STRING);
+ Lisp_Object font = Qnil;
if (EQ (font_param, Qunbound))
font_param = Qnil;
- font = !NILP (font_param) ? font_param
- : x_get_arg (dpyinfo, parms, Qfont, "font", "Font", RES_TYPE_STRING);
- if (! STRINGP (font))
+ if (NILP (font_param))
+ {
+ /* System font should take precedendce 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 ();
+ if (system_font)
+ {
+ char *name = xstrdup (system_font);
+ font = font_open_by_name (f, name);
+ free (name);
+ }
+ }
+
+ if (NILP (font))
+ font = !NILP (font_param) ? font_param
+ : x_get_arg (dpyinfo, parms, Qfont, "font", "Font", RES_TYPE_STRING);
+
+ if (! FONTP (font) && ! STRINGP (font))
{
char *names[]
= {
#ifdef HAVE_XFT
/* This will find the normal Xft font. */
- "monospace-12",
+ "monospace-10",
#endif
"-adobe-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-1",
"-misc-fixed-medium-r-normal-*-*-140-*-*-c-*-iso8859-1",
we've applied the `default' face settings. */
x_set_frame_parameters (f, Fcons (Fcons (Qfont_param, font_param), Qnil));
}
+
+ /* This call will make X resources override any system font setting. */
x_default_parameter (f, parms, Qfont, font, "font", "Font", RES_TYPE_STRING);
}
return Qnil;
}
+static void
+set_machine_and_pid_properties (struct frame *f)
+{
+ /* See the above comment "Note: Encoding strategy". */
+ XTextProperty text;
+ int bytes, stringp;
+ int do_free_text_value = 0;
+ long pid = (long) getpid ();
+
+ text.value = x_encode_text (Vsystem_name,
+ Qcompound_text, 0, &bytes, &stringp,
+ &do_free_text_value);
+ text.encoding = (stringp ? XA_STRING
+ : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT);
+ text.format = 8;
+ text.nitems = bytes;
+ XSetWMClientMachine (FRAME_X_DISPLAY (f),
+ FRAME_OUTER_WINDOW (f),
+ &text);
+ if (do_free_text_value)
+ xfree (text.value);
+
+ XChangeProperty (FRAME_X_DISPLAY (f),
+ FRAME_OUTER_WINDOW (f),
+ XInternAtom (FRAME_X_DISPLAY (f),
+ "_NET_WM_PID",
+ False),
+ XA_CARDINAL, 32, PropModeReplace,
+ (unsigned char *) &pid, 1);
+}
+
DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
1, 1, 0,
doc: /* Make a new X window, which is called a "frame" in Emacs terms.
error ("Invalid frame font");
}
-#ifdef USE_LUCID
- /* Prevent lwlib/xlwmenu.c from crashing because of a bug
- whereby it fails to get any font. */
- xlwmenu_default_font = XLoadQueryFont (FRAME_X_DISPLAY (f), "fixed");
-#endif
-
/* Frame contents get displaced if an embedded X window has a border. */
if (! FRAME_X_EMBEDDED_P (f))
- x_default_parameter (f, parms, Qborder_width, make_number (2),
+ x_default_parameter (f, parms, Qborder_width, make_number (0),
"borderWidth", "BorderWidth", RES_TYPE_NUMBER);
/* This defaults to 1 in order to match xterm. We recognize either
#endif
"internalBorderWidth", "internalBorderWidth",
RES_TYPE_NUMBER);
- x_default_parameter (f, parms, Qvertical_scroll_bars, Qleft,
+ x_default_parameter (f, parms, Qvertical_scroll_bars,
+#if defined(USE_GTK) && defined(USE_TOOLKIT_SCROLL_BARS)
+ Qright,
+#else
+ Qleft,
+#endif
"verticalScrollBars", "ScrollBars",
RES_TYPE_SYMBOL);
happen. */
init_frame_faces (f);
- x_default_parameter (f, parms, Qmenu_bar_lines, make_number (1),
- "menuBar", "MenuBar", RES_TYPE_NUMBER);
- x_default_parameter (f, parms, Qtool_bar_lines, make_number (1),
- "toolBar", "ToolBar", RES_TYPE_NUMBER);
+ /* 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);
+
x_default_parameter (f, parms, Qbuffer_predicate, Qnil,
"bufferPredicate", "BufferPredicate",
RES_TYPE_SYMBOL);
;
}
+ BLOCK_INPUT;
+
+ /* Set machine name and pid for the purpose of window managers. */
+ set_machine_and_pid_properties(f);
+
/* Set the WM leader property. GTK does this itself, so this is not
needed when using GTK. */
if (dpyinfo->client_leader_window != 0)
{
- BLOCK_INPUT;
XChangeProperty (FRAME_X_DISPLAY (f),
FRAME_OUTER_WINDOW (f),
dpyinfo->Xatom_wm_client_leader,
XA_WINDOW, 32, PropModeReplace,
(unsigned char *) &dpyinfo->client_leader_window, 1);
- UNBLOCK_INPUT;
}
+ UNBLOCK_INPUT;
+
/* Initialize `default-minibuffer-frame' in case this is the first
frame on this terminal. */
if (FRAME_HAS_MINIBUF_P (f)
know about that structure. */
Lisp_Object
-x_get_focus_frame (frame)
- struct frame *frame;
+x_get_focus_frame (struct frame *frame)
{
struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (frame);
Lisp_Object xfocus;
}
\f
int
-x_pixel_width (f)
- register struct frame *f;
+x_pixel_width (register struct frame *f)
{
return FRAME_PIXEL_WIDTH (f);
}
int
-x_pixel_height (f)
- register struct frame *f;
+x_pixel_height (register struct frame *f)
{
return FRAME_PIXEL_HEIGHT (f);
}
int
-x_char_width (f)
- register struct frame *f;
+x_char_width (register struct frame *f)
{
return FRAME_COLUMN_WIDTH (f);
}
int
-x_char_height (f)
- register struct frame *f;
+x_char_height (register struct frame *f)
{
return FRAME_LINE_HEIGHT (f);
}
int
-x_screen_planes (f)
- register struct frame *f;
+x_screen_planes (register struct frame *f)
{
return FRAME_X_DISPLAY_INFO (f)->n_planes;
}
members of DPYINFO appropriately. Called from x_term_init. */
void
-select_visual (dpyinfo)
- struct x_display_info *dpyinfo;
+select_visual (struct x_display_info *dpyinfo)
{
Display *dpy = dpyinfo->display;
Screen *screen = dpyinfo->screen;
vinfo_template.screen = XScreenNumberOfScreen (screen);
vinfo = XGetVisualInfo (dpy, VisualIDMask | VisualScreenMask,
&vinfo_template, &n_visuals);
- if (n_visuals != 1)
+ if (n_visuals <= 0)
fatal ("Can't get proper X visual info");
dpyinfo->n_planes = vinfo->depth;
Open a new connection if necessary. */
struct x_display_info *
-x_display_info_for_name (name)
- Lisp_Object name;
+x_display_info_for_name (Lisp_Object name)
{
Lisp_Object names;
struct x_display_info *dpyinfo;
/* Wait for responses to all X commands issued so far for frame F. */
void
-x_sync (f)
- FRAME_PTR f;
+x_sync (FRAME_PTR f)
{
BLOCK_INPUT;
XSync (FRAME_X_DISPLAY (f), False);
shown on the frames. */
void
-show_hourglass (timer)
- struct atimer *timer;
+show_hourglass (struct atimer *timer)
{
/* The timer implementation will cancel this timer automatically
after this function has run. Set hourglass_atimer to null
shown. */
void
-hide_hourglass ()
+hide_hourglass (void)
{
if (hourglass_shown_p)
{
Tool tips
***********************************************************************/
-static Lisp_Object x_create_tip_frame P_ ((struct x_display_info *,
- Lisp_Object, Lisp_Object));
-static void compute_tip_xy P_ ((struct frame *, Lisp_Object, Lisp_Object,
- Lisp_Object, int, int, int *, int *));
+static Lisp_Object x_create_tip_frame (struct x_display_info *,
+ Lisp_Object, Lisp_Object);
+static void compute_tip_xy (struct frame *, Lisp_Object, Lisp_Object,
+ Lisp_Object, int, int, int *, int *);
/* The frame of a currently visible tooltip. */
static Lisp_Object
-unwind_create_tip_frame (frame)
- Lisp_Object frame;
+unwind_create_tip_frame (Lisp_Object frame)
{
Lisp_Object deleted;
when this happens. */
static Lisp_Object
-x_create_tip_frame (dpyinfo, parms, text)
- struct x_display_info *dpyinfo;
- Lisp_Object parms, text;
+x_create_tip_frame (struct x_display_info *dpyinfo, Lisp_Object parms, Lisp_Object text)
{
struct frame *f;
Lisp_Object frame, tem;
needed to determine window geometry. */
x_default_font_parameter (f, parms);
- x_default_parameter (f, parms, Qborder_width, make_number (2),
+ x_default_parameter (f, parms, Qborder_width, make_number (0),
"borderWidth", "BorderWidth", RES_TYPE_NUMBER);
/* This defaults to 2 in order to match xterm. We recognize either
{
XSetWindowAttributes attrs;
unsigned long mask;
+ Atom type = FRAME_X_DISPLAY_INFO (f)->Xatom_net_window_type_tooltip;
BLOCK_INPUT;
mask = CWBackPixel | CWOverrideRedirect | CWEventMask;
f->border_width,
CopyFromParent, InputOutput, CopyFromParent,
mask, &attrs);
+ XChangeProperty (FRAME_X_DISPLAY (f), tip_window,
+ FRAME_X_DISPLAY_INFO (f)->Xatom_net_window_type,
+ XA_ATOM, 32, PropModeReplace,
+ (unsigned char *)&type, 1);
UNBLOCK_INPUT;
}
the display in *ROOT_X, and *ROOT_Y. */
static void
-compute_tip_xy (f, parms, dx, dy, width, height, root_x, root_y)
- struct frame *f;
- Lisp_Object parms, dx, dy;
- int width, height;
- int *root_x, *root_y;
+compute_tip_xy (struct frame *f, Lisp_Object parms, Lisp_Object dx, Lisp_Object dy, int width, int height, int *root_x, int *root_y)
{
Lisp_Object left, top;
int win_x, win_y;
clear_glyph_matrix (w->desired_matrix);
clear_glyph_matrix (w->current_matrix);
SET_TEXT_POS (pos, BEGV, BEGV_BYTE);
- try_window (FRAME_ROOT_WINDOW (f), pos, 0);
+ try_window (FRAME_ROOT_WINDOW (f), pos, TRY_WINDOW_IGNORE_FONTS_CHANGE);
/* Compute width and height of the tooltip. */
width = height = 0;
/* Let the row go over the full width of the frame. */
row->full_width_p = 1;
+ row_width = row->pixel_width;
/* There's a glyph at the end of rows that is used to place
the cursor there. Don't include the width of this glyph. */
if (row->used[TEXT_AREA])
{
last = &row->glyphs[TEXT_AREA][row->used[TEXT_AREA] - 1];
- row_width = row->pixel_width - last->pixel_width;
+ if (INTEGERP (last->object))
+ row_width -= last->pixel_width;
}
- else
- row_width = row->pixel_width;
height += row->height;
width = max (width, row_width);
{
struct frame *f = SELECTED_FRAME ();
Widget w = f->output_data.x->menubar_widget;
- extern void xlwmenu_redisplay P_ ((Widget));
+ extern void xlwmenu_redisplay (Widget);
if (!DoesSaveUnders (FRAME_X_DISPLAY_INFO (f)->screen)
&& w != NULL)
#ifdef USE_GTK
static Lisp_Object
-clean_up_dialog (arg)
- Lisp_Object arg;
+clean_up_dialog (Lisp_Object arg)
{
x_menu_set_in_use (0);
{
FRAME_PTR f = check_x_frame (frame);
char *name;
- Lisp_Object default_font, font = Qnil;
+ Lisp_Object font;
Lisp_Object font_param;
char *default_name = NULL;
- struct gcpro gcpro1;
+ struct gcpro gcpro1, gcpro2;
int count = SPECPDL_INDEX ();
check_x ();
BLOCK_INPUT;
- GCPRO1(font_param);
- font_param = Fframe_parameter (frame, Qfont_param);
+ GCPRO2(font_param, font);
- if (x_last_font_name != NULL)
- default_name = x_last_font_name;
- else if (STRINGP (font_param))
- default_name = SDATA (font_param);
- else if (FONTP (default_font))
+ XSETFONT (font, FRAME_FONT (f));
+ font_param = Ffont_get (font, intern (":name"));
+ if (STRINGP (font_param))
+ default_name = xstrdup (SDATA (font_param));
+ else
{
- XSETFONT (default_font, FRAME_FONT (f));
- default_name = alloca (256);
- if (font_unparse_gtkname (default_font, f, default_name, 256) < 0)
- default_name = NULL;
+ font_param = Fframe_parameter (frame, Qfont_param);
+ if (STRINGP (font_param))
+ default_name = xstrdup (SDATA (font_param));
+ }
+
+ if (default_name == NULL && x_last_font_name != NULL)
+ default_name = xstrdup (x_last_font_name);
+
+ /* Convert fontconfig names to Gtk names, i.e. remove - before number */
+ if (default_name)
+ {
+ char *p = strrchr (default_name, '-');
+ if (p)
+ {
+ char *ep = p+1;
+ while (isdigit (*ep))
+ ++ep;
+ if (*ep == '\0') *p = ' ';
+ }
}
name = xg_get_font_name (f, default_name);
+ xfree (default_name);
if (name)
{
};
void
-syms_of_xfns ()
+syms_of_xfns (void)
{
/* This is zero if not using X windows. */
x_in_use = 0;
/* The section below is built by the lisp expression at the top of the file,
just above where these variables are declared. */
/*&&& init symbols here &&&*/
- Qnone = intern ("none");
+ Qnone = intern_c_string ("none");
staticpro (&Qnone);
- Qsuppress_icon = intern ("suppress-icon");
+ Qsuppress_icon = intern_c_string ("suppress-icon");
staticpro (&Qsuppress_icon);
- Qundefined_color = intern ("undefined-color");
+ Qundefined_color = intern_c_string ("undefined-color");
staticpro (&Qundefined_color);
- Qcompound_text = intern ("compound-text");
+ Qcompound_text = intern_c_string ("compound-text");
staticpro (&Qcompound_text);
- Qcancel_timer = intern ("cancel-timer");
+ Qcancel_timer = intern_c_string ("cancel-timer");
staticpro (&Qcancel_timer);
- Qfont_param = intern ("font-parameter");
+ Qfont_param = intern_c_string ("font-parameter");
staticpro (&Qfont_param);
/* This is the end of symbol initialization. */
Fput (Qundefined_color, Qerror_conditions,
- Fcons (Qundefined_color, Fcons (Qerror, Qnil)));
+ pure_cons (Qundefined_color, pure_cons (Qerror, Qnil)));
Fput (Qundefined_color, Qerror_message,
- build_string ("Undefined color"));
+ make_pure_c_string ("Undefined color"));
DEFVAR_LISP ("x-pointer-shape", &Vx_pointer_shape,
doc: /* The shape of the pointer when over text.
the tool bar buttons. */);
x_gtk_whole_detached_tool_bar = 0;
- Fprovide (intern ("x"), Qnil);
+ Fprovide (intern_c_string ("x"), Qnil);
#ifdef USE_X_TOOLKIT
- Fprovide (intern ("x-toolkit"), Qnil);
+ Fprovide (intern_c_string ("x-toolkit"), Qnil);
#ifdef USE_MOTIF
- Fprovide (intern ("motif"), Qnil);
+ Fprovide (intern_c_string ("motif"), Qnil);
DEFVAR_LISP ("motif-version-string", &Vmotif_version_string,
doc: /* Version info for LessTif/Motif. */);
is not an X toolkit in that sense (USE_X_TOOLKIT is not defined).
But for a user it is a toolkit for X, and indeed, configure
accepts --with-x-toolkit=gtk. */
- Fprovide (intern ("x-toolkit"), Qnil);
- Fprovide (intern ("gtk"), Qnil);
+ Fprovide (intern_c_string ("x-toolkit"), Qnil);
+ Fprovide (intern_c_string ("gtk"), Qnil);
DEFVAR_LISP ("gtk-version-string", &Vgtk_version_string,
doc: /* Version info for GTK+. */);
char gtk_version[40];
g_snprintf (gtk_version, sizeof (gtk_version), "%u.%u.%u",
GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION);
- Vgtk_version_string = build_string (gtk_version);
+ Vgtk_version_string = make_pure_string (gtk_version, strlen (gtk_version), strlen (gtk_version), 0);
}
#endif /* USE_GTK */