comparison src/keyboard.c @ 6053:19d123e039fa

(make_lispy_movement, make_lispy_event): In non-scrollbar mouse case, return coords in pixel units.
author Richard M. Stallman <rms@gnu.org>
date Thu, 24 Feb 1994 06:19:34 +0000
parents 0aa565fdb1b9
children 443b78042b86
comparison
equal deleted inserted replaced
6052:cff556bf85e8 6053:19d123e039fa
2492 { 2492 {
2493 int part; 2493 int part;
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;
2505 2509
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;
2519 2518
2520 items = FRAME_MENU_BAR_ITEMS (f); 2519 items = FRAME_MENU_BAR_ITEMS (f);
2521 for (; CONSP (items); items = XCONS (items)->cdr) 2520 for (; CONSP (items); items = XCONS (items)->cdr)
2522 { 2521 {
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,
2534 Fcons (Fcons (event->x, event->y), 2534 Fcons (Fcons (event->x, event->y),
2535 Fcons (make_number (event->timestamp), 2535 Fcons (make_number (event->timestamp),
2540 Fcons (position, Qnil)); 2540 Fcons (position, Qnil));
2541 else 2541 else
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;
2559 else if (part == 2) 2560 else if (part == 2)
2560 posn = Qvertical_line; 2561 posn = Qvertical_line;
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
2569 = Fcons (window, 2569 = Fcons (window,
2570 Fcons (posn, 2570 Fcons (posn,
2572 Fcons (make_number (event->timestamp), 2572 Fcons (make_number (event->timestamp),
2573 Qnil)))); 2573 Qnil))));
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];
2591 2594
2592 start_pos = *start_pos_ptr; 2595 start_pos = *start_pos_ptr;
2726 2729
2727 /* Or is it an ordinary mouse movement? */ 2730 /* Or is it an ordinary mouse movement? */
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;
2744 else if (area == 2) 2756 else if (area == 2)
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 {
2753 XSET (window, Lisp_Frame, frame); 2764 XSET (window, Lisp_Frame, frame);
2754 posn = Qnil; 2765 posn = Qnil;