586 |
Lisp_Object Qvertical_scroll_bar; |
Lisp_Object Qvertical_scroll_bar; |
587 |
Lisp_Object Qmenu_bar; |
Lisp_Object Qmenu_bar; |
588 |
extern Lisp_Object Qleft_margin, Qright_margin; |
extern Lisp_Object Qleft_margin, Qright_margin; |
589 |
|
extern Lisp_Object Qleft_fringe, Qright_fringe; |
590 |
|
|
591 |
Lisp_Object recursive_edit_unwind (), command_loop (); |
Lisp_Object recursive_edit_unwind (), command_loop (); |
592 |
Lisp_Object Fthis_command_keys (); |
Lisp_Object Fthis_command_keys (); |
4956 |
|
|
4957 |
int double_click_count; |
int double_click_count; |
4958 |
|
|
4959 |
|
/* Return position of a mouse click or wheel event */ |
4960 |
|
|
4961 |
|
static Lisp_Object |
4962 |
|
make_lispy_position (f, x, y, time) |
4963 |
|
struct frame *f; |
4964 |
|
Lisp_Object *x, *y; |
4965 |
|
unsigned long time; |
4966 |
|
{ |
4967 |
|
Lisp_Object window; |
4968 |
|
enum window_part part; |
4969 |
|
Lisp_Object posn = Qnil; |
4970 |
|
Lisp_Object extra_info = Qnil; |
4971 |
|
int wx, wy; |
4972 |
|
|
4973 |
|
/* Set `window' to the window under frame pixel coordinates (x,y) */ |
4974 |
|
if (f) |
4975 |
|
window = window_from_coordinates (f, XINT (*x), XINT (*y), |
4976 |
|
&part, &wx, &wy, 0); |
4977 |
|
else |
4978 |
|
window = Qnil; |
4979 |
|
|
4980 |
|
if (WINDOWP (window)) |
4981 |
|
{ |
4982 |
|
/* It's a click in window window at frame coordinates (x,y) */ |
4983 |
|
struct window *w = XWINDOW (window); |
4984 |
|
Lisp_Object object = Qnil; |
4985 |
|
int textpos = -1, rx = -1, ry = -1; |
4986 |
|
|
4987 |
|
/* Set event coordinates to window-relative coordinates |
4988 |
|
for constructing the Lisp event below. */ |
4989 |
|
XSETINT (*x, wx); |
4990 |
|
XSETINT (*y, wy); |
4991 |
|
|
4992 |
|
if (part == ON_MODE_LINE || part == ON_HEADER_LINE) |
4993 |
|
{ |
4994 |
|
/* Mode line or header line. Look for a string under |
4995 |
|
the mouse that may have a `local-map' property. */ |
4996 |
|
Lisp_Object string; |
4997 |
|
int charpos; |
4998 |
|
|
4999 |
|
posn = part == ON_MODE_LINE ? Qmode_line : Qheader_line; |
5000 |
|
rx = wx, ry = wy; |
5001 |
|
string = mode_line_string (w, &rx, &ry, part, &charpos); |
5002 |
|
if (STRINGP (string)) |
5003 |
|
object = Fcons (string, make_number (charpos)); |
5004 |
|
if (w == XWINDOW (selected_window)) |
5005 |
|
textpos = PT; |
5006 |
|
else |
5007 |
|
textpos = XMARKER (w->pointm)->charpos; |
5008 |
|
} |
5009 |
|
else if (part == ON_VERTICAL_BORDER) |
5010 |
|
{ |
5011 |
|
posn = Qvertical_line; |
5012 |
|
wx = -1; |
5013 |
|
} |
5014 |
|
else if (part == ON_LEFT_MARGIN || part == ON_RIGHT_MARGIN) |
5015 |
|
{ |
5016 |
|
Lisp_Object string; |
5017 |
|
int charpos; |
5018 |
|
|
5019 |
|
posn = (part == ON_LEFT_MARGIN) ? Qleft_margin : Qright_margin; |
5020 |
|
rx = wx, ry = wy; |
5021 |
|
string = marginal_area_string (w, &rx, &ry, part, &charpos); |
5022 |
|
if (STRINGP (string)) |
5023 |
|
object = Fcons (string, make_number (charpos)); |
5024 |
|
} |
5025 |
|
else if (part == ON_LEFT_FRINGE || part == ON_RIGHT_FRINGE) |
5026 |
|
{ |
5027 |
|
posn = (part == ON_LEFT_FRINGE) ? Qleft_fringe : Qright_fringe; |
5028 |
|
rx = 0; |
5029 |
|
} |
5030 |
|
|
5031 |
|
if (textpos < 0) |
5032 |
|
{ |
5033 |
|
Lisp_Object string; |
5034 |
|
struct display_pos p; |
5035 |
|
wx = max (WINDOW_LEFT_MARGIN_WIDTH (w), wx); |
5036 |
|
buffer_posn_from_coords (w, &wx, &wy, &string, &p); |
5037 |
|
textpos = CHARPOS (p.pos); |
5038 |
|
if (rx < 0) |
5039 |
|
rx = wx; |
5040 |
|
if (ry < 0) |
5041 |
|
ry = wy; |
5042 |
|
|
5043 |
|
if (NILP (posn)) |
5044 |
|
{ |
5045 |
|
posn = make_number (textpos); |
5046 |
|
if (STRINGP (string)) |
5047 |
|
object = Fcons (string, |
5048 |
|
make_number (CHARPOS (p.string_pos))); |
5049 |
|
} |
5050 |
|
} |
5051 |
|
|
5052 |
|
extra_info = Fcons (object, |
5053 |
|
Fcons (make_number (textpos), |
5054 |
|
Fcons (Fcons (make_number (rx), |
5055 |
|
make_number (ry)), |
5056 |
|
Qnil))); |
5057 |
|
} |
5058 |
|
else if (f != 0) |
5059 |
|
{ |
5060 |
|
XSETFRAME (window, f); |
5061 |
|
} |
5062 |
|
else |
5063 |
|
{ |
5064 |
|
window = Qnil; |
5065 |
|
XSETFASTINT (*x, 0); |
5066 |
|
XSETFASTINT (*y, 0); |
5067 |
|
} |
5068 |
|
|
5069 |
|
return Fcons (window, |
5070 |
|
Fcons (posn, |
5071 |
|
Fcons (Fcons (*x, *y), |
5072 |
|
Fcons (make_number (time), |
5073 |
|
extra_info)))); |
5074 |
|
} |
5075 |
|
|
5076 |
/* Given a struct input_event, build the lisp event which represents |
/* Given a struct input_event, build the lisp event which represents |
5077 |
it. If EVENT is 0, build a mouse movement event from the mouse |
it. If EVENT is 0, build a mouse movement event from the mouse |
5078 |
movement buffer, which should have a movement event in it. |
movement buffer, which should have a movement event in it. |
5207 |
Lisp_Object position; |
Lisp_Object position; |
5208 |
Lisp_Object *start_pos_ptr; |
Lisp_Object *start_pos_ptr; |
5209 |
Lisp_Object start_pos; |
Lisp_Object start_pos; |
|
Lisp_Object window; |
|
5210 |
|
|
5211 |
position = Qnil; |
position = Qnil; |
5212 |
|
|
5213 |
/* Build the position as appropriate for this mouse click. */ |
/* Build the position as appropriate for this mouse click. */ |
5214 |
if (event->kind == MOUSE_CLICK_EVENT) |
if (event->kind == MOUSE_CLICK_EVENT) |
5215 |
{ |
{ |
|
enum window_part part; |
|
5216 |
struct frame *f = XFRAME (event->frame_or_window); |
struct frame *f = XFRAME (event->frame_or_window); |
5217 |
Lisp_Object posn; |
#if ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK) |
|
Lisp_Object string_info = Qnil; |
|
5218 |
int row, column; |
int row, column; |
5219 |
int wx, wy; |
#endif |
5220 |
|
|
5221 |
/* Ignore mouse events that were made on frame that |
/* Ignore mouse events that were made on frame that |
5222 |
have been deleted. */ |
have been deleted. */ |
5223 |
if (! FRAME_LIVE_P (f)) |
if (! FRAME_LIVE_P (f)) |
5224 |
return Qnil; |
return Qnil; |
5225 |
|
|
5226 |
|
#if ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK) |
5227 |
/* EVENT->x and EVENT->y are frame-relative pixel |
/* EVENT->x and EVENT->y are frame-relative pixel |
5228 |
coordinates at this place. Under old redisplay, COLUMN |
coordinates at this place. Under old redisplay, COLUMN |
5229 |
and ROW are set to frame relative glyph coordinates |
and ROW are set to frame relative glyph coordinates |
5232 |
pixel_to_glyph_coords (f, XINT (event->x), XINT (event->y), |
pixel_to_glyph_coords (f, XINT (event->x), XINT (event->y), |
5233 |
&column, &row, NULL, 1); |
&column, &row, NULL, 1); |
5234 |
|
|
|
#if ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK) |
|
5235 |
/* In the non-toolkit version, clicks on the menu bar |
/* In the non-toolkit version, clicks on the menu bar |
5236 |
are ordinary button events in the event buffer. |
are ordinary button events in the event buffer. |
5237 |
Distinguish them, and invoke the menu. |
Distinguish them, and invoke the menu. |
5285 |
} |
} |
5286 |
#endif /* not USE_X_TOOLKIT && not USE_GTK */ |
#endif /* not USE_X_TOOLKIT && not USE_GTK */ |
5287 |
|
|
5288 |
/* Set `window' to the window under frame pixel coordinates |
position = make_lispy_position (f, &event->x, &event->y, |
5289 |
event->x/event->y. */ |
event->timestamp); |
|
window = window_from_coordinates (f, XINT (event->x), |
|
|
XINT (event->y), |
|
|
&part, &wx, &wy, 0); |
|
|
|
|
|
if (!WINDOWP (window)) |
|
|
{ |
|
|
window = event->frame_or_window; |
|
|
posn = Qnil; |
|
|
} |
|
|
else |
|
|
{ |
|
|
/* It's a click in window window at frame coordinates |
|
|
event->x/ event->y. */ |
|
|
struct window *w = XWINDOW (window); |
|
|
|
|
|
/* Set event coordinates to window-relative coordinates |
|
|
for constructing the Lisp event below. */ |
|
|
XSETINT (event->x, wx); |
|
|
XSETINT (event->y, wy); |
|
|
|
|
|
if (part == ON_MODE_LINE || part == ON_HEADER_LINE) |
|
|
{ |
|
|
/* Mode line or header line. Look for a string under |
|
|
the mouse that may have a `local-map' property. */ |
|
|
Lisp_Object string; |
|
|
int charpos; |
|
|
|
|
|
posn = part == ON_MODE_LINE ? Qmode_line : Qheader_line; |
|
|
string = mode_line_string (w, wx, wy, part, &charpos); |
|
|
if (STRINGP (string)) |
|
|
string_info = Fcons (string, make_number (charpos)); |
|
|
} |
|
|
else if (part == ON_VERTICAL_BORDER) |
|
|
posn = Qvertical_line; |
|
|
else if (part == ON_LEFT_MARGIN || part == ON_RIGHT_MARGIN) |
|
|
{ |
|
|
int charpos; |
|
|
Lisp_Object object = marginal_area_string (w, wx, wy, part, |
|
|
&charpos); |
|
|
posn = (part == ON_LEFT_MARGIN) ? Qleft_margin : Qright_margin; |
|
|
if (STRINGP (object)) |
|
|
string_info = Fcons (object, make_number (charpos)); |
|
|
} |
|
|
else |
|
|
{ |
|
|
Lisp_Object object; |
|
|
struct display_pos p; |
|
|
buffer_posn_from_coords (w, &wx, &wy, &object, &p); |
|
|
posn = make_number (CHARPOS (p.pos)); |
|
|
if (STRINGP (object)) |
|
|
string_info |
|
|
= Fcons (object, |
|
|
make_number (CHARPOS (p.string_pos))); |
|
|
} |
|
|
} |
|
|
|
|
|
position |
|
|
= Fcons (window, |
|
|
Fcons (posn, |
|
|
Fcons (Fcons (event->x, event->y), |
|
|
Fcons (make_number (event->timestamp), |
|
|
(NILP (string_info) |
|
|
? Qnil |
|
|
: Fcons (string_info, Qnil)))))); |
|
5290 |
} |
} |
5291 |
#ifndef USE_TOOLKIT_SCROLL_BARS |
#ifndef USE_TOOLKIT_SCROLL_BARS |
5292 |
else |
else |
5293 |
{ |
{ |
5294 |
/* It's a scrollbar click. */ |
/* It's a scrollbar click. */ |
5295 |
|
Lisp_Object window; |
5296 |
Lisp_Object portion_whole; |
Lisp_Object portion_whole; |
5297 |
Lisp_Object part; |
Lisp_Object part; |
5298 |
|
|
5457 |
case WHEEL_EVENT: |
case WHEEL_EVENT: |
5458 |
{ |
{ |
5459 |
Lisp_Object position; |
Lisp_Object position; |
|
Lisp_Object window; |
|
5460 |
Lisp_Object head; |
Lisp_Object head; |
5461 |
|
|
5462 |
/* Build the position as appropriate for this mouse click. */ |
/* Build the position as appropriate for this mouse click. */ |
|
enum window_part part; |
|
5463 |
struct frame *f = XFRAME (event->frame_or_window); |
struct frame *f = XFRAME (event->frame_or_window); |
|
Lisp_Object posn; |
|
|
Lisp_Object string_info = Qnil; |
|
|
int row, column; |
|
|
int wx, wy; |
|
|
position = Qnil; |
|
5464 |
|
|
5465 |
/* Ignore wheel events that were made on frame that have been |
/* Ignore wheel events that were made on frame that have been |
5466 |
deleted. */ |
deleted. */ |
5467 |
if (! FRAME_LIVE_P (f)) |
if (! FRAME_LIVE_P (f)) |
5468 |
return Qnil; |
return Qnil; |
5469 |
|
|
5470 |
/* EVENT->x and EVENT->y are frame-relative pixel |
position = make_lispy_position (f, &event->x, &event->y, |
5471 |
coordinates at this place. Under old redisplay, COLUMN |
event->timestamp); |
|
and ROW are set to frame relative glyph coordinates |
|
|
which are then used to determine whether this click is |
|
|
in a menu (non-toolkit version). */ |
|
|
pixel_to_glyph_coords (f, XINT (event->x), XINT (event->y), |
|
|
&column, &row, NULL, 1); |
|
|
|
|
|
/* Set `window' to the window under frame pixel coordinates |
|
|
event->x/event->y. */ |
|
|
window = window_from_coordinates (f, XINT (event->x), |
|
|
XINT (event->y), |
|
|
&part, &wx, &wy, 0); |
|
|
|
|
|
if (!WINDOWP (window)) |
|
|
{ |
|
|
window = event->frame_or_window; |
|
|
posn = Qnil; |
|
|
} |
|
|
else |
|
|
{ |
|
|
/* It's a click in window window at frame coordinates |
|
|
event->x/ event->y. */ |
|
|
struct window *w = XWINDOW (window); |
|
|
|
|
|
/* Set event coordinates to window-relative coordinates |
|
|
for constructing the Lisp event below. */ |
|
|
XSETINT (event->x, wx); |
|
|
XSETINT (event->y, wy); |
|
|
|
|
|
if (part == ON_MODE_LINE || part == ON_HEADER_LINE) |
|
|
{ |
|
|
/* Mode line or header line. Look for a string under |
|
|
the mouse that may have a `local-map' property. */ |
|
|
Lisp_Object string; |
|
|
int charpos; |
|
|
|
|
|
posn = part == ON_MODE_LINE ? Qmode_line : Qheader_line; |
|
|
string = mode_line_string (w, wx, wy, part, &charpos); |
|
|
if (STRINGP (string)) |
|
|
string_info = Fcons (string, make_number (charpos)); |
|
|
} |
|
|
else if (part == ON_VERTICAL_BORDER) |
|
|
posn = Qvertical_line; |
|
|
else if (part == ON_LEFT_MARGIN || part == ON_RIGHT_MARGIN) |
|
|
{ |
|
|
int charpos; |
|
|
Lisp_Object object = marginal_area_string (w, wx, wy, part, |
|
|
&charpos); |
|
|
posn = (part == ON_LEFT_MARGIN) ? Qleft_margin : Qright_margin; |
|
|
if (STRINGP (object)) |
|
|
string_info = Fcons (object, make_number (charpos)); |
|
|
} |
|
|
else |
|
|
{ |
|
|
Lisp_Object object; |
|
|
struct display_pos p; |
|
|
buffer_posn_from_coords (w, &wx, &wy, &object, &p); |
|
|
posn = make_number (CHARPOS (p.pos)); |
|
|
if (STRINGP (object)) |
|
|
string_info |
|
|
= Fcons (object, |
|
|
make_number (CHARPOS (p.string_pos))); |
|
|
} |
|
|
} |
|
|
|
|
|
position |
|
|
= Fcons (window, |
|
|
Fcons (posn, |
|
|
Fcons (Fcons (event->x, event->y), |
|
|
Fcons (make_number (event->timestamp), |
|
|
(NILP (string_info) |
|
|
? Qnil |
|
|
: Fcons (string_info, Qnil)))))); |
|
5472 |
|
|
5473 |
/* Set double or triple modifiers to indicate the wheel speed. */ |
/* Set double or triple modifiers to indicate the wheel speed. */ |
5474 |
{ |
{ |
5662 |
|
|
5663 |
case DRAG_N_DROP_EVENT: |
case DRAG_N_DROP_EVENT: |
5664 |
{ |
{ |
|
enum window_part part; |
|
5665 |
FRAME_PTR f; |
FRAME_PTR f; |
5666 |
Lisp_Object window; |
Lisp_Object head, position; |
|
Lisp_Object posn; |
|
5667 |
Lisp_Object files; |
Lisp_Object files; |
|
int wx, wy; |
|
5668 |
|
|
5669 |
/* The frame_or_window field should be a cons of the frame in |
/* The frame_or_window field should be a cons of the frame in |
5670 |
which the event occurred and a list of the filenames |
which the event occurred and a list of the filenames |
5680 |
if (! FRAME_LIVE_P (f)) |
if (! FRAME_LIVE_P (f)) |
5681 |
return Qnil; |
return Qnil; |
5682 |
|
|
5683 |
window = window_from_coordinates (f, XINT (event->x), |
position = make_lispy_position (f, &event->x, &event->y, |
5684 |
XINT (event->y), |
event->timestamp); |
|
&part, &wx, &wy, 0); |
|
|
|
|
|
if (!WINDOWP (window)) |
|
|
{ |
|
|
window = XCAR (event->frame_or_window); |
|
|
posn = Qnil; |
|
|
} |
|
|
else |
|
|
{ |
|
|
/* It's an event in window `window' at frame coordinates |
|
|
event->x/ event->y. */ |
|
|
struct window *w = XWINDOW (window); |
|
|
|
|
|
/* Set event coordinates to window-relative coordinates |
|
|
for constructing the Lisp event below. */ |
|
|
XSETINT (event->x, wx); |
|
|
XSETINT (event->y, wy); |
|
|
|
|
|
if (part == ON_MODE_LINE) |
|
|
posn = Qmode_line; |
|
|
else if (part == ON_VERTICAL_BORDER) |
|
|
posn = Qvertical_line; |
|
|
else if (part == ON_HEADER_LINE) |
|
|
posn = Qheader_line; |
|
|
else |
|
|
{ |
|
|
Lisp_Object object; |
|
|
struct display_pos p; |
|
|
buffer_posn_from_coords (w, &wx, &wy, &object, &p); |
|
|
posn = make_number (CHARPOS (p.pos)); |
|
|
} |
|
|
} |
|
|
|
|
|
{ |
|
|
Lisp_Object head, position; |
|
|
|
|
|
position |
|
|
= Fcons (window, |
|
|
Fcons (posn, |
|
|
Fcons (Fcons (event->x, event->y), |
|
|
Fcons (make_number (event->timestamp), |
|
|
Qnil)))); |
|
5685 |
|
|
5686 |
head = modify_event_symbol (0, event->modifiers, |
head = modify_event_symbol (0, event->modifiers, |
5687 |
Qdrag_n_drop, Qnil, |
Qdrag_n_drop, Qnil, |
5688 |
lispy_drag_n_drop_names, |
lispy_drag_n_drop_names, |
5689 |
&drag_n_drop_syms, 1); |
&drag_n_drop_syms, 1); |
5690 |
return Fcons (head, |
return Fcons (head, |
5691 |
Fcons (position, |
Fcons (position, |
5692 |
Fcons (files, |
Fcons (files, |
5693 |
Qnil))); |
Qnil))); |
|
} |
|
5694 |
} |
} |
5695 |
#endif /* HAVE_MOUSE */ |
#endif /* HAVE_MOUSE */ |
5696 |
|
|
5763 |
/* Or is it an ordinary mouse movement? */ |
/* Or is it an ordinary mouse movement? */ |
5764 |
else |
else |
5765 |
{ |
{ |
5766 |
enum window_part area; |
Lisp_Object position; |
|
Lisp_Object window; |
|
|
Lisp_Object posn; |
|
|
int wx, wy; |
|
5767 |
|
|
5768 |
if (frame) |
position = make_lispy_position (frame, &x, &y, time); |
|
/* It's in a frame; which window on that frame? */ |
|
|
window = window_from_coordinates (frame, XINT (x), XINT (y), |
|
|
&area, &wx, &wy, 0); |
|
|
else |
|
|
window = Qnil; |
|
|
|
|
|
if (WINDOWP (window)) |
|
|
{ |
|
|
struct window *w = XWINDOW (window); |
|
|
|
|
|
/* Set window relative coordinates. */ |
|
|
XSETINT (x, wx); |
|
|
XSETINT (y, wy); |
|
|
|
|
|
if (area == ON_MODE_LINE) |
|
|
posn = Qmode_line; |
|
|
else if (area == ON_VERTICAL_BORDER) |
|
|
posn = Qvertical_line; |
|
|
else if (area == ON_HEADER_LINE) |
|
|
posn = Qheader_line; |
|
|
else |
|
|
{ |
|
|
Lisp_Object object; |
|
|
struct display_pos p; |
|
|
buffer_posn_from_coords (w, &wx, &wy, &object, &p); |
|
|
posn = make_number (CHARPOS (p.pos)); |
|
|
} |
|
|
} |
|
|
else if (frame != 0) |
|
|
{ |
|
|
XSETFRAME (window, frame); |
|
|
posn = Qnil; |
|
|
} |
|
|
else |
|
|
{ |
|
|
window = Qnil; |
|
|
posn = Qnil; |
|
|
XSETFASTINT (x, 0); |
|
|
XSETFASTINT (y, 0); |
|
|
} |
|
5769 |
|
|
5770 |
return Fcons (Qmouse_movement, |
return Fcons (Qmouse_movement, |
5771 |
Fcons (Fcons (window, |
Fcons (position, |
|
Fcons (posn, |
|
|
Fcons (Fcons (x, y), |
|
|
Fcons (make_number (time), |
|
|
Qnil)))), |
|
5772 |
Qnil)); |
Qnil)); |
5773 |
} |
} |
5774 |
} |
} |