Add a new module: ecore_input
as always with docs and example
This commit is contained in:
parent
592467c7bd
commit
f3e6315413
|
@ -110,6 +110,7 @@ API Reference
|
|||
:titlesonly:
|
||||
|
||||
module-ecore
|
||||
module-ecore_input
|
||||
module-ecore_con
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
|
||||
.. automodule:: efl.ecore_input
|
||||
|
|
@ -0,0 +1,244 @@
|
|||
# Copyright (C) 2007-2015 various contributors (see AUTHORS)
|
||||
#
|
||||
# This file is part of Python-EFL.
|
||||
#
|
||||
# Python-EFL is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 3 of the License, or (at your option) any later version.
|
||||
#
|
||||
# Python-EFL is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this Python-EFL. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from efl.eina cimport Eina_Bool
|
||||
from efl.ecore cimport Ecore_Event_Handler, ecore_event_handler_add, \
|
||||
ecore_event_handler_del
|
||||
|
||||
|
||||
cdef extern from "Ecore_Input.h":
|
||||
|
||||
####################################################################
|
||||
# Enums
|
||||
#
|
||||
cpdef enum Ecore_Event_Modifier: # this is not really an enum
|
||||
ECORE_EVENT_MODIFIER_SHIFT
|
||||
ECORE_EVENT_MODIFIER_CTRL
|
||||
ECORE_EVENT_MODIFIER_ALT
|
||||
ECORE_EVENT_MODIFIER_WIN
|
||||
ECORE_EVENT_MODIFIER_SCROLL
|
||||
ECORE_EVENT_MODIFIER_NUM
|
||||
ECORE_EVENT_MODIFIER_CAPS
|
||||
ECORE_EVENT_LOCK_SCROLL
|
||||
ECORE_EVENT_LOCK_NUM
|
||||
ECORE_EVENT_LOCK_CAPS
|
||||
ECORE_EVENT_LOCK_SHIFT
|
||||
ECORE_EVENT_MODIFIER_ALTGR
|
||||
ctypedef enum Ecore_Event_Modifier:
|
||||
pass
|
||||
|
||||
####################################################################
|
||||
# events (not exposed to python)
|
||||
#
|
||||
int ECORE_EVENT_KEY_DOWN
|
||||
int ECORE_EVENT_KEY_UP
|
||||
int ECORE_EVENT_MOUSE_BUTTON_DOWN
|
||||
int ECORE_EVENT_MOUSE_BUTTON_UP
|
||||
int ECORE_EVENT_MOUSE_MOVE
|
||||
int ECORE_EVENT_MOUSE_IN
|
||||
int ECORE_EVENT_MOUSE_OUT
|
||||
int ECORE_EVENT_MOUSE_WHEEL
|
||||
|
||||
####################################################################
|
||||
# Data Types
|
||||
#
|
||||
ctypedef void *Ecore_Window
|
||||
|
||||
ctypedef struct _EventPoint:
|
||||
int x
|
||||
int y
|
||||
|
||||
ctypedef struct _EventMulti:
|
||||
int device
|
||||
double radius
|
||||
double radius_x
|
||||
double radius_y
|
||||
double pressure
|
||||
double angle
|
||||
double x
|
||||
double y
|
||||
_EventPoint root
|
||||
|
||||
ctypedef struct Ecore_Event_Key:
|
||||
const char *keyname
|
||||
const char *key
|
||||
const char *string
|
||||
const char *compose
|
||||
Ecore_Window window
|
||||
Ecore_Window root_window
|
||||
Ecore_Window event_window
|
||||
unsigned int timestamp
|
||||
unsigned int modifiers
|
||||
int same_screen
|
||||
unsigned int keycode
|
||||
void *data
|
||||
|
||||
ctypedef struct Ecore_Event_Mouse_Button:
|
||||
Ecore_Window window
|
||||
Ecore_Window root_window
|
||||
Ecore_Window event_window
|
||||
unsigned int timestamp
|
||||
unsigned int modifiers
|
||||
unsigned int buttons
|
||||
unsigned int double_click
|
||||
unsigned int triple_click
|
||||
int same_screen
|
||||
int x
|
||||
int y
|
||||
_EventPoint root
|
||||
_EventMulti multi
|
||||
|
||||
ctypedef struct Ecore_Event_Mouse_Wheel:
|
||||
Ecore_Window window
|
||||
Ecore_Window root_window
|
||||
Ecore_Window event_window
|
||||
unsigned int timestamp
|
||||
unsigned int modifiers
|
||||
int same_screen
|
||||
int direction
|
||||
int z
|
||||
int x
|
||||
int y
|
||||
_EventPoint root
|
||||
|
||||
ctypedef struct Ecore_Event_Mouse_Move:
|
||||
Ecore_Window window
|
||||
Ecore_Window root_window
|
||||
Ecore_Window event_window
|
||||
unsigned int timestamp
|
||||
unsigned int modifiers
|
||||
int same_screen
|
||||
int x
|
||||
int y
|
||||
_EventPoint root
|
||||
_EventMulti multi
|
||||
|
||||
ctypedef struct Ecore_Event_Mouse_IO:
|
||||
Ecore_Window window
|
||||
Ecore_Window event_window
|
||||
unsigned int timestamp
|
||||
unsigned int modifiers
|
||||
int x
|
||||
int y
|
||||
|
||||
|
||||
####################################################################
|
||||
# Functions
|
||||
#
|
||||
int ecore_event_init()
|
||||
int ecore_event_shutdown()
|
||||
|
||||
|
||||
####################################################################
|
||||
# Python classes
|
||||
#
|
||||
from efl.ecore cimport Event, EventHandler
|
||||
|
||||
|
||||
cdef class Window:
|
||||
# Can we do something with this opaque stuct ?
|
||||
pass
|
||||
|
||||
|
||||
cdef class InputEventHandler(EventHandler):
|
||||
pass
|
||||
|
||||
|
||||
cdef class EventPoint:
|
||||
cdef readonly int x
|
||||
cdef readonly int y
|
||||
|
||||
|
||||
cdef class EventMulti:
|
||||
cdef readonly int device
|
||||
cdef readonly double radius
|
||||
cdef readonly double radius_x
|
||||
cdef readonly double radius_y
|
||||
cdef readonly double pressure
|
||||
cdef readonly double angle
|
||||
cdef readonly double x
|
||||
cdef readonly double y
|
||||
cdef readonly double root_x
|
||||
cdef readonly double root_y
|
||||
|
||||
|
||||
cdef class EventKey(Event):
|
||||
cdef readonly object keyname
|
||||
cdef readonly object key
|
||||
cdef readonly object string
|
||||
cdef readonly object compose
|
||||
## Can we do something with this Window opaque struct ?
|
||||
# cdef readonly Window window
|
||||
# cdef readonly Window root_window
|
||||
# cdef readonly Window event_window
|
||||
cdef readonly unsigned int modifiers
|
||||
cdef readonly unsigned int timestamp
|
||||
cdef readonly unsigned int keycode
|
||||
cdef readonly object same_screen
|
||||
|
||||
|
||||
cdef class EventMouseButton(Event):
|
||||
# cdef readonly Window window
|
||||
# cdef readonly Window root_window
|
||||
# cdef readonly Window event_window
|
||||
cdef readonly unsigned int modifiers
|
||||
cdef readonly unsigned int timestamp
|
||||
cdef readonly unsigned int buttons
|
||||
cdef readonly object double_click
|
||||
cdef readonly object triple_click
|
||||
cdef readonly object same_screen
|
||||
cdef readonly int x
|
||||
cdef readonly int y
|
||||
cdef readonly EventPoint root
|
||||
cdef readonly EventMulti multi
|
||||
|
||||
|
||||
cdef class EventMouseMove(Event):
|
||||
# cdef readonly Window window
|
||||
# cdef readonly Window root_window
|
||||
# cdef readonly Window event_window
|
||||
cdef readonly unsigned int modifiers
|
||||
cdef readonly unsigned int timestamp
|
||||
cdef readonly object same_screen
|
||||
cdef readonly int x
|
||||
cdef readonly int y
|
||||
cdef readonly EventPoint root
|
||||
cdef readonly EventMulti multi
|
||||
|
||||
|
||||
cdef class EventMouseIO(Event):
|
||||
# cdef readonly Window window
|
||||
# cdef readonly Window event_window
|
||||
cdef readonly unsigned int modifiers
|
||||
cdef readonly unsigned int timestamp
|
||||
cdef readonly int x
|
||||
cdef readonly int y
|
||||
|
||||
|
||||
cdef class EventMouseWheel(Event):
|
||||
# cdef readonly Window window
|
||||
# cdef readonly Window root_window
|
||||
# cdef readonly Window event_window
|
||||
cdef readonly unsigned int modifiers
|
||||
cdef readonly unsigned int timestamp
|
||||
cdef readonly object same_screen
|
||||
cdef readonly int direction
|
||||
cdef readonly int z
|
||||
cdef readonly int x
|
||||
cdef readonly int y
|
||||
cdef readonly EventPoint root
|
||||
|
|
@ -0,0 +1,112 @@
|
|||
# Copyright (C) 2007-2015 various contributors (see AUTHORS)
|
||||
#
|
||||
# This file is part of Python-EFL.
|
||||
#
|
||||
# Python-EFL is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 3 of the License, or (at your option) any later version.
|
||||
#
|
||||
# Python-EFL is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this Python-EFL. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
"""
|
||||
|
||||
:mod:`efl.ecore_input` Module
|
||||
#############################
|
||||
|
||||
.. versionadded:: 1.17
|
||||
|
||||
This module provide access to the low-level input events, you usually
|
||||
don't need to use this stuff, unless you need some sort of custom event
|
||||
handling.
|
||||
|
||||
To be informed about specific events just use one of the
|
||||
on_*_add(func, \*args, \**kargs) functions, the callback given will be fired
|
||||
when events occur.
|
||||
|
||||
Callback signature is::
|
||||
|
||||
func(event, *args, **kargs) → int
|
||||
|
||||
Where ``event`` will be a class relative to the specific event (such as
|
||||
:class:`EventKey`) All the additional arguments and keyword arguments passed
|
||||
in the \*_add function will be passed back in the callback.
|
||||
|
||||
In some events (EventKey at least) the callback function may return
|
||||
ecore.ECORE_CALLBACK_DONE or ecore.ECORE_CALLBACK_PASS_ON to block the
|
||||
event propagation down the chain or not.
|
||||
|
||||
To stop receiving event use :func:`efl.ecore.EventHandler.delete`
|
||||
|
||||
|
||||
Enumerations
|
||||
============
|
||||
|
||||
.. _Ecore_Event_Modifier:
|
||||
|
||||
Ecore_Event_Modifier
|
||||
--------------------
|
||||
|
||||
.. data:: ECORE_EVENT_MODIFIER_SHIFT
|
||||
|
||||
.. data:: ECORE_EVENT_MODIFIER_CTRL
|
||||
|
||||
.. data:: ECORE_EVENT_MODIFIER_ALT
|
||||
|
||||
.. data:: ECORE_EVENT_MODIFIER_WIN
|
||||
|
||||
.. data:: ECORE_EVENT_MODIFIER_SCROLL
|
||||
|
||||
.. data:: ECORE_EVENT_MODIFIER_NUM
|
||||
|
||||
.. data:: ECORE_EVENT_MODIFIER_CAPS
|
||||
|
||||
.. data:: ECORE_EVENT_LOCK_SCROLL
|
||||
|
||||
.. data:: ECORE_EVENT_LOCK_NUM
|
||||
|
||||
.. data:: ECORE_EVENT_LOCK_CAPS
|
||||
|
||||
.. data:: ECORE_EVENT_LOCK_SHIFT
|
||||
|
||||
.. data:: ECORE_EVENT_MODIFIER_ALTGR
|
||||
|
||||
|
||||
Classes and Functions
|
||||
=====================
|
||||
|
||||
"""
|
||||
|
||||
|
||||
import atexit
|
||||
import traceback
|
||||
|
||||
|
||||
def init():
|
||||
""" Initialize the Ecore Input library
|
||||
|
||||
.. note:: You never need to call this, it is automatically called at module
|
||||
import
|
||||
"""
|
||||
ecore_event_init()
|
||||
_ecore_input_events_register()
|
||||
|
||||
def shutdown():
|
||||
""" Shutdown the Ecore Input library.
|
||||
|
||||
.. note:: You never need to call this, it is automatically called at exit
|
||||
|
||||
"""
|
||||
ecore_event_shutdown()
|
||||
|
||||
|
||||
include "efl.ecore_input_events.pxi"
|
||||
|
||||
init()
|
||||
atexit.register(shutdown)
|
|
@ -0,0 +1,377 @@
|
|||
# Copyright (C) 2007-2015 various contributors (see AUTHORS)
|
||||
#
|
||||
# This file is part of Python-EFL.
|
||||
#
|
||||
# Python-EFL is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 3 of the License, or (at your option) any later version.
|
||||
#
|
||||
# Python-EFL is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this Python-EFL. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
from efl.utils.conversions cimport _ctouni
|
||||
from efl.ecore cimport _event_mapping_register, _event_mapping_get
|
||||
|
||||
|
||||
cdef int _input_events_registered = 0
|
||||
|
||||
cdef int _ecore_input_events_register() except 0:
|
||||
global _input_events_registered
|
||||
|
||||
if _input_events_registered == 0:
|
||||
_event_mapping_register(ECORE_EVENT_KEY_DOWN, EventKey)
|
||||
_event_mapping_register(ECORE_EVENT_KEY_UP, EventKey)
|
||||
_event_mapping_register(ECORE_EVENT_MOUSE_BUTTON_DOWN, EventMouseButton)
|
||||
_event_mapping_register(ECORE_EVENT_MOUSE_BUTTON_UP, EventMouseButton)
|
||||
_event_mapping_register(ECORE_EVENT_MOUSE_MOVE, EventMouseMove)
|
||||
_event_mapping_register(ECORE_EVENT_MOUSE_IN, EventMouseIO)
|
||||
_event_mapping_register(ECORE_EVENT_MOUSE_OUT, EventMouseIO)
|
||||
_event_mapping_register(ECORE_EVENT_MOUSE_WHEEL, EventMouseWheel)
|
||||
|
||||
_input_events_registered = 1
|
||||
|
||||
return 1
|
||||
|
||||
|
||||
cdef Eina_Bool _input_event_handler_cb(void *data, int type, void *event) with gil:
|
||||
cdef EventHandler handler
|
||||
cdef Eina_Bool r
|
||||
|
||||
assert event != NULL
|
||||
assert data != NULL, "data should not be NULL!"
|
||||
handler = <EventHandler>data
|
||||
assert type == handler.type, "handler type isn't the same as event type!"
|
||||
|
||||
try:
|
||||
r = handler._exec(event)
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
r = 0
|
||||
|
||||
return r
|
||||
|
||||
|
||||
cdef class InputEventHandler(EventHandler):
|
||||
"""
|
||||
The event handler class
|
||||
|
||||
You never instantiate this class directly, instead use one of the
|
||||
on_*_add() functions.
|
||||
"""
|
||||
def __init__(self, int type, func, *args, **kargs):
|
||||
|
||||
if not callable(func):
|
||||
raise TypeError("Parameter 'func' must be callable")
|
||||
|
||||
event_cls = _event_mapping_get(type)
|
||||
if event_cls is None:
|
||||
raise ValueError("Unknow Ecore_Event type %d" % type)
|
||||
|
||||
self.type = type
|
||||
self.event_cls = event_cls
|
||||
self.func = func
|
||||
self.args = args
|
||||
self.kargs = kargs
|
||||
self._set_obj(ecore_event_handler_add(type, _input_event_handler_cb,
|
||||
<void *>self))
|
||||
|
||||
|
||||
cdef class EventKey(Event):
|
||||
""" EventKey()
|
||||
|
||||
Contains information about an Ecore keyboard event.
|
||||
|
||||
.. seealso :: :func:`on_key_down_add`, :func:`on_key_up_add`
|
||||
|
||||
:ivar str keyname: The key name
|
||||
:ivar str key: The key symbol
|
||||
:ivar str string:
|
||||
:ivar int compose: Final string corresponding to the key symbol composed
|
||||
:ivar int timestamp: Time when the event occurred.
|
||||
:ivar int modifiers: :ref:`Ecore_Event_Modifier` The OR combination of modifiers key
|
||||
:ivar bool same_screen: Same screen flag
|
||||
:ivar int keycode: Key scan code numeric value
|
||||
|
||||
"""
|
||||
cdef int _set_obj(self, void *o) except 0:
|
||||
cdef Ecore_Event_Key *obj
|
||||
obj = <Ecore_Event_Key*>o
|
||||
self.keyname = _ctouni(obj.keyname)
|
||||
self.key = _ctouni(obj.key)
|
||||
self.string = _ctouni(obj.string)
|
||||
self.compose = _ctouni(obj.compose)
|
||||
## Can we do something with this Window opaque struct ?
|
||||
# self.window = Window(<unsigned long><void*>obj.window)
|
||||
# self.root_window = Window(<unsigned long><void*>obj.root_window)
|
||||
# self.event_window = Window(<unsigned long><void*>obj.event_window)
|
||||
self.timestamp = obj.timestamp
|
||||
self.modifiers = obj.modifiers
|
||||
self.same_screen = bool(obj.same_screen)
|
||||
self.keycode = obj.keycode
|
||||
return 1
|
||||
|
||||
|
||||
cdef class EventPoint:
|
||||
"""
|
||||
:ivar int x: x coordinate
|
||||
:ivar int y: y coordinate
|
||||
"""
|
||||
def __init__(self, int x, int y):
|
||||
self.x = x
|
||||
self.y = y
|
||||
|
||||
def __repr__(self):
|
||||
return "<EventPoint x=%d y=%d>" % (self.x, self.y)
|
||||
|
||||
cdef class EventMulti:
|
||||
"""
|
||||
:ivar int device: 0 if normal mouse, 1+ for other mouse-devices (eg multi-touch - other fingers)
|
||||
:ivar double radius: radius of press point - radius_x and y if its an ellipse (radius is the average of the 2)
|
||||
:ivar double radius_x:
|
||||
:ivar double radius_y:
|
||||
:ivar double pressure: 1.0 == normal, > 1.0 == more, 0.0 == none
|
||||
:ivar double angle: relative to perpendicular (0.0 == perpendicular), in degrees
|
||||
:ivar double x: with sub-pixel precision, if available
|
||||
:ivar double y: with sub-pixel precision, if available
|
||||
:ivar double root_x: with sub-pixel precision, if available
|
||||
:ivar double root_y: with sub-pixel precision, if available
|
||||
"""
|
||||
def __init__(self, int device, double radius, double radius_x, double radius_y,
|
||||
double pressure, double angle, double x, double y,
|
||||
double root_x, double root_y):
|
||||
self.device = device
|
||||
self.radius = radius
|
||||
self.radius_x = radius_x
|
||||
self.radius_y = radius_y
|
||||
self.pressure = pressure
|
||||
self.angle = angle
|
||||
self.x = x
|
||||
self.y = y
|
||||
self.root_x = root_x
|
||||
self.root_y = root_y
|
||||
|
||||
def __repr__(self):
|
||||
return "<EventMulti>"
|
||||
|
||||
|
||||
cdef class EventMouseButton(Event):
|
||||
""" EventMouseButton()
|
||||
|
||||
Contains information about an Ecore mouse button event.
|
||||
|
||||
.. seealso :: :func:`on_mouse_button_down_add`, :func:`on_mouse_button_up_add`
|
||||
|
||||
:ivar int timestamp: Time when the event occurred
|
||||
:ivar int modifiers: :ref:`Ecore_Event_Modifier` The OR combination of modifiers key
|
||||
:ivar int buttons: The button that was used
|
||||
:ivar bool double_click: Double click event
|
||||
:ivar bool triple_click: Triple click event
|
||||
:ivar bool same_screen: Same screen flag
|
||||
:ivar int x: x coordinate relative to window where event happened
|
||||
:ivar int y: y coordinate relative to window where event happened
|
||||
:ivar EventPoint root: :class:`EventPoint` Coordinates relative to root window
|
||||
|
||||
"""
|
||||
cdef int _set_obj(self, void *o) except 0:
|
||||
cdef Ecore_Event_Mouse_Button *obj
|
||||
obj = <Ecore_Event_Mouse_Button*>o
|
||||
# self.window = Window(<unsigned long><void*>obj.window)
|
||||
# self.root_window = Window(<unsigned long><void*>obj.root_window)
|
||||
# self.event_window = Window(<unsigned long><void*>obj.event_window)
|
||||
self.timestamp = obj.timestamp
|
||||
self.modifiers = obj.modifiers
|
||||
self.buttons = obj.buttons
|
||||
self.double_click = bool(obj.double_click)
|
||||
self.triple_click = bool(obj.triple_click)
|
||||
self.same_screen = bool(obj.same_screen)
|
||||
self.x = obj.x
|
||||
self.y = obj.y
|
||||
self.root = EventPoint(obj.root.x, obj.root.y)
|
||||
self.multi = EventMulti(obj.multi.device, obj.multi.radius,
|
||||
obj.multi.radius_x, obj.multi.radius_y,
|
||||
obj.multi.pressure, obj.multi.angle,
|
||||
obj.multi.x, obj.multi.y,
|
||||
obj.multi.root.x, obj.multi.root.y)
|
||||
return 1
|
||||
|
||||
|
||||
cdef class EventMouseMove(Event):
|
||||
""" EventMouseMove()
|
||||
|
||||
Contains information about an Ecore mouse move event.
|
||||
|
||||
.. seealso :: :func:`on_mouse_move_add`
|
||||
|
||||
:ivar int timestamp: Time when the event occurred
|
||||
:ivar int modifiers: :ref:`Ecore_Event_Modifier` The OR combination of modifiers key
|
||||
:ivar bool same_screen: Same screen flag
|
||||
:ivar int x: x coordinate relative to window where event happened
|
||||
:ivar int y: y coordinate relative to window where event happened
|
||||
:ivar EventPoint root: Coordinates relative to root window
|
||||
|
||||
"""
|
||||
cdef int _set_obj(self, void *o) except 0:
|
||||
cdef Ecore_Event_Mouse_Move *obj
|
||||
obj = <Ecore_Event_Mouse_Move *>o
|
||||
# self.window = Window(<unsigned long><void*>obj.window)
|
||||
# self.root_window = Window(<unsigned long><void*>obj.root_window)
|
||||
# self.event_window = Window(<unsigned long><void*>obj.event_window)
|
||||
self.timestamp = obj.timestamp
|
||||
self.modifiers = obj.modifiers
|
||||
self.same_screen = bool(obj.same_screen)
|
||||
self.x = obj.x
|
||||
self.y = obj.y
|
||||
self.root = EventPoint(obj.root.x, obj.root.y)
|
||||
self.multi = EventMulti(obj.multi.device, obj.multi.radius,
|
||||
obj.multi.radius_x, obj.multi.radius_y,
|
||||
obj.multi.pressure, obj.multi.angle,
|
||||
obj.multi.x, obj.multi.y,
|
||||
obj.multi.root.x, obj.multi.root.y)
|
||||
return 1
|
||||
|
||||
|
||||
cdef class EventMouseIO(Event):
|
||||
""" EventMouseIO()
|
||||
|
||||
Contains information about an Ecore mouse input/output event.
|
||||
|
||||
.. seealso :: :func:`on_mouse_in_add`, :func:`on_mouse_out_add`
|
||||
|
||||
:ivar int timestamp: Time when the event occurred
|
||||
:ivar int modifiers: :ref:`Ecore_Event_Modifier` The OR combination of modifiers key
|
||||
:ivar int x: x coordinate relative to window where event happened
|
||||
:ivar int y: y coordinate relative to window where event happened
|
||||
|
||||
"""
|
||||
cdef int _set_obj(self, void *o) except 0:
|
||||
cdef Ecore_Event_Mouse_IO *obj
|
||||
obj = <Ecore_Event_Mouse_IO *>o
|
||||
# self.window = Window(<unsigned long><void*>obj.window)
|
||||
# self.event_window = Window(<unsigned long><void*>obj.event_window)
|
||||
self.timestamp = obj.timestamp
|
||||
self.modifiers = obj.modifiers
|
||||
self.x = obj.x
|
||||
self.y = obj.y
|
||||
return 1
|
||||
|
||||
|
||||
cdef class EventMouseWheel(Event):
|
||||
""" EventMouseWheel()
|
||||
|
||||
Contains information about an Ecore mouse wheel event.
|
||||
|
||||
.. seealso :: :func:`on_mouse_wheel_add`
|
||||
|
||||
:ivar int timestamp: Time when the event occurred
|
||||
:ivar int modifiers: :ref:`Ecore_Event_Modifier` The OR combination of modifiers key
|
||||
:ivar bool same_screen: Same screen flag
|
||||
:ivar int direction: Orientation of the wheel (horizontal/vertical)
|
||||
:ivar int z: Value of the wheel event (+1/-1)
|
||||
:ivar int x: x coordinate relative to window where event happened
|
||||
:ivar int y: y coordinate relative to window where event happened
|
||||
:ivar EventPoint root: Coordinates relative to root window.
|
||||
|
||||
"""
|
||||
cdef int _set_obj(self, void *o) except 0:
|
||||
cdef Ecore_Event_Mouse_Wheel *obj
|
||||
obj = <Ecore_Event_Mouse_Wheel *>o
|
||||
# self.window = Window(<unsigned long><void*>obj.window)
|
||||
# self.root_window = Window(<unsigned long><void*>obj.root_window)
|
||||
# self.event_window = Window(<unsigned long><void*>obj.event_window)
|
||||
self.timestamp = obj.timestamp
|
||||
self.modifiers = obj.modifiers
|
||||
self.same_screen = bool(obj.same_screen)
|
||||
self.direction = obj.direction
|
||||
self.z = obj.z
|
||||
self.x = obj.x
|
||||
self.y = obj.y
|
||||
self.root = EventPoint(obj.root.x, obj.root.y)
|
||||
return 1
|
||||
|
||||
|
||||
def on_key_down_add(func, *args, **kargs):
|
||||
"""
|
||||
Creates an ecore event handler for the ECORE_EVENT_KEY_DOWN event.
|
||||
|
||||
:return: :class:`InputEventHandler`
|
||||
|
||||
.. seealso:: :class:`EventKey`
|
||||
"""
|
||||
return InputEventHandler(ECORE_EVENT_KEY_DOWN, func, *args, **kargs)
|
||||
|
||||
def on_key_up_add(func, *args, **kargs):
|
||||
"""
|
||||
Creates an ecore event handler for the ECORE_EVENT_KEY_UP event.
|
||||
|
||||
:return: :class:`InputEventHandler`
|
||||
|
||||
.. seealso:: :class:`EventKey`
|
||||
"""
|
||||
return InputEventHandler(ECORE_EVENT_KEY_UP, func, *args, **kargs)
|
||||
|
||||
def on_mouse_button_down_add(func, *args, **kargs):
|
||||
"""
|
||||
Creates an ecore event handler for the ECORE_EVENT_MOUSE_BUTTON_DOWN event.
|
||||
|
||||
:return: :class:`InputEventHandler`
|
||||
|
||||
.. seealso:: :class:`EventMouseButton`
|
||||
"""
|
||||
return InputEventHandler(ECORE_EVENT_MOUSE_BUTTON_DOWN, func, *args, **kargs)
|
||||
|
||||
def on_mouse_button_up_add(func, *args, **kargs):
|
||||
"""
|
||||
Create an ecore event handler for the ECORE_EVENT_MOUSE_BUTTON_UP event.
|
||||
|
||||
:return: :class:`InputEventHandler`
|
||||
|
||||
.. seealso:: :class:`EventMouseButton`
|
||||
"""
|
||||
return InputEventHandler(ECORE_EVENT_MOUSE_BUTTON_UP, func, *args, **kargs)
|
||||
|
||||
def on_mouse_move_add(func, *args, **kargs):
|
||||
"""
|
||||
Create an ecore event handler for the ECORE_EVENT_MOUSE_MOVE event.
|
||||
|
||||
:return: :class:`InputEventHandler`
|
||||
|
||||
.. seealso:: :class:`EventMouseMove`
|
||||
"""
|
||||
return InputEventHandler(ECORE_EVENT_MOUSE_MOVE, func, *args, **kargs)
|
||||
|
||||
def on_mouse_in_add(func, *args, **kargs):
|
||||
"""
|
||||
Create an ecore event handler for the ECORE_EVENT_MOUSE_IN event.
|
||||
|
||||
:return: :class:`InputEventHandler`
|
||||
|
||||
.. seealso:: :class:`EventMouseIO`
|
||||
"""
|
||||
return InputEventHandler(ECORE_EVENT_MOUSE_IN, func, *args, **kargs)
|
||||
|
||||
def on_mouse_out_add(func, *args, **kargs):
|
||||
"""
|
||||
Create an ecore event handler for the ECORE_EVENT_MOUSE_OUT event.
|
||||
|
||||
:return: :class:`InputEventHandler`
|
||||
|
||||
.. seealso:: :class:`EventMouseIO`
|
||||
"""
|
||||
return InputEventHandler(ECORE_EVENT_MOUSE_OUT, func, *args, **kargs)
|
||||
|
||||
def on_mouse_wheel_add(func, *args, **kargs):
|
||||
"""
|
||||
Create an ecore event handler for the ECORE_EVENT_MOUSE_WHEEL event.
|
||||
|
||||
:return: :class:`InputEventHandler`
|
||||
|
||||
.. seealso:: :class:`EventMouseWheel`
|
||||
"""
|
||||
return InputEventHandler(ECORE_EVENT_MOUSE_WHEEL, func, *args, **kargs)
|
|
@ -0,0 +1,88 @@
|
|||
#!/usr/bin/env python
|
||||
# encoding: utf-8
|
||||
|
||||
|
||||
from efl import evas
|
||||
from efl import ecore
|
||||
from efl import ecore_input
|
||||
from efl import elementary as elm
|
||||
|
||||
|
||||
|
||||
def _event_cb1(event, one, two, asd):
|
||||
print(event)
|
||||
print(one, two, asd) # test args and kargs
|
||||
print()
|
||||
return ecore.ECORE_CALLBACK_PASS_ON # or ECORE_CALLBACK_DONE to stop propagation
|
||||
|
||||
def _event_cb2(event):
|
||||
print(event)
|
||||
print()
|
||||
return ecore.ECORE_CALLBACK_PASS_ON
|
||||
|
||||
|
||||
move_handler = None
|
||||
|
||||
def move_connect_cb(btn):
|
||||
global move_handler
|
||||
|
||||
if move_handler is None:
|
||||
move_handler = ecore_input.on_mouse_move_add(_event_cb2)
|
||||
|
||||
def move_delete_cb(btn):
|
||||
global move_handler
|
||||
|
||||
if move_handler is not None:
|
||||
move_handler.delete()
|
||||
move_handler = None
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
win = elm.StandardWindow("ecore_input_test", "Ecore Input Test",
|
||||
size=(200,200))
|
||||
win.callback_delete_request_add(lambda w: elm.exit())
|
||||
win.focus_highlight_enabled = True
|
||||
win.focus_highlight_animate = True
|
||||
|
||||
tb = elm.Table(win, padding=(10,10), size_hint_expand=evas.EXPAND_BOTH,
|
||||
size_hint_fill=evas.FILL_BOTH)
|
||||
win.resize_object_add(tb)
|
||||
tb.show()
|
||||
|
||||
lb = elm.Label(tb, text="<b><info>Watch for events in console.</info></b>")
|
||||
tb.pack(lb, 0, 0, 2, 1)
|
||||
lb.show()
|
||||
|
||||
bt = elm.Button(tb, text="Connect MouseMove")
|
||||
bt.callback_clicked_add(move_connect_cb)
|
||||
tb.pack(bt, 0, 1, 1, 1)
|
||||
bt.show()
|
||||
bt.focus = True
|
||||
|
||||
bt = elm.Button(tb, text="Delete MouseMove")
|
||||
bt.callback_clicked_add(move_delete_cb)
|
||||
tb.pack(bt, 1, 1, 1, 1)
|
||||
bt.show()
|
||||
|
||||
en = elm.Entry(tb, text="Test event propagation",
|
||||
editable=True, scrollable=True, single_line=True,
|
||||
size_hint_expand=evas.EXPAND_HORIZ,
|
||||
size_hint_fill=evas.FILL_BOTH)
|
||||
tb.pack(en, 0, 2, 2, 1)
|
||||
en.show()
|
||||
|
||||
# NOTE FOR BRAVE HACKERS:
|
||||
# You can setup the event callbacks BEFORE win creation to have the ability
|
||||
# to stop (ECORE_CALLBACK_DONE) or continue (ECORE_CALLBACK_PASS_ON) the
|
||||
# event propagation down to elementary widgets.
|
||||
ecore_input.on_key_down_add(_event_cb1, 1, 2, 'DOWN')
|
||||
ecore_input.on_key_up_add(_event_cb2)
|
||||
ecore_input.on_mouse_button_down_add(_event_cb2)
|
||||
ecore_input.on_mouse_button_up_add(_event_cb2)
|
||||
ecore_input.on_mouse_in_add(_event_cb2) # this event do not work here
|
||||
ecore_input.on_mouse_out_add(_event_cb2) # this event do not work here
|
||||
ecore_input.on_mouse_wheel_add(_event_cb2)
|
||||
|
||||
win.show()
|
||||
elm.run()
|
17
setup.py
17
setup.py
|
@ -308,6 +308,20 @@ if set(("build", "build_ext", "install", "bdist", "sdist")) & set(sys.argv):
|
|||
eina_libs + evas_libs)
|
||||
ext_modules.append(ecore_ext)
|
||||
|
||||
# === Ecore Input ===
|
||||
ecore_input_cflags, ecore_input_libs = pkg_config('EcoreInput',
|
||||
'ecore-input',
|
||||
EFL_MIN_VER)
|
||||
ecore_input_ext = Extension("ecore_input",
|
||||
["efl/ecore_input/efl.ecore_input" + module_suffix],
|
||||
include_dirs=['include/'],
|
||||
extra_compile_args=list(set(ecore_cflags +
|
||||
ecore_file_cflags +
|
||||
ecore_input_cflags)),
|
||||
extra_link_args=ecore_libs + ecore_file_libs +
|
||||
ecore_input_libs)
|
||||
ext_modules.append(ecore_input_ext)
|
||||
|
||||
# === Ecore Con ===
|
||||
ecore_con_cflags, ecore_con_libs = pkg_config('EcoreCon', 'ecore-con',
|
||||
EFL_MIN_VER)
|
||||
|
@ -323,9 +337,6 @@ if set(("build", "build_ext", "install", "bdist", "sdist")) & set(sys.argv):
|
|||
|
||||
# === Ecore X ===
|
||||
try:
|
||||
ecore_input_cflags, ecore_input_libs = pkg_config('EcoreInput',
|
||||
'ecore-input',
|
||||
EFL_MIN_VER)
|
||||
ecore_x_cflags, ecore_x_libs = pkg_config('EcoreX', 'ecore-x',
|
||||
EFL_MIN_VER)
|
||||
except SystemExit:
|
||||
|
|
Loading…
Reference in New Issue