diff --git a/src/cef_v59..v66_changes.txt b/src/cef_v59..v66_changes.txt index 36ce50d5..600f194d 100644 --- a/src/cef_v59..v66_changes.txt +++ b/src/cef_v59..v66_changes.txt @@ -64,7 +64,7 @@ MISC ---- + Compare src/client_handler/dialog_handler_gtk.cpp (and .h) with upstream cefclient files -- In subprocess/print_handler_gtk.cpp use GetWindow implementation ++ In subprocess/print_handler_gtk.cpp use GetWindow implementation from x11.cpp NEW FEATURES diff --git a/src/client_handler/x11.cpp b/src/client_handler/x11.cpp index 9ebfe2c8..2e97a6e9 100644 --- a/src/client_handler/x11.cpp +++ b/src/client_handler/x11.cpp @@ -2,6 +2,9 @@ // All rights reserved. Licensed under BSD 3-clause license. // Project website: https://github.com/cztomczak/cefpython +// NOTE: This file is also used by "subprocess" and "libcefpythonapp" +// targets during build. + #include "x11.h" #include "include/base/cef_logging.h" @@ -24,6 +27,7 @@ void InstallX11ErrorHandlers() { // Copied from upstream cefclient. // Install xlib error handlers so that the application won't be terminated // on non-fatal errors. Must be done after initializing GTK. + LOG(INFO) << "[Browser process] Install X11 error handlers"; XSetErrorHandler(XErrorHandlerImpl); XSetIOErrorHandler(XIOErrorHandlerImpl); } @@ -48,6 +52,7 @@ void SetX11WindowTitle(CefRefPtr browser, char* title) { } GtkWindow* CefBrowser_GetGtkWindow(CefRefPtr browser) { + // TODO: Should return NULL when using the Views framework // -- REWRITTEN FOR CEF PYTHON USE CASE -- // X11 window handle ::Window xwindow = browser->GetHost()->GetWindowHandle(); @@ -68,6 +73,10 @@ GtkWindow* CefBrowser_GetGtkWindow(CefRefPtr browser) { // internally, so GTK wasn't yet initialized and must do it // now, so that display is available. Also must install X11 // error handlers to avoid 'BadWindow' errors. + // -- + // A similar code is in cefpython_app.cpp and it might already + // been executed. If making changes here, make changes there + // as well. LOG(INFO) << "[Browser process] Initialize GTK"; gtk_init(0, NULL); InstallX11ErrorHandlers(); diff --git a/src/subprocess/Makefile b/src/subprocess/Makefile index b6f003be..f52b72df 100644 --- a/src/subprocess/Makefile +++ b/src/subprocess/Makefile @@ -35,8 +35,8 @@ else ifeq ($(UNAME_S), Darwin) endif ifeq ($(UNAME_S), Linux) - CPP_FILES = print_handler_gtk.cpp - LIBS = -lcef -lgobject-2.0 -lglib-2.0 -lgtk-x11-2.0 + CPP_FILES = print_handler_gtk.cpp ../client_handler/x11.cpp + LIBS = -lcef -lX11 -lgobject-2.0 -lglib-2.0 -lgtk-x11-2.0 -lgdk-x11-2.0 else ifeq ($(UNAME_S), Darwin) CPP_FILES = # Include framework before libcef_dll_wrapper diff --git a/src/subprocess/Makefile-libcefpythonapp b/src/subprocess/Makefile-libcefpythonapp index e811a32f..57f3dcce 100644 --- a/src/subprocess/Makefile-libcefpythonapp +++ b/src/subprocess/Makefile-libcefpythonapp @@ -12,7 +12,7 @@ UNAME_S = $(shell uname -s) CCFLAGS = -fPIC -DBROWSER_PROCESS $(CEF_CCFLAGS) ifeq ($(UNAME_S), Linux) - SRC_MORE = print_handler_gtk.cpp \ + SRC_MORE = print_handler_gtk.cpp ../client_handler/x11.cpp \ main_message_loop/main_message_loop_external_pump_linux.cpp else ifeq ($(UNAME_S), Darwin) SRC_MORE = main_message_loop/main_message_loop_external_pump_mac.mm diff --git a/src/subprocess/cefpython_app.cpp b/src/subprocess/cefpython_app.cpp index 9105da3c..a02a7cd5 100644 --- a/src/subprocess/cefpython_app.cpp +++ b/src/subprocess/cefpython_app.cpp @@ -21,6 +21,7 @@ #include #include #include +#include "client_handler/x11.h" #include "print_handler_gtk.h" #endif // OS_LINUX #endif // BROWSER_PROCESS @@ -221,10 +222,14 @@ CefRefPtr CefPythonApp::GetPrintHandler() { #if defined(OS_LINUX) // For print handler to work GTK must be initialized. This is // required for some of the examples. + // -- + // A similar code is in client_handler/x11.cpp. If making changes here, + // make changes there as well. GdkDisplay* gdk_display = gdk_display_get_default(); if (!gdk_display) { LOG(INFO) << "[Browser process] Initialize GTK"; gtk_init(0, NULL); + InstallX11ErrorHandlers(); } #endif #endif diff --git a/src/subprocess/print_handler_gtk.cpp b/src/subprocess/print_handler_gtk.cpp index 18c8c1c4..3bfc30c5 100644 --- a/src/subprocess/print_handler_gtk.cpp +++ b/src/subprocess/print_handler_gtk.cpp @@ -19,6 +19,8 @@ #include "include/wrapper/cef_helpers.h" #include "include/wrapper/cef_closure_task.h" +#include "client_handler/x11.h" + namespace { // CUPS Duplex attribute and values. @@ -374,7 +376,7 @@ struct ClientPrintHandlerGtk::PrintHandler { CefRefPtr callback) { dialog_callback_ = callback; - GtkWindow* parent = GetWindow(); + GtkWindow* parent = CefBrowser_GetGtkWindow(browser_); // TODO(estade): We need a window title here. dialog_ = gtk_print_unix_dialog_new(NULL, parent); g_signal_connect(dialog_, "delete-event", @@ -429,18 +431,6 @@ struct ClientPrintHandlerGtk::PrintHandler { } private: - // Returns the GtkWindow* for the browser. Will return NULL when using the - // Views framework. - GtkWindow* GetWindow() { - // TODO(cefpython): Test the code that is commented out whether it works - /* - CefWindowHandle hwnd = browser_->GetWindowHandle(); - if (hwnd) - return GTK_WINDOW(hwnd); - */ - return NULL; - } - void OnDialogResponse(GtkDialog* dialog, gint response_id) { int num_matched_handlers = g_signal_handlers_disconnect_by_func( dialog_, reinterpret_cast(&OnDialogResponseThunk), this);