6

I have a full screen application based on Qt. Full screen applications should always be on top because otherwise part of the window will be obstructed. I want the frameless full screen window to have child windows (special dialogs, ..). These child windows should be shown on top of the full screen window. Not much sense in showing them below.

A short, self contained example is:

from PySide import QtGui, QtCore

app = QtGui.QApplication([])

window = QtGui.QWidget(f=QtCore.Qt.WindowStaysOnTopHint)

child_window = QtGui.QWidget(window, f=QtCore.Qt.Window)
child_window.resize(400, 300)

layout = QtGui.QVBoxLayout(window)
exit = QtGui.QPushButton('Exit')
exit.clicked.connect(app.exit)
layout.addWidget(exit)
create = QtGui.QPushButton('Create child window')
create.clicked.connect(child_window.show)
layout.addWidget(create)
layout.addStretch()

window.showFullScreen()

app.exec_()

It's written in Python and tested on Python 3.X + PySide 1.2.2 (Qt 4.8) + Ubuntu 14.04 (Unity desktop) or Windows 7. However transformation to C++ Qt (or PyQt) should be straightforward.

The observation is that on Windows everything is as described at the beginning. The Qt.WindowsStaysOnTopHint is not necessary, while on Ubuntu it is.

On Ubuntu I see that initially the full screen main window is on top of everything but as soon as a child dialog window is created the usual desktop decorations (top and left bars) are shown above the full screen main window obstructing part of the view! As soon as the child window is closed the full screen window is on top again.

Question is now if there is anything that can be done to have a full screen window which is on top plus child windows on Ubuntu and with Qt?

The different behavior between Windows and Linux is also not satisfying because OS specific code should be avoided if possible.


Later:

Using the overview of available desktop environment on Ubuntu I installed several environments and tested them.

KDE, Lubuntu (Lxde?) and Openbox work as expected (and equally to Windows). The main window stays on top when shown full screen and child windows are displayed above.

However for Gnome-Shell (Gnome 3), Xfce, Unity and Awesome the desktop decoration stays on top of full screen mode windows of children windows are displayed also. Xfce and Unity behave exactly equal, Gnome and Awesome have even some small additional problems.

Community
  • 1
  • 1
NoDataDumpNoContribution
  • 10,591
  • 9
  • 64
  • 104
  • How does it behave on other Linux distros with an un-mucked-about-with Qt (e.g Debian)? Ubuntu has, at least in the past, hacked some Qt things to try and bring it in line with their particular vision (ie the global menubar). Googling some combo of "ubuntu qt bug menubar fullscreen" will turn up numerous issues; I've no idea what the Ubuntu situation is currently, but I've done fullscreen apps on Debian, with dialogs, and they work fine. NB Ubuntu != Linux ! – timday Jun 28 '14 at 21:20
  • In KDE (Kubuntu) it works as expected. – doru Jun 29 '14 at 07:47
  • @doru Good to know. So I probably need to limit the scope from Linux to Ubuntu. – NoDataDumpNoContribution Jun 29 '14 at 09:09
  • I tried different desktop environments yesterday: gnome-shell and awesome and the results were even worse. Upated question and will test more tonight. – NoDataDumpNoContribution Jul 01 '14 at 07:45
  • @timday Sorry I don't want to go that far now and try other distros. I tested different desktop environments on my Ubuntu and saw some that work and others that do not (see updated question). I might try more later but for now my hope for a workaround is low. So I guess I will award the bounty to any answer that does some testing into where else or why it works or doesn't work unless someone finds a fix - which I don't believe. It seems to be a real bug. – NoDataDumpNoContribution Jul 01 '14 at 20:39
  • Nobody wants to do any more research on it or maybe knows some cool full screen apps that use Qt, run under Linux and have child windows? I'd be happy to see some examples so I can test them or dig into them and see how they are doing things. – NoDataDumpNoContribution Jul 04 '14 at 18:04

1 Answers1

0

Did you tried thing which documentation suggests?

Qt::WindowStaysOnTopHint 0x00040000 Informs the window system that the window should stay on top of all other windows. Note that on some window managers on X11 you also have to pass Qt::X11BypassWindowManagerHint for this flag to work correctly.

Another thing why you want other window to be a child if it you what to be under a parent?

Marek R
  • 32,568
  • 6
  • 55
  • 140
  • I didn't try `X11BypassWindowManagerHint` so far because of the negative side effects like missing keyboard focus handling but yesterday I tested it and it doesn't give the desired effect (full screen did not work anymore if I remember correctly). – NoDataDumpNoContribution Jul 01 '14 at 07:43
  • Why child window? Well it's a full screen app with child dialogs, so this would be the natural way. Also child windows should mostly be in front of parent windows automatically. And child windows do not create additional entries in the task bar. But I tried it with standalone windows and nothing changed. Updated question. – NoDataDumpNoContribution Jul 01 '14 at 07:44
  • `X11BypassWindowManagerHint` passed to a child window does prevent it from making the desktop decorations visible. Have you managed to solve/workaround this issue? – user362515 Dec 01 '15 at 16:06