Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JS dialogs and file dialogs not working on Linux #241

Closed
cztomczak opened this issue Jul 4, 2016 · 1 comment
Closed

JS dialogs and file dialogs not working on Linux #241

cztomczak opened this issue Jul 4, 2016 · 1 comment
Labels
Milestone

Comments

@cztomczak
Copy link
Owner

cztomczak commented Jul 4, 2016

Upstream CEF 51 is now using X11 library for window management. Previously it used GTK. Now with X11 under the hood there are no default implementations for dialogs in libcef on Linux and that includes: print dialog, js dialogs, file dialog. However the cefclient sample application provides implementations for these dialogs using the GTK library. But it needs to be copied with a few minor modifications. Print dialog was already implemented in Issue #238 by copying print_handler_gtk.cc / print_handler_gtk.h files almost entirely.

To implement js/file dialogs copy these two files from upstream cefclient:

  1. https://bitbucket.org/chromiumembedded/cef/src/60b37186508edb13da9dff185f1b9658be674152/tests/cefclient/browser/dialog_handler_gtk.cc?at=master&fileviewer=file-view-default (and rename to .cpp)
  2. https://bitbucket.org/chromiumembedded/cef/src/60b37186508edb13da9dff185f1b9658be674152/tests/cefclient/browser/dialog_handler_gtk.h?at=master&fileviewer=file-view-default

Also copy some code from cefclient's client_handler.h/client_handler.cc and add it somewhere in cefpython's src/client_handler/client_handler.cpp/h files:

#if defined(OS_LINUX)
#include "cefclient/browser/dialog_handler_gtk.h"
#endif

...

#if defined(OS_LINUX)
  // Custom dialog handler for GTK.
  CefRefPtr<ClientDialogHandlerGtk> dialog_handler_;
#endif

...

#if defined(OS_LINUX)
  CefRefPtr<CefDialogHandler> GetDialogHandler() OVERRIDE {
    return dialog_handler_;
  }
  CefRefPtr<CefJSDialogHandler> GetJSDialogHandler() OVERRIDE {
    return dialog_handler_;
  }
#endif

...

#if defined(OS_LINUX)
  // Provide the GTK-based dialog implementation on Linux.
  dialog_handler_ = new ClientDialogHandlerGtk();
#endif

This will require a bit more of modifications than it was required when copying Print dialog. That's because we already expose JSDialogHandler callbacks to python:

https://github.com/cztomczak/cefpython/blob/master/api/JavascriptDialogHandler.md

So the code needs to be modified to take into account that if there is a JavascriptDialogHandler callback provided in Python then use it, otherwise use the default implementation copied from cefclient. This might require modifying the javascript_dialog_handler.pyx file.

@cztomczak cztomczak added the bug label Jul 4, 2016
@cztomczak cztomczak added this to the v56 milestone Mar 17, 2017
cztomczak added a commit that referenced this issue Mar 20, 2017
…...

In wxpython.py and gtk2.py examples the js alert dialog when run
from a popup gives focus to the main window. The popup window is
created internally by CEF and this probably needs to be changed
so that popups are created by wx in OnBeforePopup and this will
resolve issue with alert focus. In qt4.py and tkinter.py and
hello_world.py examples focus works fine in the popup window.

Add --hello-world flag to build.py and run_examples.py tools.
@cztomczak
Copy link
Owner Author

Default js and file dialogs implementation added in commit c5951b6. If you return True in OnJavascriptDialog / OnBeforeUnloadJavascriptDialog callbacks then the default implementation will not be run.

In wxpython.py and gtk2.py examples the js alert dialog when run from a popup gives focus to the main window. The popup window is created internally by CEF and this probably needs to be changed so that popups are created by wx in OnBeforePopup and this will resolve issue with alert focus. In qt4.py and tkinter_.py and hello_world.py examples focus works fine in the popup window.

Turned out this wasn't a simple task of copy/paste from upstream client, there were several issues that needed fixes. Done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant