emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Extending fringe backgrounds to scroll bar gaps


From: YAMAMOTO Mitsuharu
Subject: Re: Extending fringe backgrounds to scroll bar gaps
Date: Sat, 23 Jun 2007 11:05:56 +0900
User-agent: Wanderlust/2.14.0 (Africa) SEMI/1.14.6 (Maruoka) FLIM/1.14.8 (Shijō) APEL/10.6 Emacs/22.1.50 (sparc-sun-solaris2.8) MULE/5.0 (SAKAKI)

>>>>> On Fri, 22 Jun 2007 10:19:18 +0200, "Juanma Barranquero" <address@hidden> 
>>>>> said:

> It doesn't help. The redisplay bug is still present. BTW, it only
> happens AFAICS when `indicate-empty-lines' is t and the fringe is
> showing the empty lines bitmap.

I could reproduce it also on Mac with indicate-empty-lines, left
scroll bar, and half-width fringes.  The fringe background was not
extended when the bitmap fills the fringe.

                                     YAMAMOTO Mitsuharu
                                address@hidden

Index: src/w32term.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/w32term.c,v
retrieving revision 1.260
diff -c -p -r1.260 w32term.c
*** src/w32term.c       20 Jun 2007 08:32:59 -0000      1.260
--- src/w32term.c       22 Jun 2007 23:20:32 -0000
*************** w32_draw_fringe_bitmap (w, row, p)
*** 682,687 ****
--- 682,741 ----
  
    hdc = get_frame_dc (f);
  
+   if (!p->overlay_p)
+     {
+       int bx = p->bx, by = p->by, nx = p->nx, ny = p->ny;
+ 
+       /* If the fringe is adjacent to the left (right) scroll bar of a
+        leftmost (rightmost, respectively) window, then extend its
+        background to the gap between the fringe and the bar.  */
+       if ((WINDOW_LEFTMOST_P (w)
+          && WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w))
+         || (WINDOW_RIGHTMOST_P (w)
+             && WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_RIGHT (w)))
+       {
+         int sb_width = WINDOW_CONFIG_SCROLL_BAR_WIDTH (w);
+ 
+         if (sb_width > 0)
+           {
+             int left = WINDOW_SCROLL_BAR_AREA_X (w);
+             int width = (WINDOW_CONFIG_SCROLL_BAR_COLS (w)
+                          * FRAME_COLUMN_WIDTH (f));
+ 
+             if (bx < 0)
+               {
+                 /* Bitmap fills the fringe.  */
+                 if (left + width == p->x)
+                   bx = left + sb_width;
+                 else if (p->x + p->wd == left)
+                   bx = left;
+                 if (bx >= 0)
+                   {
+                     int header_line_height = WINDOW_HEADER_LINE_HEIGHT (w);
+ 
+                     nx = width - sb_width;
+                     by = WINDOW_TO_FRAME_PIXEL_Y (w, max (header_line_height,
+                                                           row->y));
+                     ny = row->visible_height;
+                   }
+               }
+             else
+               {
+                 if (left + width == bx)
+                   {
+                     bx = left + sb_width;
+                     nx += width - sb_width;
+                   }
+                 else if (bx + nx == left)
+                   nx += width - sb_width;
+               }
+           }
+       }
+ 
+       if (bx >= 0 && nx > 0)
+       w32_fill_area (f, hdc, face->background, bx, by, nx, ny);
+     }
+ 
    /* Must clip because of partially visible lines.  */
    rowY = WINDOW_TO_FRAME_PIXEL_Y (w, row->y);
    if (p->y < rowY)
*************** w32_draw_fringe_bitmap (w, row, p)
*** 699,710 ****
    else
      w32_clip_to_row (w, row, -1, hdc);
  
-   if (p->bx >= 0 && !p->overlay_p)
-     {
-       w32_fill_area (f, hdc, face->background,
-                    p->bx, p->by, p->nx, p->ny);
-     }
- 
    if (p->which && p->which < max_fringe_bmp)
      {
        HBITMAP pixmap = fringe_bmp[p->which];
--- 753,758 ----
*************** x_scroll_bar_create (w, top, left, width
*** 3637,3642 ****
--- 3685,3691 ----
    XSETINT (bar->start, 0);
    XSETINT (bar->end, 0);
    bar->dragging = Qnil;
+   bar->fringe_extended_p = Qnil;
  
    /* Requires geometry to be set before call to create the real window */
  
*************** w32_set_vertical_scroll_bar (w, portion,
*** 3700,3705 ****
--- 3749,3755 ----
    struct scroll_bar *bar;
    int top, height, left, sb_left, width, sb_width;
    int window_y, window_height;
+   int fringe_extended_p;
  
    /* Get window dimensions.  */
    window_box (w, -1, 0, &window_y, 0, &window_height);
*************** w32_set_vertical_scroll_bar (w, portion,
*** 3719,3727 ****
  
    /* Compute the left edge of the scroll bar.  */
    if (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_RIGHT (w))
!     sb_left = left + width - sb_width - (width - sb_width) / 2;
    else
!     sb_left = left + (width - sb_width) / 2;
  
    /* Does the scroll bar exist yet?  */
    if (NILP (w->vertical_scroll_bar))
--- 3769,3788 ----
  
    /* Compute the left edge of the scroll bar.  */
    if (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_RIGHT (w))
!     sb_left = left + (WINDOW_RIGHTMOST_P (w) ? width - sb_width : 0);
    else
!     sb_left = left + (WINDOW_LEFTMOST_P (w) ? 0 : width - sb_width);
! 
!   if (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w))
!     fringe_extended_p = (WINDOW_LEFTMOST_P (w)
!                        && WINDOW_LEFT_FRINGE_WIDTH (w)
!                        && (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w)
!                            || WINDOW_LEFT_MARGIN_COLS (w) == 0));
!   else
!     fringe_extended_p = (WINDOW_RIGHTMOST_P (w)
!                        && WINDOW_RIGHT_FRINGE_WIDTH (w)
!                        && (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w)
!                            || WINDOW_RIGHT_MARGIN_COLS (w) == 0));
  
    /* Does the scroll bar exist yet?  */
    if (NILP (w->vertical_scroll_bar))
*************** w32_set_vertical_scroll_bar (w, portion,
*** 3731,3737 ****
        if (width > 0 && height > 0)
        {
          hdc = get_frame_dc (f);
!         w32_clear_area (f, hdc, left, top, width, height);
          release_frame_dc (f, hdc);
        }
        UNBLOCK_INPUT;
--- 3792,3801 ----
        if (width > 0 && height > 0)
        {
          hdc = get_frame_dc (f);
!         if (fringe_extended_p)
!           w32_clear_area (f, hdc, sb_left, top, sb_width, height);
!         else
!           w32_clear_area (f, hdc, left, top, width, height);
          release_frame_dc (f, hdc);
        }
        UNBLOCK_INPUT;
*************** w32_set_vertical_scroll_bar (w, portion,
*** 3750,3756 ****
        if ( XINT (bar->left) == sb_left
             && XINT (bar->top) == top
             && XINT (bar->width) ==  sb_width
!            && XINT (bar->height) == height )
          {
            /* Redraw after clear_frame. */
            if (!my_show_window (f, hwnd, SW_NORMAL))
--- 3814,3821 ----
        if ( XINT (bar->left) == sb_left
             && XINT (bar->top) == top
             && XINT (bar->width) ==  sb_width
!            && XINT (bar->height) == height
!          && !NILP (bar->fringe_extended_p) == fringe_extended_p )
          {
            /* Redraw after clear_frame. */
            if (!my_show_window (f, hwnd, SW_NORMAL))
*************** w32_set_vertical_scroll_bar (w, portion,
*** 3767,3777 ****
              hdc = get_frame_dc (f);
              /* Since Windows scroll bars are smaller than the space reserved
                 for them on the frame, we have to clear "under" them.  */
!             w32_clear_area (f, hdc,
!                             left,
!                             top,
!                             width,
!                             height);
              release_frame_dc (f, hdc);
            }
            /* Make sure scroll bar is "visible" before moving, to ensure the
--- 3832,3841 ----
              hdc = get_frame_dc (f);
              /* Since Windows scroll bars are smaller than the space reserved
                 for them on the frame, we have to clear "under" them.  */
!             if (fringe_extended_p)
!               w32_clear_area (f, hdc, sb_left, top, sb_width, height);
!             else
!               w32_clear_area (f, hdc, left, top, width, height);
              release_frame_dc (f, hdc);
            }
            /* Make sure scroll bar is "visible" before moving, to ensure the
*************** w32_set_vertical_scroll_bar (w, portion,
*** 3801,3806 ****
--- 3865,3872 ----
            UNBLOCK_INPUT;
          }
      }
+   bar->fringe_extended_p = fringe_extended_p ? Qt : Qnil;
+ 
    w32_set_scroll_bar_thumb (bar, portion, position, whole);
  
    XSETVECTOR (w->vertical_scroll_bar, bar);
Index: src/w32term.h
===================================================================
RCS file: /cvsroot/emacs/emacs/src/w32term.h,v
retrieving revision 1.68
diff -c -p -r1.68 w32term.h
*** src/w32term.h       22 Feb 2007 22:50:15 -0000      1.68
--- src/w32term.h       22 Jun 2007 23:20:32 -0000
*************** struct scroll_bar {
*** 487,492 ****
--- 487,496 ----
       place where the user grabbed it.  If the handle isn't currently
       being dragged, this is Qnil.  */
    Lisp_Object dragging;
+ 
+   /* t if the background of the fringe that is adjacent to a scroll
+      bar is extended to the gap between the fringe and the bar.  */
+   Lisp_Object fringe_extended_p;
  };
  
  /* The number of elements a vector holding a struct scroll_bar needs.  */
*************** extern void w32_fill_rect ();
*** 576,589 ****
  extern void w32_clear_window ();
  
  #define w32_fill_area(f,hdc,pix,x,y,nx,ny) \
! { \
      RECT rect; \
      rect.left = x; \
      rect.top = y; \
      rect.right = x + nx; \
      rect.bottom = y + ny; \
      w32_fill_rect (f,hdc,pix,&rect); \
! }
  
  #define w32_clear_rect(f,hdc,lprect) \
  w32_fill_rect (f,hdc,f->output_data.x->background_pixel,lprect)
--- 580,593 ----
  extern void w32_clear_window ();
  
  #define w32_fill_area(f,hdc,pix,x,y,nx,ny) \
! do { \
      RECT rect; \
      rect.left = x; \
      rect.top = y; \
      rect.right = x + nx; \
      rect.bottom = y + ny; \
      w32_fill_rect (f,hdc,pix,&rect); \
! } while (0)
  
  #define w32_clear_rect(f,hdc,lprect) \
  w32_fill_rect (f,hdc,f->output_data.x->background_pixel,lprect)
Index: src/xterm.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/xterm.c,v
retrieving revision 1.947
diff -c -p -r1.947 xterm.c
*** src/xterm.c 8 Jun 2007 20:06:31 -0000       1.947
--- src/xterm.c 22 Jun 2007 23:20:32 -0000
*************** x_draw_fringe_bitmap (w, row, p)
*** 720,727 ****
    else
      x_clip_to_row (w, row, -1, gc);
  
!   if (p->bx >= 0 && !p->overlay_p)
      {
        /* In case the same realized face is used for fringes and
         for something displayed in the text (e.g. face `region' on
         mono-displays, the fill style may have been changed to
