* calendar/calendar.el (calendar-cursor-to-date): Add argument `event'.
[bpt/emacs.git] / src / xterm.c
index d1aef14..d2222b4 100644 (file)
@@ -469,8 +469,8 @@ x_set_frame_alpha (f)
   Window win = FRAME_OUTER_WINDOW (f);
   double alpha = 1.0;
   double alpha_min = 1.0;
-  unsigned int opac;
-  
+  unsigned long opac;
+
   if (FRAME_X_DISPLAY_INFO (f)->root_window != FRAME_X_OUTPUT (f)->parent_desc)
     /* Since the WM decoration lies under the FRAME_OUTER_WINDOW,
        we must treat the former instead of the latter. */
@@ -491,7 +491,7 @@ x_set_frame_alpha (f)
   else if (0.0 <= alpha && alpha < alpha_min && alpha_min <= 1.0)
     alpha = alpha_min;
 
-  opac = (unsigned int)(alpha * OPAQUE);
+  opac = alpha * OPAQUE;
 
   /* return unless necessary */
   {
@@ -502,9 +502,9 @@ x_set_frame_alpha (f)
 
     XGetWindowProperty(dpy, win, XInternAtom(dpy, OPACITY, False),
                       0L, 1L, False, XA_CARDINAL, &actual, &format, &n, &left,
-                      (unsigned char **) &data);
-    if (data != None)
-      if (*(unsigned int *)data == opac)
+                      &data);
+    if (actual != None)
+      if (*(unsigned long *)data == opac)
        {
          XFree ((void *) data);
          return;
@@ -2664,8 +2664,10 @@ x_draw_glyph_string (s)
       x_set_glyph_string_clipping (s);
       relief_drawn_p = 1;
     }
-  else if ((s->prev && s->prev->hl != s->hl && s->left_overhang)
-          || (s->next && s->next->hl != s->hl && s->right_overhang))
+  else if (!s->clip_head /* draw_glyphs didn't specify a clip mask. */
+          && !s->clip_tail
+          && ((s->prev && s->prev->hl != s->hl && s->left_overhang)
+              || (s->next && s->next->hl != s->hl && s->right_overhang)))
     /* We must clip just this glyph.  left_overhang part has already
        drawn when s->prev was drawn, and right_overhang part will be
        drawn later when s->next is drawn. */
@@ -2725,7 +2727,7 @@ x_draw_glyph_string (s)
              else
                thickness = 1;
              if (x_underline_at_descent_line)
-               position = (s->height - thickness) - s->ybase;
+               position = (s->height - thickness) - (s->ybase - s->y);
              else
                {
                  /* Get the underline position.  This is the recommended
@@ -2742,9 +2744,16 @@ x_draw_glyph_string (s)
                  else if (s->font)
                    position = (s->font->descent + 1) / 2;
                }
-             s->underline_thickness = thickness;
-             s->underline_position = position;
+             position = max (position, underline_minimum_offset);
            }
+         /* Check the sanity of thickness and position.  We should
+            avoid drawing underline out of the current line area.  */
+         if (s->y + s->height <= s->ybase + position)
+           position = (s->height - 1) - (s->ybase - s->y);
+         if (s->y + s->height < s->ybase + position + thickness)
+           thickness = (s->y + s->height) - (s->ybase + position);
+         s->underline_thickness = thickness;
+         s->underline_position = position;
          y = s->ybase + position;
          if (s->face->underline_defaulted_p)
            XFillRectangle (s->display, s->window, s->gc,
@@ -9505,9 +9514,7 @@ x_free_frame_resources (f)
       XFlush (FRAME_X_DISPLAY (f));
     }
 
-  if (f->output_data.x->saved_menu_event)
-    xfree (f->output_data.x->saved_menu_event);
-
+  xfree (f->output_data.x->saved_menu_event);
   xfree (f->output_data.x);
   f->output_data.x = NULL;
 
@@ -10514,10 +10521,8 @@ x_delete_display (dpyinfo)
     xim_close_dpy (dpyinfo);
 #endif
 
-  if (dpyinfo->x_id_name)
-    xfree (dpyinfo->x_id_name);
-  if (dpyinfo->color_cells)
-    xfree (dpyinfo->color_cells);
+  xfree (dpyinfo->x_id_name);
+  xfree (dpyinfo->color_cells);
   xfree (dpyinfo);
 }
 
@@ -10777,7 +10782,9 @@ syms_of_xterm ()
      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.  */);
+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.  */);
   x_use_underline_position_properties = 1;
 
   DEFVAR_BOOL ("x-underline-at-descent-line",