4190 |
frame->mouse_moved = 1; |
frame->mouse_moved = 1; |
4191 |
last_mouse_scroll_bar = Qnil; |
last_mouse_scroll_bar = Qnil; |
4192 |
note_mouse_highlight (frame, pos->h, pos->v); |
note_mouse_highlight (frame, pos->h, pos->v); |
4193 |
|
/* Remember which glyph we're now on. */ |
4194 |
|
remember_mouse_glyph (frame, pos->h, pos->v, &last_mouse_glyph); |
4195 |
} |
} |
4196 |
} |
} |
4197 |
|
|
4200 |
Mouse Face |
Mouse Face |
4201 |
************************************************************************/ |
************************************************************************/ |
4202 |
|
|
|
static int glyph_rect P_ ((struct frame *f, int, int, Rect *)); |
|
|
|
|
|
|
|
4203 |
/* MAC TODO: This should be called from somewhere (or removed) ++KFS */ |
/* MAC TODO: This should be called from somewhere (or removed) ++KFS */ |
4204 |
|
|
4205 |
static void |
static void |
4213 |
} |
} |
4214 |
|
|
4215 |
|
|
|
/* Try to determine frame pixel position and size of the glyph under |
|
|
frame pixel coordinates X/Y on frame F . Return the position and |
|
|
size in *RECT. Value is non-zero if we could compute these |
|
|
values. */ |
|
|
|
|
|
static int |
|
|
glyph_rect (f, x, y, rect) |
|
|
struct frame *f; |
|
|
int x, y; |
|
|
Rect *rect; |
|
|
{ |
|
|
Lisp_Object window; |
|
|
|
|
|
window = window_from_coordinates (f, x, y, 0, &x, &y, 0); |
|
|
|
|
|
if (!NILP (window)) |
|
|
{ |
|
|
struct window *w = XWINDOW (window); |
|
|
struct glyph_row *r = MATRIX_FIRST_TEXT_ROW (w->current_matrix); |
|
|
struct glyph_row *end = r + w->current_matrix->nrows - 1; |
|
|
|
|
|
for (; r < end && r->enabled_p; ++r) |
|
|
if (r->y <= y && r->y + r->height > y) |
|
|
{ |
|
|
/* Found the row at y. */ |
|
|
struct glyph *g = r->glyphs[TEXT_AREA]; |
|
|
struct glyph *end = g + r->used[TEXT_AREA]; |
|
|
int gx; |
|
|
|
|
|
rect->top = WINDOW_TO_FRAME_PIXEL_Y (w, r->y); |
|
|
rect->bottom = rect->top + r->height; |
|
|
|
|
|
if (x < r->x) |
|
|
{ |
|
|
/* x is to the left of the first glyph in the row. */ |
|
|
/* Shouldn't this be a pixel value? |
|
|
WINDOW_LEFT_EDGE_X (w) seems to be the right value. |
|
|
++KFS */ |
|
|
rect->left = WINDOW_LEFT_EDGE_COL (w); |
|
|
rect->right = WINDOW_TO_FRAME_PIXEL_X (w, r->x); |
|
|
return 1; |
|
|
} |
|
|
|
|
|
for (gx = r->x; g < end; gx += g->pixel_width, ++g) |
|
|
if (gx <= x && gx + g->pixel_width > x) |
|
|
{ |
|
|
/* x is on a glyph. */ |
|
|
rect->left = WINDOW_TO_FRAME_PIXEL_X (w, gx); |
|
|
rect->right = rect->left + g->pixel_width; |
|
|
return 1; |
|
|
} |
|
|
|
|
|
/* x is to the right of the last glyph in the row. */ |
|
|
rect->left = WINDOW_TO_FRAME_PIXEL_X (w, gx); |
|
|
/* Shouldn't this be a pixel value? |
|
|
WINDOW_RIGHT_EDGE_X (w) seems to be the right value. |
|
|
++KFS */ |
|
|
rect->right = WINDOW_RIGHT_EDGE_COL (w); |
|
|
return 1; |
|
|
} |
|
|
} |
|
|
|
|
|
/* The y is not on any row. */ |
|
|
return 0; |
|
|
} |
|
|
|
|
|
/* MAC TODO: This should be called from somewhere (or removed) ++KFS */ |
|
|
|
|
|
/* Record the position of the mouse in last_mouse_glyph. */ |
|
|
static void |
|
|
remember_mouse_glyph (f1, gx, gy) |
|
|
struct frame * f1; |
|
|
int gx, gy; |
|
|
{ |
|
|
if (!glyph_rect (f1, gx, gy, &last_mouse_glyph)) |
|
|
{ |
|
|
int width = FRAME_SMALLEST_CHAR_WIDTH (f1); |
|
|
int height = FRAME_SMALLEST_FONT_HEIGHT (f1); |
|
|
|
|
|
/* Arrange for the division in FRAME_PIXEL_X_TO_COL etc. to |
|
|
round down even for negative values. */ |
|
|
if (gx < 0) |
|
|
gx -= width - 1; |
|
|
if (gy < 0) |
|
|
gy -= height - 1; |
|
|
#if 0 |
|
|
/* This was the original code from XTmouse_position, but it seems |
|
|
to give the position of the glyph diagonally next to the one |
|
|
the mouse is over. */ |
|
|
gx = (gx + width - 1) / width * width; |
|
|
gy = (gy + height - 1) / height * height; |
|
|
#else |
|
|
gx = gx / width * width; |
|
|
gy = gy / height * height; |
|
|
#endif |
|
|
|
|
|
last_mouse_glyph.left = gx; |
|
|
last_mouse_glyph.top = gy; |
|
|
last_mouse_glyph.right = gx + width; |
|
|
last_mouse_glyph.bottom = gy + height; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
4216 |
static struct frame * |
static struct frame * |
4217 |
mac_focus_frame (dpyinfo) |
mac_focus_frame (dpyinfo) |
4218 |
struct mac_display_info *dpyinfo; |
struct mac_display_info *dpyinfo; |
4228 |
|
|
4229 |
|
|
4230 |
/* Return the current position of the mouse. |
/* Return the current position of the mouse. |
4231 |
*fp should be a frame which indicates which display to ask about. |
*FP should be a frame which indicates which display to ask about. |
4232 |
|
|
4233 |
If the mouse movement started in a scroll bar, set *fp, *bar_window, |
If the mouse movement started in a scroll bar, set *FP, *BAR_WINDOW, |
4234 |
and *part to the frame, window, and scroll bar part that the mouse |
and *PART to the frame, window, and scroll bar part that the mouse |
4235 |
is over. Set *x and *y to the portion and whole of the mouse's |
is over. Set *X and *Y to the portion and whole of the mouse's |
4236 |
position on the scroll bar. |
position on the scroll bar. |
4237 |
|
|
4238 |
If the mouse movement started elsewhere, set *fp to the frame the |
If the mouse movement started elsewhere, set *FP to the frame the |
4239 |
mouse is on, *bar_window to nil, and *x and *y to the character cell |
mouse is on, *BAR_WINDOW to nil, and *X and *Y to the character cell |
4240 |
the mouse is over. |
the mouse is over. |
4241 |
|
|
4242 |
Set *time to the server time-stamp for the time at which the mouse |
Set *TIME to the server time-stamp for the time at which the mouse |
4243 |
was at this position. |
was at this position. |
4244 |
|
|
4245 |
Don't store anything if we don't have a valid set of values to report. |
Don't store anything if we don't have a valid set of values to report. |
4256 |
Lisp_Object *x, *y; |
Lisp_Object *x, *y; |
4257 |
unsigned long *time; |
unsigned long *time; |
4258 |
{ |
{ |
4259 |
Point mouse_pos; |
FRAME_PTR f1; |
|
int ignore1, ignore2; |
|
|
struct frame *f = mac_focus_frame (FRAME_MAC_DISPLAY_INFO (*fp)); |
|
|
WindowPtr wp = FRAME_MAC_WINDOW (f); |
|
|
Lisp_Object frame, tail; |
|
4260 |
|
|
4261 |
BLOCK_INPUT; |
BLOCK_INPUT; |
4262 |
|
|
4264 |
x_scroll_bar_report_motion (fp, bar_window, part, x, y, time); |
x_scroll_bar_report_motion (fp, bar_window, part, x, y, time); |
4265 |
else |
else |
4266 |
{ |
{ |
4267 |
|
Lisp_Object frame, tail; |
4268 |
|
|
4269 |
/* Clear the mouse-moved flag for every frame on this display. */ |
/* Clear the mouse-moved flag for every frame on this display. */ |
4270 |
FOR_EACH_FRAME (tail, frame) |
FOR_EACH_FRAME (tail, frame) |
4271 |
XFRAME (frame)->mouse_moved = 0; |
XFRAME (frame)->mouse_moved = 0; |
4272 |
|
|
4273 |
last_mouse_scroll_bar = Qnil; |
last_mouse_scroll_bar = Qnil; |
4274 |
|
|
4275 |
SetPortWindowPort (wp); |
if (FRAME_MAC_DISPLAY_INFO (*fp)->grabbed && last_mouse_frame |
4276 |
|
&& FRAME_LIVE_P (last_mouse_frame)) |
4277 |
GetMouse (&mouse_pos); |
f1 = last_mouse_frame; |
4278 |
|
else |
4279 |
pixel_to_glyph_coords (f, mouse_pos.h, mouse_pos.v, &ignore1, &ignore2, |
f1 = mac_focus_frame (FRAME_MAC_DISPLAY_INFO (*fp)); |
4280 |
&last_mouse_glyph, insist); |
|
4281 |
|
if (f1) |
4282 |
*bar_window = Qnil; |
{ |
4283 |
*part = scroll_bar_handle; |
/* Ok, we found a frame. Store all the values. |
4284 |
*fp = f; |
last_mouse_glyph is a rectangle used to reduce the |
4285 |
XSETINT (*x, mouse_pos.h); |
generation of mouse events. To not miss any motion |
4286 |
XSETINT (*y, mouse_pos.v); |
events, we must divide the frame into rectangles of the |
4287 |
*time = last_mouse_movement_time; |
size of the smallest character that could be displayed |
4288 |
|
on it, i.e. into the same rectangles that matrices on |
4289 |
|
the frame are divided into. */ |
4290 |
|
Point mouse_pos; |
4291 |
|
|
4292 |
|
SetPortWindowPort (FRAME_MAC_WINDOW (f1)); |
4293 |
|
GetMouse (&mouse_pos); |
4294 |
|
remember_mouse_glyph (f1, mouse_pos.h, mouse_pos.v, |
4295 |
|
&last_mouse_glyph); |
4296 |
|
|
4297 |
|
*bar_window = Qnil; |
4298 |
|
*part = 0; |
4299 |
|
*fp = f1; |
4300 |
|
XSETINT (*x, mouse_pos.h); |
4301 |
|
XSETINT (*y, mouse_pos.v); |
4302 |
|
*time = last_mouse_movement_time; |
4303 |
|
} |
4304 |
} |
} |
4305 |
|
|
4306 |
UNBLOCK_INPUT; |
UNBLOCK_INPUT; |