X-Git-Url: https://git.hcoop.net/bpt/emacs.git/blobdiff_plain/845ca893904e4664063cb5c121b34925386849f7..97ad076930d59fa19b8f4bfb95f21df84cc9c8a4:/src/xterm.c diff --git a/src/xterm.c b/src/xterm.c index 9587a47f9b..ac846f23e9 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -520,7 +520,7 @@ x_set_frame_alpha (struct frame *f) if (rc == Success && actual != None) { unsigned long value = *(unsigned long *)data; - XFree ((void *) data); + XFree (data); if (value == opac) { x_uncatch_errors (); @@ -628,7 +628,7 @@ x_draw_vertical_window_border (struct window *w, int x, int y0, int y1) static void x_update_window_end (struct window *w, int cursor_on_p, int mouse_face_overwritten_p) { - Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (XFRAME (w->frame)); + Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (XFRAME (WVAR (w, frame))); if (!w->pseudo_window_p) { @@ -715,7 +715,7 @@ x_after_update_window_line (struct glyph_row *desired_row) struct frame *f; int width, height; - xassert (w); + eassert (w); if (!desired_row->mode_line_p && !w->pseudo_window_p) desired_row->redraw_fringe_bitmaps_p = 1; @@ -728,7 +728,7 @@ x_after_update_window_line (struct glyph_row *desired_row) overhead is very small. */ if (windows_or_buffers_changed && desired_row->full_width_p - && (f = XFRAME (w->frame), + && (f = XFRAME (WVAR (w, frame)), width = FRAME_INTERNAL_BORDER_WIDTH (f), width != 0) && (height = desired_row->visible_height, @@ -931,7 +931,7 @@ static void x_draw_box_rect (struct glyph_string *, int, int, int, int, int, int, int, XRectangle *); static void x_scroll_bar_clear (struct frame *); -#if GLYPH_DEBUG +#ifdef GLYPH_DEBUG static void x_check_font (struct frame *, struct font *); #endif @@ -1033,7 +1033,7 @@ x_set_mouse_face_gc (struct glyph_string *s) s->gc = FRAME_X_DISPLAY_INFO (s->f)->scratch_cursor_gc; } - xassert (s->gc != 0); + eassert (s->gc != 0); } @@ -1090,7 +1090,7 @@ x_set_glyph_string_gc (struct glyph_string *s) } /* GC must have been set. */ - xassert (s->gc != 0); + eassert (s->gc != 0); } @@ -1438,12 +1438,12 @@ x_draw_glyphless_glyph_string_foreground (struct glyph_string *s) #ifdef USE_X_TOOLKIT -static struct frame *x_frame_of_widget (Widget); static Boolean cvt_string_to_pixel (Display *, XrmValue *, Cardinal *, XrmValue *, XrmValue *, XtPointer *); static void cvt_pixel_dtor (XtAppContext, XrmValue *, XtPointer, XrmValue *, Cardinal *); +#ifdef USE_LUCID /* Return the frame on which widget WIDGET is used.. Abort if frame cannot be determined. */ @@ -1478,9 +1478,6 @@ x_frame_of_widget (Widget widget) abort (); } - -#ifdef USE_LUCID - /* Allocate a color which is lighter or darker than *PIXEL by FACTOR or DELTA. Try a color with RGB values multiplied by FACTOR first. If this produces the same color as PIXEL, try a color where all RGB @@ -1496,7 +1493,7 @@ x_alloc_lighter_color_for_widget (Widget widget, Display *display, Colormap cmap return x_alloc_lighter_color (f, display, cmap, pixel, factor, delta); } -#endif +#endif /* USE_LUCID */ /* Structure specifying which arguments should be passed by Xt to @@ -1691,8 +1688,8 @@ x_query_colors (struct frame *f, XColor *colors, int ncolors) for (i = 0; i < ncolors; ++i) { unsigned long pixel = colors[i].pixel; - xassert (pixel < dpyinfo->ncolor_cells); - xassert (dpyinfo->color_cells[pixel].pixel == pixel); + eassert (pixel < dpyinfo->ncolor_cells); + eassert (dpyinfo->color_cells[pixel].pixel == pixel); colors[i] = dpyinfo->color_cells[pixel]; } } @@ -1850,7 +1847,7 @@ x_alloc_lighter_color (struct frame *f, Display *display, Colormap cmap, long un x_query_color (f, &color); /* Change RGB values by specified FACTOR. Avoid overflow! */ - xassert (factor >= 0); + eassert (factor >= 0); new.red = min (0xffff, factor * color.red); new.green = min (0xffff, factor * color.green); new.blue = min (0xffff, factor * color.blue); @@ -2562,7 +2559,7 @@ x_draw_image_glyph_string (struct glyph_string *s) static void x_draw_stretch_glyph_string (struct glyph_string *s) { - xassert (s->first_glyph->type == STRETCH_GLYPH); + eassert (s->first_glyph->type == STRETCH_GLYPH); if (s->hl == DRAW_CURSOR && !x_stretch_cursor_p) @@ -3026,7 +3023,7 @@ x_delete_glyphs (struct frame *f, register int n) void x_clear_area (Display *dpy, Window window, int x, int y, int width, int height, int exposures) { - xassert (width > 0 && height > 0); + eassert (width > 0 && height > 0); XClearArea (dpy, window, x, y, width, height, exposures); } @@ -3168,26 +3165,22 @@ XTflash (struct frame *f) x_flush (f); { - EMACS_TIME wakeup, delay; - - EMACS_GET_TIME (wakeup); - EMACS_SET_SECS_NSECS (delay, 0, 150 * 1000 * 1000); - EMACS_ADD_TIME (wakeup, wakeup, delay); + EMACS_TIME delay = make_emacs_time (0, 150 * 1000 * 1000); + EMACS_TIME wakeup = add_emacs_time (current_emacs_time (), delay); /* Keep waiting until past the time wakeup or any input gets available. */ while (! detect_input_pending ()) { - EMACS_TIME current, timeout; - - EMACS_GET_TIME (current); + EMACS_TIME current = current_emacs_time (); + EMACS_TIME timeout; /* Break if result would not be positive. */ if (EMACS_TIME_LE (wakeup, current)) break; /* How long `select' should wait. */ - EMACS_SET_SECS_NSECS (timeout, 0, 10 * 1000 * 1000); + timeout = make_emacs_time (0, 10 * 1000 * 1000); /* Try to wait that long--but we might wake up sooner. */ pselect (0, NULL, NULL, NULL, &timeout, NULL); @@ -3302,7 +3295,7 @@ x_ins_del_lines (struct frame *f, int vpos, int n) static void x_scroll_run (struct window *w, struct run *run) { - struct frame *f = XFRAME (w->frame); + struct frame *f = XFRAME (WVAR (w, frame)); int x, y, width, height, from_y, to_y, bottom_y; /* Get frame-relative bounding box of the text display area of W, @@ -3717,7 +3710,7 @@ x_find_modifier_meanings (struct x_display_info *dpyinfo) dpyinfo->alt_mod_mask &= ~dpyinfo->meta_mod_mask; } - XFree ((char *) syms); + XFree (syms); XFreeModifiermap (mods); } @@ -4251,9 +4244,9 @@ xt_action_hook (Widget widget, XtPointer client_data, String action_name, scroll_bar_end_scroll, 0, 0); w = XWINDOW (window_being_scrolled); - if (!NILP (XSCROLL_BAR (w->vertical_scroll_bar)->dragging)) + if (!NILP (XSCROLL_BAR (WVAR (w, vertical_scroll_bar))->dragging)) { - XSCROLL_BAR (w->vertical_scroll_bar)->dragging = Qnil; + XSCROLL_BAR (WVAR (w, vertical_scroll_bar))->dragging = Qnil; /* The thumb size is incorrect while dragging: fix it. */ set_vertical_scroll_bar (w); } @@ -4284,7 +4277,7 @@ x_send_scroll_bar_event (Lisp_Object window, int part, int portion, int whole) XEvent event; XClientMessageEvent *ev = (XClientMessageEvent *) &event; struct window *w = XWINDOW (window); - struct frame *f = XFRAME (w->frame); + struct frame *f = XFRAME (WVAR (w, frame)); ptrdiff_t i; BLOCK_INPUT; @@ -4360,7 +4353,7 @@ x_scroll_bar_to_input_event (XEvent *event, struct input_event *ievent) ievent->timestamp = CurrentTime; #else ievent->timestamp = - XtLastTimestampProcessed (FRAME_X_DISPLAY (XFRAME (w->frame))); + XtLastTimestampProcessed (FRAME_X_DISPLAY (XFRAME (WVAR (w, frame)))); #endif ievent->part = ev->data.l[1]; ievent->code = ev->data.l[2]; @@ -4639,7 +4632,7 @@ x_create_toolkit_scroll_bar (struct frame *f, struct scroll_bar *bar) Widget widget; Arg av[20]; int ac = 0; - char const *scroll_bar_name = SCROLL_BAR_NAME; + const char *scroll_bar_name = SCROLL_BAR_NAME; unsigned long pixel; BLOCK_INPUT; @@ -4669,7 +4662,7 @@ x_create_toolkit_scroll_bar (struct frame *f, struct scroll_bar *bar) } widget = XmCreateScrollBar (f->output_data.x->edit_widget, - scroll_bar_name, av, ac); + (char *) scroll_bar_name, av, ac); /* Add one callback for everything that can happen. */ XtAddCallback (widget, XmNdecrementCallback, xm_scroll_callback, @@ -4961,7 +4954,7 @@ x_set_toolkit_scroll_bar_thumb (struct scroll_bar *bar, int portion, int positio static struct scroll_bar * x_scroll_bar_create (struct window *w, int top, int left, int width, int height) { - struct frame *f = XFRAME (w->frame); + struct frame *f = XFRAME (WVAR (w, frame)); struct scroll_bar *bar = ALLOCATE_PSEUDOVECTOR (struct scroll_bar, x_window, PVEC_OTHER); @@ -5187,7 +5180,7 @@ x_scroll_bar_remove (struct scroll_bar *bar) #endif /* Dissociate this scroll bar from its window. */ - XWINDOW (bar->window)->vertical_scroll_bar = Qnil; + WVAR (XWINDOW (bar->window), vertical_scroll_bar) = Qnil; UNBLOCK_INPUT; } @@ -5201,7 +5194,7 @@ x_scroll_bar_remove (struct scroll_bar *bar) static void XTset_vertical_scroll_bar (struct window *w, int portion, int whole, int position) { - struct frame *f = XFRAME (w->frame); + struct frame *f = XFRAME (WVAR (w, frame)); struct scroll_bar *bar; int top, height, left, sb_left, width, sb_width; int window_y, window_height; @@ -5252,7 +5245,7 @@ XTset_vertical_scroll_bar (struct window *w, int portion, int whole, int positio #endif /* Does the scroll bar exist yet? */ - if (NILP (w->vertical_scroll_bar)) + if (NILP (WVAR (w, vertical_scroll_bar))) { if (width > 0 && height > 0) { @@ -5275,7 +5268,7 @@ XTset_vertical_scroll_bar (struct window *w, int portion, int whole, int positio /* It may just need to be moved and resized. */ unsigned int mask = 0; - bar = XSCROLL_BAR (w->vertical_scroll_bar); + bar = XSCROLL_BAR (WVAR (w, vertical_scroll_bar)); BLOCK_INPUT; @@ -5399,7 +5392,7 @@ XTset_vertical_scroll_bar (struct window *w, int portion, int whole, int positio } #endif /* not USE_TOOLKIT_SCROLL_BARS */ - XSETVECTOR (w->vertical_scroll_bar, bar); + XSETVECTOR (WVAR (w, vertical_scroll_bar), bar); } @@ -5443,10 +5436,10 @@ XTredeem_scroll_bar (struct window *window) struct frame *f; /* We can't redeem this window's scroll bar if it doesn't have one. */ - if (NILP (window->vertical_scroll_bar)) + if (NILP (WVAR (window, vertical_scroll_bar))) abort (); - bar = XSCROLL_BAR (window->vertical_scroll_bar); + bar = XSCROLL_BAR (WVAR (window, vertical_scroll_bar)); /* Unlink it from the condemned list. */ f = XFRAME (WINDOW_FRAME (window)); @@ -5454,11 +5447,11 @@ XTredeem_scroll_bar (struct window *window) { /* If the prev pointer is nil, it must be the first in one of the lists. */ - if (EQ (FRAME_SCROLL_BARS (f), window->vertical_scroll_bar)) + if (EQ (FRAME_SCROLL_BARS (f), WVAR (window, vertical_scroll_bar))) /* It's not condemned. Everything's fine. */ return; else if (EQ (FRAME_CONDEMNED_SCROLL_BARS (f), - window->vertical_scroll_bar)) + WVAR (window, vertical_scroll_bar))) FRAME_CONDEMNED_SCROLL_BARS (f) = bar->next; else /* If its prev pointer is nil, it must be at the front of @@ -5617,7 +5610,7 @@ x_scroll_bar_handle_click (struct scroll_bar *bar, XEvent *event, struct input_e static void x_scroll_bar_note_movement (struct scroll_bar *bar, XEvent *event) { - FRAME_PTR f = XFRAME (XWINDOW (bar->window)->frame); + FRAME_PTR f = XFRAME (WVAR (XWINDOW (bar->window), frame)); last_mouse_movement_time = event->xmotion.time; @@ -5777,9 +5770,9 @@ static struct x_display_info *next_noop_dpyinfo; do \ { \ if (f->output_data.x->saved_menu_event == 0) \ - f->output_data.x->saved_menu_event \ - = (XEvent *) xmalloc (sizeof (XEvent)); \ - *f->output_data.x->saved_menu_event = event; \ + f->output_data.x->saved_menu_event = \ + xmalloc (sizeof (XEvent)); \ + *f->output_data.x->saved_menu_event = event; \ inev.ie.kind = MENU_BAR_ACTIVATE_EVENT; \ XSETFRAME (inev.ie.frame_or_window, f); \ } \ @@ -6364,7 +6357,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr, mouse highlighting. */ if (!hlinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight) && (f == 0 - || !EQ (f->tool_bar_window, hlinfo->mouse_face_window))) + || !EQ (FVAR (f, tool_bar_window), hlinfo->mouse_face_window))) { clear_mouse_face (hlinfo); hlinfo->mouse_face_hidden = 1; @@ -6450,7 +6443,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr, if (status_return == XBufferOverflow) { copy_bufsiz = nbytes + 1; - copy_bufptr = (unsigned char *) alloca (copy_bufsiz); + copy_bufptr = alloca (copy_bufsiz); nbytes = XmbLookupString (FRAME_XIC (f), &event.xkey, (char *) copy_bufptr, copy_bufsiz, &keysym, @@ -6791,8 +6784,8 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr, create event iff we don't leave the selected frame. */ && (focus_follows_mouse - || (EQ (XWINDOW (window)->frame, - XWINDOW (selected_window)->frame)))) + || (EQ (WVAR (XWINDOW (window), frame), + WVAR (XWINDOW (selected_window), frame))))) { inev.ie.kind = SELECT_WINDOW_EVENT; inev.ie.frame_or_window = window; @@ -6911,15 +6904,15 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr, if (f) { /* Is this in the tool-bar? */ - if (WINDOWP (f->tool_bar_window) - && WINDOW_TOTAL_LINES (XWINDOW (f->tool_bar_window))) + if (WINDOWP (FVAR (f, tool_bar_window)) + && WINDOW_TOTAL_LINES (XWINDOW (FVAR (f, tool_bar_window)))) { Lisp_Object window; int x = event.xbutton.x; int y = event.xbutton.y; window = window_from_coordinates (f, x, y, 0, 1); - tool_bar_p = EQ (window, f->tool_bar_window); + tool_bar_p = EQ (window, FVAR (f, tool_bar_window)); if (tool_bar_p && event.xbutton.button < 4) { @@ -7341,7 +7334,7 @@ x_draw_hollow_cursor (struct window *w, struct glyph_row *row) static void x_draw_bar_cursor (struct window *w, struct glyph_row *row, int width, enum text_cursor_kinds kind) { - struct frame *f = XFRAME (w->frame); + struct frame *f = XFRAME (WVAR (w, frame)); struct glyph *cursor_glyph; /* If cursor is out of bounds, don't draw garbage. This can happen @@ -7510,7 +7503,7 @@ x_draw_window_cursor (struct window *w, struct glyph_row *glyph_row, int x, int } #ifdef HAVE_X_I18N - if (w == XWINDOW (f->selected_window)) + if (w == XWINDOW (FVAR (f, selected_window))) if (FRAME_XIC (f) && (FRAME_XIC_STYLE (f) & XIMPreeditPosition)) xic_set_preeditarea (w, x, y); #endif @@ -7670,7 +7663,7 @@ x_error_catcher (Display *display, XErrorEvent *event) void x_catch_errors (Display *dpy) { - struct x_error_message_stack *data = xmalloc (sizeof (*data)); + struct x_error_message_stack *data = xmalloc (sizeof *data); /* Make sure any errors from previous requests have been dealt with. */ XSync (dpy, False); @@ -7798,7 +7791,7 @@ x_connection_closed (Display *dpy, const char *error_message) Lisp_Object frame, tail; ptrdiff_t idx = SPECPDL_INDEX (); - error_msg = (char *) alloca (strlen (error_message) + 1); + error_msg = alloca (strlen (error_message) + 1); strcpy (error_msg, error_message); handling_signal = 0; @@ -8161,7 +8154,7 @@ xim_instantiate_callback (Display *display, XPointer client_data, XPointer call_ xic_set_statusarea (f); if (FRAME_XIC_STYLE (f) & XIMPreeditPosition) { - struct window *w = XWINDOW (f->selected_window); + struct window *w = XWINDOW (FVAR (f, selected_window)); xic_set_preeditarea (w, w->cursor.x, w->cursor.y); } } @@ -8187,14 +8180,13 @@ xim_initialize (struct x_display_info *dpyinfo, char *resource_name) if (use_xim) { #ifdef HAVE_X11R6_XIM - struct xim_inst_t *xim_inst; + struct xim_inst_t *xim_inst = xmalloc (sizeof *xim_inst); ptrdiff_t len; - xim_inst = (struct xim_inst_t *) xmalloc (sizeof (struct xim_inst_t)); dpyinfo->xim_callback_data = xim_inst; xim_inst->dpyinfo = dpyinfo; len = strlen (resource_name); - xim_inst->resource_name = (char *) xmalloc (len + 1); + xim_inst->resource_name = xmalloc (len + 1); memcpy (xim_inst->resource_name, resource_name, len + 1); XRegisterIMInstantiateCallback (dpyinfo->display, dpyinfo->xrdb, resource_name, emacs_class, @@ -8811,9 +8803,8 @@ x_wait_for_event (struct frame *f, int eventtype) /* Set timeout to 0.1 second. Hopefully not noticeable. Maybe it should be configurable. */ - EMACS_SET_SECS_USECS (tmo, 0, 100000); - EMACS_GET_TIME (tmo_at); - EMACS_ADD_TIME (tmo_at, tmo_at, tmo); + tmo = make_emacs_time (0, 100 * 1000 * 1000); + tmo_at = add_emacs_time (current_emacs_time (), tmo); while (pending_event_wait.eventtype) { @@ -8826,11 +8817,11 @@ x_wait_for_event (struct frame *f, int eventtype) FD_ZERO (&fds); FD_SET (fd, &fds); - EMACS_GET_TIME (time_now); + time_now = current_emacs_time (); if (EMACS_TIME_LT (tmo_at, time_now)) break; - EMACS_SUB_TIME (tmo, tmo_at, time_now); + tmo = sub_emacs_time (tmo_at, time_now); if (pselect (fd + 1, &fds, NULL, NULL, &tmo, NULL) == 0) break; /* Timeout */ } @@ -8951,7 +8942,7 @@ x_set_window_size (struct frame *f, int change_gravity, int cols, int rows) #endif /* not USE_GTK */ /* If cursor was outside the new size, mark it as off. */ - mark_window_cursors_off (XWINDOW (f->root_window)); + mark_window_cursors_off (XWINDOW (FVAR (f, root_window))); /* Clear out any recollection of where the mouse highlighting was, since it might be in a place that's outside the new frame size. @@ -9801,7 +9792,7 @@ x_wm_set_icon_position (struct frame *f, int icon_x, int icon_y) Fonts ***********************************************************************/ -#if GLYPH_DEBUG +#ifdef GLYPH_DEBUG /* Check that FONT is valid on frame F. It is if it can be found in F's font table. */ @@ -9809,12 +9800,12 @@ x_wm_set_icon_position (struct frame *f, int icon_x, int icon_y) static void x_check_font (struct frame *f, struct font *font) { - xassert (font != NULL && ! NILP (font->props[FONT_TYPE_INDEX])); + eassert (font != NULL && ! NILP (font->props[FONT_TYPE_INDEX])); if (font->driver->check) - xassert (font->driver->check (f, font) == 0); + eassert (font->driver->check (f, font) == 0); } -#endif /* GLYPH_DEBUG != 0 */ +#endif /* GLYPH_DEBUG */ /*********************************************************************** @@ -10036,7 +10027,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) const char *file = "~/.emacs.d/gtkrc"; Lisp_Object s, abs_file; - s = make_string (file, strlen (file)); + s = build_string (file); abs_file = Fexpand_file_name (s, Qnil); if (! NILP (abs_file) && !NILP (Ffile_readable_p (abs_file))) @@ -10098,8 +10089,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) /* We have definitely succeeded. Record the new connection. */ - dpyinfo = (struct x_display_info *) xmalloc (sizeof (struct x_display_info)); - memset (dpyinfo, 0, sizeof *dpyinfo); + dpyinfo = xzalloc (sizeof *dpyinfo); hlinfo = &dpyinfo->mouse_highlight; terminal = x_create_terminal (dpyinfo); @@ -10117,7 +10107,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) terminal->kboard = share->terminal->kboard; else { - terminal->kboard = (KBOARD *) xmalloc (sizeof (KBOARD)); + terminal->kboard = xmalloc (sizeof *terminal->kboard); init_kboard (terminal->kboard); KVAR (terminal->kboard, Vwindow_system) = Qx; @@ -10127,7 +10117,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) terminal->kboard->next_kboard = all_kboards; all_kboards = terminal->kboard; - if (!EQ (XSYMBOL (Qvendor_specific_keysyms)->function, Qunbound)) + if (!EQ (SVAR (XSYMBOL (Qvendor_specific_keysyms), function), Qunbound)) { char *vendor = ServerVendor (dpy); @@ -10171,7 +10161,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) dpyinfo->display = dpy; /* Set the name of the terminal. */ - terminal->name = (char *) xmalloc (SBYTES (display_name) + 1); + terminal->name = xmalloc (SBYTES (display_name) + 1); memcpy (terminal->name, SSDATA (display_name), SBYTES (display_name)); terminal->name[SBYTES (display_name)] = 0; @@ -10182,10 +10172,8 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) lim = min (PTRDIFF_MAX, SIZE_MAX) - sizeof "@"; if (lim - SBYTES (Vinvocation_name) < SBYTES (Vsystem_name)) memory_full (SIZE_MAX); - dpyinfo->x_id_name - = (char *) xmalloc (SBYTES (Vinvocation_name) - + SBYTES (Vsystem_name) - + 2); + dpyinfo->x_id_name = xmalloc (SBYTES (Vinvocation_name) + + SBYTES (Vsystem_name) + 2); strcat (strcat (strcpy (dpyinfo->x_id_name, SSDATA (Vinvocation_name)), "@"), SSDATA (Vsystem_name)); @@ -10373,16 +10361,18 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) const int atom_count = sizeof (atom_refs) / sizeof (atom_refs[0]); /* 1 for _XSETTINGS_SN */ const int total_atom_count = 1 + atom_count; - Atom *atoms_return = xmalloc (sizeof (Atom) * total_atom_count); - char **atom_names = xmalloc (sizeof (char *) * total_atom_count); - char xsettings_atom_name[64]; + Atom *atoms_return = xmalloc (total_atom_count * sizeof *atoms_return); + char **atom_names = xmalloc (total_atom_count * sizeof *atom_names); + static char const xsettings_fmt[] = "_XSETTINGS_S%d"; + char xsettings_atom_name[sizeof xsettings_fmt - 2 + + INT_STRLEN_BOUND (int)]; for (i = 0; i < atom_count; i++) atom_names[i] = (char *) atom_refs[i].name; /* Build _XSETTINGS_SN atom name */ - snprintf (xsettings_atom_name, sizeof (xsettings_atom_name), - "_XSETTINGS_S%d", XScreenNumberOfScreen (dpyinfo->screen)); + sprintf (xsettings_atom_name, xsettings_fmt, + XScreenNumberOfScreen (dpyinfo->screen)); atom_names[i] = xsettings_atom_name; XInternAtoms (dpyinfo->display, atom_names, total_atom_count, @@ -10400,7 +10390,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) dpyinfo->x_dnd_atoms_size = 8; dpyinfo->x_dnd_atoms_length = 0; - dpyinfo->x_dnd_atoms = xmalloc (sizeof (*dpyinfo->x_dnd_atoms) + dpyinfo->x_dnd_atoms = xmalloc (sizeof *dpyinfo->x_dnd_atoms * dpyinfo->x_dnd_atoms_size); dpyinfo->net_supported_atoms = NULL; @@ -10409,13 +10399,10 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) connection = ConnectionNumber (dpyinfo->display); dpyinfo->connection = connection; - - { - dpyinfo->gray - = XCreatePixmapFromBitmapData (dpyinfo->display, dpyinfo->root_window, - gray_bits, gray_width, gray_height, - 1, 0, 1); - } + dpyinfo->gray + = XCreatePixmapFromBitmapData (dpyinfo->display, dpyinfo->root_window, + gray_bits, gray_width, gray_height, + 1, 0, 1); #ifdef HAVE_X_I18N xim_initialize (dpyinfo, resource_name); @@ -10604,9 +10591,7 @@ x_activate_timeout_atimer (void) BLOCK_INPUT; if (!x_timeout_atimer_activated_flag) { - EMACS_TIME interval; - - EMACS_SET_SECS_USECS (interval, 0, 100000); + EMACS_TIME interval = make_emacs_time (0, 100 * 1000 * 1000); start_atimer (ATIMER_RELATIVE, interval, x_process_timeouts, 0); x_timeout_atimer_activated_flag = 1; } @@ -10847,7 +10832,7 @@ syms_of_xterm (void) last_mouse_press_frame = Qnil; #ifdef USE_GTK - xg_default_icon_file = make_pure_c_string ("icons/hicolor/scalable/apps/emacs.svg"); + xg_default_icon_file = build_pure_c_string ("icons/hicolor/scalable/apps/emacs.svg"); staticpro (&xg_default_icon_file); DEFSYM (Qx_gtk_map_stock, "x-gtk-map-stock");