Code to dispatch mouse events to python
This commit is contained in:
parent
f6b0fcbc0f
commit
ba1ee7e6cc
@ -122,6 +122,16 @@ encode_mouse_scroll(Window *w, bool upwards, int mods) {
|
|||||||
|
|
||||||
// }}}
|
// }}}
|
||||||
|
|
||||||
|
static void
|
||||||
|
dispatch_mouse_event(Window *w, int button, int count, int modifiers) {
|
||||||
|
if (w->render_data.screen && PyCallable_Check(w->render_data.screen->callbacks)) {
|
||||||
|
PyObject *callback_ret = PyObject_CallMethod(w->render_data.screen->callbacks, "on_mouse_event", "{si si si}",
|
||||||
|
"button", button, "count", count, "modifiers", modifiers);
|
||||||
|
if (callback_ret == NULL) PyErr_Print();
|
||||||
|
else Py_DECREF(callback_ret);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static inline unsigned int
|
static inline unsigned int
|
||||||
window_left(Window *w) {
|
window_left(Window *w) {
|
||||||
return w->geometry.left - w->padding.left;
|
return w->geometry.left - w->padding.left;
|
||||||
|
|||||||
@ -21,3 +21,4 @@ EdgeLiteral = str
|
|||||||
PowerlineStyle = str
|
PowerlineStyle = str
|
||||||
MatchType = str
|
MatchType = str
|
||||||
Protocol = object
|
Protocol = object
|
||||||
|
MouseEvent = dict
|
||||||
|
|||||||
@ -41,19 +41,27 @@ from .window import Window as WindowType
|
|||||||
|
|
||||||
EdgeLiteral = Literal['left', 'top', 'right', 'bottom']
|
EdgeLiteral = Literal['left', 'top', 'right', 'bottom']
|
||||||
MatchType = Literal['mime', 'ext', 'protocol', 'file', 'path', 'url', 'fragment_matches']
|
MatchType = Literal['mime', 'ext', 'protocol', 'file', 'path', 'url', 'fragment_matches']
|
||||||
|
PowerlineStyle = Literal['angled', 'slanted', 'round']
|
||||||
GRT_a = Literal['t', 'T', 'q', 'p', 'd', 'f', 'a']
|
GRT_a = Literal['t', 'T', 'q', 'p', 'd', 'f', 'a']
|
||||||
GRT_f = Literal[24, 32, 100]
|
GRT_f = Literal[24, 32, 100]
|
||||||
GRT_t = Literal['d', 'f', 't', 's']
|
GRT_t = Literal['d', 'f', 't', 's']
|
||||||
GRT_o = Literal['z']
|
GRT_o = Literal['z']
|
||||||
GRT_m = Literal[0, 1]
|
GRT_m = Literal[0, 1]
|
||||||
GRT_d = Literal['a', 'A', 'c', 'C', 'i', 'I', 'p', 'P', 'q', 'Q', 'x', 'X', 'y', 'Y', 'z', 'Z', 'f', 'F']
|
GRT_d = Literal['a', 'A', 'c', 'C', 'i', 'I', 'p', 'P', 'q', 'Q', 'x', 'X', 'y', 'Y', 'z', 'Z', 'f', 'F']
|
||||||
|
|
||||||
|
|
||||||
|
class WindowSystemMouseEvent(TypedDict):
|
||||||
|
button: int
|
||||||
|
count: int
|
||||||
|
mods: int
|
||||||
|
|
||||||
|
|
||||||
__all__ = (
|
__all__ = (
|
||||||
'EdgeLiteral', 'MatchType', 'GRT_a', 'GRT_f', 'GRT_t', 'GRT_o', 'GRT_m', 'GRT_d',
|
'EdgeLiteral', 'MatchType', 'GRT_a', 'GRT_f', 'GRT_t', 'GRT_o', 'GRT_m', 'GRT_d',
|
||||||
'GraphicsCommandType', 'HandlerType', 'AbstractEventLoop', 'AddressFamily', 'Socket', 'CompletedProcess',
|
'GraphicsCommandType', 'HandlerType', 'AbstractEventLoop', 'AddressFamily', 'Socket', 'CompletedProcess',
|
||||||
'PopenType', 'Protocol', 'TypedDict', 'MarkType', 'ImageManagerType', 'Debug', 'LoopType', 'MouseEvent',
|
'PopenType', 'Protocol', 'TypedDict', 'MarkType', 'ImageManagerType', 'Debug', 'LoopType', 'MouseEvent',
|
||||||
'TermManagerType', 'KittensKeyActionType', 'BossType', 'ChildType', 'BadLineType',
|
'TermManagerType', 'KittensKeyActionType', 'BossType', 'ChildType', 'BadLineType',
|
||||||
'KeyActionType', 'KeyMap', 'KittyCommonOpts', 'SequenceMap', 'CoreTextFont',
|
'KeyActionType', 'KeyMap', 'KittyCommonOpts', 'SequenceMap', 'CoreTextFont', 'WindowSystemMouseEvent',
|
||||||
'FontConfigPattern', 'ScreenType', 'StartupCtx', 'KeyEventType', 'LayoutType',
|
'FontConfigPattern', 'ScreenType', 'StartupCtx', 'KeyEventType', 'LayoutType', 'PowerlineStyle',
|
||||||
'RemoteCommandType', 'SessionType', 'SessionTab', 'SpecialWindowInstance', 'TabType', 'ScreenSize', 'WindowType'
|
'RemoteCommandType', 'SessionType', 'SessionTab', 'SpecialWindowInstance', 'TabType', 'ScreenSize', 'WindowType'
|
||||||
)
|
)
|
||||||
PowerlineStyle = Literal['angled', 'slanted', 'round']
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user