Don't globally add to change-major-mode-hook.
[bpt/emacs.git] / src / xterm.c
index b774a00..67335d4 100644 (file)
@@ -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.  */
@@ -3522,6 +3540,7 @@ process_expose_from_menu (event)
        {
          f->async_visible = 1;
          f->async_iconified = 0;
+         f->output_data.x->has_been_visible = 1;
          SET_FRAME_GARBAGED (f);
        }
       else
@@ -3956,6 +3975,7 @@ XTread_socket (sd, bufp, numchars, expected)
                    {
                      f->async_visible = 1;
                      f->async_iconified = 0;
+                     f->output_data.x->has_been_visible = 1;
                      SET_FRAME_GARBAGED (f);
                    }
                  else
@@ -4036,6 +4056,7 @@ XTread_socket (sd, bufp, numchars, expected)
                {
                  f->async_visible = 1;
                  f->async_iconified = 0;
+                 f->output_data.x->has_been_visible = 1;
 
                  /* wait_reading_process_input will notice this and update
                     the frame's display structures.  */
@@ -5676,7 +5697,8 @@ x_make_frame_visible (f)
        that is 3 pixels too low.  Perhaps that's really the border width.  */
 
     if (! FRAME_VISIBLE_P (f)
-       && f->output_data.x->win_gravity == NorthWestGravity)
+       && f->output_data.x->win_gravity == NorthWestGravity
+       && f->output_data.x->has_been_visible)
       {
        BLOCK_INPUT;
 
@@ -6311,8 +6333,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.  */
@@ -6517,17 +6539,19 @@ x_load_font (f, fontname, size)
     /* 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,
-       1:0xA0A0..0xFFFF, 3:0x20A0..0x7FFF, or 2:0xA020..0xFF7F).  For the
-       moment, we don't know which charset uses this font.  So, we set
-       informatoin in fontp->encoding[1] which is never used by any
-       charset.  If mapping can't be decided, set 4.  */
+       the font code-points (0:0x20..0x7F, 1:0xA0..0xFF,
+       0:0x2020..0x7F7F, 1:0xA0A0..0xFFFF, 3:0x20A0..0x7FFF, or
+       2:0xA020..0xFF7F).  For the moment, we don't know which charset
+       uses this font.  So, we set informatoin in fontp->encoding[1]
+       which is never used by any charset.  If mapping can't be
+       decided, set FONT_ENCODING_NOT_DECIDED.  */
     fontp->encoding[1]
       = (font->max_byte1 == 0
         /* 1-byte font */
         ? (font->min_char_or_byte2 < 0x80
            ? (font->max_char_or_byte2 < 0x80
               ? 0              /* 0x20..0x7F */
-              : 4)             /* 0x20..0xFF (can't decide) */
+              : FONT_ENCODING_NOT_DECIDED) /* 0x20..0xFF */
            : 1)                /* 0xA0..0xFF */
         /* 2-byte font */
         : (font->min_byte1 < 0x80
@@ -6535,13 +6559,13 @@ x_load_font (f, fontname, size)
               ? (font->min_char_or_byte2 < 0x80
                  ? (font->max_char_or_byte2 < 0x80
                     ? 0                /* 0x2020..0x7F7F */
-                    : 4)       /* 0x2020..0x7FFF (can't decide) */
+                    : FONT_ENCODING_NOT_DECIDED) /* 0x2020..0x7FFF */
                  : 3)          /* 0x20A0..0x7FFF */
-              : 4)             /* 0x20??..0xA0?? (can't decide) */
+              : FONT_ENCODING_NOT_DECIDED) /* 0x20??..0xA0?? */
            : (font->min_char_or_byte2 < 0x80
               ? (font->max_char_or_byte2 < 0x80
                  ? 2           /* 0xA020..0xFF7F */
-                 : 4)          /* 0xA020..0xFFFF (can't decide) */
+                 : FONT_ENCODING_NOT_DECIDED) /* 0xA020..0xFFFF */
               : 1)));          /* 0xA0A0..0xFFFF */
 
     fontp->baseline_offset