X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/caacfeb891addc51922527d6d83f5e558659fa40..f78f1a83df3ed97fd59ec98143f156af3cfd4491:/src/xfns.c diff --git a/src/xfns.c b/src/xfns.c index c126d6ad36..0bcf458b04 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -1,6 +1,6 @@ /* Functions for the X window system. Copyright (C) 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, - 2001, 2002, 2003, 2004, 2005 Free Software Foundation. + 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -16,11 +16,10 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Emacs; see the file COPYING. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ +the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +Boston, MA 02110-1301, USA. */ #include -#include #include #include @@ -1880,7 +1879,8 @@ hack_wm_protocols (f, widget) BLOCK_INPUT; { - Atom type, *atoms = 0; + Atom type; + unsigned char *catoms; int format = 0; unsigned long nitems = 0; unsigned long bytes_after; @@ -1889,20 +1889,27 @@ hack_wm_protocols (f, widget) FRAME_X_DISPLAY_INFO (f)->Xatom_wm_protocols, (long)0, (long)100, False, XA_ATOM, &type, &format, &nitems, &bytes_after, - (unsigned char **) &atoms) + &catoms) == Success) && format == 32 && type == XA_ATOM) - while (nitems > 0) - { - nitems--; - if (atoms[nitems] == FRAME_X_DISPLAY_INFO (f)->Xatom_wm_delete_window) - need_delete = 0; - else if (atoms[nitems] == FRAME_X_DISPLAY_INFO (f)->Xatom_wm_take_focus) - need_focus = 0; - else if (atoms[nitems] == FRAME_X_DISPLAY_INFO (f)->Xatom_wm_save_yourself) - need_save = 0; - } - if (atoms) XFree ((char *) atoms); + { + Atom *atoms = (Atom *) catoms; + while (nitems > 0) + { + nitems--; + if (atoms[nitems] + == FRAME_X_DISPLAY_INFO (f)->Xatom_wm_delete_window) + need_delete = 0; + else if (atoms[nitems] + == FRAME_X_DISPLAY_INFO (f)->Xatom_wm_take_focus) + need_focus = 0; + else if (atoms[nitems] + == FRAME_X_DISPLAY_INFO (f)->Xatom_wm_save_yourself) + need_save = 0; + } + } + if (catoms) + XFree (catoms); } { Atom props [10]; @@ -1951,6 +1958,114 @@ static XIMStyle supported_xim_styles[] = /* Create an X fontset on frame F with base font name BASE_FONTNAME. */ +char xic_defaut_fontset[] = "-*-*-*-r-normal--14-*-*-*-*-*-*-*"; + +/* Create an Xt fontset spec from the name of a base font. + If `motif' is True use the Motif syntax. */ +char * +xic_create_fontsetname (base_fontname, motif) + char *base_fontname; + Bool motif; +{ + const char *sep = motif ? ";" : ","; + char *fontsetname; + + /* 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; + fontsetname = xmalloc (len); + bzero (fontsetname, len); + strcpy (fontsetname, base_fontname); + } + else + { + /* Make a fontset name from the base font name. + The font set will be made of the following elements: + - the base font. + - the base font where the charset spec is replaced by -*-*. + - the same but with the family also replaced with -*-*-. */ + char *p = base_fontname; + int i; + + for (i = 0; *p; p++) + if (*p == '-') i++; + if (i != 14) + { /* 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; + fontsetname = xmalloc (len); + bzero (fontsetname, len); + strcpy (fontsetname, base_fontname); + strcat (fontsetname, sep); + strcat (fontsetname, xic_defaut_fontset); + } + else + { + int len; + char *p1 = NULL, *p2 = NULL; + char *font_allcs = NULL; + char *font_allfamilies = NULL; + char *font_all = NULL; + char *allcs = "*-*-*-*-*-*-*"; + char *allfamilies = "-*-*-"; + char *all = "*-*-*-*-"; + + for (i = 0, p = base_fontname; i < 8; p++) + { + if (*p == '-') + { + i++; + if (i == 3) + p1 = p + 1; + else if (i == 7) + p2 = p + 1; + } + } + /* Build the font spec that matches all charsets. */ + len = p - base_fontname + strlen (allcs) + 1; + font_allcs = (char *) alloca (len); + bzero (font_allcs, len); + bcopy (base_fontname, font_allcs, p - base_fontname); + strcat (font_allcs, allcs); + + /* Build the font spec that matches all families. */ + len = p - p1 + strlen (allcs) + strlen (allfamilies) + 1; + font_allfamilies = (char *) alloca (len); + bzero (font_allfamilies, len); + strcpy (font_allfamilies, allfamilies); + bcopy (p1, font_allfamilies + strlen (allfamilies), p - p1); + strcat (font_allfamilies, allcs); + + /* Build the font spec that matches all. */ + len = p - p2 + strlen (allcs) + strlen (all) + strlen (allfamilies) + 1; + font_all = (char *) alloca (len); + bzero (font_all, len); + strcpy (font_all, allfamilies); + strcat (font_all, all); + bcopy (p2, font_all + strlen (all) + strlen (allfamilies), p - p2); + strcat (font_all, allcs); + + /* Build the actual font set name. */ + len = strlen (base_fontname) + strlen (font_allcs) + + strlen (font_allfamilies) + strlen (font_all) + 5; + fontsetname = xmalloc (len); + bzero (fontsetname, len); + strcpy (fontsetname, base_fontname); + strcat (fontsetname, sep); + strcat (fontsetname, font_allcs); + strcat (fontsetname, sep); + strcat (fontsetname, font_allfamilies); + strcat (fontsetname, sep); + strcat (fontsetname, font_all); + } + } + if (motif) + strcat (fontsetname, ":"); + return fontsetname; +} + static XFontSet xic_create_xfontset (f, base_fontname) struct frame *f; @@ -1962,6 +2077,9 @@ xic_create_xfontset (f, base_fontname) char *def_string; Lisp_Object rest, frame; + if (!base_fontname) + base_fontname = xic_defaut_fontset; + /* See if there is another frame already using same fontset. */ FOR_EACH_FRAME (rest, frame) { @@ -1978,12 +2096,15 @@ xic_create_xfontset (f, base_fontname) if (!xfs) { + char *fontsetname = xic_create_fontsetname (base_fontname, False); + /* New fontset. */ xfs = XCreateFontSet (FRAME_X_DISPLAY (f), - base_fontname, &missing_list, + fontsetname, &missing_list, &missing_count, &def_string); if (missing_list) XFreeStringList (missing_list); + xfree (fontsetname); } if (FRAME_XIC_BASE_FONTNAME (f)) @@ -2065,6 +2186,11 @@ create_frame_xic (f) if (FRAME_XIC (f)) return; + /* Create X fontset. */ + xfs = xic_create_xfontset + (f, (FRAME_FONTSET (f) < 0) ? NULL + : (char *) SDATA (fontset_ascii (FRAME_FONTSET (f)))); + xim = FRAME_X_XIM (f); if (xim) { @@ -2072,52 +2198,9 @@ create_frame_xic (f) XPoint spot; XVaNestedList preedit_attr; XVaNestedList status_attr; - char *base_fontname; - int fontset; s_area.x = 0; s_area.y = 0; s_area.width = 1; s_area.height = 1; spot.x = 0; spot.y = 1; - /* Create X fontset. */ - fontset = FRAME_FONTSET (f); - if (fontset < 0) - base_fontname = "-*-*-*-r-normal--14-*-*-*-*-*-*-*"; - else - { - /* Determine the base fontname from the ASCII font name of - FONTSET. */ - char *ascii_font = (char *) SDATA (fontset_ascii (fontset)); - char *p = ascii_font; - int i; - - for (i = 0; *p; p++) - if (*p == '-') i++; - if (i != 14) - /* As the font name doesn't conform to XLFD, we can't - modify it to get a suitable base fontname for the - frame. */ - base_fontname = "-*-*-*-r-normal--14-*-*-*-*-*-*-*"; - else - { - int len = strlen (ascii_font) + 1; - char *p1 = NULL; - - for (i = 0, p = ascii_font; i < 8; p++) - { - if (*p == '-') - { - i++; - if (i == 3) - p1 = p + 1; - } - } - base_fontname = (char *) alloca (len); - bzero (base_fontname, len); - strcpy (base_fontname, "-*-*-"); - bcopy (p1, base_fontname + 5, p - p1); - strcat (base_fontname, "*-*-*-*-*-*-*"); - } - } - xfs = xic_create_xfontset (f, base_fontname); /* Determine XIC style. */ if (xic_style == 0) @@ -4156,7 +4239,7 @@ no value of TYPE. */) Atom prop_atom; int rc; Lisp_Object prop_value = Qnil; - char *tmp_data = NULL; + unsigned char *tmp_data = NULL; Atom actual_type; Atom target_type = XA_STRING; int actual_format; @@ -4196,7 +4279,7 @@ no value of TYPE. */) rc = XGetWindowProperty (FRAME_X_DISPLAY (f), target_window, prop_atom, 0, 0, False, target_type, &actual_type, &actual_format, &actual_size, - &bytes_remaining, (unsigned char **) &tmp_data); + &bytes_remaining, &tmp_data); if (rc == Success) { int size = bytes_remaining; @@ -4209,7 +4292,7 @@ no value of TYPE. */) ! NILP (delete_p), target_type, &actual_type, &actual_format, &actual_size, &bytes_remaining, - (unsigned char **) &tmp_data); + &tmp_data); if (rc == Success && tmp_data) { /* The man page for XGetWindowProperty says: @@ -4233,14 +4316,14 @@ no value of TYPE. */) long *ldata = (long *) tmp_data; for (i = 0; i < actual_size; ++i) - idata[i]= (int) ldata[i]; + idata[i] = (int) ldata[i]; } if (NILP (vector_ret_p)) prop_value = make_string (tmp_data, size); else prop_value = x_property_data_to_lisp (f, - (unsigned char *) tmp_data, + tmp_data, actual_type, actual_format, actual_size); @@ -4283,6 +4366,14 @@ static Lisp_Object Vhourglass_delay; static void show_hourglass P_ ((struct atimer *)); static void hide_hourglass P_ ((void)); +/* Return non-zero if houglass timer has been started or hourglass is shown. */ + +int +hourglass_started () +{ + return hourglass_shown_p || hourglass_atimer != NULL; +} + /* Cancel a currently active hourglass timer, and start a new one. */ @@ -4292,6 +4383,10 @@ start_hourglass () EMACS_TIME delay; int secs, usecs = 0; + /* Don't bother for ttys. */ + if (NILP (Vwindow_system)) + return; + cancel_hourglass (); if (INTEGERP (Vhourglass_delay) @@ -4510,9 +4605,6 @@ x_create_tip_frame (dpyinfo, parms, text) check_x (); - /* Use this general default value to start with until we know if - this frame has a specified name. */ - Vx_resource_name = Vinvocation_name; #ifdef MULTI_KBOARD kb = dpyinfo->kboard; @@ -4526,7 +4618,6 @@ x_create_tip_frame (dpyinfo, parms, text) && !EQ (name, Qunbound) && !NILP (name)) error ("Invalid frame name--not a string or nil"); - Vx_resource_name = name; frame = Qnil; GCPRO3 (parms, name, frame); @@ -4995,7 +5086,7 @@ Text larger than the specified size is clipped. */) clear_glyph_matrix (w->desired_matrix); clear_glyph_matrix (w->current_matrix); SET_TEXT_POS (pos, BEGV, BEGV_BYTE); - try_window (FRAME_ROOT_WINDOW (f), pos); + try_window (FRAME_ROOT_WINDOW (f), pos, 0); /* Compute width and height of the tooltip. */ width = height = 0;