aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKim F. Storm2005-10-11 22:36:35 +0000
committerKim F. Storm2005-10-11 22:36:35 +0000
commit1bb92ecaf315a4327bbdd9a98f0b9504d6ede91f (patch)
tree842216a6f5488c67782762d577909c272c18d840 /src
parente2570d37b26c728ac4b5d90c7f6e362b880ba243 (diff)
downloademacs-1bb92ecaf315a4327bbdd9a98f0b9504d6ede91f.tar.gz
emacs-1bb92ecaf315a4327bbdd9a98f0b9504d6ede91f.zip
(note_mouse_movement): Fix last_mouse_glyph check.
(glyph_rect, remember_mouse_glyph): Remove w32 specific versions. (note_mouse_movement, w32_mouse_position): Use generic remember_mouse_glyph, add last_mouse_glyph arg.
Diffstat (limited to 'src')
-rw-r--r--src/w32term.c114
1 files changed, 4 insertions, 110 deletions
diff --git a/src/w32term.c b/src/w32term.c
index 7e352bfd50d..96d26344b53 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -3204,8 +3204,6 @@ construct_drag_n_drop (result, msg, f)
3204static MSG last_mouse_motion_event; 3204static MSG last_mouse_motion_event;
3205static Lisp_Object last_mouse_motion_frame; 3205static Lisp_Object last_mouse_motion_frame;
3206 3206
3207static void remember_mouse_glyph P_ ((struct frame *, int, int));
3208
3209static void 3207static void
3210note_mouse_movement (frame, msg) 3208note_mouse_movement (frame, msg)
3211 FRAME_PTR frame; 3209 FRAME_PTR frame;
@@ -3227,9 +3225,9 @@ note_mouse_movement (frame, msg)
3227 3225
3228 /* Has the mouse moved off the glyph it was on at the last sighting? */ 3226 /* Has the mouse moved off the glyph it was on at the last sighting? */
3229 else if (mouse_x < last_mouse_glyph.left 3227 else if (mouse_x < last_mouse_glyph.left
3230 || mouse_x > last_mouse_glyph.right 3228 || mouse_x >= last_mouse_glyph.right
3231 || mouse_y < last_mouse_glyph.top 3229 || mouse_y < last_mouse_glyph.top
3232 || mouse_y > last_mouse_glyph.bottom) 3230 || mouse_y >= last_mouse_glyph.bottom)
3233 { 3231 {
3234 frame->mouse_moved = 1; 3232 frame->mouse_moved = 1;
3235 last_mouse_scroll_bar = Qnil; 3233 last_mouse_scroll_bar = Qnil;
@@ -3238,7 +3236,7 @@ note_mouse_movement (frame, msg)
3238 gets called when mouse tracking is enabled but we also need 3236 gets called when mouse tracking is enabled but we also need
3239 to keep track of the mouse for help_echo and highlighting at 3237 to keep track of the mouse for help_echo and highlighting at
3240 other times. */ 3238 other times. */
3241 remember_mouse_glyph (frame, mouse_x, mouse_y); 3239 remember_mouse_glyph (frame, mouse_x, mouse_y, &last_mouse_glyph);
3242 } 3240 }
3243} 3241}
3244 3242
@@ -3250,8 +3248,6 @@ note_mouse_movement (frame, msg)
3250static struct scroll_bar *x_window_to_scroll_bar (); 3248static struct scroll_bar *x_window_to_scroll_bar ();
3251static void x_scroll_bar_report_motion (); 3249static void x_scroll_bar_report_motion ();
3252static void x_check_fullscreen P_ ((struct frame *)); 3250static void x_check_fullscreen P_ ((struct frame *));
3253static int glyph_rect P_ ((struct frame *f, int, int, RECT *));
3254
3255 3251
3256static void 3252static void
3257redo_mouse_highlight () 3253redo_mouse_highlight ()
@@ -3270,108 +3266,6 @@ w32_define_cursor (window, cursor)
3270{ 3266{
3271 PostMessage (window, WM_EMACS_SETCURSOR, (WPARAM) cursor, 0); 3267 PostMessage (window, WM_EMACS_SETCURSOR, (WPARAM) cursor, 0);
3272} 3268}
3273
3274/* Try to determine frame pixel position and size of the glyph under
3275 frame pixel coordinates X/Y on frame F . Return the position and
3276 size in *RECT. Value is non-zero if we could compute these
3277 values. */
3278
3279static int
3280glyph_rect (f, x, y, rect)
3281 struct frame *f;
3282 int x, y;
3283 RECT *rect;
3284{
3285 Lisp_Object window;
3286
3287 window = window_from_coordinates (f, x, y, 0, &x, &y, 0);
3288
3289 if (!NILP (window))
3290 {
3291 struct window *w = XWINDOW (window);
3292 struct glyph_row *r = MATRIX_FIRST_TEXT_ROW (w->current_matrix);
3293 struct glyph_row *end = r + w->current_matrix->nrows - 1;
3294
3295 for (; r < end && r->enabled_p; ++r)
3296 if (r->y <= y && r->y + r->height > y)
3297 {
3298 /* Found the row at y. */
3299 struct glyph *g = r->glyphs[TEXT_AREA];
3300 struct glyph *end = g + r->used[TEXT_AREA];
3301 int gx;
3302
3303 rect->top = WINDOW_TO_FRAME_PIXEL_Y (w, r->y);
3304 rect->bottom = rect->top + r->height;
3305
3306 if (x < r->x)
3307 {
3308 /* x is to the left of the first glyph in the row. */
3309 /* Shouldn't this be a pixel value?
3310 WINDOW_LEFT_EDGE_X (w) seems to be the right value.
3311 ++KFS */
3312 rect->left = WINDOW_LEFT_EDGE_COL (w);
3313 rect->right = WINDOW_TO_FRAME_PIXEL_X (w, r->x);
3314 return 1;
3315 }
3316
3317 for (gx = r->x; g < end; gx += g->pixel_width, ++g)
3318 if (gx <= x && gx + g->pixel_width > x)
3319 {
3320 /* x is on a glyph. */
3321 rect->left = WINDOW_TO_FRAME_PIXEL_X (w, gx);
3322 rect->right = rect->left + g->pixel_width;
3323 return 1;
3324 }
3325
3326 /* x is to the right of the last glyph in the row. */
3327 rect->left = WINDOW_TO_FRAME_PIXEL_X (w, gx);
3328 /* Shouldn't this be a pixel value?
3329 WINDOW_RIGHT_EDGE_X (w) seems to be the right value.
3330 ++KFS */
3331 rect->right = WINDOW_RIGHT_EDGE_COL (w);
3332 return 1;
3333 }
3334 }
3335
3336 /* The y is not on any row. */
3337 return 0;
3338}
3339
3340/* Record the position of the mouse in last_mouse_glyph. */
3341static void
3342remember_mouse_glyph (f1, gx, gy)
3343 struct frame * f1;
3344 int gx, gy;
3345{
3346 if (!glyph_rect (f1, gx, gy, &last_mouse_glyph))
3347 {
3348 int width = FRAME_SMALLEST_CHAR_WIDTH (f1);
3349 int height = FRAME_SMALLEST_FONT_HEIGHT (f1);
3350
3351 /* Arrange for the division in FRAME_PIXEL_X_TO_COL etc. to
3352 round down even for negative values. */
3353 if (gx < 0)
3354 gx -= width - 1;
3355 if (gy < 0)
3356 gy -= height - 1;
3357#if 0
3358 /* This was the original code from XTmouse_position, but it seems
3359 to give the position of the glyph diagonally next to the one
3360 the mouse is over. */
3361 gx = (gx + width - 1) / width * width;
3362 gy = (gy + height - 1) / height * height;
3363#else
3364 gx = gx / width * width;
3365 gy = gy / height * height;
3366#endif
3367
3368 last_mouse_glyph.left = gx;
3369 last_mouse_glyph.top = gy;
3370 last_mouse_glyph.right = gx + width;
3371 last_mouse_glyph.bottom = gy + height;
3372 }
3373}
3374
3375/* Return the current position of the mouse. 3269/* Return the current position of the mouse.
3376 *fp should be a frame which indicates which display to ask about. 3270 *fp should be a frame which indicates which display to ask about.
3377 3271
@@ -3474,7 +3368,7 @@ w32_mouse_position (fp, insist, bar_window, part, x, y, time)
3474 || insist); 3368 || insist);
3475#else 3369#else
3476 ScreenToClient (FRAME_W32_WINDOW (f1), &pt); 3370 ScreenToClient (FRAME_W32_WINDOW (f1), &pt);
3477 remember_mouse_glyph (f1, pt.x, pt.y); 3371 remember_mouse_glyph (f1, pt.x, pt.y, &last_mouse_glyph);
3478#endif 3372#endif
3479 3373
3480 *bar_window = Qnil; 3374 *bar_window = Qnil;