PDA

View Full Version : Fullscreen application under Gnome



cionci
30th December 2007, 17:59
I've tried various code to make my QT application run full screen, but with no success.
I've found this in Qt Assistant:

void QWidget::showFullScreen () [slot]

Shows the widget in full-screen mode.
Calling this function only affects windows.
To return from full-screen mode, call showNormal().
Full-screen mode works fine under Windows, but has certain problems under X. These problems are due to limitations of the ICCCM protocol that specifies the communication between X11 clients and the window manager. ICCCM simply does not understand the concept of non-decorated full-screen windows. Therefore, the best we can do is to request a borderless window and place and resize it to fill the entire screen. Depending on the window manager, this may or may not work. The borderless window is requested using MOTIF hints, which are at least partially supported by virtually all modern window managers.
An alternative would be to bypass the window manager entirely and create a window with the Qt::X11BypassWindowManagerHint flag. This has other severe problems though, like totally broken keyboard focus and very strange effects on desktop changes or when the user raises other windows.
X11 window managers that follow modern post-ICCCM specifications support full-screen mode properly.
See also showNormal(), showMaximized(), show(), hide(), and isVisible().

How can I use those MOTIF hints ? There's a simpler way to run my QT application full screen in Gnome ?

high_flyer
30th December 2007, 18:26
is your widget a Qt 'window'?

cionci
30th December 2007, 18:38
Yes, it's derived by QWidget.

high_flyer
30th December 2007, 19:11
Yes, it's derived by QWidget.
That doesn't make it a window yet.


A window is a widget that isn't visually the child of any other widget and that usually has a frame and a window title.

A window can have a parent widget. It will then be grouped with its parent and deleted when the parent is deleted, minimized when the parent is minimized etc. If supported by the window manager, it will also have a common taskbar entry with its parent.

QDialog and QMainWindow widgets are by default windows, even if a parent widget is specified in the constructor. This behavior is specified by the Qt::Window flag.

cionci
30th December 2007, 19:18
Ok, now it's derived from QMainWindow. How can I set it full screen ?

high_flyer
30th December 2007, 19:21
and.....?
Saying its not working doesn't include enough information.
Relevant code will be helpful.

cionci
30th December 2007, 19:31
#include "BaseWindow.h"

#include <QPushButton>
#include <QPalette>
#include <QPixmap>
#include <QBrush>

#include "TransparentPushButton.h"
#include "WindowManager.h"

#include <cstdlib>

BaseWindow::BaseWindow(const char *backgroundFileName, QWidget *parent)
: QMainWindow(parent)
{
resize(1024, 768);

setWindowState(windowState() ^ Qt::WindowFullScreen);

QPalette palette;
QPixmap pixmap = QPixmap(backgroundFileName);
palette.setBrush(backgroundRole(), QBrush(pixmap));
setPalette(palette);

TransparentPushButton *quit = new TransparentPushButton(990, 368, 34, 34, this);

setFocus();

QObject::connect(quit, SIGNAL(clicked()), WindowManager::TheManager, SLOT(standby()));
}
I think it's not working beacuse of the problem with X quoted before.

cionci
30th December 2007, 20:38
It works using this code:



setFixedSize(qApp->desktop()->size());
setWindowFlags(Qt::FramelessWindowHint);

high_flyer
30th December 2007, 20:51
Well the important thing is you got what you want.
The problem with it, is that it will only work for screens that are 1024x 768 pixels. (I mean the first code you posted)
In addition you are setting size to the window, and I suspect this conflicts with full screen mode (but I am not sure about that) , since full screen takes the screen size as you did manfully in the second code you posted.
Try omitting the size setting in the constructor, and see if it will show full screen with out

setFixedSize(qApp->desktop()->size());
(just out of interest)

moowy
31st December 2007, 02:17
This works fine under my gnome desktop:



Window::Window(QWidget *parent)
: QWidget(parent)
{
Qt::WindowStates state = windowState();
state |= Qt::WindowFullScreen;
setWindowState( state );

cionci
31st December 2007, 09:07
Do you set the size of the windget calling resize or setFixedSize ? Do you have Compiz enabled ?

With Compiz enabled my app goes fullscreen simply setting widget size to desktop size. But on a Compiz disabled system the same app is placed in the space between Gnome panels and Metacity window decoration is displayed.

If I set the size AND I set Qt::FramelessWindowHint flag the widget goes fullscreen also on the Compiz disabled system.

high_flyer: if I omit resize or setFixedSize and I use showFullScreen or setWindowState to set Qt::WindowFullScreen state the window has a small size.
If I use only setFixedSize I've the same behaviour described above with Compiz enabled or disabled.

So for me the only way to go fullscreen is:


setFixedSize(qApp->desktop()->size());
setWindowFlags(Qt::FramelessWindowHint);

moowy
31st December 2007, 11:08
I don't use compiz. I don't use anything but the code I posted to make fullscreen applications.

cionci
31st December 2007, 12:30
Ok...I'll try your code in a new empty project and then I'll post it here.

cionci
31st December 2007, 15:22
moowy: your code works with Compiz disabled, but don't work with Compiz enable.

Thanks a lot, I'll try to make it compatible with Compiz.

hvengel
8th March 2008, 22:36
Do you set the size of the windget calling resize or setFixedSize ? Do you have Compiz enabled ?

With Compiz enabled my app goes fullscreen simply setting widget size to desktop size. But on a Compiz disabled system the same app is placed in the space between Gnome panels and Metacity window decoration is displayed.

If I set the size AND I set Qt::FramelessWindowHint flag the widget goes fullscreen also on the Compiz disabled system.

high_flyer: if I omit resize or setFixedSize and I use showFullScreen or setWindowState to set Qt::WindowFullScreen state the window has a small size.
If I use only setFixedSize I've the same behaviour described above with Compiz enabled or disabled.

So for me the only way to go fullscreen is:


setFixedSize(qApp->desktop()->size());
setWindowFlags(Qt::FramelessWindowHint);

The above code is clearly wrong on a system with more than one monitor (IE. assuming that you want your app to take over one screen) since QApplication::desktop()->size() will return the size of the desktop and NOT the size of any of the screens that make up the desktop.

I my application I have been using Qt::WStyle_StaysOnTop flag as my WindowFlag and this will result in a full screen app on most systems including KDE, Windows and OS/X. But this does not work on some systems. I am am not sure exactly which systems this applies to. I know it does not work on a GNOME system with Compiz. But I am not sure if this is a Compiz issue or a GNOME issue. In any case is there a definitive answer to how to make this work for all systems?