emacs-pretest-bug
[Top][All Lists]
Advanced

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

Re: address@hidden: Selecting region & setting point with mouse at left


From: YAMAMOTO Mitsuharu
Subject: Re: address@hidden: Selecting region & setting point with mouse at left border]
Date: Tue, 07 Jun 2005 18:45:48 +0900
User-agent: Wanderlust/2.14.0 (Africa) SEMI/1.14.6 (Maruoka) FLIM/1.14.6 (Marutamachi) APEL/10.6 Emacs/22.0.50 (sparc-sun-solaris2.8) MULE/5.0 (SAKAKI)

>>>>> On Sun, 05 Jun 2005 23:46:36 +0200, address@hidden (Kim F. Storm) said:

> I have tried to reproduce it on GNU/Linux, but it works for me.

> I tried with the "variable-pitch" face, on a line with a ' as the
> first character on a line -- and I can select it with the mouse
> without problems.

> So it seems to be a MAC specific problem.

The problem seems to be solved by using remember_mouse_glyph instead
of pixel_to_glyph_coords in XTmouse_position as in the W32 version.
But this fix causes some problems that are also related to other
platforms.

  1. When I drag the mouse from the text area into the right edge of
     the left fringe area, the beginning of the highlighted region is
     advanced suddenly.  This can also be reproduced on X11.

  2. It seems that glyph_rect does not calculate the correct area on
     any platforms.  On X11, the area becomes outside the mouse
     pointer.  On W32 and Mac, some adjustment for
     WINDOW_LEFT_FRINGE_WIDTH is needed.  I tried to fix that on Mac
     in the patch below, but it causes some problems:

     2.1 Sometimes a tooltip is not shown.  I hope the first fragment
         of the patch below fix this.

     2.2 The value of last_mouse_glyph may become invalid.  For
         example, after clicking the image on the splash screen,
         dragging the area where the image was displayed does not
         issue mouse-movement events.  I think last_mouse_glyph should
         be cleared in some appropriate timing, but I'm not sure when
         it is.

                                     YAMAMOTO Mitsuharu
                                address@hidden

Index: src/macterm.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/macterm.c,v
retrieving revision 1.117
diff -c -r1.117 macterm.c
*** src/macterm.c       6 Jun 2005 20:23:56 -0000       1.117
--- src/macterm.c       7 Jun 2005 03:01:15 -0000
***************
*** 3910,3915 ****
--- 3910,3917 ----
        last_mouse_scroll_bar = Qnil;
        note_mouse_highlight (frame, pos->h, pos->v);
      }
+   else
+     help_echo_string = previous_help_echo_string;
  }
  
  /* This is used for debugging, to turn off note_mouse_highlight.  */
***************
*** 3961,3968 ****
        struct glyph_row *r = MATRIX_FIRST_TEXT_ROW (w->current_matrix);
        struct glyph_row *end = r + w->current_matrix->nrows - 1;
  
        for (; r < end && r->enabled_p; ++r)
!       if (r->y <= y && r->y + r->height > y)
          {
            /* Found the row at y.  */
            struct glyph *g = r->glyphs[TEXT_AREA];
--- 3963,3973 ----
        struct glyph_row *r = MATRIX_FIRST_TEXT_ROW (w->current_matrix);
        struct glyph_row *end = r + w->current_matrix->nrows - 1;
  
+       if (r->y > y)
+       return 0;
+ 
        for (; r < end && r->enabled_p; ++r)
!       if (r->y + r->height > y)
          {
            /* Found the row at y.  */
            struct glyph *g = r->glyphs[TEXT_AREA];
***************
*** 3975,4003 ****
            if (x < r->x)
              {
                /* x is to the left of the first glyph in the row.  */
!               /* Shouldn't this be a pixel value?
!                  WINDOW_LEFT_EDGE_X (w) seems to be the right value.
!                  ++KFS */
!               rect->left = WINDOW_LEFT_EDGE_COL (w);
!               rect->right = WINDOW_TO_FRAME_PIXEL_X (w, r->x);
                return 1;
              }
  
            for (gx = r->x; g < end; gx += g->pixel_width, ++g)
!             if (gx <= x && gx + g->pixel_width > x)
                {
                  /* x is on a glyph.  */
!                 rect->left = WINDOW_TO_FRAME_PIXEL_X (w, gx);
                  rect->right = rect->left + g->pixel_width;
                  return 1;
                }
  
            /* x is to the right of the last glyph in the row.  */
!           rect->left = WINDOW_TO_FRAME_PIXEL_X (w, gx);
!           /* Shouldn't this be a pixel value?
!              WINDOW_RIGHT_EDGE_X (w) seems to be the right value.
!              ++KFS */
!           rect->right = WINDOW_RIGHT_EDGE_COL (w);
            return 1;
          }
      }
