forked from cztomczak/cefpython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfocus_handler.pyx
More file actions
63 lines (54 loc) · 2.09 KB
/
focus_handler.pyx
File metadata and controls
63 lines (54 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# Copyright (c) 2016 CEF Python, see the Authors file.
# All rights reserved. Licensed under BSD 3-clause license.
# Project website: https://github.com/cztomczak/cefpython
include "../cefpython.pyx"
include "../browser.pyx"
cimport cef_types
from cef_types cimport TID_UI
FOCUS_SOURCE_NAVIGATION = cef_types.FOCUS_SOURCE_NAVIGATION
FOCUS_SOURCE_SYSTEM = cef_types.FOCUS_SOURCE_SYSTEM
cdef public void FocusHandler_OnTakeFocus(
CefRefPtr[CefBrowser] cef_browser,
cpp_bool next_
) except * with gil:
cdef PyBrowser browser
try:
assert IsThread(TID_UI), "Must be called on the UI thread"
browser = GetPyBrowser(cef_browser, "OnTakeFocus")
callback = browser.GetClientCallback("OnTakeFocus")
if callback:
callback(browser=browser, next=next_)
except:
(exc_type, exc_value, exc_trace) = sys.exc_info()
sys.excepthook(exc_type, exc_value, exc_trace)
cdef public cpp_bool FocusHandler_OnSetFocus(
CefRefPtr[CefBrowser] cef_browser,
cef_types.cef_focus_source_t source
) except * with gil:
cdef PyBrowser browser
cdef py_bool ret
try:
assert IsThread(TID_UI), "Must be called on the UI thread"
browser = GetPyBrowser(cef_browser, "OnSetFocus")
callback = browser.GetClientCallback("OnSetFocus")
if callback:
ret = callback(browser=browser, source=source)
return bool(ret)
else:
return False
except:
(exc_type, exc_value, exc_trace) = sys.exc_info()
sys.excepthook(exc_type, exc_value, exc_trace)
cdef public void FocusHandler_OnGotFocus(
CefRefPtr[CefBrowser] cef_browser
) except * with gil:
cdef PyBrowser browser
try:
assert IsThread(TID_UI), "Must be called on the UI thread"
browser = GetPyBrowser(cef_browser, "OnGotFocus")
callback = browser.GetClientCallback("OnGotFocus")
if callback:
callback(browser=browser)
except:
(exc_type, exc_value, exc_trace) = sys.exc_info()
sys.excepthook(exc_type, exc_value, exc_trace)