@@ -283,22 +283,22 @@ static X11_PenHandle *X11_MaybeAddPen(SDL_VideoDevice *_this, const XIDeviceInfo
283
283
284
284
X11_PenHandle * X11_MaybeAddPenByDeviceID (SDL_VideoDevice * _this , int deviceid )
285
285
{
286
- if (!X11_Xinput2IsInitialized ()) return NULL ;
287
- SDL_VideoData * data = _this -> internal ;
288
- int num_device_info = 0 ;
289
- XIDeviceInfo * device_info = X11_XIQueryDevice (data -> display , deviceid , & num_device_info );
290
- if (device_info ) {
291
- SDL_assert (num_device_info == 1 );
292
- X11_PenHandle * handle = X11_MaybeAddPen (_this , device_info );
293
- X11_XIFreeDeviceInfo (device_info );
294
- return handle ;
286
+ if (X11_Xinput2IsInitialized ()) {
287
+ SDL_VideoData * data = _this -> internal ;
288
+ int num_device_info = 0 ;
289
+ XIDeviceInfo * device_info = X11_XIQueryDevice (data -> display , deviceid , & num_device_info );
290
+ if (device_info ) {
291
+ SDL_assert (num_device_info == 1 );
292
+ X11_PenHandle * handle = X11_MaybeAddPen (_this , device_info );
293
+ X11_XIFreeDeviceInfo (device_info );
294
+ return handle ;
295
+ }
295
296
}
296
297
return NULL ;
297
298
}
298
299
299
300
void X11_RemovePenByDeviceID (int deviceid )
300
301
{
301
- if (!X11_Xinput2IsInitialized ()) return ;
302
302
X11_PenHandle * handle = X11_FindPenByDeviceID (deviceid );
303
303
if (handle ) {
304
304
SDL_RemovePenDevice (0 , handle -> pen );
@@ -308,7 +308,10 @@ void X11_RemovePenByDeviceID(int deviceid)
308
308
309
309
void X11_InitPen (SDL_VideoDevice * _this )
310
310
{
311
- if (!X11_Xinput2IsInitialized ()) return ;
311
+ if (!X11_Xinput2IsInitialized ()) {
312
+ return ; // we need XIQueryDevice() for this.
313
+ }
314
+
312
315
SDL_VideoData * data = _this -> internal ;
313
316
314
317
#define LOOKUP_PEN_ATOM (X ) X11_XInternAtom(data->display, X, False)
@@ -338,7 +341,6 @@ static void X11_FreePenHandle(SDL_PenID instance_id, void *handle, void *userdat
338
341
339
342
void X11_QuitPen (SDL_VideoDevice * _this )
340
343
{
341
- if (!X11_Xinput2IsInitialized ()) return ;
342
344
SDL_RemoveAllPenDevices (X11_FreePenHandle , NULL );
343
345
}
344
346
0 commit comments