-
-
Notifications
You must be signed in to change notification settings - Fork 49
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
GTK+ 3.22 Port #9
Comments
Do these x11 errors also appear when using GTK 2? |
No, only with GTK+ 3.
The window handle is valid. The window is realized in examples/gtk.h:58. Also, the very first error is BadMatch (8), not BadWindow (3). |
You can set parent window to NULL and CEF will create a window of its own such case. Set here NULL instead of window_info.parent_window = NULL; Does it work then? |
Take a look at hello world examples for GTK 3. Things might work a bit differently there. See for example here: https://developer.gnome.org/gtk3/stable/gtk-getting-started.html |
The result is the same with the GTK+ 3 Hello World exmaple. Both the original and the new example
So, for whatever reason, CEF seems not to like a valid window id. Cefpython uses C++ API and its |
What OS and gtk3 version are you using? |
Debian 9 Stretch, GTK+ 3.22.11. |
Can you try with GTK 3.10? |
Sure, I need to download Ubuntu 14.04 first. Anyway, there are some experiments I tried yesterday. Tracebacks from gdb:
Both logs contain
which comes from my modifications of
and that means that the very first child window of the passed parent window has been created without any issues (no X errors emitted). |
Looks to me there is an issue with embedding with newer GTK / XLib. Try these to workaround the issue:
|
It indeed does work with GTK+ 3.10.8-0ubuntu1.6 (Ubuntu 14.04). I'll now go up from 3.10 to find the first GTK+ release that does not work. I hope I will then understand the issue better and will try the suggested workarounds. Thanks for your tips. |
@cztomczak, I've identified the very first failing revision - GNOME/gtk@dae447728d between GTK+ 3.15.1 and 3.15.2. GTK+ changed the selection of default window visuals (need to study more what that means) and I guess that CEF uses incompatible visuals somewhere (hence the BadMatch X error). |
GtkWidget* create_gtk_window(char* title, int width, int height) {
printf("create_gtk_window\n");
// Create window.
GtkWidget* window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
...
// GTK+ > 3.15.1 uses an X11 visual optimized for GTK+'s OpenGL stuff
// since revid dae447728d: https://github.com/GNOME/gtk/commit/dae447728d
// However, it breaks CEF: https://github.com/cztomczak/cefcapi/issues/9
// Let's use the default X11 visual instead the GTK's blessed one.
GdkScreen* screen = gdk_screen_get_default();
GList* visuals = gdk_screen_list_visuals(screen);
printf("n visuals: %u\n", g_list_length(visuals));
GdkX11Screen* x11_screen = GDK_X11_SCREEN(screen);
g_assert(x11_screen != NULL);
Visual* default_xvisual = DefaultVisual(GDK_SCREEN_XDISPLAY(x11_screen),
GDK_SCREEN_XNUMBER(x11_screen));
GdkVisual* default_visual = NULL;
int i = 0;
while (visuals != NULL) {
GdkVisual* visual = GDK_X11_VISUAL (visuals->data);
if (default_xvisual->visualid == gdk_x11_visual_get_xvisual(
GDK_X11_VISUAL (visuals->data))->visualid) {
printf("Default visual %d\n", i);
default_visual = visual;
}
i++;
visuals = visuals->next;
}
gtk_widget_set_visual(GTK_WIDGET(window), default_visual);
gtk_widget_show_all(window);
return vbox;
}
|
So, I'm proposing following changes. Should I submit them as 5 separate pull requests or combine them somewhow?
|
Great progress Fenryxo! Updating CEF should be a separate PR. Others changes I would divide into two PRs: update old example + add new example. |
This can be made later. Closing as the main issue has been addressed. |
@fenryxo I am working on an app that uses GTK 3.22 and your fix works good. The x11 default visual resolves issue. I am testing with CEF v70 (3538 branch). However I need transparent windows in my application and I need them to work in windowed mode. When using GTK 2 I can get transparent windows working just fine. However with GTK 3.22 only the default x11 visual seems to work with CEF. When I set a RGBA x11 visual then I get the same issue when using GTK 3 "blessed" visual. In my case with latest CEF v70 and in a C++ app I get a bit different stack trace with issue occuring when showing x11 window:
I still have to debug this further as some symbols are missing. If you have any idea on how to make it work with RGBA visual then it would be greatly appreciated. |
It seems that both our issues occur at a call to https://bitbucket.org/chromiumembedded/cef/issues/2490/x11-findchild-fails-during-a-call-to This line code seems to be the culrpit of all the issues: This is Marshall's comment:
|
In your logs the crash also occurs at
|
Here is the patch to fix diff --git a/libcef/browser/native/window_x11.cc b/libcef/browser/native/window_x11.cc
index 2300b1b..4e99e3c 100644
--- a/libcef/browser/native/window_x11.cc
+++ b/libcef/browser/native/window_x11.cc
@@ -40,9 +40,10 @@ const char kXdndProxy[] = "XdndProxy";
::Window child_window = x11::None;
unsigned int nchildren;
if (XQueryTree(display, window, &root, &parent, &children, &nchildren)) {
- DCHECK_EQ(1U, nchildren);
- child_window = children[0];
- XFree(children);
+ if (children) {
+ child_window = children[0];
+ XFree(children);
+ }
}
return child_window;
} However now I get an error during a call to XGetWindowAttributes in Chromium code: bool NativeViewGLSurfaceGLX::Initialize(GLSurfaceFormat format) {
XWindowAttributes attributes;
if (!XGetWindowAttributes(gfx::GetXDisplay(), parent_window_, &attributes)) {
LOG(ERROR) << "XGetWindowAttributes failed for window " << parent_window_
<< ".";
return false;
} |
Reported issue on the CEF Forum: https://magpcss.org/ceforum/viewtopic.php?f=6&t=16402 |
Hello @cztomczak, I no longer use the original approach - forcing GTK+ to use the default X Visual. Instead, I force CEF to use the visual selected by GTK+ (tiliado/cef@d53adf7 & tiliado/valacef@1184840). If I recall correctly, the reason for that was an issue with transparency - GTK+ 3 client-side decorations didn't work correctly with the default X Visual.
I think that no X window is actually created because of conflicting X visuals, so there is simply no window to find. All subsequent X calls should fail as well because of invalid window id. |
@fenryxo Thanks. With your patch I am able to get it working with default GTK 3 visual. However I still can't get whole window transparency to work. |
I get a transparent GTK 3 window working with such code: GdkScreen *gtk_screen = gtk_window_get_screen( m_window );
GdkVisual *rgba_visual = gdk_screen_get_rgba_visual( gtk_screen );
gtk_widget_set_visual( m_widget_window, rgba_visual );
GtkCssProvider *provider = gtk_css_provider_new();
GError *error = NULL;
gtk_css_provider_load_from_data( provider,
"#main-window { background-color: rgba(0, 0, 0, 0); }",
-1, &error );
g_assert_no_error( error );
gtk_style_context_add_provider_for_screen(
gdk_screen_get_default(),
GTK_STYLE_PROVIDER( provider ),
GTK_STYLE_PROVIDER_PRIORITY_USER );
g_object_unref( provider );
gtk_widget_set_name( m_widget_window, "main-window" ); Then I embed CEF browser inside it and the background becomes white. I then try apply your patch and call override functions to set RGBA visual and I still see white background: GdkScreen* screen = gdk_screen_get_default();
GdkVisual *rgba_visual = gdk_screen_get_rgba_visual( screen );
VisualID xvisualid = gdk_x11_visual_get_xvisual(
GDK_X11_VISUAL(rgba_visual))->visualid;
cef_override_system_visual(xvisualid);
cef_override_rgba_visual(xvisualid); Overriding with GTK 3 visual also doesn't work, the background is still white: GdkVisual* system_visual = gtk_widget_get_visual( m_widget_window );
VisualID xvisualid = gdk_x11_visual_get_xvisual(
GDK_X11_VISUAL(system_visual))->visualid;
cef_override_system_visual(xvisualid);
cef_override_rgba_visual(xvisualid); |
Is the white background painted by GTK or CEF? |
My understanding of the docs for
|
@fenryxo Thanks. Just a follow up. I managed to get transparency working, but without GTK. It required additional code patching in Chromium and CEF. |
Thanks for letting me know. Are the patches in upstream CEF repo? |
It was part of a proprietary system, but I can let you know what needs to be done. In that specific system I couldn't make it work with GTK 3, but it worked in cefclient with GTK 2. There is a PR in CEF that adds transparency support, but only when running app in Views mode ( |
It would be great if we managed to make CEF work with GTK+ 3. I'm afraid I don't have enough experience with CEF to do it on my own.
The text was updated successfully, but these errors were encountered: