emacs-devel
[Top][All Lists]
Advanced

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

Re: Subject: w32 mouse wheel handling


From: David Ponce
Subject: Re: Subject: w32 mouse wheel handling
Date: Sun, 25 May 2003 10:34:13 +0200
User-agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.4b) Gecko/20030524

Hi Michael,

[...]
> I would agree with this.  When I wrote the original mouse wheel
> support (now long since changed to better implementations), I created
> the mouse-wheel event because (to the best of my knowlede, at the
> time at least) these events hadn't been standardized into a
> mouse-4/mouse-5 event at that time in X.

Thanks for your feedback!

Here is an updated patch following Kim's latest changes.
Also it should work on W95 too (it would be nice if a W32 guru could
review it ;-).

Sincerely,
David

Index: src/keyboard.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/keyboard.c,v
retrieving revision 1.746
diff -c -r1.746 keyboard.c
*** src/keyboard.c      24 May 2003 21:59:25 -0000      1.746
--- src/keyboard.c      25 May 2003 08:24:31 -0000
***************
*** 5514,5520 ****
        }
        }
  #endif /* WINDOWSNT */
! #if defined(WINDOWSNT) || defined(MAC_OSX)
      case MOUSE_WHEEL_EVENT:
        {
        enum window_part part;
--- 5514,5520 ----
        }
        }
  #endif /* WINDOWSNT */
! #if defined(MAC_OSX)
      case MOUSE_WHEEL_EVENT:
        {
        enum window_part part;
***************
*** 5587,5593 ****
                                             Qnil))));
        }
        }
! #endif /* WINDOWSNT || MAC_OSX */

      case DRAG_N_DROP_EVENT:
        {
--- 5587,5593 ----
                                             Qnil))));
        }
        }
! #endif /* MAC_OSX */

      case DRAG_N_DROP_EVENT:
        {
Index: src/w32term.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/w32term.c,v
retrieving revision 1.189
diff -c -r1.189 w32term.c
*** src/w32term.c       24 May 2003 22:06:19 -0000      1.189
--- src/w32term.c       25 May 2003 08:24:42 -0000
***************
*** 2911,2918 ****
       struct frame *f;
  {
    POINT p;
!   result->kind = MOUSE_WHEEL_EVENT;
!   result->code = (short) HIWORD (msg->msg.wParam);
    result->timestamp = msg->msg.time;
    result->modifiers = msg->dwModifiers;
    p.x = LOWORD (msg->msg.lParam);
--- 2911,2918 ----
       struct frame *f;
  {
    POINT p;
!   result->kind = MOUSE_CLICK_EVENT;
!   result->code = ( GET_WHEEL_DELTA_WPARAM (msg->msg.wParam) < 0 )? 4 : 3;
    result->timestamp = msg->msg.time;
    result->modifiers = msg->dwModifiers;
    p.x = LOWORD (msg->msg.lParam);
***************
*** 4383,4408 ****
          }

        case WM_MOUSEWHEEL:
!           if (dpyinfo->grabbed && last_mouse_frame
!               && FRAME_LIVE_P (last_mouse_frame))
!             f = last_mouse_frame;
!           else
!             f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
!
!           if (f)
!             {
!               if ((!dpyinfo->w32_focus_frame
!                    || f == dpyinfo->w32_focus_frame)
!                   && (numchars >= 1))
!                 {
!                   construct_mouse_wheel (bufp, &msg, f);
!                   bufp++;
!                   count++;
!                   numchars--;
!                 }
!             }
!         break;
!
        case WM_DROPFILES:
          f = x_window_to_frame (dpyinfo, msg.msg.hwnd);

--- 4383,4473 ----
          }

        case WM_MOUSEWHEEL:
!       {
!         /* Convert each Windows mouse wheel event in a couple of
!            Emacs mouse click down/up events.  Scrolling the wheel up
!            is associated to mouse button 4 and scrolling the wheel
!            down to the mouse button 5.  */
!         int button;
!         int up;
!       
!         up = msg.dwModifiers & up_modifier;
!       
!         if (dpyinfo->grabbed && last_mouse_frame
!             && FRAME_LIVE_P (last_mouse_frame))
!           f = last_mouse_frame;
!         else
!           f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
!       
!         if (f)
!           {
!             Lisp_Object window;
!             POINT p;
!             int x, y;
!       
!             p.x = LOWORD (msg.msg.lParam);
!             p.y = HIWORD (msg.msg.lParam);
!             ScreenToClient (msg.msg.hwnd, &p);
!             x = XFASTINT (p.x);
!             y = XFASTINT (p.y);
!       
!             window = window_from_coordinates (f, x, y, 0, 0, 0, 0);
!       
!             /* Ignore mouse wheel events not in a window.  */
!             if (!WINDOWP(window))
!               break;
!       
!             if ((!dpyinfo->w32_focus_frame
!                  || f == dpyinfo->w32_focus_frame)
!                 && (numchars >= 1))
!               {
!                 if ( !up )
!                   {
!                     /* Emit an Emacs mouse down message.       */
!                     msg.dwModifiers |= down_modifier;
!                     construct_mouse_wheel (bufp, &msg, f);
!                     bufp++;
!                     count++;
!                     numchars--;
!               
!                     /* Push a simulated WM_MOUSEWHEEL up message.  */
!                     msg.dwModifiers &= ~down_modifier;
!                     msg.dwModifiers |= up_modifier;
!                     prepend_msg (&msg);
!                   }
!                 else
!                   {
!                     /* Emit an Emacs mouse up message.  */
!                     construct_mouse_wheel (bufp, &msg, f);
!                     bufp++;
!                     count++;
!                     numchars--;
!                   }
!               }
!           }
!       
!         button = ( GET_WHEEL_DELTA_WPARAM (msg.msg.wParam) < 0 )? 4 : 3;
!       
!         if (up)
!           {
!             dpyinfo->grabbed &= ~ (1 << button);
!           }
!         else
!           {
!             dpyinfo->grabbed |= (1 << button);
!             last_mouse_frame = f;
!             /* Ignore any mouse motion that happened
!                before this event; any subsequent mouse-movement
!                Emacs events should reflect only motion after
!                the ButtonPress.  */
!             if (f != 0)
!               f->mouse_moved = 0;
!       
!             last_tool_bar_item = -1;
!           }
!       }
!       break;
!       
        case WM_DROPFILES:
          f = x_window_to_frame (dpyinfo, msg.msg.hwnd);

***************
*** 4749,4772 ****
          /* Check for messages registered at runtime. */
          if (msg.msg.message == msh_mousewheel)
            {
!             if (dpyinfo->grabbed && last_mouse_frame
!                 && FRAME_LIVE_P (last_mouse_frame))
!               f = last_mouse_frame;
!             else
!               f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
!
!             if (f)
!               {
!                 if ((!dpyinfo->w32_focus_frame
!                      || f == dpyinfo->w32_focus_frame)
!                     && (numchars >= 1))
!                   {
!                     construct_mouse_wheel (bufp, &msg, f);
!                     bufp++;
!                     count++;
!                     numchars--;
!                   }
!               }
            }
          break;
        }
--- 4814,4822 ----
          /* Check for messages registered at runtime. */
          if (msg.msg.message == msh_mousewheel)
            {
!               /* Forward MSH_MOUSEWHEEL as WM_MOUSEWHEEL.  */
!               msg.msg.message == WM_MOUSEWHEEL;
!               prepend_msg (&msg);
            }
          break;
        }






reply via email to

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