From: <Blu...@us...> - 2010-09-07 20:38:36
|
Revision: 394 http://virtplayground.svn.sourceforge.net/virtplayground/?rev=394&view=rev Author: BlueWolf_ Date: 2010-09-07 20:38:29 +0000 (Tue, 07 Sep 2010) Log Message: ----------- Added mouse_focus and key_focus back to the sh again, as a certian pygame-bug came back again (Not always giving the right variable, depending on OS/Window Manager) Modified Paths: -------------- trunk/client/VP.py trunk/client/gui.py Modified: trunk/client/VP.py =================================================================== --- trunk/client/VP.py 2010-09-06 19:37:54 UTC (rev 393) +++ trunk/client/VP.py 2010-09-07 20:38:29 UTC (rev 394) @@ -37,6 +37,9 @@ sh['timer'] = Timer() sh['downloader'] = Downloader() sh['login_info'] = None + + sh['key_focus'] = True + sh['mouse_focus'] = True # Fire up pygame os.environ['SDL_VIDEO_CENTERED']='1' @@ -86,7 +89,7 @@ if ev.type == QUIT: break - if ev.type == MOUSEMOTION: + elif ev.type == MOUSEMOTION: # Prevent this event from overflowing the queue. Always # return the position right now and remove al other # mousemotions in the queue @@ -96,7 +99,18 @@ ev = pygame.event.Event(MOUSEMOTION, buttons = ev.buttons, pos = pos) + + sh['mouse_focus'] = True + elif ev.type == KEYDOWN: + sh['key_focus'] = True + + elif ev.type == ACTIVEEVENT: + if ev.state == 1: # Mouse + sh['mouse_focus'] = bool(ev.gain) + elif ev.state == 2: # Key + sh['key_focus'] = bool(ev.gain) + # Send through all the layers if sh['windows'].event(ev): continue if sh['layout'].event(ev): continue Modified: trunk/client/gui.py =================================================================== --- trunk/client/gui.py 2010-09-06 19:37:54 UTC (rev 393) +++ trunk/client/gui.py 2010-09-07 20:38:29 UTC (rev 394) @@ -116,7 +116,7 @@ if pos == None: pos = pygame.mouse.get_pos() - if pygame.mouse.get_focused(): + if sh['mouse_focus']: # Get the current hovered object rect, hover = self.this_pos(pos) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |