Stefan Monnier writes: >> @@ -3074,6 +3078,35 @@ x_window (struct frame *f, long window_prompting) >> class_hints.res_class = SSDATA (Vx_resource_class); >> XSetClassHint (FRAME_X_DISPLAY (f), XtWindow (shell_widget), &class_hints); >> >> +#ifdef HAVE_XINPUT2 >> + if (FRAME_DISPLAY_INFO (f)->supports_xi2) >> + { >> + XIEventMask mask; >> + ptrdiff_t l = XIMaskLen (XI_LASTEVENT); >> + unsigned char *m; >> + mask.mask = m = alloca (l); >> + memset (m, 0, l); >> + mask.mask_len = l; >> + mask.deviceid = XIAllMasterDevices; >> + >> + XISetMask (m, XI_ButtonPress); >> + XISetMask (m, XI_ButtonRelease); >> + XISetMask (m, XI_KeyPress); >> + XISetMask (m, XI_KeyRelease); >> + XISetMask (m, XI_Motion); >> + XISetMask (m, XI_Enter); >> + XISetMask (m, XI_Leave); >> + XISetMask (m, XI_FocusIn); >> + XISetMask (m, XI_FocusOut); >> + XISetMask (m, XI_PropertyEvent); >> + XISetMask (m, XI_HierarchyChanged); >> + XISetMask (m, XI_DeviceChanged); >> + XISelectEvents (FRAME_X_DISPLAY (f), >> + FRAME_X_WINDOW (f), >> + &mask, 1); >> + } >> +#endif >> + >> #ifdef HAVE_X_I18N >> FRAME_XIC (f) = NULL; >> if (use_xim) >> @@ -3254,6 +3287,35 @@ x_window (struct frame *f) >> } >> #endif /* HAVE_X_I18N */ >> >> +#ifdef HAVE_XINPUT2 >> + if (FRAME_DISPLAY_INFO (f)->supports_xi2) >> + { >> + XIEventMask mask; >> + ptrdiff_t l = XIMaskLen (XI_LASTEVENT); >> + unsigned char *m; >> + mask.mask = m = alloca (l); >> + memset (m, 0, l); >> + mask.mask_len = l; >> + mask.deviceid = XIAllMasterDevices; >> + >> + XISetMask (m, XI_ButtonPress); >> + XISetMask (m, XI_ButtonRelease); >> + XISetMask (m, XI_KeyPress); >> + XISetMask (m, XI_KeyRelease); >> + XISetMask (m, XI_Motion); >> + XISetMask (m, XI_Enter); >> + XISetMask (m, XI_Leave); >> + XISetMask (m, XI_FocusIn); >> + XISetMask (m, XI_FocusOut); >> + XISetMask (m, XI_PropertyEvent); >> + XISetMask (m, XI_HierarchyChanged); >> + XISetMask (m, XI_DeviceChanged); >> + XISelectEvents (FRAME_X_DISPLAY (f), >> + FRAME_X_WINDOW (f), >> + &mask, 1); >> + } >> +#endif >> + > Any reason this isn't consolidated into a separate function to avoid the > code duplication? Thanks, done. During development there were a few different masks that needed to be added to the no-toolkit build. >> + struct xi_device_t *xi_device = >> + &dpyinfo->devices[actual_devices++]; > The GNU coding standard encourages to cut lines just *before* infix > operators rather after. E.g.: > > struct xi_device_t *xi_device > = &dpyinfo->devices[actual_devices++]; Also fixed, see attached patch. > That's a damn large chunk of code to add into a function. It's `handle_one_xevent' after all. > A lot of it is copy&pasted from other parts of `handle_one_xevent`. > Please avoid such code duplication (`handle_one_xevent` is already bad > enough from this point of view). I don't know enough about most of the Core Input code to dare change it. It does mysterious things that I can not understand. Also, most of the XInput 2 event code differs in subtle ways from the Core Input code (see for example how the button grab is handled there). It would make even more of a mess to try to reuse the Core Input > Also the code uses more than 80 columns at various places for no good > reason; that needs to be fixed. I tried to fix that as well. Thanks for the comments.