diff options
| author | Dmitry Antipov | 2013-09-19 11:48:53 +0400 |
|---|---|---|
| committer | Dmitry Antipov | 2013-09-19 11:48:53 +0400 |
| commit | ced135ebdbfb0eea719ce165a454e7ff0b681e88 (patch) | |
| tree | 17311f84267e23afbd4d1131ea2fe1fa14aa6f55 /src/w32term.c | |
| parent | f75447737926fd8c898b9e0b77f581f4993a52f1 (diff) | |
| download | emacs-ced135ebdbfb0eea719ce165a454e7ff0b681e88.tar.gz emacs-ced135ebdbfb0eea719ce165a454e7ff0b681e88.zip | |
* xterm.h (struct x_display_info): New members last_mouse_glyph_frame,
last_mouse_scroll_bar, last_mouse_glyph and last_mouse_movement_time,
going to replace static variables below. Adjust comments.
* xterm.c (last_mouse_glyph, last_mouse_glyph_frame)
(last_mouse_scroll_bar, last_mouse_movement_time): Remove.
(note_mouse_movement, XTmouse_position, x_scroll_bar_note_movement)
(x_scroll_bar_report_motion, handle_one_xevent, syms_of_xterm):
Related users changed.
* w32term.h (struct w32_display_info): New members last_mouse_glyph_frame,
last_mouse_scroll_bar, last_mouse_scroll_bar_pos, last_mouse_glyph and
last_mouse_movement_time, going to replace static variables below.
Adjust comments.
* w32term.c (last_mouse_glyph_frame, last_mouse_scroll_bar)
(last_mouse_scroll_bar_pos, last_mouse_glyph, last_mouse_movement_time):
Remove.
(note_mouse_movement, w32_mouse_position, w32_scroll_bar_handle_click)
(x_scroll_bar_report_motion, syms_of_w32term): Related users changed.
* nsterm.h (struct ns_display_info): New members last_mouse_glyph,
last_mouse_movement_time and last_mouse_scroll_bar, going to replace
static variables below.
* nsterm.m (last_mouse_glyph, last_mouse_movement_time)
(last_mouse_scroll_bar): Remove.
(note_mouse_movement, ns_mouse_position, mouseMoved, mouseEntered)
(mouseExited): Related users changed.
Diffstat (limited to 'src/w32term.c')
| -rw-r--r-- | src/w32term.c | 77 |
1 files changed, 25 insertions, 52 deletions
diff --git a/src/w32term.c b/src/w32term.c index 805ee59ea4f..3377a8911e2 100644 --- a/src/w32term.c +++ b/src/w32term.c | |||
| @@ -171,31 +171,6 @@ int last_scroll_bar_drag_pos; | |||
| 171 | /* Keyboard code page - may be changed by language-change events. */ | 171 | /* Keyboard code page - may be changed by language-change events. */ |
| 172 | int w32_keyboard_codepage; | 172 | int w32_keyboard_codepage; |
| 173 | 173 | ||
| 174 | /* Mouse movement. */ | ||
| 175 | |||
| 176 | /* Where the mouse was last time we reported a mouse event. */ | ||
| 177 | static RECT last_mouse_glyph; | ||
| 178 | static struct frame *last_mouse_glyph_frame; | ||
| 179 | |||
| 180 | /* The scroll bar in which the last motion event occurred. | ||
| 181 | |||
| 182 | If the last motion event occurred in a scroll bar, we set this | ||
| 183 | so w32_mouse_position can know whether to report a scroll bar motion or | ||
| 184 | an ordinary motion. | ||
| 185 | |||
| 186 | If the last motion event didn't occur in a scroll bar, we set this | ||
| 187 | to Qnil, to tell w32_mouse_position to return an ordinary motion event. */ | ||
| 188 | static Lisp_Object last_mouse_scroll_bar; | ||
| 189 | static int last_mouse_scroll_bar_pos; | ||
| 190 | |||
| 191 | /* This is a hack. We would really prefer that w32_mouse_position would | ||
| 192 | return the time associated with the position it returns, but there | ||
| 193 | doesn't seem to be any way to wrest the time-stamp from the server | ||
| 194 | along with the position query. So, we just keep track of the time | ||
| 195 | of the last movement we received, and return that in hopes that | ||
| 196 | it's somewhat accurate. */ | ||
| 197 | static Time last_mouse_movement_time; | ||
| 198 | |||
| 199 | /* Incremented by w32_read_socket whenever it really tries to read | 174 | /* Incremented by w32_read_socket whenever it really tries to read |
| 200 | events. */ | 175 | events. */ |
| 201 | static int volatile input_signal_count; | 176 | static int volatile input_signal_count; |
| @@ -3310,12 +3285,13 @@ note_mouse_movement (struct frame *frame, MSG *msg) | |||
| 3310 | struct w32_display_info *dpyinfo; | 3285 | struct w32_display_info *dpyinfo; |
| 3311 | int mouse_x = LOWORD (msg->lParam); | 3286 | int mouse_x = LOWORD (msg->lParam); |
| 3312 | int mouse_y = HIWORD (msg->lParam); | 3287 | int mouse_y = HIWORD (msg->lParam); |
| 3288 | RECT *r; | ||
| 3313 | 3289 | ||
| 3314 | if (!FRAME_X_OUTPUT (frame)) | 3290 | if (!FRAME_X_OUTPUT (frame)) |
| 3315 | return 0; | 3291 | return 0; |
| 3316 | 3292 | ||
| 3317 | dpyinfo = FRAME_DISPLAY_INFO (frame); | 3293 | dpyinfo = FRAME_DISPLAY_INFO (frame); |
| 3318 | last_mouse_movement_time = msg->time; | 3294 | dpyinfo->last_mouse_movement_time = msg->time; |
| 3319 | dpyinfo->last_mouse_motion_frame = frame; | 3295 | dpyinfo->last_mouse_motion_frame = frame; |
| 3320 | dpyinfo->last_mouse_motion_x = mouse_x; | 3296 | dpyinfo->last_mouse_motion_x = mouse_x; |
| 3321 | dpyinfo->last_mouse_motion_y = mouse_y; | 3297 | dpyinfo->last_mouse_motion_y = mouse_y; |
| @@ -3323,28 +3299,27 @@ note_mouse_movement (struct frame *frame, MSG *msg) | |||
| 3323 | if (msg->hwnd != FRAME_W32_WINDOW (frame)) | 3299 | if (msg->hwnd != FRAME_W32_WINDOW (frame)) |
| 3324 | { | 3300 | { |
| 3325 | frame->mouse_moved = 1; | 3301 | frame->mouse_moved = 1; |
| 3326 | last_mouse_scroll_bar = Qnil; | 3302 | dpyinfo->last_mouse_scroll_bar = NULL; |
| 3327 | note_mouse_highlight (frame, -1, -1); | 3303 | note_mouse_highlight (frame, -1, -1); |
| 3328 | last_mouse_glyph_frame = 0; | 3304 | dpyinfo->last_mouse_glyph_frame = NULL; |
| 3329 | return 1; | 3305 | return 1; |
| 3330 | } | 3306 | } |
| 3331 | 3307 | ||
| 3332 | /* Has the mouse moved off the glyph it was on at the last sighting? */ | 3308 | /* Has the mouse moved off the glyph it was on at the last sighting? */ |
| 3333 | if (frame != last_mouse_glyph_frame | 3309 | r = &dpyinfo->last_mouse_glyph; |
| 3334 | || mouse_x < last_mouse_glyph.left | 3310 | if (frame != dpyinfo->last_mouse_glyph_frame |
| 3335 | || mouse_x >= last_mouse_glyph.right | 3311 | || mouse_x < r->left || mouse_x >= r->right |
| 3336 | || mouse_y < last_mouse_glyph.top | 3312 | || mouse_y < r->top || mouse_y >= r->bottom) |
| 3337 | || mouse_y >= last_mouse_glyph.bottom) | ||
| 3338 | { | 3313 | { |
| 3339 | frame->mouse_moved = 1; | 3314 | frame->mouse_moved = 1; |
| 3340 | last_mouse_scroll_bar = Qnil; | 3315 | dpyinfo->last_mouse_scroll_bar = NULL; |
| 3341 | note_mouse_highlight (frame, mouse_x, mouse_y); | 3316 | note_mouse_highlight (frame, mouse_x, mouse_y); |
| 3342 | /* Remember the mouse position here, as w32_mouse_position only | 3317 | /* Remember the mouse position here, as w32_mouse_position only |
| 3343 | gets called when mouse tracking is enabled but we also need | 3318 | gets called when mouse tracking is enabled but we also need |
| 3344 | to keep track of the mouse for help_echo and highlighting at | 3319 | to keep track of the mouse for help_echo and highlighting at |
| 3345 | other times. */ | 3320 | other times. */ |
| 3346 | remember_mouse_glyph (frame, mouse_x, mouse_y, &last_mouse_glyph); | 3321 | remember_mouse_glyph (frame, mouse_x, mouse_y, r); |
| 3347 | last_mouse_glyph_frame = frame; | 3322 | dpyinfo->last_mouse_glyph_frame = frame; |
| 3348 | return 1; | 3323 | return 1; |
| 3349 | } | 3324 | } |
| 3350 | 3325 | ||
| @@ -3398,7 +3373,7 @@ w32_mouse_position (struct frame **fp, int insist, Lisp_Object *bar_window, | |||
| 3398 | 3373 | ||
| 3399 | block_input (); | 3374 | block_input (); |
| 3400 | 3375 | ||
| 3401 | if (! NILP (last_mouse_scroll_bar) && insist == 0) | 3376 | if (dpyinfo->last_mouse_scroll_bar && insist == 0) |
| 3402 | x_scroll_bar_report_motion (fp, bar_window, part, x, y, time); | 3377 | x_scroll_bar_report_motion (fp, bar_window, part, x, y, time); |
| 3403 | else | 3378 | else |
| 3404 | { | 3379 | { |
| @@ -3410,7 +3385,7 @@ w32_mouse_position (struct frame **fp, int insist, Lisp_Object *bar_window, | |||
| 3410 | FOR_EACH_FRAME (tail, frame) | 3385 | FOR_EACH_FRAME (tail, frame) |
| 3411 | XFRAME (frame)->mouse_moved = 0; | 3386 | XFRAME (frame)->mouse_moved = 0; |
| 3412 | 3387 | ||
| 3413 | last_mouse_scroll_bar = Qnil; | 3388 | dpyinfo->last_mouse_scroll_bar = NULL; |
| 3414 | 3389 | ||
| 3415 | GetCursorPos (&pt); | 3390 | GetCursorPos (&pt); |
| 3416 | 3391 | ||
| @@ -3448,16 +3423,17 @@ w32_mouse_position (struct frame **fp, int insist, Lisp_Object *bar_window, | |||
| 3448 | on it, i.e. into the same rectangles that matrices on | 3423 | on it, i.e. into the same rectangles that matrices on |
| 3449 | the frame are divided into. */ | 3424 | the frame are divided into. */ |
| 3450 | 3425 | ||
| 3426 | dpyinfo = FRAME_DISPLAY_INFO (f1); | ||
| 3451 | ScreenToClient (FRAME_W32_WINDOW (f1), &pt); | 3427 | ScreenToClient (FRAME_W32_WINDOW (f1), &pt); |
| 3452 | remember_mouse_glyph (f1, pt.x, pt.y, &last_mouse_glyph); | 3428 | remember_mouse_glyph (f1, pt.x, pt.y, &dpyinfo->last_mouse_glyph); |
| 3453 | last_mouse_glyph_frame = f1; | 3429 | dpyinfo->last_mouse_glyph_frame = f1; |
| 3454 | 3430 | ||
| 3455 | *bar_window = Qnil; | 3431 | *bar_window = Qnil; |
| 3456 | *part = 0; | 3432 | *part = 0; |
| 3457 | *fp = f1; | 3433 | *fp = f1; |
| 3458 | XSETINT (*x, pt.x); | 3434 | XSETINT (*x, pt.x); |
| 3459 | XSETINT (*y, pt.y); | 3435 | XSETINT (*y, pt.y); |
| 3460 | *time = last_mouse_movement_time; | 3436 | *time = dpyinfo->last_mouse_movement_time; |
| 3461 | } | 3437 | } |
| 3462 | } | 3438 | } |
| 3463 | } | 3439 | } |
| @@ -4005,6 +3981,7 @@ w32_scroll_bar_handle_click (struct scroll_bar *bar, W32Msg *msg, | |||
| 4005 | 3981 | ||
| 4006 | { | 3982 | { |
| 4007 | int top_range = VERTICAL_SCROLL_BAR_TOP_RANGE (f, XINT (bar->height)); | 3983 | int top_range = VERTICAL_SCROLL_BAR_TOP_RANGE (f, XINT (bar->height)); |
| 3984 | struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window))); | ||
| 4008 | int y; | 3985 | int y; |
| 4009 | int dragging = !NILP (bar->dragging); | 3986 | int dragging = !NILP (bar->dragging); |
| 4010 | SCROLLINFO si; | 3987 | SCROLLINFO si; |
| @@ -4016,9 +3993,7 @@ w32_scroll_bar_handle_click (struct scroll_bar *bar, W32Msg *msg, | |||
| 4016 | y = si.nPos; | 3993 | y = si.nPos; |
| 4017 | 3994 | ||
| 4018 | bar->dragging = Qnil; | 3995 | bar->dragging = Qnil; |
| 4019 | 3996 | FRAME_DISPLAY_INFO (f)->last_mouse_scroll_bar_pos = msg->msg.wParam; | |
| 4020 | |||
| 4021 | last_mouse_scroll_bar_pos = msg->msg.wParam; | ||
| 4022 | 3997 | ||
| 4023 | switch (LOWORD (msg->msg.wParam)) | 3998 | switch (LOWORD (msg->msg.wParam)) |
| 4024 | { | 3999 | { |
| @@ -4101,7 +4076,8 @@ x_scroll_bar_report_motion (struct frame **fp, Lisp_Object *bar_window, | |||
| 4101 | Lisp_Object *x, Lisp_Object *y, | 4076 | Lisp_Object *x, Lisp_Object *y, |
| 4102 | unsigned long *time) | 4077 | unsigned long *time) |
| 4103 | { | 4078 | { |
| 4104 | struct scroll_bar *bar = XSCROLL_BAR (last_mouse_scroll_bar); | 4079 | struct w32_display_info *dpyinfo = FRAME_DISPLAY_INFO (*fp); |
| 4080 | struct scroll_bar *bar = dpyinfo->last_mouse_scroll_bar; | ||
| 4105 | Window w = SCROLL_BAR_W32_WINDOW (bar); | 4081 | Window w = SCROLL_BAR_W32_WINDOW (bar); |
| 4106 | struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window))); | 4082 | struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window))); |
| 4107 | int pos; | 4083 | int pos; |
| @@ -4120,13 +4096,13 @@ x_scroll_bar_report_motion (struct frame **fp, Lisp_Object *bar_window, | |||
| 4120 | pos = si.nPos; | 4096 | pos = si.nPos; |
| 4121 | top_range = si.nMax - si.nPage + 1; | 4097 | top_range = si.nMax - si.nPage + 1; |
| 4122 | 4098 | ||
| 4123 | switch (LOWORD (last_mouse_scroll_bar_pos)) | 4099 | switch (LOWORD (dpyinfo->last_mouse_scroll_bar_pos)) |
| 4124 | { | 4100 | { |
| 4125 | case SB_THUMBPOSITION: | 4101 | case SB_THUMBPOSITION: |
| 4126 | case SB_THUMBTRACK: | 4102 | case SB_THUMBTRACK: |
| 4127 | *part = scroll_bar_handle; | 4103 | *part = scroll_bar_handle; |
| 4128 | if (VERTICAL_SCROLL_BAR_TOP_RANGE (f, XINT (bar->height)) <= 0xffff) | 4104 | if (VERTICAL_SCROLL_BAR_TOP_RANGE (f, XINT (bar->height)) <= 0xffff) |
| 4129 | pos = HIWORD (last_mouse_scroll_bar_pos); | 4105 | pos = HIWORD (dpyinfo->last_mouse_scroll_bar_pos); |
| 4130 | break; | 4106 | break; |
| 4131 | case SB_LINEDOWN: | 4107 | case SB_LINEDOWN: |
| 4132 | *part = scroll_bar_handle; | 4108 | *part = scroll_bar_handle; |
| @@ -4141,9 +4117,9 @@ x_scroll_bar_report_motion (struct frame **fp, Lisp_Object *bar_window, | |||
| 4141 | XSETINT (*y, top_range); | 4117 | XSETINT (*y, top_range); |
| 4142 | 4118 | ||
| 4143 | f->mouse_moved = 0; | 4119 | f->mouse_moved = 0; |
| 4144 | last_mouse_scroll_bar = Qnil; | 4120 | dpyinfo->last_mouse_scroll_bar = NULL; |
| 4145 | 4121 | ||
| 4146 | *time = last_mouse_movement_time; | 4122 | *time = dpyinfo->last_mouse_movement_time; |
| 4147 | 4123 | ||
| 4148 | unblock_input (); | 4124 | unblock_input (); |
| 4149 | } | 4125 | } |
| @@ -6553,9 +6529,6 @@ syms_of_w32term (void) | |||
| 6553 | staticpro (&w32_display_name_list); | 6529 | staticpro (&w32_display_name_list); |
| 6554 | w32_display_name_list = Qnil; | 6530 | w32_display_name_list = Qnil; |
| 6555 | 6531 | ||
| 6556 | staticpro (&last_mouse_scroll_bar); | ||
| 6557 | last_mouse_scroll_bar = Qnil; | ||
| 6558 | |||
| 6559 | DEFSYM (Qvendor_specific_keysyms, "vendor-specific-keysyms"); | 6532 | DEFSYM (Qvendor_specific_keysyms, "vendor-specific-keysyms"); |
| 6560 | 6533 | ||
| 6561 | DEFSYM (Qadded, "added"); | 6534 | DEFSYM (Qadded, "added"); |