diff options
| author | Jason Rumney | 2003-06-01 21:38:37 +0000 |
|---|---|---|
| committer | Jason Rumney | 2003-06-01 21:38:37 +0000 |
| commit | 637ad49d45388b4b7e87be14619a247365a0e5b8 (patch) | |
| tree | cb2f075faa647e48672036b48b692be40487b6c2 /src | |
| parent | a153acb7d6cb5f8c04d7ba67e32f22c0e31efc18 (diff) | |
| download | emacs-637ad49d45388b4b7e87be14619a247365a0e5b8.tar.gz emacs-637ad49d45388b4b7e87be14619a247365a0e5b8.zip | |
(construct_mouse_wheel): Construct WHEEL_EVENT.
(w32_read_socket): Map w32 WM_MOUSEWHEEL events to Emacs
WHEEL_EVENT events.
Diffstat (limited to 'src')
| -rw-r--r-- | src/w32term.c | 96 |
1 files changed, 27 insertions, 69 deletions
diff --git a/src/w32term.c b/src/w32term.c index 0087a00b56d..539df459402 100644 --- a/src/w32term.c +++ b/src/w32term.c | |||
| @@ -2916,10 +2916,22 @@ construct_mouse_wheel (result, msg, f) | |||
| 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); |
| @@ -4389,15 +4401,6 @@ w32_read_socket (sd, bufp, numchars, expected) | |||
| 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; |
| @@ -4406,70 +4409,25 @@ w32_read_socket (sd, bufp, numchars, expected) | |||
| 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 | ||