emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 7d672ed069: Translate state of XI2 entry events when sending them


From: Po Lu
Subject: master 7d672ed069: Translate state of XI2 entry events when sending them to xwidgets
Date: Wed, 29 Dec 2021 05:38:27 -0500 (EST)

branch: master
commit 7d672ed069f7936b9410f61cff2df97f804fabff
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    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 671d0390a0..30e9c2895d 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]