@@ -296,6 +296,98 @@ def ungrab_device(self, deviceid, time):
296296 deviceid = deviceid ,
297297 )
298298
299+ class XIPassiveGrabDevice (rq .ReplyRequest ):
300+ _request = rq .Struct (
301+ rq .Card8 ('opcode' ),
302+ rq .Opcode (54 ),
303+ rq .RequestLength (),
304+ rq .Card32 ('time' ),
305+ rq .Window ('grab_window' ),
306+ rq .Cursor ('cursor' , (X .NONE , )),
307+ rq .Card32 ('detail' ),
308+ DEVICEID ('deviceid' ),
309+ rq .LengthOf ('modifiers' , 2 ),
310+ rq .LengthOf ('mask' , 2 ),
311+ rq .Set ('grab_type' , 1 , (GrabtypeButton , GrabtypeKeycode , GrabtypeEnter ,
312+ GrabtypeFocusIn , GrabtypeTouchBegin )),
313+ rq .Set ('grab_mode' , 1 , (GrabModeSync , GrabModeAsync )),
314+ rq .Set ('paired_device_mode' , 1 , (GrabModeSync , GrabModeAsync )),
315+ rq .Bool ('owner_events' ),
316+ rq .Pad (2 ),
317+ rq .List ('mask' , rq .Card32 ),
318+ rq .List ('modifiers' , rq .Card32 ),
319+ )
320+
321+ _reply = rq .Struct (
322+ rq .ReplyCode (),
323+ rq .Pad (1 ),
324+ rq .Card16 ('sequence_number' ),
325+ rq .ReplyLength (),
326+ rq .LengthOf ('modifiers' , 2 ),
327+ rq .Pad (22 ),
328+ rq .List ('modifiers' , rq .Card32 ),
329+ )
330+
331+ def passive_grab_device (self , deviceid , time , detail ,
332+ grab_type , grab_mode , paired_device_mode ,
333+ owner_events , event_mask , modifiers ):
334+ mask = pack_event_mask (deviceid , event_mask )
335+ return XIPassiveGrabDevice (
336+ display = self .display ,
337+ opcode = self .display .get_extension_major (extname ),
338+ deviceid = deviceid ,
339+ grab_window = self ,
340+ time = time ,
341+ cursor = X .NONE ,
342+ detail = detail ,
343+ grab_type = grab_type ,
344+ grab_mode = grab_mode ,
345+ paired_device_mode = paired_device_mode ,
346+ owner_events = owner_events ,
347+ mask = mask ['mask' ],
348+ modifiers = modifiers ,
349+ )
350+
351+ def grab_keycode (self , deviceid , time , keycode ,
352+ grab_mode , paired_device_mode ,
353+ owner_events , event_mask , modifiers ):
354+ return passive_grab_device (self , deviceid , time , keycode ,
355+ GrabtypeKeycode ,
356+ grab_mode , paired_device_mode ,
357+ owner_events , event_mask , modifiers )
358+
359+ class XIPassiveUngrabDevice (rq .Request ):
360+
361+ _request = rq .Struct (
362+ rq .Card8 ('opcode' ),
363+ rq .Opcode (55 ),
364+ rq .RequestLength (),
365+ rq .Window ('grab_window' ),
366+ rq .Card32 ('detail' ),
367+ DEVICEID ('deviceid' ),
368+ rq .LengthOf ('modifiers' , 2 ),
369+ rq .Set ('grab_type' , 1 , (GrabtypeButton , GrabtypeKeycode ,
370+ GrabtypeEnter , GrabtypeFocusIn ,
371+ GrabtypeTouchBegin )),
372+ rq .Pad (3 ),
373+ rq .List ('modifiers' , rq .Card32 ),
374+ )
375+
376+ def passive_ungrab_device (self , deviceid , detail , grab_type , modifiers ):
377+ return XIPassiveUngrabDevice (
378+ display = self .display ,
379+ opcode = self .display .get_extension_major (extname ),
380+ deviceid = deviceid ,
381+ grab_window = self ,
382+ detail = detail ,
383+ grab_type = grab_type ,
384+ modifiers = modifiers ,
385+ )
386+
387+ def ungrab_keycode (self , deviceid , keycode , modifiers ):
388+ return passive_ungrab_device (self , deviceid , keycode ,
389+ GrabtypeKeycode , modifiers )
390+
299391HierarchyInfo = rq .Struct (
300392 DEVICEID ('deviceid' ),
301393 DEVICEID ('attachment' ),
@@ -363,6 +455,8 @@ def init(disp, info):
363455 disp .extension_add_method ('window' , 'xinput_select_events' , select_events )
364456 disp .extension_add_method ('window' , 'xinput_grab_device' , grab_device )
365457 disp .extension_add_method ('display' , 'xinput_ungrab_device' , ungrab_device )
458+ disp .extension_add_method ('window' , 'xinput_grab_keycode' , grab_keycode )
459+ disp .extension_add_method ('window' , 'xinput_ungrab_keycode' , ungrab_keycode )
366460
367461 disp .ge_add_event_data (info .major_opcode , KeyPress , DeviceEventData )
368462 disp .ge_add_event_data (info .major_opcode , KeyRelease , DeviceEventData )
0 commit comments