Looking at Pygame, I couldn't find any functions that checked to see if the app itself was focused, and pygame.ACTIVEEVENT seemed to be triggering on the inner SDL window rather than the WM border. At the moment I'm changing the 'if renpy.display.interface.focused:' controller-event checks to 'if pygame.key.get_focused() or renpy.display.interface.focused:' in my games, which seems to work as desired on my computer and the one that reported the bug. My question is, is this the right approach? Are there any likely gotchas?
(The included diff works on 6.12.2 and 6.17.7, haven't tested it on other versions.)
Code: Select all
*** renpy/display/joystick.py 2011-07-14 08:25:02.000000000 -0700
--- /home/renpy/renpy-6.17.7+NOPICKLES-sdk/renpy/display/joystick.py 2014-09-20 23:15:26.322397887 -0700
***************
*** 62,68 ****
if ev.type == pygame.JOYAXISMOTION:
! if not renpy.display.interface.focused:
return None
if ev.value >= 0.5:
--- 62,68 ----
if ev.type == pygame.JOYAXISMOTION:
! if (not pygame.key.get_focused()) and (not renpy.display.interface.focused):
return None
if ev.value >= 0.5:
***************
*** 96,103 ****
press=press, release=release)
if ev.type == pygame.JOYBUTTONDOWN:
!
! if not renpy.display.interface.focused:
return None
return pygame.event.Event(renpy.display.core.JOYEVENT,
--- 96,103 ----
press=press, release=release)
if ev.type == pygame.JOYBUTTONDOWN:
!
! if (not pygame.key.get_focused()) and (not renpy.display.interface.focused):
return None
return pygame.event.Event(renpy.display.core.JOYEVENT,
***************
*** 105,111 ****
release=None)
if ev.type == pygame.JOYBUTTONUP:
! if not renpy.display.interface.focused:
return None
return pygame.event.Event(renpy.display.core.JOYEVENT,
--- 105,111 ----
release=None)
if ev.type == pygame.JOYBUTTONUP:
! if (not pygame.key.get_focused()) and (not renpy.display.interface.focused):
return None
return pygame.event.Event(renpy.display.core.JOYEVENT,