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