comparison src/xterm.c @ 36492:da77079d6981

(glyph_rect): New function. (XTmouse_position): Use it to raise the threshold for mouse movement event generation.
author Gerd Moellmann <gerd@gnu.org>
date Fri, 02 Mar 2001 20:49:19 +0000
parents 488c4787ec0a
children b6b9363f3e20
comparison
equal deleted inserted replaced
36491:532d458f0d2b 36492:da77079d6981
475 static void x_update_window_begin P_ ((struct window *)); 475 static void x_update_window_begin P_ ((struct window *));
476 static void x_draw_vertical_border P_ ((struct window *)); 476 static void x_draw_vertical_border P_ ((struct window *));
477 static void x_after_update_window_line P_ ((struct glyph_row *)); 477 static void x_after_update_window_line P_ ((struct glyph_row *));
478 static INLINE void take_vertical_position_into_account P_ ((struct it *)); 478 static INLINE void take_vertical_position_into_account P_ ((struct it *));
479 static void x_produce_stretch_glyph P_ ((struct it *)); 479 static void x_produce_stretch_glyph P_ ((struct it *));
480 480 static struct scroll_bar *x_window_to_scroll_bar P_ ((Window));
481 static void x_scroll_bar_report_motion P_ ((struct frame **, Lisp_Object *,
482 enum scroll_bar_part *,
483 Lisp_Object *, Lisp_Object *,
484 unsigned long *));
481 485
482 /* Flush display of frame F, or of all frames if F is null. */ 486 /* Flush display of frame F, or of all frames if F is null. */
483 487
484 static void 488 static void
485 x_flush (f) 489 x_flush (f)
7383 dpyinfo->mouse_face_beg_row = dpyinfo->mouse_face_beg_col = -1; 7387 dpyinfo->mouse_face_beg_row = dpyinfo->mouse_face_beg_col = -1;
7384 dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_end_col = -1; 7388 dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_end_col = -1;
7385 dpyinfo->mouse_face_window = Qnil; 7389 dpyinfo->mouse_face_window = Qnil;
7386 } 7390 }
7387 } 7391 }
7392
7388 7393
7389 static struct scroll_bar *x_window_to_scroll_bar (); 7394 static int glyph_rect P_ ((struct frame *f, int, int, XRectangle *));
7390 static void x_scroll_bar_report_motion (); 7395
7396
7397 /* Try to determine frame pixel position and size of the glyph under
7398 frame pixel coordinates X/Y on frame F . Return the position and
7399 size in *RECT. Value is non-zero if we could compute these
7400 values. */
7401
7402 static int
7403 glyph_rect (f, x, y, rect)
7404 struct frame *f;
7405 int x, y;
7406 XRectangle *rect;
7407 {
7408 Lisp_Object window;
7409 int part, found = 0;
7410
7411 window = window_from_coordinates (f, x, y, &part, 0);
7412 if (!NILP (window))
7413 {
7414 struct window *w = XWINDOW (window);
7415 struct glyph_row *r = MATRIX_FIRST_TEXT_ROW (w->current_matrix);
7416 struct glyph_row *end = r + w->current_matrix->nrows - 1;
7417 int area;
7418
7419 frame_to_window_pixel_xy (w, &x, &y);
7420
7421 for (; !found && r < end && r->enabled_p; ++r)
7422 if (r->y >= y)
7423 {
7424 struct glyph *g = r->glyphs[TEXT_AREA];
7425 struct glyph *end = g + r->used[TEXT_AREA];
7426 int gx;
7427
7428 for (gx = r->x; !found && g < end; gx += g->pixel_width, ++g)
7429 if (gx >= x)
7430 {
7431 rect->width = g->pixel_width;
7432 rect->height = r->height;
7433 rect->x = WINDOW_TO_FRAME_PIXEL_X (w, gx);
7434 rect->y = WINDOW_TO_FRAME_PIXEL_Y (w, r->y);
7435 found = 1;
7436 }
7437 }
7438 }
7439
7440 return found;
7441 }
7442
7391 7443
7392 /* Return the current position of the mouse. 7444 /* Return the current position of the mouse.
7393 *fp should be a frame which indicates which display to ask about. 7445 *FP should be a frame which indicates which display to ask about.
7394 7446
7395 If the mouse movement started in a scroll bar, set *fp, *bar_window, 7447 If the mouse movement started in a scroll bar, set *FP, *BAR_WINDOW,
7396 and *part to the frame, window, and scroll bar part that the mouse 7448 and *PART to the frame, window, and scroll bar part that the mouse
7397 is over. Set *x and *y to the portion and whole of the mouse's 7449 is over. Set *X and *Y to the portion and whole of the mouse's
7398 position on the scroll bar. 7450 position on the scroll bar.
7399 7451
7400 If the mouse movement started elsewhere, set *fp to the frame the 7452 If the mouse movement started elsewhere, set *FP to the frame the
7401 mouse is on, *bar_window to nil, and *x and *y to the character cell 7453 mouse is on, *BAR_WINDOW to nil, and *X and *Y to the character cell
7402 the mouse is over. 7454 the mouse is over.
7403 7455
7404 Set *time to the server time-stamp for the time at which the mouse 7456 Set *TIME to the server time-stamp for the time at which the mouse
7405 was at this position. 7457 was at this position.
7406 7458
7407 Don't store anything if we don't have a valid set of values to report. 7459 Don't store anything if we don't have a valid set of values to report.
7408 7460
7409 This clears the mouse_moved flag, so we can wait for the next mouse 7461 This clears the mouse_moved flag, so we can wait for the next mouse
7571 events, we must divide the frame into rectangles of the 7623 events, we must divide the frame into rectangles of the
7572 size of the smallest character that could be displayed 7624 size of the smallest character that could be displayed
7573 on it, i.e. into the same rectangles that matrices on 7625 on it, i.e. into the same rectangles that matrices on
7574 the frame are divided into. */ 7626 the frame are divided into. */
7575 7627
7576 #if OLD_REDISPLAY_CODE 7628 int width, height, gx, gy;
7577 int ignore1, ignore2; 7629 XRectangle rect;
7578 pixel_to_glyph_coords (f1, win_x, win_y, &ignore1, &ignore2, 7630
7579 &last_mouse_glyph, 7631 if (glyph_rect (f1, win_x, win_y, &rect))
7580 FRAME_X_DISPLAY_INFO (f1)->grabbed 7632 last_mouse_glyph = rect;
7581 || insist); 7633 else
7582 #else 7634 {
7583 { 7635 width = FRAME_SMALLEST_CHAR_WIDTH (f1);
7584 int width = FRAME_SMALLEST_CHAR_WIDTH (f1); 7636 height = FRAME_SMALLEST_FONT_HEIGHT (f1);
7585 int height = FRAME_SMALLEST_FONT_HEIGHT (f1); 7637 gx = win_x;
7586 int x = win_x; 7638 gy = win_y;
7587 int y = win_y;
7588 7639
7589 /* Arrange for the division in PIXEL_TO_CHAR_COL etc. to 7640 /* Arrange for the division in PIXEL_TO_CHAR_COL etc. to
7590 round down even for negative values. */ 7641 round down even for negative values. */
7591 if (x < 0) 7642 if (gx < 0)
7592 x -= width - 1; 7643 gx -= width - 1;
7593 if (y < 0) 7644 if (y < 0)
7594 y -= height - 1; 7645 gy -= height - 1;
7595 7646 gx = (gx + width - 1) / width * width;
7596 last_mouse_glyph.width = width; 7647 gy = (gy + height - 1) / height * height;
7597 last_mouse_glyph.height = height; 7648
7598 last_mouse_glyph.x = (x + width - 1) / width * width; 7649 last_mouse_glyph.width = width;
7599 last_mouse_glyph.y = (y + height - 1) / height * height; 7650 last_mouse_glyph.height = height;
7600 } 7651 last_mouse_glyph.x = gx;
7601 #endif 7652 last_mouse_glyph.y = gy;
7653 }
7602 7654
7603 *bar_window = Qnil; 7655 *bar_window = Qnil;
7604 *part = 0; 7656 *part = 0;
7605 *fp = f1; 7657 *fp = f1;
7606 XSETINT (*x, win_x); 7658 XSETINT (*x, win_x);