Skip to content

Commit 90452e3

Browse files
committed
Support window title in hello_world.py example on Mac (cztomczak#339)
1 parent 8315fb0 commit 90452e3

File tree

5 files changed

+16
-7
lines changed

5 files changed

+16
-7
lines changed

src/cefpython.pyx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,8 @@ def CreateBrowserSync(windowInfo=None,
813813
cef_window.get().RequestFocus()
814814
windowInfo = WindowInfo()
815815
windowInfo.SetAsChild(cef_window.get().GetWindowHandle())
816-
Debug("CefWindow handle = "+str(cef_window.get().GetWindowHandle()))
816+
Debug("CefWindow handle = "
817+
+str(<uintptr_t>cef_window.get().GetWindowHandle()))
817818
"""
818819

819820
# Only title was set in hello_world.py example
@@ -881,7 +882,7 @@ def CreateBrowserSync(windowInfo=None,
881882
Debug("CefBrowser::CreateBrowserSync() succeeded")
882883

883884
Debug("CefBrowser window handle = "
884-
+str(cefBrowser.get().GetHost().get().GetWindowHandle()))
885+
+str(<uintptr_t>cefBrowser.get().GetHost().get().GetWindowHandle()))
885886

886887
# Request context - part 2/2.
887888
if g_applicationSettings["unique_request_context_per_browser"]:
@@ -910,7 +911,8 @@ def CreateBrowserSync(windowInfo=None,
910911
x11.SetX11WindowTitle(cefBrowser,
911912
PyStringToChar(windowInfo.windowName))
912913
ELIF UNAME_SYSNAME == "Darwin":
913-
pass
914+
MacSetWindowTitle(cefBrowser,
915+
PyStringToChar(windowInfo.windowName))
914916

915917
return pyBrowser
916918

src/client_handler/util_mac.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
#include <string>
99
#include "include/cef_base.h"
1010
#include "include/cef_app.h"
11+
#include "include/cef_browser.h"
1112

1213
void MacInitialize();
14+
void MacSetWindowTitle(CefRefPtr<CefBrowser> browser, char* title);
1315

1416
#endif // CEFPYTHON_UTIL_MAC_H_

src/client_handler/util_mac.mm

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ void MacInitialize() {
6666
[NSApplication sharedApplication];
6767
}
6868

69-
void MacSetTitle(CefRefPtr<CefBrowser> browser, char* title) {
69+
void MacSetWindowTitle(CefRefPtr<CefBrowser> browser, char* title) {
7070
NSView* view = browser->GetHost()->GetWindowHandle();
71-
view.window!.title = title;
71+
NSString* nstitle = [NSString stringWithFormat:@"%s" , title];
72+
view.window.title = nstitle;
7273
}

src/compile_time_constants.pxi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# This file was generated by setup.py
2-
DEF UNAME_SYSNAME = "Linux"
2+
DEF UNAME_SYSNAME = "Darwin"
33
DEF PY_MAJOR_VERSION = 2

src/extern/mac.pxd

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,9 @@
22
# All rights reserved. Licensed under BSD 3-clause license.
33
# Project website: https://github.com/cztomczak/cefpython
44

5+
from cef_ptr cimport CefRefPtr
6+
from cef_browser cimport CefBrowser
7+
58
cdef extern from "client_handler/util_mac.h":
6-
cdef void MacInitialize()
9+
void MacInitialize()
10+
void MacSetWindowTitle(CefRefPtr[CefBrowser] browser, char* title)

0 commit comments

Comments
 (0)