diff options
| author | Kim F. Storm | 2004-01-06 22:37:39 +0000 |
|---|---|---|
| committer | Kim F. Storm | 2004-01-06 22:37:39 +0000 |
| commit | eee5863b686e80bb8b40bb8d3a2affa8d0024e20 (patch) | |
| tree | 5a4539aa89e5ce33d72e6ec23ad918507f40ec4b /src/keyboard.c | |
| parent | 6a3d9c9ff43c38fbfc5d63e3026b76356ea97c62 (diff) | |
| download | emacs-eee5863b686e80bb8b40bb8d3a2affa8d0024e20.tar.gz emacs-eee5863b686e80bb8b40bb8d3a2affa8d0024e20.zip | |
(make_lispy_position): Use modified mode_line_string,
buffer_posn_from_coords, and marginal_area_string functions to
include both string object and image object in the lispy position.
Also add actual glyph width and height to position.
(read_key_sequence): Use real buffer position from mouse
event to find keymap property even when click is in marginal area.
Diffstat (limited to 'src/keyboard.c')
| -rw-r--r-- | src/keyboard.c | 98 |
1 files changed, 52 insertions, 46 deletions
diff --git a/src/keyboard.c b/src/keyboard.c index 3ac73750afc..f843edf6438 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -2943,13 +2943,13 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu) | |||
| 2943 | { | 2943 | { |
| 2944 | Lisp_Object posn; | 2944 | Lisp_Object posn; |
| 2945 | 2945 | ||
| 2946 | posn = POSN_BUFFER_POSN (EVENT_START (c)); | 2946 | posn = POSN_POSN (EVENT_START (c)); |
| 2947 | /* Handle menu-bar events: | 2947 | /* Handle menu-bar events: |
| 2948 | insert the dummy prefix event `menu-bar'. */ | 2948 | insert the dummy prefix event `menu-bar'. */ |
| 2949 | if (EQ (posn, Qmenu_bar) || EQ (posn, Qtool_bar)) | 2949 | if (EQ (posn, Qmenu_bar) || EQ (posn, Qtool_bar)) |
| 2950 | { | 2950 | { |
| 2951 | /* Change menu-bar to (menu-bar) as the event "position". */ | 2951 | /* Change menu-bar to (menu-bar) as the event "position". */ |
| 2952 | POSN_BUFFER_SET_POSN (EVENT_START (c), Fcons (posn, Qnil)); | 2952 | POSN_SET_POSN (EVENT_START (c), Fcons (posn, Qnil)); |
| 2953 | 2953 | ||
| 2954 | also_record = c; | 2954 | also_record = c; |
| 2955 | Vunread_command_events = Fcons (c, Vunread_command_events); | 2955 | Vunread_command_events = Fcons (c, Vunread_command_events); |
| @@ -4982,9 +4982,11 @@ make_lispy_position (f, x, y, time) | |||
| 4982 | { | 4982 | { |
| 4983 | /* It's a click in window window at frame coordinates (x,y) */ | 4983 | /* It's a click in window window at frame coordinates (x,y) */ |
| 4984 | struct window *w = XWINDOW (window); | 4984 | struct window *w = XWINDOW (window); |
| 4985 | Lisp_Object object = Qnil; | 4985 | Lisp_Object string_info = Qnil; |
| 4986 | int textpos = -1, rx = -1, ry = -1; | 4986 | int textpos = -1, rx = -1, ry = -1; |
| 4987 | int dx = -1, dy = -1; | 4987 | int dx = -1, dy = -1; |
| 4988 | int width = -1, height = -1; | ||
| 4989 | Lisp_Object object = Qnil; | ||
| 4988 | 4990 | ||
| 4989 | /* Set event coordinates to window-relative coordinates | 4991 | /* Set event coordinates to window-relative coordinates |
| 4990 | for constructing the Lisp event below. */ | 4992 | for constructing the Lisp event below. */ |
| @@ -5000,9 +5002,10 @@ make_lispy_position (f, x, y, time) | |||
| 5000 | 5002 | ||
| 5001 | posn = part == ON_MODE_LINE ? Qmode_line : Qheader_line; | 5003 | posn = part == ON_MODE_LINE ? Qmode_line : Qheader_line; |
| 5002 | rx = wx, ry = wy; | 5004 | rx = wx, ry = wy; |
| 5003 | string = mode_line_string (w, &rx, &ry, &dx, &dy, part, &charpos); | 5005 | string = mode_line_string (w, part, &rx, &ry, &charpos, |
| 5006 | &object, &dx, &dy, &width, &height); | ||
| 5004 | if (STRINGP (string)) | 5007 | if (STRINGP (string)) |
| 5005 | object = Fcons (string, make_number (charpos)); | 5008 | string_info = Fcons (string, make_number (charpos)); |
| 5006 | if (w == XWINDOW (selected_window)) | 5009 | if (w == XWINDOW (selected_window)) |
| 5007 | textpos = PT; | 5010 | textpos = PT; |
| 5008 | else | 5011 | else |
| @@ -5013,6 +5016,7 @@ make_lispy_position (f, x, y, time) | |||
| 5013 | posn = Qvertical_line; | 5016 | posn = Qvertical_line; |
| 5014 | wx = -1; | 5017 | wx = -1; |
| 5015 | dx = 0; | 5018 | dx = 0; |
| 5019 | width = 1; | ||
| 5016 | } | 5020 | } |
| 5017 | else if (part == ON_LEFT_MARGIN || part == ON_RIGHT_MARGIN) | 5021 | else if (part == ON_LEFT_MARGIN || part == ON_RIGHT_MARGIN) |
| 5018 | { | 5022 | { |
| @@ -5021,22 +5025,10 @@ make_lispy_position (f, x, y, time) | |||
| 5021 | 5025 | ||
| 5022 | posn = (part == ON_LEFT_MARGIN) ? Qleft_margin : Qright_margin; | 5026 | posn = (part == ON_LEFT_MARGIN) ? Qleft_margin : Qright_margin; |
| 5023 | rx = wx, ry = wy; | 5027 | rx = wx, ry = wy; |
| 5024 | string = marginal_area_string (w, &rx, &ry, &dx, &dy, part, &charpos); | 5028 | string = marginal_area_string (w, part, &rx, &ry, &charpos, |
| 5029 | &object, &dx, &dy, &width, &height); | ||
| 5025 | if (STRINGP (string)) | 5030 | if (STRINGP (string)) |
| 5026 | object = Fcons (string, make_number (charpos)); | 5031 | string_info = Fcons (string, make_number (charpos)); |
| 5027 | #ifdef HAVE_WINDOW_SYSTEM | ||
| 5028 | else if (IMAGEP (string)) | ||
| 5029 | { | ||
| 5030 | Lisp_Object image_map, hotspot; | ||
| 5031 | object = string; | ||
| 5032 | if ((image_map = Fplist_get (XCDR (object), QCmap), | ||
| 5033 | !NILP (image_map)) | ||
| 5034 | && (hotspot = find_hot_spot (image_map, dx, dy), | ||
| 5035 | CONSP (hotspot)) | ||
| 5036 | && (hotspot = XCDR (hotspot), CONSP (hotspot))) | ||
| 5037 | posn = XCAR (hotspot); | ||
| 5038 | } | ||
| 5039 | #endif | ||
| 5040 | } | 5032 | } |
| 5041 | else if (part == ON_LEFT_FRINGE || part == ON_RIGHT_FRINGE) | 5033 | else if (part == ON_LEFT_FRINGE || part == ON_RIGHT_FRINGE) |
| 5042 | { | 5034 | { |
| @@ -5055,46 +5047,60 @@ make_lispy_position (f, x, y, time) | |||
| 5055 | 5047 | ||
| 5056 | if (textpos < 0) | 5048 | if (textpos < 0) |
| 5057 | { | 5049 | { |
| 5058 | Lisp_Object string; | 5050 | Lisp_Object string2, object2 = Qnil; |
| 5059 | struct display_pos p; | 5051 | struct display_pos p; |
| 5060 | int dx2, dy2; | 5052 | int dx2, dy2; |
| 5053 | int width2, height2; | ||
| 5061 | wx = max (WINDOW_LEFT_MARGIN_WIDTH (w), wx); | 5054 | wx = max (WINDOW_LEFT_MARGIN_WIDTH (w), wx); |
| 5062 | buffer_posn_from_coords (w, &wx, &wy, &dx2, &dy2, &string, &p); | 5055 | string2 = buffer_posn_from_coords (w, &wx, &wy, &p, |
| 5056 | &object2, &dx2, &dy2, | ||
| 5057 | &width2, &height2); | ||
| 5063 | textpos = CHARPOS (p.pos); | 5058 | textpos = CHARPOS (p.pos); |
| 5064 | if (rx < 0) rx = wx; | 5059 | if (rx < 0) rx = wx; |
| 5065 | if (ry < 0) ry = wy; | 5060 | if (ry < 0) ry = wy; |
| 5066 | if (dx < 0) dx = dx2; | 5061 | if (dx < 0) dx = dx2; |
| 5067 | if (dy < 0) dy = dy2; | 5062 | if (dy < 0) dy = dy2; |
| 5063 | if (width < 0) width = width2; | ||
| 5064 | if (height < 0) height = height2; | ||
| 5068 | 5065 | ||
| 5069 | if (NILP (posn)) | 5066 | if (NILP (posn)) |
| 5070 | { | 5067 | { |
| 5071 | posn = make_number (textpos); | 5068 | posn = make_number (textpos); |
| 5072 | if (STRINGP (string)) | 5069 | if (STRINGP (string2)) |
| 5073 | object = Fcons (string, | 5070 | string_info = Fcons (string2, |
| 5074 | make_number (CHARPOS (p.string_pos))); | 5071 | make_number (CHARPOS (p.string_pos))); |
| 5075 | #ifdef HAVE_WINDOW_SYSTEM | ||
| 5076 | else if (IMAGEP (string)) | ||
| 5077 | { | ||
| 5078 | Lisp_Object image_map, hotspot; | ||
| 5079 | object = string; | ||
| 5080 | if ((image_map = Fplist_get (XCDR (object), QCmap), | ||
| 5081 | !NILP (image_map)) | ||
| 5082 | && (hotspot = find_hot_spot (image_map, dx, dy), | ||
| 5083 | CONSP (hotspot)) | ||
| 5084 | && (hotspot = XCDR (hotspot), CONSP (hotspot))) | ||
| 5085 | posn = XCAR (hotspot); | ||
| 5086 | } | ||
| 5087 | #endif | ||
| 5088 | } | 5072 | } |
| 5073 | if (NILP (object)) | ||
| 5074 | object = object2; | ||
| 5089 | } | 5075 | } |
| 5090 | 5076 | ||
| 5077 | #ifdef HAVE_WINDOW_SYSTEM | ||
| 5078 | if (IMAGEP (object)) | ||
| 5079 | { | ||
| 5080 | Lisp_Object image_map, hotspot; | ||
| 5081 | if ((image_map = Fplist_get (XCDR (object), QCmap), | ||
| 5082 | !NILP (image_map)) | ||
| 5083 | && (hotspot = find_hot_spot (image_map, dx, dy), | ||
| 5084 | CONSP (hotspot)) | ||
| 5085 | && (hotspot = XCDR (hotspot), CONSP (hotspot))) | ||
| 5086 | posn = XCAR (hotspot); | ||
| 5087 | } | ||
| 5088 | #endif | ||
| 5089 | |||
| 5090 | /* Object info */ | ||
| 5091 | extra_info = Fcons (object, | 5091 | extra_info = Fcons (object, |
| 5092 | Fcons (Fcons (make_number (dx), | ||
| 5093 | make_number (dy)), | ||
| 5094 | Fcons (Fcons (make_number (width), | ||
| 5095 | make_number (height)), | ||
| 5096 | Qnil))); | ||
| 5097 | |||
| 5098 | /* String info */ | ||
| 5099 | extra_info = Fcons (string_info, | ||
| 5092 | Fcons (make_number (textpos), | 5100 | Fcons (make_number (textpos), |
| 5093 | Fcons (Fcons (make_number (rx), | 5101 | Fcons (Fcons (make_number (rx), |
| 5094 | make_number (ry)), | 5102 | make_number (ry)), |
| 5095 | Fcons (Fcons (make_number (dx), | 5103 | extra_info))); |
| 5096 | make_number (dy)), | ||
| 5097 | Qnil)))); | ||
| 5098 | } | 5104 | } |
| 5099 | else if (f != 0) | 5105 | else if (f != 0) |
| 5100 | { | 5106 | { |
| @@ -8862,7 +8868,7 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, | |||
| 8862 | Lisp_Object window, posn; | 8868 | Lisp_Object window, posn; |
| 8863 | 8869 | ||
| 8864 | window = POSN_WINDOW (EVENT_START (key)); | 8870 | window = POSN_WINDOW (EVENT_START (key)); |
| 8865 | posn = POSN_BUFFER_POSN (EVENT_START (key)); | 8871 | posn = POSN_POSN (EVENT_START (key)); |
| 8866 | 8872 | ||
| 8867 | if (CONSP (posn) | 8873 | if (CONSP (posn) |
| 8868 | || (!NILP (fake_prefixed_keys) | 8874 | || (!NILP (fake_prefixed_keys) |
| @@ -8920,7 +8926,7 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, | |||
| 8920 | localized_local_map = 1; | 8926 | localized_local_map = 1; |
| 8921 | start = EVENT_START (key); | 8927 | start = EVENT_START (key); |
| 8922 | 8928 | ||
| 8923 | if (CONSP (start) && CONSP (XCDR (start))) | 8929 | if (CONSP (start) && POSN_INBUFFER_P (start)) |
| 8924 | { | 8930 | { |
| 8925 | pos = POSN_BUFFER_POSN (start); | 8931 | pos = POSN_BUFFER_POSN (start); |
| 8926 | if (INTEGERP (pos) | 8932 | if (INTEGERP (pos) |
| @@ -9030,7 +9036,7 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, | |||
| 9030 | { | 9036 | { |
| 9031 | Lisp_Object posn; | 9037 | Lisp_Object posn; |
| 9032 | 9038 | ||
| 9033 | posn = POSN_BUFFER_POSN (EVENT_START (key)); | 9039 | posn = POSN_POSN (EVENT_START (key)); |
| 9034 | /* Handle menu-bar events: | 9040 | /* Handle menu-bar events: |
| 9035 | insert the dummy prefix event `menu-bar'. */ | 9041 | insert the dummy prefix event `menu-bar'. */ |
| 9036 | if (EQ (posn, Qmenu_bar) || EQ (posn, Qtool_bar)) | 9042 | if (EQ (posn, Qmenu_bar) || EQ (posn, Qtool_bar)) |
| @@ -9042,8 +9048,8 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, | |||
| 9042 | 9048 | ||
| 9043 | /* Zap the position in key, so we know that we've | 9049 | /* Zap the position in key, so we know that we've |
| 9044 | expanded it, and don't try to do so again. */ | 9050 | expanded it, and don't try to do so again. */ |
| 9045 | POSN_BUFFER_SET_POSN (EVENT_START (key), | 9051 | POSN_SET_POSN (EVENT_START (key), |
| 9046 | Fcons (posn, Qnil)); | 9052 | Fcons (posn, Qnil)); |
| 9047 | 9053 | ||
| 9048 | mock_input = t + 2; | 9054 | mock_input = t + 2; |
| 9049 | goto replay_sequence; | 9055 | goto replay_sequence; |