Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Qt Wayland client wait for Wayland Compositor
QtWS25 Last Chance

Qt Wayland client wait for Wayland Compositor

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
wayland
5 Posts 3 Posters 1.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mmader87
    wrote on 10 Oct 2020, 11:45 last edited by aha_1980 10 Dec 2020, 03:12
    #1

    I am creating my own wayland compositor and client program.

    In an ideal world, the compositor will be loaded before the client application. I have encountered a situation where this is not true.

    However, I was wondering if there was a way for the client app to wait programmatically for the compositor before running.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 10 Oct 2020, 18:11 last edited by
      #2

      Hi and welcome to devnet,

      Can you describe the situation when it happens ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Mmader87
        wrote on 2 Nov 2020, 22:57 last edited by
        #3

        Yes, I get the following message when I try to run my wayland client.

        Failed to create wl_display (No such file or directory)
        qt.qpa.plugin: Could not load the Qt platform plugin "wayland" in "" even though it was found.
        This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
        Available platform plugins are: wayland-egl, wayland.

        I know this is a pretty standard message. In my situation I know it is because the wayland compositor hasn't fully initialized yet. If I manually wait a second or two to launch the wayland client everything works fine. However, adding in wasted time is undesired as boot time is critical.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 3 Nov 2020, 20:32 last edited by
          #4

          How are you starting the compositor ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • E Offline
            E Offline
            ehopperdietzel
            wrote on 1 Jul 2022, 18:41 last edited by
            #5

            You could use the wayland-client library like this before your instantiate your QApplication:

            #include <QApplication>
            #include <wayland-client.h>
            #include <unistd.h>
            
            int main(int argc, char *argv[])
            {
                struct wl_display *display = NULL;
            
                while(!display)
                {
                    // Return NULL if no compositor avaliable in wayland-0
                    display = wl_display_connect(NULL);
                    
                    // Wait 200 ms so you dont overuse your CPU
                    usleep(200000);
                }
                
                // Disconnect because QApplication will stablish its own connection
                wl_display_disconnect(display);
            
                // Start the app
                QApplication app(argc,argv);
                
                ...
                
            }
            

            Its a bit ugly but it should work.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved