summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Andreoli <dave@gurumeditation.it>2017-07-15 22:52:39 +0200
committerDave Andreoli <dave@gurumeditation.it>2017-07-15 22:52:39 +0200
commit5b9ba62e8f440009cd07da19f2276cfdb0415ddc (patch)
tree785124e64bedeb163467c1c7a9297aa0b36e27b9
parent26a4c38d670b8f0a55ada9c981f46452bde2ee3e (diff)
Fix a nasty ecore.x and ecore.input conflict
Both modules register the ECORE_EVENT_* events, so if you use them toghether one of the 2 was failing to run because the events was already registered by the other. I'm fixing this by keeping a local event map in ecore.input, not the cleaner solution but it's the safer one I can found (in term of backward compatibility) This fix (at least) epymc in standalone mode (without a wm)
-rw-r--r--efl/ecore_input/efl.ecore_input_events.pxi36
1 files changed, 19 insertions, 17 deletions
diff --git a/efl/ecore_input/efl.ecore_input_events.pxi b/efl/ecore_input/efl.ecore_input_events.pxi
index fce723b..b88beec 100644
--- a/efl/ecore_input/efl.ecore_input_events.pxi
+++ b/efl/ecore_input/efl.ecore_input_events.pxi
@@ -17,7 +17,6 @@
17 17
18 18
19from efl.utils.conversions cimport _ctouni 19from efl.utils.conversions cimport _ctouni
20from efl.ecore cimport _event_mapping_register, _event_mapping_get
21 20
22 21
23ECORE_EVENT_MODIFIER_SHIFT = enums.ECORE_EVENT_MODIFIER_SHIFT 22ECORE_EVENT_MODIFIER_SHIFT = enums.ECORE_EVENT_MODIFIER_SHIFT
@@ -34,23 +33,25 @@ ECORE_EVENT_LOCK_SHIFT = enums.ECORE_EVENT_LOCK_SHIFT
34ECORE_EVENT_MODIFIER_ALTGR = enums.ECORE_EVENT_MODIFIER_ALTGR 33ECORE_EVENT_MODIFIER_ALTGR = enums.ECORE_EVENT_MODIFIER_ALTGR
35 34
36 35
37 36# NOTE: Cannot use ecore._event_mapping_register helper here
38cdef int _input_events_registered = 0 37# because ECORE_EVENT_* are already registered by ecore.x
38# Thus we need a separate mapping to not conflict.
39cdef object _input_event_type_mapping = None
39 40
40cdef int _ecore_input_events_register() except 0: 41cdef int _ecore_input_events_register() except 0:
41 global _input_events_registered 42 global _input_event_type_mapping
42 43
43 if _input_events_registered == 0: 44 if not _input_event_type_mapping:
44 _event_mapping_register(ECORE_EVENT_KEY_DOWN, EventKey) 45 _input_event_type_mapping = {
45 _event_mapping_register(ECORE_EVENT_KEY_UP, EventKey) 46 ECORE_EVENT_KEY_DOWN: EventKey,
46 _event_mapping_register(ECORE_EVENT_MOUSE_BUTTON_DOWN, EventMouseButton) 47 ECORE_EVENT_KEY_UP: EventKey,
47 _event_mapping_register(ECORE_EVENT_MOUSE_BUTTON_UP, EventMouseButton) 48 ECORE_EVENT_MOUSE_BUTTON_DOWN: EventMouseButton,
48 _event_mapping_register(ECORE_EVENT_MOUSE_MOVE, EventMouseMove) 49 ECORE_EVENT_MOUSE_BUTTON_UP: EventMouseButton,
49 _event_mapping_register(ECORE_EVENT_MOUSE_IN, EventMouseIO) 50 ECORE_EVENT_MOUSE_MOVE: EventMouseMove,
50 _event_mapping_register(ECORE_EVENT_MOUSE_OUT, EventMouseIO) 51 ECORE_EVENT_MOUSE_IN: EventMouseIO,
51 _event_mapping_register(ECORE_EVENT_MOUSE_WHEEL, EventMouseWheel) 52 ECORE_EVENT_MOUSE_OUT: EventMouseIO,
52 53 ECORE_EVENT_MOUSE_WHEEL: EventMouseWheel,
53 _input_events_registered = 1 54 }
54 55
55 return 1 56 return 1
56 57
@@ -85,7 +86,7 @@ cdef class InputEventHandler(EventHandler):
85 if not callable(func): 86 if not callable(func):
86 raise TypeError("Parameter 'func' must be callable") 87 raise TypeError("Parameter 'func' must be callable")
87 88
88 event_cls = _event_mapping_get(type) 89 event_cls = _input_event_type_mapping.get(type)
89 if event_cls is None: 90 if event_cls is None:
90 raise ValueError("Unknow Ecore_Event type %d" % type) 91 raise ValueError("Unknow Ecore_Event type %d" % type)
91 92
@@ -145,6 +146,7 @@ cdef class EventPoint:
145 def __repr__(self): 146 def __repr__(self):
146 return "<EventPoint x=%d y=%d>" % (self.x, self.y) 147 return "<EventPoint x=%d y=%d>" % (self.x, self.y)
147 148
149
148cdef class EventMulti: 150cdef class EventMulti:
149 """ 151 """
150 :ivar int device: 0 if normal mouse, 1+ for other mouse-devices (eg multi-touch - other fingers) 152 :ivar int device: 0 if normal mouse, 1+ for other mouse-devices (eg multi-touch - other fingers)