--- 720,729 ----
    else
      x_clip_to_row (w, row, -1, gc);
  
!   if (!p->overlay_p)
      {
+       int bx = p->bx, by = p->by, nx = p->nx, ny = p->ny;
+ 
        /* In case the same realized face is used for fringes and
         for something displayed in the text (e.g. face `region' on
         mono-displays, the fill style may have been changed to
*************** x_draw_fringe_bitmap (w, row, p)
*** 731,738 ****
        else
        XSetForeground (display, face->gc, face->background);
  
!       XFillRectangle (display, window, face->gc,
!                     p->bx, p->by, p->nx, p->ny);
  
        if (!face->stipple)
        XSetForeground (display, face->gc, face->foreground);
--- 733,787 ----
        else
        XSetForeground (display, face->gc, face->background);
  
! #ifdef USE_TOOLKIT_SCROLL_BARS
!       /* If the fringe is adjacent to the left (right) scroll bar of a
!        leftmost (rightmost, respectively) window, then extend its
!        background to the gap between the fringe and the bar.  */
!       if ((WINDOW_LEFTMOST_P (w)
!          && WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w))
!         || (WINDOW_RIGHTMOST_P (w)
!             && WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_RIGHT (w)))
!       {
!         int sb_width = WINDOW_CONFIG_SCROLL_BAR_WIDTH (w);
! 
!         if (sb_width > 0)
!           {
!             int left = WINDOW_SCROLL_BAR_AREA_X (w);
!             int width = (WINDOW_CONFIG_SCROLL_BAR_COLS (w)
!                          * FRAME_COLUMN_WIDTH (f));
! 
!             if (bx < 0)
!               {
!                 /* Bitmap fills the fringe.  */
!                 if (left + width == p->x)
!                   bx = left + sb_width;
!                 else if (p->x + p->wd == left)
!                   bx = left;
!                 if (bx >= 0)
!                   {
!                     int header_line_height = WINDOW_HEADER_LINE_HEIGHT (w);
! 
!                     nx = width - sb_width;
!                     by = WINDOW_TO_FRAME_PIXEL_Y (w, max (header_line_height,
!                                                           row->y));
!                     ny = row->visible_height;
!                   }
!               }
!             else
!               {
!                 if (left + width == bx)
!                   {
!                     bx = left + sb_width;
!                     nx += width - sb_width;
!                   }
!                 else if (bx + nx == left)
!                   nx += width - sb_width;
!               }
!           }
!       }
! #endif
!       if (bx >= 0 && nx > 0)
!       XFillRectangle (display, window, face->gc, bx, by, nx, ny);
  
        if (!face->stipple)
        XSetForeground (display, face->gc, face->foreground);
