unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: David Ponce <david.ponce@wanadoo.fr>
Cc: emacs-devel <emacs-devel@gnu.org>
Subject: Re: Subject: w32 mouse wheel handling
Date: Sun, 25 May 2003 10:34:13 +0200	[thread overview]
Message-ID: <3ED08005.9020503@wanadoo.fr> (raw)
In-Reply-To: <871xynu0bo.fsf@cs.cmu.edu>

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	other threads:[~2003-05-25  8:34 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-23 14:47 Subject: w32 mouse wheel handling David PONCE
2003-05-25  4:17 ` Michael Welsh Duggan
2003-05-25  8:34   ` David Ponce [this message]
2003-05-25 15:19   ` Stefan Monnier
2003-05-25 23:22     ` Kim F. Storm
2003-05-26  5:09       ` Kai Großjohann
2003-05-27 12:44         ` Richard Stallman
2003-05-28 22:18           ` David Ponce
2003-05-29  7:33             ` Jason Rumney
2003-05-30  0:50             ` Richard Stallman
2003-05-30 12:14               ` David Ponce
2003-05-26 13:30   ` Jason Rumney
2003-05-27  7:21 ` Jason Rumney
  -- strict thread matches above, loose matches on Subject: below --
2003-05-27  8:12 David PONCE
2003-05-27  8:29 ` Juanma Barranquero
2003-05-27  8:45   ` Jason Rumney
2003-05-27  8:49     ` Juanma Barranquero
2003-05-27 22:41     ` Richard Stallman
2003-05-28  7:50       ` Oliver Scholz
2003-05-27 14:28   ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3ED08005.9020503@wanadoo.fr \
    --to=david.ponce@wanadoo.fr \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).