comparison src/w32term.c @ 50247:f9447a2e045c

* xdisp.c (pixel_to_glyph_coords, glyph_to_pixel_coords): Add generic versions here. Remove system specific versions defined elsewhere.
author Kim F. Storm <storm@cua.dk>
date Fri, 21 Mar 2003 22:56:52 +0000
parents 3fb54e5a7201
children 1a5341fe785b
comparison
equal deleted inserted replaced
50246:84e4dd9629ee 50247:f9447a2e045c
2797 } 2797 }
2798 2798
2799 2799
2800 2800
2801 /* Mouse clicks and mouse movement. Rah. */ 2801 /* Mouse clicks and mouse movement. Rah. */
2802
2803 /* Given a pixel position (PIX_X, PIX_Y) on frame F, return glyph
2804 co-ordinates in (*X, *Y). Set *BOUNDS to the rectangle that the
2805 glyph at X, Y occupies, if BOUNDS != 0. If NOCLIP is non-zero, do
2806 not force the value into range. */
2807
2808 void
2809 pixel_to_glyph_coords (f, pix_x, pix_y, x, y, bounds, noclip)
2810 FRAME_PTR f;
2811 register int pix_x, pix_y;
2812 register int *x, *y;
2813 RECT *bounds;
2814 int noclip;
2815 {
2816 /* Support tty mode: if Vwindow_system is nil, behave correctly. */
2817 if (NILP (Vwindow_system))
2818 {
2819 *x = pix_x;
2820 *y = pix_y;
2821 return;
2822 }
2823
2824 /* Arrange for the division in PIXEL_TO_CHAR_COL etc. to round down
2825 even for negative values. */
2826 if (pix_x < 0)
2827 pix_x -= FONT_WIDTH (FRAME_FONT (f)) - 1;
2828 if (pix_y < 0)
2829 pix_y -= (f)->output_data.w32->line_height - 1;
2830
2831 pix_x = PIXEL_TO_CHAR_COL (f, pix_x);
2832 pix_y = PIXEL_TO_CHAR_ROW (f, pix_y);
2833
2834 if (bounds)
2835 {
2836 bounds->left = CHAR_TO_PIXEL_COL (f, pix_x);
2837 bounds->top = CHAR_TO_PIXEL_ROW (f, pix_y);
2838 bounds->right = bounds->left + FONT_WIDTH (FRAME_FONT (f)) - 1;
2839 bounds->bottom = bounds->top + f->output_data.w32->line_height - 1;
2840 }
2841
2842 if (!noclip)
2843 {
2844 if (pix_x < 0)
2845 pix_x = 0;
2846 else if (pix_x > FRAME_WINDOW_WIDTH (f))
2847 pix_x = FRAME_WINDOW_WIDTH (f);
2848
2849 if (pix_y < 0)
2850 pix_y = 0;
2851 else if (pix_y > f->height)
2852 pix_y = f->height;
2853 }
2854
2855 *x = pix_x;
2856 *y = pix_y;
2857 }
2858
2859
2860 /* Given HPOS/VPOS in the current matrix of W, return corresponding
2861 frame-relative pixel positions in *FRAME_X and *FRAME_Y. If we
2862 can't tell the positions because W's display is not up to date,
2863 return 0. */
2864
2865 int
2866 glyph_to_pixel_coords (w, hpos, vpos, frame_x, frame_y)
2867 struct window *w;
2868 int hpos, vpos;
2869 int *frame_x, *frame_y;
2870 {
2871 int success_p;
2872
2873 xassert (hpos >= 0 && hpos < w->current_matrix->matrix_w);
2874 xassert (vpos >= 0 && vpos < w->current_matrix->matrix_h);
2875
2876 if (display_completed)
2877 {
2878 struct glyph_row *row = MATRIX_ROW (w->current_matrix, vpos);
2879 struct glyph *glyph = row->glyphs[TEXT_AREA];
2880 struct glyph *end = glyph + min (hpos, row->used[TEXT_AREA]);
2881
2882 *frame_y = row->y;
2883 *frame_x = row->x;
2884 while (glyph < end)
2885 {
2886 *frame_x += glyph->pixel_width;
2887 ++glyph;
2888 }
2889
2890 success_p = 1;
2891 }
2892 else
2893 {
2894 *frame_y = *frame_x = 0;
2895 success_p = 0;
2896 }
2897
2898 *frame_y = WINDOW_TO_FRAME_PIXEL_Y (w, *frame_y);
2899 *frame_x = WINDOW_TO_FRAME_PIXEL_X (w, *frame_x);
2900 return success_p;
2901 }
2902 2802
2903 /* Parse a button MESSAGE. The button index is returned in PBUTTON, and 2803 /* Parse a button MESSAGE. The button index is returned in PBUTTON, and
2904 the state in PUP. XBUTTON provides extra information for extended mouse 2804 the state in PUP. XBUTTON provides extra information for extended mouse
2905 button messages. Returns FALSE if unable to parse the message. */ 2805 button messages. Returns FALSE if unable to parse the message. */
2906 BOOL 2806 BOOL