GTKMM and XCB display opening issue

Hey guys, Im learning GTK and X11 programming.

Im coding in C++, using GTKMM 4.0 and XCB.

I manage to create a window using XCB and another one using GTKMM. The problem is: I cant spawn both at the same time.

When I open the X11 display with “xcb_connect” I can’t spawn the GTK window after using “gtk_display_get_default”.

But if I comment the “xcb_connect” I can spawn the GTK window. The same happens commenting “gtk_display_get_default”… I then can spawn the XCB window.

But again, if I use both display-opening functions, one of the windows will not appear… I’ve been searching the docs for answers but no luck so far. Am I doing something wrong?

Thanks in advance and apologies for any grammatical mistakes.

Heres the code, so that my topic remains short.

Hello, that is a good question. Fortunately it seems this is not a GTK or XCB problem. The join function in C++ will block the calling thread until the target thread returns. Try spawning both threads first, and then joining them:

  std::thread threadTest(gtkThread, argc, argv);
  std::thread threadTest2(xThread, argc, argv);

Thank you for your reply and suggestion.

I did as you said and still the two windows don’t appear at the same time.

But now I’m getting the following message in the TTY, after starting the X server:

Gdk-Message: 17:23:25.268: Failed to get file transfer portal: The connection is closed

Google is not helping at all… Do you have any idea what is happening?

Also, heres the link for the project’s GitHub, if anyone wants to analise it further.

Thanks again for your help.

Sorry, not able to reproduce. I tried the code in GNOME shell, and saw both windows, and I did not get that error message.

Thanks again for the reply.

I also was able to run the code when running the program from the terminal; the two windows spawn normally.

The problem arrives then starting the program from a TTY, like a standalone window manager. I do “startx”, with with “exec test” in my .xinitrc and then just one of the windows appear.

I read more parts of your code, you are masking events on the root window and not doing anything with them:

  values[0] =
  xcb_change_window_attributes_checked(dpy, scre->root, XCB_CW_EVENT_MASK,

You must either remove those lines, or finish implementing the window manager. And since you are not checking the error, this will silently fail if another window manager is already running.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.