X-Git-Url: http://git.hcoop.net/bpt/emacs.git/blobdiff_plain/fd60bf6c902b47daadda6ebf442045dbe1328941..2bfa3d3e1fb347ba76bddf77f3e288049635821d:/src/xterm.c diff --git a/src/xterm.c b/src/xterm.c index 8c2b6254e5..b64ca2d4d0 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -37,6 +37,11 @@ along with GNU Emacs. If not, see . */ #include #endif +/* Using Xft implies that XRender is available. */ +#ifdef HAVE_XFT +#include +#endif + /* Load sys/types.h if not already loaded. In some systems loading it twice is suicidal. */ #ifndef makedev @@ -221,7 +226,6 @@ static void x_lower_frame (struct frame *); static const XColor *x_color_cells (Display *, int *); static int x_io_error_quitter (Display *); static struct terminal *x_create_terminal (struct x_display_info *); -void x_delete_terminal (struct terminal *); static void x_update_end (struct frame *); static void XTframe_up_to_date (struct frame *); static void x_clear_frame (struct frame *); @@ -354,8 +358,10 @@ x_find_topmost_parent (struct frame *f) unsigned int nchildren; win = wi; - XQueryTree (dpy, win, &root, &wi, &children, &nchildren); - XFree (children); + if (XQueryTree (dpy, win, &root, &wi, &children, &nchildren)) + XFree (children); + else + break; } return win; @@ -903,7 +909,7 @@ x_set_mouse_face_gc (struct glyph_string *s) else face_id = FACE_FOR_CHAR (s->f, face, 0, -1, Qnil); s->face = FACE_FROM_ID (s->f, face_id); - PREPARE_FACE_FOR_DISPLAY (s->f, s->face); + prepare_face_for_display (s->f, s->face); if (s->font == s->face->font) s->gc = s->face->gc; @@ -951,7 +957,7 @@ x_set_mode_line_face_gc (struct glyph_string *s) static void x_set_glyph_string_gc (struct glyph_string *s) { - PREPARE_FACE_FOR_DISPLAY (s->f, s->face); + prepare_face_for_display (s->f, s->face); if (s->hl == DRAW_NORMAL_TEXT) { @@ -6454,7 +6460,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, for (i = 0, nchars = 0; i < nbytes; i++) { - if (ASCII_BYTE_P (copy_bufptr[i])) + if (ASCII_CHAR_P (copy_bufptr[i])) nchars++; STORE_KEYSYM_FOR_DEBUG (copy_bufptr[i]); } @@ -6809,9 +6815,10 @@ handle_one_xevent (struct x_display_info *dpyinfo, { dpyinfo->grabbed |= (1 << event->xbutton.button); dpyinfo->last_mouse_frame = f; - - if (!tool_bar_p) - last_tool_bar_item = -1; +#if ! defined (USE_GTK) + if (f && !tool_bar_p) + f->last_tool_bar_item = -1; +#endif /* not USE_GTK */ } else dpyinfo->grabbed &= ~(1 << event->xbutton.button); @@ -7577,7 +7584,7 @@ x_connection_closed (Display *dpy, const char *error_message) { struct x_display_info *dpyinfo = x_display_info_for_display (dpy); Lisp_Object frame, tail; - ptrdiff_t idx = SPECPDL_INDEX (); + dynwind_begin (); error_msg = alloca (strlen (error_message) + 1); strcpy (error_msg, error_message); @@ -7666,7 +7673,7 @@ For details, see etc/PROBLEMS.\n", totally_unblock_input (); - unbind_to (idx, Qnil); + dynwind_end (); clear_waiting_for_input (); /* Tell GCC not to suggest attribute 'noreturn' for this function. */ @@ -7853,11 +7860,6 @@ xim_destroy_callback (XIM xim, XPointer client_data, XPointer call_data) #endif /* HAVE_X11R6 */ -#ifdef HAVE_X11R6 -/* This isn't prototyped in OSF 5.0 or 5.1a. */ -extern char *XSetIMValues (XIM, ...); -#endif - /* Open the connection to the XIM server on display DPYINFO. RESOURCE_NAME is the resource name Emacs uses. */ @@ -9773,7 +9775,7 @@ x_toggle_visible_pointer (struct frame *f, bool invisible) else XDefineCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), f->output_data.x->current_cursor); - f->pointer_invisible = invisible; + f->pointer_invisible = invisible; } /* Setup pointer blanking, prefer Xfixes if available. */ @@ -10014,8 +10016,8 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) if (lim - SBYTES (Vinvocation_name) < SBYTES (Vsystem_name)) memory_full (SIZE_MAX); dpyinfo->x_id = ++x_display_id; - dpyinfo->x_id_name = xmalloc (SBYTES (Vinvocation_name) - + SBYTES (Vsystem_name) + 2); + dpyinfo->x_id_name = xmalloc_atomic (SBYTES (Vinvocation_name) + + SBYTES (Vsystem_name) + 2); strcat (strcat (strcpy (dpyinfo->x_id_name, SSDATA (Vinvocation_name)), "@"), SSDATA (Vsystem_name)); @@ -10085,14 +10087,27 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) #ifdef HAVE_XFT { - /* If we are using Xft, check dpi value in X resources. - It is better we use it as well, since Xft will use it, as will all - Gnome applications. If our real DPI is smaller or larger than the - one Xft uses, our font will look smaller or larger than other - for other applications, even if it is the same font name (monospace-10 - for example). */ - char *v = XGetDefault (dpyinfo->display, "Xft", "dpi"); + /* If we are using Xft, the following precautions should be made: + + 1. Make sure that the Xrender extension is added before the Xft one. + Otherwise, the close-display hook set by Xft is called after the one + for Xrender, and the former tries to re-add the latter. This results + in inconsistency of internal states and leads to X protocol error when + one reconnects to the same X server (Bug#1696). + + 2. Check dpi value in X resources. It is better we use it as well, + since Xft will use it, as will all Gnome applications. If our real DPI + is smaller or larger than the one Xft uses, our font will look smaller + or larger than other for other applications, even if it is the same + font name (monospace-10 for example). */ + + int event_base, error_base; + char *v; double d; + + XRenderQueryExtension (dpyinfo->display, &event_base, &error_base); + + v = XGetDefault (dpyinfo->display, "Xft", "dpi"); if (v != NULL && sscanf (v, "%lf", &d) == 1) dpyinfo->resy = dpyinfo->resx = d; } @@ -10221,7 +10236,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) 1, 0, 1); x_setup_pointer_blanking (dpyinfo); - + #ifdef HAVE_X_I18N xim_initialize (dpyinfo, resource_name); #endif @@ -10537,7 +10552,7 @@ x_create_terminal (struct x_display_info *dpyinfo) terminal->menu_show_hook = x_menu_show; #if defined (USE_X_TOOLKIT) || defined (USE_GTK) terminal->popup_dialog_hook = xw_popup_dialog; -#endif +#endif terminal->set_vertical_scroll_bar_hook = XTset_vertical_scroll_bar; terminal->condemn_scroll_bars_hook = XTcondemn_scroll_bars; terminal->redeem_scroll_bar_hook = XTredeem_scroll_bar; @@ -10549,13 +10564,12 @@ x_create_terminal (struct x_display_info *dpyinfo) return terminal; } -void +static void x_initialize (void) { baud_rate = 19200; x_noop_count = 0; - last_tool_bar_item = -1; any_help_event_p = 0; ignore_next_mouse_click_timeout = 0;