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
59 lines (51 loc) · 1.89 KB
/
focus_handler.pyx
File metadata and controls
59 lines (51 loc) · 1.89 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
# Copyright (c) 2016 CEF Python. See the Authors and License files.
include "../cefpython.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)
callback = browser.GetClientCallback("OnTakeFocus")
if callback:
callback(browser, 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)
callback = browser.GetClientCallback("OnSetFocus")
if callback:
ret = callback(browser, 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)
callback = browser.GetClientCallback("OnGotFocus")
if callback:
callback(browser)
except:
(exc_type, exc_value, exc_trace) = sys.exc_info()
sys.excepthook(exc_type, exc_value, exc_trace)