]> code.delx.au - gnu-emacs/blobdiff - src/xterm.c
(x_make_frame_visible): Check has_been_visible
[gnu-emacs] / src / xterm.c
index e1b7937bc2c8d4eb2531c27c9522ff71add6229c..6393ae5202e2023e814a1615b37853aa98f98ef1 100644 (file)
@@ -692,7 +692,7 @@ dumpglyphs (f, left, top, gp, n, hl, just_foreground, cmpcharp)
            struct font_info *fontp;
 
            if ((fontset < 0 && (fontset = FRAME_FONTSET (f)) < 0)
-               || !(fontp = fs_load_font (f, FRAME_X_FONT_TABLE (f),
+               || !(fontp = FS_LOAD_FONT (f, FRAME_X_FONT_TABLE (f),
                                           charset, NULL, fontset)))
              goto font_not_found;
 
@@ -703,6 +703,13 @@ dumpglyphs (f, left, top, gp, n, hl, just_foreground, cmpcharp)
              = (font->max_byte1 != 0
                 ? (line_height + font->ascent - font->descent) / 2
                 : f->output_data.x->font_baseline - fontp->baseline_offset);
+           if (FONT_HEIGHT (font) <= line_height
+               && (font->ascent > baseline
+                   || font->descent > line_height - baseline))
+             /* Adjust baseline for this font to show the whole
+                 glyphs in a line.  */
+             baseline = line_height - font->descent;
+             
            if (cmpcharp && cmpcharp->cmp_rule == NULL)
              {
                relative_compose = fontp->relative_compose;
@@ -863,7 +870,7 @@ dumpglyphs (f, left, top, gp, n, hl, just_foreground, cmpcharp)
 
            /* The current code at first set foreground to background,
              fill the area, then recover the original foreground.
-             Aren't there any more smart ways?  */
+             Aren't there any smarter ways?  */
 
            XGetGCValues (FRAME_X_DISPLAY (f), gc, mask, &xgcv);
            XSetForeground (FRAME_X_DISPLAY (f), gc, xgcv.background);
@@ -1028,22 +1035,33 @@ dumpglyphs (f, left, top, gp, n, hl, just_foreground, cmpcharp)
              }
 #endif
          }
-       if (!font || require_clipping && !NILP (Vhighlight_wrong_size_font))
+       if (!font)
          {
-           /* Show rectangles to show that we found no font or a font
-               of inappropriate size.  */
+           /* Show rectangles to indicate that we found no font.  */
+           int limit = cmpcharp ? 1 : len;
 
-           if (cmpcharp)
-             XDrawRectangle
-               (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc,
-                left, top, run_width - 1, line_height - 1);
-           else
-             for (i = 0; i < len; i++)
-               XDrawRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc,
-                               left + glyph_width * i, top,
-                               glyph_width -1, line_height - 1);
+           for (i = 0; i < limit; i++)
+             XDrawRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc,
+                             left + glyph_width * i, top,
+                             glyph_width - 1, line_height - 1);
          }
-       
+       else if (require_clipping && !NILP (Vhighlight_wrong_size_font))
+         {
+           /* Show ??? to indicate that we found a font of
+               inappropriate size.  */
+           int limit = cmpcharp ? 1 : len;
+
+           for (i = 0; i < limit; i++)
+             {
+               XDrawLine (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc,
+                          left + glyph_width * i, top + line_height - 1,
+                          left + glyph_width * i + 1, top + line_height - 1);
+               XDrawLine (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc,
+                          left + glyph_width * i, top + line_height - 3,
+                          left + glyph_width * i, top + line_height - 1);
+             }
+         }
+
        /* We should probably check for XA_UNDERLINE_POSITION and
           XA_UNDERLINE_THICKNESS properties on the font, but let's
           just get the thing working, and come back to that.  */
@@ -5240,6 +5258,11 @@ x_new_fontset (f, fontsetname)
   if (fontset < 0)
     return Qnil;
 
+  if (f->output_data.x->fontset == fontset)
+    /* This fontset is already set in frame F.  There's nothing more
+       to do.  */
+    return build_string (fontsetname);
+
   fontsetp = FRAME_FONTSET_DATA (f)->fontset_table[fontset];
 
   if (!fontsetp->fontname[CHARSET_ASCII])
@@ -5254,7 +5277,7 @@ x_new_fontset (f, fontsetname)
 
   /* Since x_new_font doesn't update any fontset information, do it now.  */
   f->output_data.x->fontset = fontset;
-  fs_load_font (f, FRAME_X_FONT_TABLE (f),
+  FS_LOAD_FONT (f, FRAME_X_FONT_TABLE (f),
                CHARSET_ASCII, XSTRING (result)->data, fontset);
 
   return build_string (fontsetname);
@@ -5664,6 +5687,10 @@ x_make_frame_visible (f)
   {
     Lisp_Object frame;
     int count = input_signal_count;
+    /* This must be before UNBLOCK_INPUT
+       since events that arrive in response to the actions above
+       will set it when they are handled.  */
+    int previously_visible = f->output_data.x->has_been_visible;
 
     original_left = f->output_data.x->left_pos;
     original_top = f->output_data.x->top_pos;
@@ -5676,11 +5703,15 @@ x_make_frame_visible (f)
     /* Now move the window back to where it was "supposed to be".
        But don't do it if the gravity is negative.
        When the gravity is negative, this uses a position
-       that is 3 pixels too low.  Perhaps that's really the border width.  */
+       that is 3 pixels too low.  Perhaps that's really the border width.
+
+       Don't do this if the window has never been visible before,
+       because the window manager may choose the position
+       and we don't want to override it.  */
 
     if (! FRAME_VISIBLE_P (f)
        && f->output_data.x->win_gravity == NorthWestGravity
-       && f->output_data.x->has_been_visible)
+       && previously_visible)
       {
        BLOCK_INPUT;
 
@@ -6247,28 +6278,19 @@ x_list_fonts (f, pattern, size, maxnames)
      int size;
      int maxnames;
 {
-  Lisp_Object list, patterns = Qnil, newlist = Qnil, key, tem, second_best;
+  Lisp_Object list, patterns, newlist = Qnil, key, tem, second_best;
   Display *dpy = f != NULL ? FRAME_X_DISPLAY (f) : x_display_list->display;
 
-  for (list = Valternative_fontname_alist; CONSP (list);
-       list = XCONS (list)->cdr)
-    {
-      tem = XCONS (list)->car;
-      if (CONSP (tem)
-         && STRINGP (XCONS (tem)->car)
-         && !NILP (Fstring_equal (XCONS (tem)->car, pattern)))
-       {
-         patterns = XCONS (tem)->cdr;
-         break;
-       }
-    }
+  patterns = Fassoc (pattern, Valternative_fontname_alist);
+  if (NILP (patterns))
+    patterns = Fcons (pattern, Qnil);
 
-  for (patterns = Fcons (pattern, patterns); CONSP (patterns);
-       patterns = XCONS (patterns)->cdr, pattern = XCONS (patterns)->car)
+  for (; CONSP (patterns); patterns = XCONS (patterns)->cdr)
     {
       int num_fonts;
       char **names;
 
+      pattern = XCONS (patterns)->car;
       /* See if we cached the result for this particular query.  */
       if (f && (tem = XCONS (FRAME_X_DISPLAY_INFO (f)->name_list_element)->cdr,
                key = Fcons (pattern, make_number (maxnames)),
@@ -6315,8 +6337,8 @@ x_list_fonts (f, pattern, size, maxnames)
                  if (NILP (Fassoc (tem, list)))
                    {
                      if (STRINGP (Vx_pixel_size_width_font_regexp)
-                         && (fast_string_match_ignore_case
-                             (Vx_pixel_size_width_font_regexp, names[i])
+                         && ((fast_c_string_match_ignore_case
+                              (Vx_pixel_size_width_font_regexp, names[i]))
                              >= 0))
                        /* We can set the value of PIXEL_SIZE to the
                          width of this font.  */
@@ -6444,6 +6466,11 @@ x_load_font (f, fontname, size)
     struct font_info *fontp;
     unsigned long value;
 
+    /* If we have found fonts by x_list_font, load one of them.  If
+       not, we still try to load a font by the name given as FONTNAME
+       because XListFonts (called in x_list_font) of some X server has
+       a bug of not finding a font even if the font surely exists and
+       is loadable by XLoadQueryFont.  */
     if (!NILP (font_names))
       fontname = (char *) XSTRING (XCONS (font_names)->car)->data;
 
@@ -6518,6 +6545,29 @@ x_load_font (f, fontname, size)
     fontp->size = font->max_bounds.width;
     fontp->height = font->ascent + font->descent;
 
+    if (NILP (font_names))
+      {
+       /* We come here because of a bug of XListFonts mentioned at
+          the head of this block.  Let's store this information in
+          the cache for x_list_fonts.  */
+       Lisp_Object lispy_name = build_string (fontname);
+       Lisp_Object lispy_full_name = build_string (fontp->full_name);
+
+       XCONS (dpyinfo->name_list_element)->cdr
+         = Fcons (Fcons (Fcons (lispy_name, make_number (256)),
+                         Fcons (Fcons (lispy_full_name,
+                                       make_number (fontp->size)),
+                                Qnil)),
+                  XCONS (dpyinfo->name_list_element)->cdr);
+       if (full_name)
+         XCONS (dpyinfo->name_list_element)->cdr
+           = Fcons (Fcons (Fcons (lispy_full_name, make_number (256)),
+                           Fcons (Fcons (lispy_full_name,
+                                         make_number (fontp->size)),
+                                  Qnil)),
+                    XCONS (dpyinfo->name_list_element)->cdr);
+      }
+
     /* The slot `encoding' specifies how to map a character
        code-points (0x20..0x7F or 0x2020..0x7F7F) of each charset to
        the font code-points (0:0x20..0x7F, 1:0xA0..0xFF, 0:0x2020..0x7F7F,