Commit aced8e84 authored by Alan Third's avatar Alan Third

Change events to match mac port events

The changelog from the commit two before will cover this if they're
squashed, which is my plan. Hence no changelog entry here.
parent d932d344
Pipeline #38 failed with stage
......@@ -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
......
......@@ -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) \
......
......@@ -6561,7 +6561,6 @@ - (void)magnifyWithEvent: (NSEvent *) e
{
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 @@ - (void)magnifyWithEvent: (NSEvent *) e
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 @@ - (void)swipeWithEvent: (NSEvent *) e
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 @@ - (void)rotateWithEvent: (NSEvent *) e
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);
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment