WindowTransparentForInput not worked on wayland
-
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();
}
-
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();
}
@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.
-
@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.
@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.
-
@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.
@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:
- The wayland protocol does not allow / support it
- The specific windowing manager you are using does not support / implement it
- 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. -
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
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!