diff options
| author | Po Lu | 2024-06-01 21:27:51 +0800 |
|---|---|---|
| committer | Po Lu | 2024-06-01 21:33:19 +0800 |
| commit | 7af5d6fc9a352d4f53f8e48a6bc9ae9a3bf235a3 (patch) | |
| tree | 67417b08d0a225611aec934023478a28a32c5316 /src | |
| parent | b4a93b4484c7406a395f1c1f3e8d1236138ba2a9 (diff) | |
| download | emacs-7af5d6fc9a352d4f53f8e48a6bc9ae9a3bf235a3.tar.gz emacs-7af5d6fc9a352d4f53f8e48a6bc9ae9a3bf235a3.zip | |
Improve touch-screen support on PGTK
* lisp/touch-screen.el (touch-screen-translate-touch): Do not
prepend posn if the symbol is such that keyboard.c will do so
immediately after returning.
* src/pgtkterm.c (pgtk_toolkit_position): Remove mistakenly
ported code.
(pgtk_create_terminal): Remove toolkit_position hook.
(motion_notify_event, button_event): Ignore emulated pointer
events, and apply an additional test to circumvent a GDK
oversight.
(touch_event_cb): Correct return type, and provide touch
sequence initialization and removal events as
`last_click_event's.
Diffstat (limited to 'src')
| -rw-r--r-- | src/pgtkterm.c | 66 |
1 files changed, 34 insertions, 32 deletions
diff --git a/src/pgtkterm.c b/src/pgtkterm.c index 886f115c391..49b7ea406f8 100644 --- a/src/pgtkterm.c +++ b/src/pgtkterm.c | |||
| @@ -224,34 +224,6 @@ pgtk_regenerate_devices (struct pgtk_display_info *dpyinfo) | |||
| 224 | pgtk_enumerate_devices (dpyinfo, false); | 224 | pgtk_enumerate_devices (dpyinfo, false); |
| 225 | } | 225 | } |
| 226 | 226 | ||
| 227 | static void | ||
| 228 | pgtk_toolkit_position (struct frame *f, int x, int y, | ||
| 229 | bool *menu_bar_p, bool *tool_bar_p) | ||
| 230 | { | ||
| 231 | GdkRectangle test_rect; | ||
| 232 | int scale; | ||
| 233 | |||
| 234 | y += (FRAME_MENUBAR_HEIGHT (f) | ||
| 235 | + FRAME_TOOLBAR_TOP_HEIGHT (f)); | ||
| 236 | x += FRAME_TOOLBAR_LEFT_WIDTH (f); | ||
| 237 | |||
| 238 | if (FRAME_EXTERNAL_MENU_BAR (f)) | ||
| 239 | *menu_bar_p = (x >= 0 && x < FRAME_PIXEL_WIDTH (f) | ||
| 240 | && y >= 0 && y < FRAME_MENUBAR_HEIGHT (f)); | ||
| 241 | |||
| 242 | if (FRAME_X_OUTPUT (f)->toolbar_widget) | ||
| 243 | { | ||
| 244 | scale = xg_get_scale (f); | ||
| 245 | test_rect.x = x / scale; | ||
| 246 | test_rect.y = y / scale; | ||
| 247 | test_rect.width = 1; | ||
| 248 | test_rect.height = 1; | ||
| 249 | |||
| 250 | *tool_bar_p = gtk_widget_intersect (FRAME_X_OUTPUT (f)->toolbar_widget, | ||
| 251 | &test_rect, NULL); | ||
| 252 | } | ||
| 253 | } | ||
| 254 | |||
| 255 | static Lisp_Object | 227 | static Lisp_Object |
| 256 | pgtk_get_device_for_event (struct pgtk_display_info *dpyinfo, | 228 | pgtk_get_device_for_event (struct pgtk_display_info *dpyinfo, |
| 257 | GdkEvent *event) | 229 | GdkEvent *event) |
| @@ -4042,8 +4014,8 @@ xg_scroll_callback (GtkRange * range, | |||
| 4042 | /* Callback for button release. Sets dragging to -1 when dragging is done. */ | 4014 | /* Callback for button release. Sets dragging to -1 when dragging is done. */ |
| 4043 | 4015 | ||
| 4044 | static gboolean | 4016 | static gboolean |
| 4045 | xg_end_scroll_callback (GtkWidget * widget, | 4017 | xg_end_scroll_callback (GtkWidget *widget, |
| 4046 | GdkEventButton * event, gpointer user_data) | 4018 | GdkEventButton *event, gpointer user_data) |
| 4047 | { | 4019 | { |
| 4048 | struct scroll_bar *bar = user_data; | 4020 | struct scroll_bar *bar = user_data; |
| 4049 | bar->dragging = -1; | 4021 | bar->dragging = -1; |
| @@ -4889,7 +4861,6 @@ pgtk_create_terminal (struct pgtk_display_info *dpyinfo) | |||
| 4889 | terminal->focus_frame_hook = pgtk_focus_frame; | 4861 | terminal->focus_frame_hook = pgtk_focus_frame; |
| 4890 | terminal->set_frame_offset_hook = pgtk_set_offset; | 4862 | terminal->set_frame_offset_hook = pgtk_set_offset; |
| 4891 | terminal->free_pixmap = pgtk_free_pixmap; | 4863 | terminal->free_pixmap = pgtk_free_pixmap; |
| 4892 | terminal->toolkit_position_hook = pgtk_toolkit_position; | ||
| 4893 | 4864 | ||
| 4894 | /* Other hooks are NULL by default. */ | 4865 | /* Other hooks are NULL by default. */ |
| 4895 | 4866 | ||
| @@ -5929,6 +5900,17 @@ motion_notify_event (GtkWidget *widget, GdkEvent *event, | |||
| 5929 | struct frame *f, *frame; | 5900 | struct frame *f, *frame; |
| 5930 | struct pgtk_display_info *dpyinfo; | 5901 | struct pgtk_display_info *dpyinfo; |
| 5931 | Mouse_HLInfo *hlinfo; | 5902 | Mouse_HLInfo *hlinfo; |
| 5903 | GdkDevice *device; | ||
| 5904 | |||
| 5905 | /* Ignore emulated pointer events generated from a touch screen | ||
| 5906 | event. */ | ||
| 5907 | if (gdk_event_get_pointer_emulated (event) | ||
| 5908 | /* The event must not have emerged from a touch device either, as | ||
| 5909 | GDK does not set pointer_emulated in events generated on | ||
| 5910 | Wayland as on X, and as the X Input Extension specifies. */ | ||
| 5911 | || ((device = gdk_event_get_source_device (event)) | ||
| 5912 | && (gdk_device_get_source (device) == GDK_SOURCE_TOUCHSCREEN))) | ||
| 5913 | return FALSE; | ||
| 5932 | 5914 | ||
| 5933 | EVENT_INIT (inev.ie); | 5915 | EVENT_INIT (inev.ie); |
| 5934 | inev.ie.kind = NO_EVENT; | 5916 | inev.ie.kind = NO_EVENT; |
| @@ -6068,6 +6050,17 @@ button_event (GtkWidget *widget, GdkEvent *event, | |||
| 6068 | bool tab_bar_p = false; | 6050 | bool tab_bar_p = false; |
| 6069 | bool tool_bar_p = false; | 6051 | bool tool_bar_p = false; |
| 6070 | Lisp_Object tab_bar_arg = Qnil; | 6052 | Lisp_Object tab_bar_arg = Qnil; |
| 6053 | GdkDevice *device; | ||
| 6054 | |||
| 6055 | /* Ignore emulated pointer events generated from a touch screen | ||
| 6056 | event. */ | ||
| 6057 | if (gdk_event_get_pointer_emulated (event) | ||
| 6058 | /* The event must not have emerged from a touch device either, as | ||
| 6059 | GDK does not set pointer_emulated in events generated on | ||
| 6060 | Wayland as on X, and as the X Input Extension specifies. */ | ||
| 6061 | || ((device = gdk_event_get_source_device (event)) | ||
| 6062 | && (gdk_device_get_source (device) == GDK_SOURCE_TOUCHSCREEN))) | ||
| 6063 | return FALSE; | ||
| 6071 | 6064 | ||
| 6072 | EVENT_INIT (inev.ie); | 6065 | EVENT_INIT (inev.ie); |
| 6073 | inev.ie.kind = NO_EVENT; | 6066 | inev.ie.kind = NO_EVENT; |
| @@ -6642,7 +6635,7 @@ pgtk_find_touch_point (struct pgtk_display_info *dpyinfo, | |||
| 6642 | return NULL; | 6635 | return NULL; |
| 6643 | } | 6636 | } |
| 6644 | 6637 | ||
| 6645 | static bool | 6638 | static gboolean |
| 6646 | touch_event_cb (GtkWidget *self, GdkEvent *event, gpointer user_data) | 6639 | touch_event_cb (GtkWidget *self, GdkEvent *event, gpointer user_data) |
| 6647 | { | 6640 | { |
| 6648 | struct pgtk_display_info *dpyinfo; | 6641 | struct pgtk_display_info *dpyinfo; |
| @@ -6742,6 +6735,15 @@ touch_event_cb (GtkWidget *self, GdkEvent *event, gpointer user_data) | |||
| 6742 | { | 6735 | { |
| 6743 | inev.ie.device = pgtk_get_device_for_event (dpyinfo, event); | 6736 | inev.ie.device = pgtk_get_device_for_event (dpyinfo, event); |
| 6744 | evq_enqueue (&inev); | 6737 | evq_enqueue (&inev); |
| 6738 | |||
| 6739 | /* Next, save this event for future menu activations, unless it is | ||
| 6740 | only an update. */ | ||
| 6741 | if (event->type != GDK_TOUCH_UPDATE) | ||
| 6742 | { | ||
| 6743 | if (dpyinfo->last_click_event != NULL) | ||
| 6744 | gdk_event_free (dpyinfo->last_click_event); | ||
| 6745 | dpyinfo->last_click_event = gdk_event_copy (event); | ||
| 6746 | } | ||
| 6745 | } | 6747 | } |
| 6746 | 6748 | ||
| 6747 | return inev.ie.kind != NO_EVENT; | 6749 | return inev.ie.kind != NO_EVENT; |