diff options
| author | Juanma Barranquero | 2003-05-26 23:03:17 +0000 |
|---|---|---|
| committer | Juanma Barranquero | 2003-05-26 23:03:17 +0000 |
| commit | 1c64a4a2961e4eeaf577aab866857e60a2f5a0a1 (patch) | |
| tree | e0493b0a71bb6f08af2834f8f51c8b5d9727e1b7 /src | |
| parent | f84b99383bc0723bf41e47c02e212a1f632f31b9 (diff) | |
| download | emacs-1c64a4a2961e4eeaf577aab866857e60a2f5a0a1.tar.gz emacs-1c64a4a2961e4eeaf577aab866857e60a2f5a0a1.zip | |
(construct_mouse_wheel): Result is a MOUSE_CLICK_EVENT. Scrolling down/up the
mouse wheel is respectively mapped to mouse button 4 and 5.
(w32_read_socket): Map w32 WM_MOUSEWHEEL events to Emacs MOUSE_CLICK_EVENT
events. Forward w32 MSH_MOUSEWHEEL events as WM_MOUSEWHEEL events.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 14 | ||||
| -rw-r--r-- | src/w32term.c | 231 |
2 files changed, 162 insertions, 83 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index b2c60e4fe92..31720b50730 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,17 @@ | |||
| 1 | 2003-05-27 David Ponce <david@dponce.com> | ||
| 2 | |||
| 3 | Handle W32 mouse wheel events as mouse click events, like in X. | ||
| 4 | |||
| 5 | * keyboard.c (make_lispy_event) [WINDOWSNT]: Don't handle | ||
| 6 | MOUSE_WHEEL_EVENT anymore. | ||
| 7 | |||
| 8 | * w32term.c (construct_mouse_wheel): Result is a MOUSE_CLICK_EVENT. | ||
| 9 | Scrolling down/up the mouse wheel is respectively mapped to mouse | ||
| 10 | button 4 and 5. | ||
| 11 | (w32_read_socket): Map w32 WM_MOUSEWHEEL events to Emacs | ||
| 12 | MOUSE_CLICK_EVENT events. Forward w32 MSH_MOUSEWHEEL events as | ||
| 13 | WM_MOUSEWHEEL events. | ||
| 14 | |||
| 1 | 2003-05-27 Andreas Schwab <schwab@suse.de> | 15 | 2003-05-27 Andreas Schwab <schwab@suse.de> |
| 2 | 16 | ||
| 3 | * buffer.c (syms_of_buffer) <default-direction-reversed>: Doc fix. | 17 | * buffer.c (syms_of_buffer) <default-direction-reversed>: Doc fix. |
diff --git a/src/w32term.c b/src/w32term.c index 8ee27b8be7e..2900acf7f0a 100644 --- a/src/w32term.c +++ b/src/w32term.c | |||
| @@ -495,7 +495,7 @@ w32_draw_vertical_window_border (w, x, y0, y1) | |||
| 495 | struct frame *f = XFRAME (WINDOW_FRAME (w)); | 495 | struct frame *f = XFRAME (WINDOW_FRAME (w)); |
| 496 | RECT r; | 496 | RECT r; |
| 497 | HDC hdc; | 497 | HDC hdc; |
| 498 | 498 | ||
| 499 | r.left = x; | 499 | r.left = x; |
| 500 | r.right = x + 1; | 500 | r.right = x + 1; |
| 501 | r.top = y0; | 501 | r.top = y0; |
| @@ -2911,8 +2911,8 @@ construct_mouse_wheel (result, msg, f) | |||
| 2911 | struct frame *f; | 2911 | struct frame *f; |
| 2912 | { | 2912 | { |
| 2913 | POINT p; | 2913 | POINT p; |
| 2914 | result->kind = MOUSE_WHEEL_EVENT; | 2914 | result->kind = MOUSE_CLICK_EVENT; |
| 2915 | result->code = (short) HIWORD (msg->msg.wParam); | 2915 | result->code = (GET_WHEEL_DELTA_WPARAM (msg->msg.wParam) < 0) ? 4 : 3; |
| 2916 | result->timestamp = msg->msg.time; | 2916 | result->timestamp = msg->msg.time; |
| 2917 | result->modifiers = msg->dwModifiers; | 2917 | result->modifiers = msg->dwModifiers; |
| 2918 | p.x = LOWORD (msg->msg.lParam); | 2918 | p.x = LOWORD (msg->msg.lParam); |
| @@ -3111,7 +3111,7 @@ glyph_rect (f, x, y, rect) | |||
| 3111 | 3111 | ||
| 3112 | /* x is to the right of the last glyph in the row. */ | 3112 | /* x is to the right of the last glyph in the row. */ |
| 3113 | rect->left = WINDOW_TO_FRAME_PIXEL_X (w, gx); | 3113 | rect->left = WINDOW_TO_FRAME_PIXEL_X (w, gx); |
| 3114 | /* Shouldn't this be a pixel value? | 3114 | /* Shouldn't this be a pixel value? |
| 3115 | WINDOW_RIGHT_EDGE_X (w) seems to be the right value. | 3115 | WINDOW_RIGHT_EDGE_X (w) seems to be the right value. |
| 3116 | ++KFS */ | 3116 | ++KFS */ |
| 3117 | rect->right = WINDOW_RIGHT_EDGE_COL (w); | 3117 | rect->right = WINDOW_RIGHT_EDGE_COL (w); |
| @@ -4382,25 +4382,90 @@ w32_read_socket (sd, bufp, numchars, expected) | |||
| 4382 | break; | 4382 | break; |
| 4383 | } | 4383 | } |
| 4384 | 4384 | ||
| 4385 | case WM_MOUSEWHEEL: | 4385 | case WM_MOUSEWHEEL: |
| 4386 | if (dpyinfo->grabbed && last_mouse_frame | 4386 | { |
| 4387 | && FRAME_LIVE_P (last_mouse_frame)) | 4387 | /* Convert each Windows mouse wheel event in a couple of |
| 4388 | f = last_mouse_frame; | 4388 | Emacs mouse click down/up events. Scrolling the wheel up |
| 4389 | else | 4389 | is associated to mouse button 4 and scrolling the wheel |
| 4390 | f = x_window_to_frame (dpyinfo, msg.msg.hwnd); | 4390 | down to the mouse button 5. */ |
| 4391 | int button; | ||
| 4392 | int up; | ||
| 4391 | 4393 | ||
| 4392 | if (f) | 4394 | up = msg.dwModifiers & up_modifier; |
| 4393 | { | 4395 | |
| 4394 | if ((!dpyinfo->w32_focus_frame | 4396 | if (dpyinfo->grabbed && last_mouse_frame |
| 4395 | || f == dpyinfo->w32_focus_frame) | 4397 | && FRAME_LIVE_P (last_mouse_frame)) |
| 4396 | && (numchars >= 1)) | 4398 | f = last_mouse_frame; |
| 4397 | { | 4399 | else |
| 4398 | construct_mouse_wheel (bufp, &msg, f); | 4400 | f = x_window_to_frame (dpyinfo, msg.msg.hwnd); |
| 4399 | bufp++; | 4401 | |
| 4400 | count++; | 4402 | if (f) |
| 4401 | numchars--; | 4403 | { |
| 4402 | } | 4404 | Lisp_Object window; |
| 4403 | } | 4405 | POINT p; |
| 4406 | int x, y; | ||
| 4407 | |||
| 4408 | p.x = LOWORD (msg.msg.lParam); | ||
| 4409 | p.y = HIWORD (msg.msg.lParam); | ||
| 4410 | ScreenToClient (msg.msg.hwnd, &p); | ||
| 4411 | x = XFASTINT (p.x); | ||
| 4412 | y = XFASTINT (p.y); | ||
| 4413 | |||
| 4414 | window = window_from_coordinates (f, x, y, 0, 0, 0, 0); | ||
| 4415 | |||
| 4416 | /* Ignore mouse wheel events not in a window. */ | ||
| 4417 | if (!WINDOWP(window)) | ||
| 4418 | break; | ||
| 4419 | |||
| 4420 | if ((!dpyinfo->w32_focus_frame | ||
| 4421 | || f == dpyinfo->w32_focus_frame) | ||
| 4422 | && (numchars >= 1)) | ||
| 4423 | { | ||
| 4424 | if ( !up ) | ||
| 4425 | { | ||
| 4426 | /* Emit an Emacs mouse down message. */ | ||
| 4427 | msg.dwModifiers |= down_modifier; | ||
| 4428 | construct_mouse_wheel (bufp, &msg, f); | ||
| 4429 | bufp++; | ||
| 4430 | count++; | ||
| 4431 | numchars--; | ||
| 4432 | |||
| 4433 | /* Push a simulated WM_MOUSEWHEEL up message. */ | ||
| 4434 | msg.dwModifiers &= ~down_modifier; | ||
| 4435 | msg.dwModifiers |= up_modifier; | ||
| 4436 | prepend_msg (&msg); | ||
| 4437 | } | ||
| 4438 | else | ||
| 4439 | { | ||
| 4440 | /* Emit an Emacs mouse up message. */ | ||
| 4441 | construct_mouse_wheel (bufp, &msg, f); | ||
| 4442 | bufp++; | ||
| 4443 | count++; | ||
| 4444 | numchars--; | ||
| 4445 | } | ||
| 4446 | } | ||
| 4447 | } | ||
| 4448 | |||
| 4449 | button = ( GET_WHEEL_DELTA_WPARAM (msg.msg.wParam) < 0 )? 4 : 3; | ||
| 4450 | |||
| 4451 | if (up) | ||
| 4452 | { | ||
| 4453 | dpyinfo->grabbed &= ~ (1 << button); | ||
| 4454 | } | ||
| 4455 | else | ||
| 4456 | { | ||
| 4457 | dpyinfo->grabbed |= (1 << button); | ||
| 4458 | last_mouse_frame = f; | ||
| 4459 | /* Ignore any mouse motion that happened | ||
| 4460 | before this event; any subsequent mouse-movement | ||
| 4461 | Emacs events should reflect only motion after | ||
| 4462 | the ButtonPress. */ | ||
| 4463 | if (f != 0) | ||
| 4464 | f->mouse_moved = 0; | ||
| 4465 | |||
| 4466 | last_tool_bar_item = -1; | ||
| 4467 | } | ||
| 4468 | } | ||
| 4404 | break; | 4469 | break; |
| 4405 | 4470 | ||
| 4406 | case WM_DROPFILES: | 4471 | case WM_DROPFILES: |
| @@ -4624,12 +4689,12 @@ w32_read_socket (sd, bufp, numchars, expected) | |||
| 4624 | case WM_SETFOCUS: | 4689 | case WM_SETFOCUS: |
| 4625 | /* TODO: Port this change: | 4690 | /* TODO: Port this change: |
| 4626 | 2002-06-28 Jan D. <jan.h.d@swipnet.se> | 4691 | 2002-06-28 Jan D. <jan.h.d@swipnet.se> |
| 4627 | * xterm.h (struct x_output): Add focus_state. | 4692 | * xterm.h (struct x_output): Add focus_state. |
| 4628 | * xterm.c (x_focus_changed): New function. | 4693 | * xterm.c (x_focus_changed): New function. |
| 4629 | (x_detect_focus_change): New function. | 4694 | (x_detect_focus_change): New function. |
| 4630 | (XTread_socket): Call x_detect_focus_change for FocusIn/FocusOut | 4695 | (XTread_socket): Call x_detect_focus_change for FocusIn/FocusOut |
| 4631 | EnterNotify and LeaveNotify to track X focus changes. | 4696 | EnterNotify and LeaveNotify to track X focus changes. |
| 4632 | */ | 4697 | */ |
| 4633 | f = x_any_window_to_frame (dpyinfo, msg.msg.hwnd); | 4698 | f = x_any_window_to_frame (dpyinfo, msg.msg.hwnd); |
| 4634 | 4699 | ||
| 4635 | dpyinfo->w32_focus_event_frame = f; | 4700 | dpyinfo->w32_focus_event_frame = f; |
| @@ -4791,65 +4856,65 @@ w32_read_socket (sd, bufp, numchars, expected) | |||
| 4791 | Lisp_Object tail, frame; | 4856 | Lisp_Object tail, frame; |
| 4792 | 4857 | ||
| 4793 | FOR_EACH_FRAME (tail, frame) | 4858 | FOR_EACH_FRAME (tail, frame) |
| 4794 | { | 4859 | { |
| 4795 | FRAME_PTR f = XFRAME (frame); | 4860 | FRAME_PTR f = XFRAME (frame); |
| 4796 | /* The tooltip has been drawn already. Avoid the | 4861 | /* The tooltip has been drawn already. Avoid the |
| 4797 | SET_FRAME_GARBAGED below. */ | 4862 | SET_FRAME_GARBAGED below. */ |
| 4798 | if (EQ (frame, tip_frame)) | 4863 | if (EQ (frame, tip_frame)) |
| 4799 | continue; | 4864 | continue; |
| 4800 | 4865 | ||
| 4801 | /* Check "visible" frames and mark each as obscured or not. | 4866 | /* Check "visible" frames and mark each as obscured or not. |
| 4802 | Note that async_visible is nonzero for unobscured and | 4867 | Note that async_visible is nonzero for unobscured and |
| 4803 | obscured frames, but zero for hidden and iconified frames. */ | 4868 | obscured frames, but zero for hidden and iconified frames. */ |
| 4804 | if (FRAME_W32_P (f) && f->async_visible) | 4869 | if (FRAME_W32_P (f) && f->async_visible) |
| 4805 | { | 4870 | { |
| 4806 | RECT clipbox; | 4871 | RECT clipbox; |
| 4807 | HDC hdc; | 4872 | HDC hdc; |
| 4808 | 4873 | ||
| 4809 | enter_crit (); | 4874 | enter_crit (); |
| 4810 | /* Query clipping rectangle for the entire window area | 4875 | /* Query clipping rectangle for the entire window area |
| 4811 | (GetWindowDC), not just the client portion (GetDC). | 4876 | (GetWindowDC), not just the client portion (GetDC). |
| 4812 | Otherwise, the scrollbars and menubar aren't counted as | 4877 | Otherwise, the scrollbars and menubar aren't counted as |
| 4813 | part of the visible area of the frame, and we may think | 4878 | part of the visible area of the frame, and we may think |
| 4814 | the frame is obscured when really a scrollbar is still | 4879 | the frame is obscured when really a scrollbar is still |
| 4815 | visible and gets WM_PAINT messages above. */ | 4880 | visible and gets WM_PAINT messages above. */ |
| 4816 | hdc = GetWindowDC (FRAME_W32_WINDOW (f)); | 4881 | hdc = GetWindowDC (FRAME_W32_WINDOW (f)); |
| 4817 | GetClipBox (hdc, &clipbox); | 4882 | GetClipBox (hdc, &clipbox); |
| 4818 | ReleaseDC (FRAME_W32_WINDOW (f), hdc); | 4883 | ReleaseDC (FRAME_W32_WINDOW (f), hdc); |
| 4819 | leave_crit (); | 4884 | leave_crit (); |
| 4820 | 4885 | ||
| 4821 | if (clipbox.right == clipbox.left | 4886 | if (clipbox.right == clipbox.left |
| 4822 | || clipbox.bottom == clipbox.top) | 4887 | || clipbox.bottom == clipbox.top) |
| 4823 | { | 4888 | { |
| 4824 | /* Frame has become completely obscured so mark as | 4889 | /* Frame has become completely obscured so mark as |
| 4825 | such (we do this by setting async_visible to 2 so | 4890 | such (we do this by setting async_visible to 2 so |
| 4826 | that FRAME_VISIBLE_P is still true, but redisplay | 4891 | that FRAME_VISIBLE_P is still true, but redisplay |
| 4827 | will skip it). */ | 4892 | will skip it). */ |
| 4828 | f->async_visible = 2; | 4893 | f->async_visible = 2; |
| 4829 | 4894 | ||
| 4830 | if (!FRAME_OBSCURED_P (f)) | 4895 | if (!FRAME_OBSCURED_P (f)) |
| 4831 | { | 4896 | { |
| 4832 | DebPrint (("frame %p (%s) obscured\n", f, | 4897 | DebPrint (("frame %p (%s) obscured\n", f, |
| 4833 | SDATA (f->name))); | 4898 | SDATA (f->name))); |
| 4834 | } | 4899 | } |
| 4835 | } | 4900 | } |
| 4836 | else | 4901 | else |
| 4837 | { | 4902 | { |
| 4838 | /* Frame is not obscured, so mark it as such. */ | 4903 | /* Frame is not obscured, so mark it as such. */ |
| 4839 | f->async_visible = 1; | 4904 | f->async_visible = 1; |
| 4840 | 4905 | ||
| 4841 | if (FRAME_OBSCURED_P (f)) | 4906 | if (FRAME_OBSCURED_P (f)) |
| 4842 | { | 4907 | { |
| 4843 | SET_FRAME_GARBAGED (f); | 4908 | SET_FRAME_GARBAGED (f); |
| 4844 | DebPrint (("obscured frame %p (%s) found to be visible\n", f, | 4909 | DebPrint (("obscured frame %p (%s) found to be visible\n", f, |
| 4845 | SDATA (f->name))); | 4910 | SDATA (f->name))); |
| 4846 | 4911 | ||
| 4847 | /* Force a redisplay sooner or later. */ | 4912 | /* Force a redisplay sooner or later. */ |
| 4848 | record_asynch_buffer_change (); | 4913 | record_asynch_buffer_change (); |
| 4849 | } | 4914 | } |
| 4850 | } | 4915 | } |
| 4851 | } | 4916 | } |
| 4852 | } | 4917 | } |
| 4853 | } | 4918 | } |
| 4854 | 4919 | ||
| 4855 | UNBLOCK_INPUT; | 4920 | UNBLOCK_INPUT; |
| @@ -6223,12 +6288,12 @@ w32_term_init (display_name, xrm_option, resource_name) | |||
| 6223 | unsigned char *bits = fringe_bitmaps[i].bits; | 6288 | unsigned char *bits = fringe_bitmaps[i].bits; |
| 6224 | for (j = 0; j < h; j++) | 6289 | for (j = 0; j < h; j++) |
| 6225 | { | 6290 | { |
| 6226 | static unsigned char swap_nibble[16] | 6291 | static unsigned char swap_nibble[16] |
| 6227 | = { 0x0, 0x8, 0x4, 0xc, /* 0000 1000 0100 1100 */ | 6292 | = { 0x0, 0x8, 0x4, 0xc, /* 0000 1000 0100 1100 */ |
| 6228 | 0x2, 0xa, 0x6, 0xe, /* 0010 1010 0110 1110 */ | 6293 | 0x2, 0xa, 0x6, 0xe, /* 0010 1010 0110 1110 */ |
| 6229 | 0x1, 0x9, 0x5, 0xd, /* 0001 1001 0101 1101 */ | 6294 | 0x1, 0x9, 0x5, 0xd, /* 0001 1001 0101 1101 */ |
| 6230 | 0x3, 0xb, 0x7, 0xf }; /* 0011 1011 0111 1111 */ | 6295 | 0x3, 0xb, 0x7, 0xf }; /* 0011 1011 0111 1111 */ |
| 6231 | 6296 | ||
| 6232 | unsigned char b = *bits++; | 6297 | unsigned char b = *bits++; |
| 6233 | *wb++ = (unsigned short)((swap_nibble[b & 0xf]<<4) | 6298 | *wb++ = (unsigned short)((swap_nibble[b & 0xf]<<4) |
| 6234 | | (swap_nibble[(b>>4) & 0xf])); | 6299 | | (swap_nibble[(b>>4) & 0xf])); |