--- 3980,4006 ----
            if (x < r->x)
              {
                /* x is to the left of the first glyph in the row.  */
!               rect->left = WINDOW_LEFT_EDGE_X (w);
!               rect->right = WINDOW_TO_FRAME_PIXEL_X (w, r->x)
!                 + WINDOW_LEFT_FRINGE_WIDTH (w); /* or modify 
WINDOW_TO_FRAME_PIXEL_X ? */
                return 1;
              }
  
            for (gx = r->x; g < end; gx += g->pixel_width, ++g)
!             if (gx + g->pixel_width > x)
                {
                  /* x is on a glyph.  */
!                 rect->left = WINDOW_TO_FRAME_PIXEL_X (w, gx)
!                   + WINDOW_LEFT_FRINGE_WIDTH (w); /* or modify 
WINDOW_TO_FRAME_PIXEL_X ? */
                  rect->right = rect->left + g->pixel_width;
                  return 1;
                }
  
            /* x is to the right of the last glyph in the row.  */
!           rect->left = WINDOW_TO_FRAME_PIXEL_X (w, gx)
!             + WINDOW_LEFT_FRINGE_WIDTH (w); /* or modify 
WINDOW_TO_FRAME_PIXEL_X ? */
! 
!           rect->right = WINDOW_RIGHT_EDGE_X (w);
            return 1;
          }
      }
***************
*** 4006,4012 ****
    return 0;
  }
  
- /* MAC TODO:  This should be called from somewhere (or removed)  ++KFS */
  
  /* Record the position of the mouse in last_mouse_glyph.  */
  static void
--- 4009,4014 ----
***************
*** 4087,4097 ****
       Lisp_Object *x, *y;
       unsigned long *time;
  {
!   Point mouse_pos;
!   int ignore1, ignore2;
!   struct frame *f = mac_focus_frame (FRAME_MAC_DISPLAY_INFO (*fp));
!   WindowPtr wp = FRAME_MAC_WINDOW (f);
!   Lisp_Object frame, tail;
  
    BLOCK_INPUT;
  
--- 4089,4095 ----
       Lisp_Object *x, *y;
       unsigned long *time;
  {
!   FRAME_PTR f1;
  
    BLOCK_INPUT;
  
***************
*** 4099,4123 ****
      x_scroll_bar_report_motion (fp, bar_window, part, x, y, time);
    else
      {
        /* Clear the mouse-moved flag for every frame on this display.  */
        FOR_EACH_FRAME (tail, frame)
!         XFRAME (frame)->mouse_moved = 0;
  
        last_mouse_scroll_bar = Qnil;
  
!       SetPortWindowPort (wp);
! 
!       GetMouse (&mouse_pos);
! 
!       pixel_to_glyph_coords (f, mouse_pos.h, mouse_pos.v, &ignore1, &ignore2,
!                              &last_mouse_glyph, insist);
  
!       *bar_window = Qnil;
!       *part = scroll_bar_handle;
!       *fp = f;
!       XSETINT (*x, mouse_pos.h);
!       XSETINT (*y, mouse_pos.v);
!       *time = last_mouse_movement_time;
      }
  
    UNBLOCK_INPUT;
--- 4097,4140 ----
      x_scroll_bar_report_motion (fp, bar_window, part, x, y, time);
    else
      {
+       Lisp_Object frame, tail;
+ 
        /* Clear the mouse-moved flag for every frame on this display.  */
        FOR_EACH_FRAME (tail, frame)
!       XFRAME (frame)->mouse_moved = 0;
  
        last_mouse_scroll_bar = Qnil;
  
!       if (FRAME_MAC_DISPLAY_INFO (*fp)->grabbed && last_mouse_frame
!         && FRAME_LIVE_P (last_mouse_frame))
!       f1 = last_mouse_frame;
!       else
!       f1 = mac_focus_frame (FRAME_MAC_DISPLAY_INFO (*fp));    
  
!       if (f1)
!       {
!         /* Ok, we found a frame.  Store all the values.
!            last_mouse_glyph is a rectangle used to reduce the
!            generation of mouse events.  To not miss any motion
!            events, we must divide the frame into rectangles of the
!            size of the smallest character that could be displayed
!            on it, i.e. into the same rectangles that matrices on
!            the frame are divided into.  */
!         Point mouse_pos;
! 
!         SetPortWindowPort (FRAME_MAC_WINDOW (f1));
! 
!         GetMouse (&mouse_pos);
! 
!         remember_mouse_glyph (f1, mouse_pos.h, mouse_pos.v);
! 
!         *bar_window = Qnil;
!         *part = 0;
!         *fp = f1;
!         XSETINT (*x, mouse_pos.h);
!         XSETINT (*y, mouse_pos.v);
!         *time = last_mouse_movement_time;
!       }
      }
  
    UNBLOCK_INPUT;




reply via email to

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