Skip to content

Commit 5ce5c36

Browse files
committed
Fix DevTools window not showing on Windows (cztomczak#303)...
Add "Quick build instructions for Windows" section indocs/Build-instructions. Fix invalid types for window handles on Windows 64-bit (cztomczak#302). Also fix long long for other pointers such as in PaintBuffer. Also fix long long for uint types. Get rid of invalid/unnecessary long conversions eg. from int64 type.
1 parent 6f7c52d commit 5ce5c36

19 files changed

+152
-77
lines changed

docs/Build-instructions.md

Lines changed: 64 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,33 @@
11
# Build instructions
22

3-
__IMPORTANT NOTE__: These instructions are for the new releases of CEF Python
4-
(Chrome v51 and later). Currently only Linux platform is being tested.
5-
For the old v31 release that is supported on all platforms, see build
6-
instructions on the wiki pages.
3+
These instructions are for the new releases of CEF Python v50+.
4+
For the old v31 release that is supported on all platforms, see
5+
the build instructions on the wiki pages.
6+
7+
If you would like to quickly build cefpython then see the
8+
[Quick build instructions for Windows](#quick-build-instructions-for-windows)
9+
and [Quick build instructions for Linux](#quick-build-instructions-for-linux)
10+
sections for complete instructions.
711

812
There are several types of builds you can perform:
913

10-
1. You can build CEF Python using prebuilt CEF binaries that were
11-
uploaded to GH releases (tagged eg. v51-upstream)
12-
2. You can build both CEF Python and CEF from sources, but note
14+
1. You can build CEF Python using prebuilt CEF binaries and libraries
15+
that were uploaded to GH releases (tagged eg. v55-upstream)
16+
2. You can build CEF Python using prebuilt CEF binaries from
17+
Spotify Automated Builds.
18+
3. You can build both CEF and CEF Python from sources, but note
1319
that Building CEF is a long process that can take hours.
14-
In the tools/ directory there is the automate.py script that
15-
automates building CEF.
16-
3. You may also use prebuilt binaries from Spotify automated builds,
17-
see the CEF automated builds section.
1820

19-
Before you can build CEF Python or CEF you must satisfy requirements
20-
listed on this page.
21+
Detailed instructions for building can be found in module doc comments
22+
in the `automate.py` and `build.py` tools (the tools/ directory).
23+
24+
Before you can build CEF Python or CEF you must satisfy some
25+
[requirements](#requirements) listed on this page.
2126

2227

2328
Table of contents:
24-
* [Build CEF Python on Linux](#build-cef-python-on-linux)
29+
* [Quick build instructions for Windows](#quick-build-instructions-for-windows)
30+
* [Quick build instructions for Linux](#quick-build-instructions-for-linux)
2531
* [Requirements](#requirements)
2632
* [Build CEF Python using prebuilt CEF binaries](#build-cef-python-using-prebuilt-cef-binaries)
2733
* [Build both CEF Python and CEF from sources](#build-both-cef-python-and-cef-from-sources)
@@ -30,7 +36,44 @@ Table of contents:
3036
* [How to patch](#how-to-patch)
3137

3238

33-
## Build CEF Python on Linux
39+
## Quick build instructions for Windows
40+
41+
Complete steps for building CEF Python v50+ using prebuilt binaries
42+
and libraries from GitHub releases:
43+
44+
1) Tested and works fine on Windows 7 64-bit
45+
46+
2) Download [ninja](https://github.com/ninja-build/ninja) 1.7.2 or later
47+
and add it to PATH.
48+
49+
3) Download [cmake](https://cmake.org/download/) 3.7.2 or later and add
50+
it to PATH.
51+
52+
4) For Python 2.7 Install "Visual C++ Compiler for Python 2.7"
53+
from [here](https://www.microsoft.com/en-us/download/details.aspx?id=44266)
54+
55+
5) For Python 2.7 and when using using "Visual C++ compiler for Python 2.7"
56+
you have to install "Visual C++ 2008 Redistributable Package (x64)"
57+
from [here](https://www.microsoft.com/en-us/download/details.aspx?id=15336)
58+
59+
6) Install python dependencies by running:
60+
`cd cefpython/tools/ && pip install -r requirements.txt`
61+
(Cython version from requirements.txt must match exactly)
62+
63+
7) Download 32-bit Windows binaries and libraries from
64+
[GH releases](https://github.com/cztomczak/cefpython/tags)
65+
tagged e.g. 'v55-upstream' when building v55.
66+
67+
8) Extract the archive it in the "cefpython/build/" directory.
68+
69+
9) Build cefpython and run examples (xx.x is version number eg. 55.4):
70+
```
71+
cd cefpython/build/
72+
python ../tools/build.py xx.x
73+
```
74+
75+
76+
## Quick build instructions for Linux
3477

3578
Complete steps for building CEF Python v50+ using prebuilt
3679
binaries from GitHub releases:
@@ -47,18 +90,19 @@ binaries from GitHub releases:
4790
(Cython version from requirements.txt must match exactly)
4891

4992
5) Download 64-bit Linux binaries and libraries from
50-
[GH releases](https://github.com/cztomczak/cefpython/releases)
51-
tagged e.g. 'v50-upstream' when building v50.
93+
[GH releases](https://github.com/cztomczak/cefpython/tags)
94+
tagged e.g. 'v55-upstream' when building v55.
5295

5396
6) Extract it in the cefpython/build/ directory and rename the extracted
5497
directory to "cef_linux64".
5598

56-
8) Build cefpython and run examples (xx.x is version e.g. 50.0):
99+
7) Build cefpython and run examples (xx.x is version e.g. 50.0):
57100
```
58101
cd cefpython/src/linux/
59102
python compile.py xx.x
60103
```
61104

105+
62106
## Requirements
63107

64108
Below are platform specific requirements. Do these first before
@@ -69,6 +113,8 @@ __Windows__
69113

70114
* Install an appropriate MS compiler for a specific Python version:
71115
https://wiki.python.org/moin/WindowsCompilers
116+
* For Python 2.7 install "Microsoft Visual C++ Compiler for Python 2.7"
117+
from [here](https://www.microsoft.com/en-us/download/details.aspx?id=44266)
72118
* When using "Visual C++ compiler for Python 2.7" you have to install
73119
"Microsoft Visual C++ 2008 Redistributable Package (x64)" from
74120
[here](https://www.microsoft.com/en-us/download/details.aspx?id=15336)

docs/Tutorial.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ Table of contents:
99
* [Hello world](#hello-world)
1010
* [CEF's multiprocess architecture](#cefs-multiprocess-architecture)
1111
* [Handling Python exceptions](#handling-python-exceptions)
12+
* [Message loop](#message-loop)
13+
* [Settings](#settings)
14+
* [Handlers](#handlers)
15+
* [Javascript integration](#javascript-integration)
16+
* [Plugins](#plugins)
17+
* [Helper functions](#helper-functions)
18+
* [Build executable](#build-executable)
19+
* [What's next?](#whats-next)
1220

1321

1422
## Install and download examples

src/browser.pyx

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ cpdef PyBrowser GetBrowserByWindowHandle(WindowHandle windowHandle):
107107
for browserId in g_pyBrowsers:
108108
pyBrowser = g_pyBrowsers[browserId]
109109
if (pyBrowser.GetWindowHandle() == windowHandle or
110-
pyBrowser.GetUserData("__outerWindowHandle") == long(windowHandle)):
110+
pyBrowser.GetUserData("__outerWindowHandle") == windowHandle):
111111
return pyBrowser
112112
return None
113113

@@ -312,7 +312,7 @@ cdef class PyBrowser:
312312

313313
cpdef object GetFrameByIdentifier(self, object identifier):
314314
return GetPyFrame(self.GetCefBrowser().get().GetFrame(
315-
<long long>long(identifier)))
315+
<int64>identifier))
316316

317317
cpdef list GetFrameNames(self):
318318
assert IsThread(TID_UI), (
@@ -418,7 +418,7 @@ cdef class PyBrowser:
418418
IF UNAME_SYSNAME == "Linux":
419419
x11.SetX11WindowBounds(self.GetCefBrowser(), x, y, width, height)
420420
ELSE:
421-
raise Exception("SetBounds() not implemented on this platform")
421+
NonCriticalError("SetBounds() not implemented on this platform")
422422

423423
cpdef py_void SetFocus(self, enable):
424424
self.GetCefBrowserHost().get().SetFocus(bool(enable))
@@ -430,13 +430,19 @@ cdef class PyBrowser:
430430
self.GetCefBrowserHost().get().SetZoomLevel(zoomLevel)
431431

432432
cpdef py_void ShowDevTools(self):
433-
cdef CefWindowInfo windowInfo
434-
cdef CefRefPtr[ClientHandler] clientHandler =\
433+
cdef CefWindowInfo window_info
434+
IF UNAME_SYSNAME == "Windows":
435+
# On Windows with empty window_info structure the devtools
436+
# window doesn't appear.
437+
window_info.SetAsPopup(
438+
<CefWindowHandle>self.GetOpenerWindowHandle(),
439+
PyToCefStringValue("DevTools"))
440+
cdef CefRefPtr[ClientHandler] client_handler =\
435441
<CefRefPtr[ClientHandler]?>new ClientHandler()
436442
cdef CefBrowserSettings settings
437443
cdef CefPoint inspect_element_at
438444
self.GetCefBrowserHost().get().ShowDevTools(
439-
windowInfo, <CefRefPtr[CefClient]?>clientHandler, settings,
445+
window_info, <CefRefPtr[CefClient]?>client_handler, settings,
440446
inspect_element_at)
441447

442448
cpdef py_void StopLoad(self):
@@ -454,7 +460,8 @@ cdef class PyBrowser:
454460
cpdef py_void ToggleFullscreen_Windows(self):
455461
cdef WindowHandle windowHandle
456462
if self.GetUserData("__outerWindowHandle"):
457-
windowHandle = <WindowHandle>self.GetUserData("__outerWindowHandle")
463+
windowHandle = <WindowHandle>\
464+
self.GetUserData("__outerWindowHandle")
458465
else:
459466
windowHandle = self.GetWindowHandle()
460467

@@ -463,7 +470,7 @@ cdef class PyBrowser:
463470
"Browser.ToggleFullscreen() failed: no window handle "
464471
"found")
465472

466-
cdef HWND hwnd = <HWND><int>int(windowHandle)
473+
cdef HWND hwnd = <HWND>windowHandle
467474
cdef RECT rect
468475
cdef HMONITOR monitor
469476
cdef MONITORINFO monitorInfo
@@ -533,7 +540,7 @@ cdef class PyBrowser:
533540
if "type" in pyEvent:
534541
cefEvent.type = int(pyEvent["type"])
535542
if "modifiers" in pyEvent:
536-
cefEvent.modifiers = long(pyEvent["modifiers"])
543+
cefEvent.modifiers = <uint32>pyEvent["modifiers"]
537544
# Always set CefKeyEvent.windows_key_code in SendKeyEvent, even on
538545
# Linux. When sending key event for 'backspace' on Linux and setting
539546
# "native_key_code", "character", "unmodified_character" it doesn't
@@ -639,15 +646,15 @@ cdef class PyBrowser:
639646
# -------------------------------------------------------------------------
640647

641648
cpdef py_void DragTargetDragEnter(self, DragData drag_data, int x, int y,
642-
long long allowed_ops):
649+
uint32 allowed_ops):
643650
cdef CefMouseEvent mouse_event
644651
mouse_event.x = x
645652
mouse_event.y = y
646653
self.GetCefBrowserHost().get().DragTargetDragEnter(
647654
drag_data.cef_drag_data, mouse_event,
648655
<cef_types.cef_drag_operations_mask_t>allowed_ops)
649656

650-
cpdef py_void DragTargetDragOver(self, int x, int y, long long allowed_ops):
657+
cpdef py_void DragTargetDragOver(self, int x, int y, uint32 allowed_ops):
651658
cdef CefMouseEvent mouse_event
652659
mouse_event.x = x
653660
mouse_event.y = y
@@ -663,7 +670,7 @@ cdef class PyBrowser:
663670
mouse_event.y = y
664671
self.GetCefBrowserHost().get().DragTargetDrop(mouse_event)
665672

666-
cpdef py_void DragSourceEndedAt(self, int x, int y, long long operation):
673+
cpdef py_void DragSourceEndedAt(self, int x, int y, uint32 operation):
667674
self.GetCefBrowserHost().get().DragSourceEndedAt(
668675
x, y, <cef_types.cef_drag_operations_mask_t>operation)
669676

src/cefpython.pyx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -312,11 +312,11 @@ import weakref
312312
# would be a bad idea.
313313
ctypedef object py_string
314314

315-
# You can't use "void" along with cpdef function returning None, it is planned to be
316-
# added to Cython in the future, creating this virtual type temporarily. If you
317-
# change it later to "void" then don't forget to add "except *".
315+
# You can't use "void" along with cpdef function returning None, it is
316+
# planned to be added to Cython in the future, creating this virtual
317+
# type temporarily. If you change it later to "void" then don't forget
318+
# to add "except *".
318319
ctypedef object py_void
319-
ctypedef long long WindowHandle
320320

321321
# noinspection PyUnresolvedReferences
322322
from cpython cimport PyLong_FromVoidPtr
@@ -363,6 +363,9 @@ from libc.stdint cimport uint64_t
363363
# noinspection PyUnresolvedReferences
364364
from libc.stdint cimport uintptr_t
365365

366+
# noinspection PyUnresolvedReferences
367+
ctypedef uintptr_t WindowHandle
368+
366369
# noinspection PyUnresolvedReferences
367370
cimport ctime
368371

@@ -388,6 +391,7 @@ from cef_types cimport (
388391
CefSettings, CefBrowserSettings, CefRect, CefPoint,
389392
CefKeyEvent, CefMouseEvent, CefScreenInfo,
390393
PathKey, PK_DIR_EXE, PK_DIR_MODULE,
394+
int32, uint32, int64, uint64,
391395
)
392396

393397
from cef_task cimport *
@@ -938,7 +942,8 @@ def Shutdown():
938942
# If the the two code blocks above, that tried to close browsers
939943
# and free CEF references, failed, then display an error about it!
940944
if len(g_pyBrowsers):
941-
Error("Shutdown called, but there are still browser references alive!")
945+
NonCriticalError("Shutdown called, but there are still browser"
946+
" references alive")
942947

943948
Debug("Shutdown()")
944949
with nogil:

src/client_handler/render_handler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,13 @@ bool RenderHandler::StartDragging(CefRefPtr<CefBrowser> browser,
9494
{
9595
REQUIRE_UI_THREAD();
9696
return RenderHandler_StartDragging(browser, drag_data,
97-
static_cast<long>(allowed_ops), x, y);
97+
allowed_ops, x, y);
9898
}
9999

100100

101101
void RenderHandler::UpdateDragCursor(CefRefPtr<CefBrowser> browser,
102102
DragOperation operation)
103103
{
104104
REQUIRE_UI_THREAD();
105-
RenderHandler_UpdateDragCursor(browser, static_cast<long>(operation));
105+
RenderHandler_UpdateDragCursor(browser, operation);
106106
}

src/extern/cef/cef_types.pxd

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,19 @@ include "compile_time_constants.pxi"
77
from libcpp cimport bool as cpp_bool
88
# noinspection PyUnresolvedReferences
99
from libc.stddef cimport wchar_t
10+
# noinspection PyUnresolvedReferences
11+
from libc.stdint cimport int32_t, uint32_t, int64_t, uint64_t
1012
from cef_string cimport cef_string_t
1113
# noinspection PyUnresolvedReferences
1214
from libc.limits cimport UINT_MAX
1315

1416
cdef extern from "include/internal/cef_types.h":
1517

16-
ctypedef unsigned int uint32
17-
ctypedef int int32
18-
ctypedef long long int64
19-
ctypedef unsigned long long uint64
18+
ctypedef int32_t int32
19+
ctypedef uint32_t uint32
20+
ctypedef int64_t int64
21+
ctypedef uint64_t uint64
22+
2023
IF UNAME_SYSNAME == "Windows":
2124
# noinspection PyUnresolvedReferences
2225
ctypedef wchar_t char16

src/frame.pyx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ cdef PyFrame GetPyFrame(CefRefPtr[CefFrame] cefFrame):
2121
Debug("GetPyFrame(): returning None")
2222
return
2323
cdef PyFrame pyFrame
24-
# long long
25-
cdef object frameId = cefFrame.get().GetIdentifier()
24+
cdef object frameId = cefFrame.get().GetIdentifier() # int64
2625
cdef int browserId = cefFrame.get().GetBrowser().get().GetIdentifier()
2726
assert (frameId and browserId), "frameId or browserId empty"
2827
cdef object uniqueFrameId = GetUniqueFrameId(browserId, frameId)

src/handlers/render_handler.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ cdef public void RenderHandler_OnScrollOffsetChanged(
247247
cdef public cpp_bool RenderHandler_StartDragging(
248248
CefRefPtr[CefBrowser] cef_browser,
249249
CefRefPtr[CefDragData] cef_drag_data,
250-
long long allowed_ops,
250+
uint32 allowed_ops,
251251
int x, int y
252252
) except * with gil:
253253
cdef PyBrowser browser
@@ -276,7 +276,7 @@ cdef public cpp_bool RenderHandler_StartDragging(
276276

277277
cdef public void RenderHandler_UpdateDragCursor(
278278
CefRefPtr[CefBrowser] cef_browser,
279-
long long operation,
279+
uint32 operation,
280280
) except * with gil:
281281
cdef PyBrowser browser
282282
try:

src/handlers/request_handler.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ cdef public cpp_bool RequestHandler_OnQuotaRequest(
267267
returnValue = clientCallback(
268268
browser=pyBrowser,
269269
origin_url=pyOriginUrl,
270-
new_size=long(newSize),
270+
new_size=newSize,
271271
callback=CreatePyRequestCallback(cefRequestCallback))
272272
return bool(returnValue)
273273
else:

src/handlers/resource_handler.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ cdef public void ResourceHandler_GetResponseHeaders(
122122
if userCallback:
123123
returnValue = userCallback(pyResponse, responseLengthOut,
124124
redirectUrlOut)
125-
(&cefResponseLength)[0] = <int64>long(responseLengthOut[0])
125+
(&cefResponseLength)[0] = <int64>responseLengthOut[0]
126126
if redirectUrlOut[0]:
127127
PyToCefString(redirectUrlOut[0], cefRedirectUrl)
128128
return

0 commit comments

Comments
 (0)