emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] scratch/touch aced8e8: Change events to match mac port eve


From: Alan Third
Subject: [Emacs-diffs] scratch/touch aced8e8: Change events to match mac port events
Date: Tue, 27 Jun 2017 16:00:57 -0400 (EDT)

branch: scratch/touch
commit aced8e8482f93683d7f1299782901e8c2990c704
Author: Alan Third <address@hidden>
Commit: Alan Third <address@hidden>

    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.
---
 lisp/touch.el   |  5 ++--
 src/keyboard.c  | 71 ++++++++-------------------------------------------------
 src/nsterm.m    | 20 +++++++++-------
 src/termhooks.h | 21 +++--------------
 4 files changed, 27 insertions(+), 90 deletions(-)

diff --git a/lisp/touch.el b/lisp/touch.el
index ef38f47..4e7b614 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 747776f..902005f 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 f9710d5..aad5b2a 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 08f6884..2c04f62 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]