@@ -37,6 +37,8 @@ static int xinput2_initialized = 0;
37
37
38
38
#ifdef SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH
39
39
static int xinput2_multitouch_supported = 0 ;
40
+ #endif
41
+ #ifdef SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_GESTURE
40
42
static int xinput2_pinch_swipe_supported = 0 ;
41
43
#endif
42
44
@@ -157,6 +159,8 @@ SDL_bool X11_InitXinput2(SDL_VideoDevice *_this)
157
159
#ifdef SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH
158
160
/* Multitouch needs XInput 2.2 */
159
161
xinput2_multitouch_supported = xinput2_version_atleast (version , 2 , 2 );
162
+ #endif
163
+ #ifdef SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_GESTURE
160
164
/* Gesture and Swipe needs XInput 2.4 */
161
165
xinput2_pinch_swipe_supported = xinput2_version_atleast (version , 2 , 4 );
162
166
#endif
@@ -482,7 +486,7 @@ void X11_HandleXinput2Event(SDL_VideoDevice *_this, XGenericEventCookie *cookie)
482
486
{
483
487
const XIDeviceEvent * xev = (const XIDeviceEvent * )cookie -> data ;
484
488
const SDL_Pen * pen = SDL_GetPenPtr (X11_PenIDFromDeviceID (xev -> deviceid ));
485
- #if SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH
489
+ #ifdef SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH
486
490
SDL_bool pointer_emulated = ((xev -> flags & XIPointerEmulated ) != 0 );
487
491
#else
488
492
SDL_bool pointer_emulated = SDL_FALSE ;
@@ -525,7 +529,7 @@ void X11_HandleXinput2Event(SDL_VideoDevice *_this, XGenericEventCookie *cookie)
525
529
}
526
530
} break ;
527
531
528
- #if SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH
532
+ #ifdef SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH
529
533
case XI_TouchBegin :
530
534
{
531
535
const XIDeviceEvent * xev = (const XIDeviceEvent * )cookie -> data ;
@@ -552,7 +556,9 @@ void X11_HandleXinput2Event(SDL_VideoDevice *_this, XGenericEventCookie *cookie)
552
556
xinput2_normalize_touch_coordinates (window , xev -> event_x , xev -> event_y , & x , & y );
553
557
SDL_SendTouchMotion (0 , xev -> sourceid , xev -> detail , window , x , y , 1.0 );
554
558
} break ;
559
+ #endif /* SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH */
555
560
561
+ #ifdef SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_GESTURE
556
562
case XI_GesturePinchBegin :
557
563
case XI_GesturePinchUpdate :
558
564
case XI_GesturePinchEnd :
@@ -584,7 +590,7 @@ void X11_HandleXinput2Event(SDL_VideoDevice *_this, XGenericEventCookie *cookie)
584
590
SDL_SendSwipe (0 , window , x , y );
585
591
} break ;
586
592
587
- #endif /* SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH */
593
+ #endif /* SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_GESTURE */
588
594
}
589
595
#endif /* SDL_VIDEO_DRIVER_X11_XINPUT2 */
590
596
}
@@ -617,15 +623,19 @@ void X11_Xinput2SelectTouch(SDL_VideoDevice *_this, SDL_Window *window)
617
623
XISetMask (mask , XI_TouchEnd );
618
624
XISetMask (mask , XI_Motion );
619
625
626
+
620
627
if (X11_Xinput2IsPinchSwipeSupported ()) {
628
+ #ifdef SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_GESTURE
621
629
XISetMask (mask , XI_GesturePinchBegin );
622
630
XISetMask (mask , XI_GesturePinchUpdate );
623
631
XISetMask (mask , XI_GesturePinchEnd );
624
632
XISetMask (mask , XI_GestureSwipeBegin );
625
633
XISetMask (mask , XI_GestureSwipeUpdate );
626
634
XISetMask (mask , XI_GestureSwipeEnd );
635
+ #endif
627
636
}
628
637
638
+
629
639
X11_XISelectEvents (data -> display , window_data -> xwindow , & eventmask , 1 );
630
640
#endif
631
641
}
@@ -699,7 +709,7 @@ int X11_Xinput2IsMultitouchSupported(void)
699
709
700
710
int X11_Xinput2IsPinchSwipeSupported (void )
701
711
{
702
- #ifdef SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH
712
+ #ifdef SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_GESTURE
703
713
return xinput2_initialized && xinput2_pinch_swipe_supported ;
704
714
#else
705
715
return 0 ;
0 commit comments