comparison src/w32term.c @ 51382:e099ac71bd76

(construct_mouse_wheel): Construct WHEEL_EVENT. (w32_read_socket): Map w32 WM_MOUSEWHEEL events to Emacs WHEEL_EVENT events.
author Jason Rumney <jasonr@gnu.org>
date Sun, 01 Jun 2003 21:38:37 +0000
parents 827c306f0515
children c631ebcc0df9
comparison
equal deleted inserted replaced
51381:a2b5bb57e1c9 51382:e099ac71bd76
2914 struct input_event *result; 2914 struct input_event *result;
2915 W32Msg *msg; 2915 W32Msg *msg;
2916 struct frame *f; 2916 struct frame *f;
2917 { 2917 {
2918 POINT p; 2918 POINT p;
2919 result->kind = MOUSE_CLICK_EVENT; 2919 int delta;
2920 result->code = (GET_WHEEL_DELTA_WPARAM (msg->msg.wParam) < 0) ? 4 : 3; 2920
2921 result->kind = WHEEL_EVENT;
2922 result->code = 0;
2921 result->timestamp = msg->msg.time; 2923 result->timestamp = msg->msg.time;
2922 result->modifiers = msg->dwModifiers; 2924
2925 /* A WHEEL_DELTA positive value indicates that the wheel was rotated
2926 forward, away from the user (up); a negative value indicates that
2927 the wheel was rotated backward, toward the user (down). */
2928 delta = GET_WHEEL_DELTA_WPARAM (msg->msg.wParam);
2929
2930 /* The up and down modifiers indicate if the wheel was rotated up or
2931 down based on WHEEL_DELTA value. */
2932 result->modifiers = (msg->dwModifiers
2933 | ((delta < 0 ) ? down_modifier : up_modifier));
2934
2923 p.x = LOWORD (msg->msg.lParam); 2935 p.x = LOWORD (msg->msg.lParam);
2924 p.y = HIWORD (msg->msg.lParam); 2936 p.y = HIWORD (msg->msg.lParam);
2925 ScreenToClient (msg->msg.hwnd, &p); 2937 ScreenToClient (msg->msg.hwnd, &p);
2926 XSETINT (result->x, p.x); 2938 XSETINT (result->x, p.x);
2927 XSETINT (result->y, p.y); 2939 XSETINT (result->y, p.y);
4387 break; 4399 break;
4388 } 4400 }
4389 4401
4390 case WM_MOUSEWHEEL: 4402 case WM_MOUSEWHEEL:
4391 { 4403 {
4392 /* Convert each Windows mouse wheel event in a couple of
4393 Emacs mouse click down/up events. Scrolling the wheel up
4394 is associated to mouse button 4 and scrolling the wheel
4395 down to the mouse button 5. */
4396 int button;
4397 int up;
4398
4399 up = msg.dwModifiers & up_modifier;
4400
4401 if (dpyinfo->grabbed && last_mouse_frame 4404 if (dpyinfo->grabbed && last_mouse_frame
4402 && FRAME_LIVE_P (last_mouse_frame)) 4405 && FRAME_LIVE_P (last_mouse_frame))
4403 f = last_mouse_frame; 4406 f = last_mouse_frame;
4404 else 4407 else
4405 f = x_window_to_frame (dpyinfo, msg.msg.hwnd); 4408 f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
4406 4409
4407 if (f) 4410 if (f)
4408 { 4411 {
4409 Lisp_Object window;
4410 POINT p;
4411 int x, y;
4412
4413 p.x = LOWORD (msg.msg.lParam);
4414 p.y = HIWORD (msg.msg.lParam);
4415 ScreenToClient (msg.msg.hwnd, &p);
4416 x = XFASTINT (p.x);
4417 y = XFASTINT (p.y);
4418
4419 window = window_from_coordinates (f, x, y, 0, 0, 0, 0);
4420
4421 /* Ignore mouse wheel events not in a window. */
4422 if (!WINDOWP(window))
4423 break;
4424 4412
4425 if ((!dpyinfo->w32_focus_frame 4413 if ((!dpyinfo->w32_focus_frame
4426 || f == dpyinfo->w32_focus_frame) 4414 || f == dpyinfo->w32_focus_frame)
4427 && (numchars >= 1)) 4415 && (numchars >= 1))
4428 { 4416 {
4429 if ( !up ) 4417 /* Emit an Emacs wheel-up/down event. */
4430 { 4418 construct_mouse_wheel (bufp, &msg, f);
4431 /* Emit an Emacs mouse down message. */ 4419 bufp++;
4432 msg.dwModifiers |= down_modifier; 4420 count++;
4433 construct_mouse_wheel (bufp, &msg, f); 4421 numchars--;
4434 bufp++;
4435 count++;
4436 numchars--;
4437
4438 /* Push a simulated WM_MOUSEWHEEL up message. */
4439 msg.dwModifiers &= ~down_modifier;
4440 msg.dwModifiers |= up_modifier;
4441 prepend_msg (&msg);
4442 }
4443 else
4444 {
4445 /* Emit an Emacs mouse up message. */
4446 construct_mouse_wheel (bufp, &msg, f);
4447 bufp++;
4448 count++;
4449 numchars--;
4450 }
4451 } 4422 }
4423 /* Ignore any mouse motion that happened before this
4424 event; any subsequent mouse-movement Emacs events
4425 should reflect only motion after the
4426 ButtonPress. */
4427 f->mouse_moved = 0;
4452 } 4428 }
4453 4429 last_mouse_frame = f;
4454 button = (GET_WHEEL_DELTA_WPARAM (msg.msg.wParam) < 0)? 4 : 3; 4430 last_tool_bar_item = -1;
4455
4456 if (up)
4457 {
4458 dpyinfo->grabbed &= ~ (1 << button);
4459 }
4460 else
4461 {
4462 dpyinfo->grabbed |= (1 << button);
4463 last_mouse_frame = f;
4464 /* Ignore any mouse motion that happened
4465 before this event; any subsequent mouse-movement
4466 Emacs events should reflect only motion after
4467 the ButtonPress. */
4468 if (f != 0)
4469 f->mouse_moved = 0;
4470
4471 last_tool_bar_item = -1;
4472 }
4473 } 4431 }
4474 break; 4432 break;
4475 4433
4476 case WM_DROPFILES: 4434 case WM_DROPFILES:
4477 f = x_window_to_frame (dpyinfo, msg.msg.hwnd); 4435 f = x_window_to_frame (dpyinfo, msg.msg.hwnd);