X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/e4cebfca13580f80fb0ecee27afb81b55c031535..823564e519dd1f3e81a79949e1abc033c9e7c0a5:/src/xfns.c diff --git a/src/xfns.c b/src/xfns.c index 50a56b5561..eec19b9d27 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -83,6 +83,8 @@ along with GNU Emacs. If not, see . */ #undef USG /* ####KLUDGE for Solaris 2.2 and up */ #include #define USG +#ifdef USG /* Pacify gcc -Wunused-macros. */ +#endif #else #include #endif @@ -105,16 +107,13 @@ along with GNU Emacs. If not, see . */ #if !defined(NO_EDITRES) #define HACK_EDITRES -extern void _XEditResCheckMessages (); +extern void _XEditResCheckMessages (Widget, XtPointer, XEvent *, Boolean *); #endif /* not defined NO_EDITRES */ /* Unique id counter for widgets created by the Lucid Widget Library. */ extern LWLIB_ID widget_id_tick; -extern void free_frame_menubar (); -extern double atof (); - #ifdef USE_MOTIF #endif /* USE_MOTIF */ @@ -146,7 +145,7 @@ static Lisp_Object Qcompound_text, Qcancel_timer; Lisp_Object Qfont_param; #if GLYPH_DEBUG -int image_cache_refcount, dpyinfo_refcount; +static int image_cache_refcount, dpyinfo_refcount; #endif #if defined (USE_GTK) && defined (HAVE_FREETYPE) @@ -217,7 +216,7 @@ check_x_display_info (Lisp_Object object) struct terminal *t = get_terminal (object, 1); if (t->type != output_x_window) - error ("Terminal %"pEd" is not an X display", XINT (object)); + error ("Terminal %"pI"d is not an X display", XINT (object)); dpyinfo = t->display_info.x; } @@ -428,7 +427,7 @@ x_top_window_to_frame (struct x_display_info *dpyinfo, int wdesc) void x_real_positions (FRAME_PTR f, int *xptr, int *yptr) { - int win_x, win_y, outer_x, outer_y; + int win_x, win_y, outer_x IF_LINT (= 0), outer_y IF_LINT (= 0); int real_x = 0, real_y = 0; int had_errors = 0; Window win = f->output_data.x->parent_desc; @@ -1075,8 +1074,7 @@ x_set_border_pixel (struct frame *f, int pix) if (FRAME_X_WINDOW (f) != 0 && f->border_width > 0) { BLOCK_INPUT; - XSetWindowBorder (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), - (unsigned long)pix); + XSetWindowBorder (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), pix); UNBLOCK_INPUT; if (FRAME_VISIBLE_P (f)) @@ -1228,7 +1226,7 @@ x_set_menu_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval) } #else /* not USE_X_TOOLKIT && not USE_GTK */ FRAME_MENU_BAR_LINES (f) = nlines; - change_window_heights (f->root_window, nlines - olines); + resize_frame_windows (f, FRAME_LINES (f), 0); /* If the menu bar height gets changed, the internal border below the top margin has to be cleared. Also, if the menu bar gets @@ -1267,6 +1265,7 @@ x_set_menu_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval) } #endif /* not USE_X_TOOLKIT && not USE_GTK */ adjust_glyphs (f); + run_window_configuration_change_hook (f); } @@ -1327,7 +1326,7 @@ x_set_tool_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval) } FRAME_TOOL_BAR_LINES (f) = nlines; - change_window_heights (root_window, delta); + resize_frame_windows (f, FRAME_LINES (f), 0); adjust_glyphs (f); /* We also have to make sure that the internal border at the top of @@ -1363,6 +1362,9 @@ x_set_tool_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval) if (WINDOWP (f->tool_bar_window)) clear_glyph_matrix (XWINDOW (f->tool_bar_window)->current_matrix); } + + run_window_configuration_change_hook (f); + } @@ -1696,10 +1698,14 @@ void x_set_scroll_bar_default_width (struct frame *f) { int wid = FRAME_COLUMN_WIDTH (f); - #ifdef USE_TOOLKIT_SCROLL_BARS +#ifdef USE_GTK + int minw = xg_get_default_scrollbar_width (); +#else + int minw = 16; +#endif /* A minimum width of 14 doesn't look good for toolkit scroll bars. */ - int width = 16 + 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM; + int width = minw + 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM; FRAME_CONFIG_SCROLL_BAR_COLS (f) = (width + wid - 1) / wid; FRAME_CONFIG_SCROLL_BAR_WIDTH (f) = width; #else @@ -1877,7 +1883,7 @@ xic_create_fontsetname (const char *base_fontname, int motif) /* Make a fontset name from the base font name. */ if (xic_defaut_fontset == base_fontname) { /* There is no base font name, use the default. */ - int len = strlen (base_fontname) + 2; + ptrdiff_t len = strlen (base_fontname) + 2; fontsetname = xmalloc (len); memset (fontsetname, 0, len); strcpy (fontsetname, base_fontname); @@ -1890,7 +1896,7 @@ xic_create_fontsetname (const char *base_fontname, int motif) - the base font where the charset spec is replaced by -*-*. - the same but with the family also replaced with -*-*-. */ const char *p = base_fontname; - int i; + ptrdiff_t i; for (i = 0; *p; p++) if (*p == '-') i++; @@ -1898,7 +1904,8 @@ xic_create_fontsetname (const char *base_fontname, int motif) { /* As the font name doesn't conform to XLFD, we can't modify it to generalize it to allcs and allfamilies. Use the specified font plus the default. */ - int len = strlen (base_fontname) + strlen (xic_defaut_fontset) + 3; + ptrdiff_t len = + strlen (base_fontname) + strlen (xic_defaut_fontset) + 3; fontsetname = xmalloc (len); memset (fontsetname, 0, len); strcpy (fontsetname, base_fontname); @@ -1907,7 +1914,7 @@ xic_create_fontsetname (const char *base_fontname, int motif) } else { - int len; + ptrdiff_t len; const char *p1 = NULL, *p2 = NULL, *p3 = NULL; char *font_allcs = NULL; char *font_allfamilies = NULL; @@ -1934,7 +1941,7 @@ xic_create_fontsetname (const char *base_fontname, int motif) wildcard. */ if (*p3 != '*') { - int diff = (p2 - p3) - 2; + ptrdiff_t diff = (p2 - p3) - 2; base = alloca (strlen (base_fontname) + 1); memcpy (base, base_fontname, p3 - base_fontname); @@ -1994,11 +2001,8 @@ xic_create_fontsetname (const char *base_fontname, int motif) #ifdef DEBUG_XIC_FONTSET static void -print_fontset_result (xfs, name, missing_list, missing_count) - XFontSet xfs; - char *name; - char **missing_list; - int missing_count; +print_fontset_result (XFontSet xfs, char *name, char **missing_list, + int missing_count) { if (xfs) fprintf (stderr, "XIC Fontset created: %s\n", name); @@ -2428,10 +2432,10 @@ x_window (struct frame *f, long window_prompting, int minibuffer_only) /* Do some needed geometry management. */ { - int len; + ptrdiff_t len; char *tem, shell_position[32]; - Arg al[10]; - int ac = 0; + Arg gal[10]; + int gac = 0; int extra_borders = 0; int menubar_size = (f->output_data.x->menubar_widget @@ -2492,8 +2496,8 @@ x_window (struct frame *f, long window_prompting, int minibuffer_only) If Emacs had just one program position, we could set it in fallback resources, but since each make-frame call can specify different program positions, this is easier. */ - XtSetArg (al[ac], XtNx, left); ac++; - XtSetArg (al[ac], XtNy, top); ac++; + XtSetArg (gal[gac], XtNx, left); gac++; + XtSetArg (gal[gac], XtNy, top); gac++; } } @@ -2504,8 +2508,8 @@ x_window (struct frame *f, long window_prompting, int minibuffer_only) when the frame is deleted. */ tem = (char *) xmalloc (len); strncpy (tem, shell_position, len); - XtSetArg (al[ac], XtNgeometry, tem); ac++; - XtSetValues (shell_widget, al, ac); + XtSetArg (gal[gac], XtNgeometry, tem); gac++; + XtSetValues (shell_widget, gal, gac); } XtManageChild (pane_widget); @@ -2920,7 +2924,7 @@ unwind_create_frame (Lisp_Object frame) /* If frame is ``official'', nothing to do. */ if (!CONSP (Vframe_list) || !EQ (XCAR (Vframe_list), frame)) { -#if GLYPH_DEBUG +#if GLYPH_DEBUG && XASSERTS struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); #endif @@ -2929,7 +2933,7 @@ unwind_create_frame (Lisp_Object frame) #if GLYPH_DEBUG /* Check that reference counts are indeed correct. */ xassert (dpyinfo->reference_count == dpyinfo_refcount); - xassert (dpyinfo->image_cache->refcount == image_cache_refcount); + xassert (dpyinfo->terminal->image_cache->refcount == image_cache_refcount); #endif return Qt; } @@ -2958,7 +2962,7 @@ x_default_font_parameter (struct frame *f, Lisp_Object parms) { char *name = xstrdup (system_font); font = font_open_by_name (f, name); - free (name); + xfree (name); } } @@ -3150,10 +3154,6 @@ This function is an internal primitive--use `make-frame' instead. */) /* With FRAME_X_DISPLAY_INFO set up, this unwind-protect is safe. */ record_unwind_protect (unwind_create_frame, frame); -#if GLYPH_DEBUG - image_cache_refcount = FRAME_IMAGE_CACHE (f)->refcount; - dpyinfo_refcount = dpyinfo->reference_count; -#endif /* GLYPH_DEBUG */ /* These colors will be set anyway later, but it's important to get the color reference counts right, so initialize them! */ @@ -3308,6 +3308,11 @@ This function is an internal primitive--use `make-frame' instead. */) happen. */ init_frame_faces (f); +#if GLYPH_DEBUG + image_cache_refcount = FRAME_IMAGE_CACHE (f)->refcount; + dpyinfo_refcount = dpyinfo->reference_count; +#endif /* GLYPH_DEBUG */ + /* The X resources controlling the menu-bar and tool-bar are processed specially at startup, and reflected in the mode variables; ignore them here. */ @@ -3495,7 +3500,7 @@ x_get_focus_frame (struct frame *frame) policy. But I think it's okay to use when it's clearly done following a user-command. */ -DEFUE ("x-focus-frame", Fx_focus_frame, Sx_focus_frame, 1, 1, 0, +DEFUN ("x-focus-frame", Fx_focus_frame, Sx_focus_frame, 1, 1, 0, doc: /* Set the input focus to FRAME. FRAME nil means use the selected frame. */) (Lisp_Object frame) @@ -3548,7 +3553,7 @@ DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2, 0, return Qnil; } -DEFUE ("xw-display-color-p", Fxw_display_color_p, Sxw_display_color_p, 0, 1, 0, +DEFUN ("xw-display-color-p", Fxw_display_color_p, Sxw_display_color_p, 0, 1, 0, doc: /* Internal function called by `display-color-p', which see. */) (Lisp_Object terminal) { @@ -3570,7 +3575,7 @@ DEFUE ("xw-display-color-p", Fxw_display_color_p, Sxw_display_color_p, 0, 1, 0, } } -DEFUE ("x-display-grayscale-p", Fx_display_grayscale_p, Sx_display_grayscale_p, +DEFUN ("x-display-grayscale-p", Fx_display_grayscale_p, Sx_display_grayscale_p, 0, 1, 0, doc: /* Return t if the X display supports shades of gray. Note that color displays do support shades of gray. @@ -4296,18 +4301,9 @@ no value of TYPE (always string in the MS Windows case). */) if (! NILP (source)) { - if (NUMBERP (source)) - { - if (FLOATP (source)) - target_window = (Window) XFLOAT (source); - else - target_window = XFASTINT (source); - - if (target_window == 0) - target_window = FRAME_X_DISPLAY_INFO (f)->root_window; - } - else if (CONSP (source)) - target_window = cons_to_long (source); + CONS_TO_INTEGER (source, Window, target_window); + if (! target_window) + target_window = FRAME_X_DISPLAY_INFO (f)->root_window; } BLOCK_INPUT; @@ -4353,7 +4349,7 @@ no value of TYPE (always string in the MS Windows case). */) property and those are indeed in 32 bit quantities if format is 32. */ - if (actual_format == 32 && actual_format < BITS_PER_LONG) + if (32 < BITS_PER_LONG && actual_format == 32) { unsigned long i; int *idata = (int *) tmp_data; @@ -4609,10 +4605,6 @@ x_create_tip_frame (struct x_display_info *dpyinfo, #endif /* USE_TOOLKIT_SCROLL_BARS */ f->icon_name = Qnil; FRAME_X_DISPLAY_INFO (f) = dpyinfo; -#if GLYPH_DEBUG - image_cache_refcount = FRAME_IMAGE_CACHE (f)->refcount; - dpyinfo_refcount = dpyinfo->reference_count; -#endif /* GLYPH_DEBUG */ f->output_data.x->parent_desc = FRAME_X_DISPLAY_INFO (f)->root_window; f->output_data.x->explicit_parent = 0; @@ -4724,6 +4716,11 @@ x_create_tip_frame (struct x_display_info *dpyinfo, happen. */ init_frame_faces (f); +#if GLYPH_DEBUG + image_cache_refcount = FRAME_IMAGE_CACHE (f)->refcount; + dpyinfo_refcount = dpyinfo->reference_count; +#endif /* GLYPH_DEBUG */ + f->output_data.x->parent_desc = FRAME_X_DISPLAY_INFO (f)->root_window; x_figure_window_size (f, parms, 0); @@ -5198,7 +5195,7 @@ Text larger than the specified size is clipped. */) } -DEFUE ("x-hide-tip", Fx_hide_tip, Sx_hide_tip, 0, 0, 0, +DEFUN ("x-hide-tip", Fx_hide_tip, Sx_hide_tip, 0, 0, 0, doc: /* Hide the current tooltip window, if there is any. Value is t if tooltip was open, nil otherwise. */) (void) @@ -5206,7 +5203,6 @@ Value is t if tooltip was open, nil otherwise. */) int count; Lisp_Object deleted, frame, timer; struct gcpro gcpro1, gcpro2; - struct frame *f; /* Return quickly if nothing to do. */ if (NILP (tip_timer) && NILP (tip_frame)) @@ -5225,11 +5221,13 @@ Value is t if tooltip was open, nil otherwise. */) call1 (Qcancel_timer, timer); #ifdef USE_GTK - /* When using system tooltip, tip_frame is the Emacs frame on which - the tip is shown. */ - f = XFRAME (frame); - if (FRAME_LIVE_P (f) && xg_hide_tooltip (f)) - frame = Qnil; + { + /* When using system tooltip, tip_frame is the Emacs frame on which + the tip is shown. */ + struct frame *f = XFRAME (frame); + if (FRAME_LIVE_P (f) && xg_hide_tooltip (f)) + frame = Qnil; + } #endif if (FRAMEP (frame)) @@ -5243,7 +5241,7 @@ Value is t if tooltip was open, nil otherwise. */) items is unmapped. Redisplay the menu manually... */ { Widget w; - f = SELECTED_FRAME (); + struct frame *f = SELECTED_FRAME (); w = f->output_data.x->menubar_widget; if (!DoesSaveUnders (FRAME_X_DISPLAY_INFO (f)->screen) @@ -5462,12 +5460,12 @@ Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories. */) /* Get the result. */ if (result == XmCR_OK) { - XmString text; + XmString text_string; String data; - XtVaGetValues (dialog, XmNtextString, &text, NULL); - XmStringGetLtoR (text, XmFONTLIST_DEFAULT_TAG, &data); - XmStringFree (text); + XtVaGetValues (dialog, XmNtextString, &text_string, NULL); + XmStringGetLtoR (text_string, XmFONTLIST_DEFAULT_TAG, &data); + XmStringFree (text_string); file = build_string (data); XtFree (data); } @@ -5796,25 +5794,14 @@ syms_of_xfns (void) /* 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_c_string ("none"); - staticpro (&Qnone); - Qsuppress_icon = intern_c_string ("suppress-icon"); - staticpro (&Qsuppress_icon); - Qundefined_color = intern_c_string ("undefined-color"); - staticpro (&Qundefined_color); - Qcompound_text = intern_c_string ("compound-text"); - staticpro (&Qcompound_text); - Qcancel_timer = intern_c_string ("cancel-timer"); - staticpro (&Qcancel_timer); - Qfont_param = intern_c_string ("font-parameter"); - staticpro (&Qfont_param); + DEFSYM (Qnone, "none"); + DEFSYM (Qsuppress_icon, "suppress-icon"); + DEFSYM (Qundefined_color, "undefined-color"); + DEFSYM (Qcompound_text, "compound-text"); + DEFSYM (Qcancel_timer, "cancel-timer"); + DEFSYM (Qfont_param, "font-parameter"); /* This is the end of symbol initialization. */ - /* Text property `display' should be nonsticky by default. */ - Vtext_property_default_nonsticky - = Fcons (Fcons (Qdisplay, Qt), Vtext_property_default_nonsticky); - - Fput (Qundefined_color, Qerror_conditions, pure_cons (Qundefined_color, pure_cons (Qerror, Qnil))); Fput (Qundefined_color, Qerror_message,