diff options
| author | Richard M. Stallman | 1994-02-24 06:19:34 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1994-02-24 06:19:34 +0000 |
| commit | 9e20143afcd6a5f9e695b4cf7255d0b1e572dbc3 (patch) | |
| tree | 767dd5cd38a1f1123bace0688bd9c745742d1616 /src | |
| parent | d8858cfe4afe3eddda36fc775bc6bda125a7215c (diff) | |
| download | emacs-9e20143afcd6a5f9e695b4cf7255d0b1e572dbc3.tar.gz emacs-9e20143afcd6a5f9e695b4cf7255d0b1e572dbc3.zip | |
(make_lispy_movement, make_lispy_event):
In non-scrollbar mouse case, return coords in pixel units.
Diffstat (limited to 'src')
| -rw-r--r-- | src/keyboard.c | 69 |
1 files changed, 40 insertions, 29 deletions
diff --git a/src/keyboard.c b/src/keyboard.c index bd8788f1501..2ae4e763ebf 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -2494,11 +2494,15 @@ make_lispy_event (event) | |||
| 2494 | FRAME_PTR f = XFRAME (event->frame_or_window); | 2494 | FRAME_PTR f = XFRAME (event->frame_or_window); |
| 2495 | Lisp_Object window; | 2495 | Lisp_Object window; |
| 2496 | Lisp_Object posn; | 2496 | Lisp_Object posn; |
| 2497 | int row, column; | ||
| 2498 | |||
| 2499 | pixel_to_glyph_coords (f, XINT (event->x), XINT (event->y), | ||
| 2500 | &column, &row, 0, 0); | ||
| 2497 | 2501 | ||
| 2498 | #ifdef USE_X_TOOLKIT | 2502 | #ifdef USE_X_TOOLKIT |
| 2499 | if (FRAME_EXTERNAL_MENU_BAR (f) && XINT (event->y) == -1) | 2503 | if (FRAME_EXTERNAL_MENU_BAR (f) && XINT (event->y) == -1) |
| 2500 | #else | 2504 | #else |
| 2501 | if (XINT (event->y) < FRAME_MENU_BAR_LINES (f)) | 2505 | if (row < FRAME_MENU_BAR_LINES (f)) |
| 2502 | #endif | 2506 | #endif |
| 2503 | { | 2507 | { |
| 2504 | Lisp_Object items; | 2508 | Lisp_Object items; |
| @@ -2506,13 +2510,8 @@ make_lispy_event (event) | |||
| 2506 | #ifdef USE_X_TOOLKIT | 2510 | #ifdef USE_X_TOOLKIT |
| 2507 | /* The click happened in the menubar. | 2511 | /* The click happened in the menubar. |
| 2508 | Look for the menu item selected. */ | 2512 | Look for the menu item selected. */ |
| 2509 | int row, column; | ||
| 2510 | |||
| 2511 | items = map_event_to_object (event, f); | 2513 | items = map_event_to_object (event, f); |
| 2512 | 2514 | ||
| 2513 | pixel_to_glyph_coords (f, XINT (event->x), XINT (event->y), | ||
| 2514 | &column, &row, 0, 0); | ||
| 2515 | XFASTINT (event->x) = column; | ||
| 2516 | XFASTINT (event->y) = 1; | 2515 | XFASTINT (event->y) = 1; |
| 2517 | #else /* not USE_X_TOOLKIT */ | 2516 | #else /* not USE_X_TOOLKIT */ |
| 2518 | int hpos; | 2517 | int hpos; |
| @@ -2523,11 +2522,12 @@ make_lispy_event (event) | |||
| 2523 | Lisp_Object pos, string; | 2522 | Lisp_Object pos, string; |
| 2524 | pos = Fcdr (Fcdr (Fcar (items))); | 2523 | pos = Fcdr (Fcdr (Fcar (items))); |
| 2525 | string = Fcar (Fcdr (Fcar (items))); | 2524 | string = Fcar (Fcdr (Fcar (items))); |
| 2526 | if (XINT (event->x) >= XINT (pos) | 2525 | if (column >= XINT (pos) |
| 2527 | && XINT (event->x) < XINT (pos) + XSTRING (string)->size) | 2526 | && column < XINT (pos) + XSTRING (string)->size) |
| 2528 | break; | 2527 | break; |
| 2529 | } | 2528 | } |
| 2530 | #endif /* not USE_X_TOOLKIT */ | 2529 | #endif /* not USE_X_TOOLKIT */ |
| 2530 | |||
| 2531 | position | 2531 | position |
| 2532 | = Fcons (event->frame_or_window, | 2532 | = Fcons (event->frame_or_window, |
| 2533 | Fcons (Qmenu_bar, | 2533 | Fcons (Qmenu_bar, |
| @@ -2542,17 +2542,18 @@ make_lispy_event (event) | |||
| 2542 | return Fcons (Qnil, Fcons (position, Qnil)); | 2542 | return Fcons (Qnil, Fcons (position, Qnil)); |
| 2543 | } | 2543 | } |
| 2544 | 2544 | ||
| 2545 | window = window_from_coordinates (f, XINT (event->x), | 2545 | window = window_from_coordinates (f, column, row, &part); |
| 2546 | XINT (event->y), &part); | ||
| 2547 | 2546 | ||
| 2548 | if (XTYPE (window) != Lisp_Window) | 2547 | if (XTYPE (window) != Lisp_Window) |
| 2549 | posn = Qnil; | 2548 | posn = Qnil; |
| 2550 | else | 2549 | else |
| 2551 | { | 2550 | { |
| 2552 | XSETINT (event->x, | 2551 | int pixcolumn, pixrow; |
| 2553 | (XINT (event->x) - XINT (XWINDOW (window)->left))); | 2552 | column -= XINT (XWINDOW (window)->left); |
| 2554 | XSETINT (event->y, | 2553 | row -= XINT (XWINDOW (window)->top); |
| 2555 | (XINT (event->y) - XINT (XWINDOW (window)->top))); | 2554 | glyph_to_pixel_coords (f, column, row, &pixcolumn, &pixrow); |
| 2555 | XSETINT (event->x, pixcolumn); | ||
| 2556 | XSETINT (event->y, pixrow); | ||
| 2556 | 2557 | ||
| 2557 | if (part == 1) | 2558 | if (part == 1) |
| 2558 | posn = Qmode_line; | 2559 | posn = Qmode_line; |
| @@ -2561,8 +2562,7 @@ make_lispy_event (event) | |||
| 2561 | else | 2562 | else |
| 2562 | XSET (posn, Lisp_Int, | 2563 | XSET (posn, Lisp_Int, |
| 2563 | buffer_posn_from_coords (XWINDOW (window), | 2564 | buffer_posn_from_coords (XWINDOW (window), |
| 2564 | XINT (event->x), | 2565 | column, row)); |
| 2565 | XINT (event->y))); | ||
| 2566 | } | 2566 | } |
| 2567 | 2567 | ||
| 2568 | position | 2568 | position |
| @@ -2574,17 +2574,20 @@ make_lispy_event (event) | |||
| 2574 | } | 2574 | } |
| 2575 | else | 2575 | else |
| 2576 | { | 2576 | { |
| 2577 | Lisp_Object window = event->frame_or_window; | 2577 | Lisp_Object window; |
| 2578 | Lisp_Object portion_whole = Fcons (event->x, event->y); | 2578 | Lisp_Object portion_whole; |
| 2579 | Lisp_Object part = *scroll_bar_parts[(int) event->part]; | 2579 | Lisp_Object part; |
| 2580 | |||
| 2581 | window = event->frame_or_window; | ||
| 2582 | portion_whole = Fcons (event->x, event->y); | ||
| 2583 | part = *scroll_bar_parts[(int) event->part]; | ||
| 2580 | 2584 | ||
| 2581 | position = | 2585 | position = |
| 2582 | Fcons (window, | 2586 | Fcons (window, |
| 2583 | Fcons (Qvertical_scroll_bar, | 2587 | Fcons (Qvertical_scroll_bar, |
| 2584 | Fcons (portion_whole, | 2588 | Fcons (portion_whole, |
| 2585 | Fcons (make_number (event->timestamp), | 2589 | Fcons (make_number (event->timestamp), |
| 2586 | Fcons (part, | 2590 | Fcons (part, Qnil))))); |
| 2587 | Qnil))))); | ||
| 2588 | } | 2591 | } |
| 2589 | 2592 | ||
| 2590 | start_pos_ptr = &XVECTOR (button_down_location)->contents[button]; | 2593 | start_pos_ptr = &XVECTOR (button_down_location)->contents[button]; |
| @@ -2728,16 +2731,25 @@ make_lispy_movement (frame, bar_window, part, x, y, time) | |||
| 2728 | else | 2731 | else |
| 2729 | { | 2732 | { |
| 2730 | int area; | 2733 | int area; |
| 2731 | Lisp_Object window = | 2734 | Lisp_Object window; |
| 2732 | (frame | ||
| 2733 | ? window_from_coordinates (frame, XINT (x), XINT (y), &area) | ||
| 2734 | : Qnil); | ||
| 2735 | Lisp_Object posn; | 2735 | Lisp_Object posn; |
| 2736 | int column, row; | ||
| 2737 | |||
| 2738 | pixel_to_glyph_coords (frame, XINT (x), XINT (y), &column, &row, 0, 0); | ||
| 2739 | |||
| 2740 | if (frame) | ||
| 2741 | window = window_from_coordinates (frame, column, row, &area); | ||
| 2742 | else | ||
| 2743 | window = Qnil; | ||
| 2736 | 2744 | ||
| 2737 | if (XTYPE (window) == Lisp_Window) | 2745 | if (XTYPE (window) == Lisp_Window) |
| 2738 | { | 2746 | { |
| 2739 | XSETINT (x, XINT (x) - XINT (XWINDOW (window)->left)); | 2747 | int pixcolumn, pixrow; |
| 2740 | XSETINT (y, XINT (y) - XINT (XWINDOW (window)->top)); | 2748 | column -= XINT (XWINDOW (window)->left); |
| 2749 | row -= XINT (XWINDOW (window)->top); | ||
| 2750 | glyph_to_pixel_coords (frame, column, row, &pixcolumn, &pixrow); | ||
| 2751 | XSETINT (x, pixcolumn); | ||
| 2752 | XSETINT (y, pixrow); | ||
| 2741 | 2753 | ||
| 2742 | if (area == 1) | 2754 | if (area == 1) |
| 2743 | posn = Qmode_line; | 2755 | posn = Qmode_line; |
| @@ -2745,8 +2757,7 @@ make_lispy_movement (frame, bar_window, part, x, y, time) | |||
| 2745 | posn = Qvertical_line; | 2757 | posn = Qvertical_line; |
| 2746 | else | 2758 | else |
| 2747 | XSET (posn, Lisp_Int, | 2759 | XSET (posn, Lisp_Int, |
| 2748 | buffer_posn_from_coords (XWINDOW (window), | 2760 | buffer_posn_from_coords (XWINDOW (window), column, row)); |
| 2749 | XINT (x), XINT (y))); | ||
| 2750 | } | 2761 | } |
| 2751 | else if (frame != 0) | 2762 | else if (frame != 0) |
| 2752 | { | 2763 | { |