From 84e240f64014f1e27dc1b3769f5ea83046f683d0 Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Wed, 8 Mar 2017 12:11:11 +0200 Subject: New event handling The current event handling relies on the PageFlipHandlerBase class which has to be implemented on the python side. This patch implements a more versatile event handling, where any python object can be passed as data to the commit or page flip, and it's up to the python implementation to decide what to do with that data when receiving the event. Note that when doing the commit or page_flip, the ref count of the given python object is incremented to keep it alive. The ref count is decremented when reading the events with the new helper method card.read_events(). This helper _has_ to be used to ensure the objects get released properly. Signed-off-by: Tomi Valkeinen --- py/tests/db.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'py/tests') diff --git a/py/tests/db.py b/py/tests/db.py index eb31669..d51820c 100755 --- a/py/tests/db.py +++ b/py/tests/db.py @@ -7,7 +7,7 @@ import selectors bar_width = 20 bar_speed = 8 -class FlipHandler(pykms.PageFlipHandlerBase): +class FlipHandler(): def __init__(self): super().__init__() self.bar_xpos = 0 @@ -75,7 +75,11 @@ fliphandler.handle_page_flip(0, 0) def readdrm(fileobj, mask): #print("EVENT"); - card.call_page_flip_handlers() + #card.call_page_flip_handlers() + for ev in card.read_events(): + if ev.type == pykms.DrmEventType.FLIP_COMPLETE: + ev.data.handle_page_flip(ev.seq, ev.time) + def readkey(fileobj, mask): #print("KEY EVENT"); -- cgit v1.2.3