diff options
author | Alan Third <alan@idiocy.org> | 2017-06-27 20:59:05 +0100 |
---|---|---|
committer | Alan Third <alan@idiocy.org> | 2017-06-27 20:59:05 +0100 |
commit | aced8e8482f93683d7f1299782901e8c2990c704 (patch) | |
tree | 897a5606547a77ab27c878a06a77bc8e1c08f473 | |
parent | d932d344ee33d23e8237b78a5a7d123e813aed18 (diff) | |
download | emacs-scratch/touch.tar.gz |
Change events to match mac port eventsscratch/touch
The changelog from the commit two before will cover this if they're
squashed, which is my plan. Hence no changelog entry here.
-rw-r--r-- | lisp/touch.el | 5 | ||||
-rw-r--r-- | src/keyboard.c | 71 | ||||
-rw-r--r-- | src/nsterm.m | 20 | ||||
-rw-r--r-- | src/termhooks.h | 21 |
4 files changed, 27 insertions, 90 deletions
diff --git a/lisp/touch.el b/lisp/touch.el index ef38f473753..4e7b6145159 100644 --- a/lisp/touch.el +++ b/lisp/touch.el @@ -57,7 +57,7 @@ (defun touch-gesture--pinch (event) "Increase or decrease the text scale according to EVENT." (interactive (list last-input-event)) - (let ((delta (caddr event))) + (let ((delta (* 25 (caddr event)))) (if (not (= delta 0)) (text-scale-increase delta)))) @@ -76,7 +76,8 @@ factor. (global-unset-key [touch-scroll]) (when touch-gesture-mode (global-set-key [touch-scroll] 'touch-gesture--scroll) - (global-set-key [touch-pinch] 'touch-gesture--pinch))) + (global-set-key [magnify-up] 'touch-gesture--pinch) + (global-set-key [magnify-down] 'touch-gesture--pinch))) ;;; Compatibility entry point ;; preloaded ;;;###autoload diff --git a/src/keyboard.c b/src/keyboard.c index 747776f73dd..902005fed21 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -5110,8 +5110,8 @@ static const char *const lispy_wheel_names[] = static const char *const touch_names[] = { - "touch-scroll", "touch-pinch", "touch-rotate", "touch-swipe-up", - "touch-swipe-down", "touch-swipe-left", "touch-swipe-right" + "touch-scroll", "magnify-up", "magnify-down", "rotate-right", "rotate-left", + "swipe-up", "swipe-down", "swipe-left", "swipe-right" }; /* drag-n-drop events are generated when a set of selected files are @@ -6053,11 +6053,12 @@ make_lispy_event (struct input_event *event) return list3 (head, position, deltas); } - case TOUCH_PINCH_EVENT: + case TOUCH_GESTURE_EVENT: { Lisp_Object position; Lisp_Object head; - Lisp_Object delta = event->arg; + Lisp_Object arg = event->arg; + int symbol_num = event->code; struct frame *f = XFRAME (event->frame_or_window); /* Ignore touch events that were made on frame that have @@ -6068,67 +6069,13 @@ make_lispy_event (struct input_event *event) position = make_lispy_position (f, event->x, event->y, event->timestamp); - head = modify_event_symbol (1, event->modifiers, Qtouch_gesture, Qnil, - touch_names, &touch_syms, ASIZE (touch_syms)); - - return list3 (head, position, delta); - } - - case TOUCH_SWIPE_UP_EVENT: - case TOUCH_SWIPE_DOWN_EVENT: - case TOUCH_SWIPE_LEFT_EVENT: - case TOUCH_SWIPE_RIGHT_EVENT: - { - Lisp_Object position; - Lisp_Object head; - struct frame *f = XFRAME (event->frame_or_window); - int symbol_num; - - /* Ignore touch events that were made on frame that have - been deleted. */ - if (! FRAME_LIVE_P (f)) - return Qnil; - - position = make_lispy_position (f, event->x, event->y, - event->timestamp); - - switch (event->kind) - { - case TOUCH_SWIPE_UP_EVENT: - symbol_num = 3; - case TOUCH_SWIPE_DOWN_EVENT: - symbol_num = 4; - case TOUCH_SWIPE_LEFT_EVENT: - symbol_num = 5; - case TOUCH_SWIPE_RIGHT_EVENT: - symbol_num = 6; - } - head = modify_event_symbol (symbol_num, event->modifiers, Qtouch_gesture, Qnil, touch_names, &touch_syms, ASIZE (touch_syms)); - return list2 (head, position); - } - - case TOUCH_ROTATE_EVENT: - { - Lisp_Object position; - Lisp_Object head; - Lisp_Object rotation = event->arg; - struct frame *f = XFRAME (event->frame_or_window); - - /* Ignore touch events that were made on frame that have - been deleted. */ - if (! FRAME_LIVE_P (f)) - return Qnil; - - position = make_lispy_position (f, event->x, event->y, - event->timestamp); - - head = modify_event_symbol (2, event->modifiers, Qtouch_gesture, Qnil, - touch_names, &touch_syms, ASIZE (touch_syms)); - - return list3 (head, position, rotation); + if (NILP(arg)) + return list2 (head, position); + else + return list3 (head, position, arg); } #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \ diff --git a/src/nsterm.m b/src/nsterm.m index f9710d573d6..aad5b2ab86c 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -6561,7 +6561,6 @@ not_in_argv (NSString *arg) { struct ns_display_info *dpyinfo = FRAME_DISPLAY_INFO (emacsframe); NSPoint p = [self convertPoint: [e locationInWindow] fromView: nil]; - Lisp_Object delta; NSTRACE ("[EmacsView magnifyWithEvent:]"); @@ -6572,10 +6571,10 @@ not_in_argv (NSString *arg) dpyinfo->last_mouse_frame = emacsframe; - delta = make_float ([e magnification] * 25); - - emacs_event->kind = TOUCH_PINCH_EVENT; - emacs_event->arg = delta; + /* code 1 is 'magnify-up', code 2 is 'magnify-down'. */ + emacs_event->code = ([e magnification] > 0) ? 1 : 2; + emacs_event->arg = make_float ([e magnification]); + emacs_event->kind = TOUCH_GESTURE_EVENT; emacs_event->modifiers = EV_MODIFIERS (e) | EV_UDMODIFIERS (e); @@ -6602,12 +6601,14 @@ not_in_argv (NSString *arg) dpyinfo->last_mouse_frame = emacsframe; if (dx != 0) - emacs_event->kind = (dx > 0) ? TOUCH_SWIPE_LEFT_EVENT : TOUCH_SWIPE_RIGHT_EVENT; + emacs_event->code = (dx > 0) ? 7 : 8; else if (dy != 0) - emacs_event->kind = (dy > 0) ? TOUCH_SWIPE_UP_EVENT : TOUCH_SWIPE_DOWN_EVENT; + emacs_event->code = (dy > 0) ? 5 : 6; else return; /* No swipe direction detected. */ + emacs_event->kind = TOUCH_GESTURE_EVENT; + emacs_event->arg = Qnil; emacs_event->modifiers = EV_MODIFIERS (e) | EV_UDMODIFIERS (e); @@ -6631,7 +6632,10 @@ not_in_argv (NSString *arg) dpyinfo->last_mouse_frame = emacsframe; - emacs_event->kind = TOUCH_ROTATE_EVENT; + /* Code 3 is 'rotate-right', code 4 is 'rotate-left'. */ + emacs_event->code = ([e rotation] < 0) ? 3 : 4; + + emacs_event->kind = TOUCH_GESTURE_EVENT; emacs_event->arg = make_float([e rotation]);; emacs_event->modifiers = EV_MODIFIERS (e) | EV_UDMODIFIERS (e); diff --git a/src/termhooks.h b/src/termhooks.h index 08f6884da44..2c04f62d092 100644 --- a/src/termhooks.h +++ b/src/termhooks.h @@ -128,29 +128,14 @@ enum event_kind position. .arg holds a list in the form: (delta-x delta-y). */ - TOUCH_PINCH_EVENT, /* Touch pinch event generated by a + TOUCH_GESTURE_EVENT, /* Touch pinch event generated by a touchpad or touch screen. .modifiers holds the state of any modifier keys. .x and .y contain the mouse position. - .arg holds the pinch delta as a float. */ - TOUCH_ROTATE_EVENT, /* Touch rotate event generated by a - touchpad or touch screen. - .modifiers holds the state of any - modifier keys. - .x and .y contain the mouse - position. - .arg holds the rotation delta as a - float. */ - /* The following four events are touch swipe events generated by a - touchpad or touchscreen. - .modifiers holds the state of any modifier keys. - .x and .y contain the mouse position. */ - TOUCH_SWIPE_UP_EVENT, - TOUCH_SWIPE_DOWN_EVENT, - TOUCH_SWIPE_LEFT_EVENT, - TOUCH_SWIPE_RIGHT_EVENT, + .arg, if non-NULL, holds the delta + as a float. */ #ifdef HAVE_NTGUI LANGUAGE_CHANGE_EVENT, /* A LANGUAGE_CHANGE_EVENT is generated when HAVE_NTGUI or on Mac OS |