I made multithreaded message loop work. I started my coding using an example that used CreateBrowserSync instead of CreateBrowser (btw I couldn't figure out the difference between then). I've just changed to the latter, removed the g_idle_add hook that called CefDoMessageLoopWork, and it's working as a breeze now.
I'm using 3.2171.1949 on windows32, with windowed rendering.
The code I've used to hook a GtkDrawingArea to cef was this, if anyone else is crazy enough to run a gtk app on windows:
- Code: Select all
static void setAsChild(GtkWidget *widget, CefWindowInfo &info) {
gtk_widget_realize(widget);
GdkWindow *gdk_window = gtk_widget_get_window(GTK_WIDGET(widget));
if (!gdk_window_ensure_native(gdk_window)) {
g_error("gdk_window_ensure_native failed...");
}
HWND hWnd = gdk_win32_window_get_impl_hwnd(gdk_window);
RECT rect;
printf("rect: %ld %ld %ld %ld\n", rect.bottom, rect.left, rect.right, rect.top);
GetClientRect(hWnd, &rect);
info.SetAsChild(hWnd, rect);
}
This is the callback to inform cef's window that the widget was resized:
- Code: Select all
extern "C" {
void __declspec(dllexport) on_area_size_allocate(GtkWidget *widget,
GdkRectangle *allocation,
gpointer user_data) {
CefRefPtr<CefBrowser> browser = NULL;
if (g_handler) {
browser = g_handler->GetBrowser();
}
if (browser) {
HWND hWnd = browser->GetHost()->GetWindowHandle();
HDWP hdwp = BeginDeferWindowPos(1);
hdwp = DeferWindowPos(hdwp, hWnd, NULL, 0, 0,
allocation->width, allocation->height, SWP_NOZORDER);
EndDeferWindowPos(hdwp);
} else {
// At least the first time gtk generates this event, there's no native window realized.
// It'll call it again with a realized window and we catch that then.
//printf("Had no window to hook to.\n");
}
}
}