| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent fbd46fe commit ce95f56
16 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,6 +2,16 @@ | |||
| 2 | 2 | # License: New BSD License. | |
| 3 | 3 | # Website: http://code.google.com/p/cefpython/ | |
| 4 | 4 | ||
| 5 | + # cef_key_type_t, SendKeyEvent(). | ||
| 6 | + KEYTYPE_KEYUP = cef_types.KT_KEYUP | ||
| 7 | + KEYTYPE_KEYDOWN = cef_types.KT_KEYDOWN | ||
| 8 | + KEYTYPE_CHAR = cef_types.KT_CHAR | ||
| 9 | + | ||
| 10 | + # cef_mouse_button_type_t, SendMouseClickEvent(). | ||
| 11 | + MOUSEBUTTON_LEFT = cef_types.MBT_LEFT | ||
| 12 | + MOUSEBUTTON_MIDDLE = cef_types.MBT_MIDDLE | ||
| 13 | + MOUSEBUTTON_RIGHT = cef_types.MBT_RIGHT | ||
| 14 | + | ||
| 5 | 15 | # If you try to keep PyBrowser() objects inside cpp_vector you will | |
| 6 | 16 | # get segmentation faults, as they will be garbage collected. | |
| 7 | 17 | ||
@@ -272,6 +282,9 @@ cdef class PyBrowser: | |||
| 272 | 282 | preinc(iterator) | |
| 273 | 283 | return names | |
| 274 | 284 | ||
| 285 | + cpdef int GetIdentifier(self) except *: | ||
| 286 | + return self.GetCefBrowser().get().GetIdentifier() | ||
| 287 | + | ||
| 275 | 288 | cpdef PyFrame GetMainFrame(self): | |
| 276 | 289 | return GetPyFrame(self.GetCefBrowser().get().GetMainFrame()) | |
| 277 | 290 | ||
@@ -512,20 +525,44 @@ cdef class PyBrowser: | |||
| 512 | 525 | ||
| 513 | 526 | IF CEF_VERSION == 1: | |
| 514 | 527 | ||
| 515 | - cpdef py_void SendKeyEvent(self): | ||
| 516 | - pass | ||
| 528 | + cpdef py_void SendKeyEvent(self, cef_types.cef_key_type_t keyType, | ||
| 529 | + tuple keyInfo, int modifiers): | ||
| 530 | + cdef CefKeyInfo cefKeyInfo | ||
| 531 | + IF UNAME_SYSNAME == "Windows": | ||
| 532 | + assert len(keyInfo) == 3, "Invalid keyInfo param" | ||
| 533 | + cefKeyInfo.key = keyInfo[0] | ||
| 534 | + cefKeyInfo.sysChar = keyInfo[1] | ||
| 535 | + cefKeyInfo.imeChar = keyInfo[2] | ||
| 536 | + ELIF UNAME_SYSNAME == "Darwin": | ||
| 537 | + cefKeyInfo.keyCode = keyInfo[0] | ||
| 538 | + cefKeyInfo.character = keyInfo[1] | ||
| 539 | + cefKeyInfo.characterNoModifiers = keyInfo[2] | ||
| 540 | + ELIF UNAME_SYSNAME == "Linux": | ||
| 541 | + cefKeyInfo.key = keyInfo[0] | ||
| 542 | + ELSE: | ||
| 543 | + raise Exception("Invalid UNAME_SYSNAME") | ||
| 544 | + | ||
| 545 | + self.GetCefBrowser().get().SendKeyEvent(keyType, cefKeyInfo, | ||
| 546 | + modifiers) | ||
| 517 | 547 | ||
| 518 | - cpdef py_void SendMouseClickEvent(self): | ||
| 519 | - pass | ||
| 548 | + cpdef py_void SendMouseClickEvent(self, int x, int y, | ||
| 549 | + cef_types.cef_mouse_button_type_t mouseButtonType, | ||
| 550 | + py_bool mouseUp, int clickCount): | ||
| 551 | + self.GetCefBrowser().get().SendMouseClickEvent(x, y, | ||
| 552 | + mouseButtonType, bool(mouseUp), clickCount) | ||
| 520 | 553 | ||
| 521 | - cpdef py_void SendMouseMoveEvent(self): | ||
| 522 | - pass | ||
| 554 | + cpdef py_void SendMouseMoveEvent(self, int x, int y, | ||
| 555 | + py_bool mouseLeave): | ||
| 556 | + self.GetCefBrowser().get().SendMouseMoveEvent(x, y, | ||
| 557 | + bool(mouseLeave)) | ||
| 523 | 558 | ||
| 524 | - cpdef py_void SendMouseWheelEvent(self): | ||
| 525 | - pass | ||
| 559 | + cpdef py_void SendMouseWheelEvent(self, int x, int y, | ||
| 560 | + int deltaX, int deltaY): | ||
| 561 | + self.GetCefBrowser().get().SendMouseWheelEvent(x, y, | ||
| 562 | + deltaX, deltaY) | ||
| 526 | 563 | ||
| 527 | - cpdef py_void SendFocusEvent(self): | ||
| 528 | - pass | ||
| 564 | + cpdef py_void SendFocusEvent(self, py_bool setFocus): | ||
| 565 | + self.GetCefBrowser().get().SendFocusEvent(bool(setFocus)) | ||
| 529 | 566 | ||
| 530 | 567 | cpdef py_void SendCaptureLostEvent(self): | |
| 531 | - pass | ||
| 568 | + self.GetCefBrowser().get().SendCaptureLostEvent() | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,6 +14,12 @@ | |||
| 14 | 14 | # | |
| 15 | 15 | # This will enable your copy of python to find the panda libraries. | |
| 16 | 16 | ||
| 17 | + # TODO: implement forwarding key/mouse events to the CEF browser. | ||
| 18 | + # Browser object has following methods: SendKeyEvent(), | ||
| 19 | + # SendMouseClickEvent(), SendMouseMoveEvent(), | ||
| 20 | + # SendMouseWheelEvent(), SendFocusEvent(), | ||
| 21 | + # SendCaptureLostEvent(). | ||
| 22 | + | ||
| 17 | 23 | import platform | |
| 18 | 24 | if platform.architecture()[0] != "32bit": | |
| 19 | 25 | raise Exception("Unsupported architecture: %s" % ( | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -41,7 +41,7 @@ __PYX_EXTERN_C DL_IMPORT(bool) RenderHandler_GetScreenPoint(CefRefPtr<CefBrowser | |||
| 41 | 41 | __PYX_EXTERN_C DL_IMPORT(void) RenderHandler_OnPopupShow(CefRefPtr<CefBrowser>, bool); | |
| 42 | 42 | __PYX_EXTERN_C DL_IMPORT(void) RenderHandler_OnPopupSize(CefRefPtr<CefBrowser>, CefRect &); | |
| 43 | 43 | __PYX_EXTERN_C DL_IMPORT(void) RenderHandler_OnPaint(CefRefPtr<CefBrowser>, cef_paint_element_type_t, std::vector<CefRect> &, void *); | |
| 44 | - __PYX_EXTERN_C DL_IMPORT(bool) RenderHandler_OnCursorChange(CefRefPtr<CefBrowser>, CefCursorHandle); | ||
| 44 | + __PYX_EXTERN_C DL_IMPORT(void) RenderHandler_OnCursorChange(CefRefPtr<CefBrowser>, CefCursorHandle); | ||
| 45 | 45 | __PYX_EXTERN_C DL_IMPORT(void) V8ContextHandler_OnContextCreated(CefRefPtr<CefBrowser>, CefRefPtr<CefFrame>, CefRefPtr<CefV8Context>); | |
| 46 | 46 | __PYX_EXTERN_C DL_IMPORT(void) V8ContextHandler_OnContextReleased(CefRefPtr<CefBrowser>, CefRefPtr<CefFrame>, CefRefPtr<CefV8Context>); | |
| 47 | 47 | __PYX_EXTERN_C DL_IMPORT(void) V8ContextHandler_OnUncaughtException(CefRefPtr<CefBrowser>, CefRefPtr<CefFrame>, CefRefPtr<CefV8Context>, CefRefPtr<CefV8Exception>, CefRefPtr<CefV8StackTrace>); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -29,9 +29,10 @@ void SwapBufferFromBgraToRgba(void* _dest, void* _src, int width, int height) { | |||
| 29 | 29 | int length = width*height; | |
| 30 | 30 | for (int i = 0; i < length; i++) { | |
| 31 | 31 | bgra = src[i]; | |
| 32 | - rgba = (bgra & 0x00ff0000) >> 16 | ||
| 33 | - | (bgra & 0xff00ff00) | ||
| 34 | - | (bgra & 0x000000ff) << 16; | ||
| 32 | + // BGRA in hex = 0xAARRGGBB. | ||
| 33 | + rgba = (bgra & 0x00ff0000) >> 16 // Red >> Blue. | ||
| 34 | + | (bgra & 0xff00ff00) // Green Alpha. | ||
| 35 | + | (bgra & 0x000000ff) << 16; // Blue >> Red. | ||
| 35 | 36 | dest[i] = rgba; | |
| 36 | 37 | } | |
| 37 | 38 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,8 +11,9 @@ from cef_client cimport CefClient | |||
| 11 | 11 | from libcpp cimport bool as cpp_bool | |
| 12 | 12 | from libcpp.vector cimport vector as cpp_vector | |
| 13 | 13 | from cef_frame cimport CefFrame | |
| 14 | - from cef_types cimport cef_paint_element_type_t | ||
| 14 | + cimport cef_types | ||
| 15 | 15 | from cef_types_wrappers cimport CefRect | |
| 16 | + from cef_platform cimport CefKeyInfo | ||
| 16 | 17 | ||
| 17 | 18 | IF UNAME_SYSNAME == "Windows": | |
| 18 | 19 | from cef_win cimport CefWindowHandle, CefWindowInfo | |
@@ -54,15 +55,28 @@ cdef extern from "include/cef_browser.h": | |||
| 54 | 55 | cpp_bool IsPopupVisible() | |
| 55 | 56 | int GetIdentifier() | |
| 56 | 57 | ||
| 57 | - # off-screen rendering. | ||
| 58 | - cpp_bool GetSize(cef_paint_element_type_t type, | ||
| 58 | + # Off-screen rendering. | ||
| 59 | + | ||
| 60 | + cpp_bool GetSize(cef_types.cef_paint_element_type_t type, | ||
| 59 | 61 | int& width, int& height) | |
| 60 | - void SetSize(cef_paint_element_type_t type, | ||
| 62 | + void SetSize(cef_types.cef_paint_element_type_t type, | ||
| 61 | 63 | int width, int height) | |
| 62 | 64 | void Invalidate(CefRect& dirtyRect) | |
| 63 | - cpp_bool GetImage(cef_paint_element_type_t type, | ||
| 65 | + cpp_bool GetImage(cef_types.cef_paint_element_type_t type, | ||
| 64 | 66 | int width, int height, void* buffer) | |
| 65 | 67 | ||
| 68 | + # Sending mouse/key events. | ||
| 69 | + | ||
| 70 | + void SendKeyEvent(cef_types.cef_key_type_t type, | ||
| 71 | + CefKeyInfo& keyInfo, int modifiers) | ||
| 72 | + void SendMouseClickEvent(int x, int y, | ||
| 73 | + cef_types.cef_mouse_button_type_t type, | ||
| 74 | + cpp_bool mouseUp, int clickCount) | ||
| 75 | + void SendMouseMoveEvent(int x, int y, cpp_bool mouseLeave) | ||
| 76 | + void SendMouseWheelEvent(int x, int y, int deltaX, int deltaY) | ||
| 77 | + void SendFocusEvent(cpp_bool setFocus) | ||
| 78 | + void SendCaptureLostEvent() | ||
| 79 | + | ||
| 66 | 80 | # virtual CefRefPtr<CefClient> GetClient() =0; | |
| 67 | 81 | ||
| 68 | 82 | ELIF CEF_VERSION == 3: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,9 @@ | |||
| 1 | + # Copyright (c) 2012 CefPython Authors. All rights reserved. | ||
| 2 | + # License: New BSD License. | ||
| 3 | + # Website: http://code.google.com/p/cefpython/ | ||
| 4 | + | ||
| 5 | + from cef_types_linux cimport _cef_key_info_t | ||
| 6 | + | ||
| 7 | + cdef extern from "include/internal/cef_linux.h": | ||
| 8 | + | ||
| 9 | + ctypedef _cef_key_info_t CefKeyInfo | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,9 @@ | |||
| 1 | + # Copyright (c) 2012 CefPython Authors. All rights reserved. | ||
| 2 | + # License: New BSD License. | ||
| 3 | + # Website: http://code.google.com/p/cefpython/ | ||
| 4 | + | ||
| 5 | + from cef_types_mac cimport _cef_key_info_t | ||
| 6 | + | ||
| 7 | + cdef extern from "include/internal/cef_mac.h": | ||
| 8 | + | ||
| 9 | + ctypedef _cef_key_info_t CefKeyInfo | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,10 @@ | |||
| 1 | + # Copyright (c) 2012 CefPython Authors. All rights reserved. | ||
| 2 | + # License: New BSD License. | ||
| 3 | + # Website: http://code.google.com/p/cefpython/ | ||
| 4 | + | ||
| 5 | + IF UNAME_SYSNAME == "Windows": | ||
| 6 | + from cef_win cimport * | ||
| 7 | + ELIF UNAME_SYSNAME == "Darwin": | ||
| 8 | + from cef_mac cimport * | ||
| 9 | + ELIF UNAME_SYSNAME == "Linux": | ||
| 10 | + from cef_linux cimport * | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -151,7 +151,21 @@ cdef extern from "include/internal/cef_types.h": | |||
| 151 | 151 | PID_RENDERER, | |
| 152 | 152 | ||
| 153 | 153 | IF CEF_VERSION == 1: | |
| 154 | + | ||
| 155 | + # Browser > GetImage(), RenderHandler > OnPaint(). | ||
| 154 | 156 | ctypedef enum cef_paint_element_type_t: | |
| 155 | 157 | PET_VIEW = 0, | |
| 156 | 158 | PET_POPUP, | |
| 157 | 159 | ||
| 160 | + # Browser > SendKeyEvent(). | ||
| 161 | + ctypedef enum cef_key_type_t: | ||
| 162 | + KT_KEYUP = 0, | ||
| 163 | + KT_KEYDOWN, | ||
| 164 | + KT_CHAR, | ||
| 165 | + | ||
| 166 | + # Browser > SendMouseClickEvent(). | ||
| 167 | + ctypedef enum cef_mouse_button_type_t: | ||
| 168 | + MBT_LEFT = 0, | ||
| 169 | + MBT_MIDDLE, | ||
| 170 | + MBT_RIGHT, | ||
| 171 | + | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments