[SOLVED] X error in 2623 when trying to set Qt win as parent

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Re: X error in 2623 when trying to set Qt window as parent (

Postby Czarek » Wed Mar 09, 2016 8:14 am

What if you pass an invalid window handle?

From your first post:
Code: Select all
Window XCreateWindow(
    Display*      /* display */,
    Window      /* parent */,
    int         /* x */,                      // 0
    int         /* y */,                      // 0
    unsigned int   /* width */,               // 800
    unsigned int   /* height */,              // 600

What are the values for Window and Display*?

A bit late, but now we can see the crucial part of your code - how you create the window. I've looked at your C++ Qt example. You are embedding an external process non-qt control (CEF) directly inside the Qt Widget control. Did you ensure with the Qt documentation that you are allowed to do that? From what I know the QX11EmbedContainer control is designed for this.
Maintainer of the CEF Python, PHP Desktop and CEF C API projects. My LinkedIn.
User avatar
Czarek
Virtuoso
 
Posts: 1927
Joined: Sun Nov 06, 2011 2:12 am

Re: X error in 2623 when trying to set Qt window as parent (

Postby Czarek » Wed Mar 09, 2016 8:17 am

Also it looks like you are providing GtkWidget window handle, but CEF expects X11 window handle.
Maintainer of the CEF Python, PHP Desktop and CEF C API projects. My LinkedIn.
User avatar
Czarek
Virtuoso
 
Posts: 1927
Joined: Sun Nov 06, 2011 2:12 am

Re: X error in 2623 when trying to set Qt window as parent (

Postby Czarek » Wed Mar 09, 2016 8:22 am

One more thing. Sometimes bad code happens to work, same as bugs happen ;) In regards to -> "it worked in earlier CEF, but now it stopped working - so it must be a CEF bug".
Maintainer of the CEF Python, PHP Desktop and CEF C API projects. My LinkedIn.
User avatar
Czarek
Virtuoso
 
Posts: 1927
Joined: Sun Nov 06, 2011 2:12 am

Re: X error in 2623 when trying to set Qt window as parent (

Postby romariorios » Wed Mar 09, 2016 8:54 am

Czarek wrote:What if you pass an invalid window handle?

Nothing happens. The window simply doesn't appear.

Czarek wrote:From your first post:
Code: Select all
Window XCreateWindow(
    Display*      /* display */,
    Window      /* parent */,
    int         /* x */,                      // 0
    int         /* y */,                      // 0
    unsigned int   /* width */,               // 800
    unsigned int   /* height */,              // 600

What are the values for Window and Display*?

I'd have to debug to it to know for sure. I'll try to verify that later.

Czarek wrote:A bit late, but now we can see the crucial part of your code - how you create the window. I've looked at your C++ Qt example. You are embedding an external process non-qt control (CEF) directly inside the Qt Widget control. Did you ensure with the Qt documentation that you are allowed to do that? From what I know the QX11EmbedContainer control is designed for this.

I might be wrong, but isn't this what cefclient does, basically? It just sets the Gtk Window as the parent with SetAsChild and doesn't do anything from the Gtk side.

In any case, QWidget::createWindowContainer can create a QWidget from an external window, but I think that's not a requirement for embedding windows inside Qt applications. (EDIT: I'll try to use it anyway, just in case)

Czarek wrote:Also it looks like you are providing GtkWidget window handle, but CEF expects X11 window handle.

No, I'm providing an X11 window handle. See: https://doc.qt.io/qt-5/qwidget.html#winId

Czarek wrote:One more thing. Sometimes bad code happens to work, same as bugs happen ;) In regards to -> "it worked in earlier CEF, but now it stopped working - so it must be a CEF bug".

But I only assumed it was a CEF bug after testing the standard 2526 and 2623 builds (as mentioned in my previous post). Before that, I assumed it was some mistake emerging from the customizations I did to CEF and cefsimple.
romariorios
Mentor
 
Posts: 50
Joined: Thu Apr 30, 2015 6:13 am
Location: Brazil

Re: X error in 2623 when trying to set Qt window as parent (

Postby Czarek » Wed Mar 09, 2016 10:42 am

Czarek wrote:Also it looks like you are providing GtkWidget window handle, but CEF expects X11 window handle.

No, I'm providing an X11 window handle. See: https://doc.qt.io/qt-5/qwidget.html#winId

I have twisted that sentence around. It should be - winId() returns X11 window handle, but CEF expects GtkWidget pointer. This was true as of CEF branch 1650. But I recall there were some changes in later CEF versions to allow embedding using x11 handle as well.

Just use QX11EmbedContainer and it should work.
Maintainer of the CEF Python, PHP Desktop and CEF C API projects. My LinkedIn.
User avatar
Czarek
Virtuoso
 
Posts: 1927
Joined: Sun Nov 06, 2011 2:12 am

Re: X error in 2623 when trying to set Qt window as parent (

Postby romariorios » Wed Mar 09, 2016 1:14 pm

Czarek wrote:I have twisted that sentence around. It should be - winId() returns X11 window handle, but CEF expects GtkWidget pointer.

I'm pretty sure this isn't the case anymore. For example, cefclient/browser/browser_window_std_gtk.cc, line 98:

Code: Select all
  CefWindowInfo window_info;
  window_info.SetAsChild(GetXWindowForWidget(parent_handle), rect);

The GetXWindowForWidget() function returns an X11 Window, as you can see from line 23:

Code: Select all
::Window GetXWindowForWidget(GtkWidget* widget) {


Czarek wrote:Just use QX11EmbedContainer and it should work.

That's a Qt4 class. Qt5's equivalent would probably be QWidget::createWindowContainer() and QWindow::fromWinId(), but I need to get cefsimple's winId first. Any idea on how to do that? (EDIT: actually, nevermind that, I think I got it).
romariorios
Mentor
 
Posts: 50
Joined: Thu Apr 30, 2015 6:13 am
Location: Brazil

Re: X error in 2623 when trying to set Qt window as parent (

Postby Czarek » Wed Mar 09, 2016 2:55 pm

Maintainer of the CEF Python, PHP Desktop and CEF C API projects. My LinkedIn.
User avatar
Czarek
Virtuoso
 
Posts: 1927
Joined: Sun Nov 06, 2011 2:12 am

Re: X error in 2623 when trying to set Qt window as parent (

Postby romariorios » Thu Mar 10, 2016 12:50 pm


Thanks. Based on that, here's what I tried:

Code: Select all
#include <QApplication>

#include <QDebug>

#include <QWidget>
#include <QWindow>

int main(int argc, char *argv[])
{
  QApplication a(argc, argv);

  QWidget w;
  auto wId = w.winId();
  auto subW = QWindow::fromWinId(wId);
  auto container = QWidget::createWindowContainer(subW);

  w.show();

  qDebug() << "WinID:" << container->winId();

  return a.exec();
}

Then I call SetAsChild with that winId from the cefsimple side. It still doesn't work.

By comparison, I made a similar Qt 4 application using QX11EmbedContainer:

Code: Select all
#include <QApplication>

#include <QDebug>

#include <QX11EmbedContainer>

int main(int argc, char *argv[])
{
  QApplication a(argc, argv);

  QX11EmbedContainer container;
  container.resize(800, 600);
  container.show();

  qDebug() << "WinID:" << container.winId();

  return a.exec();
}

Works just fine. But I can't use Qt 4, unfortunately.

Any ideas on how to do that properly with Qt 5?
romariorios
Mentor
 
Posts: 50
Joined: Thu Apr 30, 2015 6:13 am
Location: Brazil

Re: X error in 2623 when trying to set Qt window as parent (

Postby Czarek » Thu Mar 10, 2016 1:18 pm

Are you using the latest Qt 5.5 stable? Print "wId" for debug info. Call subW.show() and container.show() as well - currently only w.show() is called.
Maintainer of the CEF Python, PHP Desktop and CEF C API projects. My LinkedIn.
User avatar
Czarek
Virtuoso
 
Posts: 1927
Joined: Sun Nov 06, 2011 2:12 am

Re: X error in 2623 when trying to set Qt window as parent (

Postby romariorios » Thu Mar 10, 2016 3:03 pm

Czarek wrote:Are you using the latest Qt 5.5 stable?
Yup

Czarek wrote:Print "wId" for debug info. Call subW.show() and container.show() as well - currently only w.show() is called.

Okay, here's the modified version:

Code: Select all
#include <QApplication>

#include <QDebug>

#include <QWidget>
#include <QWindow>

int main(int argc, char *argv[])
{
  QApplication a(argc, argv);

  QWidget w;
  auto wId = w.winId();
  auto subW = QWindow::fromWinId(wId);
  auto container = QWidget::createWindowContainer(subW);

  w.show();
  subW->show();
  container->show();

  qDebug() << "Widget WId:" << wId;
  qDebug() << "Sub-win WId:" << subW->winId();
  qDebug() << "Container WId:" << container->winId();

  return a.exec();
}

It prints out:
Code: Select all
Widget WId: 96468996
Sub-win WId: 96468996
Container WId: 96469003

I passed both IDs to SetAsChild with no success, no window is shown -- still works with 2526.
romariorios
Mentor
 
Posts: 50
Joined: Thu Apr 30, 2015 6:13 am
Location: Brazil

PreviousNext

Return to Support Forum

Who is online

Users browsing this forum: No registered users and 95 guests