/* 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, 2010
- Free Software Foundation, Inc.
+
+Copyright (C) 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+ 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+ Free Software Foundation, Inc.
This file is part of GNU Emacs.
#include <Xm/Xm.h>
#include <Xm/DialogS.h>
#include <Xm/FileSB.h>
+#include <Xm/List.h>
+#include <Xm/TextF.h>
#endif
#ifdef USE_LUCID
static Lisp_Object x_default_scroll_bar_color_parameter (struct frame *,
Lisp_Object,
Lisp_Object,
- char *, char *,
+ const char *, const char *,
int);
\f
int real_x = 0, real_y = 0;
int had_errors = 0;
Window win = f->output_data.x->parent_desc;
+ Atom actual_type;
+ unsigned long actual_size, bytes_remaining;
+ int i, rc, actual_format;
+ struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
+ long max_len = 400;
+ Display *dpy = FRAME_X_DISPLAY (f);
+ unsigned char *tmp_data = NULL;
+ Atom target_type = XA_CARDINAL;
BLOCK_INPUT;
- x_catch_errors (FRAME_X_DISPLAY (f));
+ x_catch_errors (dpy);
- if (win == FRAME_X_DISPLAY_INFO (f)->root_window)
+ if (win == dpyinfo->root_window)
win = FRAME_OUTER_WINDOW (f);
/* This loop traverses up the containment tree until we hit the root
had_errors = x_had_errors_p (FRAME_X_DISPLAY (f));
}
+
+ if (dpyinfo->root_window == f->output_data.x->parent_desc)
+ {
+ /* Try _NET_FRAME_EXTENTS if our parent is the root window. */
+ rc = XGetWindowProperty (dpy, win, dpyinfo->Xatom_net_frame_extents,
+ 0, max_len, False, target_type,
+ &actual_type, &actual_format, &actual_size,
+ &bytes_remaining, &tmp_data);
+
+ if (rc == Success && actual_type == target_type && !x_had_errors_p (dpy)
+ && actual_size == 4 && actual_format == 32)
+ {
+ int ign;
+ Window rootw;
+ long *fe = (long *)tmp_data;
+
+ XGetGeometry (FRAME_X_DISPLAY (f), win,
+ &rootw, &real_x, &real_y, &ign, &ign, &ign, &ign);
+ outer_x = -fe[0];
+ outer_y = -fe[2];
+ real_x -= fe[0];
+ real_y -= fe[2];
+ }
+ }
+
+ if (tmp_data) XFree (tmp_data);
+
x_uncatch_errors ();
UNBLOCK_INPUT;
x_defined_color (struct frame *f, const char *color_name,
XColor *color, int alloc_p)
{
- int success_p;
+ int success_p = 0;
Display *dpy = FRAME_X_DISPLAY (f);
Colormap cmap = FRAME_X_COLORMAP (f);
BLOCK_INPUT;
- success_p = XParseColor (dpy, cmap, color_name, color);
+#ifdef USE_GTK
+ success_p = xg_check_special_colors (f, color_name, color);
+#endif
+ if (!success_p)
+ success_p = XParseColor (dpy, cmap, color_name, color);
if (success_p && alloc_p)
success_p = x_alloc_nearest_color (f, cmap, color);
UNBLOCK_INPUT;
}
int
-xg_set_icon_from_xpm_data (FRAME_PTR f, char **data)
+xg_set_icon_from_xpm_data (FRAME_PTR f, const char **data)
{
int result = 0;
- GdkPixbuf *pixbuf = gdk_pixbuf_new_from_xpm_data ((const char **) data);
+ GdkPixbuf *pixbuf = gdk_pixbuf_new_from_xpm_data (data);
if (!pixbuf)
return 0;
if (FRAME_X_DISPLAY_INFO (f)->invisible_cursor == 0)
FRAME_X_DISPLAY_INFO (f)->invisible_cursor = make_invisible_cursor (f);
-
+
if (cursor != x->text_cursor
&& x->text_cursor != 0)
XFreeCursor (dpy, x->text_cursor);
static Lisp_Object
x_default_scroll_bar_color_parameter (struct frame *f,
Lisp_Object alist, Lisp_Object prop,
- char *xprop, char *xclass,
+ const char *xprop, const char *xclass,
int foreground_p)
{
struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
}
if (! xfs)
{
- char *last_resort = "-*-*-*-r-normal--*-*-*-*-*-*";
+ const char *last_resort = "-*-*-*-r-normal--*-*-*-*-*-*";
missing_list = NULL;
xfs = XCreateFontSet (FRAME_X_DISPLAY (f), last_resort,
if (! FONTP (font) && ! STRINGP (font))
{
- char *names[]
+ const char *names[]
= {
#ifdef HAVE_XFT
/* This will find the normal Xft font. */
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);
-
+ /* This will set WM_CLIENT_MACHINE and WM_LOCALE_NAME. */
+ XSetWMProperties (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), NULL, NULL,
+ NULL, 0, NULL, NULL, NULL);
XChangeProperty (FRAME_X_DISPLAY (f),
FRAME_OUTER_WINDOW (f),
XInternAtom (FRAME_X_DISPLAY (f),
"background", "Background", RES_TYPE_STRING);
x_default_parameter (f, parms, Qmouse_color, build_string ("black"),
"pointerColor", "Foreground", RES_TYPE_STRING);
- x_default_parameter (f, parms, Qcursor_color, build_string ("black"),
- "cursorColor", "Foreground", RES_TYPE_STRING);
x_default_parameter (f, parms, Qborder_color, build_string ("black"),
"borderColor", "BorderColor", RES_TYPE_STRING);
x_default_parameter (f, parms, Qscreen_gamma, Qnil,
"waitForWM", "WaitForWM", RES_TYPE_BOOLEAN);
x_default_parameter (f, parms, Qfullscreen, Qnil,
"fullscreen", "Fullscreen", RES_TYPE_SYMBOL);
+ x_default_parameter (f, parms, Qtool_bar_position,
+ f->tool_bar_position, 0, 0, RES_TYPE_SYMBOL);
/* Compute the size of the X window. */
window_prompting = x_figure_window_size (f, parms, 1);
\f
DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, 1, 2, 0,
- doc: /* Internal function called by `color-defined-p', which see. */)
+ doc: /* Internal function called by `color-defined-p', which see
+.\(Note that the Nextstep version of this function ignores FRAME.) */)
(Lisp_Object color, Lisp_Object frame)
{
XColor foo;
(Lisp_Object terminal)
{
struct x_display_info *dpyinfo = check_x_display_info (terminal);
- char *vendor = ServerVendor (dpyinfo->display);
+ const char *vendor = ServerVendor (dpyinfo->display);
if (! vendor) vendor = "";
return build_string (vendor);
static struct visual_class
{
- char *name;
+ const char *name;
int class;
}
visual_classes[] =
DEFUN ("x-open-connection", Fx_open_connection, Sx_open_connection,
1, 3, 0,
- doc: /* Open a connection to an X server.
+ doc: /* Open a connection to a display server.
DISPLAY is the name of the display to connect to.
Optional second arg XRM-STRING is a string of resources in xrdb format.
If the optional third arg MUST-SUCCEED is non-nil,
-terminate Emacs if we can't open the connection. */)
+terminate Emacs if we can't open the connection.
+\(In the Nextstep version, the last two arguments are currently ignored.) */)
(Lisp_Object display, Lisp_Object xrm_string, Lisp_Object must_succeed)
{
unsigned char *xrm_option;
DEFUN ("x-synchronize", Fx_synchronize, Sx_synchronize, 1, 2, 0,
doc: /* If ON is non-nil, report X errors as soon as the erring request is made.
+This function only has an effect on X Windows. With MS Windows, it is
+defined but does nothing.
+
If ON is nil, allow buffering of requests.
Turning on synchronization prohibits the Xlib routines from buffering
requests and seriously degrades performance, but makes debugging much
DEFUN ("x-change-window-property", Fx_change_window_property,
Sx_change_window_property, 2, 6, 0,
doc: /* Change window property PROP to VALUE on the X window of FRAME.
-PROP must be a string.
-VALUE may be a string or a list of conses, numbers and/or strings.
-If an element in the list is a string, it is converted to
-an Atom and the value of the Atom is used. If an element is a cons,
-it is converted to a 32 bit number where the car is the 16 top bits and the
-cdr is the lower 16 bits.
+PROP must be a string. VALUE may be a string or a list of conses,
+numbers and/or strings. If an element in the list is a string, it is
+converted to an atom and the value of the atom is used. If an element
+is a cons, it is converted to a 32 bit number where the car is the 16
+top bits and the cdr is the lower 16 bits.
+
FRAME nil or omitted means use the selected frame.
If TYPE is given and non-nil, it is the name of the type of VALUE.
If TYPE is not given or nil, the type is STRING.
It must be one of 8, 16 or 32.
If VALUE is a string or FORMAT is nil or not given, FORMAT defaults to 8.
If OUTER_P is non-nil, the property is changed for the outer X window of
-FRAME. Default is to change on the edit X window.
-
-Value is VALUE. */)
+FRAME. Default is to change on the edit X window. */)
(Lisp_Object prop, Lisp_Object value, Lisp_Object frame, Lisp_Object type, Lisp_Object format, Lisp_Object outer_p)
{
struct frame *f = check_x_frame (frame);
1, 6, 0,
doc: /* Value is the value of window property PROP on FRAME.
If FRAME is nil or omitted, use the selected frame.
-If TYPE is nil or omitted, get the property as a string. Otherwise TYPE
-is the name of the Atom that denotes the type expected.
+
+On MS Windows, this function only accepts the PROP and FRAME arguments.
+
+On X Windows, the following optional arguments are also accepted:
+If TYPE is nil or omitted, get the property as 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 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
-no value of TYPE. */)
+no value of TYPE (always string in the MS Windows case). */)
(Lisp_Object prop, Lisp_Object frame, Lisp_Object type, Lisp_Object source, Lisp_Object delete_p, Lisp_Object vector_ret_p)
{
struct frame *f = check_x_frame (frame);
Automatically hide the tooltip after TIMEOUT seconds. TIMEOUT nil
means use the default timeout of 5 seconds.
-If the list of frame parameters PARAMS contains a `left' parameters,
+If the list of frame parameters PARMS contains a `left' parameters,
the tooltip is displayed at that x-position. Otherwise it is
displayed at the mouse position, with offset DX added (default is 5 if
DX isn't specified). Likewise for the y-position; if a `top' frame
int root_x, root_y;
struct buffer *old_buffer;
struct text_pos pos;
- int i, width, height;
+ int i, width, height, seen_reversed_p;
struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
int old_windows_or_buffers_changed = windows_or_buffers_changed;
int count = SPECPDL_INDEX ();
try_window (FRAME_ROOT_WINDOW (f), pos, TRY_WINDOW_IGNORE_FONTS_CHANGE);
/* Compute width and height of the tooltip. */
- width = height = 0;
+ width = height = seen_reversed_p = 0;
for (i = 0; i < w->desired_matrix->nrows; ++i)
{
struct glyph_row *row = &w->desired_matrix->rows[i];
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];
- if (INTEGERP (last->object))
- row_width -= last->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->reversed_p)
+ {
+ last = &row->glyphs[TEXT_AREA][row->used[TEXT_AREA] - 1];
+ if (INTEGERP (last->object))
+ row_width -= last->pixel_width;
+ }
+ else
+ {
+ /* There could be a stretch glyph at the beginning of R2L
+ rows that is produced by extend_face_to_end_of_line.
+ Don't count that glyph. */
+ struct glyph *g = row->glyphs[TEXT_AREA];
+
+ if (g->type == STRETCH_GLYPH && INTEGERP (g->object))
+ {
+ row_width -= g->pixel_width;
+ seen_reversed_p = 1;
+ }
+ }
}
height += row->height;
width = max (width, row_width);
}
+ /* If we've seen partial-length R2L rows, we need to re-adjust the
+ tool-tip frame width and redisplay it again, to avoid over-wide
+ tips due to the stretch glyph that extends R2L lines to full
+ width of the frame. */
+ if (seen_reversed_p)
+ {
+ /* w->total_cols and FRAME_TOTAL_COLS want the width in columns,
+ not in pixels. */
+ width /= WINDOW_FRAME_COLUMN_WIDTH (w);
+ w->total_cols = make_number (width);
+ FRAME_TOTAL_COLS (f) = width;
+ adjust_glyphs (f);
+ clear_glyph_matrix (w->desired_matrix);
+ clear_glyph_matrix (w->current_matrix);
+ try_window (FRAME_ROOT_WINDOW (f), pos, 0);
+ width = height = 0;
+ /* Recompute width and height of the tooltip. */
+ for (i = 0; i < w->desired_matrix->nrows; ++i)
+ {
+ struct glyph_row *row = &w->desired_matrix->rows[i];
+ struct glyph *last;
+ int row_width;
+
+ if (!row->enabled_p || !row->displays_text_p)
+ break;
+ row->full_width_p = 1;
+ row_width = row->pixel_width;
+ if (row->used[TEXT_AREA] && !row->reversed_p)
+ {
+ last = &row->glyphs[TEXT_AREA][row->used[TEXT_AREA] - 1];
+ if (INTEGERP (last->object))
+ row_width -= last->pixel_width;
+ }
+
+ height += row->height;
+ width = max (width, row_width);
+ }
+ }
+
/* Add the frame's internal border to the width and height the X
window should have. */
height += 2 * FRAME_INTERNAL_BORDER_WIDTH (f);
/* When using system tooltip, tip_frame is the Emacs frame on which
the tip is shown. */
f = XFRAME (frame);
- if (xg_hide_tooltip (f))
+ if (FRAME_LIVE_P (f) && xg_hide_tooltip (f))
frame = Qnil;
#endif
/* Callback for "OK" and "Cancel" on file selection dialog. */
static void
-file_dialog_cb (widget, client_data, call_data)
- Widget widget;
- XtPointer call_data, client_data;
+file_dialog_cb (Widget widget, XtPointer client_data, XtPointer call_data)
{
int *result = (int *) client_data;
XmAnyCallbackStruct *cb = (XmAnyCallbackStruct *) call_data;
in this case. */
static void
-file_dialog_unmap_cb (widget, client_data, call_data)
- Widget widget;
- XtPointer call_data, client_data;
+file_dialog_unmap_cb (Widget widget, XtPointer client_data, XtPointer call_data)
{
int *result = (int *) client_data;
*result = XmCR_CANCEL;
}
static Lisp_Object
-clean_up_file_dialog (arg)
- Lisp_Object arg;
+clean_up_file_dialog (Lisp_Object arg)
{
struct Lisp_Save_Value *p = XSAVE_VALUE (arg);
Widget dialog = (Widget) p->pointer;
doc: /* Read file name, prompting with PROMPT in directory DIR.
Use a file selection dialog. Select DEFAULT-FILENAME in the dialog's file
selection box, if specified. If MUSTMATCH is non-nil, the returned file
-or directory must exist. ONLY-DIR-P is ignored." */)
+or directory must exist.
+
+This function is only defined on MS Windows, and X Windows with the
+Motif or Gtk toolkits. With the Motif toolkit, ONLY-DIR-P is ignored.
+Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories. */)
(Lisp_Object prompt, Lisp_Object dir, Lisp_Object default_filename, Lisp_Object mustmatch, Lisp_Object only_dir_p)
{
int result;
doc: /* Read file name, prompting with PROMPT in directory DIR.
Use a file selection dialog. Select DEFAULT-FILENAME in the dialog's file
selection box, if specified. If MUSTMATCH is non-nil, the returned file
-or directory must exist. If ONLY-DIR-P is non-nil, the user can only select
-directories. */)
+or directory must exist.
+
+This function is only defined on MS Windows, and X Windows with the
+Motif or Gtk toolkits. With the Motif toolkit, ONLY-DIR-P is ignored.
+Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories. */)
(Lisp_Object prompt, Lisp_Object dir, Lisp_Object default_filename, Lisp_Object mustmatch, Lisp_Object only_dir_p)
{
FRAME_PTR f = SELECTED_FRAME ();
font_param = Ffont_get (font, intern (":name"));
if (STRINGP (font_param))
default_name = xstrdup (SDATA (font_param));
- else
+ else
{
font_param = Fframe_parameter (frame, Qfont_param);
if (STRINGP (font_param))
default_name = xstrdup (x_last_font_name);
/* Convert fontconfig names to Gtk names, i.e. remove - before number */
- if (default_name)
+ if (default_name)
{
char *p = strrchr (default_name, '-');
if (p)
Vx_cursor_fore_pixel = Qnil;
DEFVAR_LISP ("x-max-tooltip-size", &Vx_max_tooltip_size,
- doc: /* Maximum size for tooltips. Value is a pair (COLUMNS . ROWS).
-Text larger than this is clipped. */);
+ doc: /* Maximum size for tooltips.
+Value is a pair (COLUMNS . ROWS). Text larger than this is clipped. */);
Vx_max_tooltip_size = Fcons (make_number (80), make_number (40));
DEFVAR_LISP ("x-no-window-manager", &Vx_no_window_manager,
#endif /* HAVE_X_WINDOWS */
-/* arch-tag: 55040d02-5485-4d58-8b22-95a7a05f3288
- (do not change this comment) */