X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/43dc73f18fb590168face8211d9e434455e2df33..2afd5e90eb946a0e70547e56a4c705d7d0d4cb7f:/src/xfns.c diff --git a/src/xfns.c b/src/xfns.c index cd3dcdd54f..1b9b629b36 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -65,6 +65,10 @@ Boston, MA 02111-1307, USA. */ #include "[.bitmaps]gray.xbm" #endif +#ifdef USE_GTK +#include "gtkutil.h" +#endif + #ifdef USE_X_TOOLKIT #include @@ -185,10 +189,9 @@ Lisp_Object Vx_pixel_size_width_font_regexp; Lisp_Object Qauto_raise; Lisp_Object Qauto_lower; -Lisp_Object Qbar, Qhbar; Lisp_Object Qborder_color; Lisp_Object Qborder_width; -Lisp_Object Qbox; +extern Lisp_Object Qbox; Lisp_Object Qcursor_color; Lisp_Object Qcursor_type; Lisp_Object Qgeometry; @@ -301,12 +304,7 @@ check_x_display_info (frame) dpyinfo = x_display_info_for_name (frame); else { - FRAME_PTR f; - - CHECK_LIVE_FRAME (frame); - f = XFRAME (frame); - if (! FRAME_X_P (f)) - error ("Non-X frame used"); + FRAME_PTR f = check_x_frame (frame); dpyinfo = FRAME_X_DISPLAY_INFO (f); } @@ -346,6 +344,15 @@ x_window_to_frame (dpyinfo, wdesc) || f->output_data.x->icon_desc == wdesc) return f; #else /* not USE_X_TOOLKIT */ +#ifdef USE_GTK + if (f->output_data.x->edit_widget) + { + GtkWidget *gwdesc = xg_win_to_widget (wdesc); + struct x_output *x = f->output_data.x; + if (gwdesc != 0 && gwdesc == x->edit_widget) + return f; + } +#endif /* USE_GTK */ if (FRAME_X_WINDOW (f) == wdesc || f->output_data.x->icon_desc == wdesc) return f; @@ -354,7 +361,7 @@ x_window_to_frame (dpyinfo, wdesc) return 0; } -#ifdef USE_X_TOOLKIT +#if defined (USE_X_TOOLKIT) || defined (USE_GTK) /* Like x_window_to_frame but also compares the window with the widget's windows. */ @@ -383,6 +390,15 @@ x_any_window_to_frame (dpyinfo, wdesc) found = f; else if (x->widget) { +#ifdef USE_GTK + GtkWidget *gwdesc = xg_win_to_widget (wdesc); + if (gwdesc != 0 + && (gwdesc == x->widget + || gwdesc == x->edit_widget + || gwdesc == x->vbox_widget + || gwdesc == x->menubar_widget)) + found = f; +#else if (wdesc == XtWindow (x->widget) || wdesc == XtWindow (x->column_widget) || wdesc == XtWindow (x->edit_widget)) @@ -390,6 +406,7 @@ x_any_window_to_frame (dpyinfo, wdesc) /* Match if the window is this frame's menubar. */ else if (lw_window_is_in_menubar (wdesc, x->menubar_widget)) found = f; +#endif } else if (FRAME_X_WINDOW (f) == wdesc) /* A tooltip frame. */ @@ -425,10 +442,19 @@ x_non_menubar_window_to_frame (dpyinfo, wdesc) return f; else if (x->widget) { +#ifdef USE_GTK + GtkWidget *gwdesc = xg_win_to_widget (wdesc); + if (gwdesc != 0 + && (gwdesc == x->widget + || gwdesc == x->edit_widget + || gwdesc == x->vbox_widget)) + return f; +#else if (wdesc == XtWindow (x->widget) || wdesc == XtWindow (x->column_widget) || wdesc == XtWindow (x->edit_widget)) return f; +#endif } else if (FRAME_X_WINDOW (f) == wdesc) /* A tooltip frame. */ @@ -458,9 +484,25 @@ x_menubar_window_to_frame (dpyinfo, wdesc) continue; x = f->output_data.x; /* Match if the window is this frame's menubar. */ +#ifdef USE_GTK + if (x->menubar_widget) + { + GtkWidget *gwdesc = xg_win_to_widget (wdesc); + int found = 0; + + BLOCK_INPUT; + if (gwdesc != 0 + && (gwdesc == x->menubar_widget + || gtk_widget_get_parent (gwdesc) == x->menubar_widget)) + found = 1; + UNBLOCK_INPUT; + if (found) return f; + } +#else if (x->menubar_widget && lw_window_is_in_menubar (wdesc, x->menubar_widget)) return f; +#endif } return 0; } @@ -490,6 +532,11 @@ x_top_window_to_frame (dpyinfo, wdesc) if (x->widget) { /* This frame matches if the window is its topmost widget. */ +#ifdef USE_GTK + GtkWidget *gwdesc = xg_win_to_widget (wdesc); + if (gwdesc == x->widget) + return f; +#else if (wdesc == XtWindow (x->widget)) return f; #if 0 /* I don't know why it did this, @@ -499,6 +546,7 @@ x_top_window_to_frame (dpyinfo, wdesc) if (x->menubar_widget && wdesc == XtWindow (x->menubar_widget)) return f; +#endif #endif } else if (FRAME_X_WINDOW (f) == wdesc) @@ -507,7 +555,7 @@ x_top_window_to_frame (dpyinfo, wdesc) } return 0; } -#endif /* USE_X_TOOLKIT */ +#endif /* USE_X_TOOLKIT || USE_GTK */ @@ -641,7 +689,7 @@ x_create_bitmap_from_file (f, file) { if (dpyinfo->bitmaps[id].refcount && dpyinfo->bitmaps[id].file - && !strcmp (dpyinfo->bitmaps[id].file, (char *) XSTRING (file)->data)) + && !strcmp (dpyinfo->bitmaps[id].file, (char *) SDATA (file))) { ++dpyinfo->bitmaps[id].refcount; return id + 1; @@ -654,7 +702,7 @@ x_create_bitmap_from_file (f, file) return -1; emacs_close (fd); - filename = (char *) XSTRING (found)->data; + filename = (char *) SDATA (found); result = XReadBitmapFile (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), filename, &width, &height, &bitmap, &xhot, &yhot); @@ -665,11 +713,11 @@ x_create_bitmap_from_file (f, file) dpyinfo->bitmaps[id - 1].pixmap = bitmap; dpyinfo->bitmaps[id - 1].refcount = 1; dpyinfo->bitmaps[id - 1].file - = (char *) xmalloc (STRING_BYTES (XSTRING (file)) + 1); + = (char *) xmalloc (SBYTES (file) + 1); dpyinfo->bitmaps[id - 1].depth = 1; dpyinfo->bitmaps[id - 1].height = height; dpyinfo->bitmaps[id - 1].width = width; - strcpy (dpyinfo->bitmaps[id - 1].file, XSTRING (file)->data); + strcpy (dpyinfo->bitmaps[id - 1].file, SDATA (file)); return id; } @@ -1301,9 +1349,14 @@ x_report_frame_params (f, alistptr) store_in_alist (alistptr, Qright_fringe, make_number (f->output_data.x->right_fringe_width)); store_in_alist (alistptr, Qscroll_bar_width, - make_number (FRAME_HAS_VERTICAL_SCROLL_BARS (f) - ? FRAME_SCROLL_BAR_PIXEL_WIDTH(f) - : 0)); + (! FRAME_HAS_VERTICAL_SCROLL_BARS (f) + ? make_number (0) + : FRAME_SCROLL_BAR_PIXEL_WIDTH (f) > 0 + ? make_number (FRAME_SCROLL_BAR_PIXEL_WIDTH (f)) + /* nil means "use default width" + for non-toolkit scroll bar. + ruler-mode.el depends on this. */ + : Qnil)); sprintf (buf, "%ld", (long) FRAME_X_WINDOW (f)); store_in_alist (alistptr, Qwindow_id, build_string (buf)); @@ -1390,9 +1443,9 @@ x_decode_color (f, color_name, mono_color) #if 0 /* Don't do this. It's wrong when we're not using the default colormap, it makes freeing difficult, and it's probably not an important optimization. */ - if (strcmp (XSTRING (color_name)->data, "black") == 0) + if (strcmp (SDATA (color_name), "black") == 0) return BLACK_PIX_DEFAULT (f); - else if (strcmp (XSTRING (color_name)->data, "white") == 0) + else if (strcmp (SDATA (color_name), "white") == 0) return WHITE_PIX_DEFAULT (f); #endif @@ -1402,7 +1455,7 @@ x_decode_color (f, color_name, mono_color) /* x_defined_color is responsible for coping with failures by looking for a near-miss. */ - if (x_defined_color (f, XSTRING (color_name)->data, &cdef, 1)) + if (x_defined_color (f, SDATA (color_name), &cdef, 1)) return cdef.pixel; Fsignal (Qerror, Fcons (build_string ("Undefined color"), @@ -1554,6 +1607,10 @@ x_set_background_color (f, arg, oldval) XSetWindowBackground (dpy, FRAME_X_WINDOW (f), bg); XSetForeground (dpy, x->cursor_gc, bg); +#ifdef USE_GTK + xg_set_background_color (f, bg); +#endif + #ifndef USE_TOOLKIT_SCROLL_BARS /* Turns out to be annoying with toolkit scroll bars. */ { @@ -1839,63 +1896,13 @@ x_set_border_pixel (f, pix) } -/* Value is the internal representation of the specified cursor type - ARG. If type is BAR_CURSOR, return in *WIDTH the specified width - of the bar cursor. */ - -enum text_cursor_kinds -x_specified_cursor_type (arg, width) - Lisp_Object arg; - int *width; -{ - enum text_cursor_kinds type; - - if (EQ (arg, Qbar)) - { - type = BAR_CURSOR; - *width = 2; - } - else if (CONSP (arg) - && EQ (XCAR (arg), Qbar) - && INTEGERP (XCDR (arg)) - && XINT (XCDR (arg)) >= 0) - { - type = BAR_CURSOR; - *width = XINT (XCDR (arg)); - } - else if (EQ (arg, Qhbar)) - { - type = HBAR_CURSOR; - *width = 2; - } - else if (CONSP (arg) - && EQ (XCAR (arg), Qhbar) - && INTEGERP (XCDR (arg)) - && XINT (XCDR (arg)) >= 0) - { - type = HBAR_CURSOR; - *width = XINT (XCDR (arg)); - } - else if (NILP (arg)) - type = NO_CURSOR; - else - /* Treat anything unknown as "box cursor". - It was bad to signal an error; people have trouble fixing - .Xdefaults with Emacs, when it has something bad in it. */ - type = FILLED_BOX_CURSOR; - - return type; -} void x_set_cursor_type (f, arg, oldval) FRAME_PTR f; Lisp_Object arg, oldval; { - int width; - - FRAME_DESIRED_CURSOR (f) = x_specified_cursor_type (arg, &width); - f->output_data.x->cursor_width = width; + set_frame_cursor_types (f, arg); /* Make sure the cursor gets redrawn. */ cursor_type_changed = 1; @@ -1919,9 +1926,9 @@ x_set_icon_type (f, arg, oldval) BLOCK_INPUT; if (NILP (arg)) result = x_text_icon (f, - (char *) XSTRING ((!NILP (f->icon_name) + (char *) SDATA ((!NILP (f->icon_name) ? f->icon_name - : f->name))->data); + : f->name))); else result = x_bitmap_icon (f, arg); @@ -1973,11 +1980,11 @@ x_set_icon_name (f, arg, oldval) BLOCK_INPUT; result = x_text_icon (f, - (char *) XSTRING ((!NILP (f->icon_name) - ? f->icon_name - : !NILP (f->title) - ? f->title - : f->name))->data); + (char *) SDATA ((!NILP (f->icon_name) + ? f->icon_name + : !NILP (f->title) + ? f->title + : f->name))); if (result) { @@ -2005,12 +2012,12 @@ x_set_font (f, arg, oldval) BLOCK_INPUT; result = (STRINGP (fontset_name) - ? x_new_fontset (f, XSTRING (fontset_name)->data) - : x_new_font (f, XSTRING (arg)->data)); + ? x_new_fontset (f, SDATA (fontset_name)) + : x_new_font (f, SDATA (arg))); UNBLOCK_INPUT; if (EQ (result, Qnil)) - error ("Font `%s' is not defined", XSTRING (arg)->data); + error ("Font `%s' is not defined", SDATA (arg)); else if (EQ (result, Qt)) error ("The characters of the given font have varying widths"); else if (STRINGP (result)) @@ -2170,7 +2177,7 @@ x_set_menu_bar_lines (f, value, oldval) /* Make sure we redisplay all windows in this frame. */ windows_or_buffers_changed++; -#ifdef USE_X_TOOLKIT +#if defined (USE_X_TOOLKIT) || defined (USE_GTK) FRAME_MENU_BAR_LINES (f) = 0; if (nlines) { @@ -2187,7 +2194,7 @@ x_set_menu_bar_lines (f, value, oldval) if (FRAME_X_P (f)) f->output_data.x->menubar_widget = 0; } -#else /* not USE_X_TOOLKIT */ +#else /* not USE_X_TOOLKIT && not USE_GTK */ FRAME_MENU_BAR_LINES (f) = nlines; x_change_window_heights (f->root_window, nlines - olines); #endif /* not USE_X_TOOLKIT */ @@ -2219,7 +2226,27 @@ x_set_tool_bar_lines (f, value, oldval) else nlines = 0; - /* Make sure we redisplay all windows in this frame. */ +#ifdef USE_GTK + FRAME_TOOL_BAR_LINES (f) = 0; + if (nlines) + { + 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; + update_frame_tool_bar (f); + } + else + { + if (FRAME_EXTERNAL_TOOL_BAR (f)) + free_frame_tool_bar (f); + FRAME_EXTERNAL_TOOL_BAR (f) = 0; + } + + return; +#endif + + /* Make sure we redisplay all windows in this frame. */ ++windows_or_buffers_changed; delta = nlines - FRAME_TOOL_BAR_LINES (f); @@ -2380,9 +2407,9 @@ x_encode_text (string, coding_system, selectionp, text_bytes, stringp) int *text_bytes, *stringp; int selectionp; { - unsigned char *str = XSTRING (string)->data; - int chars = XSTRING (string)->size; - int bytes = STRING_BYTES (XSTRING (string)); + unsigned char *str = SDATA (string); + int chars = SCHARS (string); + int bytes = SBYTES (string); int charset_info; int bufsize; unsigned char *buf; @@ -2404,9 +2431,9 @@ x_encode_text (string, coding_system, selectionp, text_bytes, stringp) && !NILP (Ffboundp (coding.pre_write_conversion))) { string = run_pre_post_conversion_on_str (string, &coding, 1); - str = XSTRING (string)->data; - chars = XSTRING (string)->size; - bytes = STRING_BYTES (XSTRING (string)); + str = SDATA (string); + chars = SCHARS (string); + bytes = SBYTES (string); } coding.src_multibyte = 1; coding.dst_multibyte = 0; @@ -2463,7 +2490,7 @@ x_set_name (f, name, explicit) /* Check for no change needed in this very common case before we do any consing. */ if (!strcmp (FRAME_X_DISPLAY_INFO (f)->x_id_name, - XSTRING (f->name)->data)) + SDATA (f->name))) return; name = build_string (FRAME_X_DISPLAY_INFO (f)->x_id_name); } @@ -2490,9 +2517,7 @@ x_set_name (f, name, explicit) int bytes, stringp; Lisp_Object coding_system; - coding_system = Vlocale_coding_system; - if (NILP (coding_system)) - coding_system = Qcompound_text; + coding_system = Qcompound_text; text.value = x_encode_text (name, coding_system, 0, &bytes, &stringp); text.encoding = (stringp ? XA_STRING : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT); @@ -2518,20 +2543,27 @@ x_set_name (f, name, explicit) XSetWMIconName (FRAME_X_DISPLAY (f), XtWindow (f->output_data.x->widget), &icon); #else /* not USE_X_TOOLKIT */ +#ifdef USE_GTK + gtk_window_set_title (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)), + SDATA (name)); + XSetWMIconName (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), + &icon); +#else /* not USE_GTK */ XSetWMName (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), &text); XSetWMIconName (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), &icon); +#endif /* not USE_GTK */ #endif /* not USE_X_TOOLKIT */ if (!NILP (f->icon_name) - && icon.value != XSTRING (f->icon_name)->data) + && icon.value != (unsigned char *) SDATA (f->icon_name)) xfree (icon.value); - if (text.value != XSTRING (name)->data) + if (text.value != (unsigned char *) SDATA (name)) xfree (text.value); } #else /* not HAVE_X11R4 */ XSetIconName (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), - XSTRING (name)->data); + SDATA (name)); XStoreName (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), - XSTRING (name)->data); + SDATA (name)); #endif /* not HAVE_X11R4 */ UNBLOCK_INPUT; } @@ -2597,9 +2629,7 @@ x_set_title (f, name, old_name) int bytes, stringp; Lisp_Object coding_system; - coding_system = Vlocale_coding_system; - if (NILP (coding_system)) - coding_system = Qcompound_text; + coding_system = Qcompound_text; text.value = x_encode_text (name, coding_system, 0, &bytes, &stringp); text.encoding = (stringp ? XA_STRING : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT); @@ -2625,20 +2655,27 @@ x_set_title (f, name, old_name) XSetWMIconName (FRAME_X_DISPLAY (f), XtWindow (f->output_data.x->widget), &icon); #else /* not USE_X_TOOLKIT */ +#ifdef USE_GTK + gtk_window_set_title (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)), + SDATA (name)); + XSetWMIconName (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), + &icon); +#else /* not USE_GTK */ XSetWMName (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), &text); XSetWMIconName (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), &icon); +#endif /* not USE_GTK */ #endif /* not USE_X_TOOLKIT */ if (!NILP (f->icon_name) - && icon.value != XSTRING (f->icon_name)->data) + && icon.value != (unsigned char *) SDATA (f->icon_name)) xfree (icon.value); - if (text.value != XSTRING (name)->data) + if (text.value != (unsigned char *) SDATA (name)) xfree (text.value); } #else /* not HAVE_X11R4 */ XSetIconName (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), - XSTRING (name)->data); + SDATA (name)); XStoreName (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), - XSTRING (name)->data); + SDATA (name)); #endif /* not HAVE_X11R4 */ UNBLOCK_INPUT; } @@ -2763,10 +2800,10 @@ validate_x_resource_name () if (STRINGP (Vx_resource_name)) { - unsigned char *p = XSTRING (Vx_resource_name)->data; + unsigned char *p = SDATA (Vx_resource_name); int i; - len = STRING_BYTES (XSTRING (Vx_resource_name)); + len = SBYTES (Vx_resource_name); /* Only letters, digits, - and _ are valid in resource names. Count the valid characters and count the invalid ones. */ @@ -2805,12 +2842,12 @@ validate_x_resource_name () for (i = 0; i < len; i++) { - int c = XSTRING (new)->data[i]; + int c = SREF (new, i); if (! ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '-' || c == '_')) - XSTRING (new)->data[i] = '_'; + SSET (new, i, '_'); } } @@ -2850,37 +2887,37 @@ and the class is `Emacs.CLASS.SUBCLASS'. */) /* Allocate space for the components, the dots which separate them, and the final '\0'. Make them big enough for the worst case. */ - name_key = (char *) alloca (STRING_BYTES (XSTRING (Vx_resource_name)) + name_key = (char *) alloca (SBYTES (Vx_resource_name) + (STRINGP (component) - ? STRING_BYTES (XSTRING (component)) : 0) - + STRING_BYTES (XSTRING (attribute)) + ? SBYTES (component) : 0) + + SBYTES (attribute) + 3); - class_key = (char *) alloca (STRING_BYTES (XSTRING (Vx_resource_class)) - + STRING_BYTES (XSTRING (class)) + class_key = (char *) alloca (SBYTES (Vx_resource_class) + + SBYTES (class) + (STRINGP (subclass) - ? STRING_BYTES (XSTRING (subclass)) : 0) + ? SBYTES (subclass) : 0) + 3); /* Start with emacs.FRAMENAME for the name (the specific one) and with `Emacs' for the class key (the general one). */ - strcpy (name_key, XSTRING (Vx_resource_name)->data); - strcpy (class_key, XSTRING (Vx_resource_class)->data); + strcpy (name_key, SDATA (Vx_resource_name)); + strcpy (class_key, SDATA (Vx_resource_class)); strcat (class_key, "."); - strcat (class_key, XSTRING (class)->data); + strcat (class_key, SDATA (class)); if (!NILP (component)) { strcat (class_key, "."); - strcat (class_key, XSTRING (subclass)->data); + strcat (class_key, SDATA (subclass)); strcat (name_key, "."); - strcat (name_key, XSTRING (component)->data); + strcat (name_key, SDATA (component)); } strcat (name_key, "."); - strcat (name_key, XSTRING (attribute)->data); + strcat (name_key, SDATA (attribute)); value = x_get_string_resource (check_x_display_info (Qnil)->xrdb, name_key, class_key); @@ -2916,37 +2953,37 @@ display_x_get_resource (dpyinfo, attribute, class, component, subclass) /* Allocate space for the components, the dots which separate them, and the final '\0'. Make them big enough for the worst case. */ - name_key = (char *) alloca (STRING_BYTES (XSTRING (Vx_resource_name)) + name_key = (char *) alloca (SBYTES (Vx_resource_name) + (STRINGP (component) - ? STRING_BYTES (XSTRING (component)) : 0) - + STRING_BYTES (XSTRING (attribute)) + ? SBYTES (component) : 0) + + SBYTES (attribute) + 3); - class_key = (char *) alloca (STRING_BYTES (XSTRING (Vx_resource_class)) - + STRING_BYTES (XSTRING (class)) + class_key = (char *) alloca (SBYTES (Vx_resource_class) + + SBYTES (class) + (STRINGP (subclass) - ? STRING_BYTES (XSTRING (subclass)) : 0) + ? SBYTES (subclass) : 0) + 3); /* Start with emacs.FRAMENAME for the name (the specific one) and with `Emacs' for the class key (the general one). */ - strcpy (name_key, XSTRING (Vx_resource_name)->data); - strcpy (class_key, XSTRING (Vx_resource_class)->data); + strcpy (name_key, SDATA (Vx_resource_name)); + strcpy (class_key, SDATA (Vx_resource_class)); strcat (class_key, "."); - strcat (class_key, XSTRING (class)->data); + strcat (class_key, SDATA (class)); if (!NILP (component)) { strcat (class_key, "."); - strcat (class_key, XSTRING (subclass)->data); + strcat (class_key, SDATA (subclass)); strcat (name_key, "."); - strcat (name_key, XSTRING (component)->data); + strcat (name_key, SDATA (component)); } strcat (name_key, "."); - strcat (name_key, XSTRING (attribute)->data); + strcat (name_key, SDATA (attribute)); value = x_get_string_resource (dpyinfo->xrdb, name_key, class_key); @@ -2968,13 +3005,13 @@ x_get_resource_string (attribute, class) /* Allocate space for the components, the dots which separate them, and the final '\0'. */ - name_key = (char *) alloca (STRING_BYTES (XSTRING (Vinvocation_name)) + name_key = (char *) alloca (SBYTES (Vinvocation_name) + strlen (attribute) + 2); class_key = (char *) alloca ((sizeof (EMACS_CLASS) - 1) + strlen (class) + 2); sprintf (name_key, "%s.%s", - XSTRING (Vinvocation_name)->data, + SDATA (Vinvocation_name), attribute); sprintf (class_key, "%s.%s", EMACS_CLASS, class); @@ -3032,15 +3069,15 @@ x_get_arg (dpyinfo, alist, param, attribute, class, type) switch (type) { case RES_TYPE_NUMBER: - return make_number (atoi (XSTRING (tem)->data)); + return make_number (atoi (SDATA (tem))); case RES_TYPE_FLOAT: - return make_float (atof (XSTRING (tem)->data)); + return make_float (atof (SDATA (tem))); case RES_TYPE_BOOLEAN: tem = Fdowncase (tem); - if (!strcmp (XSTRING (tem)->data, "on") - || !strcmp (XSTRING (tem)->data, "true")) + if (!strcmp (SDATA (tem), "on") + || !strcmp (SDATA (tem), "true")) return Qt; else return Qnil; @@ -3054,11 +3091,11 @@ x_get_arg (dpyinfo, alist, param, attribute, class, type) { Lisp_Object lower; lower = Fdowncase (tem); - if (!strcmp (XSTRING (lower)->data, "on") - || !strcmp (XSTRING (lower)->data, "true")) + if (!strcmp (SDATA (lower), "on") + || !strcmp (SDATA (lower), "true")) return Qt; - else if (!strcmp (XSTRING (lower)->data, "off") - || !strcmp (XSTRING (lower)->data, "false")) + else if (!strcmp (SDATA (lower), "off") + || !strcmp (SDATA (lower), "false")) return Qnil; else return Fintern (tem, Qnil); @@ -3191,7 +3228,7 @@ or a list (- N) meaning -N pixels relative to bottom/right corner. */) CHECK_STRING (string); - geometry = XParseGeometry ((char *) XSTRING (string)->data, + geometry = XParseGeometry ((char *) SDATA (string), &x, &y, &width, &height); #if 0 @@ -3564,7 +3601,7 @@ create_frame_xic (f) { /* Determine the base fontname from the ASCII font name of FONTSET. */ - char *ascii_font = (char *) XSTRING (fontset_ascii (fontset))->data; + char *ascii_font = (char *) SDATA (fontset_ascii (fontset)); char *p = ascii_font; int i; @@ -3719,7 +3756,9 @@ xic_set_statusarea (f) area.height = needed->height; area.x = PIXEL_WIDTH (f) - area.width - FRAME_INTERNAL_BORDER_WIDTH (f); area.y = (PIXEL_HEIGHT (f) - area.height - - FRAME_MENUBAR_HEIGHT (f) - FRAME_INTERNAL_BORDER_WIDTH (f)); + - FRAME_MENUBAR_HEIGHT (f) + - FRAME_TOOLBAR_HEIGHT (f) + - FRAME_INTERNAL_BORDER_WIDTH (f)); XFree (needed); attr = XVaCreateNestedList (0, XNArea, &area, NULL); @@ -3785,7 +3824,7 @@ x_window (f, window_prompting, minibuffer_only) Elsewhere we specify the window name for the window manager. */ { - char *str = (char *) XSTRING (Vx_resource_name)->data; + char *str = (char *) SDATA (Vx_resource_name); f->namebuf = (char *) xmalloc (strlen (str) + 1); strcpy (f->namebuf, str); } @@ -3918,8 +3957,8 @@ x_window (f, window_prompting, minibuffer_only) validate_x_resource_name (); - class_hints.res_name = (char *) XSTRING (Vx_resource_name)->data; - class_hints.res_class = (char *) XSTRING (Vx_resource_class)->data; + class_hints.res_name = (char *) SDATA (Vx_resource_name); + class_hints.res_class = (char *) SDATA (Vx_resource_class); XSetClassHint (FRAME_X_DISPLAY (f), XtWindow (shell_widget), &class_hints); #ifdef HAVE_X_I18N @@ -3993,7 +4032,16 @@ x_window (f, window_prompting, minibuffer_only) } #else /* not USE_X_TOOLKIT */ +#ifdef USE_GTK +void +x_window (f) + FRAME_PTR f; +{ + if (! xg_create_frame_widgets (f)) + error ("Unable to create window"); +} +#else /*! USE_GTK */ /* Create and set up the X window for frame F. */ void @@ -4046,8 +4094,8 @@ x_window (f) validate_x_resource_name (); - class_hints.res_name = (char *) XSTRING (Vx_resource_name)->data; - class_hints.res_class = (char *) XSTRING (Vx_resource_class)->data; + class_hints.res_name = (char *) SDATA (Vx_resource_name); + class_hints.res_class = (char *) SDATA (Vx_resource_class); XSetClassHint (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), &class_hints); /* The menubar is part of the ordinary display; @@ -4096,6 +4144,7 @@ x_window (f) error ("Unable to create window"); } +#endif /* not USE_GTK */ #endif /* not USE_X_TOOLKIT */ /* Handle the icon stuff for this window. Perhaps later we might @@ -4134,9 +4183,9 @@ x_icon (f, parms) ? IconicState : NormalState)); - x_text_icon (f, (char *) XSTRING ((!NILP (f->icon_name) + x_text_icon (f, (char *) SDATA ((!NILP (f->icon_name) ? f->icon_name - : f->name))->data); + : f->name))); UNBLOCK_INPUT; } @@ -4304,7 +4353,7 @@ This function is an internal primitive--use `make-frame' instead. */) int minibuffer_only = 0; long window_prompting = 0; int width, height; - int count = BINDING_STACK_SIZE (); + int count = SPECPDL_INDEX (); struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; Lisp_Object display; struct x_display_info *dpyinfo = NULL; @@ -4469,9 +4518,9 @@ This function is an internal primitive--use `make-frame' instead. */) { tem = Fquery_fontset (font, Qnil); if (STRINGP (tem)) - font = x_new_fontset (f, XSTRING (tem)->data); + font = x_new_fontset (f, SDATA (tem)); else - font = x_new_font (f, XSTRING (font)->data); + font = x_new_font (f, SDATA (font)); } /* Try out a font which we hope has bold and italic variations. */ @@ -4673,7 +4722,7 @@ This function is an internal primitive--use `make-frame' instead. */) new frames. */ call1 (Qface_set_after_frame_default, frame); -#ifdef USE_X_TOOLKIT +#if defined (USE_X_TOOLKIT) || defined (USE_GTK) /* Create the menu bar. */ if (!minibuffer_only && FRAME_EXTERNAL_MENU_BAR (f)) { @@ -4681,13 +4730,15 @@ This function is an internal primitive--use `make-frame' instead. */) frame and we didn't make it visible. */ initialize_frame_menubar (f); +#ifndef USE_GTK /* This is a no-op, except under Motif where it arranges the main window for the widgets on it. */ lw_set_main_areas (f->output_data.x->column_widget, f->output_data.x->menubar_widget, f->output_data.x->edit_widget); +#endif /* not USE_GTK */ } -#endif /* USE_X_TOOLKIT */ +#endif /* USE_X_TOOLKIT || USE_GTK */ /* Tell the server what size and position, etc, we want, and how badly we want them. This should be done after we have the menu @@ -4785,7 +4836,7 @@ DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, 1, 2, 0, CHECK_STRING (color); - if (x_defined_color (f, XSTRING (color)->data, &foo, 0)) + if (x_defined_color (f, SDATA (color), &foo, 0)) return Qt; else return Qnil; @@ -4801,7 +4852,7 @@ DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2, 0, CHECK_STRING (color); - if (x_defined_color (f, XSTRING (color)->data, &foo, 0)) + if (x_defined_color (f, SDATA (color), &foo, 0)) { Lisp_Object rgb[3]; @@ -5212,12 +5263,12 @@ select_visual (dpyinfo) /* VALUE should be of the form CLASS-DEPTH, where CLASS is one of `PseudoColor', `TrueColor' etc. and DEPTH is the color depth, a decimal number. NAME is compared with case ignored. */ - char *s = (char *) alloca (STRING_BYTES (XSTRING (value)) + 1); + char *s = (char *) alloca (SBYTES (value) + 1); char *dash; int i, class = -1; XVisualInfo vinfo; - strcpy (s, XSTRING (value)->data); + strcpy (s, SDATA (value)); dash = index (s, '-'); if (dash) { @@ -5241,7 +5292,7 @@ select_visual (dpyinfo) if (class == -1 || !XMatchVisualInfo (dpy, XScreenNumberOfScreen (screen), dpyinfo->n_planes, class, &vinfo)) - fatal ("Invalid visual specification `%s'", XSTRING (value)->data); + fatal ("Invalid visual specification `%s'", SDATA (value)); dpyinfo->visual = vinfo.visual; } @@ -5300,10 +5351,10 @@ x_display_info_for_name (name) validate_x_resource_name (); dpyinfo = x_term_init (name, (char *)0, - (char *) XSTRING (Vx_resource_name)->data); + (char *) SDATA (Vx_resource_name)); if (dpyinfo == 0) - error ("Cannot connect to X server %s", XSTRING (name)->data); + error ("Cannot connect to X server %s", SDATA (name)); x_in_use = 1; XSETFASTINT (Vwindow_system_version, 11); @@ -5333,7 +5384,7 @@ terminate Emacs if we can't open the connection. */) error ("Not using X Windows"); if (! NILP (xrm_string)) - xrm_option = (unsigned char *) XSTRING (xrm_string)->data; + xrm_option = (unsigned char *) SDATA (xrm_string); else xrm_option = (unsigned char *) 0; @@ -5342,18 +5393,19 @@ terminate Emacs if we can't open the connection. */) /* This is what opens the connection and sets x_current_display. This also initializes many symbols, such as those used for input. */ dpyinfo = x_term_init (display, xrm_option, - (char *) XSTRING (Vx_resource_name)->data); + (char *) SDATA (Vx_resource_name)); if (dpyinfo == 0) { if (!NILP (must_succeed)) fatal ("Cannot connect to X server %s.\n\ Check the DISPLAY environment variable or use `-d'.\n\ -Also use the `xhost' program to verify that it is set to permit\n\ -connections from your machine.\n", - XSTRING (display)->data); +Also use the `xauth' program to verify that you have the proper\n\ +authorization information needed to connect the X server.\n\ +An insecure way to solve the problem may be to use `xhost'.\n", + SDATA (display)); else - error ("Cannot connect to X server %s", XSTRING (display)->data); + error ("Cannot connect to X server %s", SDATA (display)); } x_in_use = 1; @@ -5667,7 +5719,7 @@ parse_image_spec (spec, keywords, nkeywords, type) /* Find key in KEYWORDS. Error if not found. */ for (i = 0; i < nkeywords; ++i) - if (strcmp (keywords[i].name, XSTRING (SYMBOL_NAME (key))->data) == 0) + if (strcmp (keywords[i].name, SDATA (SYMBOL_NAME (key))) == 0) break; if (i == nkeywords) @@ -6147,7 +6199,7 @@ x_alloc_image_color (f, img, color_name, dflt) xassert (STRINGP (color_name)); - if (x_defined_color (f, XSTRING (color_name)->data, &color, 1)) + if (x_defined_color (f, SDATA (color_name), &color, 1)) { /* This isn't called frequently so we get away with simply reallocating the color vector to the needed size, here. */ @@ -6641,6 +6693,7 @@ x_put_x_image (f, ximg, pixmap, width, height) struct frame *f; XImage *ximg; Pixmap pixmap; + int width, height; { GC gc; @@ -6885,7 +6938,7 @@ xbm_image_p (object) if (STRINGP (elt)) { - if (XSTRING (elt)->size + if (SCHARS (elt) < (width + BITS_PER_CHAR - 1) / BITS_PER_CHAR) return 0; } @@ -6900,7 +6953,7 @@ xbm_image_p (object) } else if (STRINGP (data)) { - if (XSTRING (data)->size + if (SCHARS (data) < (width + BITS_PER_CHAR - 1) / BITS_PER_CHAR * height) return 0; } @@ -7230,9 +7283,9 @@ xbm_file_p (data) { int w, h; return (STRINGP (data) - && xbm_read_bitmap_data (XSTRING (data)->data, - (XSTRING (data)->data - + STRING_BYTES (XSTRING (data))), + && xbm_read_bitmap_data (SDATA (data), + (SDATA (data) + + SBYTES (data)), &w, &h, NULL)); } @@ -7268,7 +7321,7 @@ xbm_load (f, img) return 0; } - contents = slurp_file (XSTRING (file)->data, &size); + contents = slurp_file (SDATA (file), &size); if (contents == NULL) { image_error ("Error loading XBM image `%s'", img->spec, Qnil); @@ -7318,9 +7371,9 @@ xbm_load (f, img) background); if (in_memory_file_p) - success_p = xbm_load_image (f, img, XSTRING (data)->data, - (XSTRING (data)->data - + STRING_BYTES (XSTRING (data)))); + success_p = xbm_load_image (f, img, SDATA (data), + (SDATA (data) + + SBYTES (data))); else { if (VECTORP (data)) @@ -7334,13 +7387,13 @@ xbm_load (f, img) { Lisp_Object line = XVECTOR (data)->contents[i]; if (STRINGP (line)) - bcopy (XSTRING (line)->data, p, nbytes); + bcopy (SDATA (line), p, nbytes); else bcopy (XBOOL_VECTOR (line)->data, p, nbytes); } } else if (STRINGP (data)) - bits = XSTRING (data)->data; + bits = SDATA (data); else bits = XBOOL_VECTOR (data)->data; @@ -7742,10 +7795,10 @@ xpm_load (f, img) { Lisp_Object name = XCAR (XCAR (tail)); Lisp_Object color = XCDR (XCAR (tail)); - xpm_syms[i].name = (char *) alloca (XSTRING (name)->size + 1); - strcpy (xpm_syms[i].name, XSTRING (name)->data); - xpm_syms[i].value = (char *) alloca (XSTRING (color)->size + 1); - strcpy (xpm_syms[i].value, XSTRING (color)->data); + xpm_syms[i].name = (char *) alloca (SCHARS (name) + 1); + strcpy (xpm_syms[i].name, SDATA (name)); + xpm_syms[i].value = (char *) alloca (SCHARS (color) + 1); + strcpy (xpm_syms[i].value, SDATA (color)); } } @@ -7766,14 +7819,14 @@ xpm_load (f, img) } rc = XpmReadFileToPixmap (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), - XSTRING (file)->data, &img->pixmap, &img->mask, + SDATA (file), &img->pixmap, &img->mask, &attrs); } else { Lisp_Object buffer = image_spec_value (img->spec, QCdata, NULL); rc = XpmCreatePixmapFromBuffer (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), - XSTRING (buffer)->data, + SDATA (buffer), &img->pixmap, &img->mask, &attrs); } @@ -8573,7 +8626,7 @@ pbm_load (f, img) return 0; } - contents = slurp_file (XSTRING (file)->data, &size); + contents = slurp_file (SDATA (file), &size); if (contents == NULL) { image_error ("Error reading `%s'", file, Qnil); @@ -8588,8 +8641,8 @@ pbm_load (f, img) { Lisp_Object data; data = image_spec_value (img->spec, QCdata, NULL); - p = XSTRING (data)->data; - end = p + STRING_BYTES (XSTRING (data)); + p = SDATA (data); + end = p + SBYTES (data); } /* Check magic number. */ @@ -8938,7 +8991,7 @@ png_load (f, img) } /* Open the image file. */ - fp = fopen (XSTRING (file)->data, "rb"); + fp = fopen (SDATA (file), "rb"); if (!fp) { image_error ("Cannot open image file `%s'", file, Qnil); @@ -8960,8 +9013,8 @@ png_load (f, img) else { /* Read from memory. */ - tbr.bytes = XSTRING (specified_data)->data; - tbr.len = STRING_BYTES (XSTRING (specified_data)); + tbr.bytes = SDATA (specified_data); + tbr.len = SBYTES (specified_data); tbr.index = 0; /* Check PNG signature. */ @@ -9056,8 +9109,8 @@ png_load (f, img) screen_gamma = (f->gamma ? 1 / f->gamma / 0.45455 : 2.2); +#if 0 /* Avoid double gamma correction for PNG images. */ /* Tell the PNG lib to handle gamma correction for us. */ - #if defined(PNG_READ_sRGB_SUPPORTED) || defined(PNG_WRITE_sRGB_SUPPORTED) if (png_get_sRGB (png_ptr, info_ptr, &intent)) /* The libpng documentation says this is right in this case. */ @@ -9070,6 +9123,7 @@ png_load (f, img) else /* Use the standard default for the image gamma. */ png_set_gamma (png_ptr, screen_gamma, 0.45455); +#endif /* if 0 */ /* Handle alpha channel by combining the image with a background color. Do this only if a real alpha channel is supplied. For @@ -9084,7 +9138,7 @@ png_load (f, img) /* The user specified `:background', use that. */ { XColor color; - if (x_defined_color (f, XSTRING (specified_bg)->data, &color, 0)) + if (x_defined_color (f, SDATA (specified_bg), &color, 0)) { png_color_16 user_bg; @@ -9504,7 +9558,7 @@ jpeg_load (f, img) return 0; } - fp = fopen (XSTRING (file)->data, "r"); + fp = fopen (SDATA (file), "r"); if (fp == NULL) { image_error ("Cannot open `%s'", file, Qnil); @@ -9551,8 +9605,8 @@ jpeg_load (f, img) if (NILP (specified_data)) jpeg_stdio_src (&cinfo, (FILE *) fp); else - jpeg_memory_src (&cinfo, XSTRING (specified_data)->data, - STRING_BYTES (XSTRING (specified_data))); + jpeg_memory_src (&cinfo, SDATA (specified_data), + SBYTES (specified_data)); jpeg_read_header (&cinfo, TRUE); @@ -9898,7 +9952,7 @@ tiff_load (f, img) } /* Try to open the image file. */ - tiff = TIFFOpen (XSTRING (file)->data, "r"); + tiff = TIFFOpen (SDATA (file), "r"); if (tiff == NULL) { image_error ("Cannot open `%s'", file, Qnil); @@ -9909,8 +9963,8 @@ tiff_load (f, img) else { /* Memory source! */ - memsrc.bytes = XSTRING (specified_data)->data; - memsrc.len = STRING_BYTES (XSTRING (specified_data)); + memsrc.bytes = SDATA (specified_data); + memsrc.len = SBYTES (specified_data); memsrc.index = 0; tiff = TIFFClientOpen ("memory_source", "r", &memsrc, @@ -10147,7 +10201,7 @@ gif_load (f, img) } /* Open the GIF file. */ - gif = DGifOpenFileName (XSTRING (file)->data); + gif = DGifOpenFileName (SDATA (file)); if (gif == NULL) { image_error ("Cannot open `%s'", file, Qnil); @@ -10159,8 +10213,8 @@ gif_load (f, img) { /* Read from memory! */ current_gif_memory_src = &memsrc; - memsrc.bytes = XSTRING (specified_data)->data; - memsrc.len = STRING_BYTES (XSTRING (specified_data)); + memsrc.bytes = SDATA (specified_data); + memsrc.len = SBYTES (specified_data); memsrc.index = 0; gif = DGifOpen(&memsrc, gif_read_from_memory); @@ -10610,10 +10664,10 @@ selected frame. Value is VALUE. */) CHECK_STRING (value); BLOCK_INPUT; - prop_atom = XInternAtom (FRAME_X_DISPLAY (f), XSTRING (prop)->data, False); + prop_atom = XInternAtom (FRAME_X_DISPLAY (f), SDATA (prop), False); XChangeProperty (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), prop_atom, XA_STRING, 8, PropModeReplace, - XSTRING (value)->data, XSTRING (value)->size); + SDATA (value), SCHARS (value)); /* Make sure the property is set when we return. */ XFlush (FRAME_X_DISPLAY (f)); @@ -10635,7 +10689,7 @@ FRAME nil or omitted means use the selected frame. Value is PROP. */) CHECK_STRING (prop); BLOCK_INPUT; - prop_atom = XInternAtom (FRAME_X_DISPLAY (f), XSTRING (prop)->data, False); + prop_atom = XInternAtom (FRAME_X_DISPLAY (f), SDATA (prop), False); XDeleteProperty (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), prop_atom); /* Make sure the property is removed when we return. */ @@ -10666,7 +10720,7 @@ value. */) CHECK_STRING (prop); BLOCK_INPUT; - prop_atom = XInternAtom (FRAME_X_DISPLAY (f), XSTRING (prop)->data, False); + prop_atom = XInternAtom (FRAME_X_DISPLAY (f), SDATA (prop), False); rc = XGetWindowProperty (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), prop_atom, 0, 0, False, XA_STRING, &actual_type, &actual_format, &actual_size, @@ -10937,7 +10991,7 @@ x_create_tip_frame (dpyinfo, parms, text) Lisp_Object name; long window_prompting = 0; int width, height; - int count = BINDING_STACK_SIZE (); + int count = SPECPDL_INDEX (); struct gcpro gcpro1, gcpro2, gcpro3; struct kboard *kb; int face_change_count_before = face_change_count; @@ -11059,9 +11113,9 @@ x_create_tip_frame (dpyinfo, parms, text) { tem = Fquery_fontset (font, Qnil); if (STRINGP (tem)) - font = x_new_fontset (f, XSTRING (tem)->data); + font = x_new_fontset (f, SDATA (tem)); else - font = x_new_font (f, XSTRING (font)->data); + font = x_new_font (f, SDATA (font)); } /* Try out a font which we hope has bold and italic variations. */ @@ -11193,7 +11247,12 @@ x_create_tip_frame (dpyinfo, parms, text) f->height = 0; SET_FRAME_WIDTH (f, 0); change_frame_size (f, height, width, 1, 0, 0); - + + /* Add `tooltip' frame parameter's default value. */ + if (NILP (Fframe_parameter (frame, intern ("tooltip")))) + Fmodify_frame_parameters (frame, Fcons (Fcons (intern ("tooltip"), Qt), + Qnil)); + /* Set up faces after all frame parameters are known. This call also merges in face attributes specified for new frames. @@ -11328,7 +11387,7 @@ Text larger than the specified size is clipped. */) int i, width, height; struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; int old_windows_or_buffers_changed = windows_or_buffers_changed; - int count = BINDING_STACK_SIZE (); + int count = SPECPDL_INDEX (); specbind (Qinhibit_redisplay, Qt); @@ -11521,7 +11580,7 @@ Value is t if tooltip was open, nil otherwise. */) GCPRO2 (frame, timer); tip_frame = tip_timer = deleted = Qnil; - count = BINDING_STACK_SIZE (); + count = SPECPDL_INDEX (); specbind (Qinhibit_redisplay, Qt); specbind (Qinhibit_quit, Qt); @@ -11610,7 +11669,7 @@ selection dialog's entry field, if MUSTMATCH is non-nil. */) int ac = 0; extern XtAppContext Xt_app_con; XmString dir_xmstring, pattern_xmstring; - int count = specpdl_ptr - specpdl; + int count = SPECPDL_INDEX (); struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; GCPRO5 (prompt, dir, default_filename, mustmatch, file); @@ -11625,10 +11684,10 @@ selection dialog's entry field, if MUSTMATCH is non-nil. */) /* Create the dialog with PROMPT as title, using DIR as initial directory and using "*" as pattern. */ dir = Fexpand_file_name (dir, Qnil); - dir_xmstring = XmStringCreateLocalized (XSTRING (dir)->data); + dir_xmstring = XmStringCreateLocalized (SDATA (dir)); pattern_xmstring = XmStringCreateLocalized ("*"); - XtSetArg (al[ac], XmNtitle, XSTRING (prompt)->data); ++ac; + XtSetArg (al[ac], XmNtitle, SDATA (prompt)); ++ac; XtSetArg (al[ac], XmNdirectory, dir_xmstring); ++ac; XtSetArg (al[ac], XmNpattern, pattern_xmstring); ++ac; XtSetArg (al[ac], XmNresizePolicy, XmRESIZE_GROW); ++ac; @@ -11679,7 +11738,7 @@ selection dialog's entry field, if MUSTMATCH is non-nil. */) int item_pos; default_xmstring - = XmStringCreateLocalized (XSTRING (default_filename)->data); + = XmStringCreateLocalized (SDATA (default_filename)); if (!XmListItemExists (list, default_xmstring)) { @@ -11696,18 +11755,14 @@ selection dialog's entry field, if MUSTMATCH is non-nil. */) XmListSetPos (list, item_pos); } - /* Process events until the user presses Cancel or OK. Block - and unblock input here so that we get a chance of processing - expose events. */ - UNBLOCK_INPUT; + /* Process events until the user presses Cancel or OK. */ result = 0; while (result == 0) { - BLOCK_INPUT; - XtAppProcessEvent (Xt_app_con, XtIMAll); - UNBLOCK_INPUT; + XEvent event; + XtAppNextEvent (Xt_app_con, &event); + x_dispatch_event (&event, FRAME_X_DISPLAY (f) ); } - BLOCK_INPUT; /* Get the result. */ if (result == XmCR_OK) @@ -11739,6 +11794,58 @@ selection dialog's entry field, if MUSTMATCH is non-nil. */) #endif /* USE_MOTIF */ +#ifdef USE_GTK + +DEFUN ("x-file-dialog", Fx_file_dialog, Sx_file_dialog, 2, 4, 0, + "Read file name, prompting with PROMPT in directory DIR.\n\ +Use a file selection dialog.\n\ +Select DEFAULT-FILENAME in the dialog's file selection box, if\n\ +specified. Don't let the user enter a file name in the file\n\ +selection dialog's entry field, if MUSTMATCH is non-nil.") + (prompt, dir, default_filename, mustmatch) + Lisp_Object prompt, dir, default_filename, mustmatch; +{ + FRAME_PTR f = SELECTED_FRAME (); + char *fn; + Lisp_Object file = Qnil; + int count = specpdl_ptr - specpdl; + struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; + char *cdef_file; + char *cprompt; + + GCPRO5 (prompt, dir, default_filename, mustmatch, file); + CHECK_STRING (prompt); + CHECK_STRING (dir); + + /* Prevent redisplay. */ + specbind (Qinhibit_redisplay, Qt); + + BLOCK_INPUT; + + if (STRINGP (default_filename)) + cdef_file = SDATA (default_filename); + else + cdef_file = SDATA (dir); + + fn = xg_get_file_name (f, SDATA (prompt), cdef_file, ! NILP (mustmatch)); + + if (fn) + { + file = build_string (fn); + xfree (fn); + } + + UNBLOCK_INPUT; + UNGCPRO; + + /* Make "Cancel" equivalent to C-g. */ + if (NILP (file)) + Fsignal (Qquit, Qnil); + + return unbind_to (count, file); +} + +#endif /* USE_GTK */ /*********************************************************************** @@ -11845,16 +11952,10 @@ syms_of_xfns () staticpro (&Qauto_raise); Qauto_lower = intern ("auto-lower"); staticpro (&Qauto_lower); - Qbar = intern ("bar"); - staticpro (&Qbar); - Qhbar = intern ("hbar"); - staticpro (&Qhbar); Qborder_color = intern ("border-color"); staticpro (&Qborder_color); Qborder_width = intern ("border-width"); staticpro (&Qborder_width); - Qbox = intern ("box"); - staticpro (&Qbox); Qcursor_color = intern ("cursor-color"); staticpro (&Qcursor_color); Qcursor_type = intern ("cursor-type"); @@ -11966,7 +12067,7 @@ A cross is always drawn on black & white displays. */); cross_disabled_images = 0; DEFVAR_LISP ("x-bitmap-file-path", &Vx_bitmap_file_path, - doc: /* List of directories to search for bitmap files for X. */); + doc: /* List of directories to search for window system bitmap files. */); Vx_bitmap_file_path = decode_env_path ((char *) 0, PATH_BITMAPS); DEFVAR_LISP ("x-pointer-shape", &Vx_pointer_shape,