From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: David Ponce Newsgroups: gmane.emacs.devel Subject: Re: Subject: w32 mouse wheel handling Date: Sun, 25 May 2003 10:34:13 +0200 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <3ED08005.9020503@wanadoo.fr> References: <25058549.1053701279594.JavaMail.www@wwinf0601> <871xynu0bo.fsf@cs.cmu.edu> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: main.gmane.org 1053851525 20387 80.91.224.249 (25 May 2003 08:32:05 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sun, 25 May 2003 08:32:05 +0000 (UTC) Cc: emacs-devel Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Sun May 25 10:32:03 2003 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19JqvD-0005Ie-00 for ; Sun, 25 May 2003 10:32:03 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 19Jr7q-0003P5-00 for ; Sun, 25 May 2003 10:45:06 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.20) id 19Jqwj-0005UH-Ar for emacs-devel@quimby.gnus.org; Sun, 25 May 2003 04:33:37 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.20) id 19JqwD-00057G-6Q for emacs-devel@gnu.org; Sun, 25 May 2003 04:33:05 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.20) id 19Jqvz-0004e5-AT for emacs-devel@gnu.org; Sun, 25 May 2003 04:32:58 -0400 Original-Received: from smtp6.wanadoo.fr ([193.252.22.28] helo=mwinf0304.wanadoo.fr) by monty-python.gnu.org with esmtp (Exim 4.20) id 19JqvX-0003QW-3C for emacs-devel@gnu.org; Sun, 25 May 2003 04:32:23 -0400 Original-Received: from wanadoo.fr (unknown [80.15.12.230]) by mwinf0304.wanadoo.fr (SMTP Server) with ESMTP id E93E0A803FE8; Sun, 25 May 2003 10:32:21 +0200 (CEST) User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.4b) Gecko/20030524 X-Accept-Language: en-us, en Original-To: Michael Welsh Duggan In-Reply-To: <871xynu0bo.fsf@cs.cmu.edu> X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Emacs development discussions. List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:14230 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:14230 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; }