#! /usr/bin/python
# 
# test case for a posible bug on event handling
#
# tried on
#   python-soya 0.13.2-3+b1
#   Python 2.4.4 (#2, Aug 16 2007, 02:03:40)
#   KDE 3.5.7
#   Debian sid Linux 2.6.22
#
import soya

soya.init()

class KeyListenLoop(soya.MainLoop):
  def begin_round(self):
    soya.MainLoop.begin_round(self)
    for ev in soya.process_event():
       # exit on escape key or window close
      if (ev[0] == soya.sdlconst.KEYDOWN and ev[1] == soya.sdlconst.K_ESCAPE
          or ev[0] == soya.sdlconst.QUIT):
        self.stop()

      # test: try to move or resize the window, display the application
      # window menu or removing/restoring window border decoration
      elif (ev[0] == soya.sdlconst.KEYUP):
        print str(ev[0])+","+str(ev[1])

KeyListenLoop().main_loop()