emacs-devel
[Top][All Lists]
Advanced

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

Re: Native scrollbars? [was: visible-bell patch for Mac OS X]


From: YAMAMOTO Mitsuharu
Subject: Re: Native scrollbars? [was: visible-bell patch for Mac OS X]
Date: Sat, 13 Feb 2010 16:32:48 +0900
User-agent: Wanderlust/2.14.0 (Africa) SEMI/1.14.6 (Maruoka) FLIM/1.14.8 (Shijō) APEL/10.6 Emacs/22.3 (sparc-sun-solaris2.8) MULE/5.0 (SAKAKI)

>>>>> On Sat, 13 Feb 2010 06:45:33 +0000, David De La Harpe Golden 
>>>>> <address@hidden> said:

> It's quite a minor and transient effect (on my system anyway).
> Still, I guess the flash inversion area in xterm.c/XTflash() is
> winding up a bit off somehow - the intent of the code does seem to
> be that scrollbars should be excluded from the area, but maybe it's
> only working for some cases.

The current code just trims off the margins outside leftmost left (or
rightmost right) scroll bars.

Just adding more excluded area at the edge positions gives
inconsistent result as found in multiple patches proposed for the NS
port, because scroll bars might overlap with the flashed area at some
non-edge positions.  I think a consistent way is to avoid inversion
(or re-invert to recover the original image) for the overlapped area:

  http://lists.gnu.org/archive/html/emacs-devel/2010-02/msg00038.html

The above mail includes a patch for the Mac port using re-inversion,
and it can be ported to GTK+ as below.  Though I've never observed
flicker by re-inversion of overlapped area, that might happen in
principle (this is not an issue for the Mac port because of
double-buffering).  Maybe create a Pixmap for the inverted area first?

                                     YAMAMOTO Mitsuharu
                                address@hidden

=== modified file 'src/xterm.c'
*** src/xterm.c 2010-01-19 04:32:47 +0000
--- src/xterm.c 2010-02-03 08:47:20 +0000
***************
*** 3037,3045 ****
        int flash_height = FRAME_LINE_HEIGHT (f);
        /* These will be the left and right margins of the rectangles.  */
        int flash_left = FRAME_INTERNAL_BORDER_WIDTH (f);
!       int flash_right = FRAME_PIXEL_WIDTH (f) - FRAME_INTERNAL_BORDER_WIDTH 
(f);
! 
        int width;
  
        /* Don't flash the area between a scroll bar and the frame
         edge it is next to.  */
--- 3037,3047 ----
        int flash_height = FRAME_LINE_HEIGHT (f);
        /* These will be the left and right margins of the rectangles.  */
        int flash_left = FRAME_INTERNAL_BORDER_WIDTH (f);
!       int flash_right = (FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, FRAME_COLS (f))
!                        - FRAME_INTERNAL_BORDER_WIDTH (f));
        int width;
+       XRectangle rects[2];
+       int i, nrects;
  
        /* Don't flash the area between a scroll bar and the frame
         edge it is next to.  */
***************
*** 3059,3083 ****
  
        width = flash_right - flash_left;
  
-       /* If window is tall, flash top and bottom line.  */
        if (height > 3 * FRAME_LINE_HEIGHT (f))
        {
!         XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc,
!                         flash_left,
!                         (FRAME_INTERNAL_BORDER_WIDTH (f)
!                          + FRAME_TOP_MARGIN_HEIGHT (f)),
!                         width, flash_height);
!         XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc,
!                         flash_left,
!                         (height - flash_height
!                          - FRAME_INTERNAL_BORDER_WIDTH (f)),
!                         width, flash_height);
        }
        else
!       /* If it is short, flash it all.  */
        XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc,
!                       flash_left, FRAME_INTERNAL_BORDER_WIDTH (f),
!                       width, height - 2 * FRAME_INTERNAL_BORDER_WIDTH (f));
  
        x_flush (f);
  
--- 3061,3113 ----
  
        width = flash_right - flash_left;
  
        if (height > 3 * FRAME_LINE_HEIGHT (f))
        {
!         /* If window is tall, flash top and bottom line.  */
!         STORE_NATIVE_RECT (rects[0],
!                            flash_left, (FRAME_INTERNAL_BORDER_WIDTH (f)
!                                         + FRAME_TOP_MARGIN_HEIGHT (f)),
!                            width, flash_height);
!         rects[1] = rects[0];
!         rects[1].y = height - flash_height - FRAME_INTERNAL_BORDER_WIDTH (f);
!         nrects = 2;
        }
        else
!       {
!         /* If it is short, flash it all.  */
!         STORE_NATIVE_RECT (rects[0],
!                            flash_left, FRAME_INTERNAL_BORDER_WIDTH (f),
!                            width,
!                            height - 2 * FRAME_INTERNAL_BORDER_WIDTH (f));
!         nrects = 1;
!       }
! 
!       for (i = 0; i < nrects; i++)
        XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc,
!                       rects[i].x, rects[i].y,
!                       rects[i].width, rects[i].height);
! #ifdef USE_GTK
!       /* In case scroll bars don't have their own windows, we cancel
!        color flipping for scroll bar area.  */
!       if (FRAME_HAS_VERTICAL_SCROLL_BARS (f))
!       {
!         Lisp_Object bar;
! 
!         for (bar = FRAME_SCROLL_BARS (f); !NILP (bar);
!              bar = XSCROLL_BAR (bar)->next)
!           {
!             struct scroll_bar *b = XSCROLL_BAR (bar);
!             XRectangle bar_rect, r;
! 
!             STORE_NATIVE_RECT (bar_rect, b->left, b->top,
!                                b->width, b->height);
!             for (i = 0; i < nrects; i++)
!               if (x_intersect_rectangles (rects + i, &bar_rect, &r))
!                 XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc,
!                                 r.x, r.y, r.width, r.height);
!           }
!       }
! #endif        /* USE_GTK */
  
        x_flush (f);
  
***************
*** 3113,3137 ****
          }
        }
  
!       /* If window is tall, flash top and bottom line.  */
!       if (height > 3 * FRAME_LINE_HEIGHT (f))
        {
!         XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc,
!                         flash_left,
!                         (FRAME_INTERNAL_BORDER_WIDTH (f)
!                          + FRAME_TOP_MARGIN_HEIGHT (f)),
!                         width, flash_height);
!         XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc,
!                         flash_left,
!                         (height - flash_height
!                          - FRAME_INTERNAL_BORDER_WIDTH (f)),
!                         width, flash_height);
        }
!       else
!       /* If it is short, flash it all.  */
!       XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc,
!                       flash_left, FRAME_INTERNAL_BORDER_WIDTH (f),
!                       width, height - 2 * FRAME_INTERNAL_BORDER_WIDTH (f));
  
        XFreeGC (FRAME_X_DISPLAY (f), gc);
        x_flush (f);
--- 3143,3172 ----
          }
        }
  
!       for (i = 0; i < nrects; i++)
!       XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc,
!                       rects[i].x, rects[i].y,
!                       rects[i].width, rects[i].height);
! #ifdef USE_GTK
!       if (FRAME_HAS_VERTICAL_SCROLL_BARS (f))
        {
!         Lisp_Object bar;
! 
!         for (bar = FRAME_SCROLL_BARS (f); !NILP (bar);
!              bar = XSCROLL_BAR (bar)->next)
!           {
!             struct scroll_bar *b = XSCROLL_BAR (bar);
!             XRectangle bar_rect, r;
! 
!             STORE_NATIVE_RECT (bar_rect, b->left, b->top,
!                                b->width, b->height);
!             for (i = 0; i < nrects; i++)
!               if (x_intersect_rectangles (rects + i, &bar_rect, &r))
!                 XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc,
!                                 r.x, r.y, r.width, r.height);
!           }
        }
! #endif        /* USE_GTK */
  
        XFreeGC (FRAME_X_DISPLAY (f), gc);
        x_flush (f);









reply via email to

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