]> git.eshelyaron.com Git - emacs.git/commitdiff
Enable accessing tool bar with the touch screen
authorPo Lu <luangruo@yahoo.com>
Sun, 9 Jun 2024 13:25:08 +0000 (21:25 +0800)
committerEshel Yaron <me@eshelyaron.com>
Mon, 10 Jun 2024 07:26:16 +0000 (09:26 +0200)
* src/w32fns.c (w32_createwindow): Reset tool_bar_dwID.

* src/w32term.c (w32_read_socket): Reserve touch event sequences
that fall on the tool bar for future tool-bar manipulation.

* src/w32term.h (struct w32_output) <tool_bar_dwID>: New field.

(cherry picked from commit f22ae39a1ae563c0318cb86e913345abba4b6d8c)

src/w32fns.c
src/w32term.c
src/w32term.h

index 062ed0f5ef25783ef32326c3029699e43edda196..5b0e4a895d0fc469184e234576521309f9952104 100644 (file)
@@ -2592,6 +2592,9 @@ w32_createwindow (struct frame *f, int *coords)
       f->output_data.w32->touch_base = touch_base;
       touch_base += MAX_TOUCH_POINTS;
 
+      /* Reset the tool bar touch sequence identifier slot.  */
+      f->output_data.w32->tool_bar_dwID = -1;
+
       f->left_pos = rect.left;
       f->top_pos = rect.top;
     }
index 61185279cf9098ea3d1f50def3eaa057a3ed90a0..62037e3b2cd7fea02ae14da8e9402792a1ef58bc 100644 (file)
@@ -6117,7 +6117,7 @@ w32_read_socket (struct terminal *terminal,
          if (f)
            {
              TOUCHINPUT *points;
-             int i, x, px, py;
+             int i, x UNINIT, px, py;
              POINT pt;
 
              points = alloca (sizeof *points * LOWORD (msg.msg.wParam));
@@ -6137,6 +6137,20 @@ w32_read_socket (struct terminal *terminal,
                      if (!points[i].dwID)
                        continue;
 
+                     /* Skip to `touch_located' if the point is
+                        reserved for the tool bar, and hasn't just been
+                        placed.  */
+                     if (points[i].dwID
+                         == FRAME_OUTPUT_DATA (f)->tool_bar_dwID)
+                       {
+                         if (points[i].dwFlags & TOUCHEVENTF_UP)
+                           goto touch_located;
+
+                         /* Other like events should be simply
+                            discarded.  */
+                         continue;
+                       }
+
                      /* Search for a slot in touch_ids that is either
                         empty or matches dwID.  */
                      for (x = 0; x < MAX_TOUCH_POINTS; x++)
@@ -6171,6 +6185,18 @@ w32_read_socket (struct terminal *terminal,
 
                      if (points[i].dwFlags & TOUCHEVENTF_UP)
                        {
+                         if (points[i].dwID
+                             == FRAME_OUTPUT_DATA (f)->tool_bar_dwID)
+                           {
+                             FRAME_OUTPUT_DATA (f)->tool_bar_dwID = -1;
+                             if (f->last_tool_bar_item != -1)
+                               handle_tool_bar_click (f, px, py, false, 0);
+
+                             /* Cancel any outstanding mouse highlight.  */
+                             note_mouse_highlight (f, -1, -1);
+                             continue;
+                           }
+
                          /* Clear the entry in touch_ids and report the
                             change.  Unless, of course, the entry be
                             empty.  */
@@ -6190,37 +6216,67 @@ w32_read_socket (struct terminal *terminal,
                      else if (points[i].dwFlags & TOUCHEVENTF_DOWN)
                        {
                          bool recorded_p;
+                         Lisp_Object window;
 
-                       touchscreen_down:
                          recorded_p
                            = FRAME_OUTPUT_DATA (f)->touch_ids[x] != -1;
 
-                         /* Report and record (if not already recorded)
-                            the addition.  */
-                         FRAME_OUTPUT_DATA (f)->touch_ids[x] = points[i].dwID;
+                         /* Update the local record of its
+                            position.  */
                          FRAME_OUTPUT_DATA (f)->touch_x[x] = px;
                          FRAME_OUTPUT_DATA (f)->touch_y[x] = py;
 
                          if (recorded_p)
-                           movement_p = true;
-                         else
                            {
-                             inev.kind = TOUCHSCREEN_BEGIN_EVENT;
-                             inev.timestamp = msg.msg.time;
-                             XSETFRAME (inev.frame_or_window, f);
-                             XSETINT (inev.x, px);
-                             XSETINT (inev.y, py);
-                             XSETINT (inev.arg, x + base);
-                             kbd_buffer_store_event (&inev);
-                             EVENT_INIT (inev);
+                             movement_p = true;
+                             continue;
+                           }
+
+                         /* This event might have landed above the tool
+                            bar, which if true its dwID should be
+                            reserved for manipulation of the tool bar.  */
+                         window = window_from_coordinates (f, px, py, 0,
+                                                           true, true, true);
+                         if (EQ (window, f->tool_bar_window))
+                           {
+                             if (!NILP (Vmouse_highlight))
+                               {
+                                 note_mouse_highlight (f, px, py);
+
+                                 /* Always allow future mouse motion to
+                                    update the mouse highlight, no matter
+                                    where it is.  */
+                                 memset (&dpyinfo->last_mouse_glyph, 0,
+                                         sizeof dpyinfo->last_mouse_glyph);
+                                 dpyinfo->last_mouse_glyph_frame = f;
+                               }
+
+                             handle_tool_bar_click (f, px, py, true, 0);
+                             FRAME_OUTPUT_DATA (f)->tool_bar_dwID
+                               = points[i].dwID;
+                             continue;
                            }
+
+                         /* Report and record (if not already recorded)
+                            the addition.  */
+                         FRAME_OUTPUT_DATA (f)->touch_ids[x] = points[i].dwID;
+
+                         inev.kind = TOUCHSCREEN_BEGIN_EVENT;
+                         inev.timestamp = msg.msg.time;
+                         XSETFRAME (inev.frame_or_window, f);
+                         XSETINT (inev.x, px);
+                         XSETINT (inev.y, py);
+                         XSETINT (inev.arg, x + base);
+                         kbd_buffer_store_event (&inev);
+                         EVENT_INIT (inev);
                        }
                      else
                        {
                          bool recorded_p
                            = FRAME_OUTPUT_DATA (f)->touch_ids[x] != -1;
+
                          if (!recorded_p)
-                           goto touchscreen_down;
+                           continue;
 
                          if (FRAME_OUTPUT_DATA (f)->touch_x[x] != px
                              || FRAME_OUTPUT_DATA (f)->touch_y[x] != py)
index 1cdb165d2eddc5aec4a05c4b07bbd9476e3c37f2..47be542f57076bd4a853fa69ddc581c31cf6ddc8 100644 (file)
@@ -446,6 +446,10 @@ struct w32_output
   /* Base value for touch point identifiers registered by this
      frame.  */
   EMACS_INT touch_base;
+
+  /* Windows identifier of any touch point reserved for the tool bar, or
+     -1.  */
+  DWORD tool_bar_dwID;
 };
 
 extern struct w32_output w32term_display;