*************** x_scroll_bar_create (w, top, left, width
*** 4787,4792 ****
--- 4836,4844 ----
    XSETINT (bar->start, 0);
    XSETINT (bar->end, 0);
    bar->dragging = Qnil;
+ #ifdef USE_TOOLKIT_SCROLL_BARS
+   bar->fringe_extended_p = Qnil;
+ #endif
  
    /* Add bar to its frame's list of scroll bars.  */
    bar->next = FRAME_SCROLL_BARS (f);
*************** XTset_vertical_scroll_bar (w, portion, w
*** 4979,4984 ****
--- 5031,5039 ----
    struct scroll_bar *bar;
    int top, height, left, sb_left, width, sb_width;
    int window_y, window_height;
+ #ifdef USE_TOOLKIT_SCROLL_BARS
+   int fringe_extended_p;
+ #endif
  
    /* Get window dimensions.  */
    window_box (w, -1, 0, &window_y, 0, &window_height);
*************** XTset_vertical_scroll_bar (w, portion, w
*** 4999,5013 ****
    /* Compute the left edge of the scroll bar.  */
  #ifdef USE_TOOLKIT_SCROLL_BARS
    if (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_RIGHT (w))
!     sb_left = (left +
!              (WINDOW_RIGHTMOST_P (w)
!               ? width - sb_width - (width - sb_width) / 2
!               : 0));
!   else
!     sb_left = (left +
!              (WINDOW_LEFTMOST_P (w)
!               ? (width - sb_width) / 2
!               : width - sb_width));
  #else
    if (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_RIGHT (w))
      sb_left = left + width - sb_width;
--- 5054,5062 ----
    /* Compute the left edge of the scroll bar.  */
  #ifdef USE_TOOLKIT_SCROLL_BARS
    if (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_RIGHT (w))
!     sb_left = left + (WINDOW_RIGHTMOST_P (w) ? width - sb_width : 0);
!   else
!     sb_left = left + (WINDOW_LEFTMOST_P (w) ? 0 : width - sb_width);
  #else
    if (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_RIGHT (w))
      sb_left = left + width - sb_width;
*************** XTset_vertical_scroll_bar (w, portion, w
*** 5015,5028 ****
      sb_left = left;
  #endif
  
    /* Does the scroll bar exist yet?  */
    if (NILP (w->vertical_scroll_bar))
      {
        if (width > 0 && height > 0)
        {
          BLOCK_INPUT;
!         x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
!                       left, top, width, height, False);
          UNBLOCK_INPUT;
        }
  
--- 5064,5096 ----
      sb_left = left;
  #endif
  
+ #ifdef USE_TOOLKIT_SCROLL_BARS
+   if (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w))
+     fringe_extended_p = (WINDOW_LEFTMOST_P (w)
+                        && WINDOW_LEFT_FRINGE_WIDTH (w)
+                        && (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w)
+                            || WINDOW_LEFT_MARGIN_COLS (w) == 0));
+   else
+     fringe_extended_p = (WINDOW_RIGHTMOST_P (w)
+                        && WINDOW_RIGHT_FRINGE_WIDTH (w)
+                        && (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w)
+                            || WINDOW_RIGHT_MARGIN_COLS (w) == 0));
+ #endif
+ 
    /* Does the scroll bar exist yet?  */
    if (NILP (w->vertical_scroll_bar))
      {
        if (width > 0 && height > 0)
        {
          BLOCK_INPUT;
! #ifdef USE_TOOLKIT_SCROLL_BARS
!         if (fringe_extended_p)
!           x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
!                         sb_left, top, sb_width, height, False);
!         else
! #endif
!           x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
!                         left, top, width, height, False);
          UNBLOCK_INPUT;
        }
  
