diff options
Diffstat (limited to 'src/xterm.c')
-rw-r--r-- | src/xterm.c | 194 |
1 files changed, 100 insertions, 94 deletions
diff --git a/src/xterm.c b/src/xterm.c index 3cadf693804..e9cebcebba4 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -549,10 +549,8 @@ x_cr_accumulate_data (void *closure, const unsigned char *data, } static void -x_cr_destroy (Lisp_Object arg) +x_cr_destroy (void *cr) { - cairo_t *cr = (cairo_t *) XSAVE_POINTER (arg, 0); - block_input (); cairo_destroy (cr); unblock_input (); @@ -611,7 +609,7 @@ x_cr_export_frames (Lisp_Object frames, cairo_surface_type_t surface_type) cr = cairo_create (surface); cairo_surface_destroy (surface); - record_unwind_protect (x_cr_destroy, make_save_ptr (cr)); + record_unwind_protect_ptr (x_cr_destroy, cr); while (1) { @@ -924,8 +922,8 @@ x_set_frame_alpha (struct frame *f) if (FLOATP (Vframe_alpha_lower_limit)) alpha_min = XFLOAT_DATA (Vframe_alpha_lower_limit); - else if (INTEGERP (Vframe_alpha_lower_limit)) - alpha_min = (XINT (Vframe_alpha_lower_limit)) / 100.0; + else if (FIXNUMP (Vframe_alpha_lower_limit)) + alpha_min = (XFIXNUM (Vframe_alpha_lower_limit)) / 100.0; if (alpha < 0.0) return; @@ -996,12 +994,7 @@ static void x_update_begin (struct frame *f) { #ifdef USE_CAIRO - if (! NILP (tip_frame) && XFRAME (tip_frame) == f - && ! FRAME_VISIBLE_P (f) -#ifdef USE_GTK - && !NILP (Fframe_parameter (tip_frame, Qtooltip)) -#endif - ) + if (FRAME_TOOLTIP_P (f) && !FRAME_VISIBLE_P (f)) return; if (! FRAME_CR_SURFACE (f)) @@ -1984,7 +1977,13 @@ x_draw_glyphless_glyph_string_foreground (struct glyph_string *s) for (i = 0; i < s->nchars; i++, glyph++) { - char buf[7], *str = NULL; +#ifdef GCC_LINT + enum { PACIFY_GCC_BUG_81401 = 1 }; +#else + enum { PACIFY_GCC_BUG_81401 = 0 }; +#endif + char buf[7 + PACIFY_GCC_BUG_81401]; + char *str = NULL; int len = glyph->u.glyphless.len; if (glyph->u.glyphless.method == GLYPHLESS_DISPLAY_ACRONYM) @@ -3113,14 +3112,14 @@ x_draw_image_relief (struct glyph_string *s) if (s->face->id == TOOL_BAR_FACE_ID) { if (CONSP (Vtool_bar_button_margin) - && INTEGERP (XCAR (Vtool_bar_button_margin)) - && INTEGERP (XCDR (Vtool_bar_button_margin))) + && FIXNUMP (XCAR (Vtool_bar_button_margin)) + && FIXNUMP (XCDR (Vtool_bar_button_margin))) { - extra_x = XINT (XCAR (Vtool_bar_button_margin)); - extra_y = XINT (XCDR (Vtool_bar_button_margin)); + extra_x = XFIXNUM (XCAR (Vtool_bar_button_margin)); + extra_y = XFIXNUM (XCDR (Vtool_bar_button_margin)); } - else if (INTEGERP (Vtool_bar_button_margin)) - extra_x = extra_y = XINT (Vtool_bar_button_margin); + else if (FIXNUMP (Vtool_bar_button_margin)) + extra_x = extra_y = XFIXNUM (Vtool_bar_button_margin); } top_p = bot_p = left_p = right_p = false; @@ -3705,33 +3704,53 @@ x_draw_glyph_string (struct glyph_string *s) else { struct font *font = font_for_underline_metrics (s); + unsigned long minimum_offset; + bool underline_at_descent_line; + bool use_underline_position_properties; + Lisp_Object val + = buffer_local_value (Qunderline_minimum_offset, + s->w->contents); + if (FIXNUMP (val)) + minimum_offset = XFIXNAT (val); + else + minimum_offset = 1; + val = buffer_local_value (Qx_underline_at_descent_line, + s->w->contents); + underline_at_descent_line + = !(NILP (val) || EQ (val, Qunbound)); + val + = buffer_local_value (Qx_use_underline_position_properties, + s->w->contents); + use_underline_position_properties + = !(NILP (val) || EQ (val, Qunbound)); /* Get the underline thickness. Default is 1 pixel. */ if (font && font->underline_thickness > 0) thickness = font->underline_thickness; else thickness = 1; - if (x_underline_at_descent_line) + if (underline_at_descent_line) position = (s->height - thickness) - (s->ybase - s->y); else { - /* Get the underline position. This is the recommended - vertical offset in pixels from the baseline to the top of - the underline. This is a signed value according to the + /* Get the underline position. This is the + recommended vertical offset in pixels from + the baseline to the top of the underline. + This is a signed value according to the specs, and its default is ROUND ((maximum descent) / 2), with ROUND(x) = floor (x + 0.5) */ - if (x_use_underline_position_properties + if (use_underline_position_properties && font && font->underline_position >= 0) position = font->underline_position; else if (font) position = (font->descent + 1) / 2; else - position = underline_minimum_offset; + position = minimum_offset; } - position = max (position, underline_minimum_offset); + position = max (position, minimum_offset); } /* Check the sanity of thickness and position. We should avoid drawing underline out of the current line area. */ @@ -4372,16 +4391,6 @@ x_focus_changed (int type, int state, struct x_display_info *dpyinfo, struct fra { x_new_focus_frame (dpyinfo, frame); dpyinfo->x_focus_event_frame = frame; - - /* Don't stop displaying the initial startup message - for a switch-frame event we don't need. */ - /* When run as a daemon, Vterminal_frame is always NIL. */ - bufp->arg = (((NILP (Vterminal_frame) - || ! FRAME_X_P (XFRAME (Vterminal_frame)) - || EQ (Fdaemonp (), Qt)) - && CONSP (Vframe_list) - && !NILP (XCDR (Vframe_list))) - ? Qt : Qnil); bufp->kind = FOCUS_IN_EVENT; XSETFRAME (bufp->frame_or_window, frame); } @@ -4821,15 +4830,15 @@ x_x_to_emacs_modifiers (struct x_display_info *dpyinfo, int state) Lisp_Object tem; tem = Fget (Vx_ctrl_keysym, Qmodifier_value); - if (INTEGERP (tem)) mod_ctrl = XINT (tem) & INT_MAX; + if (FIXNUMP (tem)) mod_ctrl = XFIXNUM (tem) & INT_MAX; tem = Fget (Vx_alt_keysym, Qmodifier_value); - if (INTEGERP (tem)) mod_alt = XINT (tem) & INT_MAX; + if (FIXNUMP (tem)) mod_alt = XFIXNUM (tem) & INT_MAX; tem = Fget (Vx_meta_keysym, Qmodifier_value); - if (INTEGERP (tem)) mod_meta = XINT (tem) & INT_MAX; + if (FIXNUMP (tem)) mod_meta = XFIXNUM (tem) & INT_MAX; tem = Fget (Vx_hyper_keysym, Qmodifier_value); - if (INTEGERP (tem)) mod_hyper = XINT (tem) & INT_MAX; + if (FIXNUMP (tem)) mod_hyper = XFIXNUM (tem) & INT_MAX; tem = Fget (Vx_super_keysym, Qmodifier_value); - if (INTEGERP (tem)) mod_super = XINT (tem) & INT_MAX; + if (FIXNUMP (tem)) mod_super = XFIXNUM (tem) & INT_MAX; return ( ((state & (ShiftMask | dpyinfo->shift_lock_mask)) ? shift_modifier : 0) | ((state & ControlMask) ? mod_ctrl : 0) @@ -4851,15 +4860,15 @@ x_emacs_to_x_modifiers (struct x_display_info *dpyinfo, EMACS_INT state) Lisp_Object tem; tem = Fget (Vx_ctrl_keysym, Qmodifier_value); - if (INTEGERP (tem)) mod_ctrl = XINT (tem); + if (FIXNUMP (tem)) mod_ctrl = XFIXNUM (tem); tem = Fget (Vx_alt_keysym, Qmodifier_value); - if (INTEGERP (tem)) mod_alt = XINT (tem); + if (FIXNUMP (tem)) mod_alt = XFIXNUM (tem); tem = Fget (Vx_meta_keysym, Qmodifier_value); - if (INTEGERP (tem)) mod_meta = XINT (tem); + if (FIXNUMP (tem)) mod_meta = XFIXNUM (tem); tem = Fget (Vx_hyper_keysym, Qmodifier_value); - if (INTEGERP (tem)) mod_hyper = XINT (tem); + if (FIXNUMP (tem)) mod_hyper = XFIXNUM (tem); tem = Fget (Vx_super_keysym, Qmodifier_value); - if (INTEGERP (tem)) mod_super = XINT (tem); + if (FIXNUMP (tem)) mod_super = XFIXNUM (tem); return ( ((state & mod_alt) ? dpyinfo->alt_mod_mask : 0) @@ -5508,8 +5517,8 @@ x_scroll_bar_to_input_event (const XEvent *event, #endif ievent->code = 0; ievent->part = ev->data.l[2]; - ievent->x = make_number (ev->data.l[3]); - ievent->y = make_number (ev->data.l[4]); + ievent->x = make_fixnum (ev->data.l[3]); + ievent->y = make_fixnum (ev->data.l[4]); ievent->modifiers = 0; } @@ -5543,8 +5552,8 @@ x_horizontal_scroll_bar_to_input_event (const XEvent *event, #endif ievent->code = 0; ievent->part = ev->data.l[2]; - ievent->x = make_number (ev->data.l[3]); - ievent->y = make_number (ev->data.l[4]); + ievent->x = make_fixnum (ev->data.l[3]); + ievent->y = make_fixnum (ev->data.l[4]); ievent->modifiers = 0; } @@ -8106,7 +8115,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, /* Redo the mouse-highlight after the tooltip has gone. */ if (event->xunmap.window == tip_window) { - tip_window = 0; + tip_window = None; x_redo_mouse_highlight (dpyinfo); } @@ -8198,7 +8207,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, /* If mouse-highlight is an integer, input clears out mouse highlighting. */ - if (!hlinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight) + if (!hlinfo->mouse_face_hidden && FIXNUMP (Vmouse_highlight) #if ! defined (USE_GTK) && (f == 0 || !EQ (f->tool_bar_window, hlinfo->mouse_face_window)) @@ -8355,15 +8364,15 @@ handle_one_xevent (struct x_display_info *dpyinfo, /* Now non-ASCII. */ if (HASH_TABLE_P (Vx_keysym_table) - && (c = Fgethash (make_number (keysym), + && (c = Fgethash (make_fixnum (keysym), Vx_keysym_table, Qnil), - NATNUMP (c))) + FIXNATP (c))) { - inev.ie.kind = (SINGLE_BYTE_CHAR_P (XFASTINT (c)) + inev.ie.kind = (SINGLE_BYTE_CHAR_P (XFIXNAT (c)) ? ASCII_KEYSTROKE_EVENT : MULTIBYTE_CHAR_KEYSTROKE_EVENT); - inev.ie.code = XFASTINT (c); + inev.ie.code = XFIXNAT (c); goto done_keysym; } @@ -8748,7 +8757,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, #ifdef USE_X_TOOLKIT /* Tip frames are pure X window, set size for them. */ - if (! NILP (tip_frame) && XFRAME (tip_frame) == f) + if (FRAME_TOOLTIP_P (f)) { if (FRAME_PIXEL_HEIGHT (f) != configureEvent.xconfigure.height || FRAME_PIXEL_WIDTH (f) != configureEvent.xconfigure.width) @@ -9819,7 +9828,7 @@ x_connection_closed (Display *dpy, const char *error_message, bool ioerror) current Xt versions, this isn't needed either. */ #ifdef USE_GTK /* A long-standing GTK bug prevents proper disconnect handling - (https://gitlab.gnome.org/GNOME/gtk/issues/221). Once, + <https://gitlab.gnome.org/GNOME/gtk/issues/221>. Once, the resulting Glib error message loop filled a user's disk. To avoid this, kill Emacs unconditionally on disconnect. */ shut_down_emacs (0, Qnil); @@ -9850,7 +9859,7 @@ For details, see etc/PROBLEMS.\n", if (terminal_list == 0) { fprintf (stderr, "%s\n", error_msg); - Fkill_emacs (make_number (70)); + Fkill_emacs (make_fixnum (70)); /* NOTREACHED */ } @@ -9932,7 +9941,6 @@ x_io_error_quitter (Display *display) snprintf (buf, sizeof buf, "Connection lost to X server '%s'", DisplayString (display)); x_connection_closed (display, buf, true); - assume (false); } /* Changing the font of the frame. */ @@ -9986,11 +9994,7 @@ x_new_font (struct frame *f, Lisp_Object font_object, int fontset) /* Don't change the size of a tip frame; there's no point in doing it because it's done in Fx_show_tip, and it leads to problems because the tip frame has no widget. */ - if (NILP (tip_frame) || XFRAME (tip_frame) != f -#ifdef USE_GTK - || NILP (Fframe_parameter (tip_frame, Qtooltip)) -#endif - ) + if (!FRAME_TOOLTIP_P (f)) { adjust_frame_size (f, FRAME_COLS (f) * FRAME_COLUMN_WIDTH (f), FRAME_LINES (f) * FRAME_LINE_HEIGHT (f), 3, @@ -10255,8 +10259,8 @@ x_calc_absolute_position (struct frame *f) XSETFRAME (frame, f); edges = Fx_frame_edges (frame, Qouter_edges); if (!NILP (edges)) - width = (XINT (Fnth (make_number (2), edges)) - - XINT (Fnth (make_number (0), edges))); + width = (XFIXNUM (Fnth (make_fixnum (2), edges)) + - XFIXNUM (Fnth (make_fixnum (0), edges))); } if (p) @@ -10297,8 +10301,8 @@ x_calc_absolute_position (struct frame *f) if (NILP (edges)) edges = Fx_frame_edges (frame, Qouter_edges); if (!NILP (edges)) - height = (XINT (Fnth (make_number (3), edges)) - - XINT (Fnth (make_number (1), edges))); + height = (XFIXNUM (Fnth (make_fixnum (3), edges)) + - XFIXNUM (Fnth (make_fixnum (1), edges))); } if (p) @@ -10502,16 +10506,16 @@ set_wm_state (Lisp_Object frame, bool add, Atom atom, Atom value) { struct x_display_info *dpyinfo = FRAME_DISPLAY_INFO (XFRAME (frame)); - x_send_client_event (frame, make_number (0), frame, + x_send_client_event (frame, make_fixnum (0), frame, dpyinfo->Xatom_net_wm_state, - make_number (32), + make_fixnum (32), /* 1 = add, 0 = remove */ Fcons - (make_number (add), + (make_fixnum (add), Fcons - (make_fixnum_or_float (atom), + (INT_TO_INTEGER (atom), (value != 0 - ? list1 (make_fixnum_or_float (value)) + ? list1 (INT_TO_INTEGER (value)) : Qnil)))); } @@ -10639,14 +10643,14 @@ get_current_wm_state (struct frame *f, #ifdef USE_XCB xcb_get_property_cookie_t prop_cookie; xcb_get_property_reply_t *prop; - xcb_atom_t *reply_data; + xcb_atom_t *reply_data UNINIT; #else Display *dpy = FRAME_X_DISPLAY (f); unsigned long bytes_remaining; int rc, actual_format; Atom actual_type; unsigned char *tmp_data = NULL; - Atom *reply_data; + Atom *reply_data UNINIT; #endif *sticky = false; @@ -11140,8 +11144,8 @@ x_set_window_size_1 (struct frame *f, bool change_gravity, { frame_size_history_add (f, Qx_set_window_size_1, width, height, - list2 (make_number (old_height), - make_number (pixelheight + FRAME_MENUBAR_HEIGHT (f)))); + list2 (make_fixnum (old_height), + make_fixnum (pixelheight + FRAME_MENUBAR_HEIGHT (f)))); XResizeWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), old_width, pixelheight + FRAME_MENUBAR_HEIGHT (f)); @@ -11150,7 +11154,7 @@ x_set_window_size_1 (struct frame *f, bool change_gravity, { frame_size_history_add (f, Qx_set_window_size_2, width, height, - list2 (make_number (old_width), make_number (pixelwidth))); + list2 (make_fixnum (old_width), make_fixnum (pixelwidth))); XResizeWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), pixelwidth, old_height); @@ -11160,10 +11164,10 @@ x_set_window_size_1 (struct frame *f, bool change_gravity, { frame_size_history_add (f, Qx_set_window_size_3, width, height, - list3 (make_number (pixelwidth + FRAME_TOOLBAR_WIDTH (f)), - make_number (pixelheight + FRAME_TOOLBAR_HEIGHT (f) + list3 (make_fixnum (pixelwidth + FRAME_TOOLBAR_WIDTH (f)), + make_fixnum (pixelheight + FRAME_TOOLBAR_HEIGHT (f) + FRAME_MENUBAR_HEIGHT (f)), - make_number (FRAME_MENUBAR_HEIGHT (f)))); + make_fixnum (FRAME_MENUBAR_HEIGHT (f)))); XResizeWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), pixelwidth, pixelheight + FRAME_MENUBAR_HEIGHT (f)); @@ -11228,7 +11232,7 @@ x_set_window_size (struct frame *f, bool change_gravity, /* The following breaks our calculations. If it's really needed, think of something else. */ #if false - if (NILP (tip_frame) || XFRAME (tip_frame) != f) + if (!FRAME_TOOLTIP_P (f)) { int text_width, text_height; @@ -11347,9 +11351,9 @@ x_ewmh_activate_frame (struct frame *f) { Lisp_Object frame; XSETFRAME (frame, f); - x_send_client_event (frame, make_number (0), frame, + x_send_client_event (frame, make_fixnum (0), frame, dpyinfo->Xatom_net_active_window, - make_number (32), + make_fixnum (32), list2i (1, dpyinfo->last_user_time)); } } @@ -13275,11 +13279,12 @@ syms_of_xterm (void) x_use_underline_position_properties, doc: /* Non-nil means make use of UNDERLINE_POSITION font properties. A value of nil means ignore them. If you encounter fonts with bogus -UNDERLINE_POSITION font properties, for example 7x13 on XFree prior -to 4.1, set this to nil. You can also use `underline-minimum-offset' -to override the font's UNDERLINE_POSITION for small font display -sizes. */); +UNDERLINE_POSITION font properties, set this to nil. You can also use +`underline-minimum-offset' to override the font's UNDERLINE_POSITION for +small font display sizes. */); x_use_underline_position_properties = true; + DEFSYM (Qx_use_underline_position_properties, + "x-use-underline-position-properties"); DEFVAR_BOOL ("x-underline-at-descent-line", x_underline_at_descent_line, @@ -13290,6 +13295,7 @@ A value of nil means to draw the underline according to the value of the variable `x-use-underline-position-properties', which is usually at the baseline level. The default value is nil. */); x_underline_at_descent_line = false; + DEFSYM (Qx_underline_at_descent_line, "x-underline-at-descent-line"); DEFVAR_BOOL ("x-mouse-click-focus-ignore-position", x_mouse_click_focus_ignore_position, @@ -13323,15 +13329,15 @@ With MS Windows or Nextstep, the value is t. */); DEFSYM (Qmodifier_value, "modifier-value"); DEFSYM (Qctrl, "ctrl"); - Fput (Qctrl, Qmodifier_value, make_number (ctrl_modifier)); + Fput (Qctrl, Qmodifier_value, make_fixnum (ctrl_modifier)); DEFSYM (Qalt, "alt"); - Fput (Qalt, Qmodifier_value, make_number (alt_modifier)); + Fput (Qalt, Qmodifier_value, make_fixnum (alt_modifier)); DEFSYM (Qhyper, "hyper"); - Fput (Qhyper, Qmodifier_value, make_number (hyper_modifier)); + Fput (Qhyper, Qmodifier_value, make_fixnum (hyper_modifier)); DEFSYM (Qmeta, "meta"); - Fput (Qmeta, Qmodifier_value, make_number (meta_modifier)); + Fput (Qmeta, Qmodifier_value, make_fixnum (meta_modifier)); DEFSYM (Qsuper, "super"); - Fput (Qsuper, Qmodifier_value, make_number (super_modifier)); + Fput (Qsuper, Qmodifier_value, make_fixnum (super_modifier)); DEFVAR_LISP ("x-ctrl-keysym", Vx_ctrl_keysym, doc: /* Which keys Emacs uses for the ctrl modifier. |