From 7d672ed069f7936b9410f61cff2df97f804fabff Mon Sep 17 00:00:00 2001 From: Po Lu Date: Wed, 29 Dec 2021 18:37:04 +0800 Subject: [PATCH] Translate state of XI2 entry events when sending them to xwidgets * src/xwidget.c (xi_translate_notify_detail): New function. (xwidget_motion_or_crossing): Translate detail and state of GenericEvents before sending them to the widget. --- src/xwidget.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/xwidget.c b/src/xwidget.c index 671d0390a0b..30e9c2895d4 100644 --- a/src/xwidget.c +++ b/src/xwidget.c @@ -1229,6 +1229,28 @@ xwidget_scroll (struct xwidget_view *view, double x, double y, } #endif +#ifdef HAVE_XINPUT2 +static GdkNotifyType +xi_translate_notify_detail (int detail) +{ + switch (detail) + { + case NotifyInferior: + return GDK_NOTIFY_INFERIOR; + case NotifyAncestor: + return GDK_NOTIFY_ANCESTOR; + case NotifyVirtual: + return GDK_NOTIFY_VIRTUAL; + case NotifyNonlinear: + return GDK_NOTIFY_NONLINEAR; + case NotifyNonlinearVirtual: + return GDK_NOTIFY_NONLINEAR_VIRTUAL; + default: + emacs_abort (); + } +} +#endif + void xwidget_motion_or_crossing (struct xwidget_view *view, const XEvent *event) { @@ -1306,6 +1328,19 @@ xwidget_motion_or_crossing (struct xwidget_view *view, const XEvent *event) xg_event->crossing.y_root = (gdouble) xev->root_y; xg_event->crossing.time = xev->time; xg_event->crossing.focus = xev->focus; + xg_event->crossing.detail = xi_translate_notify_detail (xev->detail); + xg_event->crossing.state = xev->mods.effective; + + if (xev->buttons.mask_len) + { + if (XIMaskIsSet (xev->buttons.mask, 1)) + xg_event->crossing.state |= GDK_BUTTON1_MASK; + if (XIMaskIsSet (xev->buttons.mask, 2)) + xg_event->crossing.state |= GDK_BUTTON2_MASK; + if (XIMaskIsSet (xev->buttons.mask, 3)) + xg_event->crossing.state |= GDK_BUTTON3_MASK; + } + gdk_event_set_device (xg_event, find_suitable_pointer (view->frame)); } #endif -- 2.39.2