*************** XTset_vertical_scroll_bar (w, portion, w
*** 5049,5061 ****
  #ifdef USE_TOOLKIT_SCROLL_BARS
  
        /* Move/size the scroll bar widget.  */
!       if (mask)
        {
          /* Since toolkit scroll bars are smaller than the space reserved
             for them on the frame, we have to clear "under" them.  */
          if (width > 0 && height > 0)
!           x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
!                           left, top, width, height, False);
  #ifdef USE_GTK
            xg_update_scrollbar_pos (f,
                                     SCROLL_BAR_X_WINDOW (bar),
--- 5117,5135 ----
  #ifdef USE_TOOLKIT_SCROLL_BARS
  
        /* Move/size the scroll bar widget.  */
!       if (mask || !NILP (bar->fringe_extended_p) != fringe_extended_p)
        {
          /* Since toolkit scroll bars are smaller than the space reserved
             for them on the frame, we have to clear "under" them.  */
          if (width > 0 && height > 0)
!           {
!             if (fringe_extended_p)
!               x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
!                             sb_left, top, sb_width, height, False);
!             else
!               x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
!                             left, top, width, height, False);
!           }
  #ifdef USE_GTK
            xg_update_scrollbar_pos (f,
                                     SCROLL_BAR_X_WINDOW (bar),
*************** XTset_vertical_scroll_bar (w, portion, w
*** 5130,5135 ****
--- 5204,5211 ----
      }
  
  #ifdef USE_TOOLKIT_SCROLL_BARS
+   bar->fringe_extended_p = fringe_extended_p ? Qt : Qnil;
+ 
    x_set_toolkit_scroll_bar_thumb (bar, portion, position, whole);
  #else /* not USE_TOOLKIT_SCROLL_BARS */
    /* Set the scroll bar's current state, unless we're currently being
Index: src/xterm.h
===================================================================
RCS file: /cvsroot/emacs/emacs/src/xterm.h,v
retrieving revision 1.190
diff -c -p -r1.190 xterm.h
*** src/xterm.h 21 Jan 2007 04:18:14 -0000      1.190
--- src/xterm.h 22 Jun 2007 23:20:33 -0000
*************** struct scroll_bar
*** 807,812 ****
--- 807,818 ----
       place where the user grabbed it.  If the handle isn't currently
       being dragged, this is Qnil.  */
    Lisp_Object dragging;
+ 
+ #ifdef USE_TOOLKIT_SCROLL_BARS
+   /* t if the background of the fringe that is adjacent to a scroll
+      bar is extended to the gap between the fringe and the bar.  */
+   Lisp_Object fringe_extended_p;
+ #endif
  };
  
  /* The number of elements a vector holding a struct scroll_bar needs.  */




reply via email to

[Prev in Thread] Current Thread [Next in Thread]