Mercurial > emacs
comparison src/w32term.c @ 51258:a35e5665c742
(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.
author | Juanma Barranquero <lekktu@gmail.com> |
---|---|
date | Mon, 26 May 2003 23:01:05 +0000 |
parents | 082b768216a0 |
children | 0e4f36767c58 |
comparison
equal
deleted
inserted
replaced
51257:730bcd34a440 | 51258:a35e5665c742 |
---|---|
493 int x, y0, y1; | 493 int x, y0, y1; |
494 { | 494 { |
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; |
502 r.bottom = y1; | 502 r.bottom = y1; |
503 | 503 |
2909 struct input_event *result; | 2909 struct input_event *result; |
2910 W32Msg *msg; | 2910 W32Msg *msg; |
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); |
2919 p.y = HIWORD (msg->msg.lParam); | 2919 p.y = HIWORD (msg->msg.lParam); |
2920 ScreenToClient (msg->msg.hwnd, &p); | 2920 ScreenToClient (msg->msg.hwnd, &p); |
3109 return 1; | 3109 return 1; |
3110 } | 3110 } |
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); |
3118 return 1; | 3118 return 1; |
3119 } | 3119 } |
4380 last_tool_bar_item = -1; | 4380 last_tool_bar_item = -1; |
4381 } | 4381 } |
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 | 4391 int button; |
4392 if (f) | 4392 int up; |
4393 { | 4393 |
4394 if ((!dpyinfo->w32_focus_frame | 4394 up = msg.dwModifiers & up_modifier; |
4395 || f == dpyinfo->w32_focus_frame) | 4395 |
4396 && (numchars >= 1)) | 4396 if (dpyinfo->grabbed && last_mouse_frame |
4397 { | 4397 && FRAME_LIVE_P (last_mouse_frame)) |
4398 construct_mouse_wheel (bufp, &msg, f); | 4398 f = last_mouse_frame; |
4399 bufp++; | 4399 else |
4400 count++; | 4400 f = x_window_to_frame (dpyinfo, msg.msg.hwnd); |
4401 numchars--; | 4401 |
4402 } | 4402 if (f) |
4403 } | 4403 { |
4404 Lisp_Object window; | |
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: |
4407 f = x_window_to_frame (dpyinfo, msg.msg.hwnd); | 4472 f = x_window_to_frame (dpyinfo, msg.msg.hwnd); |
4408 | 4473 |
4622 break; | 4687 break; |
4623 | 4688 |
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; |
4636 | 4701 |
4637 if (f) | 4702 if (f) |
4789 if (count > 0 || check_visibility) | 4854 if (count > 0 || check_visibility) |
4790 { | 4855 { |
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; |
4856 return count; | 4921 return count; |
4857 } | 4922 } |
6221 = (unsigned short *)alloca (h * sizeof (unsigned short)); | 6286 = (unsigned short *)alloca (h * sizeof (unsigned short)); |
6222 unsigned short *wb = w32bits; | 6287 unsigned short *wb = w32bits; |
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])); |
6235 } | 6300 } |
6236 fringe_bmp[i] = CreateBitmap (wd, h, 1, 1, w32bits); | 6301 fringe_bmp[i] = CreateBitmap (wd, h, 1, 1, w32bits); |