diff options
| author | Dmitry Antipov | 2014-09-24 11:17:51 +0400 |
|---|---|---|
| committer | Dmitry Antipov | 2014-09-24 11:17:51 +0400 |
| commit | 4b930ccbb4fc4b848f318e09eddd172c2acf9b9b (patch) | |
| tree | 349f033caa6278c11cae123b8d2f949ec7e3df10 /src/keyboard.c | |
| parent | 4620e6bccd98625208d8be4d960d24119a20594f (diff) | |
| download | emacs-4b930ccbb4fc4b848f318e09eddd172c2acf9b9b.tar.gz emacs-4b930ccbb4fc4b848f318e09eddd172c2acf9b9b.zip | |
* termhooks.h (enum scroll_bar_part): Begin from 0 to allow...
(struct input_event): ...unsigned bitfields. Likewise for
`event_kind' member. Prefer unsigned for `code' and 'modifiers'.
Use `timestamp' for HELP_EVENT position. Add compile-time assert.
* keyboard.c (gen_help_event, kbd_buffer_store_help_event)
(kbd_buffer_get_event): Adjust users.
(scroll_bar_parts): Add Qnil to match scroll_bar_nowhere.
(make_scroll_bar_position): New function, refactored out of...
(make_lispy_event): ...adjusted user.
* nsterm.h (EmacsScroller): Use enum for `last_hit_part' member.
* nsterm.m (ns_mouse_position, mouseUp):
* term.c (term_mouse_position):
* w32inevt.c (w32_console_mouse_position):
* w32term.c (w32_mouse_position):
* xterm.c (XTmouse_position): Use scroll_bar_above_handle.
(x_send_scroll_bar_event, xm_scroll_callback, xg_scroll_callback):
Prefer enum and explicit enum members to integers and numeric values.
Diffstat (limited to 'src/keyboard.c')
| -rw-r--r-- | src/keyboard.c | 58 |
1 files changed, 23 insertions, 35 deletions
diff --git a/src/keyboard.c b/src/keyboard.c index f79c1c94167..7625586650f 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -3747,14 +3747,12 @@ gen_help_event (Lisp_Object help, Lisp_Object frame, Lisp_Object window, | |||
| 3747 | { | 3747 | { |
| 3748 | struct input_event event; | 3748 | struct input_event event; |
| 3749 | 3749 | ||
| 3750 | EVENT_INIT (event); | ||
| 3751 | |||
| 3752 | event.kind = HELP_EVENT; | 3750 | event.kind = HELP_EVENT; |
| 3753 | event.frame_or_window = frame; | 3751 | event.frame_or_window = frame; |
| 3754 | event.arg = object; | 3752 | event.arg = object; |
| 3755 | event.x = WINDOWP (window) ? window : frame; | 3753 | event.x = WINDOWP (window) ? window : frame; |
| 3756 | event.y = help; | 3754 | event.y = help; |
| 3757 | event.code = pos; | 3755 | event.timestamp = pos; |
| 3758 | kbd_buffer_store_event (&event); | 3756 | kbd_buffer_store_event (&event); |
| 3759 | } | 3757 | } |
| 3760 | 3758 | ||
| @@ -3771,7 +3769,7 @@ kbd_buffer_store_help_event (Lisp_Object frame, Lisp_Object help) | |||
| 3771 | event.arg = Qnil; | 3769 | event.arg = Qnil; |
| 3772 | event.x = Qnil; | 3770 | event.x = Qnil; |
| 3773 | event.y = help; | 3771 | event.y = help; |
| 3774 | event.code = 0; | 3772 | event.timestamp = 0; |
| 3775 | kbd_buffer_store_event (&event); | 3773 | kbd_buffer_store_event (&event); |
| 3776 | } | 3774 | } |
| 3777 | 3775 | ||
| @@ -4086,7 +4084,7 @@ kbd_buffer_get_event (KBOARD **kbp, | |||
| 4086 | 4084 | ||
| 4087 | frame = event->frame_or_window; | 4085 | frame = event->frame_or_window; |
| 4088 | object = event->arg; | 4086 | object = event->arg; |
| 4089 | position = make_number (event->code); | 4087 | position = make_number (event->timestamp); |
| 4090 | window = event->x; | 4088 | window = event->x; |
| 4091 | help = event->y; | 4089 | help = event->y; |
| 4092 | clear_event (event); | 4090 | clear_event (event); |
| @@ -5201,9 +5199,11 @@ static Lisp_Object Qleftmost, Qrightmost; | |||
| 5201 | static Lisp_Object Qend_scroll; | 5199 | static Lisp_Object Qend_scroll; |
| 5202 | static Lisp_Object Qratio; | 5200 | static Lisp_Object Qratio; |
| 5203 | 5201 | ||
| 5204 | /* An array of scroll bar parts, indexed by an enum scroll_bar_part value. */ | 5202 | /* An array of scroll bar parts, indexed by an enum scroll_bar_part value. |
| 5203 | Note that Qnil corresponds to scroll_bar_nowhere and should not appear | ||
| 5204 | in Lisp events. */ | ||
| 5205 | static Lisp_Object *const scroll_bar_parts[] = { | 5205 | static Lisp_Object *const scroll_bar_parts[] = { |
| 5206 | &Qabove_handle, &Qhandle, &Qbelow_handle, | 5206 | &Qnil, &Qabove_handle, &Qhandle, &Qbelow_handle, |
| 5207 | &Qup, &Qdown, &Qtop, &Qbottom, &Qend_scroll, &Qratio, | 5207 | &Qup, &Qdown, &Qtop, &Qbottom, &Qend_scroll, &Qratio, |
| 5208 | &Qbefore_handle, &Qhorizontal_handle, &Qafter_handle, | 5208 | &Qbefore_handle, &Qhorizontal_handle, &Qafter_handle, |
| 5209 | &Qleft, &Qright, &Qleftmost, &Qrightmost, &Qend_scroll, &Qratio | 5209 | &Qleft, &Qright, &Qleftmost, &Qrightmost, &Qend_scroll, &Qratio |
| @@ -5450,6 +5450,16 @@ toolkit_menubar_in_use (struct frame *f) | |||
| 5450 | #endif | 5450 | #endif |
| 5451 | } | 5451 | } |
| 5452 | 5452 | ||
| 5453 | /* Build the part of Lisp event which represents scroll bar state from | ||
| 5454 | EV. TYPE is one of Qvertical_scroll_bar or Qhorizontal_scroll_bar. */ | ||
| 5455 | |||
| 5456 | static Lisp_Object | ||
| 5457 | make_scroll_bar_position (struct input_event *ev, Lisp_Object type) | ||
| 5458 | { | ||
| 5459 | return list5 (ev->frame_or_window, type, Fcons (ev->x, ev->y), | ||
| 5460 | make_number (ev->timestamp), *scroll_bar_parts[ev->part]); | ||
| 5461 | } | ||
| 5462 | |||
| 5453 | /* Given a struct input_event, build the lisp event which represents | 5463 | /* Given a struct input_event, build the lisp event which represents |
| 5454 | it. If EVENT is 0, build a mouse movement event from the mouse | 5464 | it. If EVENT is 0, build a mouse movement event from the mouse |
| 5455 | movement buffer, which should have a movement event in it. | 5465 | movement buffer, which should have a movement event in it. |
| @@ -5667,20 +5677,8 @@ make_lispy_event (struct input_event *event) | |||
| 5667 | } | 5677 | } |
| 5668 | #ifndef USE_TOOLKIT_SCROLL_BARS | 5678 | #ifndef USE_TOOLKIT_SCROLL_BARS |
| 5669 | else | 5679 | else |
| 5670 | { | 5680 | /* It's a scrollbar click. */ |
| 5671 | /* It's a scrollbar click. */ | 5681 | position = make_scroll_bar_position (event, Qvertical_scroll_bar); |
| 5672 | Lisp_Object window; | ||
| 5673 | Lisp_Object portion_whole; | ||
| 5674 | Lisp_Object part; | ||
| 5675 | |||
| 5676 | window = event->frame_or_window; | ||
| 5677 | portion_whole = Fcons (event->x, event->y); | ||
| 5678 | part = *scroll_bar_parts[(int) event->part]; | ||
| 5679 | |||
| 5680 | position = list5 (window, Qvertical_scroll_bar, | ||
| 5681 | portion_whole, make_number (event->timestamp), | ||
| 5682 | part); | ||
| 5683 | } | ||
| 5684 | #endif /* not USE_TOOLKIT_SCROLL_BARS */ | 5682 | #endif /* not USE_TOOLKIT_SCROLL_BARS */ |
| 5685 | 5683 | ||
| 5686 | if (button >= ASIZE (button_down_location)) | 5684 | if (button >= ASIZE (button_down_location)) |
| @@ -5957,14 +5955,9 @@ make_lispy_event (struct input_event *event) | |||
| 5957 | 5955 | ||
| 5958 | case SCROLL_BAR_CLICK_EVENT: | 5956 | case SCROLL_BAR_CLICK_EVENT: |
| 5959 | { | 5957 | { |
| 5960 | Lisp_Object position, head, window, portion_whole, part; | 5958 | Lisp_Object position, head; |
| 5961 | 5959 | ||
| 5962 | window = event->frame_or_window; | 5960 | position = make_scroll_bar_position (event, Qvertical_scroll_bar); |
| 5963 | portion_whole = Fcons (event->x, event->y); | ||
| 5964 | part = *scroll_bar_parts[(int) event->part]; | ||
| 5965 | |||
| 5966 | position = list5 (window, Qvertical_scroll_bar, portion_whole, | ||
| 5967 | make_number (event->timestamp), part); | ||
| 5968 | 5961 | ||
| 5969 | /* Always treat scroll bar events as clicks. */ | 5962 | /* Always treat scroll bar events as clicks. */ |
| 5970 | event->modifiers |= click_modifier; | 5963 | event->modifiers |= click_modifier; |
| @@ -5987,14 +5980,9 @@ make_lispy_event (struct input_event *event) | |||
| 5987 | 5980 | ||
| 5988 | case HORIZONTAL_SCROLL_BAR_CLICK_EVENT: | 5981 | case HORIZONTAL_SCROLL_BAR_CLICK_EVENT: |
| 5989 | { | 5982 | { |
| 5990 | Lisp_Object position, head, window, portion_whole, part; | 5983 | Lisp_Object position, head; |
| 5991 | |||
| 5992 | window = event->frame_or_window; | ||
| 5993 | portion_whole = Fcons (event->x, event->y); | ||
| 5994 | part = *scroll_bar_parts[(int) event->part]; | ||
| 5995 | 5984 | ||
| 5996 | position = list5 (window, Qhorizontal_scroll_bar, portion_whole, | 5985 | position = make_scroll_bar_position (event, Qhorizontal_scroll_bar); |
| 5997 | make_number (event->timestamp), part); | ||
| 5998 | 5986 | ||
| 5999 | /* Always treat scroll bar events as clicks. */ | 5987 | /* Always treat scroll bar events as clicks. */ |
| 6000 | event->modifiers |= click_modifier; | 5988 | event->modifiers |= click_modifier; |