Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. WindowTransparentForInput not worked on wayland
Forum Updated to NodeBB v4.3 + New Features

WindowTransparentForInput not worked on wayland

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 1.0k Views 1 Watching
  • 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.
  • H Offline
    H Offline
    hoytluo
    wrote on last edited by
    #1

    I have the following code to make a transparent window. It works well on X11 but on wayland ,it dosen't . I can't caputure or clik the lower window. is this a qt bug or wanland bug?

    #include <QApplication>
    #include <QWidget>
    #include <QLabel>

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

        w.setAttribute(Qt::WA_WState_WindowOpacitySet, true);
        w.setAttribute(Qt::WA_TranslucentBackground, true);
        w.setAttribute(Qt::WA_TransparentForMouseEvents, true); // this is good on x11 but bad on wayland
    
        w.setWindowFlags(Qt::WindowTransparentForInput
        | Qt::FramelessWindowHint
        | Qt::WindowStaysOnTopHint
        ); // the WindowTransparentForInput is bad on wayland
    
        w.resize(800, 600);
        QLabel l(&w);;
        l.setText("hello world this is a very long text. \n#####################################\n*********************************\n");
        l.show();
    
        w.show();
        return a.exec();
    

    }

    A 1 Reply Last reply
    0
    • H hoytluo

      I have the following code to make a transparent window. It works well on X11 but on wayland ,it dosen't . I can't caputure or clik the lower window. is this a qt bug or wanland bug?

      #include <QApplication>
      #include <QWidget>
      #include <QLabel>

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

          w.setAttribute(Qt::WA_WState_WindowOpacitySet, true);
          w.setAttribute(Qt::WA_TranslucentBackground, true);
          w.setAttribute(Qt::WA_TransparentForMouseEvents, true); // this is good on x11 but bad on wayland
      
          w.setWindowFlags(Qt::WindowTransparentForInput
          | Qt::FramelessWindowHint
          | Qt::WindowStaysOnTopHint
          ); // the WindowTransparentForInput is bad on wayland
      
          w.resize(800, 600);
          QLabel l(&w);;
          l.setText("hello world this is a very long text. \n#####################################\n*********************************\n");
          l.show();
      
          w.show();
          return a.exec();
      

      }

      A Offline
      A Offline
      Asperamanca
      wrote on last edited by
      #2

      @hoytluo
      I can't comment on input transparency specifically, but....
      It looks like to use it on a top-level widget. So what is the other window you'd like to receive the inputs?

      The problem here is that your widget may reject the inputs, but then it's Wayland's job to decide who gets them. And Wayland has very different philosophies than X11. For example, you could argue that you should not direct input to a window the user is not seeing as the topmost window, for security reasons.

      Test if the flag works well when you use it on a child widget. If that is the case, Qt is probably not to blame.

      H 1 Reply Last reply
      0
      • A Asperamanca

        @hoytluo
        I can't comment on input transparency specifically, but....
        It looks like to use it on a top-level widget. So what is the other window you'd like to receive the inputs?

        The problem here is that your widget may reject the inputs, but then it's Wayland's job to decide who gets them. And Wayland has very different philosophies than X11. For example, you could argue that you should not direct input to a window the user is not seeing as the topmost window, for security reasons.

        Test if the flag works well when you use it on a child widget. If that is the case, Qt is probably not to blame.

        H Offline
        H Offline
        hoytluo
        wrote on last edited by
        #3

        @Asperamanca
        Thanks for your reply.
        The other window is that under the toplevel window.
        for example in my image , the 'trans-widget' window is upper on the terminal window(title 'infogo@infogo.....),so when I click or select the red region, the response window should be the terminal window. on x11 this is right(I think maybe the x-sever send the click event to the terminal),but on wayland the terminal dosen't receive the event(I think myaby the wayland send the event to the trans-widget). so from my opinion , I think the WindowTransparentForInput flag has not been sended to the wayland server(but the WindowStaysOnTopHint flag is function good) or the flag is not recognized by the wayland server?

        ' it's Wayland's job to decide who gets them' This is the point of my question.

        8786de88-98d1-424d-9b7e-666e482a659d-image.png

        A 1 Reply Last reply
        0
        • H hoytluo

          @Asperamanca
          Thanks for your reply.
          The other window is that under the toplevel window.
          for example in my image , the 'trans-widget' window is upper on the terminal window(title 'infogo@infogo.....),so when I click or select the red region, the response window should be the terminal window. on x11 this is right(I think maybe the x-sever send the click event to the terminal),but on wayland the terminal dosen't receive the event(I think myaby the wayland send the event to the trans-widget). so from my opinion , I think the WindowTransparentForInput flag has not been sended to the wayland server(but the WindowStaysOnTopHint flag is function good) or the flag is not recognized by the wayland server?

          ' it's Wayland's job to decide who gets them' This is the point of my question.

          8786de88-98d1-424d-9b7e-666e482a659d-image.png

          A Offline
          A Offline
          Asperamanca
          wrote on last edited by
          #4

          @hoytluo That sounds like the windows involved are from different processes. Then any events will have to go via the windowing manager. That means, Qt can ask the windowing manager nicely to do something, and the windowing manager can do it, not do it, or do something else entirely.

          Without knowing any details on that topic, I can see three broad reasons why it doesn't work:

          1. The wayland protocol does not allow / support it
          2. The specific windowing manager you are using does not support / implement it
          3. Qt does not ask the "right" way.

          Have you seen other applications on the same system provide a similar functionality than what you want to achieve? If yes, this may be a bug in Qt, which you could report on bugreports.qt.io
          In that case, I would at least try to get some kind of documentation that shows the protocol allows it.

          1 Reply Last reply
          0
          • H Offline
            H Offline
            hoytluo
            wrote on last edited by
            #5

            I can't find other app to get the similar info. and i test this code on ubuntu 22.04 and uos-20, both of them don't work functional.
            I explore the qtwayland source code(https://code.qt.io/cgit/qt/qtwayland.git), the window set flag by calling mShellSuface->setWindowFlags
            13b2d44f-83dd-4c1c-a8d0-dc87abbb37f4-image.png
            and then call set_window_flags on the shell extension.
            And I find the function set_window_flags on surface-extension.xml , but the function only support three value

                  <enum name="windowflag">
                        <entry name="OverridesSystemGestures" value="1"/>
                        <entry name="StaysOnTop" value="2"/>
                        <entry name="BypassWindowManager" value="4"/>
                    </enum>
            
                    <request name="set_window_flags">
                        <arg name="flags" type="int"/>
                    </request>
            
            

            so, it's qtwayland that dosen't support the WindowTransparentForInput ? am I on the right way? thanks!

            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