From: Po Lu Date: Sun, 9 Jun 2024 13:25:08 +0000 (+0800) Subject: Enable accessing tool bar with the touch screen X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=49711b1c7a56e5836b944c9ab356bc6207addb24;p=emacs.git Enable accessing tool bar with the touch screen * 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) : New field. (cherry picked from commit f22ae39a1ae563c0318cb86e913345abba4b6d8c) --- diff --git a/src/w32fns.c b/src/w32fns.c index 062ed0f5ef2..5b0e4a895d0 100644 --- a/src/w32fns.c +++ b/src/w32fns.c @@ -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; } diff --git a/src/w32term.c b/src/w32term.c index 61185279cf9..62037e3b2cd 100644 --- a/src/w32term.c +++ b/src/w32term.c @@ -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) diff --git a/src/w32term.h b/src/w32term.h index 1cdb165d2ed..47be542f570 100644 --- a/src/w32term.h +++ b/src/w32term.h @@ -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;