1

I would like to arrange focus of two applications in a wayland-weston desktop system. Two applications are:

  1. Written in Qt/QML, fullscreen
  2. Written with Wayland Client API + OpenGL, fullscreen

I would like to keep App#1 always on top and App#2 always on bottom, even if I kill and respawn either of them. I also would like to do this while both of them are fullscreen apps.

I have investigated and found few ways to achieve this:

  1. Using wmctrl to arrange windows in a desktop system: I've tried this. However, I get Cannot open display.. I found out later that wmctrl does not work with Weston/XWayland, works only with X11. So, I don't think this is an option any longer.

  2. Make the App#1 (Qt/QML) always on top by default: What I've tried in order to solve this is I've added the following in my main.qml:

    ApplicationWindow {
        visible: true
        visibility: "FullScreen"
        width: 1920
        height: 720
        flags: Qt.WindowStaysOnTopHint|Qt.FramelessWindowHint
    
        MainScreen{
            anchors.fill: parent
        }
    }
    
  3. Make the App#2 (Wayland Client API/OpenGL) always on bottom by default. To be honest, I am not familiar with Wayland Client API that much, but I could explore it with some guidance, if something like this is even possible.

Right now, My focus is making Qt application always on top. It works in my PC, but it does not work in target platform. My PC is Ubuntu 16.04, with Xorg. Target platform has weston compositor with xwayland backend. I don't know why it does not work in the target. It maybe the desktop system. Any guidance and ideas are appreciated. Thanks

EDIT: main.cpp

    QGuiApplication app(argc, argv);
    QQmlApplicationEngine engine;
    engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
    if (engine.rootObjects().isEmpty())
        return -1;
    return app.exec();

EDIT main.qml

import QtQuick 2.0
import QtQuick.Controls 2.0
import QtQuick.Window 2.2
import "app/main"

ApplicationWindow {
    visible: true
    visibility: "FullScreen"
    maximumWidth: 1920
    maximumHeight: 720
    minimumWidth: 1920
    minimumHeight: 720
    width: 1920
    height: 720
    title: qsTr("App")
    flags: Qt.FramelessWindowHint|Qt.WindowStaysOnTopHint

    MainScreen{
        anchors.fill: parent
    }

}

EDIT: Qt Version Qt 5.10.1 on PC, Qt 5.8.0 on target platform

mozcelikors
  • 2,582
  • 8
  • 43
  • 77

2 Answers2

1

I have opened an issue on Qt Bugs and learned from a Qt employee that this is not possible due to the restrictions from Weston compositor. So, either I will create my own compositor or use a different one.

mozcelikors
  • 2,582
  • 8
  • 43
  • 77
  • oh that's bad. And would it be the same on newer versions of Qt? – madduci Feb 12 '19 at 06:59
  • 1
    I think so, I applied a workaround (animating a mouse click) and solved it. But still its not so good to have that. – mozcelikors Feb 12 '19 at 08:21
  • 1
    It may not be supported by the core wayland protocols, but there is an extension protocols, layer-shell, that does support it. The wlroots project has defined this protocol and some compositors implement it, though it is not yet considered stable. Eventually Qt will likely use this or another similar protocol, though a number of compositors may not implement them until there exists a permissions system to allow some apps to use them and some not to. So it's not a fundamental limitation of wayland and I think things will get better. – Chris Billington Feb 26 '19 at 00:06
0

You should set the flags in your main C++ file

EDIT

This is for Qt/C++ apps:

setWindowFlags(Qt::Window | Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
showFullScreen();

You can follow the guide here:

Windows Flags

For QML, you can use, in the .qml file:

import QtQuick.Window 2.2 // Window.FullScreen
import QtQuick.Controls 1.3 // ApplicationWindow

ApplicationWindow
{
   id: window
   onActiveChanged: {
       window.visibility = activeFocusItem ? Window.FullScreen :  Window.Minimized;
   }
}    
madduci
  • 2,635
  • 1
  • 32
  • 51
  • Unfortunately, it did not change anything. I'm adding my qml file for reference. – mozcelikors Feb 01 '19 at 07:45
  • 1
    That's an interesting hack. @mozcelikors, you're on Qt 5.10, at that point the xdg-shell v6 implementation didn't have fullscreen support which is probably why it doesn't work for you. You could try upgrading or using `xdg-shell-v5` or `wl-shell` by setting `QT_WAYLAND_SHELL_INTEGRATION` in the environment. – bobbaluba Feb 11 '19 at 15:06